<?php
session_start();
ob_start();
include("config.php");
if (isset($_GET['p']) && $_GET['p'] == "login") {
$username=mysql_real_escape_string($_POST['username']);
$password=mysql_real_escape_string($_POST['password']);
$login_user = mysql_fetch_array(mysql_query("SELECT * FROM `users` where `user`='$username'"));
$username_check=$login_user['user'];
$password_check=$login_user['pass'];
if($_SESSION['img']==$_POST['security'])
{
if(!$username || !$password)
{
$error="<p align=right><font color='#FF0000' face='Tahoma' style='font-size: 8pt'>لطفا تمامي فيل ها را كامل كنيد.</font></p>";
}else{
if ($username == $username_check || $password==$password_check) {
$_SESSION["resller_on"]="true";
$_SESSION["resller_username"]=$username_check;
$_SESSION["resller_password"]=$password_check;
if($username_check=="admin")
{
echo <<<HTML
<meta http-equiv="refresh" content="0; url= admin.php">
HTML;
}else{
echo <<<HTML
<meta http-equiv="refresh" content="0; url= user.php">
HTML;
}
} else {
$error= "<p align=right><font color='#FF0000' face='Tahoma' style='font-size: 8pt'>متاسفانه کلمه عبور / نام کاربری شما مجاز نیست</font></p>";
}
}
}else{
$error="<p align=right><font color='#FF0000' face='Tahoma' style='font-size: 8pt'>كد امنيتي اشباه است.</font></p>";
}
}
if ($_SESSION["resller_on"] == "true") {
if(check()=="user_1")
{
echo <<<HTML
<meta http-equiv="refresh" content="0; url= user.php">
HTML;
}else if(check()=="admin_1")
{
echo <<<HTML
<meta http-equiv="refresh" content="0; url= admin.php">
HTML;
}
}else{
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>ورود</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/style.css">
<!--[if lte IE 8]>
<script type="text/javascript" src="js/html5.js"></script>
<![endif]-->
</head>
<body>
<header id="top">
<div class="container_12 clearfix">
<div id="logo" class="grid_12">
<!-- replace with your website title or logo -->
<a id="site-title" href="#">مدیریت سایت</a>
</div>
</div>
</header>
<div id="login" class="box">
<h2>ورود به پنل کاربری</h2>
<section>
<form action="?p=login" method="post">
<dl>
<dt><label for="username">نام کاربری</label></dt>
<dd><input id="username" name="username" type="text" /></dd>
<dt><label for="adminpassword">رمز عبور</label></dt>
<dd><input name="password" id="adminpassword" type="password" /></dd>
<dt><label for="sec">کد امنیتی</label></dt>
<dd><img id="sec" border="0" src="img/img.php" />
<a href="#" onClick="document.getElementById('sec').src = 'img/img.php?id='+randnumber(); return false"><img src="images/refresh.png" width="20" height="20"/></a>
</dd>
<dt><label for="secnum">کد امنیتی را در کادر پایین وارد نمایید</label></dt>
<dd><input name="security" id="secnum" type="text" /></dd>
</dl>
<p>
<button type="submit" name="login" class="button gray" id="loginbtn">ورود</button>
<button type="reset" name="reset" class="button red" id="loginbtn">انصراف</button>
</p>
<?php
echo $error;
$error='';
?>
<p>آی پی شما <?php echo $_SERVER['REMOTE_ADDR'];?> می باشد. تمامی اطلاعات شما در سایت ذخیره خواهد شد</p>
</form>
<a href="registration.php">
<button name="signup" class="button green" id="loginbtn">ثبت نام</button>
</a>
</section>
</div>
<div style="position:absolute; overflow:hidden; left:400px; top:50px; width:600px; height:auto;padding:4px;background-color:white;border-radius:8px;text-align:center;font-family:tahoma;font-size:12px;">
<div class="ed">
<font face="Hilda Sonnenschein Dingbats" color="blue" size="3" class="ws19"><p align="right">برای استفاده از امکانات رایگان سایت ثبت نام کنید و وارد پنل کاربری خود شوید </p></font>
</div>
</div>
</body>
</html>
<?php }?>