<?php

require_once 'core/system.php'; 


unreg();



if(isset($_GET['exit'])){
	setcookie('login', '', time()-1, '/');
	setcookie('pass', '', time()-1, '/');
	session_destroy();
	header("Location: ../index.php");
	exit;
}

if(isset($_GET) and !empty($_GET['login']) and !empty($_GET['pass'])){
	$login = protect($_GET['login'], 12);
	$password = protect(md5_sault($_GET['pass']));
$check = $dbc->query("SELECT * FROM `users` WHERE `login` = '".$login."' and `pass` = '".$password."'"); $check = $check->num_rows;


	if($check == 0)	{
	
		head('Авторизация');
		

$_SESSION['log']='<font color=red>Данные не верны</font>'; header('location:sign');
		exit;
		
	}	else	{
		setcookie('login', $login, time()+3600*24*365, '/');
		setcookie('pass', $password, time()+3600*24*365, '/');
		
		head('Авторизация');
		
			if(!empty($_GET['r'])){
		$r = int($_GET['r']);
$test_ref = $dbc->query("SELECT `id`,`login` FROM `users` WHERE `id`='".$r."' LIMIT 1")-fetch_assoc();


			if($test_ref and $test_ref['login']!= $login){
$id_ref_us= $dbc->query("SELECT `id` FROM `users` WHERE `login`='".$login."' and `pass` = '".$password."' LIMIT 1")->fetch_assoc();


$test_ref = $dbc->query("SELECT `id` FROM `referal` WHERE `user_ref`='".$id_ref_us['id']."'"); $test_ref = $test_ref->num_rows;


			if($test_ref == 0){
		$dbc->query("INSERT INTO `referal` SET

		`ref_id`='".$r."',
		`user_ref`='".$id_ref_us['id']."',
		`time`='".time()."',
		`ok`='0'");
				}
			}
		}
		header ("Location: ../index.php");exit;
//echo "<html><head><meta http-equiv='Refresh' content='0; URL=index.php'></head></html>";
	}
}
head('Авторизация');

if (isset($_SESSION['log'])){?><center><?=$_SESSION['log']?><center><?   $_SESSION['log']=NULL; }



?><style>

body {
background: url('/img/start3.png') 80% 0 no-repeat #000; }

   
 .flash {
       
    text-align: center;
    font-size: 10px;
    color: #fff;
    padding: 0 0 17px 0;
    
     padding-top: 22%
    
       
   }  
   
   
   
   
.w160px {width: 260px;}
.mt110 {margin-top:109px;}
.start
{color: yellow;}
body
{ background-color: #
000; background-position: top
center; }
.back-start
{ background: #000 url('/img/start3.png') top center no-repeat; display: block;

</style><?


echo'<center>

</br></br></br></br><div class="flash">


<form action="sign" method="get">
<span class=info><b>Логин:</b></span>


<br/>
<div class="form-field">
<input class="nixwar" style="width:68%; height:20px; color: violet; box-shadow: 0 0 30px;" name="login" type="text">
</div>

<br/>
<span class=info><b>Пароль:</span></b>

<br/>
<div class="form-field">
<input class="nixwar" style="width:68%; height:20px; color: violet; box-shadow: 0 0 30px;" name="pass" type="password">
</div>
</br>


<input type="image" height="43"width="218 id="submit" alt="login"
       src="/img/StartGame/entergame.png">







</div>
</div>
</form>

  
<a href="/recovery.php?pass" class="start"><img height="43"width="218" src="/img/StartGame/forgotpassword.png" alt="Забыли Пароль" border="0"></a>

  
  
  
</br></br> </div>
';


?>