Файл: Arhmobi_esdcms/theme/theme.add.php
Строк: 20
<?php
include_once '../sys/inc/start.php';
$doc = new document(4);
$doc->title = __('Создание темы дня');
$doc->ret(__('К темам'), './');
$theme = & $_SESSION['theme_create'];
if (isset($_POST['clear'])) $theme = array();
if (empty($theme)) {
    $theme = array();
    $theme['title'] = '';
    $theme['text'] = '';
    $theme['checked'] = false;
}
if ($theme['checked'] && isset($_POST['send'])) {
    if (empty($_POST['captcha']) || empty($_POST['captcha_session']) || !captcha::check($_POST['captcha'], $_POST['captcha_session']))
        $doc->err(__('Ошибка при вводе чисел с картинки'));
    else {
        $res = $db->prepare("INSERT INTO `theme` (`title`, `time`, `text`, `id_user`) VALUES (?,?,?,?)");
        $res->execute(Array($theme['title'], TIME, $theme['text'], $user->id));
        $doc->msg(__('Тема дня успешно опубликована'));
        $theme = array();
        header('Refresh: 1; ./');
        exit;
    }
}
if (isset($_POST['edit'])) $theme['checked'] = 0;
if (isset($_POST['next'])) {
    $title = text::for_name($_POST['title']);
    $text = text::input_text($_POST['text']);
    if (!$title) $doc->err(__('Заполните "Заголовок темы"'));
    else $theme['title'] = $title;
    if (!$text) $doc->err(__('Заполните "Текст темы"'));
    else $theme['text'] = $text;
    if ($title && $text) $theme['checked'] = 1;
}
$form = new form('?' . passgen());
$form->text('title', __('Заголовок Темы дня'), $theme['title'], true, false, $theme['checked']);
$form->textarea('text', __('Текст темы'), $theme['text'], true, $theme['checked']);
if ($theme['checked']) {
    $form->captcha();
    $form->button(__('Редактировать'), 'edit', false);
    $form->button(__('Опубликовать'), 'send', false);
} else {
    $form->button(__('Очистить'), 'clear', false);
    $form->button(__('Далее'), 'next', false);
}
$form->display();