Example #1
0
/**
 * Smarty truncate modifier plugin
 *
 * Type:     modifier<br>
 * Name:     truncate<br>
 * Purpose:  Truncate a string to a certain length if necessary,
 *           optionally splitting in the middle of a word, and
 *           appending the $etc string or inserting $etc into the middle.
 * @link http://smarty.php.net/manual/en/language.modifier.truncate.php
 *          truncate (Smarty online manual)
 * @author   Monte Ohrt <monte at ohrt dot com> with modifications by Matthew Crider (mcrider at sfu dot ca)
 * @param string
 * @param integer
 * @param string
 * @param boolean
 * @param boolean
 * @param boolean
 * @return string
 */
function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false, $skip_tags = true)
{
    if ($length == 0) {
        return '';
    }
    if (strlen($string) > $length) {
        $originalLength = strlen($string);
        if ($skip_tags) {
            if ($middle) {
                $tagsReverse = array();
                remove_tags($string, $tagsReverse, true, $length);
            }
            $tags = array();
            $string = remove_tags($string, $tags, false, $length);
        }
        $length -= min($length, strlen($etc));
        if (!$middle) {
            if (!$break_words) {
                $string = preg_replace('/\\s+?(\\S+)?$/', '', substr($string, 0, $length + 1));
            } else {
                $string = substr($string, 0, $length + 1);
            }
            if ($skip_tags) {
                $string = reinsert_tags($string, $tags);
            }
            return close_tags($string) . $etc;
        } else {
            $firstHalf = substr($string, 0, $length / 2);
            $secondHalf = substr($string, -$length / 2);
            if ($break_words) {
                if ($skip_tags) {
                    $firstHalf = reinsert_tags($firstHalf, $tags);
                    $secondHalf = reinsert_tags($secondHalf, $tagsReverse, true);
                    return close_tags($firstHalf) . $etc . close_tags($secondHalf, true);
                } else {
                    return $firstHalf . $etc . $secondHalf;
                }
            } else {
                for ($i = $length / 2; $string[$i] != ' '; $i++) {
                    $firstHalf = substr($string, 0, $i + 1);
                }
                for ($i = $length / 2; substr($string, -$i, 1) != ' '; $i++) {
                    $secondHalf = substr($string, -$i - 1);
                }
                if ($skip_tags) {
                    $firstHalf = reinsert_tags($firstHalf, $tags);
                    $secondHalf = reinsert_tags($secondHalf, $tagsReverse, strlen($string));
                    return close_tags($firstHalf) . $etc . close_tags($secondHalf, true);
                } else {
                    return $firstHalf . $etc . $secondHalf;
                }
            }
        }
    } else {
        return $string;
    }
}
Example #2
0
function SaveStatus($text, $statusType, $login = NULL)
{
    session_start();
    $freelancer = new freelancer();
    $text = addslashes(substr(stripslashes(trim($text)), 0, 200));
    close_tags($text, 's');
    $freelancer->status_text = antispam(htmlspecialchars(htmlspecialchars_decode(change_q_x(trim($text), true, false), ENT_QUOTES), ENT_QUOTES));
    $freelancer->status_type = intval($statusType);
    if ($freelancer->statusToStr($statusType)) {
        $stdStatus = "";
        $objResponse = new xajaxResponse();
        $uid = hasPermissions('users') && $login != $_SESSION['login'] ? $freelancer->GetUid($err, $login) : get_uid(false);
        $pro = hasPermissions('users') && $login != $_SESSION['login'] ? is_pro(true, $uid) : is_pro();
        $error = $freelancer->Update($uid, $res);
        if (!$freelancer->status_text) {
            $freelancer->status_text = $stdStatus;
        }
        $freelancer->status_text = stripslashes($freelancer->status_text);
        switch ($freelancer->status_type) {
            case 1:
                $status_cls = 'b-status b-status_busy';
                break;
            case 2:
                $status_cls = 'b-status b-status_abs';
                break;
            case -1:
                $status_cls = 'b-status b-status_no';
                break;
            default:
                $status_cls = 'b-status b-status_free';
        }
        if (!$noassign) {
            require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/stop_words.php';
            $stop_words = new stop_words(hasPermissions('users'));
            $sStatusText = $pro ? $freelancer->status_text : $stop_words->replace($freelancer->status_text);
            //$GLOBALS['xajax']->setCharEncoding("windows-1251");
            $jsobj = json_encode(array('data' => iconv('CP1251', 'UTF8', $freelancer->status_text)));
            $objResponse->assign("statusText", "innerHTML", $freelancer->status_text == $stdStatus ? "" : reformat($sStatusText, 40, 0, 1, 25));
            $objResponse->assign("statusTitle", "innerHTML", $freelancer->statusToStr($statusType));
            //            $objResponse->assign("statusTitle", "style.display", $statusType > -1 ? '' : 'none');
            $objResponse->script("statusType = {$statusType};\n\t\t\t                      statusTxt = document.getElementById('statusText').innerHTML;\n\t\t\t                      statusTxtSrc = {$jsobj};");
        }
        $objResponse->script("\$('bstatus').erase('class');\n             \$('bstatus').addClass('{$status_cls}');");
    }
    return $objResponse;
}
Example #3
0
 function truncate($length)
 {
     $this->is_truncated = FALSE;
     if ($length > 0 && mb_strlen($this->content) > $length + $length / 2) {
         $this->is_truncated = TRUE;
         $this->content = rtrim(preg_replace('/(?:[&<\\{]\\w{1,10}|[^}>\\s]{1,15}|http\\S+)$/u', '', mb_substr($this->content, 0, $length)));
         $this->content .= '&hellip;';
         if (preg_match('/<\\w+>/', $this->content)) {
             $this->content = close_tags($this->content);
         }
     }
 }
function do_submit1()
{
    global $db, $main_smarty, $dblang, $the_template, $linkres, $current_user, $Story_Content_Tags_To_Allow;
    $linkres = new Link();
    $main_smarty->assign('auto_vote', auto_vote);
    $main_smarty->assign('Submit_Show_URL_Input', Submit_Show_URL_Input);
    $main_smarty->assign('Submit_Require_A_URL', Submit_Require_A_URL);
    $main_smarty->assign('link_id', sanitize($_POST['id'], 3));
    define('pagename', 'submit');
    $main_smarty->assign('pagename', pagename);
    $linkres->store();
    $linkres->id = sanitize($_POST['id'], 3);
    $thecat = get_cached_category_data('category_id', $linkres->category);
    $main_smarty->assign('request_category_name', $thecat->category_name);
    if (!isset($_POST['summarytext'])) {
        $linkres->link_summary = utf8_substr(sanitize($_POST['bodytext'], 4, $Story_Content_Tags_To_Allow), 0, StorySummary_ContentTruncate - 1);
        $linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary));
    } else {
        $linkres->link_summary = sanitize($_POST['summarytext'], 4, $Story_Content_Tags_To_Allow);
        $linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary));
        if (utf8_strlen($linkres->link_summary) > StorySummary_ContentTruncate) {
            loghack('SubmitAStory-SummaryGreaterThanLimit', 'username: '******'|email: ' . sanitize($_POST["email"], 3), true);
            $linkres->link_summary = utf8_substr($linkres->link_summary, 0, StorySummary_ContentTruncate - 1);
            $linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary));
        }
    }
    $sid = $_POST["sid"];
    tags_insert_string($sid, $dblang, $linkres->tags);
    //$main_smarty->assign('the_story', $linkres->print_summary('full', true));
    $main_smarty->assign('tags', $linkres->tags);
    if (!empty($linkres->tags)) {
        $tags_words = str_replace(",", ", ", $linkres->tags);
        $tags_url = urlencode($linkres->tags);
        $main_smarty->assign('tags_words', $tags_words);
        $main_smarty->assign('tags_url', $tags_url);
    }
    $main_smarty->assign('submit_url_title', $linkres->url_title);
    $main_smarty->assign('submit_id', $linkres->id);
    $main_smarty->assign('submit_title', str_replace('"', "&#034;", $link_title));
    $main_smarty->assign('submit_content', $link_content);
    include mnminclude . 'redirector.php';
    $x = new redirector($_SERVER['REQUEST_URI']);
    //$Sid=$_SESSION['newSid'];
    header("Location:" . my_base_url . my_pligg_base . "/story.php?title={$sid}");
    $vars = '';
    check_actions('do_submit2', $vars);
    $_SESSION['step'] = 2;
    $main_smarty->display($the_template . '/pligg.tpl');
}
Example #5
0
/**
* Еще версия change_q()
* 
* @see change_q()
*
* @param string  $input			Текст
* @param boolean $strip_all		если истина, то все спец. символы преобразуются в сущности,
                       					иначе режутся атрибуты ВСЕХ тегов и теги, которые не входят в (b|br|i|p|ul|li|cut),
                       					становятся &lt;ТЕГ&gt;, а все кавычки и амперсэнды переводятся в сущности.
* @param boolean $strip_tags		если ($strip_tags && $strip_all), то все теги просто убиваются, а кавычки и амперсэнды переводятся в сущности.
                       					если !$strip_all, то значения не имеет (не проверяется вообще).
* @param string  $safe_tags		список тегов, которые можно оставить. Имеет значение только если !$strip_all.
* @param boolean $a_tag			Удаляем или нет ссылки, которые есть в тексте
* @param boolean $a_tag			Обрезать или нет пробелы по концам (trim)
     * @param boolean $is_addslashes    Добавлять слеши если выключен magic_quotes или не добавлять
     * @param int $max_len              Максимальная длина итоговой строки. Параметр действует только для close_tags()
* @return string
*/
function change_q_x($input, $strip_all = TRUE, $strip_tags = TRUE, $safe_tags = 'b|br|i|p|ul|li|cut|s|h[1-6]{1}', $a_tag = FALSE, $trim = false, $add_slashes = true, $max_len = null)
{
    setlocale(LC_ALL, 'ru_RU.CP1251');
    $input = str_replace(array('&#60;', '&#62;', '&#x3C;', '&#x3E;'), array('&lt;', '&gt;', '&lt;', '&gt;'), $input);
    // удаление NULL байта
    $input = preg_replace('~\\\\0~', '', $input);
    if ($strip_all) {
        if ($strip_tags) {
            $input = preg_replace('/<[^>]*(>|$)/', '', $input);
        }
        // вообще убиваем теги все.
        //$input = htmlspecialchars($input, ENT_QUOTES, 'cp1251'); // остаются кавычки и амперсэнд, преобразуем их в сущности.
        $input = str_replace(array('<', '>', '"', '\''), array('&lt;', '&gt;', '&quot;', '&#039;'), $input);
    } else {
        //close_tags($input, 's,i,b,h1,h2,h3,h4,h5,h6', $max_len);
        $safe_tags = is_null($safe_tags) ? 'b|br|i|p|ul|li|cut|s|h[1-6]{1}' : $safe_tags;
        // определяем рабочую переменную -- строка, которая НЕ ДОЛЖНА встречаться в исходном тексте.
        $dS = '@;;,,@;;@;__-=-=@~~~~' . mt_rand(8, 10000);
        $input = str_replace(array("<br />", "<br>"), array("\n", "\n"), $input);
        // сохраняем выравнивание у параграфов
        $input = preg_replace('#<p[^>]*?align=\\\\"(center|left|right)\\\\"#', '<p$1 ', $input);
        $safe_tags .= '|pcenter|pleft|pright';
        $input = preg_replace("/<({$safe_tags})\\s[^>]*?>/mix", "<\$1>", $input);
        // Чистим теги типа <strong style='awesome'> на <>
        // удаляем запрещенные атрибуты тегов
        $badAttrs = "onmousemove|onerror|onclick|onload|onunload|onabort|onblur|onchange|onfocus|onreset|onsubmit|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmouseup|onmouseover|onmouseout|onselect|javascript";
        $inputNew = "";
        while ($input !== $inputOld) {
            $inputOld = $input;
            $input = preg_replace("/<(.+?)((?:{$badAttrs})=[^\\s>]+)([^>]*?)>/mix", "<\$1\$3>", $input);
        }
        $input = preg_replace('/' . $dS . '/', '', $input);
        // убиваем ее, если все-таки встретилась (шанс чрезвычайно мал, но все же)
        $input = preg_replace('/(<|>)/', $dS . '$1', $input);
        // заменяем все '<' и '>' на $dS плюс суффикс '<' или '>' соответственно.
        $input = preg_replace("/{$dS}<(\\/?({$safe_tags})){$dS}>/i", '<$1>', $input);
        // оставляем только безопасные теги.
        $input = preg_replace('/' . $dS . '</', '&lt;', $input);
        // теперь заменяем оставшиеся $dS в соответствии с суффиксом на &lt; или &gt;
        $input = preg_replace('/' . $dS . '>/', '&gt;', $input);
        $input = preg_replace('/(\\r?\\n)/', "\n", $input);
        //$input = nl2br($input);
        // не работает такое. $input = preg_replace('#(<br //>\s*){3,}#i', '<br /><br />', $input); // максимум два BR-тега.
        /*if(strstr($safe_tags, 'img') && !preg_match('/<img.*?>/', $input)
          && !preg_match('/<p.*?>/', $input) ) */
        $input = preg_replace('/\\"/', '&quot;', $input);
        // все кавычки переводим в сущности.
        $input = preg_replace('/\'/', '&#039;', $input);
        // восстанавливаем выравнивание
        $input = str_replace(array('<pcenter', '<pleft', '<pright'), array('<p align="center"', '<p align="left"', '<p align="right"'), $input);
        $input = str_replace(array("<cut>", "</cut>"), array("<!-- -W-EDITOR-CUT- -->", "<!-- -W-EDITOR-CUT-END -->"), $input);
        close_tags($input, 's,i,b,h1,h2,h3,h4,h5,h6', $max_len);
        $input = str_replace(array("<!-- -W-EDITOR-CUT- -->", "<!-- -W-EDITOR-CUT-END -->"), array("<cut>", "</cut>"), $input);
    }
    if (!get_magic_quotes_gpc() && $add_slashes && !defined('NEO')) {
        $input = addslashes((string) $input);
    }
    if ($trim) {
        $input = trim($input);
    }
    setlocale(LC_ALL, 'en_US.UTF-8');
    //setlocale(LC_ALL, '');
    return $input;
}
Example #6
0
     $url = str_replace('&amp;', '&', $url);
     $linkres->url = $url;
 }
 $vars = '';
 check_actions('edit_link_hook', $vars);
 if (is_array($_POST['category'])) {
     $linkres->category = sanitize($_POST['category'][0], 3);
     $linkres->additional_cats = array_slice($_POST['category'], 1);
 } else {
     $linkres->category = sanitize($_POST['category'], 3);
 }
 if ($linkres->title != stripslashes(sanitize($_POST['title'], 3))) {
     $linkres->title = stripslashes(sanitize($_POST['title'], 3));
     $linkres->title_url = makeUrlFriendly($linkres->title, $linkres->id);
 }
 $linkres->content = close_tags(sanitize($_POST['bodytext'], 4, $Story_Content_Tags_To_Allow));
 $linkres->tags = tags_normalize_string(stripslashes(sanitize($_POST['tags'], 3)));
 if (sanitize($_POST['summarytext'], 3) == "") {
     $linkres->link_summary = utf8_substr(sanitize($_POST['bodytext'], 4, $Story_Content_Tags_To_Allow), 0, StorySummary_ContentTruncate - 1);
     //$linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary));
 } else {
     $linkres->link_summary = sanitize($_POST['summarytext'], 4, $Story_Content_Tags_To_Allow);
     //$linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary));
     if (utf8_strlen($linkres->link_summary) > StorySummary_ContentTruncate) {
         loghack('SubmitAStory-SummaryGreaterThanLimit', 'username: '******'|email: ' . sanitize($_POST["email"], 3), true);
         $linkres->link_summary = utf8_substr($linkres->link_summary, 0, StorySummary_ContentTruncate - 1);
         //$linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary));
     }
 }
 // Steef 2k7-07 security fix start ----------------------------------------------------------
 $linkres->link_field1 = sanitize($_POST['link_field1'], 4, $Story_Content_Tags_To_Allow);
