Example #1
0
 /**
  * Render a user-facing error page, using the default HTML error template
  * rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link SS_HTTPResponse} class
  * the keep dependencies minimal. 
  * 
  * @uses ErrorPage
  *
  * @param int $statusCode HTTP Status Code (Default: 500)
  * @param string $friendlyErrorMessage User-focused error message. Should not contain code pointers or "tech-speak".
  *    Used in the HTTP Header and ajax responses.
  * @param string $friendlyErrorDetail Detailed user-focused message. Is just used if no {@link ErrorPage} is found
  *    for this specific status code.
  * @return string HTML error message for non-ajax requests, plaintext for ajax-request.
  */
 static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $friendlyErrorDetail = null)
 {
     if (!$friendlyErrorMessage) {
         $friendlyErrorMessage = self::$friendly_error_header;
     }
     if (!$friendlyErrorDetail) {
         $friendlyErrorDetail = self::$friendly_error_detail;
     }
     if (!headers_sent()) {
         header(sprintf('%s %d %s', $_SERVER['SERVER_PROTOCOL'], $statusCode, strip_tags(str_replace(array("\n", "\r"), '', $friendlyErrorMessage))));
     }
     if (Director::is_ajax()) {
         echo $friendlyErrorMessage;
     } else {
         $errorFilePath = ErrorPage::get_filepath_for_errorcode($statusCode, Translatable::get_current_locale());
         if (file_exists($errorFilePath)) {
             $content = file_get_contents(ASSETS_PATH . "/error-{$statusCode}.html");
             // $BaseURL is left dynamic in error-###.html, so that multi-domain sites don't get broken
             echo str_replace('$BaseURL', Director::absoluteBaseURL(), $content);
         } else {
             $renderer = new DebugView();
             $renderer->writeHeader();
             $renderer->writeInfo("Website Error", $friendlyErrorMessage, $friendlyErrorDetail);
             if (Email::getAdminEmail()) {
                 $mailto = Email::obfuscate(Email::getAdminEmail());
                 $renderer->writeParagraph('Contact an administrator: ' . $mailto . '');
             }
             $renderer->writeFooter();
         }
     }
 }
Example #2
0
 /**
  * Render a user-facing error page, using the default HTML error template
  * rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link SS_HTTPResponse} class
  * the keep dependencies minimal. 
  * 
  * @uses ErrorPage
  *
  * @param int $statusCode HTTP Status Code (Default: 500)
  * @param string $friendlyErrorMessage User-focused error message. Should not contain code pointers
  *                                     or "tech-speak". Used in the HTTP Header and ajax responses.
  * @param string $friendlyErrorDetail Detailed user-focused message. Is just used if no {@link ErrorPage} is found
  *                                    for this specific status code.
  * @return string HTML error message for non-ajax requests, plaintext for ajax-request.
  */
 public static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $friendlyErrorDetail = null)
 {
     if (!$friendlyErrorMessage) {
         $friendlyErrorMessage = Config::inst()->get('Debug', 'friendly_error_header');
     }
     if (!$friendlyErrorDetail) {
         $friendlyErrorDetail = Config::inst()->get('Debug', 'friendly_error_detail');
     }
     if (!headers_sent()) {
         $currController = Controller::has_curr() ? Controller::curr() : null;
         // Ensure the error message complies with the HTTP 1.1 spec
         $msg = strip_tags(str_replace(array("\n", "\r"), '', $friendlyErrorMessage));
         if ($currController) {
             $response = $currController->getResponse();
             $response->setStatusCode($statusCode, $msg);
         } else {
             header($_SERVER['SERVER_PROTOCOL'] . " {$statusCode} {$msg}");
         }
     }
     if (Director::is_ajax()) {
         echo $friendlyErrorMessage;
     } else {
         if (class_exists('ErrorPage')) {
             $errorFilePath = ErrorPage::get_filepath_for_errorcode($statusCode, class_exists('Translatable') ? Translatable::get_current_locale() : null);
             if (file_exists($errorFilePath)) {
                 $content = file_get_contents(ASSETS_PATH . "/error-{$statusCode}.html");
                 // $BaseURL is left dynamic in error-###.html, so that multi-domain sites don't get broken
                 echo str_replace('$BaseURL', Director::absoluteBaseURL(), $content);
             }
         } else {
             $renderer = new DebugView();
             $renderer->writeHeader();
             $renderer->writeInfo("Website Error", $friendlyErrorMessage, $friendlyErrorDetail);
             if (Email::config()->admin_email) {
                 $mailto = Email::obfuscate(Email::config()->admin_email);
                 $renderer->writeParagraph('Contact an administrator: ' . $mailto . '');
             }
             $renderer->writeFooter();
         }
     }
     return false;
 }
