• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ErrorPage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ErrorPage的典型用法代码示例。如果您正苦于以下问题:PHP ErrorPage类的具体用法?PHP ErrorPage怎么用?PHP ErrorPage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ErrorPage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: requireDefaultRecords

 /**
  * Create an {@link ErrorPage} for status code 503
  * 
  * @see UnderConstruction_Extension::onBeforeInit()
  * @see DataObjectDecorator::requireDefaultRecords()
  * @return Void
  */
 function requireDefaultRecords()
 {
     // Ensure that an assets path exists before we do any error page creation
     if (!file_exists(ASSETS_PATH)) {
         mkdir(ASSETS_PATH);
     }
     $pageUnderConstructionErrorPage = DataObject::get_one('ErrorPage', "\"ErrorCode\" = '503'");
     $pageUnderConstructionErrorPageExists = $pageUnderConstructionErrorPage && $pageUnderConstructionErrorPage->exists() ? true : false;
     $pageUnderConstructionErrorPagePath = ErrorPage::get_filepath_for_errorcode(503);
     if (!($pageUnderConstructionErrorPageExists && file_exists($pageUnderConstructionErrorPagePath))) {
         if (!$pageUnderConstructionErrorPageExists) {
             $pageUnderConstructionErrorPage = new ErrorPage();
             $pageUnderConstructionErrorPage->ErrorCode = 503;
             $pageUnderConstructionErrorPage->Title = _t('UnderConstruction.TITLE', 'Under Construction');
             $pageUnderConstructionErrorPage->Content = _t('UnderConstruction.CONTENT', '<p>Sorry, this site is currently under construction.</p>');
             $pageUnderConstructionErrorPage->Status = 'New page';
             $pageUnderConstructionErrorPage->write();
             $pageUnderConstructionErrorPage->publish('Stage', 'Live');
         }
         // Ensure a static error page is created from latest error page content
         $response = Director::test(Director::makeRelative($pageUnderConstructionErrorPage->Link()));
         if ($fh = fopen($pageUnderConstructionErrorPagePath, 'w')) {
             $written = fwrite($fh, $response->getBody());
             fclose($fh);
         }
         if ($written) {
             DB::alteration_message('503 error page created', 'created');
         } else {
             DB::alteration_message(sprintf('503 error page could not be created at %s. Please check permissions', $pageUnderConstructionErrorPagePath), 'error');
         }
     }
 }
开发者ID:helpfulrobot,项目名称:frankmullenger-underconstruction,代码行数:39,代码来源:UnderConstruction.php


示例2: die_fancy

 static function die_fancy($except)
 {
     // Log the error?
     if ($except instanceof InternalException) {
         Log::error($except->getMessage());
     }
     // Utility: error pages
     $view = new ErrorPage($except);
     $view->write();
     exit;
 }
开发者ID:jlsa,项目名称:justitia,代码行数:11,代码来源:ErrorPage.php


