<?PHP
/*
=====================================================
 DataLife Engine v9.3 - by DLE Farsi Group 
-----------------------------------------------------
 http://datalifeengine.ir/
-----------------------------------------------------
 Copyright (c) 2006,2011 DLE Farsi Group
=====================================================
*/
if( ! defined( 'DATALIFEENGINE' ) ) {
	die( "Hacking attempt!" );
}

$news_result = dle_cache( $mod, $config['skin'] );

if( ! $news_result ) {

	$this_month = date( 'Y-m-d H:i:s', $_TIME );
	
	if( $mod == "randnews" ) $order = "RAND()";
	if( $mod == "lastnews" ) $order = "date DESC";
	else $order = "rating DESC, comm_num DESC, news_read DESC, date DESC";
	
	$limit = intval( $limit );
	if( ! $limit ) $limit = 10;
	
	$db->query( "SELECT id, title, date, alt_name, category, flag FROM " . PREFIX . "_post WHERE approve='1' AND date < '$this_month' ORDER BY {$order} LIMIT 0,{$limit}");

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

		$row['date'] = strtotime( $row['date'] );
		$row['category'] = intval( $row['category'] );

		if (strlen($row['title']) > 55) $row['title'] = dle_substr ($row['title'], 0, 55, $config['charset'])." ...";

		if( $config['allow_alt_url'] == "yes" ) {
			
			if( $row['flag'] and $config['seo_type'] ) {
				
				if( $row['category'] and $config['seo_type'] == 2 ) {
					
					$full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
				
				} else {
					
					$full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
				
				}
			
			} else {
				
				$full_link = $config['http_home_url'] . jdate( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
			}
		
		} else {
			
			$full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
		
		}
		
		if( dle_strlen( $row['title'], $config['charset'] ) > 55 ) $title = dle_substr( $row['title'], 0, 55, $config['charset'] ) . " ...";
		else $title = $row['title'];
		
		$link = "<a href=\"" . $full_link . "\">" . stripslashes( $title ) . "</a>";

		$news_result .= "<li>" . $link . "</li>";
	}
	
	create_cache( $mod, $news_result, $config['skin'] );
}

echo $news_result;

?>