Ejemplo n.º 1
0
 /**
  * Test for PMA_selectServer
  *
  * @return void
  */
 public function testPMASelectServer()
 {
     $not_only_options = false;
     $omit_fieldset = false;
     $GLOBALS['cfg']['DefaultTabServer'] = "welcome";
     $GLOBALS['cfg']['Servers'] = array('0' => array('host' => 'host0', 'port' => 'port0', 'only_db' => 'only_db0', 'user' => 'user0', 'auth_type' => 'config'), '1' => array('host' => 'host1', 'port' => 'port1', 'only_db' => 'only_db1', 'user' => 'user1', 'auth_type' => 'config'));
     //$not_only_options=false & $omit_fieldset=false
     $html = PMA_selectServer($not_only_options, $omit_fieldset);
     $server = $GLOBALS['cfg']['Servers']['0'];
     //server items
     $this->assertContains($server['host'], $html);
     $this->assertContains($server['port'], $html);
     $this->assertContains($server['only_db'], $html);
     $this->assertContains($server['user'], $html);
     $not_only_options = true;
     $omit_fieldset = true;
     $GLOBALS['cfg']['DisplayServersList'] = null;
     //$not_only_options=true & $omit_fieldset=true
     $html = PMA_selectServer($not_only_options, $omit_fieldset);
     //$GLOBALS['cfg']['DefaultTabServer']
     $this->assertContains(PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabServer'], 'server'), $html);
     //labels
     $this->assertContains(__('Current Server:'), $html);
     $this->assertContains('(' . __('Servers') . ')', $html);
     //server items
     $server = $GLOBALS['cfg']['Servers']['0'];
     $this->assertContains($server['host'], $html);
     $this->assertContains($server['port'], $html);
     $this->assertContains($server['only_db'], $html);
     $this->assertContains($server['user'], $html);
 }
Ejemplo n.º 2
0
/**
 * Builds the HTML td elements for one database to display in the list
 * of databases from server_databases.php (which can be modified by
 * db_create.php)
 *
 * @param array   $current           current database
 * @param boolean $is_superuser      user status
 * @param string  $url_query         url query
 * @param array   $column_order      column order
 * @param array   $replication_types replication types
 * @param array   $replication_info  replication info
 *
 * @return array $column_order, $out
 */
function PMA_buildHtmlForDb($current, $is_superuser, $url_query, $column_order, $replication_types, $replication_info)
{
    $out = '';
    if ($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) {
        $out .= '<td class="tool">';
        $out .= '<input type="checkbox" name="selected_dbs[]" class="checkall" ' . 'title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" ' . 'value="' . htmlspecialchars($current['SCHEMA_NAME']) . '"';
        if ($GLOBALS['dbi']->isSystemSchema($current['SCHEMA_NAME'], true)) {
            $out .= ' disabled="disabled"';
        }
        $out .= ' /></td>';
    }
    $out .= '<td class="name">' . '<a href="' . PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database') . $url_query . '&amp;db=' . urlencode($current['SCHEMA_NAME']) . '" title="' . sprintf(__('Jump to database'), htmlspecialchars($current['SCHEMA_NAME'])) . '">' . ' ' . htmlspecialchars($current['SCHEMA_NAME']) . '</a>' . '</td>';
    foreach ($column_order as $stat_name => $stat) {
        if (array_key_exists($stat_name, $current)) {
            $unit = '';
            if (is_numeric($stat['footer'])) {
                $column_order[$stat_name]['footer'] += $current[$stat_name];
            }
            if ($stat['format'] === 'byte') {
                list($value, $unit) = PMA_Util::formatByteDown($current[$stat_name], 3, 1);
            } elseif ($stat['format'] === 'number') {
                $value = PMA_Util::formatNumber($current[$stat_name], 0);
            } else {
                $value = htmlentities($current[$stat_name], 0);
            }
            $out .= '<td class="value">';
            if (isset($stat['description_function'])) {
                $out .= '<dfn title="' . $stat['description_function']($current[$stat_name]) . '">';
            }
            $out .= $value;
            if (isset($stat['description_function'])) {
                $out .= '</dfn>';
            }
            $out .= '</td>';
            if ($stat['format'] === 'byte') {
                $out .= '<td class="unit">' . $unit . '</td>';
            }
        }
    }
    foreach ($replication_types as $type) {
        if ($replication_info[$type]['status']) {
            $out .= '<td class="tool" style="text-align: center;">';
            $key = array_search($current["SCHEMA_NAME"], $replication_info[$type]['Ignore_DB']);
            if (mb_strlen($key) > 0) {
                $out .= PMA_Util::getIcon('s_cancel.png', __('Not replicated'));
            } else {
                $key = array_search($current["SCHEMA_NAME"], $replication_info[$type]['Do_DB']);
                if (mb_strlen($key) > 0 || isset($replication_info[$type]['Do_DB'][0]) && $replication_info[$type]['Do_DB'][0] == "" && count($replication_info[$type]['Do_DB']) == 1) {
                    // if ($key != null) did not work for index "0"
                    $out .= PMA_Util::getIcon('s_success.png', __('Replicated'));
                }
            }
            $out .= '</td>';
        }
    }
    if ($is_superuser && !PMA_DRIZZLE) {
        $out .= '<td class="tool">' . '<a onclick="' . 'PMA_commonActions.setDb(\'' . PMA_jsFormat($current['SCHEMA_NAME']) . '\');' . '" href="server_privileges.php' . $url_query . '&amp;db=' . urlencode($current['SCHEMA_NAME']) . '&amp;checkprivsdb=' . urlencode($current['SCHEMA_NAME']) . '" title="' . sprintf(__('Check privileges for database "%s".'), htmlspecialchars($current['SCHEMA_NAME'])) . '">' . ' ' . PMA_Util::getIcon('s_rights.png', __('Check Privileges')) . '</a></td>';
    }
    return array($column_order, $out);
}
Ejemplo n.º 3
0
 /**
  * Initialises the class
  *
  * @param string $name     An identifier for the new node
  * @param int    $type     Type of node, may be one of CONTAINER or OBJECT
  * @param bool   $is_group Whether this object has been created
  *                         while grouping nodes
  */
 public function __construct($name, $type = Node::OBJECT, $is_group = false)
 {
     parent::__construct($name, $type, $is_group);
     $this->icon = PMA_Util::getImage('s_db.png', __('Database operations'));
     $script_name = PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database');
     $this->links = array('text' => $script_name . '?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token '], 'icon' => 'db_operations.php?server=' . $GLOBALS['server'] . '&amp;db=%1$s&amp;token=' . $_SESSION[' PMA_token '], 'title' => __('Structure'));
     $this->classes = 'database';
 }
