Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 258 lines (230 sloc) 7.563 kb
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
1 <?php
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
f8f47541 » lem9
2010-05-06 gettext conversion
4 * this file is register_globals safe
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
5 *
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
6 * @todo move JavaScript out of here into .js files
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
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 PMA_isSuperuser()
16 * @uses PMA_outBufferPre()
17 * @uses PMA_getRelationsParam()
18 * @uses PMA_isValid()
19 * @uses PMA_ifSetOr()
20 * @uses PMA_getHistory()
21 * @uses PMA_generate_common_url()
22 * @uses PMA_generate_common_hidden_inputs()
23 * @uses PMA_escapeJsString()
8480ffb6 » lem9
2009-06-07 improve function names
24 * @uses PMA_generate_html_tabs()
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
25 * @uses PMA_sqlQueryForm()
26 * @uses PMA_jsFormat()
27 * @uses in_array()
28 * @uses strlen()
29 * @uses preg_replace()
30 * @uses htmlspecialchars()
56941e50 » nijel
2008-11-24 Adding @package, second part.
31 * @package phpMyAdmin
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
32 */
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
33
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
34 /**
35 *
36 */
d0facc3d » Sebastian Mendel
2007-03-20 splitted common.lib.php into common.inc.php, core.lib.php and common.…
37 require_once './libraries/common.inc.php';
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
38
c8eaea4e » lem9
2006-05-30 is_superuser not defined
39 $is_superuser = PMA_isSuperuser();
40
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
41 /**
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
42 * Gets a core script and starts output buffering work
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
43 */
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
44 require_once './libraries/sql_query_form.lib.php';
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
45
46 /**
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
47 * starts output buffering if requested and supported
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
48 */
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
49 require_once './libraries/ob.lib.php';
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
50 PMA_outBufferPre();
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
51
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
52 /**
ee767e2d » nijel
2010-07-26 No need to explicitely include relation.lib its anyway included in co…
53 * load relation params
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
54 */
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
55 $cfgRelation = PMA_getRelationsParam();
56
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
57 /**
58 * load bookmark support
59 */
60 require_once './libraries/bookmark.lib.php';
071a0684 » Sebastian Mendel
2005-10-18 wrong handling of linebreaks in query: bug #1243888
61
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
62 $querydisplay_tabs = array(
63 'sql',
64 'files',
65 'history',
66 'full',
67 );
8fc4a4ce » Sebastian Mendel
2005-11-23 moved styles into css
68
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
69 if (isset($_REQUEST['querydisplay_tab'])
70 && in_array($_REQUEST['querydisplay_tab'], $querydisplay_tabs)) {
71 $querydisplay_tab = $_REQUEST['querydisplay_tab'];
3143135a » Sebastian Mendel
2005-10-11 XHTML 1.0 trans. compliance and more semantic XHTML output
72 } else {
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
73 $querydisplay_tab = $GLOBALS['cfg']['QueryWindowDefTab'];
64bd56df » nijel
2005-09-26 Support for browsing selected columns (RFE #1275909).
74 }
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
75
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
76 /**
77 * $_REQUEST['no_js'] is set if open new window by JavaScript failed
78 * so this page is loaded in main frame
79 */
80 $no_js = PMA_ifSetOr($_REQUEST['no_js'], false);
37d50c18 » derrabus
2003-11-26 Huge set of optimizations, please test!
81
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
82 if ($no_js) {
83 $querydisplay_tab = 'full';
84 $tabs = false;
85 } else {
5de17e7c » lem9
2005-08-16 patch #1252031, CSS for navigation tabs
86 $tabs = array();
87 $tabs['sql']['icon'] = 'b_sql.png';
f8f47541 » lem9
2010-05-06 gettext conversion
88 $tabs['sql']['text'] = __('SQL');
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
89 $tabs['sql']['fragment'] = '#';
29a41fc9 » Crack
2011-09-25 "javascript:" is not needed here
90 $tabs['sql']['attr'] = 'onclick="PMA_querywindowCommit(\'sql\');return false;"';
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
91 $tabs['sql']['active'] = (bool) ($querydisplay_tab == 'sql');
5de17e7c » lem9
2005-08-16 patch #1252031, CSS for navigation tabs
92 $tabs['import']['icon'] = 'b_import.png';
f8f47541 » lem9
2010-05-06 gettext conversion
93 $tabs['import']['text'] = __('Import files');
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
94 $tabs['import']['fragment'] = '#';
29a41fc9 » Crack
2011-09-25 "javascript:" is not needed here
95 $tabs['import']['attr'] = 'onclick="PMA_querywindowCommit(\'files\');return false;"';
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
96 $tabs['import']['active'] = (bool) ($querydisplay_tab == 'files');
0be9c380 » nijel
2005-10-12 Make drop and empty tabs lead to structure instead of SQL.
97 $tabs['history']['icon'] = 'b_bookmark.png';
f8f47541 » lem9
2010-05-06 gettext conversion
98 $tabs['history']['text'] = __('SQL history');
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
99 $tabs['history']['fragment'] = '#';
29a41fc9 » Crack
2011-09-25 "javascript:" is not needed here
100 $tabs['history']['attr'] = 'onclick="PMA_querywindowCommit(\'history\');return false;"';
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
101 $tabs['history']['active'] = (bool) ($querydisplay_tab == 'history');
4d878ae9 » Garvin Hicking
2003-02-27 See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywi…
102
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
103 if ($GLOBALS['cfg']['QueryWindowDefTab'] == 'full') {
f8f47541 » lem9
2010-05-06 gettext conversion
104 $tabs['all']['text'] = __('All');
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
105 $tabs['all']['fragment'] = '#';
29a41fc9 » Crack
2011-09-25 "javascript:" is not needed here
106 $tabs['all']['attr'] = 'onclick="PMA_querywindowCommit(\'full\');return false;"';
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
107 $tabs['all']['active'] = (bool) ($querydisplay_tab == 'full');
210576b0 » Garvin Hicking
2003-04-20 Fixed Bug #723955, 723736, 723713 (Query Frame)
108 }
4d878ae9 » Garvin Hicking
2003-02-27 See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywi…
109 }
110
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
111 if ($GLOBALS['cfg']['PropertiesIconic']) {
8fc4a4ce » Sebastian Mendel
2005-11-23 moved styles into css
112 $titles['Change'] =
071a0684 » Sebastian Mendel
2005-10-18 wrong handling of linebreaks in query: bug #1243888
113 '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
f8f47541 » lem9
2010-05-06 gettext conversion
114 . 'b_edit.png" alt="' . __('Change') . '" title="' . __('Change')
071a0684 » Sebastian Mendel
2005-10-18 wrong handling of linebreaks in query: bug #1243888
115 . '" />';
a199e510 » lem9
2003-09-30 clarification
116
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
117 if ('both' === $GLOBALS['cfg']['PropertiesIconic']) {
3e3f5f64 » lem9
2011-02-16 Link is too near the rest of the text
118 $titles['Change'] .= __('Change') . ' ';
a199e510 » lem9
2003-09-30 clarification
119 }
120 } else {
3e3f5f64 » lem9
2011-02-16 Link is too near the rest of the text
121 $titles['Change'] = __('Change') . ' ';
a199e510 » lem9
2003-09-30 clarification
122 }
123
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
124 $url_query = PMA_generate_common_url($db, $table);
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
125
b2f3ae5f » Sebastian Mendel
2007-04-01 make $sql_query persistent (init it, never unset it, always assume it…
126 if (! empty($sql_query)) {
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
127 $show_query = 1;
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
128 }
129
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
130 if ($no_js) {
b8741540 » Sebastian Mendel
2005-09-27 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
131 // ... we redirect to appropriate query sql page
132 // works only full if $db and $table is also stored/grabbed from $_COOKIE
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
133 if (strlen($table)) {
ad06b4a9 » nijel
2006-10-25 Rename tbl_* files to drop useless _properties part.
134 require './tbl_sql.php';
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
135 } elseif (strlen($db)) {
cac42470 » nijel
2006-10-25 Rename db_* files to drop useless _details part.
136 require './db_sql.php';
7358f5a7 » Sebastian Mendel
2006-01-14 allow 0 as name for database, table collumn, alias and index
137 } else {
7ae4646d » nijel
2005-10-30 Fix including of files when search path does not contain current dire…
138 require './server_sql.php';
b8741540 » Sebastian Mendel
2005-09-27 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
139 }
140 exit;
141 }
142
143 /**
144 * Defines the query to be displayed in the query textarea
145 */
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
146 if (! empty($show_query)) {
b8741540 » Sebastian Mendel
2005-09-27 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
147 $query_to_display = $sql_query;
148 } else {
149 $query_to_display = '';
150 }
b2f3ae5f » Sebastian Mendel
2007-04-01 make $sql_query persistent (init it, never unset it, always assume it…
151 $sql_query = '';
b8741540 » Sebastian Mendel
2005-09-27 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
152
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
153 /**
98c8a771 » Sebastian Mendel
2007-10-05 refactored JavaScript handling
154 * prepare JavaScript functionality
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
155 */
98c8a771 » Sebastian Mendel
2007-10-05 refactored JavaScript handling
156 $js_include[] = 'common.js';
157 $js_include[] = 'querywindow.js';
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
158
159 if (PMA_isValid($_REQUEST['auto_commit'], 'identical', 'true')) {
98c8a771 » Sebastian Mendel
2007-10-05 refactored JavaScript handling
160 $js_events[] = array(
161 'event' => 'load',
162 'function' => 'PMA_queryAutoCommit',
163 );
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
164 }
165 if (PMA_isValid($_REQUEST['init'])) {
98c8a771 » Sebastian Mendel
2007-10-05 refactored JavaScript handling
166 $js_events[] = array(
167 'event' => 'load',
168 'function' => 'PMA_querywindowResize',
169 );
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
170 }
ad8dc8e1 » lem9
2007-10-20 bug #1805102, TextareaAutoSelect issues
171 // always set focus to the textarea
7bb8eddf » lem9
2007-11-26 patch #1837691 [query window] js errors, thanks to Victor Volkov
172 if ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full') {
173 $js_events[] = array(
174 'event' => 'load',
175 'function' => 'PMA_querywindowSetFocus',
176 );
177 }
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
178
98c8a771 » Sebastian Mendel
2007-10-05 refactored JavaScript handling
179 /**
180 * start HTTP/HTML output
181 */
182 require_once './libraries/header_http.inc.php';
183 require_once './libraries/header_meta_style.inc.php';
184 require_once './libraries/header_scripts.inc.php';
185 ?>
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
186 </head>
187
98c8a771 » Sebastian Mendel
2007-10-05 refactored JavaScript handling
188 <body id="bodyquerywindow">
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
189 <div id="querywindowcontainer">
9889178b » lem9
2005-11-16 new query window behavior
190 <?php
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
191
192 if ($tabs) {
8480ffb6 » lem9
2009-06-07 improve function names
193 echo PMA_generate_html_tabs($tabs, array());
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
194 unset($tabs);
9889178b » lem9
2005-11-16 new query window behavior
195 }
37d50c18 » derrabus
2003-11-26 Huge set of optimizations, please test!
196
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
197 PMA_sqlQueryForm($query_to_display, $querydisplay_tab);
198
199 // Hidden forms and query frame interaction stuff
200
201 $_sql_history = PMA_getHistory($GLOBALS['cfg']['Server']['user']);
202 if (! empty($_sql_history)
203 && ($querydisplay_tab == 'history' || $querydisplay_tab == 'full')) {
204 $tab = $querydisplay_tab != 'full' ? 'sql' : 'full';
f8f47541 » lem9
2010-05-06 gettext conversion
205 echo __('SQL history') . ':<br />'
206 . '<ul>';
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
207 foreach ($_sql_history as $query) {
9889178b » lem9
2005-11-16 new query window behavior
208 echo '<li>' . "\n";
d27b8efa » Sebastian Mendel
2007-03-26 removed unnecessary JavaScript code (due to session based history)
209
9889178b » lem9
2005-11-16 new query window behavior
210 // edit link
d27b8efa » Sebastian Mendel
2007-03-26 removed unnecessary JavaScript code (due to session based history)
211 $url_params = array(
212 'querydisplay_tab' => $tab,
213 'sql_query' => $query['sqlquery'],
214 'db' => $query['db'],
215 'table' => $query['table'],
216 );
217 echo '<a href="querywindow.php' . PMA_generate_common_url($url_params)
218 . '">' . $titles['Change'] . '</a>';
219
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
220 // execute link
d27b8efa » Sebastian Mendel
2007-03-26 removed unnecessary JavaScript code (due to session based history)
221 $url_params['auto_commit'] = 'true';
222 echo '<a href="import.php' . PMA_generate_common_url($url_params) . '"'
223 . ' target="frame_content">';
224
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
225 if (! empty($query['db'])) {
226 echo '[';
227 echo htmlspecialchars(PMA_backquote($query['db']));
228 if (! empty($query['table'])) {
229 echo '.' . htmlspecialchars(PMA_backquote($query['table']));
230 }
231 echo '] ';
232 }
233 if (strlen($query['sqlquery']) > 120) {
234 echo '<span title="' . htmlspecialchars($query['sqlquery']) . '">';
235 echo htmlspecialchars(substr($query['sqlquery'], 0, 50)) . ' [...] ';
236 echo htmlspecialchars(substr($query['sqlquery'], -50));
237 echo '</span>';
238 } else {
239 echo htmlspecialchars($query['sqlquery']);
240 }
241 echo '</a>' . "\n";
9889178b » lem9
2005-11-16 new query window behavior
242 echo '</li>' . "\n";
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
243 }
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
244 unset($tab, $_sql_history, $query);
9889178b » lem9
2005-11-16 new query window behavior
245 echo '</ul>' . "\n";
246 }
247 ?>
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
248 <form action="querywindow.php" method="post" name="hiddenqueryform"
249 id="hiddenqueryform">
250 <?php echo PMA_generate_common_hidden_inputs('', ''); ?>
251 <input type="hidden" name="db" value="<?php echo htmlspecialchars($db); ?>" />
252 <input type="hidden" name="table" value="<?php echo htmlspecialchars($table); ?>" />
d27b8efa » Sebastian Mendel
2007-03-26 removed unnecessary JavaScript code (due to session based history)
253 <input type="hidden" name="sql_query" value="" />
4d878ae9 » Garvin Hicking
2003-02-27 See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywi…
254 <input type="hidden" name="querydisplay_tab" value="<?php echo $querydisplay_tab; ?>" />
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
255 </form>
64bd56df » nijel
2005-09-26 Support for browsing selected columns (RFE #1275909).
256 </div>
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
257 </body>
258 </html>
Something went wrong with that request. Please try again.