if(!defined('DATALIFEENGINE')){die("Hacking attempt!");} $word = 40; $limit = $config['newslist_num']; if (isset ( $_SESSION['dle_sort_newslist'] )) $news_sort_by = $_SESSION['dle_sort_newslist']; else $news_sort_by = $config['news_sort']; if (isset ( $_SESSION['dle_direction_newslist'] )) $news_direction_by = $_SESSION['dle_direction_newslist']; else $news_direction_by = $config['news_msort']; if (isset ( $_REQUEST['category'] )) { if (substr ( $_GET['category'], - 1, 1 ) == '/') $_GET['category'] = substr ( $_GET['category'], 0, - 1 ); $category = explode ( '/', $_GET['category'] ); $category = end ( $category ); $category = $db->safesql ( strip_tags ( $category ) ); $link_cat = $category ."/"; } else $category = ''; $news_query = "WHERE approve='1' AND allow_main = '1'"; $cat_news_number = "WHERE approve='1' AND allow_main = '1'"; if($category){$cat_name = "WHERE alt_name='".$category."'";} $result_category = $db->query("SELECT name,alt_name,id,descr,keywords FROM ".PREFIX."_category $cat_name"); $name_category = $db->get_row($result_category); $meta_description = stripslashes($name_category['descr']); $meta_keywords = stripslashes($name_category['keywords']); if($category){ $cat = get_sub_cats( $name_category['id'] ); $cat_news_number = "WHERE `category` regexp '[[:<:]]({$cat})[[:>:]]' AND approve='1'"; $news_query = "WHERE `category` regexp '[[:<:]]({$cat})[[:>:]]' AND approve='1'"; } /* Делаем запрос на подсчёт количества новостей */ $sql_page = "SELECT COUNT(*) as count FROM " . PREFIX . "_post $cat_news_number ORDER BY $news_sort_by $news_direction_by"; $temp = $db->super_query($sql_page); $posts = $temp['count']; if($posts > 0){ $page = intval( $_REQUEST['page'] ); $total = intval( ( ( $posts - 1 ) / $limit ) + 1 ); if( $page <= 0 ) $page = 1; if( $page > $total ) $page = $total; $start = $page * $limit - $limit; $i = $start; $result = $db->query("SELECT id,autor,title,category,alt_name,date,comm_num,rating,news_read FROM ".PREFIX."_post $news_query ORDER BY $news_sort_by $news_direction_by LIMIT " . $start . "," . $limit); $tpl->load_template('newslist/newslist.tpl'); while($row = $db->get_row($result)){ $i++; if (strlen($row['title']) > $word) $title = stripcslashes(substr ($row['title'], 0, $word))." ..."; else $title = stripcslashes($row['title']); $date_news = strtotime($row['date']); $link = $config['http_home_url'].$row['id']."-".$row['alt_name'].".html"; $date = date("d.m.Y",strtotime($row['date'])); $tpl->set("{date}", $date); $tpl->set('{spoiler}',""); $tpl->set('{story}',''); $metatags['titles'] = "Все новости » ".$name_category['name']; $tpl->copy_template = "