Exemplo n.º 1
0
 function user_title($count, $title)
 {
     global $config;
     if ($count and dle_strlen($title, $config['charset']) > $count) {
         $title = dle_substr($title, 0, $count, $config['charset']);
         if ($temp_dmax = dle_strrpos($title, ' ', $config['charset'])) {
             $title = dle_substr($title, 0, $temp_dmax, $config['charset']);
         }
     }
     return $title;
 }
Exemplo n.º 2
0
 /**
  * @param        $data    - контент
  * @param        $limit
  * @param string $etc     - Окончание обрезанного текста
  * @param bool   $wordcut - жесткое ограничение символов
  *
  * @param string $charset
  *
  * @return string $data - обрезанный результат
  */
 public static function textLimit($data, $limit, $etc = '…', $wordcut = false, $charset = 'utf-8')
 {
     $data = strip_tags($data, '<br>');
     $data = trim(str_replace(['<br>', '<br />'], ' ', $data));
     if ($limit && dle_strlen($data, $charset) > $limit) {
         $data = dle_substr($data, 0, $limit, $charset) . $etc;
         if (!$wordcut && ($word_pos = dle_strrpos($data, ' ', $charset))) {
             $data = dle_substr($data, 0, $word_pos, $charset) . $etc;
         }
     }
     return $data;
 }
Exemplo n.º 3
0
function check_name($name)
{
    global $lang, $db, $banned_info, $relates_word, $config;
    $stop = '';
    $name = urldecode($name);
    if (dle_strlen($name, $config['charset']) > 30 or dle_strlen(trim($name), $config['charset']) < 3) {
        $stop .= $lang['reg_err_3'];
    }
    if (preg_match("/[\\||\\'|\\<|\\>|\\[|\\]|\"|\\!|\\?|\$|\\@|\\/|\\\\|\\&\\~\\*\\{\\+]/", $name)) {
        $stop .= $lang['reg_err_4'];
    }
    if (stripos(urlencode($name), "%AD") !== false) {
        $stop .= $lang['reg_err_4'];
    }
    if (strpos(strtolower($name), '.php') !== false) {
        $stop .= $lang['reg_err_4'];
    }
    if (count($banned_info['name'])) {
        foreach ($banned_info['name'] as $banned) {
            $banned['name'] = str_replace('\\*', '.*', preg_quote($banned['name'], "#"));
            if ($banned['name'] and preg_match("#^{$banned['name']}\$#i", $name)) {
                if ($banned['descr']) {
                    $lang['reg_err_21'] = str_replace("{descr}", $lang['reg_err_22'], $lang['reg_err_21']);
                    $lang['reg_err_21'] = str_replace("{descr}", $banned['descr'], $lang['reg_err_21']);
                } else {
                    $lang['reg_err_21'] = str_replace("{descr}", "", $lang['reg_err_21']);
                }
                $stop .= $lang['reg_err_21'];
            }
        }
    }
    if (!$stop) {
        if (function_exists('mb_strtolower')) {
            $name = trim(mb_strtolower($name, $config['charset']));
        } else {
            $name = trim(strtolower($name));
        }
        $search_name = strtr($name, $relates_word);
        $db->query("SELECT name FROM " . USERPREFIX . "_users WHERE LOWER(name) REGEXP '[[:<:]]{$search_name}[[:>:]]' OR name = '{$name}'");
        if ($db->num_rows() > 0) {
            $stop .= $lang['reg_err_20'];
        }
    }
    if (!$stop) {
        return false;
    } else {
        return $stop;
    }
}
Exemplo n.º 4
0
         } else {
             $tpl->copy_template = preg_replace("'\\[xfnotgiven_{$preg_safe_name}\\](.*?)\\[/xfnotgiven_{$preg_safe_name}\\]'is", "", $tpl->copy_template);
             $tpl->copy_template = str_replace("[xfgiven_{$value[0]}]", "", $tpl->copy_template);
             $tpl->copy_template = str_replace("[/xfgiven_{$value[0]}]", "", $tpl->copy_template);
         }
         $xfieldsdata[$value[0]] = stripslashes($xfieldsdata[$value[0]]);
         if ($config['allow_links'] and $value[3] == "textarea" and function_exists('replace_links')) {
             $xfieldsdata[$value[0]] = replace_links($xfieldsdata[$value[0]], $replace_links['news']);
         }
         $tpl->copy_template = str_replace("[xfvalue_{$value[0]}]", $xfieldsdata[$value[0]], $tpl->copy_template);
         if (preg_match("#\\[xfvalue_{$preg_safe_name} limit=['\"](.+?)['\"]\\]#i", $tpl->copy_template, $matches)) {
             $count = intval($matches[1]);
             $xfieldsdata[$value[0]] = str_replace("</p><p>", " ", $xfieldsdata[$value[0]]);
             $xfieldsdata[$value[0]] = strip_tags($xfieldsdata[$value[0]], "<br>");
             $xfieldsdata[$value[0]] = trim(str_replace("<br>", " ", str_replace("<br />", " ", str_replace("\n", " ", str_replace("\r", "", $xfieldsdata[$value[0]])))));
             if ($count and dle_strlen($xfieldsdata[$value[0]], $config['charset']) > $count) {
                 $xfieldsdata[$value[0]] = dle_substr($xfieldsdata[$value[0]], 0, $count, $config['charset']);
                 if ($temp_dmax = dle_strrpos($xfieldsdata[$value[0]], ' ', $config['charset'])) {
                     $xfieldsdata[$value[0]] = dle_substr($xfieldsdata[$value[0]], 0, $temp_dmax, $config['charset']);
                 }
             }
             $tpl->set($matches[0], $xfieldsdata[$value[0]]);
         }
     }
 }
 $category_id = $row['category'];
 $tpl->compile('content');
 if ($user_group[$member_id['user_group']]['allow_hide']) {
     $tpl->result['content'] = str_ireplace("[hide]", "", str_ireplace("[/hide]", "", $tpl->result['content']));
 } else {
     $tpl->result['content'] = preg_replace("#\\[hide\\](.+?)\\[/hide\\]#ims", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $tpl->result['content']);
Exemplo n.º 5
0
function create_metatags($story)
{
    global $config, $db;
    $keyword_count = 20;
    $newarr = array();
    $headers = array();
    $quotes = array("\"", "`", "\t", '\\n', '\\r', "\n", "\r", '\\', ",", ".", "/", "¬", "#", ";", ":", "@", "~", "[", "]", "{", "}", "=", "-", "+", ")", "(", "*", "^", "%", "\$", "<", ">", "?", "!", '"');
    $fastquotes = array("\"", "`", "\t", "\n", "\r", '"', '\\r', '\\n', "\$", "{", "}", "[", "]", "<", ">");
    $story = preg_replace("#\\[hide\\](.+?)\\[/hide\\]#is", "", $story);
    $story = preg_replace("'\\[attachment=(.*?)\\]'si", "", $story);
    $story = preg_replace("'\\[page=(.*?)\\](.*?)\\[/page\\]'si", "", $story);
    $story = str_replace("{PAGEBREAK}", "", $story);
    $story = str_replace("&nbsp;", " ", $story);
    $story = str_replace('<br />', ' ', $story);
    $story = strip_tags($story);
    $story = preg_replace("#&(.+?);#", "", $story);
    $story = trim(str_replace(" ,", "", $story));
    if (trim($_REQUEST['meta_title']) != "") {
        $headers['title'] = trim(htmlspecialchars(strip_tags(stripslashes($_REQUEST['meta_title']))));
        $headers['title'] = $db->safesql(str_replace($fastquotes, '', $headers['title']));
    } else {
        $headers['title'] = "";
    }
    if (trim($_REQUEST['descr']) != "") {
        $headers['description'] = dle_substr(strip_tags(stripslashes($_REQUEST['descr'])), 0, 190, $config['charset']);
        $headers['description'] = $db->safesql(str_replace($fastquotes, '', $headers['description']));
    } else {
        $story = str_replace($fastquotes, '', $story);
        $headers['description'] = $db->safesql(dle_substr(stripslashes($story), 0, 190, $config['charset']));
    }
    if (trim($_REQUEST['keywords']) != "") {
        $headers['keywords'] = $db->safesql(str_replace($fastquotes, " ", strip_tags(stripslashes($_REQUEST['keywords']))));
    } else {
        $story = str_replace($quotes, ' ', $story);
        $arr = explode(" ", $story);
        foreach ($arr as $word) {
            if (dle_strlen($word, $config['charset']) > 4) {
                $newarr[] = $word;
            }
        }
        $arr = array_count_values($newarr);
        arsort($arr);
        $arr = array_keys($arr);
        $total = count($arr);
        $offset = 0;
        $arr = array_slice($arr, $offset, $keyword_count);
        $headers['keywords'] = $db->safesql(implode(", ", $arr));
    }
    return $headers;
}
Exemplo n.º 6
0
		/**
		 * @param $data - контент
		 * @param $length - максимальный размер возвращаемого контента
		 * 
		 * @return $data - обрезанный результат 
		 */
		public function textLimit($data, $count)
		{
			if ($this->config['text_limit'] != '0') 
			{	
				$data = strip_tags($data, '<br>');
				$data = trim(str_replace( array('<br>','<br />'), ' ', $data));

				if($count && dle_strlen($data, $this->dle_config['charset'] ) > $count)
				{
					$data = dle_substr( $data, 0, $count, $this->dle_config['charset'] ). '&hellip;';					
					if( !$this->config['wordcut'] && ($word_pos = dle_strrpos( $data, ' ', $this->dle_config['charset'] )) ) 
						$data = dle_substr( $data, 0, $word_pos, $this->dle_config['charset'] ). '&hellip;';

				}
			}
			return $data;
		}
Exemplo n.º 7
0
    } else {
        $full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
    }
    $row['title'] = stripslashes($row['title']);
    if (dle_strlen($row['title'], $config['charset']) > 43) {
        $title = dle_substr($row['title'], 0, 43, $config['charset']) . " ...";
    } else {
        $title = $row['title'];
    }
    $row['short_story'] = trim(htmlspecialchars(strip_tags(stripslashes(str_replace(array("<br />", "&nbsp;"), " ", $row['short_story']))), ENT_QUOTES, $config['charset']));
    if ($user_group[$member_id['user_group']]['allow_hide']) {
        $row['short_story'] = str_ireplace("[hide]", "", str_ireplace("[/hide]", "", $row['short_story']));
    } else {
        $row['short_story'] = preg_replace("#\\[hide\\](.+?)\\[/hide\\]#is", "", $row['short_story']);
    }
    if (dle_strlen($row['short_story'], $config['charset']) > 150) {
        $description = dle_substr($row['short_story'], 0, 150, $config['charset']) . " ...";
    } else {
        $description = $row['short_story'];
    }
    $description = str_replace('&amp;', '&', $description);
    $description = preg_replace("'\\[attachment=(.*?)\\]'si", "", $description);
    $buffer .= "<a href=\"" . $full_link . "\"><span class=\"searchheading\">" . stripslashes($title) . "</span>";
    $buffer .= "<span>" . $description . "</span></a>";
}
if (!$buffer) {
    $buffer .= "<span class=\"notfound\">{$lang['related_not_found']}</span>";
}
$buffer .= '<span class="seperator"><a href="' . $config['http_home_url'] . '?do=search&amp;mode=advanced&amp;subaction=search&amp;story=' . $query . '">' . $lang['s_ffullstart'] . '</a></span><br class="break" />';
@header("Content-type: text/html; charset=" . $config['charset']);
echo $buffer;
Exemplo n.º 8
0
 function getuser()
 {
     global $config, $lang;
     if ($this->auth !== false) {
         $user = $this->auth->get_user($this->social_config);
         if (is_array($user) and $config['charset'] == "windows-1251") {
             if (function_exists('mb_convert_encoding')) {
                 $user['name'] = mb_convert_encoding($user['name'], "windows-1251", "UTF-8");
                 $user['nickname'] = mb_convert_encoding($user['nickname'], "windows-1251", "UTF-8");
             } elseif (function_exists('iconv')) {
                 $user['name'] = iconv("UTF-8", "windows-1251//IGNORE", $user['name']);
                 $user['nickname'] = iconv("UTF-8", "windows-1251//IGNORE", $user['nickname']);
             }
         }
         if (is_array($user)) {
             if (!$user['nickname']) {
                 $user['nickname'] = $user['name'];
             }
             $not_allow_symbol = array("\"", "`", "\t", '\\n', '\\r', "\n", "\r", '\\', ",", "/", "¬", "#", ";", ":", "~", "[", "]", "{", "}", ")", "(", "*", "^", "%", "\$", "<", ">", "?", "!", '"', "'", " ", "&");
             $user['email'] = str_replace($not_allow_symbol, '', $user['email']);
             $user['nickname'] = preg_replace("/[\\||\\'|\\<|\\>|\\[|\\]|\"|\\!|\\?|\$|\\@|\\#|\\/|\\\\|\\&\\~\\*\\{\\+]/", '', $user['nickname']);
             $user['nickname'] = str_ireplace(".php", ".ppp", $user['nickname']);
             $user['nickname'] = trim(htmlspecialchars($user['nickname'], ENT_QUOTES, $config['charset']));
             $user['name'] = trim(htmlspecialchars($user['name'], ENT_QUOTES, $config['charset']));
             if (dle_strlen($user['nickname'], $config['charset']) > 37) {
                 $user['nickname'] = dle_substr($user['nickname'], 37, $count, $config['charset']);
             }
         }
         return $user;
     } else {
         return $lang['social_err_2'];
     }
 }
