getHiddenInputs() public static method

Generates text with hidden inputs.
See also: URL::getCommon()
public static getHiddenInputs ( string | array $db = '', string $table = '', integer $indent, string | array $skip = [] ) : string
$db string | array optional database name (can also be an array of parameters)
$table string optional table name
$indent integer indenting level
$skip string | array do not generate a hidden field for this parameter (can be an array of strings)
return string string with input fields
/**
 * return HTML for the sql query boxes
 *
 * @param boolean|string $query       query to display in the textarea
 *                                    or true to display last executed
 * @param boolean|string $display_tab sql|full|false
 *                                    what part to display
 *                                    false if not inside querywindow
 * @param string         $delimiter   delimiter
 *
 * @return string
 *
 * @usedby  server_sql.php
 * @usedby  db_sql.php
 * @usedby  tbl_sql.php
 * @usedby  tbl_structure.php
 * @usedby  tbl_tracking.php
 */
function PMA_getHtmlForSqlQueryForm($query = true, $display_tab = false, $delimiter = ';')
{
    $html = '';
    if (!$display_tab) {
        $display_tab = 'full';
    }
    // query to show
    if (true === $query) {
        $query = $GLOBALS['sql_query'];
    }
    // set enctype to multipart for file uploads
    if ($GLOBALS['is_upload']) {
        $enctype = ' enctype="multipart/form-data"';
    } else {
        $enctype = '';
    }
    $table = '';
    $db = '';
    if (strlen($GLOBALS['db']) === 0) {
        // prepare for server related
        $goto = empty($GLOBALS['goto']) ? 'server_sql.php' : $GLOBALS['goto'];
    } elseif (strlen($GLOBALS['table']) === 0) {
        // prepare for db related
        $db = $GLOBALS['db'];
        $goto = empty($GLOBALS['goto']) ? 'db_sql.php' : $GLOBALS['goto'];
    } else {
        $table = $GLOBALS['table'];
        $db = $GLOBALS['db'];
        $goto = empty($GLOBALS['goto']) ? 'tbl_sql.php' : $GLOBALS['goto'];
    }
    // start output
    $html .= '<form method="post" action="import.php" ' . $enctype;
    $html .= ' class="ajax lock-page"';
    $html .= ' id="sqlqueryform" name="sqlform">' . "\n";
    $html .= '<input type="hidden" name="is_js_confirmed" value="0" />' . "\n" . URL::getHiddenInputs($db, $table) . "\n" . '<input type="hidden" name="pos" value="0" />' . "\n" . '<input type="hidden" name="goto" value="' . htmlspecialchars($goto) . '" />' . "\n" . '<input type="hidden" name="message_to_show" value="' . __('Your SQL query has been executed successfully.') . '" />' . "\n" . '<input type="hidden" name="prev_sql_query" value="' . htmlspecialchars($query) . '" />' . "\n";
    // display querybox
    if ($display_tab === 'full' || $display_tab === 'sql') {
        $html .= PMA_getHtmlForSqlQueryFormInsert($query, $delimiter);
    }
    // Bookmark Support
    if ($display_tab === 'full') {
        $cfgBookmark = Bookmark::getParams();
        if ($cfgBookmark) {
            $html .= PMA_getHtmlForSqlQueryFormBookmark();
        }
    }
    // Japanese encoding setting
    if (Encoding::canConvertKanji()) {
        $html .= Encoding::kanjiEncodingForm();
    }
    $html .= '</form>' . "\n";
    // print an empty div, which will be later filled with
    // the sql query results by ajax
    $html .= '<div id="sqlqueryresultsouter"></div>';
    return $html;
}
Example #2
0
/**
 * Get HTML for display indexes
 *
 * @return string $html_output
 */
function PMA_getHtmlForDisplayIndexes()
{
    $html_output = '<div id="index_div" class="ajax" >';
    $html_output .= PMA\libraries\Index::getHtmlForIndexes($GLOBALS['table'], $GLOBALS['db']);
    $html_output .= '<fieldset class="tblFooters print_ignore" style="text-align: ' . 'left;"><form action="tbl_indexes.php" method="post">';
    $html_output .= URL::getHiddenInputs($GLOBALS['db'], $GLOBALS['table']);
    $html_output .= sprintf(__('Create an index on &nbsp;%s&nbsp;columns'), '<input type="number" name="added_fields" value="1" ' . 'min="1" required="required" />');
    $html_output .= '<input type="hidden" name="create_index" value="1" />' . '<input class="add_index ajax"' . ' type="submit" value="' . __('Go') . '" />';
    $html_output .= '</form>' . '</fieldset>' . '</div>';
    return $html_output;
}
/**
 * Prints Html For Display Import Hidden Input
 *
 * @param String $import_type Import type: server, database, table
 * @param String $db          Selected DB
 * @param String $table       Selected Table
 *
 * @return string
 */
function PMA_getHtmlForHiddenInputs($import_type, $db, $table)
{
    $html = '';
    if ($import_type == 'server') {
        $html .= URL::getHiddenInputs('', '', 1);
    } elseif ($import_type == 'database') {
        $html .= URL::getHiddenInputs($db, '', 1);
    } else {
        $html .= URL::getHiddenInputs($db, $table, 1);
    }
    $html .= '    <input type="hidden" name="import_type" value="' . $import_type . '" />' . "\n";
    return $html;
}
 /**
  * Tests for PMA_getHtmlForDataDefinitionAndManipulationStatements() method.
  *
  * @return void
  * @test
  */
 public function testPMAGetHtmlForDataDefinitionAndManipulationStatements()
 {
     $url_query = "url_query";
     $last_version = 10;
     $html = PMA_getHtmlForDataDefinitionAndManipulationStatements($url_query, $last_version, $GLOBALS['db'], array($GLOBALS['table']));
     $this->assertContains('<div id="div_create_version">', $html);
     $this->assertContains($url_query, $html);
     $this->assertContains(URL::getHiddenInputs($GLOBALS['db']), $html);
     $item = sprintf(__('Create version %1$s of %2$s'), $last_version + 1, htmlspecialchars($GLOBALS['db'] . '.' . $GLOBALS['table']));
     $this->assertContains($item, $html);
     $item = '<input type="checkbox" name="delete" value="true"' . ' checked="checked" /> DELETE<br/>';
     $this->assertContains($item, $html);
     $this->assertContains(__('Create version'), $html);
 }
 /**
  * Test for PMA_getHtmlForCreateTable
  *
  * @return void
  */
 public function testPMAGetHtmlForCreateTable()
 {
     $db = "pma_db";
     //Call the test function
     $html = PMA_getHtmlForCreateTable($db);
     //getImage
     $this->assertContains(PMA\libraries\Util::getImage('b_table_add.png'), $html);
     //__('Create table')
     $this->assertContains(__('Create table'), $html);
     //URL::getHiddenInputs
     $this->assertContains(URL::getHiddenInputs($db), $html);
     //label
     $this->assertContains(__('Name'), $html);
     $this->assertContains(__('Number of columns'), $html);
     //button
     $this->assertContains(__('Go'), $html);
 }
/**
 * Function to get html for relational field selection
 *
 * @param string $db            current database
 * @param string $table         current table
 * @param string $field         field
 * @param array  $foreignData   foreign column data
 * @param string $fieldkey      field key
 * @param string $current_value current columns's value
 *
 * @return string
 */
