<?
ob_start("ob_gzhandler");
include("./includes/config.php");
include("./lang/arabic.php");
include("./includes/function.php");
include("./includes/online.php");
include("./includes/easytemplate.php");
include("./includes/inquiry.php");
$PhpGroup_style['def_style'] = "designs/$style";
$stylepath= $PhpGroup_style['def_style'];
$tpl = new EasyTemplate;
$tpl->Temp = $PhpGroup_style['def_style'];
$tpl->Cache = "easycache";

//get the can name in the right page
$selectc = @mysql_db_query("$dbName", "SELECT * FROM `cat`  WHERE `cat_group` = '1' ORDER BY `cat`.`cat_display` ASC  ") ;
while ($s =  @mysql_fetch_assoc($selectc)){
$cat[] =   $s  ;
}
@mysql_free_result($selectc);

//loginbox
loginbox( $login );



//get the last new poem
$selectnewdivan = mysql_db_query("$dbName", "SELECT * FROM `divan`  WHERE `divan_group` = '1' ORDER BY `divan_id` DESC LIMIT 10 ") ;
while ($ndivan =  @mysql_fetch_assoc($selectnewdivan)){
$nd[] =   $ndivan  ;
}

@mysql_free_result($selectnewdivan);



//statistics
$selectcount= mysql_db_query("$dbName", "SELECT * FROM  cat;") ;
$totalcat = mysql_affected_rows();
@mysql_free_result($selectcount);
$selectcount= mysql_db_query("$dbName", "SELECT * FROM  divan;") ;
$totaldivan = mysql_affected_rows();
@mysql_free_result($selectcount);
$selectcount= mysql_db_query("$dbName", "SELECT * FROM  users;") ;
$totalusers = mysql_affected_rows();
@mysql_free_result($selectcount);

//getcat info

$username = $_COOKIE[traidusername];
$password = $_COOKIE[traiduserpassword];
$userid = $_COOKIE[traiduserid];


$subtitle = "&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;المفلضة   ";

echo $tpl->display("headerinclude.html");
//header
echo $tpl->display("header.html");
//endheader
 echo $tpl->display("bodyinclude.html");

 if (($close) == ('yes')){
echo $tpl->display("message.html");
traidntright();
echo $tpl->display("footer.html");
exit();
}

if(($username)==('')){
$message = "من فضلك قم بتسجيل الدخول";
@setcookie('traidusername',$username,time()-36000);
echo $tpl->display("message.html");
traidntright();
echo $tpl->display("footer.html");
exit();
}


$getuser = mysql_db_query("$dbName", "SELECT * FROM  `users` WHERE `user_name` = '$username' and `user_password` = '$password' and `user_id` = '$userid' ;") ;
$find = mysql_affected_rows();
if(($find)==('0')){

$message = "عفوا قم باعاده تسجيل الدخول";
@setcookie('traidusername',$username,time()-36000);
echo $tpl->display("message.html");
traidntright();
echo $tpl->display("footer.html");
exit();
}

//page body

$selectcatpoem = mysql_db_query("$dbName", "SELECT * FROM `favorite` WHERE `user_id` = '$userid'  ORDER BY `favorite`.`fav_id` DESC   ") ;
$totalpoumincat = mysql_affected_rows();
if(($totalpoumincat)==('0')){
$message = "لا يوجد قصائد بمفضلتك";
echo $tpl->display("message.html");
}else{
//get poem
while ($catdivan =  @mysql_fetch_assoc($selectcatpoem)){
$cp[] =   $catdivan  ;
$diid = $catdivan[divan_id];
}

 //


 //
//get poum
echo "<br>".$tpl->display("viewfav.html");

}

//page body
//page left
//get most divan visit

traidntright();
echo $tpl->display("footer.html");
//page footer

ob_end_flush();
?>