<?
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_id` 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 ") ;
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);


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();
}

//coment
$username = $_COOKIE[traidusername];
$password = $_COOKIE[traiduserpassword];
if(!isset($_COOKIE[traidusername])  ){
$message = $lang[commforuser];
}else{
$getuser = mysql_db_query("$dbName", "SELECT * FROM  `users` WHERE `user_name` = '$username' and `user_password` = '$password' ;") ;
$find = mysql_affected_rows();
if(($find)==('0')){

$message = $lang[relogin];
@setcookie('traidusername',$username,time()-36000);
}else{
$comment = trim($_POST[C1]);
$newcomment = nl2br($comment);
$vcode = trim($_POST[vcode]);
$poeimid = trim($_POST[poeimid]);
$code = md5($vcode);
$cp = $_SESSION['key'];
$ref = $_SERVER['HTTP_REFERER'];
$time = date('d-m-Y');
if(($code)!=($cp)){
$message = "<p align='center'>$lang[falsecode]<br><a href='javascript:history.back()'>$lang[goback]</a></p>";
}elseif(($newcomment)==('')){
$message = "<p align='center'>$lang[emptycomment]<br><a href='javascript:history.back()'>$lang[goback]</a></p>";
}else{
if(eregi(">",$comment)) {
$message = " يمنع استخدام الاكواد<br><a href='javascript:history.back()'>$lang[goback]</a></p>";
}else{
$addcomtodb = mysql_db_query("$dbName", "INSERT INTO `comments` ( `comment_id` , `comment_value` , `comment_group` , `comment_date` , `divan_id` , `user_name` )
VALUES (NULL , '$newcomment', '2', '$time', '$poeimid', '$username');") ;
if($addcomtodb){
$message = "$lang[waitapp]<br><a href='javascript:history.back()'>$lang[goback]</a></p>";
	 echo"<META HTTP-EQUIV='Refresh' CONTENT='2; url=$ref'>";
	}else{
  $message= "
$lang[addcommpr]<br><a href='javascript:history.back()'>$lang[goback]</a></p>
  ";
  echo"<META HTTP-EQUIV='Refresh' CONTENT='2; url=$ref'>";
	}

}

}

}
}

//comet

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

ob_end_flush();
?>