Example #7
0
function content($num)
{
    $theContent = get_the_content();
    $output = preg_replace('/<img[^>]+./', '', $theContent);
    $soutput = strip_shortcodes($output);
    $limit = $num + 1;
    $content = explode(' ', $soutput, $limit);
    array_pop($content);
    $content = implode(" ", $content);
    $content = strip_tags($content, '<p><a><address><a><abbr><acronym><b><big><blockquote><br><caption><cite><class><code><col><del><dd><div><dl><dt><em><font><h1><h2><h3><h4><h5><h6><hr><i><figure><img><iframe><ins><kbd><li><ol><p><pre><q><s><span><strike><strong><sub><sup><table><tbody><td><tfoot><tr><tt><ul><var>');
    echo close_tags($content);
}
Example #8
0
function Lenta_Show($page = 1)
{
    global $DB;
    session_start();
    require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/portfolio.php";
    require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/professions.php";
    require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/commune.php";
    require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/links.php";
    require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/lenta.php";
    require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/users.php";
    require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/blogs.php";
    /*require_once( $_SERVER['DOCUMENT_ROOT'] . '/classes/stop_words.php' );
        
    $stop_words = new stop_words( false );*/
    $yt_replace_id = array();
    $yt_replace_data = array();
    $uid = get_uid(false);
    $objResponse = new xajaxResponse();
    ob_start();
    if (!($groups = professions::GetAllGroupsLite())) {
        return;
    }
    if (!($lenta = lenta::GetUserLenta($uid))) {
    }
    $sort = $_COOKIE['lenta_fav_order'] != "" ? $_COOKIE['lenta_fav_order'] : "date";
    $favs = lenta::GetFavorites($uid, $sort);
    if (!($myComms = commune::GetCommunes(NULL, $uid, NULL, commune::OM_CM_MY))) {
        $myComms = array();
    }
    if (!($joinedComms = commune::GetCommunes(NULL, NULL, $uid, commune::OM_CM_JOINED))) {
        $joinedComms = array();
    }
    // Все сообщества, доступные пользователю.
    $communes = array();
    foreach ($myComms as $comm) {
        $communes[] = $comm;
    }
    foreach ($joinedComms as $comm) {
        $communes[] = $comm;
    }
    // Блоги
    if (!($blog_grs = blogs::GetThemes($error, 1))) {
        $blog_grs = array();
    }
    $blg = NULL;
    if ($lenta && $lenta['blog_grs'] && !empty($lenta['blog_grs'])) {
        $blg = implode(',', $lenta['blog_grs']);
    }
    $pgs = NULL;
    if ($lenta['all_profs_checked'] == 'f') {
        if ($lenta && $lenta['prof_groups'] && !empty($lenta['prof_groups'])) {
            $pgs = implode(',', $lenta['prof_groups']);
        }
    }
    $allThemesCount = 0;
    $cms = NULL;
    $user_comm_mods = array();
    // Отбираем среди выбранных ранее сообществ в ленте, те которые до сих пор остаются
    // доступными ему для просмотра в ленте (его могли удалить или забанить). А также заполняем массив user_mod-ов на каждое из сообществ.
    if ($lenta && $lenta['communes'] && !empty($lenta['communes'])) {
        $i = 0;
        $cms = '';
        foreach ($lenta['communes'] as $cm_id) {
            if ($uStatus = commune::GetUserCommuneRel($cm_id, $uid)) {
                $ucm = $user_mod;
                $ucm |= commune::MOD_COMM_MODERATOR * $uStatus['is_moderator'];
                $ucm |= commune::MOD_COMM_MANAGER * $uStatus['is_manager'];
                $ucm |= commune::MOD_COMM_ADMIN * ($uStatus['is_admin'] || $uStatus['is_moderator'] || $uStatus['is_manager']);
                $ucm |= commune::MOD_COMM_AUTHOR * $uStatus['is_author'];
                $ucm |= commune::MOD_COMM_ASKED * $uStatus['is_asked'];
                $ucm |= commune::MOD_COMM_ACCEPTED * ($uStatus['is_accepted'] || $ucm & commune::MOD_COMM_ADMIN);
                $ucm |= commune::MOD_COMM_BANNED * $uStatus['is_banned'];
                $ucm |= commune::MOD_COMM_DELETED * $uStatus['is_deleted'];
                $user_comm_mods[$cm_id] = $ucm;
                if (!$uStatus['is_deleted'] && !$uStatus['is_banned'] && $uStatus['is_blocked_commune'] == 0 && ($uStatus['is_accepted'] || $uStatus['is_author'])) {
                    $cms .= (!$i++ ? '' : ',') . $cm_id;
                }
            }
        }
    }
    //if($cms)
    //  $allThemesCount -= commune::GetMyThemesCount($cms, $uid);
    if ($lenta && $lenta['all_profs_checked'] == 't' || $cms || $pgs || $blg) {
        $items = lenta::GetLentaItems($uid, $lenta && $lenta['my_team_checked'] == 't', $lenta && $lenta['all_profs_checked'] == 't', $pgs, $cms, ($page - 1) * lenta::MAX_ON_PAGE, lenta::MAX_ON_PAGE, $allWorkCount, $blg);
    }
    if (!$items) {
        $items = array();
    }
    //    var_dump($favs);
    $stars = array(0 => 'bsg.png', 1 => 'bsgr.png', 2 => 'bsy.png', 3 => 'bsr.png');
    $i = 0;
    foreach ($items as $item) {
        switch ($item['item_type']) {
            case '2':
                // Сообщества
                $top = $item;
                $user_mod = $user_comm_mods[$top['commune_id']];
                if ($top['member_is_banned'] && !($user_mod & (commune::MOD_ADMIN | commune::MOD_COMM_AUTHOR | commune::MOD_COMM_MANAGER)) || $top['is_private'] == 't' && $top['user_id'] != $uid && !($user_mod & (commune::MOD_ADMIN | commune::MOD_COMM_AUTHOR | commune::MOD_COMM_MANAGER)) || $top['is_blocked'] && $top['commune_author_id'] != $uid) {
                    continue;
                }
                $aThemeId = is_array($top['theme_id']) ? $top['theme_id'] : array($top['theme_id']);
                $top['answers'] = $DB->rows("SELECT * FROM commune_poll_answers WHERE theme_id IN (?l) ORDER BY id", array($top['theme_id']));
                $GLOBALS[LINK_INSTANCE_NAME] = new links('commune');
                $user_id = $uid;
                $mod = $user_mod;
                $is_member = $mod & (commune::MOD_ADMIN | commune::MOD_COMM_ACCEPTED | commune::MOD_COMM_AUTHOR);
                $is_moder = $mod & (commune::MOD_ADMIN | commune::MOD_MODER | commune::MOD_COMM_MODERATOR | commune::MOD_COMM_AUTHOR);
                $commune_info = commune::getCommuneInfoByMsgID($top['id']);
                ?>
                                <style>
.lo-m .lo-i-my-d .ac-pro, .lo-m .lo-i-my-d .ac-epro {
margin-right: 0px;
}
.lo .utxt .b-layout__txt .b-icon__lprofi{ vertical-align:baseline !important; top:2px !important;}
.lo .utxt>.b-pic{ margin-right:10px !important;}
</style>
								<div class="lo lo-m" id='idTop_<?php 
                echo $top['id'];
                ?>
' style='margin-bottom:0px !important;'>
									<ul class="lo-p">
										<li class="lo-s">
											<div class="b-layout_bordrad_3">
												<a href="/commune" class="lnk-dot-666">Сообщества</a>
											</div>
										</li>
										<li class="post-f-fav">
                                            <?php 
                $msg_id = $top['id'];
                ?>
                                            <?php 
                if ($favs['CM' . $msg_id]) {
                    ?>
 
                                                <img src="/images/bookmarks/<?php 
                    echo $stars[$favs['CM' . $msg_id]['priority']];
                    ?>
" alt="" on="<?php 
                    echo $is_fav ? 1 : 0;
                    ?>
" id="favstar<?php 
                    echo 'CM' . $msg_id;
                    ?>
" <?php 
                    if ($uid) {
                        ?>
onclick="ShowFavFloatLenta(<?php 
                        echo $msg_id;
                        ?>
, <?php 
                        echo $uid;
                        ?>
, 'CM')" ><?php 
                    }
                    ?>
                                            <?php 
                } else {
                    ?>
                                                <img src="/images/bookmarks/bsw.png" alt="" on="<?php 
                    echo $is_fav ? 1 : 0;
                    ?>
" id="favstar<?php 
                    echo 'CM' . $msg_id;
                    ?>
" <?php 
                    if ($uid) {
                        ?>
onclick="ShowFavFloatLenta(<?php 
                        echo $msg_id;
                        ?>
, <?php 
                        echo $uid;
                        ?>
, 'CM')" ><?php 
                    }
                    ?>
                                            <?php 
                }
                ?>
                                            <ul class="post-f-fav-sel" style="display:none;" id="FavFloat<?php 
                echo $msg_id;
                ?>
"></ul>
										</li>
									</ul>
									<div class="utxt">
<?php 
                print __LentaPrntUsrInfo($top, 'user_', '', '', false, true);
                ?>
										<h3>
                                        <?php 
                if ($top['is_private'] == 't') {
                    ?>
                                        <img src="/images/icons/eye-hidden.png" alt="Скрытый пост" title="Скрытый пост">&nbsp;	            
                                        <?php 
                }
                //if
                ?>
                                        <?php 
                $sTitle = $top['title'];
                ?>
                                        <?php 
                $sMessage = $top['msgtext'];
                ?>
                                        <a href="<?php 
                echo getFriendlyURL('commune', $top['id']);
                ?>
?om=<?php 
                echo commune::OM_TH_NEW;
                ?>
"><?php 
                echo reformat2($sTitle, 30, 0, 1);
                ?>
</a>&nbsp;</h3>
										<p><?php 
                echo reformat2($sMessage, 46, 1, 0, 1);
                ?>
</p>

                                        <!-- Questions -->
			<?php 
                if ($top['question'] != '') {
                    ?>
			<div id="poll-<?php 
                    echo $top['theme_id'];
                    ?>
" class="commune-poll">
				<div class="commune-poll-theme"><?php 
                    echo reformat($top['question'], 43, 0, 1);
                    ?>
</div>
				<div id="poll-answers-<?php 
                    echo $top['theme_id'];
                    ?>
">
				<?php 
                    if ($top['poll_closed'] == 't') {
                        ?>
<table class="b-layout__table b-layout__table_width_full"><?php 
                    }
                    ?>
                <?php 
                    // если надо вывести только количество ответов
                    $showAnswers = $top['poll_votes'] || !$user_id || $top['commune_blocked'] == 't' || $top['user_is_banned'] || $top['member_is_banned'] || !$is_member;
                    if ($showAnswers) {
                        ?>
<table class="poll-variants"><?php 
                    }
                    ?>
				<?php 
                    $i = 0;
                    $max = 0;
                    if ($top['poll_closed'] == 't') {
                        foreach ($top['answers'] as $answer) {
                            $max = max($max, $answer['votes']);
                        }
                    }
                    foreach ($top['answers'] as $answer) {
                        ?>

						<?php 
                        if ($top['poll_closed'] == 't') {
                            ?>
                        	<tr class="b-layout__tr">
                              <td class="b-layout__left b-layout__left_width_50"><label class="b-layout__txt" for="poll_<?php 
                            echo $i;
                            ?>
"><?php 
                            echo reformat($answer['answer'], 30, 0, 1);
                            ?>
</label></td>
                              <td class="b-layout__middle b-layout__middle_width_30 b-layout__middle_center"><?php 
                            echo $answer['votes'];
                            ?>
</td>
                              <td class=" b-layout__right "><div class=" res-line rl1" style="width: <?php 
                            echo $max ? round(100 * $answer['votes'] / $max * 3) : 0;
                            ?>
px;"></div></td>
                            </tr>
                        <?php 
                        } else {
                            ?>
                            <?php 
                            if ($showAnswers) {
                                ?>
                                <tr>
                                    <td class="bp-gres"><?php 
                                echo $answer['votes'];
                                ?>
</td>
                                    <td>
                                        <label><?php 
                                echo $answer['answer'];
                                ?>
</label>
                                    </td>
                                </tr>
                            <?php 
                            } else {
                                ?>
                                <?php 
                                if ($top['poll_multiple'] == 't') {
                                    ?>
                                <div class="b-check b-check_padbot_10">
                                    <input id="poll-<?php 
                                    echo $top['theme_id'];
                                    ?>
_<?php 
                                    echo $i;
                                    ?>
" class="b-check__input" type="checkbox" name="poll_vote[]" value="<?php 
                                    echo $answer['id'];
                                    ?>
" />
                                    <label class="b-check__label b-check__label_fontsize_13" for="poll-<?php 
                                    echo $top['theme_id'];
                                    ?>
_<?php 
                                    echo $i++;
                                    ?>
"><?php 
                                    echo reformat($answer['answer'], 30, 0, 1);
                                    ?>
</label>
                                </div>
                                <?php 
                                } else {
                                    ?>
                                <div class="b-radio__item  b-radio__item_padbot_5">
                                    <table class="b-layout__table b-layout__table_width_full" cellpadding="0" cellspacing="0" border="0">
                                        <tr class="b-layout__tr">
                                            <td class="b-layout__left b-layout__left_width_15"><input id="poll-<?php 
                                    echo $top['theme_id'];
                                    ?>
_<?php 
                                    echo $i;
                                    ?>
" class="b-radio__input b-radio__input_top_-3" type="radio" name="poll_vote" value="<?php 
                                    echo $answer['id'];
                                    ?>
" /></td>
                                            <td class="b-layout__right"><label class="b-radio__label b-radio__label_fontsize_13" for="poll-<?php 
                                    echo $top['theme_id'];
                                    ?>
_<?php 
                                    echo $i++;
                                    ?>
"><?php 
                                    echo reformat($answer['answer'], 30, 0, 1);
                                    ?>
</label></td>
                                        </tr>
                                    </table>
                                </div>
                                <?php 
                                }
                                ?>
                            <?php 
                            }
                            ?>
                            
                        <?php 
                        }
                        ?>

				<?php 
                    }
                    ?>
                <?php 
                    if ($showAnswers) {
                        ?>
</table><?php 
                    }
                    ?>
				<?php 
                    if ($top['poll_closed'] == 't') {
                        ?>
</table><?php 
                    }
                    ?>
				</div>
				<?php 
                    if (!$top['poll_votes'] && $user_id && $top['poll_closed'] != 't' && $top['commune_blocked'] != 't' && !$top['user_is_banned'] && !$top['member_is_banned'] && $is_member) {
                        ?>
                
                <div class="b-buttons b-buttons_inline-block">
                    <span id="poll-btn-vote-<?php 
                        echo $top['theme_id'];
                        ?>
">
                        <a class="b-button b-button_flat b-button_flat_grey" href="javascript: return false;" onclick="poll.vote('Commune', <?php 
                        echo $top['theme_id'];
                        ?>
); return false;">Ответить</a>&nbsp;&nbsp;&nbsp;                
                    </span>                
					<span id="poll-btn-result-<?php 
                        echo $top['theme_id'];
                        ?>
" ><a class="b-buttons__link b-buttons__link_dot_0f71c8" href="javascript: return false;" onclick="poll.showResult('Commune', <?php 
                        echo $top['theme_id'];
                        ?>
); return false;">Посмотреть результаты</a></span>
                </div>
				<?php 
                    } else {
                        ?>
				<span id="poll-btn-vote-<?php 
                        echo $top['theme_id'];
                        ?>
"></span>
				<span id="poll-btn-result-<?php 
                        echo $top['theme_id'];
                        ?>
"></span>
				<?php 
                    }
                    ?>
			</div>
            <br />
			<?php 
                }
                ?>
                                        <!-- /Questions -->

                                        <!-- Youtube -->
