[phpMP-CVS] CVS: phpMP/includes constants.php,1.18,1.19 core.php,1.46,1.47 debug.php,1.3,1.4 functio
Status: Pre-Alpha
Brought to you by:
heimidal
From: Brian R. <hei...@us...> - 2003-05-02 04:54:08
|
Update of /cvsroot/phpmp/phpMP/includes In directory sc8-pr-cvs1:/tmp/cvs-serv10803/includes Modified Files: constants.php core.php debug.php functions.php session.php template.php Log Message: Fixed a few things. Removed redudant lines in template.php (redundant if initialized by Core). Config.php should always remain empty in CVS. Started work on debug interface. Lastly, autologin will now work as I want it to. Index: constants.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/constants.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** constants.php 9 Feb 2003 21:19:06 -0000 1.18 --- constants.php 2 May 2003 04:52:57 -0000 1.19 *************** *** 36,40 **** define("GMT_PLUS_5", 5); // Karachi. define("GMT_PLUS_5_30", 5.5); // New Delhi. - define("GMT_PLUS_5_45", 5.75); // Kathmandu. define("GMT_PLUS_6", 6); // Almaty. define("GMT_PLUS_6_30", 6.5); // Rangoon. --- 36,39 ---- *************** *** 47,50 **** --- 46,52 ---- define("GMT_PLUS_12", 12); // Auckland. define("GMT_PLUS_13", 13); // Nuku'alofa. + + define("DEBUG_ON", 1); + //define("DEBUG_ON", 0); ?> Index: core.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/core.php,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -r1.46 -r1.47 *** core.php 23 Apr 2003 07:21:03 -0000 1.46 --- core.php 2 May 2003 04:52:57 -0000 1.47 *************** *** 23,27 **** function Core( $optional_files = array() ) { ! if (get_magic_quotes_gpc()) { --- 23,27 ---- function Core( $optional_files = array() ) { ! set_magic_quotes_runtime(0); if (get_magic_quotes_gpc()) { *************** *** 35,38 **** --- 35,41 ---- define( 'PHPMP_ROOT', './' ); } + + error_reporting(E_ERROR | E_WARNING | E_PARSE); + //error_reporting(E_ALL); include_once( PHPMP_ROOT . 'config.php' ); *************** *** 44,47 **** --- 47,52 ---- $Debug = new Debug(); + set_error_handler(array('Debug', 'msgDisplay')); + include_once( PHPMP_ROOT . 'dba/' . DB_TYPE . '.dba' ); $DB = new DB(); *************** *** 86,94 **** // This while() statement will loop through the // $optional_files and include each file. ! $i = 0; ! while( $my_file = $optional_files[$i] ) { ! include_once(PHPMP_ROOT . 'includes/' . $my_file . '.php'); ! $i++; } --- 91,102 ---- // This while() statement will loop through the // $optional_files and include each file. ! if(count($optional_files) > 0) { ! $i = 0; ! while( $my_file = $optional_files[$i] ) ! { ! include_once(PHPMP_ROOT . 'includes/' . $my_file . '.php'); ! $i++; ! } } *************** *** 96,102 **** include_once(PHPMP_ROOT . 'includes/template.php'); $Template = new Template(); // Create an instance of Template. ! ! } ! } --- 104,110 ---- include_once(PHPMP_ROOT . 'includes/template.php'); $Template = new Template(); // Create an instance of Template. ! ! $DB->close(); ! } } Index: debug.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/debug.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** debug.php 8 Feb 2003 09:36:57 -0000 1.3 --- debug.php 2 May 2003 04:52:57 -0000 1.4 *************** *** 9,12 **** --- 9,40 ---- } + // Very similar to that of phpBB2, considering this is my first forray into error management. + // Hopefully, once I figure all of these different error codes and such out, I'll make it fit in more with the project. + function msgDisplay($errno, $msg_text, $errfile, $errline) + { + global $DB, $Config, $User, $Template; + + switch($errno) + { + case E_WARNING: + break; + + case E_NOTICE: + echo "PHP Notice on line <b>$errline</b> in <b>$errfile</b> :: <b>$msg_text</b><br />"; + break; + + case E_USER_ERROR: + if(isset($DB)) + { + $DB->close(); + echo "A User Error has occurred. Please notify the <a href=\"mailto: " . $Config['site_contact'] . "\">board administrator</a>."; + } + break; + + case E_USER_NOTICE: + echo "A User Notice has been issued. Please notify the <a href=\"mailto: " . $Config['site_contact'] . "\">board administrator</a>."; + break; + } + } } Index: functions.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/functions.php,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** functions.php 23 Apr 2003 07:21:03 -0000 1.27 --- functions.php 2 May 2003 04:52:57 -0000 1.28 *************** *** 7,11 **** function createVars() { ! global $Config; ( $User->data['date_format'] != '' ) ? ($Config['date_format'] = $User->data['date_format']) : ($Config['date_format'] = $Config['default_date_format']); --- 7,11 ---- function createVars() { ! global $Config, $User; ( $User->data['date_format'] != '' ) ? ($Config['date_format'] = $User->data['date_format']) : ($Config['date_format'] = $Config['default_date_format']); Index: session.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/session.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** session.php 29 Apr 2003 08:40:54 -0000 1.4 --- session.php 2 May 2003 04:52:57 -0000 1.5 *************** *** 14,22 **** // Starts the session. Must be called. ! function start($clean_all = false) { if($this->started == false) { - $this->clean(/*$clean_all*/ $_POST['clean_all'] ); $this->getSessionData(); $this->started = true; --- 14,21 ---- // Starts the session. Must be called. ! function start() { if($this->started == false) { $this->getSessionData(); $this->started = true; *************** *** 41,46 **** $DB->query($sql); ! setcookie($Config['cookie_name'] . '_auto', '', time() - 3600, $Config['cookie_path'], $Config['cookie_domain'], $Config['cookie_secure']); ! setcookie($Config['cookie_name'] . '_data', '', time() - 3600, $Config['cookie_path'], $Config['cookie_domain'], $Config['cookie_secure']); } --- 40,45 ---- $DB->query($sql); ! setcookie($Config['cookie_name'] . '_auto', '', time() - 31536000, $Config['cookie_path'], $Config['cookie_domain'], $Config['cookie_secure']); ! setcookie($Config['cookie_name'] . '_data', '', time() - 31536000, $Config['cookie_path'], $Config['cookie_domain'], $Config['cookie_secure']); } *************** *** 86,90 **** global $User, $DB, $Config; ! if( $_POST['do_login'] == true ) { $this->login(); --- 85,89 ---- global $User, $DB, $Config; ! if( (isset($_POST['do_login'])) && ($_POST['do_login'] == true) ) { $this->login(); *************** *** 171,174 **** --- 170,174 ---- $cookie_data = urlencode( $this->session_user_id . ':' . $this->session_key ); setcookie($Config['cookie_name'] . '_data', $cookie_data, $cur_time + $Config['session_length'], $Config['cookie_path'], $Config['cookie_domain'], $Config['cookie_secure']); + $this->clean(); } *************** *** 178,185 **** $rand = rand(0,10); ! if(($rand >= 1) || ($clean_all == true)) // 1:10 chance of session cleanup. This may later become a setting. { $sql = "DELETE FROM " . DB_SESSIONS_TABLE . " WHERE session_exp_time<" . time(); $DB->query($sql); } } --- 178,193 ---- $rand = rand(0,10); ! if(($rand <= 1) || ($clean_all == true)) // 1:10 chance of session cleanup. This may later become a setting. { $sql = "DELETE FROM " . DB_SESSIONS_TABLE . " WHERE session_exp_time<" . time(); $DB->query($sql); + + if((!empty($this->session_user_id)) && ($this->session_user_id != 1) && (!empty($this->session_key))) + // Note that, if we reach this point, the following query will remove past sessions for this user which may not have expired. + // This is good, but would be better if done for all users or if done during the creation of new sessions. + { + $sql = "DELETE FROM " . DB_SESSIONS_TABLE . " WHERE session_user_id=" . $this->session_user_id . " AND session_key!='" . $this->session_key . "'"; + $DB->query($sql); + } } } *************** *** 204,208 **** } ! if( $this->session_key == '' ) // If we don't have a session key by now, there isn't one saved. { $this->session_key = md5( uniqid (microtime(), 1) ); --- 212,216 ---- } ! if(empty($this->session_key)) // If we don't have a session key by now, there isn't one saved. { $this->session_key = md5( uniqid (microtime(), 1) ); *************** *** 234,238 **** { // We'll unset the cookie and continue on like nothing ever happened. ! setcookie($Config['cookie_name'] . '_auto', '', time() - 3600, $Config['cookie_path'], $Config['cookie_domain'], $Config['cookie_secure']); return false; $this->session_user_id = 1; --- 242,246 ---- { // We'll unset the cookie and continue on like nothing ever happened. ! setcookie($Config['cookie_name'] . '_auto', '', time() - 31536000, $Config['cookie_path'], $Config['cookie_domain'], $Config['cookie_secure']); return false; $this->session_user_id = 1; Index: template.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/template.php,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -r1.28 -r1.29 *** template.php 1 May 2003 21:59:30 -0000 1.28 --- template.php 2 May 2003 04:52:57 -0000 1.29 *************** *** 4,13 **** // This will utilize a flat-file template system. - include_once( C_PHPMP_ROOT . 'dba/' . DB_TYPE . '.dba' ); - $DB = new DB; - class template { - var $tplname, $tplvars; $tplvars = new array(); --- 4,9 ---- *************** *** 29,33 **** $this->tplvars = $DB->fetchArray($query); } - } --- 25,28 ---- |