|
Hello This is an easy script I made for my site. Feel free to use it.
<?php //////////////////////////////// //////////Made by mikeo///////// ////////Vizionary Studios/////// ////////////////////////////////
$mm = "yes"; //change this to no if you want to turn MM out. all small letters. no and yes and not No and Yes $ip = array("ip1","ip2","etc","etc!"); //ips that are allowed to view the page when in mm mode $ip2 = $_SERVER["REMOTE_ADDR"]; $error = "Sorry we are closed."; //message when in mm mode
$is_in_array = false; for($x=0; $x < count($ip); $x++) { if($ip[$x] == $ip2) { $is_in_array = true; } }
if($mm == "yes" AND $is_in_array == false){
echo $error;
}else{
echo "This is the real page";
}
?>
I have added the info after the parts u need to edit.
Have Fun!
|
|
|
|
|
Interesting way of doing that....
|
|
|
|
|
Thanks, it was the first code I made with an if a while ago
|
|
|
|
|
Wow, that's cool...I think. I wouldn't know since I don't know PHP, but after reading through it and based on the title of this thread, it closes your website/forum and puts it in Maintanence Mode. Nice work.
|
|
|
|
Thanks dude And yea, and u can let sum ips in, and they are allowed in when it's closed A bit like ADMINS and GMODS can come in the forum on probards when in mm mode
|
|
|
|
|
Though, its easier to integrate a MM into a website with registration
|
|
|
|
|
It is, but this is without registration so it goes through ip. With registration u acan just do that, if status = Admin or Gmod then allowed.
|
|
|
|
|
Yep. That's how I'm setting it up on the forum I'm coding.... *cough* I mean, on the SZ website
|
|
|
|
|
Haha, ok. But this is for when you have no registration You can make it to let some USERS in if you have registration. Then u change the array the username's who are allowed. And add a query. But it would be best for a site with registration with status check yea. BUT, I can't make it for a site with users, because I don't know how they: 1. Coded the users system 2. So don't know anyting
|
|
|
|
|
Yep. I understand, but still, good work none the less.
|
|
|
|
|
Haha, thanks
|
|
|
|
|
<?php //////////////////////////////// //////////Made by mikeo///////// ////////Vizionary Studios/////// ////////////////////////////////
// Configuration $mm = true; //Change to false if you want to turn off MM. All small letters. $allowed_ip = array( "127.0.0.1", "127.0.0.2", ); $mm_msg = "Currently under maintainence.";
// Do not edit below $user_ip = $_SERVER['REMOTE_ADDR']; $allowed = false;
foreach($allowed_ip as $ip) { if ($user_ip == $ip) { $allowed = true; } }
if ($allowed == false && $mm == true) die($mm_msg); ?>
I edited your code slightly. This edited one can be easily added to the top of your page without having to copy the whole HTML into the "echo" function. Nice code, btw.
Last Edit: Sept 10, 2005 0:37:18 GMT by Kai
|
Religion should be put back in its place - beneath man, not above him.
|
|
|
|
please do not edit my code as I have copyright on it!
|
|
|
|
|
please do not edit my code as I have copyright on it! Legally, he's perfectly within the law to edit and redistribute your code, as long as he doesn't claim that it's his own work - unless of course he's changed it so much that it's nothing like your code anymore, then he can claim that it's his.
|
|
|
|
Yes.... he's right, I'm afraid. =/ All he did was modify it... though he did remove the copyright (on accident most likely, so I'll readd it). In the copyright, you said its buy you and for Visionary Studios. =/
|
|
|
|