<?php 
                if ($top['yt_link']) {
                    $tmp_yt_id = $top['id'] . 'ytlink' . mt_rand(1, 1000000);
                    $tmp_yt_data = show_video($top['id'], $top['yt_link']);
                    array_push($yt_replace_id, '/' . $tmp_yt_id . '/');
                    array_push($yt_replace_data, $tmp_yt_data);
                    echo "<div style='padding-top: 20px'>" . $tmp_yt_id . "</div><br/>";
                }
                ?>


<?php 
                //            (($top['youtube_link'])? ("<div style='padding-top: 20px'>".show_video($top['id'], $top['youtube_link'])."</div><br/>"):"")
                ?>

                                        <!-- /Youtube -->

                                        <!-- Attach -->
<?php 
                if ($top['attach']) {
                    $attach = $top['attach'][0];
                    if ($attach['fname']) {
                        $att_ext = strtolower(CFile::getext($attach['fname']));
                        if ($att_ext == "swf") {
                            print "<br/>" . viewattachExternal($top['user_login'], $attach['fname'], "upload", "/blogs/view_attach.php?user="******"&attach=" . $attach['fname']) . "<br/>";
                        } elseif ($att_ext == 'flv') {
                            print "<br/>" . viewattachLeft($top['user_login'], $attach['fname'], "upload", $file, 1000, 470, 307200, true, $attach['small'] == 't' ? 1 : 0) . "<br/>";
                        } else {
                            print "<br/>" . viewattachLeft($top['user_login'], $attach['fname'], "upload", $file, 1000, 470, 307200, !($attach['small'] == 't'), $attach['small'] == 't' ? 1 : 0) . "<br/>";
                        }
                    }
                    echo '<br/>';
                    if (sizeof($top['attach']) > 1) {
                        echo "<a href=\"" . getFriendlyURL('commune', $top['id']) . "\"><b>" . blogs::ShowMoreAttaches(sizeof($top['attach'])) . "</b></a><br/><br/>";
                    }
                }
                ?>

                                        <!-- /Attach -->


									</div>
									<ul class="lo-i">
                                        <?php 
                $post_year = dateFormat('Y', $top['post_time']);
                ?>
                                        <li class="lo-i-cm">
                                            <a href="<?php 
                echo getFriendlyURL('commune', $top['id']);
                ?>
