Exemple #1
0
     $attachedfiles->addNewSession($asid);
 } else {
     $attachedfiles = new attachedfiles($_POST['attachedfiles_session']);
     $asid = $_POST['attachedfiles_session'];
 }
 $attachedfiles_info = $attachedfiles->calcFiles();
 if ($msg === '' && $question === '' && empty($alert[5]) && !$countfiles && $yt_link === '' && !$attachedfiles_info['count']) {
     $error_flag = 1;
     $alert[2] = 'Поле заполнено некорректно';
 }
 if (($msg !== '' || $attach['name'][0] || $question !== '' || $yt_link != '' || $attachedfiles_info['count']) && get_uid() && !$error_flag) {
     list($alert1, $error_flag, $error, $msg_id, $th_id, $id_gr) = $blog_obj->NewThread(get_uid(), $gr, $base, (string) $name, (string) $msg, $files, getRemoteIP(), $mod, 0, NULL, $yt_link, $close_comments, $is_private, $ontop, $question, $answers, $multiple);
     if (!($alert1 || $error || $error_flag)) {
         //$nStopWordsCnt = $stop_words->calculate( $msg, $name, $question, $answers );
         $attachedfiles_files = $attachedfiles->getFiles(array(1, 3, 4));
         $blog_obj->addAttachedFiles($attachedfiles_files, $msg_id, NULL, $draft_id ? true : false);
         $attachedfiles->clear();
         //$blog_obj->insertIntoModeration( $msg_id, $nStopWordsCnt ); // больше не модерируем
     }
     if ($draft_id && !($alert1 || $error || $error_flag)) {
         require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/drafts.php';
         drafts::DeleteDraft($draft_id, get_uid(false), 3);
     }
 }
 if ($alert1) {
     $alert = $alert + $alert1;
 }
 if ($site == 'journal') {
     unset($_SESSION['user.journal.new_tr.result']);
     $question = str_replace(array('"', "'", '\\', '<', '>'), array('&quot;', '&#039;', '&#92;', '&lt;', '&gt;'), stripslashes($_POST['question']));
     $answers = array();
/**
 * Сохранение Блоги: посты и комментарии
 * 
 * @param object $objResponse xajaxResponse
 * @param string $rec_id идентификатор записи
 * @param string $rec_type тип записи
 * @param array $aForm массив данных
 * @param string $sDrawFunc имя функции для выполнения после сохранения
 */
function _admEditBlogsSaveForm(&$objResponse, $rec_id = '', $rec_type = '', $aForm = array(), $sDrawFunc = '')
{
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/user_content.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/blogs.php';
    $mod = hasPermissions('blogs') ? 0 : 1;
    $alert = array();
    $olduserlogin = $aForm['olduserlogin'];
    // логин автора блога
    $close_comments = $aForm['close_comments'] ? 't' : 'f';
    // запретить комментирование
    $is_private = $aForm['is_private'] ? 't' : 'f';
    // показывать только мне
    $ontop = $aForm['ontop'] ? 't' : 'f';
    // закрепить тему наверху
    $categ = change_q_x($aForm['category'], true);
    // раздел
    $close_comments = $rec_type == 2 ? 'n' : $close_comments;
    $is_private = $rec_type == 2 ? 'n' : $is_private;
    list($gr, $t) = explode('|', $categ);
    // название, текст
    if (strlen($aForm['msg']) > blogs::MAX_DESC_CHARS) {
        $error_flag = 1;
        $alert[1] = 'Максимальный размер сообщения ' . blogs::MAX_DESC_CHARS . ' символов!';
    }
    $msg = change_q_x(antispam($aForm['msg']), false, false, 'b|br|i|p|ul|li|cut|s|h[1-6]{1}', false, false);
    $name = substr_entity(change_q_x(antispam($aForm['name']), true, false), 0, 96, true);
    // ссылка на youtube
    $yt_link = $aForm['yt_link'] ? $aForm['yt_link'] : '';
    if ($yt_link != '') {
        $v_yt_link = video_validate($yt_link);
        if (!$v_yt_link) {
            $alert[4] = 'Неверная ссылка.';
        } else {
            $yt_link = $v_yt_link;
        }
    }
    // опросы
    $question = substr_entity(change_q_x(antispam(trim((string) $aForm['question'])), false, false, ''), 0, blogs::MAX_POLL_CHARS, true);
    $multiple = (bool) $aForm['multiple'];
    $answers = array();
    $answers_exists = array();
    $i = 0;
    if (is_array($aForm['answers']) && !empty($aForm['answers'])) {
        foreach ($aForm['answers'] as $pa) {
            if (trim((string) $pa) !== '') {
                $answers[] = substr_entity(change_q_x(antispam(preg_replace('/&/', '&amp;', (string) trim($pa))), false, false, ''), 0, blogs::MAX_POLL_ANSWER_CHARS * 2, true);
                $i++;
            }
        }
    }
    if (is_array($aForm['answers_exists']) && !empty($aForm['answers_exists'])) {
        foreach ($aForm['answers_exists'] as $key => $pa) {
            if (trim((string) $pa) !== '') {
                $answers_exists[$key] = substr_entity(change_q_x(antispam(preg_replace('/&/', '&amp;', (string) trim($pa))), false, false, ''), 0, blogs::MAX_POLL_ANSWER_CHARS * 2, true);
                $i++;
            }
        }
    }
    if ($i > 0 && $question === '') {
        $alert[5] = 'Введите текст вопроса';
    } else {
        if ($i > blogs::MAX_POLL_ANSWERS) {
            $alert[5] = 'Вы можете указать максимум ' . blogs::MAX_POLL_ANSWERS . ' отетов';
        } else {
            if ($i < 2 && $question !== '') {
                $alert[5] = 'Нужно указать минимум 2 варианта ответа в голосовании';
            }
        }
    }
    // файлы
    $files_session = $aForm['attachedfiles_session'];
    if (!$files_session) {
        $attachedfiles = new attachedfiles('', true);
        $asid = $attachedfiles->createSessionID();
        $attachedfiles->addNewSession($asid);
        $files_session = $asid;
    } else {
        $attachedfiles = new attachedfiles($files_session);
        $asid = $files_session;
    }
    $files_info = $attachedfiles->calcFiles();
    if ($msg === '' && $question === '' && empty($alert[5]) && !$files_info['count'] && $yt_link === '') {
        $alert[1] = 'Сообщение не должно быть пустым';
    }
    if (!$alert) {
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/messages.php';
        $blogs = new blogs();
        $blogs->Edit($_SESSION['uid'], $rec_id, $msg, $name, array(), getRemoteIP(), $err, $mod, '', $gr, $t, array(), $olduserlogin, $yt_link, $close_comments, $is_private, $ontop, null, $question, $answers, $answers_exists, $multiple);
        $files = $attachedfiles->getFiles(array(1, 3, 4));
        $blogs->addAttachedFiles($files, $rec_id, $olduserlogin, false);
        $attachedfiles->clear();
        $sReason = _parseReason($aForm['user_id'], $aForm['adm_edit_text']);
        messages::blogModifiedNotification($rec_type, $aForm['oldusertitle'], $aForm['post_time'], $aForm['user_name'], $aForm['user_surname'], $olduserlogin, $sReason);
        $content_id = user_content::MODER_BLOGS;
        _admEditAfterAll($objResponse, $content_id, $rec_id, $rec_type, $sDrawFunc, $aForm);
    } else {
        _setErrors($objResponse, $alert, array(1 => 'msg', 4 => 'yt_link', 5 => 'question'), $sDrawFunc);
    }
}
Exemple #3
0
 } elseif (!$error && !$error_flag && ($msg !== '' || $attach['name'] || $attach_have || $attach_delete || $question || $yt_link || $attachedfiles_info['count'])) {
     $blogs = new blogs();
     if (hasPermissions('blogs')) {
         $ontop = isset($_POST['ontop']) && $_POST['ontop'] == 't' ? 't' : 'f';
     } else {
         $ontop = null;
     }
     if ($_POST['not_is_private']) {
         $is_private = 'n';
     }
     if ($_POST['not_close_comments']) {
         $close_comments = 'n';
     }
     $blogs->Edit($_SESSION['uid'], $reply, $msg, $msg_name, $files, getRemoteIP(), $err, $mod, '', $gr, $t, $attach_delete, $olduserlogin, $yt_link, $close_comments, $is_private, $ontop, null, $question, $answers, $answers_exists, $multiple);
     $attachedfiles_files = $attachedfiles->getFiles(array(1, 3, 4));
     $blogs->addAttachedFiles($attachedfiles_files, $reply, $olduserlogin, $draft_id ? true : false);
     $attachedfiles->clear();
     //$nStopWordsCnt = $stop_words->calculate( $msg, $msg_name, $question, $answers, $answers_exists );
     //$blogs->insertIntoModeration( $reply, $nStopWordsCnt, (!$categ ? 1 : 0) ); // больше не модерируем
     if (is_array($err) && !isNulArray($err)) {
         $error_flag = 1;
         $alert[3] = $err[3];
         $action = "edit";
         $edit_id = $reply;
     } else {
         $last_id = $reply;
         if ($draft_id) {
             require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/drafts.php";
             drafts::DeleteDraft($draft_id, get_uid(false), 3);
         }
         header("Location: " . getFriendlyURL("blog", $thread) . "?pagefrom=" . intval($_POST['pagefrom']) . '&openlevel=' . $reply . "&ord=" . $_GET["ord"]);