本文整理汇总了PHP中AuthService::getSecureToken方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthService::getSecureToken方法的具体用法?PHP AuthService::getSecureToken怎么用?PHP AuthService::getSecureToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthService
的用法示例。
在下文中一共展示了AuthService::getSecureToken方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switchAction
public function switchAction($action, $httpVars, $postProcessData)
{
if (!isset($this->actions[$action])) {
return false;
}
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(false)) {
return false;
}
$plugin = AJXP_PluginsService::findPlugin("access", $repository->getAccessType());
$streamData = $plugin->detectStreamWrapper(true);
$destStreamURL = $streamData["protocol"] . "://" . $repository->getId() . "/";
if ($action == "audio_proxy") {
$file = AJXP_Utils::decodeSecureMagic(base64_decode($httpVars["file"]));
$cType = "audio/" . array_pop(explode(".", $file));
$localName = basename($file);
header("Content-Type: " . $cType . "; name=\"" . $localName . "\"");
header("Content-Length: " . filesize($destStreamURL . $file));
$stream = fopen("php://output", "a");
call_user_func(array($streamData["classname"], "copyFileInStream"), $destStreamURL . $file, $stream);
fflush($stream);
fclose($stream);
$node = new AJXP_Node($destStreamURL . $file);
AJXP_Controller::applyHook("node.read", array($node));
//exit(1);
} else {
if ($action == "ls") {
if (!isset($httpVars["playlist"])) {
// This should not happen anyway, because of the applyCondition.
AJXP_Controller::passProcessDataThrough($postProcessData);
return;
}
// We transform the XML into XSPF
$xmlString = $postProcessData["ob_output"];
$xmlDoc = new DOMDocument();
$xmlDoc->loadXML($xmlString);
$xElement = $xmlDoc->documentElement;
header("Content-Type:application/xspf+xml;charset=UTF-8");
print '<?xml version="1.0" encoding="UTF-8"?>';
print '<playlist version="1" xmlns="http://xspf.org/ns/0/">';
print "<trackList>";
foreach ($xElement->childNodes as $child) {
$isFile = $child->getAttribute("is_file") == "true";
$label = $child->getAttribute("text");
$ar = explode(".", $label);
$ext = strtolower(end($ar));
if (!$isFile || $ext != "mp3") {
continue;
}
print "<track><location>" . AJXP_SERVER_ACCESS . "?secure_token=" . AuthService::getSecureToken() . "&get_action=audio_proxy&file=" . base64_encode($child->getAttribute("filename")) . "</location><title>" . $label . "</title></track>";
}
print "</trackList>";
AJXP_XMLWriter::close("playlist");
}
}
}
示例2: strpos
$action = "ping";
if (preg_match('/MSIE 7/', $_SERVER['HTTP_USER_AGENT']) || preg_match('/MSIE 8/', $_SERVER['HTTP_USER_AGENT'])) {
$action = "get_boot_gui";
} else {
$action = strpos($_SERVER["HTTP_ACCEPT"], "text/html") !== false ? "get_boot_gui" : "ping";
}
if (isset($_GET["action"]) || isset($_GET["get_action"])) {
$action = isset($_GET["get_action"]) ? $_GET["get_action"] : $_GET["action"];
} else {
if (isset($_POST["action"]) || isset($_POST["get_action"])) {
$action = isset($_POST["get_action"]) ? $_POST["get_action"] : $_POST["action"];
}
}
$pluginsUnSecureActions = ConfService::getDeclaredUnsecureActions();
$unSecureActions = array_merge($pluginsUnSecureActions, array("get_secure_token"));
if (!in_array($action, $unSecureActions) && AuthService::getSecureToken()) {
$token = "";
if (isset($_GET["secure_token"])) {
$token = $_GET["secure_token"];
} else {
if (isset($_POST["secure_token"])) {
$token = $_POST["secure_token"];
}
}
if ($token == "" || !AuthService::checkSecureToken($token)) {
throw new Exception("You are not allowed to access this resource.");
}
}
if (AuthService::usersEnabled()) {
$httpVars = array_merge($_GET, $_POST);
AuthService::logUser(null, null);
示例3: switchAction
public function switchAction($action, $httpVars, $postProcessData)
{
$repository = ConfService::getRepository();
if (!$repository->detectStreamWrapper(false)) {
return false;
}
if ($action == "audio_proxy") {
$selection = new UserSelection($repository, $httpVars);
$destStreamURL = $selection->currentBaseUrl();
$node = new AJXP_Node($destStreamURL . "/" . $selection->getUniqueFile());
// Backward compat
// May be a backward compatibility problem, try to base64decode the filepath
if (!file_exists($node->getUrl()) && strpos($httpVars["file"], "base64encoded:") === false) {
$file = AJXP_Utils::decodeSecureMagic(base64_decode($httpVars["file"]));
if (!file_exists($destStreamURL . $file)) {
throw new Exception("Cannot find file!");
} else {
$node = new AJXP_Node($destStreamURL . $file);
}
}
if (!is_readable($node->getUrl())) {
throw new Exception("Cannot find file!");
}
$fileUrl = $node->getUrl();
$localName = basename($fileUrl);
$cType = "audio/" . array_pop(explode(".", $localName));
$size = filesize($node->getUrl());
header("Content-Type: " . $cType . "; name=\"" . $localName . "\"");
header("Content-Length: " . $size);
$stream = fopen("php://output", "a");
AJXP_MetaStreamWrapper::copyFileInStream($fileUrl, $stream);
fflush($stream);
fclose($stream);
AJXP_Controller::applyHook("node.read", array($node));
$this->logInfo('Preview', 'Read content of ' . $node->getUrl(), array("files" => $node->getUrl()));
//exit(1);
} else {
if ($action == "ls") {
if (!isset($httpVars["playlist"])) {
// This should not happen anyway, because of the applyCondition.
AJXP_Controller::passProcessDataThrough($postProcessData);
return false;
}
// We transform the XML into XSPF
$xmlString = $postProcessData["ob_output"];
$xmlDoc = new DOMDocument();
$xmlDoc->loadXML($xmlString);
$xElement = $xmlDoc->documentElement;
header("Content-Type:application/xspf+xml;charset=UTF-8");
print '<?xml version="1.0" encoding="UTF-8"?>';
print '<playlist version="1" xmlns="http://xspf.org/ns/0/">';
print "<trackList>";
foreach ($xElement->childNodes as $child) {
$isFile = $child->getAttribute("is_file") == "true";
$label = $child->getAttribute("text");
$ar = explode(".", $label);
$ext = strtolower(end($ar));
if (!$isFile || $ext != "mp3") {
continue;
}
print "<track><location>" . AJXP_SERVER_ACCESS . "?secure_token=" . AuthService::getSecureToken() . "&get_action=audio_proxy&file=" . base64_encode($child->getAttribute("filename")) . "</location><title>" . $label . "</title></track>";
}
print "</trackList>";
AJXP_XMLWriter::close("playlist");
}
}
}