Beispiel #1
0
 /**
  * 更新用户信息
  * @param $set
  * @return unknown_type
  */
 function updateStatus($set = null)
 {
     if (empty($set)) {
         $set = array(self::$lastlogin => date('Y-m-d H:i:s'), self::$lastip => Swoole_client::getIP());
     }
     $this->db->update($this->user['id'], $set, $this->table);
 }
Beispiel #2
0
 /**
  * 运行
  * @return unknown_type
  */
 function worker()
 {
     $ip = Swoole_client::getIP();
     if (count($this->access_ip) > 0 and !in_array($ip, $this->access_ip)) {
         return $this->error(1);
     }
     $auth_func = $this->auth;
     if (!$auth_func or $auth_func(trim($_GET['user']), trim($_GET['pass']))) {
         unset($_GET['user'], $_GET['pass']);
         if (!empty($_GET['func'])) {
             $func = trim($_GET['func']);
             unset($_GET['func']);
             if (isset($this->func_list[$func])) {
                 $func = $this->func_list[$func];
                 if (!function_exists($func)) {
                     return $this->error(2);
                 }
                 return json_encode(call_user_func_array($func, $_GET));
             } else {
                 return $this->error(3);
             }
         } elseif (!empty($_GET['class']) and !empty($_GET['method'])) {
             $class = trim($_GET['class']);
             $method = trim($_GET['method']);
             unset($_GET['class'], $_GET['method']);
             if (isset($this->class_list[$class])) {
                 $class = $this->class_list[$class];
                 $obj = new $class();
                 if (!method_exists($obj, $method)) {
                     return $this->error(4);
                 }
                 foreach ($_GET as $k => $g) {
                     $obj->{$k} = $g;
                 }
                 return json_encode(call_user_func_array(array($obj, $method), $_POST));
             } else {
                 return $this->error(5);
             }
         }
     } else {
         return $this->error(6);
     }
 }
Beispiel #3
0
function http_redirect($url, $mode = 301)
{
    Swoole_client::redirect($url, $mode);
}
Beispiel #4
0
 static function raise($text = false)
 {
     if (self::$error_url) {
         Swoole_client::redirect(self::$error_url);
     }
     if ($text) {
         exit($text);
     } else {
         exit('Web input param error!');
     }
 }