[BETA] Oops - Database Down 0.0.3

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Joe Belmaati
Registered User
Posts: 2110
Joined: Sun Sep 28, 2003 7:35 pm
Location: Denmark

[BETA] Oops - Database Down 0.0.3

Post by Joe Belmaati »

Familiar with this message?
phpBB : Critical Error

Could not connect to the database


This is a very, very simple hack. Instead of the error message, the user will get a custom error page that is very easy to taylor to fit the design of your website. Whatever phpBB page user tries to call in browser (i.e. loading bookmarks etc) they will be redirected to the custom error page. There's a simple link to email the board admin. I have included a few settable config values such as board email, template name etc that you can adjust to your own needs. Remember, there's no connection to the database, so everything is hard-coded.

DOWNLOAD

Code: Select all

##############################################################
## MOD Title: Oops
## MOD Author: Joe Belmaati < belmaati@gmail.com > N/A
## MOD Description: When your database is down: Instead of the
##					familiar "Critical error, could not
##					connect message", your users will get
##					redirected to a custom error page. There they
##					will have an option to send you an email, i.e.
##					to notify you that something is wrong. It is
##					easy to style the error page to suit your taste
##					just mess about with the html code until your
##					happy with the outcome.
##
## MOD Version: BETA 0.0.3
##
## Installation Level: Easy
## Installation Time: 2 Minutes
## Files To Edit: 	(1)
##				  	includes/db.php
##
## Included Files:  (1)
##					oops.php
##
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes: Not much to add. This is a very simple MOD, if it can even be called a MOD
##
##############################################################
## MOD History:
##
##   2005-04-10 - BETA 0.0.3
##      - catering for mysql4 db file implemented
##
##   2005-04-10 - BETA 0.0.2
##      - PHP exit(); function added
##
##   2005-04-07 - BETA 0.0.1
##      - initial BETA
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
Last edited by Joe Belmaati on Sun Apr 10, 2005 9:46 pm, edited 6 times in total.
Image
User avatar
yexusbeliever
Registered User
Posts: 586
Joined: Mon Dec 08, 2003 8:49 pm
Location: Olympus phpBB3

Post by yexusbeliever »

thanks! I will use this mod. :D
User avatar
yexusbeliever
Registered User
Posts: 586
Joined: Mon Dec 08, 2003 8:49 pm
Location: Olympus phpBB3

Post by yexusbeliever »

thanks! I will use this mod. :D
Joe Belmaati
Registered User
Posts: 2110
Joined: Sun Sep 28, 2003 7:35 pm
Location: Denmark

Post by Joe Belmaati »

Excellent :D
Image
Rapid Dr3am
Registered User
Posts: 198
Joined: Sun Jul 13, 2003 4:14 pm
Location: Incommunicado
Contact:

Post by Rapid Dr3am »

An ingenious idea. :D
Joe Belmaati
Registered User
Posts: 2110
Joined: Sun Sep 28, 2003 7:35 pm
Location: Denmark

Post by Joe Belmaati »

Thank you VERY much :D Your post made me very happy.
Image
chyduskam
Registered User
Posts: 110
Joined: Thu Oct 28, 2004 9:33 am
Location: Saint Petersburg, Russia
Contact:

Post by chyduskam »

Good Idea, only 2 notice

Code: Select all

. #
#-----[ REPLACE WITH ]------------------------------------------
#

	header("location: oops.php");
As I thing must:

Code: Select all

. #
#-----[ REPLACE WITH ]------------------------------------------
#

	header("location: oops.php");
        exit;
2. HTTP/1.1 requires an absolute URI as argument to 'Location'
DKing
Registered User
Posts: 751
Joined: Sat Jul 03, 2004 8:38 pm

Post by DKing »

Wow... sounds like a great idea! I'll have to download it once it gets more stable (higher version ;)). But I really do love the idea and all!

-DKing
-DKing
Latest phpBB Version: 2.0.21
Search For a MOD: MOD Search
»»EDDY««
Registered User
Posts: 220
Joined: Mon Jun 02, 2003 10:14 am
Location: Poland/Slupsk
Contact:

Post by »»EDDY«« »

Thats better:

Code: Select all

header("HTTP/1.0 307 Temporary redirect");
header("Location: oops.php");
header("Connection: close"); 
Make a Tiny URL in excellent domain heh.pl


cooling system & water cooling
MarcN
Registered User
Posts: 193
Joined: Sun Mar 20, 2005 9:17 am
Location: From the Netherlands
Contact:

Post by MarcN »

Nice! This is really cool!
Sorry, for my bad English :cry:
Joe Belmaati
Registered User
Posts: 2110
Joined: Sun Sep 28, 2003 7:35 pm
Location: Denmark

Post by Joe Belmaati »

Thank you very much for the feedback. I dug this out of common.php

Code: Select all

if( !defined("PHPBB_INSTALLED") )
{
	header("Location: install/install.$phpEx");
	exit;
}
so I suppose chyduskam's suggestion is the right one.. with the exception of the need for an absolute URI.

DKing,
I believe this MOD is completely stable. The redirect works as advertised in the MOD description. Testing whether it works for your board is very easy. Open your config.php and change a character is your password. Then try to call a phpBB page in your browser. After confirming that everything works change the password back, and voìla, you're back in business.
Image
DKing
Registered User
Posts: 751
Joined: Sat Jul 03, 2004 8:38 pm

Post by DKing »

Joe Belmaati wrote: DKing,
I believe this MOD is completely stable. The redirect works as advertised in the MOD description. Testing whether it works for your board is very easy. Open your config.php and change a character is your password. Then try to call a phpBB page in your browser. After confirming that everything works change the password back, and voìla, you're back in business.

Alright... I'll try it out! ;)

Thanks,
-DKing
-DKing
Latest phpBB Version: 2.0.21
Search For a MOD: MOD Search
User avatar
Kalipo
Registered User
Posts: 551
Joined: Mon Dec 08, 2003 1:47 pm

Post by Kalipo »

:?

Got it, tried it, saw this...
Warning: mysql_connect(): Access denied for user: 'me@host' (Using password: YES) in .../public_html/db/mysql4.php on line 48

Warning: Cannot modify header information - headers already sent by (output started at .../public_html/db/mysql4.php:xx) in .../public_html/includes/db.php on line 63

Code: Select all

if(!$db->db_connect_id)
{
        header("Location: oops.$phpEx"); <----------Line 63
        exit;
}

?>
Joe Belmaati
Registered User
Posts: 2110
Joined: Sun Sep 28, 2003 7:35 pm
Location: Denmark

Post by Joe Belmaati »

That's bizzare, because no headers are sent when the db is down. That's why I put headers in oops.php

Did you change your PW in config.php to test the result?
Image
User avatar
*=Matt=*
Registered User
Posts: 389
Joined: Mon Dec 20, 2004 11:56 pm
Location: Oakdale, Wisconsin

Post by *=Matt=* »

that is the something i get

Code: Select all

Warning: mysql_connect(): Can't connect to MySQL server on '1' (22) in /home/mattgru/public_html/forums/db/mysql4.php on line 48

Warning: Cannot modify header information - headers already sent by (output started at /home/mattgru/public_html/forums/db/mysql4.php:48) in /home/mattgru/public_html/forums/includes/db.php on line 63
Post Reply

Return to “[2.0.x] MODs in Development”