本文整理汇总了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;
}