[phpMP-CVS] CVS: phpMP/includes Config_File.class.php,1.1,1.2 Smarty.class.php,1.1,1.2 Smarty_Compil
Status: Pre-Alpha
Brought to you by:
heimidal
From: Brian R. <hei...@us...> - 2002-08-14 17:44:10
|
Update of /cvsroot/phpmp/phpMP/includes In directory usw-pr-cvs1:/tmp/cvs-serv26026/includes Modified Files: Config_File.class.php Smarty.class.php Smarty_Compiler.class.php auth.php Log Message: Upgraded Smarty template engine to 2.3.0. Fixed small online users problem (again) and changed all HTTP______VARS calls in auth to _POST or the like. Index: Config_File.class.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/Config_File.class.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** Config_File.class.php 25 Jul 2002 11:06:25 -0000 1.1 --- Config_File.class.php 14 Aug 2002 17:44:06 -0000 1.2 *************** *** 4,8 **** * Config_File class. * ! * @version 2.2.0 * @author Andrei Zmievski <an...@ph...> * @access public --- 4,8 ---- * Config_File class. * ! * @version 2.3.0 * @author Andrei Zmievski <an...@ph...> * @access public *************** *** 125,139 **** if (!empty($var_name)) { ! if (empty($section_name)) ! { return $this->_config_data[$file_name]["vars"][$var_name]; } - else - return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]; } else { ! if (empty($section_name)) return (array)$this->_config_data[$file_name]["vars"]; ! else ! return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"]; } } --- 125,145 ---- if (!empty($var_name)) { ! if (empty($section_name)) { return $this->_config_data[$file_name]["vars"][$var_name]; + } else { + if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name])) + return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]; + else + return array(); } } else { ! if (empty($section_name)) { return (array)$this->_config_data[$file_name]["vars"]; ! } else { ! if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"])) ! return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"]; ! else ! return array(); ! } } } Index: Smarty.class.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/Smarty.class.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** Smarty.class.php 25 Jul 2002 11:06:25 -0000 1.1 --- Smarty.class.php 14 Aug 2002 17:44:06 -0000 1.2 *************** *** 6,10 **** * Andrei Zmievski <an...@ph...> * ! * Version: 2.2.0 * Copyright: 2001,2002 ispi of Lincoln, Inc. * --- 6,10 ---- * Andrei Zmievski <an...@ph...> * ! * Version: 2.3.0 * Copyright: 2001,2002 ispi of Lincoln, Inc. * *************** *** 153,156 **** --- 153,159 ---- // you can set this to false if your PHP environment // does not allow the creation of them. + var $default_modifiers = array(); + // modifiers to implicitly append to every var + // example: array('escape:"htmlall"'); /**************************************************************************/ *************** *** 169,173 **** var $_config = array(); // loaded configuration settings var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty' ! var $_version = '2.2.0'; // Smarty version number var $_extract = false; // flag for custom functions var $_inclusion_depth = 0; // current template inclusion depth --- 172,176 ---- var $_config = array(); // loaded configuration settings var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty' ! var $_version = '2.3.0'; // Smarty version number var $_extract = false; // flag for custom functions var $_inclusion_depth = 0; // current template inclusion depth *************** *** 214,218 **** if(empty($this->debug_tpl)) { // set path to debug template from SMARTY_DIR ! $this->debug_tpl = SMARTY_DIR.'debug.tpl'; } } --- 217,221 ---- if(empty($this->debug_tpl)) { // set path to debug template from SMARTY_DIR ! $this->debug_tpl = 'file:'.SMARTY_DIR.'debug.tpl'; } } *************** *** 238,245 **** } ! /*======================================================================*\ Function: append ! Purpose: appens values to template variables \*======================================================================*/ function append($tpl_var, $value = NULL) --- 241,258 ---- } ! /*======================================================================*\ ! Function: assign_by_ref() ! Purpose: assigns values to template variables by reference ! \*======================================================================*/ ! function assign_by_ref($tpl_var, &$value) ! { ! if ($tpl_var != '' && isset($value)) ! $this->_tpl_vars[$tpl_var] = &$value; ! $this->_extract = true; ! } ! /*======================================================================*\ Function: append ! Purpose: appends values to template variables \*======================================================================*/ function append($tpl_var, $value = NULL) *************** *** 247,257 **** if (is_array($tpl_var)) { foreach ($tpl_var as $key => $val) { ! if (!empty($key)) { ! (array)$this->_tpl_vars[$key][] = $val; } } } else { ! if (!empty($tpl_var) && isset($value)) { ! (array)$this->_tpl_vars[$tpl_var][] = $value; } } --- 260,276 ---- if (is_array($tpl_var)) { foreach ($tpl_var as $key => $val) { ! if ($key != '') { ! if(!@is_array($this->_tpl_vars[$key])) { ! settype($this->_tpl_vars[$key],'array'); ! } ! $this->_tpl_vars[$key][] = $val; } } } else { ! if ($tpl_var != '' && isset($value)) { ! if(!@is_array($this->_tpl_vars[$tpl_var])) { ! settype($this->_tpl_vars[$tpl_var],'array'); ! } ! $this->_tpl_vars[$tpl_var][] = $value; } } *************** *** 259,262 **** --- 278,296 ---- } + /*======================================================================*\ + Function: append_by_ref + Purpose: appends values to template variables by reference + \*======================================================================*/ + function append_by_ref($tpl_var, &$value) + { + if ($tpl_var != '' && isset($value)) { + if(!@is_array($this->_tpl_vars[$tpl_var])) { + settype($this->_tpl_vars[$tpl_var],'array'); + } + $this->_tpl_vars[$tpl_var][] = &$value; + } + $this->_extract = true; + } + /*======================================================================*\ *************** *** 452,457 **** Purpose: clear cached content for the given template and cache id \*======================================================================*/ ! function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null) { if (!isset($compile_id)) $compile_id = $this->compile_id; --- 486,492 ---- Purpose: clear cached content for the given template and cache id \*======================================================================*/ ! function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null) { + if (!isset($compile_id)) $compile_id = $this->compile_id; *************** *** 468,473 **** return $funcname('clear', $this, $dummy, $tpl_file, $cache_id, $compile_id); } else { ! return $this->_rm_auto($this->cache_dir, $tpl_file, $auto_id); } } --- 503,509 ---- return $funcname('clear', $this, $dummy, $tpl_file, $cache_id, $compile_id); } else { ! return $this->_rm_auto($this->cache_dir, $tpl_file, $auto_id, $exp_time); } + } *************** *** 477,481 **** Purpose: clear the entire contents of cache (all templates) \*======================================================================*/ ! function clear_all_cache() { if (!empty($this->cache_handler_func)) { --- 513,517 ---- Purpose: clear the entire contents of cache (all templates) \*======================================================================*/ ! function clear_all_cache($exp_time = null) { if (!empty($this->cache_handler_func)) { *************** *** 483,487 **** return $funcname('clear', $this, $dummy); } else { ! return $this->_rm_auto($this->cache_dir); } } --- 519,523 ---- return $funcname('clear', $this, $dummy); } else { ! return $this->_rm_auto($this->cache_dir,null,null,$exp_time); } } *************** *** 519,527 **** This function is for advanced use only, not normally needed. \*======================================================================*/ ! function clear_compiled_tpl($tpl_file = null, $compile_id = null) { if (!isset($compile_id)) $compile_id = $this->compile_id; ! return $this->_rm_auto($this->compile_dir, $tpl_file, $compile_id); } --- 555,563 ---- This function is for advanced use only, not normally needed. \*======================================================================*/ ! function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null) { if (!isset($compile_id)) $compile_id = $this->compile_id; ! return $this->_rm_auto($this->compile_dir, $tpl_file, $compile_id, $exp_time); } *************** *** 722,745 **** // we must force compile the debug template in case the environment // changed between separate applications. ! $_orig_ldelim = $this->left_delimiter; ! $_orig_rdelim = $this->right_delimiter; $this->left_delimiter = '{'; $this->right_delimiter = '}'; ! ob_start(); ! $force_compile_orig = $this->force_compile; $this->force_compile = true; $compile_path = $this->_get_compile_path($this->debug_tpl); if ($this->_process_template($this->debug_tpl, $compile_path)) { include($compile_path); } ! $results = ob_get_contents(); ! $this->force_compile = $force_compile_orig; ! ob_end_clean(); ! $this->left_delimiter = $_orig_ldelim; ! $this->right_delimiter = $_orig_rdelim; return $results; --- 758,785 ---- // we must force compile the debug template in case the environment // changed between separate applications. ! $_ldelim_orig = $this->left_delimiter; ! $_rdelim_orig = $this->right_delimiter; $this->left_delimiter = '{'; $this->right_delimiter = '}'; ! $_force_compile_orig = $this->force_compile; $this->force_compile = true; + $_compile_id_orig = $this->_compile_id; + $this->_compile_id = null; + $compile_path = $this->_get_compile_path($this->debug_tpl); if ($this->_process_template($this->debug_tpl, $compile_path)) { + ob_start(); include($compile_path); + $results = ob_get_contents(); + ob_end_clean(); } ! $this->force_compile = $_force_compile_orig; ! $this->_compile_id = $_compile_id_orig; ! $this->left_delimiter = $_ldelim_orig; ! $this->right_delimiter = $_rdelim_orig; return $results; *************** *** 936,948 **** { // split tpl_path by the first colon ! $file_path_parts = explode(':', $file_path, 2); ! if (count($file_path_parts) == 1) { // no resource type, treat as type "file" $resource_type = 'file'; ! $resource_name = $file_path_parts[0]; } else { ! $resource_type = $file_path_parts[0]; ! $resource_name = $file_path_parts[1]; if ($resource_type != 'file') { $this->_load_resource_plugin($resource_type); --- 976,988 ---- { // split tpl_path by the first colon ! $_file_path_parts = explode(':', $file_path, 2); ! if (count($_file_path_parts) == 1) { // no resource type, treat as type "file" $resource_type = 'file'; ! $resource_name = $_file_path_parts[0]; } else { ! $resource_type = $_file_path_parts[0]; ! $resource_name = $_file_path_parts[1]; if ($resource_type != 'file') { $this->_load_resource_plugin($resource_type); *************** *** 954,964 **** // relative pathname to $file_base_path // use the first directory where the file is found ! foreach ((array)$file_base_path as $curr_path) { ! if (@is_file($curr_path . DIR_SEP . $resource_name)) { ! $resource_name = $curr_path . DIR_SEP . $resource_name; return true; } // didn't find the file, try include_path ! if($this->_get_include_path($curr_path . DIR_SEP . $resource_name, $_include_path)) { $resource_name = $_include_path; return true; --- 994,1005 ---- // relative pathname to $file_base_path // use the first directory where the file is found ! foreach ((array)$file_base_path as $_curr_path) { ! $_fullpath = $_curr_path . DIR_SEP . $resource_name; ! if (@is_file($_fullpath)) { ! $resource_name = $_fullpath; return true; } // didn't find the file, try include_path ! if($this->_get_include_path($_fullpath, $_include_path)) { $resource_name = $_include_path; return true; *************** *** 1061,1064 **** --- 1102,1106 ---- $smarty_compiler->_plugins = &$this->_plugins; $smarty_compiler->_tpl_vars = &$this->_tpl_vars; + $smarty_compiler->default_modifiers = $this->default_modifiers; if ($smarty_compiler->_compile_file($tpl_file, $template_source, $template_compiled)) *************** *** 1277,1281 **** $this->_plugins['insert'][$name][1], $this->_plugins['insert'][$name][2], ! false); } return $this->_smarty_md5."{insert_cache $arg_string}".$this->_smarty_md5; --- 1319,1323 ---- $this->_plugins['insert'][$name][1], $this->_plugins['insert'][$name][2], ! !empty($args['script']) ? true : false); } return $this->_smarty_md5."{insert_cache $arg_string}".$this->_smarty_md5; *************** *** 1453,1461 **** // make source name safe for filename if($this->use_sub_dirs) { ! $_filename = basename($auto_source); $_crc32 = crc32($auto_source) . $_dir_sep; ! // prepend N in case crc32 was negative to avoid possible ! // OS issues with directory names starting with a "-" ! $_crc32 = 'N' . substr($_crc32,0,3) . $_dir_sep . 'N' . $_crc32; $res .= $_crc32 . $_filename . '.php'; } else { --- 1495,1503 ---- // make source name safe for filename if($this->use_sub_dirs) { ! $_filename = urlencode(basename($auto_source)); $_crc32 = crc32($auto_source) . $_dir_sep; ! // prepend %% to avoid name conflicts with ! // with $auto_id names ! $_crc32 = '%%' . substr($_crc32,0,3) . $_dir_sep . '%%' . $_crc32; $res .= $_crc32 . $_filename . '.php'; } else { *************** *** 1471,1475 **** Purpose: delete an automagically created file by name and id \*======================================================================*/ ! function _rm_auto($auto_base, $auto_source = null, $auto_id = null) { if (!is_dir($auto_base)) --- 1513,1517 ---- Purpose: delete an automagically created file by name and id \*======================================================================*/ ! function _rm_auto($auto_base, $auto_source = null, $auto_id = null, $exp_time = null) { if (!is_dir($auto_base)) *************** *** 1477,1481 **** if(!isset($auto_id) && !isset($auto_source)) { ! $res = $this->_rmdir($auto_base, 0); } else { $tname = $this->_get_auto_filename($auto_base, $auto_source, $auto_id); --- 1519,1523 ---- if(!isset($auto_id) && !isset($auto_source)) { ! $res = $this->_rmdir($auto_base, 0, $exp_time); } else { $tname = $this->_get_auto_filename($auto_base, $auto_source, $auto_id); *************** *** 1484,1488 **** $res = @unlink($tname); } elseif ($this->use_sub_dirs) { ! $res = $this->_rmdir($tname, 1); } else { // remove matching file names --- 1526,1530 ---- $res = @unlink($tname); } elseif ($this->use_sub_dirs) { ! $res = $this->_rmdir($tname, 1, $exp_time); } else { // remove matching file names *************** *** 1492,1496 **** continue; } elseif (substr($auto_base . DIR_SEP . $filename,0,strlen($tname)) == $tname) { ! unlink($auto_base . DIR_SEP . $filename); } } --- 1534,1538 ---- continue; } elseif (substr($auto_base . DIR_SEP . $filename,0,strlen($tname)) == $tname) { ! $this->_unlink($auto_base . DIR_SEP . $filename, $exp_time); } } *************** *** 1506,1510 **** WARNING: no security whatsoever!! \*======================================================================*/ ! function _rmdir($dirname, $level = 1) { --- 1548,1552 ---- WARNING: no security whatsoever!! \*======================================================================*/ ! function _rmdir($dirname, $level = 1, $exp_time = null) { *************** *** 1514,1521 **** if ($entry != '.' && $entry != '..') { if (is_dir($dirname . DIR_SEP . $entry)) { ! $this->_rmdir($dirname . DIR_SEP . $entry, $level + 1); } else { ! unlink($dirname . DIR_SEP . $entry); } } --- 1556,1563 ---- if ($entry != '.' && $entry != '..') { if (is_dir($dirname . DIR_SEP . $entry)) { ! $this->_rmdir($dirname . DIR_SEP . $entry, $level + 1, $exp_time); } else { ! $this->_unlink($dirname . DIR_SEP . $entry, $exp_time); } } *************** *** 1535,1538 **** --- 1577,1595 ---- /*======================================================================*\ + Function: _unlink + Purpose: unlink a file, possibly using expiration time + \*======================================================================*/ + function _unlink($resource, $exp_time = null) + { + if(isset($exp_time)) { + if(time() - filemtime($resource) >= $exp_time) { + unlink($resource); + } + } else { + unlink($resource); + } + } + + /*======================================================================*\ Function: _create_dir_structure Purpose: create full directory structure *************** *** 1917,1921 **** Purpose: trigger Smarty plugin error \*======================================================================*/ ! function _trigger_plugin_error($error_msg, $tpl_file = null, $tpl_line = null, $error_type = E_USER_WARNING) { if (isset($tpl_line) && isset($tpl_file)) { --- 1974,1978 ---- Purpose: trigger Smarty plugin error \*======================================================================*/ ! function _trigger_plugin_error($error_msg, $tpl_file = null, $tpl_line = null, $error_type = E_USER_ERROR) { if (isset($tpl_line) && isset($tpl_file)) { Index: Smarty_Compiler.class.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/Smarty_Compiler.class.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** Smarty_Compiler.class.php 25 Jul 2002 11:06:25 -0000 1.1 --- Smarty_Compiler.class.php 14 Aug 2002 17:44:06 -0000 1.2 *************** *** 7,11 **** * Andrei Zmievski <an...@ph...> * ! * Version: 2.2.0 * Copyright: 2001,2002 ispi of Lincoln, Inc. * --- 7,11 ---- * Andrei Zmievski <an...@ph...> * ! * Version: 2.3.0 * Copyright: 2001,2002 ispi of Lincoln, Inc. * *************** *** 1109,1113 **** $var_ref = $parts[0]; $modifiers = isset($parts[1]) ? $parts[1] : ''; ! preg_match_all('!\[(?:\$\w+|\w+(\.\w+)?)\]|(->|\.)\$?\w+|^\w+!', $var_ref, $match); $indexes = $match[0]; --- 1109,1118 ---- $var_ref = $parts[0]; $modifiers = isset($parts[1]) ? $parts[1] : ''; ! ! if(!empty($this->default_modifiers) && !preg_match('!(^|\|)smarty:nodefaults($|\|)!',$modifiers)) { ! $_default_mod_string = implode('|',(array)$this->default_modifiers); ! $modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string . '|' . $modifiers; ! } ! preg_match_all('!\[(?:\$\w+|\w+(\.\w+)?)\]|(->|\.)\$?\w+|^\w+!', $var_ref, $match); $indexes = $match[0]; *************** *** 1214,1217 **** --- 1219,1228 ---- for ($i = 0, $for_max = count($modifiers); $i < $for_max; $i++) { $modifier_name = $modifiers[$i]; + + if($modifier_name == 'smarty') { + // skip smarty modifier + continue; + } + preg_match_all('!:(' . $qstr_regexp . '|[^:]+)!', $modifier_arg_strings[$i], $match); $modifier_args = $match[1]; *************** *** 1223,1227 **** $map_array = 'true'; } ! $this->_add_plugin('modifier', $modifier_name); --- 1234,1238 ---- $map_array = 'true'; } ! $this->_add_plugin('modifier', $modifier_name); Index: auth.php =================================================================== RCS file: /cvsroot/phpmp/phpMP/includes/auth.php,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -r1.18 -r1.19 *** auth.php 10 Aug 2002 20:41:33 -0000 1.18 --- auth.php 14 Aug 2002 17:44:06 -0000 1.19 *************** *** 42,45 **** --- 42,46 ---- var $mpcookie; + var $first_login; function session_cleanup() { *************** *** 60,68 **** function AuthUser() { ! global $MPCONF, $Functions, $DBA, $HTTP_POST_VARS; $this->session_cleanup(); ! if(empty($HTTP_POST_VARS['username'])) { session_start(); } --- 61,69 ---- function AuthUser() { ! global $MPCONF, $Functions, $DBA; $this->session_cleanup(); ! if(empty($_POST['username'])) { session_start(); } *************** *** 72,84 **** } ! if(($HTTP_POST_VARS['username'] != "") && ($HTTP_POST_VARS['password'] != "")) { $new_key = $Functions->createHash(); session_id($new_key); session_start(); ! $enc_password = md5($HTTP_POST_VARS['password']); ! $result = $DBA->query('SELECT * FROM ' . $MPCONF['DB']['table_prefix'] . "users WHERE username='{$HTTP_POST_VARS['username']}' AND password='$enc_password'"); $num_rows = $DBA->num_rows($result); if($num_rows > 0) { --- 73,86 ---- } ! if(($_POST['username'] != "") && ($_POST['password'] != "")) { + $result = $DBA->query("DELETE FROM " . $MPCONF['DB']['table_prefix'] . "sessions WHERE username = " . $_POST['username']); $new_key = $Functions->createHash(); session_id($new_key); session_start(); ! $enc_password = md5($_POST['password']); ! $result = $DBA->query('SELECT * FROM ' . $MPCONF['DB']['table_prefix'] . "users WHERE username='{$_POST['username']}' AND password='$enc_password'"); $num_rows = $DBA->num_rows($result); if($num_rows > 0) { *************** *** 88,91 **** --- 90,95 ---- if($MPCONF['USR']['active'] == 1) { + $this->first_login = 1; + unset($_SESSION['user_array']); $_SESSION['user_array'] = $user_array; *************** *** 108,114 **** $this->AuthAdmin(); ! //} elseif($HTTP_COOKIE_VARS[$MPCONF['SES']['extcookie']]) { ! //$this->mpcookie = $HTTP_COOKIE_VARS[$MPCONF['SES']['extcookie']]; //$authstring = $this->mpcookie; --- 112,118 ---- $this->AuthAdmin(); ! //} elseif($_COOKIE[$MPCONF['SES']['extcookie']]) { ! //$this->mpcookie = $_COOKIE[$MPCONF['SES']['extcookie']]; //$authstring = $this->mpcookie; *************** *** 121,125 **** //$userdata = $this->FetchUserVars($sess_user); ! //$DBA->query("INSERT INTO " . $MPCONF['DB']['table_prefix'] . "sessions (sesskey, expiretime, userid, username) VALUES('$sesskey', '" . $this->cookietime . "', " . $userdata['user_id'] . ", '$sess_user')"); //setcookie($cookiename, $sess_user, $this->cookietime, $MPCONF['GEN']['uri']); --- 125,129 ---- //$userdata = $this->FetchUserVars($sess_user); ! //$DBA->query("INSERT INTO " . $MPCONF['DB']['table_prefix'] . "sessions (sesskey, expiretime, user_id) VALUES('$sesskey', '" . $this->cookietime . "', " . $userdata['user_id'] . ", )"); //setcookie($cookiename, $sess_user, $this->cookietime, $MPCONF['GEN']['uri']); |