From 8e03e68d687015b5cd8c9d3857e1a1d007252afa Mon Sep 17 00:00:00 2001 From: canyonknight Date: Sun, 3 Feb 2013 16:26:28 +0000 Subject: Add database wrapper class and new connection method Uses the Singleton pattern to ensure all queries use the same database connection that is released upon script completion. All database connections should now be called with DB::connect() and not db_connect(). Signed-off-by: canyonknight Signed-off-by: Lukas Fleischer --- web/lib/translator.inc.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'web/lib/translator.inc.php') diff --git a/web/lib/translator.inc.php b/web/lib/translator.inc.php index 1477b17..67693e0 100644 --- a/web/lib/translator.inc.php +++ b/web/lib/translator.inc.php @@ -12,6 +12,7 @@ set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR # print __("This is a %smajor%s problem!", "", ""); include_once('config.inc.php'); +include_once('DB.class.php'); include_once('gettext.php'); include_once('streams.php'); @@ -69,7 +70,7 @@ function __() { # set up the visitor's language # -function set_lang($dbh=NULL) { +function set_lang() { global $LANG; global $SUPPORTED_LANGS; global $PERSISTENT_COOKIE_TIMEOUT; @@ -90,9 +91,7 @@ function set_lang($dbh=NULL) { } elseif (isset($_COOKIE["AURSID"])) { # No language but a session; use default lang preference # - if(!$dbh) { - $dbh = db_connect(); - } + $dbh = DB::connect(); $q = "SELECT LangPreference FROM Users, Sessions "; $q.= "WHERE Users.ID = Sessions.UsersID "; $q.= "AND Sessions.SessionID = '"; -- cgit v1.2.3-54-g00ecf