function PMA_getHtmlForRelationalFieldSelection($db, $table, $field, $foreignData, $fieldkey, $current_value)
{
    $gotopage = PMA_getHtmlForGotoPage($foreignData);
    $showall = PMA_getHtmlForShowAll($foreignData);
    $output = '<form class="ajax" ' . 'id="browse_foreign_form" name="browse_foreign_from" ' . 'action="browse_foreigners.php" method="post">' . '<fieldset>' . URL::getHiddenInputs($db, $table) . '<input type="hidden" name="field" value="' . htmlspecialchars($field) . '" />' . '<input type="hidden" name="fieldkey" value="' . (isset($fieldkey) ? htmlspecialchars($fieldkey) : '') . '" />';
    if (isset($_REQUEST['rownumber'])) {
        $output .= '<input type="hidden" name="rownumber" value="' . htmlspecialchars($_REQUEST['rownumber']) . '" />';
    }
    $filter_value = isset($_REQUEST['foreign_filter']) ? htmlspecialchars($_REQUEST['foreign_filter']) : '';
    $output .= '<span class="formelement">' . '<label for="input_foreign_filter">' . __('Search:') . '</label>' . '<input type="text" name="foreign_filter" ' . 'id="input_foreign_filter" ' . 'value="' . $filter_value . '" data-old="' . $filter_value . '" ' . '/>' . '<input type="submit" name="submit_foreign_filter" value="' . __('Go') . '" />' . '</span>' . '<span class="formelement">' . $gotopage . '</span>' . '<span class="formelement">' . $showall . '</span>' . '</fieldset>' . '</form>';
    $output .= '<table width="100%" id="browse_foreign_table">';
    if (!is_array($foreignData['disp_row'])) {
        $output .= '</tbody>' . '</table>';
        return $output;
    }
    $header = '<tr>
        <th>' . __('Keyname') . '</th>
        <th>' . __('Description') . '</th>
        <td width="20%"></td>
        <th>' . __('Description') . '</th>
        <th>' . __('Keyname') . '</th>
    </tr>';
    $output .= '<thead>' . $header . '</thead>' . "\n" . '<tfoot>' . $header . '</tfoot>' . "\n" . '<tbody>' . "\n";
    $descriptions = array();
    $keys = array();
    foreach ($foreignData['disp_row'] as $relrow) {
        if ($foreignData['foreign_display'] != false) {
            $descriptions[] = $relrow[$foreignData['foreign_display']];
        } else {
            $descriptions[] = '';
        }
        $keys[] = $relrow[$foreignData['foreign_field']];
    }
    asort($keys);
    $horizontal_count = 0;
    $odd_row = true;
    $indexByDescription = 0;
    foreach ($keys as $indexByKeyname => $value) {
        list($html, $horizontal_count, $odd_row, $indexByDescription) = PMA_getHtmlForOneKey($horizontal_count, $header, $odd_row, $keys, $indexByKeyname, $descriptions, $indexByDescription, $current_value);
        $output .= $html;
    }
    $output .= '</tbody>' . '</table>';
    return $output;
}
 /**
  * Test for PMA_getHtmlForChangePassword
  *
  * @return void
  */
 public function testPMAGetHtmlForChangePassword()
 {
     $username = "******";
     $hostname = "pma_hostname";
     //Call the test function
     $html = PMA_getHtmlForChangePassword('change_pw', $username, $hostname);
     //PMA_PHP_SELF
     $this->assertContains($GLOBALS['PMA_PHP_SELF'], $html);
     //URL::getHiddenInputs
     $this->assertContains(URL::getHiddenInputs(), $html);
     //$username & $hostname
     $this->assertContains(htmlspecialchars($username), $html);
     $this->assertContains(htmlspecialchars($hostname), $html);
     //labels
     $this->assertContains(__('Change password'), $html);
     $this->assertContains(__('No Password'), $html);
     $this->assertContains(__('Password:'******'Password:'), $html);
 }
/**
 * Returns HTML code for the language selector
 *
 * @param boolean $use_fieldset whether to use fieldset for selection
 * @param boolean $show_doc     whether to show documentation links
 *
 * @return string
 *
 * @access  public
 */
function PMA_getLanguageSelectorHtml($use_fieldset = false, $show_doc = true)
{
    $retval = '';
    $available_languages = LanguageManager::getInstance()->sortedLanguages();
    // Display language selection only if there
    // is more than one language to choose from
    if (count($available_languages) > 1) {
        $retval .= '<form method="get" action="index.php" class="disableAjax">';
        $_form_params = array('db' => $GLOBALS['db'], 'table' => $GLOBALS['table']);
        $retval .= URL::getHiddenInputs($_form_params);
        // For non-English, display "Language" with emphasis because it's
        // not a proper word in the current language; we show it to help
        // people recognize the dialog
        $language_title = __('Language') . (__('Language') != 'Language' ? ' - <em>Language</em>' : '');
        if ($show_doc) {
            $language_title .= PMA\libraries\Util::showDocu('faq', 'faq7-2');
        }
        if ($use_fieldset) {
            $retval .= '<fieldset><legend lang="en" dir="ltr">' . $language_title . '</legend>';
        } else {
            $retval .= '<bdo lang="en" dir="ltr"><label for="sel-lang">' . $language_title . ': </label></bdo>';
        }
        $retval .= '<select name="lang" class="autosubmit" lang="en"' . ' dir="ltr" id="sel-lang">';
        foreach ($available_languages as $language) {
            //Is current one active?
            if ($language->isActive()) {
                $selected = ' selected="selected"';
            } else {
                $selected = '';
            }
            $retval .= '<option value="' . $language->getCode() . '"' . $selected . '>';
            $retval .= $language->getName();
            $retval .= '</option>';
        }
        $retval .= '</select>';
        if ($use_fieldset) {
            $retval .= '</fieldset>';
        }
        $retval .= '</form>';
    }
    return $retval;
}
/**
 * Displays top part of the form
 *
 * @param string $action        default: $_SERVER['REQUEST_URI']
 * @param string $method        'post' or 'get'
 * @param array  $hidden_fields array of form hidden fields (key: field name)
 *
 * @return string
 */
function PMA_displayFormTop($action = null, $method = 'post', $hidden_fields = null)
{
    static $has_check_page_refresh = false;
    if ($action === null) {
        $action = $_SERVER['REQUEST_URI'];
    }
    if ($method != 'post') {
        $method = 'get';
    }
    $htmlOutput = '<form method="' . $method . '" action="' . htmlspecialchars($action) . '" class="config-form disableAjax">';
    $htmlOutput .= '<input type="hidden" name="tab_hash" value="" />';
    // we do validation on page refresh when browser remembers field values,
    // add a field with known value which will be used for checks
    if (!$has_check_page_refresh) {
        $has_check_page_refresh = true;
        $htmlOutput .= '<input type="hidden" name="check_page_refresh" ' . ' id="check_page_refresh" value="" />' . "\n";
    }
    $htmlOutput .= URL::getHiddenInputs('', '', 0, 'server') . "\n";
    $htmlOutput .= URL::getHiddenFields((array) $hidden_fields);
    return $htmlOutput;
}
/**
 * Get HTML for the Change password dialog
 *
 * @param string $mode     where is the function being called?
 *                         values : 'change_pw' or 'edit_other'
 * @param string $username username
 * @param string $hostname hostname
 *
 * @return string html snippet
 */
