[phpMP-CVS] CVS: phpMP/core main.php,NONE,1.1 admin.php,1.1,1.2 debug.php,1.2,1.3 functions.php,1.2,
Status: Pre-Alpha
Brought to you by:
heimidal
From: Brian R. <hei...@us...> - 2003-09-14 09:24:30
|
Update of /cvsroot/phpmp/phpMP/core In directory sc8-pr-cvs1:/tmp/cvs-serv4793/core Modified Files: admin.php debug.php functions.php language.php mpcode.php session.php template.php Added Files: main.php Removed Files: core.php Log Message: core/core.php has been moved to core/main.php. The Core class has been renamed to Portal. --- NEW FILE: main.php --- <?php /* * phpMP - The PHP Modular Portal System * Copyright (C) 2002-2003 Brian Rose and the phpMP group * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id: main.php,v 1.1 2003/09/14 09:24:25 heimidal Exp $ * */ class Portal // Does, literally, everything. { var $_cfgvars; /** * @return arr array * @param arr array * @desc Strips magic quotes from the * superglobal arrays. */ function strip_magic_quotes($arr) { foreach ($arr as $k => $v) { if (is_array($v)) { $arr[$k] = strip_magic_quotes($v); } else { $arr[$k] = stripslashes($v); } } return $arr; } /** * @return void * @param optional_files array * @desc Initiates all core components. */ function Core( $optional_files = array() ) { // The following code ensures that, no matter what, the dreaded // magic_quotes function will *never* mess with our data. // The addslashes() function *should* be used when necessary. // The stripslashes() function is worthless with these fixes in place. set_magic_quotes_runtime(0); if (get_magic_quotes_gpc()) { if (!empty($_GET)) { $_GET = $this->strip_magic_quotes($_GET); } if (!empty($_POST)) { $_POST = $this->strip_magic_quotes($_POST); } if (!empty($_COOKIE)) { $_COOKIE = $this->strip_magic_quotes($_COOKIE); } } error_reporting(E_ALL); //error_reporting(E_ERROR | E_WARNING | E_PARSE); $blah = include_once( C_PHPMP_ROOT . 'config.php' ); // Globalize all major class-containing variables. global $Debug, $DB, $User, $MPCode, $Template; include_once( C_PHPMP_ROOT . 'core/debug.php' ); $Debug = new Debug(); include_once( C_PHPMP_ROOT . 'core/dba/' . DB_TYPE . '.php' ); $DB = new sql_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(C_PHPMP_ROOT . 'core/config.init.php'); $this->_cfg_start(); include_once(C_PHPMP_ROOT . 'core/constants.php'); include_once(C_PHPMP_ROOT . 'core/functions.php'); include_once(C_PHPMP_ROOT . 'core/user.php'); $User = new User(); // Create an instance of User. create_vars(); include_once(C_PHPMP_ROOT . 'core/session.php'); $Session = new Session(); $Session->start(); $Session->run(); include_once(C_PHPMP_ROOT . 'core/language.php'); $Language = new Language(); include_once(C_PHPMP_ROOT . 'core/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(C_PHPMP_ROOT . 'core/' . $my_file . '.php'); $i++; } } include_once(C_PHPMP_ROOT . 'core/template.php'); $Template = new Template(); if( $User->get('template') == false ) { $Config->set('template', $Config->get('default_tpl')); } else { $Config->set('template', $User->get('template')); } $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: admin.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/core/admin.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** admin.php 14 Sep 2003 06:37:52 -0000 1.1 --- admin.php 14 Sep 2003 09:24:25 -0000 1.2 *************** *** 108,112 **** if (C_USE_PORTAL_PERMS == 1) { $checked = "CHECKED"; } else { $checked = ""; } print "<input type=\"checkbox\" name=\"portperms\" value=\"1\" " . $checked . "> Use Portal Permissions?<br>"; ! print "<input type=\"submit\" name=\"submit_general\" value=\"Submit Configuration\">"; print "</form>"; } --- 108,112 ---- if (C_USE_PORTAL_PERMS == 1) { $checked = "CHECKED"; } else { $checked = ""; } print "<input type=\"checkbox\" name=\"portperms\" value=\"1\" " . $checked . "> Use Portal Permissions?<br>"; ! print "<input type=\"submit\" name=\"submit_general\" value=\"Submit Portaluration\">"; print "</form>"; } Index: debug.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/core/debug.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** debug.php 14 Sep 2003 07:02:10 -0000 1.2 --- debug.php 14 Sep 2003 09:24:25 -0000 1.3 *************** *** 46,50 **** function msg_display($errno, $msg_text, $errfile, $errline) { ! global $DB, $Core, $User, $Template; switch($errno) --- 46,50 ---- function msg_display($errno, $msg_text, $errfile, $errline) { ! global $DB, $Portal, $User, $Template; switch($errno) *************** *** 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; } --- 66,70 ---- case E_USER_NOTICE: ! echo "A User Notice has been issued. Please notify the <a href=\"mailto: " . $Portal['site_contact'] . "\">board administrator</a>."; break; } Index: functions.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/core/functions.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** functions.php 14 Sep 2003 07:02:10 -0000 1.2 --- functions.php 14 Sep 2003 09:24:25 -0000 1.3 *************** *** 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. } --- 29,36 ---- function create_vars() { ! global $Portal, $User; ! ( $User->get('date_format') != '' ) ? ($Portal->set('date_format', $User->get('date_format'))) : ($Portal->set('date_format', $Portal->get('default_date_format'))); ! $Portal->set('time_now', date( $Portal->get('date_format') ) ); // This is here...for now. } Index: language.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/core/language.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** language.php 14 Sep 2003 07:02:10 -0000 1.2 --- language.php 14 Sep 2003 09:24:25 -0000 1.3 *************** *** 33,39 **** function Language() { ! global $Core, $User, $Local; ! $cfg_lang = $Core->get('default_lang'); $usr_lang = $User->get('language'); $lang = ''; --- 33,39 ---- function Language() { ! global $Portal, $User, $Local; ! $cfg_lang = $Portal->get('default_lang'); $usr_lang = $User->get('language'); $lang = ''; *************** *** 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'; --- 41,45 ---- (empty($usr_lang)) ? $lang = $cfg_lang : $lang = $usr_lang; ! $Portal->set('language', $lang); $lang_file = C_PHPMP_ROOT . 'languages/' . $lang . '/lang_main.php'; Index: mpcode.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/core/mpcode.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** mpcode.php 14 Sep 2003 06:37:52 -0000 1.1 --- mpcode.php 14 Sep 2003 09:24:25 -0000 1.2 *************** *** 49,53 **** // This may not be the best way, but it works function _replace($string) { ! include (C_PHPMP_ROOT . "includes/mpcode_arrays.php"); foreach ($mpcode as $key => $code) { --- 49,53 ---- // This may not be the best way, but it works function _replace($string) { ! include (C_PHPMP_ROOT . "core/mpcode_arrays.php"); foreach ($mpcode as $key => $code) { Index: session.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/core/session.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** session.php 14 Sep 2003 07:02:10 -0000 1.2 --- session.php 14 Sep 2003 09:24:25 -0000 1.3 *************** *** 57,63 **** function destroy() { ! global $DB, $Core, $SID; ! $exp_time = time() + $Core->get('session_length'); $this->page = basename($_SERVER['REQUEST_URI']); --- 57,63 ---- function destroy() { ! global $DB, $Portal, $SID; ! $exp_time = time() + $Portal->get('session_length'); $this->page = basename($_SERVER['REQUEST_URI']); *************** *** 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); } --- 74,81 ---- $this->session_user_id = ANONYMOUS; ! setcookie($Portal->get('cookie_name') . '_auto', '', time() - 31536000, $Portal->get('cookie_path'), $Portal->get('cookie_domain'), $Portal->get('cookie_secure')); $cookie_data = urlencode( ANONYMOUS . ':' . $this->session_key ); ! (setcookie($Portal->get('cookie_name') . '_data', $cookie_data, $cur_time + $Portal->get('session_length'), $Portal->get('cookie_path'), $Portal->get('cookie_domain'), $Portal->get('cookie_secure'))) ? ($SID = "?sid=") : ($SID = "?sid=" . $this->session_key); } *************** *** 86,90 **** function login() { ! global $User, $DB, $Core; $this->do_login == true; --- 86,90 ---- function login() { ! global $User, $DB, $Portal; $this->do_login == true; *************** *** 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')); } } --- 116,120 ---- { $auto_cookie_data = urlencode( $this->session_user_id . ':' . $passwd_enc . ':' . $User->get('invisible_mode') ); ! setcookie($Portal->get('cookie_name') . '_auto', $auto_cookie_data, time() + 31536000, $Portal->get('cookie_path'), $Portal->get('cookie_domain'), $Portal->get('cookie_secure')); } } *************** *** 131,135 **** function run() { ! global $User, $DB, $Core, $SID; if( isset($_POST['do_login']) && ($_POST['do_login'] == true) ) --- 131,135 ---- function run() { ! global $User, $DB, $Portal, $SID; if( isset($_POST['do_login']) && ($_POST['do_login'] == true) ) *************** *** 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. --- 149,153 ---- $cur_time = time(); // Time as of right now. ! $exp_time = $cur_time + $Portal->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($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(); } --- 219,223 ---- $cookie_data = urlencode( $this->session_user_id . ':' . $this->session_key ); ! (setcookie($Portal->get('cookie_name') . '_data', $cookie_data, $cur_time + $Portal->get('session_length'), $Portal->get('cookie_path'), $Portal->get('cookie_domain'), $Portal->get('cookie_secure'))) ? ($SID = "?sid=") : ($SID = "?sid=" . $this->session_key); $this->clean(); } *************** *** 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 ) ); --- 254,263 ---- function get_session_data() { ! global $Portal, $DB, $User; // Let's see if we have a standard cookie available. ! if(!empty($_COOKIE[$Portal->get('cookie_name') . '_data'])) { ! $cookie_data = $_COOKIE[$Portal->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[$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 ) ); --- 284,290 ---- if( ($this->session_user_id == ANONYMOUS) || empty($this->session_user_id) ) { ! if( !empty( $_COOKIE[$Portal->get('cookie_name') . '_auto'] ) ) // We have an autologin cookie set. { ! $auto_cookie_data = $_COOKIE[$Portal->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($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; --- 306,310 ---- { // We'll unset the cookie and continue on like nothing ever happened. ! setcookie($Portal->get('cookie_name') . '_auto', '', time() - 31536000, $Portal->get('cookie_path'), $Portal->get('cookie_domain'), $Portal->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.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** template.php 14 Sep 2003 07:02:10 -0000 1.2 --- template.php 14 Sep 2003 09:24:25 -0000 1.3 *************** *** 119,123 **** function display($handle) { ! global $Core, $Local; if ($filename = $this->_tpl_load($handle)) --- 119,123 ---- function display($handle) { ! global $Portal, $Local; if ($filename = $this->_tpl_load($handle)) *************** *** 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 --- 136,142 ---- function _tpl_load(&$handle) { ! global $Portal, $user; ! $filename = $this->cachedir . $this->filename[$handle] . '.' . (($this->static_lang) ? $Portal->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, $Core, $Local; $handle = $filename; --- 231,235 ---- function _tpl_include($filename, $include = true) { ! global $user, $Portal, $Local; $handle = $filename; *************** *** 257,261 **** function compile($code, $no_echo = false, $echo_var = '') { ! global $Core; error_reporting(E_ERROR | E_WARNING | E_PARSE); --- 257,261 ---- function compile($code, $no_echo = false, $echo_var = '') { ! global $Portal; error_reporting(E_ERROR | E_WARNING | E_PARSE); *************** *** 334,338 **** case 'INCLUDEPHP': ! if ($Core->get('tpl_php')) { $temp = ''; --- 334,338 ---- case 'INCLUDEPHP': ! if ($Portal->get('tpl_php')) { $temp = ''; *************** *** 343,347 **** case 'PHP': ! if ($Core->get('tpl_php')) { $temp = ''; --- 343,347 ---- case 'PHP': ! if ($Portal->get('tpl_php')) { $temp = ''; *************** *** 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+')) --- 695,701 ---- function compile_write(&$handle, $data) { ! global $user, $Portal; ! $filename = $this->cachedir . $this->filename[$handle] . '.' . (($this->static_lang) ? $Portal->get('language') . '.' : '') . 'php'; if ($fp = @fopen($filename, 'w+')) --- core.php DELETED --- |