Example #1
0
/**
 * Заменяет теги видое в тексте WYSYWIG редактора на временные макросы
 * и копирует их в $video
 * @param  $text   исходный текст
 * @param  &$video - массив в который будут копироваться оригинальные теги видео
 * @param  $forReformat - если true то вместо img будет видеоплеер
 * @return string $text
 * */
function wysiwyg_video_replace($text, &$video, $forReformat = false)
{
    $patt = "#<img[^>]*class=[^>]+wysiwyg_video[^>]+>#si";
    $find = preg_match_all($patt, $text, $videos);
    $text = preg_replace($patt, "WYSIWYG_VIDEO", $text);
    $video = array();
    if ($find) {
        $videos = $videos[0];
        $pattURL = "#(?:video_url=[\\\\]?\")(.*?)(?:[\\\\]?\")#si";
        foreach ($videos as $key => $vid) {
            preg_match($pattURL, $vid, $videoURLs);
            $videoURL = $videoURLs[1];
            if (!$forReformat) {
                if (video_validate($videoURL)) {
                    $video[] = '<img class="wysiwyg_video" src="/images/video.png" video_url="' . $videoURL . '">';
                } else {
                    $video[] = '';
                }
            } else {
                $video[] = show_video('wysiwyg_video' . $key, $videoURL);
            }
        }
    }
    return $text;
}
/**
 * Сохранение работы в портфолио
 * 
 * @param object $objResponse xajaxResponse
 * @param string $rec_id идентификатор записи
 * @param string $rec_type тип записи
 * @param array $aForm массив данных
 * @param string $sDrawFunc имя функции для выполнения после сохранения
 */
function _admEditPortfolioSaveForm(&$objResponse, $rec_id = '', $rec_type = '', $aForm = array(), $sDrawFunc = '')
{
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/user_content.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/portfolio.php';
    require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/users.php';
    $max_time_value = 100;
    //стоимость работы из портфолио
    $max_portf_cost[0] = 100000;
    // usd
    $max_portf_cost[1] = 100000;
    // euro
    $max_portf_cost[2] = 5000000;
    // rur
    $max_portf_cost[3] = 100000;
    // fm
    $user = new users();
    $user->GetUserByUID($aForm['user_id']);
    // инициализация
    $aPortf = portfolio::GetPortfById($rec_id);
    $alert = array();
    $maxlen = $aForm['is_video'] ? 80 : 120;
    $name = substr($aForm['pname'], 0, $maxlen);
    $name = change_q_x($name, false, true, '', false, false);
    $name = $name ? $name : '';
    $descr = substr(change_q_new(trim(stripslashes($aForm['descr']))), 0, 1500);
    $prof = intval($aForm['prof']);
    $new_prof = intval($aForm['new_prof']);
    $prj_id = $rec_id;
    $cost = intval(str_replace(' ', '', $aForm['pcost']) * 100) / 100;
    $cost_type = intval($aForm['pcosttype']);
    $time_value = intval(trim($aForm['ptime']));
    $time_type = intval($aForm['ptimeei']);
    $is_video = $aForm['is_video'] ? 't' : 'f';
    $video_link = $aForm['is_video'] ? stripslashes(trim($aForm['v_video_link'])) : '';
    $link = $aForm['is_video'] ? '' : addhttp(trim(substr(change_q_x($aForm['link'], true), 0, 150)));
    $link = $link ? $link : '';
    $make_position = $aForm['make_position'];
    $make_position_num = trim($aForm['make_position_num']);
    $update_prev = intval($aForm['upd_prev']);
    $prev_type = intval($aForm['prev_type']);
    $del_prev = intval($aForm['del_prev']);
    $new_position = NULL;
    $pict = substr(change_q_new(trim(stripslashes($aForm['pict']))), 0, 1500);
    $prev_pict = substr(change_q_new(trim(stripslashes($aForm['prev_pict']))), 0, 1500);
    if ($new_prof != $prof) {
        $new_position = 0;
    }
    if (isset($make_position)) {
        switch ($make_position) {
            case 'first':
                $new_position = 1;
                break;
            case 'last':
                $new_position = 0;
                break;
            case 'num':
            default:
                $new_position = intval($make_position_num);
                $new_position = $new_position <= 0 ? 1 : $new_position;
                break;
        }
    }
    // валидация (нумерация алертов как в первоначальном варианте радактирования и новый нулевой)
    if (!$name || strlen(trim(stripslashes($aForm['pname']))) > 80) {
        $alert[1] = 'Поле заполнено некорректно';
    }
    if ($link != '' && !url_validate($link, true)) {
        $alert[6] = 'Поле заполнено некорректно';
    }
    if ($is_video == 't') {
        $v_video_link = video_validate($video_link);
        if (!$v_video_link) {
            $alert[206] = "Поле заполнено некорректно";
        } else {
            $video_link = preg_replace("/^http:\\/\\//", '', $v_video_link);
        }
    }
    if ($cost < 0 || $cost > $max_portf_cost[$cost_type]) {
        $alert[4] = 'Стоимость должна быть в пределе от 0 ' . view_range_cost2(0, $max_portf_cost[$cost_type], '', '', false, $cost_type) . ($cost_type != 2 ? '.' : '');
    }
    if ($time_value < 0 || $time_value > $max_time_value) {
        $alert[5] = 'Временные затраты должны быть в пределе от 0 до ' . $max_time_value . '.';
    }
    if ($new_prof != $prof && ($new_prof == professions::CLIENTS_PROF_ID || $new_prof == professions::BEST_PROF_ID) && portfolio::CountAll($aForm['user_id'], $new_prof, true) >= portfolio::MAX_BEST_WORKS) {
        $alert[0] = 'Превышено количество работ в этом разделе';
    }
    // сохраняем
    if (!$alert) {
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/messages.php';
        $sReason = _parseReason($aForm['user_id'], $aForm['adm_edit_text']);
        $portf = new portfolio();
        $portf->EditPortf($aForm['user_id'], $name, $img, $sm_img, $link, $descr, $new_prof, $cost, $cost_type, $time_type, $time_value, $prev_type, $prj_id, $file_error, $preview_error, $new_position, 0, $video_link, $update_prev, $_SESSION['uid'], $pict, $prev_pict, $user->login, $sReason);
        if ($del_prev) {
            $portf->DelPict($user->login, $prj_id, 0);
        }
        messages::portfolioModifiedNotification($aPortf, $user, $sReason);
        $content_id = user_content::MODER_PORTFOLIO;
        _admEditAfterAll($objResponse, $content_id, $rec_id, $rec_type, $sDrawFunc, $aForm);
    } else {
        _setErrors($objResponse, $alert, array(0 => 'prof', 1 => 'pname', 2 => 'descr', 4 => 'pcost', 5 => 'ptime', 6 => 'link', 206 => 'video_link'), $sDrawFunc);
    }
}
Example #3
0
                 $variantExists = 1;
                 break;
             }
         }
         if ($variantExists) {
             $msg = change_q_x(antispam($_POST['msg']), false, false);
         } else {
             $msg = change_q_x(antispam($_POST['msg']), false, false, 'b|br|i|p|ul|li|cut|s|h[1-6]{1}', false, false);
         }
     } else {
         $msg = change_q_x(antispam($_POST['msg']), false, false, 'b|br|i|p|ul|li|cut|s|h[1-6]{1}', false, false);
     }
 }
 $yt_link = $_POST['yt_link'];
 if ($yt_link != '') {
     $v_yt_link = video_validate($yt_link);
     if (!$v_yt_link) {
         $error_flag = 1;
         $alert[4] = 'Неверная ссылка.';
     } else {
         $yt_link = $v_yt_link;
     }
 }
 // опросы
 $question = substr_entity(change_q_x(antispam(preg_replace('/&/', '&amp;', trim((string) $_POST['question']))), false, false, ''), 0, blogs::MAX_POLL_CHARS, true);
 $answers = array();
 $answers_exists = array();
 $multiple = (bool) $_POST['multiple'];
 if (is_array($_POST['answers']) && !empty($_POST['answers'])) {
     $i = 0;
     foreach ($_POST['answers'] as $pa) {
Example #4
0
     }
     $alert[$enum] = "Поле заполнено некорректно";
 }
 //if (!($link || $prj_pict || $descr)) { $error_flag = 1; $alert[2] = "Поле заполнено некорректно"; }
 //if (($link != '') && (!eregi("^((http|https|ftp)://){0,1}((([a-zа-я0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6}))|(([0-9]{1,3}\.){3}([0-9]{1,3})))((/|\?)[a-z0-9~#%&'_\+=:\?\.-]*)*)$", $link)))
 //{
 //  $error_flag = 1;
 //  $alert[6] = 'Поле заполнено некорректно. Неверный формат ссылки.';
 //}
 //$link = preg_replace("/^http:\/\//","",$link);
 if ($link != '' && !url_validate($link, true)) {
     $error_flag = 1;
     $alert[6] = "Поле заполнено некорректно";
 }
 if ($is_video == 't') {
     $v_video_link = video_validate($video_link);
     if (!$v_video_link) {
         $error_flag = 1;
         $alert[206] = "Поле заполнено некорректно";
     } else {
         $video_link = preg_replace("/^http:\\/\\//", "", $v_video_link);
     }
 }
 if ($cost < 0 || $cost > $max_portf_cost[$cost_type]) {
     $error_flag = 1;
     if ($is_video == 'f') {
         $enum = 4;
     } else {
         $enum = 204;
     }
     $alert[$enum] = 'Поле заполнено некорректно. Стоимость должна быть в пределе от 0 ' . view_range_cost2(0, $max_portf_cost[$cost_type], '', '', false, $cost_type) . ($cost_type != 2 ? '.' : '');
Example #5
0
 /**
  * Заполняет массив $this->post_msg данными из пользовательского запроса.
  * @see sbr_stages::addMsg()
  * @see sbr_stages::editMsg()
  * 
  * @param array $request   $_GET | $_POST
  * @param array $files   $_FILES
  */
 private function _new_msgInitFromRequest($request, $files)
 {
     foreach ($request as $field => $value) {
         if ($field == 'id') {
             continue;
         }
         if (is_scalar($value)) {
             $value = stripslashes($value);
         }
         switch ($field) {
             case 'msgtext':
                 if (!trim($value)) {
                     $this->error['msgs'][$field] = 'Сообщение не должно быть пустым';
                 }
                 break;
             case 'msg_id':
                 $this->post_msg['id'] = $value;
                 break;
             case 'parent_id':
                 $value = intvalPgSql($value);
                 break;
             case 'delattach':
                 $value = intarrPgSql($value);
                 break;
             case 'yt_link':
                 if (trim($value)) {
                     if (!($val = video_validate($value))) {
                         $this->error['msgs'][$field] = 'Неверная ссылка';
                     } else {
                         $value = $val;
                     }
                 }
                 break;
             default:
                 break;
         }
         $this->post_msg[$field] = $value;
     }
     $this->post_msg['stage_id'] = $this->data['id'];
     if ($files) {
         foreach ($files as $i => $attach) {
             $file = new CFile($attach['id']);
             $file->table = 'file_sbr';
             if ($file->_remoteCopy($this->sbr->getUploadDir() . $file->name)) {
                 $this->uploaded_files[] = $file;
             }
         }
     }
     if ($this->uploaded_files) {
         unset($this->error['msgs']['msgtext']);
         if (count($this->error['msgs']) == 0) {
             unset($this->error['msgs']);
         }
     }
 }
        $str = viewattachLeft(NULL, $attach["name"], $attach['path'], $file, 0, 0, 0, 0, 0, 0, $nn);
        echo '<div class = "b-layout__txt b-layout__txt_padbot_5">', $str, '</div>';
        $nn++;
    }
    ?>
                    </div>
                <?php 
}
//elseif
?>

                <?php 
if (video_validate($project['videolnk'])) {
    ?>
					<?php 
    echo show_video($project['id'], video_validate($project['videolnk']));
    ?>
                <?php 
}
?>

                <?php 
if ($project['kind'] != 9) {
    ?>
         
                <div class="b-layout__txt b-layout__txt_fontsize_11 b-layout__txt_bold">Разделы:</div>
                <div class="b-layout__txt b-layout__txt_fontsize_11 <?php 
    if (!($project['ico_payed'] == 't' || $project['is_upped'] == 't' || $project['kind'] == 4)) {
        ?>
b-layout__txt_padbot_20<?php 
    }
Example #7
0
 public function validateWork($params)
 {
     $portf_cost = self::$portf_cost;
     foreach ($params as $name => $value) {
         switch ($name) {
             case 'video':
                 if ($value != '') {
                     if (!video_validate($value)) {
                         $error[$name] = 'Поле заполнено некорректно. Введите корректную ссылку на видео.';
                     }
                 }
                 break;
             case 'work_name':
                 if ($value == '') {
                     $error[$name] = 'Поле заполнено некорректно. Введите название.';
                 }
                 if (strlen(trim(stripslashes($value))) > 120) {
                     $error[$name] = 'Поле заполнено некорректно. Название должно содержать не более 120 символов.';
                 }
                 break;
             case 'link':
                 if ($value != '' && !url_validate($value, true)) {
                     $error[$name] = 'Поле заполнено некорректно. Введите корректную ссылку.';
                 }
                 break;
             case 'work_cost':
                 $cost_type = $params['work_cost_type_db_id'];
                 if ($value < 0 || $value > self::$portf_cost[$cost_type]) {
                     $error[$name] = 'Поле заполнено некорректно. Стоимость должна быть в пределе от 0 ' . view_range_cost2(0, self::$portf_cost[$cost_type], '', '', false, $cost_type) . ($cost_type != 2 ? '.' : '');
                 }
                 break;
             case 'time_cost':
                 if ($value < 0 || $value > self::MAX_TIME_VALUE) {
                     $error[$name] = 'Поле заполнено некорректно. Временные затраты должны быть в пределе от 0 до ' . self::MAX_TIME_VALUE . '.';
                 }
                 break;
         }
     }
     return $error;
 }
Example #8
0
         }
     }
 }
 if (strlen($_POST['title']) > commune::MSG_TITLE_MAX_LENGTH) {
     $alert['title'] = 'Количество символов превышает допустимое (' . commune::MSG_TITLE_MAX_LENGTH . ')';
 }
 if (is_empty_html($msgtext) && $question == '' && empty($alert) && $nTotalSize == 0 && $youtube_link == '' && count($attachedfiles_files) == 0) {
     $alert['msgtext'] = 'Поле заполнено некорректно';
     $msgtext = '';
 } else {
     if (strlen($msgtext) > commune::MSG_TEXT_MAX_LENGTH) {
         $alert['msgtext'] = 'Количество символов превышает допустимое';
     }
 }
 if ($youtube_link != '') {
     if ($video = video_validate($youtube_link)) {
         $request['youtube_link'] = $video;
     } else {
         $alert['youtube'] = 'Неверная ссылка';
     }
 }
 if ($alert) {
     //if(!$file->name) $request['attach'] = $prev_attach;
 } else {
     $draft_id = intval(__paramInit('int', 'draft_id', 'draft_id'));
     if ($message_id = commune::CreateMessage($request, $id, $user_id, $message_id, $files, $question, $answers, $answers_exists, $multiple)) {
         commune::DeleteMarkedAttach($message_id);
         commune::addAttachedFiles($attachedfiles_files, $message_id, NULL, $draft_id ? true : false);
         $attachedfiles->clear();
         if ($site != 'Topic') {
             if ($action == 'do.Edit.post' && ($om == commune::OM_TH_ACTUAL || $om == commune::OM_TH_MY)) {
Example #9
0
 /**
  * Проверка передаваемых данных для сохранения/изменения комментария
  * 
  * @param boolean $edit_mode   Флаг указывающий какие данные на проверке при создании или при редактировании, 
  *                             для проверки валидности автора к редактированию комментария
  * @return type 
  */
 protected function checkInput($edit_mode = false)
 {
     $uid = get_uid(false);
     if (!$uid) {
         header("Location: /fbd.php");
         die;
     }
     $tn = 0;
     if ($this->enableWysiwyg) {
         if ($this->enableNewWysiwyg) {
             $msg = __paramValue('ckedit', antispam($_POST['cmsgtext']));
             //$msg = __paramValue('ckedit_nocut', antispam($_POST['cmsgtext']));
         } else {
             $msg = __paramValue('wysiwyg_tidy', antispam($_POST['cmsgtext']));
         }
     } else {
         $msg = change_q_x(antispam(stripslashes($_POST['cmsgtext'])), false, false, 'b|br|i|p|ul|li|cut|s|h[1-6]{1}', false, false);
     }
     $reply = __paramInit('int', null, 'parent_id', NULL);
     $order_type = __paramInit('int', null, 'ord');
     $thread = __paramInit('int', 'id');
     $rmatt = $_POST['rmattaches'];
     $no_redirect = $_POST['no_redirect'];
     if ($edit_mode) {
         $mod = $this->_options['is_permission'];
         $comment = $this->getData($reply);
         if (!$mod && $comment['author'] != get_uid(false)) {
             header("Location: /fbd.php");
             die;
         }
     }
     // загрузка файлов
     $files = array();
     $attach = $_FILES['attach'];
     if (is_array($attach) && !empty($attach['name'])) {
         foreach ($attach['name'] as $key => $v) {
             if (!$attach['name'][$key] || $key > self::MAX_FILE_COUNT) {
                 continue;
             }
             $_POST['is_attached'] = true;
             $files[] = new CFile(array('name' => $attach['name'][$key], 'type' => $attach['type'][$key], 'tmp_name' => $attach['tmp_name'][$key], 'error' => $attach['error'][$key], 'size' => $attach['size'][$key]));
             if ($attach['size'][$key] == 0) {
                 $alert['attach'] = "Пустой файл";
             }
         }
     }
     $yt_link = $_POST['yt_link'];
     if ((!$msg || is_empty_html($msg)) && !$_POST['is_attached'] && $yt_link == '') {
         $alert['msgtext'] = 'Поле не должно быть пустым';
     } elseif (strlen_real($msg) > self::MSG_TEXT_MAX_LENGTH) {
         $alert['msgtext'] = 'Количество символов превышает допустимое';
     } elseif ($this->enableWysiwyg) {
         /*$tidy = new tidy();
           $msg = $tidy->repairString(
               $msg,
               array(
                   'fix-backslash' => false,
                   'show-body-only' => true,
                   'bare' => true,
                   'preserve-entities' => true,
                   'wrap' => '0'),
               'raw');*/
         $msg = str_replace("\n", "", $msg);
         $msg = preg_replace("/\\h/", " ", $msg);
     }
     if ($yt_link != '') {
         $v_yt_link = video_validate($yt_link);
         if (!$v_yt_link) {
             $alert['yt_link'] = "Неверная ссылка.";
         } else {
             $yt_link = $v_yt_link;
         }
     } else {
         $yt_link = null;
     }
     $model = $this->model();
     list($att, $uperr, $error_flag) = $this->UploadFiles($files, array('width' => 390, 'height' => 1000, 'less' => 0), '', $model['attaches']['file_table']);
     if ($uperr) {
         $alert['attach'] = $uperr;
         $att = $comment['attach'];
     }
     $this->_post_msg = array('resource' => $this->_resource_id, 'parent_id' => $reply, 'author' => get_uid(false), 'msgtext' => $msg, 'yt' => $edit_mode && !$yt_link ? "" : $yt_link, 'attaches' => $att, 'rmattaches' => $rmatt);
     if (!isset($alert)) {
         $new = $this->save($this->_post_msg, $edit_mode ? $comment['id'] : null, $comment['author']);
         // если автор комментария прикрепляет новые файлы - на модерирование
         // пока не используется - на модерирование сразу при insert/update
         /*if ( $edit_mode && $new && $files && $comment['author'] == $uid 
               && $model['comments']['fields']['moderator_status'] && $model['moderation_rec_type'] 
           ) {
               $GLOBALS['DB']->query( 'UPDATE ' . $model['comments']['table'] 
                   . ' SET ' . $model['comments']['fields']['moderator_status'] .' = 0' 
                   . ' WHERE ' . $model['comments']['fields']['id'] .' = ?i', $comment['id'] );
               $GLOBALS['DB']->query( 'DELETE FROM moderation WHERE rec_id = ?i AND rec_type = ?i', 
                   $comment['id'], $model['moderation_rec_type'] );
           }*/
         if ($new && !count($this->errors) && !$no_redirect) {
             // Сделано в связи с тем что IE(любой версии) не понимает #anchor, если делать в PHP header()
             $_SESSION['c_new_id'] = intVal($new);
             $parse = parse_url($_SERVER['HTTP_REFERER']);
             $location = $parse['path'] . '?' . url($_SERVER['HTTP_REFERER'], array('r' => rand(1, 1000)));
             header("Location: {$location}", true, 303);
             exit;
         }
     } else {
         if ($edit_mode) {
             $this->_post_msg['attaches'] = $comment['attach'];
         } else {
             $this->_post_msg['attaches'] = null;
         }
     }
     return $alert;
 }