Browse Source

Fixes

master
M@d D3n 6 years ago
parent
commit
543966f737
  1. 34
      .htaccess
  2. 29
      README.md
  3. 136
      admin/functions/func.admin.common.php
  4. 4
      admin/templates/rubs/form.tpl
  5. 2
      admin/templates/sysblocks/list.tpl
  6. 84
      class/class.core.php
  7. 385
      class/class.debug.php
  8. 16
      class/class.meta.php
  9. 3
      class/class.modules.php
  10. 18
      class/class.session.php
  11. 2
      class/class.utm.php
  12. 163
      fields/checkbox_multi/field.php
  13. 163
      fields/multi_checkbox/field.php
  14. 0
      fields/multi_checkbox/lang/bg.txt
  15. 0
      fields/multi_checkbox/lang/cz.txt
  16. 0
      fields/multi_checkbox/lang/en.txt
  17. 0
      fields/multi_checkbox/lang/pl.txt
  18. 0
      fields/multi_checkbox/lang/ru.txt
  19. 0
      fields/multi_checkbox/lang/ua.txt
  20. 0
      fields/multi_checkbox/tpl/field-doc.tpl
  21. 0
      fields/multi_checkbox/tpl/field-req.tpl
  22. 0
      fields/multi_checkbox/tpl/field.tpl
  23. 3
      fields/tags/field.php
  24. 6
      functions/func.block.php
  25. 4
      functions/func.breadcrumbs.php
  26. 64
      functions/func.common.php
  27. 4
      functions/func.documents.php
  28. 20
      functions/func.fields.php
  29. 207
      functions/func.helpers.php
  30. 6
      functions/func.login.php
  31. 6
      functions/func.mail.php
  32. 1
      functions/func.modulglobals.php
  33. 2
      functions/func.navigation.php
  34. 173
      functions/func.parserequest.php
  35. 8
      functions/func.sysblock.php
  36. 6
      functions/func.thumbnails.php
  37. 42
      functions/func.users.php
  38. 4
      functions/func.watermarks.php
  39. 10
      inc/init.php
  40. 1
      install/data_base.sql

34
.htaccess

@ -11,7 +11,6 @@ Options -Indexes +FollowSymLinks
# | PHP Configuration |
# ------------------------------------------------------------------------------
<ifModule mod_php5.c>
php_value default_charset utf-8
#Отлючаем вывод ошибок
@ -40,39 +39,6 @@ Options -Indexes +FollowSymLinks
php_flag magic_quotes_runtime off
php_flag register_globals off
</ifModule>
<ifModule !mod_php5.c>
php_value default_charset utf-8
#Отлючаем вывод ошибок
#php_value error_reporting E_NONE
# Этот параметр устанавливает максимальное время в секундах, позволяющее скрипту запускаться прежде, чем он завершается синтаксическим анализатором.
#php_value max_execution_time 300
# Максимальное время загрузки данных для скрипта, в том числе и файлов из формы
#php_value max_input_time 300
# Ограничивает максимальный объем данных, получаемых от пользователя методом POST
#php_value post_max_size 32M
# Устанавливает максимальный размер файла, который может быть получен методом POST (меньше, чем post_max_size)
#php_value upload_max_filesize 32M
# Максимальное кол-во загружаемых файлов
#php_value max_file_uploads 50
# Включаем у PHP короткие <?
#php_value short_open_tag On
php_flag magic_quotes_gpc off
php_flag magic_quotes_runtime off
php_flag register_globals off
</ifModule>
# ------------------------------------------------------------------------------
# | CORS-enabled images |

29
README.md

