Commit cd24c03466289b190ab5f2b639904a985d6673e7
1 parent
e9b49a20
KTS-2360
"Remove cache logging." Updated. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7203 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
54 additions
and
54 deletions
lib/session/Session.inc
| ... | ... | @@ -8,7 +8,7 @@ |
| 8 | 8 | * License Version 1.1.2 ("License"); You may not use this file except in |
| 9 | 9 | * compliance with the License. You may obtain a copy of the License at |
| 10 | 10 | * http://www.knowledgetree.com/KPL |
| 11 | - * | |
| 11 | + * | |
| 12 | 12 | * Software distributed under the License is distributed on an "AS IS" |
| 13 | 13 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. |
| 14 | 14 | * See the License for the specific language governing rights and |
| ... | ... | @@ -19,16 +19,16 @@ |
| 19 | 19 | * (ii) the KnowledgeTree copyright notice |
| 20 | 20 | * in the same form as they appear in the distribution. See the License for |
| 21 | 21 | * requirements. |
| 22 | - * | |
| 22 | + * | |
| 23 | 23 | * The Original Code is: KnowledgeTree Open Source |
| 24 | - * | |
| 24 | + * | |
| 25 | 25 | * The Initial Developer of the Original Code is The Jam Warehouse Software |
| 26 | 26 | * (Pty) Ltd, trading as KnowledgeTree. |
| 27 | 27 | * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright |
| 28 | 28 | * (C) 2007 The Jam Warehouse Software (Pty) Ltd; |
| 29 | 29 | * All Rights Reserved. |
| 30 | 30 | * Contributor( s): ______________________________________ |
| 31 | - */ | |
| 31 | + */ | |
| 32 | 32 | |
| 33 | 33 | class Session { |
| 34 | 34 | var $_bNotEmpty = true; |
| ... | ... | @@ -42,7 +42,7 @@ class Session { |
| 42 | 42 | function create(&$oUser) { |
| 43 | 43 | $iUserId = $oUser->getId(); |
| 44 | 44 | global $default; |
| 45 | - | |
| 45 | + | |
| 46 | 46 | session_start(); |
| 47 | 47 | |
| 48 | 48 | if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { |
| ... | ... | @@ -54,23 +54,23 @@ class Session { |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | - | |
| 57 | + | |
| 58 | 58 | if ($oUser->getDisabled()) { |
| 59 | 59 | return PEAR::raiseError(_kt("Your account has been disabled. Please contact the system administrator for assistance.")); |
| 60 | 60 | } |
| 61 | - | |
| 61 | + | |
| 62 | 62 | // bind user id to session |
| 63 | 63 | $_SESSION["userID"] = $iUserId; |
| 64 | 64 | $_SESSION["KTErrorMessage"] = array(); |
| 65 | - | |
| 65 | + | |
| 66 | 66 | // use the PHP generated session id |
| 67 | 67 | $sessionID = session_id(); |
| 68 | 68 | |
| 69 | 69 | // retrieve client ip |
| 70 | 70 | $ip = $this->getClientIP(); |
| 71 | 71 | |
| 72 | - $default->log->debug("Session::create() new session for $iUserId, from $ip, sessionID=$sessionID"); | |
| 73 | - | |
| 72 | + if (KTLOG_CACHE) $default->log->debug("Session::create() new session for $iUserId, from $ip, sessionID=$sessionID"); | |
| 73 | + | |
| 74 | 74 | // insert session information into db |
| 75 | 75 | $aParams = array( |
| 76 | 76 | 'session_id' => $sessionID, |
| ... | ... | @@ -100,10 +100,10 @@ class Session { |
| 100 | 100 | |
| 101 | 101 | $oProvider =& KTAuthenticationUtil::getAuthenticationProviderForUser($oUser); |
| 102 | 102 | $oProvider->login($oUser); |
| 103 | - | |
| 103 | + | |
| 104 | 104 | return $sessionID; |
| 105 | 105 | } |
| 106 | - | |
| 106 | + | |
| 107 | 107 | /** |
| 108 | 108 | * Destroys the current session. |
| 109 | 109 | */ |
| ... | ... | @@ -113,7 +113,7 @@ class Session { |
| 113 | 113 | session_start(); |
| 114 | 114 | $sSessionID = session_id(); |
| 115 | 115 | $iUserId = $_SESSION["userID"]; |
| 116 | - | |
| 116 | + | |
| 117 | 117 | // remove the session information from the database |
| 118 | 118 | |
| 119 | 119 | $sTable = KTUtil::getTableName('sessions'); |
| ... | ... | @@ -132,9 +132,9 @@ class Session { |
| 132 | 132 | unset($_SESSION['userID']); |
| 133 | 133 | unset($_SESSION['sessionStatus']); |
| 134 | 134 | session_unset(); |
| 135 | - session_destroy(); | |
| 135 | + session_destroy(); | |
| 136 | 136 | } |
| 137 | - | |
| 137 | + | |
| 138 | 138 | /** |
| 139 | 139 | * Removes any stale sessions for the specified userID |
| 140 | 140 | * |
| ... | ... | @@ -198,7 +198,7 @@ class Session { |
| 198 | 198 | |
| 199 | 199 | // this should be an existing session, so check the db |
| 200 | 200 | $aRows = DBUtil::getResultArray(array("SELECT * FROM $default->sessions_table WHERE session_id = ?", $sessionID)); |
| 201 | - | |
| 201 | + | |
| 202 | 202 | $numrows = count($aRows); |
| 203 | 203 | |
| 204 | 204 | // FIXME: if there aren't more rows that the max sessions for this user |
| ... | ... | @@ -209,16 +209,16 @@ class Session { |
| 209 | 209 | return false; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - $default->log->debug("Session::verify found session in db"); | |
| 212 | + if (KTLOG_CACHE) $default->log->debug("Session::verify found session in db"); | |
| 213 | 213 | $aRow = $aRows[0]; |
| 214 | 214 | |
| 215 | 215 | $iUserID = $aRow["user_id"]; |
| 216 | - | |
| 217 | - $oKTConfig = KTConfig::getSingleton(); | |
| 216 | + | |
| 217 | + $oKTConfig = KTConfig::getSingleton(); | |
| 218 | 218 | $allowAnon = $oKTConfig->get('session/allowAnonymousLogin', false); |
| 219 | - | |
| 219 | + | |
| 220 | 220 | $ANON = -2; |
| 221 | - if ((!$allowAnon) && ($iUserID == $ANON)) { | |
| 221 | + if ((!$allowAnon) && ($iUserID == $ANON)) { | |
| 222 | 222 | Session::destroy(); // delete the anonymous session - config.ini has changed under this session. |
| 223 | 223 | return PEAR::raiseError(_kt("Anonymous logins are no longer allowed by the system administrator. Please login.")); |
| 224 | 224 | } |
| ... | ... | @@ -229,7 +229,7 @@ class Session { |
| 229 | 229 | if ($ipTracking && ($ip != trim($aRow["ip"]))) { |
| 230 | 230 | return PEAR::raiseError(_kt("You are coming from a different IP address than the session requires")); |
| 231 | 231 | } |
| 232 | - | |
| 232 | + | |
| 233 | 233 | if (empty($_SESSION['userID'])) { |
| 234 | 234 | Session::removeStaleSessions(); |
| 235 | 235 | |
| ... | ... | @@ -263,10 +263,10 @@ class Session { |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | Session::removeStaleSessions(); |
| 266 | - | |
| 266 | + | |
| 267 | 267 | return false; |
| 268 | 268 | } |
| 269 | - | |
| 269 | + | |
| 270 | 270 | /** |
| 271 | 271 | * Retrieves and returns the IP address of the current user |
| 272 | 272 | */ | ... | ... |
lib/session/SiteMap.inc
| ... | ... | @@ -358,13 +358,13 @@ class SiteMap { |
| 358 | 358 | |
| 359 | 359 | // for each section |
| 360 | 360 | foreach ($this->aSiteMap as $section => $valArr) { |
| 361 | - //$default->log->debug("Sitemap::getPage section=$section"); | |
| 361 | + if (KTLOG_CACHE) $default->log->debug("Sitemap::getPage section=$section"); | |
| 362 | 362 | // for each group, page array combination |
| 363 | 363 | foreach ($valArr as $requiredAccess => $pageArr) { |
| 364 | 364 | // now loop through pages until we find the right one |
| 365 | 365 | foreach ($pageArr as $ackshin => $page) { |
| 366 | 366 | if ($ackshin == $action) { |
| 367 | - $default->log->debug("Sitemap::getPageArray calling hasPermission current requiredAccess=$requiredAccess, action=$ackshin"); | |
| 367 | + if (KTLOG_CACHE) $default->log->debug("Sitemap::getPageArray calling hasPermission current requiredAccess=$requiredAccess, action=$ackshin"); | |
| 368 | 368 | if ($this->hasPermission($requiredAccess)) { |
| 369 | 369 | if (KTUtil::arrayGet($_SERVER, 'kt_no_extensions')) { |
| 370 | 370 | return str_replace('.php', '', $page["page"]); |
| ... | ... | @@ -503,7 +503,7 @@ class SiteMap { |
| 503 | 503 | $results = array(); |
| 504 | 504 | // need to loop through all (groupName, page) arrays in this section |
| 505 | 505 | foreach ($this->aSiteMap[$sSectionName] as $requiredAccess => $pages) { |
| 506 | - $default->log->debug("Sitemap::getDefaultActionArray calling hasPermission current requiredAccess=$requiredAccess"); | |
| 506 | + if (KTLOG_CACHE) $default->log->debug("Sitemap::getDefaultActionArray calling hasPermission current requiredAccess=$requiredAccess"); | |
| 507 | 507 | if ($this->hasPermission($requiredAccess)) { |
| 508 | 508 | foreach ($pages as $action => $pageArray) { |
| 509 | 509 | if ($pageArray["default"] && $pageArray["enabled"]) { |
| ... | ... | @@ -570,21 +570,21 @@ class SiteMap { |
| 570 | 570 | */ |
| 571 | 571 | function getActionFromPageArray($sPage) { |
| 572 | 572 | global $default; |
| 573 | - // $default->log->debug("Sitemap::getActionFromPage: page=$sPage"); | |
| 573 | + if (KTLOG_CACHE) $default->log->debug("Sitemap::getActionFromPage: page=$sPage"); | |
| 574 | 574 | // for each section |
| 575 | 575 | if (!strpos($sPage, '.php')) { |
| 576 | 576 | $sPage .= '.php'; |
| 577 | 577 | } |
| 578 | 578 | foreach ($this->aSiteMap as $section => $valArr) { |
| 579 | - //$default->log->debug("Sitemap::getActionFromPage section=$section"); | |
| 579 | + if (KTLOG_CACHE) $default->log->debug("Sitemap::getActionFromPage section=$section"); | |
| 580 | 580 | // for each group, page array combination |
| 581 | 581 | foreach ($valArr as $requiredAccess => $pageArr) { |
| 582 | - //$default->log->debug("Sitemap::getActionFromPage access=$requiredAccess"); | |
| 582 | + if (KTLOG_CACHE) $default->log->debug("Sitemap::getActionFromPage access=$requiredAccess"); | |
| 583 | 583 | // now loop through pages until we find the right one |
| 584 | 584 | foreach ($pageArr as $action => $page) { |
| 585 | - //$default->log->debug("Sitemap::getActionFromPage action=$action, reqPage=$sPage; page=" . $page["page"]); | |
| 585 | + if (KTLOG_CACHE) $default->log->debug("Sitemap::getActionFromPage action=$action, reqPage=$sPage; page=" . $page["page"]); | |
| 586 | 586 | if ($sPage == $page["page"]) { |
| 587 | - //$default->log->debug("Sitemap::getActionFromPage found action=$action for page=$sPage"); | |
| 587 | + if (KTLOG_CACHE) $default->log->debug("Sitemap::getActionFromPage found action=$action for page=$sPage"); | |
| 588 | 588 | return $action; |
| 589 | 589 | } |
| 590 | 590 | } |
| ... | ... | @@ -613,13 +613,13 @@ class SiteMap { |
| 613 | 613 | if (!$this->bUseDB) { |
| 614 | 614 | // clear section table |
| 615 | 615 | if ($sql->query("DELETE from $default->site_sections_table")) { |
| 616 | - $default->log->debug("Sitemap::syncWithDB removed sections"); | |
| 616 | + if (KTLOG_CACHE) $default->log->debug("Sitemap::syncWithDB removed sections"); | |
| 617 | 617 | } else { |
| 618 | 618 | $default->log->error("Sitemap::syncWithDB remove sections failed"); |
| 619 | 619 | } |
| 620 | 620 | // clear sitemap table |
| 621 | 621 | if ($sql->query("DELETE from $default->sitemap_table")) { |
| 622 | - $default->log->debug("Sitemap::syncWithDB removed sitemap"); | |
| 622 | + if (KTLOG_CACHE) $default->log->debug("Sitemap::syncWithDB removed sitemap"); | |
| 623 | 623 | } else { |
| 624 | 624 | $default->log->error("Sitemap::syncWithDB remove sitemap failed"); |
| 625 | 625 | } |
| ... | ... | @@ -631,13 +631,13 @@ class SiteMap { |
| 631 | 631 | ); |
| 632 | 632 | $id = DBUtil::autoInsert($default->site_sections_table, $aFieldValues); |
| 633 | 633 | |
| 634 | - // $default->log->debug("Sitemap::syncWithDB insert=$sSectionSql"); | |
| 634 | + if (KTLOG_CACHE) $default->log->debug("Sitemap::syncWithDB insert=$sSectionSql"); | |
| 635 | 635 | |
| 636 | 636 | if (PEAR::isError($id)) { |
| 637 | 637 | $default->log->error("Sitemap::syncWithDB add section $section failed"); |
| 638 | 638 | } else { |
| 639 | 639 | $sectionID = $id; |
| 640 | - $default->log->debug("Sitemap::syncWithDB added section $section; $sectionID"); | |
| 640 | + if (KTLOG_CACHE) $default->log->debug("Sitemap::syncWithDB added section $section; $sectionID"); | |
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | // for each group, page array combination |
| ... | ... | @@ -655,9 +655,9 @@ class SiteMap { |
| 655 | 655 | ); |
| 656 | 656 | $id = DBUtil::autoInsert($default->sitemap_table, $aFieldValues); |
| 657 | 657 | if (PEAR::isError($id)) { |
| 658 | - $default->log->debug("Sitemap::syncWithDB sitemap insert failed ($sSiteMapSql)"); | |
| 658 | + $default->log->error("Sitemap::syncWithDB sitemap insert failed ($sSiteMapSql)"); | |
| 659 | 659 | } else { |
| 660 | - $default->log->debug("Sitemap::syncWithDb sitemap insert worked for ($action, " . $page["page"] . ")"); | |
| 660 | + if (KTLOG_CACHE) $default->log->debug("Sitemap::syncWithDb sitemap insert worked for ($action, " . $page["page"] . ")"); | |
| 661 | 661 | } |
| 662 | 662 | } |
| 663 | 663 | } | ... | ... |
lib/session/control.inc
| ... | ... | @@ -8,7 +8,7 @@ |
| 8 | 8 | * License Version 1.1.2 ("License"); You may not use this file except in |
| 9 | 9 | * compliance with the License. You may obtain a copy of the License at |
| 10 | 10 | * http://www.knowledgetree.com/KPL |
| 11 | - * | |
| 11 | + * | |
| 12 | 12 | * Software distributed under the License is distributed on an "AS IS" |
| 13 | 13 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. |
| 14 | 14 | * See the License for the specific language governing rights and |
| ... | ... | @@ -19,9 +19,9 @@ |
| 19 | 19 | * (ii) the KnowledgeTree copyright notice |
| 20 | 20 | * in the same form as they appear in the distribution. See the License for |
| 21 | 21 | * requirements. |
| 22 | - * | |
| 22 | + * | |
| 23 | 23 | * The Original Code is: KnowledgeTree Open Source |
| 24 | - * | |
| 24 | + * | |
| 25 | 25 | * The Initial Developer of the Original Code is The Jam Warehouse Software |
| 26 | 26 | * (Pty) Ltd, trading as KnowledgeTree. |
| 27 | 27 | * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright |
| ... | ... | @@ -51,7 +51,7 @@ function controllerRedirect($sAction, $sQueryString = "") { |
| 51 | 51 | // generate url |
| 52 | 52 | $url = generateControllerUrl($sAction, $sQueryString); |
| 53 | 53 | // now redirect |
| 54 | - $default->log->debug("controllerRedirect: redirect to $url"); | |
| 54 | + if (KTLOG_CACHE) $default->log->debug("controllerRedirect: redirect to $url"); | |
| 55 | 55 | redirect($url); |
| 56 | 56 | exit(0); |
| 57 | 57 | } |
| ... | ... | @@ -67,11 +67,11 @@ function controllerRedirect($sAction, $sQueryString = "") { |
| 67 | 67 | function generateLink($sTargetPage, $sQueryString = "", $sLinkText = "", $bLinkUrl = false) { |
| 68 | 68 | global $default; |
| 69 | 69 | |
| 70 | - $sLink = "http" . ($default->sslEnabled ? "s" : "") . "://" . $default->serverName . | |
| 70 | + $sLink = "http" . ($default->sslEnabled ? "s" : "") . "://" . $default->serverName . | |
| 71 | 71 | ((substr($sTargetPage, 0, strlen($default->rootUrl)) != $default->rootUrl) ? $default->rootUrl : "") . |
| 72 | - (substr($sTargetPage, 0, 1) == "/" ? "" : "/") . | |
| 72 | + (substr($sTargetPage, 0, 1) == "/" ? "" : "/") . | |
| 73 | 73 | $sTargetPage; |
| 74 | - | |
| 74 | + | |
| 75 | 75 | $sLink = KTUtil::addQueryString($sLink, $sQueryString); |
| 76 | 76 | if($bLinkUrl == true){ |
| 77 | 77 | $sLinkText = $sLink; |
| ... | ... | @@ -137,12 +137,12 @@ function checkSessionAndRedirect($bRedirect, $bDownload = false) { |
| 137 | 137 | $sessionStatus = $session->verify(); |
| 138 | 138 | |
| 139 | 139 | if ($sessionStatus === true) { |
| 140 | - $default->log->debug("checkSession:: returning true"); | |
| 140 | + if (KTLOG_CACHE) $default->log->debug("checkSession:: returning true"); | |
| 141 | 141 | return true; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | // verification failed |
| 145 | - $default->log->debug("checkSession:: session check failed"); | |
| 145 | + if (KTLOG_CACHE) $default->log->debug("checkSession:: session check failed"); | |
| 146 | 146 | if (empty($bRedirect)) { |
| 147 | 147 | return $sessionStatus; |
| 148 | 148 | } |
| ... | ... | @@ -151,11 +151,11 @@ function checkSessionAndRedirect($bRedirect, $bDownload = false) { |
| 151 | 151 | if (PEAR::isError($sessionStatus)) { |
| 152 | 152 | $sErrorMessage = $sessionStatus->getMessage(); |
| 153 | 153 | } |
| 154 | - | |
| 154 | + | |
| 155 | 155 | $oKTConfig = KTConfig::getSingleton(); |
| 156 | 156 | $dest = 'login'; |
| 157 | 157 | if ($oKTConfig->get('allowAnonymousLogin', false)) { $dest = 'dashboard'; } |
| 158 | - | |
| 158 | + | |
| 159 | 159 | // redirect to login with error message |
| 160 | 160 | if ($sErrorMessage) { |
| 161 | 161 | // session timed out |
| ... | ... | @@ -166,13 +166,13 @@ function checkSessionAndRedirect($bRedirect, $bDownload = false) { |
| 166 | 166 | |
| 167 | 167 | $redirect = urlencode(KTUtil::addQueryStringSelf($_SERVER["QUERY_STRING"])); |
| 168 | 168 | if ((strlen($redirect) > 1)) { |
| 169 | - $default->log->debug("checkSession:: redirect url=$redirect"); | |
| 169 | + if (KTLOG_CACHE) $default->log->debug("checkSession:: redirect url=$redirect"); | |
| 170 | 170 | // this session verification failure represents either the first visit to |
| 171 | 171 | // the site OR a session timeout etc. (in which case we still want to bounce |
| 172 | 172 | // the user to the login page, and then back to whatever page they're on now) |
| 173 | 173 | $url = $url . "&redirect=" . $redirect; |
| 174 | 174 | } |
| 175 | - $default->log->debug("checkSession:: about to redirect to $url"); | |
| 175 | + if (KTLOG_CACHE) $default->log->debug("checkSession:: about to redirect to $url"); | |
| 176 | 176 | redirect($url); |
| 177 | 177 | exit; |
| 178 | 178 | } |
| ... | ... | @@ -180,15 +180,15 @@ function checkSessionAndRedirect($bRedirect, $bDownload = false) { |
| 180 | 180 | /** |
| 181 | 181 | * Verifies the current session |
| 182 | 182 | * Automatically redirects to the login page on session verification failure |
| 183 | - * @param boolean optional parameter set if we're downloading a file | |
| 183 | + * @param boolean optional parameter set if we're downloading a file | |
| 184 | 184 | */ |
| 185 | 185 | function checkSession($bDownload = false, $bHandleNoAccess = true) { |
| 186 | 186 | global $default; |
| 187 | 187 | if (checkSessionAndRedirect(true, $bDownload)) { |
| 188 | - $default->log->debug("control.inc: print the session variables: " . arrayToString($_SESSION)); | |
| 188 | + if (KTLOG_CACHE) $default->log->debug("control.inc: print the session variables: " . arrayToString($_SESSION)); | |
| 189 | 189 | // the session is cool, now check if we access to this page |
| 190 | 190 | $pageName = KTUtil::getRequestScriptName($_SERVER); |
| 191 | - $default->log->debug("control.inc: page=" . $pageName . " ? " . $_SESSION["pageAccess"][$pageName]); | |
| 191 | + if (KTLOG_CACHE) $default->log->debug("control.inc: page=" . $pageName . " ? " . $_SESSION["pageAccess"][$pageName]); | |
| 192 | 192 | if ($_SESSION["pageAccess"][$pageName]) { |
| 193 | 193 | return true; |
| 194 | 194 | } else { | ... | ... |