<?
define('SOFTPUBS_IN', true);
require_once(dirname(__FILE__) . '/includes/init.php');

require_once(ROOT_PATH.'includes/header.php');
this_channel(CHANNEL_PRODUCT_ID);
$list_type_url	=	'product.php';

if(!is_file(TEMPLATE_DIR.'/product.html')){
	require_once(ROOT_PATH.'/index.php');
	exit;
}

$limit			=		10;
$page   			=  	@(int)$_GET['page']?(int)$_GET['page']:1;
$this_page     =  	($page-1)*$limit;	
$sql				=		"SELECT * FROM {$db_obj->db_pre}software WHERE is_stop=0";			
$count_sql		=		"SELECT COUNT(software_id) AS count FROM {$db_obj->db_pre}software WHERE is_stop=0 ";	
if($soft_cat_id=(int)$_GET['cat_id']){
	$cat_id_str			=	$glo_category_obj->recursion_category('software',$soft_cat_id);	
	$sql					.=		" AND cat_id in ($cat_id_str)";
	$count_sql			.=		" AND cat_id in ($cat_id_str)";
	$order_type			=	" is_cat_commend ";	
	$this_cat			=	$glo_category_obj->get_cat_this_is_here('software',$soft_cat_id,'product');
}else{
	$order_type			=	"is_channel_commend ";
}
$sql				.=		"  ORDER BY {$order_type} DESC,last_update DESC  limit $this_page,$limit";

$soft_list_res	=	$db_obj->getRecords($sql);
if($soft_list_res){
	$soft_list_res	=	format_software_list($soft_list_res);
	$count							=		$db_obj->getNumber($count_sql);
	$page_arr						=		pagination_arr($page,$count,$limit,10,'page');	
	foreach($page_arr['thepage'] as $key=>$val){
		$page_arr['thepage'][$key]	=	get_url($val,$this_cat['cat_name']);
	}
}	

parse_template('product.html');