@ -5,8 +5,6 @@
* [Системные требования](#Системные-требования)
* [Модули](#Модули)
* [Установка](#Установка)
* [Ресурсы](#Ресурсы)
@ -21,34 +19,9 @@
* ПО WEB сервера:
* Apache >= 1.3
* Nginx >= 1.6.2
* PHP >= 5.6.x разрешить использовать короткие теги short_open_tag = On (zlib, cURL, mbString, JSON)
* PHP >= 5.6.x (zlib, cURL, mbString, JSON)
* PHP >= 7.x ... <= 7.2.x
## Модули
Описание и загрузка модулей
| Наименование | Описание |
|---------------------------------|-----------------------------|
| [Комментарии] | Система комментирования публикаций. |
| [Контактные формы] | Модуль предназначен для создания различных веб-форм для контактов.Поддержка различных типов полей. |
| [Публикатор документов] | Данный модуль предназначен для создания форм ввода и редактирования документов на сайте. |
| [Вопрос-Ответ (FAQ)] | Модуль создания раширенной справочной системы на основе тегов. |
| [Галерея] | Модуль для создания и управления галереями изображений. |
| [Авторизация] | Модуль поддержки Регистрации/Авторизации пользователей. |
| [Рассылки] | Модуль позволяет осуществлять рассылки новостей и другой информации пользователям. |
| [Похожие документы] | Модуль позволяет выводить список связанных документов *(Связующим элементом документов является первое слово из поля Ключевые слова.)* |
| [Быстрый переход] | Данный модуль является альтернативным способом организации меню навигации на сайте. Он представлен в виде выпадающего списка разделов и подразделов вашего сайта. |
| [RSS] | Данный модуль предзназначен для организации RSS потоков на вашем сайте. |
| [Поиск] | Организация поиска по сайту. |
| [Карта сайта] | Построение карты сайта на базе пунктов меню навигации. |
| [Корзина] | Модуль электронной комерции. |
| [Импорт] | Импорт документов в выбранную рубрику. |
| [Рейтинг документов] | Поддержка оценок для публикаций. |
| [Навигация по документам рубрики] | Данный модуль позволяет организовать навигацию по документам в пределах рубрики. |
И другие
## Установка
1. Распакуйте содержимое архива в новую папку на вашем локальном компьютере.

136
admin/functions/func.admin.common.php

@ -12,23 +12,32 @@
/**
* Если был referer, то перенапрявляем на него
*
* @param
* @return $link
* @return mixed|null|string $link
*/
function get_referer_admin_link()
{
static $link = null;
$ok = false;
if ($link === null)
{
if (isset($_SERVER['HTTP_REFERER']))
{
$link = parse_url($_SERVER['HTTP_REFERER']);
$ok = (trim($link['host']) == $_SERVER['HTTP_HOST']) ? true : false;
$ok = (trim($link['path']) != '/admin/admin.php') ? true : false;
$ok = (trim($link['host']) == $_SERVER['HTTP_HOST'])
? true
: false;
$ok = (trim($link['path']) != '/admin/admin.php')
? true
: false;
}
$link = ($ok === true ? $_SERVER['HTTP_REFERER'] : '/admin/index.php');
$link = ($ok === true
? $_SERVER['HTTP_REFERER']
: '/admin/index.php');
}
return $link;
@ -38,11 +47,11 @@
/**
* Получаем кол-во записей в журналах событий
*
* @return Array массив из кол-ва записей
* @return void массив из кол-ва записей
*/
function getLogRecords()
{
global $AVE_DB, $AVE_Template;
global $AVE_Template;
$logs = array();
$logdata = array();
@ -54,17 +63,17 @@
$_sqldir = BASE_DIR . '/tmp/logs/sql.php';
if (file_exists($_logdir))
@eval(' ?>' . file_get_contents($_logdir) . '<?php ');
@eval(' ?>' . file_get_contents($_logdir) . '<?'.'php ');
$logs['logs'] = count($logdata);
if (file_exists($_404dir))
@eval(' ?>' . file_get_contents($_404dir) . '<?php ');
@eval(' ?>' . file_get_contents($_404dir) . '<?'.'php ');
$logs['404'] = count($log404);
if (file_exists($_sqldir))
@eval(' ?>' . file_get_contents($_sqldir) . '<?php ');
@eval(' ?>' . file_get_contents($_sqldir) . '<?'.'php ');
$logs['sql'] = count($logsql);
@ -81,7 +90,8 @@
* Список пользователей за последние $onlinetime секунд
*
* @param int $onlinetime количество секунд
* @return Array массив из пользователей отсортированный по последней активности
*
* @return void массив из пользователей отсортированный по последней активности
*/
function get_online_users($onlinetime = USERS_TIME_SHOW)
{
@ -91,7 +101,7 @@
$sql = @$AVE_DB->Query("SELECT * FROM " . PREFIX . "_users WHERE last_visit > " . $time . " ORDER BY last_visit DESC");
$online_users=Array();
$online_users = array();
while ($row = $sql->FetchRow())
{
@ -124,6 +134,7 @@
return $file_size;
}
/**
* Извлечение из БД статистики по основным компонентам системы
*
@ -187,7 +198,8 @@
*/
function get_dir_size($directory)
{
if (!is_dir($directory)) return -1;
if (! is_dir($directory))
return -1;
$size = 0;
@ -425,7 +437,8 @@
$status = fclose($handle);
if ($retbytes && $status) return $cnt;
if ($retbytes && $status)
return $cnt;
return $status;
}
@ -468,16 +481,20 @@
//Проверка на наличие модуля Контакты и новых писем
function ContactsModuleCheck() {
function ContactsModuleCheck()
{
global $AVE_DB, $AVE_Template;
$sql = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_module WHERE ModuleFunction = 'contact' and ModuleStatus = '1'");
$enable = $sql->numrows();
if ($enable != "0" || $enable != ""){
$enable = $sql->NumRows();
if ($enable != "0" || $enable != "")
{
$contacts = "1";
$sql_num = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_modul_contact_info WHERE Aw_Zeit = '0'");
$num_posts = $sql_num->numrows();
} else {
$num_posts = $sql_num->NumRows();
}
else
{
$contacts = "0";
}
$AVE_Template->assign('num_posts', $num_posts);
@ -486,21 +503,26 @@
//Проверка на наличие модуля Логин
function LoginModuleCheck() {
function LoginModuleCheck()
{
global $AVE_DB, $AVE_Template;
$sql = $AVE_DB->Query("SELECT * FROM " . PREFIX . "_module WHERE ModuleFunction = 'mod_login' and ModuleStatus = '1'");
$enable = $sql->numrows();
if ($enable != "0" || $enable != ""){
$login_menu = "1";
} else {
$login_menu = "0";
}
$enable = $sql->NumRows();
if ($enable != '0' || $enable != '')
$login_menu = '1';
else
$login_menu = '0';
$AVE_Template->assign('login_menu', $login_menu);
}
//Выводим на главную список последних 15 документов
/**
* Выводим на главную список последних 15 документов
*/
function DisplayMainDocuments()
{
global $AVE_DB, $AVE_Template;
@ -516,7 +538,7 @@
WHERE 1 = 1
AND rub.rubric_docs_active = '1'
ORDER BY doc.document_published DESC LIMIT 0,10");
while($row = $sql->fetchrow()) {
while($row = $sql->FetchRow()) {
$row->rubric_title = showrubricName($row->rubric_id);
$row->document_title = stripslashes(htmlspecialchars_decode(pretty_chars($row->document_title)));
$row->document_breadcrum_title = stripslashes(htmlspecialchars_decode(pretty_chars($row->document_breadcrum_title)));
@ -527,7 +549,7 @@
$row->canOpenClose = 0;
$row->rubric_admin_teaser_template = @eval2var(' ?>'.($row->rubric_admin_teaser_template > ''
? @showrequestelement($row, $row->rubric_admin_teaser_template)
: '').'<?php ');
: '') . '<?'.'php ');
// разрешаем редактирование и удаление
// если автор имеет право изменять свои документы в рубрике
@ -570,57 +592,93 @@
$AVE_Template->assign('doc_start', $doc_start);
}
/**
* @param $id
*
* @return mixed
*/
function showrubricName($id)
{
global $AVE_DB;
$sql = $AVE_DB->Query("SELECT rubric_title FROM " . PREFIX . "_rubrics WHERE Id = '$id'");
$row = $sql->fetchrow();
$row = $sql->FetchRow();
return $row->rubric_title;
}
/**
* @param $id
*
* @return mixed
*/
function showuserName($id)
{
global $AVE_DB;
$sql = $AVE_DB->Query("SELECT user_name FROM " . PREFIX . "_users WHERE Id = '$id'");
$row = $sql->fetchrow();
$row = $sql->FetchRow();
return $row->user_name;
}
/**
*
*/
function cacheShow()
{
global $AVE_Template;
$showCache = format_size(get_dir_size($AVE_Template->cache_dir_root));
echo json_encode(array($showCache, 'accept'));
}
/**
* @param $id
*
* @return mixed
*/
function templateName($id)
{
global $AVE_DB;
$sql = $AVE_DB->Query("
SELECT * FROM " . PREFIX . "_templates
WHERE Id = '$id'
SELECT
*
FROM
" . PREFIX . "_templates
WHERE
Id = '$id'
");
$row = $sql->fetchrow();
$row = $sql->FetchRow();
return $row->template_title;
}
/**
* @param $id
*
* @return mixed
*/
function groupName($id)
{
global $AVE_DB;
$sql = $AVE_DB->Query("
SELECT * FROM " . PREFIX . "_user_groups
WHERE user_group = '$id'
SELECT
*
FROM
" . PREFIX . "_user_groups
WHERE
user_group = '$id'
");
$row = $sql->fetchrow();
$row = $sql->FetchRow();
return $row->user_group_name;
}

4
admin/templates/rubs/form.tpl

@ -599,11 +599,11 @@
<strong>{$field.rubric_field_title}</strong>
</td>
<td>
<a class="rightDir" title="{#RUBRIK_INSERT_HELP#}" href="javascript:void(0);" onclick="textSelection2('[tag:rfld:{$field.Id}][0]', '');"><strong>[tag:rfld:{$field.Id}][150]</strong></a>
<a class="rightDir" title="{#RUBRIK_INSERT_HELP#}" href="javascript:void(0);" onclick="textSelection2_1('[tag:rfld:{$field.Id}][0]', '');"><strong>[tag:rfld:{$field.Id}][150]</strong></a>
</td>
<td>
{if $field.rubric_field_alias}
<a class="rightDir" title="{#RUBRIK_INSERT_HELP#}" href="javascript:void(0);" onclick="textSelection2('[tag:rfld:{$field.rubric_field_alias}][0]', '');"><strong>[tag:rfld:{$field.rubric_field_alias}][0]</strong></a>
<a class="rightDir" title="{#RUBRIK_INSERT_HELP#}" href="javascript:void(0);" onclick="textSelection2_1('[tag:rfld:{$field.rubric_field_alias}][0]', '');"><strong>[tag:rfld:{$field.rubric_field_alias}][0]</strong></a>
{/if}
</td>
<td align="center">

2
admin/templates/sysblocks/list.tpl

@ -120,7 +120,7 @@
<td align="center">{$sysblock->sysblock_author_id|escape}</td>
<td align="center">
<span class="date_text dgrey">{$sysblock->sysblock_created|date_format:$TIME_FORMAT|translate_date}</span>
<span class="date_text dgrey">{$sysblock->sysblock_created|date_format:$TIME_FORMAT|pretty_date}</span>
</td>
<td>

84
class/class.core.php

@ -72,7 +72,6 @@
* @param string $param параметр настройки, если не указан - все параметры
* @return mixed
*/
function _sysBlock($id, $param = '')
{
global $AVE_DB;
@ -100,6 +99,14 @@
}
/**
* Получаем шаблон документа
*
* @param $rubric_id
* @param $template_id
*
* @return bool|null|string
*/
function _getMainTemplate($rubric_id, $template_id)
{
global $AVE_DB;
@ -179,6 +186,7 @@
: null;
}
/**
* Метод, предназначенный для получения шаблонов
*
@ -286,6 +294,7 @@
return $out;
}
/**
* Метод, предназначенный для получения шаблона модуля
*
@ -342,6 +351,7 @@
return stripslashes($out);
}
/**
* Метод, предназначенный для получения прав доступа к документам рубрики
*
@ -402,7 +412,7 @@
/**
* Метод, предназначенный для обработки события 404 Not Found, т.е. когда страница не найдена.
*
* @return unknown
* @return void
*/
function _coreErrorPage404()
{
@ -491,6 +501,7 @@
return (isset($this->curentdoc->Id) && $this->curentdoc->Id == $document_id);
}
/**
* Метод, предназначенный для получения содержимого страницы с 404 ошибкой
*
@ -535,6 +546,7 @@
return (isset($this->curentdoc->Id) && $this->curentdoc->Id == $page_not_found_id);
}
/**
* Метод, предназначенный для получения МЕТА-тегов для различных модулей.
* ToDo
@ -565,6 +577,7 @@
return (isset($this->curentdoc->Id) && $this->curentdoc->Id == 1);
}
/**
* Метод, предназначенный для определения статуса документа (доступен ли он к публикации).
*
@ -614,6 +627,7 @@
return (! empty($this->curentdoc));
}
/**
* Метод парсинга тега [tag:(css|js):files]
* для вывода css/js-файлов в шаблоне через combine.php
@ -667,6 +681,13 @@
}
/**
* @param $main_content
* @param $id
* @param $rubTmpl
*
* @return mixed|null|string|string[]
*/
function _main_content ($main_content, $id, $rubTmpl)
{
global $AVE_DB, $AVE_Template;
@ -689,10 +710,10 @@
// Парсим элементы полей
$main_content = preg_replace_callback(
'/\[tag:fld:([a-zA-Z0-9-_]+)\]\[([0-9]+)]\[([0-9]+)]/',
create_function(
'$m',
'return get_field_element($m[1], $m[2], $m[3], ' . $this->curentdoc->Id . ');'
),
function ($m)
{
return get_field_element($m[1], $m[2], $m[3], $this->curentdoc->Id);
},
$main_content
);
@ -702,10 +723,10 @@
// Повторно парсим элементы полей
$main_content = preg_replace_callback(
'/\[tag:fld:([a-zA-Z0-9-_]+)\]\[([0-9]+)]\[([0-9]+)]/',
create_function(
'$m',
'return get_field_element($m[1], $m[2], $m[3], ' . $this->curentdoc->Id . ');'
),
function ($m)
{
return get_field_element($m[1], $m[2], $m[3], $this->curentdoc->Id);
},
$main_content
);
@ -744,8 +765,10 @@
// парсим теги в шаблоне рубрики
$main_content = preg_replace_callback(
'/\[tag:date:([a-zA-Z0-9-. \/]+)\]/',
create_function('$m','return translate_date(date($m[1], '.$this->curentdoc->document_published.'));
'),
function ($m)
{
return translate_date(date($m[1], $this->curentdoc->document_published));
},
$main_content
);
@ -786,6 +809,11 @@
}
/**
* Получаем ID для кеша документа
*
* @return array|bool
*/
function _get_cache_id()
{
$cache = array();
@ -811,6 +839,13 @@
}
/**
* Создаем компилированный документ
*
* @param $main_content
*
* @return bool
*/
function setCompileDocument ($main_content)
{
$cache = $this->_get_cache_id();
@ -841,6 +876,11 @@
}
/**
* Получаем скомпилированный документ
*
* @return bool|string
*/
function getCompileDocument ()
{
$cache = $this->_get_cache_id();
@ -1019,6 +1059,7 @@
}
}
/**
* Метод, предназанченный для сборки всей страницы в единое целое.
*
@ -1117,7 +1158,9 @@
// Выполняем Код рубрики До загрузки документа
ob_start();
eval(' ?>' . $this->curentdoc->rubric_start_code . '<?php ');
ob_end_clean();
// Получаем шаблон
@ -1517,10 +1560,10 @@
// Парсим тизер документа
$out = preg_replace_callback(
'/\[tag:teaser:(\d+)(|:\[(.*?)\])\]/',
create_function(
'$m',
'return showteaser($m[1], $m[2]);'
),
function ($m)
{
return showteaser($m[1], $m[2]);
},
$out
);
@ -1528,10 +1571,10 @@
if (defined('RUB_ID'))
$out = preg_replace_callback(
'/\[tag:docauthoravatar:(\d+)\]/',
create_function(
'$m',
'return getAvatar('.intval($this->curentdoc->document_author_id).', $m[1]);'
),
function ($m)
{
return getAvatar(intval($this->curentdoc->document_author_id), $m[1]);
},
$out
);
@ -1570,6 +1613,7 @@
echo $out;
}
/**
* Метод, предназначенный для формирования ЧПУ, а также для поиска документа и разбора
* дополнительных параметров в URL

385
class/class.debug.php

@ -35,20 +35,29 @@
* Функция для вывода переменной (для отладки)
*
* @param mixed $var любая переменная
* @param bool $exit
* @param null $bg
* @param bool $echo
*
* @return false|null|string|string[]
*/
public static function _echo($var, $exit = false, $bg = null)
public static function _echo($var, $exit = false, $bg = null, $echo = true)
{
$code = '';
$backtrace = debug_backtrace();
$backtrace = $backtrace[0];
if (preg_match('/([^\(]*)\((.*)\)/i', $backtrace['file']))
{
$file = preg_match('/([^\(]*)\((.*)\)/i', $backtrace['file'], $match);
preg_match('/([^\(]*)\((.*)\)/i', $backtrace['file'], $match);
$file = $match[1];
}
$fh = fopen((isset($file) ? $file : $backtrace['file']), 'r');
$fh = fopen((isset($file)
? $file
: $backtrace['file']), 'r');
$line = 0;
@ -71,7 +80,7 @@
$var_dump = htmlspecialchars($var_dump);
$var_dump = preg_replace('/(=&gt;)/', '<span style="color: #FF8C00;">$1</span>', $var_dump);
$var_dump = preg_replace('/(=&gt;)/', '<span style="color: #ff8c00;">$1</span>', $var_dump);
ob_end_clean();
@ -84,26 +93,54 @@
$fn_name = 'EVAL';
if (! $bg)
{
$br = '2a5885';
$bg = '43648c';
}
else
{
$br = $bg;
}
$var_dump = '
<div style="border: 1px solid #'.$br.'; margin: 5px 0; font-size: 11px; font-family: Consolas, Verdana, Arial; border-radius: 3px;">
<div style="background:#'.$bg.'; color: #fff; margin: 0; padding: 5px;">
var_dump(<strong>' . trim($fn_name) . '</strong>) - ' . self::_trace() .
'</div>
<style>
.debug_bg {
margin: 20px;
border: 1px solid #d9d9d9;
background-color: #f1efef;
border-radius: 5px;
box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
font-family: "Consolas", Verdana, Arial;
font-size: 11px;
}
.debug_top {
color: #ffffff;
font-size: 15px;
font-weight: bold;
padding-left: 20px;
padding-top: 10px;
padding-bottom: 10px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);
background-color: #' . $bg . ';
background-repeat: repeat-x;
border-bottom: 1px solid #ffffff;
}
.debug_box {
margin: 10px;
padding: 4px;
background-color: #efeded;
border: 1px solid #dedcdc;
}
</style>
<div class="debug_bg">
<div class="debug_top">
var_dump(<strong>' . trim($fn_name) . '</strong>)
</div>
'.self::_trace().'
<div class="debug_box">
<pre style="background:#f5f5f5; color: #000; margin: 0; padding: 5px; border: 0; font-size: 11px; font-family: Consolas, Verdana, Arial;">'
. $var_dump .
'</pre>
</div>
</div>
';
if (! $echo)
return $var_dump;
echo $var_dump;
if ($exit)
@ -115,27 +152,34 @@
* Функция для вывода переменной (для отладки)
*
* @param mixed $var любая переменная
* @param bool $exit
* @param null $bg
* @param bool $echo
*
* @return null|string|string[]
*/
public static function _print($var, $exit = false, $bg = null)
public static function _print($var, $exit = false, $bg = null, $echo = true)
{
$code = '';
$backtrace = debug_backtrace();
$backtrace = $backtrace[0];
if (preg_match('/([^\(]*)\((.*)\)/i', $backtrace['file']))
{
$file = preg_match('/([^\(]*)\((.*)\)/i', $backtrace['file'], $match);
preg_match('/([^\(]*)\((.*)\)/i', $backtrace['file'], $match);
$file = $match[1];
}
$fh = fopen((isset($file) ? $file : $backtrace['file']), 'r');
$fh = fopen((isset($file)
? $file
: $backtrace['file']), 'r');
$line = 0;
while (++$line <= $backtrace['line'])
{
$code = fgets($fh);
}
fclose($fh);
@ -160,26 +204,54 @@
$fn_name = 'EVAL';
if (! $bg)
{
$br = '365899';
$bg = '4e5665';
}
else
{
$br = $bg;
}
$var_dump = '
<div style="border: 1px solid #'.$br.'; margin: 5px 0; font-size: 11px; font-family: Consolas, Verdana, Arial; border-radius: 3px;">
<div style="background:#'.$bg.'; color: #fff; margin: 0; padding: 5px;">
print_r(<strong>' . trim($fn_name) . '</strong>) - ' . self::_trace() .
'</div>
<pre style="background:#f0f0f0; color: #000; margin: 0; padding: 5px; border: 0; font-size: 11px; font-family: Consolas, Verdana, Arial;">'
<style>
.debug_bg {
margin: 20px;
border: 1px solid #d9d9d9;
background-color: #f1efef;
border-radius: 5px;
box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
font-family: Consolas, Verdana, Arial;
font-size: 11px;
}
.debug_top {
color: #ffffff;
font-size: 15px;
font-weight: bold;
padding-left: 20px;
padding-top: 10px;
padding-bottom: 10px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);
background-color: #'.$bg.';
background-repeat: repeat-x;
border-bottom: 1px solid #ffffff;
}
.debug_box {
margin: 10px;
padding: 4px;
background-color: #efeded;
border: 1px solid #dedcdc;
}
</style>
<div class="debug_bg">
<div class="debug_top">
print_r(<strong>' . trim($fn_name) . '</strong>)
</div>
'.self::_trace().'
<div class="debug_box">
<pre style="background:#f5f5f5; color: #000; margin: 0; padding: 5px; border: 0; font-size: 11px; font-family: Consolas, Verdana, Arial;">'
. $var_dump .
'</pre>
</div>
</div>
';
if (! $echo)
return $var_dump;
echo $var_dump;
if ($exit)
@ -191,27 +263,34 @@
* Функция для вывода переменной (для экспорта)
*
* @param mixed $var любая переменная
* @param bool $exit
* @param null $bg
* @param bool $echo
*
* @return string
*/
public static function _exp($var, $exit = false, $bg = null)
public static function _exp($var, $exit = false, $bg = null, $echo = true)
{
$code = '';
$backtrace = debug_backtrace();
$backtrace = $backtrace[0];
if (preg_match('/([^\(]*)\((.*)\)/i', $backtrace['file']))
{
$file = preg_match('/([^\(]*)\((.*)\)/i', $backtrace['file'], $match);
preg_match('/([^\(]*)\((.*)\)/i', $backtrace['file'], $match);
$file = $match[1];
}
$fh = fopen((isset($file) ? $file : $backtrace['file']), 'r');
$fh = fopen((isset($file)
? $file
: $backtrace['file']), 'r');
$line = 0;
while (++$line <= $backtrace['line'])
{
$code = fgets($fh);
}
fclose($fh);
@ -230,14 +309,7 @@
$fn_name = 'EVAL';
if (! $bg)
{
$br = 'bbb';
$bg = 'ccc';
}
else
{
$br = $bg;
}
$var_export = htmlspecialchars(ob_get_contents());
@ -246,16 +318,51 @@
ob_end_clean();
$var_dump = '
<div style="border: 1px solid #'.$br.'; margin: 5px 0; font-size: 11px; font-family: Consolas, Verdana, Arial; border-radius: 3px;">
<div style="background:#'.$bg.'; color: #000; margin: 0; padding: 5px;">var_export(<strong>'
. trim($fn_name) . '</strong>) - ' . self::_trace() .
'</div>
<pre style="background:#f0f0f0; color: #000; margin: 0; padding: 5px; border: 0; font-size: 11px; font-family: Consolas, Verdana, Arial;">'
<style>
.debug_bg {
margin: 20px;
border: 1px solid #d9d9d9;
background-color: #f1efef;
border-radius: 5px;
box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
font-family: Consolas, Verdana, Arial;
font-size: 11px;
}
.debug_top {
color: #ffffff;
font-size: 15px;
font-weight: bold;
padding-left: 20px;
padding-top: 10px;
padding-bottom: 10px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);
background-color: #'.$bg.';
background-repeat: repeat-x;
border-bottom: 1px solid #ffffff;
}
.debug_box {
margin: 10px;
padding: 4px;
background-color: #efeded;
border: 1px solid #dedcdc;
}
</style>
<div class="debug_bg">
<div class="debug_top">
var_export(<strong>' . trim($fn_name) . '</strong>)
</div>
'.self::_trace().'
<div class="debug_box">
<pre style="background:#f5f5f5; color: #000; margin: 0; padding: 5px; border: 0; font-size: 11px; font-family: Consolas, Verdana, Arial;">'
. $var_export .
'</pre>
</div>
</div>
';
if (! $echo)
return $var_dump;
echo $var_dump;
if ($exit)
@ -268,27 +375,33 @@
*
* @param mixed $var любая переменная
* @param bool $exit true - остановливает дальнейшее выполнение скрипта, false - продолжает выполнять скрипт
* @param null $bg
* @param bool $echo
*
* @return false|string
*/
public static function _html($var, $exit = false)
public static function _html($var, $exit = false, $bg = null, $echo = true)
{
$code = '';
$backtrace = debug_backtrace();
$backtrace = $backtrace[0];
if (preg_match('/([^\(]*)\((.*)\)/i', $backtrace['file']))
{
$file = preg_match('/([^\(]*)\((.*)\)/i', $backtrace['file'], $match);
preg_match('/([^\(]*)\((.*)\)/i', $backtrace['file'], $match);
$file = $match[1];
}
$fh = fopen((isset($file) ? $file : $backtrace['file']), 'r');
$fh = fopen((isset($file)
? $file
: $backtrace['file']), 'r');
$line = 0;
while (++$line <= $backtrace['line'])
{
$code = fgets($fh);
}
fclose($fh);
@ -298,28 +411,72 @@
var_export($var);
$fn_name = !empty($name)
? $name[1]
: 'EVAL';
if (! empty($name))
{
$fn_name = explode(',', $name[1]);
$fn_name = array_shift($fn_name);
}
else
$fn_name = 'EVAL';
if (! $bg)
$bg = '43648c';
$var_dump = ob_get_contents();
ob_end_clean();
$var_dump = '
<div style="border: 1px solid #bbb; margin: 5px 0; font-size: 11px; font-family: Consolas, Verdana, Arial; border-radius: 3px;">
<div style="background:#ccc; color: #000; margin: 0; padding: 5px;">var_export(<strong>'
. trim($fn_name) . '</strong>) - ' . self::_trace() .
'</div>
<pre style="background:#f0f0f0; color: #000; margin: 0; padding: 5px; border: 0; font-size: 11px; font-family: Consolas, Verdana, Arial;">'
<style>
.debug_bg {
margin: 20px;
border: 1px solid #d9d9d9;
background-color: #f1efef;
border-radius: 5px;
box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
font-family: Consolas, Verdana, Arial;
border-radius: 3px;
font-size: 11px;
}
.debug_top {
color: #ffffff;
font-size: 15px;
font-weight: bold;
padding-left: 20px;
padding-top: 10px;
padding-bottom: 10px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);
background-color: #'.$bg.';
background-repeat: repeat-x;
border-bottom: 1px solid #ffffff;
}
.debug_box {
margin: 10px;
padding: 4px;
background-color: #efeded;
border: 1px solid #dedcdc;
}
</style>
<div class="debug_bg">
<div class="debug_top">
var_export(<strong>' . trim($fn_name) . '</strong>)
</div>
'.self::_trace().'
<div class="debug_box">
<pre style="background:#f5f5f5; color: #000; margin: 0; padding: 5px; border: 0; font-size: 11px; font-family: Consolas, Verdana, Arial;">'
. htmlentities($var_dump, ENT_QUOTES) .
'</pre>
</div>
</div>
';
if (! $echo)
return $var_dump;
echo $var_dump;
if ($exit) exit;
if ($exit)
exit;
}
@ -328,9 +485,13 @@
*
* @param mixed $var любая переменная
* @param bool $exit true - остановливает дальнейшее выполнение скрипта, false - продолжает выполнять скрипт
* @param null $bg
* @param bool $append
*/
public static function _dump($var, $append = true, $exit = false, $bg = null)
public static function _dump($var, $exit = false, $bg = null, $append = true)
{
$code = '';
$backtrace = debug_backtrace();
$backtrace = $backtrace[0];
@ -341,14 +502,14 @@
$file = $match[1];
}
$fh = fopen((isset($file) ? $file : $backtrace['file']), 'r');
$fh = fopen((isset($file)
? $file
: $backtrace['file']), 'r');
$line = 0;
while (++$line <= $backtrace['line'])
{
$code = fgets($fh);
}
fclose($fh);
@ -387,14 +548,46 @@
}
$var_dump = '
<div style="border: 1px solid #'.$br.'; margin: 5px 0; font-size: 11px; font-family: Consolas, Verdana, Arial; border-radius: 3px;">
<div style="background:#'.$bg.'; color: #fff; margin: 0; padding: 5px;">
<strong>' . date("j F Y, H:i:s") . '</strong> - var_dump(<strong>' . trim($fn_name) . '</strong>) - ' . self::_trace() .
'</div>
<style>
.debug_bg {
margin: 20px;
border: 1px solid #d9d9d9;
background-color: #f1efef;
border-radius: 5px;
box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
font-family: Consolas, Verdana, Arial;
font-size: 11px;
}
.debug_top {
color: #ffffff;
font-size: 15px;
font-weight: bold;
padding-left: 20px;
padding-top: 10px;
padding-bottom: 10px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);
background-color: #'.$bg.';
background-repeat: repeat-x;
border-bottom: 1px solid #ffffff;
}
.debug_box {
margin: 10px;
padding: 4px;
background-color: #efeded;
border: 1px solid #dedcdc;
}
</style>
<div class="debug_bg">
<div class="debug_top">
var_dump(<strong>' . trim($fn_name) . '</strong>)
</div>
'.self::_trace().'
<div class="debug_box">
<pre style="background:#f5f5f5; color: #000; margin: 0; padding: 5px; border: 0; font-size: 11px; font-family: Consolas, Verdana, Arial;">'
. $var_dump .
'</pre>
</div>
</div>
';
if ($append)
@ -423,26 +616,22 @@
$file = $trace['file'];
$function = $trace['function'];
//$function = $trace['function'];
$class = (isset($bt[2]['class'])
? $bt[2]['class']
: 'None');
if (isset($bt[2]['class']))
{
$type = $bt[2]['type'];
}
else
{
$type = 'Unknow';
}
$function = isset($bt[2]['function'])
? $bt[2]['function']
: 'None';
return sprintf('Class: <strong>%s</strong> | Type: <strong>%s</strong> | Function: <strong>%s</strong> | File: <strong>%s</strong> line <strong>%s</strong>', $class, $type, $function, $file, $line);
return sprintf('<div class="debug_box">Class: <strong>%s</strong> | Type: <strong>%s</strong> | Function: <strong>%s</strong></div><div class="debug_box">File: <strong>%s</strong> line <strong>%s</strong></div>', $class, $type, $function, $file, $line);
}
@ -461,7 +650,8 @@
* Функция отвечает за окончание таймера
*
* @param string $name любая переменная (ключ массива)
* @return
*
* @return string
*/
public static function endTime($name = '')
{
@ -503,21 +693,13 @@
public static function formatSize($size)
{
if ($size >= 1073741824)
{
$size = round($size / 1073741824 * 100) / 100 . ' Gb';
}
elseif ($size >= 1048576)
{
$size = round($size / 1048576 * 100) / 100 . ' Mb';
}
elseif ($size >= 1024)
{
$size = round($size / 1024 * 100) / 100 . ' Kb';
}
else
{
$size = $size . ' b';
}
return $size;
}
@ -541,21 +723,24 @@
}
/**
* @param $header
* @param $body
* @param $caller
* @param bool $exit
*/
public static function _errorSql ($header, $body, $caller, $exit = false)
{
Debug::_echo(preg_replace('/(\s)+/s', ' ', $header));
Debug::_echo(DB::queryList($body));
Debug::_echo($caller);
if ($exit)
exit;
//
}
/**
* Вывод статистики
*
* @param null $type
*
* @return int|null|string
*/
public static function getStatistic ($type = null)
{
@ -618,10 +803,13 @@
}
/**
* @param string $type
*
* @return false|null|string|string[]
*/
public static function _stat_get($type = 'get')
{
$var = '123123';
ob_start();
if ($type == 'get')
var_dump($_GET);
@ -645,7 +833,10 @@
return $stat;
}
//
/**
* @return string
*/
public static function displayInfo ()
{
global $AVE_DB;

16
class/class.meta.php

@ -16,12 +16,14 @@ class Meta
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)
{
if( (int) $keyword_count ) $this->_keyword_count = $keyword_count;
if ((int)$keyword_count)
$this->_keyword_count = $keyword_count;
}
public function generateMeta($text)
@ -49,16 +51,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);
arsort($arr);
$arr = array_keys($arr);
$total = count( $arr );
// Не используется
// $total = count($arr);
$offset = 0;

3
class/class.modules.php

@ -404,6 +404,7 @@
ModuleSysName = '" . MODULE_PATH . "'
");
}
// Сохраняем системное сообщение в журнал
reportLog ($AVE_Template->get_config_vars('MODULES_ACTION_UPDATE') . ' (' . MODULE_PATH . ')');
@ -514,7 +515,7 @@
foreach ($files as $file)
{
if (substr($file, -1) == '/')
moduleRemove($file);
$this->moduleRemove($file);
else
unlink($file);
}

18
class/class.session.php

@ -54,6 +54,7 @@ class AVE_Session_DB
private $mysql_connect = null;
private $mysql_db = null;
/* Create a connection to a database */
function __construct()
{
@ -73,26 +74,24 @@ class AVE_Session_DB
: get_cfg_var("session.gc_maxlifetime"));
if (! $this->mysql_connect = mysqli_connect ($this->db_host, $this->db_user, $this->db_pass))
{
$this->error();
}
if (! $this->mysql_db = mysqli_select_db ($this->mysql_connect, $this->db_dbase))
{
$this->error();
}
$this->mysql_connect->set_charset('utf8');
return true;
}
/* Open session */
function _open($path, $name)
{
return true;
}
/* Close session */
function _close()
{
@ -104,26 +103,24 @@ class AVE_Session_DB
return true;
}
/* 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() . "'");
if ((list($value, $ip) = @mysqli_fetch_row($qid)) && $ip == $_SERVER['REMOTE_ADDR'])
{
return $value;
}
return '';
}
/* 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'))"))
{
$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;
}
@ -139,14 +136,11 @@ class AVE_Session_DB
{
$session_res = @mysqli_query($this->mysql_connect, "DELETE FROM ".PREFIX."_sessions WHERE expire < (UNIX_TIMESTAMP(NOW()) - " . (int)$maxlifetime . ")");
if (!$session_res) {
if (! $session_res)
return false;
}
else
{
return true;
}
}
function error() {
ob_start();

2
class/class.utm.php

@ -1,6 +1,5 @@
<?php
/*
Версия от 06.03.2018г.
Как это работает:
@ -9,7 +8,6 @@
3) Если utm_history уже есть, то сохраняет данные в utm_last
4) utm_last перезаписывается при каждом новом значении, а utm_history всегда остаётся неизменной (если был передан хотя бы один параметр)
5) utm_source сохраняется всегда до закрытия браузера
*/
class UTMCookie
{

163
fields/checkbox_multi/field.php

@ -1,163 +0,0 @@
<?php
/**
* AVE.cms
*
* @package AVE.cms
* @version 3.x
* @filesource
* @copyright © 2007-2015 AVE.cms, http://www.ave-cms.ru
*
* @license GPL v.2
*/
// Мульти чекбокс
function get_field_checkbox_multi($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null, $_tpl=null)
{
global $AVE_Template;
$fld_dir = dirname(__FILE__) . '/';
$tpl_dir = $fld_dir . 'tpl/';
$lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
$AVE_Template->config_load($lang_file, 'lang');
$AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
$AVE_Template->config_load($lang_file, 'admin');
$res = array();
switch ($action)
{
case 'edit':
$default_items = explode(',', $default);
$default_items = array_diff($default_items, array(''));
$field_value_array = explode('|', $field_value);
$field_value_array = array_values(array_diff($field_value_array, array('')));
$AVE_Template->assign('items', $default_items);
$AVE_Template->assign('used', $field_value_array);
$AVE_Template->assign('doc_id', (isset($_REQUEST['Id']) ? (int)$_REQUEST['Id'] : 0));
$AVE_Template->assign('field_id', $field_id);
$AVE_Template->assign('field_value', $field_value);
$tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin', $_tpl);
return $AVE_Template->fetch($tpl_file);
break;
case 'doc':
$default_items = explode(',', $default);
$items = explode('|', $field_value);
$items = array_diff($items, array(''));
if (! empty($items))
{
foreach($items as $item)
{
if ($item)
{
if ($tpl_empty)
{
$item = $default_items[(int)$item-1];
}
else
{
$field_param = explode('|', $item);
$item = preg_replace_callback(
'/\[tag:parametr:(\d+)\]/i',
function($data) use($field_param, $default_items)
{
return $default_items[$field_param[(int)$data[1]]-1];
},
$tpl
);
}
}
$res[] = $item;
}
}
$tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc', $_tpl);
if ($tpl_empty && $tpl_file)
{
$AVE_Template->assign('field_id', $field_id);
$AVE_Template->assign('field_value', $res);
$AVE_Template->assign('rubric_id', $rubric_id);
$AVE_Template->assign('default', $default_items);
return $AVE_Template->fetch($tpl_file);
}
return (! empty($res))
? implode(PHP_EOL, $res)
: $tpl;
break;
case 'req':
$default_items = explode(',', $default);
$items = explode('|', $field_value);
$items = array_diff($items, array(''));
if (! empty($items))
{
foreach($items as $item)
{
if ($item)
{
if ($tpl_empty)
{
$item = $default_items[(int)$item-1];
}
else
{
$field_param = explode('|', $item);
$item = preg_replace_callback(
'/\[tag:parametr:(\d+)\]/i',
function($data) use($field_param, $default_items)
{
return $default_items[$field_param[(int)$data[1]]-1];
},
$tpl
);
}
}
$res[] = $item;
}
}
$tpl_file = get_field_tpl($tpl_dir, $field_id, 'req', $_tpl);
if ($tpl_empty && $tpl_file)
{
$AVE_Template->assign('field_id', $field_id);
$AVE_Template->assign('field_value', $res);
$AVE_Template->assign('rubric_id', $rubric_id);
$AVE_Template->assign('default', $default_items);
return $AVE_Template->fetch($tpl_file);
}
return (! empty($res))
? implode(PHP_EOL, $res)
: $tpl;
break;
case 'name':
return $AVE_Template->get_config_vars('name');
break;
}
return ($res ? $res : $field_value);
}
?>

163
fields/multi_checkbox/field.php

@ -0,0 +1,163 @@
<?
/**
* AVE.cms
*
* @package AVE.cms
* @version 3.x
* @filesource
* @copyright © 2007-2015 AVE.cms, http://www.ave-cms.ru
*
* @license GPL v.2
*/
// Мульти чекбокс
function get_field_multi_checkbox($field_value, $action, $field_id=0, $tpl='', $tpl_empty=0, &$maxlength=null, $document_fields=array(), $rubric_id=0, $default=null)
{
global $AVE_Template;
$fld_dir = dirname(__FILE__) . '/';
$tpl_dir = $fld_dir . 'tpl/';
$lang_file = $fld_dir . 'lang/' . (defined('ACP') ? $_SESSION['admin_language'] : $_SESSION['user_language']) . '.txt';
$AVE_Template->config_load($lang_file, 'lang');
$AVE_Template->assign('config_vars', $AVE_Template->get_config_vars());
$AVE_Template->config_load($lang_file, 'admin');
$res = array();
switch ($action)
{
case 'edit':
$default_items = explode(',', $default);
$default_items = array_diff($default_items, array(''));
$field_value_array = explode('|', $field_value);
$field_value_array = array_values(array_diff($field_value_array, array('')));
$AVE_Template->assign('items', $default_items);
$AVE_Template->assign('used', $field_value_array);
$AVE_Template->assign('doc_id', (isset($_REQUEST['Id']) ? (int)$_REQUEST['Id'] : 0));
$AVE_Template->assign('field_id', $field_id);
$AVE_Template->assign('field_value', $field_value);
$tpl_file = get_field_tpl($tpl_dir, $field_id, 'admin');
return $AVE_Template->fetch($tpl_file);
break;
case 'doc':
$default_items = explode(',', $default);
$items = explode('|', $field_value);
$items = array_diff($items, array(''));
if (! empty($items))
{
foreach($items as $item)
{
if ($item)
{
if ($tpl_empty)
{
$item = $default_items[(int)$item-1];
}
else
{
$field_param = explode('|', $item);
$item = preg_replace_callback(
'/\[tag:parametr:(\d+)\]/i',
function($data) use($field_param, $default_items)
{
return $default_items[$field_param[(int)$data[1]]-1];
},
$tpl
);
}
}
$res[] = $item;
}
}
$tpl_file = get_field_tpl($tpl_dir, $field_id, 'doc');
if ($tpl_empty && $tpl_file)
{
$AVE_Template->assign('field_id', $field_id);
$AVE_Template->assign('field_value', $res);
$AVE_Template->assign('rubric_id', $rubric_id);
$AVE_Template->assign('default', $default_items);
return $AVE_Template->fetch($tpl_file);
}
return (! empty($res))
? implode(PHP_EOL, $res)
: $tpl;
break;
case 'req':
$default_items = explode(',', $default);
$items = explode('|', $field_value);
$items = array_diff($items, array(''));
if (! empty($items))
{
foreach($items as $item)
{
if ($item)
{
if ($tpl_empty)
{
$item = $default_items[(int)$item-1];
}
else
{
$field_param = explode('|', $item);
$item = preg_replace_callback(
'/\[tag:parametr:(\d+)\]/i',
function($data) use($field_param, $default_items)
{
return $default_items[$field_param[(int)$data[1]]-1];
},
$tpl
);
}
}
$res[] = $item;
}
}
$tpl_file = get_field_tpl($tpl_dir, $field_id, 'req');
if ($tpl_empty && $tpl_file)
{
$AVE_Template->assign('field_id', $field_id);
$AVE_Template->assign('field_value', $res);
$AVE_Template->assign('rubric_id', $rubric_id);
$AVE_Template->assign('default', $default_items);
return $AVE_Template->fetch($tpl_file);
}
return (! empty($res))
? implode(PHP_EOL, $res)
: $tpl;
break;
case 'name':
return $AVE_Template->get_config_vars('name');
break;
}
return ($res ? $res : $field_value);
}
?>

0
fields/checkbox_multi/lang/bg.txt → fields/multi_checkbox/lang/bg.txt

0
fields/checkbox_multi/lang/cz.txt → fields/multi_checkbox/lang/cz.txt

0
fields/checkbox_multi/lang/en.txt → fields/multi_checkbox/lang/en.txt

0
fields/checkbox_multi/lang/pl.txt → fields/multi_checkbox/lang/pl.txt

0
fields/checkbox_multi/lang/ru.txt → fields/multi_checkbox/lang/ru.txt

0
fields/checkbox_multi/lang/ua.txt → fields/multi_checkbox/lang/ua.txt

0
fields/checkbox_multi/tpl/field-doc.tpl → fields/multi_checkbox/tpl/field-doc.tpl

0
fields/checkbox_multi/tpl/field-req.tpl → fields/multi_checkbox/tpl/field-req.tpl

0
fields/checkbox_multi/tpl/field.tpl → fields/multi_checkbox/tpl/field.tpl

3
fields/tags/field.php

@ -196,9 +196,6 @@
// Делаем уникальные значения
$field_value = array_unique($tags);
if (empty($field_value))
$field_value = '';
return $field_value;
}
}

6
functions/func.block.php

@ -15,10 +15,12 @@
* Обработка тега блока
*
* @param int $id идентификатор системного блока
*
* @return bool|mixed|null|string|string[]
*/
function parse_block($id)
{
global $AVE_DB, $AVE_Core;
global $AVE_DB;
if (is_array($id))
$id = $id[1];
@ -97,5 +99,7 @@
return $return;
}
return false;
}
?>

4
functions/func.breadcrumbs.php

@ -210,13 +210,9 @@
$bread_crumb .= sprintf($bread_self_box, $current->document_breadcrum_title);
if (! $noprint)
{
$crumbs[$curent_document] = sprintf($bread_box, $bread_crumb);
}
else
{
$crumbs[$curent_document] = '';
}
unset($bread_crumb);

64
functions/func.common.php

@ -22,6 +22,10 @@
/**
* Функция загрузки файлов с удаленного сервера через CURL
* как альтернатива для file_get_conents
*
* @param $sourceFileName
*
* @return mixed
*/
function CURL_file_get_contents($sourceFileName)
{
@ -32,6 +36,7 @@
$st = curl_exec($ch);
curl_close($ch);
return ($st);
}
@ -131,6 +136,8 @@
* @internal param int $id идентификатор запроса
* @return string
*/
if (! function_exists("eval2var"))
{
function eval2var($expression)
{
global $AVE_DB, $AVE_Core, $AVE_Template;
@ -143,6 +150,7 @@
return $content;
}
}
/**
@ -510,6 +518,13 @@
/**
* Вывод статистики
*
* @param int $t
* @param int $m
* @param int $q
* @param int $l
*
* @return string
*/
function get_statistic($t=0, $m=0, $q=0, $l=0)
{
@ -538,6 +553,11 @@
/**
* Комментарии в SMARTY
*
* @param $tpl_source
* @param $smarty
*
* @return string
*/
function add_template_comment($tpl_source, &$smarty)
{
@ -612,10 +632,10 @@
closedir($handle);
}
$return = array(
'files' => $files,
'thumbs' => $thumbs
);
//$return = array(
// 'files' => $files,
// 'thumbs' => $thumbs
//);
return $files;
}
@ -630,6 +650,8 @@
{
$dir = BASE_DIR . "/" . $path;
$files = array();
if ($handle = opendir($dir))
{
while (false !== ($file = readdir($handle)))
@ -645,6 +667,7 @@
}
closedir($handle);
}
return $files;
}
@ -685,10 +708,12 @@
/**
* Функция записывает в указанную папку .htaccess с содержанием "Deny from all"
*
* @param $dir
*/
function write_htaccess_deny($dir)
{
$file = $dir . '/.htaccess';
if (! file_exists($file))
{
if (! is_dir($dir))
@ -751,7 +776,7 @@
$object = (array)$object;
if ($object === array())
return;
return $object;
foreach($object as $key => &$value)
{
@ -774,7 +799,7 @@
* @param array $array The array to sort.
* @param string|array $key The index(es) to sort the array on.
* @param int $sort_flags The optional parameter to modify the sorting
* @param string $sort_way The optional parameter to modify the sorting as DESC or ASC
* @param int $sort_way The optional parameter to modify the sorting as DESC or ASC
* behavior. This parameter does not work when
* supplying an array in the $key parameter.
*
@ -852,7 +877,6 @@
*
* @param string $string
* @param $limit
* @return string
*/
function findautor($string, $limit)
{
@ -878,6 +902,7 @@
);
$users = array();
while ($row = $sql->FetchRow())
{
$ava=getAvatar($row->Id,40);
@ -890,6 +915,7 @@
'avatar'=>($ava ? $ava : ABS_PATH.'admin/templates/images/user.png')
);
}
echo json_encode($users);
}
@ -926,7 +952,6 @@
/**
* Функция поиска тегов
*
* @param string $string - запрос
* @return string
*/
function searchTags()
@ -942,12 +967,10 @@
$tags = array();
$ii = 0;
//$ii = 0;
while ($row = $sql->GetCell())
{
$tags[]['value'] = $row;
}
echo json_encode($tags);
exit;
@ -1002,6 +1025,8 @@
/**
* Создание cookie
*
* @param string $cookie_domain
*/
function set_cookie_domain($cookie_domain = '')
{
@ -1039,7 +1064,7 @@
/**
* Функция проверяет наличие Ajax запроса
*
* @return bool true|false - Ajax
* @return bool
*/
function isAjax()
{
@ -1050,6 +1075,8 @@
/**
* Функция делает html в 1 строчку, удаляет лишние пробелы, комментарии и т.д.
*
* @param $data
*
* @return string
*/
function compress_htlm($data)
@ -1077,7 +1104,8 @@
/**
* Функция делает компрессию данных
*
* @return string
* @param $data
*
*/
function output_compress($data)
{
@ -1132,15 +1160,21 @@
* Функция создает короткий URL документа для редиректа
* После выполения функции нужно очистить кеш данного документа
*
* @return
* @param int $length
* @param $doc_id
*
* @return bool
*/
function gen_short_link ($length = 1, $doc_id)
function gen_short_link ($length, $doc_id)
{
global $AVE_DB;
if (! is_numeric($doc_id))
return false;
if (! $length)
$length = 1;
// Проврека на существование редиректа для данного документа
$check_doc = $AVE_DB->Query("
SELECT

4
functions/func.documents.php

@ -79,7 +79,7 @@
* @param int $doc_id - номер id документа
* @param string $key - параметр документа
*
* @return string
* @return string | bool | array
*/
function get_document ($doc_id , $key ='')
{
@ -114,7 +114,7 @@
*
* @param int $doc_id - номер id документа
*
* @return object
* @return object | bool
*/
function getDocument ($doc_id)
{

20
functions/func.fields.php

@ -104,6 +104,8 @@
/**
* Возвращаем тип поля
*
* @param string $type
*
* @return mixed
*/
function get_field_type ($type = '')
@ -129,14 +131,10 @@
$id = substr($v, strlen('get_field_'));
if ($name != false && is_string($name))
$fields[] = array('id' => $id,'name' => (isset($fields_vars[$name])
? $fields_vars[$name]
: $name));
$fields[] = array('id' => $id, 'name' => $name);
if (! empty($type) && $id == $type)
$field = array('id' => $id,'name' => (isset($fields_vars[$name])
? $fields_vars[$name]
: $name));
$field = array('id' => $id, 'name' => $name);
}
else
continue;
@ -208,7 +206,6 @@
/**
* Возвращаем
*
* @param $rubric_id
* @param $id
*
* @return string
@ -286,9 +283,11 @@
* @param int $field_id идентификатор поля
* @param int $document_id
*
* @param null $_tpl
*
* @return string
*/
function document_get_field($field_id, $document_id = null, $_tpl = null)
function document_get_field($field_id, $document_id = null, $_tpl = null, $maxlength = null)
{
global $AVE_Core;
@ -409,7 +408,7 @@
*/
function get_document_fields($document_id, $values = null)
{
global $AVE_DB, $request_documents, $AVE_Core;
global $AVE_DB, $AVE_Core; //$request_documents
static $document_fields = array();
@ -488,9 +487,7 @@
$row['field_value'] = (string)$row['field_value'] . (string)$row['field_value_more'];
if ($values)
{
$row['field_value']=(isset($values[$row['rubric_field_id']]) ? $values[$row['rubric_field_id']] : $row['field_value']);
}
if ($row['field_value'] === '')
{
@ -733,7 +730,6 @@
*
* @param int $field_id ([tag:fld:X]) - номер поля
* @param int $doc_id
* @param int $parametr ([tag:parametr:X]) - часть поля
*
* @return string
*/

207
functions/func.helpers.php

@ -18,7 +18,8 @@
* @param string
* @return string
*/
if (!function_exists('str_nospace')){
if (! function_exists('str_nospace'))
{
function str_nospace($string)
{
return trim(str_replace(array(' ',"\r","\n","\t"),'', $string));
@ -32,7 +33,8 @@ if (!function_exists('str_nospace')){
* @param string $string данные
* @return string
*/
if (!function_exists('full_trim')){
if (! function_exists('full_trim'))
{
function full_trim($string)
{
return trim(preg_replace('/\s{2,}/', ' ', $string));
@ -46,7 +48,8 @@ if (!function_exists('full_trim')){
* @param string $string данные
* @return string
*/
if (!function_exists('utf8')){
if (! function_exists('utf8'))
{
function utf8($string){
$string = iconv('windows-1251', 'utf-8', $string);
return $string;
@ -61,20 +64,33 @@ if (!function_exists('utf8')){
* @param null $val
* @return array
*/
if (!function_exists('collect_data')){
if (! function_exists('collect_data'))
{
function collect_data($type = '', $val = null)
{
static $arr = array();
if(empty($type)) return false;
if($val&& !trim($type) == ''){
if(!is_array($val))$val = array($val);
foreach($val as $value){
if(!isset($arr[$type])) $arr[$type] = array();
if (empty($type))
return false;
if ($val && !trim($type) == '')
{
if (! is_array($val))
$val = array($val);
foreach($val as $value)
{
if (! isset($arr[$type]))
$arr[$type] = array();
if (! in_array($value, $arr[$type]))
$arr[$type][] = $value;
}
}
return isset($arr[$type]) ? $arr[$type] : false;
return isset($arr[$type])
? $arr[$type]
: false;
}
}
@ -119,11 +135,13 @@ include (BASE_DIR . '/lib/StripTagsSmart/strip_tags_smart.php');
* @param string $b конечная метка
* @return int время между метками
*/
if (!function_exists('microtime_diff')){
if (! function_exists('microtime_diff'))
{
function microtime_diff($a, $b)
{
list($a_dec, $a_sec) = explode(' ', $a);
list($b_dec, $b_sec) = explode(' ', $b);
return $b_sec - $a_sec + $b_dec - $a_dec;
}
}
@ -135,7 +153,8 @@ if (!function_exists('microtime_diff')){
* @param string $path
* @param string $to
*/
if (!function_exists('file_encoding')){
if (! function_exists('file_encoding'))
{
function file_encoding($path, $to='utf')
{
$f = file_get_contents($path);
@ -157,29 +176,37 @@ if (!function_exists('file_encoding')){
* @version $Revision: 1.23 $
* @since PHP 5
* @require PHP 4.0.0 (user_error)
*
* @param $keys
* @param $values
*
* @return array|bool
*/
function php_compat_array_combine($keys, $values)
{
if (!is_array($keys)) {
user_error('array_combine() expects parameter 1 to be array, ' .
gettype($keys) . ' given', E_USER_WARNING);
return;
if (! is_array($keys))
{
user_error('array_combine() expects parameter 1 to be array, ' . gettype($keys) . ' given', E_USER_WARNING);
return false;
}
if (!is_array($values)) {
user_error('array_combine() expects parameter 2 to be array, ' .
gettype($values) . ' given', E_USER_WARNING);
return;
if (! is_array($values))
{
user_error('array_combine() expects parameter 2 to be array, ' . gettype($values) . ' given', E_USER_WARNING);
return false;
}
$key_count = count($keys);
$value_count = count($values);
if ($key_count !== $value_count) {
if ($key_count !== $value_count)
{
user_error('array_combine() Both parameters should have equal number of elements', E_USER_WARNING);
return false;
}
if ($key_count === 0 || $value_count === 0) {
if ($key_count === 0 || $value_count === 0)
{
user_error('array_combine() Both parameters should have number of elements at least 0', E_USER_WARNING);
return false;
}
@ -188,7 +215,9 @@ function php_compat_array_combine($keys, $values)
$values = array_values($values);
$combined = array();
for ($i = 0; $i < $key_count; $i++) {
for ($i = 0; $i < $key_count; $i++)
{
$combined[$keys[$i]] = $values[$i];
}
@ -196,7 +225,8 @@ function php_compat_array_combine($keys, $values)
}
// Define
if (!function_exists('array_combine')) {
if (! function_exists('array_combine'))
{
function array_combine($keys, $values)
{
return php_compat_array_combine($keys, $values);
@ -210,10 +240,13 @@ if (!function_exists('array_combine')) {
* @param mixed $var
* @return string
*/
if (!function_exists('post')){
if (! function_exists('post'))
{
function post($var)
{
return (isset($_POST[$var])) ? $_POST[$var] : '';
return (isset($_POST[$var]))
? $_POST[$var]
: '';
}
}
@ -224,10 +257,13 @@ if (!function_exists('post')){
* @param mixed $var
* @return string
*/
if (!function_exists('get')){
if (! function_exists('get'))
{
function get($var)
{
return (isset($_GET[$var])) ? $_GET[$var] : '';
return (isset($_GET[$var]))
? $_GET[$var]
: '';
}
}
@ -241,7 +277,8 @@ if (!function_exists('get')){
* @param bool $str
* @return mixed|string
*/
if (!function_exists('sanitize')){
if (! function_exists('sanitize'))
{
function sanitize($string, $trim = false, $int = false, $str = false)
{
$string = filter_var($string, FILTER_SANITIZE_STRING);
@ -284,7 +321,8 @@ if (!function_exists('sanitize')){
* @param string $end_char
* @return mixed|string
*/
if (!function_exists('cleanSanitize')){
if (! function_exists('cleanSanitize'))
{
function cleanSanitize($string, $trim = false, $end_char = '&#8230;')
{
$string = cleanOut($string);
@ -303,7 +341,8 @@ if (!function_exists('cleanSanitize')){
'"'), $string);
if ($trim) {
if (strlen($string) < $trim) {
if (strlen($string) < $trim)
{
return $string;
}
@ -312,20 +351,25 @@ if (!function_exists('cleanSanitize')){
"\r",
"\n"), ' ', $string));
if (strlen($string) <= $trim) {
if (strlen($string) <= $trim)
{
return $string;
}
$out = "";
foreach (explode(' ', trim($string)) as $val) {
foreach (explode(' ', trim($string)) as $val)
{
$out .= $val . ' ';
if (strlen($out) >= $trim) {
if (strlen($out) >= $trim)
{
$out = trim($out);
return (strlen($out) == strlen($string)) ? $out : $out . $end_char;
}
}
}
return $string;
}
}
@ -423,6 +467,11 @@ if (!function_exists('truncate_text'))
* Swap named HTML entities with numeric entities.
*
* @see http://www.lazycat.org/software/html_entity_decode_full.phps
*
* @param $matches
* @param bool $destroy
*
* @return mixed|string
*/
function convert_entity($matches, $destroy = true)
{
@ -480,8 +529,12 @@ function convert_entity($matches, $destroy = true)
'zwj' => '&#8205;', 'zwnj' => '&#8204;'
);
if (isset($table[$matches[1]])) return $table[$matches[1]];
else return $destroy ? '' : $matches[0];
if (isset($table[$matches[1]]))
return $table[$matches[1]];
else
return $destroy
? ''
: $matches[0];
}
@ -510,12 +563,13 @@ if (!function_exists('stripTags'))
* @param mixed $filename
* @return string
*/
if (!function_exists('stripExt')){
if (! function_exists('stripExt'))
{
function stripExt($filename)
{
if (strpos($filename, ".") === false) {
if (strpos($filename, ".") === false)
return ucwords($filename);
} else
else
return substr(ucwords($filename), 0, strrpos($filename, "."));
}
}
@ -527,7 +581,8 @@ if (!function_exists('stripExt')){
* @param mixed $text
* @return string
*/
if (!function_exists('cleanOut')){
if (! function_exists('cleanOut'))
{
function cleanOut($text)
{
$text = strtr($text, array(
@ -549,7 +604,8 @@ if (!function_exists('cleanOut')){
* @param string $operator
* @return bool
*/
if (!function_exists('compareFloatNumbers')){
if (! function_exists('compareFloatNumbers'))
{
function compareFloatNumbers($float1, $float2, $operator='=')
{
// Check numbers to 5 digits of precision
@ -628,16 +684,19 @@ if (!function_exists('compareFloatNumbers')){
* @param bool $value
* @return bool
*/
if (!function_exists('searchforValue')){
if (!function_exists('searchforValue'))
{
function searchforValue($array, $key, $value)
{
if($array) {
foreach ($array as $val) {
if ($val->$key == $value) {
if($array)
{
foreach ($array as $val)
{
if ($val->$key == $value)
return true;
}
}
}
return false;
}
}
@ -651,18 +710,25 @@ if (!function_exists('searchforValue')){
* @param mixed $val2
* @return array|int
*/
if (!function_exists('findInArray')){
if (! function_exists('findInArray'))
{
function findInArray($array, $val1, $val2)
{
if($array) {
if ($array)
{
$result = array();
foreach ($array as $val) {
if ($val->$val1 == $val2) {
foreach ($array as $val)
{
if ($val->$val1 == $val2)
$result[] = $val;
}
return ($result)
? $result
: 0;
}
return ($result) ? $result : 0;
}
return 0;
}
}
@ -676,7 +742,8 @@ if (!function_exists('findInArray')){
* @param int $maxSpeed
* @return bool
*/
if (!function_exists('downloadFile')){
if (! function_exists('downloadFile'))
{
function downloadFile($fileLocation, $fileName, $maxSpeed = 5120)
{
if (connection_status() != 0)
@ -722,25 +789,29 @@ if (!function_exists('downloadFile')){
$contentType = $fileTypes[$extension];
header("Cache-Control: public");
header("Content-Transfer-Encoding: binary\n");
header('Content-Type: $contentType');
$contentDisposition = 'attachment';
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE"))
{
$fileName = preg_replace('/\./', '%2e', $fileName, substr_count($fileName, '.') - 1);
header("Content-Disposition: $contentDisposition;filename=\"$fileName\"");
} else {
}
else
{
header("Content-Disposition: $contentDisposition;filename=\"$fileName\"");
}
header("Accept-Ranges: bytes");
$range = 0;
$size = filesize($fileLocation);
if (isset($_SERVER['HTTP_RANGE'])) {
if (isset($_SERVER['HTTP_RANGE']))
{
list($a, $range) = explode("=", $_SERVER['HTTP_RANGE']);
str_replace($range, "-", $range);
$size2 = $size - 1;
@ -748,32 +819,35 @@ if (!function_exists('downloadFile')){
header("HTTP/1.1 206 Partial Content");
header("Content-Length: $new_length");
header("Content-Range: bytes $range$size2/$size");
} else {
}
else
{
$size2 = $size - 1;
header("Content-Range: bytes 0-$size2/$size");
header("Content-Length: " . $size);
}
if ($size == 0) {
if ($size == 0)
die('Zero byte file! Aborting download');
}
$fp = fopen("$fileLocation", "rb");
fseek($fp, $range);
while (!feof($fp) and (connection_status() == 0)) {
while (! feof($fp) and (connection_status() == 0))
{
set_time_limit(0);
print (fread($fp, 1024 * $maxSpeed));
flush();
ob_flush();
sleep(1);
}
fclose($fp);
exit;
return ((connection_status() == 0) and !connection_aborted());
//return ((connection_status() == 0) and !connection_aborted());
}
}
@ -783,11 +857,12 @@ if (!function_exists('downloadFile')){
* @param string $hexcolor Значение цвета в HEX. Example: #A9B7D3
* @return array|bool
*/
if (!function_exists('color_h2d')){
function color_h2d($hexcolor) {
if(mb_strlen($hexcolor) != 7 || mb_strpos($hexcolor, "#") === false) {
if (! function_exists('color_h2d'))
{
function color_h2d($hexcolor)
{
if(mb_strlen($hexcolor) != 7 || mb_strpos($hexcolor, "#") === false)
return false;
}
return array( "r" => hexdec(mb_substr($hexcolor, 1, 2)),
"g" => hexdec(mb_substr($hexcolor, 3, 2)),

6
functions/func.login.php

@ -89,7 +89,7 @@
last_visit = '" . $time . "',
password = '" . $hash . "',
salt = '" . $salt . "',
user_ip = '" . $u_ip . "'
user_ip = '" . (int)$u_ip . "'
WHERE
Id = '" . $row->Id . "'
");
@ -129,7 +129,7 @@
" . PREFIX . "_users_session
(`user_id`,`hash`,`ip`,`agent`,`last_activ`)
values
('" . $row->Id . "','" . addslashes($auth) . "','" . $u_ip . "','" . addslashes($_SERVER['HTTP_USER_AGENT']) . "','" . time() . "')
('" . $row->Id . "','" . addslashes($auth) . "','" . (int)$u_ip . "','" . addslashes($_SERVER['HTTP_USER_AGENT']) . "','" . time() . "')
";
$AVE_DB->Query($sql);
@ -293,7 +293,7 @@
" . PREFIX . "_users_session
SET
last_activ = '" . time() . "',
ip = '" . ip2long($_SERVER['REMOTE_ADDR']) . "'
ip = '" . (int)ip2long($_SERVER['REMOTE_ADDR']) . "'
WHERE
Id = '" . $row->Id . "'
");

6
functions/func.mail.php

@ -236,8 +236,10 @@ if ( ! function_exists('safe_mailto'))
foreach ($x as $val){ ?>l[<?php echo $i++; ?>]='<?php echo $val; ?>';<?php } ?>
for (var i = l.length-1; i >= 0; i=i-1){
if (l[i].substring(0, 1) == '|') document.write("&#"+unescape(l[i].substring(1))+";");
else document.write(unescape(l[i]));}
if
(l[i].substring(0, 1) == '|') document.write("&#"+unescape(l[i].substring(1))+";");
else
document.write(unescape(l[i]));}
//]]>
</script><?php

1
functions/func.modulglobals.php

@ -55,6 +55,7 @@ function set_module_globals($modulepath, $lang_section = false)
{
$AVE_Template->config_load($lang_file, $lang_section);
}
$config_vars = $AVE_Template->get_config_vars();
$AVE_Template->assign('tpl_dir', $tpl_dir);

2
functions/func.navigation.php

@ -75,7 +75,7 @@
if (! $navi_menu)
{
echo 'Menu ', $navi_id, ' not found!';
return;
return '';
}
// выставляем гостевую группу по дефолту

173
functions/func.parserequest.php

@ -11,6 +11,14 @@
* @license GPL v.2
*/
/**
* Достаем настройки запроса
*
* @param $id
*
* @return string
*/
function request_get_settings($id)
{
global $AVE_DB;
@ -41,7 +49,9 @@
* Возвращает строку условий в SQL-формате
*
* @param int $id идентификатор запроса
* @return string
* @param bool $update_db
*
* @return array
*/
function request_get_condition_sql_string($id, $update_db = false)
{
@ -122,7 +132,9 @@
")->GetCell();
}
$fv = $numeric[$fid] ? "t$fid.field_number_value" : "UPPER(t$fid.field_value)";
$fv = $numeric[$fid]
? "t$fid.field_number_value"
: "UPPER(t$fid.field_value)";
// подставляем название таблицы в свободные условия
$val = addcslashes(str_ireplace(array('[field]','[numeric_field]'),$fv,$val),"'");
@ -130,7 +142,7 @@
// формируем выбор таблицы
// первый раз евалом проходим значение и запоминаем это в переменной $v[$i]
// как только таблица выбрана, фиксируем это в $t[$fid], чтобы не выбирать по несколько раз одни и те же таблицы
$from[] = "<?php \$v[$i] = trim(eval2var(' ?>$val<? ')); \$t = array(); if (\$v[$i]>'' && !isset(\$t[$fid])) {echo \"%%PREFIX%%_document_fields AS t$fid,\"; \$t[$fid]=1;}?>";
$from[] = "<?php \$v[$i] = trim(eval2var(' ?>$val<?php ')); \$t = array(); if (\$v[$i]>'' && !isset(\$t[$fid])) {echo \"%%PREFIX%%_document_fields AS t$fid,\"; \$t[$fid]=1;} ?>";
// обрабатываем условия
switch ($type)
@ -161,8 +173,8 @@
case 'IN=': $where[] = "<?=(\$v[$i]>'' && \$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]>'' && \$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[] = "<?=\$v[$i]>'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv=ANY(\$v[$i]))) $join\" : ''?>"; break;
case 'FRE': $where[] = "<?=\$v[$i]>'' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND (\$v[$i]))) $join\" : ''?>"; break;
case 'ANY': $where[] = "<?php echo \$v[$i] > '' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND $fv=ANY(\$v[$i]))) $join\" : ''; ?>"; break;
case 'FRE': $where[] = "<?php echo \$v[$i] > '' ? \"(t$fid.document_id = a.id AND (t$fid.rubric_field_id = '$fid' AND (\$v[$i]))) $join\" : ''; ?>"; break;
}
$i++;
@ -177,13 +189,13 @@
$from = (isset($from_dd) ? array_merge($from, $from_dd) : $from);
$from = implode(' ', $from);
$where_dd = (isset($where_dd) ? ' AND ' : '') . implode(' AND ', $where_dd);
$where = implode(' ', $where) . " <?php \$a = array(); echo (!array_sum(\$a) || '$join'=='AND') ? '1=1' : '1=0'?>";
$where = implode(' ', $where) . " <?php \$a = array(); echo (!array_sum(\$a) || '$join'=='AND') ? '1=1' : '1=0'; ?>";
$retval = array('from' => $from, 'where' => $where . $where_dd);
}
else
{
$from = implode(' ', $from);
$where = implode(' ', $where) . " <?php \$a = array(); echo (!array_sum(\$a) || '$join'=='AND') ? '1=1' : '1=0'?>";
$where = implode(' ', $where) . " <?php \$a = array(); echo (!array_sum(\$a) || '$join'=='AND') ? '1=1' : '1=0'; ?>";
$retval = array('from' => $from, 'where' => $where);
}
}
@ -207,14 +219,19 @@
}
/*
/**
* Функция принимает строку, и возвращает
* адрес первого изображения, которую найдет
*
* @param $data
*
* @return string
*/
function getImgSrc($data)
{
preg_match_all("/(<img )(.+?)( \/)?(>)/u", $data, $images);
$_req_exp = '/(<img )(.+?)( \/)?(>)/u';
preg_match_all($_req_exp, $data, $images);
$host = $images[2][0];
@ -232,23 +249,22 @@
preg_match('/(.+)' . THUMBNAIL_DIR . '\/(.+)-.\d+x\d+(\..+)/u', $host, $matches);
if (isset($matches[1]))
{
return $matches[1] . $matches[2] . $matches[3];
}
else
{
return $host;
}
}
}
/**
* Функция обработки тэгов полей с использованием шаблонов
* в соответствии с типом поля
*
* @param int $rubric_id идентификатор рубрики
* @param $field_id
* @param int $document_id идентификатор документа
* @param int $maxlength максимальное количество символов обрабатываемого поля
* @param string $maxlength максимальное количество символов обрабатываемого поля
* @param int $rubric_id идентификатор рубрики
*
* @return string
*/
function request_get_document_field($field_id, $document_id, $maxlength = '', $rubric_id = 0)
@ -440,41 +456,36 @@
$item = preg_replace_callback('/\[tag:sysblock:([A-Za-z0-9-_]{1,20}+)\]/', 'parse_sysblock', $item);
// Парсим элементы полей
$item = preg_replace_callback(
'/\[tag:rfld:([a-zA-Z0-9-_]+)\]\[([0-9]+)]\[([0-9]+)]/',
create_function(
'$m',
'return get_field_element($m[1], $m[2], $m[3], ' . $row->Id . ');'
),
$item
);
$item = preg_replace_callback('/\[tag:rfld:([a-zA-Z0-9-_]+)\]\[([0-9]+)]\[([0-9]+)]/',
function ($m) use ($row)
{
return get_field_element($m[1], $m[2], $m[3], (int)$row->Id);
},
$item);
// Парсим теги полей
$item = preg_replace_callback(
'/\[tag:rfld:([a-zA-Z0-9-_]+)]\[(more|esc|img|strip|[0-9-]+)]/',
create_function(
'$m',
'return request_get_document_field($m[1], ' . $row->Id . ', $m[2], ' . (int)$row->rubric_id . ');'
),
$item
);
$item = preg_replace_callback('/\[tag:rfld:([a-zA-Z0-9-_]+)]\[(more|esc|img|strip|[0-9-]+)]/',
function ($m) use ($row)
{
return request_get_document_field($m[1], (int)$row->Id, $m[2], (int)$row->rubric_id);
},
$item);
// Повторно парсим теги полей
$item = preg_replace_callback(
'/\[tag:rfld:([a-zA-Z0-9-_]+)]\[(more|esc|img|strip|[0-9-]+)]/',
create_function(
'$m',
'return request_get_document_field($m[1], ' . $row->Id . ', $m[2], ' . (int)$row->rubric_id . ');'
),
$item
);
$item = preg_replace_callback('/\[tag:rfld:([a-zA-Z0-9-_]+)]\[(more|esc|img|strip|[0-9-]+)]/',
function ($m) use ($row)
{
return request_get_document_field($m[1], (int)$row->Id, $m[2], (int)$row->rubric_id);
},
$item);
// Возвращаем поле документа из БД (document_***)
$item = preg_replace_callback('/\[tag:doc:([a-zA-Z0-9-_]+)\]/u',
function ($match) use ($row)
function ($m) use ($row)
{
return isset($row->{$match[1]})
? $row->{$match[1]}
return isset($row->{$m[1]})
? $row->{$m[1]}
: null;
},
$item
@ -483,11 +494,11 @@
// Если пришел вызов на активацию языковых файлов
$item = preg_replace_callback(
'/\[tag:langfile:([a-zA-Z0-9-_]+)\]/u',
function ($match)
function ($m)
{
global $AVE_Template;
return $AVE_Template->get_config_vars($match[1]);
return $AVE_Template->get_config_vars($m[1]);
},
$item
);
@ -502,14 +513,12 @@
. '/', $item);
// Watermarks
$item = preg_replace_callback(
'/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/',
create_function(
'$m',
'watermarks($m[1], $m[2], $m[3]);'
),
$item
);
$item = preg_replace_callback('/\[tag:watermark:(.+?):([a-zA-Z]+):([0-9]+)\]/',
function ($m)
{
watermarks($m[1], $m[2], $m[3]);
},
$item);
// Удаляем ошибочные теги полей документа и языковые, в шаблоне рубрики
$item = preg_replace('/\[tag:doc:\d*\]/', '', $item);
@ -522,14 +531,12 @@
if ($tparams != '')
{
// Заменяем tparam в тизере
$item = preg_replace_callback(
'/\[tparam:([0-9]+)\]/',
create_function(
'$m',
'return f_params_of_teaser('.$tparams_id.', $m[1]);'
),
$item
);
$item = preg_replace_callback('/\[tparam:([0-9]+)\]/',
function ($m) use ($tparams_id)
{
return f_params_of_teaser($tparams_id, $m[1]);
},
$item);
}
else
{
@ -560,28 +567,25 @@
$item = str_replace('[tag:docdate]', pretty_date(strftime(DATE_FORMAT, $row->document_published)), $item);
$item = str_replace('[tag:doctime]', pretty_date(strftime(TIME_FORMAT, $row->document_published)), $item);
$item = str_replace('[tag:humandate]', human_date($row->document_published), $item);
$item = preg_replace_callback(
'/\[tag:date:([a-zA-Z0-9-. \/]+)\]/',
create_function('$m','return translate_date(date($m[1], '.$row->document_published.'));
'),
$item
);
if (preg_match('/\[tag:docauthor]/u', $item))
$item = preg_replace_callback('/\[tag:date:([a-zA-Z0-9-. \/]+)\]/',
function ($m) use ($row)
{
return translate_date(date($m[1], $row->document_published));
},
$item);
if (preg_match('/\[tag:docauthor]/u', $item))
$item = str_replace('[tag:docauthor]', get_username_by_id($row->document_author_id), $item);
}
$item = str_replace('[tag:docauthorid]', $row->document_author_id, $item);
$item = preg_replace_callback(
'/\[tag:docauthoravatar:(\d+)\]/',
create_function(
'$m',
'return getAvatar('.intval($row->document_author_id).', $m[1]);'
),
$item
);
$item = preg_replace_callback('/\[tag:docauthoravatar:(\d+)\]/',
function ($m) use ($row)
{
return getAvatar(intval($row->document_author_id), $m[1]);
},
$item);
if (isset($use_cache) && $use_cache == 1)
{
@ -611,6 +615,8 @@
* оформленный с использованием шаблона
*
* @param int $id идентификатор запроса
* @param array $params
*
* @return string
*/
function request_parse($id, $params = array())
@ -677,7 +683,7 @@
$sort = strtolower($sort);
// Добавляем условие в SQL
$request_join[$fid] = "<? if (preg_match('t[]'))?><?=(! isset(\$t[$fid])) ? \"LEFT JOIN " . PREFIX . "_document_fields AS t$fid ON (t$fid.document_id = a.Id AND t$fid.rubric_field_id='$fid')\" : ''?>";
$request_join[$fid] = "<?php if (preg_match('t[]'))?><?=(! isset(\$t[$fid])) ? \"LEFT JOIN " . PREFIX . "_document_fields AS t$fid ON (t$fid.document_id = a.Id AND t$fid.rubric_field_id='$fid')\" : ''?>";
// Если в сортировке указано ASC иначе DESC
$asc_desc = strpos(strtolower($sort),'asc') !== false
@ -695,6 +701,7 @@
? 'ASC'
: 'DESC';
// ToDo - ХЗ что это
$request_order[$param] = "$fid " . $asc_desc;
}
}
@ -705,7 +712,7 @@
$fid = (int)$request->request_order_by_nat;
// Добавляем с учётом переменной $t из условий, чтобы не выбирать те же таблиы заново - это оптимизирует время
$request_join[$fid] = "<?= (! isset(\$t[$fid])) ? \"LEFT JOIN " . PREFIX . "_document_fields AS t$fid ON (t$fid.document_id = a.Id AND t$fid.rubric_field_id='$fid')\" : ''?>";
$request_join[$fid] = "<?php echo (! isset(\$t[$fid])) ? \"LEFT JOIN " . PREFIX . "_document_fields AS t$fid ON (t$fid.document_id = a.Id AND t$fid.rubric_field_id='$fid')\" : ''?>";
$request_order['field-' . $fid] = "t$fid.field_value " . $request->request_asc_desc;
$request_order_fields[] = $fid;
@ -899,8 +906,6 @@
if (isset($params['RETURN_SQL']) && $params['RETURN_SQL'] == 1)
return $AVE_DB->GetFoundRows();
$num_items = 0;
// Если есть вывод пагинации, то выполняем запрос на получение кол-ва элементов
if ($request->request_show_pagination == 1 || (isset($params['SHOW']) && $params['SHOW'] == 1))
$num_items = $AVE_DB->NumAllRows($sql_request, (int)$request->request_cache_lifetime, 'rqs_' . $id);
@ -1043,8 +1048,6 @@
$request_changed = $request->request_changed;
$request_changed_elements = $request->request_changed_elements;
$item = '';
foreach ($rows as $row)
{
$x++;
@ -1053,7 +1056,7 @@
$req_item_num = $item_num;
$item = showrequestelement($row, $request->request_template_item);
$item = '<'.'?php $item_num='.var_export($item_num,1).'; $last_item='.var_export($last_item,1).'?'.'>'.$item;
$item = '<?php $req_item_id = ' . $row->Id . ';?>' . $item;
$item = '<'.'?php $req_item_id = ' . $row->Id . '; ?>' . $item;
$item = str_replace('[tag:if_first]', '<'.'?php if(isset($item_num) && $item_num===1) { ?'.'>', $item);
$item = str_replace('[tag:if_not_first]', '<'.'?php if(isset($item_num) && $item_num!==1) { ?'.'>', $item);
$item = str_replace('[tag:if_last]', '<'.'?php if(isset($last_item) && $last_item) { ?'.'>', $item);
@ -1124,7 +1127,7 @@
//-- Возвращаем параметр документа из БД
$main_template = preg_replace_callback('/\[tag:doc:([a-zA-Z0-9-_]+)\]/u',
function ($match)
function ($match) use ($row)
{
return isset($row->{$match[1]})
? $row->{$match[1]}

8
functions/func.sysblock.php

@ -15,17 +15,19 @@
* Обработка тега системного блока
*
* @param int $id идентификатор системного блока
*
* @return bool|mixed|null|string|string[]
*/
function parse_sysblock($id)
{
global $AVE_DB, $AVE_Core;
global $AVE_DB;
if (is_array($id))
$id = $id[1];
Debug::startTime('SYSBLOCK_' . $id);
$eval_sysblock = false;
// $eval_sysblock = false;
if ($id != '')
{
@ -101,5 +103,7 @@
return $return;
}
return false;
}
?>

6
functions/func.thumbnails.php

@ -24,6 +24,8 @@
| <li>size - размер миниатюры</li>
| </ul>
|
| make_thumbnail(array('link' => URL, 'size' => SIZE));
|
| @return string
*/
function make_thumbnail ($params)
@ -42,15 +44,13 @@
if (! is_dir(dirname($path)))
mkdir(dirname($path), 0777, true);
mkdir($path, 0777);
mkdir($path, 0777, true);
}
$link = ABS_PATH . UPLOAD_DIR . '/ext/' . substr($md5, 0, 4) . '/' . $md5 . '.jpg';
if (! file_exists(BASE_DIR . $link))
{
file_put_contents(BASE_DIR . $link . '.tmp', $params['link']);
}
$params['link'] = $link;
}

42
functions/func.users.php

@ -20,25 +20,28 @@
* @param string $prefix
* @return string путь до файла с превью
*/
function getAvatar($id = null, $size = 58, $prefix = "")
function getAvatar($id = null, $size = 58, $prefix = '')
{
global $AVE_DB;
static $result = array();
if ($id === null) $id = $_SESSION['user_id'];
if ($id === null)
$id = $_SESSION['user_id'];
if(!isset($result[$id])){
if (! isset($result[$id]))
{
$user = get_user_rec_by_id($id);
$ava = ABS_PATH. UPLOAD_DIR .'/avatars/'.(($prefix==="")?"":$prefix).md5($user->user_name);
$ava = ABS_PATH . UPLOAD_DIR . '/avatars/' . (($prefix === '') ? '' : $prefix) . md5($user->user_name);
$ava = (file_exists(BASE_DIR.$ava.'.jpg') ? $ava.'.jpg' : (file_exists(BASE_DIR . $ava . '.png') ? $ava . '.png' : (file_exists(BASE_DIR.$ava.'.gif') ? $ava.'.gif' : '')));
$result[$id] = $ava;
}
$ava = $result[$id];
$src = (file_exists(BASE_DIR.$ava) ?
make_thumbnail(array('link' => $ava,'size' => 'c' . $size . 'x' . $size)):
make_thumbnail(array('link' => $AVE_DB->Query("SELECT default_avatar FROM " . PREFIX . "_user_groups WHERE user_group=" . (int)$user->user_group)->GetCell(), 'size' => 'c' . $size . 'x' . $size))
$src = (file_exists(BASE_DIR . $ava)
? make_thumbnail(array('link' => $ava,'size' => 'c' . $size . 'x' . $size))
: make_thumbnail(array('link' => $AVE_DB->Query("SELECT default_avatar FROM " . PREFIX . "_user_groups WHERE user_group=" . (int)$user->user_group)->GetCell(), 'size' => 'c' . $size . 'x' . $size))
);
return $src;
@ -65,16 +68,12 @@ function SetAvatar($id, $avatar)
$new_ava = BASE_DIR . '/' . UPLOAD_DIR . '/avatars/' . md5($user->user_name) . '.' . strtolower($file_ext);
foreach (glob(BASE_DIR . '/' . UPLOAD_DIR . '/avatars/' . md5($user->user_name) . '.*') as $filename)
{
foreach (glob(BASE_DIR . '/' . UPLOAD_DIR . '/avatars/' . md5($user->user_name) . '.*') AS $filename)
@unlink($filename);
}
//Чистим превьюшки
foreach (glob(BASE_DIR . '/' . UPLOAD_DIR . '/avatars/' . THUMBNAIL_DIR . '/' . md5($user->user_name) . '*.*') as $filename)
{
foreach (glob(BASE_DIR . '/' . UPLOAD_DIR . '/avatars/' . THUMBNAIL_DIR . '/' . md5($user->user_name) . '*.*') AS $filename)
@unlink($filename);
}
@file_put_contents($new_ava, file_get_contents($avatar));
@unlink($avatar);
@ -103,9 +102,10 @@ function get_username($login = '', $first_name = '', $last_name = '', $short = 1
{
if ($first_name != '' && $last_name != '')
{
if ($short == 1) $first_name = mb_substr($first_name, 0, 1, 'utf-8') . '.';
if ($short == 1)
$first_name = mb_substr($first_name, 0, 1, 'utf-8') . '.';
return ucfirst_utf8(mb_strtolower($first_name)) . ' ' . ucfirst_utf8(mb_strtolower($last_name));
return ucfirst_utf8(mb_strtolower($login));
}
elseif ($first_name != '' && $last_name == '')
{
@ -131,7 +131,8 @@ function get_username($login = '', $first_name = '', $last_name = '', $short = 1
* @param int $id - идентификатор пользователя
* @return object
*/
function get_user_rec_by_id($id){
function get_user_rec_by_id($id)
{
global $AVE_DB;
static $users = array();
@ -159,7 +160,8 @@ function get_user_rec_by_id($id){
* @param int $id - идентификатор группы
* @return object
*/
function get_usergroup_rec_by_id($id){
function get_usergroup_rec_by_id($id)
{
global $AVE_DB;
static $usergroups = array();
@ -175,6 +177,7 @@ function get_usergroup_rec_by_id($id){
$usergroups[$id] = $row;
}
return $usergroups[$id];
}
@ -233,7 +236,10 @@ function get_useremail_by_id($id)
function get_username_by_id($id, $param = 1)
{
$row = get_user_rec_by_id($id);
$row = !empty($row) ? get_username($row->user_name, $row->firstname, $row->lastname, $param) : get_username();
$row = (! empty($row))
? get_username($row->user_name, $row->firstname, $row->lastname, $param)
: get_username();
return $row;
}

4
functions/func.watermarks.php

@ -56,8 +56,6 @@
*/
function watermarks ($file, $position='center', $transparency=100)
{
global $AVE_DB;
if (! defined('WATERMARKS_DIR') || ! defined('WATERMARKS_FILE'))
return $file;
@ -187,7 +185,7 @@
if ($watermark->_img['main']['type'] == 2)
{
$image = getimagesize("$imagePath/$imageName", $info);
// $image = getimagesize("$imagePath/$imageName", $info); Not used
if (! isset($info['APP13']))
{

10
inc/init.php

@ -67,12 +67,12 @@
{
@reset($array);
while (list($key, $val) = @each($array))
foreach ($array AS $_k => $_v)
{
if (is_string($val))
$array[$key] = addslashes($val);
elseif (is_array($val))
$array[$key] = add_slashes($val);
if (is_string($_v))
$array[$_k] = addslashes($_v);
elseif (is_array($_v))
$array[$_k] = add_slashes($_v);
}
return $array;

1
install/data_base.sql

@ -310,6 +310,7 @@ INSERT INTO `%%PRFX%%_settings` VALUES
'%d %B %Y, %H:%M',
'RU',
'0',
'0',
'<div class=\"hidden_box\">\n Содержимое скрыто.\n</div>'
);#inst#

Loading…
Cancel
Save