" <?php 
                echo $top['current_count'] == NULL && intval($top['count_comments']) != 0 ? 'style="font-weight:bold;"' : '';
                ?>
><?php 
                echo $top['closed_comments'] == 't' ? "Комментирование закрыто" : "Комментарии (" . intval($top['count_comments']) . ")";
                ?>
</a>
                                            <?php 
                if ($top['closed_comments'] == 'f') {
                    $top['current_count'] = $top['current_count'] == '' ? $top['a_count'] - 1 : $top['current_count'];
                    if ($top['a_count'] > 1) {
                        $unread = $top['a_count'] - 1 - $top['current_count'];
                    }
                    if ($unread > 0) {
                        ?>
                                                <a href="<?php 
                        echo getFriendlyURL('commune', $top['id']);
                        ?>
#unread" style="color:#6BA813; font-weight:bold;">(<?php 
                        echo $unread;
                        ?>
 <?php 
                        echo $unread == 1 ? "новый" : "новых";
                        ?>
)</a>
                                                <?php 
                    }
                    $unread = 0;
                }
                ?>
                                        </li>
										<li class="lo-i-c"><a href="/commune/?id=<?php 
                echo $top['commune_id'];
                ?>
"><?php 
                echo $top['commune_name'];
                ?>
</a>, <a href="/commune/?gr=<?php 
                echo $top['commune_group_id'];
                ?>
"><?php 
                echo $top['commune_group_name'];
                ?>
</a></li>
										<li><?php 
                echo $post_year > 2000 ? dateFormat("d.m.Y H:i", $top['post_time']) : '';
                ?>
</li>
									</ul>
								</div>
                                <br>

                            <?php 
                break;
            case '1':
                // Портфолио
                $work = $item;
                if ($work['work_is_blocked']) {
                    continue;
                }
                $is_fav = isset($favs['PF' . $work['portfolio_id']]) ? 1 : 0;
                $msg_id = $work['portfolio_id'];
                ?>
								<div class="lo lo-m" style='margin-bottom:0px !important;'>
									<ul class="lo-p">
										<li class="lo-s">
											<div class="b-layout_bordrad_3">
												<a href="/portfolio" class="lnk-dot-666">Работы</a>
											</div>
										</li>
										<li class="post-f-fav">
                                            <?php 
                if ($favs['PF' . $msg_id]) {
                    ?>
 
                                                <img src="/images/bookmarks/<?php 
                    echo $stars[$favs['PF' . $msg_id]['priority']];
                    ?>
" alt="" on="<?php 
                    echo $is_fav ? 1 : 0;
                    ?>
" id="favstar<?php 
                    echo 'PF' . $msg_id;
                    ?>
" <?php 
                    if ($uid) {
                        ?>
onclick="ShowFavFloatLenta(<?php 
                        echo $msg_id;
                        ?>
, <?php 
                        echo $uid;
                        ?>
, 'PF')" ><?php 
                    }
                    ?>
                                            <?php 
                } else {
                    ?>
                                                <img src="/images/bookmarks/bsw.png" alt="" on="<?php 
                    echo $is_fav ? 1 : 0;
                    ?>
" id="favstar<?php 
                    echo 'PF' . $msg_id;
                    ?>
" <?php 
                    if ($uid) {
                        ?>
onclick="ShowFavFloatLenta(<?php 
                        echo $msg_id;
                        ?>
, <?php 
                        echo $uid;
                        ?>
, 'PF')" ><?php 
                    }
                    ?>
                                            <?php 
                }
                ?>
                                            <ul class="post-f-fav-sel" style="display:none;" id="FavFloat<?php 
                echo $msg_id;
                ?>
"></ul>
										</li>
									</ul>
									<div class="utxt">
                                        <?php 
                print __LentaPrntUsrInfo($work, 'user_', '', '', false, true);
                ?>
                                        <?php 
                $sTitle = $work['name'];
                ?>
										<h3><a href="/users/<?php 
                echo $work['user_login'];
                ?>
/viewproj.php?prjid=<?php 
                echo $work['portfolio_id'];
                ?>
"><?php 
                echo reformat2($sTitle, 40, 0, 1);
                ?>
</a>&nbsp;</h3>
                                        <?php 
                $is_preview = $work['pict'] || $work['prev_pict'];
                if ($is_preview && $work['prev_type'] != 1) {
                    echo view_preview($work['user_login'], $work['prev_pict'], "upload", $align, true, true, '', 200) . "<br/><br/>";
                }
                close_tags($work['descr'], array('b', 'i'));
                $sDescr = $work['descr'];
                ?>
										<p><?php 
                echo reformat($sDescr, 80, 0, 0, 1);
                ?>
</p>



									</div>
									<ul class="lo-i">
                                        <?php 
                $post_year = dateFormat('Y', $work['post_time']);
                ?>
										<li class="lo-i-c"><a href="/freelancers/?prof=<?php 
                echo $work['prof_id'];
                ?>
"><?php 
                echo $work['prof_name'];
                ?>
</a></li>
										<li><?php 
                echo $post_year > 2000 ? dateFormat("d.m.Y H:i", $work['post_time']) : '';
                ?>
</li>
									</ul>
								</div>
                                <br>
                            <?php 
                break;
            case '4':
                // Блоги
                $item['thread_id'] = $item['theme_id'];
                $item['answers'] = $DB->rows("SELECT * FROM blogs_poll_answers WHERE thread_id IN (?l) ORDER BY id", array($item['thread_id']));
                $GLOBALS[LINK_INSTANCE_NAME] = new links('blogs');
                $user_id = $uid;
                ?>
								<div class="lo lo-m" id='idBlog_<?php 
                echo $item['thread_id'];
                ?>
' style='margin-bottom:0px !important;'>
									<ul class="lo-p">
										<li class="lo-s">
											<div class="b-layout_bordrad_3">
												<a href="/blogs" class="lnk-dot-666">Блоги</a>
											</div>
										</li>
										<li class="post-f-fav">
                                            <?php 
                $msg_id = $item['theme_id'];
                ?>
                                            <?php 
                if ($favs['BL' . $msg_id]) {
                    ?>
 
                                                <img src="/images/bookmarks/<?php 
                    echo $stars[$favs['BL' . $msg_id]['priority']];
                    ?>
" alt="" on="<?php 
                    echo $is_fav ? 1 : 0;
                    ?>
" id="favstar<?php 
                    echo 'BL' . $msg_id;
                    ?>
" <?php 
                    if ($uid) {
                        ?>
onclick="ShowFavFloatLenta(<?php 
                        echo $msg_id;
                        ?>
, <?php 
                        echo $uid;
                        ?>
, 'BL')" ><?php 
                    }
                    ?>
                                            <?php 
                } else {
                    ?>
                                                <img src="/images/bookmarks/bsw.png" alt="" on="<?php 
                    echo $is_fav ? 1 : 0;
                    ?>
" id="favstar<?php 
                    echo 'BL' . $msg_id;
                    ?>
" <?php 
                    if ($uid) {
                        ?>
onclick="ShowFavFloatLenta(<?php 
                        echo $msg_id;
                        ?>
, <?php 
                        echo $uid;
                        ?>
, 'BL')" ><?php 
                    }
                    ?>
                                            <?php 
                }
                ?>
                                            <ul class="post-f-fav-sel" style="display:none;" id="FavFloat<?php 
                echo $msg_id;
                ?>
"></ul>
										</li>
									</ul>
									<div class="utxt">
                                        <?php 
                print __LentaPrntUsrInfo($item, 'user_', '', '', false, true);
                ?>
                                        <?php 
                $sTitle = $item['title'];
                ?>
                                        <?php 
                $sMessage = $item['msgtext'];
                ?>
										<h3><a href="<?php 
                echo getFriendlyURL("blog", $item['theme_id']);
                ?>
"><?php 
                echo reformat2($sTitle, 30, 0, 1);
                ?>
</a>&nbsp;</h3>
										<p><?php 
                echo reformat($sMessage, 46, 1, -($item['is_chuck'] == 't'), 1);
                ?>
</p>

                                        <!-- Questions -->
			<?php 
                if ($item['question'] != '') {
                    ?>
			<div id="poll-<?php 
                    echo $item['thread_id'];
                    ?>
" class="poll">
				<div class="commune-poll-theme"><?php 
                    echo reformat($item['question'], 43, 0, 1);
                    ?>
</div>
				<div id="poll-answers-<?php 
                    echo $item['thread_id'];
                    ?>
">
				<?php 
                    if ($item['poll_multiple'] != 't') {
                        ?>
<div class="b-radio b-radio_layout_vertical"><?php 
                    }
                    ?>
				<?php 
                    if ($item['poll_closed'] == 't') {
                        ?>
<table class="b-layout__table b-layout__table_width_full"><?php 
                    }
                    ?>
				<?php 
                    $i = 0;
                    $max = 0;
                    if ($item['poll_closed'] == 't') {
                        foreach ($item['answers'] as $answer) {
                            $max = max($max, $answer['votes']);
                        }
                    }
                    foreach ($item['answers'] as $answer) {
                        ?>
				
				<?php 
                        if ($item['poll_closed'] == 't') {
                            ?>
                    <tr class="b-layout__tr">
                      <td class="b-layout__left b-layout__left_width_50"><label class="b-layout__txt" for="poll_<?php 
                            echo $i;
                            ?>
"><?php 
                            echo reformat($answer['answer'], 30, 0, 1);
                            ?>
</label></td>
                      <td class="b-layout__middle b-layout__middle_width_30 b-layout__middle_center"><?php 
                            echo $answer['votes'];
                            ?>
</td>
                      <td class=" b-layout__right "><div class=" res-line rl1" style="width: <?php 
                            echo $max ? round(100 * $answer['votes'] / $max * 3) : 0;
                            ?>
px;"></div></td>
                    </tr>
				<?php 
                        } else {
                            ?>
					<?php 
                            if ($item['poll_votes'] || !$user_id) {
                                ?>
						<div class="bp-gres"><?php 
                                echo $answer['votes'];
                                ?>
</div>
					<?php 
                            } else {
                                ?>
						
						<?php 
                                if ($item['poll_multiple'] == 't') {
                                    ?>
                        	<div class="b-check b-check_padbot_10">
								<input id="poll-<?php 
                                    echo $item['thread_id'];
                                    ?>
_<?php 
                                    echo $i;
                                    ?>
" class="b-check__input" type="checkbox" name="poll_vote[]" value="<?php 
                                    echo $answer['id'];
                                    ?>
" />
                                <label class="b-check__label b-check__label_fontsize_13" for="poll-<?php 
                                    echo $item['thread_id'];
                                    ?>
_<?php 
                                    echo $i++;
                                    ?>
"><?php 
                                    echo reformat($answer['answer'], 30, 0, 1);
                                    ?>
</label>
                            </div>
						<?php 
                                } else {
                                    ?>
                        	<div class="b-radio__item  b-radio__item_padbot_5">
                            	<table class="b-layout__table b-layout__table_width_full" cellpadding="0" cellspacing="0" border="0">
                                	<tr class="b-layout__tr">
                                    	<td class="b-layout__left b-layout__left_width_15"><input id="poll-<?php 
                                    echo $item['thread_id'];
                                    ?>
_<?php 
                                    echo $i;
                                    ?>
" class="b-radio__input b-radio__input_top_-3" type="radio" name="poll_vote" value="<?php 
                                    echo $answer['id'];
                                    ?>
" /></td>
                                        <td class="b-layout__right"><label class="b-radio__label b-radio__label_fontsize_13" for="poll-<?php 
                                    echo $item['thread_id'];
                                    ?>
_<?php 
                                    echo $i++;
                                    ?>
"><?php 
                                    echo reformat($answer['answer'], 30, 0, 1);
                                    ?>
</label></td>
                                    </tr>
                                </table>
                            </div>
						<?php 
                                }
                                ?>
					<?php 
                            }
                            ?>
					
				<?php 
                        }
                        ?>
				
				<?php 
                    }
                    ?>
				<?php 
                    if ($item['poll_closed'] == 't') {
                        ?>
</table><?php 
                    }
                    ?>
				<?php 
                    if ($item['poll_multiple'] != 't') {
                        ?>
</div><?php 
                    }
                    ?>
				</div>
				<?php 
                    if (!$item['poll_votes'] && $user_id && $item['poll_closed'] != 't') {
                        ?>
                <div class="b-buttons b-buttons_inline-block">
                    <span id="poll-btn-vote-<?php 
                        echo $item['thread_id'];
                        ?>
">
                        <a class="b-button b-button_flat b-button_flat_grey" href="javascript: return false;"  onclick="poll.vote('Blogs', <?php 
                        echo $item['thread_id'];
                        ?>
); return false;">Ответить</a>                
                        &nbsp;&nbsp;&nbsp;
                    </span>                
                    <span id="poll-btn-result-<?php 
                        echo $item['thread_id'];
                        ?>
"><a class="b-buttons__link b-buttons__link_dot_0f71c8" href="javascript: return false;" onclick="poll.showResult('Blogs', <?php 
                        echo $item['thread_id'];
                        ?>
); return false;">Посмотреть результаты</a>&nbsp;&nbsp;&nbsp;</span>
                </div>
				<?php 
                    } else {
                        ?>
				<span id="poll-btn-vote-<?php 
                        echo $item['thread_id'];
                        ?>
"></span>
				<span id="poll-btn-result-<?php 
                        echo $item['thread_id'];
                        ?>
"></span>
				<?php 
                    }
                    ?>
			</div>
            <br/>
			<?php 
                }
                ?>
                                        <!-- /Questions -->

                                        <!-- Youtube -->
