本文整理匯總了PHP中Handler::before方法的典型用法代碼示例。如果您正苦於以下問題:PHP Handler::before方法的具體用法?PHP Handler::before怎麽用?PHP Handler::before使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Handler
的用法示例。
在下文中一共展示了Handler::before方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: before
function before($method)
{
if (parent::before($method)) {
header("Content-Type: text/json");
if (!$_SESSION["uid"] && $method != "login" && $method != "isloggedin") {
$this->wrap(self::STATUS_ERR, array("error" => 'NOT_LOGGED_IN'));
return false;
}
if ($_SESSION["uid"] && $method != "logout" && !get_pref('ENABLE_API_ACCESS')) {
$this->wrap(self::STATUS_ERR, array("error" => 'API_DISABLED'));
return false;
}
$this->seq = (int) $_REQUEST['seq'];
return true;
}
return false;
}
示例2: before
function before($method)
{
return parent::before($method) && $_SESSION['uid'];
}
示例3: before
function before($method)
{
// Check for all client in Android except ReadKit in Mac, Mr. Reader and Dalvik
if (strpos($_SERVER['HTTP_USER_AGENT'], "Dalvik") !== false || strpos($_SERVER['HTTP_USER_AGENT'], "ReadKit") !== false || strpos($_SERVER['HTTP_USER_AGENT'], "Mr. Reader") !== false) {
$this->ID_HACK_FOR_MRREADER = 0;
} else {
$this->ID_HACK_FOR_MRREADER = 1;
// and readkit and dalvik...
}
if (parent::before($method)) {
if (self::DEBUG) {
// add request to debug log
file_put_contents(self::DEBUG_FILE, 'parameter: ' . json_encode($_REQUEST) . "\n", FILE_APPEND);
}
// set the user from the db
$this->setUser();
// are we xml or json?
$this->setXml();
if ($this->xml) {
header("Content-Type: text/xml");
} else {
header("Content-Type: application/json");
}
// check we have a valid user
if (!$_SESSION["uid"]) {
$this->wrap(self::STATUS_ERR, NULL);
return false;
}
// check if user has api access enabled
if ($_SESSION["uid"] && !get_pref('ENABLE_API_ACCESS')) {
$this->wrap(self::STATUS_ERR, NULL);
return false;
}
return true;
}
return false;
}