[phpMP-CVS] CVS: phpMP/includes config.init.php,NONE,1.1 core.php,1.53,1.54
Status: Pre-Alpha
Brought to you by:
heimidal
From: Brian R. <hei...@us...> - 2003-05-17 07:00:42
|
Update of /cvsroot/phpmp/phpMP/includes In directory sc8-pr-cvs1:/tmp/cvs-serv14768 Modified Files: core.php Added Files: config.init.php Log Message: Moved the Config class to its own file. --- NEW FILE: config.init.php --- <?php class Config { var $_cfgvars; function Config() { 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->fetchArray( $result ) ) { $this->_cfgvars[$row['config_key']] = $row['config_value']; } } function set($cfgkey, $cfgval) { if( (!empty($cfgkey)) && (eregi('^[a-z]+[_a-z0-9-]*$', $cfgkey)) && (!empty($cfgval)) ) { $this->_cfgvars[strtolower($cfgkey)] = $cfgval; return true; } else { return false; } } function get($cfgkey) { if( !empty($this->_cfgvars[strtolower($cfgkey)]) ) { return $this->_cfgvars[strtolower($cfgkey)]; } else { return false; } } } ?> Index: core.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/core.php,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -r1.53 -r1.54 *** core.php 14 May 2003 06:26:09 -0000 1.53 --- core.php 17 May 2003 07:00:39 -0000 1.54 *************** *** 1,152 **** ! <?php ! ! class Core // Does, literally, everything. ! { ! ! function stripMagicQuotes($arr) ! { ! foreach ($arr as $k => $v) ! { ! if (is_array($v)) ! { ! $arr[$k] = strip_magic_quotes($v); ! } ! else ! { ! $arr[$k] = stripslashes($v); ! } ! } ! ! return $arr; ! } ! ! // Initiates all core components. ! // Author: Brian 'Heimidal' Rose ! // Accepts: $optional_files (string of needed files separated by commas). ! // Returns: none. ! function Core( $optional_files = array() ) ! { ! set_magic_quotes_runtime(0); ! if (get_magic_quotes_gpc()) ! { ! if (!empty($_GET)) { $_GET = $this->stripMagicQuotes($_GET); } ! if (!empty($_POST)) { $_POST = $this->stripMagicQuotes($_POST); } ! if (!empty($_COOKIE)) { $_COOKIE = $this->stripMagicQuotes($_COOKIE); } ! } ! ! if( !defined("PHPMP_ROOT") ) ! { ! define( 'PHPMP_ROOT', './' ); ! } ! ! error_reporting(E_ERROR | E_WARNING | E_PARSE); ! //error_reporting(E_ALL); ! ! include_once( PHPMP_ROOT . 'config.php' ); ! ! // Globalize all major class-containing variables. ! global $Config, $Debug, $DB, $User, $MPCode, $Template; ! ! include_once( PHPMP_ROOT . 'includes/debug.php' ); ! $Debug = new Debug(); ! ! set_error_handler(array('Debug', 'msgDisplay')); ! ! include_once( PHPMP_ROOT . 'dba/' . DB_TYPE . '.dba' ); ! $DB = new DB(); ! $DB->connect(); ! ! define("DB_CONFIG_TABLE", DB_NAME . '.' . DB_TABLE_PREFIX . 'config'); ! define("DB_USERS_TABLE", DB_NAME . '.' . DB_TABLE_PREFIX . 'users'); ! define("DB_SESSIONS_TABLE", DB_NAME . '.' . DB_TABLE_PREFIX . 'sessions'); ! define("DB_MODULES_TABLE", DB_NAME . '.' . DB_TABLE_PREFIX . 'modules'); ! define("DB_BLOCK_TABLE", DB_NAME . '.' . DB_TABLE_PREFIX . 'blocks'); ! define("DB_TEMPLATE_VARS_TABLE", DB_NAME . '.' . DB_TABLE_PREFIX . 'template_vars'); ! ! $Config = new Config(); ! ! include_once(PHPMP_ROOT . 'includes/constants.php'); ! ! include_once(PHPMP_ROOT . 'includes/functions.php'); ! ! include_once(PHPMP_ROOT . 'includes/user.php'); ! $User = new User(); // Create an instance of User. ! ! createVars(); ! ! include_once(PHPMP_ROOT . 'includes/session.php'); ! $Session = new Session(); ! ! $Session->start(); ! $Session->run(); ! ! include_once(PHPMP_ROOT . 'includes/language.php'); ! $Language = new Language(); ! ! include_once(PHPMP_ROOT . 'includes/mpcode.php'); ! ! // 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++; ! } ! } ! ! //include_once(PHPMP_ROOT . 'includes/Smarty.class.php'); ! include_once(PHPMP_ROOT . 'includes/template.php'); ! $Template = new Template($Session->page); // Create an instance of Template. ! ! $DB->close(); ! } ! } ! ! class Config ! { ! var $_cfgvars; ! ! function Config() ! { ! 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->fetchArray( $result ) ) ! { ! $this->_cfgvars[$row['config_key']] = $row['config_value']; ! } ! } ! ! function set($cfgkey, $cfgval) ! { ! if( (!empty($cfgkey)) && (eregi('^[a-z]+[_a-z0-9-]*$', $cfgkey)) && (!empty($cfgval)) ) ! { ! $this->_cfgvars[strtolower($cfgkey)] = $cfgval; ! return true; ! } ! else ! { ! return false; ! } ! } ! ! function get($cfgkey) ! { ! if( !empty($this->_cfgvars[strtolower($cfgkey)]) ) ! { ! return $this->_cfgvars[strtolower($cfgkey)]; ! } ! else ! { ! return false; ! } ! } ! } ! ?> --- 1,109 ---- ! <?php ! ! class Core // Does, literally, everything. ! { ! ! function stripMagicQuotes($arr) ! { ! foreach ($arr as $k => $v) ! { ! if (is_array($v)) ! { ! $arr[$k] = strip_magic_quotes($v); ! } ! else ! { ! $arr[$k] = stripslashes($v); ! } ! } ! ! return $arr; ! } ! ! // Initiates all core components. ! // Author: Brian 'Heimidal' Rose ! // Accepts: $optional_files (string of needed files separated by commas). ! // Returns: none. ! function Core( $optional_files = array() ) ! { ! set_magic_quotes_runtime(0); ! if (get_magic_quotes_gpc()) ! { ! if (!empty($_GET)) { $_GET = $this->stripMagicQuotes($_GET); } ! if (!empty($_POST)) { $_POST = $this->stripMagicQuotes($_POST); } ! if (!empty($_COOKIE)) { $_COOKIE = $this->stripMagicQuotes($_COOKIE); } ! } ! ! if( !defined("PHPMP_ROOT") ) ! { ! define( 'PHPMP_ROOT', './' ); ! } ! ! error_reporting(E_ERROR | E_WARNING | E_PARSE); ! //error_reporting(E_ALL); ! ! include_once( PHPMP_ROOT . 'config.php' ); ! ! // Globalize all major class-containing variables. ! global $Config, $Debug, $DB, $User, $MPCode, $Template; ! ! include_once( PHPMP_ROOT . 'includes/debug.php' ); ! $Debug = new Debug(); ! ! set_error_handler(array('Debug', 'msgDisplay')); ! ! include_once( PHPMP_ROOT . 'dba/' . DB_TYPE . '.dba' ); ! $DB = new DB(); ! $DB->connect(); ! ! define("DB_CONFIG_TABLE", DB_NAME . '.' . DB_TABLE_PREFIX . 'config'); ! define("DB_USERS_TABLE", DB_NAME . '.' . DB_TABLE_PREFIX . 'users'); ! define("DB_SESSIONS_TABLE", DB_NAME . '.' . DB_TABLE_PREFIX . 'sessions'); ! define("DB_MODULES_TABLE", DB_NAME . '.' . DB_TABLE_PREFIX . 'modules'); ! define("DB_BLOCK_TABLE", DB_NAME . '.' . DB_TABLE_PREFIX . 'blocks'); ! define("DB_TEMPLATE_VARS_TABLE", DB_NAME . '.' . DB_TABLE_PREFIX . 'template_vars'); ! ! include_once(PHPMP_ROOT . 'includes/config.init.php'); ! $Config = new Config(); ! ! include_once(PHPMP_ROOT . 'includes/constants.php'); ! ! include_once(PHPMP_ROOT . 'includes/functions.php'); ! ! include_once(PHPMP_ROOT . 'includes/user.php'); ! $User = new User(); // Create an instance of User. ! ! createVars(); ! ! include_once(PHPMP_ROOT . 'includes/session.php'); ! $Session = new Session(); ! ! $Session->start(); ! $Session->run(); ! ! include_once(PHPMP_ROOT . 'includes/language.php'); ! $Language = new Language(); ! ! include_once(PHPMP_ROOT . 'includes/mpcode.php'); ! ! // 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++; ! } ! } ! ! //include_once(PHPMP_ROOT . 'includes/Smarty.class.php'); ! include_once(PHPMP_ROOT . 'includes/template.php'); ! $Template = new Template($Session->page); // Create an instance of Template. ! ! $DB->close(); ! } ! } ! ?> |