Documentation TYPO3 par Ameos

querywindow.php

00001 <?php
00002 /* $Id: querywindow.php,v 2.18 2005/08/16 17:49:57 lem9 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 <!--
00052 function query_auto_commit() {
00053     document.sqlform.submit();
00054 }
00055 
00056 function query_tab_commit(tab) {
00057     document.querywindow.querydisplay_tab.value = tab;
00058     document.querywindow.submit();
00059     return false;
00060 }
00061 
00062 // js form validation stuff
00063 
00064 var errorMsg0   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strFormEmpty']); ?>';
00065 var errorMsg1   = '<?php echo str_replace('\'', '\\\'', $GLOBALS['strNotNumber']); ?>';
00066 var noDropDbMsg = '<?php echo((!$GLOBALS['cfg']['AllowUserDropDatabase']) ? str_replace('\'', '\\\'', $GLOBALS['strNoDropDatabases']) : ''); ?>';
00067 var confirmMsg  = '<?php echo(($GLOBALS['cfg']['Confirm']) ? str_replace('\'', '\\\'', $GLOBALS['strDoYouReally']) : ''); ?>';
00068 
00069 //-->
00070 </script>
00071 <script src="libraries/functions.js" type="text/javascript" language="javascript"></script>
00072 </head>
00073 
00074 <body bgcolor="<?php echo ($cfg['QueryFrameJS'] ? $cfg['LeftBgColor'] : $cfg['RightBgColor']); ?>">
00075 <?php
00076 if ($cfg['QueryFrameJS'] && !isset($no_js)) {
00077     $querydisplay_tab = (isset($querydisplay_tab) ? $querydisplay_tab : $cfg['QueryWindowDefTab']);
00078 
00079     $tabs = array();
00080     $tabs['sql']['icon']   = 'b_sql.png';
00081     $tabs['sql']['text']   = $strSQL;
00082     $tabs['sql']['link']   = '#';
00083     $tabs['sql']['attr']   = 'onclick="javascript:query_tab_commit(\'sql\');return false;"';
00084     $tabs['sql']['active'] = (bool) (isset($querydisplay_tab) && $querydisplay_tab == 'sql');
00085     $tabs['import']['icon']   = 'b_import.png';
00086     $tabs['import']['text']   = $strImportFiles;
00087     $tabs['import']['link']   = '#';
00088     $tabs['import']['attr']   = 'onclick="javascript:query_tab_commit(\'files\');return false;"';
00089     $tabs['import']['active'] = (bool) (isset($querydisplay_tab) && $querydisplay_tab == 'files');
00090     $tabs['history']['text']   = $strQuerySQLHistory;
00091     $tabs['history']['link']   = '#';
00092     $tabs['history']['attr']   = 'onclick="javascript:query_tab_commit(\'history\');return false;"';
00093     $tabs['history']['active'] = (bool) (isset($querydisplay_tab) && $querydisplay_tab == 'history');
00094 
00095     if ($cfg['QueryWindowDefTab'] == 'full') {
00096         $tabs['all']['text']   = $strAll;
00097         $tabs['all']['link']   = '#';
00098         $tabs['all']['attr']   = 'onclick="javascript:query_tab_commit(\'full\');return false;"';
00099         $tabs['all']['active'] = (bool) (isset($querydisplay_tab) && $querydisplay_tab == 'full');
00100     }
00101 
00102     echo PMA_getTabs( $tabs );
00103     unset( $tabs );
00104 } else {
00105     $querydisplay_tab = 'full';
00106 }
00107 
00108 ?>
00109 <br />
00110 <?php
00111 if ($cfg['PropertiesIconic'] == true) {
00112     // We need to copy the value or else the == 'both' check will always return true
00113     $propicon = (string)$cfg['PropertiesIconic'];
00114 
00115     if ($propicon == 'both') {
00116         $iconic_spacer = '<div class="nowrap">';
00117     } else {
00118         $iconic_spacer = '';
00119     }
00120 
00121     $titles['Change']        = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' . $pmaThemeImage . 'b_edit.png" alt="' . $strChange . '" title="' . $strChange . '" border="0" />';
00122 
00123     if ($propicon == 'both') {
00124         $titles['Change']        .= '&nbsp;' . $strChange . '&nbsp;</div>';
00125     }
00126 } else {
00127     $titles['Change']        = $strChange;
00128 }
00129 
00130 // Hidden forms and query frame interaction stuff
00131 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
00132 
00133     $input_query_history = array();
00134     $sql_history = array();
00135     $dup_sql = array();
00136 
00137     if (isset($query_history_latest) && isset($query_history_latest_db) && $query_history_latest != '' && $query_history_latest_db != '') {
00138         if ($cfg['QueryHistoryDB'] && $cfgRelation['historywork']) {
00139             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);
00140         }
00141 
00142         $input_query_history[] = '<input type="hidden" name="query_history[]" value="' . $query_history_latest . '" />';
00143         $input_query_history[] = '<input type="hidden" name="query_history_db[]" value="' . htmlspecialchars($query_history_latest_db) . '" />';
00144         $input_query_history[] = '<input type="hidden" name="query_history_table[]" value="' . (isset($query_history_latest_table) ? htmlspecialchars($query_history_latest_table) : '') . '" />';
00145 
00146         $sql_history[] = '<li>'
00147                        . '<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>'
00148                        . '&nbsp;<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>'
00149                        . '</li>' . "\n";
00150 
00151         $sql_query = urldecode($query_history_latest);
00152         $db = $query_history_latest_db;
00153         $table = $query_history_latest_table;
00154         $dup_sql[$query_history_latest] = true;
00155     } elseif (isset($query_history_latest) && $query_history_latest != '') {
00156         $sql_query = urldecode($query_history_latest);
00157     }
00158 
00159     if (isset($sql_query)) {
00160         $show_query = 1;
00161     }
00162 
00163     if ($cfg['QueryHistoryDB'] && $cfgRelation['historywork']) {
00164 
00165         $temp_history = PMA_getHistory($cfg['Server']['user']);
00166         if (is_array($temp_history) && count($temp_history) > 0) {
00167             foreach ($temp_history AS $history_nr => $history_array) {
00168                 if (!isset($dup_sql[$history_array['sqlquery']])) {
00169                     $sql_history[] = '<li>'
00170                                    . '<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>'
00171                                    . '<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>'
00172                                    . '</li>' . "\n";
00173                     $dup_sql[$history_array['sqlquery']] = true;
00174                 }
00175             }
00176         }
00177 
00178     } else {
00179 
00180         if (isset($query_history) && is_array($query_history)) {
00181             $current_index = count($query_history);
00182             foreach ($query_history AS $query_no => $query_sql) {
00183                 if (!isset($dup_sql[$query_sql])) {
00184 
00185                     $input_query_history[] = '<input type="hidden" name="query_history[]" value="' . $query_sql . '" />';
00186                     $input_query_history[] = '<input type="hidden" name="query_history_db[]" value="' . htmlspecialchars($query_history_db[$query_no]) . '" />';
00187                     $input_query_history[] = '<input type="hidden" name="query_history_table[]" value="' . (isset($query_history_table[$query_no]) ? htmlspecialchars($query_history_table[$query_no]) : '') . '" />';
00188 
00189                     $sql_history[] = '<li>'
00190                                    . '<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>'
00191                                    . '<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>'
00192                                    . '</li>' . "\n";
00193                     $dup_sql[$query_sql] = true;
00194                 } // end if check if this item exists
00195             } // end while print history
00196         } // end if history exists
00197 
00198     } // end if DB-based history
00199 }
00200 
00201 $url_query = PMA_generate_common_url(isset($db) ? $db : '', isset($table) ? $table : '');
00202 if (!isset($goto)) {
00203     $goto = '';
00204 }
00205 
00206 require_once './libraries/bookmark.lib.php';
00207 $is_inside_querywindow = TRUE;
00208 require './tbl_query_box.php';
00209 
00210 // Hidden forms and query frame interaction stuff
00211 if ($cfg['QueryFrame'] && $cfg['QueryFrameJS']) {
00212     if (isset($auto_commit) && $auto_commit == 'true') {
00213     ?>
00214         <script type="text/javascript" language="javascript">
00215         query_auto_commit();
00216         </script>
00217     <?php
00218     }
00219 
00220     if (isset($sql_history) && isset($querydisplay_tab) && ($querydisplay_tab == 'history' || $querydisplay_tab == 'full') && is_array($sql_history) && count($sql_history) > 0) {
00221     ?>
00222         <?php echo $strQuerySQLHistory . ':<br /><ul>' . implode('', $sql_history) . '</ul>'; ?>
00223     <?php
00224     }
00225 ?>
00226 <form action="querywindow.php" method="post" name="querywindow">
00227 <?php
00228     echo PMA_generate_common_hidden_inputs('', '');
00229     if (count($input_query_history) > 0) {
00230         echo implode("\n", $input_query_history);
00231     }
00232 ?>
00233     <input type="hidden" name="db" value="<?php echo (empty($db) ? '' : htmlspecialchars($db)); ?>" />
00234     <input type="hidden" name="table" value="<?php echo (empty($table) ? '' : htmlspecialchars($table)); ?>" />
00235 
00236     <input type="hidden" name="query_history_latest" value="" />
00237     <input type="hidden" name="query_history_latest_db" value="" />
00238     <input type="hidden" name="query_history_latest_table" value="" />
00239 
00240     <input type="hidden" name="previous_db" value="<?php echo htmlspecialchars($db); ?>" />
00241 
00242     <input type="hidden" name="auto_commit" value="false" />
00243     <input type="hidden" name="querydisplay_tab" value="<?php echo $querydisplay_tab; ?>" />
00244 </form>
00245 
00246 <?php
00247 }
00248 
00249 $tmp_querydisplay_tab =  (isset($querydisplay_tab) ? $querydisplay_tab : $cfg['QueryWindowDefTab']);
00250 if ($tmp_querydisplay_tab == 'sql' || $tmp_querydisplay_tab == $cfg['QueryWindowDefTab']) {
00251 ?>
00252 <script type="text/jscript" language="javascript">
00253 <!--
00254     if (document.getElementById && typeof(document.getElementById('sqlcontainer'))!='undefined') {
00255         var newWidth  = document.getElementById('sqlcontainer').offsetWidth + 40;
00256         var newHeight = document.getElementById('sqlcontainer').offsetHeight + 100;
00257         self.resizeTo(newWidth, newHeight);
00258     }
00259 //-->
00260 </script>
00261 <?php
00262 }
00263 ?>
00264 </body>
00265 </html>
00266 
00267 <?php
00271 if (isset($dbh) && $dbh) {
00272     PMA_DBI_close($dbh);
00273 }
00274 if (isset($userlink) && $userlink) {
00275     PMA_DBI_close($userlink);
00276 }
00277 
00278 
00282 if (isset($cfg['OBGzip']) && $cfg['OBGzip']
00283     && isset($ob_mode) && $ob_mode) {
00284      PMA_outBufferPost($ob_mode);
00285 }
00286 ?>


Généré par Les experts TYPO3 avec  doxygen 1.4.6