当前位置: 首页>>代码示例>>PHP>>正文


PHP AJXP_Utils::osFromUserAgent方法代码示例

本文整理汇总了PHP中AJXP_Utils::osFromUserAgent方法的典型用法代码示例。如果您正苦于以下问题:PHP AJXP_Utils::osFromUserAgent方法的具体用法?PHP AJXP_Utils::osFromUserAgent怎么用?PHP AJXP_Utils::osFromUserAgent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AJXP_Utils的用法示例。


在下文中一共展示了AJXP_Utils::osFromUserAgent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authTokenActions

 /**
  * @param String $action
  * @param Array $httpVars
  * @param Array $fileVars
  * @return String
  */
 function authTokenActions($action, $httpVars, $fileVars)
 {
     if (AuthService::getLoggedUser() == null) {
         return;
     }
     $this->storage = ConfService::getConfStorageImpl();
     if (!is_a($this->storage, "sqlConfDriver")) {
         return false;
     }
     $user = AuthService::getLoggedUser()->getId();
     if (AuthService::getLoggedUser()->isAdmin() && isset($httpVars["user_id"])) {
         $user = AJXP_Utils::sanitize($httpVars["user_id"], AJXP_SANITIZE_EMAILCHARS);
     }
     switch ($action) {
         case "keystore_generate_auth_token":
             if (ConfService::getCoreConf("SESSION_SET_CREDENTIALS", "auth")) {
                 $this->logDebug("Keystore Generate Tokens", "Session Credentials set: returning empty tokens to force basic authentication");
                 HTMLWriter::charsetHeader("text/plain");
                 echo "";
                 break;
             }
             $token = AJXP_Utils::generateRandomString();
             $private = AJXP_Utils::generateRandomString();
             $data = array("USER_ID" => $user, "PRIVATE" => $private);
             if (!empty($httpVars["device"])) {
                 // Revoke previous tokens for this device
                 $device = $httpVars["device"];
                 $keys = $this->storage->simpleStoreList("keystore", null, "", "serial", '%"DEVICE_ID";s:' . strlen($device) . ':"' . $device . '"%');
                 foreach ($keys as $keyId => $keyData) {
                     if ($keyData["USER_ID"] != $user) {
                         continue;
                     }
                     $this->storage->simpleStoreClear("keystore", $keyId);
                 }
                 $data["DEVICE_ID"] = $device;
             }
             $data["DEVICE_UA"] = $_SERVER['HTTP_USER_AGENT'];
             $data["DEVICE_IP"] = $_SERVER['REMOTE_ADDR'];
             $this->storage->simpleStoreSet("keystore", $token, $data, "serial");
             HTMLWriter::charsetHeader("application/json");
             echo json_encode(array("t" => $token, "p" => $private));
             break;
         case "keystore_revoke_tokens":
             // Invalidate previous tokens
             $mess = ConfService::getMessages();
             $passedKeyId = "";
             if (isset($httpVars["key_id"])) {
                 $passedKeyId = $httpVars["key_id"];
             }
             $keys = $this->storage->simpleStoreList("keystore", null, $passedKeyId, "serial", '%"USER_ID";s:' . strlen($user) . ':"' . $user . '"%');
             foreach ($keys as $keyId => $keyData) {
                 $this->storage->simpleStoreClear("keystore", $keyId);
             }
             $message = array("result" => "SUCCESS", "message" => $mess["keystore.8"]);
             HTMLWriter::charsetHeader("application/json");
             echo json_encode($message);
             break;
         case "keystore_list_tokens":
             if (!isset($user)) {
                 break;
             }
             $keys = $this->storage->simpleStoreList("keystore", null, "", "serial", '%"USER_ID";s:' . strlen($user) . ':"' . $user . '"%');
             foreach ($keys as $keyId => &$keyData) {
                 unset($keyData["PRIVATE"]);
                 unset($keyData["USER_ID"]);
                 $deviceDesc = "Web Browser";
                 $deviceOS = "Unkown";
                 if (isset($keyData["DEVICE_UA"])) {
                     $agent = $keyData["DEVICE_UA"];
                     if (strpos($agent, "python-requests") !== false) {
                         $deviceDesc = "PydioSync";
                         if (strpos($agent, "Darwin") !== false) {
                             $deviceOS = "Mac OS X";
                         } else {
                             if (strpos($agent, "Windows/7") !== false) {
                                 $deviceOS = "Windows 7";
                             } else {
                                 if (strpos($agent, "Windows/8") !== false) {
                                     $deviceOS = "Windows 8";
                                 } else {
                                     if (strpos($agent, "Linux") !== false) {
                                         $deviceOS = "Linux";
                                     }
                                 }
                             }
                         }
                     } else {
                         $deviceOS = AJXP_Utils::osFromUserAgent($agent);
                     }
                 }
                 $keyData["DEVICE_DESC"] = $deviceDesc;
                 $keyData["DEVICE_OS"] = $deviceOS;
             }
             header("Content-type: application/json;");
//.........这里部分代码省略.........
开发者ID:ad-m,项目名称:pydio-core,代码行数:101,代码来源:class.KeystoreAuthFrontend.php


注:本文中的AJXP_Utils::osFromUserAgent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。