<?
session_start();
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";
echo $tpl->display("headerinclude.html");
//start qurey
//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);
 echo $tpl->display("header.html");
echo $tpl->display("bodyinclude.html");
if ($_POST['username'] == '' or $_POST['password'] == ''){
$message ="$lang[rongpass]
<br><b><a href='index.html'>$lang[back]</a></b>
";
echo $tpl->display("message.html");
traidntright();
echo $tpl->display("footer.html");
exit();
}

$username = trim($_POST['username']);
$username = mysql_real_escape_string($username);
$pass = trim($_POST['password']);
$pass = mysql_real_escape_string($pass);
$password = md5($pass);

$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[rongpass]
<br><b><a href='index.html'>$lang[back]</a></b>
";
echo $tpl->display("message.html");
echo $tpl->display("footer.html");
exit();
}else{while ($user =  @mysql_fetch_assoc($getuser)){$userid = $user[user_id];
$username = $user[user_name];
$uservisite = $user[user_visit];
$group = $user[user_group];
}
if(($group)==('2')){$message ="
$lang[waitactiv]&nbsp;
<br><b><a href='index.php'>$lang[back]</a></b>
";
echo $tpl->display("message.html");
traidntright();
echo $tpl->display("footer.html");
exit();
}elseif(($group)==('3')){$message ="
$lang[band]
<br><b><a href='index.html'>$lang[back]</a></b>

";
echo $tpl->display("message.html");
traidntright();
echo $tpl->display("footer.html");
exit();

}else{
$ip=  $_SERVER[REMOTE_ADDR];
$visit = date('d-m-Y');
$update = mysql_db_query("$dbName", "UPDATE `users` SET `user_visit` = '$visit' WHERE `users`.`user_id` ='$userid' LIMIT 1 ;") ;
$updateonline = @mysql_db_query("$dbName", "UPDATE `online` SET `user_name` = '$username' WHERE `online`.`online_ip` = '$ip' LIMIT 1 ;") ;
$_SESSION[userid] = $userid;
$_SESSION[usergroup] = $group;
@setcookie('traidusername',$username,time()+3600);
@setcookie('traiduserpassword',$password,time()+3600);
@setcookie('traidlastvisit',$uservisite,time()+3600);
@setcookie('traiduserid',$userid,time()+3600);
$refre = $_SERVER['HTTP_REFERER'];
$message ="
<b>$lang[suclogin]</b>
<br><a href='index.php'><b><span style='text-decoration: none'>$lang[notredirect]</span></b></a>
<META HTTP-EQUIV='Refresh' CONTENT='2; url=$refre'>
";
echo $tpl->display("message.html");

}

}

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

ob_end_flush();
?>