Ejemplo n.º 1
1
/**
 * Prints server state traffic information
 *
 * @param PMA_ServerStatusData $ServerStatusData Server status data
 *
 * @return string
 */
function PMA_getHtmlForServerStateTraffic($ServerStatusData)
{
    $hour_factor = 3600 / $ServerStatusData->status['Uptime'];
    $retval = '<table id="serverstatustraffic" class="data noclick">';
    $retval .= '<thead>';
    $retval .= '<tr>';
    $retval .= '<th colspan="2">';
    $retval .= __('Traffic') . '&nbsp;';
    $retval .= PMA_Util::showHint(__('On a busy server, the byte counters may overrun, so those statistics ' . 'as reported by the MySQL server may be incorrect.'));
    $retval .= '</th>';
    $retval .= '<th>&oslash; ' . __('per hour') . '</th>';
    $retval .= '</tr>';
    $retval .= '</thead>';
    $retval .= '<tbody>';
    $retval .= '<tr class="odd">';
    $retval .= '<th class="name">' . __('Received') . '</th>';
    $retval .= '<td class="value">';
    $retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_received'], 3, 1));
    $retval .= '</td>';
    $retval .= '<td class="value">';
    $retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_received'] * $hour_factor, 3, 1));
    $retval .= '</td>';
    $retval .= '</tr>';
    $retval .= '<tr class="even">';
    $retval .= '<th class="name">' . __('Sent') . '</th>';
    $retval .= '<td class="value">';
    $retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_sent'], 3, 1));
    $retval .= '</td>';
    $retval .= '<td class="value">';
    $retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_sent'] * $hour_factor, 3, 1));
    $retval .= '</td>';
    $retval .= '</tr>';
    $retval .= '<tr class="odd">';
    $retval .= '<th class="name">' . __('Total') . '</th>';
    $retval .= '<td class="value">';
    $bytes_received = $ServerStatusData->status['Bytes_received'];
    $bytes_sent = $ServerStatusData->status['Bytes_sent'];
    $retval .= implode(' ', PMA_Util::formatByteDown($bytes_received + $bytes_sent, 3, 1));
    $retval .= '</td>';
    $retval .= '<td class="value">';
    $bytes_received = $ServerStatusData->status['Bytes_received'];
    $bytes_sent = $ServerStatusData->status['Bytes_sent'];
    $retval .= implode(' ', PMA_Util::formatByteDown(($bytes_received + $bytes_sent) * $hour_factor, 3, 1));
    $retval .= '</td>';
    $retval .= '</tr>';
    $retval .= '</tbody>';
    $retval .= '</table>';
    return $retval;
}
Ejemplo n.º 2
1
/**
 * display table header (<table><thead>...</thead><tbody>)
 *
 * @param boolean $db_is_system_schema whether db is information schema or not
 * @param boolean $replication         whether to sho replication status
 *
 * @return string html data
 */
function PMA_tableHeader($db_is_system_schema = false, $replication = false)
{
    $cnt = 0;
    // Let's count the columns...
    if ($db_is_system_schema) {
        $action_colspan = 4;
    } else {
        $action_colspan = 7;
    }
    $html_output = '<table class="data">' . "\n" . '<thead>' . "\n" . '<tr><th></th>' . "\n" . '<th>' . PMA_sortableTableHeader(__('Table'), 'table') . '</th>' . "\n";
    if ($replication) {
        $html_output .= '<th>' . "\n" . '        ' . __('Replication') . "\n" . '</th>';
    }
    $html_output .= '<th colspan="' . $action_colspan . '">' . "\n" . '        ' . __('Action') . "\n" . '</th>' . '<th>' . PMA_sortableTableHeader(__('Rows'), 'records', 'DESC') . PMA_Util::showHint(PMA_sanitize(__('May be approximate. See [doc@faq3-11]FAQ 3.11[/doc].'))) . "\n" . '</th>' . "\n";
    if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
        $html_output .= '<th>' . PMA_sortableTableHeader(__('Type'), 'type') . '</th>' . "\n";
        $cnt++;
        $html_output .= '<th>' . PMA_sortableTableHeader(__('Collation'), 'collation') . '</th>' . "\n";
        $cnt++;
    }
    if ($GLOBALS['is_show_stats']) {
        // larger values are more interesting so default sort order is DESC
        $html_output .= '<th>' . PMA_sortableTableHeader(__('Size'), 'size', 'DESC') . '</th>' . "\n" . '<th>' . PMA_sortableTableHeader(__('Overhead'), 'overhead', 'DESC') . '</th>' . "\n";
        $cnt += 2;
    }
    if ($GLOBALS['cfg']['ShowDbStructureCreation']) {
        // larger values are more interesting so default sort order is DESC
        $html_output .= '<th>' . PMA_sortableTableHeader(__('Creation'), 'creation', 'DESC') . '</th>' . "\n";
        $cnt += 2;
    }
    if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) {
        // larger values are more interesting so default sort order is DESC
        $html_output .= '<th>' . PMA_sortableTableHeader(__('Last update'), 'last_update', 'DESC') . '</th>' . "\n";
        $cnt += 2;
    }
    if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) {
        // larger values are more interesting so default sort order is DESC
        $html_output .= '<th>' . PMA_sortableTableHeader(__('Last check'), 'last_check', 'DESC') . '</th>' . "\n";
        $cnt += 2;
    }
    $html_output .= '</tr>' . "\n";
    $html_output .= '</thead>' . "\n";
    $html_output .= '<tbody>' . "\n";
    $GLOBALS['colspan_for_structure'] = $cnt + $action_colspan + 3;
    return $html_output;
}
Ejemplo n.º 3
0
 /**
  * Sets the import plugin properties.
  * Called in the constructor.
  *
  * @return void
  */
 protected function setProperties()
 {
     $this->_setAnalyze(false);
     if ($GLOBALS['plugin_param'] !== 'table') {
         $this->_setAnalyze(true);
     }
     $generalOptions = parent::setProperties();
     $this->properties->setText('CSV');
     $this->properties->setExtension('csv');
     if ($GLOBALS['plugin_param'] !== 'table') {
         $leaf = new BoolPropertyItem();
         $leaf->setName("col_names");
         $leaf->setText(__('The first line of the file contains the table column names' . ' <i>(if this is unchecked, the first line will become part' . ' of the data)</i>'));
         $generalOptions->addProperty($leaf);
     } else {
         $hint = new PMA_Message(__('If the data in each row of the file is not' . ' in the same order as in the database, list the corresponding' . ' column names here. Column names must be separated by commas' . ' and not enclosed in quotations.'));
         $leaf = new TextPropertyItem();
         $leaf->setName("columns");
         $leaf->setText(__('Column names: ') . PMA_Util::showHint($hint));
         $generalOptions->addProperty($leaf);
     }
     $leaf = new BoolPropertyItem();
     $leaf->setName("ignore");
     $leaf->setText(__('Do not abort on INSERT error'));
     $generalOptions->addProperty($leaf);
 }
Ejemplo n.º 4
0
/**
 * Prints server traffic information
 *
 * @param Object $ServerStatusData An instance of the PMA_ServerStatusData class
 *
 * @return string
 */
