Ejemplo n.º 1
0
 /**
  * This is the action to handle external exceptions.
  */
 public function actionError()
 {
     if ($error = Yii::app()->errorHandler->error) {
         if (Yii::app()->request->isAjaxRequest || MiniHttp::isPCClient()) {
             echo $error['message'];
         } else {
             $this->render('error', $error);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * 判断是否是Web浏览器
  * 通过referer判断是否是浏览器客户端
  */
 public static function clientIsBrowser()
 {
     //如是PC客户端,则也遵循浏览器的逻辑
     if (MiniHttp::isPCClient()) {
         return true;
     }
     if (array_key_exists("client_id", $_REQUEST)) {
         if ($_REQUEST["client_id"] === "JsQCsjF3yr7KACyT") {
             return true;
         } else {
             return false;
         }
     }
     if (array_key_exists("HTTP_REFERER", $_SERVER)) {
         $refer = $_SERVER["HTTP_REFERER"];
         if (!empty($refer)) {
             return true;
         }
     }
     if (array_key_exists("PHPSESSID", $_COOKIE)) {
         return true;
     }
     return false;
 }
Ejemplo n.º 3
0
 /**
  * 获得当前登录的设备
  * @param $user
  * @return null
  */
 private function getCurrentDevice($user)
 {
     $deviceType = 1;
     if (MiniHttp::isPCClient()) {
         if (MiniHttp::isWindowsOS()) {
             $deviceType = 2;
             //Windows 客户端
         } else {
             if (MiniHttp::isMacOS()) {
                 $deviceType = 3;
                 //Mac 客户端
             } else {
                 $deviceType = 5;
                 //Linux 客户端
             }
         }
     }
     //对设备进行检测
     if ($deviceType == 1) {
         $device = DeviceManager::getDevice($user["id"], MConst::DEVICE_WEB, "web", $_SERVER['HTTP_USER_AGENT']);
     } else {
         $device = MiniUserDevice::getInstance()->getFirstByDeviceTypeAndDeviceName($user["id"], $deviceType);
     }
     return $device;
 }