Help building a maintenance system for my site

software development

#1

Hello,
I am trying to build a system where by there will be a page in a folder (lets call it foo for now) that will allow me to change the status of the site between active and down. Currently i am doing this with an .htaccess file that redirects all requests to a maintenance.html page, so there is no way that i can access the directory foo to change the status. is there a good way to do this with htaccess, or can anyone think of a way to do it with php? I am right now at a loss.

thanks

-Frank
Admin of splra.org


#2

i guess what i would do would be to

  • create a flat file with the respective flags indicating active/down

  • on pages that you want to restrict access to, check against the flat file to see if the page is suppose to active/down.

  • write a php form page that writes to the flat file if you want the status of the site be up or down.

obviously you should probably chmod the flat file to 700


#3

except it would be when i want the entire site to be down. it is just a pain having to ssh into the site just to change its status

-Frank
Admin of splra.org


#4

a simple way in php would be to create a seperate text file with a single value in it. In your index.php page you would use an if else statement. If the value is 0 print “Sorry page is down for mantainence” and end the program. otherwise if the value is 1 continue.
you could then decide if you just want to upload the text file each time, or write a php program that will write the value for you.
The problem I am forseeing is users that are accessing directory indexes. You may want to place a php program in those directories and have php create the index for them. That way the php program can check the value of your text file. Then if you wanted to you could add values to specify what directories are down for mantainence.
Just some thoughts,
Silk

My website


#5

problem is i want to take the entire site down for maintanence. that would be alot of work using your method, but it is a good idea, just more work than i want to do.

-Frank


#6

You could do a conditional in your .htaccess based on IP. Have a rewriterule something like

RewriteCond %{REMOTE_ADDR} ^123.45.67.89$
RewriteRule ^.* maintenancepage.html [R]

where you replace the 123, etc with your IP address, and maintenancepage with whatever your maintenance page is.

Have those two lines commented out when live (with #s), uncomment when you need maintenance.


Jonathan
http://fleshy.org.nz/yum/