fixed a PHP3 bug and coding standards

This commit is contained in:
Loïc Chapeaux
2002-05-25 08:53:55 +00:00
parent b630e21d67
commit 28a72c8e1a

View File

@@ -927,21 +927,23 @@ if (typeof(document.getElementById) != 'undefined'
<td bgcolor="<?php echo $GLOBALS['cfg']['BgcolorOne']; ?>"> <td bgcolor="<?php echo $GLOBALS['cfg']['BgcolorOne']; ?>">
<?php <?php
echo "\n"; echo "\n";
// Html format the query to be displayed
// The nl2br function isn't used because its result isn't a valid // The nl2br function isn't used because its result isn't a valid
// xhtml1.0 statement before php4.0.5 ("<br>" and not "<br />") // xhtml1.0 statement before php4.0.5 ("<br>" and not "<br />")
// if we want to show some sql code it is easiest to create it here // If we want to show some sql code it is easiest to create it here
$sqlnr = 1; $sqlnr = 1;
if(isset($GLOBALS['showasphp'])){$showasphp = &$GLOBALS['showasphp'];} if (!empty($GLOBALS['show_as_php'])) {
if(isset($showasphp) and ($showasphp=='true')){ $new_line = '&quot;;<br />' . "\n" . ' $sql .= &quot;';
$new_line = '&quot;;<br />' . "\n" . ' $sql .= &quot;'; } else {
}else{ $new_line = '<br />' . "\n" . ' ';
$new_line = '<br />' . "\n" . ' ';
} }
$query_base = htmlspecialchars($GLOBALS['sql_query']); $query_base = htmlspecialchars($GLOBALS['sql_query']);
$query_base = ereg_replace("((\015\012)|(\015)|(\012))+", $new_line, $query_base); $query_base = ereg_replace("((\015\012)|(\015)|(\012))+", $new_line, $query_base);
if(isset($showasphp) and ($showasphp=='true')){ if (!empty($GLOBALS['show_as_php'])) {
$query_base = '$sql = &quot;'.$query_base; $query_base = '$sql = &quot;' . $query_base;
} }
// Prepares links that may be displayed to edit/explain the query
if (!isset($GLOBALS['show_query']) || $GLOBALS['show_query'] != 'y') { if (!isset($GLOBALS['show_query']) || $GLOBALS['show_query'] != 'y') {
if (!isset($GLOBALS['goto'])) { if (!isset($GLOBALS['goto'])) {
$edit_target = (isset($GLOBALS['table'])) ? 'tbl_properties.php3' : 'db_details.php3'; $edit_target = (isset($GLOBALS['table'])) ? 'tbl_properties.php3' : 'db_details.php3';
@@ -951,29 +953,32 @@ if (typeof(document.getElementById) != 'undefined'
$edit_target = ''; $edit_target = '';
} }
if ($edit_target == 'tbl_properties.php3') { if ($edit_target == 'tbl_properties.php3') {
$edit_link = '<a href="tbl_properties.php3?lang=' . $GLOBALS['lang'] . '&amp;server=' . urlencode($GLOBALS['server']) . '&amp;db=' . urlencode($GLOBALS['db']) . '&amp;table=' . urlencode($GLOBALS['table']) . '&amp;sql_query=' . urlencode($GLOBALS['sql_query']) . '&amp;show_query=y#querybox">' . $GLOBALS['strEdit'] . '</a>'; $edit_link = '<a href="tbl_properties.php3?lang=' . $GLOBALS['lang'] . '&amp;server=' . $GLOBALS['server'] . '&amp;db=' . urlencode($GLOBALS['db']) . '&amp;table=' . urlencode($GLOBALS['table']) . '&amp;sql_query=' . urlencode($GLOBALS['sql_query']) . '&amp;show_query=y#querybox">' . $GLOBALS['strEdit'] . '</a>';
} else if ($edit_target != '') { } else if ($edit_target != '') {
$edit_link = '<a href="db_details.php3?lang=' . $GLOBALS['lang'] . '&amp;server=' . urlencode($GLOBALS['server']) . '&amp;db=' . urlencode($GLOBALS['db']) . '&amp;sql_query=' . urlencode($GLOBALS['sql_query']) . '&amp;show_query=y#querybox">' . $GLOBALS['strEdit'] . '</a>'; $edit_link = '<a href="db_details.php3?lang=' . $GLOBALS['lang'] . '&amp;server=' . $GLOBALS['server'] . '&amp;db=' . urlencode($GLOBALS['db']) . '&amp;sql_query=' . urlencode($GLOBALS['sql_query']) . '&amp;show_query=y#querybox">' . $GLOBALS['strEdit'] . '</a>';
} }
// want to have the query explained (Mike Beck 2002-05-22) // Want to have the query explained (Mike Beck 2002-05-22)
// but do not explain an explain (lem9) // but do not explain an explain (lem9)
// if (!eregi('^EXPLAIN[[:space:]]+', $GLOBALS['sql_query'])) {
if (!ereg('EXPLAIN',$GLOBALS['sql_query'])) {; $explain_link = '[<a href="sql.php3?lang=' . $GLOBALS['lang'] . '&amp;server=' . $GLOBALS['server'] . '&amp;db=' . urlencode($GLOBALS['db']) . '&amp;table=' . urlencode($GLOBALS['table']) . '&amp;sql_query=' . urlencode('EXPLAIN '.$GLOBALS['sql_query']) . '">' . $GLOBALS['strExplain'] . '</a>]&nbsp;';
$explain_link='[<a href="sql.php3?lang=' . $GLOBALS['lang'] . '&amp;server=' . urlencode($GLOBALS['server']) . '&amp;db=' . urlencode($GLOBALS['db']) . '&amp;table=' . urlencode($GLOBALS['table']) . '&amp;sql_query=' . urlencode('EXPLAIN '.$GLOBALS['sql_query']) . '">' . $GLOBALS['strExplain'] . '</a>]&nbsp;';
} else { } else {
$explain_link=''; $explain_link = '';
} }
// Also i would like to get the SQL formed in some nice php-code (Mike Beck 2002-05-22) // Also we would like to get the SQL formed in some nice
if(isset($showasphp) and ($showasphp=='true')){ // php-code (Mike Beck 2002-05-22)
$php_link ='<a href="sql.php3?lang=' . $GLOBALS['lang'] . '&amp;server=' . urlencode($GLOBALS['server']) . '&amp;db=' . urlencode($GLOBALS['db']) . '&amp;table=' . urlencode($GLOBALS['table']) . '&amp;sql_query=' . urlencode($GLOBALS['sql_query']) . '&amp;showasphp=false">' . $GLOBALS['strNoPhp'] . '</a>'; if (!empty($GLOBALS['show_as_php'])) {
}else{ $php_link = '<a href="sql.php3?lang=' . $GLOBALS['lang'] . '&amp;server=' . $GLOBALS['server'] . '&amp;db=' . urlencode($GLOBALS['db']) . '&amp;table=' . urlencode($GLOBALS['table']) . '&amp;sql_query=' . urlencode($GLOBALS['sql_query']) . '&amp;show_as_php=0">' . $GLOBALS['strNoPhp'] . '</a>';
$php_link ='<a href="sql.php3?lang=' . $GLOBALS['lang'] . '&amp;server=' . urlencode($GLOBALS['server']) . '&amp;db=' . urlencode($GLOBALS['db']) . '&amp;table=' . urlencode($GLOBALS['table']) . '&amp;sql_query=' . urlencode($GLOBALS['sql_query']) . '&amp;showasphp=true">' . $GLOBALS['strPhp'] . '</a>'; } else {
$php_link = '<a href="sql.php3?lang=' . $GLOBALS['lang'] . '&amp;server=' . $GLOBALS['server'] . '&amp;db=' . urlencode($GLOBALS['db']) . '&amp;table=' . urlencode($GLOBALS['table']) . '&amp;sql_query=' . urlencode($GLOBALS['sql_query']) . '&amp;show_as_php=1">' . $GLOBALS['strPhp'] . '</a>';
} }
} }
// Displays the message
echo ' ' . $GLOBALS['strSQLQuery'] . '&nbsp;:';
if (!empty($edit_target)) { if (!empty($edit_target)) {
echo ' ' . $GLOBALS['strSQLQuery'] . '&nbsp;:&nbsp;[' . $edit_link . ']&nbsp;' . $explain_link . '[' . $php_link . ']<br />' . "\n"; echo '&nbsp;[' . $edit_link . ']&nbsp;' . $explain_link . '[' . $php_link . ']<br />' . "\n";
} else { } else {
echo ' ' . $GLOBALS['strSQLQuery'] . '&nbsp;:<br />' . "\n"; echo '<br />' . "\n";
} }
echo ' ' . $query_base; echo ' ' . $query_base;
// If a 'LIMIT' clause has been programatically added to the query // If a 'LIMIT' clause has been programatically added to the query
@@ -981,9 +986,9 @@ if (typeof(document.getElementById) != 'undefined'
if (!empty($GLOBALS['sql_limit_to_append'])) { if (!empty($GLOBALS['sql_limit_to_append'])) {
echo $GLOBALS['sql_limit_to_append']; echo $GLOBALS['sql_limit_to_append'];
} }
if (!empty($GLOBALS['show_as_php'])) {
echo '&quot;;';
} }
if(isset($showasphp) and ($showasphp=='true')){
echo '&quot;;';
echo "\n"; echo "\n";
?> ?>
</td> </td>