Exemplo n.º 1
0
 /**
  * Returns debug data
  *
  * @access	protected
  * @return	string		Debug HTML
  */
 public function html_showDebugInfo()
 {
     $input = "";
     $queries = "";
     $sload = "";
     $stats = "";
     //-----------------------------------------
     // Form & Get & Skin
     //-----------------------------------------
     if ($this->settings['debug_level'] >= 2) {
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>IPSDebug сообщения</div><div class='row1' style='padding:6px'>\n";
         foreach (IPSDebug::getMessages() as $dx => $entry) {
             $stats .= "<strong>{$entry}</strong><br />\n";
         }
         $stats .= "</div>\n</div>";
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>IPSMember кеши</div><div class='row1' style='padding:6px'>\n";
         if (is_array(IPSMember::$debugData)) {
             foreach (IPSMember::$debugData as $entry) {
                 $stats .= "<strong>{$entry}</strong><br />\n";
             }
         }
         $stats .= "</div>\n</div>";
         /* Included Files */
         if (function_exists('get_included_files')) {
             $__files = get_included_files();
             $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>(" . count($__files) . ") подключенных файлов</div><div class='row1' style='padding:6px'>\n";
             foreach ($__files as $__f) {
                 $stats .= "<strong>{$__f}</strong><br />";
             }
             $stats .= '</div></div>';
         }
         /* Caches */
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>Загруженных кешей</div><div class='row1' style='padding:6px'>\n";
         $_total = 0;
         if (is_array($this->cache->debugInfo)) {
             foreach ($this->cache->debugInfo as $key => $data) {
                 $_size = $data['size'];
                 $_total += $_size;
                 $stats .= "<strong>{$key}</strong> - " . IPSLib::sizeFormat($_size) . "<br />\n";
             }
         }
         $stats .= "<strong>ИТОГО: " . IPSLib::sizeFormat($_total) . "</strong></div>\n</div>";
         /* Loaded classes */
         $loadedClasses = $this->registry->getLoadedClassesAsArray();
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>Загруженные классы через ipsRegistry::getClass()</div><div class='row1' style='padding:6px'>\n";
         if (is_array($loadedClasses)) {
             foreach ($loadedClasses as $entry) {
                 $stats .= "<strong>{$entry}</strong><br />\n";
             }
         }
         $stats .= "</div>\n</div>";
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>FORM и GET данные</div><div class='row1' style='padding:6px'>\n";
         foreach ($this->request as $k => $v) {
             if (in_array(strtolower($k), array('pass', 'password'))) {
                 $v = '*******';
             }
             $stats .= "<strong>{$k}</strong> = {$v}<br />\n";
         }
         $stats .= "</div>\n</div>";
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>SKIN, MEMBER & TASK Info</div><div class='row1' style='padding:6px'>\n";
         while (list($k, $v) = each($this->skin)) {
             if (is_array($v)) {
                 continue;
             }
             if (strlen($v) > 120) {
                 $v = substr($v, 0, 120) . '...';
             }
             $stats .= "<strong>{$k}</strong> = " . IPSText::htmlspecialchars($v) . "<br />\n";
         }
         //-----------------------------------------
         // Stop E_ALL moaning...
         //-----------------------------------------
         $cache = $this->caches['systemvars'];
         $cache['task_next_run'] = $cache['task_next_run'] ? $cache['task_next_run'] : 0;
         $stats .= "<b>Следующая задача</b> = " . $this->registry->getClass('class_localization')->getDate($cache['task_next_run'], 'LONG') . "\n<br /><b>Время</b> = " . $this->registry->getClass('class_localization')->getDate(time(), 'LONG');
         $stats .= "<br /><b>Сейчас</b> = " . time();
         $stats .= "<p>Пользователь: last_visit: " . $this->memberData['last_visit'] . " / " . $this->registry->getClass('class_localization')->getDate($this->memberData['last_visit'], 'LONG') . "</p>";
         $stats .= "<p>Пользователь: uagent_key: " . $this->memberData['userAgentKey'] . "</p>";
         $stats .= "<p>Пользователь: uagent_type: " . $this->memberData['userAgentType'] . "</p>";
         $stats .= "<p>Пользователь: uagent_version: " . $this->memberData['userAgentVersion'] . "</p>";
         $stats .= "</div>\n</div>";
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>Загруженные PHP шаблоны</div><div class='row1' style='padding:6px'>\n";
         $stats .= "<strong>" . implode(", ", array_keys($this->output->compiled_templates)) . "</strong><br />\n";
         $stats .= "<strong>" . implode(", ", array_keys($this->output->loaded_templates)) . "</strong><br />\n";
         $stats .= "<strong>" . implode(", ", array_values($this->registry->getClass('class_localization')->loaded_lang_files)) . "</strong><br />\n";
         $stats .= "</div>\n</div>";
     }
     //-----------------------------------------
     // SQL
     //-----------------------------------------
     if ($this->settings['debug_level'] >= 3) {
         $stats .= "<br />\n<div class='tableborder' style='overflow:auto'>\n<div class='subtitle'>Запросы</div><div class='row1' style='padding:6px'>";
         foreach ($this->DB->obj['cached_queries'] as $q) {
             $q = htmlspecialchars($q);
             $q = str_ireplace("SELECT", "<span style='color:red'>SELECT</span>", $q);
             $q = preg_replace("/^UPDATE/i", "<span style='color:blue'>UPDATE</span>", $q);
             $q = preg_replace("/^DELETE/i", "<span style='color:orange'>DELETE</span>", $q);
             $q = preg_replace("/^INSERT/i", "<span style='color:green'>INSERT</span>", $q);
             $q = str_replace("LEFT JOIN", "<span style='color:red'>LEFT JOIN</span>", $q);
             $stats .= "<p style='padding:6px;border-bottom:1px solid black'>{$q}</p>\n";
         }
         if (count($this->DB->obj['shutdown_queries'])) {
             foreach ($this->DB->obj['shutdown_queries'] as $q) {
                 $q = htmlspecialchars($q);
                 $q = preg_replace("/^SELECT/i", "<span style='color:red'>SELECT</span>", $q);
                 $q = preg_replace("/^UPDATE/i", "<span style='color:blue'>UPDATE</span>", $q);
                 $q = preg_replace("/^DELETE/i", "<span style='color:orange'>DELETE</span>", $q);
                 $q = preg_replace("/^INSERT/i", "<span style='color:green'>INSERT</span>", $q);
                 $q = str_replace("LEFT JOIN", "<span style='color:red'>LEFT JOIN</span>", $q);
                 //$q = preg_replace( "/(".$this->settings['sql_tbl_prefix'].")(\S+?)([\s\.,]|$)/", "<span class='purple'>\\1\\2</span>\\3", $q );
                 $stats .= "<div style='background:#DEDEDE'><b>SHUTDOWN:</b> {$q}</div><br />\n";
             }
         }
         $stats .= "</div>\n</div>";
     }
     //-----------------------------------------
     // Memory usage
     //-----------------------------------------
     if (IPS_MEMORY_DEBUG_MODE and defined('IPS_MEMORY_START') and $this->memberData['g_access_cp']) {
         if (is_array(IPSDebug::$memory_debug)) {
             $memory .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>MEMORY USAGE</div><div class='row1' style='padding:6px'>\n";
             $memory .= "<table cellpadding='4' cellspacing='0' border='0' width='100%'>\n";
             $_c = 0;
             foreach (IPSDebug::$memory_debug as $usage) {
                 $_col = $_c % 2 ? '#eee' : '#ddd';
                 $_c++;
                 if ($usage[1] > 500 * 1024) {
                     $_col .= ";color:#D00000";
                 } else {
                     if ($usage[1] < 10 * 1024) {
                         $_col .= ";color:darkgreen";
                     } else {
                         if ($usage[1] < 100 * 1024) {
                             $_col .= ";color:darkorange";
                         }
                     }
                 }
                 $memory .= "<tr><td width='60%' style='background-color:{$_col}' align='left'>{$usage[0]}</td><td style='background-color:{$_col}' align='left'><strong>" . IPSLib::sizeFormat($usage[1]) . "</strong></td></tr>";
             }
             $memory .= "</table></div></div>";
         }
         $end = memory_get_usage();
         $peak_end = function_exists('memory_get_peak_usage') ? memory_get_peak_usage() : memory_get_usage();
         $_used = $end - IPS_MEMORY_START;
         $peak_used = $peak_end - IPS_MEMORY_START;
         $stats .= $memory;
         $stats .= "Total Memory Used: " . IPSLib::sizeFormat($_used) . " (Peak:" . IPSLib::sizeFormat($peak_used) . ")";
     }
     if ($stats) {
         $stats = "\n\t\t\t\t\t  <div align='center' style='width:92%; margin:120px auto 20px auto; overflow:auto;'>\n\t\t\t\t\t   <div class='tableborder' align='left'>\n\t\t\t\t\t\t<div class='maintitle'>Debug Information (<a href='#' onclick=\"\$('debug').toggle(); return false;\">Toggle Debug Information</a>)</div>\n\t\t\t\t\t\t <div style='padding:5px;background:#8394B2;' id='debug'>{$stats}</div>\n\t\t\t\t\t   </div>\n\t\t\t\t\t  </div>";
     }
     return $stats;
 }
 /**
  * Returns debug data
  *
  * @access	private
  * @return	string		Debug HTML
  */
 public function html_showDebugInfo()
 {
     $input = "";
     $queries = "";
     $sload = "";
     $stats = "";
     //-----------------------------------------
     // Form & Get & Skin
     //-----------------------------------------
     /* Admins only */
     if (!$this->memberData['g_access_cp']) {
         //return '';
     }
     if ($this->settings['debug_level'] >= 2) {
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>IPSDebug Messages</div><div class='row1' style='padding:6px'>\n";
         foreach (IPSDebug::getMessages() as $dx => $entry) {
             $stats .= "<strong>{$entry}</strong><br />\n";
         }
         $stats .= "</div>\n</div>";
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>IPSMember Cache Actions</div><div class='row1' style='padding:6px'>\n";
         if (is_array(IPSMember::$debugData)) {
             foreach (IPSMember::$debugData as $entry) {
                 $stats .= "<strong>{$entry}</strong><br />\n";
             }
         }
         $stats .= "</div>\n</div>";
         /* Included Files */
         if (function_exists('get_included_files')) {
             $__files = get_included_files();
             $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>(" . count($__files) . ") Included Files</div><div class='row1' style='padding:6px'>\n";
             foreach ($__files as $__f) {
                 $stats .= "<strong>{$__f}</strong><br />";
             }
             $stats .= '</div></div>';
         }
         /* Caches */
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>Loaded Caches</div><div class='row1' style='padding:6px'>\n";
         $_total = 0;
         if (is_array($this->cache->debugInfo)) {
             foreach ($this->cache->debugInfo as $key => $data) {
                 $_size = $data['size'];
                 $_total += $_size;
                 $stats .= "<strong>{$key}</strong> - " . IPSLib::sizeFormat($_size) . "<br />\n";
             }
         }
         $stats .= "<strong>TOTAL: " . IPSLib::sizeFormat($_total) . "</strong></div>\n</div>";
         /* Loaded classes */
         $loadedClasses = $this->registry->getLoadedClassesAsArray();
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>Loaded Classes In ipsRegistry::getClass()</div><div class='row1' style='padding:6px'>\n";
         if (is_array($loadedClasses)) {
             foreach ($loadedClasses as $entry) {
                 $stats .= "<strong>{$entry}</strong><br />\n";
             }
         }
         $stats .= "</div>\n</div>";
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>FORM and GET Input</div><div class='row1' style='padding:6px'>\n";
         foreach ($this->request as $k => $v) {
             if (in_array(strtolower($k), array('pass', 'password'))) {
                 $v = '*******';
             }
             $stats .= "<strong>{$k}</strong> = {$v}<br />\n";
         }
         $stats .= "</div>\n</div>";
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>SKIN, MEMBER & TASK Info</div><div class='row1' style='padding:6px'>\n";
         while (list($k, $v) = each($this->skin)) {
             if (is_array($v)) {
                 continue;
             }
             if (strlen($v) > 120) {
                 $v = substr($v, 0, 120) . '...';
             }
             $stats .= "<strong>{$k}</strong> = " . IPSText::htmlspecialchars($v) . "<br />\n";
         }
         //-----------------------------------------
         // Stop E_ALL moaning...
         //-----------------------------------------
         $cache = $this->caches['systemvars'];
         $cache['task_next_run'] = $cache['task_next_run'] ? $cache['task_next_run'] : 0;
         $stats .= "<b>Next task</b> = " . $this->registry->getClass('class_localization')->getDate($cache['task_next_run'], 'LONG') . "\n<br /><b>Time now</b> = " . $this->registry->getClass('class_localization')->getDate(time(), 'LONG');
         $stats .= "<br /><b>Timestamp Now</b> = " . time();
         $stats .= "<p>MEMBER: last_visit: " . $this->memberData['last_visit'] . " / " . $this->registry->getClass('class_localization')->getDate($this->memberData['last_visit'], 'LONG') . "</p>";
         $stats .= "<p>MEMBER: uagent_key: " . $this->memberData['userAgentKey'] . "</p>";
         $stats .= "<p>MEMBER: uagent_type: " . $this->memberData['userAgentType'] . "</p>";
         $stats .= "<p>MEMBER: uagent_version: " . $this->memberData['userAgentVersion'] . "</p>";
         $stats .= "</div>\n</div>";
         $stats .= "<br />\n<div class='tableborder'>\n<div class='subtitle'>Loaded PHP Templates</div><div class='row1' style='padding:6px'>\n";
         $stats .= "<strong>" . implode(", ", array_keys($this->output->compiled_templates)) . "</strong><br />\n";
         $stats .= "<strong>" . implode(", ", array_keys($this->output->loaded_templates)) . "</strong><br />\n";
         $stats .= "<strong>" . implode(", ", array_values($this->registry->getClass('class_localization')->loaded_lang_files)) . "</strong><br />\n";
         $stats .= "</div>\n</div>";
     }
     //-----------------------------------------
     // SQL
     //-----------------------------------------
     if ($this->settings['debug_level'] >= 3) {
         $stats .= "<br />\n<div class='tableborder' style='overflow:auto'>\n<div class='subtitle'>Queries Used</div><div class='row1' style='padding:6px'>";
         foreach ($this->DB->obj['cached_queries'] as $q) {
             $q = htmlspecialchars($q);
             $q = str_ireplace("SELECT", "<span style='color:red'>SELECT</span>", $q);
             $q = preg_replace("/^UPDATE/i", "<span style='color:blue'>UPDATE</span>", $q);
             $q = preg_replace("/^DELETE/i", "<span style='color:orange'>DELETE</span>", $q);
             $q = preg_replace("/^INSERT/i", "<span style='color:green'>INSERT</span>", $q);
             $q = str_replace("LEFT JOIN", "<span style='color:red'>LEFT JOIN</span>", $q);
             $stats .= "<p style='padding:6px;border-bottom:1px solid black'>{$q}</p>\n";
         }
         if (count($this->DB->obj['shutdown_queries'])) {
             foreach ($this->DB->obj['shutdown_queries'] as $q) {
                 $q = htmlspecialchars($q);
                 $q = preg_replace("/^SELECT/i", "<span style='color:red'>SELECT</span>", $q);
                 $q = preg_replace("/^UPDATE/i", "<span style='color:blue'>UPDATE</span>", $q);
                 $q = preg_replace("/^DELETE/i", "<span style='color:orange'>DELETE</span>", $q);
                 $q = preg_replace("/^INSERT/i", "<span style='color:green'>INSERT</span>", $q);
                 $q = str_replace("LEFT JOIN", "<span style='color:red'>LEFT JOIN</span>", $q);
                 //$q = preg_replace( "/(".$this->settings['sql_tbl_prefix'].")(\S+?)([\s\.,]|$)/", "<span class='purple'>\\1\\2</span>\\3", $q );
                 $stats .= "<div style='background:#DEDEDE'><b>SHUTDOWN:</b> {$q}</div><br />\n";
             }
         }
         $stats .= "</div>\n</div>";
     }
     if ($stats) {
         $stats = "\n\t\t\t\t\t  <div align='center'>\n\t\t\t\t\t   <div class='row2' style='padding:8px;vertical-align:middle'><a href='#' onclick=\"\$('debug').toggle(); return false;\">Hide Debug Information</a></div>\n\t\t\t\t\t   <br />\n\t\t\t\t\t   <div class='tableborder' align='left' id='debug'>\n\t\t\t\t\t\t<div class='maintitle'>Debug Information</div>\n\t\t\t\t\t\t <div style='padding:5px;background:#8394B2;'>{$stats}</div>\n\t\t\t\t\t   </div>\n\t\t\t\t\t  </div>";
     }
     return $stats;
 }