本文整理汇总了PHP中common::ErrorBuffer方法的典型用法代码示例。如果您正苦于以下问题:PHP common::ErrorBuffer方法的具体用法?PHP common::ErrorBuffer怎么用?PHP common::ErrorBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common
的用法示例。
在下文中一共展示了common::ErrorBuffer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gp_install
background:#fff2a3;
color:#4d4931;
}
</style>
</head>
<body>
<div class="wrapper">
<?php
new gp_install();
echo common::ErrorBuffer(false);
echo '</div>';
echo '</body></html>';
//Install Class
class gp_install
{
var $can_write_data = true;
var $ftp_root = false;
var $root_mode;
function __construct()
{
global $languages, $install_language, $langmessage;
//language preferences
$install_language = 'en';
if (isset($_GET['lang']) && isset($languages[$_GET['lang']])) {
$install_language = $_GET['lang'];
示例2: BufferOut
/**
* Complete the response by adding final content to the <head> of the document
* @static
* @since 2.4.1
* @param string $buffer html content
* @return string finalized response
*/
static function BufferOut($buffer)
{
global $config, $gp_head_content, $addonFolderName, $dataDir, $addon_current_id, $wbErrorBuffer;
//add error notice if there was a fatal error
if (!ini_get('display_errors') && function_exists('error_get_last')) {
//check for fatal error
$fatal_errors = array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR);
$last_error = error_get_last();
if (is_array($last_error) && in_array($last_error['type'], $fatal_errors)) {
$last_error['request'] = $_SERVER['REQUEST_URI'];
if ($addon_current_id) {
$last_error['addon_name'] = $config['addons'][$addonFolderName]['name'];
$last_error['addon_id'] = $addon_current_id;
}
$last_error['file'] = realpath($last_error['file']);
//may be redundant
showError($last_error['type'], $last_error['message'], $last_error['file'], $last_error['line'], false);
//send error to logger
$reload = false;
//disable execution
if (count(self::$catchable)) {
$last_error['time'] = time();
$last_error['request_method'] = $_SERVER['REQUEST_METHOD'];
if (!empty($last_error['file'])) {
$last_error['file_modified'] = filemtime($last_error['file']);
$last_error['file_size'] = filesize($last_error['file']);
}
//error text, check for existing fatal notice
if (count(self::$fatal_notices)) {
$content = end(self::$fatal_notices);
reset(self::$fatal_notices);
if ($content[0] == '{' && ($temp = json_decode($content, true))) {
$last_error = $temp;
}
} else {
$content = json_encode($last_error);
}
//$buffer .= pre(self::$catchable).'<hr/>';
//$buffer .= '<h3>Existing Fatal Notices</h3>'.pre(self::$fatal_notices).'<hr/>';
$temp = array_reverse(self::$catchable);
foreach ($temp as $error_hash => $info) {
$file = $dataDir . '/data/_site/fatal_' . $error_hash;
gpFiles::Save($file, $content);
$reload = true;
if ($info['catchable_type'] == 'exec') {
break;
}
}
}
//reload non-logged in users automatically, display message to admins
$buffer .= '<p>Oops, an error occurred while generating this page.<p>';
if (!common::LoggedIn()) {
if ($reload) {
$buffer .= 'Reloading... <script type="text/javascript">window.setTimeout(function(){window.location.href = window.location.href},1000);</script>';
} else {
$buffer .= '<p>If you are the site administrator, you can troubleshoot the problem by changing php\'s display_errors setting to 1 in the gpconfig.php file.</p>' . '<p>If the problem is being caused by an addon, you may also be able to bypass the error by enabling gpEasy\'s safe mode in the gpconfig.php file.</p>' . '<p>More information is available in the <a href="http://docs.gpeasy.com/Main/Troubleshooting">gpEasy documentation</a>.</p>' . '<p><a href="">Reload this page to continue</a>.</p>';
}
} else {
$buffer .= '<h3>Error Details</h3>' . pre($last_error) . '<p><a href="">Reload this page</a></p>';
if ($reload) {
$buffer .= '<p><a href="">Reload this page with the faulty component disabled</a></p>' . '<p><a href="?cmd=enable_component&hash=' . $error_hash . '">Reload this page with the faulty component enabled</a></p>';
}
$buffer .= '<p style="font-size:90%">Note: Error details are only displayed for logged in administrators</p>' . common::ErrorBuffer(true, false);
}
}
}
//remove lock
if (defined('gp_has_lock') && gp_has_lock) {
gpFiles::Unlock('write', gp_random);
}
//replace the <head> placeholder with header content
$placeholder = '<!-- get_head_placeholder ' . gp_random . ' -->';
$pos = strpos($buffer, $placeholder);
if ($pos === false) {
return $buffer;
}
$buffer = substr_replace($buffer, $gp_head_content, $pos, strlen($placeholder));
//add jquery if needed
$placeholder = '<!-- jquery_placeholder ' . gp_random . ' -->';
$pos = strpos($buffer, $placeholder);
if ($pos !== false) {
$replacement = '';
if (strpos($buffer, '<script') !== false) {
if ($config['jquery'] != 'local') {
$replacement = "\n<script type=\"text/javascript\" src=\"//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js\"></script>";
} else {
$replacement = "\n<script type=\"text/javascript\" src=\"" . common::GetDir('/include/thirdparty/js/jquery.js') . "\"></script>";
}
}
$buffer = substr_replace($buffer, $replacement, $pos, strlen($placeholder));
}
//messages
$pos = strpos($buffer, '<!-- message_start ' . gp_random . ' -->');
//.........这里部分代码省略.........
示例3: stop
/**
* Stop loading gpEasy
* Check to see if gpEasy has already been installed
*
*/
static function stop()
{
global $dataDir;
if (!gpFiles::Exists($dataDir . '/data/_site/config.php')) {
if (file_exists($dataDir . '/include/install/install.php')) {
common::SetLinkPrefix();
includeFile('install/install.php');
die;
}
}
die('<p>Notice: The site configuration did not load properly.</p>' . '<p>If you are the site administrator, you can troubleshoot the problem turning debugging "on" or bypass it by enabling gpEasy safe mode.</p>' . '<p>More information is available in the <a href="http://docs.gpeasy.com/Main/Troubleshooting">gpEasy documentation</a>.</p>' . common::ErrorBuffer(true, false));
}
示例4: AdminBuffer
/**
* Perform admin only changes to the content buffer
*
*/
function AdminBuffer($buffer)
{
global $gp_random, $wbErrorBuffer, $gp_admin_html;
$nonce = common::new_nonce('post', true);
// Add a generic admin nonce field to each post form
// Admin nonces are also added with javascript if needed
$count = preg_match_all('#<form[^<>]+method=[\'"]post[\'"][^<>]+>#i', $buffer, $matches);
if ($count) {
$matches[0] = array_unique($matches[0]);
foreach ($matches[0] as $match) {
//make sure it's a local action
if (preg_match('#action=[\'"]([^\'"]+)[\'"]#i', $match, $sub_matches)) {
$action = $sub_matches[1];
if (substr($action, 0, 2) === '//') {
continue;
} elseif (strpos($action, '://')) {
continue;
}
}
$replacement = $match . '<span class="nodisplay"><input type="hidden" name="verified" value="' . $nonce . '"/></span>';
$buffer = str_replace($match, $replacement, $buffer);
}
}
//add error notice if there was a fatal error
if (!gpdebug && function_exists('error_get_last')) {
//check for fatal error
$fatal_errors = array(E_ERROR, E_PARSE);
$last_error = error_get_last();
if (is_array($last_error) && in_array($last_error['type'], $fatal_errors)) {
showError($last_error['type'], $last_error['message'], $last_error['file'], $last_error['line'], false);
$buffer .= '<p>An error occurred while generating this page.<p> ' . '<p>If you are the site administrator, you can troubleshoot the problem turning debugging "on" or bypass it by enabling safe mode.</p>' . '<p>More information is available in the <a href="http://docs.gpeasy.com/Main/Troubleshooting">gpEasy documentation</a>.</p>' . common::ErrorBuffer(true, false);
}
}
//add $gp_admin_html to the document
if (strlen($gp_admin_html)) {
$pos = false;
$pos_admin_html = strpos($buffer, 'id="gp_admin_html"');
$pos_body = strpos($buffer, '<body');
if ($pos_admin_html !== false) {
$pos = $pos_admin_html;
} elseif ($pos_body !== false) {
$gp_admin_html = '<div id="gp_admin_html" class="a2">' . $gp_admin_html . '</div>';
$pos = $pos_body;
}
if ($pos !== false) {
$pos = strpos($buffer, '>', $pos);
$buffer = substr_replace($buffer, $gp_admin_html, $pos + 1, 0);
}
}
return $buffer;
}
示例5: FatalMessage
/**
* Return the message displayed when a fatal error has been caught
*
*/
public static function FatalMessage($error_details)
{
$message = '<p>Oops, an error occurred while generating this page.<p>';
if (!common::LoggedIn()) {
//reload non-logged in users automatically if there were catchable errors
if (self::$catchable) {
$message .= 'Reloading... <script type="text/javascript">window.setTimeout(function(){window.location.href = window.location.href},1000);</script>';
} else {
$message .= '<p>If you are the site administrator, you can troubleshoot the problem by changing php\'s display_errors setting to 1 in the gpconfig.php file.</p>' . '<p>If the problem is being caused by an addon, you may also be able to bypass the error by enabling gpEasy\'s safe mode in the gpconfig.php file.</p>' . '<p>More information is available in the <a href="http://docs.gpeasy.com/Main/Troubleshooting">gpEasy documentation</a>.</p>' . '<p><a href="">Reload this page to continue</a>.</p>';
}
return $message;
}
$message .= '<h3>Error Details</h3>' . pre($error_details) . '<p><a href="">Reload this page</a></p>' . '<p style="font-size:90%">Note: Error details are only displayed for logged in administrators</p>' . common::ErrorBuffer(true, false);
return $message;
}
示例6: stop
function stop()
{
die('<p>Notice: The site configuration did not load properly.</p>' . '<p>If you are the site administrator, you can troubleshoot the problem turning debugging "on" or bypass it by enabling safe mode.</p>' . '<p>More information is available in the <a href="http://docs.gpeasy.com/Main/Troubleshooting">gpEasy documentation</a>.</p>' . common::ErrorBuffer(true, false));
}