[phpMP-CVS] CVS: phpMP/includes auth.php,1.29,1.30 functions.php,1.18,1.19 language.php,1.7,1.8 temp
Status: Pre-Alpha
Brought to you by:
heimidal
From: Brian R. <hei...@us...> - 2003-02-07 23:29:27
|
Update of /cvsroot/phpmp/phpMP/includes In directory sc8-pr-cvs1:/tmp/cvs-serv29029/includes Modified Files: auth.php functions.php language.php template.php user.php Log Message: Various updates and code consolidation. Index: auth.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/auth.php,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -r1.29 -r1.30 *** auth.php 6 Feb 2003 01:46:50 -0000 1.29 --- auth.php 7 Feb 2003 23:28:49 -0000 1.30 *************** *** 1,62 **** ! <?php ! ! class Auth // Authenticates user. Only included if user auth is set to be used. ! { ! ! var $curr_user; ! var $SESSID; ! ! function Auth() ! { ! ! global $DB; ! ! // Session ID is contained in the URL. ! if( isset( $_GET['SESSID'] ) ) ! { ! define("C_SESSID_LOC", 1); ! ! $session_id = $_GET['SESSID']; ! ! } ! // We're using the cookie set by the previous session. ! elseif( isset( $_COOKIE[C_COOKIE_NAME] ) ) ! { ! ! define("C_SESSID_LOC", 2); ! ! $session_id = $_COOKIE[C_COOKIE_NAME]; ! ! } ! ! $sql = "SELECT * FROM " . DB_SESSIONS_TABLE . " WHERE sessid=" . $session_id . " AND expiry<" . time(); ! $result = $DB->query($sql); ! ! $numrows = $DB->numRows($result); ! ! if($numrows >= 1) ! { ! ! $sess_data = $DB->fetchArray($result); ! ! } ! else // The session doesn't exist or has expired. ! { ! ! die("Your session has expired."); ! ! } ! ! if( C_SESSID_LOC == 2 ) // We need to set up the cookie. ! { ! ! ! // Set up cookie/url procedures and such. ! ! } ! ! } ! ! } ! ! ?> \ No newline at end of file --- 1 ---- ! <?php class Auth // Authenticates user. Only included if user auth is set to be used. { var $curr_user; var $session_id; function Auth() { global $DB; // Session ID is contained in the URL. if( isset( $_GET['s'] ) ) { define("C_SESSID_LOC", 1); $this->session_id = $_GET['s']; } // We're using the cookie set by the previous session. elseif( isset( $_COOKIE[C_COOKIE_NAME] ) ) { define("C_SESSID_LOC", 2); $this->session_id = $_COOKIE[C_COOKIE_NAME]; } // There is no Session ID. We'll have to make one. else { // Create a Session ID for our use. $this->session_id = makeSessionID(); // We must now determine where the session id should be placed. if( U_SESSION_URL == 1 ) { } } $sql = "SELECT * FROM " . DB_SESSIONS_TABLE . " WHERE sessid=" . $this->session_id . " AND expiry<" . time(); $result = $DB->query($sql); $numrows = $DB->numRows($result); if($numrows >= 1) { $sess_data = $DB->fetchArray($result); } else // The session doesn't exist or has expired. { die("Your session has expired."); } if( C_SESSID_LOC == 2 ) // We need to set up the cookie. { // Set up cookie/url procedures and such. } } } ?> \ No newline at end of file Index: functions.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/functions.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** functions.php 6 Feb 2003 01:50:32 -0000 1.18 --- functions.php 7 Feb 2003 23:28:50 -0000 1.19 *************** *** 1,21 **** ! <?php ! ! // Defines constants whose contents may be questionable. ! // Author: Brian 'Heimidal' Rose ! // Accepts: none. ! // Returns: none. ! function createConstants() ! { ! ! if( U_DATE_FORMAT != '' ) ! { ! define( "C_DATE_FORMAT", U_DATE_FORMAT ); ! } ! else ! { ! define( "C_DATE_FORMAT", C_DEFAULT_DATE_FORMAT ); ! } ! ! } ! ! ?> \ No newline at end of file --- 1 ---- ! <?php // Defines constants whose contents may be questionable. // Author: Brian 'Heimidal' Rose // Accepts: none. // Returns: none. function createConstants() { ( U_DATE_FORMAT != '' ) ? define( "C_DATE_FORMAT", U_DATE_FORMAT ) : define( "C_DATE_FORMAT", C_DEFAULT_DATE_FORMAT ); } function makeSessionID() { } ?> \ No newline at end of file Index: language.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/language.php,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** language.php 4 Feb 2003 21:43:23 -0000 1.7 --- language.php 7 Feb 2003 23:28:50 -0000 1.8 *************** *** 1 **** ! <?php class Language { function Language() { if( defined("U_LANGUAGE") ) { define( "C_LANGUAGE", U_LANGUAGE ); } else { define( "C_LANGUAGE", C_DEFAULT_LANG ); } global $Local; include_once( C_PHPMP_ROOT . 'languages/' . C_LANGUAGE . '/lang_main.php' ); $Local = new Localization(); } } ?> \ No newline at end of file --- 1 ---- ! <?php class Language { function Language() { defined("U_LANGUAGE") ? define( "C_LANGUAGE", U_LANGUAGE ) : define( "C_LANGUAGE", C_DEFAULT_LANG ); global $Local; include_once( C_PHPMP_ROOT . 'languages/' . C_LANGUAGE . '/lang_main.php' ); $Local = new Localization(); } } ?> \ No newline at end of file Index: template.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/template.php,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -r1.25 -r1.26 *** template.php 4 Feb 2003 21:43:26 -0000 1.25 --- template.php 7 Feb 2003 23:28:51 -0000 1.26 *************** *** 1 **** ! <?php // Contains the Template class. // This will utilize a flat-file template system. class Template extends Smarty { // Assigns template constants. // This function should somehow be integrated into constants.php. // Author: Nrian 'Heimidal' Rose // Accepts: none. // Returns: none. function assignConstants() { $this->assign( array( "C_SITE_ADDR" => SITE_ADDR, "C_SITE_NAME" => SITE_NAME, "C_REL_PATH" => REL_PATH, "C_TIME_NOW" => TIME_NOW, "C_TEMPLATE" => TEMPLATE ) ); } // Assigns template vars through lang files. // Author: Brian 'Heimidal' Rose // Accepts: none. // Returns: none. function assignLangVars() { global $Local; $this->assign( $Local->lang ); } // Initiates the Template engine. // Author: Brian 'Heimidal' Rose // Accepts: none. // Returns: none. function Template() { if( defined( "U_USR_TPL" ) && ( C_OVERRIDE_USR_TPL == 0 ) ) { define( "C_TEMPLATE", U_TEMPLATE ); } else { define( "C_TEMPLATE", C_DEFAULT_TPL ); } // Set up the directories for Smarty. $this->template_dir = './templates/' . C_TEMPLATE; $this->compile_dir = './templates/' . C_TEMPLATE . '/compile'; $this->config_dir = './templates/' . C_TEMPLATE . '/configs'; $this->cache_dir = ''; // Turn on compile_check. $this->compile_check = 1; // Switch for caching. $this->caching = false; // Caching does not currently work. Maybe later. } } ?> \ No newline at end of file --- 1 ---- ! <?php // Contains the Template class. // This will utilize a flat-file template system. class Template extends Smarty { // Assigns template constants. // This function should somehow be integrated into constants.php. // Author: Nrian 'Heimidal' Rose // Accepts: none. // Returns: none. function assignConstants() { $this->assign( array( "C_SITE_ADDR" => SITE_ADDR, "C_SITE_NAME" => SITE_NAME, "C_REL_PATH" => REL_PATH, "C_TIME_NOW" => TIME_NOW, "C_TEMPLATE" => TEMPLATE ) ); } // Assigns template vars through lang files. // Author: Brian 'Heimidal' Rose // Accepts: none. // Returns: none. function assignLangVars() { global $Local; $this->assign( $Local->lang ); } // Initiates the Template engine. // Author: Brian 'Heimidal' Rose // Accepts: none. // Returns: none. function Template() { ( defined( "U_USR_TPL" ) && ( C_OVERRIDE_USR_TPL == 0 ) ) ? define( "C_TEMPLATE", U_TEMPLATE ) : define( "C_TEMPLATE", C_DEFAULT_TPL ); // Set up the directories for Smarty. $this->template_dir = './templates/' . C_TEMPLATE; $this->compile_dir = './templates/' . C_TEMPLATE . '/compile'; $this->config_dir = './templates/' . C_TEMPLATE . '/configs'; $this->cache_dir = ''; // Turn on compile_check. $this->compile_check = 1; // Switch for caching. $this->caching = false; // Caching does not currently work. Maybe later. } } ?> \ No newline at end of file Index: user.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/user.php,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -r1.12 -r1.13 *** user.php 6 Feb 2003 01:46:50 -0000 1.12 --- user.php 7 Feb 2003 23:28:51 -0000 1.13 *************** *** 1,92 **** ! <?php ! ! class User // Creates a barrier between the Auth class and the outside world. ! // If user doesn't need to be auth'ed, he isn't. ! { ! ! // Fetches user information/variables from the database. ! // Author: Brian 'Heimidal' Rose ! // Accepts: $user (integer). ! // Returns: boolean. ! function _snapshot( $user ) ! { ! ! global $DB; ! ! $sql = "SELECT * FROM " . DB_USERS_TABLE . " WHERE userid=" . $DB->escapeString($user); ! ! $qry = $DB->query($sql); ! ! if( $DB->numRows( $qry ) < 1 ) { ! ! return false; ! ! } ! else { ! $user_array = $DB->fetchArray($qry); ! ! while( list ($key, $val) = each ($user_array) ) ! { ! define( "U_" . strtoupper($key), "$val" ); ! } ! ! return true; ! } ! } ! ! // Session cleanup routine. ! // Author: Brian 'Heimidal' Rose ! // Accepts: none. ! // Returns: none. ! function sessionClean() ! { ! ! global $DB; ! ! $rand = rand(0,10); ! if($rand >= 1) // 1:10 chance of session cleanup. This may later become a setting. ! { ! ! $sql = "DELETE FROM " . DB_SESSIONS_TABLE . " WHERE expiry<" . time(); ! $DB->query($sql); ! ! } ! ! } ! ! // User initialization function. Does -EVERYTHING- except explicit session cleanup. ! // Author: Brian 'Heimidal' Rose ! // Accepts: none. ! // Returns: none. ! function User() ! { ! ! $this->sessionClean(); ! ! // Must decide is this is an anonymous user or a registered user. ! ! if( ( C_USE_PORTAL_PERMS == 1 ) || ( defined( P_USE_ADMIN_PERMS ) ) ) // Checks for use_perms setting and makes sure we're not entering the admin area. ! { ! ! // We want to use authentication. ! ! global $Auth; ! ! include_once( C_PHPMP_ROOT . 'includes/auth.php' ); ! $Auth = new Auth(); // Initializes Auth, which also authenticates the user. ! ! $this->_snapshot( $Auth->curr_user ); // Gets snapshot of user info/vars. ! ! } ! else // We're not going to bother auth'ing the user. ! { ! ! $this->_snapshot('1'); // Gets snapshot of anon user info/vars. ! ! } ! ! } ! ! } ! ! ?> \ No newline at end of file --- 1 ---- ! <?php class User // Creates a barrier between the Auth class and the outside world. // If user doesn't need to be auth'ed, he isn't. { // Fetches user information/variables from the database. // Author: Brian 'Heimidal' Rose // Accepts: $user (integer). // Returns: boolean. function _snapshot( $user ) { global $DB; $sql = "SELECT * FROM " . DB_USERS_TABLE . " WHERE userid=" . $DB->escapeString($user); $qry = $DB->query($sql); if( $DB->numRows( $qry ) < 1 ) { die('User(' . $user . ') not found.'); } else { $user_array = $DB->fetchArray($qry); while( list ($key, $val) = each ($user_array) ) { define( "U_" . strtoupper($key), "$val" ); } return true; } } // Session cleanup routine. // Author: Brian 'Heimidal' Rose // Accepts: none. // Returns: none. function sessionClean() { global $DB; $rand = rand(0,10); if($rand >= 1) // 1:10 chance of session cleanup. This may later become a setting. { $sql = "DELETE FROM " . DB_SESSIONS_TABLE . " WHERE expiry<" . time(); $DB->query($sql); } } // User initialization function. Does -EVERYTHING- except explicit session cleanup. // Author: Brian 'Heimidal' Rose // Accepts: none. // Returns: none. function User() { $this->sessionClean(); // Must decide is this is an anonymous user or a registered user. if( ( C_USE_PORTAL_PERMS == 1 ) || ( defined( P_USE_ADMIN_PERMS ) ) ) // Checks for use_perms setting and makes sure we're not entering the admin area. { // We want to use authentication. global $Auth; include_once( C_PHPMP_ROOT . 'includes/auth.php' ); $Auth = new Auth(); // Initializes Auth, which also authenticates the user. $this->_snapshot( $Auth->curr_user ); // Gets snapshot of user info/vars. } else // We're not going to bother auth'ing the user. { $this->_snapshot('1'); // Gets snapshot of anon user info/vars. } } } ?> \ No newline at end of file |