Exemplo n.º 9
0
        }
        if (count($images)) {
            $i = 0;
            foreach ($images as $url) {
                $i++;
                $tpl->copy_template = str_replace('{image-' . $i . '}', $url, $tpl->copy_template);
                $tpl->copy_template = str_replace('[image-' . $i . ']', "", $tpl->copy_template);
                $tpl->copy_template = str_replace('[/image-' . $i . ']', "", $tpl->copy_template);
            }
        }
        $tpl->copy_template = preg_replace("#\\[image-(.+?)\\](.+?)\\[/image-(.+?)\\]#is", "", $tpl->copy_template);
        $tpl->copy_template = preg_replace("#\\{image-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template);
    }
    $tpl->set('{short-story}', $row['short_story']);
    if (preg_match("#\\{short-story limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches)) {
        $count = intval($matches[1]);
        $row['short_story'] = str_replace("</p><p>", " ", $row['short_story']);
        $row['short_story'] = strip_tags($row['short_story'], "<br>");
        $row['short_story'] = trim(str_replace("<br>", " ", str_replace("<br />", " ", str_replace("\n", " ", str_replace("\r", "", $row['short_story'])))));
        if ($count and dle_strlen($row['short_story'], $config['charset']) > $count) {
            $row['short_story'] = dle_substr($row['short_story'], 0, $count, $config['charset']);
            if ($temp_dmax = dle_strrpos($row['short_story'], ' ', $config['charset'])) {
                $row['short_story'] = dle_substr($row['short_story'], 0, $temp_dmax, $config['charset']);
            }
        }
        $tpl->set($matches[0], $row['short_story']);
    }
    $tpl->compile('content');
}
$tpl->clear();
$db->free($sql_result);
Exemplo n.º 10
0
 } else {
     $send_mail_log = false;
 }
 if (intval($user_group[$member_id['user_group']]['max_info']) > 0 and dle_strlen($info, $config['charset']) > $user_group[$member_id['user_group']]['max_info']) {
     $stop .= $lang['news_err_22'];
 }
 if (intval($user_group[$member_id['user_group']]['max_signature']) > 0 and dle_strlen($signature, $config['charset']) > $user_group[$member_id['user_group']]['max_signature']) {
     $stop .= $lang['not_allowed_sig'];
 }
 if (dle_strlen($fullname, $config['charset']) > 100) {
     $stop .= $lang['news_err_23'];
 }
 if (preg_match("/[\\||\\'|\\<|\\>|\"|\\!|\\]|\\?|\$|\\@|\\/|\\\\|\\&\\~\\*\\+]/", $fullname)) {
     $stop .= $lang['news_err_35'];
 }
 if (dle_strlen($land, $config['charset']) > 100) {
     $stop .= $lang['news_err_24'];
 }
 if (preg_match("/[\\||\\'|\\<|\\>|\"|\\!|\\]|\\?|\$|\\@|\\/|\\\\|\\&\\~\\*\\+]/", $land)) {
     $stop .= $lang['news_err_36'];
 }
 if (strlen($icq) > 20) {
     $stop .= $lang['news_err_25'];
 }
 if ($parse->not_allowed_tags) {
     $stop .= $lang['news_err_34'];
 }
 if ($parse->not_allowed_text) {
     $stop .= $lang['news_err_38'];
 }
 $db->query("SELECT name FROM " . USERPREFIX . "_users WHERE email = '{$email}' AND user_id != '{$id}'");
