<?php

/* FIRESHOP: Advanced Content Market System                         */

/* ============================================                         */

/*                                                                      */

/* Copyright (c) 2012 by Mohamad Porhaji                                */

/* http://Firedesign.ir                                                   */

/*                                                                      */

/* This program is free software.  */

/************************************************************************/

/* $Id: page_cat.php,v 1.0.0.1 2012/02/18 By Mohamad Porhaji $ */
@session_start();
define('CAT_PAGE_FILE', true);
require_once("mainfile.php");
global $db,$pro_limit;


if(!isset($_GET['id']) or !is_numeric(@$_GET['id'])){
    Header("Location: index.php");
    die();

}else{
$id =$_GET['id'];

global $db,$pro_limit;
$id_cat=$_SESSION['CAT_ID'];
$total_pro = $db->sql_numrows($db->sql_query("SELECT * FROM fireshop_product WHERE `product_cat`='$id_cat' ")); 

$page_num=ceil($total_pro/$pro_limit);

if($id<=$page_num){

$limit=($pro_limit*$id);

$az=($limit-$pro_limit);

$page_id=$id;
}else{

}


}


$title_page_over="صفحات";
$page_title = "صفحات ";




function content(){

if(!isset($_GET['id']) or !is_numeric(@$_GET['id'])){
    Header("Location: index.php");
    die();

}else{
$id =$_GET['id'];

global $db,$pro_limit;
$id_cat=$_SESSION['CAT_ID'];
$total_pro = $db->sql_numrows($db->sql_query("SELECT * FROM fireshop_product WHERE `product_cat`='$id_cat' ")); 

$page_num=ceil($total_pro/$pro_limit);

if($id<=$page_num){

$limit=($pro_limit*$id);

$az=($limit-$pro_limit);

}else{
echo"چنين صفحه اي وجود ندارد";
}


}
}



function pagination_cat(){
echo "<link href=\"template/pagination.css\" rel=\"stylesheet\" type=\"text/css\" >\n";
if (defined('CAT_FILE'))
{  global $db,$pro_limit,$id_cat,$page_id;

$total_pro = $db->sql_numrows($db->sql_query("SELECT * FROM fireshop_product WHERE `product_cat`='$id_cat' "));
$page_num=ceil($total_pro/$pro_limit);
if($page_num>0){
echo"<br/><table dir=\"rtl\" width=\"690\">
<tr align=\"center\">
<td >
<div class=\"pagination\">
<div class=\"this_page\"><a>1</a></div>";
for($i = 2;$i<=$page_num;$i++){
if($i<=8){
echo"<div class=\"page_nav\"><a href=\"page_cat.php?id=$i\">$i</a></div>";}
}echo"<div class=\"page_t\"><a>تعداد كل صفحات : $page_num</a></div><div class=\"clear\"></div></div></td></tr></table>";}
}else{
global $db,$pro_limit,$id_cat,$page_id;
$total_pro = $db->sql_numrows($db->sql_query("SELECT * FROM fireshop_product WHERE `product_cat`='$id_cat' "));
$page_num=ceil($total_pro/$pro_limit);
if($page_num>0){
$last_page=$page_id-1;
echo"<br/><table dir=\"rtl\" width=\"690\">
<tr align=\"center\">
<td >
<div class=\"pagination\">";
if($page_id>1){echo"<div class=\"page_nav\"><a href=\"page_cat.php?id=1\"><<</a></div>";}
if($last_page>0){
echo"<div class=\"page_nav\"><a href=\"page_cat.php?id=$last_page\">$last_page</a></div>";}

echo"<div class=\"this_page\"><a>$page_id</a></div>";
for($i = $page_id;$i<$page_num;$i++){
if($i<=8){
$i_2=$i+1;

echo"

<div class=\"page_nav\"><a href=\"page_cat.php?id=$i_2\">$i_2</a></div>";}
}echo"<div class=\"page_t\"><a>تعداد كل صفحات : $page_num</a></div><div class=\"clear\"></div></div></td></tr></table>";}
}


}


theme();

?>