<?php
if(!defined('MOD'))  die("access die");
$rules = intval($_GET['rules']);
$work = $_GET['work'];
$page = intval($_GET['pageno']);
$pagenum = 40;

if ( $rules > 0 ) $where = 'WHERE rules ='.$rules;
if ( empty( $page )) $page = 1;

$sql_rule = "SELECT `id`, `name` FROM ".TABLEPRE."collect_rule";
$result_rule = qdb::Query( $sql_rule );
while ( $row_rule = qdb::fetchArray( $result_rule )){
	if ( $rules == $row_rule['id'] ){
		$row_rule['selected'] = 'selected';
	}
	$selected = '';
	$classs[] = $row_rule;
}


$pagesql = "SELECT COUNT(*) FROM ".TABLEPRE."collect_links ".$where;
$num = qdb::QueryAlone( $pagesql );
$curr_page = ( $page - 1 ) * $pagenum;

$sql = "SELECT * FROM ".TABLEPRE."collect_links ".$where." ORDER BY `id` ASC LIMIT $curr_page , $pagenum";
$result = qdb::Query( $sql );
while ( $row_rule = qdb::fetchArray( $result )){
	switch ( $row_rule[adopt] ){
		case 0:
			$row_rule['adopt'] = '·ٌ';
		break 1;
		case 1:
			$row_rule['adopt'] = 'تا';
		break 1;
	}

	switch ( $row_rule['import'] )
	{
		case 0:
			$row_rule['import'] = '·ٌ';
			break 1;
		case 1:
			$row_rule['import'] = 'تا';
			break 1;
	}
	$row_rule[date] = qbase::formatTime('Y-m-d H:i:s',$row_rule[date]);
	$lists[] = $row_rule;
}
include qbase::template( $path . '/' .  'link_show' );
?>