<?php 
                if ($item['yt_link']) {
                    $tmp_yt_id = $item['id'] . 'ytlink' . rand(1, 1000000);
                    $tmp_yt_data = show_video($item['id'], $item['yt_link']);
                    array_push($yt_replace_id, '/' . $tmp_yt_id . '/');
                    array_push($yt_replace_data, $tmp_yt_data);
                    echo "<div style='padding-top: 20px'>" . $tmp_yt_id . "</div><br/>";
                }
                //            =(($item['yt_link'])? ("<div style='padding-top: 20px'>".show_video($item['id'], $item['yt_link'])."</div>"):"")
                ?>
                                        <!-- /Youtube -->

                                        <!-- Attach -->
<?php 
                if ($item['attach']) {
                    $attach = $item['attach'][0];
                    if ($attach['fname']) {
                        $att_ext = strtolower(CFile::getext($attach['fname']));
                        if ($att_ext == "swf") {
                            print "<br/>" . viewattachExternal($item['user_login'], $attach['fname'], "upload", "/blogs/view_attach.php?user="******"&attach=" . $attach['fname']) . "<br/>";
                        } elseif ($att_ext == 'flv') {
                            print "<br/>" . viewattachLeft($item['user_login'], $attach['fname'], "upload", $file, 1000, 470, 307200, true, $attach['small'] == 2 ? 1 : 0) . "<br/>";
                        } else {
                            print "<br/>" . viewattachLeft($item['user_login'], $attach['fname'], "upload", $file, 1000, 470, 307200, !$attach['small'], $attach['small'] == 2 ? 1 : 0) . "<br/>";
                        }
                    }
                    echo '<br/>';
                    if (sizeof($item['attach']) > 1) {
                        echo "<a href=\"" . getFriendlyURL("blog", $item['theme_id']) . "\"><b>" . blogs::ShowMoreAttaches(sizeof($item['attach'])) . "</b></a><br/><br/>";
                    }
                }
                ?>

                                        <!-- /Attach -->
									</div>
									<ul class="lo-i">
                                        <?php 
                $post_year = dateFormat('Y', $item['post_time']);
                ?>
                                        <li class="lo-i-cm">
                                            <a href="<?php 
                echo getFriendlyURL("blog", $item['theme_id']);
                ?>
" <?php 
                echo $item['current_count'] == NULL && intval($item['count_comments']) != 0 ? 'style="font-weight:bold;"' : '';
                ?>
><?php 
                echo $item['closed_comments'] == 't' ? "Комментирование закрыто" : "Комментарии (" . intval($item['count_comments']) . ")";
                ?>
</a>
                                            <?php 
                if (isset($item['status_comments']) && $item['count_comments'] > 0 && $item['status_comments'] < $item['count_comments'] && $item['status_comments'] != -100 && $item['closed_comments'] == 'f') {
                    $new_comments_num = $item['count_comments'] - $item['status_comments'];
                    ?>
                                              <a href="<?php 
                    echo getFriendlyURL("blog", $item['theme_id']);
                    ?>
#unread" style="color:#6BA813; font-weight:bold;">(<?php 
                    echo $new_comments_num;
                    ?>
 <?php 
                    echo $new_comments_num == 1 ? "новый" : "новых";
                    ?>
)</a>
                                              <?php 
                } else {
                    if (isset($item['status_comments']) && $item['count_comments'] > 0 && $item['status_comments'] < $item['count_comments'] && $item['status_comments'] == -100 && $item['closed_comments'] == 'f') {
                        $new_comments_num = $item['count_comments'];
                        ?>
                                              <a href="<?php 
                        echo getFriendlyURL("blog", $item['theme_id']);
                        ?>
#unread" style="color:#6BA813; font-weight:bold;">(<?php 
                        echo $new_comments_num;
                        ?>
 <?php 
                        echo $new_comments_num == 1 ? "новый" : "новых";
                        ?>
)</a>
                                              <?php 
                    }
                }
                ?>
                                        </li>
										<li class="lo-i-c"><a href="<?php 
                echo getFriendlyURL("blog_group", $item['commune_group_id']);
                ?>
"><?php 
                echo $item['commune_group_name'];
                ?>
</a></li>
										<li><?php 
                echo $post_year > 2000 ? dateFormat("d.m.Y H:i", $item['post_time']) : '';
                ?>
</li>
									</ul>
								</div>
                                <br>
                                    <?php 
                break;
        }
        $i++;
    }
    ?>

                    <?php 
    //                      $allThemesCount = lenta::GetLentaThemesCount($cms);
    ?>


<br/>
                        <?php 
    // Страницы
    $count = 4;
    $pages = ceil(($allWorkCount + $allThemesCount) / lenta::MAX_ON_PAGE);
    $html = '<div class="b-pager" >';
    if (is_array($count)) {
        list($scount, $ecount) = $count;
    } else {
        $scount = $ecount = $count;
    }
    if ($pages > 1) {
        $start = $page - $scount;
        if ($start < 1) {
            $start = 1;
        }
        $end = $page + $ecount;
        if ($end > $pages) {
            $end = $pages;
        }
        $html .= '<ul class="b-pager__back-next">';
        if ($page < $pages) {
            $html .= "<input type=\"hidden\" id=\"next_navigation_link1\" value=\"" . ($page + 1) . "\">";
            $html .= '<li class="b-pager__next" id="nav_next_not_active1"><a class="b-pager__link" href="javascript:void(0)" onClick="document.location.href=\'#lentatop\'; spiner.show(); xajax_Lenta_Show(' . ($page + 1) . '); return false;" id="PrevLink"></a>&nbsp;&nbsp;</li>';
        }
        if ($page > 1) {
            $html .= "<input type=\"hidden\" id=\"pre_navigation_link1\" value=\"" . ($page - 1) . "\">";
            $html .= '<li class="b-pager__back">&nbsp;&nbsp;<a id="NextLink" class="b-pager__link" href="javascript:void(0)" onClick="document.location.href=\'#lentatop\'; spiner.show(); xajax_Lenta_Show(' . ($page - 1) . '); return false;"></a></li>';
        }
        $html .= '</ul>';
        $html .= '<ul class="b-pager__list">';
        for ($i = $start; $i <= $end; $i++) {
            if ($i == $start && $start > 1) {
                $html .= '<li class="b-pager__item"><a class="b-pager__link" href="javascript:void(0)" onClick="document.location.href=\'#lentatop\'; spiner.show(); xajax_Lenta_Show(1); return false;">1</a></li>';
                if ($i == 3) {
                    $html .= '<li class="b-pager__item"><a class="b-pager__link" href="javascript:void(0)" onClick="document.location.href=\'#lentatop\'; spiner.show(); xajax_Lenta_Show(2); return false;">2</a></li>';
                } elseif ($i != 2) {
                    $html .= "<li class='b-pager__item'>&hellip;</li>";
                }
            }
            $html .= $page == $i ? '<li class="b-pager__item b-pager__item_active"><span class="b-pager__b1"><span class="b-pager__b2">' . $i . '</span></span></li>' : '<li class="b-pager__item"><a class="b-pager__link" href="javascript:void(0)" onClick="document.location.href=\'#lentatop\'; spiner.show(); xajax_Lenta_Show(' . $i . '); return false;">' . $i . '</a></li>';
            if ($i == $end && $pages - 1 > $end) {
                $html .= '<li class="b-pager__item">&hellip;</li>';
            }
        }
        $html .= '</ul>';
    }
    echo $html . '</div>';
    // Страницы закончились
    ?>
    	                  
          
