<?
##########################################################
#########          by Elektroshok               ##########
#########      E-mail: awsdaa@gmail.com         ##########
#########           ICQ: 308410                 ##########
#########     Модуль вывода на главной          ##########
#########      Назначение catindex.php          ##########
##########################################################
if ($conf['index_allow_top_read_cat_10'] == "yes"){
$top_read_cat_10 = dle_cache("top_read_cat_10", $conf['skin']);
if (!$top_read_cat_10) {
	
	$this_month = date ('Y-m-d', time()-(3600*24*27));

	$db->query("SELECT id, title, date, alt_name, short_story, news_read FROM " . PREFIX . "_post WHERE approve='$conf[allow_index_metka]' AND category regexp '[[:<:]]($conf[cat_num_10])[[:>:]]' ORDER BY  date DESC LIMIT 0,$conf[top_number_mod]");

	while($row = $db->get_row()){

		$row['date'] = strtotime($row['date']);
        
		if (strlen($row['title']) > 10)
			$title = substr ($row['title'], 0, $conf["index_top_title"])." ...";
		else
			$title = $row['title'];

		$go_page = ($config['ajax']) ? "onclick=\"DlePage('newsid=".$row['id']."'); return false;\" " : "";

		if ($conf['allow_alt_url'] == "yes")
	        $link = "<a {$go_page}href=\"".$config['http_home_url'].date('Y/m/d/', $row['date']).$row['alt_name'].".html\">".stripslashes($title)."</a>";
		else 
	        $link = "<a {$go_page}href=\"$PHP_SELF?newsid=".$row['id']."\">".stripslashes($title)."</a>";
	        if ($conf['allow_read_num']=="yes")
            $read = "(".$row['news_read'].")";
//Убираем изображение из текста на главной
if ($conf['allow_images_catindex'] == "yes"){
$img =  get_img_basic($row['short_story']);
if ($img =="")
$images ="";
else
	if ($conf['img_blank'] == "yes"){
	$images_show = "<a href=\"$img\" target=\"_top\">";
	$images_show_a = "</a>";
}else{
	$images_show = "<a href=\"$img\" target=\"_blank\">";
	$images_show_a = "</a>";
};
	if ($conf['img_click_allow'] == "no"){
	$images_show = "";
	$images_show_a = "";
};
$images = $images_show."<img src=\"$img\" align=\"".$conf[img_catindex_align]."\" width=\"".$conf[img_catindex_wigth]."\" height=\"".$conf[img_catindex_hieght]."\">".$images_show_a;
$row['short_story'] = preg_replace( "#<img src=[\"'](\S+?)['\"].+?".">#is", "", $row['short_story'] );
$row['short_story'] = preg_replace( "#<!--ThumbBegin-->(.+?)<!--ThumbEnd-->#ie", "", $row['short_story']);
$row['short_story'] = preg_replace( "#<!--ThumbBegin-->(.+?)<!--ThumbEnd-->#ie", "", $row['short_story']);
$row['short_story'] = preg_replace( "#<img src=[\"'](\S+?)['\"] align=['\"](.+?)['\"].+?".">#is", "", $row['short_story'] );
}else{
	$row['short_story'] = preg_replace( "#<img src=[\"'](\S+?)['\"].+?".">#is", "", $row['short_story'] );
	$row['short_story'] = preg_replace( "#<!--ThumbBegin-->(.+?)<!--ThumbEnd-->#ie", "", $row['short_story']);
	$row['short_story'] = preg_replace( "#<img src=[\"'](\S+?)['\"] align=['\"](.+?)['\"].+?".">#is", "", $row['short_story'] );
}; 

//Включение отображение новости на главной
	if ($conf['allow_short_story']=="yes"){ 
		if ($conf['allow_alt_url'] == "yes")
		if ($conf['allow_dalee']=="yes"){
$links = "<a {$go_page} href=\"".$config['http_home_url'].date('Y/m/d/', $row['date']).$row['alt_name'].".html\">"."Далее"."</a>";
}else{
	$links = "<a {$go_page} href=\"".$config['http_home_url'].date('Y/m/d/', $row['date']).$row['alt_name'].".html\">"."</a>";
}
		else 
		if ($conf['allow_dalee']=="yes"){
	        $links = "<a {$go_page}href=\"$PHP_SELF?newsid=".$row['id']."\">"."Далее"."</a>";
			}else{
			$links = "<a {$go_page}href=\"$PHP_SELF?newsid=".$row['id']."\">"."</a>";	
			}	  
            if (strlen($row['short_story']) > 50)
            $short_story = substr ($row['short_story'],0, $conf["index_top_symbol"])."...$links";
            else
            $short_story = stripslashes($row['short_story']);
//Конец обреза текста к статье
//Время к статье
if ($conf['date_story']=="yes"){
$date_story =langdate($conf['timestamp_active'], $row['date']);
};
		$top_read_cat_10 .= "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><div class=\"$conf[index_top_css_mod_title]\">&raquo;".$link.$read."<br>".$date_story."</div>".$images.stripslashes("<div class=\"$conf[index_top_css]\">".$short_story."</div></td></tr></table>");
            }else{
					$top_read_cat_10 .= "<div class=\"$conf[index_top_css_mod_title]\">&raquo;".$link.$read.$register."</div>";
			}
	} 
	}

	$db->free();
		create_cache ("top_read_cat_10", $top_read_cat_10, $conf['skin']);
}
?>