Exemplo n.º 11
0
 if ($config['allow_combine']) {
     $row = $db->super_query("SELECT id, post_id, user_id, date, text, ip, is_register, approve, parent FROM " . PREFIX . "_comments WHERE post_id = '{$post_id}' ORDER BY id DESC LIMIT 0,1");
     if ($row['id']) {
         if ($row['user_id'] == $member_id['user_id'] and $row['is_register'] and $row['parent'] == $parent) {
             $update_comments = true;
         } elseif ($row['ip'] == $_IP and !$row['is_register'] and !$is_logged and $row['parent'] == $parent) {
             $update_comments = true;
         }
         $row['date'] = strtotime($row['date']);
         if (date("Y-m-d", $row['date']) != date("Y-m-d", $_TIME)) {
             $update_comments = false;
         }
         if ($user_group[$member_id['user_group']]['edit_limit'] and $row['date'] + $user_group[$member_id['user_group']]['edit_limit'] * 60 < $_TIME) {
             $update_comments = false;
         }
         if (dle_strlen($row['text'], $config['charset']) + dle_strlen($comments, $config['charset']) > $config['comments_maxlen'] and $update_comments) {
             $update_comments = false;
             $stop[] = $lang['news_err_3'];
             $CN_HALT = TRUE;
             msgbox($lang['all_err_1'], implode("<br />", $stop) . "<br /><br /><a href=\"javascript:history.go(-1)\">" . $lang['all_prev'] . "</a>");
         }
     }
 }
 if (!$CN_HALT) {
     if ($config['allow_cmod'] and $user_group[$member_id['user_group']]['allow_modc']) {
         if ($update_comments) {
             if ($row['approve']) {
                 $update_comments = false;
             }
         }
         $where_approve = 0;
Exemplo n.º 12
0
function cmplinks($a, $b)
{
    global $config;
    return dle_strlen($b['word'], $config['charset']) - dle_strlen($a['word'], $config['charset']);
}
Exemplo n.º 13
0
function create_keywords($story)
{
    global $metatags, $config;
    $keyword_count = 20;
    $newarr = array();
    $quotes = array("\"", "`", "\t", "\n", "\r", ",", ".", "/", "¬", "#", ";", ":", "@", "~", "[", "]", "{", "}", "=", "-", "+", ")", "(", "*", "^", "%", "\$", "<", ">", "?", "!", '"');
    $fastquotes = array("\"", "`", "\t", "\n", "\r", '"', "\\", '\\r', '\\n', "/", "{", "}", "[", "]");
    $story = preg_replace("#\\[hide\\](.+?)\\[/hide\\]#is", "", $story);
    $story = preg_replace("'\\[attachment=(.*?)\\]'si", "", $story);
    $story = preg_replace("'\\[page=(.*?)\\](.*?)\\[/page\\]'si", "", $story);
    $story = str_replace("{PAGEBREAK}", "", $story);
    $story = str_replace("&nbsp;", " ", $story);
    $story = str_replace('<br />', ' ', $story);
    $story = strip_tags($story);
    $story = preg_replace("#&(.+?);#", "", $story);
    $story = trim(str_replace(" ,", "", stripslashes($story)));
    $story = str_replace($fastquotes, '', $story);
    $metatags['description'] = dle_substr($story, 0, 190, $config['charset']);
    $story = str_replace($quotes, ' ', $story);
    $arr = explode(" ", $story);
    foreach ($arr as $word) {
        if (dle_strlen($word, $config['charset']) > 4) {
            $newarr[] = $word;
        }
    }
    $arr = array_count_values($newarr);
    arsort($arr);
    $arr = array_keys($arr);
    $total = count($arr);
    $offset = 0;
    $arr = array_slice($arr, $offset, $keyword_count);
    $metatags['keywords'] = implode(", ", $arr);
}
Exemplo n.º 14
0
     }
     $row = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_sendlog WHERE user = '******' AND flag='2'");
     if ($row['count'] >= $user_group[$member_id['user_group']]['max_mail_day']) {
         $stop .= str_replace('{max}', $user_group[$member_id['user_group']]['max_mail_day'], $lang['feed_err_9']);
     }
 }
 if (empty($name) or dle_strlen($name, $config['charset']) > 100) {
     $stop .= $lang['feed_err_1'];
 }
 if (empty($email) or dle_strlen($email, $config['charset']) > 50 or @count(explode("@", $email)) != 2) {
     $stop .= $lang['feed_err_2'];
 }
 if (empty($subject) or dle_strlen($subject, $config['charset']) > 200) {
     $stop .= $lang['feed_err_4'];
 }
 if (empty($message) or dle_strlen($message, $config['charset']) > 20000) {
     $stop .= $lang['feed_err_5'];
 }
 if ($user_group[$member_id['user_group']]['captcha_feedback']) {
     if ($config['allow_recaptcha']) {
         if ($_POST['recaptcha_response_field'] and $_POST['recaptcha_challenge_field']) {
             require_once ENGINE_DIR . '/classes/recaptcha.php';
             $resp = recaptcha_check_answer($config['recaptcha_private_key'], $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
             if ($resp->is_valid) {
                 $_POST['sec_code'] = 1;
                 $_SESSION['sec_code_session'] = 1;
             } else {
                 $_SESSION['sec_code_session'] = false;
             }
         } else {
             $_SESSION['sec_code_session'] = false;
Exemplo n.º 15
0
     }
     $row['story'] = preg_replace("'\\[PAGE=(.*?)\\](.*?)\\[/PAGE\\]'si", $replacepage, $row['story']);
 } else {
     $row['story'] = preg_replace("'\\[PAGE=(.*?)\\](.*?)\\[/PAGE\\]'si", "", $row['story']);
 }
 $row['story'] = str_replace('{ACCEPT-DECLINE}', "", $row['story']);
 $title = stripslashes(strip_tags($row['title']));
 if ($row['allow_template']) {
     $tpl->load_template('static.tpl');
     if ($config['allow_alt_url'] == "yes") {
         $static_descr = "<a title=\"" . $title . "\" href=\"" . $config['http_home_url'] . $row['static_name'] . ".html\" >" . $title . "</a>";
     } else {
         $static_descr = "<a title=\"" . $title . "\" href=\"{$PHP_SELF}?do=static&page=" . $row['static_name'] . "\" >" . $title . "</a>";
     }
     $tpl->set('{description}', $static_descr);
     if (dle_strlen($row['story'], $config['charset']) > 2000) {
         $row['story'] = dle_substr(strip_tags($row['story']), 0, 2000, $config['charset']) . " .... ";
         if ($config['allow_alt_url'] == "yes") {
             $row['story'] .= "( <a href=\"" . $config['http_home_url'] . $row['static_name'] . ".html\" >" . $lang['search_s_go'] . "</a> )";
         } else {
             $row['story'] .= "( <a href=\"{$PHP_SELF}?do=static&page=" . $row['static_name'] . "\" >" . $lang['search_s_go'] . "</a> )";
         }
     }
     $tpl->set('{static}', $row['story']);
     $tpl->set('{pages}', '');
     if (@date("Ymd", $row['date']) == date("Ymd", $_TIME)) {
         $tpl->set('{date}', $lang['time_heute'] . langdate(", H:i", $row['date']));
     } elseif (@date("Ymd", $row['date']) == date("Ymd", $_TIME - 86400)) {
         $tpl->set('{date}', $lang['time_gestern'] . langdate(", H:i", $row['date']));
     } else {
         $tpl->set('{date}', langdate($config['timestamp_active'], $row['date']));
Exemplo n.º 16
0
     if (count($images)) {
         $i = 0;
         foreach ($images as $url) {
             $i++;
             $tpl->copy_template = str_replace('{image-' . $i . '}', $url, $tpl->copy_template);
             $tpl->copy_template = str_replace('[image-' . $i . ']', "", $tpl->copy_template);
             $tpl->copy_template = str_replace('[/image-' . $i . ']', "", $tpl->copy_template);
         }
     }
     $tpl->copy_template = preg_replace("#\\[image-(.+?)\\](.+?)\\[/image-(.+?)\\]#is", "", $tpl->copy_template);
     $tpl->copy_template = preg_replace("#\\{image-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template);
 }
 $content['description'] = strip_tags($content['description'], "<br>");
 $content['description'] = str_replace("<br>", " ", str_replace("<br />", " ", $content['description']));
 $content['description'] = trim($content['description']);
 if ($value['dmax'] and dle_strlen($content['description'], $config['charset']) > $value['dmax']) {
     $content['description'] = dle_substr($content['description'], 0, $value['dmax'], $config['charset']);
     if ($temp_dmax = dle_strrpos($content['description'], ' ', $config['charset'])) {
         $content['description'] = dle_substr($content['description'], 0, $temp_dmax, $config['charset']);
     }
     $content['description'] .= " ...";
 }
 $content['link'] = htmlspecialchars($content['link'], ENT_QUOTES, $config['charset']);
 $tpl->set('{title}', $content['title']);
 $tpl->set('{news}', $content['description']);
 $tpl->set('[link]', "<a href=\"{$content['link']}\" target=\"_blank\">");
 $tpl->set('[/link]', "</a>");
 $tpl->set('{link}', $content['link']);
 $tpl->set('{category}', $content['category']);
 $tpl->set('{author}', $content['author']);
 $tpl->set('{date}', langdate($value['rss_date_format'], $content['date']));
Exemplo n.º 17
0
    $related['category'] = intval($related['category']);
    $news_date = date('d-m-Y', $related['date']);
    if ($config['allow_alt_url'] == "yes") {
        if ($config['seo_type'] == 1 or $config['seo_type'] == 2) {
            if ($related['category'] and $config['seo_type'] == 2) {
                $full_link = $config['http_home_url'] . get_url($related['category']) . "/" . $related['id'] . "-" . $related['alt_name'] . ".html";
            } else {
                $full_link = $config['http_home_url'] . $related['id'] . "-" . $related['alt_name'] . ".html";
            }
        } else {
            $full_link = $config['http_home_url'] . date('Y/m/d/', $related['date']) . $related['alt_name'] . ".html";
        }
    } else {
        $full_link = $config['http_home_url'] . "index.php?newsid=" . $related['id'];
    }
    if (dle_strlen($related['title'], $config['charset']) > 65) {
        $related['title'] = dle_substr($related['title'], 0, 65, $config['charset']) . " ...";
    }
    if ($user_group[$member_id['user_group']]['allow_all_edit']) {
        $d_link = "<a href=\"?mod=editnews&action=editnews&id={$related['id']}\" target=\"_blank\"><img style=\"vertical-align: middle;border:none;\" alt=\"{$lang['edit_rel']}\" src=\"engine/skins/images/notepad.png\" /></a>&nbsp;&nbsp;<a onclick=\"confirmDelete('?mod=editnews&action=doeditnews&ifdelete=yes&id={$related['id']}&user_hash={$dle_login_hash}', '{$related['id']}'); return false;\" href=\"?mod=editnews&action=doeditnews&ifdelete=yes&id={$related['id']}&user_hash={$dle_login_hash}\" target=\"_blank\"><img style=\"vertical-align: middle;border:none;\" alt=\"{$lang['edit_seldel']}\" src=\"engine/skins/images/delete.png\" /></a>&nbsp;&nbsp;";
    } else {
        $d_link = "";
    }
    $buffer .= "<div style=\"padding:2px;\">{$d_link}{$news_date} - <a href=\"" . $full_link . "\" target=\"_blank\">" . stripslashes($related['title']) . "</a></div>";
}
$db->close();
@header("Content-type: text/html; charset=" . $config['charset']);
if ($buffer) {
    echo "<div style=\"width:600px; background: #ffc;border:1px solid #9E9E9E;padding: 5px;margin-top: 7px;margin-right: 10px;\">" . $buffer . "</div>";
} else {
    echo "<div style=\"width:542px;background: #ffc;border:1px solid #9E9E9E;padding: 5px;margin-top: 7px;margin-right: 10px;\">" . $lang['related_not_found'] . "</div>";
Exemplo n.º 18
0
     $tpl->set('[/yandex]', "");
     $tpl->set('{yandex_url}', $yandex_url);
 } else {
     $tpl->set_block("'\\[yandex\\](.*?)\\[/yandex\\]'si", "");
     $tpl->set('{yandex_url}', '');
 }
 if (preg_match("#\\{text limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches)) {
     $count = intval($matches[1]);
     $stext = preg_replace("#<!--TBegin(.+?)<!--TEnd-->#is", "", $template);
     $stext = preg_replace("#<!--MBegin(.+?)<!--MEnd-->#is", "", $stext);
     $stext = preg_replace("'\\[attachment=(.*?)\\]'si", "", $stext);
     $stext = preg_replace("#\\[hide\\](.+?)\\[/hide\\]#ims", "", $stext);
     $stext = str_replace("</p><p>", " ", $stext);
     $stext = strip_tags($stext, "<br>");
     $stext = trim(str_replace("<br>", " ", str_replace("<br />", " ", str_replace("\n", " ", str_replace("\r", "", $stext)))));
     if ($count and dle_strlen($stext, $config['charset']) > $count) {
         $stext = dle_substr($stext, 0, $count, $config['charset']);
         if ($temp_dmax = dle_strrpos($stext, ' ', $config['charset'])) {
             $stext = dle_substr($stext, 0, $temp_dmax, $config['charset']);
         }
     }
     $tpl->set($matches[0], $stext);
 }
 if (stripos($tpl->copy_template, "{image-") !== false) {
     $images = array();
     preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $template, $media);
     $data = preg_replace('/(img|src)("|\'|="|=\')(.*)/i', "\$3", $media[0]);
     foreach ($data as $url) {
         $info = pathinfo($url);
         if (isset($info['extension'])) {
             if ($info['filename'] == "spoiler-plus" or $info['filename'] == "spoiler-plus") {
Exemplo n.º 19
0
     if (strlen($_POST['comments']) < 8) {
         $_POST['comments'] = "";
     }
     $parse->ParseFilter(array('div', 'span', 'p', 'br', 'strong', 'em', 'ul', 'li', 'ol', 'b', 'u', 'i', 's'), array(), 0, 1);
     if ($user_group[$member_id['user_group']]['allow_url']) {
         $parse->tagsArray[] = 'a';
     }
     if ($user_group[$member_id['user_group']]['allow_image']) {
         $parse->tagsArray[] = 'img';
     }
     $comments = $db->safesql($parse->BB_Parse($parse->process(trim($_POST['comments']))));
 }
 if (empty($name) or empty($subj) or $comments == "") {
     $stop .= $lang['pm_err_2'];
 }
 if (dle_strlen($subj, $config['charset']) > 250) {
     $stop .= $lang['pm_err_3'];
 }
 if ($parse->not_allowed_tags) {
     $stop .= "<li>" . $lang['news_err_33'] . "</li>";
 }
 if ($parse->not_allowed_text) {
     $stop .= "<li>" . $lang['news_err_37'] . "</li>";
 }
 if ($user_group[$member_id['user_group']]['captcha_pm']) {
     if ($config['allow_recaptcha']) {
         require_once ENGINE_DIR . '/classes/recaptcha.php';
         $sec_code = 1;
         $sec_code_session = false;
         if ($_POST['recaptcha_response_field'] and $_POST['recaptcha_challenge_field']) {
             $resp = recaptcha_check_answer($config['recaptcha_private_key'], $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
Exemplo n.º 20
0
function check_registration($name, $email, $social_user)
{
    global $lang, $db, $banned_info, $config, $popup;
    $stop = "";
    if (empty($name) or preg_match("/[\\||\\'|\\<|\\>|\\[|\\]|\"|\\!|\\?|\$|\\@|\\/|\\\\|\\&\\~\\*\\{\\+]/", $name) or dle_strlen($name, $config['charset']) > 40) {
        return false;
    }
    if (empty($email) or strlen($email) > 50 or @count(explode("@", $email)) != 2) {
        return false;
    }
    if (strpos(strtolower($name), '.php') !== false) {
        return false;
    }
    if (stripos(urlencode($name), "%AD") !== false) {
        return false;
    }
    if ($config['max_users'] > 0) {
        $row = $db->super_query("SELECT COUNT(*) as count FROM " . USERPREFIX . "_users");
        if ($row['count'] >= $config['max_users']) {
            echo str_replace("{text}", $lang['reg_err_10'], $popup);
            die;
        }
    }
    if (count($banned_info['name'])) {
        foreach ($banned_info['name'] as $banned) {
            $banned['name'] = str_replace('\\*', '.*', preg_quote($banned['name'], "#"));
            if ($banned['name'] and preg_match("#^{$banned['name']}\$#i", $name)) {
                if ($banned['descr']) {
                    $lang['reg_err_21'] = str_replace("{descr}", $lang['reg_err_22'], $lang['reg_err_21']);
                    $lang['reg_err_21'] = str_replace("{descr}", $banned['descr'], $lang['reg_err_21']);
                } else {
                    $lang['reg_err_21'] = str_replace("{descr}", "", $lang['reg_err_21']);
                }
                echo str_replace("{text}", $lang['reg_err_21'], $popup);
                die;
            }
        }
    }
    if (count($banned_info['email'])) {
        foreach ($banned_info['email'] as $banned) {
            $banned['email'] = str_replace('\\*', '.*', preg_quote($banned['email'], "#"));
            if ($banned['email'] and preg_match("#^{$banned['email']}\$#i", $email)) {
                if ($banned['descr']) {
                    $lang['reg_err_23'] = str_replace("{descr}", $lang['reg_err_22'], $lang['reg_err_23']);
                    $lang['reg_err_23'] = str_replace("{descr}", $banned['descr'], $lang['reg_err_23']);
                } else {
                    $lang['reg_err_23'] = str_replace("{descr}", "", $lang['reg_err_23']);
                }
                echo str_replace("{text}", $lang['reg_err_23'], $popup);
                die;
            }
        }
    }
    $email = $db->safesql($email);
    $row = $db->super_query("SELECT email, name, user_id, user_group  FROM " . USERPREFIX . "_users WHERE email = '{$email}'");
    if ($row['user_id']) {
        if ($row['user_group'] == 1) {
            echo str_replace("{text}", $lang['reg_err_42'], $popup);
            die;
        } else {
            register_wait_user($social_user, $row['user_id'], $row['name'], $row['email'], 0, '');
        }
    }
    if (!$config['reg_multi_ip']) {
        $row = $db->super_query("SELECT COUNT(*) as count FROM " . USERPREFIX . "_users WHERE logged_ip = '{$_IP}'");
        if ($row['count']) {
            echo str_replace("{text}", $lang['reg_err_26'], $popup);
            die;
        }
    }
    return true;
}
Exemplo n.º 21
0
 public function lastTopics(dle_template $tpl)
 {
     if (!$this->config['allow_forum_block'] || !$this->config['allow_module']) {
         return '';
     }
     if ((int) $this->config['block_cache_time']) {
         $cache = dle_cache('xen_block_cache_time');
         if ($cache) {
             $cache = unserialize($cache);
             if (!empty($cache['time']) && $cache['time'] > time() - $this->config['block_cache_time']) {
                 return $cache['data'];
             }
         }
     }
     $forum_id = "";
     if ($this->config['bad_forum_for_block'] && !$this->config['good_forum_for_block']) {
         $forum_bad = explode(",", $this->config['bad_forum_for_block']);
         $forum_id = " AND t.node_id NOT IN('" . implode("','", $forum_bad) . "')";
     } elseif (!$this->config['bad_forum_for_block'] && $this->config['good_forum_for_block']) {
         $forum_good = explode(",", $this->config['good_forum_for_block']);
         $forum_id = " AND t.node_id IN('" . implode("','", $forum_good) . "')";
     }
     if (!(int) $this->config['count_post']) {
         $this->config['count_post'] = 10;
     }
     $sth = $this->db->query('SELECT t.title, t.thread_id, t.last_post_date, t.reply_count, t.view_count, f.title as forum_title, t.node_id, t.last_post_username, t.last_post_user_id
             FROM ' . F_PREFIX . 'thread AS t
             LEFT JOIN ' . F_PREFIX . 'node AS f
             ON f.node_id = t.node_id
             WHERE discussion_state="visible"' . $forum_id . ' 
             ORDER BY t.last_post_date DESC 
             LIMIT 0, ' . intval($this->config['count_post']));
     $forum_url = rtrim($this->options['boardUrl'], "/") . "/";
     if (!$this->config['block_rewrite_url']) {
         $forum_url .= "index.php?";
     }
     $tpl->load_template('block_forum_posts.tpl');
     preg_match("'\\[row\\](.*?)\\[/row\\]'si", $tpl->copy_template, $matches);
     $block_content = '';
     while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
         $short_name = $title = $this->_convert_encoding($row["title"], true);
         $row['last_post_username'] = $this->_convert_encoding($row['last_post_username'], true);
         if (!empty($this->config['length_name']) && dle_strlen($title, $this->DLEConfig['charset']) > $this->config['length_name']) {
             $short_name = dle_substr($title, 0, $this->config['length_name'], $this->DLEConfig['charset']) . " ...";
         }
         switch (date("d.m.Y", $row["last_post_date"])) {
             case date("d.m.Y"):
                 $date = date($this->lang['today_in'] . "H:i", $row["last_post_date"]);
                 break;
             case date("d.m.Y", time() - 86400):
                 $date = date($this->lang['yesterday_in'] . "H:i", $row["last_post_date"]);
                 break;
             default:
                 $date = date("d.m.Y H:i", $row["last_post_date"]);
         }
         $replace = array('{user}' => $this->_convert_encoding($row['last_post_username'], true), '{user_url}' => $forum_url . "members/" . $this->getTitleForUrl($row['last_post_username']) . "." . $row['last_post_user_id'] . "/", '{reply_count}' => $row["reply_count"], '{view_count}' => $row["view_count"], '{full_name}' => $title, '{post_url}' => $forum_url . "threads/" . $this->getTitleForUrl($row['title']) . "." . $row["thread_id"] . "/", '{shot_name_post}' => $short_name, '{forum_name}' => $this->_convert_encoding($row['forum_title'], true), '{forum_url}' => $forum_url . "forums/" . $this->getTitleForUrl($row['forum_title']) . "." . $row["node_id"] . "/", '{date}' => $date);
         $block_content .= strtr($matches[1], $replace);
     }
     $tpl->set_block("'\\[row\\](.*?)\\[/row\\]'si", $block_content);
     $tpl->compile('block_forum_posts');
     $tpl->clear();
     if ((int) $this->config['block_cache_time']) {
         create_cache('xen_block_cache_time', serialize(array('time' => time(), 'data' => $tpl->result['block_forum_posts'])));
     }
     return $tpl->result['block_forum_posts'];
 }
Exemplo n.º 22
0
function check_reg($name, $email, $password1, $password2, $sec_code = 1, $sec_code_session = 1)
{
    global $lang, $db, $banned_info, $relates_word, $config;
    $stop = "";
    $name = urldecode($name);
    if ($sec_code != $sec_code_session or !$sec_code_session) {
        $stop .= $lang['reg_err_19'];
    }
    if ($password1 != $password2) {
        $stop .= $lang['reg_err_1'];
    }
    if (strlen($password1) < 6) {
        $stop .= $lang['reg_err_2'];
    }
    if (dle_strlen($name, $config['charset']) > 30 or dle_strlen(trim($name), $config['charset']) < 3) {
        $stop .= $lang['reg_err_3'];
    }
    if (preg_match("/[\\||\\'|\\<|\\>|\\[|\\]|\"|\\!|\\?|\$|\\@|\\/|\\\\|\\&\\~\\*\\{\\+]/", $name)) {
        $stop .= $lang['reg_err_4'];
    }
    if (empty($email) or strlen($email) > 50 or @count(explode("@", $email)) != 2) {
        $stop .= $lang['reg_err_6'];
    }
    if (strpos(strtolower($name), '.php') !== false) {
        $stop .= $lang['reg_err_4'];
    }
    if (stripos(urlencode($name), "%AD") !== false) {
        $stop .= $lang['reg_err_4'];
    }
    if (count($banned_info['name'])) {
        foreach ($banned_info['name'] as $banned) {
            $banned['name'] = str_replace('\\*', '.*', preg_quote($banned['name'], "#"));
            if ($banned['name'] and preg_match("#^{$banned['name']}\$#i", $name)) {
                if ($banned['descr']) {
                    $lang['reg_err_21'] = str_replace("{descr}", $lang['reg_err_22'], $lang['reg_err_21']);
                    $lang['reg_err_21'] = str_replace("{descr}", $banned['descr'], $lang['reg_err_21']);
                } else {
                    $lang['reg_err_21'] = str_replace("{descr}", "", $lang['reg_err_21']);
                }
                $stop .= $lang['reg_err_21'];
            }
        }
    }
    if (count($banned_info['email'])) {
        foreach ($banned_info['email'] as $banned) {
            $banned['email'] = str_replace('\\*', '.*', preg_quote($banned['email'], "#"));
            if ($banned['email'] and preg_match("#^{$banned['email']}\$#i", $email)) {
                if ($banned['descr']) {
                    $lang['reg_err_23'] = str_replace("{descr}", $lang['reg_err_22'], $lang['reg_err_23']);
                    $lang['reg_err_23'] = str_replace("{descr}", $banned['descr'], $lang['reg_err_23']);
                } else {
                    $lang['reg_err_23'] = str_replace("{descr}", "", $lang['reg_err_23']);
                }
                $stop .= $lang['reg_err_23'];
            }
        }
    }
    if ($stop == "") {
        if (function_exists('mb_strtolower')) {
            $name = trim(mb_strtolower($name, $config['charset']));
        } else {
            $name = trim(strtolower($name));
        }
        $search_name = strtr($name, $relates_word);
        $row = $db->super_query("SELECT COUNT(*) as count FROM " . USERPREFIX . "_users WHERE email = '{$email}' OR LOWER(name) REGEXP '[[:<:]]{$search_name}[[:>:]]' OR name = '{$name}'");
        if ($row['count']) {
            $stop .= $lang['reg_err_8'];
        }
    }
    return $stop;
}
Exemplo n.º 23
0
     $use_html = false;
 }
 $comm_txt = trim($parse->BB_Parse($parse->process(convert_unicode($_POST['comm_txt'], $config['charset'])), $use_html));
 if ($parse->not_allowed_tags) {
     die("error");
 }
 if ($parse->not_allowed_text) {
     die("error");
 }
 if (dle_strlen($comm_txt, $config['charset']) > $config['comments_maxlen']) {
     die("error");
 }
 if ($comm_txt == "") {
     die("error");
 }
 if (intval($config['comments_minlen']) and dle_strlen($comm_txt, $config['charset']) < $config['comments_minlen']) {
     die("error");
 }
 //* Автоперенос длинных слов
 if (intval($config['auto_wrap'])) {
     $comm_txt = preg_split('((>)|(<))', $comm_txt, -1, PREG_SPLIT_DELIM_CAPTURE);
     $n = count($comm_txt);
     for ($i = 0; $i < $n; $i++) {
         if ($comm_txt[$i] == "<") {
             $i++;
             continue;
         }
         $comm_txt[$i] = preg_replace("#([^\\s\n\r]{" . intval($config['auto_wrap']) . "})#i", "\\1<br />", $comm_txt[$i]);
     }
     $comm_txt = join("", $comm_txt);
 }
Exemplo n.º 24
0
 public function Start($CommCfg)
 {
     $this->New_Cfg($CommCfg);
     // создаем новый конфиг
     $where = array();
     // проверка некоторых параметров конфига по версиях
     $allow_alt_url = $this->config['version_id'] >= '10.2' ? $this->config['allow_alt_url'] == '1' : $this->config['allow_alt_url'] == "yes";
     $allow_cache = $this->config['version_id'] >= '10.2' ? $this->config['allow_cache'] == '1' : $this->config['allow_cache'] == "yes";
     $allow_multi_category = $this->config['version_id'] >= '10.2' ? $this->config['allow_multi_category'] == '1' : $this->config['allow_multi_category'] == "yes";
     if ($this->config['version_id'] >= '10.4' and $this->comm_cfg['rating_comm']) {
         // рейтинг комментариев только для DLE 10.4 и выще
         $where[] = "c.rating > {$this->comm_cfg[rating_comm]}";
     }
     // работа с категориями
     if ($allow_multi_category) {
         if ($this->comm_cfg['stop_category']) {
             $where[] = "category NOT REGEXP '[[:<:]](" . $this->Explode_Category($this->comm_cfg['stop_category'], "multi") . ")[[:>:]]'";
         }
         if ($this->comm_cfg['from_category']) {
             $where[] = "category REGEXP '[[:<:]](" . $this->Explode_Category($this->comm_cfg['from_category'], "multi") . ")[[:>:]]'";
         }
     } else {
         if ($this->comm_cfg['stop_category']) {
             $where[] = "category NOT IN ('" . $this->Explode_Category($this->comm_cfg['stop_category']) . "')";
         }
         if ($this->comm_cfg['from_category']) {
             $where[] = "category IN ('" . $this->Explode_Category($this->comm_cfg['from_category']) . "')";
         }
     }
     if ($this->comm_cfg['news_xfield']) {
         // работа с доп полями новостей
         $where[] = $this->Explode_xField($this->comm_cfg['news_xfield'], "p.xfields");
     }
     if ($this->comm_cfg['user_xfield']) {
         // работа с доп полями пользователей
         $where[] = $this->Explode_xField($this->comm_cfg['user_xfield'], "u.xfields");
     }
     // работа с новостями
     if ($this->comm_cfg['stop_id']) {
         $where[] = $this->Explode_NewsID($this->comm_cfg['stop_id']);
     }
     if ($this->comm_cfg['from_id']) {
         $where[] = $this->Explode_NewsID($this->comm_cfg['from_id']);
     }
     if ($this->comm_cfg['ncomm']) {
         // выводим только с комментариями у новостей больше чем
         $where[] = "p.comm_num > {$this->comm_cfg[ncomm]}";
     }
     if ($this->comm_cfg['fixed']) {
         // выводим только с зафиксированых новостей
         $where[] = "p.fixed = 1";
     }
     if ($this->comm_cfg['tags']) {
         $t = explode(',', $this->comm_cfg['tags']);
         $t = implode('|', $t);
         $where[] = "p.tags regexp '[[:<:]](" . $t . ")[[:>:]]'";
     }
     if ($this->comm_cfg['news_read']) {
         // выводим только с комментариями у новостей больше чем
         $where[] = "e.news_read > {$this->comm_cfg[news_read]}";
     }
     if ($this->comm_cfg['rating_news']) {
         // выводим только с комментариями у новостей больше чем
         $where[] = "e.rating > {$this->comm_cfg[rating_news]}";
     }
     if ($this->comm_cfg['only_avatar']) {
         // выводим только с аватарами
         $where[] = "u.foto != ''";
     }
     if ($this->comm_cfg['only_news']) {
         // выводим только с новостями
         $where[] = "u.news_num > 0";
     }
     if ($this->comm_cfg['only_fav']) {
         // выводим только с закладками
         $where[] = "u.favorites != ''";
     }
     if ($this->comm_cfg['only_fullname']) {
         // выводим только с полным именем
         $where[] = "u.fullname != ''";
     }
     if ($this->comm_cfg['only_land']) {
         // выводим только с место жительством
         $where[] = "u.land != ''";
     }
     if ($this->comm_cfg['news_user']) {
         // выводим только если новостей больше чем
         $where[] = "u.news_num > {$this->comm_cfg[news_user]}";
     }
     if ($this->comm_cfg['comm']) {
         // выводим только если комментариев больше чем
         $where[] = "u.comm_num > {$this->comm_cfg[comm]}";
     }
     // префикс кэша
     $Comm_hash = md5($this->comm_cfg['max_comm'] . $this->comm_cfg['max_text'] . $this->comm_cfg['max_title'] . $this->comm_cfg['check_guest'] . $this->comm_cfg['stop_category'] . $this->comm_cfg['from_category'] . $this->comm_cfg['stop_id'] . $this->comm_cfg['from_id'] . $this->comm_cfg['only_avatar'] . $this->comm_cfg['only_news'] . $this->comm_cfg['news_user'] . $this->comm_cfg['comm'] . $this->comm_cfg['only_fav'] . $this->comm_cfg['only_fullname'] . $this->comm_cfg['only_land']);
     $is_change = false;
     if (!$allow_cache) {
         if ($this->config['version_id'] >= '10.2') {
             $this->config['allow_cache'] = '1';
         } else {
             $this->config['allow_cache'] = "yes";
         }
         $is_change = true;
     }
     $Comm = dle_cache("Comm_", $this->config['skin'] . $Comm_hash);
     // подгружаем из кэша
     if (!$Comm) {
         if (count($where) > 0) {
             $where = " AND " . implode(" AND ", $where);
         } else {
             $where = "";
         }
         $sql = $this->db->query("SELECT c.id as comid, c.post_id, c.date, c.user_id, c.is_register, c.text, c.autor, c.email, c.approve, p.id, p.date as newsdate, p.title, p.category, p.comm_num, p.alt_name, e.news_id, e.news_read, e.rating, u.foto, u.user_group, u.user_id FROM " . PREFIX . "_comments as c, " . PREFIX . "_post as p, " . PREFIX . "_post_extras as e, " . PREFIX . "_users as u WHERE p.id=c.post_id AND e.news_id=c.post_id AND c.approve = 1 AND c.user_id = u.user_id {$where} ORDER BY c.date DESC LIMIT 0, " . $this->comm_cfg['max_comm']);
         $tpl = new dle_template();
         $tpl->dir = TEMPLATE_DIR;
         $tpl->load_template('comm/comm.tpl');
         $count_rows = $sql->num_rows;
         if ($count_rows > 0) {
             while ($row = $this->db->get_row($sql)) {
                 $row['date'] = strtotime($row['date']);
                 $row['category'] = intval($row['category']);
                 // Обработка ссылки на комментарий
                 $on_page = FALSE;
                 if ($row['comm_num'] > $this->config['comm_nummers']) {
                     $on_page = 'page,1,' . ceil($row['comm_num'] / $this->config['comm_nummers']) . ',';
                 }
                 if ($allow_alt_url) {
                     if ($condition = $this->config['seo_type'] == 1 or $this->config['seo_type'] == 2) {
                         if ($row['category'] and $this->config['seo_type'] == 2) {
                             $full_link = $this->config['http_home_url'] . get_url($row['category']) . "/" . $on_page . $row['id'] . "-" . $row['alt_name'] . ".html";
                         } else {
                             $full_link = $this->config['http_home_url'] . $on_page . $row['id'] . "-" . $row['alt_name'] . ".html";
                         }
                     } else {
                         $full_link = $this->config['http_home_url'] . date('Y/m/d/', $row['date']) . $on_page . $row['alt_name'] . ".html";
                     }
                 } else {
                     $full_link = $this->config['http_home_url'] . "index.php?newsid=" . $row['id'];
                 }
                 $full_link = $full_link . '#comment-id-' . $row['comid'];
                 // Обработка текста комментария
                 if (dle_strlen($row['text'], $this->config['charset']) > $this->comm_cfg['max_text']) {
                     $text = stripslashes(dle_substr($row['text'], 0, $this->comm_cfg['max_text'], $this->config['charset']) . " ...");
                 } else {
                     $text = stripslashes($row['text']);
                 }
                 // Обработка заголовка новости (title)
                 if (dle_strlen($row['title'], $this->config['charset']) > $this->comm_cfg['max_title']) {
                     $title = stripslashes(dle_substr($row['title'], 0, $this->comm_cfg['max_title'], $this->config['charset']) . " ...");
                 } else {
                     $title = stripslashes($row['title']);
                 }
                 // Обработка ника автора комментария
                 if ($row['is_register'] == 1) {
                     if ($allow_alt_url) {
                         $go_page = $this->config['http_home_url'] . "user/" . urlencode($row['autor']) . "/";
                     } else {
                         $go_page = "{$PHP_SELF}?subaction=userinfo&amp;user="******"onclick=\"ShowProfile('" . urlencode($row['autor']) . "', '" . htmlspecialchars($go_page, ENT_QUOTES, $this->config['charset']) . "', '" . $this->group[$this->member['user_group']]['admin_editusers'] . "'); return false;\"";
                     } else {
                         $go_page = "onclick=\"ShowProfile('" . urlencode($row['autor']) . "', '" . $go_page . "'); return false;\"";
                     }
                     if ($allow_alt_url) {
                         $author = "<a {$go_page} href=\"" . $this->config['http_home_url'] . "user/" . urlencode($row['autor']) . "/\">" . $row['autor'] . "</a>";
                     } else {
                         $author = "<a {$go_page} href=\"{$PHP_SELF}?subaction=userinfo&amp;user="******"\">" . $row['autor'] . "</a>";
                     }
                 } else {
                     $author = strip_tags($row['autor']);
                 }
                 // Обработка фото автора комментария
                 if ($row['foto'] and $row['is_register'] == 1) {
                     if (count(explode("@", $row['foto'])) == 2) {
                         $tpl->set('{foto}', '//www.gravatar.com/avatar/' . md5(trim($row['foto'])) . '?s=' . intval($this->group[$row['user_group']]['max_foto']));
                     } else {
                         if ($this->config['version_id'] >= '10.5') {
                             if (strpos($row['foto'], "//") === 0) {
                                 $avatar = "http:" . $row['foto'];
                             } else {
                                 $avatar = $row['foto'];
                             }
                             $avatar = @parse_url($avatar);
                             if ($avatar['host']) {
                                 $tpl->set('{foto}', $row['foto']);
                             } else {
                                 $tpl->set('{foto}', $this->config['http_home_url'] . "uploads/fotos/" . $row['foto']);
                             }
                         } else {
                             if ($row['foto'] and file_exists(ROOT_DIR . "/uploads/fotos/" . $row['foto'])) {
                                 $tpl->set('{foto}', $this->config['http_home_url'] . "uploads/fotos/" . $row['foto']);
                             }
                         }
                     }
                 } else {
                     $tpl->set('{foto}', "{THEME}/dleimages/noavatar.png");
                 }
                 // Обработка ссылки автора комментария
                 if ($allow_alt_url) {
                     $user_url = $this->config['http_home_url'] . "user/" . urlencode($row['autor']) . "/";
                 } else {
                     $user_url = "{$PHP_SELF}?subaction=userinfo&amp;user="******", H:i", $row['date']));
                 } elseif (date('Ymd', $row['date']) == date('Ymd', $_TIME - 86400)) {
                     $tpl->set('{date}', $lang['time_gestern'] . langdate(", H:i", $row['date']));
                 } else {
                     $tpl->set('{date}', langdate($this->config['timestamp_active'], $row['date']));
                 }
                 $tpl->copy_template = preg_replace("#\\{date=(.+?)\\}#ie", "langdate('\\1', '{$row['date']}')", $tpl->copy_template);
                 $tpl->set('{text}', $text);
                 //текст комментария
                 $tpl->set('{user_url}', $user_url);
                 // ссылка на автора
                 $tpl->set('{user_name}', $row['autor']);
                 // просто ник автора
                 $tpl->set('[user_url]', "<a href=\"" . $user_url . "\">");
                 // оборачиваем в ссылку
                 $tpl->set('[/user_url]', "</a>");
                 // оборачиваем в ссылку
                 $tpl->set('{author}', $author);
                 // автор с ссылкой на профиль с модальным окном
                 $tpl->set('[color]', $this->group[$row['user_group']]['group_prefix']);
                 // префикс цвета группы
                 $tpl->set('[/color]', $this->group[$row['user_group']]['group_suffix']);
                 // суфикс цвета группы
                 $tpl->set('{title}', $title);
                 // укороченный заголовок
                 $tpl->set('{long_title}', stripslashes($row['title']));
                 // полный заголовок
                 $tpl->set('{rating}', $row['rating']);
                 // рейтинг новости
                 $tpl->set('{views}', $row['news_read']);
                 // просмотров новости
                 $tpl->set('{full_link}', $full_link);
                 // линк на комментарий
                 $tpl->set('{comm_num}', $row['comm_num']);
                 // кол-во комментариев новости
                 $tpl->set("{error}", "");
                 $tpl->set('[comm]', "");
                 $tpl->set('[/comm]', "");
                 $tpl->set_block("'\\[not-comm\\](.*?)\\[/not-comm\\]'si", "");
                 $tpl->compile('comm');
                 //компиляция шаблона
             }
             $this->db->free($sql);
             //очищаем от запросов
         } else {
             $tpl->set("{error}", "Комментариев нету!");
             $tpl->set_block("'\\[comm\\](.*?)\\[/comm\\]'si", "");
             $tpl->set('[not-comm]', "");
             $tpl->set('[/not-comm]', "");
             $tpl->compile('comm');
         }
         $tpl->clear();
         //очищаем шаблон
         $Comm = $tpl->result['comm'];
         if (preg_match_all('/<!--dle_spoiler(.*?)<!--\\/dle_spoiler-->/is', $Comm, $spoilers)) {
             foreach ($spoilers as $spoiler) {
                 $Comm = str_replace($spoiler, '<div class="quote">Для просмотра содержимого спойлера, перейдите к выбранному комментарию.</div>', $Comm);
             }
         }
         if ($this->group[$this->member['user_group']]['allow_hide']) {
             $Comm = preg_replace("'\\[hide\\](.*?)\\[/hide\\]'si", "\\1", $Comm);
         } else {
             $Comm = preg_replace("'\\[hide\\](.*?)\\[/hide\\]'si", "<div class=\"quote\"> Для вашей группы скрытый текст не виден </div>", $Comm);
         }
         create_cache("Comm_", $Comm, $this->config['skin'] . $Comm_hash);
         //создаем кэш
         if ($is_change) {
             $this->config['allow_cache'] = false;
         }
         //выключаем кэш принудительно (возвращаем назад)
     }
     echo '<div class="iComm" id="iComm"><ul class="lastcomm">' . $Comm . '</ul> <!-- .lastcomm --></div>';
 }
Exemplo n.º 25
0
 $full_story = $parse->process($_POST['full_story']);
 $short_story = $parse->process($_POST['short_story']);
 if ($config['allow_admin_wysiwyg'] or $allow_br != '1') {
     $full_story = $db->safesql($parse->BB_Parse($full_story));
     $short_story = $db->safesql($parse->BB_Parse($short_story));
 } else {
     $full_story = $db->safesql($parse->BB_Parse($full_story, false));
     $short_story = $db->safesql($parse->BB_Parse($short_story, false));
 }
 if ($parse->not_allowed_text) {
     msg("error", $lang['addnews_error'], $lang['news_err_39'], "javascript:history.go(-1)");
 }
 if (trim($title) == "" and $ifdelete != "yes") {
     msg("error", $lang['cat_error'], $lang['addnews_alert'], "javascript:history.go(-1)");
 }
 if (dle_strlen($title, $config['charset']) > 255) {
     msg("error", $lang['cat_error'], $lang['addnews_ermax'], "javascript:history.go(-1)");
 }
 if (trim($_POST['alt_name']) == "" or !$_POST['alt_name']) {
     $alt_name = totranslit(stripslashes($title));
 } else {
     $alt_name = totranslit(stripslashes($_POST['alt_name']));
 }
 $title = $db->safesql($title);
 $metatags = create_metatags($short_story . $full_story);
 $catalog_url = $db->safesql(dle_substr(htmlspecialchars(strip_tags(stripslashes(trim($_POST['catalog_url']))), ENT_QUOTES, $config['charset']), 0, 3, $config['charset']));
 if ($config['create_catalog'] and !$catalog_url) {
     $catalog_url = $db->safesql(dle_substr(htmlspecialchars(strip_tags(stripslashes(trim($title))), ENT_QUOTES, $config['charset']), 0, 1, $config['charset']));
 }
 $editreason = $db->safesql(htmlspecialchars(strip_tags(stripslashes(trim($_POST['editreason']))), ENT_QUOTES, $config['charset']));
 if (@preg_match("/[\\||\\<|\\>|\"|\\!|\\?|\$|\\@|\\/|\\\\|\\&\\~\\*\\+]/", $_POST['tags'])) {
Exemplo n.º 26
0
 }
 if ($parse->not_allowed_text) {
     $tpl->copy_template = $lang['news_err_39'];
 }
 $tpl->copy_template = str_replace('[full-preview]', "", $tpl->copy_template);
 $tpl->copy_template = str_replace('[/full-preview]', "", $tpl->copy_template);
 $tpl->copy_template = preg_replace("'\\[short-preview\\](.*?)\\[/short-preview\\]'si", "", $tpl->copy_template);
 $tpl->copy_template = preg_replace("'\\[static-preview\\](.*?)\\[/static-preview\\]'si", "", $tpl->copy_template);
 if (strlen($full_story) < 10 and strpos($tpl->copy_template, "{short-story}") === false) {
     $full_story = $short_story;
 }
 $tpl->set('{title}', $title);
 if (preg_match("#\\{title limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches)) {
     $count = intval($matches[1]);
     $title = strip_tags($title);
     if ($count and dle_strlen($title, $config['charset']) > $count) {
         $title = dle_substr($title, 0, $count, $config['charset']);
         if ($temp_dmax = dle_strrpos($title, ' ', $config['charset'])) {
             $title = dle_substr($title, 0, $temp_dmax, $config['charset']);
         }
     }
     $tpl->set($matches[0], $title);
 }
 if (!count($_REQUEST['category'])) {
     $_REQUEST['category'] = array();
     $_REQUEST['category'][] = '0';
 }
 $c_list = array();
 foreach ($_REQUEST['category'] as $value) {
     $c_list[] = intval($value);
 }