Example #1
0
 public static function signin($login, $password)
 {
     $password = sha1(md5($password));
     $user = DB::toRow("SELECT users.* FROM users WHERE (email='{$login}' or login='******')");
     if (!$user->id) {
         Session::set('auth_error', 'USER_UNKNOWN');
     } elseif ($user->password != $password) {
         Session::set('auth_error', 'PASSWORD_WRONG');
     } elseif (!$user->status) {
         Session::set('auth_error', 'ACCESS_DENID');
     } else {
         $auth = new stdClass();
         foreach ($user as $f => $v) {
             $auth->{$f} = $v;
         }
         if (!empty($auth->src)) {
             $auth->src = LOCALHOST . "assets/avatar/" . $auth->src;
         } elseif (empty($auth->src) and !empty($auth->facebook_id)) {
             $auth->src = "https://graph.facebook.com/" . $auth->facebook_id . "/picture?height=128";
         } else {
             $auth->src = LOCALHOST . "files/avatar/dafault.jpg";
         }
         Session::setFixed('auth', $auth);
         Session::delete('auth_error');
         return $auth;
     }
     return false;
 }