-
☆ 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?
-
☆ 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
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.
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();
}
?>
hi there,
and maybe <?php instead of <?
j
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();
}
?>
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;
thanks for your suggestions it works perfect.
Thanks!
Glad it worked for you.