From 97290b236ddef5377dacaab076ccb906a64196ca Mon Sep 17 00:00:00 2001 From: "M@dD3n" Date: Mon, 19 Aug 2019 09:34:29 +0300 Subject: [PATCH] Fixes --- admin/lang/ru/sysblocks.txt | 5 +- admin/templates/sysblocks/form.tpl | 8 +- admin/templates/sysblocks/form_visual.tpl | 0 admin/templates/sysblocks/list.tpl | 2 +- admin/templates/sysblocks/multi.tpl | 0 admin/templates/sysblocks/nav.tpl | 0 class/class.blocks.php | 0 class/class.core.php | 146 ++++--------- class/class.dbdump.php | 0 class/class.debug.php | 72 ++++--- class/class.docs.php | 2 +- class/class.hooks.php | 0 class/class.logs.php | 0 class/class.meta.php | 30 ++- class/class.modules.php | 5 +- class/class.navigation.php | 0 class/class.paginations.php | 6 +- class/class.porter.php | 0 class/class.request.php | 0 class/class.session.files.php | 0 class/class.session.memcached.php | 0 class/class.session.php | 246 +++++++++++----------- class/class.settings.php | 0 class/class.sysblocks.php | 17 +- class/class.template.php | 0 class/class.templates.php | 0 class/class.user.php | 0 class/class.utm.php | 170 +++++++-------- functions/.htaccess | 0 functions/func.common.php | 2 +- functions/func.fields.php | 101 +++++++-- functions/func.pagination.php | 4 +- functions/func.parserequest.php | 44 ++-- functions/func.sysblock.php | 100 ++++++++- tmp/update/sql.update.php | 25 ++- 35 files changed, 568 insertions(+), 417 deletions(-) mode change 100644 => 100755 admin/lang/ru/sysblocks.txt mode change 100644 => 100755 admin/templates/sysblocks/form.tpl mode change 100644 => 100755 admin/templates/sysblocks/form_visual.tpl mode change 100644 => 100755 admin/templates/sysblocks/list.tpl mode change 100644 => 100755 admin/templates/sysblocks/multi.tpl mode change 100644 => 100755 admin/templates/sysblocks/nav.tpl mode change 100644 => 100755 class/class.blocks.php mode change 100644 => 100755 class/class.dbdump.php mode change 100644 => 100755 class/class.hooks.php mode change 100644 => 100755 class/class.logs.php mode change 100644 => 100755 class/class.meta.php mode change 100644 => 100755 class/class.modules.php mode change 100644 => 100755 class/class.navigation.php mode change 100644 => 100755 class/class.paginations.php mode change 100644 => 100755 class/class.porter.php mode change 100644 => 100755 class/class.request.php mode change 100644 => 100755 class/class.session.files.php mode change 100644 => 100755 class/class.session.memcached.php mode change 100644 => 100755 class/class.session.php mode change 100644 => 100755 class/class.settings.php mode change 100644 => 100755 class/class.sysblocks.php mode change 100644 => 100755 class/class.template.php mode change 100644 => 100755 class/class.templates.php mode change 100644 => 100755 class/class.user.php mode change 100644 => 100755 class/class.utm.php mode change 100644 => 100755 functions/.htaccess diff --git a/admin/lang/ru/sysblocks.txt b/admin/lang/ru/sysblocks.txt old mode 100644 new mode 100755 index 8d2b540..d5e451e --- a/admin/lang/ru/sysblocks.txt +++ b/admin/lang/ru/sysblocks.txt @@ -73,4 +73,7 @@ SYSBLOCK_ALIAS = "Алиас" SYSBLOCK_I = "Опционально. Алиас позволяет использовать легко запоминающийся тег [tag:sysblock:alias] вместо [tag:sysblock:id]. Алиас не должен являться числом, может содержать только цифры, латинские буквы, дефис, подчёркивание, иметь длину не более 20 символов и быть уникальным в пределах модуля" SYSBLOCK_ACCEPT = "Этот алиас можно использовать" SYSBLOCK_ER_SYN = "Неверный алиас!
Алиас не должен являться числом, может содержать только цифры, латинские буквы, дефис, подчёркивание и иметь длину не более 20 символов" -SYSBLOCK_ER_EXISTS = "Неверный алиас!
Данный алиас уже привязан к другоому системному блоку" \ No newline at end of file +SYSBLOCK_ER_EXISTS = "Неверный алиас!
Данный алиас уже привязан к другоому системному блоку" + +// v 3.25 +SYSBLOCK_EVAL = "Выполнять PHP перед выозвращением результата" \ No newline at end of file diff --git a/admin/templates/sysblocks/form.tpl b/admin/templates/sysblocks/form.tpl old mode 100644 new mode 100755 index afc4fe6..c991080 --- a/admin/templates/sysblocks/form.tpl +++ b/admin/templates/sysblocks/form.tpl @@ -42,7 +42,7 @@ {#SYSBLOCK_NAME#} - +
@@ -50,7 +50,7 @@ {#SYSBLOCK_DESCRIPTION#} - + @@ -60,7 +60,7 @@ [?] {#SYSBLOCK_ALIAS#}: - +
  @@ -81,7 +81,7 @@ - + {if $sysblock_external} diff --git a/admin/templates/sysblocks/form_visual.tpl b/admin/templates/sysblocks/form_visual.tpl old mode 100644 new mode 100755 diff --git a/admin/templates/sysblocks/list.tpl b/admin/templates/sysblocks/list.tpl old mode 100644 new mode 100755 index b71f84e..1346805 --- a/admin/templates/sysblocks/list.tpl +++ b/admin/templates/sysblocks/list.tpl @@ -120,7 +120,7 @@ {$sysblock->sysblock_author_id|escape} - {$sysblock->sysblock_created|date_format:$TIME_FORMAT|pretty_date} + {$sysblock->sysblock_created|date_format:$TIME_FORMAT|translate_date} diff --git a/admin/templates/sysblocks/multi.tpl b/admin/templates/sysblocks/multi.tpl old mode 100644 new mode 100755 diff --git a/admin/templates/sysblocks/nav.tpl b/admin/templates/sysblocks/nav.tpl old mode 100644 new mode 100755 diff --git a/class/class.blocks.php b/class/class.blocks.php old mode 100644 new mode 100755 diff --git a/class/class.core.php b/class/class.core.php index dedaef4..d2a3d8d 100755 --- a/class/class.core.php +++ b/class/class.core.php @@ -66,47 +66,6 @@ public $_module_not_found = 'Запрашиваемый модуль не найден.'; - /** - * Получение основных настроек сисблока - * - * @param string $param параметр настройки, если не указан - все параметры - * @return mixed - */ - function _sysBlock($id, $param = '') - { - global $AVE_DB; - - static $sys_block = null; - - if ($sys_block === null) - { - $sys_block = $AVE_DB->Query(" - SELECT - * - FROM - " . PREFIX . "_sysblocks - WHERE - " . (is_numeric($id) ? 'id' : 'sysblock_alias') . " = '" . $id . "' - ")->FetchAssocArray(); - } - - if ($param == '') - return $sys_block; - - return isset($sys_block[$param]) - ? $sys_block[$param] - : null; - } - - - /** - * Получаем шаблон документа - * - * @param $rubric_id - * @param $template_id - * - * @return bool|null|string - */ function _getMainTemplate($rubric_id, $template_id) { global $AVE_DB; @@ -186,7 +145,6 @@ : null; } - /** * Метод, предназначенный для получения шаблонов * @@ -294,7 +252,6 @@ return $out; } - /** * Метод, предназначенный для получения шаблона модуля * @@ -351,7 +308,6 @@ return stripslashes($out); } - /** * Метод, предназначенный для получения прав доступа к документам рубрики * @@ -412,7 +368,7 @@ /** * Метод, предназначенный для обработки события 404 Not Found, т.е. когда страница не найдена. * - * @return void + * @return unknown */ function _coreErrorPage404() { @@ -501,7 +457,6 @@ return (isset($this->curentdoc->Id) && $this->curentdoc->Id == $document_id); } - /** * Метод, предназначенный для получения содержимого страницы с 404 ошибкой * @@ -546,7 +501,6 @@ return (isset($this->curentdoc->Id) && $this->curentdoc->Id == $page_not_found_id); } - /** * Метод, предназначенный для получения МЕТА-тегов для различных модулей. * ToDo @@ -577,7 +531,6 @@ return (isset($this->curentdoc->Id) && $this->curentdoc->Id == 1); } - /** * Метод, предназначенный для определения статуса документа (доступен ли он к публикации). * @@ -627,7 +580,6 @@ return (! empty($this->curentdoc)); } - /** * Метод парсинга тега [tag:(css|js):files] * для вывода css/js-файлов в шаблоне через combine.php @@ -681,13 +633,6 @@ } - /** - * @param $main_content - * @param $id - * @param $rubTmpl - * - * @return mixed|null|string|string[] - */ function _main_content ($main_content, $id, $rubTmpl) { global $AVE_DB, $AVE_Template; @@ -695,13 +640,13 @@ // Проверяем теги полей в шаблоне рубрики на условие != '' if (defined('USE_GET_FIELDS') && USE_GET_FIELDS) { - $main_content = preg_replace("/\[tag:if_notempty:fld:([a-zA-Z0-9-_]+)\]/u", '<'.'?php if((htmlspecialchars(get_field(\'$1\'), ENT_QUOTES)) != \'\') { '.' ?'.'>', $rubTmpl); - $main_content = preg_replace("/\[tag:if_empty:fld:([a-zA-Z0-9-_]+)\]/u", '<'.'?php if((htmlspecialchars(get_field(\'$1\'), ENT_QUOTES)) == \'\') { '.' ?'.'>', $main_content); + $main_content = preg_replace("/\[tag:if_notempty:fld:([a-zA-Z0-9-_]+)\]/u", '<'.'?php if((htmlspecialchars(get_field(\'$1\'), ENT_QUOTES)) != \'\') { '.'?'.'>', $rubTmpl); + $main_content = preg_replace("/\[tag:if_empty:fld:([a-zA-Z0-9-_]+)\]/u", '<'.'?php if((htmlspecialchars(get_field(\'$1\'), ENT_QUOTES)) == \'\') { '.'?'.'>', $main_content); } else { - $main_content = preg_replace("/\[tag:if_notempty:fld:([a-zA-Z0-9-_]+)\]/u", '<'.'?php if((htmlspecialchars(document_get_field(\'$1\'), ENT_QUOTES)) != \'\') { '.' ?'.'>', $rubTmpl); - $main_content = preg_replace("/\[tag:if_empty:fld:([a-zA-Z0-9-_]+)\]/u", '<'.'?php if((htmlspecialchars(document_get_field(\'$1\'), ENT_QUOTES)) == \'\') { '.' ?'.'>', $main_content); + $main_content = preg_replace("/\[tag:if_notempty:fld:([a-zA-Z0-9-_]+)\]/u", '<'.'?php if((htmlspecialchars(document_get_field(\'$1\'), ENT_QUOTES)) != \'\') { '.'?'.'>', $rubTmpl); + $main_content = preg_replace("/\[tag:if_empty:fld:([a-zA-Z0-9-_]+)\]/u", '<'.'?php if((htmlspecialchars(document_get_field(\'$1\'), ENT_QUOTES)) == \'\') { '.'?'.'>', $main_content); } $main_content = str_replace('[tag:if:else]', '', $main_content); @@ -710,10 +655,10 @@ // Парсим элементы полей $main_content = preg_replace_callback( '/\[tag:fld:([a-zA-Z0-9-_]+)\]\[([0-9]+)]\[([0-9]+)]/', - function ($m) - { - return get_field_element($m[1], $m[2], $m[3], $this->curentdoc->Id); - }, + create_function( + '$m', + 'return get_field_element($m[1], $m[2], $m[3], ' . $this->curentdoc->Id . ');' + ), $main_content ); @@ -723,10 +668,10 @@ // Повторно парсим элементы полей $main_content = preg_replace_callback( '/\[tag:fld:([a-zA-Z0-9-_]+)\]\[([0-9]+)]\[([0-9]+)]/', - function ($m) - { - return get_field_element($m[1], $m[2], $m[3], $this->curentdoc->Id); - }, + create_function( + '$m', + 'return get_field_element($m[1], $m[2], $m[3], ' . $this->curentdoc->Id . ');' + ), $main_content ); @@ -765,10 +710,8 @@ // парсим теги в шаблоне рубрики $main_content = preg_replace_callback( '/\[tag:date:([a-zA-Z0-9-. \/]+)\]/', - function ($m) - { - return translate_date(date($m[1], $this->curentdoc->document_published)); - }, + create_function('$m','return translate_date(date($m[1], '.$this->curentdoc->document_published.')); + '), $main_content ); @@ -809,11 +752,6 @@ } - /** - * Получаем ID для кеша документа - * - * @return array|bool - */ function _get_cache_id() { $cache = array(); @@ -839,13 +777,6 @@ } - /** - * Создаем компилированный документ - * - * @param $main_content - * - * @return bool - */ function setCompileDocument ($main_content) { $cache = $this->_get_cache_id(); @@ -876,11 +807,6 @@ } - /** - * Получаем скомпилированный документ - * - * @return bool|string - */ function getCompileDocument () { $cache = $this->_get_cache_id(); @@ -1059,7 +985,6 @@ } } - /** * Метод, предназанченный для сборки всей страницы в единое целое. * @@ -1088,14 +1013,14 @@ } // проверяем разрешение на внешнее обращение - if (! $this->_sysBlock($_REQUEST['sysblock'], 'sysblock_external')) + if (! _getSysBlock($_REQUEST['sysblock'], 'sysblock_external')) { header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true); exit; } // проверяем разрешение на обращение только по Ajax - if ($this->_sysBlock($_REQUEST['sysblock'], 'sysblock_ajax')) + if (_getSysBlock($_REQUEST['sysblock'], 'sysblock_ajax')) { if (isAjax()) $out = parse_sysblock($_REQUEST['sysblock']); @@ -1158,9 +1083,7 @@ // Выполняем Код рубрики До загрузки документа ob_start(); - eval(' ?>' . $this->curentdoc->rubric_start_code . 'coreModuleTagParse($out); @@ -1560,10 +1499,10 @@ // Парсим тизер документа $out = preg_replace_callback( '/\[tag:teaser:(\d+)(|:\[(.*?)\])\]/', - function ($m) - { - return showteaser($m[1], $m[2]); - }, + create_function( + '$m', + 'return showteaser($m[1], $m[2]);' + ), $out ); @@ -1571,10 +1510,10 @@ if (defined('RUB_ID')) $out = preg_replace_callback( '/\[tag:docauthoravatar:(\d+)\]/', - function ($m) - { - return getAvatar(intval($this->curentdoc->document_author_id), $m[1]); - }, + create_function( + '$m', + 'return getAvatar('.intval($this->curentdoc->document_author_id).', $m[1]);' + ), $out ); @@ -1613,7 +1552,6 @@ echo $out; } - /** * Метод, предназначенный для формирования ЧПУ, а также для поиска документа и разбора * дополнительных параметров в URL diff --git a/class/class.dbdump.php b/class/class.dbdump.php old mode 100644 new mode 100755 diff --git a/class/class.debug.php b/class/class.debug.php index 5d45c9e..ef642a8 100644 --- a/class/class.debug.php +++ b/class/class.debug.php @@ -41,7 +41,7 @@ * * @return false|null|string|string[] */ - public static function _echo($var, $exit = false, $bg = null, $echo = true) + public static function _echo($var, $exit = false, $_bg = null, $echo = true) { $code = ''; @@ -92,8 +92,10 @@ else $fn_name = 'EVAL'; - if (empty($bg)) - $bg = '43648c'; + if ($_bg) + $bg = 'style="background: #' . $_bg . ';"'; + else + $bg = ''; $var_dump = '
-
+
var_dump(' . trim($fn_name) . ')
'.self::_trace().' @@ -157,7 +160,7 @@ * * @return null|string|string[] */ - public static function _print($var, $exit = false, $bg = null, $echo = true) + public static function _print($var, $exit = false, $_bg = null, $echo = true) { $code = ''; @@ -202,8 +205,10 @@ else $fn_name = 'EVAL'; - if (! $bg) - $bg = '4e5665'; + if ($_bg) + $bg = 'style="background: #' . $_bg . ';"'; + else + $bg = ''; $var_dump = '
-
+
print_r(' . trim($fn_name) . ')
'.self::_trace().' @@ -267,7 +273,7 @@ * * @return string */ - public static function _exp($var, $exit = false, $bg = null, $echo = true) + public static function _exp($var, $exit = false, $_bg = null, $echo = true) { $code = ''; @@ -306,8 +312,10 @@ else $fn_name = 'EVAL'; - if (! $bg) - $bg = 'ccc'; + if ($_bg) + $bg = 'style="background: #' . $_bg . ';"'; + else + $bg = ''; $var_export = htmlspecialchars(ob_get_contents()); @@ -321,9 +329,9 @@ margin: 20px; border: 1px solid #d9d9d9; background-color: #f1efef; - border-radius: 3px; + border-radius: 5px; box-shadow: 0 0 3px rgba(0, 0, 0, 0.1); - font-family: Consolas, Verdana, Arial; + font-family: "Consolas", Verdana, Arial; font-size: 11px; } .debug_top { @@ -334,6 +342,7 @@ padding-top: 10px; padding-bottom: 10px; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75); + background-color: #ccc; background-repeat: repeat-x; border-bottom: 1px solid #ffffff; } @@ -345,7 +354,7 @@ }
-
+
var_export(' . trim($fn_name) . ')
'.self::_trace().' @@ -377,7 +386,7 @@ * * @return false|string */ - public static function _html($var, $exit = false, $bg = null, $echo = true) + public static function _html($var, $exit = false, $_bg = null, $echo = true) { $code = ''; @@ -416,8 +425,10 @@ else $fn_name = 'EVAL'; - if (! $bg) - $bg = '43648c'; + if ($_bg) + $bg = 'style="background: #' . $_bg . ';"'; + else + $bg = ''; $var_dump = ob_get_contents(); @@ -429,9 +440,9 @@ margin: 20px; border: 1px solid #d9d9d9; background-color: #f1efef; - border-radius: 3px; - box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1); - font-family: Consolas, Verdana, Arial; + border-radius: 5px; + box-shadow: 0 0 3px rgba(0, 0, 0, 0.1); + font-family: "Consolas", Verdana, Arial; font-size: 11px; } .debug_top { @@ -442,6 +453,7 @@ padding-top: 10px; padding-bottom: 10px; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75); + background-color: #43648c; background-repeat: repeat-x; border-bottom: 1px solid #ffffff; } @@ -453,7 +465,7 @@ }
-
+
var_export(' . trim($fn_name) . ')
'.self::_trace().' @@ -533,7 +545,14 @@ $fn_name = 'EVAL'; if (! $bg) + { + $br = '2a5885'; $bg = '43648c'; + } + else + { + $br = $bg; + } $var_dump = '
-
+
var_dump(' . trim($fn_name) . ')
'.self::_trace().' diff --git a/class/class.docs.php b/class/class.docs.php index 9ee204b..75f8339 100755 --- a/class/class.docs.php +++ b/class/class.docs.php @@ -1478,7 +1478,7 @@ // Если пришел вызов поля, который связан с модулем if (isset($data['field_module'])) { - while(list($mod_key, $mod_val) = each($_REQUEST['field_module'])) + while(list($mod_key, $mod_val) = each($data['field_module'])) { require_once(BASE_DIR . '/modules/' . $mod_val . '/document.php'); diff --git a/class/class.hooks.php b/class/class.hooks.php old mode 100644 new mode 100755 diff --git a/class/class.logs.php b/class/class.logs.php old mode 100644 new mode 100755 diff --git a/class/class.meta.php b/class/class.meta.php old mode 100644 new mode 100755 index 3f21a23..bbdbf49 --- a/class/class.meta.php +++ b/class/class.meta.php @@ -14,19 +14,17 @@ class Meta { private $_keyword_count = 10; - public function __construct($keyword_count = false) + public function __construct( $keyword_count = false ) { - if ((int)$keyword_count) - $this->_keyword_count = $keyword_count; + if( (int) $keyword_count ) $this->_keyword_count = $keyword_count; } - public function setKeywordCount($keyword_count) + public function setKeywordCount( $keyword_count ) { - if ((int)$keyword_count) - $this->_keyword_count = $keyword_count; + if( (int) $keyword_count ) $this->_keyword_count = $keyword_count; } - public function generateMeta($text) + public function generateMeta( $text ) { $newarr = array (); @@ -51,24 +49,20 @@ class Meta $arr = explode( " ", $text ); - foreach ($arr as $word) - { - if (mb_strlen(($word)) > 4 OR (mb_strtoupper($word) == $word) and mb_strlen(($word)) > 1) - $newarr[] = $word; + foreach ( $arr as $word ) { + if( mb_strlen( ($word) ) > 4 OR (mb_strtoupper($word)==$word) and mb_strlen( ($word) ) > 1) $newarr[] = $word; } - $arr = array_count_values($newarr); + $arr = array_count_values( $newarr ); + arsort( $arr ); - arsort($arr); + $arr = array_keys( $arr ); - $arr = array_keys($arr); - - // Не используется - // $total = count($arr); + $total = count( $arr ); $offset = 0; - $arr = array_slice($arr, $offset, $this->_keyword_count); + $arr = array_slice( $arr, $offset, $this->_keyword_count ); $return['keywords'] = implode( ", ", $arr ); $return['description'] = trim(mb_substr( trim($text), 0, 220 ),'.').'.'; diff --git a/class/class.modules.php b/class/class.modules.php old mode 100644 new mode 100755 index 7815c6d..44bf724 --- a/class/class.modules.php +++ b/class/class.modules.php @@ -404,7 +404,6 @@ ModuleSysName = '" . MODULE_PATH . "' "); } - // Сохраняем системное сообщение в журнал reportLog ($AVE_Template->get_config_vars('MODULES_ACTION_UPDATE') . ' (' . MODULE_PATH . ')'); @@ -514,8 +513,8 @@ foreach ($files as $file) { - if (substr($file, -1) == '/') - $this->moduleRemove($file); + if(substr($file, -1) == '/') + moduleRemove($file); else unlink($file); } diff --git a/class/class.navigation.php b/class/class.navigation.php old mode 100644 new mode 100755 diff --git a/class/class.paginations.php b/class/class.paginations.php old mode 100644 new mode 100755 index 9c0dc46..34dddf0 --- a/class/class.paginations.php +++ b/class/class.paginations.php @@ -132,7 +132,10 @@ $search = array('[link]', '[page]', '[name]'); $replace = array($template_label, $page, $page); - $link = str_replace($search, $replace, $pagination_link_template); + if ($curent_page != 1) + $link = str_replace($search, $replace, $pagination_link_template); + else + $link = str_replace($search, $replace, $pagination_link_active_template); $pagination .= sprintf($pagination_link_box, str_replace(array('{s}', '{t}'), $page, str_replace(array('&' . $type . '={s}', '&' . $type . '={s}', '/' . $type . '-{s}'), '', $link))); } @@ -150,6 +153,7 @@ } } + // Следующая if ($curent_page < $total_pages) { diff --git a/class/class.porter.php b/class/class.porter.php old mode 100644 new mode 100755 diff --git a/class/class.request.php b/class/class.request.php old mode 100644 new mode 100755 diff --git a/class/class.session.files.php b/class/class.session.files.php old mode 100644 new mode 100755 diff --git a/class/class.session.memcached.php b/class/class.session.memcached.php old mode 100644 new mode 100755 diff --git a/class/class.session.php b/class/class.session.php old mode 100644 new mode 100755 index a1b9cad..03cbcf2 --- a/class/class.session.php +++ b/class/class.session.php @@ -1,155 +1,161 @@ db_host = $config['dbhost']; - $this->db_user = $config['dbuser']; - $this->db_pass = $config['dbpass']; - $this->db_dbase = $config['dbname']; - $this->db_prefix = $config['dbpref']; + /** + * Имя пользователя + * + * @var string + */ + protected $db_user; - $this->sess_lifetime = (defined('SESSION_LIFETIME') && is_numeric(SESSION_LIFETIME)) - ? SESSION_LIFETIME - : (get_cfg_var("session.gc_maxlifetime") < 1440 - ? 1440 - : get_cfg_var("session.gc_maxlifetime")); + /** + * Пароль + * + * @var string + */ + protected $db_pass; - if (! $this->mysql_connect = mysqli_connect ($this->db_host, $this->db_user, $this->db_pass)) - $this->error(); + /** + * Имя текущей БД. + * + * @var string + */ + protected $db_dbase; - if (! $this->mysql_db = mysqli_select_db ($this->mysql_connect, $this->db_dbase)) - $this->error(); + /** + * Префикс БД. + * + * @var string + */ + protected $db_prefix; - $this->mysql_connect->set_charset('utf8'); + private $mysql_connect = null; + private $mysql_db = null; - return true; + /* Create a connection to a database */ + function __construct() + { + // Подключаем конфигурационный файл с параметрами подключения + require (BASE_DIR . '/config/db.config.php'); + + $this->db_host = $config['dbhost']; + $this->db_user = $config['dbuser']; + $this->db_pass = $config['dbpass']; + $this->db_dbase = $config['dbname']; + $this->db_prefix = $config['dbpref']; + + $this->sess_lifetime = (defined('SESSION_LIFETIME') && is_numeric(SESSION_LIFETIME)) + ? SESSION_LIFETIME + : (get_cfg_var("session.gc_maxlifetime") < 1440 + ? 1440 + : get_cfg_var("session.gc_maxlifetime")); + + if (! $this->mysql_connect = mysqli_connect ($this->db_host, $this->db_user, $this->db_pass)) + { + $this->error(); } - - /* Open session */ - function _open($path, $name) + if (! $this->mysql_db = mysqli_select_db ($this->mysql_connect, $this->db_dbase)) { - return true; + $this->error(); } + $this->mysql_connect->set_charset('utf8'); - /* Close session */ - function _close() - { - @mysqli_query($this->mysql_connect, "DELETE FROM " . PREFIX . "_sessions WHERE expiry < '" . time() . "'"); + return true; + } - if ($this->mysql_connect !== null) - @mysqli_close($this->mysql_connect); + /* Open session */ + function _open($path, $name) + { + return true; + } - return true; - } + /* Close session */ + function _close() + { + @mysqli_query($this->mysql_connect, "DELETE FROM " . PREFIX . "_sessions WHERE expiry < '" . time() . "'"); + if ($this->mysql_connect !== null) + @mysqli_close($this->mysql_connect); - /* Read session */ - function _read($ses_id) - { - $qid = @mysqli_query($this->mysql_connect, "SELECT value, Ip FROM " . PREFIX . "_sessions WHERE sesskey = '" . $ses_id . "' AND expiry > '" . time() . "'"); + return true; + } - if ((list($value, $ip) = @mysqli_fetch_row($qid)) && $ip == $_SERVER['REMOTE_ADDR']) - return $value; + /* Read session */ + function _read($ses_id) + { + $qid = @mysqli_query($this->mysql_connect, "SELECT value, Ip FROM " . PREFIX . "_sessions WHERE sesskey = '" . $ses_id . "' AND expiry > '" . time() . "'"); - return ''; + if ((list($value, $ip) = @mysqli_fetch_row($qid)) && $ip == $_SERVER['REMOTE_ADDR']) + { + return $value; } + return ''; + } - /* Write new data */ - function _write($ses_id, $data) + /* Write new data */ + function _write($ses_id, $data) + { + if (! $qid = @mysqli_query($this->mysql_connect, "INSERT INTO ".PREFIX."_sessions VALUES ('".$ses_id."', ".(time()+$this->sess_lifetime).", '".addslashes($data)."', '".$_SERVER['REMOTE_ADDR']."', FROM_UNIXTIME(expiry, '%d.%m.%Y, %H:%i:%s'))")) { - if (! $qid = @mysqli_query($this->mysql_connect, "INSERT INTO ".PREFIX."_sessions VALUES ('".$ses_id."', ".(time()+$this->sess_lifetime).", '".addslashes($data)."', '".$_SERVER['REMOTE_ADDR']."', FROM_UNIXTIME(expiry, '%d.%m.%Y, %H:%i:%s'))")) - $qid = @mysqli_query($this->mysql_connect, "UPDATE ".PREFIX."_sessions SET expiry = ".(time()+$this->sess_lifetime).", expire_datum = FROM_UNIXTIME(expiry,'%d.%m.%Y, %H:%i:%s'), value = '".addslashes($data)."', Ip = '".$_SERVER['REMOTE_ADDR']."' WHERE sesskey = '".$ses_id."' AND expiry > '".time()."'"); - - return $qid; + $qid = @mysqli_query($this->mysql_connect, "UPDATE ".PREFIX."_sessions SET expiry = ".(time()+$this->sess_lifetime).", expire_datum = FROM_UNIXTIME(expiry,'%d.%m.%Y, %H:%i:%s'), value = '".addslashes($data)."', Ip = '".$_SERVER['REMOTE_ADDR']."' WHERE sesskey = '".$ses_id."' AND expiry > '".time()."'"); } - /* Destroy session */ - function _destroy($ses_id) - { - return @mysqli_query($this->mysql_connect, "DELETE FROM ".PREFIX."_sessions WHERE sesskey = '".$ses_id."'"); - } + return $qid; + } - /* Garbage collection, deletes old sessions */ - function _gc($maxlifetime) - { - $session_res = @mysqli_query($this->mysql_connect, "DELETE FROM ".PREFIX."_sessions WHERE expire < (UNIX_TIMESTAMP(NOW()) - " . (int)$maxlifetime . ")"); + /* Destroy session */ + function _destroy($ses_id) + { + return @mysqli_query($this->mysql_connect, "DELETE FROM ".PREFIX."_sessions WHERE sesskey = '".$ses_id."'"); + } - if (! $session_res) - return false; - else - return true; - } + /* Garbage collection, deletes old sessions */ + function _gc($maxlifetime) + { + $session_res = @mysqli_query($this->mysql_connect, "DELETE FROM ".PREFIX."_sessions WHERE expire < (UNIX_TIMESTAMP(NOW()) - " . (int)$maxlifetime . ")"); - function error() { - ob_start(); - header('HTTP/1.1 503 Service Temporarily Unavailable'); - header('Status: 503 Service Temporarily Unavailable'); - header('Retry-After: 3600'); - header('X-Powered-By:'); - display_notice("Error connect to MySQL."); - die; + if (!$session_res) { + return false; + } + else + { + return true; } } + + function error() { + ob_start(); + header('HTTP/1.1 503 Service Temporarily Unavailable'); + header('Status: 503 Service Temporarily Unavailable'); + header('Retry-After: 3600'); + header('X-Powered-By:'); + display_notice("Error connect to MySQL."); + die; + } +} ?> \ No newline at end of file diff --git a/class/class.settings.php b/class/class.settings.php old mode 100644 new mode 100755 diff --git a/class/class.sysblocks.php b/class/class.sysblocks.php old mode 100644 new mode 100755 index a6534f1..3740161 --- a/class/class.sysblocks.php +++ b/class/class.sysblocks.php @@ -38,7 +38,7 @@ /** * Вывод списка системных блоков */ - function sys_blockList() + function sys_blockList () { global $AVE_DB, $AVE_Template; @@ -70,7 +70,7 @@ * * @param int $sysblock_id идентификатор системного блока */ - function sys_blockSave($sysblock_id = null) + function sys_blockSave ($sysblock_id = null) { global $AVE_DB, $AVE_Template; @@ -78,10 +78,10 @@ { $_REQUEST['sysblock_external'] = (isset($_REQUEST['sysblock_external'])) ? $_REQUEST['sysblock_external'] : 0; + $_REQUEST['sysblock_eval'] = (isset($_REQUEST['sysblock_eval'])) ? $_REQUEST['sysblock_eval'] : 0; $_REQUEST['sysblock_ajax'] = (isset($_REQUEST['sysblock_ajax'])) ? $_REQUEST['sysblock_ajax'] : 0; $_REQUEST['sysblock_visual'] = (isset($_REQUEST['sysblock_visual'])) ? $_REQUEST['sysblock_visual'] : 0; - - $sysblock_alias = isset($_REQUEST['sysblock_alias']) ? $_REQUEST['sysblock_alias'] : ''; + $_REQUEST['sysblock_alias'] = isset($_REQUEST['sysblock_alias']) ? $_REQUEST['sysblock_alias'] : ''; $sql = $AVE_DB->Query(" UPDATE @@ -91,6 +91,7 @@ sysblock_description = '" . addslashes($_REQUEST['sysblock_description']) . "', sysblock_alias = '" . $_REQUEST['sysblock_alias'] . "', sysblock_text = '" . $_REQUEST['sysblock_text'] . "', + sysblock_eval = '" . (int)$_REQUEST['sysblock_eval'] . "', sysblock_external = '" . (int)$_REQUEST['sysblock_external'] . "', sysblock_ajax = '" . (int)$_REQUEST['sysblock_ajax'] . "', sysblock_visual = '" . (int)$_REQUEST['sysblock_visual'] . "' @@ -140,6 +141,7 @@ sysblock_alias = '" . $_REQUEST['sysblock_alias'] . "', sysblock_text = '" . $_REQUEST['sysblock_text'] . "', sysblock_author_id = '" . (int)$_SESSION['user_id'] . "', + sysblock_eval = '" . (int)$_REQUEST['sysblock_eval'] . "', sysblock_external = '" . (int)$_REQUEST['sysblock_external'] . "', sysblock_ajax = '" . (int)$_REQUEST['sysblock_ajax'] . "', sysblock_visual = '" . (int)$_REQUEST['sysblock_visual'] . "', @@ -163,7 +165,7 @@ * * @param int $sysblock_id идентификатор системного блока */ - function sys_blockEdit($sysblock_id) + function sys_blockEdit ($sysblock_id) { global $AVE_DB, $AVE_Template; @@ -201,13 +203,14 @@ /** * Создание системного блока */ - function sys_blockNew() + function sys_blockNew () { global $AVE_DB, $AVE_Template; $row['sysblock_name'] = ''; $row['sysblock_alias'] = ''; $row['sysblock_text'] = ''; + $row['sysblock_eval'] = '1'; $row['sysblock_visual'] = (isset($_REQUEST['sysblock_visual']) && $_REQUEST['sysblock_visual'] != 0) ? $_REQUEST['sysblock_visual'] : ''; $AVE_Template->assign('sid', 0); @@ -237,7 +240,7 @@ * * @param int $sysblock_id идентификатор системного блока */ - function sys_blockDelete($sysblock_id) + function sys_blockDelete ($sysblock_id) { global $AVE_DB, $AVE_Template; diff --git a/class/class.template.php b/class/class.template.php old mode 100644 new mode 100755 diff --git a/class/class.templates.php b/class/class.templates.php old mode 100644 new mode 100755 diff --git a/class/class.user.php b/class/class.user.php old mode 100644 new mode 100755 diff --git a/class/class.utm.php b/class/class.utm.php old mode 100644 new mode 100755 index 6294aaf..0cd9081 --- a/class/class.utm.php +++ b/class/class.utm.php @@ -1,119 +1,121 @@ parameters as $param) - if (isset($_GET[$param]) && $_GET[$param] != '') - $return = true; + private $utm_history = ''; + private $utm_last = ''; + private $utm_source = ''; - return $return; - } + //Проверка параметров: Если все присутствуют - true, иначе false + private function check_parameters() + { + //return true; //Сохранять всегда! - //Создаёт строку с параметрами вот такого вида: utm_source=test; utm_medium=none; utm_campaign=kompaniya1; - private function create_parameters() - { - $content = ''; - foreach($this->parameters as $param){ - - if (isset($_GET[$param]) && $_GET[$param] != '') - { - $content .= $param.'='.$_GET[$param].'; '; - - } - else - { - $content .= $param.'=none; '; - } - } + $return = false; - return $content; - } + foreach ($this->parameters as $param) + if (isset($_GET[$param]) && $_GET[$param] != '') + $return = true; - //Сохраняет переданные параметры, если требуется - //Если utm_history присутствует, то сохраняет utm_last - public function save_parameters() - { - if (isset($_GET['utm_source']) && trim($_GET['utm_source']) != '') + return $return; + } + + //Создаёт строку с параметрами вот такого вида: utm_source=test; utm_medium=none; utm_campaign=kompaniya1; + private function create_parameters() + { + $content = ''; + foreach($this->parameters as $param){ + + if (isset($_GET[$param]) && $_GET[$param] != '') { - setcookie('utm_source', $_GET['utm_source']); + $content .= $param.'='.$_GET[$param].'; '; - $this->utm_source = $_GET['utm_source']; } + else + { + $content .= $param.'=none; '; + } + } + + return $content; + } - //$utm_history = ''; + //Сохраняет переданные параметры, если требуется + //Если utm_history присутствует, то сохраняет utm_last + public function save_parameters() + { + if (isset($_GET['utm_source']) && trim($_GET['utm_source']) != '') + { + setcookie('utm_source', $_GET['utm_source']); - if (! isset($_COOKIE['utm_history']) || $_COOKIE['utm_history'] == '') - { - //Отсутствует utm_history - if($this->check_parameters() == true) - { + $this->utm_source = $_GET['utm_source']; + } - $utm_history = $this->create_parameters(); - setcookie('utm_history', $utm_history, time()+15552000); //На 6 месяцев - setcookie('utm_last', ''); + //$utm_history = ''; - $this->utm_history = $utm_history; - } + if (! isset($_COOKIE['utm_history']) || $_COOKIE['utm_history'] == '') + { + //Отсутствует utm_history + if($this->check_parameters() == true) + { + $utm_history = $this->create_parameters(); + setcookie('utm_history', $utm_history, time()+15552000); //На 6 месяцев + setcookie('utm_last', ''); + + $this->utm_history = $utm_history; } - else - { - //utm_history присутствует - $this->utm_history = $_COOKIE['utm_history']; + } + else + { + //utm_history присутствует - //Перезапишем utm_last, если есть данные для этого - if($this->check_parameters() == true){ + $this->utm_history = $_COOKIE['utm_history']; - $utm_last = $this->create_parameters(); + //Перезапишем utm_last, если есть данные для этого + if($this->check_parameters() == true){ - if($utm_last != $_COOKIE['utm_history']) - setcookie('utm_last', $utm_last, time()+15552000); //На 6 месяцев + $utm_last = $this->create_parameters(); - $this->utm_last = $utm_last; + if($utm_last != $_COOKIE['utm_history']) + setcookie('utm_last', $utm_last, time()+15552000); //На 6 месяцев - } + $this->utm_last = $utm_last; } - return true; } - //Возвращает значение cookies - public function get_value($name = '') - { - $name = trim($name); + return true; + } + + //Возвращает значение cookies + public function get_value($name = '') + { + $name = trim($name); - if ($name == '' || ! in_array($name, array('utm_history', 'utm_last', 'utm_source'))) - $name = 'utm_history'; + if ($name == '' || ! in_array($name, array('utm_history', 'utm_last', 'utm_source'))) + $name = 'utm_history'; - if (isset($this->$name) && $this->$name != '') - return $this->$name; + if (isset($this->$name) && $this->$name != '') + return $this->$name; - return isset($_COOKIE[$name]) ? $_COOKIE[$name] : ''; - } + return isset($_COOKIE[$name]) ? $_COOKIE[$name] : ''; } +} ?> \ No newline at end of file diff --git a/functions/.htaccess b/functions/.htaccess old mode 100644 new mode 100755 diff --git a/functions/func.common.php b/functions/func.common.php index e431fa9..f036961 100755 --- a/functions/func.common.php +++ b/functions/func.common.php @@ -371,7 +371,7 @@ /** - * Ссылка на реферал + * * * @return string ссылка */ diff --git a/functions/func.fields.php b/functions/func.fields.php index 2073d25..0c360ab 100644 --- a/functions/func.fields.php +++ b/functions/func.fields.php @@ -73,7 +73,7 @@ * * @return string */ - function get_field_default($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null, $_tpl=null) + function get_field_default ($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null, $_tpl=null) { switch ($action) { @@ -154,7 +154,7 @@ * @param $id * @return string */ - function get_field_alias($id) + function get_field_alias ($id) { global $AVE_DB; @@ -177,7 +177,7 @@ * * @return string */ - function get_field_num($rubric_id, $alias) + function get_field_num ($rubric_id, $alias) { global $AVE_DB; @@ -204,13 +204,13 @@ /** - * Возвращаем + * Возвращаем значение по умолчанию, для поля * * @param $id * * @return string */ - function get_field_default_value($id) + function get_field_default_value ($id) { global $AVE_DB; @@ -287,7 +287,7 @@ * * @return string */ - function document_get_field($field_id, $document_id = null, $_tpl = null, $maxlength = null) + function document_get_field ($field_id, $document_id = null, $_tpl = null, $maxlength = null) { global $AVE_Core; @@ -343,7 +343,7 @@ * содержимое поля будет очищено от HTML-тегов. * @return string */ - function document_get_field_value($field_id, $length = 0) + function document_get_field_value ($field_id, $length = 0) { if (! is_numeric($field_id)) return ''; @@ -382,7 +382,7 @@ * * @return string */ - function get_document_field($document_id, $field) + function get_document_field ($document_id, $field) { $document_fields = get_document_fields($document_id); @@ -406,7 +406,7 @@ * @internal param int $id id документа * @return mixed */ - function get_document_fields($document_id, $values = null) + function get_document_fields ($document_id, $values = null) { global $AVE_DB, $AVE_Core; //$request_documents @@ -524,7 +524,7 @@ * * @return string */ - function get_field($field_id, $doc_id = null, $parametr = null) + function get_field ($field_id, $doc_id = null, $parametr = null) { global $req_item_id; @@ -539,7 +539,7 @@ return false; //-- Забираем из базы массив полей - $field = get_document_field($doc_id, $field_id); + $field = get_document_field ($doc_id, $field_id); //-- Возвращаем нужную часть поля if ($parametr !== null) @@ -562,7 +562,7 @@ * * @return mixed */ - function get_true_field($field_id, $doc_id = null, $parametr = null) + function get_true_field ($field_id, $doc_id = null, $parametr = null) { global $req_item_id, $AVE_DB; @@ -619,7 +619,7 @@ * @param int $parametr ([tag:parametr:X]) - номер параметра элемента * @return string */ - function get_element($field_id, $item_id = 0, $parametr = null, $doc_id = null) + function get_element ($field_id, $item_id = 0, $parametr = null, $doc_id = null) { global $req_item_id; @@ -663,7 +663,7 @@ * @param int $doc_id ([tag:docid]) - id документа * @return mixed */ - function get_serialize($field_id, $item_id = null, $doc_id = null) + function get_serialize ($field_id, $item_id = null, $doc_id = null) { global $req_item_id; @@ -706,7 +706,7 @@ * * @return string */ - function get_field_element() + function get_field_element () { $param = func_get_args(); @@ -733,7 +733,7 @@ * * @return string */ - function get_field_name($field_id, $doc_id = null) + function get_field_name ($field_id, $doc_id = null) { global $req_item_id; @@ -756,4 +756,73 @@ return $field_name; } + + + /** + * Возвращает поле документа по номеру + * + * @param int $field_id ([tag:fld:X]) - номер поля + * @param int $doc_id + * @param int $parametr знчение + * + * @return mixed + */ + function get_full_field ($field_id, $doc_id = null, $parametr = null) + { + global $req_item_id, $AVE_DB; + + //-- Если не передан $doc_id, то проверяем реквест + if (! $doc_id && $req_item_id) + $doc_id = $req_item_id; + //-- Или берём для текущего дока + elseif (! $doc_id && $_REQUEST['id'] > 0) + $doc_id = $_REQUEST['id']; + //-- Возвращаем FALSE, если не число + elseif (! is_numeric($doc_id)) + return false; + + //-- Забираем поле из базы + $sql = " + SELECT + doc.document_author_id, + doc_field.document_id, + doc_field.rubric_field_id, + doc_field.field_value, + doc_field.field_number_value, + text_field.field_value AS field_value_more, + rub_field.rubric_field_alias, + rub_field.rubric_field_type, + rub_field.rubric_field_default, + rub_field.rubric_field_title, + rub_field.rubric_field_template, + rub_field.rubric_field_template_request + FROM + " . PREFIX . "_document_fields AS doc_field + JOIN + " . PREFIX . "_rubric_fields AS rub_field + ON doc_field.rubric_field_id = rub_field.Id + LEFT JOIN + " . PREFIX . "_document_fields_text AS text_field + ON (doc_field.rubric_field_id = text_field.rubric_field_id AND doc_field.document_id = text_field.document_id) + JOIN + " . PREFIX . "_documents AS doc + ON doc.Id = doc_field.document_id + WHERE + doc_field.document_id = '" . $doc_id . "' + AND + doc_field.rubric_field_id = '" . $field_id . "' + "; + + $field = $AVE_DB->Query($sql)->FetchRow(); + + $field->field_value = (string)$field->field_value . (string)$field->field_value_more; + + unset ($sql); + + //-- Возвращаем нужную часть + if ($parametr !== null) + return $field[$parametr]; + + return $field; + } ?> \ No newline at end of file diff --git a/functions/func.pagination.php b/functions/func.pagination.php index 5ad305b..1b731e8 100644 --- a/functions/func.pagination.php +++ b/functions/func.pagination.php @@ -18,7 +18,7 @@ * допустимые значения: page, apage, artpage * @return int номер текущей страницы */ - function get_current_page($type = 'page') + function get_current_page ($type = 'page') { if (!in_array($type, array('page', 'apage', 'artpage'))) return 1; @@ -38,7 +38,7 @@ * @return string HTML-код постраничной навигации */ - function get_pagination($total_pages, $type, $template_label, $navi_box = '') + function get_pagination ($total_pages, $type, $template_label, $navi_box = '') { $nav = ''; diff --git a/functions/func.parserequest.php b/functions/func.parserequest.php index f217130..4412ce1 100755 --- a/functions/func.parserequest.php +++ b/functions/func.parserequest.php @@ -147,31 +147,31 @@ // обрабатываем условия switch ($type) { - case 'N<':case '<': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv < UPPER('\$v[$i]'))) $join\" : ''?>"; break; - case 'N>':case '>': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv > UPPER('\$v[$i]'))) $join\" : ''?>"; break; - case 'N<=':case '<=': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv <= UPPER('\$v[$i]'))) $join\" : ''?>"; break; - case 'N>=':case '>=': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv >= UPPER('\$v[$i]'))) $join\" : ''?>"; break; - - case '==': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv = UPPER('\$v[$i]'))) $join\" : ''?>"; break; - case '!=': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv != UPPER('\$v[$i]'))) $join\" : ''?>"; break; - case '%%': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv LIKE UPPER('%\$v[$i]%'))) $join\" : ''?>"; break; - case '%': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv LIKE UPPER('\$v[$i]%'))) $join\" : ''?>"; break; - case '--': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv NOT LIKE UPPER('%\$v[$i]%'))) $join\" : ''?>"; break; - case '!-': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv NOT LIKE UPPER('\$v[$i]%'))) $join\" : ''?>"; break; - - case 'SEGMENT': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv < UPPER('\$v[$i]'))) $join\" : '' ?>"; break; + case 'N>':case '>': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv > UPPER('\$v[$i]'))) $join\" : '' ?>"; break; + case 'N<=':case '<=': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv <= UPPER('\$v[$i]'))) $join\" : '' ?>"; break; + case 'N>=':case '>=': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv >= UPPER('\$v[$i]'))) $join\" : '' ?>"; break; + + case '==': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv = UPPER('\$v[$i]'))) $join\" : '' ?>"; break; + case '!=': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv != UPPER('\$v[$i]'))) $join\" : '' ?>"; break; + case '%%': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv LIKE UPPER('%\$v[$i]%'))) $join\" : '' ?>"; break; + case '%': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv LIKE UPPER('\$v[$i]%'))) $join\" : '' ?>"; break; + case '--': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv NOT LIKE UPPER('%\$v[$i]%'))) $join\" : '' ?>"; break; + case '!-': $where[] = "'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv NOT LIKE UPPER('\$v[$i]%'))) $join\" : '' ?>"; break; + + case 'SEGMENT': $where[] = "'' && \$v[$i]{0}!=',' && \$v[$i]['seg'][0] <= \$v[$i]['seg'][1]) ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv >= '\" . \$v[$i]['seg'][0] . \"' AND $fv <= '\" . \$v[$i]['seg'][1] . \"')) $join\" : '');?>"; break; - case 'INTERVAL': $where[] = "'' && \$v[$i]{0}!=',' && \$v[$i]['seg'][0] <= \$v[$i]['seg'][1]) ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv >= '\" . \$v[$i]['seg'][0] . \"' AND $fv <= '\" . \$v[$i]['seg'][1] . \"')) $join\" : ''); ?>"; break; + case 'INTERVAL': $where[] = "'' && \$v[$i]{0}!=',' && \$v[$i]['seg'][0] < \$v[$i]['seg'][1]) ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv > '\" . \$v[$i]['seg'][0] . \"' AND $fv < '\" . \$v[$i]['seg'][1] . \"')) $join\" : '');?>"; break; + echo (\$v[$i]>'' && \$v[$i]{0}!=',' && \$v[$i]['seg'][0] < \$v[$i]['seg'][1]) ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv > '\" . \$v[$i]['seg'][0] . \"' AND $fv < '\" . \$v[$i]['seg'][1] . \"')) $join\" : ''); ?>"; break; - case 'IN=': $where[] = "'' && \$v[$i]{0}!=',') ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv IN (\$v[$i]))) $join\" : ''?>"; break; - case 'NOTIN=': $where[] = "'' && \$v[$i]{0}!=',') ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv NOT IN (\$v[$i]))) $join\" : ''?>"; break; + case 'IN=': $where[] = "'' && \$v[$i]{0}!=',') ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv IN (\$v[$i]))) $join\" : '' ?>"; break; + case 'NOTIN=': $where[] = "'' && \$v[$i]{0}!=',') ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv NOT IN (\$v[$i]))) $join\" : '' ?>"; break; case 'ANY': $where[] = " '' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv=ANY(\$v[$i]))) $join\" : ''; ?>"; break; case 'FRE': $where[] = " '' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND (\$v[$i]))) $join\" : ''; ?>"; break; @@ -453,7 +453,12 @@ $item = preg_replace_callback('/\[tag:block:([A-Za-z0-9-_]{1,20}+)\]/', 'parse_block', $template); // Парсим теги системных блоков - $item = preg_replace_callback('/\[tag:sysblock:([A-Za-z0-9-_]{1,20}+)\]/', 'parse_sysblock', $item); + $item = preg_replace_callback('/\[tag:sysblock:([A-Za-z0-9-_]{1,20}+)(|:\{(.*?)\})\]/', + function ($m) + { + return parse_sysblock($m[1], $m[2]); + }, + $item); // Парсим элементы полей $item = preg_replace_callback('/\[tag:rfld:([a-zA-Z0-9-_]+)\]\[([0-9]+)]\[([0-9]+)]/', @@ -559,6 +564,7 @@ $link = rewrite_link('index.php?id=' . $row->Id . '&doc=' . (empty($row->document_alias) ? prepare_url($row->document_title) : $row->document_alias)); $item = str_replace('[tag:link]', $link, $item); $item = str_replace('[tag:docid]', $row->Id, $item); + $item = str_replace('[tag:itemid]', $row->Id, $item); $item = str_replace('[tag:docitemnum]', $req_item_num, $item); $item = str_replace('[tag:adminlink]', 'index.php?do=docs&action=edit&rubric_id=' . $row->rubric_id . '&Id=' . $row->Id . '&cp=' . session_id() . '', $item); $item = str_replace('[tag:doctitle]', stripslashes(htmlspecialchars_decode($row->document_title)), $item); diff --git a/functions/func.sysblock.php b/functions/func.sysblock.php index 92c884e..f869bed 100644 --- a/functions/func.sysblock.php +++ b/functions/func.sysblock.php @@ -18,9 +18,19 @@ * * @return bool|mixed|null|string|string[] */ - function parse_sysblock($id) + function parse_sysblock ($id, $params = null) { - global $AVE_DB; + global $AVE_DB, $sysParams; + + $sysblock_eval = _getSysBlock($id, 'sysblock_eval'); + + $sparams_id = $id . md5($params); // Создаем уникальный id для каждого набора параметров + $sysParams[$sparams_id] = []; // Для отмены лишних ворнингов + + $params = trim($params,':'); // Удаляем: слева ':[', справа ']' + $params = json_decode($params, true); + + $sysParams[$sparams_id] = $params; if (is_array($id)) $id = $id[1]; @@ -31,8 +41,6 @@ if ($id != '') { - $eval_sysblock = true; - $cache = md5('sysblock' . $id); $cache_file = BASE_DIR . '/tmp/cache/sql/sysblocks/' . $id . '/' . $cache . '.code'; @@ -94,16 +102,92 @@ $return = preg_replace_callback('/\[tag:block:([A-Za-z0-9-_]{1,20}+)\]/', 'parse_block', $return); - if ($eval_sysblock) - $return = eval2var('?'.'>' . $return . '<'.'?'); + // Парсим теги системных блоков + $return = preg_replace_callback('/\[tag:sysblock:([A-Za-z0-9-_]{1,20}+)(|:\{(.*?)\})\]/', + function ($m) + { + return parse_sysblock($m[1], $m[2]); + }, + $return); + + // Если был вызов + if ($sysParams != '') + { + // Заменяем + $return = preg_replace_callback('/\[sys:param:([A-Za-z0-9-+_]+)\]/', + function ($m) use ($sparams_id) + { + return params_of_sysblocks($sparams_id, $m[1]); + }, + $return); + } + else + { + // Если чистый запрос тизера, просто вытираем tparam + $return = preg_replace('/\[sysparam:([A-Za-z0-9-+_]+)\]/', '', $return); + } - $gen_time = Debug::endTime('SYSBLOCK_' . $id); + if ($sysblock_eval) + $return = eval2var('?'.'>' . $return . '<'.'?php '); - $GLOBALS['block_generate']['SYSBLOCK'][$id] = $gen_time; + $GLOBALS['block_generate']['SYSBLOCK'][$id] = Debug::endTime('SYSBLOCK_' . $id); return $return; } return false; } + + + /** + * Функция получения уникальных параметров для каждого + * + * @param $id + * @param $el + * @return string + */ + function params_of_sysblocks($id, $el) + { + global $sysParams; + + if (isset($sysParams[$id][$el])) + return $sysParams[$id][$el]; + else + return false; + } + + + /** + * Получение основных настроек сисблока + * + * @param $param string параметр настройки, если не указан - все параметры + * @return mixed + */ + function _getSysBlock($id, $param = '') + { + global $AVE_DB; + + $sys_block = null; + + if ($sys_block === null) + { + $sql = " + SELECT + * + FROM + " . PREFIX . "_sysblocks + WHERE + " . (is_numeric($id) ? 'id' : 'sysblock_alias') . " = '" . $id . "' + "; + + $sys_block = $AVE_DB->Query($sql, -1, 'sysblocks/' . $id . '/')->FetchAssocArray(); + } + + if ($param == '') + return $sys_block; + + return isset($sys_block[$param]) + ? $sys_block[$param] + : null; + } ?> \ No newline at end of file diff --git a/tmp/update/sql.update.php b/tmp/update/sql.update.php index 0a69ddc..b8f0100 100644 --- a/tmp/update/sql.update.php +++ b/tmp/update/sql.update.php @@ -291,7 +291,7 @@ FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() - AND TABLE_NAME = 'ave325_settings' + AND TABLE_NAME = '" . PREFIX . "_settings' AND COLUMN_NAME = 'use_editor'; ")->GetCell(); @@ -324,4 +324,27 @@ "); } + // ---------------------------------------------------------------------------------------- + + $check = $AVE_DB->Query(" + SHOW COLUMNS + FROM + " . PREFIX . "_sysblocks + LIKE + 'sysblock_eval' + ")->NumRows(); + + $exist = ($check) ? true : false; + + if ($exist === false) + { + $AVE_DB->Real_Query(" + ALTER TABLE + " . PREFIX . "_sysblocks + ADD + `sysblock_eval` enum('0','1') NOT NULL DEFAULT '1' + AFTER + `sysblock_active` + "); + } ?> \ No newline at end of file