home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / libraries / sql_query_form.lib.php < prev    next >
Encoding:
PHP Script  |  2008-06-23  |  21.0 KB  |  574 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  * functions for displaying the sql query form
  5.  *
  6.  * @version $Id: sql_query_form.lib.php 11326 2008-06-17 21:32:48Z lem9 $
  7.  * @usedby  server_sql.php
  8.  * @usedby  db_sql.php
  9.  * @usedby  tbl_sql.php
  10.  * @usedby  tbl_structure.php
  11.  * @usedby  querywindow.php
  12.  */
  13. if (! defined('PHPMYADMIN')) {
  14.     exit;
  15. }
  16.  
  17. /**
  18.  *
  19.  */
  20. require_once './libraries/file_listing.php'; // used for file listing
  21. require_once './libraries/bookmark.lib.php'; // used for file listing
  22.  
  23. /**
  24.  * prints the sql query boxes
  25.  *
  26.  * @usedby  server_sql.php
  27.  * @usedby  db_sql.php
  28.  * @usedby  tbl_sql.php
  29.  * @usedby  tbl_structure.php
  30.  * @usedby  querywindow.php
  31.  * @uses    $GLOBALS['table']
  32.  * @uses    $GLOBALS['db']
  33.  * @uses    $GLOBALS['server']
  34.  * @uses    $GLOBALS['goto']
  35.  * @uses    $GLOBALS['is_upload']           from common.inc.php
  36.  * @uses    $GLOBALS['sql_query']           from grab_globals.lib.php
  37.  * @uses    $GLOBALS['cfg']['DefaultQueryTable']
  38.  * @uses    $GLOBALS['cfg']['DefaultQueryDatabase']
  39.  * @uses    $GLOBALS['cfg']['Servers']
  40.  * @uses    $GLOBALS['cfg']['DefaultTabDatabase']
  41.  * @uses    $GLOBALS['cfg']['DefaultQueryDatabase']
  42.  * @uses    $GLOBALS['cfg']['DefaultQueryTable']
  43.  * @uses    $GLOBALS['cfg']['Bookmark']['db']
  44.  * @uses    $GLOBALS['cfg']['Bookmark']['table']
  45.  * @uses    $GLOBALS['strSuccess']
  46.  * @uses    PMA_generate_common_url()
  47.  * @uses    PMA_backquote()
  48.  * @uses    PMA_DBI_fetch_result()
  49.  * @uses    PMA_showMySQLDocu()
  50.  * @uses    PMA_generate_common_hidden_inputs()
  51.  * @uses    PMA_sqlQueryFormBookmark()
  52.  * @uses    PMA_sqlQueryFormInsert()
  53.  * @uses    PMA_sqlQueryFormUpload()
  54.  * @uses    PMA_DBI_QUERY_STORE
  55.  * @uses    PMA_set_enc_form()
  56.  * @uses    sprintf()
  57.  * @uses    htmlspecialchars()
  58.  * @uses    str_replace()
  59.  * @uses    md5()
  60.  * @uses    function_exists()
  61.  * @param   boolean|string  $query          query to display in the textarea
  62.  *                                          or true to display last executed
  63.  * @param   boolean|string  $display_tab    sql|files|history|full|FALSE
  64.  *                                          what part to display
  65.  *                                          false if not inside querywindow
  66.  * @param   string          $delimiter
  67.  */
  68. function PMA_sqlQueryForm($query = true, $display_tab = false, $delimiter = ';')
  69. {
  70.     // check tab to display if inside querywindow
  71.     if (! $display_tab) {
  72.         $display_tab = 'full';
  73.         $is_querywindow = false;
  74.     } else {
  75.         $is_querywindow = true;
  76.     }
  77.  
  78.     // query to show
  79.     if (true === $query) {
  80.         $query = $GLOBALS['sql_query'];
  81.     }
  82.  
  83.     // set enctype to multipart for file uploads
  84.     if ($GLOBALS['is_upload']) {
  85.         $enctype = ' enctype="multipart/form-data"';
  86.     } else {
  87.         $enctype = '';
  88.     }
  89.  
  90.     $table  = '';
  91.     $db     = '';
  92.     if (! strlen($GLOBALS['db'])) {
  93.         // prepare for server related
  94.         $goto   = empty($GLOBALS['goto']) ?
  95.                     'server_sql.php' : $GLOBALS['goto'];
  96.     } elseif (! strlen($GLOBALS['table'])) {
  97.         // prepare for db related
  98.         $db     = $GLOBALS['db'];
  99.         $goto   = empty($GLOBALS['goto']) ?
  100.                     'db_sql.php' : $GLOBALS['goto'];
  101.     } else {
  102.         $table  = $GLOBALS['table'];
  103.         $db     = $GLOBALS['db'];
  104.         $goto   = empty($GLOBALS['goto']) ?
  105.                     'tbl_sql.php' : $GLOBALS['goto'];
  106.     }
  107.  
  108.  
  109.     // start output
  110.     if ($is_querywindow) {
  111.         ?>
  112.         <form method="post" id="sqlqueryform" target="frame_content"
  113.               action="import.php"<?php echo $enctype; ?> name="sqlform"
  114.               onsubmit="
  115.               // <![CDATA[
  116.               var save_name = window.opener.parent.frame_content.name;
  117.               window.opener.parent.frame_content.name = save_name + '<?php echo time(); ?>';
  118.               this.target = window.opener.parent.frame_content.name;
  119.               return checkSqlQuery(this);
  120.               // ]]" >
  121.         <?php
  122.     } else {
  123.         echo '<form method="post" action="import.php" ' . $enctype . ' id="sqlqueryform"'
  124.             .' onsubmit="return checkSqlQuery(this)" name="sqlform">' . "\n";
  125.     }
  126.  
  127.     if ($is_querywindow) {
  128.         echo '<input type="hidden" name="focus_querywindow" value="true" />'
  129.             ."\n";
  130.         if ($display_tab != 'sql' && $display_tab != 'full') {
  131.             echo '<input type="hidden" name="sql_query" value="" />' . "\n";
  132.             echo '<input type="hidden" name="show_query" value="1" />' . "\n";
  133.         }
  134.     }
  135.     echo '<input type="hidden" name="is_js_confirmed" value="0" />' . "\n"
  136.         .PMA_generate_common_hidden_inputs($db, $table) . "\n"
  137.         .'<input type="hidden" name="pos" value="0" />' . "\n"
  138.         .'<input type="hidden" name="goto" value="'
  139.         .htmlspecialchars($goto) . '" />' . "\n"
  140.         .'<input type="hidden" name="zero_rows" value="'
  141.         . htmlspecialchars($GLOBALS['strSuccess']) . '" />' . "\n"
  142.         .'<input type="hidden" name="prev_sql_query" value="'
  143.         . htmlspecialchars($query) . '" />' . "\n";
  144.  
  145.     // display querybox
  146.     if ($display_tab === 'full' || $display_tab === 'sql') {
  147.         PMA_sqlQueryFormInsert($query, $is_querywindow, $delimiter);
  148.     }
  149.  
  150.     // display uploads
  151.     if ($display_tab === 'files' && $GLOBALS['is_upload']) {
  152.         PMA_sqlQueryFormUpload();
  153.     }
  154.  
  155.     // Bookmark Support
  156.     if ($display_tab === 'full' || $display_tab === 'history') {
  157.         if (! empty($GLOBALS['cfg']['Bookmark'])
  158.           && $GLOBALS['cfg']['Bookmark']['db']
  159.           && $GLOBALS['cfg']['Bookmark']['table']) {
  160.             PMA_sqlQueryFormBookmark();
  161.         }
  162.     }
  163.  
  164.     // Encoding setting form appended by Y.Kawada
  165.     if (function_exists('PMA_set_enc_form')) {
  166.         echo PMA_set_enc_form('    ');
  167.     }
  168.  
  169.     echo '</form>' . "\n";
  170.     if ($is_querywindow) {
  171.         ?>
  172.         <script type="text/javascript">
  173.         //<![CDATA[
  174.             if (window.opener) {
  175.                 window.opener.parent.insertQuery();
  176.             }
  177.         //]]>
  178.         </script>
  179.         <?php
  180.     }
  181. }
  182.  
  183. /**
  184.  * prints querybox fieldset
  185.  *
  186.  * @usedby  PMA_sqlQueryForm()
  187.  * @uses    $GLOBALS['text_dir']
  188.  * @uses    $GLOBALS['cfg']['TextareaAutoSelect']
  189.  * @uses    $GLOBALS['cfg']['TextareaCols']
  190.  * @uses    $GLOBALS['cfg']['TextareaRows']
  191.  * @uses    $GLOBALS['strShowThisQuery']
  192.  * @uses    $GLOBALS['strGo']
  193.  * @uses    PMA_USR_OS
  194.  * @uses    PMA_USR_BROWSER_AGENT
  195.  * @uses    PMA_USR_BROWSER_VER
  196.  * @uses    htmlspecialchars()
  197.  * @param   string      $query          query to display in the textarea
  198.  * @param   boolean     $is_querywindow if inside querywindow or not
  199.  * @param   string      $delimiter      default delimiter to use
  200.  */
  201. function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false, $delimiter = ';')
  202. {
  203.  
  204.     // enable auto select text in textarea
  205.     if ($GLOBALS['cfg']['TextareaAutoSelect']) {
  206.         $auto_sel = ' onfocus="selectContent(this, sql_box_locked, true)"';
  207.     } else {
  208.         $auto_sel = '';
  209.     }
  210.  
  211.     // enable locking if inside query window
  212.     if ($is_querywindow) {
  213.         $locking = ' onkeypress="document.sqlform.elements[\'LockFromUpdate\'].'
  214.             .'checked = true;"';
  215.         $height = $GLOBALS['cfg']['TextareaRows'] * 1.25;
  216.     } else {
  217.         $locking = '';
  218.         $height = $GLOBALS['cfg']['TextareaRows'] * 2;
  219.     }
  220.  
  221.     $table          = '';
  222.     $db             = '';
  223.     $fields_list    = array();
  224.     if (! strlen($GLOBALS['db'])) {
  225.         // prepare for server related
  226.         $legend = sprintf($GLOBALS['strRunSQLQueryOnServer'],
  227.             '"' . htmlspecialchars(
  228.                 ! empty($GLOBALS['cfg']['Servers'][$GLOBALS['server']]['verbose']) ? $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['verbose'] : $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host']) . '"');
  229.     } elseif (! strlen($GLOBALS['table'])) {
  230.         // prepare for db related
  231.         $db     = $GLOBALS['db'];
  232.         // if you want navigation:
  233.         $strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase']
  234.             . '?' . PMA_generate_common_url($db) . '"';
  235.         if ($is_querywindow) {
  236.             $strDBLink .= ' target="_self"'
  237.                 . ' onclick="this.target=window.opener.frame_content.name"';
  238.         }
  239.         $strDBLink .= '>'
  240.             . htmlspecialchars($db) . '</a>';
  241.         // else use
  242.         // $strDBLink = htmlspecialchars($db);
  243.         $legend = sprintf($GLOBALS['strRunSQLQuery'], $strDBLink);
  244.         if (empty($query)) {
  245.             $query = str_replace('%d',
  246.                 PMA_backquote($db), $GLOBALS['cfg']['DefaultQueryDatabase']);
  247.         }
  248.     } else {
  249.         $table  = $GLOBALS['table'];
  250.         $db     = $GLOBALS['db'];
  251.         // Get the list and number of fields
  252.         // we do a try_query here, because we could be in the query window,
  253.         // trying to synchonize and the table has not yet been created
  254.         $fields_list = PMA_DBI_fetch_result(
  255.             'SHOW FULL COLUMNS FROM ' . PMA_backquote($db)
  256.             . '.' . PMA_backquote($GLOBALS['table']));
  257.  
  258.         $strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase']
  259.             . '?' . PMA_generate_common_url($db) . '"';
  260.         if ($is_querywindow) {
  261.             $strDBLink .= ' target="_self"'
  262.                 . ' onclick="this.target=window.opener.frame_content.name"';
  263.         }
  264.         $strDBLink .= '>'
  265.             . htmlspecialchars($db) . '</a>';
  266.         // else use
  267.         // $strDBLink = htmlspecialchars($db);
  268.         $legend = sprintf($GLOBALS['strRunSQLQuery'], $strDBLink);
  269.         if (empty($query) && count($fields_list)) {
  270.             $field_names = array();
  271.             foreach ($fields_list as $field) {
  272.                 $field_names[] = PMA_backquote($field['Field']);
  273.             }
  274.             $query =
  275.                 str_replace('%d', PMA_backquote($db),
  276.                     str_replace('%t', PMA_backquote($table),
  277.                         str_replace('%f',
  278.                             implode(', ', $field_names),
  279.                             $GLOBALS['cfg']['DefaultQueryTable'])));
  280.             unset($field_names);
  281.         }
  282.     }
  283.     $legend .= ': ' . PMA_showMySQLDocu('SQL-Syntax', 'SELECT');
  284.  
  285.     if (count($fields_list)) {
  286.         $sqlquerycontainer_id = 'sqlquerycontainer';
  287.     } else {
  288.         $sqlquerycontainer_id = 'sqlquerycontainerfull';
  289.     }
  290.  
  291.     echo '<a name="querybox"></a>' . "\n"
  292.         .'<div id="queryboxcontainer">' . "\n"
  293.         .'<fieldset id="querybox">' . "\n";
  294.     echo '<legend>' . $legend . '</legend>' . "\n";
  295.     echo '<div id="queryfieldscontainer">' . "\n";
  296.     echo '<div id="' . $sqlquerycontainer_id . '">' . "\n"
  297.         .'<textarea name="sql_query" id="sqlquery"'
  298.         .'  cols="' . $GLOBALS['cfg']['TextareaCols'] . '"'
  299.         .'  rows="' . $height . '"'
  300.         .'  dir="' . $GLOBALS['text_dir'] . '"'
  301.         .$auto_sel . $locking . '>' . htmlspecialchars($query) . '</textarea>' . "\n";
  302.     echo '</div>' . "\n";
  303.  
  304.     if (count($fields_list)) {
  305.         echo '<div id="tablefieldscontainer">' . "\n"
  306.             .'<label>' . $GLOBALS['strFields'] . '</label>' . "\n"
  307.             .'<select id="tablefields" name="dummy" '
  308.             .'size="' . ($GLOBALS['cfg']['TextareaRows'] - 2) . '" '
  309.             .'multiple="multiple" ondblclick="insertValueQuery()">' . "\n";
  310.         foreach ($fields_list as $field) {
  311.             echo '<option value="'
  312.                 .PMA_backquote(htmlspecialchars($field['Field'])) . '"';
  313.             if (isset($field['Field']) && strlen($field['Field']) && isset($field['Comment'])) {
  314.                 echo ' title="' . htmlspecialchars($field['Comment']) . '"';
  315.             }
  316.             echo '>' . htmlspecialchars($field['Field']) . '</option>' . "\n";
  317.         }
  318.         echo '</select>' . "\n"
  319.             .'<div id="tablefieldinsertbuttoncontainer">' . "\n";
  320.         if ($GLOBALS['cfg']['PropertiesIconic']) {
  321.             echo '<input type="button" name="insert" value="<<"'
  322.                 .' onclick="insertValueQuery()"'
  323.                 .' title="' . $GLOBALS['strInsert'] . '" />' . "\n";
  324.         } else {
  325.             echo '<input type="button" name="insert"'
  326.                 .' value="' . $GLOBALS['strInsert'] . '"'
  327.                 .' onclick="insertValueQuery()" />' . "\n";
  328.         }
  329.         echo '</div>' . "\n"
  330.             .'</div>' . "\n";
  331.     }
  332.  
  333.     echo '<div class="clearfloat"></div>' . "\n";
  334.     echo '</div>' . "\n";
  335.  
  336.     if (! empty($GLOBALS['cfg']['Bookmark'])
  337.       && $GLOBALS['cfg']['Bookmark']['db']
  338.       && $GLOBALS['cfg']['Bookmark']['table']) {
  339.         ?>
  340.         <div id="bookmarkoptions">
  341.         <div class="formelement">
  342.         <label for="bkm_label">
  343.             <?php echo $GLOBALS['strBookmarkThis']; ?>:</label>
  344.         <input type="text" name="bkm_label" id="bkm_label" value="" />
  345.         </div>
  346.         <div class="formelement">
  347.         <input type="checkbox" name="bkm_all_users" id="id_bkm_all_users"
  348.             value="true" />
  349.         <label for="id_bkm_all_users">
  350.             <?php echo $GLOBALS['strBookmarkAllUsers']; ?></label>
  351.         </div>
  352.         <div class="formelement">
  353.         <input type="checkbox" name="bkm_replace" id="id_bkm_replace"
  354.             value="true" />
  355.         <label for="id_bkm_replace">
  356.             <?php echo $GLOBALS['strBookmarkReplace']; ?></label>
  357.         </div>
  358.         </div>
  359.         <?php
  360.     }
  361.  
  362.     echo '<div class="clearfloat"></div>' . "\n";
  363.     echo '</fieldset>' . "\n"
  364.         .'</div>' . "\n";
  365.  
  366.     echo '<fieldset id="queryboxfooter" class="tblFooters">' . "\n";
  367.     echo '<div class="formelement">' . "\n";
  368.     if ($is_querywindow) {
  369.         ?>
  370.         <script type="text/javascript">
  371.         //<![CDATA[
  372.             document.writeln(' <input type="checkbox" name="LockFromUpdate" value="1" id="checkbox_lock" /> <label for="checkbox_lock"><?php echo $GLOBALS['strQueryWindowLock']; ?></label> ');
  373.         //]]>
  374.         </script>
  375.         <?php
  376.     }
  377.     echo '</div>' . "\n";
  378.     echo '<div class="formelement">' . "\n";
  379.     if (PMA_MYSQL_INT_VERSION >= 50000) {
  380.         echo '<label for="id_sql_delimiter">[ ' . $GLOBALS['strDelimiter']
  381.             .'</label>' . "\n";
  382.         echo '<input type="text" name="sql_delimiter" size="3" '
  383.             .'value="' . $delimiter . '" '
  384.             .'id="id_sql_delimiter" /> ]' . "\n";
  385.     }
  386.  
  387.     echo '<input type="checkbox" name="show_query" value="1" '
  388.         .'id="checkbox_show_query" checked="checked" />' . "\n"
  389.         .'<label for="checkbox_show_query">' . $GLOBALS['strShowThisQuery']
  390.         .'</label>' . "\n";
  391.  
  392.     echo '</div>' . "\n";
  393.     echo '<input type="submit" name="SQL" value="' . $GLOBALS['strGo'] . '" />'
  394.         ."\n";
  395.     echo '<div class="clearfloat"></div>' . "\n";
  396.     echo '</fieldset>' . "\n";
  397. }
  398.  
  399. /**
  400.  * prints bookmark fieldset
  401.  *
  402.  * @usedby  PMA_sqlQueryForm()
  403.  * @uses    PMA_listBookmarks()
  404.  * @uses    $GLOBALS['db']
  405.  * @uses    $GLOBALS['pmaThemeImage']
  406.  * @uses    $GLOBALS['cfg']['Bookmark']
  407.  * @uses    $GLOBALS['cfg']['ReplaceHelpImg']
  408.  * @uses    $GLOBALS['strBookmarkQuery']
  409.  * @uses    $GLOBALS['strBookmarkView']
  410.  * @uses    $GLOBALS['strDelete']
  411.  * @uses    $GLOBALS['strDocu']
  412.  * @uses    $GLOBALS['strGo']
  413.  * @uses    $GLOBALS['strSubmit']
  414.  * @uses    $GLOBALS['strVar']
  415.  * @uses    count()
  416.  * @uses    htmlspecialchars()
  417.  */
  418. function PMA_sqlQueryFormBookmark()
  419. {
  420.     $bookmark_list = PMA_listBookmarks($GLOBALS['db'], $GLOBALS['cfg']['Bookmark']);
  421.     if (! $bookmark_list || count($bookmark_list) < 1) {
  422.         return;
  423.     }
  424.  
  425.     echo '<fieldset id="bookmarkoptions">';
  426.     echo '<legend>';
  427.     echo $GLOBALS['strBookmarkQuery'] . '</legend>' . "\n";
  428.     echo '<div class="formelement">';
  429.     echo '<select name="id_bookmark">' . "\n";
  430.     echo '<option value=""> </option>' . "\n";
  431.     foreach ($bookmark_list as $key => $value) {
  432.         echo '<option value="' . htmlspecialchars($key) . '">'
  433.             .htmlspecialchars($value) . '</option>' . "\n";
  434.     }
  435.     //   is required for correct display with styles/line height
  436.     echo '</select> ' . "\n";
  437.     echo '</div>' . "\n";
  438.     echo '<div class="formelement">' . "\n";
  439.     echo $GLOBALS['strVar'];
  440.     if ($GLOBALS['cfg']['ReplaceHelpImg']) {
  441.         echo ' <a href="./Documentation.html#faqbookmark"'
  442.             .' target="documentation">'
  443.             .'<img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_help.png"'
  444.             .' border="0" width="11" height="11" align="middle"'
  445.             .' alt="' . $GLOBALS['strDocu'] . '" /></a> ';
  446.     } else {
  447.         echo ' (<a href="./Documentation.html#faqbookmark"'
  448.             .' target="documentation">' . $GLOBALS['strDocu'] . '</a>): ';
  449.     }
  450.     echo '<input type="text" name="bookmark_variable" class="textfield"'
  451.         .' size="10" />' . "\n";
  452.     echo '</div>' . "\n";
  453.     echo '<div class="formelement">' . "\n";
  454.     echo '<input type="radio" name="action_bookmark" value="0"'
  455.         .' id="radio_bookmark_exe" checked="checked" />'
  456.         .'<label for="radio_bookmark_exe">' . $GLOBALS['strSubmit']
  457.         .'</label>' . "\n";
  458.     echo '<input type="radio" name="action_bookmark" value="1"'
  459.         .' id="radio_bookmark_view" />'
  460.         .'<label for="radio_bookmark_view">' . $GLOBALS['strBookmarkView']
  461.         .'</label>' . "\n";
  462.     echo '<input type="radio" name="action_bookmark" value="2"'
  463.         .' id="radio_bookmark_del" />'
  464.         .'<label for="radio_bookmark_del">' . $GLOBALS['strDelete']
  465.         .'</label>' . "\n";
  466.     echo '</div>' . "\n";
  467.     echo '<div class="clearfloat"></div>' . "\n";
  468.     echo '</fieldset>' . "\n";
  469.  
  470.     echo '<fieldset id="bookmarkoptionsfooter" class="tblFooters">' . "\n";
  471.     echo '<input type="submit" name="SQL" value="' . $GLOBALS['strGo'] . '" />';
  472.     echo '<div class="clearfloat"></div>' . "\n";
  473.     echo '</fieldset>' . "\n";
  474. }
  475.  
  476. /**
  477.  * prints bookmark fieldset
  478.  *
  479.  * @usedby  PMA_sqlQueryForm()
  480.  * @uses    $GLOBALS['cfg']['GZipDump']
  481.  * @uses    $GLOBALS['cfg']['BZipDump']
  482.  * @uses    $GLOBALS['cfg']['UploadDir']
  483.  * @uses    $GLOBALS['cfg']['AvailableCharsets']
  484.  * @uses    $GLOBALS['cfg']['AllowAnywhereRecoding']
  485.  * @uses    $GLOBALS['strBzip']
  486.  * @uses    $GLOBALS['strCharsetOfFile']
  487.  * @uses    $GLOBALS['strCompression']
  488.  * @uses    $GLOBALS['strError']
  489.  * @uses    $GLOBALS['strGo']
  490.  * @uses    $GLOBALS['strGzip']
  491.  * @uses    $GLOBALS['strLocationTextfile']
  492.  * @uses    $GLOBALS['strWebServerUploadDirectory']
  493.  * @uses    $GLOBALS['strWebServerUploadDirectoryError']
  494.  * @uses    $GLOBALS['allow_recoding']
  495.  * @uses    $GLOBALS['charset']
  496.  * @uses    $GLOBALS['max_upload_size']
  497.  * @uses    PMA_supportedDecompressions()
  498.  * @uses    PMA_getFileSelectOptions()
  499.  * @uses    PMA_displayMaximumUploadSize()
  500.  * @uses    PMA_generateCharsetDropdownBox()
  501.  * @uses    PMA_generateHiddenMaxFileSize()
  502.  * @uses    PMA_MYSQL_INT_VERSION
  503.  * @uses    PMA_CSDROPDOWN_CHARSET
  504.  * @uses    empty()
  505.  */
  506. function PMA_sqlQueryFormUpload(){
  507.     $errors = array ();
  508.  
  509.     $matcher = '@\.sql(\.(' . PMA_supportedDecompressions() . '))?$@'; // we allow only SQL here
  510.  
  511.     if (!empty($GLOBALS['cfg']['UploadDir'])) {
  512.         $files = PMA_getFileSelectOptions(PMA_userDir($GLOBALS['cfg']['UploadDir']), $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ? $local_import_file : '');
  513.     } else {
  514.         $files = '';
  515.     }
  516.  
  517.     // start output
  518.     echo '<fieldset id="">';
  519.     echo '<legend>';
  520.     echo $GLOBALS['strLocationTextfile'] . '</legend>';
  521.     echo '<div class="formelement">';
  522.     echo '<input type="file" name="sql_file" class="textfield" /> ';
  523.     echo PMA_displayMaximumUploadSize($GLOBALS['max_upload_size']);
  524.     // some browsers should respect this :)
  525.     echo PMA_generateHiddenMaxFileSize($GLOBALS['max_upload_size']) . "\n";
  526.     echo '</div>';
  527.  
  528.     if ($files === FALSE) {
  529.         $errors[$GLOBALS['strError']] = $GLOBALS['strWebServerUploadDirectoryError'];
  530.     } elseif (!empty($files)) {
  531.         echo '<div class="formelement">';
  532.         echo '<strong>' . $GLOBALS['strWebServerUploadDirectory'] .':</strong>' . "\n";
  533.         echo '<select size="1" name="sql_localfile">' . "\n";
  534.         echo '<option value="" selected="selected"></option>' . "\n";
  535.         echo $files;
  536.         echo '</select>' . "\n";
  537.         echo '</div>';
  538.     }
  539.  
  540.     echo '<div class="clearfloat"></div>' . "\n";
  541.     echo '</fieldset>';
  542.  
  543.  
  544.     echo '<fieldset id="" class="tblFooters">';
  545.     if (PMA_MYSQL_INT_VERSION < 40100
  546.       && $GLOBALS['cfg']['AllowAnywhereRecoding']
  547.       && $GLOBALS['allow_recoding']) {
  548.         echo $GLOBALS['strCharsetOfFile'] . "\n"
  549.              . '<select name="charset_of_file" size="1">' . "\n";
  550.         foreach ($GLOBALS['cfg']['AvailableCharsets'] as $temp_charset) {
  551.             echo '<option value="' . $temp_charset . '"';
  552.             if ($temp_charset == $GLOBALS['charset']) {
  553.                 echo ' selected="selected"';
  554.             }
  555.             echo '>' . $temp_charset . '</option>' . "\n";
  556.         }
  557.         echo '</select>' . "\n";
  558.     } elseif (PMA_MYSQL_INT_VERSION >= 40100) {
  559.         echo $GLOBALS['strCharsetOfFile'] . "\n";
  560.         echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET,
  561.                 'charset_of_file', null, 'utf8', FALSE);
  562.     } // end if (recoding)
  563.     echo '<input type="submit" name="SQL" value="' . $GLOBALS['strGo']
  564.         .'" />' . "\n";
  565.     echo '<div class="clearfloat"></div>' . "\n";
  566.     echo '</fieldset>';
  567.  
  568.     foreach ($errors as $error => $message) {
  569.         echo '<div>' . $error . '</div>';
  570.         echo '<div>' . $message . '</div>';
  571.     }
  572. }
  573. ?>
  574.