• [Mod] Maintenance Page - Set from Admin Control panel 5 0 5 1
Currently:  

Author Topic: [Mod] Maintenance Page - Set from Admin Control panel  (Read 93922 times)

0 Members and 1 Guest are viewing this topic.

Offline Fugaziman

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
    • http://www.1024x768wallpapers.com
[Mod] Maintenance Page - Set from Admin Control panel
« on: May 14, 2003, 05:49:38 AM »
This Mod allows you to redirect you site to a "Closed for Maintenance" page from your Admin Control panel.

Database Row value added:
Settings Table

Pages changed:
- admin/settings.php
- lang/your_language/admin.php
- Index.php

New files:
 - templates/your_template/maintenance.html

Time to complete:
15-20 minutes

 :arrow: Database update:
Download this file
http://www.1024x768wallpapers.com/Code_help_files/install_MainP.zip

UnZip it and copy it into your root directory then run it through your browser
Quote
http://www.yoursite.com/install_MainP.php
This install_MainP file just inserts another row to your settings table the name "maintenance" and a value of "0". It does not change the table in any way.

 :arrow: Edit admin/settings.php
Find
  show_setting_row("gz_compress_level");

Add after
Code: [Select]
 show_setting_row("maintenance", "radio"); //Mod of maintenance page  
 :arrow: Edit lang/your_langage/admin.php
Find:
$setting['gz_compress_level'] = "GZip level of compression<br /><span class=\"smalltext\">0-9, 0=none, 9=max</span>";

Add After
Code: [Select]
$setting['maintenance'] = "Turn maintenance page ON"; //Mod of maintenance page
 :arrow: Now you have a choice....
If you want this to work when someone first comes to your site then
Edit Index.php
Find
$user_access = get_permission();

Add After
Code: [Select]
//-----------------------------------------------------
//--- Maintenance      --------------------------------
//-----------------------------------------------------
$maintenance = $config['maintenance'];
$redirect_url = TEMPLATE_PATH."/maintenance.html";
if ($maintenance){
  header("Location: ".$site_sess->url($redirect_url, "&"));
  exit;
}

//-----------------------------------------------------
//--- End of Maintenance      -------------------------
//-----------------------------------------------------

or if you want it to work for every page then ..
Edit page_header.php
Find
Code: [Select]
if (!defined('ROOT_PATH')) {
  die("Security violation");
}
and insert the code above just below it.

 :arrow: Create new file in your templates/Your_template/maintenance.html folder.

Add this html...
Code: [Select]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Site closed for Maintenance</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF">

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tablebgcolor">

<tr>
<td align="center">  
<!-- add your maintenance page content here -->
Sorry but the site is closed for maintenance
<!-- End of maintenance page content here   -->
</td>
</tr>
</table>
<br>

</body>
</html>
:arrow: Change the content of this HTML page to suite your sites needs.

 :arrow: Now you can test the Mod.
- Log into your Admin Panel
- Click on the "Settings" Link on the left side menu
- At the bottom of the General section you will see an extra Radio Button field "Turn maintenance page ON"
- Select Yes to turn Maintenance page on
- Try going to your home page

That's it. Nothing to fancy but it's a lot better than nothing

Fugaziman 8)
« Last Edit: March 30, 2005, 07:41:06 PM by V@no »
Please take time to visit us at ...
http://www.1024x768wallpapers.com
And don't forget to leave a comment or message.

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
[Mod] Maintenance Page - Set from Admin Control panel
« Reply #1 on: May 14, 2003, 06:26:53 AM »
I get the following error when I try this:
Warning: Cannot add header information - headers already sent by (output started at /home/xx/xxxxx/gallery/includes/stats.php:83) in /home/xx/xxxxx/gallery/index.php on line 41