function PMA_getHtmlForChangePassword($mode, $username, $hostname)
{
    /**
     * autocomplete feature of IE kills the "onchange" event handler and it
     * must be replaced by the "onpropertychange" one in this case
     */
    $chg_evt_handler = 'onchange';
    $is_privileges = basename($_SERVER['SCRIPT_NAME']) === 'server_privileges.php';
    $html = '<form method="post" id="change_password_form" ' . 'action="' . basename($GLOBALS['PMA_PHP_SELF']) . '" ' . 'name="chgPassword" ' . 'class="' . ($is_privileges ? 'submenu-item' : '') . '">';
    $html .= URL::getHiddenInputs();
    if (strpos($GLOBALS['PMA_PHP_SELF'], 'server_privileges') !== false) {
        $html .= '<input type="hidden" name="username" ' . 'value="' . htmlspecialchars($username) . '" />' . '<input type="hidden" name="hostname" ' . 'value="' . htmlspecialchars($hostname) . '" />';
    }
    $html .= '<fieldset id="fieldset_change_password">' . '<legend' . ($is_privileges ? ' data-submenu-label="' . __('Change password') . '"' : '') . '>' . __('Change password') . '</legend>' . '<table class="data noclick">' . '<tr class="odd">' . '<td colspan="2">' . '<input type="radio" name="nopass" value="1" id="nopass_1" ' . 'onclick="pma_pw.value = \'\'; pma_pw2.value = \'\'; ' . 'this.checked = true" />' . '<label for="nopass_1">' . __('No Password') . '</label>' . '</td>' . '</tr>' . '<tr class="even vmiddle">' . '<td>' . '<input type="radio" name="nopass" value="0" id="nopass_0" ' . 'onclick="document.getElementById(\'text_pma_pw\').focus();" ' . 'checked="checked" />' . '<label for="nopass_0">' . __('Password:'******'&nbsp;</label>' . '</td>' . '<td>' . '<input type="password" name="pma_pw" id="text_pma_pw" size="10" ' . 'class="textfield"' . $chg_evt_handler . '="nopass[1].checked = true" />' . '&nbsp;&nbsp;' . __('Re-type:') . '&nbsp;' . '<input type="password" name="pma_pw2" id="text_pma_pw2" size="10" ' . 'class="textfield"' . $chg_evt_handler . '="nopass[1].checked = true" />' . '</td>' . '</tr>';
    $serverType = PMA\libraries\Util::getServerType();
    $orig_auth_plugin = PMA_getCurrentAuthenticationPlugin('change', $username, $hostname);
    $is_superuser = $GLOBALS['dbi']->isSuperuser();
    if ($serverType == 'MySQL' && PMA_MYSQL_INT_VERSION >= 50507 || $serverType == 'MariaDB' && PMA_MYSQL_INT_VERSION >= 50200) {
        // Provide this option only for 5.7.6+
        // OR for privileged users in 5.5.7+
        if ($serverType == 'MySQL' && PMA_MYSQL_INT_VERSION >= 50706 || $is_superuser && $mode == 'edit_other') {
            $auth_plugin_dropdown = PMA_getHtmlForAuthPluginsDropdown($orig_auth_plugin, 'change_pw', 'new');
            $html .= '<tr class="vmiddle">' . '<td>' . __('Password Hashing:') . '</td><td>';
            $html .= $auth_plugin_dropdown;
            $html .= '</td></tr>' . '<tr id="tr_element_before_generate_password"></tr>' . '</table>';
            $html .= '<div ' . ($orig_auth_plugin != 'sha256_password' ? 'style="display:none"' : '') . ' id="ssl_reqd_warning_cp">' . Message::notice(__('This method requires using an \'<i>SSL connection</i>\' ' . 'or an \'<i>unencrypted connection that encrypts the ' . 'password using RSA</i>\'; while connecting to the server.') . PMA\libraries\Util::showMySQLDocu('sha256-authentication-plugin'))->getDisplay() . '</div>';
        } else {
            $html .= '<tr id="tr_element_before_generate_password"></tr>' . '</table>';
        }
    } else {
        $auth_plugin_dropdown = PMA_getHtmlForAuthPluginsDropdown($orig_auth_plugin, 'change_pw', 'old');
        $html .= '<tr class="vmiddle">' . '<td>' . __('Password Hashing:') . '</td><td>';
        $html .= $auth_plugin_dropdown . '</td></tr>' . '<tr id="tr_element_before_generate_password"></tr>' . '</table>';
    }
    $html .= '</fieldset>' . '<fieldset id="fieldset_change_password_footer" class="tblFooters">' . '<input type="hidden" name="change_pw" value="1" />' . '<input type="submit" value="' . __('Go') . '" />' . '</fieldset>' . '</form>';
    return $html;
}
Example #11
0
                </div>
                <br />
                <?php 
echo '<input type="submit" name="submit_export" value="', __('Go'), '" />';
?>
            </form>
        </div>
        <div class="group">
            <h2><?php 
echo __('Reset');
?>
</h2>
            <form class="group-cnt prefs-form disableAjax" name="prefs_reset"
                  action="prefs_manage.php" method="post">
                <?php 
echo URL::getHiddenInputs(), __('You can reset all your settings and restore them to default ' . 'values.');
?>
                <br /><br />
                <input type="submit" name="submit_clear"
                       value="<?php 
echo __('Reset');
?>
"/>
            </form>
        </div>
    </div>
    <br class="clearfloat" />
</div>

<?php 
if ($response->isAjax()) {
Example #12
0
        $response->addJSON('message', PMA\libraries\Util::getMessage(PMA\libraries\Message::success(), $sql_query));
        $response->setRequestStatus(true);
    }
    exit;
}
// prefill values if not already filled from former submission
$view = array('operation' => 'create', 'or_replace' => '', 'algorithm' => '', 'definer' => '', 'sql_security' => '', 'name' => '', 'column_names' => '', 'as' => $sql_query, 'with' => '');
if (PMA_isValid($_REQUEST['view'], 'array')) {
    $view = array_merge($view, $_REQUEST['view']);
}
$url_params['db'] = $GLOBALS['db'];
$url_params['reload'] = 1;
/**
 * Displays the page
 */
$htmlString = '<!-- CREATE VIEW options -->' . '<div id="div_view_options">' . '<form method="post" action="view_create.php">' . URL::getHiddenInputs($url_params) . '<fieldset>' . '<legend>' . (isset($_REQUEST['ajax_dialog']) ? __('Details') : ($view['operation'] == 'create' ? __('Create view') : __('Edit view'))) . '</legend>' . '<table class="rte_table">';
if ($view['operation'] == 'create') {
    $htmlString .= '<tr>' . '<td class="nowrap"><label for="or_replace">OR REPLACE</label></td>' . '<td><input type="checkbox" name="view[or_replace]" id="or_replace"';
    if ($view['or_replace']) {
        $htmlString .= ' checked="checked"';
    }
    $htmlString .= ' value="1" /></td></tr>';
}
$htmlString .= '<tr>' . '<td class="nowrap"><label for="algorithm">ALGORITHM</label></td>' . '<td><select name="view[algorithm]" id="algorithm">';
foreach ($view_algorithm_options as $option) {
    $htmlString .= '<option value="' . htmlspecialchars($option) . '"';
    if ($view['algorithm'] === $option) {
        $htmlString .= ' selected="selected"';
    }
    $htmlString .= '>' . htmlspecialchars($option) . '</option>';
}
Example #13
0
/**
 * Get HTML snippet for partition maintenance
 *
 * @param array $partition_names array of partition names for a specific db/table
 * @param array $url_params      url parameters
 *
 * @return string $html_output
 */
function PMA_getHtmlForPartitionMaintenance($partition_names, $url_params)
{
    $choices = array('ANALYZE' => __('Analyze'), 'CHECK' => __('Check'), 'OPTIMIZE' => __('Optimize'), 'REBUILD' => __('Rebuild'), 'REPAIR' => __('Repair'), 'TRUNCATE' => __('Truncate'));
    $partition_method = Partition::getPartitionMethod($GLOBALS['db'], $GLOBALS['table']);
    // add COALESCE or DROP option to choices array depeding on Partition method
    if ($partition_method == 'RANGE' || $partition_method == 'RANGE COLUMNS' || $partition_method == 'LIST' || $partition_method == 'LIST COLUMNS') {
        $choices['DROP'] = __('Drop');
    } else {
        $choices['COALESCE'] = __('Coalesce');
    }
    $html_output = '<div class="operations_half_width">' . '<form id="partitionsForm" class="ajax" ' . 'method="post" action="tbl_operations.php" >' . URL::getHiddenInputs($GLOBALS['db'], $GLOBALS['table']) . '<fieldset>' . '<legend>' . __('Partition maintenance') . Util::showMySQLDocu('partitioning_maintenance') . '</legend>';
    $html_select = '<select id="partition_name" name="partition_name[]"' . ' multiple="multiple" required="required">' . "\n";
    $first = true;
    foreach ($partition_names as $one_partition) {
        $one_partition = htmlspecialchars($one_partition);
        $html_select .= '<option value="' . $one_partition . '"';
        if ($first) {
            $html_select .= ' selected="selected"';
            $first = false;
        }
        $html_select .= '>' . $one_partition . '</option>' . "\n";
    }
    $html_select .= '</select>' . "\n";
    $html_output .= sprintf(__('Partition %s'), $html_select);
    $html_output .= '<div class="clearfloat" />';
    $html_output .= Util::getRadioFields('partition_operation', $choices, 'ANALYZE', false, true, 'floatleft');
    $this_url_params = array_merge($url_params, array('sql_query' => 'ALTER TABLE ' . Util::backquote($GLOBALS['table']) . ' REMOVE PARTITIONING;'));
    $html_output .= '<div class="clearfloat" /><br />';
    $html_output .= '<a href="sql.php' . URL::getCommon($this_url_params) . '">' . __('Remove partitioning') . '</a>';
    $html_output .= '</fieldset>' . '<fieldset class="tblFooters">' . '<input type="hidden" name="submit_partition" value="1">' . '<input type="submit" value="' . __('Go') . '" />' . '</fieldset>' . '</form>' . '</div>';
    return $html_output;
}
/**
 * Shows form which allows to quickly load
 * settings stored in browser's local storage
 *
 * @return string
 */
function PMA_userprefsAutoloadGetHeader()
{
    if (isset($_REQUEST['prefs_autoload']) && $_REQUEST['prefs_autoload'] == 'hide') {
        $_SESSION['userprefs_autoload'] = true;
        return '';
    }
    $script_name = basename(basename($GLOBALS['PMA_PHP_SELF']));
    $return_url = htmlspecialchars($script_name . '?' . http_build_query($_GET, '', '&'));
    return PMA\libraries\Template::get('prefs_autoload')->render(array('hiddenInputs' => URL::getHiddenInputs(), 'return_url' => $return_url));
}
Example #15
0
/**
 * Displays a form used to add/edit an event
 *
 * @param string $mode      If the editor will be used to edit an event
 *                              or add a new one: 'edit' or 'add'.
 * @param string $operation If the editor was previously invoked with
 *                              JS turned off, this will hold the name of
 *                              the current operation
 * @param array  $item      Data for the event returned by
 *                              PMA_EVN_getDataFromRequest() or
 *                              PMA_EVN_getDataFromName()
 *
 * @return string   HTML code for the editor.
 */