<?php

/**
 * @package silverstripe-memberprofiles
 */
if (!ClassInfo::exists('Orderable')) {
    $view = new DebugView();
    $link = 'https://github.com/ajshort/silverstripe-orderable';
    if (!headers_sent()) {
        header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error');
    }
    $view->writeHeader();
    $view->writeInfo('Dependency Error', 'The Member Profiles module requires the Orderable module.');
    $view->writeParagraph("Please install the <a href=\"{$link}\">Orderable</a> module.");
    $view->writeFooter();
    exit;
}
Director::addRules(20, array('member-approval' => 'MemberApprovalController'));
Object::add_extension('Member', 'MemberProfileExtension');
<?php

/**
 * @package silverstripe-multisites
 */
if (!ClassInfo::exists('MultiValueField')) {
    $view = new DebugView();
    $link = 'https://github.com/nyeholt/silverstripe-multivaluefield';
    if (!headers_sent()) {
        header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error');
    }
    $view->writeHeader();
    $view->writeInfo('Dependency Error', 'The Multisites module requires the MultiValueField module.');
    $view->writeParagraph("Please install the <a href=\"{$link}\">MultiValueField</a> module.");
    $view->writeFooter();
    exit;
}
if (!defined('MULTISITES_PATH')) {
    define('MULTISITES_PATH', rtrim(basename(dirname(__FILE__))));
}
CMSMenu::remove_menu_item('MultisitesCMSSiteAddController');
CMSMenu::remove_menu_item('MultisitesCMSPageAddController');
LeftAndMain::require_css(MULTISITES_PATH . '/css/MultisitesAdmin.css');
LeftAndMain::require_javascript(MULTISITES_PATH . '/javascript/MultisitesAdmin.js');
SiteTree::set_create_default_pages(false);
// Remove LeftAndMain.AddForm.js - at least until this ticket is resolved
// http://open.silverstripe.org/ticket/7987
Requirements::block(FRAMEWORK_ADMIN_DIR . '/javascript/LeftAndMain.AddForm.js');
SS_Report::add_excluded_reports(array('SideReport_EmptyPages', 'BrokenLinksReport', 'SideReport_RecentlyEdited', 'SideReport_BrokenLinks', 'SideReport_BrokenFiles', 'SideReport_BrokenVirtualPages', 'SideReport_BrokenRedirectorPages'));
Example #5
0
 /**
  * Render a user-facing error page, using the default HTML error template
  * rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link HTTPResponse} class
  * the keep dependencies minimal. 
  * 
  * @uses ErrorPage
  *
  * @param int $statusCode HTTP Status Code (Default: 500)
  * @param string $friendlyErrorMessage User-focused error message. Should not contain code pointers or "tech-speak".
  *    Used in the HTTP Header and ajax responses.
  * @param string $friendlyErrorDetail Detailed user-focused message. Is just used if no {@link ErrorPage} is found
  *    for this specific status code.
  * @return string HTML error message for non-ajax requests, plaintext for ajax-request.
  */
 static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $friendlyErrorDetail = null)
 {
     if (!$friendlyErrorMessage) {
         $friendlyErrorMessage = 'There has been an error';
     }
     if (!$friendlyErrorDetail) {
         $friendlyErrorDetail = 'The website server has not been able to respond to your request.';
     }
     if (!headers_sent()) {
         header($_SERVER['SERVER_PROTOCOL'] . " {$statusCode} {$friendlyErrorMessage}");
     }
     if (Director::is_ajax()) {
         echo $friendlyErrorMessage;
     } else {
         $errorFilePath = ErrorPage::get_filepath_for_errorcode($statusCode, Translatable::get_current_locale());
         if (file_exists($errorFilePath)) {
             echo file_get_contents($errorFilePath);
         } else {
             $renderer = new DebugView();
             $renderer->writeHeader();
             $renderer->writeInfo("Website Error", $friendlyErrorMessage, $friendlyErrorDetail);
             if (Email::getAdminEmail()) {
                 $mailto = Email::obfuscate(Email::getAdminEmail());
                 $renderer->writeParagraph('Contact an administrator: ' . $mailto . '');
             }
             $renderer->writeFooter();
         }
     }
 }