示例3: requireDefaultRecords

	/**
	 * Ensures that there is always a 404 page
	 * by checking if there's an instance of
	 * ErrorPage with a 404 error code. If there
	 * is not, one is created when the DB is built.
	 */
	function requireDefaultRecords() {
		parent::requireDefaultRecords();

		if(!DataObject::get_one('ErrorPage', "ErrorCode = '404'")) {
			$errorpage = new ErrorPage();
			$errorpage->ErrorCode = 404;
			$errorpage->Title = _t('ErrorPage.DEFAULTERRORPAGETITLE', 'Page not found');
			$errorpage->URLSegment = 'page-not-found';
			$errorpage->Content = _t('ErrorPage.DEFAULTERRORPAGECONTENT', '<p>Sorry, it seems you were trying to access a page that doesn\'t exist.</p><p>Please check the spelling of the URL you were trying to access and try again.</p>');
			$errorpage->Status = 'New page';
			$errorpage->write();
			
			Database::alteration_message('404 page created', 'created');
		}
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:21,代码来源:ErrorPage.php


示例4: testLinkShortcodeHandler

 public function testLinkShortcodeHandler()
 {
     $testFile = $this->objFromFixture('File', 'asdf');
     $parser = new ShortcodeParser();
     $parser->register('file_link', array('File', 'handle_shortcode'));
     $fileShortcode = sprintf('[file_link,id=%d]', $testFile->ID);
     $fileEnclosed = sprintf('[file_link,id=%d]Example Content[/file_link]', $testFile->ID);
     $fileShortcodeExpected = $testFile->Link();
     $fileEnclosedExpected = sprintf('<a href="%s" class="file" data-type="txt" data-size="977 KB">Example Content</a>', $testFile->Link());
     $this->assertEquals($fileShortcodeExpected, $parser->parse($fileShortcode), 'Test that simple linking works.');
     $this->assertEquals($fileEnclosedExpected, $parser->parse($fileEnclosed), 'Test enclosed content is linked.');
     $testFile->delete();
     $fileShortcode = '[file_link,id="-1"]';
     $fileEnclosed = '[file_link,id="-1"]Example Content[/file_link]';
     $this->assertEquals('', $parser->parse('[file_link]'), 'Test that invalid ID attributes are not parsed.');
     $this->assertEquals('', $parser->parse('[file_link,id="text"]'));
     $this->assertEquals('', $parser->parse('[file_link]Example Content[/file_link]'));
     if (class_exists('ErrorPage')) {
         $errorPage = ErrorPage::get()->filter('ErrorCode', 404)->First();
         $this->assertEquals($errorPage->Link(), $parser->parse($fileShortcode), 'Test link to 404 page if no suitable matches.');
         $this->assertEquals(sprintf('<a href="%s">Example Content</a>', $errorPage->Link()), $parser->parse($fileEnclosed));
     } else {
         $this->assertEquals('', $parser->parse($fileShortcode), 'Short code is removed if file record is not present.');
         $this->assertEquals('', $parser->parse($fileEnclosed));
     }
 }
开发者ID:biggtfish,项目名称:silverstripe-framework,代码行数:26,代码来源:FileTest.php


示例5: onBeforeHTTPError

 public function onBeforeHTTPError($statusCode, $request)
 {
     $response = ErrorPage::response_for($statusCode);
     if ($response) {
         throw new SS_HTTPResponse_Exception($response, $statusCode);
     }
 }
开发者ID:miamollie,项目名称:echoAerial,代码行数:7,代码来源:ErrorPageControllerExtension.php


示例6: output

 public function output()
 {
     // TODO: Refactor into a content-type option
     if (\Director::is_ajax()) {
         return $this->friendlyErrorMessage;
     } else {
         // TODO: Refactor this into CMS
         if (class_exists('ErrorPage')) {
             $errorFilePath = \ErrorPage::get_filepath_for_errorcode($this->statusCode, class_exists('Translatable') ? \Translatable::get_current_locale() : null);
             if (file_exists($errorFilePath)) {
                 $content = file_get_contents($errorFilePath);
                 if (!headers_sent()) {
                     header('Content-Type: text/html');
                 }
                 // $BaseURL is left dynamic in error-###.html, so that multi-domain sites don't get broken
                 return str_replace('$BaseURL', \Director::absoluteBaseURL(), $content);
             }
         }
         $renderer = \Debug::create_debug_view();
         $output = $renderer->renderHeader();
         $output .= $renderer->renderInfo("Website Error", $this->friendlyErrorMessage, $this->friendlyErrorDetail);
         if (\Email::config()->admin_email) {
             $mailto = \Email::obfuscate(\Email::config()->admin_email);
             $output .= $renderer->renderParagraph('Contact an administrator: ' . $mailto . '');
         }
         $output .= $renderer->renderFooter();
         return $output;
     }
 }
开发者ID:vinstah,项目名称:silverstripe-framework,代码行数:29,代码来源:DebugViewFriendlyErrorFormatter.php


示例7: __autoload

function __autoload($classe)
{
    $classe = $classe . '.php';
    if (file_exists('Controller' . DS . $classe)) {
        require_once 'Controller' . DS . $classe;
    } else {
        if (file_exists('Model' . DS . $classe)) {
            require_once 'Model' . DS . $classe;
        } else {
            if (file_exists('Model' . DS . 'Entity' . DS . $classe)) {
                require_once 'Model' . DS . 'Entity' . DS . $classe;
            } else {
                if (file_exists('Model' . DS . 'Interface' . DS . $classe)) {
                    require_once 'Model' . DS . 'Interface' . DS . $classe;
                } else {
                    if (file_exists('Library' . DS . $classe)) {
                        require_once 'Library' . DS . $classe;
                    } else {
                        if (file_exists('Exceptions' . DS . $classe)) {
                            require_once 'Exceptions' . DS . $classe;
                        } else {
                            ///se a pagina nao for encontrada ela renderiza errorPage
                            ErrorPage::page404NotFound($classe);
                        }
                    }
                }
            }
        }
    }
}
开发者ID:brunoblauzius,项目名称:sistema,代码行数:30,代码来源:index.php


示例8: create_default_error_page

 public static function create_default_error_page($code = 404, $values = [], $type = 'ErrorPage')
 {
     if (class_exists('ErrorPage')) {
         return;
     }
     $pagePath = \ErrorPage::get_filepath_for_errorcode($code);
     if (!DataList::create('ErrorPage')->filter('ErrorCode', $code)->exists() || !file_exists($pagePath)) {
         $page = Object::create($type);
         foreach ($values as $f => $v) {
             $page->{$f} = $v;
         }
         $page->ErrorCode = $code;
         $page->write();
         $page->publish('Stage', 'Live');
         $response = static::test(static::makeRelative($page->Link()));
         $written = null;
         if ($fh = fopen($pagePath, 'w')) {
             $written = fwrite($fh, $response->getBody());
             fclose($fh);
         }
         if ($written) {
             DB::alteration_message($page->Title . ' Page created', 'created');
         } else {
             DB::alteration_message(sprintf($page->Title . ' Page could not be created at %s. Please check permissions', $pagePath), 'error');
         }
     }
 }
开发者ID:helpfulrobot,项目名称:milkyway-multimedia-ss-mwm,代码行数:27,代码来源:Director.php


示例9: getByLink

 public function getByLink($url)
 {
     if (!($page = Page::get_by_link($url))) {
         $page = ErrorPage::get()->filter('ErrorCode', 404)->first();
     }
     $data = array('timepstamp' => time(), 'page' => $page->forAPI());
     return $data;
 }
开发者ID:ehyland,项目名称:json-api-utils,代码行数:8,代码来源:PageDataUtil.php


示例10: requireDefaultRecords

 /**
  * Ensures that there is always a 404 page.
  */
 function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!DataObject::get_one("ErrorPage", "ErrorCode = '404'")) {
         $errorpage = new ErrorPage();
         $errorpage->ErrorCode = 404;
         $errorpage->Title = _t('ErrorPage.DEFAULTERRORPAGETITLE', 'Page not found');
         $errorpage->URLSegment = "page-not-found";
         $errorpage->ShowInMenus = false;
         $errorpage->Content = _t('ErrorPage.DEFAULTERRORPAGECONTENT', '<p>Sorry, it seems you were trying to access a page that doesn\'t exist.</p><p>Please check the spelling of the URL you were trying to access and try again.</p>');
         $errorpage->Status = "New page";
         $errorpage->write();
         // Don't publish, as the manifest may not be built yet
         // $errorpage->publish("Stage", "Live");
         Database::alteration_message("404 page created", "created");
     }
 }