function PMA_EVN_getEditorForm($mode, $operation, $item)
{
    global $db, $table, $event_status, $event_type, $event_interval;
    $modeToUpper = mb_strtoupper($mode);
    // Escape special characters
    $need_escape = array('item_original_name', 'item_name', 'item_type', 'item_execute_at', 'item_interval_value', 'item_starts', 'item_ends', 'item_definition', 'item_definer', 'item_comment');
    foreach ($need_escape as $index) {
        $item[$index] = htmlentities($item[$index], ENT_QUOTES);
    }
    $original_data = '';
    if ($mode == 'edit') {
        $original_data = "<input name='item_original_name' " . "type='hidden' value='{$item['item_original_name']}'/>\n";
    }
    // Handle some logic first
    if ($operation == 'change') {
        if ($item['item_type'] == 'RECURRING') {
            $item['item_type'] = 'ONE TIME';
            $item['item_type_toggle'] = 'RECURRING';
        } else {
            $item['item_type'] = 'RECURRING';
            $item['item_type_toggle'] = 'ONE TIME';
        }
    }
    if ($item['item_type'] == 'ONE TIME') {
        $isrecurring_class = ' hide';
        $isonetime_class = '';
    } else {
        $isrecurring_class = '';
        $isonetime_class = ' hide';
    }
    // Create the output
    $retval = "";
    $retval .= "<!-- START " . $modeToUpper . " EVENT FORM -->\n\n";
    $retval .= "<form class='rte_form' action='db_events.php' method='post'>\n";
    $retval .= "<input name='{$mode}_item' type='hidden' value='1' />\n";
    $retval .= $original_data;
    $retval .= URL::getHiddenInputs($db, $table) . "\n";
    $retval .= "<fieldset>\n";
    $retval .= "<legend>" . __('Details') . "</legend>\n";
    $retval .= "<table class='rte_table' style='width: 100%'>\n";
    $retval .= "<tr>\n";
    $retval .= "    <td style='width: 20%;'>" . __('Event name') . "</td>\n";
    $retval .= "    <td><input type='text' name='item_name' \n";
    $retval .= "               value='{$item['item_name']}'\n";
    $retval .= "               maxlength='64' /></td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr>\n";
    $retval .= "    <td>" . __('Status') . "</td>\n";
    $retval .= "    <td>\n";
    $retval .= "        <select name='item_status'>\n";
    foreach ($event_status['display'] as $key => $value) {
        $selected = "";
        if (!empty($item['item_status']) && $item['item_status'] == $value) {
            $selected = " selected='selected'";
        }
        $retval .= "<option{$selected}>{$value}</option>";
    }
    $retval .= "        </select>\n";
    $retval .= "    </td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr>\n";
    $retval .= "    <td>" . __('Event type') . "</td>\n";
    $retval .= "    <td>\n";
    if ($GLOBALS['is_ajax_request']) {
        $retval .= "        <select name='item_type'>";
        foreach ($event_type as $key => $value) {
            $selected = "";
            if (!empty($item['item_type']) && $item['item_type'] == $value) {
                $selected = " selected='selected'";
            }
            $retval .= "<option{$selected}>{$value}</option>";
        }
        $retval .= "        </select>\n";
    } else {
        $retval .= "        <input name='item_type' type='hidden' \n";
        $retval .= "               value='{$item['item_type']}' />\n";
        $retval .= "        <div class='floatleft' style='width: 49%; " . "text-align: center; font-weight: bold;'>\n";
        $retval .= "            {$item['item_type']}\n";
        $retval .= "        </div>\n";
        $retval .= "        <input style='width: 49%;' type='submit'\n";
        $retval .= "               name='item_changetype'\n";
        $retval .= "               value='";
        $retval .= sprintf(__('Change to %s'), $item['item_type_toggle']);
        $retval .= "' />\n";
    }
    $retval .= "    </td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr class='onetime_event_row {$isonetime_class}'>\n";
    $retval .= "    <td>" . __('Execute at') . "</td>\n";
    $retval .= "    <td class='nowrap'>\n";
    $retval .= "        <input type='text' name='item_execute_at'\n";
    $retval .= "               value='{$item['item_execute_at']}'\n";
    $retval .= "               class='datetimefield' />\n";
    $retval .= "    </td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr class='recurring_event_row {$isrecurring_class}'>\n";
    $retval .= "    <td>" . __('Execute every') . "</td>\n";
    $retval .= "    <td>\n";
    $retval .= "        <input style='width: 49%;' type='text'\n";
    $retval .= "               name='item_interval_value'\n";
    $retval .= "               value='{$item['item_interval_value']}' />\n";
    $retval .= "        <select style='width: 49%;' name='item_interval_field'>";
    foreach ($event_interval as $key => $value) {
        $selected = "";
        if (!empty($item['item_interval_field']) && $item['item_interval_field'] == $value) {
            $selected = " selected='selected'";
        }
        $retval .= "<option{$selected}>{$value}</option>";
    }
    $retval .= "        </select>\n";
    $retval .= "    </td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr class='recurring_event_row{$isrecurring_class}'>\n";
    $retval .= "    <td>" . _pgettext('Start of recurring event', 'Start');
    $retval .= "    </td>\n";
    $retval .= "    <td class='nowrap'>\n";
    $retval .= "        <input type='text'\n name='item_starts'\n";
    $retval .= "               value='{$item['item_starts']}'\n";
    $retval .= "               class='datetimefield' />\n";
    $retval .= "    </td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr class='recurring_event_row{$isrecurring_class}'>\n";
    $retval .= "    <td>" . _pgettext('End of recurring event', 'End') . "</td>\n";
    $retval .= "    <td class='nowrap'>\n";
    $retval .= "        <input type='text' name='item_ends'\n";
    $retval .= "               value='{$item['item_ends']}'\n";
    $retval .= "               class='datetimefield' />\n";
    $retval .= "    </td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr>\n";
    $retval .= "    <td>" . __('Definition') . "</td>\n";
    $retval .= "    <td><textarea name='item_definition' rows='15' cols='40'>";
    $retval .= $item['item_definition'];
    $retval .= "</textarea></td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr>\n";
    $retval .= "    <td>" . __('On completion preserve') . "</td>\n";
    $retval .= "    <td><input type='checkbox'\n";
    $retval .= "             name='item_preserve'{$item['item_preserve']} /></td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr>\n";
    $retval .= "    <td>" . __('Definer') . "</td>\n";
    $retval .= "    <td><input type='text' name='item_definer'\n";
    $retval .= "               value='{$item['item_definer']}' /></td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr>\n";
    $retval .= "    <td>" . __('Comment') . "</td>\n";
    $retval .= "    <td><input type='text' name='item_comment' maxlength='64'\n";
    $retval .= "               value='{$item['item_comment']}' /></td>\n";
    $retval .= "</tr>\n";
    $retval .= "</table>\n";
    $retval .= "</fieldset>\n";
    if ($GLOBALS['is_ajax_request']) {
        $retval .= "<input type='hidden' name='editor_process_{$mode}'\n";
        $retval .= "       value='true' />\n";
        $retval .= "<input type='hidden' name='ajax_request' value='true' />\n";
    } else {
        $retval .= "<fieldset class='tblFooters'>\n";
        $retval .= "    <input type='submit' name='editor_process_{$mode}'\n";
        $retval .= "           value='" . __('Go') . "' />\n";
        $retval .= "</fieldset>\n";
    }
    $retval .= "</form>\n\n";
    $retval .= "<!-- END " . $modeToUpper . " EVENT FORM -->\n\n";
    return $retval;
}
Example #16
0
} else {
    $pos = 0;
}
$addNewColumn = PMA_getHTMLforAddNewColumn($db);
$response->addHTML($addNewColumn);
if ($total_rows <= 0) {
    $response->addHTML('<fieldset>' . __('The central list of columns for the current database is empty.') . '</fieldset>');
    $columnAdd = PMA_getHTMLforAddCentralColumn($total_rows, $pos, $db);
    $response->addHTML($columnAdd);
    exit;
}
$table_navigation_html = PMA_getHTMLforTableNavigation($total_rows, $pos, $db);
$response->addHTML($table_navigation_html);
$columnAdd = PMA_getHTMLforAddCentralColumn($total_rows, $pos, $db);
$response->addHTML($columnAdd);
$deleteRowForm = '<form method="post" id="del_form" action="db_central_columns.php">' . URL::getHiddenInputs($db) . '<input id="del_col_name" type="hidden" name="col_name" value="">' . '<input type="hidden" name="pos" value="' . $pos . '">' . '<input type="hidden" name="delete_save" value="delete"></form>';
$response->addHTML($deleteRowForm);
$table_struct = '<div id="tableslistcontainer">' . '<form name="tableslistcontainer">' . '<table id="table_columns" class="tablesorter" ' . 'style="min-width:100%" class="data">';
$response->addHTML($table_struct);
$tableheader = PMA_getCentralColumnsTableHeader('column_heading', __('Click to sort.'), 2);
$response->addHTML($tableheader);
$result = PMA_getColumnsList($db, $pos, $max_rows);
$row_num = 0;
foreach ($result as $row) {
    $tableHtmlRow = PMA_getHTMLforCentralColumnsTableRow($row, $row_num, $db);
    $response->addHTML($tableHtmlRow);
    $row_num++;
}
$response->addHTML('</table>');
$tablefooter = PMA_getCentralColumnsTableFooter($pmaThemeImage, $text_dir);
$response->addHTML($tablefooter);
Example #17
0
/**
 * generates the error report form to collect user description and preview the
 * report before being sent
 *
 * @return String the form
 */
