From 68b8e088a427d10ac4e1b50ee96e8ed50438b231 Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Thu, 26 Jan 2012 23:22:50 +0100 Subject: [PATCH] Fixed a session_regenerate_id error leaving session files in /tmp folder. --- includes/lang/gettext.php | 11 +++++++---- includes/lang/language.php | 2 ++ includes/session.inc | 15 ++++++++++----- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/includes/lang/gettext.php b/includes/lang/gettext.php index b5ab613..3023e93 100644 --- a/includes/lang/gettext.php +++ b/includes/lang/gettext.php @@ -320,7 +320,10 @@ class gettext_php_support extends gettext_native_support $this->_jobs[] = array($domain, $path); return; } - + // Don't fill the domains with false data + if (strpos($domain, $this->_lang_code) === false) + return; + $err = $this->_load_domain($domain, $path); if ($err != 0) { @@ -474,7 +477,7 @@ class gettext_php_support_parser */ function _parse_line($line, $nbr) { - $line = str_replace("\\\"", "'", $line); + $line = str_replace("\\\"", "'", $line); // Should be inside preg_match, but I couldn't find the solution. This works. if (preg_match('/^\s*?#/', $line)) { return; } if (preg_match('/^\s*?msgid \"(.*?)(?!<\\\)\"/', $line, $m)) { $this->_store_key(); @@ -562,8 +565,8 @@ function set_ext_domain($path='') { } $lang_path = $path_to_root . ($path ? '/' : '') .$path.'/lang'; - // ignore change when extension does not provide translation structure - if (file_exists($lang_path)) + // ignore change when extension does not provide translation structure and test for valid session. + if (file_exists($lang_path) && isset($_SESSION['get_text'])) $_SESSION['get_text']->add_domain($_SESSION['language']->code, $lang_path, $path ? '' : $_SESSION['language']->version); } diff --git a/includes/lang/language.php b/includes/lang/language.php index ea428fc..1d6d7d8 100644 --- a/includes/lang/language.php +++ b/includes/lang/language.php @@ -88,6 +88,8 @@ if (!function_exists("_")) { function _($text) { + if (!isset($_SESSION['get_text'])) // Don't allow using session if not is net. + return $text; $retVal = $_SESSION['get_text']->gettext($text); if ($retVal == "") return $text; diff --git a/includes/session.inc b/includes/session.inc index 6407e6e..990a51c 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -75,17 +75,20 @@ class SessionManager $_SESSION['OBSOLETE'] = true; $_SESSION['EXPIRES'] = time() + 10; - // Create new session without destroying the old one - session_regenerate_id(false); - + // Create new session destroying the old one if posiible + if (phpversion() >= "5.1.0") + session_regenerate_id(true); + else + session_regenerate_id(); + // Grab current session ID and close both sessions to allow other scripts to use them $newSession = session_id(); session_write_close(); - // Set session ID to the new one, and start it back up again + session_id($newSession); session_start(); - + // Now we unset the obsolete and expiration values for the session we want to keep unset($_SESSION['OBSOLETE']); unset($_SESSION['EXPIRES']); @@ -296,6 +299,8 @@ ini_set('session.gc_maxlifetime', 36000); // 10hrs $Session_manager = new SessionManager(); $Session_manager->sessionStart('FA'.md5(dirname(__FILE__))); +//session_name('FA'.md5(dirname(__FILE__))); +//session_start(); // this is to fix the "back-do-you-want-to-refresh" issue - thanx PHPFreaks header("Cache-control: private"); -- 2.30.2