We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21088
    • 85 Posts

    I just tried to add some PHP IP limitation code to the index.php file and suddently the site doesnt work.

    See for yourself http://www.activedesign.dk/

    I have tried to remove the added php code again, but i still get the same problem sad Please help!
      • 37550 ☆ A M B ☆
      • 711 Posts
      if you add anything before the <?php or the include which starts the session in index.php you will have written to the output before the session starts, which causes this header error.

      Can you not add your custom code to a snippet and put that in your template?
        http://www.onesmarthost.co.uk
        UK MODX Hosting with love.
        • 37550 ☆ A M B ☆
        • 711 Posts
        Quote from: need4speed at Jan 28, 2009, 11:28 AM


        I just tried to add some PHP IP limitation code to the index.php file and suddently the site doesnt work.

        See for yourself http://www.activedesign.dk/

        I have tried to remove the added php code again, but i still get the same problem sad Please help!

        If you have removed the code your best bet is to reupload index.php from a backup or original setup sometimes spaces before <?php also cause problems.
          http://www.onesmarthost.co.uk
          UK MODX Hosting with love.
          • 21088
          • 85 Posts
          This was the script i added

          <?

          if (($_SERVER[’REMOTE_ADDR’] != ’90.184.12.166’) AND ($_SERVER[’REMOTE_ADDR’] != ’62.199.175.18’) AND ($_SERVER[’REMOTE_ADDR’] != ’74.57.210.46’) AND ($_SERVER[’REMOTE_ADDR’] != ’81.19.253.252’) AND ($_SERVER[’REMOTE_ADDR’] != ’85.214.60.70’) AND ($_SERVER[’REMOTE_ADDR’] != ’83.89.195.162’))
          {
              require ’index.html’;
              die();
          }

          ?>
            • 26931
            • 2,314 Posts
            hi there,

            and maybe <?php instead of <?

            j
              • 21088
              • 85 Posts
              Now its up again... thats weird.

              But where should i enter my IP script if not in the index.php file?

              <?php

              if (($_SERVER[’REMOTE_ADDR’] != ’90.184.12.166’) AND ($_SERVER[’REMOTE_ADDR’] != ’62.199.175.18’) AND ($_SERVER[’REMOTE_ADDR’] !=

              ’74.57.210.46’) AND ($_SERVER[’REMOTE_ADDR’] != ’81.19.253.252’) AND ($_SERVER[’REMOTE_ADDR’] != ’85.214.60.70’) AND

              ($_SERVER[’REMOTE_ADDR’] != ’83.89.195.162’))
              {
              require ’index.html’;
              die();
              }

              ?>
                • 3749
                • 24,544 Posts
                It’s working now so either you fixed it, or it was a cache problem.

                With respect to your code, first make sure that your server always reports $_SERVER[’REMOTE_ADDR’].

                It might be better to turn the logic around:

                If ($_SERVER[’REMOTE_ADDR’] == 00 || $_SERVER[’REMOTE_HOST’] == ’host1’ || $_SERVER[’REMOTE_ADDR’] == 00 || $_SERVER[’REMOTE_HOST’] == ’host2’ etc. ) {

                // do nothing

                } else {

                $modx->sendRedirect($modx->config[’base_url’] . ’index.html’);

                }

                The code would have to go in index.php below the line where $modx is created: $modx = new DocumentParser;

                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 21088
                  • 85 Posts
                  thanks for your suggestions it works perfect.

                  Thanks!
                    • 3749
                    • 24,544 Posts
                    Glad it worked for you. smiley
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 15083
                      • 697 Posts
                      put you IP code in a snippet, and more gracefully redirect people who are not using the correct IP.....
                      You should never need to go hacking the index.php, or any other file for that reason!!!

                      MODx exists to prevent dirty hacks wink