From cd24c03466289b190ab5f2b639904a985d6673e7 Mon Sep 17 00:00:00 2001 From: Conrad Vermeulen Date: Fri, 21 Sep 2007 08:51:15 +0000 Subject: [PATCH] KTS-2360 "Remove cache logging." Updated. --- lib/session/Session.inc | 48 ++++++++++++++++++++++++------------------------ lib/session/SiteMap.inc | 28 ++++++++++++++-------------- lib/session/control.inc | 32 ++++++++++++++++---------------- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/lib/session/Session.inc b/lib/session/Session.inc index c907e43..039f510 100644 --- a/lib/session/Session.inc +++ b/lib/session/Session.inc @@ -8,7 +8,7 @@ * License Version 1.1.2 ("License"); You may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.knowledgetree.com/KPL - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. * See the License for the specific language governing rights and @@ -19,16 +19,16 @@ * (ii) the KnowledgeTree copyright notice * in the same form as they appear in the distribution. See the License for * requirements. - * + * * The Original Code is: KnowledgeTree Open Source - * + * * The Initial Developer of the Original Code is The Jam Warehouse Software * (Pty) Ltd, trading as KnowledgeTree. * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright * (C) 2007 The Jam Warehouse Software (Pty) Ltd; * All Rights Reserved. * Contributor( s): ______________________________________ - */ + */ class Session { var $_bNotEmpty = true; @@ -42,7 +42,7 @@ class Session { function create(&$oUser) { $iUserId = $oUser->getId(); global $default; - + session_start(); if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { @@ -54,23 +54,23 @@ class Session { } } } - + if ($oUser->getDisabled()) { return PEAR::raiseError(_kt("Your account has been disabled. Please contact the system administrator for assistance.")); } - + // bind user id to session $_SESSION["userID"] = $iUserId; $_SESSION["KTErrorMessage"] = array(); - + // use the PHP generated session id $sessionID = session_id(); // retrieve client ip $ip = $this->getClientIP(); - $default->log->debug("Session::create() new session for $iUserId, from $ip, sessionID=$sessionID"); - + if (KTLOG_CACHE) $default->log->debug("Session::create() new session for $iUserId, from $ip, sessionID=$sessionID"); + // insert session information into db $aParams = array( 'session_id' => $sessionID, @@ -100,10 +100,10 @@ class Session { $oProvider =& KTAuthenticationUtil::getAuthenticationProviderForUser($oUser); $oProvider->login($oUser); - + return $sessionID; } - + /** * Destroys the current session. */ @@ -113,7 +113,7 @@ class Session { session_start(); $sSessionID = session_id(); $iUserId = $_SESSION["userID"]; - + // remove the session information from the database $sTable = KTUtil::getTableName('sessions'); @@ -132,9 +132,9 @@ class Session { unset($_SESSION['userID']); unset($_SESSION['sessionStatus']); session_unset(); - session_destroy(); + session_destroy(); } - + /** * Removes any stale sessions for the specified userID * @@ -198,7 +198,7 @@ class Session { // this should be an existing session, so check the db $aRows = DBUtil::getResultArray(array("SELECT * FROM $default->sessions_table WHERE session_id = ?", $sessionID)); - + $numrows = count($aRows); // FIXME: if there aren't more rows that the max sessions for this user @@ -209,16 +209,16 @@ class Session { return false; } - $default->log->debug("Session::verify found session in db"); + if (KTLOG_CACHE) $default->log->debug("Session::verify found session in db"); $aRow = $aRows[0]; $iUserID = $aRow["user_id"]; - - $oKTConfig = KTConfig::getSingleton(); + + $oKTConfig = KTConfig::getSingleton(); $allowAnon = $oKTConfig->get('session/allowAnonymousLogin', false); - + $ANON = -2; - if ((!$allowAnon) && ($iUserID == $ANON)) { + if ((!$allowAnon) && ($iUserID == $ANON)) { Session::destroy(); // delete the anonymous session - config.ini has changed under this session. return PEAR::raiseError(_kt("Anonymous logins are no longer allowed by the system administrator. Please login.")); } @@ -229,7 +229,7 @@ class Session { if ($ipTracking && ($ip != trim($aRow["ip"]))) { return PEAR::raiseError(_kt("You are coming from a different IP address than the session requires")); } - + if (empty($_SESSION['userID'])) { Session::removeStaleSessions(); @@ -263,10 +263,10 @@ class Session { } Session::removeStaleSessions(); - + return false; } - + /** * Retrieves and returns the IP address of the current user */ diff --git a/lib/session/SiteMap.inc b/lib/session/SiteMap.inc index 1a6571f..2e3a3ff 100644 --- a/lib/session/SiteMap.inc +++ b/lib/session/SiteMap.inc @@ -358,13 +358,13 @@ class SiteMap { // for each section foreach ($this->aSiteMap as $section => $valArr) { - //$default->log->debug("Sitemap::getPage section=$section"); + if (KTLOG_CACHE) $default->log->debug("Sitemap::getPage section=$section"); // for each group, page array combination foreach ($valArr as $requiredAccess => $pageArr) { // now loop through pages until we find the right one foreach ($pageArr as $ackshin => $page) { if ($ackshin == $action) { - $default->log->debug("Sitemap::getPageArray calling hasPermission current requiredAccess=$requiredAccess, action=$ackshin"); + if (KTLOG_CACHE) $default->log->debug("Sitemap::getPageArray calling hasPermission current requiredAccess=$requiredAccess, action=$ackshin"); if ($this->hasPermission($requiredAccess)) { if (KTUtil::arrayGet($_SERVER, 'kt_no_extensions')) { return str_replace('.php', '', $page["page"]); @@ -503,7 +503,7 @@ class SiteMap { $results = array(); // need to loop through all (groupName, page) arrays in this section foreach ($this->aSiteMap[$sSectionName] as $requiredAccess => $pages) { - $default->log->debug("Sitemap::getDefaultActionArray calling hasPermission current requiredAccess=$requiredAccess"); + if (KTLOG_CACHE) $default->log->debug("Sitemap::getDefaultActionArray calling hasPermission current requiredAccess=$requiredAccess"); if ($this->hasPermission($requiredAccess)) { foreach ($pages as $action => $pageArray) { if ($pageArray["default"] && $pageArray["enabled"]) { @@ -570,21 +570,21 @@ class SiteMap { */ function getActionFromPageArray($sPage) { global $default; - // $default->log->debug("Sitemap::getActionFromPage: page=$sPage"); + if (KTLOG_CACHE) $default->log->debug("Sitemap::getActionFromPage: page=$sPage"); // for each section if (!strpos($sPage, '.php')) { $sPage .= '.php'; } foreach ($this->aSiteMap as $section => $valArr) { - //$default->log->debug("Sitemap::getActionFromPage section=$section"); + if (KTLOG_CACHE) $default->log->debug("Sitemap::getActionFromPage section=$section"); // for each group, page array combination foreach ($valArr as $requiredAccess => $pageArr) { - //$default->log->debug("Sitemap::getActionFromPage access=$requiredAccess"); + if (KTLOG_CACHE) $default->log->debug("Sitemap::getActionFromPage access=$requiredAccess"); // now loop through pages until we find the right one foreach ($pageArr as $action => $page) { - //$default->log->debug("Sitemap::getActionFromPage action=$action, reqPage=$sPage; page=" . $page["page"]); + if (KTLOG_CACHE) $default->log->debug("Sitemap::getActionFromPage action=$action, reqPage=$sPage; page=" . $page["page"]); if ($sPage == $page["page"]) { - //$default->log->debug("Sitemap::getActionFromPage found action=$action for page=$sPage"); + if (KTLOG_CACHE) $default->log->debug("Sitemap::getActionFromPage found action=$action for page=$sPage"); return $action; } } @@ -613,13 +613,13 @@ class SiteMap { if (!$this->bUseDB) { // clear section table if ($sql->query("DELETE from $default->site_sections_table")) { - $default->log->debug("Sitemap::syncWithDB removed sections"); + if (KTLOG_CACHE) $default->log->debug("Sitemap::syncWithDB removed sections"); } else { $default->log->error("Sitemap::syncWithDB remove sections failed"); } // clear sitemap table if ($sql->query("DELETE from $default->sitemap_table")) { - $default->log->debug("Sitemap::syncWithDB removed sitemap"); + if (KTLOG_CACHE) $default->log->debug("Sitemap::syncWithDB removed sitemap"); } else { $default->log->error("Sitemap::syncWithDB remove sitemap failed"); } @@ -631,13 +631,13 @@ class SiteMap { ); $id = DBUtil::autoInsert($default->site_sections_table, $aFieldValues); - // $default->log->debug("Sitemap::syncWithDB insert=$sSectionSql"); + if (KTLOG_CACHE) $default->log->debug("Sitemap::syncWithDB insert=$sSectionSql"); if (PEAR::isError($id)) { $default->log->error("Sitemap::syncWithDB add section $section failed"); } else { $sectionID = $id; - $default->log->debug("Sitemap::syncWithDB added section $section; $sectionID"); + if (KTLOG_CACHE) $default->log->debug("Sitemap::syncWithDB added section $section; $sectionID"); } // for each group, page array combination @@ -655,9 +655,9 @@ class SiteMap { ); $id = DBUtil::autoInsert($default->sitemap_table, $aFieldValues); if (PEAR::isError($id)) { - $default->log->debug("Sitemap::syncWithDB sitemap insert failed ($sSiteMapSql)"); + $default->log->error("Sitemap::syncWithDB sitemap insert failed ($sSiteMapSql)"); } else { - $default->log->debug("Sitemap::syncWithDb sitemap insert worked for ($action, " . $page["page"] . ")"); + if (KTLOG_CACHE) $default->log->debug("Sitemap::syncWithDb sitemap insert worked for ($action, " . $page["page"] . ")"); } } } diff --git a/lib/session/control.inc b/lib/session/control.inc index 1e2b548..d3b9a34 100644 --- a/lib/session/control.inc +++ b/lib/session/control.inc @@ -8,7 +8,7 @@ * License Version 1.1.2 ("License"); You may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.knowledgetree.com/KPL - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. * See the License for the specific language governing rights and @@ -19,9 +19,9 @@ * (ii) the KnowledgeTree copyright notice * in the same form as they appear in the distribution. See the License for * requirements. - * + * * The Original Code is: KnowledgeTree Open Source - * + * * The Initial Developer of the Original Code is The Jam Warehouse Software * (Pty) Ltd, trading as KnowledgeTree. * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright @@ -51,7 +51,7 @@ function controllerRedirect($sAction, $sQueryString = "") { // generate url $url = generateControllerUrl($sAction, $sQueryString); // now redirect - $default->log->debug("controllerRedirect: redirect to $url"); + if (KTLOG_CACHE) $default->log->debug("controllerRedirect: redirect to $url"); redirect($url); exit(0); } @@ -67,11 +67,11 @@ function controllerRedirect($sAction, $sQueryString = "") { function generateLink($sTargetPage, $sQueryString = "", $sLinkText = "", $bLinkUrl = false) { global $default; - $sLink = "http" . ($default->sslEnabled ? "s" : "") . "://" . $default->serverName . + $sLink = "http" . ($default->sslEnabled ? "s" : "") . "://" . $default->serverName . ((substr($sTargetPage, 0, strlen($default->rootUrl)) != $default->rootUrl) ? $default->rootUrl : "") . - (substr($sTargetPage, 0, 1) == "/" ? "" : "/") . + (substr($sTargetPage, 0, 1) == "/" ? "" : "/") . $sTargetPage; - + $sLink = KTUtil::addQueryString($sLink, $sQueryString); if($bLinkUrl == true){ $sLinkText = $sLink; @@ -137,12 +137,12 @@ function checkSessionAndRedirect($bRedirect, $bDownload = false) { $sessionStatus = $session->verify(); if ($sessionStatus === true) { - $default->log->debug("checkSession:: returning true"); + if (KTLOG_CACHE) $default->log->debug("checkSession:: returning true"); return true; } // verification failed - $default->log->debug("checkSession:: session check failed"); + if (KTLOG_CACHE) $default->log->debug("checkSession:: session check failed"); if (empty($bRedirect)) { return $sessionStatus; } @@ -151,11 +151,11 @@ function checkSessionAndRedirect($bRedirect, $bDownload = false) { if (PEAR::isError($sessionStatus)) { $sErrorMessage = $sessionStatus->getMessage(); } - + $oKTConfig = KTConfig::getSingleton(); $dest = 'login'; if ($oKTConfig->get('allowAnonymousLogin', false)) { $dest = 'dashboard'; } - + // redirect to login with error message if ($sErrorMessage) { // session timed out @@ -166,13 +166,13 @@ function checkSessionAndRedirect($bRedirect, $bDownload = false) { $redirect = urlencode(KTUtil::addQueryStringSelf($_SERVER["QUERY_STRING"])); if ((strlen($redirect) > 1)) { - $default->log->debug("checkSession:: redirect url=$redirect"); + if (KTLOG_CACHE) $default->log->debug("checkSession:: redirect url=$redirect"); // this session verification failure represents either the first visit to // the site OR a session timeout etc. (in which case we still want to bounce // the user to the login page, and then back to whatever page they're on now) $url = $url . "&redirect=" . $redirect; } - $default->log->debug("checkSession:: about to redirect to $url"); + if (KTLOG_CACHE) $default->log->debug("checkSession:: about to redirect to $url"); redirect($url); exit; } @@ -180,15 +180,15 @@ function checkSessionAndRedirect($bRedirect, $bDownload = false) { /** * Verifies the current session * Automatically redirects to the login page on session verification failure - * @param boolean optional parameter set if we're downloading a file + * @param boolean optional parameter set if we're downloading a file */ function checkSession($bDownload = false, $bHandleNoAccess = true) { global $default; if (checkSessionAndRedirect(true, $bDownload)) { - $default->log->debug("control.inc: print the session variables: " . arrayToString($_SESSION)); + if (KTLOG_CACHE) $default->log->debug("control.inc: print the session variables: " . arrayToString($_SESSION)); // the session is cool, now check if we access to this page $pageName = KTUtil::getRequestScriptName($_SERVER); - $default->log->debug("control.inc: page=" . $pageName . " ? " . $_SESSION["pageAccess"][$pageName]); + if (KTLOG_CACHE) $default->log->debug("control.inc: page=" . $pageName . " ? " . $_SESSION["pageAccess"][$pageName]); if ($_SESSION["pageAccess"][$pageName]) { return true; } else { -- libgit2 0.21.4