}

        // Provide a line with links to the relevant database and table
        if (isset($dbname) && empty($dbname_is_wildcard)) {
            echo '[ ' . __('Database')
                . ' <a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?'
                . $GLOBALS['url_query'] . '&amp;db=' . $url_dbname . '&amp;reload=1">'
                . htmlspecialchars($dbname) . ': ' . PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabDatabase']) . "</a> ]\n";

            if (isset($tablename)) {
                echo ' [ ' . __('Table') . ' <a href="'
                    . $GLOBALS['cfg']['DefaultTabTable'] . '?' . $GLOBALS['url_query']
                    . '&amp;db=' . $url_dbname . '&amp;table=' . htmlspecialchars(urlencode($tablename))
                    . '&amp;reload=1">' . htmlspecialchars($tablename) . ': '
                    . PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable'])
                    . "</a> ]\n";
            }
            unset($url_dbname);
        }

        if (! isset($dbname) && ! $user_does_not_exists) {
            include_once 'libraries/display_change_password.lib.php';

            echo '<form action="server_privileges.php" method="post" onsubmit="return checkPassword(this);">' . "\n"
               . PMA_generate_common_hidden_inputs('', '')
               . '<input type="hidden" name="old_username" value="' . htmlspecialchars($username) . '" />' . "\n"
               . '<input type="hidden" name="old_hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n"
               . '<fieldset id="fieldset_change_copy_user">' . "\n"
               . '    <legend>' . __('Change Login Information / Copy User') . '</legend>' . "\n";
            PMA_displayLoginInformationFields('change');
Esempio n. 2
0
/**
 * display unordered list of tables
 * calls itself recursively if table in given list
 * is a list itself
 *
 * @uses    is_array()
 * @uses    count()
 * @uses    urlencode()
 * @uses    strpos()
 * @uses    printf()
 * @uses    htmlspecialchars()
 * @uses    strlen()
 * @uses    is_array()
 * @uses    PMA_displayTableList()
 * @uses    $_REQUEST['tbl_group']
 * @uses    $GLOBALS['common_url_query']
 * @uses    $GLOBALS['table']
 * @uses    $GLOBALS['pmaThemeImage']
 * @uses    $GLOBALS['cfg']['LeftFrameTableSeparator']
 * @uses    $GLOBALS['cfg']['DefaultTabDatabase']
 * @uses    $GLOBALS['cfg']['DefaultTabTable']
 * @uses    $GLOBALS['strRows']
 * @uses    $GLOBALS['strBrowse']
 * @global  integer the element counter
 * @global  string  html code for '-' image
 * @global  string  html code for '+' image
 * @global  string  html code for self link
 * @param   array   $tables         array of tables/tablegroups
 * @param   boolean $visible        whether the list is visible or not
 * @param   string  $tab_group_full full tab group name
 * @param   string  $table_db       db of this table
 */
function PMA_displayTableList($tables, $visible = false, $tab_group_full = '', $table_db = '')
{
    if (!is_array($tables) || count($tables) === 0) {
        return;
    }
    global $element_counter, $img_minus, $img_plus, $href_left;
    $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
    if ($visible) {
        echo '<ul id="subel' . $element_counter . '">';
    } else {
        echo '<ul id="subel' . $element_counter . '" style="display: none">';
    }
    foreach ($tables as $group => $table) {
        if (isset($table['is' . $sep . 'group'])) {
            $common_url_query = $GLOBALS['common_url_query'] . '&amp;tbl_group=' . urlencode($tab_group_full . $group);
            $element_counter++;
            echo '<li>' . "\n";
            if ($visible && (isset($_REQUEST['tbl_group']) && (strpos($_REQUEST['tbl_group'], $group) === 0 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false) || strpos($GLOBALS['table'], $group) === 0)) {
                printf($href_left, $element_counter, $GLOBALS['common_url_query'] . '&amp;tbl_group=' . $tab_group_full);
                printf($img_minus, $element_counter);
            } else {
                printf($href_left, $element_counter, $common_url_query);
                printf($img_plus, $element_counter);
            }
            echo '</a>';
            ?>
            <a href="index.php?<?php 
            echo $common_url_query;
            ?>
"
                target="_parent"
                onclick="
                    if (! toggle('<?php 
            echo $element_counter;
            ?>
', true))
                        window.parent.goTo('./navigation.php?<?php 
            echo $common_url_query;
            ?>
');
                    window.parent.goTo('./<?php 
            echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query;
            ?>
', 'main');
                    return false;">
                <?php 
            if ($GLOBALS['text_dir'] === 'rtl') {
                echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
            }
            echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep)));
            if ($GLOBALS['text_dir'] === 'ltr') {
                echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
            }
            ?>
            </a>
            <?php 
            unset($table['is' . $sep . 'group']);
            unset($table['tab' . $sep . 'group']);
            unset($table['tab' . $sep . 'count']);
            if ($visible && (isset($_REQUEST['tbl_group']) && (strpos($_REQUEST['tbl_group'], $group) === 0 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false) || strpos($GLOBALS['table'], $group) === 0)) {
                PMA_displayTableList($table, true, $tab_group_full . $group, $table_db);
            } else {
                PMA_displayTableList($table, false, '', $table_db);
            }
            echo '</li>' . "\n";
        } elseif (is_array($table)) {
            $link_title = PMA_getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable']);
            // quick access icon next to each table name
            echo '<li>' . "\n";
            echo '<a title="' . htmlspecialchars($link_title) . ': ' . htmlspecialchars($table['Comment']) . ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows'] . ')"' . ' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"' . ' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?' . $GLOBALS['common_url_query'] . '&amp;table=' . urlencode($table['Name']) . '&amp;goto=' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '" >' . '<img class="icon"';
            if ('VIEW' === strtoupper($table['Comment'])) {
                echo ' src="' . $GLOBALS['pmaThemeImage'] . 's_views.png"';
            } else {
                echo ' src="' . $GLOBALS['pmaThemeImage'] . 'b_sbrowse.png"';
            }
            echo ' id="icon_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"' . ' width="10" height="10" alt="' . htmlspecialchars($link_title) . '" /></a>' . "\n";
            // link for the table name itself
            $href = $GLOBALS['cfg']['DefaultTabTable'] . '?' . $GLOBALS['common_url_query'] . '&amp;table=' . urlencode($table['Name']) . '&amp;pos=0';
            echo '<a href="' . $href . '" title="' . htmlspecialchars(PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment'] . ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . $GLOBALS['strRows']) . ')"' . ' id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">' . str_replace(' ', '&nbsp;', htmlspecialchars($table['disp_name'])) . '</a>';
            echo '</li>' . "\n";
        }
    }
    echo '</ul>';
}
Esempio n. 3
0
                        }
                        echo '    </select>' . "\n";
                    }
                } else {
                    unset($res);
                }
                echo '    <input type="text" id="text_tablename" name="tablename" />' . "\n";
            }
            echo '</fieldset>' . "\n";
            echo '<fieldset class="tblFooters">' . "\n" . '    <input type="submit" value="' . __('Go') . '" />' . '</fieldset>' . "\n" . '</form>' . "\n";
        }
        // Provide a line with links to the relevant database and table
        if (isset($dbname) && empty($dbname_is_wildcard)) {
            echo '[ ' . __('Database') . ' <a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $GLOBALS['url_query'] . '&amp;db=' . $url_dbname . '&amp;reload=1">' . htmlspecialchars($dbname) . ': ' . PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabDatabase']) . "</a> ]\n";
            if (isset($tablename)) {
                echo ' [ ' . __('Table') . ' <a href="' . $GLOBALS['cfg']['DefaultTabTable'] . '?' . $GLOBALS['url_query'] . '&amp;db=' . $url_dbname . '&amp;table=' . htmlspecialchars(urlencode($tablename)) . '&amp;reload=1">' . htmlspecialchars($tablename) . ': ' . PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . "</a> ]\n";
            }
            unset($url_dbname);
        }
        if (!isset($dbname) && !$user_does_not_exists) {
            include_once './libraries/display_change_password.lib.php';
            echo '<form action="server_privileges.php" method="post" onsubmit="return checkPassword(this);">' . "\n" . PMA_generate_common_hidden_inputs('', '') . '<input type="hidden" name="old_username" value="' . htmlspecialchars($username) . '" />' . "\n" . '<input type="hidden" name="old_hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n" . '<fieldset id="fieldset_change_copy_user">' . "\n" . '    <legend>' . __('Change Login Information / Copy User') . '</legend>' . "\n";
            PMA_displayLoginInformationFields('change');
            echo '    <fieldset>' . "\n" . '        <legend>' . __('Create a new user with the same privileges and ...') . '</legend>' . "\n";
            $choices = array('4' => __('... keep the old one.'), '1' => __('... delete the old one from the user tables.'), '2' => __('... revoke all active privileges from the old one and delete it afterwards.'), '3' => __('... delete the old one from the user tables and reload the privileges afterwards.'));
            PMA_display_html_radio('mode', $choices, '4', true);
            unset($choices);
            echo '    </fieldset>' . "\n" . '</fieldset>' . "\n" . '<fieldset id="fieldset_change_copy_user_footer" class="tblFooters">' . "\n" . '    <input type="submit" name="change_copy" value="' . __('Go') . '" />' . "\n" . '</fieldset>' . "\n" . '</form>' . "\n";
        }
    }
} elseif (isset($_REQUEST['adduser'])) {
Esempio n. 4
0
?>
';
    var text_dir = '<?php 
echo PMA_escapeJsString($GLOBALS['text_dir']);
?>
';
    var pma_absolute_uri = '<?php 
echo PMA_escapeJsString($GLOBALS['cfg']['PmaAbsoluteUri']);
?>
';
    var pma_text_default_tab = '<?php 
echo PMA_escapeJsString(PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']));
?>
';
    var pma_text_left_default_tab = '<?php 
echo PMA_escapeJsString(PMA_getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable']));
?>
';

    // for content and navigation frames

    var frame_content = 0;
    var frame_navigation = 0;
    function getFrames() {
<?php 
if ($GLOBALS['text_dir'] === 'ltr') {
    ?>
        frame_content = window.frames[1];
        frame_navigation = window.frames[0];
<?php 
} else {
Esempio n. 5
0
    // definitions used in common.js
    var common_query = '<?php echo PMA_escapeJsString(PMA_generate_common_url('', '', '&'));?>';
    var opendb_url = '<?php echo PMA_escapeJsString($GLOBALS['cfg']['DefaultTabDatabase']); ?>';
    var safari_browser = <?php echo PMA_USR_BROWSER_AGENT == 'SAFARI' ? 'true' : 'false' ?>;
    var querywindow_height = <?php echo PMA_escapeJsString($GLOBALS['cfg']['QueryWindowHeight']); ?>;
    var querywindow_width = <?php echo PMA_escapeJsString($GLOBALS['cfg']['QueryWindowWidth']); ?>;
    var collation_connection = '<?php echo PMA_escapeJsString($GLOBALS['collation_connection']); ?>';
    var lang = '<?php echo PMA_escapeJsString($GLOBALS['lang']); ?>';
    var server = '<?php echo PMA_escapeJsString($GLOBALS['server']); ?>';
    var table = '<?php echo PMA_escapeJsString($GLOBALS['table']); ?>';
    var db    = '<?php echo PMA_escapeJsString($GLOBALS['db']); ?>';
    var token = '<?php echo PMA_escapeJsString($_SESSION[' PMA_token ']); ?>';
    var text_dir = '<?php echo PMA_escapeJsString($GLOBALS['text_dir']); ?>';
    var pma_absolute_uri = '<?php echo PMA_escapeJsString($GLOBALS['cfg']['PmaAbsoluteUri']); ?>';
    var pma_text_default_tab = '<?php echo PMA_escapeJsString(PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable'])); ?>';
    var pma_text_left_default_tab = '<?php echo PMA_escapeJsString(PMA_getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable'])); ?>';

    // for content and navigation frames

    var frame_content = 0;
    var frame_navigation = 0;
    function getFrames() {
<?php if ($GLOBALS['text_dir'] === 'ltr') { ?>
        frame_content = window.frames[1];
        frame_navigation = window.frames[0];
<?php } else { ?>
        frame_content = window.frames[0];
        frame_navigation = window.frames[1];
<?php } ?>
    }
    var onloadCnt = 0;
