function getsource($file, $line) { if (!(file_exists($file) && is_file($file))) { return ''; } $data = file($file); $count = count($data) - 1; $start = $line - $GLOBALS['G_DY']["sp_error_show_source"]; if ($start < 1) { $start = 1; } $end = $line + $GLOBALS['G_DY']["sp_error_show_source"]; if ($end > $count) { $end = $count + 1; } $returns = array(); for ($i = $start; $i <= $end; $i++) { if ($i == $line) { $returns[] = "<div id='current'>" . $i . ". " . highlight_code($data[$i - 1], TRUE) . "</div>"; } else { $returns[] = $i . ". " . highlight_code($data[$i - 1], TRUE); } } return $returns; }
function highlight($string) { $string = trim($string); $string = str_replace(array("#"), array(" "), $string); $string = str_replace(array("[code]", "[/code]", "<code>", "</code>"), array("#", "#", "#", "#"), $string); $first = substr($string, 0, 1); if ($first == '#') { $i = 2; } else { $i = 3; } $exploded = explode("#", $string); foreach ($exploded as $row) { if ($row != '') { if ($i % 2 != 0) { echo $row . '<br />'; } else { echo highlight_code($row) . '<br />'; } } else { $i = $i - 1; } $i++; } }
/** * Compile Queries (added total DB queries time) * * @access private * @return string */ function _compile_queries() { $dbs = array(); // Let's determine which databases are currently connected to foreach (get_object_vars($this->CI) as $CI_object) { if (is_subclass_of(get_class($CI_object), 'CI_DB')) { $dbs[] = $CI_object; } } if (count($dbs) == 0) { $output = "\n\n"; $output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; $output .= "\n"; $output .= '<legend style="color:#0000FF;"> ' . $this->CI->lang->line('profiler_queries') . ' </legend>'; $output .= "\n"; $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; $output .= "<tr><td width='100%' style='color:#0000FF;font-weight:normal;background-color:#eee;'>" . $this->CI->lang->line('profiler_no_db') . "</td></tr>\n"; $output .= "</table>\n"; $output .= "</fieldset>"; return $output; } // Load the text helper so we can highlight the SQL $this->CI->load->helper('text'); // Key words we want bolded $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')'); $output = "\n\n"; foreach ($dbs as $db) { $output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; $output .= "\n"; $output .= '<legend style="color:#0000FF;"> ' . $this->CI->lang->line('profiler_database') . ': ' . $db->database . ' ' . $this->CI->lang->line('profiler_queries') . ': ' . count($this->CI->db->queries) . ' </legend>'; $output .= "\n"; $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n"; if (count($db->queries) == 0) { $output .= "<tr><td width='100%' style='color:#0000FF;font-weight:normal;background-color:#eee;'>" . $this->CI->lang->line('profiler_no_queries') . "</td></tr>\n"; } else { $total_time = 0.0; foreach ($db->queries as $key => $val) { $time = number_format($db->query_times[$key], 4); $val = highlight_code($val, ENT_QUOTES); foreach ($highlight as $bold) { $val = str_replace($bold, '<strong>' . $bold . '</strong>', $val); } $output .= "<tr><td width='1%' valign='top' style='color:#990000;font-weight:normal;background-color:#ddd;'>" . $time . " </td><td style='color:#000;font-weight:normal;background-color:#ddd;'>" . $val . "</td></tr>\n"; $total_time += $db->query_times[$key]; } $output .= "<tr><td width='1%' valign='top' style='color:#990000;font-weight:normal;background-color:#ddd;'>" . number_format($total_time, 4) . " </td><td style='color:#000;font-weight:normal;background-color:#ddd;'>Total queries time</td></tr>\n"; } $output .= "</table>\n"; $output .= "</fieldset>"; } return $output; }
protected function _compile_queries() { $dbs = array(); // Let's determine which databases are currently connected to foreach (get_object_vars($this->CI) as $name => $cobject) { if (is_object($cobject)) { if ($cobject instanceof CI_DB) { $dbs[get_class($this->CI) . ':$' . $name] = $cobject; } elseif ($cobject instanceof CI_Model) { foreach (get_object_vars($cobject) as $mname => $mobject) { if ($mobject instanceof CI_DB) { $dbs[get_class($cobject) . ':$' . $mname] = $mobject; } } } } } if (count($dbs) === 0) { return "\n\n" . '<fieldset id="ci_profiler_queries" style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee;">' . "\n" . '<legend style="color:#0000FF;"> ' . $this->CI->lang->line('profiler_queries') . ' </legend>' . "\n\n\n<table style=\"border:none; width:100%;\">\n" . '<tr><td style="width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px;">' . $this->CI->lang->line('profiler_no_db') . "</td></tr>\n</table>\n</fieldset>"; } // Load the text helper so we can highlight the SQL $this->CI->load->helper('text'); // Key words we want bolded $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR ', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')'); $output = "\n\n"; $count = 0; foreach ($dbs as $name => $db) { $hide_queries = count($db->queries) > $this->_query_toggle_count ? ' display:none' : ''; $total_time = number_format(array_sum($db->query_times), 4) . ' ' . $this->CI->lang->line('profiler_seconds'); $show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_' . $count . '\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\'' . $this->CI->lang->line('profiler_section_hide') . '\'?\'' . $this->CI->lang->line('profiler_section_show') . '\':\'' . $this->CI->lang->line('profiler_section_hide') . '\';">' . $this->CI->lang->line('profiler_section_hide') . '</span>)'; if ($hide_queries !== '') { $show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_' . $count . '\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\'' . $this->CI->lang->line('profiler_section_show') . '\'?\'' . $this->CI->lang->line('profiler_section_hide') . '\':\'' . $this->CI->lang->line('profiler_section_show') . '\';">' . $this->CI->lang->line('profiler_section_show') . '</span>)'; } $output .= '<fieldset id="ci_profiler_queries" style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee;">' . "\n" . '<legend style="color:#0000FF;"> ' . $this->CI->lang->line('profiler_database') . ': ' . $db->database . ' (' . $name . ') ' . $this->CI->lang->line('profiler_queries') . ': ' . count($db->queries) . ' (' . $total_time . ') ' . $show_hide_js . "</legend>\n\n\n" . '<table style="width:100%;' . $hide_queries . '" id="ci_profiler_queries_db_' . $count . "\">\n"; if (count($db->queries) === 0) { $output .= '<tr><td style="width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px;">' . $this->CI->lang->line('profiler_no_queries') . "</td></tr>\n"; } else { foreach ($db->queries as $key => $val) { $time = number_format($db->query_times[$key], 4); $val = highlight_code($val); foreach ($highlight as $bold) { $val = str_replace($bold, '<strong>' . $bold . '</strong>', $val); } $output .= '<tr><td style="padding:5px;vertical-align:top;width:1%;color:#900;font-weight:normal;background-color:#ddd;">' . $time . ' </td><td style="padding:5px;color:#000;font-weight:normal;background-color:#ddd;">' . $val . "</td></tr>\n"; } } $output .= "</table>\n</fieldset>"; $count++; } return $output; }
function highlight_code_file($path, $begin_str = null, $end_str = null) { $output = ""; $content = file_get_contents($path); if (isset($begin_str) && isset($end_str)) { $begin_pos = strpos($content, $begin_str); $begin_len = strlen($begin_str); $end_pos = strpos($content, $end_str); $subcontent = substr($content, $begin_pos + $begin_len, $end_pos - $begin_pos - $begin_len); $output = highlight_code($subcontent); } else { $output = highlight_code($content); } return $output; }
protected function _compile_queries() { $output = array(); $input = parent::_compile_queries(); if (!empty($input)) { $this->CI->load->helper('text'); $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR ', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')'); foreach ($input as $database => $info) { $database = $this->base_uri($database); $output[$database] = array('name' => array_shift($info), 'total' => $this->milliseconds(array_shift($info))); foreach ($info as $db) { $db['query'] = highlight_code($db['query']); foreach ($highlight as $bold) { $db['query'] = str_replace($bold, '<strong>' . $bold . '</strong>', $db['query']); } $output[$database][] = array('query' => $db['query'], 'time' => $this->milliseconds($db['time'])); } } } return $output; }
$count = 0; foreach ($sections['queries'] as $database => $queries) { $name = array_shift($queries); $total_time = number_format(array_shift($queries), 4) . ' ' . lang('profiler_seconds'); $hide_queries = count($queries) > $toggle ? ' display:none' : ''; if ($hide_queries !== '') { $show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_' . $count . '\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\'' . lang('profiler_section_show') . '\'?\'' . lang('profiler_section_hide') . '\':\'' . lang('profiler_section_show') . '\';">' . lang('profiler_section_show') . '</span>)'; } else { $show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_' . $count . '\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\'' . lang('profiler_section_hide') . '\'?\'' . lang('profiler_section_show') . '\':\'' . lang('profiler_section_hide') . '\';">' . lang('profiler_section_hide') . '</span>)'; } $html .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee;">' . "\n" . '<legend style="color:#0000FF;"> ' . lang('profiler_database') . ': ' . $database . ' (' . $name . ') ' . lang('profiler_queries') . ': ' . count($queries) . ' (' . $total_time . ') ' . $show_hide_js . "</legend>\n\n\n" . '<table style="width:100%;' . $hide_queries . '" id="ci_profiler_queries_db_' . $count . "\">\n"; if (count($queries) === 0) { $html .= '<tr><td style="width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px;">' . lang('profiler_no_queries') . "</td></tr>\n"; } else { foreach ($queries as $query) { $val = highlight_code(array_shift($query)); foreach ($highlight as $bold) { $val = str_replace($bold, '<strong>' . $bold . '</strong>', $val); } $time = number_format(array_shift($query), 4); $html .= '<tr><td style="padding:5px;vertical-align:top;width:1%;color:#900;font-weight:normal;background-color:#ddd;">' . $time . ' </td><td style="padding:5px;color:#000;font-weight:normal;background-color:#ddd;">' . $val . "</td></tr>\n"; } } $html .= "</table>\n</fieldset>"; $count++; } } } if (isset($sections['http_headers'])) { $html .= "\n\n" . '<fieldset id="ci_profiler_http_headers" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee;">' . "\n" . '<legend style="color:#000;"> ' . lang('profiler_headers') . ' (<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_httpheaders_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\'' . lang('profiler_section_show') . '\'?\'' . lang('profiler_section_hide') . '\':\'' . lang('profiler_section_show') . '\';">' . lang('profiler_section_show') . "</span>)</legend>\n\n\n" . '<table style="width:100%;display:none;" id="ci_profiler_httpheaders_table">' . "\n"; foreach ($sections['http_headers'] as $header => $val) {
/** * Compile Queries * * @return string */ protected function _compile_queries() { $dbs = array(); // Let's determine which databases are currently connected to foreach (get_object_vars($this->CI) as $CI_object) { if (is_object($CI_object) && is_subclass_of(get_class($CI_object), 'CI_DB')) { $dbs[] = $CI_object; } } if (count($dbs) == 0) { $output = "\n\n"; $output .= '<div style="padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#fff;border-radius:10px;border:1px solid #00F;color:#00F" id="ci_profiler_queries">'; $output .= "\n"; $output .= '<span style="position:relative;bottom:15px;background-color:#fff"> ' . $this->CI->lang->line('profiler_queries') . ' </span>'; $output .= "\n"; $output .= "\n\n<table style='width:100%;text-align:left;font-size:16px'>\n"; $output .= "<tr><td style='padding:5px;width:100%;background-color:#ddd;color:#000;'>" . $this->CI->lang->line('profiler_no_db') . "</td></tr>\n"; $output .= "</table>\n"; $output .= "</div>"; return $output; } // Load the text helper so we can highlight the SQL $this->CI->load->helper('text'); // Key words we want bolded $highlight = array('SESSION', 'SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR ', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')'); $output = "\n\n"; $count = 0; foreach ($dbs as $db) { $count++; $hide_queries = count($db->queries) > $this->_query_toggle_count ? ' display:none' : ''; $show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_' . $count . '\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\'' . $this->CI->lang->line('profiler_section_hide') . '\'?\'' . $this->CI->lang->line('profiler_section_show') . '\':\'' . $this->CI->lang->line('profiler_section_hide') . '\';">' . $this->CI->lang->line('profiler_section_hide') . '</span>)'; if ($hide_queries != '') { $show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_' . $count . '\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\'' . $this->CI->lang->line('profiler_section_show') . '\'?\'' . $this->CI->lang->line('profiler_section_hide') . '\':\'' . $this->CI->lang->line('profiler_section_show') . '\';">' . $this->CI->lang->line('profiler_section_show') . '</span>)'; } $output .= '<div style="padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#fff;border-radius:10px;border:1px solid #00F;color:#00F" id="ci_profiler_queries">'; $output .= "\n"; $output .= '<span style="position:relative;bottom:15px;background-color:#fff;padding-right:10px"> ' . $this->CI->lang->line('profiler_database') . ': ' . $db->database . ' ' . $this->CI->lang->line('profiler_queries') . ': ' . count($db->queries) . ' ' . $show_hide_js . '</span>'; $output .= "\n"; $output .= "\n\n<table style='width:100%;text-align:left;font-size:16px;{$hide_queries}' id='ci_profiler_queries_db_{$count}'>\n"; if (count($db->queries) == 0) { $output .= "<tr><td style='padding:5px;width:100%;color:#0000FF;font-size:12px'>" . $this->CI->lang->line('profiler_no_queries') . "</td></tr>\n"; } else { foreach ($db->queries as $key => $val) { $time = number_format($db->query_times[$key], 4); $val = highlight_code($val, ENT_QUOTES); foreach ($highlight as $bold) { $val = str_replace($bold, '<strong>' . $bold . '</strong>', $val); } $output .= "<tr><td style='padding:5px;background-color:#eee;font-size:14px;width:1%;vertical-align:top;color:#900;'>" . $time . " </td><td style='padding:5px;width:100%;color:#000;background-color:#eee;font-size:12px'>" . $val . "</td></tr>\n"; } } $output .= "</table>\n"; $output .= "</div>"; } return $output; }
public function test_highlight_code() { $expect = "<code><span style=\"color: #000000\">\n<span style=\"color: #0000BB\"><?php var_dump</span><span style=\"color: #007700\">(</span><span style=\"color: #0000BB\">\$this</span><span style=\"color: #007700\">); </span><span style=\"color: #0000BB\">?> </span>\n</span>\n</code>"; $this->assertEquals($expect, highlight_code('<?php var_dump($this); ?>')); }
/** * Compile Queries * * @return string */ protected function _compile_queries() { $dbs = array(); // Let's determine which databases are currently connected to foreach (get_object_vars($this->CI) as $CI_object) { if (is_object($CI_object)) { if (is_subclass_of(get_class($CI_object), 'CI_DB')) { $dbs[] = $CI_object; } else { if (is_subclass_of(get_class($CI_object), 'CI_Model')) { $module_db = method_exists($CI_object, 'db') ? $CI_object->db() : $CI_object->db; if (is_object($module_db) && is_subclass_of(get_class($module_db), 'CI_DB')) { $dbs[get_class($CI_object)] = $module_db; } } } } } if (count($dbs) == 0) { $output = "\n\n"; $output .= '<fieldset id="ci_profiler_queries" style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; $output .= "\n"; $output .= '<legend style="color:#0000FF;"> ' . $this->CI->lang->line('profiler_queries') . ' </legend>'; $output .= "\n"; $output .= "\n\n<table style='border:none; width:100%'>\n"; $output .= "<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px'>" . $this->CI->lang->line('profiler_no_db') . "</td></tr>\n"; $output .= "</table>\n"; $output .= "</fieldset>"; return $output; } // Load the text helper so we can highlight the SQL $this->CI->load->helper('text'); // Key words we want bolded $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR ', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')'); $output = "\n\n"; foreach ($dbs as $module => $db) { $module = is_string($module) ? 'MODULE: ' . $module . ' ' : ''; $output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; $output .= "\n"; $output .= '<legend style="color:#0000FF;"> ' . $module . $this->CI->lang->line('profiler_database') . ': ' . $db->database . ' ' . $this->CI->lang->line('profiler_queries') . ': ' . count($db->queries) . ' </legend>'; $output .= "\n"; $output .= "\n\n<table style='width:100%;'>\n"; if (count($db->queries) == 0) { $output .= "<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px;'>" . $this->CI->lang->line('profiler_no_queries') . "</td></tr>\n"; } else { foreach ($db->queries as $key => $val) { $time = number_format($db->query_times[$key], 4); $val = highlight_code($val, ENT_QUOTES); foreach ($highlight as $bold) { $val = str_replace($bold, '<strong>' . $bold . '</strong>', $val); } $output .= "<tr><td style='padding:5px; vertical-align: top;width:1%;color:#900;font-weight:normal;background-color:#ddd;'>" . $time . " </td><td style='padding:5px; color:#000;font-weight:normal;background-color:#ddd;'>" . $val . "</td></tr>\n"; } } $output .= "</table>\n"; $output .= "</fieldset>"; } return $output; }
/** * Compile Queries * * @return string */ protected function _compile_queries() { $dbs = array(); $output = array(); // Let's determine which databases are currently connected to foreach (get_object_vars($this->CI) as $CI_object) { if (is_object($CI_object) && is_subclass_of(get_class($CI_object), 'CI_DB')) { $dbs[] = $CI_object; } } if (count($dbs) == 0) { return $this->CI->lang->line('profiler_no_db'); } // Load the text helper so we can highlight the SQL $this->CI->load->helper('text'); foreach ($dbs as $db) { if (count($db->queries) == 0) { $output = $this->CI->lang->line('profiler_no_queries'); } else { foreach ($db->queries as $key => $val) { $time = number_format($db->query_times[$key], 4); $val = highlight_code($val, ENT_QUOTES); $output[] = array($time, $val); } } } return $output; }
public function setup_queries() { $dbs = array(); // Let's determine which databases are currently connected to foreach (get_object_vars($this->EE) as $EE_object) { if (is_object($EE_object) && is_subclass_of(get_class($EE_object), 'CI_DB')) { $dbs[] = $EE_object; } } $output = array(); if (count($dbs) == 0) { return $output; } // Load the text helper so we can highlight the SQL $this->EE->load->helper('text'); // Key words we want bolded $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR ', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')'); $count = 0; $total_time = 0; foreach ($dbs as $db) { //exit; $count++; //$output .= "\n\n<table style='width:100%;{$hide_queries}' id='ci_profiler_queries_db_{$count}'>\n"; if (count($db->queries) != 0) { foreach ($db->queries as $key => $val) { $total_time = $total_time + $db->query_times[$key]; $time = number_format($db->query_times[$key], 4); $output['queries'][] = array('query' => highlight_code($val, ENT_QUOTES), 'time' => $time); } } } $output['total_time'] = number_format($total_time, 4); return $output; }
show_error('Файлов еще нет!'); } echo '<br /><img src="../images/img/files.gif" alt="image" /> <a href="files.php?action=new&' . SID . '">Создать</a><br />'; echo '<img src="../images/img/faq.gif" alt="image" /> <a href="files.php?action=faq&' . SID . '">Помощь</a>'; } ############################################################################################ ## Обзор файла ## ############################################################################################ if ($action == "obzor") { if (preg_match('|^[a-z0-9_\\.\\-]+$|i', $file)) { if (file_exists(DATADIR . "datamain/{$file}")) { echo '<b>Просмотр файла ' . $file . '</b><br />'; $opis = file_get_contents(DATADIR . "datamain/{$file}"); $count = count($opis); echo 'Строчек: ' . (int) $count . '<br /><br />'; echo highlight_code(check($opis)) . '<br />'; echo '<br /><img src="../images/img/edit.gif" alt="image" /> <a href="files.php?action=edit&file=' . $file . '&' . SID . '">Редактировать</a><br />'; echo '<img src="../images/img/error.gif" alt="image" /> <a href="files.php?action=poddel&file=' . $file . '&' . SID . '">Удалить</a>'; } else { show_error('Ошибка! Данного файла не существует!'); } } else { show_error('Ошибка! Недопустимое название страницы!'); } echo '<br /><img src="../images/img/back.gif" alt="image" /> <a href="files.php?' . SID . '">Вернуться</a>'; } ############################################################################################ ## Подготовка к редактированию ## ############################################################################################ if ($action == "edit") { if (preg_match('|^[a-z0-9_\\.\\-]+$|i', $file)) {
protected function _compile_config() { $output = "\n\n"; $output .= "\n"; $output .= '<h4>' . $this->CI->lang->line('profiler_config') . '</h4>'; $output .= "\n"; $output .= "\n\n<div class=\"grid-container table-bordered\"><table id='ci_profiler_config_table' class=\"grid table table-hover table-striped table-condensed\">\n"; foreach ($this->CI->config->config as $config => $val) { if (is_array($val)) { $val = print_r($val, TRUE); } $output .= "<tr><td>" . $config . "</td><td>" . highlight_code($val) . "</td></tr>\n"; } $output .= "</table></div>\n"; return $output; }
/** * Syntax highlight the SQL * * @param string $sql the query and location * @return string syntax highlighted query **/ private function highlightSql($sql) { // Load the text helper so we can highlight the SQL ee()->load->helper('text'); $highlighted = highlight_code($sql, ENT_QUOTES, 'UTF-8'); foreach ($this->keywords as $keyword) { $highlighted = str_replace($keyword, '<b>' . $keyword . '</b>', $highlighted); } // get rid of non-breaking spaces $highlighted = str_replace(' ', ' ', $highlighted); return $highlighted; }
function _compile_queries() { $dbs = array(); // Let's determine which databases are currently connected to foreach (get_object_vars($this->CI) as $CI_object) { if (is_object($CI_object) && is_subclass_of(get_class($CI_object), 'CI_DB')) { $dbs[] = $CI_object; } } if (count($dbs) == 0) { $output = "<h2>" . $this->CI->lang->line('profiler_queries') . "<h2>"; return $output; } // Load the text helper so we can highlight the SQL $this->CI->load->helper('text'); // Key words we want bolded $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')'); foreach ($dbs as $db) { $output = "<h4>Database: " . $db->database . " QUERIES: " . count($this->CI->db->queries) . "</h4>"; if (count($db->queries) == 0) { $output .= "<p>No queries were run</p>"; } else { $output = "<table>\n\t\t\t\t\t<colgroup>\n\t\t\t\t\t\t<col style='width:20%'/>\n\t\t\t\t\t\t<col/>\n\t\t\t\t\t</colgroup>\n\t\t\t\t\t<thead>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<th>Time</th>\n\t\t\t\t\t\t<th>Query</th>\n\t\t\t\t\t</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>"; $tr_class = "djDebugOdd"; foreach ($db->queries as $key => $val) { $time = number_format($db->query_times[$key], 4); $val = highlight_code($val, ENT_QUOTES); foreach ($highlight as $bold) { $val = str_replace($bold, '<strong>' . $bold . '</strong>', $val); } $output .= "<tr class='{$tr_class}'><td>" . $time . "</td><td>" . $val . "</td></tr>"; if ($tr_class == "djDebugOdd") { $tr_class = "djDebugEven"; } elseif ($tr_class == "djDebugEven") { $tr_class = "djDebugOdd"; } } } $output .= "</tbody></table>"; } return $output; }
public function text_helper() { $this->load->helper('text'); $string = "Here is a nice text string consisting of eleven words."; $string = word_limiter($string, 4, "..."); $this->htmlp($string); $string = "Here is a nice text string consisting of eleven words."; $string = character_limiter($string, 20, "..."); $this->htmlp($string); $string = ascii_to_entities($string); $this->htmlp($string); $string = convert_accented_characters($string); $this->htmlp($string); $string = "darn shit sucks dinner"; $disallowed = array('darn', 'shucks', 'golly', 'phooey'); $string = word_censor($string, $disallowed, 'Beep!'); $this->htmlp($string); $string = highlight_code($string); $this->htmlp($string); $string = "Here is a nice text string about nothing in particular."; $this->htmlp(highlight_phrase($string, "nice text", '<span style="color:#990000;">', '</span>')); $string = "Here is a simple string of text that will help us demonstrate this function."; $this->htmlp(word_wrap($string, 25)); $str = 'this_string_is_entirely_too_long_and_might_break_my_design.jpg'; $this->htmlp(ellipsize($str, 32, 0.5)); }
function highlight_js($code, $width = 550, $xtrastyle = "") { require_once "inc/template.inc.php"; return str_replace("<pre ", "<pre style=\"width:" . $width . "px;" . $xtrastyle . "\" ", highlight_code(str_replace("<br />", "\n", htmlspecialchars_decode($code)), $width . "px", "Javascript", false, false)); }
/** * Compile Queries * * @return string */ protected function _compile_queries() { $dbs = array(); $output = array(); // Let's determine which databases are currently connected to foreach (get_object_vars($this->CI) as $CI_object) { if (is_object($CI_object) && is_subclass_of(get_class($CI_object), 'CI_DB')) { $dbs[] = $CI_object; } } if (count($dbs) == 0) { return $this->CI->lang->line('profiler_no_db'); } // Load the text helper so we can highlight the SQL $this->CI->load->helper('text'); // Key words we want bolded // $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR ', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')'); foreach ($dbs as $db) { if (count($db->queries) == 0) { $output = $this->CI->lang->line('profiler_no_queries'); } else { foreach ($db->queries as $key => $val) { $time = number_format($db->query_times[$key], 4); $val = highlight_code($val, ENT_QUOTES); /* foreach ($highlight as $bold) { $val = str_replace($bold, '<strong>'.$bold.'</strong>', $val); } */ $output[] = array($time, $val); } } } return $output; }
/** * Wrapper to setup the Database panel SQL queries * @return multitype:|multitype:string */ public function setup_queries() { $dbs = array(); // Let's determine which databases are currently connected to foreach (get_object_vars($this->EE) as $EE_object) { if (is_object($EE_object) && is_subclass_of(get_class($EE_object), 'CI_DB')) { $dbs[] = $EE_object; } } $output = array(); if (count($dbs) == 0) { return $output; } // Load the text helper so we can highlight the SQL $this->EE->load->helper('text'); $count = 0; $total_time = 0; foreach ($dbs as $db) { $count++; if (count($db->queries) != 0) { foreach ($db->queries as $key => $val) { $total_time = $total_time + $db->query_times[$key]; $time = number_format($db->query_times[$key], 4); $output['queries'][] = array('query' => highlight_code($val, ENT_QUOTES), 'time' => $time); } } } $output['total_time'] = number_format($total_time, 4); return $output; }
function compile_queries() { $dbs = array(); // Let's determine which databases are currently connected to if (isset(CI::$APP->dbLoaded)) { $DBBaseObject = CI::$APP->dbLoaded; } else { $DBBaseObject = CI::$APP; } foreach ($DBBaseObject as $key => $CI_object) { if (is_object($CI_object) && is_subclass_of(get_class($CI_object), 'CI_DB')) { $dbs[$key] = $CI_object; } } // Other external databases, as MongoDB $ODBBaseProfiles = array(); if (isset(CI::$APP->odbLoaded)) { $ODBBaseProfiles = CI::$APP->odbLoaded; } foreach ($ODBBaseProfiles as $key => $DBobject) { $dbs[$key] = $DBobject; } if (count($dbs) == 0) { $output = "\n\n"; $output .= '<fieldset id="ci_profiler_queries" style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; $output .= "\n"; $output .= '<legend style="color:#0000FF;"> ' . $this->CI->lang->line('profiler_queries') . ' </legend>'; $output .= "\n\n<table style='border:none; width:100%;'>\n"; $output .= "<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px'>" . $this->CI->lang->line('profiler_no_db') . "</td></tr>\n"; $output .= "</table>\n"; $output .= "</fieldset>"; return $output; } // Load the text helper so we can highlight the SQL $this->CI->load->helper('text'); // Key words we want bolded $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR ', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')'); $output = "\n\n"; $count = 0; foreach ($dbs as $dbgroup => $db) { $count++; $hide_queries = false; //(count($db->queries) > $this->_query_toggle_count) ? ' display:none' : ''; $output .= '<fieldset style="display: inline-block;border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; $output .= "\n"; $output .= '<legend style="color:#0000FF;"> ' . $this->CI->lang->line('profiler_database') . ': ' . $dbgroup . ' (' . $db->dbdriver . ') ' . $this->CI->lang->line('profiler_queries') . ': ' . count($db->queries) . ' ' . '</legend>'; $output .= "\n"; $output .= "\n\n<table style='width:100%;{$hide_queries}' id='ci_profiler_queries_db_{$count}'>\n"; if (count($db->queries) == 0) { $output .= "<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px;'>" . $this->CI->lang->line('profiler_no_queries') . "</td></tr>\n"; } else { foreach ($db->queries as $key => $val) { $time = number_format($db->query_times[$key], 6); $val = highlight_code($val, ENT_QUOTES); foreach ($highlight as $bold) { $val = str_replace($bold, '<strong>' . $bold . '</strong>', $val); } $output .= "<tr><td style='padding:5px; vertical-align: top;width:1%;color:#900;font-weight:normal;background-color:#ddd;'>" . $time . " </td><td style='padding:5px; color:#000;font-weight:normal;background-color:#ddd;'>" . $val . "</td></tr>\n"; } } $output .= "</table>\n"; $output .= "</fieldset>"; } return $output; }