function PMA_getErrorReportForm()
{
    $datas = array('report_data' => PMA_getPrettyReportData(), 'hidden_inputs' => URL::getHiddenInputs(), 'hidden_fields' => null);
    $reportData = PMA_getReportData();
    if (!empty($reportData)) {
        $datas['hidden_fields'] = URL::getHiddenFields($reportData);
    }
    return PMA\libraries\Template::get('error/report_form')->render($datas);
}
    /**
     * 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
        );

        //URL::getHiddenInputs
        $this->assertContains(
            URL::getHiddenInputs('', ''),
            $html
        );

        //items
        $this->assertContains(
            __('User'),
            $html
        );
        $this->assertContains(
            __('Host'),
            $html
        );
        $this->assertContains(
            __('Password'),
            $html
        );
        $this->assertContains(
            __('Global privileges'),
            $html
        );

        //PMA\libraries\Util::showHint
        $this->assertContains(
            PMA\libraries\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
        );
    }
Example #19
0
    /**
     * Prepare navigation for a list
     *
     * @param int      $count       number of elements in the list
     * @param int      $pos         current position in the list
     * @param array    $_url_params url parameters
     * @param string   $script      script name for form target
     * @param string   $frame       target frame
     * @param int      $max_count   maximum number of elements to display from
     *                              the list
     * @param string   $name        the name for the request parameter
     * @param string[] $classes     additional classes for the container
     *
     * @return string $list_navigator_html the  html content
     *
     * @access  public
     *
     * @todo    use $pos from $_url_params
     */
    public static function getListNavigator(
        $count, $pos, $_url_params, $script, $frame, $max_count, $name = 'pos',
        $classes = array()
    ) {

        $class = $frame == 'frame_navigation' ? ' class="ajax"' : '';

        $list_navigator_html = '';

        if ($max_count < $count) {

            $classes[] = 'pageselector';
            $list_navigator_html .= '<div class="' . implode(' ', $classes) . '">';

            if ($frame != 'frame_navigation') {
                $list_navigator_html .= __('Page number:');
            }

            // Move to the beginning or to the previous page
            if ($pos > 0) {
                $caption1 = ''; $caption2 = '';
                if (self::showIcons('TableNavigationLinksMode')) {
                    $caption1 .= '&lt;&lt; ';
                    $caption2 .= '&lt; ';
                }
                if (self::showText('TableNavigationLinksMode')) {
                    $caption1 .= _pgettext('First page', 'Begin');
                    $caption2 .= _pgettext('Previous page', 'Previous');
                }
                $title1 = ' title="' . _pgettext('First page', 'Begin') . '"';
                $title2 = ' title="' . _pgettext('Previous page', 'Previous') . '"';

                $_url_params[$name] = 0;
                $list_navigator_html .= '<a' . $class . $title1 . ' href="' . $script
                    . URL::getCommon($_url_params) . '">' . $caption1
                    . '</a>';

                $_url_params[$name] = $pos - $max_count;
                $list_navigator_html .= ' <a' . $class . $title2
                    . ' href="' . $script . URL::getCommon($_url_params) . '">'
                    . $caption2 . '</a>';
            }

            $list_navigator_html .= '<form action="' . basename($script)
                . '" method="post">';

            $list_navigator_html .= URL::getHiddenInputs($_url_params);
            $list_navigator_html .= self::pageselector(
                $name,
                $max_count,
                floor(($pos + 1) / $max_count) + 1,
                ceil($count / $max_count)
            );
            $list_navigator_html .= '</form>';

            if ($pos + $max_count < $count) {
                $caption3 = ''; $caption4 = '';
                if (self::showText('TableNavigationLinksMode')) {
                    $caption3 .= _pgettext('Next page', 'Next');
                    $caption4 .= _pgettext('Last page', 'End');
                }
                if (self::showIcons('TableNavigationLinksMode')) {
                    $caption3 .= ' &gt;';
                    $caption4 .= ' &gt;&gt;';
                    if (! self::showText('TableNavigationLinksMode')) {

                    }
                }
                $title3 = ' title="' . _pgettext('Next page', 'Next') . '"';
                $title4 = ' title="' . _pgettext('Last page', 'End') . '"';

                $_url_params[$name] = $pos + $max_count;
                $list_navigator_html .= '<a' . $class . $title3 . ' href="' . $script
                    . URL::getCommon($_url_params) . '" >' . $caption3
                    . '</a>';

                $_url_params[$name] = floor($count / $max_count) * $max_count;
                if ($_url_params[$name] == $count) {
                    $_url_params[$name] = $count - $max_count;
                }

                $list_navigator_html .= ' <a' . $class . $title4
                    . ' href="' . $script . URL::getCommon($_url_params) . '" >'
                    . $caption4 . '</a>';
            }
            $list_navigator_html .= '</div>' . "\n";
        }

        return $list_navigator_html;
    }
Example #20
0
/**
 * Display tracked tables
 *
 * @param string $db                current database
 * @param object $all_tables_result result set of tracked tables
 * @param string $url_query         url query string
 * @param string $pmaThemeImage     path to theme's image folder
 * @param string $text_dir          text direction
 * @param array  $cfgRelation       configuration storage info
 *
 * @return void
 */
