diff --git a/class/class.modules.php b/class/class.modules.php
index 9fa3168..fde50f6 100755
--- a/class/class.modules.php
+++ b/class/class.modules.php
@@ -14,17 +14,28 @@
{
public $_modules = [];
+ private static $instance = null;
- function __construct()
+
+ function __construct ()
{
$this->_modules = $this->getModules();
}
+ public static function init ()
+ {
+ if (is_null(self::$instance))
+ self::$instance = new AVE_Module;
+
+ return self::$instance;
+ }
+
+
/**
* Метод, который обрабатывает все module.php и записывает как свойство класса списки модулей
*/
- function getModules()
+ function getModules ()
{
$modules = [];
@@ -61,7 +72,7 @@
if (! is_dir($module_dir))
continue;
- $module = array();
+ $module = array ();
// Если не удалось подключить основной файл модуля module.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;
- $assign = array(); // Массив для передачи в Smarty
- $errors = array(); // Массив с ошибками
+ $assign = []; // Массив для передачи в Smarty
+ $errors = []; // Массив с ошибками
// Получаем список всех шаблонов
- $sql = $AVE_DB->Query("
+ $sql = "
SELECT
Id,
template_title
FROM
" . 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);
// Заголовок: Автор модуля
@@ -147,7 +160,7 @@
// Получаем список всех модулей
$modules = $this->_modules;
- foreach ($modules as $module)
+ foreach ($modules AS $module)
{
$module['info'] = $module['ModuleDescription'] . (! $module['ModuleAutor']
? '
'
@@ -246,7 +259,7 @@
* Метод, предназначенный для обновления в БД информации о шаблонах модулей
*
*/
- function moduleOptionsSave()
+ function moduleOptionsSave ()
{
global $AVE_DB;
@@ -264,7 +277,7 @@
");
}
- $this->clearModulesCache();
+ $this->clearModulesCache ();
// Выполянем обновление страницы со списком модулей
header('Location:index.php?do=modules&cp=' . SESSION);
@@ -276,7 +289,7 @@
* Метод, предназанченный для установки или переустановки модуля
*
*/
- function moduleInstall()
+ function moduleInstall ()
{
global $AVE_DB, $AVE_Template;
@@ -359,12 +372,14 @@
* Метод, предназначенный для обновления модуля при увеличении номера версии модуля
*
*/
- function moduleUpdate()
+ function moduleUpdate ()
{
global $AVE_DB, $AVE_Template;
// Подключаем файл с запросами к БД для данного модуля
- $module_sql_update = array();
+ $module_sql_update = [];
+
+ $module = [];
$sql_file = BASE_DIR . '/modules/' . MODULE_PATH . '/sql.php';
@@ -378,31 +393,35 @@
// Выполняем запросы обновления модуля
// из массива $module_sql_update файла sql.php
foreach ($module_sql_update as $sql)
- {
$AVE_DB->Query(str_replace('%%PRFX%%', PREFIX, $sql));
- }
}
// Обновляем модуль, если в нем не применяется (отсутствует) файл sql.php
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 . ')');
@@ -419,7 +438,7 @@
* Метод, предназанченный для удаление модуля
*
*/
- function moduleDelete()
+ function moduleDelete ()
{
global $AVE_DB, $AVE_Template;
@@ -462,7 +481,7 @@
* Метод, предназначенный для отключения/включение модуля в Панели управления
*
*/
- function moduleStatusChange()
+ function moduleStatusChange ()
{
global $AVE_DB, $AVE_Template;
@@ -490,7 +509,7 @@
ModuleSysName = '" . MODULE_PATH . "'
");
- $this->clearModulesCache();
+ $this->clearModulesCache ();
// Сохраняем системное сообщение в журнал
reportLog ((($ModuleStatus == "0")
@@ -503,7 +522,7 @@
}
- function moduleRemove($dir)
+ function moduleRemove ($dir)
{
global $AVE_DB, $AVE_Template;
@@ -514,7 +533,7 @@
foreach ($files as $file)
{
if(substr($file, -1) == '/')
- moduleRemove($file);
+ $this->moduleRemove($file);
else
unlink($file);
}
diff --git a/inc/init.php b/inc/init.php
index 0f62c3e..e7ad4ee 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -433,5 +433,5 @@
//-- Класс Модулей
require (BASE_DIR . '/class/class.modules.php');
- $AVE_Module = new AVE_Module;
+ $AVE_Module = AVE_Module::init();
?>
\ No newline at end of file
diff --git a/lib/Smarty/Config_File.class.php b/lib/Smarty/Config_File.class.php
old mode 100755
new mode 100644
index 9eb9d57..6d8c298
--- a/lib/Smarty/Config_File.class.php
+++ b/lib/Smarty/Config_File.class.php
@@ -10,384 +10,384 @@
*
* This library 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* 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
* Smarty mailing list. Send a blank e-mail to
- * smarty-discussion-subscribe@googlegroups.com
+ * smarty-discussion-subscribe@googlegroups.com
*
* @link http://www.smarty.net/
- * @version 2.6.26
+ * @version 2.6.25-dev
* @copyright Copyright: 2001-2005 New Digital Group, Inc.
* @author Andrei Zmievski
* @access public
* @package Smarty
*/
-/* $Id: Config_File.class.php 3149 2009-05-23 20:59:25Z monte.ohrt $ */
+/* $Id$ */
/**
* Config file reading class
* @package Smarty
*/
class Config_File {
- /**#@+
- * Options
- * @var boolean
- */
- /**
- * Controls whether variables with the same name overwrite each other.
- */
- var $overwrite = true;
-
- /**
- * Controls whether config values of on/true/yes and off/false/no get
- * converted to boolean values automatically.
- */
- var $booleanize = true;
-
- /**
- * Controls whether hidden config sections/vars are read from the file.
- */
- var $read_hidden = true;
-
- /**
- * Controls whether or not to fix mac or dos formatted newlines.
- * If set to true, \r or \r\n will be changed to \n.
- */
- var $fix_newlines = true;
- /**#@-*/
-
- /** @access private */
- var $_config_path = "";
- var $_config_data = array();
- /**#@-*/
-
- /**
- * Constructs a new config file class.
- *
- * @param string $config_path (optional) path to the config files
- */
- function __construct($config_path = NULL)
- {
- if (isset($config_path))
- $this->set_path($config_path);
- }
-
-
- /**
- * Set the path where configuration files can be found.
- *
- * @param string $config_path path to the config files
- */
- function set_path($config_path)
- {
- if (!empty($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'");
- return;
- }
- if(substr($config_path, -1) != DIRECTORY_SEPARATOR) {
- $config_path .= DIRECTORY_SEPARATOR;
- }
-
- $this->_config_path = $config_path;
- }
- }
-
-
- /**
- * Retrieves config info based on the file, section, and variable name.
- *
- * @param string $file_name config file to get info for
- * @param string $section_name (optional) section to get info for
- * @param string $var_name (optional) variable to get info for
- * @return string|array a value or array of values
- */
- function get($file_name, $section_name = NULL, $var_name = NULL)
- {
- if (empty($file_name)) {
- $this->_trigger_error_msg('Empty config file name');
- return;
- } else {
- $file_name = $this->_config_path . $file_name;
- if (!isset($this->_config_data[$file_name]))
- $this->load_file($file_name, false);
- }
-
- 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();
- }
- }
- }
-
-
- /**
- * Retrieves config info based on the key.
- *
- * @param $file_name string config key (filename/section/var)
- * @return string|array same as get()
- * @uses get() retrieves information from config file and returns it
- */
- function &get_key($config_key)
- {
- list($file_name, $section_name, $var_name) = explode('/', $config_key, 3);
- $result = &$this->get($file_name, $section_name, $var_name);
- return $result;
- }
-
- /**
- * Get all loaded config file names.
- *
- * @return array an array of loaded config file names
- */
- function get_file_names()
- {
- return array_keys($this->_config_data);
- }
-
-
- /**
- * Get all section names from a loaded file.
- *
- * @param string $file_name config file to get section names from
- * @return array an array of section names from the specified file
- */
- function get_section_names($file_name)
- {
- $file_name = $this->_config_path . $file_name;
- if (!isset($this->_config_data[$file_name])) {
- $this->_trigger_error_msg("Unknown config file '$file_name'");
- return;
- }
-
- return array_keys($this->_config_data[$file_name]["sections"]);
- }
-
-
- /**
- * Get all global or section variable names.
- *
- * @param string $file_name config file 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
- */
- function get_var_names($file_name, $section = NULL)
- {
- if (empty($file_name)) {
- $this->_trigger_error_msg('Empty config file name');
- return;
- } else if (!isset($this->_config_data[$file_name])) {
- $this->_trigger_error_msg("Unknown config file '$file_name'");
- return;
- }
-
- if (empty($section))
- return array_keys($this->_config_data[$file_name]["vars"]);
- else
- return array_keys($this->_config_data[$file_name]["sections"][$section]["vars"]);
- }
-
-
- /**
- * Clear loaded config data for a certain file or all files.
- *
- * @param string $file_name file to clear config data for
- */
- function clear($file_name = NULL)
- {
- if ($file_name === NULL)
- $this->_config_data = array();
- else if (isset($this->_config_data[$file_name]))
- $this->_config_data[$file_name] = array();
- }
-
-
- /**
- * Load a configuration file manually.
- *
- * @param string $file_name file name to load
- * @param boolean $prepend_path whether current config path should be
- * prepended to the filename
- */
- function load_file($file_name, $prepend_path = true)
- {
- if ($prepend_path && $this->_config_path != "")
- $config_file = $this->_config_path . $file_name;
- else
- $config_file = $file_name;
-
- ini_set('track_errors', true);
- $fp = @fopen($config_file, "r");
- if (!is_resource($fp)) {
- $this->_trigger_error_msg("Could not open config file '$config_file'");
- return false;
- }
-
- $contents = ($size = filesize($config_file)) ? fread($fp, $size) : '';
- fclose($fp);
-
- $this->_config_data[$config_file] = $this->parse_contents($contents);
- return true;
- }
-
- /**
- * Store the contents of a file manually.
- *
- * @param string $config_file file name of the related contents
- * @param string $contents the file-contents to parse
- */
- function set_file_contents($config_file, $contents)
- {
- $this->_config_data[$config_file] = $this->parse_contents($contents);
- return true;
- }
-
- /**
- * parse the source of a configuration file manually.
- *
- * @param string $contents the file-contents to parse
- */
- function parse_contents($contents)
- {
- if($this->fix_newlines) {
- // fix mac/dos formatted newlines
- $contents = preg_replace('!\r\n?!', "\n", $contents);
- }
-
- $config_data = array();
- $config_data['sections'] = array();
- $config_data['vars'] = array();
-
- /* reference to fill with data */
- $vars =& $config_data['vars'];
-
- /* parse file line by line */
- preg_match_all('!^.*\r?\n?!m', $contents, $match);
- $lines = $match[0];
- for ($i=0, $count=count($lines); $i<$count; $i++) {
- $line = $lines[$i];
- if (empty($line)) continue;
-
- if ( substr($line, 0, 1) == '[' && preg_match('!^\[(.*?)\]!', $line, $match) ) {
- /* section found */
- if (substr($match[1], 0, 1) == '.') {
- /* hidden section */
- if ($this->read_hidden) {
- $section_name = substr($match[1], 1);
- } else {
- /* break reference to $vars to ignore hidden section */
- unset($vars);
- $vars = array();
- continue;
- }
- } else {
- $section_name = $match[1];
- }
- if (!isset($config_data['sections'][$section_name]))
- $config_data['sections'][$section_name] = array('vars' => array());
- $vars =& $config_data['sections'][$section_name]['vars'];
- continue;
- }
-
- if (preg_match('/^\s*(\.?\w+)\s*=\s*(.*)/s', $line, $match)) {
- /* variable found */
- $var_name = rtrim($match[1]);
- if (strpos($match[2], '"""') === 0) {
- /* handle multiline-value */
- $lines[$i] = substr($match[2], 3);
- $var_value = '';
- while ($i<$count) {
- if (($pos = strpos($lines[$i], '"""')) === false) {
- $var_value .= $lines[$i++];
- } else {
- /* end of multiline-value */
- $var_value .= substr($lines[$i], 0, $pos);
- break;
- }
- }
- $booleanize = false;
-
- } else {
- /* handle simple value */
- $var_value = preg_replace('/^([\'"])(.*)\1$/', '\2', rtrim($match[2]));
- $booleanize = $this->booleanize;
-
- }
- $this->_set_config_var($vars, $var_name, $var_value, $booleanize);
- }
- /* else unparsable line / means it is a comment / means ignore it */
- }
- return $config_data;
- }
-
- /**#@+ @access private */
- /**
- * @param array &$container
- * @param string $var_name
- * @param mixed $var_value
- * @param boolean $booleanize determines whether $var_value is converted to
- * to true/false
- */
- function _set_config_var(&$container, $var_name, $var_value, $booleanize)
- {
- if (substr($var_name, 0, 1) == '.') {
- if (!$this->read_hidden)
- return;
- else
- $var_name = substr($var_name, 1);
- }
-
- if (!preg_match("/^[a-zA-Z_]\w*$/", $var_name)) {
- $this->_trigger_error_msg("Bad variable name '$var_name'");
- return;
- }
-
- if ($booleanize) {
- if (preg_match("/^(on|true|yes)$/i", $var_value))
- $var_value = true;
- else if (preg_match("/^(off|false|no)$/i", $var_value))
- $var_value = false;
- }
-
- if (!isset($container[$var_name]) || $this->overwrite)
- $container[$var_name] = $var_value;
- else {
- settype($container[$var_name], 'array');
- $container[$var_name][] = $var_value;
- }
- }
-
- /**
- * @uses trigger_error() creates a PHP warning/error
- * @param string $error_msg
- * @param integer $error_type one of
- */
- function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING)
- {
- trigger_error("Config_File error: $error_msg", $error_type);
- }
- /**#@-*/
+ /**#@+
+ * Options
+ * @var boolean
+ */
+ /**
+ * Controls whether variables with the same name overwrite each other.
+ */
+ var $overwrite = true;
+
+ /**
+ * Controls whether config values of on/true/yes and off/false/no get
+ * converted to boolean values automatically.
+ */
+ var $booleanize = true;
+
+ /**
+ * Controls whether hidden config sections/vars are read from the file.
+ */
+ var $read_hidden = true;
+
+ /**
+ * Controls whether or not to fix mac or dos formatted newlines.
+ * If set to true, \r or \r\n will be changed to \n.
+ */
+ var $fix_newlines = true;
+ /**#@-*/
+
+ /** @access private */
+ var $_config_path = "";
+ var $_config_data = array();
+ /**#@-*/
+
+ /**
+ * Constructs a new config file class.
+ *
+ * @param string $config_path (optional) path to the config files
+ */
+ public function __construct($config_path = NULL)
+ {
+ if (isset($config_path))
+ $this->set_path($config_path);
+ }
+
+
+ /**
+ * Set the path where configuration files can be found.
+ *
+ * @param string $config_path path to the config files
+ */
+ function set_path($config_path)
+ {
+ if (!empty($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'");
+ return;
+ }
+ if(substr($config_path, -1) != DIRECTORY_SEPARATOR) {
+ $config_path .= DIRECTORY_SEPARATOR;
+ }
+
+ $this->_config_path = $config_path;
+ }
+ }
+
+
+ /**
+ * Retrieves config info based on the file, section, and variable name.
+ *
+ * @param string $file_name config file to get info for
+ * @param string $section_name (optional) section to get info for
+ * @param string $var_name (optional) variable to get info for
+ * @return string|array a value or array of values
+ */
+ function get($file_name, $section_name = NULL, $var_name = NULL)
+ {
+ if (empty($file_name)) {
+ $this->_trigger_error_msg('Empty config file name');
+ return;
+ } else {
+ $file_name = $this->_config_path . $file_name;
+ if (!isset($this->_config_data[$file_name]))
+ $this->load_file($file_name, false);
+ }
+
+ 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();
+ }
+ }
+ }
+
+
+ /**
+ * Retrieves config info based on the key.
+ *
+ * @param $file_name string config key (filename/section/var)
+ * @return string|array same as get()
+ * @uses get() retrieves information from config file and returns it
+ */
+ function &get_key($config_key)
+ {
+ list($file_name, $section_name, $var_name) = explode('/', $config_key, 3);
+ $result = &$this->get($file_name, $section_name, $var_name);
+ return $result;
+ }
+
+ /**
+ * Get all loaded config file names.
+ *
+ * @return array an array of loaded config file names
+ */
+ function get_file_names()
+ {
+ return array_keys($this->_config_data);
+ }
+
+
+ /**
+ * Get all section names from a loaded file.
+ *
+ * @param string $file_name config file to get section names from
+ * @return array an array of section names from the specified file
+ */
+ function get_section_names($file_name)
+ {
+ $file_name = $this->_config_path . $file_name;
+ if (!isset($this->_config_data[$file_name])) {
+ $this->_trigger_error_msg("Unknown config file '$file_name'");
+ return;
+ }
+
+ return array_keys($this->_config_data[$file_name]["sections"]);
+ }
+
+
+ /**
+ * Get all global or section variable names.
+ *
+ * @param string $file_name config file 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
+ */
+ function get_var_names($file_name, $section = NULL)
+ {
+ if (empty($file_name)) {
+ $this->_trigger_error_msg('Empty config file name');
+ return;
+ } else if (!isset($this->_config_data[$file_name])) {
+ $this->_trigger_error_msg("Unknown config file '$file_name'");
+ return;
+ }
+
+ if (empty($section))
+ return array_keys($this->_config_data[$file_name]["vars"]);
+ else
+ return array_keys($this->_config_data[$file_name]["sections"][$section]["vars"]);
+ }
+
+
+ /**
+ * Clear loaded config data for a certain file or all files.
+ *
+ * @param string $file_name file to clear config data for
+ */
+ function clear($file_name = NULL)
+ {
+ if ($file_name === NULL)
+ $this->_config_data = array();
+ else if (isset($this->_config_data[$file_name]))
+ $this->_config_data[$file_name] = array();
+ }
+
+
+ /**
+ * Load a configuration file manually.
+ *
+ * @param string $file_name file name to load
+ * @param boolean $prepend_path whether current config path should be
+ * prepended to the filename
+ */
+ function load_file($file_name, $prepend_path = true)
+ {
+ if ($prepend_path && $this->_config_path != "")
+ $config_file = $this->_config_path . $file_name;
+ else
+ $config_file = $file_name;
+
+ ini_set('track_errors', true);
+ $fp = @fopen($config_file, "r");
+ if (!is_resource($fp)) {
+ $this->_trigger_error_msg("Could not open config file '$config_file'");
+ return false;
+ }
+
+ $contents = ($size = filesize($config_file)) ? fread($fp, $size) : '';
+ fclose($fp);
+
+ $this->_config_data[$config_file] = $this->parse_contents($contents);
+ return true;
+ }
+
+ /**
+ * Store the contents of a file manually.
+ *
+ * @param string $config_file file name of the related contents
+ * @param string $contents the file-contents to parse
+ */
+ function set_file_contents($config_file, $contents)
+ {
+ $this->_config_data[$config_file] = $this->parse_contents($contents);
+ return true;
+ }
+
+ /**
+ * parse the source of a configuration file manually.
+ *
+ * @param string $contents the file-contents to parse
+ */
+ function parse_contents($contents)
+ {
+ if($this->fix_newlines) {
+ // fix mac/dos formatted newlines
+ $contents = preg_replace('!\r\n?!', "\n", $contents);
+ }
+
+ $config_data = array();
+ $config_data['sections'] = array();
+ $config_data['vars'] = array();
+
+ /* reference to fill with data */
+ $vars =& $config_data['vars'];
+
+ /* parse file line by line */
+ preg_match_all('!^.*\r?\n?!m', $contents, $match);
+ $lines = $match[0];
+ for ($i=0, $count=count($lines); $i<$count; $i++) {
+ $line = $lines[$i];
+ if (empty($line)) continue;
+
+ if ( substr($line, 0, 1) == '[' && preg_match('!^\[(.*?)\]!', $line, $match) ) {
+ /* section found */
+ if (substr($match[1], 0, 1) == '.') {
+ /* hidden section */
+ if ($this->read_hidden) {
+ $section_name = substr($match[1], 1);
+ } else {
+ /* break reference to $vars to ignore hidden section */
+ unset($vars);
+ $vars = array();
+ continue;
+ }
+ } else {
+ $section_name = $match[1];
+ }
+ if (!isset($config_data['sections'][$section_name]))
+ $config_data['sections'][$section_name] = array('vars' => array());
+ $vars =& $config_data['sections'][$section_name]['vars'];
+ continue;
+ }
+
+ if (preg_match('/^\s*(\.?\w+)\s*=\s*(.*)/s', $line, $match)) {
+ /* variable found */
+ $var_name = rtrim($match[1]);
+ if (strpos($match[2], '"""') === 0) {
+ /* handle multiline-value */
+ $lines[$i] = substr($match[2], 3);
+ $var_value = '';
+ while ($i<$count) {
+ if (($pos = strpos($lines[$i], '"""')) === false) {
+ $var_value .= $lines[$i++];
+ } else {
+ /* end of multiline-value */
+ $var_value .= substr($lines[$i], 0, $pos);
+ break;
+ }
+ }
+ $booleanize = false;
+
+ } else {
+ /* handle simple value */
+ $var_value = preg_replace('/^([\'"])(.*)\1$/', '\2', rtrim($match[2]));
+ $booleanize = $this->booleanize;
+
+ }
+ $this->_set_config_var($vars, $var_name, $var_value, $booleanize);
+ }
+ /* else unparsable line / means it is a comment / means ignore it */
+ }
+ return $config_data;
+ }
+
+ /**#@+ @access private */
+ /**
+ * @param array &$container
+ * @param string $var_name
+ * @param mixed $var_value
+ * @param boolean $booleanize determines whether $var_value is converted to
+ * to true/false
+ */
+ function _set_config_var(&$container, $var_name, $var_value, $booleanize)
+ {
+ if (substr($var_name, 0, 1) == '.') {
+ if (!$this->read_hidden)
+ return;
+ else
+ $var_name = substr($var_name, 1);
+ }
+
+ if (!preg_match("/^[a-zA-Z_]\w*$/", $var_name)) {
+ $this->_trigger_error_msg("Bad variable name '$var_name'");
+ return;
+ }
+
+ if ($booleanize) {
+ if (preg_match("/^(on|true|yes)$/i", $var_value))
+ $var_value = true;
+ else if (preg_match("/^(off|false|no)$/i", $var_value))
+ $var_value = false;
+ }
+
+ if (!isset($container[$var_name]) || $this->overwrite)
+ $container[$var_name] = $var_value;
+ else {
+ settype($container[$var_name], 'array');
+ $container[$var_name][] = $var_value;
+ }
+ }
+
+ /**
+ * @uses trigger_error() creates a PHP warning/error
+ * @param string $error_msg
+ * @param integer $error_type one of
+ */
+ function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING)
+ {
+ trigger_error("Config_File error: $error_msg", $error_type);
+ }
+ /**#@-*/
}
?>
diff --git a/lib/Smarty/Smarty.class.php b/lib/Smarty/Smarty.class.php
old mode 100755
new mode 100644
index 3da9744..a06e8ff
--- a/lib/Smarty/Smarty.class.php
+++ b/lib/Smarty/Smarty.class.php
@@ -27,7 +27,7 @@
* @author Monte Ohrt
* @author Andrei Zmievski
* @package Smarty
- * @version 2.6.30
+ * @version 2.6.31-dev
*/
/* $Id$ */
@@ -465,7 +465,7 @@ class Smarty
*
* @var string
*/
- var $_version = '2.6.30';
+ var $_version = '2.6.31';
/**
* current template inclusion depth
diff --git a/lib/Smarty/Smarty_Compiler.class.php b/lib/Smarty/Smarty_Compiler.class.php
old mode 100755
new mode 100644
index 0060215..904601d
--- a/lib/Smarty/Smarty_Compiler.class.php
+++ b/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);
$this->_folded_blocks = $match;
- reset($this->_folded_blocks);
/* replace special blocks by "{php}" */
- $source_content = preg_replace_callback($search, create_function ('$matches', "return '"
- . $this->_quote_replace($this->left_delimiter) . 'php'
- . "' . str_repeat(\"\n\", substr_count('\$matches[1]', \"\n\")) .'"
- . $this->_quote_replace($this->right_delimiter)
- . "';")
+ $source_content = preg_replace_callback($search, array($this,'_preg_callback')
, $source_content);
/* Gather all template tags. */
@@ -556,7 +551,7 @@ class Smarty_Compiler extends Smarty {
case '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");
/* the number of matched elements in the regexp in _compile_file()
determins the type of folded tag that was found */
@@ -754,7 +749,12 @@ class Smarty_Compiler extends Smarty {
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
*
diff --git a/lib/Smarty/debug.tpl b/lib/Smarty/debug.tpl
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.assemble_plugin_filepath.php b/lib/Smarty/internals/core.assemble_plugin_filepath.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.assign_smarty_interface.php b/lib/Smarty/internals/core.assign_smarty_interface.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.create_dir_structure.php b/lib/Smarty/internals/core.create_dir_structure.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.display_debug_console.php b/lib/Smarty/internals/core.display_debug_console.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.get_include_path.php b/lib/Smarty/internals/core.get_include_path.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.get_microtime.php b/lib/Smarty/internals/core.get_microtime.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.get_php_resource.php b/lib/Smarty/internals/core.get_php_resource.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.is_secure.php b/lib/Smarty/internals/core.is_secure.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.is_trusted.php b/lib/Smarty/internals/core.is_trusted.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.load_plugins.php b/lib/Smarty/internals/core.load_plugins.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.load_resource_plugin.php b/lib/Smarty/internals/core.load_resource_plugin.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.process_cached_inserts.php b/lib/Smarty/internals/core.process_cached_inserts.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.process_compiled_include.php b/lib/Smarty/internals/core.process_compiled_include.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.read_cache_file.php b/lib/Smarty/internals/core.read_cache_file.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.rm_auto.php b/lib/Smarty/internals/core.rm_auto.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.rmdir.php b/lib/Smarty/internals/core.rmdir.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.run_insert_handler.php b/lib/Smarty/internals/core.run_insert_handler.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.smarty_include_php.php b/lib/Smarty/internals/core.smarty_include_php.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.write_cache_file.php b/lib/Smarty/internals/core.write_cache_file.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.write_compiled_include.php b/lib/Smarty/internals/core.write_compiled_include.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.write_compiled_resource.php b/lib/Smarty/internals/core.write_compiled_resource.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/internals/core.write_file.php b/lib/Smarty/internals/core.write_file.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/block.textformat.php b/lib/Smarty/plugins/block.textformat.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/compiler.assign.php b/lib/Smarty/plugins/compiler.assign.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.assign_debug_info.php b/lib/Smarty/plugins/function.assign_debug_info.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.config_load.php b/lib/Smarty/plugins/function.config_load.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.counter.php b/lib/Smarty/plugins/function.counter.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.cycle.php b/lib/Smarty/plugins/function.cycle.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.debug.php b/lib/Smarty/plugins/function.debug.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.eval.php b/lib/Smarty/plugins/function.eval.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.fetch.php b/lib/Smarty/plugins/function.fetch.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.html_checkboxes.php b/lib/Smarty/plugins/function.html_checkboxes.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.html_image.php b/lib/Smarty/plugins/function.html_image.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.html_options.php b/lib/Smarty/plugins/function.html_options.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.html_radios.php b/lib/Smarty/plugins/function.html_radios.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.html_select_date.php b/lib/Smarty/plugins/function.html_select_date.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.html_select_time.php b/lib/Smarty/plugins/function.html_select_time.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.html_table.php b/lib/Smarty/plugins/function.html_table.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.mailto.php b/lib/Smarty/plugins/function.mailto.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.math.php b/lib/Smarty/plugins/function.math.php
old mode 100755
new mode 100644
index 655fe72..d0ce1e6
--- a/lib/Smarty/plugins/function.math.php
+++ b/lib/Smarty/plugins/function.math.php
@@ -18,11 +18,11 @@
* @author Monte Ohrt
*
* @param array $params parameters
- * @param Smarty_Internal_Template $template template object
+ * @param Smarty
*
* @return string|null
*/
-function smarty_function_math($params, $template)
+function smarty_function_math($params, &$smarty)
{
static $_allowed_funcs =
array('int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true,
@@ -58,12 +58,28 @@ function smarty_function_math($params, $template)
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
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) {
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;
}
@@ -71,17 +87,6 @@ function smarty_function_math($params, $template)
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;
- }
$equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
}
}
@@ -92,13 +97,13 @@ function smarty_function_math($params, $template)
if (empty($params[ 'assign' ])) {
return $smarty_math_result;
} else {
- $template->assign($params[ 'assign' ], $smarty_math_result);
+ $smarty->assign($params[ 'assign' ], $smarty_math_result);
}
} else {
if (empty($params[ 'assign' ])) {
printf($params[ 'format' ], $smarty_math_result);
} else {
- $template->assign($params[ 'assign' ], sprintf($params[ 'format' ], $smarty_math_result));
+ $smarty->assign($params[ 'assign' ], sprintf($params[ 'format' ], $smarty_math_result));
}
}
}
diff --git a/lib/Smarty/plugins/function.popup.php b/lib/Smarty/plugins/function.popup.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/function.popup_init.php b/lib/Smarty/plugins/function.popup_init.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.capitalize.php b/lib/Smarty/plugins/modifier.capitalize.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.cat.php b/lib/Smarty/plugins/modifier.cat.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.count_characters.php b/lib/Smarty/plugins/modifier.count_characters.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.count_paragraphs.php b/lib/Smarty/plugins/modifier.count_paragraphs.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.count_sentences.php b/lib/Smarty/plugins/modifier.count_sentences.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.count_words.php b/lib/Smarty/plugins/modifier.count_words.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.date_format.php b/lib/Smarty/plugins/modifier.date_format.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.debug_print_var.php b/lib/Smarty/plugins/modifier.debug_print_var.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.default.php b/lib/Smarty/plugins/modifier.default.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.escape.php b/lib/Smarty/plugins/modifier.escape.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.indent.php b/lib/Smarty/plugins/modifier.indent.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.lower.php b/lib/Smarty/plugins/modifier.lower.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.nl2br.php b/lib/Smarty/plugins/modifier.nl2br.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.regex_replace.php b/lib/Smarty/plugins/modifier.regex_replace.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.replace.php b/lib/Smarty/plugins/modifier.replace.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.spacify.php b/lib/Smarty/plugins/modifier.spacify.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.string_format.php b/lib/Smarty/plugins/modifier.string_format.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.strip.php b/lib/Smarty/plugins/modifier.strip.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.strip_tags.php b/lib/Smarty/plugins/modifier.strip_tags.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.upper.php b/lib/Smarty/plugins/modifier.upper.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/modifier.wordwrap.php b/lib/Smarty/plugins/modifier.wordwrap.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/outputfilter.trimwhitespace.php b/lib/Smarty/plugins/outputfilter.trimwhitespace.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/shared.escape_special_chars.php b/lib/Smarty/plugins/shared.escape_special_chars.php
old mode 100755
new mode 100644
diff --git a/lib/Smarty/plugins/shared.make_timestamp.php b/lib/Smarty/plugins/shared.make_timestamp.php
old mode 100755
new mode 100644