Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Xikeon

Xikeon Avatar

***
Dedicated Member

152


August 2005
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!


Chris

Chris Avatar

******
Head Coder

19,519


June 2005
:P Interesting way of doing that....

Xikeon

Xikeon Avatar

***
Dedicated Member

152


August 2005
Thanks, it was the first code I made with an if a while ago ;)

Lucifer

Lucifer Avatar

*******
Mythical Studio Member

Eunuch
5,665


August 2005
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.

Xikeon

Xikeon Avatar

***
Dedicated Member

152


August 2005
Thanks dude :D 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

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
Though, its easier to integrate a MM into a website with registration :P

Xikeon

Xikeon Avatar

***
Dedicated Member

152


August 2005
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.

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
Yep. That's how I'm setting it up on the forum I'm coding.... *cough* I mean, on the SZ website :P

Xikeon

Xikeon Avatar

***
Dedicated Member

152


August 2005
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 :P

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
Yep. I understand, but still, good work none the less.

Xikeon

Xikeon Avatar

***
Dedicated Member

152


August 2005
Haha, thanks :)

Kai

Kai Avatar

**
Official Member

66


September 2005

<?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.

Xikeon

Xikeon Avatar

***
Dedicated Member

152


August 2005
please do not edit my code as I have copyright on it!

Boag

Boag Avatar
Yo Yo Ma!

**
Official Member

65


September 2005
mikeo said:
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.

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
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. =/

newBookmarkLockedFalling