19 declare(strict_types=1);
35 public function __construct(Inspector $inspector,
string $file_path,
string $file_name)
54 return str_replace(
"\0",
'', $ret);
59 if (!is_dir($this->file_path)) {
75 $file_name = $this->file_path .
'/' . $this->file_name . self::FILE_FORMAT;
76 $stream = fopen($file_name,
'wb+');
77 fwrite($stream, $this->
content());
79 chmod($file_name, 0755);
89 $message = Formatter::formatExceptionPlain($this->inspector);
91 $exception = $this->inspector->getException();
92 $previous = $exception->getPrevious();
94 $message .=
"\n\nCaused by\n" . sprintf(
95 '%s: %s in file %s on line %d',
97 $previous->getMessage(),
101 $previous = $previous->getPrevious();
110 foreach ($this->
tables() as $title => $content) {
111 $ret .=
"\n\n-- $title --\n\n";
112 if (count($content) > 0) {
113 foreach ($content as $key => $value) {
114 $key = str_pad((
string) $key, self::KEY_SPACE);
119 $indentation = str_pad(
'', self::KEY_SPACE);
120 $value = implode(
"\n",
array_map(
static function ($line) use (&$first, $indentation):
string {
125 return $indentation . $line;
126 }, explode(
"\n", print_r($value,
true))));
128 $ret .=
"$key: $value\n";
149 'POST Data' =>
$post,
152 'Session' => $_SESSION ?? [],
153 'Server/Request Data' =>
$server,
154 'Environment Variables' => $_ENV
164 foreach ($this->exclusion_list as $parameter) {
165 if (isset($super_global[$parameter])) {
166 $super_global[$parameter] =
'REMOVED FOR SECURITY';
169 if (isset($super_global[
'post_vars'][$parameter])) {
170 $super_global[
'post_vars'][$parameter] =
'REMOVED FOR SECURITY';
174 return $super_global;
179 if (!isset($server[
'HTTP_COOKIE'])) {
182 $cookie_content = $server[
'HTTP_COOKIE'];
183 $cookie_content = explode(
';', $cookie_content);
185 foreach ($cookie_content as $key => $content) {
186 $content_array = explode(
'=', $content);
187 if (trim($content_array[0]) === session_name()) {
188 $content_array[1] = substr($content_array[1], 0, 5) .
' (SHORTENED FOR SECURITY)';
189 $cookie_content[$key] = implode(
'=', $content_array);
193 $server[
'HTTP_COOKIE'] = implode(
';', $cookie_content);
withExclusionList(array $exclusion_list)
__construct(Inspector $inspector, string $file_path, string $file_name)
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
shortenPHPSessionId(array $server)
hideSensitiveData(array $super_global)
stripNullBytes(string $ret)