fix for Smarty 5
This commit is contained in:
@@ -204,19 +204,20 @@
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Метод убирает слэши во всей переменной
|
||||
*
|
||||
* @param $var
|
||||
* @param mixed $var
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
function _stripslashes($var)
|
||||
{
|
||||
if (! is_array($var))
|
||||
return stripslashes($var);
|
||||
else
|
||||
if (is_array($var))
|
||||
return array_map(array($this, '_stripslashes'), $var);
|
||||
else
|
||||
// ИСПРАВЛЕНИЕ: Гарантируем, что $var является строкой, используя ?? ''
|
||||
return stripslashes($var ?? '');
|
||||
}
|
||||
|
||||
|
||||
@@ -504,6 +505,10 @@ function _cleanvar($var)
|
||||
{
|
||||
$field_id = (int)$matches[1];
|
||||
|
||||
if (!isset($this->form['fields'][$field_id])) {
|
||||
return $matches[0];
|
||||
}
|
||||
|
||||
// забираем массив поля
|
||||
$field = $this->form['fields'][$field_id];
|
||||
|
||||
@@ -760,8 +765,14 @@ function _cleanvar($var)
|
||||
}
|
||||
break;
|
||||
|
||||
case 'file':
|
||||
$newval = implode(', ',$_FILES['form-' . $alias_id]['name']);
|
||||
case 'file':
|
||||
// 1. Безопасно получаем массив имен файлов, используя оператор объединения с null (??).
|
||||
// Если $_FILES['form-bag-report'] отсутствует или не содержит ['name'],
|
||||
// $file_names будет пустым массивом [].
|
||||
$file_names = $_FILES['form-' . $alias_id]['name'] ?? [];
|
||||
|
||||
// 2. implode() теперь безопасно работает с $file_names (массив или []).
|
||||
$newval = implode(', ', $file_names);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1046,17 +1057,17 @@ function _cleanvar($var)
|
||||
attributes = '" . addslashes(trim($field['attributes'] ?? '')) . "',
|
||||
tpl = '" . addslashes($field['tpl'] ?? '') . "'
|
||||
";
|
||||
// 🛑 ИСПРАВЛЕНИЕ PHP 8.4: Проверка существования ключа 'new'
|
||||
// ИСПРАВЛЕНИЕ PHP 8.4: Проверка существования ключа 'new'
|
||||
if (isset($field['new']) && $field['new'])
|
||||
{
|
||||
$AVE_DB->Query("
|
||||
INSERT INTO " . PREFIX . "_module_forms_fields
|
||||
SET
|
||||
form_id = '" . (int)$fid . "',
|
||||
main = '" . (int)$field['main'] . "',
|
||||
main = '" . (int)($field['main'] ?? 0) . "',
|
||||
" . $sql . "
|
||||
");
|
||||
if ($_REQUEST['demo']) $_REQUEST['demo_change'][$field_id] = (int)$AVE_DB->InsertId();
|
||||
if ($_REQUEST['demo'] ?? false) $_REQUEST['demo_change'][$field_id] = (int)$AVE_DB->InsertId();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1071,7 +1082,7 @@ function _cleanvar($var)
|
||||
}
|
||||
}
|
||||
|
||||
// 🛑 ИСПРАВЛЕНИЕ PHP 8.4: Безопасная итерация по удаляемым полям
|
||||
// ИСПРАВЛЕНИЕ PHP 8.4: Безопасная итерация по удаляемым полям
|
||||
foreach ($_REQUEST['field_del'] ?? [] as $field_id => $delete)
|
||||
{
|
||||
if (empty($delete)) continue;
|
||||
@@ -1170,12 +1181,15 @@ function _cleanvar($var)
|
||||
// rubheader
|
||||
$GLOBALS['user_header']['module_forms_' . $alias_id] = $this->_parse_tags($this->form['rubheader']);
|
||||
|
||||
// вывод финишной страницы, если включена проверка от повторной отправки
|
||||
// вывод финишной страницы, если включена проверка от повторной отправки
|
||||
if (! empty($_GET['mcnfinish']) && $form['protection'])
|
||||
{
|
||||
if ($_SESSION['mcnfinish'][$form['id'] . $_GET['mcnfinish']] === true)
|
||||
$session_key = $form['id'] . $_GET['mcnfinish']; // Определяем ключ заранее
|
||||
|
||||
// ИСПРАВЛЕНО: Используем isset() для проверки существования ключа сессии
|
||||
if (isset($_SESSION['mcnfinish'][$session_key]) && $_SESSION['mcnfinish'][$session_key] === true)
|
||||
{
|
||||
unset($_SESSION['mcnfinish'][$form['id'] . $_GET['mcnfinish']]);
|
||||
unset($_SESSION['mcnfinish'][$session_key]);
|
||||
|
||||
// формируем финишную страницу
|
||||
$tpl = $this->_parse_tags($form['finish_tpl']);
|
||||
@@ -1457,7 +1471,7 @@ function _cleanvar($var)
|
||||
|
||||
$subject = $subject_tpl;
|
||||
|
||||
$if_user_open = ($rec['agent'] === 'user');
|
||||
$if_user_open = (($rec['agent'] ?? '') === 'user'); // ИСПРАВЛЕНО: Безопасный доступ к 'agent'
|
||||
$if_admin_open = !$if_user_open;
|
||||
|
||||
$this->_parse_tag_if($mail,'if_user',$if_user_open);
|
||||
@@ -1473,7 +1487,7 @@ function _cleanvar($var)
|
||||
$subject = trim($this->_eval2var(' ?>' . $subject . '<?' . 'php '));
|
||||
|
||||
// сохраняем в бд историю (письмо, которое пришло админу)
|
||||
if ($rec['agent'] === 'history')
|
||||
if (($rec['agent'] ?? '') === 'history') // ИСПРАВЛЕНО: Безопасный доступ к 'agent'
|
||||
{
|
||||
$history['dialog']['request']['body'] = $mail;
|
||||
$history['dialog']['request']['format'] = $form['mail_set']['format'];
|
||||
|
||||
@@ -219,8 +219,22 @@
|
||||
<div class="col-half">
|
||||
<h6 ><span style="padding-right: 20px;">{#attributes#}</span> <img style="margin-top: -2px; position: relative; top: 0pt; padding: 0 3px;" class="clippy" src="{$ABS_PATH}admin/templates/images/uploader/error.png" width="10"> <span style="padding-right: 5px;">{#info_attr_name#}</span>
|
||||
<div class="pr12" style="display: inline">
|
||||
<input type="text" id="field_name_{$form.id}" value='name="form-{if $form.alias}{$form.alias}{else}{$form.id}{/if}[{$field.id}]"' style="width:120px; display: table-cell" readonly class="mousetrap" />
|
||||
<a style="display: table-cell; text-align: center" class="whiteBtn copyBtn topDir" href="javascript:void(0);" data-clipboard-action="copy" data-clipboard-target="#field_name_{$form.id}" title="{#cn_copy_to_clipboard#}">
|
||||
<input
|
||||
type="text"
|
||||
id="field_name_{$form.id|default:''}"
|
||||
value='name="form-{if $form.alias|default:false}{$form.alias}{else}{$form.id|default:''}{/if}[{$field.id|default:''}]"'
|
||||
style="width:120px; display: table-cell"
|
||||
readonly
|
||||
class="mousetrap"
|
||||
/>
|
||||
<a
|
||||
style="display: table-cell; text-align: center"
|
||||
class="whiteBtn copyBtn topDir"
|
||||
href="javascript:void(0);"
|
||||
data-clipboard-action="copy"
|
||||
data-clipboard-target="#field_name_{$form.id|default:''}"
|
||||
title="{#cn_copy_to_clipboard#}"
|
||||
>
|
||||
<img style="margin-top: -3px; position: relative; top: 4px; padding: 0 3px;" class="clippy" src="{$ABS_PATH}admin/templates/images/clippy.svg" width="13"></a>
|
||||
</div>
|
||||
</h6>
|
||||
|
||||
@@ -32,7 +32,7 @@ $smarty['action_error_title'] = '{#action_error_title#}';
|
||||
<li><a href="index.php?do=modules&cp={$sess}">{#MODULES_SUB_TITLE#}</a></li>
|
||||
<li><a href="index.php?do=modules&action=modedit&mod=forms&moduleaction=1&cp={$sess}">{#contacts#}</a></li>
|
||||
<li><a href="index.php?do=modules&action=modedit&mod=forms&moduleaction=1&cp={$sess}">{#forms#}</a></li>
|
||||
<li><strong class="code"><a href="index.php?do=modules&action=modedit&mod=forms&moduleaction=form_edit&fid={$fid}&cp={$sess}" {if $ave14}style="float:none; display:inline;"{/if}>{$form.title|escape}</a></strong></li>
|
||||
<li><strong class="code"><a href="index.php?do=modules&action=modedit&mod=forms&moduleaction=form_edit&fid={$fid}&cp={$sess}" {if $ave14}style="float:none; display:inline;"{/if}>{$form.title|default:''|escape}</a></strong></li>
|
||||
<li>{#history#}</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user