diff --git a/forms/class/forms.php b/forms/class/forms.php index e2dfa1a..4123e37 100644 --- a/forms/class/forms.php +++ b/forms/class/forms.php @@ -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']; diff --git a/forms/templates/form_fields.tpl b/forms/templates/form_fields.tpl index 3a4cfe6..570f092 100644 --- a/forms/templates/form_fields.tpl +++ b/forms/templates/form_fields.tpl @@ -219,8 +219,22 @@