Esempio n. 6
0
/**
 * display unordered list of tables
 * calls itself recursively if table in given list
 * is a list itself
 *
 * @global  integer the element counter
 * @global  string  html code for '-' image
 * @global  string  html code for '+' image
 * @global  string  html code for self link
 * @param array   $tables         array of tables/tablegroups
 * @param boolean $visible        whether the list is visible or not
 * @param string  $tab_group_full full tab group name
 * @param string  $table_db       db of this table
 */
function PMA_displayTableList($tables, $visible = false, $tab_group_full = '', $table_db = '')
{
    if (!is_array($tables) || count($tables) === 0) {
        return;
    }
    global $element_counter, $img_minus, $img_plus, $href_left;
    $sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
    if ($visible) {
        echo '<ul id="subel' . $element_counter . '">';
    } else {
        echo '<ul id="subel' . $element_counter . '" style="display: none">';
    }
    foreach ($tables as $group => $table) {
        // only allow grouping if the group has more than 1 table
        if (isset($table['is' . $sep . 'group']) && $table['tab' . $sep . 'count'] > 1) {
            $common_url_query = $GLOBALS['common_url_query'] . '&amp;tbl_group=' . urlencode($tab_group_full . $group);
            $element_counter++;
            echo '<li>' . "\n";
            if ($visible && (isset($_REQUEST['tbl_group']) && (strpos($_REQUEST['tbl_group'], $group) === 0 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false) || strpos($GLOBALS['table'], $group) === 0)) {
                printf($href_left, $element_counter, $GLOBALS['common_url_query'] . '&amp;tbl_group=' . $tab_group_full);
                printf($img_minus, $element_counter);
            } else {
                printf($href_left, $element_counter, $common_url_query);
                printf($img_plus, $element_counter);
            }
            echo '</a>';
            ?>
            <a href="index.php?<?php 
            echo $common_url_query;
            ?>
"
                target="_parent"
                onclick="
                    if (! toggle('<?php 
            echo $element_counter;
            ?>
', true))
                        window.parent.goTo('./navigation.php?<?php 
            echo $common_url_query;
            ?>
');
                    window.parent.goTo('./<?php 
            echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query;
            ?>
', 'main');
                    return false;">
                <?php 
            if ($GLOBALS['text_dir'] === 'rtl') {
                echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
            }
            echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep)));
            if ($GLOBALS['text_dir'] === 'ltr') {
                echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> ';
            }
            ?>
            </a>
            <?php 
            unset($table['is' . $sep . 'group']);
            unset($table['tab' . $sep . 'group']);
            unset($table['tab' . $sep . 'count']);
            if ($visible && (isset($_REQUEST['tbl_group']) && (strpos($_REQUEST['tbl_group'], $group) === 0 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false) || strpos($GLOBALS['table'], $group) === 0)) {
                PMA_displayTableList($table, true, $tab_group_full . $group, $table_db);
            } else {
                PMA_displayTableList($table, false, '', $table_db);
            }
            echo '</li>' . "\n";
        } elseif (is_array($table)) {
            // the table was not grouped because it is the only one with its prefix
            while (isset($table['is' . $sep . 'group'])) {
                // get the array with the actual table information
                foreach ($table as $value) {
                    if (is_array($value)) {
                        $table = $value;
                    }
                }
            }
            $link_title = PMA_getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable']);
            // quick access icon next to each table name
            echo '<li>' . "\n";
            echo '<a class="tableicon" title="' . htmlspecialchars($link_title) . ': ' . htmlspecialchars($table['Comment']) . ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')"' . ' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"' . ' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?' . $GLOBALS['common_url_query'] . '&amp;table=' . urlencode($table['Name']) . '&amp;goto=' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '" >';
            $attr = array('id' => 'icon_' . htmlspecialchars($table_db . '.' . $table['Name']));
            if (PMA_Table::isView($table_db, $table['Name'])) {
                echo PMA_getImage('s_views.png', htmlspecialchars($link_title), $attr);
            } else {
                echo PMA_getImage('b_browse.png', htmlspecialchars($link_title), $attr);
            }
            echo '</a>';
            // link for the table name itself
            $href = $GLOBALS['cfg']['DefaultTabTable'] . '?' . $GLOBALS['common_url_query'] . '&amp;table=' . urlencode($table['Name']) . '&amp;pos=0';
            echo '<a href="' . $href . '" title="' . htmlspecialchars(PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment'] . ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows')) . ')"' . ' id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">' . str_replace(' ', '&nbsp;', htmlspecialchars($table['disp_name'])) . '</a>';
            echo '</li>' . "\n";
        }
    }
    echo '</ul>';
}
Esempio n. 7
0
/**
 * DB search optimisation
 *
 * @package PhpMyAdmin
 */
