Thread: [phpMP-CVS] CVS: phpMP/core core.php,1.1,1.2 debug.php,1.1,1.2 functions.php,1.1,1.2 language.php,1.
Status: Pre-Alpha
Brought to you by:
heimidal
From: Brian R. <hei...@us...> - 2003-09-14 07:02:14
|
Update of /cvsroot/phpmp/phpMP/core In directory sc8-pr-cvs1:/tmp/cvs-serv14633/core Modified Files: core.php debug.php functions.php language.php session.php template.php Removed Files: config.init.php Log Message: Consolidated the Config class into the Core class Index: core.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/core/core.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** core.php 14 Sep 2003 06:37:52 -0000 1.1 --- core.php 14 Sep 2003 07:02:10 -0000 1.2 *************** *** 26,29 **** --- 26,31 ---- { + var $_cfgvars; + /** * @return arr array *************** *** 74,78 **** // Globalize all major class-containing variables. ! global $Config, $Debug, $DB, $User, $MPCode, $Template; include_once( C_PHPMP_ROOT . 'includes/debug.php' ); --- 76,80 ---- // Globalize all major class-containing variables. ! global $Debug, $DB, $User, $MPCode, $Template; include_once( C_PHPMP_ROOT . 'includes/debug.php' ); *************** *** 91,95 **** include_once(C_PHPMP_ROOT . 'includes/config.init.php'); ! $Config = new Config(); include_once(C_PHPMP_ROOT . 'includes/constants.php'); --- 93,97 ---- include_once(C_PHPMP_ROOT . 'includes/config.init.php'); ! $this->_cfg_start(); include_once(C_PHPMP_ROOT . 'includes/constants.php'); *************** *** 139,142 **** --- 141,198 ---- $Template->set_template( $Config->get('template'), false, true ); $DB->close(); + } + + /** + * @return void + * @desc Fetches Config vars. + */ + function _cfg_start() + { + global $DB; + + $result = $DB->query( "SELECT * FROM " . DB_CONFIG_TABLE ); + + // Loop through all config values from DB. + // Define each key as its respective value. + while( $row = $DB->fetch_array( $result ) ) + { + $this->_cfgvars[$row['config_key']] = $row['config_value']; + } + } + + /** + * @return unknown + * @param cfgkey unknown + * @param cfgval unknown + * @desc Inserts the value of a given key into the Config array. + */ + function cfg_set($cfgkey, $cfgval) + { + if( (!empty($cfgkey)) && (preg_match('/^[a-z][a-z0-9_-]+/', $cfgkey)) && (!empty($cfgval)) ) + { + $this->_cfgvars[$cfgkey] = $cfgval; + return true; + } + else + { + return false; + } + } + + /** + * @return unknown + * @param cfgkey unknown + * @desc Fetches config array values. + */ + function cfg_get($cfgkey) + { + if( !empty($this->_cfgvars[$cfgkey]) ) + { + return $this->_cfgvars[$cfgkey]; + } + else + { + return false; + } } } Index: debug.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/core/debug.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** debug.php 14 Sep 2003 06:37:52 -0000 1.1 --- debug.php 14 Sep 2003 07:02:10 -0000 1.2 *************** *** 46,50 **** function msg_display($errno, $msg_text, $errfile, $errline) { ! global $DB, $Config, $User, $Template; switch($errno) --- 46,50 ---- function msg_display($errno, $msg_text, $errfile, $errline) { ! global $DB, $Core, $User, $Template; switch($errno) *************** *** 66,70 **** case E_USER_NOTICE: ! echo "A User Notice has been issued. Please notify the <a href=\"mailto: " . $Config['site_contact'] . "\">board administrator</a>."; break; } --- 66,70 ---- case E_USER_NOTICE: ! echo "A User Notice has been issued. Please notify the <a href=\"mailto: " . $Core['site_contact'] . "\">board administrator</a>."; break; } Index: functions.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/core/functions.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** functions.php 14 Sep 2003 06:37:52 -0000 1.1 --- functions.php 14 Sep 2003 07:02:10 -0000 1.2 *************** *** 29,36 **** function create_vars() { ! global $Config, $User; ! ( $User->get('date_format') != '' ) ? ($Config->set('date_format', $User->get('date_format'))) : ($Config->set('date_format', $Config->get('default_date_format'))); ! $Config->set('time_now', date( $Config->get('date_format') ) ); // This is here...for now. } --- 29,36 ---- function create_vars() { ! global $Core, $User; ! ( $User->get('date_format') != '' ) ? ($Core->set('date_format', $User->get('date_format'))) : ($Core->set('date_format', $Core->get('default_date_format'))); ! $Core->set('time_now', date( $Core->get('date_format') ) ); // This is here...for now. } Index: language.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/core/language.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** language.php 14 Sep 2003 06:37:52 -0000 1.1 --- language.php 14 Sep 2003 07:02:10 -0000 1.2 *************** *** 33,39 **** function Language() { ! global $Config, $User, $Local; ! $cfg_lang = $Config->get('default_lang'); $usr_lang = $User->get('language'); $lang = ''; --- 33,39 ---- function Language() { ! global $Core, $User, $Local; ! $cfg_lang = $Core->get('default_lang'); $usr_lang = $User->get('language'); $lang = ''; *************** *** 41,45 **** (empty($usr_lang)) ? $lang = $cfg_lang : $lang = $usr_lang; ! $Config->set('language', $lang); $lang_file = C_PHPMP_ROOT . 'languages/' . $lang . '/lang_main.php'; --- 41,45 ---- (empty($usr_lang)) ? $lang = $cfg_lang : $lang = $usr_lang; ! $Core->set('language', $lang); $lang_file = C_PHPMP_ROOT . 'languages/' . $lang . '/lang_main.php'; Index: session.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/core/session.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** session.php 14 Sep 2003 06:37:52 -0000 1.1 --- session.php 14 Sep 2003 07:02:10 -0000 1.2 *************** *** 57,63 **** function destroy() { ! global $DB, $Config, $SID; ! $exp_time = time() + $Config->get('session_length'); $this->page = basename($_SERVER['REQUEST_URI']); --- 57,63 ---- function destroy() { ! global $DB, $Core, $SID; ! $exp_time = time() + $Core->get('session_length'); $this->page = basename($_SERVER['REQUEST_URI']); *************** *** 74,81 **** $this->session_user_id = ANONYMOUS; ! setcookie($Config->get('cookie_name') . '_auto', '', time() - 31536000, $Config->get('cookie_path'), $Config->get('cookie_domain'), $Config->get('cookie_secure')); $cookie_data = urlencode( ANONYMOUS . ':' . $this->session_key ); ! (setcookie($Config->get('cookie_name') . '_data', $cookie_data, $cur_time + $Config->get('session_length'), $Config->get('cookie_path'), $Config->get('cookie_domain'), $Config->get('cookie_secure'))) ? ($SID = "?sid=") : ($SID = "?sid=" . $this->session_key); } --- 74,81 ---- $this->session_user_id = ANONYMOUS; ! setcookie($Core->get('cookie_name') . '_auto', '', time() - 31536000, $Core->get('cookie_path'), $Core->get('cookie_domain'), $Core->get('cookie_secure')); $cookie_data = urlencode( ANONYMOUS . ':' . $this->session_key ); ! (setcookie($Core->get('cookie_name') . '_data', $cookie_data, $cur_time + $Core->get('session_length'), $Core->get('cookie_path'), $Core->get('cookie_domain'), $Core->get('cookie_secure'))) ? ($SID = "?sid=") : ($SID = "?sid=" . $this->session_key); } *************** *** 86,90 **** function login() { ! global $User, $DB, $Config; $this->do_login == true; --- 86,90 ---- function login() { ! global $User, $DB, $Core; $this->do_login == true; *************** *** 116,120 **** { $auto_cookie_data = urlencode( $this->session_user_id . ':' . $passwd_enc . ':' . $User->get('invisible_mode') ); ! setcookie($Config->get('cookie_name') . '_auto', $auto_cookie_data, time() + 31536000, $Config->get('cookie_path'), $Config->get('cookie_domain'), $Config->get('cookie_secure')); } } --- 116,120 ---- { $auto_cookie_data = urlencode( $this->session_user_id . ':' . $passwd_enc . ':' . $User->get('invisible_mode') ); ! setcookie($Core->get('cookie_name') . '_auto', $auto_cookie_data, time() + 31536000, $Core->get('cookie_path'), $Core->get('cookie_domain'), $Core->get('cookie_secure')); } } *************** *** 131,135 **** function run() { ! global $User, $DB, $Config, $SID; if( isset($_POST['do_login']) && ($_POST['do_login'] == true) ) --- 131,135 ---- function run() { ! global $User, $DB, $Core, $SID; if( isset($_POST['do_login']) && ($_POST['do_login'] == true) ) *************** *** 149,153 **** $cur_time = time(); // Time as of right now. ! $exp_time = $cur_time + $Config->get('session_length'); // Time at which this session will become invalid. $this->ip = $User->get_ip_encoded(); // Gets the user's IP address. --- 149,153 ---- $cur_time = time(); // Time as of right now. ! $exp_time = $cur_time + $Core->get('session_length'); // Time at which this session will become invalid. $this->ip = $User->get_ip_encoded(); // Gets the user's IP address. *************** *** 219,223 **** $cookie_data = urlencode( $this->session_user_id . ':' . $this->session_key ); ! (setcookie($Config->get('cookie_name') . '_data', $cookie_data, $cur_time + $Config->get('session_length'), $Config->get('cookie_path'), $Config->get('cookie_domain'), $Config->get('cookie_secure'))) ? ($SID = "?sid=") : ($SID = "?sid=" . $this->session_key); $this->clean(); } --- 219,223 ---- $cookie_data = urlencode( $this->session_user_id . ':' . $this->session_key ); ! (setcookie($Core->get('cookie_name') . '_data', $cookie_data, $cur_time + $Core->get('session_length'), $Core->get('cookie_path'), $Core->get('cookie_domain'), $Core->get('cookie_secure'))) ? ($SID = "?sid=") : ($SID = "?sid=" . $this->session_key); $this->clean(); } *************** *** 254,263 **** function get_session_data() { ! global $Config, $DB, $User; // Let's see if we have a standard cookie available. ! if(!empty($_COOKIE[$Config->get('cookie_name') . '_data'])) { ! $cookie_data = $_COOKIE[$Config->get('cookie_name') . '_data']; $cookie_array = explode(':', urldecode( $cookie_data ) ); --- 254,263 ---- function get_session_data() { ! global $Core, $DB, $User; // Let's see if we have a standard cookie available. ! if(!empty($_COOKIE[$Core->get('cookie_name') . '_data'])) { ! $cookie_data = $_COOKIE[$Core->get('cookie_name') . '_data']; $cookie_array = explode(':', urldecode( $cookie_data ) ); *************** *** 284,290 **** if( ($this->session_user_id == ANONYMOUS) || empty($this->session_user_id) ) { ! if( !empty( $_COOKIE[$Config->get('cookie_name') . '_auto'] ) ) // We have an autologin cookie set. { ! $auto_cookie_data = $_COOKIE[$Config->get('cookie_name') . '_auto']; $auto_cookie_array = explode(':', urldecode( $auto_cookie_data ) ); --- 284,290 ---- if( ($this->session_user_id == ANONYMOUS) || empty($this->session_user_id) ) { ! if( !empty( $_COOKIE[$Core->get('cookie_name') . '_auto'] ) ) // We have an autologin cookie set. { ! $auto_cookie_data = $_COOKIE[$Core->get('cookie_name') . '_auto']; $auto_cookie_array = explode(':', urldecode( $auto_cookie_data ) ); *************** *** 306,310 **** { // We'll unset the cookie and continue on like nothing ever happened. ! setcookie($Config->get('cookie_name') . '_auto', '', time() - 31536000, $Config->get('cookie_path'), $Config->get('cookie_domain'), $Config->get('cookie_secure')); return false; $this->session_user_id = ANONYMOUS; --- 306,310 ---- { // We'll unset the cookie and continue on like nothing ever happened. ! setcookie($Core->get('cookie_name') . '_auto', '', time() - 31536000, $Core->get('cookie_path'), $Core->get('cookie_domain'), $Core->get('cookie_secure')); return false; $this->session_user_id = ANONYMOUS; Index: template.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/core/template.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** template.php 14 Sep 2003 06:37:52 -0000 1.1 --- template.php 14 Sep 2003 07:02:10 -0000 1.2 *************** *** 119,123 **** function display($handle) { ! global $Config, $Local; if ($filename = $this->_tpl_load($handle)) --- 119,123 ---- function display($handle) { ! global $Core, $Local; if ($filename = $this->_tpl_load($handle)) *************** *** 136,142 **** function _tpl_load(&$handle) { ! global $Config, $user; ! $filename = $this->cachedir . $this->filename[$handle] . '.' . (($this->static_lang) ? $Config->get('language') . '.' : '') . 'php'; // Recompile page if the original template is newer, otherwise load the compiled version --- 136,142 ---- function _tpl_load(&$handle) { ! global $Core, $user; ! $filename = $this->cachedir . $this->filename[$handle] . '.' . (($this->static_lang) ? $Core->get('language') . '.' : '') . 'php'; // Recompile page if the original template is newer, otherwise load the compiled version *************** *** 231,235 **** function _tpl_include($filename, $include = true) { ! global $user, $Config, $Local; $handle = $filename; --- 231,235 ---- function _tpl_include($filename, $include = true) { ! global $user, $Core, $Local; $handle = $filename; *************** *** 257,261 **** function compile($code, $no_echo = false, $echo_var = '') { ! global $Config; error_reporting(E_ERROR | E_WARNING | E_PARSE); --- 257,261 ---- function compile($code, $no_echo = false, $echo_var = '') { ! global $Core; error_reporting(E_ERROR | E_WARNING | E_PARSE); *************** *** 334,338 **** case 'INCLUDEPHP': ! if ($Config->get('tpl_php')) { $temp = ''; --- 334,338 ---- case 'INCLUDEPHP': ! if ($Core->get('tpl_php')) { $temp = ''; *************** *** 343,347 **** case 'PHP': ! if ($Config->get('tpl_php')) { $temp = ''; --- 343,347 ---- case 'PHP': ! if ($Core->get('tpl_php')) { $temp = ''; *************** *** 695,701 **** function compile_write(&$handle, $data) { ! global $user, $Config; ! $filename = $this->cachedir . $this->filename[$handle] . '.' . (($this->static_lang) ? $Config->get('language') . '.' : '') . 'php'; if ($fp = @fopen($filename, 'w+')) --- 695,701 ---- function compile_write(&$handle, $data) { ! global $user, $Core; ! $filename = $this->cachedir . $this->filename[$handle] . '.' . (($this->static_lang) ? $Core->get('language') . '.' : '') . 'php'; if ($fp = @fopen($filename, 'w+')) --- config.init.php DELETED --- |