Ejemplo n.º 4
0
 /**
  * Initialises the class
  *
  * @param string $name     An identifier for the new node
  * @param int    $type     Type of node, may be one of CONTAINER or OBJECT
  * @param bool   $is_group Whether this object has been created
  *                         while grouping nodes
  *
  * @return Node_Table
  */
 public function __construct($name, $type = Node::OBJECT, $is_group = false)
 {
     parent::__construct($name, $type, $is_group);
     $this->icon = array();
     $this->_addIcon(PMA_Util::getScriptNameForOption($GLOBALS['cfg']['NavigationTreeDefaultTabTable'], 'table'));
     $this->_addIcon(PMA_Util::getScriptNameForOption($GLOBALS['cfg']['NavigationTreeDefaultTabTable2'], 'table'));
     $title = PMA_Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']);
     $this->title = $title;
     $script_name = PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table');
     $this->links = array('text' => $script_name . '?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s' . '&amp;pos=0&amp;token=' . $_SESSION[' PMA_token '], 'icon' => array(PMA_Util::getScriptNameForOption($GLOBALS['cfg']['NavigationTreeDefaultTabTable'], 'table') . '?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s&amp;token=' . $_SESSION[' PMA_token '], PMA_Util::getScriptNameForOption($GLOBALS['cfg']['NavigationTreeDefaultTabTable2'], 'table') . '?server=' . $GLOBALS['server'] . '&amp;db=%2$s&amp;table=%1$s&amp;token=' . $_SESSION[' PMA_token ']), 'title' => $this->title);
     $this->classes = 'table';
 }
Ejemplo n.º 5
0
/**
 * Get initial values for Sql Query Form Insert
 *
 * @param string $query query to display in the textarea
 *
 * @return array ($legend, $query, $columns_list)
 *
 * @usedby  PMA_getHtmlForSqlQueryFormInsert()
 */
