Documentation TYPO3 par Ameos

querywindow.php

00001 <?php
00002 /* $Id: querywindow.php,v 2.2 2003/11/26 22:52:24 rabus Exp $ */
00003 // vim: expandtab sw=4 ts=4 sts=4:
00004 
00005 
00010 require_once('./libraries/grab_globals.lib.php');
00011 if (!empty($db)) {
00012     $db_start = $db;
00013 }
00014 
00015 
00019 require_once('./libraries/common.lib.php');
00020 require_once('./libraries/ob.lib.php');
00021 if ($cfg['OBGzip']) {
00022     $ob_mode = PMA_outBufferModeGet();
00023     if ($ob_mode) {
00024         PMA_outBufferPre($ob_mode);
00025     }
00026 }
00027 
00028 require_once('./libraries/relation.lib.php');
00029 $cfgRelation = PMA_getRelationsParam();
00030 
00036 if ($server > 0) {
00037     PMA_availableDatabases(); // this function is defined in "common.lib.php"
00038 } else {
00039     $num_dbs = 0;
00040 }
00041 
00042 // garvin: For re-usability, moved http-headers and stylesheets
00043 // to a seperate file. It can now be included by header.inc.php,
00044 // queryframe.php, querywindow.php.
00045 
00046 require_once('./libraries/header_http.inc.php');
00047 require_once('./libraries/header_meta_style.inc.php');
00048 ?>
00049 
00050 <script type="text/javascript" language="javascript">
00051 <?php
00052 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS'] && $cfg['QueryFrameDebug']) {
00053     $js_db = (isset($db) ? $db : 'FALSE');
00054     $js_table = (isset($table) ? $table : 'FALSE');
00055     $js_server = (isset($server) ? $server : 'FALSE');
00056 
00057     $js_true_db = '\' + document.querywindow.db.value + \'';
00058     $js_true_table = '\' + document.querywindow.table.value + \'';
00059     $js_true_server = '\' + document.querywindow.server.value + \'';
00060 
00061     $js_parent = '\' + opener.location.href + \'';
00062     $js_frame = '\' + opener.parent.location.href + \'';
00063 ?>
00064 function debug() {
00065     alert('<?php echo sprintf($strQueryFrameDebugBox, $js_db, $js_table, $js_server, $js_true_db, $js_true_table, $js_true_server, $js_parent, $js_frame); ?>');
00066     return false;
00067 }
00068 <?php
00069 }
00070 ?>
00071 function query_auto_commit() {
00072     document.sqlform.submit();
00073 }
00074 
00075 function query_tab_commit(tab) {
00076     document.querywindow.querydisplay_tab.value = tab;
00077     document.querywindow.submit();
00078     return false;
00079 }
00080 
00081 // js form validation stuff
00082 var errorMsg0   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strFormEmpty']); ?>';
00083 var errorMsg1   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotNumber']); ?>';
00084 var errorMsg2   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotValidNumber']); ?>';
00085 var noDropDbMsg = '<?php echo((!$GLOBALS['cfg']['AllowUserDropDatabase']) ? str_replace('\'', '\\\'', $GLOBALS['strNoDropDatabases']) : ''); ?>';
00086 var confirmMsg  = '<?php echo(($GLOBALS['cfg']['Confirm']) ? str_replace('\'', '\\\'', $GLOBALS['strDoYouReally']) : ''); ?>';
00087 //-->
00088 </script>
00089 <script src="libraries/functions.js" type="text/javascript" language="javascript"></script>
00090 </head>
00091 
00092 <body bgcolor="<?php echo ($cfg['QueryFrameJS'] ? $cfg['LeftBgColor'] : $cfg['RightBgColor']); ?>">
00093 
00094 <?php
00095 if ($cfg['QueryFrameJS'] && !isset($no_js)) {
00096     $querydisplay_tab = (isset($querydisplay_tab) ? $querydisplay_tab : $cfg['QueryWindowDefTab']);
00097 
00098     if ($cfg['LightTabs']) {
00099         echo '&nbsp;';
00100     } else {
00101         echo '<table border="0" cellspacing="0" cellpadding="3" width="100%" class="tabs">
00102         <tr>
00103             <td width="8">&nbsp;</td>';
00104     }
00105     echo "\n";
00106     echo PMA_printTab($strSQL, '#', '', 'onClick="javascript:query_tab_commit(\'sql\');return false;"', '', (isset($querydisplay_tab) && $querydisplay_tab == 'sql' ? TRUE : FALSE));
00107     echo PMA_printTab($strImportFiles, '#', '', 'onClick="javascript:query_tab_commit(\'files\');return false;"', '', (isset($querydisplay_tab) && $querydisplay_tab == 'files' ? TRUE : FALSE));
00108     echo PMA_printTab($strQuerySQLHistory, '#', '', 'onClick="javascript:query_tab_commit(\'history\');return false;"', '', (isset($querydisplay_tab) && $querydisplay_tab == 'history' ? TRUE : FALSE));
00109 
00110     if ($cfg['QueryWindowDefTab'] == 'full') {
00111         echo PMA_printTab($strAll, '#', '', 'onClick="javascript:query_tab_commit(\'full\');return false;"', '', (isset($querydisplay_tab) && $querydisplay_tab == 'full' ? TRUE : FALSE));
00112     }
00113 
00114     if (!$cfg['LightTabs']) {
00115         echo '</tr></table>';
00116     } else {
00117         echo '<br />';
00118     }
00119 } else {
00120     $querydisplay_tab = 'full';
00121 }
00122 
00123 ?>
00124 <br />
00125 
00126 <?php
00127 if ($cfg['PropertiesIconic'] == true) {
00128     // We need to copy the value or else the == 'both' check will always return true
00129     $propicon = (string)$cfg['PropertiesIconic'];
00130 
00131     if ($propicon == 'both') {
00132         $iconic_spacer = '<nobr>';
00133     } else {
00134         $iconic_spacer = '';
00135     }
00136 
00137     $titles['Change']        = $iconic_spacer . '<img hspace="7" width="12" height="13" src="images/button_edit.png" alt="' . $strChange . '" title="' . $strChange . '" border="0" />';
00138 
00139     if ($propicon == 'both') {
00140         $titles['Change']        .= '&nbsp;' . $strChange . '&nbsp;</nobr>';
00141     }
00142 } else {
00143     $titles['Change']        = $strChange;
00144 }
00145 
00146 // Hidden forms and query frame interaction stuff
00147 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
00148 
00149     $input_query_history = array();
00150     $sql_history = array();
00151     $dup_sql = array();
00152 
00153     if (isset($query_history_latest) && isset($query_history_latest_db) && $query_history_latest != '' && $query_history_latest_db != '') {
00154         if ($cfg['QueryHistoryDB'] && $cfgRelation['historywork']) {
00155             PMA_setHistory((isset($query_history_latest_db) ? $query_history_latest_db : ''), (isset($query_history_latest_table) ? $query_history_latest_table : ''), $cfg['Server']['user'], $query_history_latest);
00156         }
00157 
00158         $input_query_history[] = '<input type="hidden" name="query_history[]" value="' . $query_history_latest . '" />';
00159         $input_query_history[] = '<input type="hidden" name="query_history_db[]" value="' . htmlspecialchars($query_history_latest_db) . '" />';
00160         $input_query_history[] = '<input type="hidden" name="query_history_table[]" value="' . (isset($query_history_latest_table) ? htmlspecialchars($query_history_latest_table) : '') . '" />';
00161 
00162         $sql_history[] = '<li>'
00163                        . '<a href="#" onClick="document.querywindow.querydisplay_tab.value = \'' . (isset($querydisplay_tab) && $querydisplay_tab != 'full' ? 'sql' : 'full') . '\'; document.querywindow.query_history_latest.value = \'' . preg_replace('/(\n)/i', ' ', addslashes(htmlspecialchars($query_history_latest))) . '\'; document.querywindow.auto_commit.value = \'false\'; document.querywindow.db.value = \'' . htmlspecialchars($query_history_latest_db) . '\'; document.querywindow.query_history_latest_db.value = \'' . htmlspecialchars($query_history_latest_db) . '\'; document.querywindow.table.value = \'' . (isset($query_history_latest_table) ? htmlspecialchars($query_history_latest_table) : '') . '\'; document.querywindow.query_history_latest_table.value = \'' . (isset($query_history_latest_table) ? htmlspecialchars($query_history_latest_table) : '') . '\'; document.querywindow.submit(); return false;">' . $titles['Change'] . '</a>'
00164                        . '<a href="#" onClick="document.querywindow.querydisplay_tab.value = \'' . (isset($querydisplay_tab) && $querydisplay_tab != 'full' ? 'sql' : 'full') . '\'; document.querywindow.query_history_latest.value = \'' . preg_replace('/(\n)/i', ' ', addslashes(htmlspecialchars($query_history_latest))) . '\'; document.querywindow.auto_commit.value = \'true\'; document.querywindow.db.value = \'' . htmlspecialchars($query_history_latest_db) . '\'; document.querywindow.query_history_latest_db.value = \'' . htmlspecialchars($query_history_latest_db) . '\'; document.querywindow.table.value = \'' . (isset($query_history_latest_table) ? htmlspecialchars($query_history_latest_table) : '') . '\'; document.querywindow.query_history_latest_table.value = \'' . (isset($query_history_latest_table) ? htmlspecialchars($query_history_latest_table) : '') . '\'; document.querywindow.submit(); return false;">[' . htmlspecialchars($query_history_latest_db) . '] ' . urldecode($query_history_latest) . '</a>'
00165                        . '</li>' . "\n";
00166 
00167         $sql_query = urldecode($query_history_latest);
00168         $db = $query_history_latest_db;
00169         $table = $query_history_latest_table;
00170         $dup_sql[$query_history_latest] = true;
00171     } elseif (isset($query_history_latest) && $query_history_latest != '') {
00172         $sql_query = urldecode($query_history_latest);
00173     }
00174 
00175     if (isset($sql_query)) {
00176         $show_query = 1;
00177     }
00178 
00179     if ($cfg['QueryHistoryDB'] && $cfgRelation['historywork']) {
00180 
00181         $temp_history = PMA_getHistory($cfg['Server']['user']);
00182         if (is_array($temp_history) && count($temp_history) > 0) {
00183             foreach($temp_history AS $history_nr => $history_array) {
00184                 if (!isset($dup_sql[$history_array['sqlquery']])) {
00185                     $sql_history[] = '<li>'
00186                                    . '<a href="#" onClick="document.querywindow.querydisplay_tab.value = \'' . (isset($querydisplay_tab) && $querydisplay_tab != 'full' ? 'sql' : 'full') . '\'; document.querywindow.query_history_latest.value = \'' . preg_replace('/(\n)/i', ' ', addslashes(htmlspecialchars($history_array['sqlquery']))) . '\'; document.querywindow.auto_commit.value = \'false\'; document.querywindow.db.value = \'' . htmlspecialchars($history_array['db']) . '\'; document.querywindow.query_history_latest_db.value = \'' . htmlspecialchars($history_array['db']) . '\'; document.querywindow.table.value = \'' . (isset($history_array['table']) ? htmlspecialchars($history_array['table']) : '') . '\'; document.querywindow.query_history_latest_table.value = \'' . (isset($history_array['table']) ? htmlspecialchars($history_array['table']) : '') . '\'; document.querywindow.submit(); return false;">' . $titles['Change'] . '</a>'
00187                                    . '<a href="#" onClick="document.querywindow.querydisplay_tab.value = \'' . (isset($querydisplay_tab) && $querydisplay_tab != 'full' ? 'sql' : 'full') . '\'; document.querywindow.query_history_latest.value = \'' . preg_replace('/(\n)/i', ' ', addslashes(htmlspecialchars($history_array['sqlquery']))) . '\'; document.querywindow.auto_commit.value = \'true\'; document.querywindow.db.value = \'' . htmlspecialchars($history_array['db']) . '\'; document.querywindow.query_history_latest_db.value = \'' . htmlspecialchars($history_array['db']) . '\'; document.querywindow.table.value = \'' . (isset($history_array['table']) ? htmlspecialchars($history_array['table']) : '') . '\'; document.querywindow.query_history_latest_table.value = \'' . (isset($history_array['table']) ? htmlspecialchars($history_array['table']) : '') . '\'; document.querywindow.submit(); return false;">[' . htmlspecialchars($history_array['db']) . '] ' . urldecode($history_array['sqlquery']) . '</a>'
00188                                    . '</li>' . "\n";
00189                     $dup_sql[$history_array['sqlquery']] = true;
00190                 }
00191             }
00192         }
00193 
00194     } else {
00195 
00196         if (isset($query_history) && is_array($query_history)) {
00197             $current_index = count($query_history);
00198             foreach($query_history AS $query_no => $query_sql) {
00199                 if (!isset($dup_sql[$query_sql])) {
00200 
00201                     $input_query_history[] = '<input type="hidden" name="query_history[]" value="' . $query_sql . '" />';
00202                     $input_query_history[] = '<input type="hidden" name="query_history_db[]" value="' . htmlspecialchars($query_history_db[$query_no]) . '" />';
00203                     $input_query_history[] = '<input type="hidden" name="query_history_table[]" value="' . (isset($query_history_table[$query_no]) ? htmlspecialchars($query_history_table[$query_no]) : '') . '" />';
00204 
00205                     $sql_history[] = '<li>'
00206                                    . '<a href="#" onClick="document.querywindow.querydisplay_tab.value = \'' . (isset($querydisplay_tab) && $querydisplay_tab != 'full' ? 'sql' : 'full') . '\'; document.querywindow.query_history_latest.value = \'' . htmlspecialchars($query_sql) . '\'; document.querywindow.auto_commit.value = \'false\'; document.querywindow.db.value = \'' . htmlspecialchars($query_history_db[$query_no]) . '\'; document.querywindow.query_history_latest_db.value = \'' . htmlspecialchars($query_history_db[$query_no]) . '\'; document.querywindow.table.value = \'' . (isset($query_history_table[$query_no]) ? htmlspecialchars($query_history_table[$query_no]) : '') . '\'; document.querywindow.query_history_latest_table.value = \'' . (isset($query_history_table[$query_no]) ? htmlspecialchars($query_history_table[$query_no]) : '') . '\'; document.querywindow.submit(); return false;">' . $titles['Change'] . '</a>'
00207                                    . '<a href="#" onClick="document.querywindow.querydisplay_tab.value = \'' . (isset($querydisplay_tab) && $querydisplay_tab != 'full' ? 'sql' : 'full') . '\'; document.querywindow.query_history_latest.value = \'' . htmlspecialchars($query_sql) . '\'; document.querywindow.auto_commit.value = \'true\'; document.querywindow.db.value = \'' . htmlspecialchars($query_history_db[$query_no]) . '\'; document.querywindow.query_history_latest_db.value = \'' . htmlspecialchars($query_history_db[$query_no]) . '\'; document.querywindow.table.value = \'' . (isset($query_history_table[$query_no]) ? htmlspecialchars($query_history_table[$query_no]) : '') . '\'; document.querywindow.query_history_latest_table.value = \'' . (isset($query_history_table[$query_no]) ? htmlspecialchars($query_history_table[$query_no]) : '') . '\'; document.querywindow.submit(); return false;">[' . htmlspecialchars($query_history_db[$query_no]) . '] ' . urldecode($query_sql) . '</a>'
00208                                    . '</li>' . "\n";
00209                     $dup_sql[$query_sql] = true;
00210                 } // end if check if this item exists
00211             } // end while print history
00212         } // end if history exists
00213 
00214     } // end if DB-based history
00215 }
00216 
00217 $url_query = PMA_generate_common_url(isset($db) ? $db : '', isset($table) ? $table : '');
00218 if (!isset($goto)) {
00219     $goto = '';
00220 }
00221 
00222 require_once './libraries/bookmark.lib.php';
00223 $is_inside_querywindow = TRUE;
00224 require './tbl_query_box.php';
00225 
00226 // Hidden forms and query frame interaction stuff
00227 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
00228     if (isset($auto_commit) && $auto_commit == 'true') {
00229     ?>
00230         <script type="text/javascript" language="javascript">
00231         query_auto_commit();
00232         </script>
00233     <?php
00234     }
00235 
00236     if (isset($sql_history) && isset($querydisplay_tab) && ($querydisplay_tab == 'history' || $querydisplay_tab == 'full') && is_array($sql_history) && count($sql_history) > 0) {
00237     ?>
00238     <li>
00239         <div style="margin-bottom: 10px"><?php echo $strQuerySQLHistory . ':<br><ul>' . implode('', $sql_history) . '</ul>'; ?></div>
00240     </li>
00241     <?php
00242     }
00243 ?>
00244 <form action="querywindow.php" method="post" name="querywindow">
00245 <?php
00246     echo PMA_generate_common_hidden_inputs('', '');
00247     if (count($input_query_history) > 0) {
00248         echo implode("\n", $input_query_history);
00249     }
00250 ?>
00251     <input type="hidden" name="db" value="<?php echo (empty($db) ? '' : htmlspecialchars($db)); ?>" />
00252     <input type="hidden" name="table" value="<?php echo (empty($table) ? '' : htmlspecialchars($table)); ?>" />
00253 
00254     <input type="hidden" name="query_history_latest" value="" />
00255     <input type="hidden" name="query_history_latest_db" value="" />
00256     <input type="hidden" name="query_history_latest_table" value="" />
00257 
00258     <input type="hidden" name="previous_db" value="<?php echo htmlspecialchars($db); ?>" />
00259 
00260     <input type="hidden" name="auto_commit" value="false" />
00261     <input type="hidden" name="querydisplay_tab" value="<?php echo $querydisplay_tab; ?>" />
00262 </form>
00263 <?php
00264 }
00265 
00266 /* REMOVE ME */
00267 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS'] && $cfg['QueryFrameDebug']) {
00268 ?>
00269 <br>
00270 <center>
00271     <a href='#' onClick='return debug();'><?php echo $strQueryFrameDebug; ?></a>
00272 </center>
00273 <?php
00274 }
00275 /* REMOVE ME */
00276 ?>
00277 
00278 </body>
00279 </html>
00280 
00281 <?php
00285 if (isset($dbh) && $dbh) {
00286     @mysql_close($dbh);
00287 }
00288 if (isset($userlink) && $userlink) {
00289     @mysql_close($userlink);
00290 }
00291 
00292 
00296 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
00297     && isset($ob_mode) && $ob_mode) {
00298      PMA_outBufferPost($ob_mode);
00299 }
00300 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6