本文整理汇总了PHP中PageModel::find403ByPid方法的典型用法代码示例。如果您正苦于以下问题:PHP PageModel::find403ByPid方法的具体用法?PHP PageModel::find403ByPid怎么用?PHP PageModel::find403ByPid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageModel
的用法示例。
在下文中一共展示了PageModel::find403ByPid方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Generate an error 403 page
* @param integer
* @param object
*/
public function generate($pageId, $objRootPage = null)
{
// Add a log entry
$this->log('Access to page ID "' . $pageId . '" denied', 'PageError403 generate()', TL_ERROR);
// Use the given root page object if available (thanks to Andreas Schempp)
if ($objRootPage === null) {
$objRootPage = $this->getRootPageFromUrl();
} else {
$objRootPage = \PageModel::findPublishedById(is_integer($objRootPage) ? $objRootPage : $objRootPage->id);
}
// Look for an error_403 page
$obj403 = \PageModel::find403ByPid($objRootPage->id);
// Die if there is no page at all
if ($obj403 === null) {
header('HTTP/1.1 403 Forbidden');
die('Forbidden');
}
// Generate the error page
if (!$obj403->autoforward || !$obj403->jumpTo) {
global $objPage;
$objPage = $this->getPageDetails($obj403);
$objHandler = new $GLOBALS['TL_PTY']['regular']();
header('HTTP/1.1 403 Forbidden');
$objHandler->generate($objPage);
exit;
}
// Forward to another page
$objNextPage = \PageModel::findPublishedById($obj403->jumpTo);
if ($objNextPage === null) {
header('HTTP/1.1 403 Forbidden');
$this->log('Forward page ID "' . $obj403->jumpTo . '" does not exist', 'PageError403 generate()', TL_ERROR);
die('Forward page not found');
}
$this->redirect($this->generateFrontendUrl($objNextPage->row(), null, $objRootPage->language), $obj403->redirect == 'temporary' ? 302 : 301);
}
示例2: handle403
/**
* {@inheritdoc}
*/
public function handle403($pageId, \PageModel $rootPage)
{
if ($rootPage->browser_auth_basic_realm && !FE_USER_LOGGED_IN) {
$authenticate = <<<EOF
WWW-Authenticate: Basic realm="{$rootPage->browser_auth_basic_realm}"
EOF;
header('HTTP/1.1 401 Unauthorized');
header($authenticate);
// Look for an error_403 page
$obj403 = \PageModel::find403ByPid($rootPage->id);
// Die if there is no page at all
if ($obj403 === null) {
echo '403 Forbidden';
exit;
}
// Generate the error page
if (!$obj403->autoforward || !$obj403->jumpTo) {
global $objPage;
$objPage = $obj403->loadDetails();
$objHandler = new $GLOBALS['TL_PTY']['regular']();
$objHandler->generate($objPage);
exit;
}
// Forward to another page
$nextPage = \PageModel::findPublishedById($obj403->jumpTo);
if ($nextPage === null) {
$this->log('Forward page ID "' . $obj403->jumpTo . '" does not exist', 'PageError403 generate()', TL_ERROR);
die('Forward page not found');
}
$url = \Environment::get('base') . \Controller::generateFrontendUrl($nextPage->row(), null, $rootPage->language);
echo <<<EOF
<!DOCTYPE html>
<html lang="de">
<head>
<meta http-equiv="refresh" content="5; URL={$url}">
</head>
<body>
Redirecting to <a href="{$url}">{$url}</a>
</body>
</html>
EOF;
exit;
}
}
示例3: generate
/**
* Generate an error 403 page
*
* @param integer $pageId
* @param \PageModel $objRootPage
*/
public function generate($pageId, $objRootPage = null)
{
// Add a log entry
$this->log('Access to page ID "' . $pageId . '" denied', __METHOD__, TL_ERROR);
// Use the given root page object if available (thanks to Andreas Schempp)
if ($objRootPage === null) {
$objRootPage = $this->getRootPageFromUrl();
} else {
$objRootPage = \PageModel::findPublishedById(is_integer($objRootPage) ? $objRootPage : $objRootPage->id);
}
// Look for a 403 page
$obj403 = \PageModel::find403ByPid($objRootPage->id);
// Die if there is no page at all
if (null === $obj403) {
header('HTTP/1.1 403 Forbidden');
die_nicely('be_forbidden', 'Forbidden');
}
// Generate the error page
if (!$obj403->autoforward || !$obj403->jumpTo) {
/** @var \PageModel $objPage */
global $objPage;
// Die nicely if the page is a 403 page already (see #8060)
if ($objPage && $objPage->type == 'error_403') {
header('HTTP/1.1 403 Forbidden');
die_nicely('be_forbidden', 'Forbidden');
}
$objPage = $obj403->loadDetails();
/** @var \PageRegular $objHandler */
$objHandler = new $GLOBALS['TL_PTY']['regular']();
header('HTTP/1.1 403 Forbidden');
$objHandler->generate($objPage);
exit;
}
// Forward to another page
$objNextPage = \PageModel::findPublishedById($obj403->jumpTo);
if (null === $objNextPage) {
header('HTTP/1.1 403 Forbidden');
$this->log('Forward page ID "' . $obj403->jumpTo . '" does not exist', __METHOD__, TL_ERROR);
die_nicely('be_no_forward', 'Forward page not found');
}
$this->redirect($this->generateFrontendUrl($objNextPage->loadDetails()->row(), null, $objRootPage->language, true), $obj403->redirect == 'temporary' ? 302 : 301);
}
示例4: checkLoginStatus
public function checkLoginStatus($objPage, $objLayout, \PageRegular $objPageRegular)
{
global $objPage;
$loggedIn = FE_USER_LOGGED_IN;
if (\Input::get('logout')) {
if (@$this->User->logout()) {
$loggedIn = false;
}
}
if (!$loggedIn && $objPage->type != "login" && (Config::get("globalLogin") == 1 || $objPage->type == "error_403")) {
$loginPage = PageModel::findOneBy("type", "login");
if (isset($loginPage) && $loginPage->published == 1) {
$loginPage->loadDetails();
$objPage = $loginPage;
$handler = new LoginPage(\Environment::get("request"));
$handler->generate($loginPage);
exit;
} else {
System::log("Please create a Login-Page urgently!!", "LoginPage\\checkLoginStatus", TL_ERROR);
if ($objPage->type == "error_403") {
return;
}
$page403_model = \PageModel::find403ByPid($objPage->rootId);
if (isset($page403_model) && $page403_model->published == 1) {
$page403_model->loadDetails();
$objPage = $page403_model;
$handler = new PageError403();
$handler->generate($page403_model->id, $page403_model->rootId);
exit;
} else {
System::log("Please create a 403-Error-Page urgently!!", "LoginPage\\checkLoginStatus", TL_ERROR);
$objPage->template = 'fe_login';
$objPage->templateGroup = $objLayout->templates;
$objPageRegular->createTemplate($objPage, $objLayout);
}
}
}
}