From 2d6d4110eabfc6986c45f8cb12d38e4a0ba50e22 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 1 Jul 2008 22:11:28 +0000 Subject: [PATCH] - web: don't check for the stop_web file in BoincDb::get(). That forces that file to include a bunch of unnecessary stuff. Do the check at a higher level. svn path=/trunk/boinc/; revision=15532 --- checkin_notes | 11 ++++++ html/inc/boinc_db.inc | 8 ----- html/inc/util.inc | 71 +++++++++++++++++++++------------------ html/user/forum_index.php | 1 - 4 files changed, 49 insertions(+), 42 deletions(-) diff --git a/checkin_notes b/checkin_notes index c8e88ef53c..9717155ff8 100644 --- a/checkin_notes +++ b/checkin_notes @@ -5322,3 +5322,14 @@ Eric 1 July 2008 parse.h procinfo_unix.C +David 1 July 2008 + - web: don't check for the stop_web file in BoincDb::get(). + That forces that file to include a bunch of unnecessary stuff. + Do the check at a higher level. + + html/ + inc/ + boinc_db.inc + util.inc + user/ + forum_index.php diff --git a/html/inc/boinc_db.inc b/html/inc/boinc_db.inc index 4d698d9de7..a0d482dbdb 100644 --- a/html/inc/boinc_db.inc +++ b/html/inc/boinc_db.inc @@ -7,14 +7,6 @@ class BoincDb extends DbConn { static $instance; static function get($readonly = false) { - global $generating_xml; - if (web_stopped()) { - if ($generating_xml) { - xml_error(-183); - } else { - db_maintenance(); - } - } if (!isset($instance)) { $config = get_config(); $user = parse_config($config, ''); diff --git a/html/inc/util.inc b/html/inc/util.inc index c30dab5757..d0a70ffee2 100644 --- a/html/inc/util.inc +++ b/html/inc/util.inc @@ -6,7 +6,6 @@ require_once("../inc/countries.inc"); require_once("../inc/db.inc"); require_once("../inc/boinc_db.inc"); require_once("../inc/translation.inc"); -require_once("../inc/forum.inc"); require_once("../inc/profile.inc"); ini_set("memory_limit", "64M"); @@ -15,38 +14,6 @@ date_default_timezone_set("UTC"); $generating_xml = false; $caching = false; -function db_maintenance() { - page_head("Not available"); - echo "This page requires database access. - Our database server is temporarily shut down for maintenance. - Please try again later. - "; - page_tail(); - exit(); -} - -// Connects to database server and selects database as noted in config.xml -// If only read-only access is necessary, -// tries instead to connect to if tag exists. -// -function db_init($try_replica=false) { - if (web_stopped()) { - db_maintenance(); - } - $retval = db_init_aux($try_replica); - if ($retval == 1) { - echo "Unable to connect to database - please try again later\n"; - echo "Error: ", mysql_errno(), mysql_error(); - exit(); - } - if ($retval == 2) { - echo "Unable to select database - please try again later"; - echo mysql_error(); - exit(); - } - return 0; -} - function send_cookie($name, $value, $permanent, $ops=false) { // the following allows independent login for projects on the same server // @@ -717,6 +684,44 @@ function show_image($src, $title, $alt, $height=null) { echo "\"$alt\""; } +function check_web_stopped() { + global $generating_xml; + if (web_stopped()) { + if ($generating_xml) { + xml_error(-183); + } else { + //page_head("Not available"); + echo "This page requires database access. + Our database server is temporarily shut down for maintenance. + Please try again later. + "; + page_tail(); + exit(); + } + } +} + +// Connects to database server and selects database as noted in config.xml +// If only read-only access is necessary, +// tries instead to connect to if tag exists. +// DEPRECATED - use boinc_db.h +// +function db_init($try_replica=false) { + check_web_stopped(); + $retval = db_init_aux($try_replica); + if ($retval == 1) { + echo "Unable to connect to database - please try again later\n"; + echo "Error: ", mysql_errno(), mysql_error(); + exit(); + } + if ($retval == 2) { + echo "Unable to select database - please try again later"; + echo mysql_error(); + exit(); + } + return 0; +} + $cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit ?> diff --git a/html/user/forum_index.php b/html/user/forum_index.php index 24b257cd0c..9142292b71 100644 --- a/html/user/forum_index.php +++ b/html/user/forum_index.php @@ -7,7 +7,6 @@ require_once('../inc/forum.inc'); require_once('../inc/pm.inc'); require_once('../inc/time.inc'); - $user = get_logged_in_user(false); // Process request to mark all posts as read