<?php 
    $content = ob_get_contents();
    ob_end_clean();
    $content_js = '';
    if ($yt_replace_data) {
        foreach ($yt_replace_data as $key => $value) {
            $yt_replace_data[$key] = preg_replace("/^(.*)<script.*\$/sm", "\$1", $value);
            $content_js .= preg_replace("/^(.*<script type='text\\/javascript'>)(.*)(<\\/script>)\$/sm", "\$2", $value);
        }
        $content = preg_replace($yt_replace_id, $yt_replace_data, $content);
        $objResponse->script($content_js);
    }
    $objResponse->assign('lenta-cnt', 'innerHTML', $content);
    $objResponse->script($content_js);
    $objResponse->script('spiner.hide();');
    $objResponse->script('$$("#lenta_cats_checkboxes input[type=checkbox]").each(function(el) { el.set("disabled", false); });');
    $objResponse->script('fix_banner();');
    return $objResponse;
}
Example #9
0
            print $user->username . "<br>\n";
        }
    }
    exit;
}
$user = new User();
$user->id = $current_user->user_id;
if (get_misc_data('status_switch') == '1' && $user->read() && status_is_allowed($user) && $user->extra_field['status_switch']) {
    // Post an update (reply)
    if ($_POST['status']) {
        unset($_SESSION['status_error']);
        $_SESSION['status_text'] = $_POST['status'];
        if (!$isgod) {
            $text = sanitize($_POST['status'], 3);
        } else {
            $text = mysql_real_escape_string(close_tags($_POST['status']));
        }
        // Post to a group
        if (enable_group && ($groupname = strstr($text, '!'))) {
            $groupname = substr($groupname, 1);
            // Check if user is allowed to post to the group
            $groups = $db->get_results("SELECT * FROM " . table_groups . " WHERE group_status='Enable' ORDER BY group_name DESC");
            foreach ($groups as $group) {
                if (strpos($groupname, $group->group_name) === 0) {
                    $group_id = $group->group_id;
                    break;
                }
            }
            if ($group_id && isMemberActive($group_id) != 'active') {
                $_SESSION['status_error'] = '<div class="error_message">You are not a member of the group "' . $group->group_name . '"</div>';
            }
/**
 * Парсит HTML одной работы в портфолио
 * 
 * @param  array $aOne массив с данными комментария
 * @param  int $status статус: 0 - не проверенно, 1 - утверждено, 2 - удалено
 * @param  string $sKind опционально. тип записи
 * @param  array $aStream данные о потоке
 * @param  int $nCnt количество записей в потоке
 * @param  int $nContentId идентификатор сущности из admin_contents (фактический из потоков, то есть со сборными)
 * @return string HTML
 */
function _parsePortfolioOne($aOne = array(), $status = 0, $sKind = '0', $aStream = array(), $nCnt = 0, $nContentId = 0)
{
    global $stop_words, $user_content, $sTeam;
    $sReturn = '';
    $sAttach = '';
    if ($aOne['is_video'] == 't') {
        // работа есть видео
        if ($aOne['prev_pict']) {
            // есть отдельно загруженное превью
            $sInner = '<img src="' . WDCPREFIX . '/users/' . $aOne['login'] . '/upload/' . $aOne['prev_pict'] . '" alt="' . $aOne['prev_pict'] . '" title="' . $aOne['prev_pict'] . '" />';
        } else {
            // нет отдельно загруженного превью
            $sInner = $aOne['video_link'];
        }
        $sAttach = '<div class="b-post__txt b-post__txt_padbot_15 b-post__txt_fontsize_15"><strong>Ссылка на YouTube/RuTube/Vimeo видео:</strong> <br/><a href="http://' . $aOne['video_link'] . '" target="_blank">' . $sInner . '</a></div>';
    } elseif ($aOne['pict']) {
        // работа есть файл
        $ext = CFile::getext($aOne['pict']);
        $preview = $aOne['prev_pict'];
        $sPreview = '';
        if (in_array($ext, $GLOBALS['graf_array']) && $ext != 'swf') {
            // работа есть картинка
            if ($aOne['pict'] != substr($preview, 3, strlen($preview))) {
                // превью сделано не на основе оригинальной картинки либо вообще отсутствует
                $sInner = '<img src="' . WDCPREFIX . '/users/' . $aOne['login'] . '/upload/tn_' . $aOne['pict'] . '" alt="' . $aOne['pict'] . '" title="' . $aOne['pict'] . '" />';
                if ($preview) {
                    // превью загружено отдельно
                    $sPreview = 'Превью: <br/><img src="' . WDCPREFIX . '/users/' . $aOne['login'] . '/upload/' . $preview . '" alt="' . $preview . '" title="' . $preview . '" />';
                }
            } else {
                // превью сделано на основе оригинальной картинки
                $sInner = '<img src="' . WDCPREFIX . '/users/' . $aOne['login'] . '/upload/' . $preview . '" alt="' . $preview . '" title="' . $preview . '" />';
            }
        } else {
            //работа не есть картинка
            if ($preview) {
                // есть отдельно загруженное превью
                $sInner = '<img src="' . WDCPREFIX . '/users/' . $aOne['login'] . '/upload/' . $preview . '" alt="' . $preview . '" title="' . $preview . '" />';
            } else {
                // нет отдельно загруженного превью
                $sInner = 'Работа';
            }
        }
        $sAttach = '<div class="b-post__txt b-post__txt_padbot_15 b-post__txt_fontsize_15">
            <a href="' . WDCPREFIX . '/users/' . $aOne['login'] . '/upload/' . $aOne['pict'] . '" target="_blank">' . $sInner . '</a><br/>
            ' . $sPreview . '
            </div>';
    }
    $txt_cost = view_cost2($aOne['cost'], '', '', false, $aOne['cost_type']);
    $txt_time = view_time($aOne['time_value'], $aOne['time_type']);
    $is_txt_time = $txt_cost != '' && $txt_time != '';
    $sLink = $GLOBALS['host'] . '/users/' . $aOne['login'];
    $sLink2 = $aOne['link'] ? '<div class="b-post__txt b-post__txt_padbot_15 b-post__txt_fontsize_15"><strong>Ссылка:</strong> <br/><a href="' . $aOne['link'] . '" target="_blank">' . $aOne['link'] . '</a></div>' : '';
    $sTitle = $status != 1 ? $stop_words->replace(xmloutofrangechars($aOne['name'])) : xmloutofrangechars($aOne['name']);
    $sTitle = reformat($sTitle, 52, 0, 1);
    $aOne['descr'] = nl2br($aOne['descr']);
    // грязный хак так как close_tags стала съедать переносы строк
    $sMessage = close_tags($aOne['descr'], 'b,i,p,ul,li');
    $sMessage = $status != 1 ? $stop_words->replace(xmloutofrangechars($aOne['descr'])) : xmloutofrangechars($aOne['descr']);
    $sMessage = reformat($sMessage, 60, 0, 0, 1);
    $aOne['is_sent'] = '0';
    $aOne['context_code'] = '1';
    $aOne['context_link'] = $sLink;
    $aOne['context_title'] = $aOne['uname'] . ' ' . $aOne['usurname'] . ' [' . $aOne['login'] . ']';
    $sJSParams = "{'content_id': {$nContentId}, 'stream_id': '{$aStream['stream_id']}', 'content_cnt': {$nCnt}, 'status': {$status}, 'is_sent': '{$aOne['is_sent']}'}";
    $sEditIcon = _parseEditIcon('admEditPortfolio', $aOne['id'], $status, $sKind, $sJSParams);
    $bIsModer = $user_content->hasContentPermissions($nContentId, permissions::getUserPermissions($aOne['user_id']));
    $sModified = $aOne['moduser_id'] && ($aOne['moduser_id'] != $aOne['user_id'] || $bIsModer) ? '<div class="b-post__txt b-post__txt_padbot_15"><span style="color:red;">Работа была отредактирована. ' . ($aOne['modified_reason'] ? 'Причина: ' . $aOne['modified_reason'] : 'Без причины') . '</span></div>' : '';
    $sPRO = $aOne['moderator_status'] == -1 ? '<div class="b-post__txt b-post__txt_fontsize_11"><span style="color: #cc4642;">У пользователя был аккаунт PRO</span></div>' : '';
    $sPro = $aOne['is_pro'] == 't' ? view_pro2($aOne['is_pro_test'] == 't' ? true : false) . '&nbsp;' : '';
    $sReturn .= '
<div class="b-post b-post_bordtop_dfe3e4 b-post_padtop_15 b-post_marg_20_10" id="my_div_content_' . $aOne['content_id'] . '_' . $aOne['id'] . '_' . $sKind . '">
    ' . _parseHidden($aOne, $sKind) . '
    ' . _parseOkIcon($status, $aOne['content_id'], $aOne['id'], $sKind, $aOne['user_id']) . '
    ' . _parsePostTime($status, $aOne['post_time']) . '
    <div class="b-username b-username_padbot_5">' . ($aOne['is_team'] == 't' ? $sTeam : $sPro) . '<a class="b-username__link b-username__link_color_fd6c30 b-username__link_fontsize_11 b-username__link_bold" href="/users/' . $aOne['login'] . '" target="_blank">' . $aOne['uname'] . ' ' . $aOne['usurname'] . ' [' . $aOne['login'] . ']</a></div>
    ' . ($aOne['warn'] ? '<div class="b-username_padbot_5"><a onclick="parent.user_content.getUserWarns(' . $aOne['user_id'] . ');" href="javascript:void(0);" class="notice">Предупреждения:&nbsp;<span id="warn_' . $aOne['user_id'] . '_' . $aOne['content_id'] . '_' . $aOne['id'] . '">' . intval($aOne['warn']) . '</span></a></div>' : '<div class="b-username_padbot_5 user-notice">Предупреждений нет</div>') . '
    ' . $sPRO . '
    ' . _parseMass($aOne, $status, $sKind) . '
    <div class="b-post__txt b-post__txt_padbot_10 b-post__txt_fontsize_15"><span class="b-post__bold">Новая работа:</span> <a class="b-post__link b-post__link_fontsize_15" href="/users/' . $aOne['login'] . '/viewproj.php?prjid=' . $aOne['id'] . '" target="_blank">' . $sTitle . '</a></div>
    <div class="b-post__txt b-post__txt_fontsize_15">' . $sMessage . '</div>
    <div class="b-post__txt b-post__txt_fontsize_15">' . $txt_cost . ($is_txt_time ? ', ' : '') . ($txt_time != '' ? $txt_time : '') . '</div>

    ' . $sAttach . '
    ' . $sLink2 . '

    ' . $sModified . '
    ' . _parseDelIcons($aOne, 'user_id', $status, $sKind, $sJSParams, $sEditIcon) . '
</div>';
    return $sReturn;
}
Example #11
0
 function truncate_content()
 {
     if (utf8_strlen($this->content) > StorySummary_ContentTruncate) {
         if (Auto_scroll == true) {
             global $main_smarty;
             $content = close_tags(utf8_substr($this->content, 0, StorySummary_ContentTruncate));
             $content .= "<div class=\"read_more_article\" storyid=\"" . $this->id . "\" > " . $main_smarty->get_config_vars('PLIGG_Visual_Read_More') . "</div>";
             $content .= "<div class=\"read_more_story" . $this->id . " hide\" >";
             $content .= close_tags(utf8_substr($this->content, StorySummary_ContentTruncate, utf8_strlen($this->content)));
             $content .= "</div>";
             // echo $content;
             return $content;
         } else {
             return close_tags(utf8_substr($this->content, 0, StorySummary_ContentTruncate)) . "...";
         }
     }
     return $this->content;
 }
Example #12
0
                    }
                }
                $p += strlen($m[0]);
            } else {
                $p++;
            }
        }
        foreach ($open as $tag => $p) {
            if ($p > 0) {
                $s .= "</" . $tag . ">";
            }
        }
    }
    foreach ($posts as $post) {
        $message = nl2br(mb_substr($post->content, 0, 500));
        close_tags($message, '(.+)');
        echo '<li>' . html::anchor('post/' . $post->url . '-' . $post->id, '<h3>&laquo;' . $post->title . '&raquo; &mdash; ' . $post->posted . ', ' . $post->username . '</h3>') . '</li>';
        echo '<li>' . $message . '...</li>';
        echo '<li>&nbsp;</li>';
        echo '<li>' . ($post->allowcomment == 1 ? '<i>Комментариев: ' . $model->get_count($post->id) . '</i>' : '<i>Комментирование запрещено</i>') . '</li>';
        echo '<li>' . html::anchor('post/' . $post->url . '-' . $post->id, 'Читать далее') . '</li>';
        echo '<li>&nbsp;</li><li>&nbsp;</li><li>&nbsp;</li>';
    }
} else {
    echo 'Нет сообщений';
}
?>
    </ul>
    <div class="pagination"><center><?php 
echo $pagination;
?>
Example #13
0
function clean_text_with_tags($string, $wrap=0, $replace_nl=true, $maxlength=0) {
	$string = add_tags(clean_text($string, $wrap, $replace_nl, $maxlength));
	$string = preg_replace_callback('/(?:&lt;|<)(\/{0,1})(\w{1,6})(?:&gt;|>)/', 'enable_tags_callback', $string);
	$string = close_tags($string);
	$string = preg_replace('/<\/(\w{1,6})>( *)<(\1)>/', "$2", $string); // Deletes useless close+open tags
	//$string = preg_replace('/<(\/{0,1}\w{1,6})>( *)<(\1)>/', "<$1>$2", $string); // Deletes repeated tags
	return $string;
}
Example #14
0
        echo $post['title'];
        ?>
</a></h3>
                <div class="date">
                    <p>
                        <span><?php 
        echo mysql_human_date($post['updated_time']);
        ?>
</span>
                        <span style="margin-left:35px;"><?php 
        echo mysql_human_time($post['updated_time']);
        ?>
</span>
                    </p>
                </div>
                <?php 
        echo close_tags(word_limiter($post['body']));
        ?>
                <a class="margin_left_15" style="font-weight:bold" href="<?php 
        echo site_url('p/' . $post['post_name']);
        ?>
">read more</a>
            </div>
        <?php 
    }
    ?>
    <?php 
}
?>
</div>
 if ($linkres->title != stripslashes(sanitize($_POST['title'], 3))) {
     $linkres->title = stripslashes(sanitize($_POST['title'], 3));
     $linkres->title_url = makeUrlFriendly($linkres->title, $linkres->id);
 }
 $linkres->content = close_tags(sanitize($_POST['bodytext'], 4, $Story_Content_Tags_To_Allow));
 $linkres->tags = tags_normalize_string(stripslashes(sanitize($_POST['tags'], 3)));
 if (sanitize($_POST['summarytext'], 3) == "") {
     $linkres->link_summary = utf8_substr(sanitize($_POST['bodytext'], 4, $Story_Content_Tags_To_Allow), 0, StorySummary_ContentTruncate - 1);
     $linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary));
 } else {
     $linkres->link_summary = sanitize($_POST['summarytext'], 4, $Story_Content_Tags_To_Allow);
     $linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary));
     if (utf8_strlen($linkres->link_summary) > StorySummary_ContentTruncate) {
         loghack('SubmitAStory-SummaryGreaterThanLimit', 'username: '******'|email: ' . sanitize($_POST["email"], 3), true);
         $linkres->link_summary = utf8_substr($linkres->link_summary, 0, StorySummary_ContentTruncate - 1);
         $linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary));
     }
 }
 $linkres->content = str_replace("\n", "<br />", $linkres->content);
 //to store edited attributes
 $linkres->edit_store();
 $story_url = $linkres->get_url();
 echo $story_url;
 //
 if (link_errors($linkres)) {
     echo "this is wrong";
     //header('Location: ' . $linkres->getmyurl());
     return;
 }
 header("Location: " . $story_url);
 //	tags_insert_string($linkres->id, $dblang, $linkres->tags);
Example #16
0
	function print_text($length = 0, $html_id=false) {
		global $current_user, $globals;

		if (!$html_id) $html_id = $this->id;

		if (!$this->basic_summary && (
					($this->author == $current_user->user_id && $globals['now'] - $this->date < $globals['comment_edit_time']) 
					|| (($this->author != $current_user->user_id || $this->type == 'admin')
					&& $current_user->user_level == 'god')) ) { // gods can always edit 
			$expand = '&nbsp;&nbsp;<a href="javascript:get_votes(\'comment_edit.php\',\'edit_comment\',\'c-'.$html_id.'\',0,'.$this->id.')" title="'._('editar comentario').'"><img class="mini-icon-text" src="'.$globals['base_static'].'img/common/edit-misc01.png" alt="edit" width="18" height="12"/></a>';

		} 
		if ($length > 0 && mb_strlen($this->content) > $length + $length/2) {

			$this->content = preg_replace('/[&<\{]\w*$/', '', mb_substr($this->content, 0 , $length));
			// Check all html tags are closed
			if (preg_match('/<\w+>/', $this->content)) {
				$this->content = close_tags($this->content);
			}
			$this->content = preg_replace('/&\w*$|<\w{1,6}>([^<>]*)$/', "$1", mb_substr($this->content, 0 , $length));
			$expand .= '&nbsp;&nbsp;' .
				'<a href="javascript:get_votes(\'get_comment.php\',\'comment\',\'cid-'.$this->id.'\',0,'.$this->id.')" title="'._('resto del comentario').'">&#187;&nbsp;'._('ver todo el comentario').'</a>';
		}

		echo put_smileys($this->put_comment_tooltips(save_text_to_html($this->content, 'comments'))) . $expand;
		echo "\n";
	}
/**
 * Сохранение профиля юзера
 * 
 * @param object $objResponse xajaxResponse
 * @param string $rec_id идентификатор записи
 * @param string $rec_type тип записи
 * @param array $aForm массив данных
 * @param string $sDrawFunc имя функции для выполнения после сохранения
 */