Also Im wondering if we can't beef it up a bit, and say put it in the pageheader.php so that it can be used no matter what page a person is on.  That way it wont just block new users, but any user on the site.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] Maintenance Page - Set from Admin Control panel
« Reply #2 on: May 14, 2003, 12:32:39 PM »
very nice!
didnt try it myself yet, but here what I can see and suggest:
1. the code that u insert into /index.php u might want insert into /includes/page_header.php because this will redirect to the mainteinance page if u try open any pages at your 4images site, not only indes.php.
2. the code
Code: [Select]
$redirect_url = TEMPLATE_PATH."/".$template."maintenance.html";should be without $template because TEMPLATE_PATH already has full path to your current template ;) so it should be like this:
Code: [Select]
$redirect_url = TEMPLATE_PATH."/maintenance.html";

Quote from: lakeside
Also Im wondering if we can't beef it up a bit, and say put it in the pageheader.php so that it can be used no matter what page a person is on. That way it wont just block new users, but any user on the site.
this sounds just what PHP SAFE MODE does...it let u work, but hit u in the head when u dont expect it...;) I understand the "closed for mainteince" as prevent visitors see error messages that could accur while u edit your code...and it can prevent fatal database damage (yes, this could happend...)

P.S. If this feature was included into original 4images, my site probably would be in the "maintence" status 24/7 ....hehe :lol:
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline HelpMeNow

  • Jr. Member
  • **
  • Posts: 94
    • View Profile
[Mod] Maintenance Page - Set from Admin Control panel
« Reply #3 on: May 14, 2003, 03:36:00 PM »
Fugaziman,

Great MOD.

What are the changes made to the database when you run the content of the zipped file with this mod?

...and if you have more than one 4images installed on your server, will this only effect the database tables for that particular 4images instant that you are working on?

Thanks

Offline Fugaziman

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
    • http://www.1024x768wallpapers.com
[Mod] Maintenance Page - Set from Admin Control panel
« Reply #4 on: May 14, 2003, 03:52:09 PM »
Quote from: HelpMeNow
Fugaziman,

Great MOD.

What are the changes made to the database when you run the content of the zipped file with this mod?

...and if you have more than one 4images installed on your server, will this only effect the database tables for that particular 4images instant that you are working on?

Thanks


HelpMeNow:
Have amended my first post to include information about what gets updated in the database. Basically the tables do not get altered just another row inserted into the settings table.
As far as multiple installs of 4 images it will only effect the installation that you set the Maintenance flag on from that installations Admin Control Panel.

Vano:
Quote
should be without $template because TEMPLATE_PATH already has full path to your current template  so it should be like this:


Thanks V@no I have amended by original post. I think I'm slowly getting the idea of this PHP stuff  :lol:

Fugaziman
Please take time to visit us at ...
http://www.1024x768wallpapers.com
And don't forget to leave a comment or message.

Offline Fugaziman

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
    • http://www.1024x768wallpapers.com
[Mod] Maintenance Page - Set from Admin Control panel
« Reply #5 on: May 14, 2003, 03:57:30 PM »
Quote from: lakeside
I get the following error when I try this:
Warning: Cannot add header information - headers already sent by (output started at /home/xx/xxxxx/gallery/includes/stats.php:83) in /home/xx/xxxxx/gallery/index.php on line 41


Looks like you have another mod in your stats page that's effecting this one. Try editing the index.php file again and moving the Maintenance mod further up the page.
Add it somewhere between...
Code: [Select]
include(ROOT_PATH.'global.php');
and
Code: [Select]
include(ROOT_PATH.'includes/stats.php');


Quote from: lakeside
Also Im wondering if we can't beef it up a bit, and say put it in the pageheader.php so that it can be used no matter what page a person is on. That way it wont just block new users, but any user on the site.


Yes this is just as easy.
Add the
Code: [Select]
//-----------------------------------------------------
//--- Maintenance      --------------------------------
//-----------------------------------------------------
$maintenance = $config['maintenance'];
$redirect_url = TEMPLATE_PATH."/".$template."maintenance.html";
echo redirect_url;
if ($maintenance){
 echo $maintenance;
  header("Location: ".$site_sess->url($redirect_url, "&"));
  exit;
}

//-----------------------------------------------------
//--- End of Maintenance      -------------------------
//-----------------------------------------------------

to your the page_header.php
just after
 
Code: [Select]
(!defined('ROOT_PATH')) {
  die("Security violation");
}


Instead of your index.php


Hope that helps  :wink:
Fugaziman
Please take time to visit us at ...
http://www.1024x768wallpapers.com
And don't forget to leave a comment or message.

Offline Fugaziman

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
    • http://www.1024x768wallpapers.com
Allow Admin Access
« Reply #6 on: May 14, 2003, 04:26:18 PM »
Just had a quick thought....

If you still want to test your changes with the Maintenance flag set then you can use this code in your page_header.php or Index.php files instead...

Code: [Select]
//-----------------------------------------------------
//--- Maintenance      --------------------------------
//-----------------------------------------------------

$maintenance = $config['maintenance'];
$redirect_url = TEMPLATE_PATH."/maintenance.html";
if ($maintenance && $user_info['user_level'] != ADMIN){
  header("Location: ".$site_sess->url($redirect_url, "&"));
  exit;
}
//-----------------------------------------------------
//--- End of Maintenance      -------------------------
//-----------------------------------------------------


So if you are logged in as Admin you can still get to your pages to make sure every thing is working okay but all others get the maintenance page.

That makes it a little bit more useful  :lol:
Please take time to visit us at ...
http://www.1024x768wallpapers.com
And don't forget to leave a comment or message.

Offline lakeside

  • Full Member
  • ***
  • Posts: 123
    • View Profile
[Mod] Maintenance Page - Set from Admin Control panel
« Reply #7 on: May 14, 2003, 05:57:35 PM »
Very nice, works perfectly now.  Just what I needed with all the tweaking I like to do, and with how slow our ftp server is.

Thanks,

Offline lutz

  • Addicted member
  • ******
  • Posts: 1.675
    • View Profile
[Mod] Maintenance Page - Set from Admin Control panel
« Reply #8 on: June 12, 2003, 10:35:42 AM »
hi,
i see, the link is down, or rather redirected to the main page... :cry:
any reasons for that?
Grüße, Lutz
kurze antworten sind nicht unhöflich gemeint, sondern effizient
short answers are not meant rude, but just efficient

Offline Fugaziman

  • Jr. Member
  • **
  • Posts: 80
    • View Profile
    • http://www.1024x768wallpapers.com
[Mod] Maintenance Page - Set from Admin Control panel
« Reply #9 on: June 12, 2003, 03:04:06 PM »
Quote from: lutz
hi,
i see, the link is down, or rather redirected to the main page... :cry:
any reasons for that?


Not sure what you mean  :?:
Fugaziman  :oops:
Please take time to visit us at ...
http://www.1024x768wallpapers.com
And don't forget to leave a comment or message.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
[Mod] Maintenance Page - Set from Admin Control panel
« Reply #10 on: June 12, 2003, 03:11:11 PM »
Quote from: lutz
hi,
i see, the link is down, or rather redirected to the main page... :cry:
any reasons for that?
try now. Fugaziman has new domain, that's all.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Nasser

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Re: [Mod] Maintenance Page - Set from Admin Control panel
« Reply #11 on: March 24, 2005, 03:32:06 AM »

 :arrow: Database update:
Download this file
http://www.1024x768wallpapers.com/Code_help_files/install_MainP.zip


I need this mod , but the link of Database update file download is not working, can anyone help please?
regards,
Nasser

Offline Nasser

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Re: [Mod] Maintenance Page - Set from Admin Control panel
« Reply #12 on: March 30, 2005, 03:53:24 PM »
can any one help in that please?

Offline JensF

  • Addicted member
  • ******
  • Posts: 1.028
    • View Profile
    • http://www.terraristik-galerie.de
Re: [Mod] Maintenance Page - Set from Admin Control panel
« Reply #13 on: March 30, 2005, 04:39:48 PM »
Hi,

open

install_MainP.php

and find

Code: [Select]
<form action="install_mainp.php" name="form" method="post">
replace it with

Code: [Select]
<form action="install_MainP.php" name="form" method="post">

Save, Upload and Test It.....
Mit freundlichem Gruß
Jens Funk



-> Sorry for my bad English <-

Offline Nasser

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Re: [Mod] Maintenance Page - Set from Admin Control panel
« Reply #14 on: March 30, 2005, 07:00:04 PM »
the downloading link is not working dear  :(