ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilLoggingErrorFileStorage Class Reference

Saves error informations into file. More...

+ Collaboration diagram for ilLoggingErrorFileStorage:

Public Member Functions

 __construct ($inspector, $file_path, $file_name)
 
 write ()
 

Data Fields

const KEY_SPACE = 25
 
const FILE_FORMAT = ".log"
 

Protected Member Functions

 createDir ($path)
 
 content ()
 
 pageHeader ()
 Get the header for the page. More...
 
 exceptionContent ()
 Get a short info about the exception. More...
 
 tablesContent ()
 Get the header for the page. More...
 
 tables ()
 Get the tables that should be rendered. More...
 

Private Member Functions

 hidePassword (array $post)
 Replace passwort from post array with security message. More...
 
 shortenPHPSessionId (array $server)
 Shorts the php session id. More...
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilLoggingErrorFileStorage::__construct (   $inspector,
  $file_path,
  $file_name 
)

Definition at line 16 of file class.ilLoggingErrorFileStorage.php.

16 {
17 $this->inspector = $inspector;
18 $this->file_path = $file_path;
19 $this->file_name = $file_name;
20 }

Member Function Documentation

◆ content()

ilLoggingErrorFileStorage::content ( )
protected

Definition at line 28 of file class.ilLoggingErrorFileStorage.php.

28 {
29 return $this->pageHeader()
30 .$this->exceptionContent()
31 .$this->tablesContent()
32 ;
33 }
pageHeader()
Get the header for the page.

References pageHeader().

Referenced by write().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createDir()

ilLoggingErrorFileStorage::createDir (   $path)
protected

Definition at line 22 of file class.ilLoggingErrorFileStorage.php.

22 {
23 if(!is_dir($this->file_path)) {
24 ilUtil::makeDirParents($this->file_path);
25 }
26 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References ilUtil\makeDirParents().

Referenced by write().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exceptionContent()

ilLoggingErrorFileStorage::exceptionContent ( )
protected

Get a short info about the exception.

Returns
string

Definition at line 59 of file class.ilLoggingErrorFileStorage.php.

59 {
60 return Formatter::formatExceptionPlain($this->inspector);
61 }

◆ hidePassword()

ilLoggingErrorFileStorage::hidePassword ( array  $post)
private

Replace passwort from post array with security message.

Parameters
array$post
Returns
array

Definition at line 128 of file class.ilLoggingErrorFileStorage.php.

128 {
129 if(isset($post["password"])) {
130 $post["password"] = "REMOVED FOR SECURITY";
131 }
132
133 return $post;
134 }

Referenced by tables().

+ Here is the caller graph for this function:

◆ pageHeader()

ilLoggingErrorFileStorage::pageHeader ( )
protected

Get the header for the page.

Returns
string

Definition at line 50 of file class.ilLoggingErrorFileStorage.php.

50 {
51 return "";
52 }

Referenced by content().

+ Here is the caller graph for this function:

◆ shortenPHPSessionId()

ilLoggingErrorFileStorage::shortenPHPSessionId ( array  $server)
private

Shorts the php session id.

Parameters
array$server
Returns
array

Definition at line 143 of file class.ilLoggingErrorFileStorage.php.

143 {
144 global $ilLog;
145
146 $cookie_content = $server["HTTP_COOKIE"];
147 $cookie_content = explode(";", $cookie_content);
148
149 foreach ($cookie_content as $key => $content) {
150 $content_array = explode("=", $content);
151 if(trim($content_array[0]) == session_name()) {
152 $content_array[1] = substr($content_array[1], 0, 5)." (SHORTENED FOR SECURITY)";
153 $cookie_content[$key] = implode("=", $content_array);
154 }
155 }
156
157 $server["HTTP_COOKIE"] = implode(";", $cookie_content);
158
159 return $server;
160 }
$server

References $ilLog, and $server.

Referenced by tables().

+ Here is the caller graph for this function:

◆ tables()

ilLoggingErrorFileStorage::tables ( )
protected

Get the tables that should be rendered.

Returns
array $title => $table

Definition at line 103 of file class.ilLoggingErrorFileStorage.php.

103 {
104 $post = $_POST;
106
107 $post = $this->hidePassword($post);
109
110 return array
111 ( "GET Data" => $_GET
112 , "POST Data" => $post
113 , "Files" => $_FILES
114 , "Cookies" => $_COOKIE
115 , "Session" => isset($_SESSION) ? $_SESSION : array()
116 , "Server/Request Data" => $server
117 , "Environment Variables" => $_ENV
118 );
119 }
$_COOKIE['ilClientId']
Definition: BPMN2Parser.php:15
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
hidePassword(array $post)
Replace passwort from post array with security message.
shortenPHPSessionId(array $server)
Shorts the php session id.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

References $_COOKIE, $_GET, $_POST, $_SERVER, $_SESSION, $server, hidePassword(), and shortenPHPSessionId().

Referenced by tablesContent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tablesContent()

ilLoggingErrorFileStorage::tablesContent ( )
protected

Get the header for the page.

Returns
string

Definition at line 68 of file class.ilLoggingErrorFileStorage.php.

68 {
69 $ret = "";
70 foreach ($this->tables() as $title => $content) {
71 $ret .= "\n\n-- $title --\n\n";
72 if (count($content) > 0) {
73 foreach ($content as $key => $value) {
74 $key = str_pad($key, self::KEY_SPACE);
75
76 // indent multiline values, first print_r, split in lines,
77 // indent all but first line, then implode again.
78 $first = true;
79 $indentation = str_pad("", self::KEY_SPACE);
80 $value = implode("\n", array_map(function($line) use (&$first, $indentation) {
81 if ($first) {
82 $first = false;
83 return $line;
84 }
85 return $indentation.$line;
86 }, explode("\n", print_r($value, true))));
87
88 $ret .= "$key: $value\n";
89 }
90 }
91 else {
92 $ret .= "empty\n";
93 }
94 }
95 return $ret;
96 }
tables()
Get the tables that should be rendered.
$ret
Definition: parser.php:6

References $ret, $title, and tables().

+ Here is the call graph for this function:

◆ write()

ilLoggingErrorFileStorage::write ( )

Definition at line 35 of file class.ilLoggingErrorFileStorage.php.

35 {
36 $this->createDir($this->file_path);
37
38 $file_name = $this->file_path."/".$this->file_name.self::FILE_FORMAT;
39 $stream = fopen($file_name, 'w+');
40 fwrite($stream, $this->content());
41 fclose($stream);
42 chmod($file_name, 0755);
43 }

References content(), and createDir().

+ Here is the call graph for this function:

Field Documentation

◆ FILE_FORMAT

const ilLoggingErrorFileStorage::FILE_FORMAT = ".log"

Definition at line 14 of file class.ilLoggingErrorFileStorage.php.

◆ KEY_SPACE

const ilLoggingErrorFileStorage::KEY_SPACE = 25

Definition at line 13 of file class.ilLoggingErrorFileStorage.php.


The documentation for this class was generated from the following file: