Sorry I read some topics about this already.. But it didn't worked or make it clear to me. I want to make sure that when my MySQL says that maintenance = 1 he redirect with header to maintenance. In maintenance the same thing happens but then when maintenance = 0 he redirect with header back to the index. This works fine.. BUT now I want to have an IP whitelist so that when its in maintenance and I visit the page I still will be able to see the website it self.. But this isn't working correctly..
I hope someone could help me and get an light on what I'm doing wrong.
The code of checkmaintenance.php:
<head><link rel="stylesheet" type="text/css" href="../css/style.css"></head>
<?php include('config-connection.php'); ?>
<?php
$whitelist = mysql_query("SELECT * FROM whitelist_ip");
while ($ip = mysql_fetch_assoc($whitelist)) {
$checkip = $ip['ip'];
}
?>
<?php
if($checkip == $_SERVER['REMOTE_ADDR']) {
echo "<center><div class='error'>The website is in maintenance. But your IP has been whitelisted so you can see the website!</div></center>";
}
?>
<?php
if($maintenance == 1){
flush(); // Flush the buffer
ob_flush();
header('Location: maintenance.php');
}else{
echo "";
}
?>
I Know that I'm a noob with PHP and I try to learn and understand it better than I do now..
To make clear what is in maintenance it self I post the part of that code beneath this:
<?php include('config/config-connection.php'); ?>
<?php
$whitelist = mysql_query("SELECT * FROM whitelist_ip");
while ($ip = mysql_fetch_assoc($whitelist)) {
$checkip = $ip['ip'];
}
?>
<?php
if($checkip == $_SERVER['REMOTE_ADDR']) {
flush(); // Flush the buffer
ob_flush();
header('Location: index.php');
}
?>
<?php
if($maintenance == 0){
flush(); // Flush the buffer
ob_flush();
header('Location: index.php');
}else{
echo "";
}
?>
Index only contains this line:
<?php include('config/checkmaintenance.php'); ?>
I would be very happy if someone could explain to me why it doesn't work. Or how I should do this better than it currently is.
Kind regards, Brian