- fixed bug #1469469 cyclic redirect with sql.php as default table-page

- re-use already existing code
This commit is contained in:
Sebastian Mendel
2006-04-13 10:39:58 +00:00
parent 594d330ae0
commit f020ab03b0
2 changed files with 30 additions and 35 deletions

View File

@@ -6,6 +6,9 @@ $Id$
$Source$ $Source$
2006-04-12 Sebastian Mendel <cybot_tm@users.sourceforge.net> 2006-04-12 Sebastian Mendel <cybot_tm@users.sourceforge.net>
* sql.php:
- fixed bug #1469469 cyclic redirect with sql.php as default table-page
- re-use already existing code
* changelog.php: * changelog.php:
link also js, html, pl, and sh files, FAQ entries link also js, html, pl, and sh files, FAQ entries
and contributors to their sf.net user page, smaller regex fixes and contributors to their sf.net user page, smaller regex fixes

62
sql.php
View File

@@ -1,6 +1,10 @@
<?php <?php
/* $Id$ */ /* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4: // vim: expandtab sw=4 ts=4 sts=4:
/**
* @todo we must handle the case if sql.php is called directly with a query
* what returns 0 rows - to prevent cyclic redirects or includes
*/
/** /**
* Gets some core libraries * Gets some core libraries
@@ -12,7 +16,7 @@ require_once './libraries/check_user_privileges.lib.php';
require_once './libraries/bookmark.lib.php'; require_once './libraries/bookmark.lib.php';
/** /**
* Could be coming from a subform ("T" column expander) * Could be coming from a subform ("T" column expander)
*/ */
if (isset($_REQUEST['dontlimitchars'])) { if (isset($_REQUEST['dontlimitchars'])) {
$dontlimitchars = $_REQUEST['dontlimitchars']; $dontlimitchars = $_REQUEST['dontlimitchars'];
@@ -51,16 +55,23 @@ if (isset($fields['dbase'])) {
$db = $fields['dbase']; $db = $fields['dbase'];
} }
// Default to browse if no query set an we have table (needed for browsing from DefaultTabTable) // Default to browse if no query set an we have table
if (!isset($sql_query) && isset($table) && isset($db)) { // (needed for browsing from DefaultTabTable)
if (! isset($sql_query) && isset($table) && isset($db)) {
require_once './libraries/bookmark.lib.php'; require_once './libraries/bookmark.lib.php';
$book_sql_query = PMA_queryBookmarks($db, $GLOBALS['cfg']['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label'); $book_sql_query = PMA_queryBookmarks($db,
if (!empty($book_sql_query)) { $GLOBALS['cfg']['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'',
'label');
if (! empty($book_sql_query)) {
$sql_query = $book_sql_query; $sql_query = $book_sql_query;
} else { } else {
$sql_query = 'SELECT * FROM ' . PMA_backquote($table); $sql_query = 'SELECT * FROM ' . PMA_backquote($table);
} }
unset($book_sql_query); unset($book_sql_query);
// set $goto to what will be displayed if query returns 0 rows
$goto = 'tbl_properties_structure.php';
} else { } else {
// Now we can check the parameters // Now we can check the parameters
PMA_checkParameters(array('sql_query')); PMA_checkParameters(array('sql_query'));
@@ -641,42 +652,23 @@ else {
if ($is_gotofile) { if ($is_gotofile) {
$goto = PMA_securePath($goto); $goto = PMA_securePath($goto);
// Checks for a valid target script // Checks for a valid target script
if (isset($table) && $table == '') {
unset($table);
}
if (isset($db) && $db == '') {
unset($db);
}
$is_db = $is_table = false; $is_db = $is_table = false;
if (strpos(' ' . $goto, 'tbl_properties') == 1) { include 'libraries/db_table_exists.lib.php';
if (!isset($table)) { if (strpos($goto, 'tbl_properties') === 0 && ! $is_table) {
$goto = 'db_details.php';
} else {
$is_table = @PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, true) . '\';', null, PMA_DBI_QUERY_STORE);
if (!($is_table && @PMA_DBI_num_rows($is_table))) {
$goto = 'db_details.php';
unset($table);
}
@PMA_DBI_free_result($is_table);
} // end if... else...
}
if (strpos(' ' . $goto, 'db_details') == 1) {
if (isset($table)) { if (isset($table)) {
unset($table); unset($table);
} }
if (!isset($db)) { $goto = 'db_details.php';
$goto = 'main.php'; }
} else { if (strpos($goto, 'db_details') === 0 && ! $is_db) {
$is_db = @PMA_DBI_select_db($db); if (isset($db)) {
if (!$is_db) { unset($db);
$goto = 'main.php'; }
unset($db); $goto = 'main.php';
}
} // end if... else...
} }
// Loads to target script // Loads to target script
if (strpos(' ' . $goto, 'db_details') == 1 if (strpos($goto, 'db_details') === 0
|| strpos(' ' . $goto, 'tbl_properties') == 1) { || strpos($goto, 'tbl_properties') === 0) {
$js_to_run = 'functions.js'; $js_to_run = 'functions.js';
} }
if ($goto != 'main.php') { if ($goto != 'main.php') {