Example #6
0
	/**
	 * Render a user-facing error page, using the default HTML error template
	 * rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link HTTPResponse} class
	 * the keep dependencies minimal. 
	 * 
	 * @uses ErrorPage
	 *
	 * @param int $statusCode HTTP Status Code (Default: 500)
	 * @param string $friendlyErrorMessage User-focused error message. Should not contain code pointers or "tech-speak".
	 *    Used in the HTTP Header and ajax responses.
	 * @param string $friendlyErrorDetail Detailed user-focused message. Is just used if no {@link ErrorPage} is found
	 *    for this specific status code.
	 * @return string HTML error message for non-ajax requests, plaintext for ajax-request.
	 */
	static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $friendlyErrorDetail = null) {
		if(!$friendlyErrorMessage) $friendlyErrorMessage = 'There has been an error';
		if(!$friendlyErrorDetail) $friendlyErrorDetail = 'The website server has not been able to respond to your request.';

		if(!headers_sent()) header($_SERVER['SERVER_PROTOCOL'] . " $statusCode $friendlyErrorMessage");

		if(Director::is_ajax()) {
			echo $friendlyErrorMessage;
		} else {
			if(file_exists(ASSETS_PATH . "/error-$statusCode.html")) {
				echo file_get_contents(ASSETS_PATH . "/error-$statusCode.html");
			} else {
				$renderer = new DebugView();
				$renderer->writeHeader();
				$renderer->writeInfo("Website Error", $friendlyErrorMessage, $friendlyErrorDetail);
				
				if(Email::getAdminEmail()) {
					$mailto = Email::obfuscate(Email::getAdminEmail());
					$renderer->writeParagraph('Contact an administrator: ' . $mailto . '');
				}

				$renderer->writeFooter();
			}
		}
	}
Example #7
0
 /**
  * Render a user-facing error page, using the default HTML error template
  * rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link SS_HTTPResponse} class
  * the keep dependencies minimal.
  *
  * @uses ErrorPage
  *
  * @param int $statusCode HTTP Status Code (Default: 500)
  * @param string $friendlyErrorMessage User-focused error message. Should not contain code pointers
  *                                     or "tech-speak". Used in the HTTP Header and ajax responses.
  * @param string $friendlyErrorDetail Detailed user-focused message. Is just used if no {@link ErrorPage} is found
  *                                    for this specific status code.
  * @return string HTML error message for non-ajax requests, plaintext for ajax-request.
  */
 public static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $friendlyErrorDetail = null)
 {
     // Ensure the error message complies with the HTTP 1.1 spec
     if (!$friendlyErrorMessage) {
         $friendlyErrorMessage = Config::inst()->get('Debug', 'friendly_error_header');
     }
     $friendlyErrorMessage = strip_tags(str_replace(array("\n", "\r"), '', $friendlyErrorMessage));
     if (!$friendlyErrorDetail) {
         $friendlyErrorDetail = Config::inst()->get('Debug', 'friendly_error_detail');
     }
     if (!headers_sent()) {
         // Allow toggle between legacy behaviour and correctly setting HTTP response code
         // In 4.0 this should be fixed to always set this response code.
         if (Config::inst()->get('Debug', 'friendly_error_httpcode') || !Controller::has_curr()) {
             header($_SERVER['SERVER_PROTOCOL'] . " {$statusCode} {$friendlyErrorMessage}");
         }
     }
     if (Director::is_ajax()) {
         echo $friendlyErrorMessage;
     } else {
         if (!headers_sent()) {
             header('Content-Type: text/html');
         }
         if (class_exists('ErrorPage')) {
             $errorFilePath = ErrorPage::get_filepath_for_errorcode($statusCode, class_exists('Translatable') ? Translatable::get_current_locale() : null);
             if (file_exists($errorFilePath)) {
                 $content = file_get_contents($errorFilePath);
                 // $BaseURL is left dynamic in error-###.html, so that multi-domain sites don't get broken
                 echo str_replace('$BaseURL', Director::absoluteBaseURL(), $content);
             }
         } else {
             $renderer = new DebugView();
             $renderer->writeHeader();
             $renderer->writeInfo("Website Error", $friendlyErrorMessage, $friendlyErrorDetail);
             if (Email::config()->admin_email) {
                 $mailto = Email::obfuscate(Email::config()->admin_email);
                 $renderer->writeParagraph('Contact an administrator: ' . $mailto . '');
             }
             $renderer->writeFooter();
         }
     }
     return false;
 }