function PMA_initQueryForm($query)
{
    $columns_list = array();
    if (!mb_strlen($GLOBALS['db'])) {
        // prepare for server related
        $legend = sprintf(__('Run SQL query/queries on server %s'), '&quot;' . htmlspecialchars(!empty($GLOBALS['cfg']['Servers'][$GLOBALS['server']]['verbose']) ? $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['verbose'] : $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host']) . '&quot;');
    } elseif (!mb_strlen($GLOBALS['table'])) {
        // prepare for db related
        $db = $GLOBALS['db'];
        // if you want navigation:
        $tmp_db_link = '<a href="' . PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database') . PMA_URL_getCommon(array('db' => $db)) . '"';
        $tmp_db_link .= '>' . htmlspecialchars($db) . '</a>';
        $legend = sprintf(__('Run SQL query/queries on database %s'), $tmp_db_link);
        if (empty($query)) {
            $query = PMA_Util::expandUserString($GLOBALS['cfg']['DefaultQueryDatabase'], 'backquote');
        }
    } else {
        $db = $GLOBALS['db'];
        // Get the list and number of fields
        // we do a try_query here, because we could be in the query window,
        // trying to synchronize and the table has not yet been created
        $columns_list = $GLOBALS['dbi']->getColumns($db, $GLOBALS['table'], null, true);
        $tmp_db_link = '<a href="' . PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database') . PMA_URL_getCommon(array('db' => $db)) . '"';
        $tmp_db_link .= '>' . htmlspecialchars($db) . '</a>';
        $legend = sprintf(__('Run SQL query/queries on database %s'), $tmp_db_link);
        if (empty($query)) {
            $query = PMA_Util::expandUserString($GLOBALS['cfg']['DefaultQueryTable'], 'backquote');
        }
    }
    $legend .= ': ' . PMA_Util::showMySQLDocu('SELECT');
    return array($legend, $query, $columns_list);
}
Ejemplo n.º 6
0
 /**
  * Returns the breadcrumbs as HTML
  *
  * @return string HTML formatted breadcrumbs
  */
 private function _getBreadcrumbs()
 {
     $retval = '';
     $tbl_is_view = $GLOBALS['dbi']->getTable($this->_db, $this->_table)->isView();
     $server_info = !empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : $GLOBALS['cfg']['Server']['host'];
     $server_info .= empty($GLOBALS['cfg']['Server']['port']) ? '' : ':' . $GLOBALS['cfg']['Server']['port'];
     $separator = "<span class='separator item'>&nbsp;»</span>";
     $item = '<a href="%1$s%2$s" class="item">';
     if (PMA_Util::showText('TabsMode')) {
         $item .= '%4$s: ';
     }
     $item .= '%3$s</a>';
     $retval .= "<div id='floating_menubar'></div>";
     $retval .= "<div id='serverinfo'>";
     if (PMA_Util::showIcons('TabsMode')) {
         $retval .= PMA_Util::getImage('s_host.png', '', array('class' => 'item'));
     }
     $retval .= sprintf($item, PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabServer'], 'server'), PMA_URL_getCommon(), htmlspecialchars($server_info), __('Server'));
     if (mb_strlen($this->_db)) {
         $retval .= $separator;
         if (PMA_Util::showIcons('TabsMode')) {
             $retval .= PMA_Util::getImage('s_db.png', '', array('class' => 'item'));
         }
         $retval .= sprintf($item, PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database'), PMA_URL_getCommon(array('db' => $this->_db)), htmlspecialchars($this->_db), __('Database'));
         // if the table is being dropped, $_REQUEST['purge'] is set to '1'
         // so do not display the table name in upper div
         if (mb_strlen($this->_table) && !(isset($_REQUEST['purge']) && $_REQUEST['purge'] == '1')) {
             include './libraries/tbl_info.inc.php';
             $retval .= $separator;
             if (PMA_Util::showIcons('TabsMode')) {
                 $icon = $tbl_is_view ? 'b_views.png' : 's_tbl.png';
                 $retval .= PMA_Util::getImage($icon, '', array('class' => 'item'));
             }
             $retval .= sprintf($item, PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table'), PMA_URL_getCommon(array('db' => $this->_db, 'table' => $this->_table)), str_replace(' ', '&nbsp;', htmlspecialchars($this->_table)), $tbl_is_view ? __('View') : __('Table'));
             /**
              * Displays table comment
              */
             if (!empty($show_comment) && !isset($GLOBALS['avoid_show_comment'])) {
                 if (mb_strstr($show_comment, '; InnoDB free')) {
                     $show_comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
                 }
                 $retval .= '<span class="table_comment"';
                 $retval .= ' id="span_table_comment">&quot;';
                 $retval .= htmlspecialchars($show_comment);
                 $retval .= '&quot;</span>';
             }
             // end if
         } else {
             // no table selected, display database comment if present
             $cfgRelation = PMA_getRelationsParam();
             // Get additional information about tables for tooltip is done
             // in PMA_Util::getDbInfo() only once
             if ($cfgRelation['commwork']) {
                 $comment = PMA_getDbComment($this->_db);
                 /**
                  * Displays table comment
                  */
                 if (!empty($comment)) {
                     $retval .= '<span class="table_comment"' . ' id="span_table_comment">&quot;' . htmlspecialchars($comment) . '&quot;</span>';
                 }
                 // end if
             }
         }
     }
     $retval .= '<div class="clearfloat"></div>';
     $retval .= '</div>';
     return $retval;
 }
Ejemplo n.º 7
0
 /**
  * returns html code for db link to default db page
  *
  * @param string $database database
  *
  * @return string  html link to default db page
  */
 public static function getDbLink($database = null)
 {
     if (!mb_strlen($database)) {
         if (!mb_strlen($GLOBALS['db'])) {
             return '';
         }
         $database = $GLOBALS['db'];
     } else {
         $database = self::unescapeMysqlWildcards($database);
     }
     return '<a href="' . PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database') . PMA_URL_getCommon(array('db' => $database)) . '" title="' . htmlspecialchars(sprintf(__('Jump to database "%s".'), $database)) . '">' . htmlspecialchars($database) . '</a>';
 }
Ejemplo n.º 8
0
/**
 * Defines the url to return to in case of error in a sql statement
 */
// Security checks
if (!empty($goto)) {
    $is_gotofile = preg_replace('@^([^?]+).*$@s', '\\1', $goto);
    if (!@file_exists('' . $is_gotofile)) {
        unset($goto);
    } else {
        $is_gotofile = $is_gotofile == $goto;
    }
} else {
    if (empty($table)) {
        $goto = PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database');
    } else {
        $goto = PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table');
    }
    $is_gotofile = true;
}
// end if
if (!isset($err_url)) {
    $err_url = (!empty($back) ? $back : $goto) . '?' . PMA_URL_getCommon(array('db' => $GLOBALS['db'])) . (mb_strpos(' ' . $goto, 'db_') != 1 && mb_strlen($table) ? '&amp;table=' . urlencode($table) : '');
}
// end if
// Coming from a bookmark dialog
if (isset($_POST['bkm_fields']['bkm_sql_query'])) {
    $sql_query = $_POST['bkm_fields']['bkm_sql_query'];
} elseif (isset($_GET['sql_query'])) {
    $sql_query = $_GET['sql_query'];
}
// This one is just to fill $db
         */
        $db_url_params['db'] = $_POST['new_db'];
        $is_superuser = $GLOBALS['dbi']->isSuperuser();
        $column_order = PMA_getColumnOrder();
        $url_query = PMA_URL_getCommon(array('db' => $_POST['new_db']));
        /**
         * String that will contain the output HTML
         * @name    $new_db_string
         */
        $new_db_string = '<tr>';
        if (empty($db_collation_for_ajax)) {
            $db_collation_for_ajax = PMA_getServerCollation();
        }
        // $dbstats comes from the create table dialog
        if (!empty($dbstats)) {
            $current = array('SCHEMA_NAME' => $_POST['new_db'], 'DEFAULT_COLLATION_NAME' => $db_collation_for_ajax, 'SCHEMA_TABLES' => '0', 'SCHEMA_TABLE_ROWS' => '0', 'SCHEMA_DATA_LENGTH' => '0', 'SCHEMA_MAX_DATA_LENGTH' => '0', 'SCHEMA_INDEX_LENGTH' => '0', 'SCHEMA_LENGTH' => '0', 'SCHEMA_DATA_FREE' => '0');
        } else {
            $current = array('SCHEMA_NAME' => $_POST['new_db'], 'DEFAULT_COLLATION_NAME' => $db_collation_for_ajax);
        }
        list($column_order, $generated_html) = PMA_buildHtmlForDb($current, $is_superuser, $url_query, $column_order, $replication_types, $GLOBALS['replication_info']);
        $new_db_string .= $generated_html;
        $new_db_string .= '</tr>';
        $response = PMA_Response::getInstance();
        $response->addJSON('message', $message);
        $response->addJSON('new_db_string', $new_db_string);
        $response->addJSON('sql_query', PMA_Util::getMessage(null, $sql_query, 'success'));
        $response->addJSON('url_query', PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database') . $url_query . '&amp;db=' . urlencode($current['SCHEMA_NAME']));
    } else {
        include_once '' . $cfg['DefaultTabDatabase'];
    }
}
Ejemplo n.º 10
0
$scripts->addFile('jqplot/plugins/jqplot.highlighter.js');
/**
 * Runs common work
 */
if (mb_strlen($GLOBALS['table'])) {
    $url_params['goto'] = PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table');
    $url_params['back'] = 'tbl_sql.php';
    include 'libraries/tbl_common.inc.php';
    include 'libraries/tbl_info.inc.php';
} elseif (mb_strlen($GLOBALS['db'])) {
    $url_params['goto'] = PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database');
    $url_params['back'] = 'sql.php';
    include 'libraries/db_common.inc.php';
    include 'libraries/db_info.inc.php';
} else {
    $url_params['goto'] = PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabServer'], 'server');
    $url_params['back'] = 'sql.php';
    include 'libraries/server_common.inc.php';
}
$data = array();
$result = $GLOBALS['dbi']->tryQuery($sql_query);
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
    $data[] = $row;
}
$keys = array_keys($data[0]);
$numeric_types = array('int', 'real');
$numeric_column_count = 0;
foreach ($keys as $idx => $key) {
    if (in_array($fields_meta[$idx]->type, $numeric_types)) {
        $numeric_column_count++;
Ejemplo n.º 11
0
 */
if (!defined('PHPMYADMIN')) {
    exit;
}
/**
 * Gets some core libraries
 */
require_once './libraries/bookmark.lib.php';
// Check parameters
PMA_Util::checkParameters(array('db', 'table'));
$db_is_system_schema = $GLOBALS['dbi']->isSystemSchema($db);
/**
 * Set parameters for links
 * @deprecated
 */
$url_query = PMA_URL_getCommon(array('db' => $db, 'table' => $table));
/**
 * Set parameters for links
 */
$url_params = array();
$url_params['db'] = $db;
$url_params['table'] = $table;
/**
 * Defines the urls to return to in case of error in a sql statement
 */
$err_url_0 = PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database') . PMA_URL_getCommon(array('db' => $db));
$err_url = PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table') . PMA_URL_getCommon($url_params);
/**
 * Ensures the database and the table exist (else move to the "parent" script)
 */
require_once './libraries/db_table_exists.lib.php';
 /**
  * Test for PMA_getLinkToDbAndTable
  *
  * @return void
  */
 public function testPMAGetLinkToDbAndTable()
 {
     $url_dbname = "url_dbname";
     $dbname = "dbname";
     $tablename = "tablename";
     $html = PMA_getLinkToDbAndTable($url_dbname, $dbname, $tablename);
     //$dbname
     $this->assertContains(__('Database'), $html);
     $this->assertContains(PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database'), $html);
     $item = PMA_URL_getCommon(array('db' => $url_dbname, 'reload' => 1));
     $this->assertContains($item, $html);
     $this->assertContains(htmlspecialchars($dbname), $html);
     //$tablename
     $this->assertContains(__('Table'), $html);
     $this->assertContains(PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table'), $html);
     $item = PMA_URL_getCommon(array('db' => $url_dbname, 'table' => $tablename, 'reload' => 1));
     $this->assertContains($item, $html);
     $this->assertContains(htmlspecialchars($tablename), $html);
     $item = PMA_Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']);
     $this->assertContains($item, $html);
 }
Ejemplo n.º 13
0
 /**
  * Returns, as an array, a list of parameters
  * used on the client side
  *
  * @return array
  */
 public function getJsParams()
 {
     $db = !empty($GLOBALS['db']) ? $GLOBALS['db'] : '';
     $table = !empty($GLOBALS['table']) ? $GLOBALS['table'] : '';
     $pftext = !empty($_SESSION['tmpval']['pftext']) ? $_SESSION['tmpval']['pftext'] : '';
     // not sure when this happens, but it happens
     if (!isset($GLOBALS['collation_connection'])) {
         $GLOBALS['collation_connection'] = 'utf8_general_ci';
     }
     $params = array('common_query' => PMA_URL_getCommon(array(), 'text'), 'opendb_url' => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database'), 'safari_browser' => PMA_USR_BROWSER_AGENT == 'SAFARI' ? 1 : 0, 'collation_connection' => $GLOBALS['collation_connection'], 'lang' => $GLOBALS['lang'], 'server' => $GLOBALS['server'], 'table' => $table, 'db' => $db, 'token' => $_SESSION[' PMA_token '], 'text_dir' => $GLOBALS['text_dir'], 'show_databases_navigation_as_tree' => $GLOBALS['cfg']['ShowDatabasesNavigationAsTree'], 'pma_absolute_uri' => $GLOBALS['cfg']['PmaAbsoluteUri'], 'pma_text_default_tab' => PMA_Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']), 'pma_text_left_default_tab' => PMA_Util::getTitleForTarget($GLOBALS['cfg']['NavigationTreeDefaultTabTable']), 'pma_text_left_default_tab2' => PMA_Util::getTitleForTarget($GLOBALS['cfg']['NavigationTreeDefaultTabTable2']), 'LimitChars' => $GLOBALS['cfg']['LimitChars'], 'pftext' => $pftext, 'confirm' => $GLOBALS['cfg']['Confirm'], 'LoginCookieValidity' => $GLOBALS['cfg']['LoginCookieValidity'], 'logged_in' => isset($GLOBALS['userlink']) ? true : false);
     if (isset($GLOBALS['cfg']['Server']) && isset($GLOBALS['cfg']['Server']['auth_type'])) {
         $params['auth_type'] = $GLOBALS['cfg']['Server']['auth_type'];
     }
     return $params;
 }
Ejemplo n.º 14
0
$target_blacklist = array('import.php', 'export.php');
// If we have a valid target, let's load that script instead
if (!empty($_REQUEST['target']) && is_string($_REQUEST['target']) && !preg_match('/^index/', $_REQUEST['target']) && !in_array($_REQUEST['target'], $target_blacklist) && in_array($_REQUEST['target'], $goto_whitelist)) {
    include $_REQUEST['target'];
    exit;
}
if (isset($_REQUEST['ajax_request']) && !empty($_REQUEST['access_time'])) {
    exit;
}
// See FAQ 1.34
if (!empty($_REQUEST['db'])) {
    $page = null;
    if (!empty($_REQUEST['table'])) {
        $page = PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table');
    } else {
        $page = PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database');
    }
    include $page;
    exit;
}
/**
 * Check if it is an ajax request to reload the recent tables list.
 */
require_once 'libraries/RecentFavoriteTable.class.php';
if ($GLOBALS['is_ajax_request'] && !empty($_REQUEST['recent_table'])) {
    $response = PMA_Response::getInstance();
    $response->addJSON('list', PMA_RecentFavoriteTable::getInstance('recent')->getHtmlList());
    exit;
}
if ($GLOBALS['PMA_Config']->isGitRevision()) {
    if (isset($_REQUEST['git_revision']) && $GLOBALS['is_ajax_request'] == true) {
Ejemplo n.º 15
0
    <script type="text/javascript">
        var PMA_TEST_THEME = true;
    </script>
    <script src="../js/get_image.js.php" type="text/javascript"></script>
    <script src="../js/functions.js" type="text/javascript"></script>
</head>
<body>
<?php 
$separator = '<span class=\'separator item\'>&nbsp;»</span>' . "\n";
$item = '<a href="%1$s?%2$s" class="item">' . ' <img class="icon %5$s" src="../themes/dot.gif"' . ' width="16" height="16" alt="" /> ' . "\n" . '%4$s: %3$s</a>' . "\n";
echo '<div id="serverinfo">' . "\n";
printf($item, PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabserver'], 'server'), PMA_URL_getCommon(), 'Server', __('Server'), 'ic_s_host');
echo $separator;
printf($item, PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database'), '', 'Database', __('Database'), 'ic_s_db');
echo $separator;
printf($item, PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table'), '', 'Table', isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? __('View') : __('Table'), isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? 'ic_b_views' : 'ic_s_tbl');
echo '<span class="table_comment" id="span_table_comment">' . '&quot;Table comment&quot;</span>' . "\n";
echo '</div>';
/**
 * Displays tab links
 */
$tabs = array();
$tabs['databases']['icon'] = 's_db.png';
$tabs['databases']['link'] = 'server_databases.php';
$tabs['databases']['text'] = __('Databases');
$tabs['sql']['icon'] = 'b_sql.png';
$tabs['sql']['link'] = 'server_sql.php';
$tabs['sql']['text'] = __('SQL');
$tabs['status']['icon'] = 's_status.png';
$tabs['status']['link'] = 'server_status.php';
$tabs['status']['text'] = __('Status');
Ejemplo n.º 16
0
         */
        $db_url_params['db'] = $_POST['new_db'];
        $is_superuser = $GLOBALS['dbi']->isSuperuser();
        $column_order = PMA_getColumnOrder();
        $url_query = PMA_URL_getCommon(array('db' => $_POST['new_db']));
        /**
         * String that will contain the output HTML
         * @name    $new_db_string
         */
        $new_db_string = '<tr>';
        if (empty($db_collation_for_ajax)) {
            $db_collation_for_ajax = PMA_getServerCollation();
        }
        // $dbstats comes from the create table dialog
        if (!empty($dbstats)) {
            $current = array('SCHEMA_NAME' => $_POST['new_db'], 'DEFAULT_COLLATION_NAME' => $db_collation_for_ajax, 'SCHEMA_TABLES' => '0', 'SCHEMA_TABLE_ROWS' => '0', 'SCHEMA_DATA_LENGTH' => '0', 'SCHEMA_MAX_DATA_LENGTH' => '0', 'SCHEMA_INDEX_LENGTH' => '0', 'SCHEMA_LENGTH' => '0', 'SCHEMA_DATA_FREE' => '0');
        } else {
            $current = array('SCHEMA_NAME' => $_POST['new_db'], 'DEFAULT_COLLATION_NAME' => $db_collation_for_ajax);
        }
        list($column_order, $generated_html) = PMA_buildHtmlForDb($current, $is_superuser, $url_query, $column_order, $replication_types, $GLOBALS['replication_info']);
        $new_db_string .= $generated_html;
        $new_db_string .= '</tr>';
        $response = PMA_Response::getInstance();
        $response->addJSON('message', $message);
        $response->addJSON('new_db_string', $new_db_string);
        $response->addJSON('sql_query', PMA_Util::getMessage(null, $sql_query, 'success'));
        $response->addJSON('url_query', PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database') . $url_query . '&amp;db=' . urlencode($current['SCHEMA_NAME']));
    } else {
        include_once '' . PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database');
    }
}
 *
 * Variable structure ex:
 * $GLOBALS['special_schema_links'] = array(
 *     // Database name is the major element
 *     'mysql' => array(
 *         // Table name
 *         'db' => array(
 *             // Column name
 *             'user' => array(
 *                 // Main url param (can be an array where represent sql)
 *                 'link_param' => 'username',
 *                 // Other url params
 *                 'link_dependancy_params' => array(
 *                     0 => array(
 *                         // URL parameter name
 *                         // (can be array where url param has static value)
 *                         'param_info' => 'hostname',
 *                         // Column name related to url param
 *                         'column_name' => 'host'
 *                     )
 *                 ),
 *                 // Page to link
 *                 'default_page' => 'server_privileges.php'
 *             )
 *         )
 *     )
 * );
 *
 */
$GLOBALS['special_schema_links'] = array('mysql' => array('columns_priv' => array('user' => array('link_param' => 'username', 'link_dependancy_params' => array(0 => array('param_info' => 'hostname', 'column_name' => 'host')), 'default_page' => 'server_privileges.php'), 'table_name' => array('link_param' => 'table', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'Db')), 'default_page' => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table')), 'column_name' => array('link_param' => 'field', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'Db'), 1 => array('param_info' => 'table', 'column_name' => 'Table_name')), 'default_page' => 'tbl_structure.php?change_column=1')), 'db' => array('user' => array('link_param' => 'username', 'link_dependancy_params' => array(0 => array('param_info' => 'hostname', 'column_name' => 'host')), 'default_page' => 'server_privileges.php')), 'event' => array('name' => array('link_param' => 'item_name', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'db')), 'default_page' => 'db_events.php?edit_item=1')), 'innodb_index_stats' => array('table_name' => array('link_param' => 'table', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'database_name')), 'default_page' => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table')), 'index_name' => array('link_param' => 'index', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'database_name'), 1 => array('param_info' => 'table', 'column_name' => 'table_name')), 'default_page' => 'tbl_structure.php')), 'innodb_table_stats' => array('table_name' => array('link_param' => 'table', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'database_name')), 'default_page' => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table'))), 'proc' => array('name' => array('link_param' => 'item_name', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'db'), 1 => array('param_info' => 'item_type', 'column_name' => 'type')), 'default_page' => 'db_routines.php?edit_item=1'), 'specific_name' => array('link_param' => 'item_name', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'db'), 1 => array('param_info' => 'item_type', 'column_name' => 'type')), 'default_page' => 'db_routines.php?edit_item=1')), 'proc_priv' => array('user' => array('link_param' => 'username', 'link_dependancy_params' => array(0 => array('param_info' => 'hostname', 'column_name' => 'Host')), 'default_page' => 'server_privileges.php'), 'routine_name' => array('link_param' => 'item_name', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'Db'), 1 => array('param_info' => 'item_type', 'column_name' => 'Routine_type')), 'default_page' => 'db_routines.php?edit_item=1')), 'proxies_priv' => array('user' => array('link_param' => 'username', 'link_dependancy_params' => array(0 => array('param_info' => 'hostname', 'column_name' => 'Host')), 'default_page' => 'server_privileges.php')), 'tables_priv' => array('user' => array('link_param' => 'username', 'link_dependancy_params' => array(0 => array('param_info' => 'hostname', 'column_name' => 'Host')), 'default_page' => 'server_privileges.php'), 'table_name' => array('link_param' => 'table', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'Db')), 'default_page' => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table'))), 'user' => array('user' => array('link_param' => 'username', 'link_dependancy_params' => array(0 => array('param_info' => 'hostname', 'column_name' => 'host')), 'default_page' => 'server_privileges.php'))), 'information_schema' => array('columns' => array('table_name' => array('link_param' => 'table', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'table_schema')), 'default_page' => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table')), 'column_name' => array('link_param' => 'field', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'table_schema'), 1 => array('param_info' => 'table', 'column_name' => 'table_name')), 'default_page' => 'tbl_structure.php?change_column=1')), 'key_column_usage' => array('table_name' => array('link_param' => 'table', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'constraint_schema')), 'default_page' => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table')), 'column_name' => array('link_param' => 'field', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'table_schema'), 1 => array('param_info' => 'table', 'column_name' => 'table_name')), 'default_page' => 'tbl_structure.php?change_column=1'), 'referenced_table_name' => array('link_param' => 'table', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'referenced_table_schema')), 'default_page' => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table')), 'referenced_column_name' => array('link_param' => 'field', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'referenced_table_schema'), 1 => array('param_info' => 'table', 'column_name' => 'referenced_table_name')), 'default_page' => 'tbl_structure.php?change_column=1')), 'partitions' => array('table_name' => array('link_param' => 'table', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'table_schema')), 'default_page' => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table'))), 'processlist' => array('user' => array('link_param' => 'username', 'link_dependancy_params' => array(0 => array('param_info' => 'hostname', 'column_name' => 'host')), 'default_page' => 'server_privileges.php')), 'referential_constraints' => array('table_name' => array('link_param' => 'table', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'constraint_schema')), 'default_page' => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table')), 'referenced_table_name' => array('link_param' => 'table', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'constraint_schema')), 'default_page' => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table'))), 'routines' => array('routine_name' => array('link_param' => 'item_name', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'routine_schema'), 1 => array('param_info' => 'item_type', 'column_name' => 'routine_type')), 'default_page' => 'db_routines.php')), 'schemata' => array('schema_name' => array('link_param' => 'db', 'default_page' => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table'))), 'statistics' => array('table_name' => array('link_param' => 'table', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'table_schema')), 'default_page' => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table')), 'column_name' => array('link_param' => 'field', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'table_schema'), 1 => array('param_info' => 'table', 'column_name' => 'table_name')), 'default_page' => 'tbl_structure.php?change_column=1')), 'tables' => array('table_name' => array('link_param' => 'table', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'table_schema')), 'default_page' => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table'))), 'table_constraints' => array('table_name' => array('link_param' => 'table', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'table_schema')), 'default_page' => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table'))), 'views' => array('table_name' => array('link_param' => 'table', 'link_dependancy_params' => array(0 => array('param_info' => 'db', 'column_name' => 'table_schema')), 'default_page' => PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table')))));
Ejemplo n.º 18
0
 /**
  * Test for getDbLink
  *
  * @return void
  */
 function testGetDbLinkWithSpecialChars()
 {
     global $cfg;
     $database = 'test&data\'base';
     $this->assertEquals('<a href="' . PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database') . '?db=' . htmlspecialchars(urlencode($database)) . '&amp;server=99&amp;lang=en&amp;token=token" title="Jump to database &quot;' . htmlspecialchars($database) . '&quot;.">' . htmlspecialchars($database) . '</a>', PMA_Util::getDbLink($database));
 }
Ejemplo n.º 19
0
/**
 * Renders the server selection in list or selectbox form, or option tags only
 *
 * @param boolean $not_only_options whether to include form tags or not
 * @param boolean $omit_fieldset    whether to omit fieldset tag or not
 *
 * @return string
 */
function PMA_selectServer($not_only_options, $omit_fieldset)
{
    $retval = '';
    // Show as list?
    if ($not_only_options) {
        $list = $GLOBALS['cfg']['DisplayServersList'];
        $not_only_options = !$list;
    } else {
        $list = false;
    }
    if ($not_only_options) {
        $retval .= '<form method="post" action="' . PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabServer'], 'server') . '" class="disableAjax">';
        if (!$omit_fieldset) {
            $retval .= '<fieldset>';
        }
        $retval .= '<label for="select_server">' . __('Current Server:') . '</label> ';
        $retval .= '<select name="server" id="select_server" class="autosubmit">';
        $retval .= '<option value="">(' . __('Servers') . ') ...</option>' . "\n";
    } elseif ($list) {
        $retval .= __('Current Server:') . '<br />';
        $retval .= '<ul id="list_server">';
    }
    foreach ($GLOBALS['cfg']['Servers'] as $key => $server) {
        if (empty($server['host'])) {
            continue;
        }
        if (!empty($GLOBALS['server']) && (int) $GLOBALS['server'] === (int) $key) {
            $selected = 1;
        } else {
            $selected = 0;
        }
        if (!empty($server['verbose'])) {
            $label = $server['verbose'];
        } else {
            $label = $server['host'];
            if (!empty($server['port'])) {
                $label .= ':' . $server['port'];
            }
        }
        if (!empty($server['only_db'])) {
            if (!is_array($server['only_db'])) {
                $label .= ' - ' . $server['only_db'];
                // try to avoid displaying a too wide selector
            } elseif (count($server['only_db']) < 4) {
                $label .= ' - ' . implode(', ', $server['only_db']);
            }
        }
        if (!empty($server['user']) && $server['auth_type'] == 'config') {
            $label .= '  (' . $server['user'] . ')';
        }
        if ($list) {
            $retval .= '<li>';
            if ($selected) {
                $retval .= '<strong>' . htmlspecialchars($label) . '</strong>';
            } else {
                $retval .= '<a class="disableAjax item" href="' . PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabServer'], 'server') . PMA_URL_getCommon(array('server' => $key)) . '" >' . htmlspecialchars($label) . '</a>';
            }
            $retval .= '</li>';
        } else {
            $retval .= '<option value="' . $key . '" ' . ($selected ? ' selected="selected"' : '') . '>' . htmlspecialchars($label) . '</option>' . "\n";
        }
    }
    // end while
    if ($not_only_options) {
        $retval .= '</select>';
        if (!$omit_fieldset) {
            $retval .= '</fieldset>';
        }
        $retval .= '</form>';
    } elseif ($list) {
        $retval .= '</ul>';
    }
    return $retval;
}
 /**
  * User is not allowed to login to MySQL -> authentication failed
  *
  * @global string  the MySQL error message PHP returns
  * @global string  the connection type (persistent or not)
  * @global string  the MySQL server port to use
  * @global string  the MySQL socket port to use
  * @global array   the current server settings
  * @global string  the font face to use in case of failure
  * @global string  the default font size to use in case of failure
  * @global string  the big font size to use in case of failure
  * @global boolean tell the "PMA_mysqlDie()" function headers have been
  *                 sent
  *
  * @return boolean   always true (no return indeed)
  */
 public function authFails()
 {
     $conn_error = $GLOBALS['dbi']->getError();
     if (!$conn_error) {
         $conn_error = __('Cannot connect: invalid settings.');
     }
     /* HTML header */
     $response = PMA_Response::getInstance();
     $response->getFooter()->setMinimal();
     $header = $response->getHeader();
     $header->setBodyId('loginform');
     $header->setTitle(__('Access denied!'));
     $header->disableMenuAndConsole();
     echo '<br /><br />
 <center>
     <h1>';
     echo sprintf(__('Welcome to %s'), ' phpMyAdmin ');
     echo '</h1>
 </center>
 <br />
 <table cellpadding="0" cellspacing="3" style="margin: 0 auto" width="80%">
     <tr>
         <td>';
     if (isset($GLOBALS['allowDeny_forbidden']) && $GLOBALS['allowDeny_forbidden']) {
         trigger_error(__('Access denied!'), E_USER_NOTICE);
     } else {
         // Check whether user has configured something
         if ($GLOBALS['PMA_Config']->source_mtime == 0) {
             echo '<p>' . sprintf(__('You probably did not create a configuration file.' . ' You might want to use the %1$ssetup script%2$s to' . ' create one.'), '<a href="setup/">', '</a>') . '</p>' . "\n";
         } elseif (!isset($GLOBALS['errno']) || isset($GLOBALS['errno']) && $GLOBALS['errno'] != 2002 && $GLOBALS['errno'] != 2003) {
             // if we display the "Server not responding" error, do not confuse
             // users by telling them they have a settings problem
             // (note: it's true that they could have a badly typed host name,
             // but anyway the current message tells that the server
             //  rejected the connection, which is not really what happened)
             // 2002 is the error given by mysqli
             // 2003 is the error given by mysql
             trigger_error(__('phpMyAdmin tried to connect to the MySQL server, and the' . ' server rejected the connection. You should check the' . ' host, username and password in your configuration and' . ' make sure that they correspond to the information given' . ' by the administrator of the MySQL server.'), E_USER_WARNING);
         }
         echo PMA_Util::mysqlDie($conn_error, '', true, '', false);
     }
     $GLOBALS['error_handler']->dispUserErrors();
     echo '</td>
     </tr>
     <tr>
         <td>' . "\n";
     echo '<a href="' . PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabServer'], 'server') . PMA_URL_getCommon(array()) . '" class="button disableAjax">' . __('Retry to connect') . '</a>' . "\n";
     echo '</td>
     </tr>' . "\n";
     if (count($GLOBALS['cfg']['Servers']) > 1) {
         // offer a chance to login to other servers if the current one failed
         include_once './libraries/select_server.lib.php';
         echo '<tr>' . "\n";
         echo ' <td>' . "\n";
         echo PMA_selectServer(true, true);
         echo ' </td>' . "\n";
         echo '</tr>' . "\n";
     }
     echo '</table>' . "\n";
     if (!defined('TESTSUITE')) {
         exit;
     }
     return true;
 }
Ejemplo n.º 21
0
}
/**
 * Gets some core libraries
 */
require_once './libraries/bookmark.lib.php';
PMA_Util::checkParameters(array('db'));
$is_show_stats = $cfg['ShowStats'];
$db_is_system_schema = $GLOBALS['dbi']->isSystemSchema($db);
if ($db_is_system_schema) {
    $is_show_stats = false;
}
/**
 * Defines the urls to return to in case of error in a sql statement
 */
$err_url_0 = 'index.php' . PMA_URL_getCommon();
$err_url = PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database') . PMA_URL_getCommon(array('db' => $db));
/** @var PMA_String $pmaString */
$pmaString = $GLOBALS['PMA_String'];
/**
 * Ensures the database exists (else move to the "parent" script) and displays
 * headers
 */
if (!isset($is_db) || !$is_db) {
    if (mb_strlen($db)) {
        $is_db = $GLOBALS['dbi']->selectDb($db);
        // This "Command out of sync" 2014 error may happen, for example
        // after calling a MySQL procedure; at this point we can't select
        // the db but it's not necessarily wrong
        if ($GLOBALS['dbi']->getError() && $GLOBALS['errno'] == 2014) {
            $is_db = true;
            unset($GLOBALS['errno']);
/**
 * Provide a line with links to the relevant database and table
 *
 * @param string $url_dbname url database name that urlencode() string
 * @param string $dbname     database name
 * @param string $tablename  table name
 *
 * @return string HTML snippet
 */
function PMA_getLinkToDbAndTable($url_dbname, $dbname, $tablename)
{
    $html_output = '[ ' . __('Database') . ' <a href="' . PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database') . PMA_URL_getCommon(array('db' => $url_dbname, 'reload' => 1)) . '">' . htmlspecialchars($dbname) . ': ' . PMA_Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabDatabase']) . "</a> ]\n";
    if (mb_strlen($tablename)) {
        $html_output .= ' [ ' . __('Table') . ' <a href="' . PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table') . PMA_URL_getCommon(array('db' => $url_dbname, 'table' => $tablename, 'reload' => 1)) . '">' . htmlspecialchars($tablename) . ': ' . PMA_Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . "</a> ]\n";
    }
    return $html_output;
}
<?php

/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * handles creation of the GIS visualizations.
 *
 * @package PhpMyAdmin
 */
require_once 'libraries/common.inc.php';
require_once './libraries/gis/GIS_Visualization.class.php';
require_once './libraries/gis/GIS_Factory.class.php';
// Runs common work
require_once 'libraries/db_common.inc.php';
$url_params['goto'] = PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database');
$url_params['back'] = 'sql.php';
$response = PMA_Response::getInstance();
// Throw error if no sql query is set
if (!isset($sql_query) || $sql_query == '') {
    $response->isSuccess(false);
    $response->addHTML(PMA_Message::error(__('No SQL query was set to fetch data.')));
    exit;
}
// Execute the query and return the result
$result = $GLOBALS['dbi']->tryQuery($sql_query);
// Get the meta data of results
$meta = $GLOBALS['dbi']->getFieldsMeta($result);
// Find the candidate fields for label column and spatial column
$labelCandidates = array();
$spatialCandidates = array();
foreach ($meta as $column_meta) {
    if ($column_meta->type == 'geometry') {