function PMA_displayTrackedTables($db, $all_tables_result, $url_query, $pmaThemeImage, $text_dir, $cfgRelation)
{
    ?>
    <div id="tracked_tables">
    <h3><?php 
    echo __('Tracked tables');
    ?>
</h3>

    <form method="post" action="db_tracking.php" name="trackedForm"
        id="trackedForm" class="ajax">
    <?php 
    echo URL::getHiddenInputs($db);
    ?>
    <table id="versions" class="data">
    <thead>
    <tr>
        <th></th>
        <th><?php 
    echo __('Table');
    ?>
</th>
        <th><?php 
    echo __('Last version');
    ?>
</th>
        <th><?php 
    echo __('Created');
    ?>
</th>
        <th><?php 
    echo __('Updated');
    ?>
</th>
        <th><?php 
    echo __('Status');
    ?>
</th>
        <th><?php 
    echo __('Action');
    ?>
</th>
        <th><?php 
    echo __('Show');
    ?>
</th>
    </tr>
    </thead>
    <tbody>
    <?php 
    // Print out information about versions
    $delete = PMA\libraries\Util::getIcon('b_drop.png', __('Delete tracking'));
    $versions = PMA\libraries\Util::getIcon('b_versions.png', __('Versions'));
    $report = PMA\libraries\Util::getIcon('b_report.png', __('Tracking report'));
    $structure = PMA\libraries\Util::getIcon('b_props.png', __('Structure snapshot'));
    $style = 'odd';
    while ($one_result = $GLOBALS['dbi']->fetchArray($all_tables_result)) {
        list($table_name, $version_number) = $one_result;
        $table_query = ' SELECT * FROM ' . PMA\libraries\Util::backquote($cfgRelation['db']) . '.' . PMA\libraries\Util::backquote($cfgRelation['tracking']) . ' WHERE `db_name` = \'' . PMA\libraries\Util::sqlAddSlashes($_REQUEST['db']) . '\' AND `table_name`  = \'' . PMA\libraries\Util::sqlAddSlashes($table_name) . '\' AND `version` = \'' . $version_number . '\'';
        $table_result = PMA_queryAsControlUser($table_query);
        $version_data = $GLOBALS['dbi']->fetchArray($table_result);
        $tbl_link = 'tbl_tracking.php' . $url_query . '&amp;table=' . htmlspecialchars($version_data['table_name']);
        $delete_link = 'db_tracking.php' . $url_query . '&amp;table=' . htmlspecialchars($version_data['table_name']) . '&amp;delete_tracking=true&amp';
        $checkbox_id = "selected_tbl_" . htmlspecialchars($version_data['table_name']);
        ?>
        <tr class="<?php 
        echo $style;
        ?>
">
            <td class="center">
                <input type="checkbox" name="selected_tbl[]"
                class="checkall" id="<?php 
        echo $checkbox_id;
        ?>
"
                value="<?php 
        echo htmlspecialchars($version_data['table_name']);
        ?>
"/>
            </td>
            <th>
                <label for="<?php 
        echo $checkbox_id;
        ?>
">
                    <?php 
        echo htmlspecialchars($version_data['table_name']);
        ?>
                </label>
            </th>
            <td class="right"><?php 
        echo $version_data['version'];
        ?>
</td>
            <td><?php 
        echo $version_data['date_created'];
        ?>
</td>
            <td><?php 
        echo $version_data['date_updated'];
        ?>
</td>
            <td>
            <?php 
        PMA_displayStatusButton($version_data, $tbl_link);
        ?>
            </td>
            <td>
            <a class="delete_tracking_anchor ajax"
               href="<?php 
        echo $delete_link;
        ?>
" >
            <?php 
        echo $delete;
        ?>
</a>
        <?php 
        echo '</td>', '<td>', '<a href="', $tbl_link, '">', $versions, '</a>', '&nbsp;&nbsp;', '<a href="', $tbl_link, '&amp;report=true&amp;version=', $version_data['version'], '">', $report, '</a>', '&nbsp;&nbsp;', '<a href="' . $tbl_link, '&amp;snapshot=true&amp;version=', $version_data['version'], '">', $structure, '</a>', '</td>', '</tr>';
        if ($style == 'even') {
            $style = 'odd';
        } else {
            $style = 'even';
        }
    }
    ?>
    </tbody>
    </table>
    <?php 
    echo PMA\libraries\Template::get('select_all')->render(array('pmaThemeImage' => $pmaThemeImage, 'text_dir' => $text_dir, 'formName' => 'trackedForm'));
    echo PMA\libraries\Util::getButtonOrImage('submit_mult', 'mult_submit', __('Delete tracking'), 'b_drop.png', 'delete_tracking');
    ?>
    </form>
    </div>
    <?php 
}
Example #21
0
 /**
  * Provides the generated QBE form
  *
  * @return string QBE form
  */
 public function getSelectionForm()
 {
     $html_output = '<form action="db_qbe.php" method="post" id="formQBE" ' . 'class="lock-page">';
     $html_output .= '<fieldset>';
     if ($GLOBALS['cfgRelation']['savedsearcheswork']) {
         $html_output .= $this->_getSavedSearchesField();
     }
     $html_output .= '<table class="data" style="width: 100%;">';
     // Get table's <tr> elements
     $html_output .= $this->_getColumnNamesRow();
     $html_output .= $this->_getColumnAliasRow();
     $html_output .= $this->_getShowRow();
     $html_output .= $this->_getSortRow();
     $html_output .= $this->_getSortOrder();
     $html_output .= $this->_getCriteriaInputboxRow();
     $html_output .= $this->_getInsDelAndOrCriteriaRows();
     $html_output .= $this->_getModifyColumnsRow();
     $html_output .= '</table>';
     $this->_new_row_count--;
     $url_params = array();
     $url_params['db'] = $this->_db;
     $url_params['criteriaColumnCount'] = $this->_new_column_count;
     $url_params['rows'] = $this->_new_row_count;
     $html_output .= URL::getHiddenInputs($url_params);
     $html_output .= '</fieldset>';
     // get footers
     $html_output .= $this->_getTableFooters();
     // get tables select list
     $html_output .= $this->_getTablesList();
     $html_output .= '</form>';
     $html_output .= '<form action="db_qbe.php" method="post" class="lock-page">';
     $html_output .= URL::getHiddenInputs(array('db' => $this->_db));
     // get SQL query
     $html_output .= '<div class="floatleft" style="width:50%">';
     $html_output .= '<fieldset>';
     $html_output .= '<legend>' . sprintf(__('SQL query on database <b>%s</b>:'), Util::getDbLink($this->_db));
     $html_output .= '</legend>';
     $text_dir = 'ltr';
     $html_output .= '<textarea cols="80" name="sql_query" id="textSqlquery"' . ' rows="' . (count($this->_criteriaTables) > 30 ? '15' : '7') . '"' . ' dir="' . $text_dir . '">';
     if (empty($this->_formColumns)) {
         $this->_formColumns = array();
     }
     $html_output .= $this->_getSQLQuery($this->_formColumns);
     $html_output .= '</textarea>';
     $html_output .= '</fieldset>';
     // displays form's footers
     $html_output .= '<fieldset class="tblFooters">';
     $html_output .= '<input type="hidden" name="submit_sql" value="1" />';
     $html_output .= '<input type="submit" value="' . __('Submit Query') . '" />';
     $html_output .= '</fieldset>';
     $html_output .= '</div>';
     $html_output .= '</form>';
     return $html_output;
 }
/**
 * Get HTML snippet for display user properties
 *
 * @param boolean $dbname_is_wildcard whether database name is wildcard or not
 * @param string  $url_dbname         url database name that urlencode() string
 * @param string  $username           username
 * @param string  $hostname           host name
 * @param string  $dbname             database name
 * @param string  $tablename          table name
 *
 * @return string $html_output
 */
function PMA_getHtmlForUserProperties($dbname_is_wildcard, $url_dbname, $username, $hostname, $dbname, $tablename)
{
    $html_output = '<div id="edit_user_dialog">';
    $html_output .= PMA_getHtmlHeaderForUserProperties($dbname_is_wildcard, $url_dbname, $dbname, $username, $hostname, $tablename, 'table');
    $sql = "SELECT '1' FROM `mysql`.`user`" . " WHERE `User` = '" . $GLOBALS['dbi']->escapeString($username) . "'" . " AND `Host` = '" . $GLOBALS['dbi']->escapeString($hostname) . "';";
    $user_does_not_exists = (bool) (!$GLOBALS['dbi']->fetchValue($sql));
    if ($user_does_not_exists) {
        $html_output .= Message::error(__('The selected user was not found in the privilege table.'))->getDisplay();
        $html_output .= PMA_getHtmlForLoginInformationFields();
    }
    $_params = array('username' => $username, 'hostname' => $hostname);
    if (!is_array($dbname) && strlen($dbname) > 0) {
        $_params['dbname'] = $dbname;
        if (strlen($tablename) > 0) {
            $_params['tablename'] = $tablename;
        }
    } else {
        $_params['dbname'] = $dbname;
    }
    $html_output .= '<form class="submenu-item" name="usersForm" ' . 'id="addUsersForm" action="server_privileges.php" method="post">' . "\n";
    $html_output .= URL::getHiddenInputs($_params);
    $html_output .= PMA_getHtmlToDisplayPrivilegesTable(PMA_ifSetOr($dbname, is_array($dbname) ? $dbname[0] : '*', 'length'), PMA_ifSetOr($tablename, '*', 'length'));
    $html_output .= '</form>' . "\n";
    if (!is_array($dbname) && strlen($tablename) === 0 && empty($dbname_is_wildcard)) {
        // no table name was given, display all table specific rights
        // but only if $dbname contains no wildcards
        if (strlen($dbname) === 0) {
            $html_output .= PMA_getHtmlForAllTableSpecificRights($username, $hostname, 'database');
        } else {
            // unescape wildcards in dbname at table level
            $unescaped_db = Util::unescapeMysqlWildcards($dbname);
            $html_output .= PMA_getHtmlForAllTableSpecificRights($username, $hostname, 'table', $unescaped_db);
            $html_output .= PMA_getHtmlForAllTableSpecificRights($username, $hostname, 'routine', $unescaped_db);
        }
    }
    // Provide a line with links to the relevant database and table
    if (!is_array($dbname) && strlen($dbname) > 0 && empty($dbname_is_wildcard)) {
        $html_output .= PMA_getLinkToDbAndTable($url_dbname, $dbname, $tablename);
    }
    if (!is_array($dbname) && strlen($dbname) === 0 && !$user_does_not_exists) {
        //change login information
        $html_output .= PMA_getHtmlForChangePassword('edit_other', $username, $hostname);
        $html_output .= PMA_getChangeLoginInformationHtmlForm($username, $hostname);
    }
    $html_output .= '</div>';
    return $html_output;
}
Example #23
0
/**
 * get html for continue insertion form
 *
 * @param string $table              name of the table
 * @param string $db                 name of the database
 * @param array  $where_clause_array array of where clauses
 * @param string $err_url            error url
 *
 * @return string                   an html snippet
 */
