本文整理汇总了PHP中highlight_code函数的典型用法代码示例。如果您正苦于以下问题:PHP highlight_code函数的具体用法?PHP highlight_code怎么用?PHP highlight_code使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了highlight_code函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getsource
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;
}
示例2: highlight
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++;
}
}
示例3: _compile_queries
/**
* 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;
}
示例4: _compile_queries
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;
}
示例5: highlight_code_file
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;
}
示例6: _compile_queries
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;
}
示例7: foreach
$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) {
示例8: _compile_queries
/**
* 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;
}
示例9: test_highlight_code
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); ?>'));
}
示例10: _compile_queries
/**
* 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;
}
示例11: _compile_queries
/**
* 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;
}
示例12: setup_queries
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;
}
示例13: show_error
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)) {
示例14: _compile_config
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;
}
示例15: highlightSql
/**
* 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;
}