more bugfixes for syntaxcoloring
This commit is contained in:
@@ -214,11 +214,13 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
|||||||
// first of all lets remove all newlines - we'll add our own later
|
// first of all lets remove all newlines - we'll add our own later
|
||||||
$sql = str_replace("\n", ' ', $sql);
|
$sql = str_replace("\n", ' ', $sql);
|
||||||
// there should always be blanks around = and after , ()
|
// there should always be blanks around = and after , ()
|
||||||
|
// fixme - i would like to replace ';' with '; ' but then i need
|
||||||
|
// to know how to do that without getting ; within strings as well
|
||||||
$sql = str_replace('=', ' = ', $sql);
|
$sql = str_replace('=', ' = ', $sql);
|
||||||
$sql = str_replace(',', ', ', $sql);
|
$sql = str_replace(',', ', ', $sql);
|
||||||
$sql = str_replace(')', ' ) ', $sql);
|
$sql = str_replace(')', ' ) ', $sql);
|
||||||
$sql = str_replace('(', ' ( ', $sql);
|
$sql = str_replace('(', ' ( ', $sql);
|
||||||
$sql = str_replace(';', ' ; ', $sql);
|
|
||||||
// now split everything by the blanks
|
// now split everything by the blanks
|
||||||
$_sql_parts=explode(' ',$sql);
|
$_sql_parts=explode(' ',$sql);
|
||||||
// start a loop over the parts check each word and put them back into $sql
|
// start a loop over the parts check each word and put them back into $sql
|
||||||
@@ -230,37 +232,39 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
|||||||
// which might lead to empty members in the array
|
// which might lead to empty members in the array
|
||||||
if(strlen($_word)==0){continue;}
|
if(strlen($_word)==0){continue;}
|
||||||
$_is_string = FALSE;
|
$_is_string = FALSE;
|
||||||
|
// debug echo "pr<70>fe: $_word ";
|
||||||
// Anything inside quots might be more than one word
|
// Anything inside quots might be more than one word
|
||||||
// so as we splitted by the blanks we have to try to get those parts back
|
// so as we splitted by the blanks we have to try to get those parts back
|
||||||
// together
|
// together
|
||||||
if (
|
if (substr($_word, 0, 1) == '\'' || substr($_word, 0, 1 == '"')
|
||||||
(substr($_word, 0, 1) == '\'' || substr($_word, 0, 1) == '"') &&
|
&& (!isset($_temp))) {
|
||||||
(!isset($_temp) || strlen($_temp)==0)
|
// start of a string
|
||||||
) {
|
$_temp = $_word;
|
||||||
// start of a string
|
$_is_string = TRUE;
|
||||||
$_temp = $_word;
|
// debug echo "starte " . $_temp . '<br />';
|
||||||
$_is_string = TRUE;
|
}else {
|
||||||
} else {
|
if(isset($_temp)) {
|
||||||
if(isset($_temp) && strlen($_temp)>0){
|
|
||||||
// we are continuing a string
|
// we are continuing a string
|
||||||
$_temp .= $_word;
|
$_temp .= $_word;
|
||||||
$_is_string = TRUE;
|
$_is_string = TRUE;
|
||||||
}
|
// debug echo "weiter " . $_temp . '<br />';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(substr($_word, strlen($_word)-1, 1) == '\''
|
if(substr($_word, strlen($_word)-1, 1) == '\''
|
||||||
|| substr($_word, strlen($_word)-1, 1) == '"') {
|
|| substr($_word, strlen($_word)-1, 1) == '"') {
|
||||||
// End of a String
|
// End of a String
|
||||||
$_word = '<font color="' . $cfg['colorStrings'] . '">' . $_temp . '</font>';
|
$_word = '<font color="' . $cfg['colorStrings'] . '">' . htmlspecialchars($_temp) . '</font>';
|
||||||
$_temp = '';
|
unset($_temp);
|
||||||
|
// debug echo "fertig " . $_word . '<br />';
|
||||||
$_is_string = FALSE;
|
$_is_string = FALSE;
|
||||||
}
|
}
|
||||||
if(!isset($_is_string) || $_is_string == FALSE) {
|
if(!isset($_is_string) || $_is_string == FALSE) {
|
||||||
// no String
|
// no String
|
||||||
if(eregi($_sfuncs, $_word)) {
|
if(eregi($_sfuncs, $_word)) {
|
||||||
$_word = '<font color="' . $cfg['colorFunctions'].'">' . $_word . '</font>';
|
$_word = '<font color="' . $cfg['colorFunctions'].'">' . htmlspecialchars($_word) . '</font>';
|
||||||
} else {
|
} else {
|
||||||
if(eregi($_skeyw, $_word)) {
|
if(eregi($_skeyw, $_word)) {
|
||||||
$_word = '<font color="' . $cfg['colorKeywords'].'">' . $_word . '</font>';
|
$_word = '<font color="' . $cfg['colorKeywords'].'">' . htmlspecialchars($_word) . '</font>';
|
||||||
if(isset($mult) && $mult == TRUE){
|
if(isset($mult) && $mult == TRUE){
|
||||||
} else {
|
} else {
|
||||||
$_word = "\n" . $_word;
|
$_word = "\n" . $_word;
|
||||||
@@ -268,10 +272,10 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
if(eregi($_scoltype, $_word)) {
|
if(eregi($_scoltype, $_word)) {
|
||||||
$_word = '<font color="' . $cfg['colorColType'].'">' . $_word . '</font>';
|
$_word = '<font color="' . $cfg['colorColType'].'">' . htmlspecialchars($_word) . '</font>';
|
||||||
} else {
|
} else {
|
||||||
if(eregi($_add, $_word)) {
|
if(eregi($_add, $_word)) {
|
||||||
$_word = '<font color="' . $cfg['colorAdd'].'">' . $_word . '</font>';
|
$_word = '<font color="' . $cfg['colorAdd'].'">' . htmlspecialchars($_word) . '</font>';
|
||||||
} else {
|
} else {
|
||||||
if($_word=='(') {
|
if($_word=='(') {
|
||||||
$_brack_o[]=$s_nr;
|
$_brack_o[]=$s_nr;
|
||||||
@@ -298,6 +302,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
|
|||||||
$_sql_p[$s_nr] = $_word;
|
$_sql_p[$s_nr] = $_word;
|
||||||
$s_nr++;
|
$s_nr++;
|
||||||
}
|
}
|
||||||
|
// debug echo "<br />";
|
||||||
} // End while
|
} // End while
|
||||||
if(isset($_brack_o)) {
|
if(isset($_brack_o)) {
|
||||||
while (list($_num,$elem) = each($_brack_o)) {
|
while (list($_num,$elem) = each($_brack_o)) {
|
||||||
@@ -1107,10 +1112,16 @@ if (typeof(document.getElementById) != 'undefined'
|
|||||||
if (!empty($GLOBALS['show_as_php'])) {
|
if (!empty($GLOBALS['show_as_php'])) {
|
||||||
$new_line = '";<br />' . "\n" . ' $sql .= "';
|
$new_line = '";<br />' . "\n" . ' $sql .= "';
|
||||||
}else{
|
}else{
|
||||||
$new_line = "<br />\n";
|
if($cfg['UseSyntaxColoring'] == FALSE){
|
||||||
|
$new_line = "<br />\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isset($new_line)){
|
||||||
|
$query_base = htmlspecialchars($GLOBALS['sql_query']);
|
||||||
|
$query_base = ereg_replace("((\015\012)|(\015)|(\012))+", $new_line, $query_base);
|
||||||
|
}else{
|
||||||
|
$query_base = $GLOBALS['sql_query'];
|
||||||
}
|
}
|
||||||
$query_base = htmlspecialchars($GLOBALS['sql_query']);
|
|
||||||
$query_base = ereg_replace("((\015\012)|(\015)|(\012))+", $new_line, $query_base);
|
|
||||||
if (!empty($GLOBALS['show_as_php'])) {
|
if (!empty($GLOBALS['show_as_php'])) {
|
||||||
$query_base = '$sql = "' . $query_base;
|
$query_base = '$sql = "' . $query_base;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user