function PMA_getContinueInsertionForm($table, $db, $where_clause_array, $err_url)
{
    $html_output = '<form id="continueForm" method="post"' . ' action="tbl_replace.php" name="continueForm">' . URL::getHiddenInputs($db, $table) . '<input type="hidden" name="goto"' . ' value="' . htmlspecialchars($GLOBALS['goto']) . '" />' . '<input type="hidden" name="err_url"' . ' value="' . htmlspecialchars($err_url) . '" />' . '<input type="hidden" name="sql_query"' . ' value="' . htmlspecialchars($_REQUEST['sql_query']) . '" />';
    if (isset($_REQUEST['where_clause'])) {
        foreach ($where_clause_array as $key_id => $where_clause) {
            $html_output .= '<input type="hidden"' . ' name="where_clause[' . $key_id . ']"' . ' value="' . htmlspecialchars(trim($where_clause)) . '" />' . "\n";
        }
    }
    $tmp = '<select name="insert_rows" id="insert_rows">' . "\n";
    $option_values = array(1, 2, 5, 10, 15, 20, 30, 40);
    foreach ($option_values as $value) {
        $tmp .= '<option value="' . $value . '"';
        if ($value == $GLOBALS['cfg']['InsertRows']) {
            $tmp .= ' selected="selected"';
        }
        $tmp .= '>' . $value . '</option>' . "\n";
    }
    $tmp .= '</select>' . "\n";
    $html_output .= "\n" . sprintf(__('Continue insertion with %s rows'), $tmp);
    unset($tmp);
    $html_output .= '</form>' . "\n";
    return $html_output;
}
Example #24
0
/**
 * Function to get html for bookmark support if bookmarks are enabled. Else will
 * return null
 *
 * @param array  $displayParts   the parts to display
 * @param array  $cfgBookmark    configuration setting for bookmarking
 * @param string $sql_query      sql query
 * @param string $db             current database
 * @param string $table          current table
 * @param string $complete_query complete query
 * @param string $bkm_user       bookmarking user
 *
 * @return string $html
 */
function PMA_getHtmlForBookmark($displayParts, $cfgBookmark, $sql_query, $db, $table, $complete_query, $bkm_user)
{
    if ($displayParts['bkm_form'] == '1' && (!empty($cfgBookmark) && empty($_GET['id_bookmark'])) && !empty($sql_query)) {
        $goto = 'sql.php' . URL::getCommon(array('db' => $db, 'table' => $table, 'sql_query' => $sql_query, 'id_bookmark' => 1));
        $bkm_sql_query = urlencode(isset($complete_query) ? $complete_query : $sql_query);
        $html = '<form action="sql.php" method="post"' . ' onsubmit="return ! emptyCheckTheField(this,' . '\'bkm_fields[bkm_label]\');"' . ' class="bookmarkQueryForm print_ignore">';
        $html .= URL::getHiddenInputs();
        $html .= '<input type="hidden" name="db"' . ' value="' . htmlspecialchars($db) . '" />';
        $html .= '<input type="hidden" name="goto" value="' . $goto . '" />';
        $html .= '<input type="hidden" name="bkm_fields[bkm_database]"' . ' value="' . htmlspecialchars($db) . '" />';
        $html .= '<input type="hidden" name="bkm_fields[bkm_user]"' . ' value="' . $bkm_user . '" />';
        $html .= '<input type="hidden" name="bkm_fields[bkm_sql_query]"' . ' value="' . $bkm_sql_query . '" />';
        $html .= '<fieldset>';
        $html .= '<legend>';
        $html .= PMA\libraries\Util::getIcon('b_bookmark.png', __('Bookmark this SQL query'), true);
        $html .= '</legend>';
        $html .= '<div class="formelement">';
        $html .= '<label>' . __('Label:');
        $html .= '<input type="text" name="bkm_fields[bkm_label]" value="" />' . '</label>';
        $html .= '</div>';
        $html .= '<div class="formelement">';
        $html .= '<label>' . '<input type="checkbox" name="bkm_all_users" value="true" />';
        $html .= __('Let every user access this bookmark') . '</label>';
        $html .= '</div>';
        $html .= '<div class="clearfloat"></div>';
        $html .= '</fieldset>';
        $html .= '<fieldset class="tblFooters">';
        $html .= '<input type="hidden" name="store_bkm" value="1" />';
        $html .= '<input type="submit"' . ' value="' . __('Bookmark this SQL query') . '" />';
        $html .= '</fieldset>';
        $html .= '</form>';
    } else {
        $html = null;
    }
    return $html;
}
 /**
  * Test for PMA_getHtmlForOtherActions
  *
  * @return void
  */
 public function testPMAGetHtmlForOtherActions()
 {
     $what = 'replace_prefix_tbl';
     $action = 'delete_row';
     $_url_params = array('url_query' => 'PMA_original_url_query');
     $full_query = 'select column from PMA_table';
     //Call the test function
     $html = PMA_getHtmlForOtherActions($what, $action, $_url_params, $full_query);
     //validate 1: form action
     $this->assertContains('<form action="' . $action . '" method="post">', $html);
     //validate 2: $_url_params
     $this->assertContains(URL::getHiddenInputs($_url_params), $html);
     //validate 3: conform
     $this->assertContains(__('Do you really want to execute the following query?'), $html);
     //validate 4: query
     $this->assertContains('<code>' . $full_query . '</code>', $html);
     //validate 5: button : yes or no
     $this->assertContains(__('Yes'), $html);
     $this->assertContains(__('No'), $html);
 }
Example #26
0
    }
    /**
     * Displays the mysql server related links
     */
    if ($server > 0) {
        include_once 'libraries/check_user_privileges.lib.php';
        // Logout for advanced authentication
        if ($cfg['Server']['auth_type'] != 'config') {
            if ($cfg['ShowChgPassword']) {
                $conditional_class = 'ajax';
                PMA_printListItem(PMA\libraries\Util::getImage('s_passwd.png') . "&nbsp;" . __('Change password'), 'li_change_password', 'user_password.php' . $common_url_query, null, null, 'change_password_anchor', "no_bullets", $conditional_class);
            }
        }
        // end if
        echo '    <li id="li_select_mysql_collation" class="no_bullets" >';
        echo '        <form method="post" action="index.php">', "\n" . URL::getHiddenInputs(null, null, 4, 'collation_connection') . '            <label for="select_collation_connection">' . "\n" . '                ' . PMA\libraries\Util::getImage('s_asci.png') . "&nbsp;" . __('Server connection collation') . "\n" . PMA\libraries\Util::showMySQLDocu('Charset-connection') . ': ' . "\n" . '            </label>' . "\n" . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'collation_connection', 'select_collation_connection', $collation_connection, true, true) . '        </form>' . "\n" . '    </li>' . "\n";
    }
    // end of if ($server > 0)
    echo '</ul>';
    echo '</div>';
}
echo '<div class="group">';
echo '<h2>', __('Appearance settings'), '</h2>';
echo '  <ul>';
// Displays language selection combo
if (empty($cfg['Lang'])) {
    echo '<li id="li_select_lang" class="no_bullets">';
    include_once 'libraries/display_select_lang.lib.php';
    echo PMA\libraries\Util::getImage('s_lang.png'), " ", PMA_getLanguageSelectorHtml();
    echo '</li>';
}
Example #27
0
/**
 * Prints Html For Export Hidden Input
 *
 * @param String $export_type  Selected Export Type
 * @param String $db           Selected DB
 * @param String $table        Selected Table
 * @param String $single_table Single Table
 * @param String $sql_query    Sql Query
 *
 * @return string
 */
