Browse Source

Fixes

pull/3/head
M@d D3n 5 years ago
parent
commit
934bda4f4b
  1. 97
      class/class.modules.php
  2. 2
      inc/init.php
  3. 712
      lib/Smarty/Config_File.class.php
  4. 4
      lib/Smarty/Smarty.class.php
  5. 16
      lib/Smarty/Smarty_Compiler.class.php
  6. 0
      lib/Smarty/debug.tpl
  7. 0
      lib/Smarty/internals/core.assemble_plugin_filepath.php
  8. 0
      lib/Smarty/internals/core.assign_smarty_interface.php
  9. 0
      lib/Smarty/internals/core.create_dir_structure.php
  10. 0
      lib/Smarty/internals/core.display_debug_console.php
  11. 0
      lib/Smarty/internals/core.get_include_path.php
  12. 0
      lib/Smarty/internals/core.get_microtime.php
  13. 0
      lib/Smarty/internals/core.get_php_resource.php
  14. 0
      lib/Smarty/internals/core.is_secure.php
  15. 0
      lib/Smarty/internals/core.is_trusted.php
  16. 0
      lib/Smarty/internals/core.load_plugins.php
  17. 0
      lib/Smarty/internals/core.load_resource_plugin.php
  18. 0
      lib/Smarty/internals/core.process_cached_inserts.php
  19. 0
      lib/Smarty/internals/core.process_compiled_include.php
  20. 0
      lib/Smarty/internals/core.read_cache_file.php
  21. 0
      lib/Smarty/internals/core.rm_auto.php
  22. 0
      lib/Smarty/internals/core.rmdir.php
  23. 0
      lib/Smarty/internals/core.run_insert_handler.php
  24. 0
      lib/Smarty/internals/core.smarty_include_php.php
  25. 0
      lib/Smarty/internals/core.write_cache_file.php
  26. 0
      lib/Smarty/internals/core.write_compiled_include.php
  27. 0
      lib/Smarty/internals/core.write_compiled_resource.php
  28. 0
      lib/Smarty/internals/core.write_file.php
  29. 0
      lib/Smarty/plugins/block.textformat.php
  30. 0
      lib/Smarty/plugins/compiler.assign.php
  31. 0
      lib/Smarty/plugins/function.assign_debug_info.php
  32. 0
      lib/Smarty/plugins/function.config_load.php
  33. 0
      lib/Smarty/plugins/function.counter.php
  34. 0
      lib/Smarty/plugins/function.cycle.php
  35. 0
      lib/Smarty/plugins/function.debug.php
  36. 0
      lib/Smarty/plugins/function.eval.php
  37. 0
      lib/Smarty/plugins/function.fetch.php
  38. 0
      lib/Smarty/plugins/function.html_checkboxes.php
  39. 0
      lib/Smarty/plugins/function.html_image.php
  40. 0
      lib/Smarty/plugins/function.html_options.php
  41. 0
      lib/Smarty/plugins/function.html_radios.php
  42. 0
      lib/Smarty/plugins/function.html_select_date.php
  43. 0
      lib/Smarty/plugins/function.html_select_time.php
  44. 0
      lib/Smarty/plugins/function.html_table.php
  45. 0
      lib/Smarty/plugins/function.mailto.php
  46. 37
      lib/Smarty/plugins/function.math.php
  47. 0
      lib/Smarty/plugins/function.popup.php
  48. 0
      lib/Smarty/plugins/function.popup_init.php
  49. 0
      lib/Smarty/plugins/modifier.capitalize.php
  50. 0
      lib/Smarty/plugins/modifier.cat.php
  51. 0
      lib/Smarty/plugins/modifier.count_characters.php
  52. 0
      lib/Smarty/plugins/modifier.count_paragraphs.php
  53. 0
      lib/Smarty/plugins/modifier.count_sentences.php
  54. 0
      lib/Smarty/plugins/modifier.count_words.php
  55. 0
      lib/Smarty/plugins/modifier.date_format.php
  56. 0
      lib/Smarty/plugins/modifier.debug_print_var.php
  57. 0
      lib/Smarty/plugins/modifier.default.php
  58. 0
      lib/Smarty/plugins/modifier.escape.php
  59. 0
      lib/Smarty/plugins/modifier.indent.php
  60. 0
      lib/Smarty/plugins/modifier.lower.php
  61. 0
      lib/Smarty/plugins/modifier.nl2br.php
  62. 0
      lib/Smarty/plugins/modifier.regex_replace.php
  63. 0
      lib/Smarty/plugins/modifier.replace.php
  64. 0
      lib/Smarty/plugins/modifier.spacify.php
  65. 0
      lib/Smarty/plugins/modifier.string_format.php
  66. 0
      lib/Smarty/plugins/modifier.strip.php
  67. 0
      lib/Smarty/plugins/modifier.strip_tags.php
  68. 0
      lib/Smarty/plugins/modifier.upper.php
  69. 0
      lib/Smarty/plugins/modifier.wordwrap.php
  70. 0
      lib/Smarty/plugins/outputfilter.trimwhitespace.php
  71. 0
      lib/Smarty/plugins/shared.escape_special_chars.php
  72. 0
      lib/Smarty/plugins/shared.make_timestamp.php

