예제 #1
0
 /**
  *
  * @param string $social_id identifire from social site 
  * @param string $provider social site name
  * @return id user or false
  */
 public static function social_login($social_id, $provider, $sessionTime = NULL)
 {
     //$sessionTime =($sessionTime)?$sessionTime:rad_config::getParam('CookieExpireTime');
     $provider_row = 'u_' . $provider . '_id';
     $id = rad_dbpdo::query('SELECT u_id, u_email, u_pass, is_admin FROM ' . RAD . 'users WHERE `' . $provider_row . '`=:' . $provider_row, array($provider_row => $social_id));
     if (!empty($id['u_id'])) {
         self::$error_code = 0;
         self::$is_admin = $id['is_admin'];
         self::$user = rad_user::getUserByID($id['u_id']);
         rad_user::setUser(self::$user);
         $_SESSION['user_dump'] = self::$user;
         $_SESSION['user'] = $id['u_email'];
         $_SESSION['pass'] = md5($id['u_pass']);
         return self::$user;
     }
     self::$error_code = self::ERROR_WRONG_PASSWORD;
     return false;
 }