function PMA_getHtmlForHiddenInput($export_type, $db, $table, $single_table, $sql_query)
{
    global $cfg;
    $html = "";
    if ($export_type == 'server') {
        $html .= URL::getHiddenInputs('', '', 1);
    } elseif ($export_type == 'database') {
        $html .= URL::getHiddenInputs($db, '', 1);
    } else {
        $html .= URL::getHiddenInputs($db, $table, 1);
    }
    // just to keep this value for possible next display of this form after saving
    // on server
    if (!empty($single_table)) {
        $html .= '<input type="hidden" name="single_table" value="TRUE" />' . "\n";
    }
    $html .= '<input type="hidden" name="export_type" value="' . $export_type . '" />';
    $html .= "\n";
    // If the export method was not set, the default is quick
    if (isset($_GET['export_method'])) {
        $cfg['Export']['method'] = $_GET['export_method'];
    } elseif (!isset($cfg['Export']['method'])) {
        $cfg['Export']['method'] = 'quick';
    }
    // The export method (quick, custom or custom-no-form)
    $html .= '<input type="hidden" name="export_method" value="' . htmlspecialchars($cfg['Export']['method']) . '" />';
    if (!empty($sql_query)) {
        $html .= '<input type="hidden" name="sql_query" value="' . htmlspecialchars($sql_query) . '" />' . "\n";
    } elseif (isset($_GET['sql_query'])) {
        $html .= '<input type="hidden" name="sql_query" value="' . htmlspecialchars($_GET['sql_query']) . '" />' . "\n";
    }
    $html .= '<input type="hidden" name="template_id"' . ' value="' . (isset($_GET['template_id']) ? htmlspecialchars($_GET['template_id']) : '') . '" />';
    return $html;
}
Example #28
0
    PMA_messagesSet('error', 'config_rw', __('Cannot load or save configuration'), Sanitize::sanitize(__('Please create web server writable folder [em]config[/em] in ' . 'phpMyAdmin top level directory as described in ' . '[doc@setup_script]documentation[/doc]. Otherwise you will be ' . 'only able to download or display it.')));
}
//
// Check https connection
//
$is_https = !empty($_SERVER['HTTPS']) && mb_strtolower($_SERVER['HTTPS']) == 'on';
if (!$is_https) {
    $text = __('You are not using a secure connection; all data (including potentially ' . 'sensitive information, like passwords) is transferred unencrypted!');
    $text .= ' <a href="#" onclick="window.location.href = \'https:\' + window.location.href.substring(window.location.protocol.length);">';
    // Temporary workaround to use tranlated message in older releases
    $text .= str_replace(array('[a@%s]', '[/a]'), array('', ''), __('If your server is also configured to accept HTTPS requests ' . 'follow [a@%s]this link[/a] to use a secure connection.'));
    $text .= '</a>';
    PMA_messagesSet('notice', 'no_https', __('Insecure connection'), $text);
}
echo '<form id="select_lang" method="post" action="', htmlspecialchars($_SERVER['REQUEST_URI']), '">';
echo URL::getHiddenInputs();
echo '<bdo lang="en" dir="ltr"><label for="lang">';
echo __('Language'), __('Language') != 'Language' ? ' - Language' : '';
echo '</label></bdo><br />';
echo '<select id="lang" name="lang" class="autosubmit" lang="en" dir="ltr">';
// create language list
$lang_list = array();
foreach ($all_languages as $each_lang) {
    //Is current one active?
    $selected = $each_lang->isActive() ? ' selected="selected"' : '';
    echo '<option value="', $each_lang->getCode(), '"', $selected, '>', $each_lang->getName(), '</option>', "\n";
}
echo '</select>';
echo '</form>';
// Check for done action info and set notice message if present
switch ($action_done) {
Example #29
0
$o_rows = 0;
$biggest_max_file_size = 0;
$url_params['db'] = $db;
$url_params['table'] = $table;
$url_params = PMA_urlParamsInEditMode($url_params, $where_clause_array, $where_clause);
$has_blob_field = false;
foreach ($table_columns as $column) {
    if (PMA_isColumn($column, array('blob', 'tinyblob', 'mediumblob', 'longblob'))) {
        $has_blob_field = true;
        break;
    }
}
//Insert/Edit form
//If table has blob fields we have to disable ajax.
$html_output .= PMA_getHtmlForInsertEditFormHeader($has_blob_field, $is_upload);
$html_output .= URL::getHiddenInputs($_form_params);
$titles['Browse'] = Util::getIcon('b_browse.png', __('Browse foreign values'));
// user can toggle the display of Function column and column types
// (currently does not work for multi-edits)
if (!$cfg['ShowFunctionFields'] || !$cfg['ShowFieldTypesInDataEditView']) {
    $html_output .= __('Show');
}
if (!$cfg['ShowFunctionFields']) {
    $html_output .= PMA_showTypeOrFunction('function', $url_params, false);
}
if (!$cfg['ShowFieldTypesInDataEditView']) {
    $html_output .= PMA_showTypeOrFunction('type', $url_params, false);
}
$GLOBALS['plugin_scripts'] = array();
foreach ($rows as $row_id => $current_row) {
    if (empty($current_row)) {
/**
 * Displays a form used to add/edit a trigger
 *
 * @param string $mode If the editor will be used to edit a trigger
 *                     or add a new one: 'edit' or 'add'.
 * @param array  $item Data for the trigger returned by PMA_TRI_getDataFromRequest()
 *                     or PMA_TRI_getDataFromName()
 *
 * @return string HTML code for the editor.
 */
function PMA_TRI_getEditorForm($mode, $item)
{
    global $db, $table, $event_manipulations, $action_timings;
    $modeToUpper = mb_strtoupper($mode);
    // Escape special characters
    $need_escape = array('item_original_name', 'item_name', 'item_definition', 'item_definer');
    foreach ($need_escape as $key => $index) {
        $item[$index] = htmlentities($item[$index], ENT_QUOTES, 'UTF-8');
    }
    $original_data = '';
    if ($mode == 'edit') {
        $original_data = "<input name='item_original_name' " . "type='hidden' value='{$item['item_original_name']}'/>\n";
    }
    $query = "SELECT `TABLE_NAME` FROM `INFORMATION_SCHEMA`.`TABLES` ";
    $query .= "WHERE `TABLE_SCHEMA`='" . $GLOBALS['dbi']->escapeString($db) . "' ";
    $query .= "AND `TABLE_TYPE`='BASE TABLE'";
    $tables = $GLOBALS['dbi']->fetchResult($query);
    // Create the output
    $retval = "";
    $retval .= "<!-- START " . $modeToUpper . " TRIGGER FORM -->\n\n";
    $retval .= "<form class='rte_form' action='db_triggers.php' method='post'>\n";
    $retval .= "<input name='{$mode}_item' type='hidden' value='1' />\n";
    $retval .= $original_data;
    $retval .= URL::getHiddenInputs($db, $table) . "\n";
    $retval .= "<fieldset>\n";
    $retval .= "<legend>" . __('Details') . "</legend>\n";
    $retval .= "<table class='rte_table' style='width: 100%'>\n";
    $retval .= "<tr>\n";
    $retval .= "    <td style='width: 20%;'>" . __('Trigger name') . "</td>\n";
    $retval .= "    <td><input type='text' name='item_name' maxlength='64'\n";
    $retval .= "               value='{$item['item_name']}' /></td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr>\n";
    $retval .= "    <td>" . __('Table') . "</td>\n";
    $retval .= "    <td>\n";
    $retval .= "        <select name='item_table'>\n";
    foreach ($tables as $key => $value) {
        $selected = "";
        if ($mode == 'add' && $value == $table) {
            $selected = " selected='selected'";
        } else {
            if ($mode == 'edit' && $value == $item['item_table']) {
                $selected = " selected='selected'";
            }
        }
        $retval .= "<option{$selected}>";
        $retval .= htmlspecialchars($value);
        $retval .= "</option>\n";
    }
    $retval .= "        </select>\n";
    $retval .= "    </td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr>\n";
    $retval .= "    <td>" . _pgettext('Trigger action time', 'Time') . "</td>\n";
    $retval .= "    <td><select name='item_timing'>\n";
    foreach ($action_timings as $key => $value) {
        $selected = "";
        if (!empty($item['item_action_timing']) && $item['item_action_timing'] == $value) {
            $selected = " selected='selected'";
        }
        $retval .= "<option{$selected}>{$value}</option>";
    }
    $retval .= "    </select></td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr>\n";
    $retval .= "    <td>" . __('Event') . "</td>\n";
    $retval .= "    <td><select name='item_event'>\n";
    foreach ($event_manipulations as $key => $value) {
        $selected = "";
        if (!empty($item['item_event_manipulation']) && $item['item_event_manipulation'] == $value) {
            $selected = " selected='selected'";
        }
        $retval .= "<option{$selected}>{$value}</option>";
    }
    $retval .= "    </select></td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr>\n";
    $retval .= "    <td>" . __('Definition') . "</td>\n";
    $retval .= "    <td><textarea name='item_definition' rows='15' cols='40'>";
    $retval .= $item['item_definition'];
    $retval .= "</textarea></td>\n";
    $retval .= "</tr>\n";
    $retval .= "<tr>\n";
    $retval .= "    <td>" . __('Definer') . "</td>\n";
    $retval .= "    <td><input type='text' name='item_definer'\n";
    $retval .= "               value='{$item['item_definer']}' /></td>\n";
    $retval .= "</tr>\n";
    $retval .= "</table>\n";
    $retval .= "</fieldset>\n";
    if ($GLOBALS['is_ajax_request']) {
        $retval .= "<input type='hidden' name='editor_process_{$mode}'\n";
        $retval .= "       value='true' />\n";
        $retval .= "<input type='hidden' name='ajax_request' value='true' />\n";
    } else {
        $retval .= "<fieldset class='tblFooters'>\n";
        $retval .= "    <input type='submit' name='editor_process_{$mode}'\n";
        $retval .= "           value='" . __('Go') . "' />\n";
        $retval .= "</fieldset>\n";
    }
    $retval .= "</form>\n\n";
    $retval .= "<!-- END " . $modeToUpper . " TRIGGER FORM -->\n\n";
    return $retval;
}