Skip to content
Newer
Older
100644 279 lines (249 sloc) 7.95 KB
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
1 <?php
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored Mar 19, 2007
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
4 * this file is register_globals save
5 *
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored Mar 19, 2007
6 * @todo move JavaScript out of here into .js files
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
7 * @uses $cfg['QueryWindowDefTab']
8 * @uses $cfg['PropertiesIconic']
9 * @uses $cfg['QueryHistoryDB']
10 * @uses $cfg['Server']['user']
11 * @uses $cfg['AllowUserDropDatabase']
12 * @uses $cfg['Confirm']
13 * @uses $GLOBALS['db']
14 * @uses $GLOBALS['table']
15 * @uses $GLOBALS['strSQL']
16 * @uses $GLOBALS['strImportFiles']
17 * @uses $GLOBALS['strQuerySQLHistory']
18 * @uses $GLOBALS['strAll']
19 * @uses $GLOBALS['strChange']
20 * @uses $GLOBALS['strFormEmpty']
21 * @uses $GLOBALS['strNotNumber']
22 * @uses $GLOBALS['strNoDropDatabases']
23 * @uses $GLOBALS['strDoYouReally']
24 * @uses $GLOBALS['strQuerySQLHistory']
25 * @uses PMA_isSuperuser()
26 * @uses PMA_outBufferPre()
27 * @uses PMA_getRelationsParam()
28 * @uses PMA_isValid()
29 * @uses PMA_ifSetOr()
30 * @uses PMA_setHistory()
31 * @uses PMA_getHistory()
32 * @uses PMA_generate_common_url()
33 * @uses PMA_generate_common_hidden_inputs()
34 * @uses PMA_escapeJsString()
35 * @uses PMA_getTabs()
36 * @uses PMA_sqlQueryForm()
37 * @uses PMA_jsFormat()
38 * @uses in_array()
39 * @uses strlen()
40 * @uses preg_replace()
41 * @uses htmlspecialchars()
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored Mar 19, 2007
42 * @version $Id$
43 */
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
44
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored Mar 19, 2007
45 /**
46 *
47 */
d0facc3 splitted common.lib.php into common.inc.php, core.lib.php and common.…
Sebastian Mendel authored Mar 20, 2007
48 require_once './libraries/common.inc.php';
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
49
c8eaea4 @lem9 is_superuser not defined
lem9 authored May 30, 2006
50 $is_superuser = PMA_isSuperuser();
51
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
52 /**
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
53 * Gets a core script and starts output buffering work
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
54 */
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
55 require_once './libraries/sql_query_form.lib.php';
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
56
57 /**
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
58 * starts output buffering if requested and supported
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
59 */
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored Mar 19, 2007
60 require_once './libraries/ob.lib.php';
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
61 PMA_outBufferPre();
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
62
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
63 /**
64 * load relations
65 */
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored Mar 19, 2007
66 require_once './libraries/relation.lib.php';
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
67 $cfgRelation = PMA_getRelationsParam();
68
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
69 /**
70 * load bookmark support
71 */
72 require_once './libraries/bookmark.lib.php';
071a068 wrong handling of linebreaks in query: bug #1243888
Sebastian Mendel authored Oct 18, 2005
73
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
74 $querydisplay_tabs = array(
75 'sql',
76 'files',
77 'history',
78 'full',
79 );
8fc4a4c moved styles into css
Sebastian Mendel authored Nov 23, 2005
80
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
81 if (isset($_REQUEST['querydisplay_tab'])
82 && in_array($_REQUEST['querydisplay_tab'], $querydisplay_tabs)) {
83 $querydisplay_tab = $_REQUEST['querydisplay_tab'];
3143135 XHTML 1.0 trans. compliance and more semantic XHTML output
Sebastian Mendel authored Oct 11, 2005
84 } else {
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
85 $querydisplay_tab = $GLOBALS['cfg']['QueryWindowDefTab'];
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
86 }
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
87
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
88 /**
89 * $_REQUEST['no_js'] is set if open new window by JavaScript failed
90 * so this page is loaded in main frame
91 */
92 $no_js = PMA_ifSetOr($_REQUEST['no_js'], false);
37d50c1 @derrabus Huge set of optimizations, please test!
derrabus authored Nov 26, 2003
93
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
94 if ($no_js) {
95 $querydisplay_tab = 'full';
96 $tabs = false;
97 } else {
5de17e7 @lem9 patch #1252031, CSS for navigation tabs
lem9 authored Aug 16, 2005
98 $tabs = array();
99 $tabs['sql']['icon'] = 'b_sql.png';
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
100 $tabs['sql']['text'] = $GLOBALS['strSQL'];
101 $tabs['sql']['fragment'] = '#';
102 $tabs['sql']['attr'] = 'onclick="javascript:PMA_querywindowCommit(\'sql\');return false;"';
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored Mar 19, 2007
103 $tabs['sql']['active'] = (bool) ($querydisplay_tab == 'sql');
5de17e7 @lem9 patch #1252031, CSS for navigation tabs
lem9 authored Aug 16, 2005
104 $tabs['import']['icon'] = 'b_import.png';
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
105 $tabs['import']['text'] = $GLOBALS['strImportFiles'];
106 $tabs['import']['fragment'] = '#';
107 $tabs['import']['attr'] = 'onclick="javascript:PMA_querywindowCommit(\'files\');return false;"';
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored Mar 19, 2007
108 $tabs['import']['active'] = (bool) ($querydisplay_tab == 'files');
0be9c38 @nijel Make drop and empty tabs lead to structure instead of SQL.
nijel authored Oct 12, 2005
109 $tabs['history']['icon'] = 'b_bookmark.png';
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
110 $tabs['history']['text'] = $GLOBALS['strQuerySQLHistory'];
111 $tabs['history']['fragment'] = '#';
112 $tabs['history']['attr'] = 'onclick="javascript:PMA_querywindowCommit(\'history\');return false;"';
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored Mar 19, 2007
113 $tabs['history']['active'] = (bool) ($querydisplay_tab == 'history');
4d878ae See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywi…
Garvin Hicking authored Feb 27, 2003
114
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored Mar 19, 2007
115 if ($GLOBALS['cfg']['QueryWindowDefTab'] == 'full') {
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
116 $tabs['all']['text'] = $GLOBALS['strAll'];
117 $tabs['all']['fragment'] = '#';
118 $tabs['all']['attr'] = 'onclick="javascript:PMA_querywindowCommit(\'full\');return false;"';
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored Mar 19, 2007
119 $tabs['all']['active'] = (bool) ($querydisplay_tab == 'full');
210576b Fixed Bug #723955, 723736, 723713 (Query Frame)
Garvin Hicking authored Apr 20, 2003
120 }
4d878ae See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywi…
Garvin Hicking authored Feb 27, 2003
121 }
122
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
123 if ($GLOBALS['cfg']['PropertiesIconic']) {
8fc4a4c moved styles into css
Sebastian Mendel authored Nov 23, 2005
124 $titles['Change'] =
071a068 wrong handling of linebreaks in query: bug #1243888
Sebastian Mendel authored Oct 18, 2005
125 '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
126 . 'b_edit.png" alt="' . $GLOBALS['strChange'] . '" title="' . $GLOBALS['strChange']
071a068 wrong handling of linebreaks in query: bug #1243888
Sebastian Mendel authored Oct 18, 2005
127 . '" />';
a199e51 @lem9 clarification
lem9 authored Sep 30, 2003
128
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored Mar 19, 2007
129 if ('both' === $GLOBALS['cfg']['PropertiesIconic']) {
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
130 $titles['Change'] .= $GLOBALS['strChange'];
a199e51 @lem9 clarification
lem9 authored Sep 30, 2003
131 }
132 } else {
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
133 $titles['Change'] = $GLOBALS['strChange'];
a199e51 @lem9 clarification
lem9 authored Sep 30, 2003
134 }
135
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
136 $url_query = PMA_generate_common_url($db, $table);
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
137
b2f3ae5 make $sql_query persistent (init it, never unset it, always assume it…
Sebastian Mendel authored Apr 1, 2007
138 if (! empty($sql_query)) {
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
139 $show_query = 1;
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
140 }
141
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
142 if ($no_js) {
b874154 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
Sebastian Mendel authored Sep 27, 2005
143 // ... we redirect to appropriate query sql page
144 // works only full if $db and $table is also stored/grabbed from $_COOKIE
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
145 if (strlen($table)) {
ad06b4a @nijel Rename tbl_* files to drop useless _properties part.
nijel authored Oct 25, 2006
146 require './tbl_sql.php';
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
147 } elseif (strlen($db)) {
cac4247 @nijel Rename db_* files to drop useless _details part.
nijel authored Oct 25, 2006
148 require './db_sql.php';
7358f5a allow 0 as name for database, table collumn, alias and index
Sebastian Mendel authored Jan 14, 2006
149 } else {
7ae4646 @nijel Fix including of files when search path does not contain current dire…
nijel authored Oct 30, 2005
150 require './server_sql.php';
b874154 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
Sebastian Mendel authored Sep 27, 2005
151 }
152 exit;
153 }
154
155 /**
156 * Defines the query to be displayed in the query textarea
157 */
03f2245 bug #1664212 querywindow loses url encoded characters
Sebastian Mendel authored Mar 19, 2007
158 if (! empty($show_query)) {
b874154 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
Sebastian Mendel authored Sep 27, 2005
159 $query_to_display = $sql_query;
160 } else {
161 $query_to_display = '';
162 }
b2f3ae5 make $sql_query persistent (init it, never unset it, always assume it…
Sebastian Mendel authored Apr 1, 2007
163 $sql_query = '';
b874154 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
Sebastian Mendel authored Sep 27, 2005
164
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
165 /**
98c8a77 refactored JavaScript handling
Sebastian Mendel authored Oct 5, 2007
166 * prepare JavaScript functionality
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
167 */
98c8a77 refactored JavaScript handling
Sebastian Mendel authored Oct 5, 2007
168 $js_include[] = 'common.js';
169 $js_include[] = 'functions.js';
170 $js_include[] = 'querywindow.js';
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
171
172 if (PMA_isValid($_REQUEST['auto_commit'], 'identical', 'true')) {
98c8a77 refactored JavaScript handling
Sebastian Mendel authored Oct 5, 2007
173 $js_events[] = array(
174 'object' => 'window',
175 'event' => 'load',
176 'function' => 'PMA_queryAutoCommit',
177 );
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
178 }
179 if (PMA_isValid($_REQUEST['init'])) {
98c8a77 refactored JavaScript handling
Sebastian Mendel authored Oct 5, 2007
180 $js_events[] = array(
181 'object' => 'window',
182 'event' => 'load',
183 'function' => 'PMA_querywindowResize',
184 );
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
185 }
186
98c8a77 refactored JavaScript handling
Sebastian Mendel authored Oct 5, 2007
187 /**
188 * start HTTP/HTML output
189 */
190 require_once './libraries/header_http.inc.php';
191 require_once './libraries/header_meta_style.inc.php';
192 require_once './libraries/header_scripts.inc.php';
193 ?>
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
194 </head>
195
98c8a77 refactored JavaScript handling
Sebastian Mendel authored Oct 5, 2007
196 <body id="bodyquerywindow">
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
197 <div id="querywindowcontainer">
9889178 @lem9 new query window behavior
lem9 authored Nov 16, 2005
198 <?php
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
199
200 if ($tabs) {
201 echo PMA_getTabs($tabs);
202 unset($tabs);
9889178 @lem9 new query window behavior
lem9 authored Nov 16, 2005
203 }
37d50c1 @derrabus Huge set of optimizations, please test!
derrabus authored Nov 26, 2003
204
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
205 PMA_sqlQueryForm($query_to_display, $querydisplay_tab);
206
207 // Hidden forms and query frame interaction stuff
208
209 $_sql_history = PMA_getHistory($GLOBALS['cfg']['Server']['user']);
210 if (! empty($_sql_history)
211 && ($querydisplay_tab == 'history' || $querydisplay_tab == 'full')) {
212 $tab = $querydisplay_tab != 'full' ? 'sql' : 'full';
213 echo $GLOBALS['strQuerySQLHistory'] . ':<br />' . "\n"
9889178 @lem9 new query window behavior
lem9 authored Nov 16, 2005
214 .'<ul>';
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
215 foreach ($_sql_history as $query) {
9889178 @lem9 new query window behavior
lem9 authored Nov 16, 2005
216 echo '<li>' . "\n";
d27b8ef removed unnecessary JavaScript code (due to session based history)
Sebastian Mendel authored Mar 26, 2007
217
9889178 @lem9 new query window behavior
lem9 authored Nov 16, 2005
218 // edit link
d27b8ef removed unnecessary JavaScript code (due to session based history)
Sebastian Mendel authored Mar 26, 2007
219 $url_params = array(
220 'querydisplay_tab' => $tab,
221 'sql_query' => $query['sqlquery'],
222 'db' => $query['db'],
223 'table' => $query['table'],
224 );
225 echo '<a href="querywindow.php' . PMA_generate_common_url($url_params)
226 . '">' . $titles['Change'] . '</a>';
227
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
228 // execute link
d27b8ef removed unnecessary JavaScript code (due to session based history)
Sebastian Mendel authored Mar 26, 2007
229 $url_params['auto_commit'] = 'true';
230 echo '<a href="import.php' . PMA_generate_common_url($url_params) . '"'
231 . ' target="frame_content">';
232
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
233 if (! empty($query['db'])) {
234 echo '[';
235 echo htmlspecialchars(PMA_backquote($query['db']));
236 if (! empty($query['table'])) {
237 echo '.' . htmlspecialchars(PMA_backquote($query['table']));
238 }
239 echo '] ';
240 }
241 if (strlen($query['sqlquery']) > 120) {
242 echo '<span title="' . htmlspecialchars($query['sqlquery']) . '">';
243 echo htmlspecialchars(substr($query['sqlquery'], 0, 50)) . ' [...] ';
244 echo htmlspecialchars(substr($query['sqlquery'], -50));
245 echo '</span>';
246 } else {
247 echo htmlspecialchars($query['sqlquery']);
248 }
249 echo '</a>' . "\n";
9889178 @lem9 new query window behavior
lem9 authored Nov 16, 2005
250 echo '</li>' . "\n";
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
251 }
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
252 unset($tab, $_sql_history, $query);
9889178 @lem9 new query window behavior
lem9 authored Nov 16, 2005
253 echo '</ul>' . "\n";
254 }
255 ?>
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
256 <form action="querywindow.php" method="post" name="hiddenqueryform"
257 id="hiddenqueryform">
258 <?php echo PMA_generate_common_hidden_inputs('', ''); ?>
259 <input type="hidden" name="db" value="<?php echo htmlspecialchars($db); ?>" />
260 <input type="hidden" name="table" value="<?php echo htmlspecialchars($table); ?>" />
d27b8ef removed unnecessary JavaScript code (due to session based history)
Sebastian Mendel authored Mar 26, 2007
261 <input type="hidden" name="sql_query" value="" />
4d878ae See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywi…
Garvin Hicking authored Feb 27, 2003
262 <input type="hidden" name="querydisplay_tab" value="<?php echo $querydisplay_tab; ?>" />
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
263 </form>
64bd56d @nijel Support for browsing selected columns (RFE #1275909).
nijel authored Sep 26, 2005
264 </div>
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
265 </body>
266 </html>
267
268 <?php
269 /**
270 * Close MySql connections
271 */
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
272 if (! empty($controllink)) {
3885bb6 @lem9 dbh becomes controllink
lem9 authored Nov 20, 2005
273 PMA_DBI_close($controllink);
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
274 }
e8f3519 documentation;
Sebastian Mendel authored Mar 22, 2007
275 if (! empty($userlink)) {
0af2b97 @lem9 typo
lem9 authored Jan 24, 2004
276 PMA_DBI_close($userlink);
dd6345c Display a (javascript) based query window as a new frame below the left
Garvin Hicking authored Feb 24, 2003
277 }
37d50c1 @derrabus Huge set of optimizations, please test!
derrabus authored Nov 26, 2003
278 ?>
Something went wrong with that request. Please try again.