开发者ID:ramziammar,项目名称:websites,代码行数:20,代码来源:ErrorPage.php


示例11: require_admin

 static function require_admin()
 {
     $user = Authentication::require_user();
     if (!$user->is_admin) {
         ErrorPage::die_fancy(new NotAuthorizedException());
     }
     return $user;
 }
开发者ID:jlsa,项目名称:justitia,代码行数:8,代码来源:Authentication.php


示例12: tearDown

 function tearDown()
 {
     parent::tearDown();
     ErrorPage::set_static_filepath($this->orig['ErrorPage_staticfilepath']);
     Director::set_environment_type($this->orig['Director_environmenttype']);
     Filesystem::removeFolder($this->tmpAssetsPath . '/ErrorPageTest');
     Filesystem::removeFolder($this->tmpAssetsPath);
 }
开发者ID:rixrix,项目名称:silverstripe-cms,代码行数:8,代码来源:ErrorPageTest.php


示例13: tearDown

 public function tearDown()
 {
     parent::tearDown();
     ErrorPage::config()->static_filepath = $this->orig['ErrorPage_staticfilepath'];
     Filesystem::removeFolder($this->tmpAssetsPath . '/ErrorPageTest');
     Filesystem::removeFolder($this->tmpAssetsPath);
     Config::inst()->update('Director', 'environment_type', $this->origEnvType);
 }
开发者ID:miamollie,项目名称:echoAerial,代码行数:8,代码来源:ErrorPageTest.php


