XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
render.php
Go to the documentation of this file.
1 <?php
23 defined('XOOPS_ROOT_PATH') or die('Restricted access');
24 
25 $ret = '';
26 if ($mode == 'popup') {
27  $dump = $this->dump('');
28  $content = '
29 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
30 <head>
31  <meta http-equiv="content-language" content="' . _LANGCODE . '" />
32  <meta http-equiv="content-type" content="text/html; charset=' . _CHARSET . '" />
33  <title>' . $xoopsConfig['sitename'] . ' - ' . _LOGGER_DEBUG . ' </title>
34  <meta name="generator" content="XOOPS" />
35  <link rel="stylesheet" type="text/css" media="all" href="' . xoops_getcss($xoopsConfig['theme_set']) . '" />
36 </head>
37 <body>' . $dump . '
38  <div style="text-align:center;">
39  <input class="formButton" value="' . _CLOSE . '" type="button" onclick="javascript:window.close();" />
40  </div>
41 ';
42  $ret .= '
43 <script type="text/javascript">
44  debug_window = openWithSelfMain("about:blank", "popup", 680, 450, true);
45  debug_window.document.clear();
46 ';
47  $lines = preg_split("/(\r\n|\r|\n)( *)/", $content);
48  foreach ($lines as $line) {
49  $ret .= "\n" . 'debug_window.document.writeln("' . str_replace(array('"' , '</'), array('\"' , '<\/'), $line) . '");';
50  }
51  $ret .= '
52  debug_window.focus();
53  debug_window.document.close();
54 </script>
55 ';
56 }
57 
58 $this->addExtra(_LOGGER_INCLUDED_FILES, sprintf(_LOGGER_FILES, count(get_included_files())));
59 $memory = 0;
60 
61 if (function_exists('memory_get_usage')) {
62  $memory = memory_get_usage() . ' bytes';
63 } else {
64  if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
65  $out = array();
66  exec('tasklist /FI "PID eq ' . getmypid() . '" /FO LIST', $out);
67  if (isset($out[5])) {
68  $memory = sprintf(_LOGGER_MEM_ESTIMATED, substr($out[5], strpos($out[5], ':') + 1));
69  }
70  }
71 }
72 if ($memory) {
73  $this->addExtra(_LOGGER_MEM_USAGE, $memory);
74 }
75 
76 if (empty($mode)) {
77  $views = array('errors' , 'deprecated', 'queries' , 'blocks' , 'extra');
78  $ret .= "\n<div id=\"xo-logger-output\">\n<div id='xo-logger-tabs'>\n";
79  $ret .= "<a href='javascript:xoSetLoggerView(\"none\")'>" . _LOGGER_NONE . "</a>\n";
80  $ret .= "<a href='javascript:xoSetLoggerView(\"\")'>" . _LOGGER_ALL . "</a>\n";
81  foreach ($views as $view) {
82  $count = count($this->$view);
83  $ret .= "<a href='javascript:xoSetLoggerView(\"$view\")'>" . constant('_LOGGER_' . strtoupper($view)) ." ($count)</a>\n";
84  }
85  $count = count($this->logstart);
86  $ret .= "<a href='javascript:xoSetLoggerView(\"timers\")'>" . _LOGGER_TIMERS . "($count)</a>\n";
87  $ret .= "</div>\n";
88 }
89 
90 if (empty($mode) || $mode == 'errors') {
91  $types = array(
92  E_USER_NOTICE => _LOGGER_E_USER_NOTICE,
93  E_USER_WARNING => _LOGGER_E_USER_WARNING,
94  E_USER_ERROR => _LOGGER_E_USER_ERROR,
95  E_NOTICE => _LOGGER_E_NOTICE,
96  E_WARNING => _LOGGER_E_WARNING,
97  /*E_STRICT => _LOGGER_E_STRICT*/
98  );
99  $class = 'even';
100  $ret .= '<table id="xo-logger-errors" class="outer"><tr><th>' . _LOGGER_ERRORS . '</th></tr>';
101  foreach ($this->errors as $error) {
102  $ret .= "\n<tr><td class='$class'>";
103  $ret .= isset($types[$error['errno']]) ? $types[$error['errno']] : _LOGGER_UNKNOWN;
104  $ret .= ": ";
105  $ret .= sprintf(_LOGGER_FILELINE, $this->sanitizePath($error['errstr']), $this->sanitizePath($error['errfile']), $error['errline']);
106  $ret .= "<br />\n</td></tr>";
107  $class = ($class == 'odd') ? 'even' : 'odd';
108  }
109  $ret .= "\n</table>\n";
110 }
111 
112 if (empty($mode) || $mode == 'deprecated') {
113  $class = 'even';
114  $ret .= '<table id="xo-logger-deprecated" class="outer"><tr><th>' . _LOGGER_DEPRECATED . '</th></tr>';
115  foreach ($this->deprecated as $message) {
116  $ret .= "\n<tr><td class='$class'>";
117  $ret .= $message;
118  $ret .= "<br />\n</td></tr>";
119  $class = ($class == 'odd') ? 'even' : 'odd';
120  }
121  $ret .= "\n</table>\n";
122 }
123 
124 if (empty($mode) || $mode == 'queries') {
125  $class = 'even';
126  $ret .= '<table id="xo-logger-queries" class="outer"><tr><th>' . _LOGGER_QUERIES . '</th></tr>';
128  $pattern = '/\b' . preg_quote($xoopsDB->prefix()) . '\_/i';
129 
130  foreach ($this->queries as $q) {
131  $sql = preg_replace($pattern, '', $q['sql']);
132  $query_time = isset($q['query_time']) ? sprintf ('%0.6f - ', $q['query_time']) : '';
133 
134  if (isset($q['error'])) {
135  $ret .= '<tr class="' . $class . '"><td><span style="color:#ff0000;">' . $query_time . htmlentities($sql) . '<br /><strong>Error number:</strong> ' . $q['errno'] . '<br /><strong>Error message:</strong> ' . $q['error'] . '</span></td></tr>';
136  } else {
137  $ret .= '<tr class="' . $class . '"><td>' . $query_time. htmlentities($sql) . '</td></tr>';
138  }
139 
140  $class = ($class == 'odd') ? 'even' : 'odd';
141  }
142  $ret .= '<tr class="foot"><td>' . _LOGGER_TOTAL . ': <span style="color:#ff0000;">' . count($this->queries) . '</span></td></tr></table>';
143 }
144 if (empty($mode) || $mode == 'blocks') {
145  $class = 'even';
146  $ret .= '<table id="xo-logger-blocks" class="outer"><tr><th colspan="2">' . _LOGGER_BLOCKS . '</th></tr>';
147  foreach ($this->blocks as $b) {
148  if ($b['cached']) {
149  $ret .= '<tr><td class="' . $class . '"><strong>' . $b['name'] . ':</strong> ' . sprintf(_LOGGER_CACHED, intval($b['cachetime'])) . '</td></tr>';
150  } else {
151  $ret .= '<tr><td class="' . $class . '"><strong>' . $b['name'] . ':</strong> ' . _LOGGER_NOT_CACHED . '</td></tr>';
152  }
153  $class = ($class == 'odd') ? 'even' : 'odd';
154  }
155  $ret .= '<tr class="foot"><td>' . _LOGGER_TOTAL . ': <span style="color:#ff0000;">' . count($this->blocks) . '</span></td></tr></table>';
156 }
157 if (empty($mode) || $mode == 'extra') {
158  $class = 'even';
159  $ret .= '<table id="xo-logger-extra" class="outer"><tr><th colspan="2">' . _LOGGER_EXTRA . '</th></tr>';
160  foreach ($this->extra as $ex) {
161  $ret .= '<tr><td class="' . $class . '"><strong>';
162  $ret .= htmlspecialchars($ex['name']) . ':</strong> ' . htmlspecialchars($ex['msg']);
163  $ret .= '</td></tr>';
164  $class = ($class == 'odd') ? 'even' : 'odd';
165  }
166  $ret .= '</table>';
167 }
168 if (empty($mode) || $mode == 'timers') {
169  $class = 'even';
170  $ret .= '<table id="xo-logger-timers" class="outer"><tr><th colspan="2">' . _LOGGER_TIMERS . '</th></tr>';
171  foreach ($this->logstart as $k => $v) {
172  $ret .= '<tr><td class="' . $class . '"><strong>';
173  $ret .= sprintf(_LOGGER_TIMETOLOAD, htmlspecialchars($k) . '</strong>', '<span style="color:#ff0000;">' . sprintf("%.03f", $this->dumpTime($k)) . '</span>');
174  $ret .= '</td></tr>';
175  $class = ($class == 'odd') ? 'even' : 'odd';
176  }
177  $ret .= '</table>';
178 }
179 
180 if (empty($mode)) {
181  $ret .= <<<EOT
182 </div>
183 <script type="text/javascript">
184  function xoLogCreateCookie(name,value,days) {
185  if (days) {
186  var date = new Date();
187  date.setTime(date.getTime()+(days*24*60*60*1000));
188  var expires = "; expires="+date.toGMTString();
189  }
190  else var expires = "";
191  document.cookie = name+"="+value+expires+"; path=/";
192  }
193  function xoLogReadCookie(name) {
194  var nameEQ = name + "=";
195  var ca = document.cookie.split(';');
196  for(var i=0;i < ca.length;i++) {
197  var c = ca[i];
198  while (c.charAt(0)==' ') c = c.substring(1,c.length);
199  if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
200  }
201  return null;
202  }
203  function xoLogEraseCookie(name) {
204  createCookie(name,"",-1);
205  }
206  function xoSetLoggerView( name ) {
207  var log = document.getElementById( "xo-logger-output" );
208  if ( !log ) return;
209  var i, elt;
210  for ( i=0; i!=log.childNodes.length; i++ ) {
211  elt = log.childNodes[i];
212  if ( elt.tagName && elt.tagName.toLowerCase() != 'script' && elt.id != "xo-logger-tabs" ) {
213  elt.style.display = ( !name || elt.id == "xo-logger-" + name ) ? "block" : "none";
214  }
215  }
216  xoLogCreateCookie( 'XOLOGGERVIEW', name, 1 );
217  }
218  xoSetLoggerView( xoLogReadCookie( 'XOLOGGERVIEW' ) );
219 </script>
220 
221 EOT;
222 }
223 
224 ?>