4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: Fugaziman 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
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
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
$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
//-----------------------------------------------------
//--- 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
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...
<!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)
-
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.
-
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$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:$redirect_url = TEMPLATE_PATH."/maintenance.html";
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:
-
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
-
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:
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
-
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...
include(ROOT_PATH.'global.php');
and
include(ROOT_PATH.'includes/stats.php');
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
//-----------------------------------------------------
//--- 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
(!defined('ROOT_PATH')) {
die("Security violation");
}
Instead of your index.php
Hope that helps :wink:
Fugaziman
-
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...
//-----------------------------------------------------
//--- 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:
-
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,
-
hi,
i see, the link is down, or rather redirected to the main page... :cry:
any reasons for that?
-
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:
-
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.
-
: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
-
can any one help in that please?
-
Hi,
open
install_MainP.php
and find
<form action="install_mainp.php" name="form" method="post">
replace it with
<form action="install_MainP.php" name="form" method="post">
Save, Upload and Test It.....
-
the downloading link is not working dear :(
-
Ups,
do this
**KLICK** (http://www.terraristik-galerie.de/sonstiges/install_MainP.zip)
-
Ups,
do this
**KLICK** (http://www.terraristik-galerie.de/sonstiges/install_MainP.zip)
thank you very much that was helpful realy
Hi,
open
install_MainP.php
and find
<form action="install_mainp.php" name="form" method="post">
replace it with
<form action="install_MainP.php" name="form" method="post">
Save, Upload and Test It.....
you've helped me so much here also
thanks alot
-
Has anyone tested this mod with 1.7.1?
-
Has anyone tested this mod with 1.7.1?
This Mod works perfectly with Version 1.7.1! :wink:
-
I got this error Warning: Cannot modify header information - headers already sent by (output started at /home/bhfqyruw/public_html/encuestas.php:166) in /home/bhfqyruw/public_html/includes/page_header.php on line 33
-
I got this error Warning: Cannot modify header information - headers already sent by (output started at /home/bhfqyruw/public_html/encuestas.php:166) in /home/bhfqyruw/public_html/includes/page_header.php on line 33
as far as I recall u've asked about this type of message several times already :P ;)
http://www.4homepages.de/forum/index.php?topic=3378.0
-
There is a modification which would be interesting for this mod:
:?: on the page, could we have a form where the users can ask to receive a mail when the site will open?
:arrow: :arrow: The user can leave his login (registered users) or his address mail (others) and as soon as the site will pass in maintenance OFF, the user will receive a mail which says:
You receive this mail because you asked to be warned : The site "what-ever-u-want.com" is on-line...
Thank you in advance for your answers.
-
i installed the mod and nothing happens.
I checked the steps, no mistake is made.
I can see the option in ACP. When i put the button on "yes" ( "put the maintenance page on" ), and save the settings, after the saving the button is put to "no" again.
And when i go to the site nothing happens, even if i log out as administrator.
strange
-
Seems like you didnt do the first step: database update.
-
Hi,
open
install_MainP.php
and find
<form action="install_mainp.php" name="form" method="post">
replace it with
<form action="install_MainP.php" name="form" method="post">
Save, Upload and Test It.....
now it works....
-
wonderful MOD ... thanks alot
-
use notepad for this
<?php
define('ROOT_PATH', './');
include(ROOT_PATH.'config.php');
include(ROOT_PATH.'global.php');
include(ROOT_PATH.'includes/constants.php');
require(ROOT_PATH.'includes/sessions.php');
$error_log = array();
$error_msg = "";
if ($action == "modinstall") {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type">
<link rel="stylesheet" href="admin/cpstyle.css">
<title>4images Installer</title>
</head>
<body leftmargin="20" topmargin="20" marginwidth="20" marginheight="20" bgcolor="#FFFFFF">
<table cellpadding="0" cellspacing="0" border="0" width="500" align="center">
<tr><td class="tableborder"><img src="admin/images/logo_installer.gif" width="500" height="45"><br />
<table cellpadding="3" cellspacing="1" border="0" width="100%">
<tr class="tablerow2"><td><b>MOD Maintenance Page</b> (by Fugaziman)</td></tr>
<tr class="tablefooter"><td align="center"> </td></tr>
</table>
<table cellpadding="3" cellspacing="1" border="0" width="100%">
<tr class="tablerow"><td colspan="2" align="right"></td></tr>
<tr class="tablerow2"><td colspan="2"><br /><blockquote>
<?php
$date = time();
$sql = "INSERT INTO ".SETTINGS_TABLE." (setting_name, setting_value)
VALUES ('maintenance', '0')";
if (!$site_db->query($sql)) {
$error_log[] = $sql;
}
if (empty($error_log)) { echo "<h4>Database update success!</h4>"; }
?>
</blockquote></td></tr>
<tr class="tablefooter"><td colspan="2"> </td></tr>
</table>
</td>
</tr>
</table>
</table>
<p align="center"> Powered by <b>4images</b> <?php echo SCRIPT_VERSION ?><br />Copyright © 2002 <a href="http://www.4homepages.de" target="_blank">4homepages.de</a>
</body>
</html>
<?php
exit;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type">
<link rel="stylesheet" href="admin/cpstyle.css">
<title>4images Installer</title>
</head>
<body leftmargin="20" topmargin="20" marginwidth="20" marginheight="20" bgcolor="#FFFFFF">
<form action="install_mainp.php" name="form" method="post">
<table cellpadding="0" cellspacing="0" border="0" width="500" align="center">
<tr><td class="tableborder"><img src="admin/images/logo_installer.gif" width="500" height="45"><br />
<table cellpadding="3" cellspacing="1" border="0" width="100%">
<tr class="tablerow2"><td><b>MOD Maintenance Page</b> (by Fugaziman)</td></tr>
<tr class="tablefooter"><td align="center"> </td></tr>
</table>
<table cellpadding="3" cellspacing="1" border="0" width="100%">
<tr class="tablerow"><td colspan="2" align="right"></td></tr>
<tr class="tablerow2"><td colspan="2"><center>
This script will modify your 4images database, so please<br><b>
<font color="#FF0000">ALWAYS BACKUP YOUR DATABASE BEFORE RUNNING THIS MOD!</b></font><br><br>
Please check out all fields shown below.<br>
If they do not correspond to your settings, please<br><b>DO NOT START INSTALLER</b>!
</center></td></tr>
<tr class="tableheader"><td colspan="2"><b><span class="tableheader">Database configuration</span></b></td></tr>
<tr class="tablerow"><td>Database server type</td><td><?php echo $db_servertype; ?></td></tr>
<tr class="tablerow2"><td>Database server hostname</td><td><?php echo stripslashes($db_host); ?></td></tr>
<tr class="tablerow"><td>Database name</td><td><?php echo stripslashes($db_name); ?></td></tr>
<tr class="tablerow2"><td>Prefix for tables in database</td><td><?php echo stripslashes($table_prefix); ?></td></tr>
<tr class="tablefooter"><td colspan="2"><center><input type="hidden" name="action" value="modinstall"><input type="submit" value="Start modify database" class="button" name="submit"></center></td></tr>
</table>
</td>
</tr>
</table>
</form>
<p align="center"> Powered by <b>4images</b> <?php echo SCRIPT_VERSION ?><br />Copyright © 2002 <a href="http://www.4homepages.de" target="_blank">4homepages.de</a>
</body>
</html>
save it as "install_mainp.php" make sure "Save as type" says "All Files
then upload it to your 4images root and run it, then follow instructions made by the author, of this script.
-
Hello,
i have a little Problem with this Mod. I have install it for a few weeks and now it works but today it doesn´t.
I have put the code into the page_header.php to have the effect at all sites. But when i go to the index.php i become a blank page. When i go to another page (details.php) it works and say me that the site is closed...
Have anyone an idea???
-
i have a little Problem with this Mod. I have install it for a few weeks and now it works but today it doesn´t.
:?: did you follow these original instructions exactly?
: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
//-----------------------------------------------------
//--- 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
if (!defined('ROOT_PATH')) {
die("Security violation");
}
and insert the code above just below it.
:?: since this first installation, did you install some other MOD?
-
since this first installation, did you install some other MOD?
Yes, i have but i don´t now which :( i have installed many mods since i installed this mod...
And i have put the code into the page_header.php that it wirks on all pages. And now it work on all pages but not on the index.php
-
it work on all pages but not on the index.php
:?: what happens if you make the modification on the two files? ( :arrow: you can try to write the same code on index.php and page_header.php :wink:)
-
Hi,
i have do it in both files but no effect....
-
When I´ll use this MOD with my backup-tool (MySqlDumper), the site should close automatically.
What SQL command I have to use to switch the site on/off :?:
-
What SQL command I have to use to switch the site on/off
In your SQL's settings table, you can manually switch the value to the previous / next one to put your site under maintenance if you do not see it under your ACP - > Settings page. ;)
-
THX I know this one.
This part should work automatic:
Before database-backup runs, the script should set maintenance page on (command before dump).
When backup is complete, the script should set maintenance page off (command after dump).
Now I search for the SQL command which I have to add to the script.
Like PphBB -> disable board
UPDATE `phpbb_config` set config_value=1 where config_name='board_disable'
Something like this...
-
Ah ! now I know what you're looking for to do.
Very well, create a PHP filename called : maintenance_update.php
and add this little content in :
<?php
define('GET_CACHES', 1);
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
if ($user_info['user_level'] == ADMIN) {
$sql = "
UPDATE ".SETTINGS_TABLE."
SET setting_value = '1'
WHERE setting_name = 'maintenance'
";
$result = $site_db->query($sql);
if ($result) {
echo "Field Updated Successfully.";
} else {
echo "Failed to update field.";
} ###### End of if statement.
} else {
show_error_page($lang['no_permission']);
} ###### End of if statement.
?>
Then, upload the PHP file to your 4images's root folder and execute the file.
Note: Make sure you login as ADMIN from your album before executing this file (for security reasons). ;)
-
Update: I have just modified my post above due to a slight mistake.
-
I think that´s more than I need :wink: I´ll try it!
Thanks!
Edit: It works :!:
I´ve changed the code above
To turn maintenance on
UPDATE `4images_settings` set setting_value=1 where setting_name='maintenance'
To turn maintenance off
UPDATE `4images_settings` set setting_value=0 where setting_name='maintenance'
Now, my site is during the backup under construction and after the backup it´s available.
-
To turn off, don't you mean :
UPDATE `4images_settings` set setting_value=0 where setting_name='maintenance'
? ;)
-
8O oops - You´ve got it! :)
I´ve corrected my post above...
-
Excellent. Now, it's clear. Thanks for your inputs. 8)
-
works well in IE, but opens a local page in Firefox -
does anyone know why?
thanks in advance -
-
Great MOD. Only one potential problem..... If I logout as admin or close the browser by mistake without turning the maintenance page back off I'm stuck! Would be great if there was an admin login box that could be inserted on the "Closed for Maintenance" page so I can get back in. Anyone have any ideas on this?
-
Download links is not working...
Please help! I really need this mod!
Thanks!
-
Hello;
the file seems to be here: install_MainP.zip (http://www.4homepages.de/forum/index.php?action=dlattach;topic=5638.0;attach=17)
-
Thanks!
You're a life saver :-D
-
Hey, my first ever post so please bare with me :). Just an update if anybody's interested. If you want to be able to log in and still use the site as an administrator, here's a code I thought I'd share:
-----
Hey, meine erste Post, so wenden Sie sich bitte mit nackten mich:). Nur ein Update, wenn jemand interessiert. Wenn Sie möchten, können sich anmelden, und nach wie vor nutzen die Site als Administrator an, hier ist ein Code Ich dachte, ich würde Aktie:
FIND/FINDE (includes/page_header.php):
if ($maintenance){
header("Location: ".$site_sess->url($redirect_url, "&"));
exit;
}
REPLACE WITH/ERSETSEN DURCH:
if ($user_info['user_level'] != ADMIN && $maintenance) {
header("Location: " . $site_sess->url($redirect_url, "&"));
exit;
}
Sorry für die schlechte Deutsch, ich habe Google Translator.
Login into your Admin CP by visiting gallery/admin/, once in the Admin CP you can return to your gallery with maintenance mode on.
-
ý thanks good mod.
-
Hallo allerseits,
habe diese MOD installiert und funktioniert bestens. :thumbup:
Mir ist aber aufgefallen, dass der Redirect nur über die Indexseite erfolgt. Wenn jetzt jemand z.B. die Top10 als Favorit abgelegt hat, dann kann er auf diese Seite trotzdem noch zugreifen.
Um das zu unterbinden - reicht es aus, wenn ich folgenden Code in jede php-Seite einfüge?
//-----------------------------------------------------
//--- Maintenance --------------------------------
//-----------------------------------------------------
$maintenance = $config['maintenance'];
$redirect_url = TEMPLATE_PATH."/maintenance.html";
if ($maintenance){
header("Location: ".$site_sess->url($redirect_url, "&"));
exit;
}
//-----------------------------------------------------
//--- End of Maintenance -------------------------
//-----------------------------------------------------
Freundliche Grüße, Bommel
-
Hallo allerseits,
wer diese MOD hier verwendet: http://www.4homepages.de/forum/index.php?topic=17155.msg91450#msg91450 kann für die Moderatoren auch die Zugriffsberechtigung während dem Wartungsmodus setzen, in dem er diese Zeile:
if ($maintenance && $user_info['user_level'] != ADMIN){
mit folgender ersetzt:
if ($maintenance && $user_info['user_level'] != ADMIN && $user_info['user_level'] != MODERADOR){
Ich liebe diese MOD... :D
Freundliche Grüße, Bommel
-
I miss Vanos help and advice. He was so nice before