[phpMP-CVS] CVS: phpMP/includes core.php,1.27,1.28
Status: Pre-Alpha
Brought to you by:
heimidal
From: Brian R. <hei...@us...> - 2002-11-30 05:55:09
|
Update of /cvsroot/phpmp/phpMP/includes In directory sc8-pr-cvs1:/tmp/cvs-serv19720 Modified Files: core.php Log Message: Restructured the way we're handling loading of files and how we'll decide what to load and when. Index: core.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/core.php,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -r1.27 -r1.28 *** core.php 6 Nov 2002 03:28:19 -0000 1.27 --- core.php 30 Nov 2002 05:55:04 -0000 1.28 *************** *** 1,5 **** <? ! class Core ## Does, literally, everything. { --- 1,5 ---- <? ! class Core // Does, literally, everything. { *************** *** 10,92 **** function _initConfig () { ! ! global $DB; ## Globalize DB class. ! $sql = "SELECT * FROM " . CONFIG_TABLE; ! $result = $DBA->query( $sql ); ! ! ## Loop through all config values from DB. ! ## Define each key as its respective value. while( $row = $DB->fetch_array( $result ) ) { ! define( $row['key'], $row['value'] ); } ! } ! // Initiates all core components. // Author: Brian 'Heimidal' Rose ! // Accepts: $required_files (string of needed files separated by commas). // Returns: none. function init ( $optional_files = array() ) { ! ! ## First, we'll create an array of files that must ! ## be loaded for any instance of the portal. We'll ! ## call this array '$required_files'. ! $required_files[] = 'debug'; ! $required_files[] = 'constants'; ! $required_files[] = 'functions'; ! $required_files[] = 'auth'; ! $required_files[] = 'parser'; ! $required_files[] = 'Smarty.class'; ! $required_files[] = 'template'; ! ! ## Next, we'll merge the $required_files array with ! ## the $optional_files array, allowing us to include ! ## all files that may be needed. ! $file_array = array_merge_recursive( $required_array, $optional_files ); ! ! ## This while() statement will loop through the ! ## $file_array and include each file. $i = 0; ! while( $my_file = $file_array[$i] ) { ! ! ## We'll use include_once() in order to keep from ! ## including a file more than once (through ! ## malicious or accidental coding of a page). include_once('./includes/' . $my_file . '.php'); $i++; ! } ! ! ## Globalize all major class-containing variables. global $Debug, $DB, $Auth, $Language, $Parser, $Template; ! ! ## Create an instance of the Debug interface. ! $Debug = new Debug(); ! ! ## We should add initialization function calls later ! ## when they're written. ! ! include_once('./dba/' . DB_TYPE . '.dba'); ## Include DBA layer. ! ! $DB = new DBA(); ## Create an instance of DBA. ! $DBA->connect; ## Connect to the specified SQL system. ! ! $this->_initConfig(); ## Grab DB-stored config values. ! ! $Auth = new Auth(); ## Create an instance of Auth. ! ! $Language = new Language(); ## Create an instance of Language. ! ! $Parser = new Parser(); ## Create an instance of Parser. ! ! $Template = new Template(); ## Create an instance of Template. ! } ! } ! ?> \ No newline at end of file --- 10,80 ---- function _initConfig () { ! ! global $DB; // Globalize DB class. ! $sql = "SELECT * FROM " . CONFIG_TABLE; ! $result = $DB->query( $sql ); ! ! // Loop through all config values from DB. ! // Define each key as its respective value. while( $row = $DB->fetch_array( $result ) ) { ! define( str_to_uppoer($row['key']), $row['value'] ); } ! } ! // Initiates all core components. // Author: Brian 'Heimidal' Rose ! // Accepts: $optional_files (string of needed files separated by commas). // Returns: none. function init ( $optional_files = array() ) { ! include_once('./config.php'); ! ! include_once('./includes/debug.php'); ! $Debug = new Debug(); ! ! include_once( './dba/' . DB_TYPE . '.dba' ); ! $DB = new DB(); ! $DB->connect; ! ! $this->_initConfig(); // Grab DB-stored config values. ! ! include_once('./includes/auth.php'); ! $Auth = new Auth(); // Create an instance of Auth. ! ! include_once('./includes/language.php'); ! ! include_once('./includes/constants.php'); ! ! include_once('./includes/functions.php'); ! ! include_once('./includes/parser.php'); ! ! // This while() statement will loop through the ! // $optional_files and include each file. $i = 0; ! while( $my_file = $optional_files[$i] ) { ! ! // We'll use include_once() in order to keep from ! // including a file more than once (through ! // malicious or accidental coding of a page). include_once('./includes/' . $my_file . '.php'); $i++; ! } ! ! include_once('./includes/Smarty.class.php'); ! include_once('./includes/template.php'); ! $Template = new Template(); // Create an instance of Template. ! ! // Globalize all major class-containing variables. global $Debug, $DB, $Auth, $Language, $Parser, $Template; ! } ! } ! ?> |