97
class/class.modules.php

@ -14,17 +14,28 @@
{ {
public $_modules = []; public $_modules = [];
private static $instance = null;
function __construct()
function __construct ()
{ {
$this->_modules = $this->getModules(); $this->_modules = $this->getModules();
} }
public static function init ()
{
if (is_null(self::$instance))
self::$instance = new AVE_Module;
return self::$instance;
}
/** /**
* Метод, который обрабатывает все module.php и записывает как свойство класса списки модулей * Метод, который обрабатывает все module.php и записывает как свойство класса списки модулей
*/ */
function getModules() function getModules ()
{ {
$modules = []; $modules = [];
@ -61,7 +72,7 @@
if (! is_dir($module_dir)) if (! is_dir($module_dir))
continue; continue;
$module = array(); $module = array ();
// Если не удалось подключить основной файл модуля module.php - Фиксируем ошибку // Если не удалось подключить основной файл модуля module.php - Фиксируем ошибку
if (! (is_file($module_dir . '/info.php') && @include_once($module_dir . '/info.php'))) if (! (is_file($module_dir . '/info.php') && @include_once($module_dir . '/info.php')))
@ -122,23 +133,25 @@
* Метод, преданзначеный для выода модулей * Метод, преданзначеный для выода модулей
* *
*/ */
function moduleList() function moduleList ()
{ {
global $AVE_DB, $AVE_Template; global $AVE_DB, $AVE_Template;
$assign = array(); // Массив для передачи в Smarty $assign = []; // Массив для передачи в Smarty
$errors = array(); // Массив с ошибками $errors = []; // Массив с ошибками
// Получаем список всех шаблонов // Получаем список всех шаблонов
$sql = $AVE_DB->Query(" $sql = "
SELECT SELECT
Id, Id,
template_title template_title
FROM FROM
" . PREFIX . "_templates " . PREFIX . "_templates
"); ";
while ($row = $sql->FetchRow()) $query = $AVE_DB->Query($sql);
while ($row = $query->FetchRow())
$assign['all_templates'][$row->Id] = htmlspecialchars($row->template_title, ENT_QUOTES); $assign['all_templates'][$row->Id] = htmlspecialchars($row->template_title, ENT_QUOTES);
// Заголовок: Автор модуля // Заголовок: Автор модуля
@ -147,7 +160,7 @@
// Получаем список всех модулей // Получаем список всех модулей
$modules = $this->_modules; $modules = $this->_modules;
foreach ($modules as $module) foreach ($modules AS $module)
{ {
$module['info'] = $module['ModuleDescription'] . (! $module['ModuleAutor'] $module['info'] = $module['ModuleDescription'] . (! $module['ModuleAutor']
? '<br /><br />' ? '<br /><br />'
@ -246,7 +259,7 @@
* Метод, предназначенный для обновления в БД информации о шаблонах модулей * Метод, предназначенный для обновления в БД информации о шаблонах модулей
* *
*/ */
function moduleOptionsSave() function moduleOptionsSave ()
{ {
global $AVE_DB; global $AVE_DB;
@ -264,7 +277,7 @@
"); ");
} }
$this->clearModulesCache(); $this->clearModulesCache ();
// Выполянем обновление страницы со списком модулей // Выполянем обновление страницы со списком модулей
header('Location:index.php?do=modules&cp=' . SESSION); header('Location:index.php?do=modules&cp=' . SESSION);
@ -276,7 +289,7 @@
* Метод, предназанченный для установки или переустановки модуля * Метод, предназанченный для установки или переустановки модуля
* *
*/ */
function moduleInstall() function moduleInstall ()
{ {
global $AVE_DB, $AVE_Template; global $AVE_DB, $AVE_Template;
@ -359,12 +372,14 @@
* Метод, предназначенный для обновления модуля при увеличении номера версии модуля * Метод, предназначенный для обновления модуля при увеличении номера версии модуля
* *
*/ */
function moduleUpdate() function moduleUpdate ()
{ {
global $AVE_DB, $AVE_Template; global $AVE_DB, $AVE_Template;
// Подключаем файл с запросами к БД для данного модуля // Подключаем файл с запросами к БД для данного модуля
$module_sql_update = array(); $module_sql_update = [];
$module = [];
$sql_file = BASE_DIR . '/modules/' . MODULE_PATH . '/sql.php'; $sql_file = BASE_DIR . '/modules/' . MODULE_PATH . '/sql.php';
@ -378,31 +393,35 @@
// Выполняем запросы обновления модуля // Выполняем запросы обновления модуля
// из массива $module_sql_update файла sql.php // из массива $module_sql_update файла sql.php
foreach ($module_sql_update as $sql) foreach ($module_sql_update as $sql)
{
$AVE_DB->Query(str_replace('%%PRFX%%', PREFIX, $sql)); $AVE_DB->Query(str_replace('%%PRFX%%', PREFIX, $sql));
}
} }
// Обновляем модуль, если в нем не применяется (отсутствует) файл sql.php // Обновляем модуль, если в нем не применяется (отсутствует) файл sql.php
elseif (file_exists($mod_file) && file_exists($sql_file) === false) elseif (file_exists($mod_file) && file_exists($sql_file) === false)
{ {
include_once ($mod_file); include ($mod_file);
if (isset ($module) && ! empty($module))
{
$sql = "
UPDATE
" . PREFIX . "_module
SET
ModuleAveTag = '" . $module['ModuleAveTag'] . "',
ModulePHPTag = '" . $module['ModulePHPTag'] . "',
ModuleFunction = '" . $module['ModuleFunction'] . "',
ModuleIsFunction = '" . $module['ModuleIsFunction'] . "',
ModuleSysName = '" . MODULE_PATH . "',
ModuleVersion = '" . $module['ModuleVersion'] . "',
ModuleTemplate = '" . $module['ModuleTemplate'] . "',
ModuleAdminEdit = '" . $module['ModuleAdminEdit'] . "',
ModuleStatus = '1'
WHERE
ModuleSysName = '" . MODULE_PATH . "'
";
$AVE_DB->Query($sql);
}
$AVE_DB->Query("
UPDATE
" . PREFIX . "_module
SET
ModuleAveTag = '" . $module['ModuleAveTag'] . "',
ModulePHPTag = '" . $module['ModulePHPTag'] . "',
ModuleFunction = '" . $module['ModuleFunction'] . "',
ModuleIsFunction = '" . $module['ModuleIsFunction'] . "',
ModuleSysName = '" . MODULE_PATH . "',
ModuleVersion = '" . $module['ModuleVersion'] . "',
ModuleTemplate = '" . $module['ModuleTemplate'] . "',
ModuleAdminEdit = '" . $module['ModuleAdminEdit'] . "',
ModuleStatus = '1'
WHERE
ModuleSysName = '" . MODULE_PATH . "'
");
} }
// Сохраняем системное сообщение в журнал // Сохраняем системное сообщение в журнал
reportLog ($AVE_Template->get_config_vars('MODULES_ACTION_UPDATE') . ' (' . MODULE_PATH . ')'); reportLog ($AVE_Template->get_config_vars('MODULES_ACTION_UPDATE') . ' (' . MODULE_PATH . ')');
@ -419,7 +438,7 @@
* Метод, предназанченный для удаление модуля * Метод, предназанченный для удаление модуля
* *
*/ */
function moduleDelete() function moduleDelete ()
{ {
global $AVE_DB, $AVE_Template; global $AVE_DB, $AVE_Template;
@ -462,7 +481,7 @@
* Метод, предназначенный для отключения/включение модуля в Панели управления * Метод, предназначенный для отключения/включение модуля в Панели управления
* *
*/ */
function moduleStatusChange() function moduleStatusChange ()
{ {
global $AVE_DB, $AVE_Template; global $AVE_DB, $AVE_Template;
@ -490,7 +509,7 @@
ModuleSysName = '" . MODULE_PATH . "' ModuleSysName = '" . MODULE_PATH . "'
"); ");
$this->clearModulesCache(); $this->clearModulesCache ();
// Сохраняем системное сообщение в журнал // Сохраняем системное сообщение в журнал
reportLog ((($ModuleStatus == "0") reportLog ((($ModuleStatus == "0")
@ -503,7 +522,7 @@
} }
function moduleRemove($dir) function moduleRemove ($dir)
{ {
global $AVE_DB, $AVE_Template; global $AVE_DB, $AVE_Template;
@ -514,7 +533,7 @@
foreach ($files as $file) foreach ($files as $file)
{ {
if(substr($file, -1) == '/') if(substr($file, -1) == '/')
moduleRemove($file); $this->moduleRemove($file);
else else
unlink($file); unlink($file);
} }

2
inc/init.php

@ -433,5 +433,5 @@
//-- Класс Модулей //-- Класс Модулей
require (BASE_DIR . '/class/class.modules.php'); require (BASE_DIR . '/class/class.modules.php');
$AVE_Module = new AVE_Module; $AVE_Module = AVE_Module::init();
?> ?>

712
lib/Smarty/Config_File.class.php

@ -10,384 +10,384 @@
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
* For questions, help, comments, discussion, etc., please join the * For questions, help, comments, discussion, etc., please join the
* Smarty mailing list. Send a blank e-mail to * Smarty mailing list. Send a blank e-mail to
* smarty-discussion-subscribe@googlegroups.com * smarty-discussion-subscribe@googlegroups.com
* *
* @link http://www.smarty.net/ * @link http://www.smarty.net/
* @version 2.6.26 * @version 2.6.25-dev
* @copyright Copyright: 2001-2005 New Digital Group, Inc. * @copyright Copyright: 2001-2005 New Digital Group, Inc.
* @author Andrei Zmievski <andrei@php.net> * @author Andrei Zmievski <andrei@php.net>
* @access public * @access public
* @package Smarty * @package Smarty
*/ */
/* $Id: Config_File.class.php 3149 2009-05-23 20:59:25Z monte.ohrt $ */ /* $Id$ */
/** /**
* Config file reading class * Config file reading class
* @package Smarty * @package Smarty
*/ */
class Config_File { class Config_File {
/**#@+ /**#@+
* Options * Options
* @var boolean * @var boolean
*/ */
/** /**
* Controls whether variables with the same name overwrite each other. * Controls whether variables with the same name overwrite each other.
*/ */
var $overwrite = true; var $overwrite = true;
/** /**
* Controls whether config values of on/true/yes and off/false/no get * Controls whether config values of on/true/yes and off/false/no get
* converted to boolean values automatically. * converted to boolean values automatically.
*/ */
var $booleanize = true; var $booleanize = true;
/** /**
* Controls whether hidden config sections/vars are read from the file. * Controls whether hidden config sections/vars are read from the file.
*/ */
var $read_hidden = true; var $read_hidden = true;
/** /**
* Controls whether or not to fix mac or dos formatted newlines. * Controls whether or not to fix mac or dos formatted newlines.
* If set to true, \r or \r\n will be changed to \n. * If set to true, \r or \r\n will be changed to \n.
*/ */
var $fix_newlines = true; var $fix_newlines = true;
/**#@-*/ /**#@-*/
/** @access private */ /** @access private */
var $_config_path = ""; var $_config_path = "";
var $_config_data = array(); var $_config_data = array();
/**#@-*/ /**#@-*/
/** /**
* Constructs a new config file class. * Constructs a new config file class.
* *
* @param string $config_path (optional) path to the config files * @param string $config_path (optional) path to the config files
*/ */
function __construct($config_path = NULL) public function __construct($config_path = NULL)
{ {
if (isset($config_path)) if (isset($config_path))
$this->set_path($config_path); $this->set_path($config_path);
} }
/** /**
* Set the path where configuration files can be found. * Set the path where configuration files can be found.
* *
* @param string $config_path path to the config files * @param string $config_path path to the config files
*/ */
function set_path($config_path) function set_path($config_path)
{ {
if (!empty($config_path)) { if (!empty($config_path)) {
if (!is_string($config_path) || !file_exists($config_path) || !is_dir($config_path)) { if (!is_string($config_path) || !file_exists($config_path) || !is_dir($config_path)) {
$this->_trigger_error_msg("Bad config file path '$config_path'"); $this->_trigger_error_msg("Bad config file path '$config_path'");
return; return;
} }
if(substr($config_path, -1) != DIRECTORY_SEPARATOR) { if(substr($config_path, -1) != DIRECTORY_SEPARATOR) {
$config_path .= DIRECTORY_SEPARATOR; $config_path .= DIRECTORY_SEPARATOR;
} }
$this->_config_path = $config_path; $this->_config_path = $config_path;
} }
} }
/** /**
* Retrieves config info based on the file, section, and variable name. * Retrieves config info based on the file, section, and variable name.
* *
* @param string $file_name config file to get info for * @param string $file_name config file to get info for
* @param string $section_name (optional) section to get info for * @param string $section_name (optional) section to get info for
* @param string $var_name (optional) variable to get info for * @param string $var_name (optional) variable to get info for
* @return string|array a value or array of values * @return string|array a value or array of values
*/ */
function get($file_name, $section_name = NULL, $var_name = NULL) function get($file_name, $section_name = NULL, $var_name = NULL)
{ {
if (empty($file_name)) { if (empty($file_name)) {
$this->_trigger_error_msg('Empty config file name'); $this->_trigger_error_msg('Empty config file name');
return; return;
} else { } else {
$file_name = $this->_config_path . $file_name; $file_name = $this->_config_path . $file_name;
if (!isset($this->_config_data[$file_name])) if (!isset($this->_config_data[$file_name]))
$this->load_file($file_name, false); $this->load_file($file_name, false);
} }
if (!empty($var_name)) { if (!empty($var_name)) {
if (empty($section_name)) { if (empty($section_name)) {
return $this->_config_data[$file_name]["vars"][$var_name]; return $this->_config_data[$file_name]["vars"][$var_name];
} else { } else {
if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name])) 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]; return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name];
else else
return array(); return array();
} }
} else { } else {
if (empty($section_name)) { if (empty($section_name)) {
return (array)$this->_config_data[$file_name]["vars"]; return (array)$this->_config_data[$file_name]["vars"];
} else { } else {
if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"])) if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"]))
return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"]; return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"];
else else
return array(); return array();
} }
} }
} }
/** /**
* Retrieves config info based on the key. * Retrieves config info based on the key.
* *
* @param $file_name string config key (filename/section/var) * @param $file_name string config key (filename/section/var)
* @return string|array same as get() * @return string|array same as get()
* @uses get() retrieves information from config file and returns it * @uses get() retrieves information from config file and returns it
*/ */
function &get_key($config_key) function &get_key($config_key)
{ {
list($file_name, $section_name, $var_name) = explode('/', $config_key, 3); list($file_name, $section_name, $var_name) = explode('/', $config_key, 3);
$result = &$this->get($file_name, $section_name, $var_name); $result = &$this->get($file_name, $section_name, $var_name);
return $result; return $result;
} }
/** /**
* Get all loaded config file names. * Get all loaded config file names.
* *
* @return array an array of loaded config file names * @return array an array of loaded config file names
*/ */
function get_file_names() function get_file_names()
{ {
return array_keys($this->_config_data); return array_keys($this->_config_data);
} }
/** /**
* Get all section names from a loaded file. * Get all section names from a loaded file.
* *
* @param string $file_name config file to get section names from * @param string $file_name config file to get section names from
* @return array an array of section names from the specified file * @return array an array of section names from the specified file
*/ */
function get_section_names($file_name) function get_section_names($file_name)
{ {
$file_name = $this->_config_path . $file_name; $file_name = $this->_config_path . $file_name;
if (!isset($this->_config_data[$file_name])) { if (!isset($this->_config_data[$file_name])) {
$this->_trigger_error_msg("Unknown config file '$file_name'"); $this->_trigger_error_msg("Unknown config file '$file_name'");
return; return;
} }
return array_keys($this->_config_data[$file_name]["sections"]); return array_keys($this->_config_data[$file_name]["sections"]);
} }
/** /**
* Get all global or section variable names. * Get all global or section variable names.
* *
* @param string $file_name config file to get info for * @param string $file_name config file to get info for
* @param string $section_name (optional) section to get info for * @param string $section_name (optional) section to get info for
* @return array an array of variables names from the specified file/section * @return array an array of variables names from the specified file/section
*/ */
function get_var_names($file_name, $section = NULL) function get_var_names($file_name, $section = NULL)
{ {
if (empty($file_name)) { if (empty($file_name)) {
$this->_trigger_error_msg('Empty config file name'); $this->_trigger_error_msg('Empty config file name');
return; return;
} else if (!isset($this->_config_data[$file_name])) { } else if (!isset($this->_config_data[$file_name])) {
$this->_trigger_error_msg("Unknown config file '$file_name'"); $this->_trigger_error_msg("Unknown config file '$file_name'");
return; return;
} }
if (empty($section)) if (empty($section))
return array_keys($this->_config_data[$file_name]["vars"]); return array_keys($this->_config_data[$file_name]["vars"]);
else else
return array_keys($this->_config_data[$file_name]["sections"][$section]["vars"]); return array_keys($this->_config_data[$file_name]["sections"][$section]["vars"]);
} }
/** /**
* Clear loaded config data for a certain file or all files. * Clear loaded config data for a certain file or all files.
* *
* @param string $file_name file to clear config data for * @param string $file_name file to clear config data for
*/ */
function clear($file_name = NULL) function clear($file_name = NULL)
{ {
if ($file_name === NULL) if ($file_name === NULL)
$this->_config_data = array(); $this->_config_data = array();
else if (isset($this->_config_data[$file_name])) else if (isset($this->_config_data[$file_name]))
$this->_config_data[$file_name] = array(); $this->_config_data[$file_name] = array();
} }
/** /**
* Load a configuration file manually. * Load a configuration file manually.
* *
* @param string $file_name file name to load * @param string $file_name file name to load
* @param boolean $prepend_path whether current config path should be * @param boolean $prepend_path whether current config path should be
* prepended to the filename * prepended to the filename
*/ */
function load_file($file_name, $prepend_path = true) function load_file($file_name, $prepend_path = true)
{ {
if ($prepend_path && $this->_config_path != "") if ($prepend_path && $this->_config_path != "")
$config_file = $this->_config_path . $file_name; $config_file = $this->_config_path . $file_name;
else else
$config_file = $file_name; $config_file = $file_name;
ini_set('track_errors', true); ini_set('track_errors', true);
$fp = @fopen($config_file, "r"); $fp = @fopen($config_file, "r");
if (!is_resource($fp)) { if (!is_resource($fp)) {
$this->_trigger_error_msg("Could not open config file '$config_file'"); $this->_trigger_error_msg("Could not open config file '$config_file'");
return false; return false;
} }
$contents = ($size = filesize($config_file)) ? fread($fp, $size) : ''; $contents = ($size = filesize($config_file)) ? fread($fp, $size) : '';
fclose($fp); fclose($fp);
$this->_config_data[$config_file] = $this->parse_contents($contents); $this->_config_data[$config_file] = $this->parse_contents($contents);
return true; return true;
} }
/** /**
* Store the contents of a file manually. * Store the contents of a file manually.
* *
* @param string $config_file file name of the related contents * @param string $config_file file name of the related contents
* @param string $contents the file-contents to parse * @param string $contents the file-contents to parse
*/ */
function set_file_contents($config_file, $contents) function set_file_contents($config_file, $contents)
{ {
$this->_config_data[$config_file] = $this->parse_contents($contents); $this->_config_data[$config_file] = $this->parse_contents($contents);
return true; return true;
} }
/** /**
* parse the source of a configuration file manually. * parse the source of a configuration file manually.
* *
* @param string $contents the file-contents to parse * @param string $contents the file-contents to parse
*/ */
function parse_contents($contents) function parse_contents($contents)
{ {
if($this->fix_newlines) { if($this->fix_newlines) {
// fix mac/dos formatted newlines // fix mac/dos formatted newlines
$contents = preg_replace('!\r\n?!', "\n", $contents); $contents = preg_replace('!\r\n?!', "\n", $contents);
} }
$config_data = array(); $config_data = array();
$config_data['sections'] = array(); $config_data['sections'] = array();
$config_data['vars'] = array(); $config_data['vars'] = array();
/* reference to fill with data */ /* reference to fill with data */
$vars =& $config_data['vars']; $vars =& $config_data['vars'];
/* parse file line by line */ /* parse file line by line */
preg_match_all('!^.*\r?\n?!m', $contents, $match); preg_match_all('!^.*\r?\n?!m', $contents, $match);
$lines = $match[0]; $lines = $match[0];
for ($i=0, $count=count($lines); $i<$count; $i++) { for ($i=0, $count=count($lines); $i<$count; $i++) {
$line = $lines[$i]; $line = $lines[$i];
if (empty($line)) continue; if (empty($line)) continue;
if ( substr($line, 0, 1) == '[' && preg_match('!^\[(.*?)\]!', $line, $match) ) { if ( substr($line, 0, 1) == '[' && preg_match('!^\[(.*?)\]!', $line, $match) ) {
/* section found */ /* section found */
if (substr($match[1], 0, 1) == '.') { if (substr($match[1], 0, 1) == '.') {
/* hidden section */ /* hidden section */
if ($this->read_hidden) { if ($this->read_hidden) {
$section_name = substr($match[1], 1); $section_name = substr($match[1], 1);
} else { } else {
/* break reference to $vars to ignore hidden section */ /* break reference to $vars to ignore hidden section */
unset($vars); unset($vars);
$vars = array(); $vars = array();
continue; continue;
} }
} else { } else {
$section_name = $match[1]; $section_name = $match[1];
} }
if (!isset($config_data['sections'][$section_name])) if (!isset($config_data['sections'][$section_name]))
$config_data['sections'][$section_name] = array('vars' => array()); $config_data['sections'][$section_name] = array('vars' => array());
$vars =& $config_data['sections'][$section_name]['vars']; $vars =& $config_data['sections'][$section_name]['vars'];
continue; continue;
} }
if (preg_match('/^\s*(\.?\w+)\s*=\s*(.*)/s', $line, $match)) { if (preg_match('/^\s*(\.?\w+)\s*=\s*(.*)/s', $line, $match)) {
/* variable found */ /* variable found */
$var_name = rtrim($match[1]); $var_name = rtrim($match[1]);
if (strpos($match[2], '"""') === 0) { if (strpos($match[2], '"""') === 0) {
/* handle multiline-value */ /* handle multiline-value */
$lines[$i] = substr($match[2], 3); $lines[$i] = substr($match[2], 3);
$var_value = ''; $var_value = '';
while ($i<$count) { while ($i<$count) {
if (($pos = strpos($lines[$i], '"""')) === false) { if (($pos = strpos($lines[$i], '"""')) === false) {
$var_value .= $lines[$i++]; $var_value .= $lines[$i++];
} else { } else {
/* end of multiline-value */ /* end of multiline-value */
$var_value .= substr($lines[$i], 0, $pos); $var_value .= substr($lines[$i], 0, $pos);
break; break;
} }
} }
$booleanize = false; $booleanize = false;
} else { } else {
/* handle simple value */ /* handle simple value */
$var_value = preg_replace('/^([\'"])(.*)\1$/', '\2', rtrim($match[2])); $var_value = preg_replace('/^([\'"])(.*)\1$/', '\2', rtrim($match[2]));
$booleanize = $this->booleanize; $booleanize = $this->booleanize;
} }
$this->_set_config_var($vars, $var_name, $var_value, $booleanize); $this->_set_config_var($vars, $var_name, $var_value, $booleanize);
} }
/* else unparsable line / means it is a comment / means ignore it */ /* else unparsable line / means it is a comment / means ignore it */
} }
return $config_data; return $config_data;
} }
/**#@+ @access private */ /**#@+ @access private */
/** /**
* @param array &$container * @param array &$container
* @param string $var_name * @param string $var_name
* @param mixed $var_value * @param mixed $var_value
* @param boolean $booleanize determines whether $var_value is converted to * @param boolean $booleanize determines whether $var_value is converted to
* to true/false * to true/false
*/ */
function _set_config_var(&$container, $var_name, $var_value, $booleanize) function _set_config_var(&$container, $var_name, $var_value, $booleanize)
{ {
if (substr($var_name, 0, 1) == '.') { if (substr($var_name, 0, 1) == '.') {
if (!$this->read_hidden) if (!$this->read_hidden)
return; return;
else else
$var_name = substr($var_name, 1); $var_name = substr($var_name, 1);
} }
if (!preg_match("/^[a-zA-Z_]\w*$/", $var_name)) { if (!preg_match("/^[a-zA-Z_]\w*$/", $var_name)) {
$this->_trigger_error_msg("Bad variable name '$var_name'"); $this->_trigger_error_msg("Bad variable name '$var_name'");
return; return;
} }
if ($booleanize) { if ($booleanize) {
if (preg_match("/^(on|true|yes)$/i", $var_value)) if (preg_match("/^(on|true|yes)$/i", $var_value))
$var_value = true; $var_value = true;
else if (preg_match("/^(off|false|no)$/i", $var_value)) else if (preg_match("/^(off|false|no)$/i", $var_value))
$var_value = false; $var_value = false;
} }
if (!isset($container[$var_name]) || $this->overwrite) if (!isset($container[$var_name]) || $this->overwrite)
$container[$var_name] = $var_value; $container[$var_name] = $var_value;
else { else {
settype($container[$var_name], 'array'); settype($container[$var_name], 'array');
$container[$var_name][] = $var_value; $container[$var_name][] = $var_value;
} }
} }
/** /**
* @uses trigger_error() creates a PHP warning/error * @uses trigger_error() creates a PHP warning/error
* @param string $error_msg * @param string $error_msg
* @param integer $error_type one of * @param integer $error_type one of
*/ */
function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING) function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING)
{ {
trigger_error("Config_File error: $error_msg", $error_type); trigger_error("Config_File error: $error_msg", $error_type);
} }
/**#@-*/ /**#@-*/
} }
?> ?>

4
lib/Smarty/Smarty.class.php

@ -27,7 +27,7 @@
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei@php.net> * @author Andrei Zmievski <andrei@php.net>
* @package Smarty * @package Smarty
* @version 2.6.30 * @version 2.6.31-dev
*/ */
/* $Id$ */ /* $Id$ */
@ -465,7 +465,7 @@ class Smarty
* *
* @var string * @var string
*/ */
var $_version = '2.6.30'; var $_version = '2.6.31';
/** /**
* current template inclusion depth * current template inclusion depth

16
lib/Smarty/Smarty_Compiler.class.php

@ -259,14 +259,9 @@ class Smarty_Compiler extends Smarty {
preg_match_all($search, $source_content, $match, PREG_SET_ORDER); preg_match_all($search, $source_content, $match, PREG_SET_ORDER);
$this->_folded_blocks = $match; $this->_folded_blocks = $match;
reset($this->_folded_blocks);
/* replace special blocks by "{php}" */ /* replace special blocks by "{php}" */
$source_content = preg_replace_callback($search, create_function ('$matches', "return '" $source_content = preg_replace_callback($search, array($this,'_preg_callback')
. $this->_quote_replace($this->left_delimiter) . 'php'
. "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
. $this->_quote_replace($this->right_delimiter)
. "';")
, $source_content); , $source_content);
/* Gather all template tags. */ /* Gather all template tags. */
@ -556,7 +551,7 @@ class Smarty_Compiler extends Smarty {
case 'php': case 'php':
/* handle folded tags replaced by {php} */ /* handle folded tags replaced by {php} */
list(, $block) = each($this->_folded_blocks); $block = array_shift($this->_folded_blocks);
$this->_current_line_no += substr_count($block[0], "\n"); $this->_current_line_no += substr_count($block[0], "\n");
/* the number of matched elements in the regexp in _compile_file() /* the number of matched elements in the regexp in _compile_file()
determins the type of folded tag that was found */ determins the type of folded tag that was found */
@ -754,7 +749,12 @@ class Smarty_Compiler extends Smarty {
return true; return true;
} }
function _preg_callback ($matches) {
return $this->_quote_replace($this->left_delimiter)
. 'php'
. str_repeat("\n", substr_count($matches[1], "\n"))
. $this->_quote_replace($this->right_delimiter);
}
/** /**
* compile custom function tag * compile custom function tag
* *

0
lib/Smarty/debug.tpl

0
lib/Smarty/internals/core.assemble_plugin_filepath.php

0
lib/Smarty/internals/core.assign_smarty_interface.php

0
lib/Smarty/internals/core.create_dir_structure.php

0
lib/Smarty/internals/core.display_debug_console.php

0
lib/Smarty/internals/core.get_include_path.php

0
lib/Smarty/internals/core.get_microtime.php

0
lib/Smarty/internals/core.get_php_resource.php

0
lib/Smarty/internals/core.is_secure.php

0
lib/Smarty/internals/core.is_trusted.php

0
lib/Smarty/internals/core.load_plugins.php

0
lib/Smarty/internals/core.load_resource_plugin.php

0
lib/Smarty/internals/core.process_cached_inserts.php

0
lib/Smarty/internals/core.process_compiled_include.php

0
lib/Smarty/internals/core.read_cache_file.php

0
lib/Smarty/internals/core.rm_auto.php

0
lib/Smarty/internals/core.rmdir.php

0
lib/Smarty/internals/core.run_insert_handler.php

0
lib/Smarty/internals/core.smarty_include_php.php

0
lib/Smarty/internals/core.write_cache_file.php

0
lib/Smarty/internals/core.write_compiled_include.php

0
lib/Smarty/internals/core.write_compiled_resource.php

0
lib/Smarty/internals/core.write_file.php

0
lib/Smarty/plugins/block.textformat.php

0
lib/Smarty/plugins/compiler.assign.php

0
lib/Smarty/plugins/function.assign_debug_info.php

0
lib/Smarty/plugins/function.config_load.php

0
lib/Smarty/plugins/function.counter.php

0
lib/Smarty/plugins/function.cycle.php

0
lib/Smarty/plugins/function.debug.php

0
lib/Smarty/plugins/function.eval.php

0
lib/Smarty/plugins/function.fetch.php

0
lib/Smarty/plugins/function.html_checkboxes.php

0
lib/Smarty/plugins/function.html_image.php

0
lib/Smarty/plugins/function.html_options.php

0
lib/Smarty/plugins/function.html_radios.php

0
lib/Smarty/plugins/function.html_select_date.php

0
lib/Smarty/plugins/function.html_select_time.php

0
lib/Smarty/plugins/function.html_table.php

0
lib/Smarty/plugins/function.mailto.php

37
lib/Smarty/plugins/function.math.php

@ -18,11 +18,11 @@
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* *
* @param array $params parameters * @param array $params parameters
* @param Smarty_Internal_Template $template template object * @param Smarty
* *
* @return string|null * @return string|null
*/ */
function smarty_function_math($params, $template) function smarty_function_math($params, &$smarty)
{ {
static $_allowed_funcs = static $_allowed_funcs =
array('int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true, array('int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true,
@ -58,12 +58,28 @@ function smarty_function_math($params, $template)
return; return;
} }
foreach ($params as $key => $val) {
if ($key != "equation" && $key != "format" && $key != "assign") {
// make sure value is not empty
if (strlen($val) == 0) {
trigger_error("math: parameter '{$key}' is empty", E_USER_WARNING);
return;
}
if (!is_numeric($val)) {
trigger_error("math: parameter '{$key}' is not numeric", E_USER_WARNING);
return;
}
}
}
// match all vars in equation, make sure all are passed // match all vars in equation, make sure all are passed
preg_match_all('!(?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)!', $equation, $match); preg_match_all('!(?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)!', $equation, $match);
foreach ($match[ 1 ] as $curr_var) { foreach ($match[ 1 ] as $curr_var) {
if ($curr_var && !isset($params[ $curr_var ]) && !isset($_allowed_funcs[ $curr_var ])) { if ($curr_var && !isset($params[ $curr_var ]) && !isset($_allowed_funcs[ $curr_var ])) {
trigger_error("math: function call $curr_var not allowed", E_USER_WARNING); trigger_error("math: function call '{$curr_var}' not allowed, or missing parameter '{$curr_var}'", E_USER_WARNING);
return; return;
} }
@ -71,17 +87,6 @@ function smarty_function_math($params, $template)
foreach ($params as $key => $val) { foreach ($params as $key => $val) {
if ($key != "equation" && $key != "format" && $key != "assign") { if ($key != "equation" && $key != "format" && $key != "assign") {
// make sure value is not empty
if (strlen($val) == 0) {
trigger_error("math: parameter $key is empty", E_USER_WARNING);
return;
}
if (!is_numeric($val)) {
trigger_error("math: parameter $key: is not numeric", E_USER_WARNING);
return;
}
$equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation); $equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
} }
} }
@ -92,13 +97,13 @@ function smarty_function_math($params, $template)
if (empty($params[ 'assign' ])) { if (empty($params[ 'assign' ])) {
return $smarty_math_result; return $smarty_math_result;
} else { } else {
$template->assign($params[ 'assign' ], $smarty_math_result); $smarty->assign($params[ 'assign' ], $smarty_math_result);
} }
} else { } else {
if (empty($params[ 'assign' ])) { if (empty($params[ 'assign' ])) {
printf($params[ 'format' ], $smarty_math_result); printf($params[ 'format' ], $smarty_math_result);
} else { } else {
$template->assign($params[ 'assign' ], sprintf($params[ 'format' ], $smarty_math_result)); $smarty->assign($params[ 'assign' ], sprintf($params[ 'format' ], $smarty_math_result));
} }
} }
} }

0
lib/Smarty/plugins/function.popup.php

0
lib/Smarty/plugins/function.popup_init.php

0
lib/Smarty/plugins/modifier.capitalize.php

0
lib/Smarty/plugins/modifier.cat.php

0
lib/Smarty/plugins/modifier.count_characters.php

0
lib/Smarty/plugins/modifier.count_paragraphs.php

0
lib/Smarty/plugins/modifier.count_sentences.php

0
lib/Smarty/plugins/modifier.count_words.php

0
lib/Smarty/plugins/modifier.date_format.php

0
lib/Smarty/plugins/modifier.debug_print_var.php

0
lib/Smarty/plugins/modifier.default.php

0
lib/Smarty/plugins/modifier.escape.php

0
lib/Smarty/plugins/modifier.indent.php

0
lib/Smarty/plugins/modifier.lower.php

0
lib/Smarty/plugins/modifier.nl2br.php

0
lib/Smarty/plugins/modifier.regex_replace.php

0
lib/Smarty/plugins/modifier.replace.php

0
lib/Smarty/plugins/modifier.spacify.php

0
lib/Smarty/plugins/modifier.string_format.php

0
lib/Smarty/plugins/modifier.strip.php

0
lib/Smarty/plugins/modifier.strip_tags.php

0
lib/Smarty/plugins/modifier.upper.php

0
lib/Smarty/plugins/modifier.wordwrap.php

0
lib/Smarty/plugins/outputfilter.trimwhitespace.php

0
lib/Smarty/plugins/shared.escape_special_chars.php

0
lib/Smarty/plugins/shared.make_timestamp.php

Loading…
Cancel
Save