Skip to content

Commit

Permalink
Merge pull request phpmyadmin#205 from lem9/bug_3820_attempt_2
Browse files Browse the repository at this point in the history
Fix for bug 3820 attempt 2
  • Loading branch information
lem9 committed Mar 8, 2013
2 parents 71a21ff + 2991073 commit 641b8ea
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions libraries/navigation/Nodes/Node.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,10 @@ public function getPaths()
*/
public function getData($type, $pos, $searchClause = '')
{
// @todo obey the DisableIS directive
$query = "SELECT `SCHEMA_NAME` ";
$query .= "FROM `INFORMATION_SCHEMA`.`SCHEMATA` ";
if (! empty($searchClause)) {
$query .= "WHERE `SCHEMA_NAME` LIKE '%";
$query .= PMA_Util::sqlAddSlashes(
$searchClause, true
);
$query .= "%' ";
}
$query .= $this->_getWhereClause($searchClause);
$query .= "ORDER BY `SCHEMA_NAME` ASC ";
$query .= "LIMIT $pos, {$GLOBALS['cfg']['MaxNavigationItems']}";
return PMA_DBI_fetch_result($query);
Expand Down Expand Up @@ -399,13 +394,7 @@ public function getPresence($type = '', $searchClause = '')
if (! $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) {
$query = "SELECT COUNT(*) ";
$query .= "FROM `INFORMATION_SCHEMA`.`SCHEMATA` ";
if (! empty($searchClause)) {
$query .= "WHERE `SCHEMA_NAME` LIKE '%";
$query .= PMA_Util::sqlAddSlashes(
$searchClause, true
);
$query .= "%' ";
}
$query .= $this->_getWhereClause($searchClause);
$retval = (int)PMA_DBI_fetch_value($query);
} else {
$query = "SHOW DATABASES ";
Expand All @@ -420,5 +409,32 @@ public function getPresence($type = '', $searchClause = '')
}
return $retval;
}

/**
* Returns the WHERE clause depending on the $searchClause parameter
* and the hide_db directive
*
* @param string $searchClause A string used to filter the results of the query
*
* @return string
*/
private function _getWhereClause($searchClause = '')
{
$whereClause = "WHERE TRUE ";
if (! empty($searchClause)) {
$whereClause .= "AND `SCHEMA_NAME` LIKE '%";
$whereClause .= PMA_Util::sqlAddSlashes(
$searchClause, true
);
$whereClause .= "%' ";
}

if (! empty($GLOBALS['cfg']['Server']['hide_db'])) {
$whereClause .= "AND `SCHEMA_NAME` NOT REGEXP '"
. $GLOBALS['cfg']['Server']['hide_db'] . "' ";
}
return $whereClause;
}

}
?>

0 comments on commit 641b8ea

Please sign in to comment.