function _admEditProfileSaveForm(&$objResponse, $rec_id = '', $rec_type = '', $aForm = array(), $sDrawFunc = '')
{
    $error = '';
    $bNew = true;
    setlocale(LC_ALL, 'ru_RU.CP1251');
    switch ($aForm['p_ucolumn']) {
        case 'uname':
            $new_val = change_q(substr(trim($aForm['new_val']), 0, 21), true);
            if (!preg_match("/^[-a-zA-Zа-яёА-ЯЁ]+\$/", $new_val)) {
                $error = 'Поле заполнено некорректно';
            }
            break;
        case 'usurname':
            $new_val = change_q(substr(trim($aForm['new_val']), 0, 21), true);
            if (!preg_match("/^[-a-zA-Zа-яёА-ЯЁ]+\$/", $new_val)) {
                $error = 'Поле заполнено некорректно';
            }
            break;
        case 'pname':
            $new_val = change_q(substr(trim(stripslashes($aForm['new_val'])), 0, 100), true);
            break;
        case 'spec_text':
            $ab_text_max_length = 500;
            $new_val = stripslashes(trim($aForm['new_val']));
            $new_val = preg_replace("|[\t]+|", " ", $new_val);
            $new_val = preg_replace("|[ ]+|", " ", $new_val);
            $original_text = $new_val;
            $newlines = intval(substr_count($new_val, "\r"));
            $new_val = change_q_x_a(substr($new_val, 0, $ab_text_max_length + $newlines), false, false, "b|i|p|ul|li{1}");
            if (strlen($original_text) > $ab_text_max_length + $newlines) {
                $error = 'Допустимо максимум ' . $ab_text_max_length . ' знаков.';
            }
            break;
        case 'resume_file':
        case 'photo':
        case 'logo':
            $del_file = intval($aForm['del_file']);
            $dir = $aForm['login'];
            $dir2 = $aForm['p_ucolumn'] == 'resume_file' ? 'resume' : ($aForm['p_ucolumn'] == 'photo' ? 'foto' : 'logo');
            if ($del_file || $aForm['new_val']) {
                $new_val = $del_file ? '' : substr(change_q_new(trim(stripslashes($aForm['new_val']))), 0, 1500);
                if ($aForm['old_val']) {
                    $oCFile = new CFile();
                    $oCFile->Delete(0, 'users/' . substr($dir, 0, 2) . '/' . $dir . '/' . $dir2 . '/', $aForm['old_val']);
                    if ($aForm['p_ucolumn'] == 'photo' || $aForm['p_ucolumn'] == 'logo') {
                        $oCFile->Delete(0, 'users/' . substr($dir, 0, 2) . '/' . $dir . '/' . $dir2 . '/', 'sm_' . $aForm['old_val']);
                    }
                }
            } else {
                // админ нажал "Сохранить" не зааплоадив файл - считаем что утвердил тот что есть
                $bNew = false;
            }
            break;
        case 'resume':
            $new_val = str_replace("\r\n", "\r", $aForm['new_val']);
            if (strlen($new_val) > 4000) {
                $error = 'Допустимо максимум 4000 знаков.';
            }
            $new_val = change_q(substr(trim($new_val), 0, 4000), false, 25);
            break;
        case 'konk':
            if (strlen($aForm['new_val']) > 4000) {
                $error = 'Допустимо максимум 4000 знаков.';
            }
            $new_val = change_q(substr(trim($aForm['new_val']), 0, 4000), false, 90);
            break;
        case 'company':
            if (strlen($aForm['new_val']) > 500) {
                $error = 'Допустимо максимум 500 знаков.';
            }
            $new_val = substr(change_q_x($aForm['new_val'], false, true, null, false, false), 0, 500);
            break;
        case 'status_text':
            $new_val = addslashes(substr(stripslashes(trim($aForm['new_val'])), 0, 200));
            close_tags($new_val, 's');
            $new_val = htmlspecialchars(htmlspecialchars_decode(change_q_x(trim($new_val), true, false), ENT_QUOTES), ENT_QUOTES);
            break;
        case 'compname':
            $new_val = change_q_x($aForm['new_val'], true);
            break;
        default:
            setlocale(LC_ALL, 'en_US.UTF-8');
            return false;
            break;
    }
    setlocale(LC_ALL, 'en_US.UTF-8');
    if (!$error) {
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/messages.php';
        if ($bNew) {
            $sReason = _parseReason($rec_id, $aForm['adm_edit_text']);
            messages::profileModifiedNotification($rec_id, $aForm['p_ucolumn'], $aForm['p_utable'], $sReason);
            if ($sDrawFunc == 'stream0' || $sDrawFunc == 'stream1' || $sDrawFunc == 'stream2') {
                user_content::editProfile($aForm['p_change_id'], $new_val);
            }
        }
        $objResponse->script('adm_edit_content.cancel();');
        if ($sDrawFunc == 'stream0' || $sDrawFunc == 'stream1' || $sDrawFunc == 'stream2') {
            $objResponse->script('parent.adm_edit_content.cancel();');
            resolveContent($aForm['p_content_id'], $aForm['p_stream_id'], user_content::MODER_PROFILE . '_' . $aForm['p_change_id'] . '_0', 1, $rec_id, $aForm['p_content_cnt'], $aForm['p_status'], $aForm['p_is_sent'], '', $objResponse);
        } else {
            // действие после редактирования по умолчанию
            if ($bNew) {
                require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/' . $aForm['p_utable'] . '.php';
                $user = new $aForm['p_utable']();
                $user->{$aForm}['p_ucolumn'] = $new_val;
                $user->moduser_id = $_SESSION['uid'];
                $user->Update($rec_id, $res);
            }
            if ($sDrawFunc == 'suspect') {
                // шерстим все профили на наличие контактов в админке
                $objResponse->script("window.location = '/siteadmin/suspicious_contacts/?site={$aForm['p_site']}&action=resolve&sid={$aForm['p_sid']}&page={$aForm['p_page']}'");
                return 0;
            }
            $objResponse->script('window.location.reload(true)');
        }
    } else {
        $sParent = $sDrawFunc == 'stream0' || $sDrawFunc == 'stream1' || $sDrawFunc == 'stream2' ? 'parent.' : '';
        $objResponse->script("{$sParent}\$('adm_edit_err_new_val').set('html', '{$error}');");
        $objResponse->script("{$sParent}\$('div_adm_edit_err_new_val').setStyle('display', '');");
        $objResponse->script("{$sParent}adm_edit_content.disabled = false; {$sParent}adm_edit_content.button();");
    }
}
Example #18
0
function do_submit2()
{
    global $db, $main_smarty, $dblang, $the_template, $linkres, $current_user, $Story_Content_Tags_To_Allow;
    $main_smarty->assign('auto_vote', auto_vote);
    $main_smarty->assign('Submit_Show_URL_Input', Submit_Show_URL_Input);
    $main_smarty->assign('Submit_Require_A_URL', Submit_Require_A_URL);
    $main_smarty->assign('link_id', sanitize($_POST['id'], 3));
    define('pagename', 'submit');
    $main_smarty->assign('pagename', pagename);
    if ($current_user->authenticated != TRUE) {
        $vars = array('username' => $current_user->user_login);
        check_actions('register_check_errors', $vars);
    }
    check_actions('submit2_check_errors', $vars);
    if ($vars['error'] == true) {
        // No action
    }
    $linkres = new Link();
    $linkres->id = sanitize($_POST['id'], 3);
    if ($_SESSION['step'] != 1) {
        die('Wrong step');
    }
    if (!is_numeric($linkres->id)) {
        die;
    }
    if (!$linkres->verify_ownership($current_user->user_id)) {
        die($main_smarty->get_config_vars('PLIGG_Visual_Submit2Errors_NoAccess'));
    }
    $linkres->read(FALSE);
    if ($linkres->votes($current_user->user_id) == 0 && auto_vote == true) {
        $linkres->insert_vote($current_user->user_id, '10');
        $linkres->store_basic();
        $linkres->read(FALSE);
    }
    if (is_array($_POST['category'])) {
        $linkres->category = sanitize($_POST['category'][0], 3);
        $linkres->additional_cats = array_slice($_POST['category'], 1);
    } else {
        $linkres->category = sanitize($_POST['category'], 3);
    }
    $thecat = get_cached_category_data('category_id', $linkres->category);
    $main_smarty->assign('request_category_name', $thecat->category_name);
    $linkres->title = stripslashes(sanitize($_POST['title'], 3));
    $linkres->title_url = makeUrlFriendly($linkres->title, $linkres->id);
    $linkres->tags = tags_normalize_string(stripslashes(sanitize($_POST['tags'], 3)));
    $linkres->content = close_tags(stripslashes(sanitize($_POST['bodytext'], 4, $Story_Content_Tags_To_Allow)));
    //$linkres->content = str_replace("\n", "<br />", $linkres->content);
    if (isset($_POST['link_field1'])) {
        $linkres->link_field1 = sanitize($_POST['link_field1'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field2'])) {
        $linkres->link_field2 = sanitize($_POST['link_field2'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field3'])) {
        $linkres->link_field3 = sanitize($_POST['link_field3'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field4'])) {
        $linkres->link_field4 = sanitize($_POST['link_field4'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field5'])) {
        $linkres->link_field5 = sanitize($_POST['link_field5'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field6'])) {
        $linkres->link_field6 = sanitize($_POST['link_field6'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field7'])) {
        $linkres->link_field7 = sanitize($_POST['link_field7'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field8'])) {
        $linkres->link_field8 = sanitize($_POST['link_field8'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field9'])) {
        $linkres->link_field9 = sanitize($_POST['link_field9'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field10'])) {
        $linkres->link_field10 = sanitize($_POST['link_field10'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field11'])) {
        $linkres->link_field11 = sanitize($_POST['link_field11'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field12'])) {
        $linkres->link_field12 = sanitize($_POST['link_field12'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field13'])) {
        $linkres->link_field13 = sanitize($_POST['link_field13'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field14'])) {
        $linkres->link_field14 = sanitize($_POST['link_field14'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field15'])) {
        $linkres->link_field15 = sanitize($_POST['link_field15'], 4, $Story_Content_Tags_To_Allow);
    }
    if (!isset($_POST['summarytext'])) {
        $linkres->link_summary = utf8_substr(sanitize($_POST['bodytext'], 4, $Story_Content_Tags_To_Allow), 0, StorySummary_ContentTruncate - 1);
        //$linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary));
    } else {
        $linkres->link_summary = sanitize($_POST['summarytext'], 4, $Story_Content_Tags_To_Allow);
        //$linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary));
        if (utf8_strlen($linkres->link_summary) > StorySummary_ContentTruncate) {
            loghack('SubmitAStory-SummaryGreaterThanLimit', 'username: '******'|email: ' . sanitize($_POST["email"], 3), true);
            $linkres->link_summary = utf8_substr($linkres->link_summary, 0, StorySummary_ContentTruncate - 1);
            //$linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary));
        }
    }
    //get link_group_id
    if (isset($_REQUEST['link_group_id']) && $_REQUEST['link_group_id'] != '') {
        $linkres->link_group_id = intval($_REQUEST['link_group_id']);
    } else {
        $linkres->link_group_id = 0;
    }
    $linkres->store();
    if (link_errors($linkres)) {
        return;
    }
    //comment subscription
    if (isset($_POST['comment_subscription'])) {
        $vars = array('link_id' => $linkres->id);
        check_actions('comment_subscription_insert_function', $vars);
    }
    //comment subscription
    if (isset($_POST['timestamp_date_day'])) {
        //open date
        $timestamp_date_day = $_POST['timestamp_date_day'];
        $timestamp_date_month = $_POST['timestamp_date_month'];
        $timestamp_date_year = $_POST['timestamp_date_year'];
        if (!is_numeric($timestamp_date_day) || !is_numeric($timestamp_date_month) || !is_numeric($timestamp_date_year)) {
            $timestamp_date = date("m-d-Y");
        } else {
            $timestamp_date = $timestamp_date_month . "-" . $timestamp_date_day . "-" . $timestamp_date_year;
        }
        $vars = array('link_id' => $linkres->id);
        $vars = array('timestamp_date' => $timestamp_date, 'link_id' => $linkres->id);
        check_actions('comment_subscription_insert_function', $vars);
    }
    $vars = '';
    check_actions('submit_step_3_after_first_store', $vars);
    if ($vars['error'] == true && link_catcha_errors('captcha_error')) {
        return;
    }
    $linkres->read(FALSE);
    $edit = true;
    $link_title = $linkres->title;
    $link_content = $linkres->content;
    $link_title = stripslashes(sanitize($_POST['title'], 3));
    $main_smarty->assign('the_story', $linkres->print_summary('full', true));
    $main_smarty->assign('tags', $linkres->tags);
    if (!empty($linkres->tags)) {
        $tags_words = str_replace(",", ", ", $linkres->tags);
        $tags_url = urlencode($linkres->tags);
        $main_smarty->assign('tags_words', $tags_words);
        $main_smarty->assign('tags_url', $tags_url);
    }
    if (isset($url)) {
        $main_smarty->assign('submit_url', $url);
    } else {
        $main_smarty->assign('submit_url', '');
    }
    $data = parse_url($linkres->url);
    $main_smarty->assign('url_short', $data['host']);
    $main_smarty->assign('submit_url_title', $linkres->url_title);
    $main_smarty->assign('submit_id', $linkres->id);
    $main_smarty->assign('submit_type', $linkres->type());
    $main_smarty->assign('submit_title', str_replace('"', "&#034;", $link_title));
    $main_smarty->assign('submit_content', $link_content);
    if (isset($trackback)) {
        $main_smarty->assign('submit_trackback', $trackback);
    } else {
        $main_smarty->assign('submit_trackback', '');
    }
    $main_smarty->assign('tpl_extra_fields', $the_template . '/submit_extra_fields');
    $main_smarty->assign('tpl_center', $the_template . '/submit_step_3_center');
    $vars = '';
    check_actions('do_submit2', $vars);
    $_SESSION['step'] = 2;
    if (Submit_Complete_Step2) {
        do_submit3();
    } else {
        $main_smarty->display($the_template . '/pligg.tpl');
    }
}
Example #19
0
function fixup_quotes($string)
{
    // skip the whole thing when there are no quotes
    if (!(strchr($string, '[quote]') || strchr($string, '[/quote]'))) {
        return $string;
    }
    $tmp = $string;
    $s_pos = 0;
    // $s_pos is position in $string
    $t_pos = 0;
    // $t_pos is position in $tmp
    $tags = new CStack();
    while (is_integer($t_pos = strpos($tmp, '['))) {
        $s_pos += $t_pos + 1;
        $tmp = substr($tmp, $t_pos + 1);
        $endpos = strpos($tmp, ']');
        if (is_integer($endpos)) {
            $curtag = substr($tmp, 0, $endpos);
            switch ($curtag) {
                case 'quote':
                    $tags->push($curtag);
                    break;
                case '/quote':
                    close_tags($tags, $s_pos, $string, substr($curtag, 1));
                    break;
                default:
                    //ttt: don't be fooled by [[quote] stuff
                    $endpos = -1;
                    break;
            }
            $s_pos += $endpos + 1;
            $tmp = substr($string, $s_pos);
        }
    }
    // if there are still some endtags missing, add them at the end
    $s_pos = strlen($string) + 1;
    // normally this should be -1, but close_tags moves back 2 chars
    close_tags($tags, $s_pos, $string);
    return $string;
}
Example #20
0
function shorten_text($text, $maxlen = 200)
{
    $html_text = $text;
    $text = replace('<*>', '', $text);
    $tags = $html_text != $text;
    $shorten = false;
    if (strlen8($text) > $maxlen) {
        $shorten = true;
        $otext = $text;
        $text = substr8($text, 0, $maxlen);
        if (!trim($text)) {
            $text = $otext;
        }
        if ($p = strrpos($text, " ") and $p * 2 > strlen($text)) {
            $text = substr($text, 0, $p);
        }
    }
    if ($tags and $shorten) {
        $p = 0;
        $hp = 0;
        while ($p < strlen($text)) {
            if ($text[$p] == $html_text[$hp]) {
                $p++;
                $hp++;
                continue;
            }
            $hp2 = strpos($html_text, '>', $hp) + 1;
            $tag = substr($html_text, $hp, $hp2 - $hp);
            $hp = $hp2;
            $text = substr($text, 0, $p) . $tag . substr($text, $p);
            $p += strlen($tag);
        }
        $text = close_tags($text);
    }
    if ($shorten) {
        $text .= " ...";
    }
    re($text);
    return $text;
}
Example #21
0
 function truncate_content()
 {
     if (utf8_strlen($this->content) > StorySummary_ContentTruncate) {
         return close_tags(utf8_substr($this->content, 0, StorySummary_ContentTruncate)) . "...";
     }
     return $this->content;
 }
Example #22
0
function get_short_txt($text, $length = 100)
{
    $text = strip_tags($text);
    return close_tags(mb_substr($text, 0, $length)) . '...';
}