require_once 'libraries/common.inc.php';
require_once 'libraries/common.lib.php';
$db = $_GET['db'];
$table_term = $_GET['table'];
$common_url_query = PMA_generate_common_url($GLOBALS['db']);
$tables_full = PMA_getTableList($db);
$tables_response = array();
foreach ($tables_full as $key => $table) {
    if (strpos($key, $table_term) !== false) {
        $link = '<li class="ajax_table"><a class="tableicon" title="' . htmlspecialchars($link_title) . ': ' . htmlspecialchars($table['Comment']) . ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')"' . ' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"' . ' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table['Name']) . '&amp;goto=' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '" >';
        $attr = array('id' => 'icon_' . htmlspecialchars($table_db . '.' . $table['Name']));
        if (PMA_Table::isView($table_db, $table['Name'])) {
            $link .= PMA_getImage('s_views.png', htmlspecialchars($link_title), $attr);
        } else {
            $link .= PMA_getImage('b_browse.png', htmlspecialchars($link_title), $attr);
        }
        $link .= '</a>';
        // link for the table name itself
        $href = $GLOBALS['cfg']['DefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table['Name']) . '&amp;pos=0';
        $link .= '<a href="' . $href . '" title="' . htmlspecialchars(PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment'] . ' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')') . '" id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">' . str_replace(' ', '&nbsp;', htmlspecialchars($table['disp_name'])) . '</a>';
        $link .= '</li>' . "\n";
        $table['line'] = $link;
        $tables_response[] = $table;
    }
}
PMA_ajaxResponse('', true, array('tables' => $tables_response));
 /**
  * @dataProvider dataProvider
  * @return void
  */
 function testGetTitleForTarget($target, $result)
 {
     $this->assertEquals($result, PMA_getTitleForTarget($target));
 }