示例14: testErrorPageLocations

 function testErrorPageLocations()
 {
     $subsite1 = $this->objFromFixture('Subsite', 'domaintest1');
     Subsite::changeSubsite($subsite1->ID);
     $path = ErrorPage::get_filepath_for_errorcode(500);
     $static_path = Config::inst()->get('ErrorPage', 'static_filepath');
     $expected_path = $static_path . '/error-500-' . $subsite1->domain() . '.html';
     $this->assertEquals($expected_path, $path);
 }
开发者ID:helpfulrobot,项目名称:mikenz-silverstripe-simplesubsites,代码行数:9,代码来源:SiteTreeSubsitesTest.php


示例15: httpError

 public function httpError($code, $message = null)
 {
     if (!Permission::check("ADMIN")) {
         $response = ErrorPage::response_for($code);
     }
     if (empty($response)) {
         $response = $message;
     }
     throw new SS_HTTPResponse_Exception($response);
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:10,代码来源:SafeXSSForm.php


示例16: ipn

 /**
  * Process IPN request from ClickBank. Only process POST request
  * 
  * @param	object	$_POST
  * @return	int		HTTP code 
  */
 public function ipn(SS_HTTPRequest $request)
 {
     if ($request->isPost()) {
         if (ClickBankManager::validate_ipn_request($request->postVars())) {
             ClickBankManager::process_ipn_request($request->postVars());
             return Director::get_status_code();
         }
     }
     return ErrorPage::response_for(404);
 }
开发者ID:rixrix,项目名称:silverstripe-clickbank,代码行数:16,代码来源:ClickBankController.php


示例17: onBeforeHTTPError

 /**
  *	Retrieve the correct error page for the current multisite instance.
  *	@param integer
  *	@param SS_HTTPRequest
  *	@throws SS_HTTPResponse_Exception
  */
 public function onBeforeHTTPError($code, $request)
 {
     $errorPage = ErrorPage::get()->filter(array('ErrorCode' => $code, 'SiteID' => Multisites::inst()->getCurrentSiteId()))->first();
     if ($errorPage) {
         Requirements::clear();
         Requirements::clear_combined_files();
         $response = ModelAsController::controller_for($errorPage)->handleRequest($request, DataModel::inst());
         throw new SS_HTTPResponse_Exception($response, $code);
     }
 }
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-multisites,代码行数:16,代码来源:MultisitesControllerExtension.php


示例18: requireDefaultRecords

 public function requireDefaultRecords()
 {
     if (Config::inst()->get('UniversalErrorPage', 'ConvertOnDevBuild')) {
         $ErrorPages = ErrorPage::get()->filter('ClassName', 'ErrorPage');
         foreach ($ErrorPages as $ErrorPage) {
             $ErrorPage->ClassName = 'UniversalErrorPage';
             $ErrorPage->write();
             $ErrorPage->doPublish();
             DB::alteration_message("#{$ErrorPage->ID} {$ErrorPage->Title} changed to UniversalErrorPage.", "changed");
         }
     }
 }
开发者ID:Marketo,项目名称:SilverStripe-UniversalErrorPage,代码行数:12,代码来源:UniversalErrorPage.php


示例19: alternateFilepathForErrorcode

 public function alternateFilepathForErrorcode($code, $locale)
 {
     $path = ErrorPage::get_static_filepath();
     $parts = array();
     if ($site = Multisites::inst()->getActiveSite()) {
         $parts[] = $site->Host;
     }
     $parts[] = $code;
     if ($locale && $this->owner->hasExtension('Translatable') && $locale != Translatable::default_locale()) {
         $parts[] = $locale;
     }
     return sprintf("%s/error-%s.html", $path, implode('-', $parts));
 }
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-multisites,代码行数:13,代码来源:MultisitesErrorPageExtension.php


示例20: onBeforeInit

 function onBeforeInit()
 {
     if (Config::inst()->get('IpAccess', 'enabled')) {
         $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), Config::inst()->get('IpAccess', 'allowed_ips'));
         if (!$ipAccess->hasAccess()) {
             if (class_exists('ErrorPage', true)) {
                 $response = ErrorPage::response_for(403);
             }
             $response = $response ? $response : 'The requested page could not be found.';
             return $this->owner->httpError(403, $response);
         }
     }
 }
开发者ID:helpfulrobot,项目名称:axyr-silverstripe-adminlogin,代码行数:13,代码来源:LimitAdminAccessExtension.php



注:本文中的ErrorPage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Errors类代码示例发布时间:2022-05-23
下一篇:
PHP ErrorHandler类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap