本文整理汇总了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;");
//.........这里部分代码省略.........