function getServerTrafficHtml($ServerStatusData)
{
    $hour_factor = 3600 / $ServerStatusData->status['Uptime'];
    $start_time = PMA_DBI_fetch_value('SELECT UNIX_TIMESTAMP() - ' . $ServerStatusData->status['Uptime']);
    $retval = '<h3>';
    $retval .= sprintf(__('Network traffic since startup: %s'), implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent'], 3, 1)));
    $retval .= '</h3>';
    $retval .= '<p>';
    $retval .= sprintf(__('This MySQL server has been running for %1$s. It started up on %2$s.'), PMA_Util::timespanFormat($ServerStatusData->status['Uptime']), PMA_Util::localisedDate($start_time)) . "\n";
    $retval .= '</p>';
    if ($GLOBALS['server_master_status'] || $GLOBALS['server_slave_status']) {
        $retval .= '<p class="notice">';
        if ($GLOBALS['server_master_status'] && $GLOBALS['server_slave_status']) {
            $retval .= __('This MySQL server works as <b>master</b> and ' . '<b>slave</b> in <b>replication</b> process.');
        } elseif ($GLOBALS['server_master_status']) {
            $retval .= __('This MySQL server works as <b>master</b> ' . 'in <b>replication</b> process.');
        } elseif ($GLOBALS['server_slave_status']) {
            $retval .= __('This MySQL server works as <b>slave</b> ' . 'in <b>replication</b> process.');
        }
        $retval .= ' ';
        $retval .= __('For further information about replication status on the server, ' . 'please visit the <a href="#replication">replication section</a>.');
        $retval .= '</p>';
    }
    /*
     * if the server works as master or slave in replication process,
     * display useful information
     */
    if ($GLOBALS['server_master_status'] || $GLOBALS['server_slave_status']) {
        $retval .= '<hr class="clearfloat" />';
        $retval .= '<h3><a name="replication">';
        $retval .= __('Replication status');
        $retval .= '</a></h3>';
        foreach ($GLOBALS['replication_types'] as $type) {
            if (isset(${"server_{$type}_status"}) && ${"server_{$type}_status"}) {
                PMA_replication_print_status_table($type);
            }
        }
    }
    $retval .= '<table id="serverstatustraffic" class="data noclick">';
    $retval .= '<thead>';
    $retval .= '<tr>';
    $retval .= '<th colspan="2">';
    $retval .= __('Traffic') . '&nbsp;';
    $retval .= PMA_Util::showHint(__('On a busy server, the byte counters may overrun, so those statistics ' . 'as reported by the MySQL server may be incorrect.'));
    $retval .= '</th>';
    $retval .= '<th>&oslash; ' . __('per hour') . '</th>';
    $retval .= '</tr>';
    $retval .= '</thead>';
    $retval .= '<tbody>';
    $retval .= '<tr class="odd">';
    $retval .= '<th class="name">' . __('Received') . '</th>';
    $retval .= '<td class="value">';
    $retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_received'], 3, 1));
    $retval .= '</td>';
    $retval .= '<td class="value">';
    $retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_received'] * $hour_factor, 3, 1));
    $retval .= '</td>';
    $retval .= '</tr>';
    $retval .= '<tr class="even">';
    $retval .= '<th class="name">' . __('Sent') . '</th>';
    $retval .= '<td class="value">';
    $retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_sent'], 3, 1));
    $retval .= '</td>';
    $retval .= '<td class="value"><?php echo';
    $retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_sent'] * $hour_factor, 3, 1));
    $retval .= '</td>';
    $retval .= '</tr>';
    $retval .= '<tr class="odd">';
    $retval .= '<th class="name">' . __('Total') . '</th>';
    $retval .= '<td class="value">';
    $retval .= implode(' ', PMA_Util::formatByteDown($ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent'], 3, 1));
    $retval .= '</td>';
    $retval .= '<td class="value">';
    $retval .= implode(' ', PMA_Util::formatByteDown(($ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent']) * $hour_factor, 3, 1));
    $retval .= '</td>';
    $retval .= '</tr>';
    $retval .= '</tbody>';
    $retval .= '</table>';
    $retval .= '<table id="serverstatusconnections" class="data noclick">';
    $retval .= '<thead>';
    $retval .= '<tr>';
    $retval .= '<th colspan="2">' . __('Connections') . '</th>';
    $retval .= '<th>&oslash; ' . __('per hour') . '</th>';
    $retval .= '<th>%</th>';
    $retval .= '</tr>';
    $retval .= '</thead>';
    $retval .= '<tbody>';
    $retval .= '<tr class="odd">';
    $retval .= '<th class="name">' . __('max. concurrent connections') . '</th>';
    $retval .= '<td class="value">';
    $retval .= PMA_Util::formatNumber($ServerStatusData->status['Max_used_connections'], 0);
    $retval .= '</td>';
    $retval .= '<td class="value">--- </td>';
    $retval .= '<td class="value">--- </td>';
    $retval .= '</tr>';
    $retval .= '<tr class="even">';
    $retval .= '<th class="name">' . __('Failed attempts') . '</th>';
    $retval .= '<td class="value">';
    $retval .= PMA_Util::formatNumber($ServerStatusData->status['Aborted_connects'], 4, 1, true);
    $retval .= '</td>';
    $retval .= '<td class="value">';
    $retval .= PMA_Util::formatNumber($ServerStatusData->status['Aborted_connects'] * $hour_factor, 4, 2, true);
    $retval .= '</td>';
    $retval .= '<td class="value">';
    if ($ServerStatusData->status['Connections'] > 0) {
        $retval .= PMA_Util::formatNumber($ServerStatusData->status['Aborted_connects'] * 100 / $ServerStatusData->status['Connections'], 0, 2, true);
        $retval .= '%';
    } else {
        $retval .= '--- ';
    }
    $retval .= '</td>';
    $retval .= '</tr>';
    $retval .= '<tr class="odd">';
    $retval .= '<th class="name">' . __('Aborted') . '</th>';
    $retval .= '<td class="value">';
    $retval .= PMA_Util::formatNumber($ServerStatusData->status['Aborted_clients'], 4, 1, true);
    $retval .= '</td>';
    $retval .= '<td class="value">';
    $retval .= PMA_Util::formatNumber($ServerStatusData->status['Aborted_clients'] * $hour_factor, 4, 2, true);
    $retval .= '</td>';
    $retval .= '<td class="value">';
    if ($ServerStatusData->status['Connections'] > 0) {
        $retval .= PMA_Util::formatNumber($ServerStatusData->status['Aborted_clients'] * 100 / $ServerStatusData->status['Connections'], 0, 2, true);
        $retval .= '%';
    } else {
        $retval .= '--- ';
    }
    $retval .= '</td>';
    $retval .= '</tr>';
    $retval .= '<tr class="even">';
    $retval .= '<th class="name">' . __('Total') . '</th>';
    $retval .= '<td class="value">';
    $retval .= PMA_Util::formatNumber($ServerStatusData->status['Connections'], 4, 0);
    $retval .= '</td>';
    $retval .= '<td class="value">';
    $retval .= PMA_Util::formatNumber($ServerStatusData->status['Connections'] * $hour_factor, 4, 2);
    $retval .= '</td>';
    $retval .= '<td class="value">';
    $retval .= PMA_Util::formatNumber(100, 0, 2);
    $retval .= '%</td>';
    $retval .= '</tr>';
    $retval .= '</tbody>';
    $retval .= '</table>';
    $url_params = array();
    $show_full_sql = !empty($_REQUEST['full']);
    if ($show_full_sql) {
        $url_params['full'] = 1;
        $full_text_link = 'server_status.php' . PMA_generate_common_url(array(), 'html', '?');
    } else {
        $full_text_link = 'server_status.php' . PMA_generate_common_url(array('full' => 1));
    }
    // This array contains display name and real column name of each
    // sortable column in the table
    $sortable_columns = array(array('column_name' => __('ID'), 'order_by_field' => 'Id'), array('column_name' => __('User'), 'order_by_field' => 'User'), array('column_name' => __('Host'), 'order_by_field' => 'Host'), array('column_name' => __('Database'), 'order_by_field' => 'db'), array('column_name' => __('Command'), 'order_by_field' => 'Command'), array('column_name' => __('Time'), 'order_by_field' => 'Time'), array('column_name' => __('Status'), 'order_by_field' => 'State'), array('column_name' => __('SQL query'), 'order_by_field' => 'Info'));
    $sortable_columns_count = count($sortable_columns);
    if (PMA_DRIZZLE) {
        $sql_query = "SELECT\n                p.id       AS Id,\n                p.username AS User,\n                p.host     AS Host,\n                p.db       AS db,\n                p.command  AS Command,\n                p.time     AS Time,\n                p.state    AS State,\n                " . ($show_full_sql ? 's.query' : 'left(p.info, ' . (int) $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] . ')') . " AS Info\n            FROM data_dictionary.PROCESSLIST p\n                " . ($show_full_sql ? 'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id' : '');
        if (!empty($_REQUEST['order_by_field']) && !empty($_REQUEST['sort_order'])) {
            $sql_query .= ' ORDER BY p.' . $_REQUEST['order_by_field'] . ' ' . $_REQUEST['sort_order'];
        }
    } else {
        $sql_query = $show_full_sql ? 'SHOW FULL PROCESSLIST' : 'SHOW PROCESSLIST';
        if (!empty($_REQUEST['order_by_field']) && !empty($_REQUEST['sort_order'])) {
            $sql_query = 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` ORDER BY `' . $_REQUEST['order_by_field'] . '` ' . $_REQUEST['sort_order'];
        }
    }
    $result = PMA_DBI_query($sql_query);
    /**
     * Displays the page
     */
    $retval .= '<table id="tableprocesslist" class="data clearfloat noclick sortable">';
    $retval .= '<thead>';
    $retval .= '<tr>';
    $retval .= '<th>' . __('Processes') . '</th>';
    foreach ($sortable_columns as $column) {
        $is_sorted = !empty($_REQUEST['order_by_field']) && !empty($_REQUEST['sort_order']) && $_REQUEST['order_by_field'] == $column['order_by_field'];
        $column['sort_order'] = 'ASC';
        if ($is_sorted && $_REQUEST['sort_order'] === 'ASC') {
            $column['sort_order'] = 'DESC';
        }
        if ($is_sorted) {
            if ($_REQUEST['sort_order'] == 'ASC') {
                $asc_display_style = 'inline';
                $desc_display_style = 'none';
            } elseif ($_REQUEST['sort_order'] == 'DESC') {
                $desc_display_style = 'inline';
                $asc_display_style = 'none';
            }
        }
        $retval .= '<th>';
        $retval .= '<a href="server_status.php' . PMA_generate_common_url($column) . '" ';
        if ($is_sorted) {
            $retval .= 'onmouseout="$(\'.soimg\').toggle()" ' . 'onmouseover="$(\'.soimg\').toggle()"';
        }
        $retval .= '>';
        $retval .= $column['column_name'];
        if ($is_sorted) {
            $retval .= '<img class="icon ic_s_desc soimg" alt="' . __('Descending') . '" title="" src="themes/dot.gif" ' . 'style="display: ' . $desc_display_style . '" />';
            $retval .= '<img class="icon ic_s_asc soimg hide" alt="' . __('Ascending') . '" title="" src="themes/dot.gif" ' . 'style="display: ' . $asc_display_style . '" />';
        }
        $retval .= '</a>';
        if (!PMA_DRIZZLE && 0 === --$sortable_columns_count) {
            $retval .= '<a href="' . $full_text_link . '">';
            if ($show_full_sql) {
                $retval .= PMA_Util::getImage('s_partialtext.png', __('Truncate Shown Queries'));
            } else {
                $retval .= PMA_Util::getImage('s_fulltext.png', __('Show Full Queries'));
            }
            $retval .= '</a>';
        }
        $retval .= '</th>';
    }
    $retval .= '</tr>';
    $retval .= '</thead>';
    $retval .= '<tbody>';
    $odd_row = true;
    while ($process = PMA_DBI_fetch_assoc($result)) {
        // Array keys need to modify due to the way it has used
        // to display column values
        if (!empty($_REQUEST['order_by_field']) && !empty($_REQUEST['sort_order'])) {
            foreach (array_keys($process) as $key) {
                $new_key = ucfirst(strtolower($key));
                $process[$new_key] = $process[$key];
                unset($process[$key]);
            }
        }
        $url_params['kill'] = $process['Id'];
        $kill_process = 'server_status.php' . PMA_generate_common_url($url_params);
        $retval .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">';
        $retval .= '<td><a href="' . $kill_process . '">' . __('Kill') . '</a></td>';
        $retval .= '<td class="value">' . $process['Id'] . '</td>';
        $retval .= '<td>' . htmlspecialchars($process['User']) . '</td>';
        $retval .= '<td>' . htmlspecialchars($process['Host']) . '</td>';
        $retval .= '<td>' . (!isset($process['db']) || !strlen($process['db']) ? '<i>' . __('None') . '</i>' : htmlspecialchars($process['db'])) . '</td>';
        $retval .= '<td>' . htmlspecialchars($process['Command']) . '</td>';
        $retval .= '<td class="value">' . $process['Time'] . '</td>';
        $retval .= '<td>' . (empty($process['State']) ? '---' : $process['State']) . '</td>';
        $retval .= '<td>';
        if (empty($process['Info'])) {
            $retval .= '---';
        } else {
            if (!$show_full_sql && strlen($process['Info']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
                $retval .= htmlspecialchars(substr($process['Info'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]';
            } else {
                $retval .= PMA_SQP_formatHtml(PMA_SQP_parse($process['Info']));
            }
        }
        $retval .= '</td>';
        $retval .= '</tr>';
        $odd_row = !$odd_row;
    }
    $retval .= '</tbody>';
    $retval .= '</table>';
    return $retval;
}
Ejemplo n.º 5
0
/**
 * returns HTML for TableInfoForm
 *
 * @param int $hostname_length Selected hostname length
 *
 * @return String HTML code
 */
function PMA_getHtmlForTableInfoForm($hostname_length)
{
    $html = '        <option value="hosttable"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'hosttable' ? ' selected="selected"' : '') . '>' . __('Use Host Table') . '</option>' . '        <option value="userdefined"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'userdefined' ? ' selected="selected"' : '') . '>' . __('Use text field:') . '</option>' . '    </select>' . '</span>' . '<input type="text" name="hostname" maxlength="' . $hostname_length . '" value="' . (isset($_REQUEST['hostname']) ? $_REQUEST['hostname'] : '') . '" title="' . __('Host') . '" onchange="pred_hostname.value = \'userdefined\';" />' . PMA_Util::showHint(__('When Host table is used, this field is ignored ' . 'and values stored in Host table are used instead.')) . '</div>' . '<div class="item">' . '<label for="select_pred_password">' . '    ' . __('Password:'******'</label>' . '<span class="options">' . '    <select name="pred_password" id="select_pred_password" title="' . __('Password') . '"' . '            onchange="if (this.value == \'none\') ' . '{ pma_pw.value = \'\'; pma_pw2.value = \'\'; } ' . 'else if (this.value == \'userdefined\') ' . '{ pma_pw.focus(); pma_pw.select(); }">' . '        <option value="none"';
    if (isset($_REQUEST['username'])) {
        $html .= '  selected="selected"';
    }
    $html .= '>' . __('No Password') . '</option>' . '        <option value="userdefined"' . (isset($_REQUEST['username']) ? '' : ' selected="selected"') . '>' . __('Use text field:') . '</option>' . '    </select>' . '</span>' . '<input type="password" id="text_pma_pw" name="pma_pw" title="' . __('Password') . '" onchange="pred_password.value = \'userdefined\';" />' . '</div>' . '<div class="item">' . '<label for="text_pma_pw2">' . '    ' . __('Re-type:') . '</label>' . '<span class="options">&nbsp;</span>' . '<input type="password" name="pma_pw2" id="text_pma_pw2" title="' . __('Re-type') . '" onchange="pred_password.value = \'userdefined\';" />' . '</div>' . '<div class="item">' . '<label for="button_generate_password">' . '    ' . __('Generate Password:'******'</label>' . '<span class="options">' . '    <input type="button" class="button" ' . 'id="button_generate_password" value="' . __('Generate') . '" onclick="suggestPassword(this.form)" />' . '</span>' . '<input type="text" name="generated_pw" id="generated_pw" />' . '</div>' . '</fieldset>';
    $html .= '<fieldset id="fieldset_user_privtable_footer" class="tblFooters">' . '    <input type="hidden" name="adduser_submit" value="1" />' . '    <input type="submit" id="adduser_submit" value="' . __('Go') . '" />' . '</fieldset>';
    return $html;
}
Ejemplo n.º 6
0
if (count($columns) > 0) {
    foreach ($columns as $row) {
        $save_row[] = $row;
    }
    $saved_row_cnt  = count($save_row);
    ?>
    <fieldset>
    <legend><?php echo __('Relations'); ?></legend>

    <table>
    <tr><th><?php echo __('Column'); ?></th>
    <?php
    if ($cfgRelation['relwork']) {
        echo '<th>' . __('Internal relation');
        if (PMA_Util::isForeignKeySupported($tbl_storage_engine)) {
            echo PMA_Util::showHint(__('An internal relation is not necessary when a corresponding FOREIGN KEY relation exists.'));
        }
        echo '</th>';
    }
    if (PMA_Util::isForeignKeySupported($tbl_storage_engine)) {
        // this does not have to be translated, it's part of the MySQL syntax
        echo '<th colspan="2">' . __('Foreign key constraint') . ' (' . $tbl_storage_engine . ')';
        echo '</th>';
    }
    ?>
    </tr>
    <?php
    $odd_row = true;
    for ($i = 0; $i < $saved_row_cnt; $i++) {
        $myfield = $save_row[$i]['Field'];
        // Use an md5 as array index to avoid having special characters in the name atttibure (see bug #1746964 )
Ejemplo n.º 7
0
/**
 * Function to get html for Foreign key form
 *
 * @param array  $columns            columns
 * @param array  $existrel_foreign   db, table, column
 * @param string $db                 current database
 * @param string $tbl_storage_engine table storage engine
 * @param array  $options_array      options array
 *
 * @return string
 */
function PMA_getHtmlForForeignKeyForm($columns, $existrel_foreign, $db, $tbl_storage_engine, $options_array)
{
    $html_output = '<fieldset>' . '<legend>' . __('Foreign key constraints') . '</legend>' . '<table id="foreign_keys" class="relationalTable">';
    $html_output .= '<tr><th>' . __('Actions') . '</th>';
    $html_output .= '<th>' . __('Constraint properties') . '</th>' . '<th>' . __('Column') . PMA_Util::showHint(__('Only columns with index will be displayed. You can define an' . ' index below.')) . '</th>';
    $html_output .= '<th colspan="3">' . __('Foreign key constraint') . ' (' . $tbl_storage_engine . ')';
    $html_output .= '</th></tr>';
    $odd_row = true;
    $i = 0;
    foreach ($existrel_foreign as $key => $one_key) {
        $html_output .= PMA_getHtmlForForeignKeyRow($one_key, $odd_row, $columns, $i++, $options_array, $tbl_storage_engine, $db);
        $odd_row = !$odd_row;
    }
    $html_output .= PMA_getHtmlForForeignKeyRow(array(), $odd_row, $columns, $i++, $options_array, $tbl_storage_engine, $db);
    $html_output .= '<tr>' . '<td colspan="5"><a class="formelement clearfloat' . ' add_foreign_key" href="">' . __('+ Add constraint') . '</td>';
    $html_output .= '</tr>';
    $html_output .= '</table>' . '</fieldset>';
    return $html_output;
}
Ejemplo n.º 8
0
/**
 * Print code to add a replication slave user to the master
 *
 * @return void
 */
function PMA_replication_gui_master_addslaveuser()
{
    list($username_length, $hostname_length) = PMA_replication_get_username_hostname_length();
    if (isset($GLOBALS['username']) && strlen($GLOBALS['username']) === 0) {
        $GLOBALS['pred_username'] = '******';
    }
    echo '<div id="master_addslaveuser_gui">';
    echo '<form autocomplete="off" method="post" action="server_privileges.php" onsubmit="return checkAddUser(this);">';
    echo PMA_generate_common_hidden_inputs('', '');
    echo '<fieldset id="fieldset_add_user_login">' . '<legend>' . __('Add slave replication user') . '</legend>' . '<input type="hidden" name="grant_count" value="25" />' . '<input type="hidden" name="createdb" id="createdb_0" value="0" />' . '<input id="checkbox_Repl_slave_priv" type="hidden" title="Needed for the replication slaves." value="Y" name="Repl_slave_priv"/>' . '<input id="checkbox_Repl_client_priv" type="hidden" title="Needed for the replication slaves." value="Y" name="Repl_client_priv"/>' . '' . '<input type="hidden" name="sr_take_action" value="true" />' . '<div class="item">' . '<label for="select_pred_username">' . '    ' . __('User name') . ':' . '</label>' . '<span class="options">' . '    <select name="pred_username" id="select_pred_username" title="' . __('User name') . '"' . '        onchange="if (this.value == \'any\') { username.value = \'\'; } else if (this.value == \'userdefined\') { username.focus(); username.select(); }">' . '        <option value="any"' . (isset($GLOBALS['pred_username']) && $GLOBALS['pred_username'] == 'any' ? ' selected="selected"' : '') . '>' . __('Any user') . '</option>' . '        <option value="userdefined"' . (!isset($GLOBALS['pred_username']) || $GLOBALS['pred_username'] == 'userdefined' ? ' selected="selected"' : '') . '>' . __('Use text field') . ':</option>' . '    </select>' . '</span>' . '<input type="text" name="username" maxlength="' . $username_length . '" title="' . __('User name') . '"' . (empty($GLOBALS['username']) ? '' : ' value="' . (isset($GLOBALS['new_username']) ? $GLOBALS['new_username'] : $GLOBALS['username']) . '"') . ' onchange="pred_username.value = \'userdefined\';" />' . '</div>' . '<div class="item">' . '<label for="select_pred_hostname">' . '    ' . __('Host') . ':' . '</label>' . '<span class="options">' . '    <select name="pred_hostname" id="select_pred_hostname" title="' . __('Host') . '"';
    $_current_user = PMA_DBI_fetch_value('SELECT USER();');
    if (!empty($_current_user)) {
        $thishost = str_replace("'", '', substr($_current_user, strrpos($_current_user, '@') + 1));
        if ($thishost == 'localhost' || $thishost == '127.0.0.1') {
            unset($thishost);
        }
    }
    echo '    onchange="if (this.value == \'any\') { hostname.value = \'%\'; } else if (this.value == \'localhost\') { hostname.value = \'localhost\'; } ' . (empty($thishost) ? '' : 'else if (this.value == \'thishost\') { hostname.value = \'' . addslashes(htmlspecialchars($thishost)) . '\'; } ') . 'else if (this.value == \'hosttable\') { hostname.value = \'\'; } else if (this.value == \'userdefined\') { hostname.focus(); hostname.select(); }">' . "\n";
    unset($_current_user);
    // when we start editing a user, $GLOBALS['pred_hostname'] is not defined
    if (!isset($GLOBALS['pred_hostname']) && isset($GLOBALS['hostname'])) {
        switch (strtolower($GLOBALS['hostname'])) {
            case 'localhost':
            case '127.0.0.1':
                $GLOBALS['pred_hostname'] = 'localhost';
                break;
            case '%':
                $GLOBALS['pred_hostname'] = 'any';
                break;
            default:
                $GLOBALS['pred_hostname'] = 'userdefined';
                break;
        }
    }
    echo '        <option value="any"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'any' ? ' selected="selected"' : '') . '>' . __('Any host') . '</option>' . '        <option value="localhost"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'localhost' ? ' selected="selected"' : '') . '>' . __('Local') . '</option>';
    if (!empty($thishost)) {
        echo '        <option value="thishost"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'thishost' ? ' selected="selected"' : '') . '>' . __('This Host') . '</option>';
    }
    unset($thishost);
    echo '        <option value="hosttable"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'hosttable' ? ' selected="selected"' : '') . '>' . __('Use Host Table') . '</option>' . '        <option value="userdefined"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'userdefined' ? ' selected="selected"' : '') . '>' . __('Use text field') . ':</option>' . '    </select>' . '</span>' . '<input type="text" name="hostname" maxlength="' . $hostname_length . '" value="' . (isset($GLOBALS['hostname']) ? $GLOBALS['hostname'] : '') . '" title="' . __('Host') . '" onchange="pred_hostname.value = \'userdefined\';" />' . PMA_Util::showHint(__('When Host table is used, this field is ignored and values stored in Host table are used instead.')) . '</div>' . '<div class="item">' . '<label for="select_pred_password">' . '    ' . __('Password') . ':' . '</label>' . '<span class="options">' . '    <select name="pred_password" id="select_pred_password" title="' . __('Password') . '"' . '            onchange="if (this.value == \'none\') { pma_pw.value = \'\'; pma_pw2.value = \'\'; } else if (this.value == \'userdefined\') { pma_pw.focus(); pma_pw.select(); }">' . '        <option value="none"';
    if (isset($GLOBALS['username'])) {
        echo '  selected="selected"';
    }
    echo '>' . __('No Password') . '</option>' . '        <option value="userdefined"' . (isset($GLOBALS['username']) ? '' : ' selected="selected"') . '>' . __('Use text field') . ':</option>' . '    </select>' . '</span>' . '<input type="password" id="text_pma_pw" name="pma_pw" title="' . __('Password') . '" onchange="pred_password.value = \'userdefined\';" />' . '</div>' . '<div class="item">' . '<label for="text_pma_pw2">' . '    ' . __('Re-type') . ':' . '</label>' . '<span class="options">&nbsp;</span>' . '<input type="password" name="pma_pw2" id="text_pma_pw2" title="' . __('Re-type') . '" onchange="pred_password.value = \'userdefined\';" />' . '</div>' . '<div class="item">' . '<label for="button_generate_password">' . '    ' . __('Generate Password') . ':' . '</label>' . '<span class="options">' . '    <input type="button" class="button" id="button_generate_password" value="' . __('Generate') . '" onclick="suggestPassword(this.form)" />' . '</span>' . '<input type="text" name="generated_pw" id="generated_pw" />' . '</div>' . '</fieldset>';
    echo '<fieldset id="fieldset_user_privtable_footer" class="tblFooters">' . '    <input type="hidden" name="adduser_submit" value="1" />' . '    <input type="submit" id="adduser_submit" value="' . __('Go') . '" />' . '</fieldset>';
    echo '</form>';
    echo '</div>';
}
/**
 * Function to get header cells
 *
 * @param bool       $is_backup  whether backup or not
 * @param array|null $columnMeta column meta data
 * @param bool       $mimework   whether mimework or not
 * @param string     $db         current database
 * @param string     $table      current table
 *
 * @return array
 */
function PMA_getHeaderCells($is_backup, $columnMeta, $mimework, $db, $table)
{
    $header_cells = array();
    $header_cells[] = __('Name');
    $header_cells[] = __('Type') . PMA_Util::showMySQLDocu('data-types');
    $header_cells[] = __('Length/Values') . PMA_Util::showHint(__('If column type is "enum" or "set", please enter the values using' . ' this format: \'a\',\'b\',\'c\'…<br />If you ever need to put' . ' a backslash ("\\") or a single quote ("\'") amongst those' . ' values, precede it with a backslash (for example \'\\\\xyz\'' . ' or \'a\\\'b\').'));
    $header_cells[] = __('Default') . PMA_Util::showHint(__('For default values, please enter just a single value,' . ' without backslash escaping or quotes, using this format: a'));
    $header_cells[] = __('Collation');
    $header_cells[] = __('Attributes');
    $header_cells[] = __('Null');
    // We could remove this 'if' and let the key information be shown and
    // editable. However, for this to work, structure.lib.php must be modified
    // to use the key fields, as tbl_addfield does.
    if (!$is_backup) {
        $header_cells[] = __('Index');
    }
    $header_cells[] = '<abbr title="AUTO_INCREMENT">A_I</abbr>';
    $header_cells[] = __('Comments');
    if (isset($columnMeta)) {
        $header_cells[] = __('Move column');
    }
    if ($mimework && $GLOBALS['cfg']['BrowseMIME']) {
        $header_cells[] = __('MIME type');
        $header_link = '<a href="transformation_overview.php?' . PMA_URL_getCommon($db, $table) . '#%s" title="' . __('List of available transformations and their options') . '" target="_blank">%s</a>';
        $transformations_hint = PMA_Util::showHint(__('Please enter the values for transformation options using this' . ' format: \'a\', 100, b,\'c\'…<br />If you ever need to put' . ' a backslash ("\\") or a single quote ("\'") amongst those' . ' values, precede it with a backslash (for example \'\\\\xyz\'' . ' or \'a\\\'b\').'));
        $header_cells[] = sprintf($header_link, 'transformation', __('Browser display transformation'));
        $header_cells[] = __('Browser display transformation options') . $transformations_hint;
        $header_cells[] = sprintf($header_link, 'input_transformation', __('Input transformation'));
        $header_cells[] = __('Input transformation options') . $transformations_hint;
    }
    return $header_cells;
}
Ejemplo n.º 10
0
    // end while over tables
}
// end if
// Now find out the columns of our $table
// need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli
$columns = PMA_DBI_get_columns($db, $table);
if (count($columns) > 0) {
    foreach ($columns as $row) {
        $save_row[] = $row;
    }
    $saved_row_cnt = count($save_row);
    $html_output .= '<fieldset>' . '<legend>' . __('Relations') . '</legend>' . '<table>' . '<tr><th>' . __('Column') . '</th>';
    if ($cfgRelation['relwork']) {
        $html_output .= '<th>' . __('Internal relation');
        if (PMA_Util::isForeignKeySupported($tbl_storage_engine)) {
            $html_output .= PMA_Util::showHint(__('An internal relation is not necessary when a corresponding' . ' FOREIGN KEY relation exists.'));
        }
        $html_output .= '</th>';
    }
    if (PMA_Util::isForeignKeySupported($tbl_storage_engine)) {
        // this does not have to be translated, it's part of the MySQL syntax
        $html_output .= '<th colspan="2">' . __('Foreign key constraint') . ' (' . $tbl_storage_engine . ')';
        $html_output .= '</th>';
    }
    $html_output .= '</tr>';
    $odd_row = true;
    for ($i = 0; $i < $saved_row_cnt; $i++) {
        $myfield = $save_row[$i]['Field'];
        // Use an md5 as array index to avoid having special characters
        // in the name atttibure (see bug #1746964 )
        $myfield_md5 = md5($myfield);
Ejemplo n.º 11
0
 /**
  * returns as HTML table of the engine's server variables
  *
  * @return string The table that was generated based on the retrieved
  *                information
  */
 function getHtmlVariables()
 {
     $odd_row = false;
     $ret = '';
     foreach ($this->getVariablesStatus() as $details) {
         $ret .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">' . "\n" . '    <td>' . "\n";
         if (!empty($details['desc'])) {
             $ret .= '        ' . PMA_Util::showHint($details['desc']) . "\n";
         }
         $ret .= '    </td>' . "\n" . '    <th>' . htmlspecialchars($details['title']) . '</th>' . "\n" . '    <td class="value">';
         switch ($details['type']) {
             case PMA_ENGINE_DETAILS_TYPE_SIZE:
                 $parsed_size = $this->resolveTypeSize($details['value']);
                 $ret .= $parsed_size[0] . '&nbsp;' . $parsed_size[1];
                 unset($parsed_size);
                 break;
             case PMA_ENGINE_DETAILS_TYPE_NUMERIC:
                 $ret .= PMA_Util::formatNumber($details['value']) . ' ';
                 break;
             default:
                 $ret .= htmlspecialchars($details['value']) . '   ';
         }
         $ret .= '</td>' . "\n" . '</tr>' . "\n";
         $odd_row = !$odd_row;
     }
     if (!$ret) {
         $ret = '<p>' . "\n" . '    ' . __('There is no detailed status information available for this storage engine.') . "\n" . '</p>' . "\n";
     } else {
         $ret = '<table class="data">' . "\n" . $ret . '</table>' . "\n";
     }
     return $ret;
 }
 /**
  * Tests for PMA_getHtmlForIndexForm() method.
  *
  * @return void
  * @test
  */
 public function testPMAGetHtmlForIndexForm()
 {
     $fields = array("field_name" => "field_type");
     $index = new PMA_Index();
     $form_params = array('db' => 'db', 'table' => 'table', 'create_index' => 1);
     $add_fields = 3;
     $html = PMA_getHtmlForIndexForm($fields, $index, $form_params, $add_fields);
     //PMA_URL_getHiddenInputs
     $this->assertContains(PMA_URL_getHiddenInputs($form_params), $html);
     //Index name
     $this->assertContains(__('Index name:'), $html);
     $doc_html = PMA_Util::showHint(PMA_Message::notice(__('"PRIMARY" <b>must</b> be the name of' . ' and <b>only of</b> a primary key!')));
     $this->assertContains($doc_html, $html);
     //Index name
     $this->assertContains(__('Index name:'), $html);
     $this->assertContains(PMA_Util::showMySQLDocu('ALTER_TABLE'), $html);
     //generateIndexSelector
     $this->assertContains($index->generateIndexSelector(), $html);
     //items
     $this->assertContains(__('Column'), $html);
     $this->assertContains(__('Size'), $html);
     $this->assertContains(sprintf(__('Add %s column(s) to index'), 1), $html);
     //$field_name & $field_type
     $this->assertContains("field_name", $html);
     $this->assertContains("field_type", $html);
 }
Ejemplo n.º 13
0
/**
 * Prints html with monitor
 *
 * @return void
 */
function printMonitor()
{
    global $server_status, $server_db_isLocal;

?>
    <div class="tabLinks" style="display:none;">
        <a href="#pauseCharts">
            <?php echo PMA_Util::getImage('play.png'); ?>
            <?php echo __('Start Monitor'); ?>
        </a>
        <a href="#settingsPopup" class="popupLink" style="display:none;">
            <?php echo PMA_Util::getImage('s_cog.png'); ?>
            <?php echo __('Settings'); ?>
        </a>
        <?php
        if (! PMA_DRIZZLE) {
            ?>
        <a href="#monitorInstructionsDialog">
            <?php echo PMA_Util::getImage('b_help.png'); ?>
            <?php echo __('Instructions/Setup'); ?>
        </a>
        <?php
        }
        ?>
        <a href="#endChartEditMode" style="display:none;">
            <?php echo PMA_Util::getImage('s_okay.png'); ?>
            <?php echo __('Done rearranging/editing charts'); ?>
        </a>
    </div>

    <div class="popupContent settingsPopup">
        <a href="#addNewChart">
            <?php echo PMA_Util::getImage('b_chart.png'); ?>
            <?php echo __('Add chart'); ?>
        </a>
        <a href="#rearrangeCharts"><?php echo PMA_Util::getImage('b_tblops.png'); ?><?php echo __('Rearrange/edit charts'); ?></a>
        <div class="clearfloat paddingtop"></div>
        <div class="floatleft">
            <?php
            echo __('Refresh rate') . '<br />';
            echo PMA_getRefreshList('gridChartRefresh', 5, Array(2, 3, 4, 5, 10, 20, 40, 60, 120, 300, 600, 1200));
        ?><br />
        </div>
        <div class="floatleft">
            <?php echo __('Chart columns'); ?> <br />
            <select name="chartColumns">
                <option>1</option>
                <option>2</option>
                <option>3</option>
                <option>4</option>
                <option>5</option>
                <option>6</option>
                <option>7</option>
                <option>8</option>
                <option>9</option>
                <option>10</option>
            </select>
        </div>

        <div class="clearfloat paddingtop">
            <b><?php echo __('Chart arrangement'); ?></b> <?php echo PMA_Util::showHint(__('The arrangement of the charts is stored to the browsers local storage. You may want to export it if you have a complicated set up.')); ?><br/>
        <a href="#importMonitorConfig"><?php echo __('Import'); ?></a>&nbsp;&nbsp;<a href="#exportMonitorConfig"><?php echo __('Export'); ?></a>&nbsp;&nbsp;<a href="#clearMonitorConfig"><?php echo __('Reset to default'); ?></a>
        </div>
    </div>

    <div id="monitorInstructionsDialog" title="<?php echo __('Monitor Instructions'); ?>" style="display:none;">
        <?php echo __('The phpMyAdmin Monitor can assist you in optimizing the server configuration and track down time intensive queries. For the latter you will need to set log_output to \'TABLE\' and have either the slow_query_log or general_log enabled. Note however, that the general_log produces a lot of data and increases server load by up to 15%'); ?>
    <?php if (PMA_MYSQL_INT_VERSION < 50106) { ?>
        <p>
        <?php echo PMA_Util::getImage('s_attention.png'); ?>
        <?php
            echo __('Unfortunately your Database server does not support logging to table, which is a requirement for analyzing the database logs with phpMyAdmin. Logging to table is supported by MySQL 5.1.6 and onwards. You may still use the server charting features however.');
        ?>
        </p>
    <?php
    } else {
    ?>
        <p></p>
        <img class="ajaxIcon" src="<?php echo $GLOBALS['pmaThemeImage']; ?>ajax_clock_small.gif" alt="Loading" />
        <div class="ajaxContent"></div>
        <div class="monitorUse" style="display:none;">
            <p></p>
            <?php
                echo '<strong>';
                echo __('Using the monitor:');
                echo '</strong><p>';
                echo __('Your browser will refresh all displayed charts in a regular interval. You may add charts and change the refresh rate under \'Settings\', or remove any chart using the cog icon on each respective chart.');
                echo '</p><p>';
                echo __('To display queries from the logs, select the relevant time span on any chart by holding down the left mouse button and panning over the chart. Once confirmed, this will load a table of grouped queries, there you may click on any occuring SELECT statements to further analyze them.');
                echo '</p>';
            ?>
            <p>
            <?php echo PMA_Util::getImage('s_attention.png'); ?>
            <?php
                echo '<strong>';
                echo __('Please note:');
                echo '</strong><br />';
                echo __('Enabling the general_log may increase the server load by 5-15%. Also be aware that generating statistics from the logs is a load intensive task, so it is advisable to select only a small time span and to disable the general_log and empty its table once monitoring is not required any more.');
            ?>
            </p>
        </div>
    <?php
    }
    ?>
    </div>

    <div id="addChartDialog" title="<?php echo __('Add chart'); ?>" style="display:none;">
        <div id="tabGridVariables">
            <p><input type="text" name="chartTitle" value="<?php echo __('Chart Title'); ?>" /></p>

            <input type="radio" name="chartType" value="preset" id="chartPreset" />
            <label for="chartPreset"><?php echo __('Preset chart'); ?></label>
            <select name="presetCharts"></select><br/>

            <input type="radio" name="chartType" value="variable" id="chartStatusVar" checked="checked" />
            <label for="chartStatusVar"><?php echo __('Status variable(s)'); ?></label><br/>
            <div id="chartVariableSettings">
                <label for="chartSeries"><?php echo __('Select series:'); ?></label><br />
                <select id="chartSeries" name="varChartList" size="1">
                    <option><?php echo __('Commonly monitored'); ?></option>
                    <option>Processes</option>
                    <option>Questions</option>
                    <option>Connections</option>
                    <option>Bytes_sent</option>
                    <option>Bytes_received</option>
                    <option>Threads_connected</option>
                    <option>Created_tmp_disk_tables</option>
                    <option>Handler_read_first</option>
                    <option>Innodb_buffer_pool_wait_free</option>
                    <option>Key_reads</option>
                    <option>Open_tables</option>
                    <option>Select_full_join</option>
                    <option>Slow_queries</option>
                </select><br />
                <label for="variableInput"><?php echo __('or type variable name:'); ?> </label>
                <input type="text" name="variableInput" id="variableInput" />
                <p></p>
                <input type="checkbox" name="differentialValue" id="differentialValue" value="differential" checked="checked" />
                <label for="differentialValue"><?php echo __('Display as differential value'); ?></label><br />
                <input type="checkbox" id="useDivisor" name="useDivisor" value="1" />
                <label for="useDivisor"><?php echo __('Apply a divisor'); ?></label>
                <span class="divisorInput" style="display:none;">
                    <input type="text" name="valueDivisor" size="4" value="1" />
                    (<a href="#kibDivisor"><?php echo __('KiB'); ?></a>, <a href="#mibDivisor"><?php echo __('MiB'); ?></a>)
                </span><br />

                <input type="checkbox" id="useUnit" name="useUnit" value="1" />
                <label for="useUnit"><?php echo __('Append unit to data values'); ?></label>

                <span class="unitInput" style="display:none;">
                    <input type="text" name="valueUnit" size="4" value="" />
                </span>
                <p>
                    <a href="#submitAddSeries"><b><?php echo __('Add this series'); ?></b></a>
                    <span id="clearSeriesLink" style="display:none;">
                       | <a href="#submitClearSeries"><?php echo __('Clear series'); ?></a>
                    </span>
                </p>
                <?php echo __('Series in Chart:'); ?><br/>
                <span id="seriesPreview">
                <i><?php echo __('None'); ?></i>
                </span>
            </div>
        </div>
    </div>

    <!-- For generic use -->
    <div id="emptyDialog" title="Dialog" style="display:none;">
    </div>

    <?php
    if (! PMA_DRIZZLE) {
    ?>
    <div id="logAnalyseDialog" title="<?php echo __('Log statistics'); ?>" style="display:none;">
        <p> <?php echo __('Selected time range:'); ?>
        <input type="text" name="dateStart" class="datetimefield" value="" /> -
        <input type="text" name="dateEnd" class="datetimefield" value="" /></p>
        <input type="checkbox" id="limitTypes" value="1" checked="checked" />
        <label for="limitTypes">
            <?php echo __('Only retrieve SELECT,INSERT,UPDATE and DELETE Statements'); ?>
        </label>
        <br/>
        <input type="checkbox" id="removeVariables" value="1" checked="checked" />
        <label for="removeVariables">
            <?php echo __('Remove variable data in INSERT statements for better grouping'); ?>
        </label>

        <?php
        echo '<p>';
        echo __('Choose from which log you want the statistics to be generated from.');
        echo '</p><p>';
        echo __('Results are grouped by query text.');
        echo '</p>';
        ?>
    </div>

    <div id="queryAnalyzerDialog" title="<?php echo __('Query analyzer'); ?>" style="display:none;">
        <textarea id="sqlquery"> </textarea>
        <p></p>
        <div class="placeHolder"></div>
    </div>
    <?php
    }
    ?>

    <table class="clearfloat" id="chartGrid">

    </table>
    <div id="logTable">
        <br/>
    </div>

    <script type="text/javascript">
        variableNames = [ <?php
    $i=0;
    foreach ($server_status as $name=>$value) {
        if (is_numeric($value)) {
            if ($i++ > 0) {
                echo ", ";
            }
            echo "'" . $name . "'";
        }
    }
    ?> ];
    </script>
<?php
}
Ejemplo n.º 14
0
 /**
  * Tests for displayFormAction()
  *
  * @return void
  * @test
  */
 public function testDisplayFormAction()
 {
     $table = $this->getMockBuilder('PMA_Table')->disableOriginalConstructor()->getMock();
     $table->expects($this->any())->method('getStatusInfo')->will($this->returnValue(""));
     $table->expects($this->any())->method('isView')->will($this->returnValue(false));
     $table->expects($this->any())->method('getNameAndTypeOfTheColumns')->will($this->returnValue(array("field_name" => "field_type")));
     $GLOBALS['dbi']->expects($this->any())->method('getTable')->will($this->returnValue($table));
     $container = Container::getDefaultContainer();
     $container->set('db', 'db');
     $container->set('table', 'table');
     $container->set('dbi', $GLOBALS['dbi']);
     $response = new \PMA\Test\Stubs\PMA_Response();
     $container->set('PMA_Response', $response);
     $container->alias('response', 'PMA_Response');
     $index = new PMA_Index();
     $ctrl = new TableIndexesController($index);
     $_REQUEST['create_index'] = true;
     $_REQUEST['added_fields'] = 3;
     $ctrl->displayFormAction();
     $html = $response->getHTMLResult();
     //PMA_URL_getHiddenInputs
     $this->assertContains(PMA_URL_getHiddenInputs(array('db' => 'db', 'table' => 'table', 'create_index' => 1)), $html);
     $doc_html = PMA_Util::showHint(PMA_Message::notice(__('"PRIMARY" <b>must</b> be the name of' . ' and <b>only of</b> a primary key!')));
     $this->assertContains($doc_html, $html);
     $this->assertContains(PMA_Util::showMySQLDocu('ALTER_TABLE'), $html);
     // generateIndexSelector
     $this->assertContains(PMA\Template::trim($index->generateIndexChoiceSelector(false)), $html);
     $this->assertContains(sprintf(__('Add %s column(s) to index'), 1), $html);
     //$field_name & $field_type
     $this->assertContains("field_name", $html);
     $this->assertContains("field_type", $html);
 }
$header_cells[] = __('Comments');
if (isset($fields_meta)) {
    // for moving, load all available column names
    $move_columns_sql_query = 'SELECT * FROM ' . PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table) . ' LIMIT 1';
    $move_columns_sql_result = PMA_DBI_try_query($move_columns_sql_query);
    $move_columns = PMA_DBI_get_fields_meta($move_columns_sql_result);
    unset($move_columns_sql_query, $move_columns_sql_result);
    $header_cells[] = __('Move column');
}
if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
    $mime_map = PMA_getMIME($db, $table);
    $available_mime = PMA_getAvailableMIMEtypes();
    $hint = '<br />' . sprintf(__('For a list of available transformation options and their MIME' . ' type transformations, click on %stransformation descriptions%s'), '<a href="transformation_overview.php?' . PMA_generate_common_url($db, $table) . '" target="_blank">', '</a>');
    $header_cells[] = __('MIME type');
    $header_cells[] = __('Browser transformation');
    $header_cells[] = __('Transformation options') . PMA_Util::showHint(__('Please enter the values for transformation options using this' . ' format: \'a\', 100, b,\'c\'…<br />If you ever need to put' . ' a backslash ("\\") or a single quote ("\'") amongst those' . ' values, precede it with a backslash (for example \'\\\\xyz\'' . ' or \'a\\\'b\').') . $hint);
}
//  workaround for field_fulltext, because its submitted indices contain
//  the index as a value, not a key. Inserted here for easier maintaineance
//  and less code to change in existing files.
if (isset($field_fulltext) && is_array($field_fulltext)) {
    foreach ($field_fulltext as $fulltext_nr => $fulltext_indexkey) {
        $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
    }
}
for ($i = 0; $i < $num_fields; $i++) {
    if (!empty($regenerate)) {
        // An error happened with previous inputs, so we will restore the data
        // to embed it once again in this form.
        $row['Field'] = isset($_REQUEST['field_name'][$i]) ? $_REQUEST['field_name'][$i] : false;
        $row['Type'] = isset($_REQUEST['field_type'][$i]) ? $_REQUEST['field_type'][$i] : false;
Ejemplo n.º 16
0
$trans = new PMA_Message();
$trans->addMessage(__('@SERVER@ will become the server name'));
if ($export_type == 'database' || $export_type == 'table') {
    $trans->addMessage(__(', @DATABASE@ will become the database name'));
    if ($export_type == 'table') {
        $trans->addMessage(__(', @TABLE@ will become the table name'));
    }
}
$msg = new PMA_Message(__('This value is interpreted using %1$sstrftime%2$s, so you can use time formatting strings. Additionally the following transformations will happen: %3$s. Other text will be kept as is. See the %4$sFAQ%5$s for details.'));
$msg->addParam('<a href="' . PMA_linkURL(PMA_getPHPDocLink('function.strftime.php')) . '" target="documentation" title="' . __('Documentation') . '">', false);
$msg->addParam('</a>', false);
$msg->addParam($trans);
$doc_url = PMA_Util::getDocuLink('faq', 'faq6-27');
$msg->addParam('<a href="' . $doc_url . '" target="documentation">', false);
$msg->addParam('</a>', false);
echo PMA_Util::showHint($msg);
echo '</label>';
echo '<input type="text" name="filename_template" id="filename_template" ';
echo ' value="';
if (isset($_GET['filename_template'])) {
    echo htmlspecialchars($_GET['filename_template']);
} else {
    if ($export_type == 'database') {
        echo htmlspecialchars($GLOBALS['PMA_Config']->getUserValue('pma_db_filename_template', $GLOBALS['cfg']['Export']['file_template_database']));
    } elseif ($export_type == 'table') {
        echo htmlspecialchars($GLOBALS['PMA_Config']->getUserValue('pma_table_filename_template', $GLOBALS['cfg']['Export']['file_template_table']));
    } else {
        echo htmlspecialchars($GLOBALS['PMA_Config']->getUserValue('pma_server_filename_template', $GLOBALS['cfg']['Export']['file_template_server']));
    }
}
echo '"';
Ejemplo n.º 17
0
 /**
  * Sets the import plugin properties.
  * Called in the constructor.
  *
  * @return void
  */
 protected function setProperties()
 {
     $this->_setAnalyze(false);
     if ($GLOBALS['plugin_param'] !== 'table') {
         $this->_setAnalyze(true);
     }
     $props = 'libraries/properties/';
     include_once "{$props}/plugins/ImportPluginProperties.class.php";
     include_once "{$props}/options/groups/OptionsPropertyRootGroup.class.php";
     include_once "{$props}/options/groups/OptionsPropertyMainGroup.class.php";
     include_once "{$props}/options/items/BoolPropertyItem.class.php";
     include_once "{$props}/options/items/TextPropertyItem.class.php";
     $importPluginProperties = new ImportPluginProperties();
     $importPluginProperties->setText('CSV');
     $importPluginProperties->setExtension('csv');
     $importPluginProperties->setOptionsText(__('Options'));
     // create the root group that will be the options field for
     // $importPluginProperties
     // this will be shown as "Format specific options"
     $importSpecificOptions = new OptionsPropertyRootGroup();
     $importSpecificOptions->setName("Format Specific Options");
     // general options main group
     $generalOptions = new OptionsPropertyMainGroup();
     $generalOptions->setName("general_opts");
     // create primary items and add them to the group
     $leaf = new BoolPropertyItem();
     $leaf->setName("replace");
     $leaf->setText(__('Replace table data with file'));
     $generalOptions->addProperty($leaf);
     $leaf = new TextPropertyItem();
     $leaf->setName("terminated");
     $leaf->setText(__('Columns separated with:'));
     $leaf->setSize(2);
     $leaf->setLen(2);
     $generalOptions->addProperty($leaf);
     $leaf = new TextPropertyItem();
     $leaf->setName("enclosed");
     $leaf->setText(__('Columns enclosed with:'));
     $leaf->setSize(2);
     $leaf->setLen(2);
     $generalOptions->addProperty($leaf);
     $leaf = new TextPropertyItem();
     $leaf->setName("escaped");
     $leaf->setText(__('Columns escaped with:'));
     $leaf->setSize(2);
     $leaf->setLen(2);
     $generalOptions->addProperty($leaf);
     $leaf = new TextPropertyItem();
     $leaf->setName("new_line");
     $leaf->setText(__('Lines terminated with:'));
     $leaf->setSize(2);
     $generalOptions->addProperty($leaf);
     if ($GLOBALS['plugin_param'] !== 'table') {
         $leaf = new BoolPropertyItem();
         $leaf->setName("col_names");
         $leaf->setText(__('The first line of the file contains the table column names' . ' <i>(if this is unchecked, the first line will become part' . ' of the data)</i>'));
         $generalOptions->addProperty($leaf);
     } else {
         $hint = new PMA_Message(__('If the data in each row of the file is not' . ' in the same order as in the database, list the corresponding' . ' column names here. Column names must be separated by commas' . ' and not enclosed in quotations.'));
         $leaf = new TextPropertyItem();
         $leaf->setName("columns");
         $leaf->setText(__('Column names: ') . PMA_Util::showHint($hint));
         $generalOptions->addProperty($leaf);
     }
     // add the main group to the root group
     $importSpecificOptions->addProperty($generalOptions);
     // set the options for the import plugin property item
     $importPluginProperties->setOptions($importSpecificOptions);
     $this->properties = $importPluginProperties;
 }
/**
 * Function to get html for displaying the index form
 *
 * @param array     $fields      fields
 * @param PMA_Index $index       index
 * @param array     $form_params form parameters
 * @param int       $add_fields  number of fields in the form
 *
 * @return string
 */
function PMA_getHtmlForIndexForm($fields, $index, $form_params, $add_fields)
{
    $html = "";
    $html .= '<form action="tbl_indexes.php" method="post" name="index_frm" id="' . 'index_frm" class="ajax"' . 'onsubmit="if (typeof(this.elements[\'index[Key_name]\'].disabled) !=' . ' \'undefined\') {' . 'this.elements[\'index[Key_name]\'].disabled = false}">';
    $html .= PMA_URL_getHiddenInputs($form_params);
    $html .= '<fieldset id="index_edit_fields">';
    $html .= '<div class="index_info">';
    $html .= '<div>' . '<div class="label">' . '<strong>' . '<label for="input_index_name">' . __('Index name:') . PMA_Util::showHint(PMA_Message::notice(__('"PRIMARY" <b>must</b> be the name of' . ' and <b>only of</b> a primary key!'))) . '</label>' . '</strong>' . '</div>' . '<input type="text" name="index[Key_name]" id="input_index_name"' . ' size="25"' . 'value="' . htmlspecialchars($index->getName()) . '"' . 'onfocus="this.select()" />' . '</div>';
    $html .= '<div>' . '<div class="label">' . '<strong>' . '<label for="input_index_comment">' . __('Comment:') . '</label>' . '</strong>' . '</div>' . '<input type="text" name="index[Index_comment]" ' . 'id="input_index_comment" size="30"' . 'value="' . htmlspecialchars($index->getComment()) . '"' . 'onfocus="this.select()" />' . '</div>';
    $html .= '<div>' . '<div class="label">' . '<strong>' . '<label for="select_index_type">' . __('Index type:') . PMA_Util::showMySQLDocu('ALTER_TABLE') . '</label>' . '</strong>' . '</div>' . '<select name="index[Index_type]" id="select_index_type" ' . (isset($_REQUEST['create_edit_table']) ? 'disabled="disabled"' : '') . '>' . $index->generateIndexSelector() . '</select>' . '</div>';
    $html .= '<div class="clearfloat"></div>';
    $html .= '</div>';
    $html .= '<table id="index_columns">';
    $html .= '<thead>' . '<tr>' . '<th>' . __('Column') . '</th>' . '<th>' . __('Size') . '</th>' . '</tr>' . '</thead>';
    $odd_row = true;
    $spatial_types = array('geometry', 'point', 'linestring', 'polygon', 'multipoint', 'multilinestring', 'multipolygon', 'geomtrycollection');
    $html .= '<tbody>';
    /* @var $column PMA_Index_Column */
    foreach ($index->getColumns() as $column) {
        $html .= '<tr class="';
        $html .= $odd_row ? 'odd' : 'even';
        $html .= 'noclick">';
        $html .= '<td><span class="drag_icon" title="' . __('Drag to reorder') . '"' . '></span>';
        $html .= '<select name="index[columns][names][]">';
        $html .= '<option value="">-- ' . __('Ignore') . ' --</option>';
        foreach ($fields as $field_name => $field_type) {
            if (($index->getType() != 'FULLTEXT' || preg_match('/(char|text)/i', $field_type)) && ($index->getType() != 'SPATIAL' || in_array($field_type, $spatial_types))) {
                $html .= '<option value="' . htmlspecialchars($field_name) . '"' . ($field_name == $column->getName() ? ' selected="selected"' : '') . '>' . htmlspecialchars($field_name) . ' [' . htmlspecialchars($field_type) . ']' . '</option>' . "\n";
            }
        }
        // end foreach $fields
        $html .= '</select>';
        $html .= '</td>';
        $html .= '<td>';
        $html .= '<input type="text" size="5" onfocus="this.select()"' . 'name="index[columns][sub_parts][]" value="';
        if ($index->getType() != 'SPATIAL') {
            $html .= $column->getSubPart();
        }
        $html .= '"/>';
        $html .= '</td>';
        $html .= '</tr>';
        $odd_row = !$odd_row;
    }
    // end foreach $edited_index_info['Sequences']
    for ($i = 0; $i < $add_fields; $i++) {
        $html .= '<tr class="';
        $html .= $odd_row ? 'odd' : 'even';
        $html .= 'noclick">';
        $html .= '<td><span class="drag_icon" title="' . __('Drag to reorder') . '"' . '></span>';
        $html .= '<select name="index[columns][names][]">';
        $html .= '<option value="">-- ' . __('Ignore') . ' --</option>';
        $j = 0;
        foreach ($fields as $field_name => $field_type) {
            if (isset($_REQUEST['create_edit_table'])) {
                $col_index = $field_type[1];
                $field_type = $field_type[0];
            }
            $html .= '<option value="' . htmlspecialchars(isset($col_index) ? $col_index : $field_name) . '" ' . ($j++ == $i ? 'selected="selected"' : '') . '>' . htmlspecialchars($field_name) . ' [' . htmlspecialchars($field_type) . ']' . '</option>' . "\n";
        }
        // end foreach $fields
        $html .= '</select>';
        $html .= '</td>';
        $html .= '<td>' . '<input type="text" size="5" onfocus="this.select()"' . 'name="index[columns][sub_parts][]" value="" />' . '</td>';
        $html .= '</tr>';
        $odd_row = !$odd_row;
    }
    // end foreach $edited_index_info['Sequences']
    $html .= '</tbody>';
    $html .= '</table>';
    $html .= '</fieldset>';
    $html .= '<fieldset class="tblFooters">';
    $btn_value = sprintf(__('Add %s column(s) to index'), 1);
    $html .= '<div class="slider"></div>';
    $html .= '<div class="add_fields">';
    $html .= '<input type="submit" value="' . $btn_value . '" />';
    $html .= '</div>';
    $html .= '</fieldset>';
    $html .= '</form>';
    return $html;
}
Ejemplo n.º 19
0
/**
 * Get HTML for each table row of the database structure table,
 * And this function returns $odd_row param also
 *
 * @param integer $curr                  current entry
 * @param boolean $odd_row               whether row is odd or not
 * @param boolean $table_is_view         whether table is view or not
 * @param array   $current_table         current table
 * @param string  $browse_table_label    browse table label action link
 * @param string  $tracking_icon         tracking icon
 * @param boolean $server_slave_status   server slave state
 * @param string  $browse_table          browse table action link
 * @param string  $tbl_url_query         table url query
 * @param string  $search_table          search table action link
 * @param boolean $db_is_system_schema   whether db is information schema or not
 * @param array   $titles                titles array
 * @param string  $empty_table           empty table action link
 * @param string  $drop_query            table drop query
 * @param string  $drop_message          table drop message
 * @param string  $collation             collation
 * @param string  $formatted_size        formatted size
 * @param string  $unit                  unit
 * @param string  $overhead              overhead
 * @param string  $create_time           create time
 * @param string  $update_time           last update time
 * @param string  $check_time            last check time
 * @param boolean $is_show_stats         whether stats is show or not
 * @param boolean $ignored               ignored
 * @param boolean $do                    do
 * @param integer $colspan_for_structure colspan for structure
 *
 * @return array $html_output, $odd_row, $approx_rows
 */
function PMA_getHtmlForStructureTableRow($curr, $odd_row, $table_is_view, $current_table, $browse_table_label, $tracking_icon, $server_slave_status, $browse_table, $tbl_url_query, $search_table, $db_is_system_schema, $titles, $empty_table, $drop_query, $drop_message, $collation, $formatted_size, $unit, $overhead, $create_time, $update_time, $check_time, $is_show_stats, $ignored, $do, $colspan_for_structure)
{
    global $db;
    $show_superscript = '';
    // there is a null value in the ENGINE
    // - when the table needs to be repaired, or
    // - when it's a view
    //  so ensure that we'll display "in use" below for a table
    //  that needs to be repaired
    $approx_rows = false;
    if (isset($current_table['TABLE_ROWS']) && ($current_table['ENGINE'] != null || $table_is_view)) {
        // InnoDB table: we did not get an accurate row count
        $approx_rows = !$table_is_view && $current_table['ENGINE'] == 'InnoDB' && !$current_table['COUNTED'];
        // Drizzle views use FunctionEngine, and the only place where they are
        // available are I_S and D_D schemas, where we do exact counting
        if ($table_is_view && $current_table['TABLE_ROWS'] >= $GLOBALS['cfg']['MaxExactCountViews'] && $current_table['ENGINE'] != 'FunctionEngine') {
            $approx_rows = true;
            $show_superscript = PMA_Util::showHint(PMA_sanitize(sprintf(__('This view has at least this number of rows. Please ' . 'refer to %sdocumentation%s.'), '[doc@cfg_MaxExactCountViews]', '[/doc]')));
        }
    }
    $html_output = PMA\Template::get('structure/structure_table_row')->render(array('db' => $db, 'curr' => $curr, 'odd_row' => $odd_row, 'table_is_view' => $table_is_view, 'current_table' => $current_table, 'browse_table_label' => $browse_table_label, 'tracking_icon' => $tracking_icon, 'server_slave_status' => $server_slave_status, 'browse_table' => $browse_table, 'tbl_url_query' => $tbl_url_query, 'search_table' => $search_table, 'db_is_system_schema' => $db_is_system_schema, 'titles' => $titles, 'empty_table' => $empty_table, 'drop_query' => $drop_query, 'drop_message' => $drop_message, 'collation' => $collation, 'formatted_size' => $formatted_size, 'unit' => $unit, 'overhead' => $overhead, 'create_time' => $create_time, 'update_time' => $update_time, 'check_time' => $check_time, 'is_show_stats' => $is_show_stats, 'ignored' => $ignored, 'do' => $do, 'colspan_for_structure' => $colspan_for_structure, 'approx_rows' => $approx_rows, 'show_superscript' => $show_superscript));
    $odd_row = !$odd_row;
    return array($html_output, $odd_row, $approx_rows);
}
Ejemplo n.º 20
0
    }
    ?>
    </legend>
    <?php 
}
?>
<div class='index_info'>
    <div>
        <div class="label">
            <strong>
                <label for="input_index_name">
                    <?php 
echo __('Index name:');
?>
                    <?php 
echo PMA_Util::showHint(PMA_Message::notice(__('("PRIMARY" <b>must</b> be the name of' . ' and <b>only of</b> a primary key!)')));
?>
                </label>
            </strong>
        </div>
        <input type="text" name="index[Key_name]" id="input_index_name" size="25"
            value="<?php 
echo htmlspecialchars($index->getName());
?>
"
            onfocus="this.select()" />
    </div>
<?php 
if (PMA_MYSQL_INT_VERSION > 50500) {
    ?>
    <div>
/**
 * Get HTML for display the users overview
 * (if less than 50 users, display them immediately)
 *
 * @param array  $result        ran sql query
 * @param array  $db_rights     user's database rights array
 * @param string $pmaThemeImage a image source link
 * @param string $text_dir      text directory
 *
 * @return string HTML snippet
 */
function PMA_getUsersOverview($result, $db_rights, $pmaThemeImage, $text_dir)
{
    while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
        $row['privs'] = PMA_extractPrivInfo($row, true);
        $db_rights[$row['User']][$row['Host']] = $row;
    }
    @$GLOBALS['dbi']->freeResult($result);
    $user_group_count = 0;
    if ($GLOBALS['cfgRelation']['menuswork']) {
        $user_group_count = PMA_getUserGroupCount();
    }
    $html_output = '<form name="usersForm" id="usersForm" action="server_privileges.php" ' . 'method="post">' . "\n" . PMA_URL_getHiddenInputs('', '') . '<table id="tableuserrights" class="data">' . "\n" . '<thead>' . "\n" . '<tr><th></th>' . "\n" . '<th>' . __('User') . '</th>' . "\n" . '<th>' . __('Host') . '</th>' . "\n" . '<th>' . __('Password') . '</th>' . "\n" . '<th>' . __('Global privileges') . ' ' . PMA_Util::showHint(__('Note: MySQL privilege names are expressed in English.')) . '</th>' . "\n";
    if ($GLOBALS['cfgRelation']['menuswork']) {
        $html_output .= '<th>' . __('User group') . '</th>' . "\n";
    }
    $html_output .= '<th>' . __('Grant') . '</th>' . "\n" . '<th colspan="' . ($user_group_count > 0 ? '3' : '2') . '">' . __('Action') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n";
    $html_output .= '<tbody>' . "\n";
    $html_output .= PMA_getHtmlTableBodyForUserRights($db_rights);
    $html_output .= '</tbody>' . '</table>' . "\n";
    $html_output .= '<div style="float:left;">' . PMA_Util::getWithSelected($pmaThemeImage, $text_dir, "usersForm") . "\n";
    $html_output .= PMA_Util::getButtonOrImage('submit_mult', 'mult_submit', 'submit_mult_export', __('Export'), 'b_tblexport.png', 'export');
    $html_output .= '<input type="hidden" name="initial" ' . 'value="' . (isset($_GET['initial']) ? $_GET['initial'] : '') . '" />';
    $html_output .= '</div>' . '<div class="clear_both" style="clear:both"></div>';
    // add/delete user fieldset
    $html_output .= PMA_getFieldsetForAddDeleteUser();
    $html_output .= '</form>' . "\n";
    return $html_output;
}
Ejemplo n.º 22
0
/**
 * Function to get html for the common form title headers
 *
 * @param array  $cfgRelation        configuration relation
 * @param string $tbl_storage_engine table storage engine
 *
 * @return string
 */
function PMA_getHtmlForCommonFormTableHeaders($cfgRelation, $tbl_storage_engine)
{
    $html_output = '<tr><th>' . __('Column') . '</th>';
    if ($cfgRelation['relwork']) {
        $html_output .= '<th>' . __('Internal relation');
        if (PMA_Util::isForeignKeySupported($tbl_storage_engine)) {
            $html_output .= PMA_Util::showHint(__('An internal relation is not necessary when a corresponding' . ' FOREIGN KEY relation exists.'));
        }
        $html_output .= '</th>';
    }
    if (PMA_Util::isForeignKeySupported($tbl_storage_engine)) {
        // this does not have to be translated, it's part of the MySQL syntax
        $html_output .= '<th colspan="2">' . __('Foreign key constraint') . ' (' . $tbl_storage_engine . ')';
        $html_output .= '</th>';
    }
    $html_output .= '</tr>';
    return $html_output;
}
Ejemplo n.º 23
0
        $possibly_readonly = ' readonly="readonly"';
    } else {
        $possibly_readonly = '';
    }

    foreach ($cons as $type) {
        if ('src' == $type) {
            $database_header = __('Source database');
        } else {
            $database_header = __('Target database');
        }

        $database_header .= PMA_Util::showHint(
            PMA_sanitize(
                sprintf(
                    '%sAllowArbitraryServer%s',
                    '[doc@AllowArbitraryServer]', '[/doc]'
                )
            )
        );
?>
      <table id="serverconnection_<?php echo $type; ?>_remote" class="data noclick">
      <caption class="tblHeaders"><?php echo $database_header; ?></caption>
      <tr class="odd">
      <td colspan="2" style="text-align: center">
         <select name="<?php echo $type; ?>_type" id="<?php echo $type; ?>_type" class="server_selector">
<?php
        if ($GLOBALS['cfg']['AllowArbitraryServer']) {
            $preselected_option = 'rmt';
            echo '<option value="rmt" selected="selected">' . __('Enter manually') . '</option>';
        } else {
            $preselected_option = 'cur';
 /**
  * Provides the main search form's html
  *
  * @return string HTML for selection form
  */
 public function getSelectionForm()
 {
     $html_output = '<a id="db_search"></a>';
     $html_output .= '<form id="db_search_form"' . ' class="ajax"' . ' method="post" action="db_search.php" name="db_search">';
     $html_output .= PMA_URL_getHiddenInputs($GLOBALS['db']);
     $html_output .= '<fieldset>';
     // set legend caption
     $html_output .= '<legend>' . __('Search in database') . '</legend>';
     $html_output .= '<table class="formlayout">';
     // inputbox for search phrase
     $html_output .= '<tr>';
     $html_output .= '<td>' . __('Words or values to search for (wildcard: "%"):') . '</td>';
     $html_output .= '<td><input type="text"' . ' name="criteriaSearchString" size="60"' . ' value="' . htmlspecialchars($this->_criteriaSearchString) . '" />';
     $html_output .= '</td>';
     $html_output .= '</tr>';
     // choices for types of search
     $html_output .= '<tr>';
     $html_output .= '<td class="right vtop">' . __('Find:') . '</td>';
     $html_output .= '<td>';
     $choices = array('1' => __('at least one of the words') . PMA_Util::showHint(__('Words are separated by a space character (" ").')), '2' => __('all words') . PMA_Util::showHint(__('Words are separated by a space character (" ").')), '3' => __('the exact phrase'), '4' => __('as regular expression') . ' ' . PMA_Util::showMySQLDocu('Regexp'));
     // 4th parameter set to true to add line breaks
     // 5th parameter set to false to avoid htmlspecialchars() escaping
     // in the label since we have some HTML in some labels
     $html_output .= PMA_Util::getRadioFields('criteriaSearchType', $choices, $this->_criteriaSearchType, true, false);
     $html_output .= '</td></tr>';
     // displays table names as select options
     $html_output .= '<tr>';
     $html_output .= '<td class="right vtop">' . __('Inside tables:') . '</td>';
     $html_output .= '<td rowspan="2">';
     $html_output .= '<select name="criteriaTables[]" size="6"' . ' multiple="multiple">';
     foreach ($this->_tables_names_only as $each_table) {
         if (in_array($each_table, $this->_criteriaTables)) {
             $is_selected = ' selected="selected"';
         } else {
             $is_selected = '';
         }
         $html_output .= '<option value="' . htmlspecialchars($each_table) . '"' . $is_selected . '>' . str_replace(' ', '&nbsp;', htmlspecialchars($each_table)) . '</option>';
     }
     // end for
     $html_output .= '</select>';
     $html_output .= '</td></tr>';
     // Displays 'select all' and 'unselect all' links
     $alter_select = '<a href="#" ' . 'onclick="setSelectOptions(\'db_search\',' . ' \'criteriaTables[]\', true); return false;">' . __('Select All') . '</a> &nbsp;/&nbsp;';
     $alter_select .= '<a href="#" ' . 'onclick="setSelectOptions(\'db_search\',' . ' \'criteriaTables[]\', false); return false;">' . __('Unselect All') . '</a>';
     $html_output .= '<tr><td class="right vbottom">' . $alter_select . '</td></tr>';
     // Inputbox for column name entry
     $html_output .= '<tr>';
     $html_output .= '<td class="right">' . __('Inside column:') . '</td>';
     $html_output .= '<td><input type="text" name="criteriaColumnName" size="60"' . 'value="' . (!empty($this->_criteriaColumnName) ? htmlspecialchars($this->_criteriaColumnName) : '') . '" /></td>';
     $html_output .= '</tr>';
     $html_output .= '</table>';
     $html_output .= '</fieldset>';
     $html_output .= '<fieldset class="tblFooters">';
     $html_output .= '<input type="submit" name="submit_search" value="' . __('Go') . '" id="buttonGo" />';
     $html_output .= '</fieldset>';
     $html_output .= '</form>';
     $html_output .= '<div id="togglesearchformdiv">' . '<a id="togglesearchformlink"></a></div>';
     return $html_output;
 }
Ejemplo n.º 25
0
 /**
  * Set the content that needs to be shown in message
  *
  * @param string  $sorted_column_message the message for sorted column
  * @param string  $limit_clause          the limit clause of analyzed query
  * @param integer $total                 the total number of rows returned by
  *                                       the SQL query without any
  *                                       programmatically appended LIMIT clause
  * @param integer $pos_next              the offset for next page
  * @param string  $pre_count             the string renders before row count
  * @param string  $after_count           the string renders after row count
  *
  * @return PMA_Message $message an object of PMA_Message
  *
  * @access  private
  *
  * @see     getTable()
  */
 private function _setMessageInformation($sorted_column_message, $limit_clause, $total, $pos_next, $pre_count, $after_count)
 {
     $unlim_num_rows = $this->__get('unlim_num_rows');
     // To use in isset()
     if (!empty($limit_clause)) {
         $limit_data = PMA_Util::analyzeLimitClause($limit_clause);
         $first_shown_rec = $limit_data['start'];
         if ($limit_data['length'] < $total) {
             $last_shown_rec = $limit_data['start'] + $limit_data['length'] - 1;
         } else {
             $last_shown_rec = $limit_data['start'] + $total - 1;
         }
     } elseif ($_SESSION['tmpval']['max_rows'] == self::ALL_ROWS || $pos_next > $total) {
         $first_shown_rec = $_SESSION['tmpval']['pos'];
         $last_shown_rec = $total - 1;
     } else {
         $first_shown_rec = $_SESSION['tmpval']['pos'];
         $last_shown_rec = $pos_next - 1;
     }
     if (PMA_Table::isView($this->__get('db'), $this->__get('table')) && $total == $GLOBALS['cfg']['MaxExactCountViews']) {
         $message = PMA_Message::notice(__('This view has at least this number of rows. ' . 'Please refer to %sdocumentation%s.'));
         $message->addParam('[doc@cfg_MaxExactCount]');
         $message->addParam('[/doc]');
         $message_view_warning = PMA_Util::showHint($message);
     } else {
         $message_view_warning = false;
     }
     $message = PMA_Message::success(__('Showing rows %1s - %2s'));
     $message->addParam($first_shown_rec);
     if ($message_view_warning) {
         $message->addParam('... ' . $message_view_warning, false);
     } else {
         $message->addParam($last_shown_rec);
     }
     $message->addMessage('(');
     if (!$message_view_warning) {
         if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
             $message_total = PMA_Message::notice($pre_count . __('%1$d total, %2$d in query'));
             $message_total->addParam($total);
             $message_total->addParam($unlim_num_rows);
         } else {
             $message_total = PMA_Message::notice($pre_count . __('%d total'));
             $message_total->addParam($total);
         }
         if (!empty($after_count)) {
             $message_total->addMessage($after_count);
         }
         $message->addMessage($message_total, '');
         $message->addMessage(', ', '');
     }
     $message_qt = PMA_Message::notice(__('Query took %01.4f seconds.') . ')');
     $message_qt->addParam($this->__get('querytime'));
     $message->addMessage($message_qt, '');
     if (!is_null($sorted_column_message)) {
         $message->addMessage($sorted_column_message, '');
     }
     return $message;
 }
 /**
  * Test for PMA_getUsersOverview
  *
  * @return void
  */
 public function testPMAGetUsersOverview()
 {
     $result = array();
     $db_rights = array();
     $pmaThemeImage = "pmaThemeImage";
     $text_dir = "text_dir";
     $GLOBALS['cfgRelation']['menuswork'] = true;
     $html = PMA_getUsersOverview($result, $db_rights, $pmaThemeImage, $text_dir);
     //PMA_URL_getHiddenInputs
     $this->assertContains(PMA_URL_getHiddenInputs('', ''), $html);
     //items
     $this->assertContains(__('User'), $html);
     $this->assertContains(__('Host'), $html);
     $this->assertContains(__('Password'), $html);
     $this->assertContains(__('Global privileges'), $html);
     //PMA_Util::showHint
     $this->assertContains(PMA_Util::showHint(__('Note: MySQL privilege names are expressed in English.')), $html);
     //__('User group')
     $this->assertContains(__('User group'), $html);
     $this->assertContains(__('Grant'), $html);
     $this->assertContains(__('Action'), $html);
     //$pmaThemeImage
     $this->assertContains($pmaThemeImage, $html);
     //$text_dir
     $this->assertContains($text_dir, $html);
     //PMA_getFieldsetForAddDeleteUser
     $this->assertContains(PMA_getFieldsetForAddDeleteUser(), $html);
 }
/**
 * Returns html with Settings dialog
 *
 * @return string
 */
function PMA_getHtmlForSettingsDialog()
{
    $retval = '<div class="popupContent settingsPopup">';
    $retval .= '<a href="#addNewChart">';
    $retval .= PMA_Util::getImage('b_chart.png') . __('Add chart');
    $retval .= '</a>';
    $retval .= '<a href="#rearrangeCharts">';
    $retval .= PMA_Util::getImage('b_tblops.png') . __('Enable charts dragging');
    $retval .= '</a>';
    $retval .= '<div class="clearfloat paddingtop"></div>';
    $retval .= '<div class="floatleft">';
    $retval .= __('Refresh rate') . '<br />';
    $retval .= PMA_getHtmlForRefreshList('gridChartRefresh', 5, array(2, 3, 4, 5, 10, 20, 40, 60, 120, 300, 600, 1200));
    $retval .= '<br />';
    $retval .= '</div>';
    $retval .= '<div class="floatleft">';
    $retval .= __('Chart columns');
    $retval .= '<br />';
    $retval .= '<select name="chartColumns">';
    $retval .= '<option>1</option>';
    $retval .= '<option>2</option>';
    $retval .= '<option>3</option>';
    $retval .= '<option>4</option>';
    $retval .= '<option>5</option>';
    $retval .= '<option>6</option>';
    $retval .= '</select>';
    $retval .= '</div>';
    $retval .= '<div class="clearfloat paddingtop">';
    $retval .= '<b>' . __('Chart arrangement') . '</b> ';
    $retval .= PMA_Util::showHint(__('The arrangement of the charts is stored to the browsers local storage. ' . 'You may want to export it if you have a complicated set up.'));
    $retval .= '<br/>';
    $retval .= '<a class="ajax" href="#importMonitorConfig">';
    $retval .= __('Import');
    $retval .= '</a>';
    $retval .= '&nbsp;&nbsp;';
    $retval .= '<a class="disableAjax" href="#exportMonitorConfig">';
    $retval .= __('Export');
    $retval .= '</a>';
    $retval .= '&nbsp;&nbsp;';
    $retval .= '<a href="#clearMonitorConfig">';
    $retval .= __('Reset to default');
    $retval .= '</a>';
    $retval .= '</div>';
    $retval .= '</div>';
    return $retval;
}
Ejemplo n.º 28
0
/**
 * Prints Html For Export Options
 *
 * @param String $export_type Selected Export Type
 *
 * @return string
 */
function PMA_getHtmlForExportOptionsOutputFormat($export_type)
{
    $html = '<li>';
    $html .= '<label for="filename_template" class="desc">';
    $html .= __('File name template:');
    $trans = new PMA_Message();
    $trans->addMessage(__('@SERVER@ will become the server name'));
    if ($export_type == 'database' || $export_type == 'table') {
        $trans->addMessage(__(', @DATABASE@ will become the database name'));
        if ($export_type == 'table') {
            $trans->addMessage(__(', @TABLE@ will become the table name'));
        }
    }
    $msg = new PMA_Message(__('This value is interpreted using %1$sstrftime%2$s, ' . 'so you can use time formatting strings. ' . 'Additionally the following transformations will happen: %3$s. ' . 'Other text will be kept as is. See the %4$sFAQ%5$s for details.'));
    $msg->addParam('<a href="' . PMA_linkURL(PMA_getPHPDocLink('function.strftime.php')) . '" target="documentation" title="' . __('Documentation') . '">', false);
    $msg->addParam('</a>', false);
    $msg->addParam($trans);
    $doc_url = PMA_Util::getDocuLink('faq', 'faq6-27');
    $msg->addParam('<a href="' . $doc_url . '" target="documentation">', false);
    $msg->addParam('</a>', false);
    $html .= PMA_Util::showHint($msg);
    $html .= '</label>';
    $html .= '<input type="text" name="filename_template" id="filename_template" ';
    $html .= ' value="';
    if (isset($_GET['filename_template'])) {
        $html .= htmlspecialchars($_GET['filename_template']);
    } else {
        if ($export_type == 'database') {
            $html .= htmlspecialchars($GLOBALS['PMA_Config']->getUserValue('pma_db_filename_template', $GLOBALS['cfg']['Export']['file_template_database']));
        } elseif ($export_type == 'table') {
            $html .= htmlspecialchars($GLOBALS['PMA_Config']->getUserValue('pma_table_filename_template', $GLOBALS['cfg']['Export']['file_template_table']));
        } else {
            $html .= htmlspecialchars($GLOBALS['PMA_Config']->getUserValue('pma_server_filename_template', $GLOBALS['cfg']['Export']['file_template_server']));
        }
    }
    $html .= '"';
    $html .= '/>';
    $html .= '<input type="checkbox" name="remember_template" ';
    $html .= 'id="checkbox_remember_template" ';
    $html .= PMA_exportCheckboxCheck('remember_file_template');
    $html .= '/>';
    $html .= '<label for="checkbox_remember_template">';
    $html .= __('use this for future exports');
    $html .= '</label>';
    $html .= '</li>';
    return $html;
}
Ejemplo n.º 29
0
/**
 * get Submit button and Reset button for action panel
 *
 * @param integer $tabindex           tab index
 * @param integer $tabindex_for_value offset for the values tabindex
 *
 * @return string an html snippet
 */
function PMA_getSubmitAndResetButtonForActionsPanel($tabindex, $tabindex_for_value)
{
    return '<td>' . PMA_Util::showHint(__('Use TAB key to move from value to value,' . ' or CTRL+arrows to move anywhere')) . '</td>' . '<td colspan="3" class="right vmiddle">' . '<input type="submit" class="control_at_footer" value="' . __('Go') . '"' . ' tabindex="' . ($tabindex + $tabindex_for_value + 6) . '" id="buttonYes" />' . '<input type="button" class="preview_sql" value="' . __('Preview SQL') . '"' . ' tabindex="' . ($tabindex + $tabindex_for_value + 7) . '" />' . '<input type="reset" class="control_at_footer" value="' . __('Reset') . '"' . ' tabindex="' . ($tabindex + $tabindex_for_value + 8) . '" />' . '</td>';
}
/**
 * Get HTML for display the users overview
 * (if less than 50 users, display them immediately)
 *
 * @param array  $result            ran sql query
 * @param array  $db_rights         user's database rights array
 * @param string $link_edit         standard link to edit privileges
 * @param string $pmaThemeImage     a image source link
 * @param string $text_dir          text directory
 * @param string $conditional_class if ajaxable 'Ajax' otherwise ''
 * @param string $link_export       standard link to export privileges
 *
 * @return string HTML snippet
 */
function PMA_getUsersOverview($result, $db_rights, $link_edit, $pmaThemeImage, $text_dir, $conditional_class, $link_export)
{
    while ($row = PMA_DBI_fetch_assoc($result)) {
        $row['privs'] = PMA_extractPrivInfo($row, true);
        $db_rights[$row['User']][$row['Host']] = $row;
    }
    @PMA_DBI_free_result($result);
    $html_output = '<form name="usersForm" id="usersForm" action="server_privileges.php" ' . 'method="post">' . "\n" . PMA_generate_common_hidden_inputs('', '') . '<table id="tableuserrights" class="data">' . "\n" . '<thead>' . "\n" . '<tr><th></th>' . "\n" . '<th>' . __('User') . '</th>' . "\n" . '<th>' . __('Host') . '</th>' . "\n" . '<th>' . __('Password') . '</th>' . "\n" . '<th>' . __('Global privileges') . ' ' . PMA_Util::showHint(__('Note: MySQL privilege names are expressed in English')) . '</th>' . "\n" . '<th>' . __('Grant') . '</th>' . "\n" . '<th colspan="2">' . __('Action') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n";
    $html_output .= '<tbody>' . "\n";
    $html_output .= PMA_getTableBodyForUserRightsTable($db_rights, $link_edit, $link_export);
    $html_output .= '</tbody>' . '</table>' . "\n";
    $html_output .= '<div style="float:left;">' . '<img class="selectallarrow"' . ' src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png"' . ' width="38" height="22"' . ' alt="' . __('With selected:') . '" />' . "\n" . '<input type="checkbox" id="checkall" title="' . __('Check All') . '" /> ' . '<label for="checkall">' . __('Check All') . '</label> ' . '<i style="margin-left: 2em">' . __('With selected:') . '</i>' . "\n";
    $html_output .= PMA_Util::getButtonOrImage('submit_mult', 'mult_submit', 'submit_mult_export', __('Export'), 'b_tblexport.png', 'export');
    $html_output .= '<input type="hidden" name="initial" ' . 'value="' . (isset($_GET['initial']) ? $_GET['initial'] : '') . '" />';
    $html_output .= '</div>' . '<div class="clear_both" style="clear:both"></div>';
    // add/delete user fieldset
    $html_output .= PMA_getFieldsetForAddDeleteUser($conditional_class);
    $html_output .= '</form>' . "\n";
    return $html_output;
}