View file base/Users.php

File size: 2.32Kb
<? //by rine(Andrey Arapov) & BEPDuKT(Aleksey Ivanov) site: dizkod.ru


	/**
	 * CLASS USERS
	 * Author given violin RAINE
	 * Participant of the group DECO
	 * E-mail: [email protected] OR [email protected]
	 * ICQ:9927785
	 */






class Users extends Base
{
	private $login;
	private $password;


 function __construct()
 {

 }

 public function check($login,$password)
 {
 	$this->login = Base::filter($login);
 	$this->password =  Base::filter($password);
    $prov = mysql_query("SELECT * FROM `user` WHERE `login`='".$this->login."' AND `pass`='".$this->password."' LIMIT 1");
    if(!mysql_num_rows($prov))
{
	return 0;
}else{
	return 1;
}

 }
  public function set($set,$login,$password)
  {
  	if($set==0){
  		Base::head('ERROR');
  		echo 'Ошибка авторизации!!!';
  		Base::foot();
  		}else{

  			setcookie('user',1,time()+60*60*24*365);
  			setcookie('login',$login,time()+60*60*24*365);
  			setcookie('password',$password,time()+60*60*24*365);

        $_SESSION['user']=true;
		$_SESSION['login']=$login;
		$_SESSION['password']=$password;
  		header('Location: /panel.php');
  		}
  }
   public function sess(){
   		$users=$_SESSION['user'];
   if($users!=true){
   	if($_COOKIE[user] == 1){
      $_SESSION['login']=$_COOKIE[login];
		$_SESSION['password']=$_COOKIE[password];
	}else{
   		Base::head('ERROR');
  		echo 'Ошибка авторизации!!!';
  		Base::foot();
  		exit;
  		}}


}
   public function user($set='assoc',$param,$imp)
   {

   	if((empty($set)) && (empty($param)) && (empty($imp)))
   	{
   		echo 'Ошибка!!!Выбор данных из бд по $param не выполнен!';
   	}
    if($set=='assoc')
    {
    	return mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `$param`='$imp'"));
    }
    if($set=='num')
    {
    	return mysql_num_rows(mysql_query("SELECT * FROM `user` WHERE `$param`='$imp'"));
    }

     }
   public function access()
   {
   	$login=$_SESSION['login'];
   	$access=mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `login`='".$login."'"));

   	return $access['level'];

   }


    public function dostup()
   {
  
  
   	$access=$this->access();
   if($access==0){
   
   echo "Pizda vam!";
   self::foot();
   exit;
   }
   
   }
   
   
   
   
}
?>