本文整理汇总了PHP中wcf\system\WCF::debugModeIsEnabled方法的典型用法代码示例。如果您正苦于以下问题:PHP WCF::debugModeIsEnabled方法的具体用法?PHP WCF::debugModeIsEnabled怎么用?PHP WCF::debugModeIsEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wcf\system\WCF
的用法示例。
在下文中一共展示了WCF::debugModeIsEnabled方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* @see wcf\system\exception\IPrintableException::show()
*/
public function show() {
if (WCF::debugModeIsEnabled()) {
echo '<pre>' . $this->getTraceAsString() . '</pre>';
}
else {
echo '<pre>' . $this->_getMessage() . '</pre>';
}
}
示例2: _getMessage
/**
* Suppresses the original error message.
*
* @see \Exception::getMessage()
*/
public function _getMessage()
{
if (!WCF::debugModeIsEnabled()) {
return 'An error occured. Sorry.';
}
$e = $this->getPrevious() ?: $this;
return $e->getMessage();
}
示例3: _getMessage
/**
* @see \Exception::getMessage()
*/
public function _getMessage()
{
// suppresses the original error message
if (!WCF::debugModeIsEnabled() && !$this->ignoreDebugMode) {
return 'An error occured. Sorry.';
}
$e = $this->getPrevious() ?: $this;
return $e->getMessage();
}
示例4: show
/**
* @see wcf\system\exception\IPrintableException::show()
*/
public function show()
{
// log error
$exceptionID = $this->logError();
// send status code
@header('HTTP/1.1 503 Service Unavailable');
// show user-defined system-exception
if (defined('SYSTEMEXCEPTION_FILE') && file_exists(SYSTEMEXCEPTION_FILE)) {
require SYSTEMEXCEPTION_FILE;
return;
}
// print report
echo '<?xml version="1.0" encoding="UTF-8"?>';
$e = $this->getPrevious() ?: $this;
?>
<!DOCTYPE html>
<html>
<head>
<title>Fatal error: <?php
echo StringUtil::encodeHTML($this->_getMessage());
?>
</title>
<style>
.systemException {
font-family: 'Trebuchet MS', Arial, sans-serif !important;
font-size: 80% !important;
text-align: left !important;
border: 1px solid #036;
border-radius: 7px;
background-color: #eee !important;
overflow: auto !important;
}
.systemException h1 {
font-size: 130% !important;
font-weight: bold !important;
line-height: 1.1 !important;
text-decoration: none !important;
text-shadow: 0 -1px 0 #003 !important;
color: #fff !important;
word-wrap: break-word !important;
border-bottom: 1px solid #036;
border-top-right-radius: 6px;
border-top-left-radius: 6px;
background-color: #369 !important;
margin: 0 !important;
padding: 5px 10px !important;
}
.systemException div {
border-top: 1px solid #fff;
border-bottom-right-radius: 6px;
border-bottom-left-radius: 6px;
padding: 0 10px !important;
}
.systemException h2 {
font-size: 130% !important;
font-weight: bold !important;
color: #369 !important;
text-shadow: 0 1px 0 #fff !important;
margin: 5px 0 !important;
}
.systemException pre, .systemException p {
text-shadow: none !important;
color: #555 !important;
margin: 0 !important;
}
.systemException pre {
font-size: .85em !important;
font-family: "Courier New" !important;
text-overflow: ellipsis;
padding-bottom: 1px;
overflow: hidden !important;
}
.systemException pre:hover{
text-overflow: clip;
overflow: auto !important;
}
</style>
</head>
<body>
<div class="systemException">
<h1>Fatal error: <?php
echo StringUtil::encodeHTML($this->_getMessage());
?>
</h1>
<?php
if (WCF::debugModeIsEnabled()) {
?>
<div>
<p><?php
echo $this->getDescription();
?>
</p>
<h2>Information:</h2>
<p>
//.........这里部分代码省略.........
示例5: __construct
/**
* Throws a JSON-encoded error message
*
* @param string $message
* @param boolean $isDoomsday
* @param string $stacktrace
* @param array<mixed> $returnValues
*/
public function __construct($message, $errorType = self::INTERNAL_ERROR, $stacktrace = null, $returnValues = array()) {
if ($stacktrace === null) $stacktrace = $this->getTraceAsString();
if (WCF::debugModeIsEnabled()) {
$responseData = array(
'message' => $message,
'stacktrace' => nl2br($stacktrace)
);
}
else {
$responseData = array(
'message' => $this->_getMessage()
);
}
$responseData['code'] = $errorType;
$responseData['returnValues'] = $returnValues;
$statusHeader = '';
switch ($errorType) {
case self::MISSING_PARAMETERS:
$statusHeader = 'HTTP/1.0 400 Bad Request';
$responseData['message'] = WCF::getLanguage()->get('wcf.ajax.error.badRequest');
$this->logError();
break;
case self::SESSION_EXPIRED:
$statusHeader = 'HTTP/1.0 401 Unauthorized';
break;
case self::INSUFFICIENT_PERMISSIONS:
$statusHeader = 'HTTP/1.0 403 Forbidden';
break;
case self::BAD_PARAMETERS:
$statusHeader = 'HTTP/1.0 412 Precondition Failed';
break;
default:
case self::INTERNAL_ERROR:
//header('HTTP/1.0 418 I\'m a Teapot');
header('HTTP/1.0 503 Service Unavailable');
$responseData['code'] = self::INTERNAL_ERROR;
if (!WCF::debugModeIsEnabled()) {
$responseData['message'] = WCF::getLanguage()->get('wcf.ajax.error.internalError');
}
$this->logError();
break;
}
header($statusHeader);
header('Content-type: application/json');
echo JSON::encode($responseData);
exit;
}
示例6: show
//.........这里部分代码省略.........
text-shadow: none !important;
color: #555 !important;
margin: 0 !important;
}
.systemException pre {
font-size: .85em !important;
font-family: "Courier New" !important;
text-overflow: ellipsis;
padding-bottom: 1px;
overflow: hidden !important;
}
.systemException pre:hover{
text-overflow: clip;
overflow: auto !important;
}
</style>
</head>
<body>
<div class="systemException">
<h1>Fatal error: <?php
if (!$this->getExceptionID()) {
?>
Unable to write log file, please make "<?php
echo FileUtil::unifyDirSeparator(WCF_DIR);
?>
log/" writable!<?php
} else {
echo StringUtil::encodeHTML($this->_getMessage());
}
?>
</h1>
<?php
if (WCF::debugModeIsEnabled()) {
?>
<div>
<?php
if ($this->getDescription()) {
?>
<p><br /><?php
echo $this->getDescription();
?>
</p><?php
}
?>
<h2>Information:</h2>
<p>
<b>id:</b> <code><?php
echo $this->getExceptionID();
?>
</code><br>
<b>error message:</b> <?php
echo StringUtil::encodeHTML($this->_getMessage());
?>
<br>
<b>error code:</b> <?php
echo intval($e->getCode());
?>
<br>
<?php
echo $this->information;
?>
<b>file:</b> <?php
echo StringUtil::encodeHTML($e->getFile());
?>
示例7: __construct
/**
* Throws a JSON-encoded error message
*
* @param string $message
* @param boolean $isDoomsday
* @param string $stacktrace
* @param array $returnValues
* @param string $exceptionID
* @param array<mixed> $returnValues
*/
public function __construct($message, $errorType = self::INTERNAL_ERROR, $stacktrace = null, $returnValues = array(), $exceptionID = '')
{
if ($stacktrace === null) {
$stacktrace = $this->getTraceAsString();
}
$responseData = array('code' => $errorType, 'message' => $message, 'returnValues' => $returnValues);
// include a stacktrace if:
// - debug mode is enabled
// - within ACP and a SystemException was thrown
if (WCF::debugModeIsEnabled(false) || WCF::debugModeIsEnabled() && self::INTERNAL_ERROR) {
$responseData['stacktrace'] = nl2br($stacktrace);
}
$statusHeader = '';
switch ($errorType) {
case self::MISSING_PARAMETERS:
$statusHeader = 'HTTP/1.0 400 Bad Request';
$responseData['exceptionID'] = $exceptionID;
$responseData['message'] = WCF::getLanguage()->get('wcf.ajax.error.badRequest');
break;
case self::SESSION_EXPIRED:
$statusHeader = 'HTTP/1.0 409 Conflict';
break;
case self::INSUFFICIENT_PERMISSIONS:
$statusHeader = 'HTTP/1.0 403 Forbidden';
break;
case self::BAD_PARAMETERS:
$statusHeader = 'HTTP/1.0 431 Bad Parameters';
$responseData['exceptionID'] = $exceptionID;
break;
default:
case self::INTERNAL_ERROR:
//header('HTTP/1.0 418 I\'m a Teapot');
header('HTTP/1.0 503 Service Unavailable');
$responseData['code'] = self::INTERNAL_ERROR;
$responseData['exceptionID'] = $exceptionID;
if (!WCF::debugModeIsEnabled()) {
$responseData['message'] = WCF::getLanguage()->get('wcf.ajax.error.internalError');
}
break;
}
header($statusHeader);
header('Content-type: application/json');
echo JSON::encode($responseData);
exit;
}
示例8: __construct
/**
* Creates a new instance of memcached.
*/
public function __construct()
{
if (!class_exists('Memcached')) {
throw new SystemException('memcached support is not enabled.');
}
if (!defined('\\Memcached::OPT_REMOVE_FAILED_SERVERS')) {
throw new SystemException('required \\Memcached::OPT_REMOVE_FAILED_SERVERS option is not available');
}
// init memcached
$this->memcached = new \Memcached();
// disable broken hosts for the remainder of the execution
// Note: This may cause outdated entries once the affected memcached
// server comes back online. But it is better than completely bailing out.
// If the outage wasn't solely related to networking the cache is flushed
// on restart of the affected memcached instance anyway.
$this->memcached->setOption(\Memcached::OPT_REMOVE_FAILED_SERVERS, 1);
// LIBKETAMA_COMPATIBLE uses consistent hashing, which causes fewer remaps
// in case a server is added or removed.
$this->memcached->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
$this->memcached->setOption(\Memcached::OPT_PREFIX_KEY, WCF_UUID . '_');
if (!WCF::debugModeIsEnabled()) {
// use the more efficient binary protocol to communicate with the memcached instance
// this option is disabled in debug mode to allow for easier debugging
// with tools, such as strace(1)
$this->memcached->setOption(\Memcached::OPT_BINARY_PROTOCOL, true);
}
// add servers
$tmp = explode("\n", StringUtil::unifyNewlines(CACHE_SOURCE_MEMCACHED_HOST));
$servers = array();
$defaultWeight = floor(100 / count($tmp));
$regex = new Regex('^\\[([a-z0-9\\:\\.]+)\\](?::([0-9]{1,5}))?(?::([0-9]{1,3}))?$', Regex::CASE_INSENSITIVE);
foreach ($tmp as $server) {
$server = StringUtil::trim($server);
if (!empty($server)) {
$host = $server;
$port = 11211;
// default memcached port
$weight = $defaultWeight;
// check for IPv6
if ($regex->match($host)) {
$matches = $regex->getMatches();
$host = $matches[1];
if (isset($matches[2])) {
$port = $matches[2];
}
if (isset($matches[3])) {
$weight = $matches[3];
}
} else {
// IPv4, try to get port and weight
if (strpos($host, ':')) {
$parsedHost = explode(':', $host);
$host = $parsedHost[0];
$port = $parsedHost[1];
if (isset($parsedHost[2])) {
$weight = $parsedHost[2];
}
}
}
$servers[] = array($host, $port, $weight);
}
}
$this->memcached->addServers($servers);
// test connection, set will fail if no memcached instances are available
// if only the target for the 'connection_testing' key is unavailable the
// requests will automatically be mapped to another server
if (!$this->memcached->set('connection_testing', true)) {
throw new SystemException('Unable to obtain any valid connection');
}
}