weird behaviour

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
benyboi
Forum Commoner
Posts: 80
Joined: Sat Feb 24, 2007 5:37 am

weird behaviour

Post by benyboi »

Due to recent events on my forum i am trying to make a "lockdown" tool. Basically i have two folders, "forum" which has the forum and "forum_lockdown" which has pages saying that there is a lockdown.

Now, i am trying to make it so that when i click the button, it renames the "forum" folder to something like "forum_8u40350d" and then the "forum_lockdown" to just "forum", so now instead of the forum is a page i created with info on. THen if i click the button again it will undo those changes and put the forum back. But my script wont work, it will only go one way - putting the forum into "lockdown" mode and it wont go back.

Code: Select all

<?php

$status=include('D:/inetpub/www-xxxxx.com/lockdown_status.php');

if ( $status = 'off' ) {
rename("D:\inetpub\www-xxxxx.com\forum", "D:\inetpub\www-xxxxxx.com\forum_ld_975j230f70");
rename("D:\inetpub\www-xxxxx.com\forum_lockdown", "D:\inetpub\www-xxxxx.com\forum");
$myFile = ('D:/inetpub/www-xxxxx.com/lockdown_status.php');
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, "on");
fclose($fh);
} else {
rename("D:\inetpub\www-xxxxx.com\forum", "D:\inetpub\www-xxxxx.com\forum_lockdown");
rename("D:\inetpub\www-xxxxx.com\forum_ld_975j230f70", "D:\inetpub\www-xxxxx.com\forum");
$myFile = ('D:/inetpub/www-xxxxx.com/lockdown_status.php');
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, "off");
fclose($fh);
}

?>

the file "lockdown_status.php" does exist and has the work "off" in it currently.
anyone know whats wrong?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

That's a weird way to do it. Can't you just have a flag that you run your forum by in the database? Just make a little table called "forum_active" and have one record in it corresponding to if it's active or not. Then, have your forum check if it's active before displaying anything.
benyboi
Forum Commoner
Posts: 80
Joined: Sat Feb 24, 2007 5:37 am

Post by benyboi »

well im using phpbb3 and wouldnt know where to start! i shall have a look tho, thanks!
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

phpBB is pretty well supported... Are you sure that there isn't a plugin that does what you're after?
Post Reply