ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Misc.php
Go to the documentation of this file.
1 <?php
7 namespace Whoops\Util;
8 
9 class Misc
10 {
21  public static function canSendHeaders()
22  {
23  return isset($_SERVER["REQUEST_URI"]) && !headers_sent();
24  }
25 
26  public static function isAjaxRequest()
27  {
28  return (
29  !empty($_SERVER['HTTP_X_REQUESTED_WITH'])
30  && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
31  }
32 
37  public static function isCommandLine()
38  {
39  return PHP_SAPI == 'cli';
40  }
41 
48  public static function translateErrorCode($error_code)
49  {
50  $constants = get_defined_constants(true);
51  if (array_key_exists('Core', $constants)) {
52  foreach ($constants['Core'] as $constant => $value) {
53  if (substr($constant, 0, 2) == 'E_' && $value == $error_code) {
54  return $constant;
55  }
56  }
57  }
58  return "E_UNKNOWN";
59  }
60 
67  public static function isLevelFatal($level)
68  {
69  $errors = E_ERROR;
70  $errors |= E_PARSE;
71  $errors |= E_CORE_ERROR;
72  $errors |= E_CORE_WARNING;
73  $errors |= E_COMPILE_ERROR;
74  $errors |= E_COMPILE_WARNING;
75  return ($level & $errors) > 0;
76  }
77 }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
static translateErrorCode($error_code)
Translate ErrorException code into the represented constant.
Definition: Misc.php:48
static isAjaxRequest()
Definition: Misc.php:26
static isCommandLine()
Check, if possible, that this execution was triggered by a command line.
Definition: Misc.php:37
static canSendHeaders()
Can we at this point in time send HTTP headers?
Definition: Misc.php:21
$errors
Definition: index.php:6
Whoops - php errors for cool kids.
static isLevelFatal($level)
Determine if an error level is fatal (halts execution)
Definition: Misc.php:67