function Context(&$Configuration) { $this->Configuration =& $Configuration; $this->BodyAttributes = ''; $this->StyleUrl = ''; $this->PageTitle = ''; $this->Dictionary = array(); $this->DelegateCollection = array(); $this->PassThruVars = array(); $this->CommentFormats = array(); $this->CommentFormats[] = 'Text'; // Create an object factory $this->ObjectFactory = new ObjectFactory(); // Current Mode $this->Mode = ForceIncomingCookieString('Mode', ''); // Url of the current page (this should be hard-coded by each page since php server vars are unreliable) $this->SelfUrl = ForceString($Configuration['SELF_URL'], 'index.php'); // Instantiate a SqlCollector (for debugging) $this->SqlCollector = new MessageCollector(); $this->SqlCollector->CssClass = 'Sql'; // Instantiate a Warning collector (for user errors) $this->WarningCollector = new MessageCollector(); // Instantiate an Error manager (for fatal errors) $this->ErrorManager = new ErrorManager(); // Instantiate a Database object (for performing database actions) $this->Database = new $Configuration['DATABASE_SERVER']($this); // Instantiate the string manipulation object $this->StringManipulator = new StringManipulator($this->Configuration); // Add the plain text manipulator $TextFormatter = new TextFormatter(); $this->StringManipulator->AddManipulator($Configuration['DEFAULT_FORMAT_TYPE'], $TextFormatter); }
function Context() { // Create an object factory $this->ObjectFactory = new ObjectFactory(); // Current Mode $this->Mode = ForceIncomingCookieString("Mode", ""); // Url of the current page $this->SelfUrl = basename(ForceString(@$_SERVER['PHP_SELF'], "index.php")); // Instantiate a SqlCollector (for debugging) $this->SqlCollector = new MessageCollector(); $this->SqlCollector->CssClass = "Sql"; // Instantiate a Warning collector (for user errors) $this->WarningCollector = new MessageCollector(); // Instantiate an Error manager (for fatal errors) $this->ErrorManager = new ErrorManager(); // Instantiate a Database object (for performing database actions) $this->Database = new MySQL(dbHOST, dbNAME, dbUSER, dbPASSWORD, $this); }
function GetIdentity() { if (!session_id()) { session_start(); } $UserID = ForceInt(@$_SESSION[$this->Context->Configuration['SESSION_USER_IDENTIFIER']], 0); if ($UserID == 0) { // UserID wasn't found in the session, so attempt to retrieve it from the cookies // Retrieve cookie values $EncryptedUserID = ForceIncomingCookieString($this->Context->Configuration['COOKIE_USER_KEY'], ''); $VerificationKey = ForceIncomingCookieString($this->Context->Configuration['COOKIE_VERIFICATION_KEY'], ''); if ($EncryptedUserID != '' && $VerificationKey != '') { // Compare against db values // Sadly, because this class is meant to be an interface for distributed objects, I can't use any of the error checking in the Lussumo Framework $Query = "select UserID\n from LUM_User\n where VerificationKey = '" . FormatStringForDatabaseInput($VerificationKey) . "'"; $Result = $this->Context->Database->Execute($Query, 'Authenticator', 'GetIdentity', 'An error occurred while attempting to validate your remember me credentials'); if ($Result) { $UserID = 0; while ($rows = $this->Context->Database->GetRow($Result)) { if ($EncryptedUserID == md5($rows['UserID'])) { $UserID = ForceInt($rows['UserID'], 0); $EncryptedUserID = $rows['EncryptedUserID']; break; } } if ($UserID > 0) { // 1. Set a new verification key $VerificationKey = DefineVerificationKey(); // 2. Update the user's information $this->UpdateLastVisit($UserID, $VerificationKey); // 3. Set the 'remember me' cookies $this->SetCookieCredentials($EncryptedUserID, $VerificationKey); // 4. Log the user's IP address $this->LogIp($UserID); } } } } // If it has now been found, set up the session. $this->AssignSessionUserID($UserID); return $UserID; }
function Context() { $this->BodyAttributes = ""; $this->StyleUrl = ""; $this->PageTitle = ""; $this->Dictionary = array(); $this->CommentFormats = array(); $this->CommentFormats[] = "Text"; $this->CommentFormats[] = "Html"; // Create an object factory $this->ObjectFactory = new ObjectFactory(); // Current Mode $this->Mode = ForceIncomingCookieString("Mode", ""); // Url of the current page $this->SelfUrl = basename(ForceString(@$_SERVER['PHP_SELF'], "index.php")); // Instantiate a string writer $this->Writer = new Writer(); // Instantiate a SqlCollector (for debugging) $this->SqlCollector = new MessageCollector(); $this->SqlCollector->CssClass = "Sql"; // Instantiate a Warning collector (for user errors) $this->WarningCollector = new MessageCollector(); // Instantiate an Error manager (for fatal errors) $this->ErrorManager = new ErrorManager(); // Instantiate a Database object (for performing database actions) $this->Database = new MySQL(dbHOST, dbNAME, dbUSER, dbPASSWORD, $this); // Instantiate the string manipulation object $this->StringManipulator = new StringManipulator(); // Add the plain text manipulator $TextFormatter = new TextFormatter(); $this->StringManipulator->AddManipulator(agDEFAULTSTRINGFORMAT, $TextFormatter); // Instantiate a Session object (to identify and profile the current user) $this->Session = new Session(); $this->Session->Start($this); // The style url (as defined by the user session) if (@$this->Session->User) { $this->StyleUrl = ForceString($this->Session->User->StyleUrl, agDEFAULT_STYLE); } }
function GetIdentity() { if (!session_id()) { session_set_cookie_params(0, $this->Context->Configuration['COOKIE_PATH'], $this->Context->Configuration['COOKIE_DOMAIN']); session_start(); } $UserID = ForceInt(@$_SESSION[$this->Context->Configuration['SESSION_USER_IDENTIFIER']], 0); if ($UserID == 0) { // UserID wasn't found in the session, so attempt to retrieve it from the cookies // Retrieve cookie values $CookieUserID = ForceIncomingCookieString($this->Context->Configuration['COOKIE_USER_KEY'], ''); $VerificationKey = ForceIncomingCookieString($this->Context->Configuration['COOKIE_VERIFICATION_KEY'], ''); if ($CookieUserID != '' && $VerificationKey != '') { // Compare against db values $s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder'); $s->SetMainTable('User', 'u'); $s->AddJoin('Role', 'r', 'RoleID', 'u', 'RoleID', 'inner join'); $s->AddSelect('UserID', 'u'); $s->AddWhere('u', 'UserID', '', FormatStringForDatabaseInput($CookieUserID), '='); $s->AddWhere('u', 'VerificationKey', '', FormatStringForDatabaseInput($VerificationKey), '='); $Result = $this->Context->Database->Select($s, 'Authenticator', 'GetIdentity', 'An error occurred while attempting to validate your remember me credentials'); if ($Result) { while ($rows = $this->Context->Database->GetRow($Result)) { $UserID = ForceInt($rows['UserID'], 0); } if ($UserID > 0) { // 1. Update the user's information $this->UpdateLastVisit($UserID); // 2. Log the user's IP address $this->LogIp($UserID); } } } } // If it has now been found, set up the session. $this->AssignSessionUserID($UserID); return $UserID; }
<?php /* * Copyright 2003 - 2005 Mark O'Sullivan * This file is part of Vanilla. * Vanilla is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. * Vanilla is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * You should have received a copy of the GNU General Public License along with Vanilla; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * The latest source code for Vanilla is available at www.lussumo.com * Contact Mark O'Sullivan at mark [at] lussumo [dot] com * * Description: Uses cookies to turn debugging information on and off */ include "library/Utility.Functions.php"; $Mode = ForceIncomingCookieString("Mode", "RELEASE"); $PageAction = ForceIncomingString("PageAction", ""); if ($PageAction == "ToggleDebug") { if ($Mode == "DEBUG") { $Mode = "RELEASE"; } elseif ($Mode == "RELEASE") { $Mode = "UPGRADE"; } else { $Mode = "DEBUG"; } setcookie("Mode", $Mode, time() + 31104000, "/"); } ////////////////////// // Display the page // ////////////////////// if ($PageAction == "ToggleDebug") { echo "processing...\r\n\t<script>\r\n\tsetTimeout(\"document.location='debug.php';\",600);\r\n\t</script>";
function ValidateCookieCredentials() { // Retrieve cookie values $EncryptedUserID = ForceIncomingCookieString("pass", ""); $VerificationKey = ForceIncomingCookieString("name", ""); $UserID = 0; $EGW_Session_ID = ForceIncomingCookieString("sessionid", ""); if ($EGW_Session_ID != "") { $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder"); $s->SetMainTable("phpgw_config", "egwc", ""); $s->AddSelect("config_value", "egwc"); $s->AddWhere("config_app", "phpgwapi", "="); $s->AddWhere("config_name", "sessions_timeout", "="); $r = $this->Context->Database->Select($this->Context, $s, $this->Name, "GetEGWSessionsTimeout", "An error occurred while getting sessions timeout", 0); if (!$r) { $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrBadSessionsTimeout") . $this->Context->Database->ConnectionError()); } else { while ($rows = $this->Context->Database->GetRow($r)) { $EGW_Sessions_Timeout = ForceInt($rows['config_value'], 0); } } $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder"); $s->SetMainTable("phpgw_sessions", "egws", ""); $s->AddSelect(array("session_id", "session_lid", "session_dla"), "egws"); $s->AddSelect("account_id", "egwu", "UserID"); $s->AddJoin("phpgw_accounts", "egwu", "account_lid", "egws", "session_lid", "left join", ""); $s->AddWhere("session_id", $EGW_Session_ID, "="); $s->AddWhere("session_dla", time() - $EGW_Sessions_Timeout, ">"); $r = $this->Context->Database->Select($this->Context, $s, $this->Name, "GetEGWSession", "An error occurred while getting session", 0); if (!$r) { $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrBadSession") . $this->Context->Database->ConnectionError()); } else { while ($rows = $this->Context->Database->GetRow($r)) { $UserID = ForceInt($rows['UserID'], 0); } } } /* if ($EncryptedUserID != "" && $VerificationKey != "") { // Compare against db values $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder"); $s->SetMainTable("User", "u"); $s->AddSelect("UserID", "u"); $s->AddSelect("UserID", "u", "EncryptedUserID", "md5"); $s->AddWhere("md5(UserID)", $EncryptedUserID, "="); $s->AddWhere("VerificationKey", $VerificationKey, "="); $UserResult = $this->Context->Database->Select($this->Context, $s, $this->Name, "ValidateCookieCredentials", "An error occurred while validating your credentials", 0); if (!$UserResult) { $this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrBadCredentials").$this->Context->Database->ConnectionError()); } else { if ($this->Context->Database->RowCount($UserResult) == 0) { // Silently fail if checking cookie credentials fails $this->Context->Session->End(); } else { // Set session variables while ($rows = $this->Context->Database->GetRow($UserResult)) { $UserID = ForceInt($rows['UserID'], 0); } if ($UserID > 0) { // Set a new verification key $VerificationKey = $this->DefineVerificationKey(); // Update the user's information $this->UpdateLastVisit($UserID, $VerificationKey); // Set the "remembery" cookies $this->SetCookieCredentials($EncryptedUserID, $VerificationKey); } } } } */ return $UserID; }
function GetIdentity() { if (!session_id()) { if ($this->Context->Configuration['SESSION_NAME']) { session_name($this->Context->Configuration['SESSION_NAME']); } session_set_cookie_params(0, $this->Context->Configuration['COOKIE_PATH'], $this->Context->Configuration['COOKIE_DOMAIN']); session_start(); } $UserID = ForceInt(@$_SESSION[$this->Context->Configuration['SESSION_USER_IDENTIFIER']], 0); if ($UserID == 0) { // UserID wasn't found in the session, so attempt to retrieve it from the cookies // Retrieve cookie values $CookieUserID = ForceIncomingCookieString($this->Context->Configuration['COOKIE_USER_KEY'], ''); $VerificationKey = ForceIncomingCookieString($this->Context->Configuration['COOKIE_VERIFICATION_KEY'], ''); $UserManager = $this->Context->ObjectFactory->NewContextObject($this->Context, 'UserManager'); $UserID = $UserManager->ValidateVerificationKey($CookieUserID, $VerificationKey); if ($UserID > 0) { // 1. Update the user's information $UserManager->UpdateUserLastVisit($UserID, $VerificationKey); // 2. Log the user's IP address $UserManager->AddUserIP($UserID); // If it has now been found, set up the session. $this->AssignSessionUserID($UserID); } } return $UserID; }
function GetIdentity() { $UserID = $this->Context->Session->GetVariable($this->Context->Configuration['SESSION_USER_IDENTIFIER'], 'int'); if ($UserID == 0) { // UserID wasn't found in the session, so attempt to retrieve it from the cookies // Retrieve cookie values $EncryptedUserID = ForceIncomingCookieString($this->Context->Configuration['COOKIE_USER_KEY'], ''); $VerificationKey = ForceIncomingCookieString($this->Context->Configuration['COOKIE_VERIFICATION_KEY'], ''); $UserManager = $this->Context->ObjectFactory->NewContextObject($this->Context, 'UserManager'); $UserID = $this->ValidateVerificationKey($UserManager, $EncryptedUserID, $VerificationKey); if ($UserID > 0) { // 1. Update the user's information $UserManager->UpdateUserLastVisit($UserID, $VerificationKey); // 2. Log the user's IP address $UserManager->AddUserIP($UserID); // If it has now been found, set up the session. $this->AssignSessionUserID($UserID); } } return $UserID; }