/** * Prints Html For Import Javascript * * @param int $upload_id The selected upload id * * @return string */ function PMA_getHtmlForImportJS($upload_id) { global $SESSION_KEY; $html = ''; $html .= '<script type="text/javascript">'; $html .= ' //<![CDATA['; //with "\n", so that the following lines won't be commented out by //<![CDATA[ $html .= "\n"; $html .= ' $( function() {'; // add event when user click on "Go" button $html .= ' $("#buttonGo").bind("click", function() {'; // hide form $html .= ' $("#upload_form_form").css("display", "none");'; if ($_SESSION[$SESSION_KEY]["handler"] != "UploadNoplugin") { $html .= PMA_getHtmlForImportWithPlugin($upload_id); } else { // no plugin available $image_tag = '<img src="' . $GLOBALS['pmaThemeImage'] . 'ajax_clock_small.gif" width="16" height="16" alt="ajax clock" /> ' . PMA_jsFormat(__('Please be patient, the file is being uploaded. ' . 'Details about the upload are not available.'), false) . PMA_Util::showDocu('faq', 'faq2-9'); $html .= " \$('#upload_form_status_info').html('" . $image_tag . "');"; $html .= ' $("#upload_form_status").css("display", "none");'; } // else // onclick $html .= ' });'; // domready $html .= ' });'; $html .= ' //]]>'; //with "\n", so that the following lines won't be commented out by //]]> $html .= "\n"; $html .= '</script>'; return $html; }
function testShowDocu() { $anchor = "relation"; $expected = '<a href="Documentation.html#' . $anchor . '" target="documentation">' . '<img src="themes/dot.gif" title="' . __('Documentation') . '" ' . 'alt="' . __('Documentation') . '" class="icon ic_b_help" /></a>'; $this->assertEquals( $expected, PMA_Util::showDocu($anchor) ); }
/** * 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) { global $lang; $retval = ''; // Display language selection only if there // is more than one language to choose from if (count($GLOBALS['available_languages']) > 1) { $retval .= '<form method="get" action="index.php" class="disableAjax">'; $_form_params = array('db' => $GLOBALS['db'], 'table' => $GLOBALS['table']); $retval .= PMA_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_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">'; uasort($GLOBALS['available_languages'], 'PMA_languageCmp'); foreach ($GLOBALS['available_languages'] as $id => $tmplang) { $lang_name = PMA_languageName($tmplang); //Is current one active? if ($lang == $id) { $selected = ' selected="selected"'; } else { $selected = ''; } $retval .= '<option value="' . $id . '"' . $selected . '>'; $retval .= $lang_name; $retval .= '</option>'; } $retval .= '</select>'; if ($use_fieldset) { $retval .= '</fieldset>'; } $retval .= '</form>'; } return $retval; }
/** * Displays for for language selection * * @param boolean $use_fieldset whether to use fieldset for selection * @param boolean $show_doc whether to show documentation links * * @return void * * @access public */ function PMA_Language_select($use_fieldset = false, $show_doc = true) { if (count($GLOBALS['available_languages']) == 1) { // no use in switching languages, there is only one available return; } global $cfg, $lang; echo '<form method="post" action="index.php" target="_parent">'; $_form_params = array('db' => $GLOBALS['db'], 'table' => $GLOBALS['table']); echo PMA_generate_common_hidden_inputs($_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_Util::showDocu('faq7_2'); } if ($use_fieldset) { echo '<fieldset><legend lang="en" dir="ltr">' . $language_title . '</legend>'; } else { echo '<bdo lang="en" dir="ltr"><label for="sel-lang">' . $language_title . ':</label></bdo>'; } echo '<select name="lang" class="autosubmit" lang="en" dir="ltr" id="sel-lang">'; uasort($GLOBALS['available_languages'], 'PMA_Language_cmp'); foreach ($GLOBALS['available_languages'] as $id => $tmplang) { $lang_name = PMA_langName($tmplang); //Is current one active? if ($lang == $id) { $selected = ' selected="selected"'; } else { $selected = ''; } echo ' '; echo '<option value="' . $id . '"' . $selected . '>' . $lang_name . '</option>' . "\n"; } echo '</select>'; if ($use_fieldset) { echo '</fieldset>'; } echo '</form>'; }
PMA_Message::notice(__('You have no saved settings!'))->display(); echo '</div>' . '</div>' . '<div class="localStorage-unsupported">'; PMA_Message::notice(__('This feature is not supported by your web browser'))->display(); echo '</div>' . '</div>' . '<input type="checkbox" id="import_merge" name="import_merge" />' . '<label for="import_merge">' . __('Merge with current configuration') . '</label>' . '<br /><br />' . '<input type="submit" name="submit_import" value="' . __('Go') . '" />' . '</form>' . '</div>'; if (file_exists('setup/index.php')) { // show only if setup script is available, allows to disable this message // by simply removing setup directory ?> <div class="group"> <h2><?php echo __('More settings'); ?> </h2> <div class="group-cnt"> <?php echo sprintf(__('You can set more settings by modifying config.inc.php, eg. ' . 'by using %sSetup script%s.'), '<a href="setup/index.php" target="_blank">', '</a>') . PMA_Util::showDocu('setup', 'setup-script'); ?> </div> </div> <?php } ?> </div> <div id="main_pane_right"> <div class="group"> <h2><?php echo __('Export'); ?> </h2> <div class="click-hide-message group-cnt" style="display:none"> <?php
/** * Returns single option in a list element * * @param string $section name of config section in * $GLOBALS['cfg'][$section] for plugin * @param string $plugin_name unique plugin name * @param array &$propertyGroup options property main group instance * @param boolean $is_subgroup if this group is a subgroup * * @return string table row with option */ function PMA_pluginGetOneOption($section, $plugin_name, &$propertyGroup, $is_subgroup = false) { $ret = "\n"; if (!$is_subgroup) { // for subgroup headers if (strpos(get_class($propertyGroup), "PropertyItem")) { $properties = [$propertyGroup]; } else { // for main groups $ret .= '<div class="export_sub_options" id="' . $plugin_name . '_' . $propertyGroup->getName() . '">'; if (method_exists($propertyGroup, 'getText')) { $text = $propertyGroup->getText(); } if ($text != null) { $ret .= '<h4>' . PMA_getString($text) . '</h4>'; } $ret .= '<ul>'; } } if (!isset($properties)) { $not_subgroup_header = true; if (method_exists($propertyGroup, 'getProperties')) { $properties = $propertyGroup->getProperties(); } } if (isset($properties)) { foreach ($properties as $propertyItem) { $property_class = get_class($propertyItem); // if the property is a subgroup, we deal with it recursively if (strpos($property_class, "Subgroup")) { // for subgroups // each subgroup can have a header, which may also be a form element $subgroup_header = $propertyItem->getSubgroupHeader(); if (isset($subgroup_header)) { $ret .= PMA_pluginGetOneOption($section, $plugin_name, $subgroup_header); } $ret .= '<li class="subgroup"><ul'; if (isset($subgroup_header)) { $ret .= ' id="ul_' . $subgroup_header->getName() . '">'; } else { $ret .= '>'; } $ret .= PMA_pluginGetOneOption($section, $plugin_name, $propertyItem, true); } else { // single property item switch ($property_class) { case "BoolPropertyItem": $ret .= '<li>' . "\n"; $ret .= '<input type="checkbox" name="' . $plugin_name . '_' . $propertyItem->getName() . '"' . ' value="something" id="checkbox_' . $plugin_name . '_' . $propertyItem->getName() . '"' . ' ' . PMA_pluginCheckboxCheck($section, $plugin_name . '_' . $propertyItem->getName()); if ($propertyItem->getForce() != null) { // Same code is also few lines lower, update both if needed $ret .= ' onclick="if (!this.checked && ' . '(!document.getElementById(\'checkbox_' . $plugin_name . '_' . $propertyItem->getForce() . '\') ' . '|| !document.getElementById(\'checkbox_' . $plugin_name . '_' . $propertyItem->getForce() . '\').checked)) ' . 'return false; else return true;"'; } $ret .= ' />'; $ret .= '<label for="checkbox_' . $plugin_name . '_' . $propertyItem->getName() . '">' . PMA_getString($propertyItem->getText()) . '</label>'; break; case "DocPropertyItem": echo "DocPropertyItem"; break; case "HiddenPropertyItem": $ret .= '<li><input type="hidden" name="' . $plugin_name . '_' . $propertyItem->getName() . '"' . ' value="' . PMA_pluginGetDefault($section, $plugin_name . '_' . $propertyItem->getName()) . '"' . ' /></li>'; break; case "MessageOnlyPropertyItem": $ret .= '<li>' . "\n"; $ret .= '<p>' . PMA_getString($propertyItem->getText()) . '</p>'; break; case "RadioPropertyItem": $default = PMA_pluginGetDefault($section, $plugin_name . '_' . $propertyItem->getName()); foreach ($propertyItem->getValues() as $key => $val) { $ret .= '<li><input type="radio" name="' . $plugin_name . '_' . $propertyItem->getName() . '" value="' . $key . '" id="radio_' . $plugin_name . '_' . $propertyItem->getName() . '_' . $key . '"'; if ($key == $default) { $ret .= ' checked="checked"'; } $ret .= ' />' . '<label for="radio_' . $plugin_name . '_' . $propertyItem->getName() . '_' . $key . '">' . PMA_getString($val) . '</label></li>'; } break; case "SelectPropertyItem": $ret .= '<li>' . "\n"; $ret .= '<label for="select_' . $plugin_name . '_' . $propertyItem->getName() . '" class="desc">' . PMA_getString($propertyItem->getText()) . '</label>'; $ret .= '<select name="' . $plugin_name . '_' . $propertyItem->getName() . '"' . ' id="select_' . $plugin_name . '_' . $propertyItem->getName() . '">'; $default = PMA_pluginGetDefault($section, $plugin_name . '_' . $propertyItem->getName()); foreach ($propertyItem->getValues() as $key => $val) { $ret .= '<option value="' . $key . '"'; if ($key == $default) { $ret .= ' selected="selected"'; } $ret .= '>' . PMA_getString($val) . '</option>'; } $ret .= '</select>'; break; case "TextPropertyItem": $ret .= '<li>' . "\n"; $ret .= '<label for="text_' . $plugin_name . '_' . $propertyItem->getName() . '" class="desc">' . PMA_getString($propertyItem->getText()) . '</label>'; $ret .= '<input type="text" name="' . $plugin_name . '_' . $propertyItem->getName() . '"' . ' value="' . PMA_pluginGetDefault($section, $plugin_name . '_' . $propertyItem->getName()) . '"' . ' id="text_' . $plugin_name . '_' . $propertyItem->getName() . '"' . ($propertyItem->getSize() != null ? ' size="' . $propertyItem->getSize() . '"' : '') . ($propertyItem->getLen() != null ? ' maxlength="' . $propertyItem->getLen() . '"' : '') . ' />'; break; default: } } } } if ($is_subgroup) { // end subgroup $ret .= '</ul></li>'; } else { // end main group if (!empty($not_subgroup_header)) { $ret .= '</ul></div>'; } } if (method_exists($propertyGroup, "getDoc")) { $doc = $propertyGroup->getDoc(); if ($doc != null) { if (count($doc) == 3) { $ret .= PMA_Util::showMySQLDocu($doc[0], $doc[1], false, $doc[2]); } elseif (count($doc) == 1) { $ret .= PMA_Util::showDocu('faq', $doc[0]); } else { $ret .= PMA_Util::showMySQLDocu($doc[0], $doc[1]); } } } // Close the list element after $doc link is displayed if (isset($property_class)) { if ($property_class == 'BoolPropertyItem' || $property_class == 'MessageOnlyPropertyItem' || $property_class == 'SelectPropertyItem' || $property_class == 'TextPropertyItem') { $ret .= '</li>'; } } $ret .= "\n"; return $ret; }
<label for="import_merge"><?php echo __('Merge with current configuration') ?></label> <br /><br /> <input type="submit" name="submit_import" value="<?php echo __('Go'); ?>" /> </form> </div> <?php if (file_exists('setup/index.php')) { // show only if setup script is available, allows to disable this message // by simply removing setup directory ?> <div class="group"> <h2><?php echo __('More settings') ?></h2> <div class="group-cnt"> <?php echo sprintf(__('You can set more settings by modifying config.inc.php, eg. by using %sSetup script%s.'), '<a href="setup/index.php">', '</a>'); echo PMA_Util::showDocu('setup_script'); ?> </div> </div> <?php } ?> </div> <div id="main_pane_right"> <div class="group"> <h2><?php echo __('Export') ?></h2> <div class="click-hide-message group-cnt" style="display:none"> <?php PMA_Message::rawSuccess(__('Configuration has been saved'))->display(); ?> </div>
/** * Displays a form used to add/edit a routine * * @param string $mode If the editor will be used to edit a routine * 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 $routine Data for the routine returned by * PMA_RTN_getDataFromRequest() or * PMA_RTN_getDataFromName() * * @return string HTML code for the editor. */ function PMA_RTN_getEditorForm($mode, $operation, $routine) { global $db, $errors, $param_sqldataaccess, $param_opts_num; // Escape special characters $need_escape = array('item_original_name', 'item_name', 'item_returnlength', 'item_definition', 'item_definer', 'item_comment'); foreach ($need_escape as $key => $index) { $routine[$index] = htmlentities($routine[$index], ENT_QUOTES, 'UTF-8'); } for ($i = 0; $i < $routine['item_num_params']; $i++) { $routine['item_param_name'][$i] = htmlentities($routine['item_param_name'][$i], ENT_QUOTES); $routine['item_param_length'][$i] = htmlentities($routine['item_param_length'][$i], ENT_QUOTES); } // Handle some logic first if ($operation == 'change') { if ($routine['item_type'] == 'PROCEDURE') { $routine['item_type'] = 'FUNCTION'; $routine['item_type_toggle'] = 'PROCEDURE'; } else { $routine['item_type'] = 'PROCEDURE'; $routine['item_type_toggle'] = 'FUNCTION'; } } else { if ($operation == 'add' || $routine['item_num_params'] == 0 && $mode == 'add' && !$errors) { $routine['item_param_dir'][] = ''; $routine['item_param_name'][] = ''; $routine['item_param_type'][] = ''; $routine['item_param_length'][] = ''; $routine['item_param_opts_num'][] = ''; $routine['item_param_opts_text'][] = ''; $routine['item_num_params']++; } else { if ($operation == 'remove') { unset($routine['item_param_dir'][$routine['item_num_params'] - 1]); unset($routine['item_param_name'][$routine['item_num_params'] - 1]); unset($routine['item_param_type'][$routine['item_num_params'] - 1]); unset($routine['item_param_length'][$routine['item_num_params'] - 1]); unset($routine['item_param_opts_num'][$routine['item_num_params'] - 1]); unset($routine['item_param_opts_text'][$routine['item_num_params'] - 1]); $routine['item_num_params']--; } } } $disableRemoveParam = ''; if (!$routine['item_num_params']) { $disableRemoveParam = " color: gray;' disabled='disabled"; } $original_routine = ''; if ($mode == 'edit') { $original_routine = "<input name='item_original_name' " . "type='hidden' " . "value='{$routine['item_original_name']}'/>\n" . "<input name='item_original_type' " . "type='hidden' " . "value='{$routine['item_original_type']}'/>\n"; } $isfunction_class = ''; $isprocedure_class = ''; $isfunction_select = ''; $isprocedure_select = ''; if ($routine['item_type'] == 'PROCEDURE') { $isfunction_class = ' hide'; $isprocedure_select = " selected='selected'"; } else { $isprocedure_class = ' hide'; $isfunction_select = " selected='selected'"; } // Create the output $retval = ""; $retval .= "<!-- START " . mb_strtoupper($mode) . " ROUTINE FORM -->\n\n"; $retval .= "<form class='rte_form' action='db_routines.php' method='post'>\n"; $retval .= "<input name='{$mode}_item' type='hidden' value='1' />\n"; $retval .= $original_routine; $retval .= PMA_URL_getHiddenInputs($db) . "\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%;'>" . __('Routine name') . "</td>\n"; $retval .= " <td><input type='text' name='item_name' maxlength='64'\n"; $retval .= " value='{$routine['item_name']}' /></td>\n"; $retval .= "</tr>\n"; $retval .= "<tr>\n"; $retval .= " <td>" . __('Type') . "</td>\n"; $retval .= " <td>\n"; if ($GLOBALS['is_ajax_request']) { $retval .= " <select name='item_type'>\n" . "<option value='PROCEDURE'{$isprocedure_select}>PROCEDURE</option>\n" . "<option value='FUNCTION'{$isfunction_select}>FUNCTION</option>\n" . "</select>\n"; } else { $retval .= "<input name='item_type' type='hidden'" . " value='{$routine['item_type']}' />\n" . "<div style='width: 49%; float: left; text-align: center;" . " font-weight: bold;'>\n" . $routine['item_type'] . "\n" . "</div>\n" . "<input style='width: 49%;' type='submit' name='routine_changetype'\n" . " value='" . sprintf(__('Change to %s'), $routine['item_type_toggle']) . "' />\n"; } $retval .= " </td>\n"; $retval .= "</tr>\n"; $retval .= "<tr>\n"; $retval .= " <td>" . __('Parameters') . "</td>\n"; $retval .= " <td>\n"; // parameter handling start $retval .= " <table class='routine_params_table'>\n"; $retval .= " <tr>\n"; $retval .= " <th class='routine_direction_cell{$isprocedure_class}'>" . __('Direction') . "</th>\n"; $retval .= " <th>" . __('Name') . "</th>\n"; $retval .= " <th>" . __('Type') . "</th>\n"; $retval .= " <th>" . __('Length/Values') . "</th>\n"; $retval .= " <th colspan='2'>" . __('Options') . "</th>\n"; $retval .= " <th class='routine_param_remove hide'> </th>\n"; $retval .= " </tr>"; for ($i = 0; $i < $routine['item_num_params']; $i++) { // each parameter $retval .= PMA_RTN_getParameterRow($routine, $i, $isprocedure_class); } $retval .= " </table>"; $retval .= " </td>"; $retval .= "</tr>"; $retval .= "<tr>"; $retval .= " <td> </td>"; $retval .= " <td>"; $retval .= " <input style='width: 49%;' type='button'"; $retval .= " name='routine_addparameter'"; $retval .= " value='" . __('Add parameter') . "' />"; $retval .= " <input style='width: 49%;" . $disableRemoveParam . "'"; $retval .= " type='submit' "; $retval .= " name='routine_removeparameter'"; $retval .= " value='" . __('Remove last parameter') . "' />"; $retval .= " </td>"; $retval .= "</tr>"; // parameter handling end $retval .= "<tr class='routine_return_row" . $isfunction_class . "'>"; $retval .= " <td>" . __('Return type') . "</td>"; $retval .= " <td><select name='item_returntype'>"; $retval .= PMA_Util::getSupportedDatatypes(true, $routine['item_returntype']); $retval .= " </select></td>"; $retval .= "</tr>"; $retval .= "<tr class='routine_return_row" . $isfunction_class . "'>"; $retval .= " <td>" . __('Return length/values') . "</td>"; $retval .= " <td><input type='text' name='item_returnlength'"; $retval .= " value='" . $routine['item_returnlength'] . "' /></td>"; $retval .= " <td class='hide no_len'>---</td>"; $retval .= "</tr>"; $retval .= "<tr class='routine_return_row" . $isfunction_class . "'>"; $retval .= " <td>" . __('Return options') . "</td>"; $retval .= " <td><div>"; $retval .= PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, "item_returnopts_text", null, $routine['item_returnopts_text']); $retval .= " </div>"; $retval .= " <div><select name='item_returnopts_num'>"; $retval .= " <option value=''></option>"; foreach ($param_opts_num as $key => $value) { $selected = ""; if (!empty($routine['item_returnopts_num']) && $routine['item_returnopts_num'] == $value) { $selected = " selected='selected'"; } $retval .= "<option" . $selected . ">" . $value . "</option>"; } $retval .= " </select></div>"; $retval .= " <div class='hide no_opts'>---</div>"; $retval .= "</td>"; $retval .= "</tr>"; $retval .= "<tr>"; $retval .= " <td>" . __('Definition') . "</td>"; $retval .= " <td><textarea name='item_definition' rows='15' cols='40'>"; $retval .= $routine['item_definition']; $retval .= "</textarea></td>"; $retval .= "</tr>"; $retval .= "<tr>"; $retval .= " <td>" . __('Is deterministic') . "</td>"; $retval .= " <td><input type='checkbox' name='item_isdeterministic'" . $routine['item_isdeterministic'] . " /></td>"; $retval .= "</tr>"; if (isset($_REQUEST['edit_item']) && !empty($_REQUEST['edit_item'])) { $retval .= "<tr>"; $retval .= " <td>" . __('Adjust Privileges'); $retval .= PMA_Util::showDocu('faq', 'faq6-39'); $retval .= "</td>"; if (!defined('PMA_DRIZZLE') || !PMA_DRIZZLE) { if (isset($GLOBALS['proc_priv']) && $GLOBALS['proc_priv'] && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']) { $retval .= " <td><input type='checkbox' name='item_adjust_privileges'" . " value='1' checked /></td>"; } else { $retval .= " <td><input type='checkbox' name='item_adjust_privileges'" . " value='1' " . "title='" . __("You do not have sufficient privileges to perform this " . "operation; Please refer to the documentation for more details") . "' disabled/></td>"; } } $retval .= "</tr>"; } $retval .= "<tr>"; $retval .= " <td>" . __('Definer') . "</td>"; $retval .= " <td><input type='text' name='item_definer'"; $retval .= " value='" . $routine['item_definer'] . "' /></td>"; $retval .= "</tr>"; $retval .= "<tr>"; $retval .= " <td>" . __('Security type') . "</td>"; $retval .= " <td><select name='item_securitytype'>"; $retval .= " <option value='DEFINER'" . $routine['item_securitytype_definer'] . ">DEFINER</option>"; $retval .= " <option value='INVOKER'" . $routine['item_securitytype_invoker'] . ">INVOKER</option>"; $retval .= " </select></td>"; $retval .= "</tr>"; $retval .= "<tr>"; $retval .= " <td>" . __('SQL data access') . "</td>"; $retval .= " <td><select name='item_sqldataaccess'>"; foreach ($param_sqldataaccess as $key => $value) { $selected = ""; if ($routine['item_sqldataaccess'] == $value) { $selected = " selected='selected'"; } $retval .= " <option" . $selected . ">" . $value . "</option>"; } $retval .= " </select></td>"; $retval .= "</tr>"; $retval .= "<tr>"; $retval .= " <td>" . __('Comment') . "</td>"; $retval .= " <td><input type='text' name='item_comment' maxlength='64'"; $retval .= " value='" . $routine['item_comment'] . "' /></td>"; $retval .= "</tr>"; $retval .= "</table>"; $retval .= "</fieldset>"; if ($GLOBALS['is_ajax_request']) { $retval .= "<input type='hidden' name='editor_process_" . $mode . "'"; $retval .= " value='true' />"; $retval .= "<input type='hidden' name='ajax_request' value='true' />"; } else { $retval .= "<fieldset class='tblFooters'>"; $retval .= " <input type='submit' name='editor_process_" . $mode . "'"; $retval .= " value='" . __('Go') . "' />"; $retval .= "</fieldset>"; } $retval .= "</form>"; $retval .= "<!-- END " . mb_strtoupper($mode) . " ROUTINE FORM -->"; return $retval; }
/** * Function to get the default sql query for browsing page * * @param String $db the current database * @param String $table the current table * * @return String $sql_query the default $sql_query for browse page */ function PMA_getDefaultSqlQueryForBrowse($db, $table) { include_once 'libraries/bookmark.lib.php'; $book_sql_query = PMA_Bookmark_get($db, '\'' . PMA_Util::sqlAddSlashes($table) . '\'', 'label', false, true); if (!empty($book_sql_query)) { $GLOBALS['using_bookmark_message'] = PMA_message::notice(__('Using bookmark "%s" as default browse query.')); $GLOBALS['using_bookmark_message']->addParam($table); $GLOBALS['using_bookmark_message']->addMessage(PMA_Util::showDocu('faq', 'faq6-22')); $sql_query = $book_sql_query; } else { $defaultOrderByClause = ''; if (isset($GLOBALS['cfg']['TablePrimaryKeyOrder']) && $GLOBALS['cfg']['TablePrimaryKeyOrder'] !== 'NONE') { $primaryKey = null; $primary = PMA_Index::getPrimary($table, $db); if ($primary !== false) { $primarycols = $primary->getColumns(); foreach ($primarycols as $col) { $primaryKey = $col->getName(); break; } if ($primaryKey != null) { $defaultOrderByClause = ' ORDER BY ' . PMA_Util::backquote($table) . '.' . PMA_Util::backquote($primaryKey) . ' ' . $GLOBALS['cfg']['TablePrimaryKeyOrder']; } } } $sql_query = 'SELECT * FROM ' . PMA_Util::backquote($table) . $defaultOrderByClause; } unset($book_sql_query); return $sql_query; }
/** * Displays authentication form * * this function MUST exit/quit the application * * @global string $conn_error the last connection error * * @return boolean|void */ public function auth() { global $conn_error; $response = PMA_Response::getInstance(); if ($response->isAjax()) { $response->setRequestStatus(false); // redirect_flag redirects to the login page $response->addJSON('redirect_flag', '1'); if (defined('TESTSUITE')) { return true; } else { exit; } } /* Perform logout to custom URL */ if (!empty($_REQUEST['old_usr']) && !empty($GLOBALS['cfg']['Server']['LogoutURL'])) { PMA_sendHeaderLocation($GLOBALS['cfg']['Server']['LogoutURL']); if (defined('TESTSUITE')) { return true; } else { exit; } } // No recall if blowfish secret is not configured as it would produce // garbage if ($GLOBALS['cfg']['LoginCookieRecall'] && !empty($GLOBALS['cfg']['blowfish_secret'])) { $default_user = $GLOBALS['PHP_AUTH_USER']; $default_server = $GLOBALS['pma_auth_server']; $autocomplete = ''; } else { $default_user = ''; $default_server = ''; // skip the IE autocomplete feature. $autocomplete = ' autocomplete="off"'; } $response->getFooter()->setMinimal(); $header = $response->getHeader(); $header->setBodyId('loginform'); $header->setTitle('phpMyAdmin'); $header->disableMenuAndConsole(); $header->disableWarnings(); if (file_exists(CUSTOM_HEADER_FILE)) { include CUSTOM_HEADER_FILE; } echo ' <div class="container"> <a href="'; echo PMA_linkURL('https://www.phpmyadmin.net/'); echo '" target="_blank" class="logo">'; $logo_image = $GLOBALS['pmaThemeImage'] . 'logo_right.png'; if (@file_exists($logo_image)) { echo '<img src="' . $logo_image . '" id="imLogo" name="imLogo" alt="phpMyAdmin" border="0" />'; } else { echo '<img name="imLogo" id="imLogo" src="' . $GLOBALS['pmaThemeImage'] . 'pma_logo.png' . '" ' . 'border="0" width="88" height="31" alt="phpMyAdmin" />'; } echo '</a> <h1>'; echo sprintf(__('Welcome to %s'), '<bdo dir="ltr" lang="en">phpMyAdmin</bdo>'); echo "</h1>"; // Show error message if (!empty($conn_error)) { PMA_Message::rawError($conn_error)->display(); } elseif (isset($_GET['session_expired']) && intval($_GET['session_expired']) == 1) { PMA_Message::rawError(__('Your session has expired. Please log in again.'))->display(); } echo "<noscript>\n"; PMA_message::error(__("Javascript must be enabled past this point!"))->display(); echo "</noscript>\n"; echo "<div class='hide js-show'>"; // Displays the languages form if (empty($GLOBALS['cfg']['Lang'])) { include_once './libraries/display_select_lang.lib.php'; // use fieldset, don't show doc link echo PMA_getLanguageSelectorHtml(true, false); } echo '</div> <br /> <!-- Login form --> <form method="post" action="index.php" name="login_form"' . $autocomplete . ' class="disableAjax login hide js-show"> <fieldset> <legend>'; echo __('Log in'); echo PMA_Util::showDocu('index'); echo '</legend>'; if ($GLOBALS['cfg']['AllowArbitraryServer']) { echo ' <div class="item"> <label for="input_servername" title="'; echo __('You can enter hostname/IP address and port separated by space.'); echo '">'; echo __('Server:'); echo '</label> <input type="text" name="pma_servername" id="input_servername"'; echo ' value="'; echo htmlspecialchars($default_server); echo '" size="24" class="textfield" title="'; echo __('You can enter hostname/IP address and port separated by space.'); echo '" /> </div>'; } echo '<div class="item"> <label for="input_username">' . __('Username:'******'</label> <input type="text" name="pma_username" id="input_username" ' . 'value="' . htmlspecialchars($default_user) . '" size="24"' . ' class="textfield"/> </div> <div class="item"> <label for="input_password">' . __('Password:'******'</label> <input type="password" name="pma_password" id="input_password"' . ' value="" size="24" class="textfield" /> </div>'; if (count($GLOBALS['cfg']['Servers']) > 1) { echo '<div class="item"> <label for="select_server">' . __('Server Choice:') . '</label> <select name="server" id="select_server"'; if ($GLOBALS['cfg']['AllowArbitraryServer']) { echo ' onchange="document.forms[\'login_form\'].' . 'elements[\'pma_servername\'].value = \'\'" '; } echo '>'; include_once './libraries/select_server.lib.php'; echo PMA_selectServer(false, false); echo '</select></div>'; } else { echo ' <input type="hidden" name="server" value="' . $GLOBALS['server'] . '" />'; } // end if (server choice) // Add captcha input field if reCaptcha is enabled if (!empty($GLOBALS['cfg']['CaptchaLoginPrivateKey']) && !empty($GLOBALS['cfg']['CaptchaLoginPublicKey'])) { // If enabled show captcha to the user on the login screen. echo '<script src="https://www.google.com/recaptcha/api.js?hl=' . $GLOBALS['lang'] . '" async defer></script>'; echo '<div class="g-recaptcha" data-sitekey="' . $GLOBALS['cfg']['CaptchaLoginPublicKey'] . '"></div>'; } echo '</fieldset> <fieldset class="tblFooters"> <input value="' . __('Go') . '" type="submit" id="input_go" />'; $_form_params = array(); if (!empty($GLOBALS['target'])) { $_form_params['target'] = $GLOBALS['target']; } if (!empty($GLOBALS['db'])) { $_form_params['db'] = $GLOBALS['db']; } if (!empty($GLOBALS['table'])) { $_form_params['table'] = $GLOBALS['table']; } // do not generate a "server" hidden field as we want the "server" // drop-down to have priority echo PMA_URL_getHiddenInputs($_form_params, '', 0, 'server'); echo '</fieldset> </form>'; // BEGIN Swekey Integration Swekey_login('input_username', 'input_go'); // END Swekey Integration if ($GLOBALS['error_handler']->hasDisplayErrors()) { echo '<div id="pma_errors">'; $GLOBALS['error_handler']->dispErrors(); echo '</div>'; } echo '</div>'; if (file_exists(CUSTOM_FOOTER_FILE)) { include CUSTOM_FOOTER_FILE; } if (!defined('TESTSUITE')) { exit; } else { return true; } }
</form> </div> <?php if (file_exists('setup/index.php')) { // show only if setup script is available, allows to disable this message // by simply removing setup directory ?> <div class="group"> <h2><?php echo __('More settings'); ?> </h2> <div class="group-cnt"> <?php echo sprintf(__('You can set more settings by modifying config.inc.php, eg. by using %sSetup script%s.'), '<a href="setup/index.php" target="_blank">', '</a>'); echo PMA_Util::showDocu('setup', 'setup-script'); ?> </div> </div> <?php } ?> </div> <div id="main_pane_right"> <div class="group"> <h2><?php echo __('Export'); ?> </h2> <div class="click-hide-message group-cnt" style="display:none"> <?php
exit; } } $response = PMA_Response::getInstance(); $response->isSuccess($retval == true); exit; } // Default to browse if no query set and we have table // (needed for browsing from DefaultTabTable) if (empty($sql_query) && strlen($table) && strlen($db)) { include_once 'libraries/bookmark.lib.php'; $book_sql_query = PMA_Bookmark_get($db, '\'' . PMA_Util::sqlAddSlashes($table) . '\'', 'label', false, true); if (!empty($book_sql_query)) { $GLOBALS['using_bookmark_message'] = PMA_message::notice(__('Using bookmark "%s" as default browse query.')); $GLOBALS['using_bookmark_message']->addParam($table); $GLOBALS['using_bookmark_message']->addMessage(PMA_Util::showDocu('faq', 'faq6-22')); $sql_query = $book_sql_query; } else { $sql_query = 'SELECT * FROM ' . PMA_Util::backquote($table); } unset($book_sql_query); // set $goto to what will be displayed if query returns 0 rows $goto = ''; } else { // Now we can check the parameters PMA_Util::checkParameters(array('sql_query')); } // instead of doing the test twice $is_drop_database = preg_match('/DROP[[:space:]]+(DATABASE|SCHEMA)[[:space:]]+/i', $sql_query); /** * Check rights in case of DROP DATABASE
/** * Function to get the default sql query for browsing page * * @param String $db the current database * @param String $table the current table * * @return String $sql_query the default $sql_query for browse page */ function PMA_getDefaultSqlQueryForBrowse($db, $table) { include_once 'libraries/bookmark.lib.php'; $book_sql_query = PMA_Bookmark_get($db, '\'' . PMA_Util::sqlAddSlashes($table) . '\'', 'label', false, true); if (!empty($book_sql_query)) { $GLOBALS['using_bookmark_message'] = PMA_message::notice(__('Using bookmark "%s" as default browse query.')); $GLOBALS['using_bookmark_message']->addParam($table); $GLOBALS['using_bookmark_message']->addMessage(PMA_Util::showDocu('faq', 'faq6-22')); $sql_query = $book_sql_query; } else { $sql_query = 'SELECT * FROM ' . PMA_Util::backquote($table); } unset($book_sql_query); return $sql_query; }
/** * Test for showDocu * * @return void */ function testShowDocu() { $this->assertEquals('<a href="./url.php?url=http%3A%2F%2Fdocs.phpmyadmin.net%2Fen%2Flatest%2Fpage.html%23anchor" target="documentation"><img src="themes/dot.gif" title="Documentation" alt="Documentation" class="icon ic_b_help" /></a>', PMA_Util::showDocu('page', 'anchor')); }
/** * Displays authentication form * * this function MUST exit/quit the application * * @global string the last connection error * * @return void */ public function auth() { global $conn_error; $response = PMA_Response::getInstance(); if ($response->isAjax()) { $response->isSuccess(false); if (!empty($conn_error)) { $response->addJSON('message', PMA_Message::error($conn_error)); } else { $response->addJSON('message', PMA_Message::error(__('Your session has expired. Please login again.'))); } exit; } /* Perform logout to custom URL */ if (!empty($_REQUEST['old_usr']) && !empty($GLOBALS['cfg']['Server']['LogoutURL'])) { PMA_sendHeaderLocation($GLOBALS['cfg']['Server']['LogoutURL']); exit; } // No recall if blowfish secret is not configured as it would produce // garbage if ($GLOBALS['cfg']['LoginCookieRecall'] && !empty($GLOBALS['cfg']['blowfish_secret'])) { $default_user = $GLOBALS['PHP_AUTH_USER']; $default_server = $GLOBALS['pma_auth_server']; $autocomplete = ''; } else { $default_user = ''; $default_server = ''; // skip the IE autocomplete feature. $autocomplete = ' autocomplete="off"'; } $cell_align = $GLOBALS['text_dir'] == 'ltr' ? 'left' : 'right'; $response->getFooter()->setMinimal(); $header = $response->getHeader(); $header->setBodyId('loginform'); $header->setTitle('phpMyAdmin'); $header->disableMenu(); $header->disableWarnings(); if (file_exists(CUSTOM_HEADER_FILE)) { include CUSTOM_HEADER_FILE; } echo ' <div class="container"> <a href="'; echo PMA_linkURL('http://www.phpmyadmin.net/'); echo '" target="_blank" class="logo">'; $logo_image = $GLOBALS['pmaThemeImage'] . 'logo_right.png'; if (@file_exists($logo_image)) { echo '<img src="' . $logo_image . '" id="imLogo" name="imLogo" alt="phpMyAdmin" border="0" />'; } else { echo '<img name="imLogo" id="imLogo" src="' . $GLOBALS['pmaThemeImage'] . 'pma_logo.png' . '" ' . 'border="0" width="88" height="31" alt="phpMyAdmin" />'; } echo '</a> <h1>'; echo sprintf(__('Welcome to %s'), '<bdo dir="ltr" lang="en">phpMyAdmin</bdo>'); echo "</h1>"; // Show error message if (!empty($conn_error)) { PMA_Message::rawError($conn_error)->display(); } echo "<noscript>\n"; PMA_message::error(__("Javascript must be enabled past this point"))->display(); echo "</noscript>\n"; echo "<div class='hide js-show'>"; // Displays the languages form if (empty($GLOBALS['cfg']['Lang'])) { include_once './libraries/display_select_lang.lib.php'; // use fieldset, don't show doc link PMA_Language_select(true, false); } echo '</div> <br /> <!-- Login form --> <form method="post" action="index.php" name="login_form"' . $autocomplete . ' target="_top" class="login hide js-show"> <fieldset> <legend>'; echo __('Log in'); echo PMA_Util::showDocu(''); echo '</legend>'; if ($GLOBALS['cfg']['AllowArbitraryServer']) { echo ' <div class="item"> <label for="input_servername" title="'; echo __('You can enter hostname/IP address and port separated by space.'); echo '">'; echo __('Server:'); echo '</label> <input type="text" name="pma_servername" id="input_servername"'; echo ' value="'; echo htmlspecialchars($default_server); echo '" size="24" class="textfield" title="'; echo __('You can enter hostname/IP address and port separated by space.'); echo '" /> </div>'; } echo '<div class="item"> <label for="input_username">' . __('Username:'******'</label> <input type="text" name="pma_username" id="input_username" ' . 'value="' . htmlspecialchars($default_user) . '" size="24"' . ' class="textfield"/> </div> <div class="item"> <label for="input_password">' . __('Password:'******'</label> <input type="password" name="pma_password" id="input_password"' . ' value="" size="24" class="textfield" /> </div>'; if (count($GLOBALS['cfg']['Servers']) > 1) { echo '<div class="item"> <label for="select_server">' . __('Server Choice') . ':</label> <select name="server" id="select_server"'; if ($GLOBALS['cfg']['AllowArbitraryServer']) { echo ' onchange="document.forms[\'login_form\'].' . 'elements[\'pma_servername\'].value = \'\'" '; } echo '>'; include_once './libraries/select_server.lib.php'; PMA_selectServer(false, false); echo '</select></div>'; } else { echo ' <input type="hidden" name="server" value="' . $GLOBALS['server'] . '" />'; } // end if (server choice) echo '</fieldset> <fieldset class="tblFooters"> <input value="' . __('Go') . '" type="submit" id="input_go" />'; $_form_params = array(); if (!empty($GLOBALS['target'])) { $_form_params['target'] = $GLOBALS['target']; } if (!empty($GLOBALS['db'])) { $_form_params['db'] = $GLOBALS['db']; } if (!empty($GLOBALS['table'])) { $_form_params['table'] = $GLOBALS['table']; } // do not generate a "server" hidden field as we want the "server" // drop-down to have priority echo PMA_generate_common_hidden_inputs($_form_params, '', 0, 'server'); echo '</fieldset> </form>'; // BEGIN Swekey Integration Swekey_login('input_username', 'input_go'); // END Swekey Integration // show the "Cookies required" message only if cookies are disabled // (we previously tried to set some cookies) if (empty($_COOKIE)) { trigger_error(__('Cookies must be enabled past this point.'), E_USER_NOTICE); } if ($GLOBALS['error_handler']->hasDisplayErrors()) { echo '<div>'; $GLOBALS['error_handler']->dispErrors(); echo '</div>'; } echo '</div>'; if (file_exists(CUSTOM_FOOTER_FILE)) { include CUSTOM_FOOTER_FILE; } echo ' <script type="text/javascript"> //<![CDATA[ // show login form in top frame. if (top != self || ! $(\'body#loginform\').length) { window.top.location.href=location; } //]]> </script>'; exit; }
/** * prints out diagnostic info for pma relation feature * * @param array $cfgRelation Relation configuration * * @return string */ function PMA_getRelationsParamDiagnostic($cfgRelation) { $retval = ''; $messages['error'] = '<font color="red"><strong>' . __('not OK') . '</strong></font>' . ' [ <a href="%s" target="documentation">' . __('Documentation') . '</a> ]'; $messages['ok'] = '<font color="green"><strong>' . _pgettext('Correctly working', 'OK') . '</strong></font>'; $messages['enabled'] = '<font color="green">' . __('Enabled') . '</font>'; $messages['disabled'] = '<font color="red">' . __('Disabled') . '</font>'; if (false === $GLOBALS['cfg']['Server']['pmadb']) { $retval .= 'PMA Database ... ' . sprintf($messages['error'], 'pmadb') . '<br />' . "\n" . __('General relation features') . ' <font color="green">' . __('Disabled') . '</font>' . "\n"; } else { $retval .= '<table>' . "\n"; $retval .= PMA_getDiagMessageForParameter('pmadb', $GLOBALS['cfg']['Server']['pmadb'], $messages, 'pmadb'); $retval .= PMA_getDiagMessageForParameter('relation', isset($cfgRelation['relation']), $messages, 'relation'); $retval .= PMA_getDiagMessageForFeature(__('General relation features'), 'relwork', $messages); $retval .= PMA_getDiagMessageForParameter('table_info', isset($cfgRelation['table_info']), $messages, 'table_info'); $retval .= PMA_getDiagMessageForFeature(__('Display Features'), 'displaywork', $messages); $retval .= PMA_getDiagMessageForParameter('table_coords', isset($cfgRelation['table_coords']), $messages, 'table_coords'); $retval .= PMA_getDiagMessageForParameter('pdf_pages', isset($cfgRelation['pdf_pages']), $messages, 'pdf_pages'); $retval .= PMA_getDiagMessageForFeature(__('Creation of PDFs'), 'pdfwork', $messages); $retval .= PMA_getDiagMessageForParameter('column_info', isset($cfgRelation['column_info']), $messages, 'column_info'); $retval .= PMA_getDiagMessageForFeature(__('Displaying Column Comments'), 'commwork', $messages, false); $retval .= PMA_getDiagMessageForFeature(__('Browser transformation'), 'mimework', $messages); if ($cfgRelation['commwork'] && !$cfgRelation['mimework']) { $retval .= '<tr><td colspan=2 class="left">'; $retval .= __('Please see the documentation on how to update your column_comments table.'); $retval .= '</td></tr>'; } $retval .= PMA_getDiagMessageForParameter('bookmarktable', isset($cfgRelation['bookmark']), $messages, 'bookmark'); $retval .= PMA_getDiagMessageForFeature(__('Bookmarked SQL query'), 'bookmarkwork', $messages); $retval .= PMA_getDiagMessageForParameter('history', isset($cfgRelation['history']), $messages, 'history'); $retval .= PMA_getDiagMessageForFeature(__('SQL history'), 'historywork', $messages); $retval .= PMA_getDiagMessageForParameter('designer_coords', isset($cfgRelation['designer_coords']), $messages, 'designer_coords'); $retval .= PMA_getDiagMessageForFeature(__('Designer'), 'designerwork', $messages); $retval .= PMA_getDiagMessageForParameter('recent', isset($cfgRelation['recent']), $messages, 'recent'); $retval .= PMA_getDiagMessageForFeature(__('Persistent recently used tables'), 'recentwork', $messages); $retval .= PMA_getDiagMessageForParameter('table_uiprefs', isset($cfgRelation['table_uiprefs']), $messages, 'table_uiprefs'); $retval .= PMA_getDiagMessageForFeature(__('Persistent tables\' UI preferences'), 'uiprefswork', $messages); $retval .= PMA_getDiagMessageForParameter('tracking', isset($cfgRelation['tracking']), $messages, 'tracking'); $retval .= PMA_getDiagMessageForFeature(__('Tracking'), 'trackingwork', $messages); $retval .= PMA_getDiagMessageForParameter('userconfig', isset($cfgRelation['userconfig']), $messages, 'userconfig'); $retval .= PMA_getDiagMessageForFeature(__('User preferences'), 'userconfigwork', $messages); $retval .= PMA_getDiagMessageForParameter('users', isset($cfgRelation['users']), $messages, 'users'); $retval .= PMA_getDiagMessageForParameter('usergroups', isset($cfgRelation['usergroups']), $messages, 'usergroups'); $retval .= PMA_getDiagMessageForFeature(__('Configurable menus'), 'menuswork', $messages); $retval .= PMA_getDiagMessageForParameter('navigationhiding', isset($cfgRelation['navigationhiding']), $messages, 'navigationhiding'); $retval .= PMA_getDiagMessageForFeature(__('Hide/show navigation items'), 'navwork', $messages); $retval .= '</table>' . "\n"; $retval .= '<p>' . __('Quick steps to setup advanced features:') . '</p>'; $retval .= '<ul>'; $retval .= '<li>'; $retval .= __('Create the needed tables with the ' . '<code>examples/create_tables.sql</code>.'); $retval .= ' ' . PMA_Util::showDocu('setup', 'linked-tables'); $retval .= '</li>'; $retval .= '<li>'; $retval .= __('Create a pma user and give access to these tables.'); $retval .= ' ' . PMA_Util::showDocu('config', 'cfg_Servers_controluser'); $retval .= '</li>'; $retval .= '<li>'; $retval .= __('Enable advanced features in configuration file ' . '(<code>config.inc.php</code>), for example by ' . 'starting from <code>config.sample.inc.php</code>.'); $retval .= ' ' . PMA_Util::showDocu('setup', 'quick-install'); $retval .= '</li>'; $retval .= '<li>'; $retval .= __('Re-login to phpMyAdmin to load the updated configuration file.'); $retval .= '</li>'; $retval .= '</ul>'; } return $retval; }
if (!PMA_DBI_checkDbExtension($GLOBALS['cfg']['Server']['extension'])) { // if it fails try alternative extension ... // and display an error ... /** * @todo add different messages for alternative extension * and complete fail (no alternative extension too) */ PMA_warnMissingExtension($GLOBALS['cfg']['Server']['extension'], false, PMA_Util::showDocu('faqmysql')); if ($GLOBALS['cfg']['Server']['extension'] === 'mysql') { $alternativ_extension = 'mysqli'; } else { $alternativ_extension = 'mysql'; } if (!PMA_DBI_checkDbExtension($alternativ_extension)) { // if alternative fails too ... PMA_warnMissingExtension($GLOBALS['cfg']['Server']['extension'], true, PMA_Util::showDocu('faqmysql')); } $GLOBALS['cfg']['Server']['extension'] = $alternativ_extension; unset($alternativ_extension); } /** * Including The DBI Plugin */ include_once './libraries/dbi/' . $GLOBALS['cfg']['Server']['extension'] . '.dbi.lib.php'; } /** * runs a query * * @param string $query SQL query to execte * @param mixed $link optional database link to use * @param int $options optional query options
else { setTimeout(perform_upload, 1000); } }); }; setTimeout(perform_upload, 1000); <?php } else { // no plugin available ?> $('#upload_form_status_info').html('<img src="<?php echo $GLOBALS['pmaThemeImage']; ?> ajax_clock_small.gif" width="16" height="16" alt="ajax clock" /> <?php echo PMA_jsFormat(__('Please be patient, the file is being uploaded. Details about the upload are not available.'), false) . PMA_Util::showDocu('faq', 'faq2-9'); ?> '); $('#upload_form_status').css("display", "none"); <?php } // else ?> }); // onclick }); // domready //]]> </script> <form action="import.php" method="post" enctype="multipart/form-data" name="import"<?php if ($_SESSION[$SESSION_KEY]["handler"] != "UploadNoplugin") { echo ' target="import_upload_iframe"';
/** * Save this table's UI preferences into phpMyAdmin database. * * @return true|PMA_Message */ protected function saveUiPrefsToDb() { $pma_table = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) . "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['table_uiprefs']); $username = $GLOBALS['cfg']['Server']['user']; $sql_query = " REPLACE INTO " . $pma_table . " VALUES ('" . $username . "', '" . PMA_Util::sqlAddSlashes($this->db_name) . "', '" . PMA_Util::sqlAddSlashes($this->name) . "', '" . PMA_Util::sqlAddSlashes(json_encode($this->uiprefs)) . "', NULL)"; $success = PMA_DBI_try_query($sql_query, $GLOBALS['controllink']); if (!$success) { $message = PMA_Message::error(__('Could not save table UI preferences')); $message->addMessage('<br /><br />'); $message->addMessage(PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink']))); return $message; } // Remove some old rows in table_uiprefs if it exceeds the configured // maximum rows $sql_query = 'SELECT COUNT(*) FROM ' . $pma_table; $rows_count = PMA_DBI_fetch_value($sql_query); $max_rows = $GLOBALS['cfg']['Server']['MaxTableUiprefs']; if ($rows_count > $max_rows) { $num_rows_to_delete = $rows_count - $max_rows; $sql_query = ' DELETE FROM ' . $pma_table . ' ORDER BY last_update ASC' . ' LIMIT ' . $num_rows_to_delete; $success = PMA_DBI_try_query($sql_query, $GLOBALS['controllink']); if (!$success) { $message = PMA_Message::error(sprintf(__('Failed to cleanup table UI preferences (see $cfg[\'Servers\'][$i][\'MaxTableUiprefs\'] %s)'), PMA_Util::showDocu('config', 'cfg_Servers_MaxTableUiprefs'))); $message->addMessage('<br /><br />'); $message->addMessage(PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink']))); print_r($message); return $message; } } return true; }
/** * Returns single option in a list element * * @param string $section name of config section in * $GLOBALS['cfg'][$section] for plugin * @param string $plugin_name unique plugin name * @param array &$propertyGroup options property main group instance * @param boolean $is_subgroup if this group is a subgroup * * @return string table row with option */ function PMA_pluginGetOneOption($section, $plugin_name, &$propertyGroup, $is_subgroup = false) { $ret = "\n"; if (!$is_subgroup) { // for subgroup headers if (mb_strpos(get_class($propertyGroup), "PropertyItem")) { $properties = array($propertyGroup); } else { // for main groups $ret .= '<div class="export_sub_options" id="' . $plugin_name . '_' . $propertyGroup->getName() . '">'; if (method_exists($propertyGroup, 'getText')) { $text = $propertyGroup->getText(); } if ($text != null) { $ret .= '<h4>' . PMA_getString($text) . '</h4>'; } $ret .= '<ul>'; } } if (!isset($properties)) { $not_subgroup_header = true; if (method_exists($propertyGroup, 'getProperties')) { $properties = $propertyGroup->getProperties(); } } if (isset($properties)) { /** @var OptionsPropertySubgroup $propertyItem */ foreach ($properties as $propertyItem) { $property_class = get_class($propertyItem); // if the property is a subgroup, we deal with it recursively if (mb_strpos($property_class, "Subgroup")) { // for subgroups // each subgroup can have a header, which may also be a form element /** @var OptionsPropertyItem $subgroup_header */ $subgroup_header = $propertyItem->getSubgroupHeader(); if (isset($subgroup_header)) { $ret .= PMA_pluginGetOneOption($section, $plugin_name, $subgroup_header); } $ret .= '<li class="subgroup"><ul'; if (isset($subgroup_header)) { $ret .= ' id="ul_' . $subgroup_header->getName() . '">'; } else { $ret .= '>'; } $ret .= PMA_pluginGetOneOption($section, $plugin_name, $propertyItem, true); continue; } // single property item $ret .= PMA_getHtmlForProperty($section, $plugin_name, $propertyItem); } } if ($is_subgroup) { // end subgroup $ret .= '</ul></li>'; } else { // end main group if (!empty($not_subgroup_header)) { $ret .= '</ul></div>'; } } if (method_exists($propertyGroup, "getDoc")) { $doc = $propertyGroup->getDoc(); if ($doc != null) { if (count($doc) == 3) { $ret .= PMA_Util::showMySQLDocu($doc[1], false, $doc[2]); } elseif (count($doc) == 1) { $ret .= PMA_Util::showDocu('faq', $doc[0]); } else { $ret .= PMA_Util::showMySQLDocu($doc[1]); } } } // Close the list element after $doc link is displayed if (isset($property_class)) { if ($property_class == 'BoolPropertyItem' || $property_class == 'MessageOnlyPropertyItem' || $property_class == 'SelectPropertyItem' || $property_class == 'TextPropertyItem') { $ret .= '</li>'; } } $ret .= "\n"; return $ret; }
/** * return HTML for sql Query Form Bookmark * * @return string|null * * @usedby PMA_getHtmlForSqlQueryForm() */ function PMA_getHtmlForSqlQueryFormBookmark() { $bookmark_list = PMA_Bookmark_getList($GLOBALS['db']); if (!$bookmark_list || count($bookmark_list) < 1) { return null; } $html = '<fieldset id="fieldsetBookmarkOptions">'; $html .= '<legend>'; $html .= __('Bookmarked SQL query') . '</legend>' . "\n"; $html .= '<div class="formelement">'; $html .= '<select name="id_bookmark" id="id_bookmark">' . "\n"; $html .= '<option value=""> </option>' . "\n"; foreach ($bookmark_list as $key => $value) { $html .= '<option value="' . htmlspecialchars($key) . '">' . htmlspecialchars($value) . '</option>' . "\n"; } // is required for correct display with styles/line height $html .= '</select> ' . "\n"; $html .= '</div>' . "\n"; $html .= '<div class="formelement">' . "\n"; $html .= __('Variable'); $html .= PMA_Util::showDocu('faq', 'faqbookmark'); $html .= '<input type="text" name="bookmark_variable" class="textfield"' . ' size="10" />' . "\n"; $html .= '</div>' . "\n"; $html .= '<div class="formelement">' . "\n"; $html .= '<input type="radio" name="action_bookmark" value="0"' . ' id="radio_bookmark_exe" checked="checked" />' . '<label for="radio_bookmark_exe">' . __('Submit') . '</label>' . "\n"; $html .= '<input type="radio" name="action_bookmark" value="1"' . ' id="radio_bookmark_view" />' . '<label for="radio_bookmark_view">' . __('View only') . '</label>' . "\n"; $html .= '<input type="radio" name="action_bookmark" value="2"' . ' id="radio_bookmark_del" />' . '<label for="radio_bookmark_del">' . __('Delete') . '</label>' . "\n"; $html .= '</div>' . "\n"; $html .= '<div class="clearfloat"></div>' . "\n"; $html .= '</fieldset>' . "\n"; $html .= '<fieldset id="fieldsetBookmarkOptionsFooter" class="tblFooters">'; $html .= '<input type="submit" name="SQL" id="button_submit_bookmark" value="' . __('Go') . '" />'; $html .= '<div class="clearfloat"></div>' . "\n"; $html .= '</fieldset>' . "\n"; return $html; }
/** * To get the message if a column index is missing. If not will return null * * @param string $table current table * @param string $db current database * @param boolean $editable whether the results table can be editable or not * @param boolean $has_unique whether there is a unique key * * @return PMA_message $message */ function PMA_getMessageIfMissingColumnIndex($table, $db, $editable, $has_unique) { if (!empty($table) && ($GLOBALS['dbi']->isSystemSchema($db) || !$editable)) { $missing_unique_column_msg = PMA_message::notice(sprintf(__('Current selection does not contain a unique column.' . ' Grid edit, checkbox, Edit, Copy and Delete features' . ' are not available. %s'), PMA_Util::showDocu('config', 'cfg_RowActionLinksWithoutUnique'))); } elseif (!empty($table) && !$has_unique) { $missing_unique_column_msg = PMA_message::notice(sprintf(__('Current selection does not contain a unique column.' . ' Grid edit, Edit, Copy and Delete features may result in' . ' undesired behavior. %s'), PMA_Util::showDocu('config', 'cfg_RowActionLinksWithoutUnique'))); } else { $missing_unique_column_msg = null; } return $missing_unique_column_msg; }
/** * Get HTML div for copy table * * @return string $html_output */ function PMA_getHtmlForCopytable() { $html_output = '<div class="operations_half_width">'; $html_output .= '<form method="post" action="tbl_operations.php" ' . 'name="copyTable" ' . 'id="copyTable" ' . ' class="ajax" ' . 'onsubmit="return emptyCheckTheField(this, \'new_name\')">' . PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table']) . '<input type="hidden" name="reload" value="1" />'; $html_output .= '<fieldset>'; $html_output .= '<legend>' . __('Copy table to (database<b>.</b>table)') . '</legend>'; if (count($GLOBALS['pma']->databases) > $GLOBALS['cfg']['MaxDbList']) { $html_output .= '<input class="halfWidth" type="text" maxlength="100" ' . 'size="30" name="target_db" ' . 'value="' . htmlspecialchars($GLOBALS['db']) . '"/>'; } else { $html_output .= '<select class="halfWidth" name="target_db">' . $GLOBALS['pma']->databases->getHtmlOptions(true, false) . '</select>'; } $html_output .= ' <strong>.</strong> '; $html_output .= '<input class="halfWidth" type="text" required="required" ' . 'size="20" name="new_name" maxlength="64" ' . 'value="' . htmlspecialchars($GLOBALS['table']) . '"/><br />'; $choices = array('structure' => __('Structure only'), 'data' => __('Structure and data'), 'dataonly' => __('Data only')); $html_output .= PMA_Util::getRadioFields('what', $choices, 'data', true); $html_output .= '<br />'; $html_output .= '<input type="checkbox" name="drop_if_exists" ' . 'value="true" id="checkbox_drop" />' . '<label for="checkbox_drop">' . sprintf(__('Add %s'), 'DROP TABLE') . '</label><br />' . '<input type="checkbox" name="sql_auto_increment" ' . 'value="1" id="checkbox_auto_increment_cp" />' . '<label for="checkbox_auto_increment_cp">' . __('Add AUTO_INCREMENT value') . '</label><br />'; // display "Add constraints" choice only if there are // foreign keys if (PMA_getForeigners($GLOBALS['db'], $GLOBALS['table'], '', 'foreign')) { $html_output .= '<input type="checkbox" name="add_constraints" ' . 'value="1" id="checkbox_constraints" checked="checked"/>'; $html_output .= '<label for="checkbox_constraints">' . __('Add constraints') . '</label><br />'; } // endif $html_output .= '<br />'; if (!PMA_DRIZZLE) { if ($GLOBALS['table_priv'] && $GLOBALS['col_priv'] && $GLOBALS['is_reload_priv']) { $html_output .= '<input type="checkbox" name="adjust_privileges" ' . 'value="1" id="checkbox_adjust_privileges" checked="checked" />'; } else { $html_output .= '<input type="checkbox" name="adjust_privileges" ' . 'value="1" id="checkbox_adjust_privileges" title="' . __('You don\'t have sufficient privileges to perform this ' . 'operation; Please refer to the documentation for more details') . '" disabled/>'; } $html_output .= '<label for="checkbox_adjust_privileges">' . __('Adjust privileges') . PMA_Util::showDocu('faq', 'faq6-39') . '</label><br />'; } if (isset($_COOKIE['pma_switch_to_new']) && $_COOKIE['pma_switch_to_new'] == 'true') { $pma_switch_to_new = 'true'; } $html_output .= '<input type="checkbox" name="switch_to_new" value="true"' . 'id="checkbox_switch"' . (isset($pma_switch_to_new) && $pma_switch_to_new == 'true' ? ' checked="checked"' : '' . '/>'); $html_output .= '<label for="checkbox_switch">' . __('Switch to copied table') . '</label>' . '</fieldset>'; $html_output .= '<fieldset class="tblFooters">' . '<input type="submit" name="submit_copy" value="' . __('Go') . '" />' . '</fieldset>' . '</form>' . '</div>'; return $html_output; }
* complain ;-) */ if (!$cfgRelation['relwork']) { echo sprintf(__('<b>%s</b> table not found or not set in %s'), 'relation', 'config.inc.php') . '<br />' . "\n" . PMA_Util::showDocu('config', 'cfg_Servers_relation') . "\n"; exit; } if (!$cfgRelation['displaywork']) { echo sprintf(__('<b>%s</b> table not found or not set in %s'), 'table_info', 'config.inc.php') . '<br />' . "\n" . PMA_Util::showDocu('config', 'cfg_Servers_table_info') . "\n"; exit; } if (!isset($cfgRelation['table_coords'])) { echo sprintf(__('<b>%s</b> table not found or not set in %s'), 'table_coords', 'config.inc.php') . '<br />' . "\n" . PMA_Util::showDocu('config', 'cfg_Servers_table_coords') . "\n"; exit; } if (!isset($cfgRelation['pdf_pages'])) { echo sprintf(__('<b>%s</b> table not found or not set in %s'), 'pdf_page', 'config.inc.php') . '<br />' . "\n" . PMA_Util::showDocu('config', 'cfg_Servers_pdf_pages') . "\n"; exit; } if ($cfgRelation['pdfwork']) { /** * User object created for presenting the HTML options * so, user can interact with it and perform export of relations schema */ include_once 'libraries/schema/User_Schema.class.php'; $user_schema = new PMA_User_Schema(); /** * This function will process the user defined pages * and tables which will be exported as Relational schema * you can set the table positions on the paper via scratchboard * for table positions, put the x,y co-ordinates *
/** * prints out diagnostic info for pma relation feature * * @param array $cfgRelation Relation configuration * * @return string */ function PMA_getRelationsParamDiagnostic($cfgRelation) { $retval = ''; $messages = array(); $messages['error'] = '<font color="red"><strong>' . __('not OK') . '</strong></font>'; $messages['ok'] = '<font color="green"><strong>' . _pgettext('Correctly working', 'OK') . '</strong></font>'; $messages['enabled'] = '<font color="green">' . __('Enabled') . '</font>'; $messages['disabled'] = '<font color="red">' . __('Disabled') . '</font>'; if (empty($cfgRelation['db'])) { $retval .= __('Configuration of pmadb… ') . $messages['error'] . PMA_Util::showDocu('setup', 'linked-tables') . '<br />' . "\n" . __('General relation features') . ' <font color="green">' . __('Disabled') . '</font>' . "\n"; if (!empty($GLOBALS['db']) && $GLOBALS['cfg']['ZeroConf']) { $retval .= PMA_getHtmlFixPMATables(true); } } else { $retval .= '<table>' . "\n"; if (!$cfgRelation['allworks'] && $GLOBALS['cfg']['ZeroConf']) { $retval .= PMA_getHtmlFixPMATables(false); $retval .= '<br />'; } $retval .= PMA_getDiagMessageForParameter('pmadb', $cfgRelation['db'], $messages, 'pmadb'); $retval .= PMA_getDiagMessageForParameter('relation', isset($cfgRelation['relation']), $messages, 'relation'); $retval .= PMA_getDiagMessageForFeature(__('General relation features'), 'relwork', $messages); $retval .= PMA_getDiagMessageForParameter('table_info', isset($cfgRelation['table_info']), $messages, 'table_info'); $retval .= PMA_getDiagMessageForFeature(__('Display Features'), 'displaywork', $messages); $retval .= PMA_getDiagMessageForParameter('table_coords', isset($cfgRelation['table_coords']), $messages, 'table_coords'); $retval .= PMA_getDiagMessageForParameter('pdf_pages', isset($cfgRelation['pdf_pages']), $messages, 'pdf_pages'); $retval .= PMA_getDiagMessageForFeature(__('Designer and creation of PDFs'), 'pdfwork', $messages); $retval .= PMA_getDiagMessageForParameter('column_info', isset($cfgRelation['column_info']), $messages, 'column_info'); $retval .= PMA_getDiagMessageForFeature(__('Displaying Column Comments'), 'commwork', $messages, false); $retval .= PMA_getDiagMessageForFeature(__('Browser transformation'), 'mimework', $messages); if ($cfgRelation['commwork'] && !$cfgRelation['mimework']) { $retval .= '<tr><td colspan=2 class="left error">'; $retval .= __('Please see the documentation on how to' . ' update your column_info table. '); $retval .= PMA_Util::showDocu('config', 'cfg_Servers_column_info'); $retval .= '</td></tr>'; } $retval .= PMA_getDiagMessageForParameter('bookmarktable', isset($cfgRelation['bookmark']), $messages, 'bookmark'); $retval .= PMA_getDiagMessageForFeature(__('Bookmarked SQL query'), 'bookmarkwork', $messages); $retval .= PMA_getDiagMessageForParameter('history', isset($cfgRelation['history']), $messages, 'history'); $retval .= PMA_getDiagMessageForFeature(__('SQL history'), 'historywork', $messages); $retval .= PMA_getDiagMessageForParameter('recent', isset($cfgRelation['recent']), $messages, 'recent'); $retval .= PMA_getDiagMessageForFeature(__('Persistent recently used tables'), 'recentwork', $messages); $retval .= PMA_getDiagMessageForParameter('favorite', isset($cfgRelation['favorite']), $messages, 'favorite'); $retval .= PMA_getDiagMessageForFeature(__('Persistent favorite tables'), 'favoritework', $messages); $retval .= PMA_getDiagMessageForParameter('table_uiprefs', isset($cfgRelation['table_uiprefs']), $messages, 'table_uiprefs'); $retval .= PMA_getDiagMessageForFeature(__('Persistent tables\' UI preferences'), 'uiprefswork', $messages); $retval .= PMA_getDiagMessageForParameter('tracking', isset($cfgRelation['tracking']), $messages, 'tracking'); $retval .= PMA_getDiagMessageForFeature(__('Tracking'), 'trackingwork', $messages); $retval .= PMA_getDiagMessageForParameter('userconfig', isset($cfgRelation['userconfig']), $messages, 'userconfig'); $retval .= PMA_getDiagMessageForFeature(__('User preferences'), 'userconfigwork', $messages); $retval .= PMA_getDiagMessageForParameter('users', isset($cfgRelation['users']), $messages, 'users'); $retval .= PMA_getDiagMessageForParameter('usergroups', isset($cfgRelation['usergroups']), $messages, 'usergroups'); $retval .= PMA_getDiagMessageForFeature(__('Configurable menus'), 'menuswork', $messages); $retval .= PMA_getDiagMessageForParameter('navigationhiding', isset($cfgRelation['navigationhiding']), $messages, 'navigationhiding'); $retval .= PMA_getDiagMessageForFeature(__('Hide/show navigation items'), 'navwork', $messages); $retval .= PMA_getDiagMessageForParameter('savedsearches', isset($cfgRelation['savedsearches']), $messages, 'savedsearches'); $retval .= PMA_getDiagMessageForFeature(__('Saving Query-By-Example searches'), 'savedsearcheswork', $messages); $retval .= PMA_getDiagMessageForParameter('central_columns', isset($cfgRelation['central_columns']), $messages, 'central_columns'); $retval .= PMA_getDiagMessageForFeature(__('Managing Central list of columns'), 'central_columnswork', $messages); $retval .= '</table>' . "\n"; if (!$cfgRelation['allworks']) { $retval .= '<p>' . __('Quick steps to setup advanced features:') . '</p>'; $retval .= '<ul>'; $retval .= '<li>'; $retval .= sprintf(__('Create the needed tables with the ' . '<code>%screate_tables.sql</code>.'), htmlspecialchars(SQL_DIR)); $retval .= ' ' . PMA_Util::showDocu('setup', 'linked-tables'); $retval .= '</li>'; $retval .= '<li>'; $retval .= __('Create a pma user and give access to these tables.'); $retval .= ' ' . PMA_Util::showDocu('config', 'cfg_Servers_controluser'); $retval .= '</li>'; $retval .= '<li>'; $retval .= __('Enable advanced features in configuration file ' . '(<code>config.inc.php</code>), for example by ' . 'starting from <code>config.sample.inc.php</code>.'); $retval .= ' ' . PMA_Util::showDocu('setup', 'quick-install'); $retval .= '</li>'; $retval .= '<li>'; $retval .= __('Re-login to phpMyAdmin to load the updated configuration file.'); $retval .= '</li>'; $retval .= '</ul>'; } } return $retval; }
include_once 'libraries/bookmark.lib.php'; $book_sql_query = PMA_Bookmark_get( $db, '\'' . PMA_Util::sqlAddSlashes($table) . '\'', 'label', false, true ); if (! empty($book_sql_query)) { $GLOBALS['using_bookmark_message'] = PMA_message::notice( __('Using bookmark "%s" as default browse query.') ); $GLOBALS['using_bookmark_message']->addParam($table); $GLOBALS['using_bookmark_message']->addMessage( PMA_Util::showDocu('faq6_22') ); $sql_query = $book_sql_query; } else { $sql_query = 'SELECT * FROM ' . PMA_Util::backquote($table); } unset($book_sql_query); // set $goto to what will be displayed if query returns 0 rows $goto = 'tbl_structure.php'; } else { // Now we can check the parameters PMA_Util::checkParameters(array('sql_query')); } // instead of doing the test twice