Subversion Repositories oidplus

Compare Revisions

Regard whitespace Rev 1265 → Rev 1266

/trunk/includes/classes/OIDplusConfigInitializationException.class.php
46,7 → 46,7
$message = '<p>'.$message.'</p><p>Please check the file <b>userdata/baseconfig/config.inc.php</b> or run <b>setup/</b> again</p>';
}
 
parent::__construct($message, $title);
parent::__construct($message, $title, 500);
}
 
}
/trunk/includes/classes/OIDplusException.class.php
34,11 → 34,18
protected $title = null;
 
/**
* @var int
*/
protected $httpStatus = 500;
 
/**
* @param string $message
* @param string|null $title
* @param int $httpStatus
*/
public function __construct(string $message, string $title=null) {
public function __construct(string $message, string $title=null, int $httpStatus=500) {
$this->title = $title;
$this->httpStatus = $httpStatus;
parent::__construct($message);
}
 
50,11 → 57,19
}
 
/**
* @return int
*/
public function getHttpStatus(): int {
return $this->httpStatus;
}
 
/**
* @return string
*/
public function getHtmlTitle(): string {
return htmlentities($this->getTitle(), ENT_SUBSTITUTE); // ENT_SUBSTITUTE because ODBC drivers might return ANSI instead of UTF-8 stuff
}
 
/**
* @return string
*/
/trunk/includes/classes/OIDplusGui.class.php
49,6 → 49,9
} else {
$out['text'] = '<p>'.$htmlmsg.'</p>';
}
if (isset($_SERVER['SCRIPT_FILENAME']) && (strtolower(basename($_SERVER['SCRIPT_FILENAME'])) !== 'ajax.php')) { // don't send HTTP error codes in ajax.php, because we want a page and not a JavaScript alert box, when someone enters an invalid OID in the GoTo-Box
if (PHP_SAPI != 'cli') @http_response_code($e instanceof OIDplusException ? $e->getHttpStatus() : 500);
}
if (OIDplus::baseConfig()->getValue('DEBUG')) {
$out['text'] .= self::getExceptionTechInfo($e);
}
132,17 → 135,20
public static function html_exception_handler(\Throwable $exception) {
// Note: This method must be static, because of its registration as Exception handler
 
if (PHP_SAPI != 'cli') @http_response_code(500);
 
if ($exception instanceof OIDplusException) {
$htmlTitle = $exception->gethtmlTitle();
$htmlMessage = $exception->getHtmlMessage();
if (isset($_SERVER['SCRIPT_FILENAME']) && (strtolower(basename($_SERVER['SCRIPT_FILENAME'])) !== 'ajax.php')) { // don't send HTTP error codes in ajax.php, because we want a page and not a JavaScript alert box, when someone enters an invalid OID in the GoTo-Box
if (PHP_SAPI != 'cli') @http_response_code($exception->getHttpStatus());
}
} else {
$htmlTitle = '';
//$htmlMessage = htmlentities($exception->getMessage());
$htmlMessage = nl2br(htmlentities(html_to_text($exception->getMessage())));
 
if (isset($_SERVER['SCRIPT_FILENAME']) && (strtolower(basename($_SERVER['SCRIPT_FILENAME'])) !== 'ajax.php')) { // don't send HTTP error codes in ajax.php, because we want a page and not a JavaScript alert box, when someone enters an invalid OID in the GoTo-Box
if (PHP_SAPI != 'cli') @http_response_code(500);
}
}
if (!$htmlTitle) {
$htmlTitle = _L('OIDplus Error');
}
/trunk/includes/classes/OIDplusHtmlException.class.php
42,7 → 42,7
* @param string $message
* @param string|null $title
*/
public function __construct(string $message, string $title=null) {
public function __construct(string $message, string $title=null, int $httpStatus=500) {
$this->htmlTitle = $title;
if ($title) {
$title = strip_tags($title);
54,7 → 54,7
$this->htmlMessage = $message;
$message_text = html_to_text($message);
 
parent::__construct($message_text, $title_text);
parent::__construct($message_text, $title_text, $httpStatus);
}
 
/**
/trunk/includes/classes/OIDplusSQLException.class.php
30,7 → 30,7
* @param string $message
*/
public function __construct(string $sql, string $message) {
parent::__construct(_L('%1 at query "%2"',$message,$sql));
parent::__construct(_L('%1 at query "%2"',$message,$sql), null, 500);
}
 
}