Thread: [phpMP-CVS] CVS: phpMP/includes auth.php,1.31,1.32 constants.php,1.16,1.17 core.php,1.42,1.43 functi
Status: Pre-Alpha
Brought to you by:
heimidal
From: Brian R. <hei...@us...> - 2003-02-08 10:48:25
|
Update of /cvsroot/phpmp/phpMP/includes In directory sc8-pr-cvs1:/tmp/cvs-serv26287/includes Modified Files: auth.php constants.php core.php functions.php sessions.php user.php Log Message: Started work on the sessions and auth management scheme. Don't try to use it yet..it's no where close to done. Index: auth.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/auth.php,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -r1.31 -r1.32 *** auth.php 8 Feb 2003 09:39:52 -0000 1.31 --- auth.php 8 Feb 2003 10:48:22 -0000 1.32 *************** *** 4,71 **** { - 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. - - } } --- 4,9 ---- Index: constants.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/constants.php,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -r1.16 -r1.17 *** constants.php 6 Feb 2003 01:52:48 -0000 1.16 --- constants.php 8 Feb 2003 10:48:22 -0000 1.17 *************** *** 1,6 **** <?php - define("C_DATE_NOW", date( C_DATE_FORMAT ) ); - define("ACTIVATE_DISABLED", 0); define("ACTIVATE_USER", 1); --- 1,4 ---- *************** *** 12,15 **** --- 10,16 ---- define("AUTH_LVL_MOD", 3); // Moderator define("AUTH_LVL_ADMIN", 4); // Administrator + + define("SESS_LOC_COOKIE", 1); //Sessions stored in cookie. + define("SESS_LOC_URL", 2); //Sessions stored in URL. ?> Index: core.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/core.php,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -r1.42 -r1.43 *** core.php 6 Feb 2003 01:46:50 -0000 1.42 --- core.php 8 Feb 2003 10:48:22 -0000 1.43 *************** *** 36,50 **** function init ( $optional_files = array() ) { include_once( C_PHPMP_ROOT . 'config.php' ); include_once( C_PHPMP_ROOT . 'includes/debug.php' ); $Debug = new Debug(); - global $DB; - include_once( C_PHPMP_ROOT . 'dba/' . DB_TYPE . '.dba' ); $DB = new DB(); $DB->connect(); $this->_initConfig(); // Grab DB-stored config values. --- 36,59 ---- function init ( $optional_files = array() ) { + + if( !defined("P_PHPMP_ROOT") ) + { + define('P_PHPMP_ROOT', './'); + } + include_once( C_PHPMP_ROOT . 'config.php' ); + // Globalize all major class-containing variables. + global $Debug, $DB, $User, $MPCode, $Template; + include_once( C_PHPMP_ROOT . 'includes/debug.php' ); $Debug = new Debug(); include_once( C_PHPMP_ROOT . 'dba/' . DB_TYPE . '.dba' ); $DB = new DB(); $DB->connect(); + include_once(C_PHPMP_ROOT . 'includes/constants.php'); + $this->_initConfig(); // Grab DB-stored config values. *************** *** 57,62 **** $Language = new Language(); ! createConstants(); ! include_once(C_PHPMP_ROOT . 'includes/constants.php'); include_once(C_PHPMP_ROOT . 'includes/mpcode.php'); --- 66,70 ---- $Language = new Language(); ! createVars(); include_once(C_PHPMP_ROOT . 'includes/mpcode.php'); *************** *** 67,74 **** while( $my_file = $optional_files[$i] ) { - include_once(C_PHPMP_ROOT . 'includes/' . $my_file . '.php'); $i++; - } --- 75,80 ---- *************** *** 76,82 **** include_once(C_PHPMP_ROOT . 'includes/template.php'); $Template = new Template(); // Create an instance of Template. - - // Globalize all major class-containing variables. - global $Debug, $User, $MPCode, $Template; } --- 82,85 ---- Index: functions.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/functions.php,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -r1.23 -r1.24 *** functions.php 8 Feb 2003 09:38:40 -0000 1.23 --- functions.php 8 Feb 2003 10:48:22 -0000 1.24 *************** *** 5,17 **** // 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() - { - } --- 5,11 ---- // Accepts: none. // Returns: none. ! function createVars() { ( U_DATE_FORMAT != '' ) ? define( "C_DATE_FORMAT", U_DATE_FORMAT ) : define( "C_DATE_FORMAT", C_DEFAULT_DATE_FORMAT ); } Index: sessions.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/sessions.php,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -r1.8 -r1.9 *** sessions.php 8 Feb 2003 09:43:29 -0000 1.8 --- sessions.php 8 Feb 2003 10:48:22 -0000 1.9 *************** *** 1,6 **** <?php ! // Session Management. ! // To be developed by Eric. ?> --- 1,65 ---- <?php ! class Session // Creates and maintains sessions for all users. ! { ! ! var $session_id; ! ! function Session() ! { ! } ! ! function startSession( $user ) ! { ! ! global $DB, $sid; ! ! // The Session ID is currently in the URL. We'll keep it that way for now. ! if( isset( $_GET['s'] ) ) ! { ! ! define('C_SESS_LOC', SESS_LOC_URL); ! ! $this->session_id = $_GET['s']; ! ! } ! // Not in the URL. Could be in a cookie. ! // NOTE: No support yet for auto-login cookies. ! elseif( isset( $_COOKIE[C_COOKIE_NAME . 'data'] ) || isset( $_COOKIE[C_COOKIE_NAME . 'sid']) ) ! ( ! ! define('C_SESS_LOC', SESS_LOC_COOKIE); ! ! $cookie_data = unserialize(C_COOKIE_NAME . 'data'); ! $this->session_id = $cookie_data['session_id']; ! ! } ! else ! { ! ! // We currently have no session_id set. ! ! } ! ! // Pull session data from the database. ! if( !empty( $this->session_id ) } ! { ! ! $sql = "SELECT u.*, s.* FROM " . DB_USERS_TABLE . " u, " . DB_SESSIONS_TABLE . " s WHERE s.sess_id = " . %this->session_id . " AND u.user_id = s.user_id"; ! ! $result = $DB->query($sql); ! $session_data = $DB->fetchRow($result); ! ! // We will now check for authenticity of the IP. ! if( isset( $session_data['user_id'] ) ) ! { ! // Will write this later. ! } ! ! } ! ! } ! ! } ?> Index: user.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/user.php,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -r1.14 -r1.15 *** user.php 8 Feb 2003 09:43:29 -0000 1.14 --- user.php 8 Feb 2003 10:48:22 -0000 1.15 *************** *** 71,80 **** // 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. } --- 71,80 ---- // We want to use authentication. ! global $Sessions; ! include_once( C_PHPMP_ROOT . 'includes/sessions.php' ); ! $Sessions = new Sessions(); // Initializes Auth, which also authenticates the user. ! $this->_snapshot( $Sessions->curr_user ); // Gets snapshot of user info/vars. } |