vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Redirect Incase of mySQL problem (https://vborg.vbsupport.ru/showthread.php?t=78340)

Harley77 03-17-2005 10:00 PM

Redirect Incase of mySQL problem
 
If someone has posted something like this before, I couldn't find it.

What this does:
It will redirect visitors to a static webpage of your choosing incase a connection to the mySQL server could not be established.

Every so often, The SQL server of our host becomes unresponsive, usually only for a few minutes, but, it's still annoying to try and load the site and have it take forver then be finally be greeted with a lovely SQL error. So, now people can get a nice friendly error page instead.

Feel free to modify and mess with it however you choose.


UPDATED


Trigunflame has provided a more elegant, sitewide solution that effectivly does the same exact thing.


Installation:

1. open includes/db_mysql.php
2. find the code below in the connect() function

Code:

if (!$this->link_id)
                {
                        $this->halt('Link-ID == false, connect failed');
                        return false;
                }

3. Replace that with

Code:

// Redirect For SQL Server Down
                if (!$this->link_id)
                {
                        $url = 'http://narutotalk.org/';
                        header ("Location: $url");
                }


Just replace the url with where ever you want it to goto.

I'm leaving the original file availible to download as it might be useful for other administrative purposes.

Polo 03-19-2005 01:16 AM

I was looking for something like this... thanks for sharing ;)

Deaths 03-19-2005 05:06 AM

Very nice, this is very usefull.

Tekton 03-19-2005 05:09 AM

It doesn't take a good coder to make a great mod :)

Harley77 03-19-2005 01:13 PM

Thank you very much.

One other note, if someone want's it, its not hard to modify the testcon.php file to take the database login settings from your vb config file. I just did it this way for flexibility and make it easier to test without causing site wide dissruption.

Deaths 03-19-2005 02:16 PM

Quote:

Originally Posted by Harley77
Thank you very much.

One other note, if someone want's it, its not hard to modify the testcon.php file to take the database login settings from your vb config file. I just did it this way for flexibility and make it easier to test without causing site wide dissruption.

I'm 99% sure this should so it, haven't tested though.

Trigunflame 03-20-2005 02:54 AM

A better solution that will work on any page.

1. open includes/db_mysql.php
2. find the code below in the connect() function
Code:

                if (!$this->link_id)
                {
                        $this->halt('Link-ID == false, connect failed');
                        return false;
                }

3. Replace that with
Code:

                // Redirect For SQL Server Down
                if (!$this->link_id)
                {
                        $url = 'http://narutotalk.org/';
                        header ("Location: $url");
                }

This will redirect users on any page, if the the DB connection could not be established.

All of the methods in the above posts's are redundant as they are trying to establish a "second" db connection. All that is going to do is slow down your pages on every load, and increase your mysql load by increasing its connections.

Harley77 03-21-2005 12:36 PM

Ah ha! new there was a better way. Curious though, would this method redirect on any kind of SQL issue such as conneciton limit reached (server side, not though VB), or any other failure to connect to the server and not just on an outright connection failure?

Deaths 03-21-2005 02:22 PM

My method, or his?

Harley77 03-21-2005 02:38 PM

His, Just wasn't sure what all errors it covered. I know that the method I put up pretty much covered all the bases incase of any kind of issue, just wasn't sure if the same was true with Trigunflames.


All times are GMT. The time now is 01:46 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01071 seconds
  • Memory Usage 1,738KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete