Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 224 lines (198 sloc) 6.531 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
e56949f1 » nijel
2011-10-25 Use package name PhpMyAdmin
7 * @package PhpMyAdmin
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
8 */
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
9
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
10 /**
11 *
12 */
b2fd866d » Jo Michael
2012-03-16 Leading ./ paths for includes can be omitted, part 2
13 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
14
c8eaea4e » lem9
2006-05-30 is_superuser not defined
15 $is_superuser = PMA_isSuperuser();
16
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
17 /**
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
18 * 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
19 */
b2fd866d » Jo Michael
2012-03-16 Leading ./ paths for includes can be omitted, part 2
20 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
21
22 /**
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
23 * 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
24 */
b2fd866d » Jo Michael
2012-03-16 Leading ./ paths for includes can be omitted, part 2
25 require_once 'libraries/ob.lib.php';
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
26 PMA_outBufferPre();
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
27
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
28 /**
ee767e2d » nijel
2010-07-26 No need to explicitely include relation.lib its anyway included in co…
29 * load relation params
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
30 */
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
31 $cfgRelation = PMA_getRelationsParam();
32
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
33 /**
34 * load bookmark support
35 */
b2fd866d » Jo Michael
2012-03-16 Leading ./ paths for includes can be omitted, part 2
36 require_once 'libraries/bookmark.lib.php';
071a0684 » Sebastian Mendel
2005-10-18 wrong handling of linebreaks in query: bug #1243888
37
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
38 $querydisplay_tabs = array(
39 'sql',
40 'files',
41 'history',
42 'full',
43 );
8fc4a4ce » Sebastian Mendel
2005-11-23 moved styles into css
44
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
45 if (isset($_REQUEST['querydisplay_tab'])
46 && in_array($_REQUEST['querydisplay_tab'], $querydisplay_tabs)) {
47 $querydisplay_tab = $_REQUEST['querydisplay_tab'];
3143135a » Sebastian Mendel
2005-10-11 XHTML 1.0 trans. compliance and more semantic XHTML output
48 } else {
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
49 $querydisplay_tab = $GLOBALS['cfg']['QueryWindowDefTab'];
64bd56df » nijel
2005-09-26 Support for browsing selected columns (RFE #1275909).
50 }
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 /**
53 * $_REQUEST['no_js'] is set if open new window by JavaScript failed
54 * so this page is loaded in main frame
55 */
56 $no_js = PMA_ifSetOr($_REQUEST['no_js'], false);
37d50c18 » derrabus
2003-11-26 Huge set of optimizations, please test!
57
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
58 if ($no_js) {
59 $querydisplay_tab = 'full';
60 $tabs = false;
61 } else {
5de17e7c » lem9
2005-08-16 patch #1252031, CSS for navigation tabs
62 $tabs = array();
d17814f4 » roccivic
2011-09-26 Replaced use of hard coded images with the sprite-aware PMA_getImage(…
63 $tabs['sql']['icon'] = 'b_sql.png';
f8f47541 » lem9
2010-05-06 gettext conversion
64 $tabs['sql']['text'] = __('SQL');
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
65 $tabs['sql']['fragment'] = '#';
29a41fc9 » Crack
2011-09-25 "javascript:" is not needed here
66 $tabs['sql']['attr'] = 'onclick="PMA_querywindowCommit(\'sql\');return false;"';
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
67 $tabs['sql']['active'] = (bool) ($querydisplay_tab == 'sql');
d17814f4 » roccivic
2011-09-26 Replaced use of hard coded images with the sprite-aware PMA_getImage(…
68 $tabs['import']['icon'] = 'b_import.png';
f8f47541 » lem9
2010-05-06 gettext conversion
69 $tabs['import']['text'] = __('Import files');
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
70 $tabs['import']['fragment'] = '#';
29a41fc9 » Crack
2011-09-25 "javascript:" is not needed here
71 $tabs['import']['attr'] = 'onclick="PMA_querywindowCommit(\'files\');return false;"';
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
72 $tabs['import']['active'] = (bool) ($querydisplay_tab == 'files');
d17814f4 » roccivic
2011-09-26 Replaced use of hard coded images with the sprite-aware PMA_getImage(…
73 $tabs['history']['icon'] = 'b_bookmark.png';
e42539a8 » madhuracj
2011-09-21 Use PMA_getIcon()
74 $tabs['history']['text'] = __('SQL history');
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
75 $tabs['history']['fragment'] = '#';
29a41fc9 » Crack
2011-09-25 "javascript:" is not needed here
76 $tabs['history']['attr'] = 'onclick="PMA_querywindowCommit(\'history\');return false;"';
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
77 $tabs['history']['active'] = (bool) ($querydisplay_tab == 'history');
4d878ae9 » Garvin Hicking
2003-02-27 See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywi…
78
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
79 if ($GLOBALS['cfg']['QueryWindowDefTab'] == 'full') {
f8f47541 » lem9
2010-05-06 gettext conversion
80 $tabs['all']['text'] = __('All');
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
81 $tabs['all']['fragment'] = '#';
29a41fc9 » Crack
2011-09-25 "javascript:" is not needed here
82 $tabs['all']['attr'] = 'onclick="PMA_querywindowCommit(\'full\');return false;"';
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
83 $tabs['all']['active'] = (bool) ($querydisplay_tab == 'full');
210576b0 » Garvin Hicking
2003-04-20 Fixed Bug #723955, 723736, 723713 (Query Frame)
84 }
4d878ae9 » Garvin Hicking
2003-02-27 See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywi…
85 }
86
e42539a8 » madhuracj
2011-09-21 Use PMA_getIcon()
87 $titles['Change'] = PMA_getIcon('b_edit.png', __('Change'));
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
88 $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
89
b2f3ae5f » Sebastian Mendel
2007-04-01 make $sql_query persistent (init it, never unset it, always assume it…
90 if (! empty($sql_query)) {
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
91 $show_query = 1;
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
92 }
93
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
94 if ($no_js) {
b8741540 » Sebastian Mendel
2005-09-27 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
95 // ... we redirect to appropriate query sql page
96 // works only full if $db and $table is also stored/grabbed from $_COOKIE
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
97 if (strlen($table)) {
b2fd866d » Jo Michael
2012-03-16 Leading ./ paths for includes can be omitted, part 2
98 include 'tbl_sql.php';
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
99 } elseif (strlen($db)) {
b2fd866d » Jo Michael
2012-03-16 Leading ./ paths for includes can be omitted, part 2
100 include 'db_sql.php';
7358f5a7 » Sebastian Mendel
2006-01-14 allow 0 as name for database, table collumn, alias and index
101 } else {
b2fd866d » Jo Michael
2012-03-16 Leading ./ paths for includes can be omitted, part 2
102 include 'server_sql.php';
b8741540 » Sebastian Mendel
2005-09-27 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
103 }
104 exit;
105 }
106
107 /**
108 * Defines the query to be displayed in the query textarea
109 */
03f22453 » Sebastian Mendel
2007-03-19 bug #1664212 querywindow loses url encoded characters
110 if (! empty($show_query)) {
b8741540 » Sebastian Mendel
2005-09-27 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
111 $query_to_display = $sql_query;
112 } else {
113 $query_to_display = '';
114 }
b2f3ae5f » Sebastian Mendel
2007-04-01 make $sql_query persistent (init it, never unset it, always assume it…
115 $sql_query = '';
b8741540 » Sebastian Mendel
2005-09-27 moved all code for queryboxes into libraries/sql_query_form.lib.php, …
116
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
117 /**
98c8a771 » Sebastian Mendel
2007-10-05 refactored JavaScript handling
118 * prepare JavaScript functionality
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
119 */
98c8a771 » Sebastian Mendel
2007-10-05 refactored JavaScript handling
120 $js_include[] = 'common.js';
121 $js_include[] = 'querywindow.js';
a3b79051 » Eric Krona
2012-02-09 Patch #3480999 Activate codemirror in the query window
122 $js_include[] = 'codemirror/lib/codemirror.js';
123 $js_include[] = 'codemirror/mode/mysql/mysql.js';
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
124
125 if (PMA_isValid($_REQUEST['auto_commit'], 'identical', 'true')) {
98c8a771 » Sebastian Mendel
2007-10-05 refactored JavaScript handling
126 $js_events[] = array(
127 'event' => 'load',
128 'function' => 'PMA_queryAutoCommit',
129 );
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
130 }
131 if (PMA_isValid($_REQUEST['init'])) {
98c8a771 » Sebastian Mendel
2007-10-05 refactored JavaScript handling
132 $js_events[] = array(
133 'event' => 'load',
134 'function' => 'PMA_querywindowResize',
135 );
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
136 }
ad8dc8e1 » lem9
2007-10-20 bug #1805102, TextareaAutoSelect issues
137 // always set focus to the textarea
7bb8eddf » lem9
2007-11-26 patch #1837691 [query window] js errors, thanks to Victor Volkov
138 if ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full') {
139 $js_events[] = array(
140 'event' => 'load',
141 'function' => 'PMA_querywindowSetFocus',
142 );
143 }
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
144
98c8a771 » Sebastian Mendel
2007-10-05 refactored JavaScript handling
145 /**
146 * start HTTP/HTML output
147 */
b2fd866d » Jo Michael
2012-03-16 Leading ./ paths for includes can be omitted, part 2
148 require_once 'libraries/header_http.inc.php';
149 require_once 'libraries/header_meta_style.inc.php';
150 require_once 'libraries/header_scripts.inc.php';
98c8a771 » Sebastian Mendel
2007-10-05 refactored JavaScript handling
151 ?>
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
152 </head>
153
98c8a771 » Sebastian Mendel
2007-10-05 refactored JavaScript handling
154 <body id="bodyquerywindow">
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
155 <div id="querywindowcontainer">
9889178b » lem9
2005-11-16 new query window behavior
156 <?php
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
157
158 if ($tabs) {
8480ffb6 » lem9
2009-06-07 improve function names
159 echo PMA_generate_html_tabs($tabs, array());
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
160 unset($tabs);
9889178b » lem9
2005-11-16 new query window behavior
161 }
37d50c18 » derrabus
2003-11-26 Huge set of optimizations, please test!
162
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
163 PMA_sqlQueryForm($query_to_display, $querydisplay_tab);
164
165 // Hidden forms and query frame interaction stuff
166
167 $_sql_history = PMA_getHistory($GLOBALS['cfg']['Server']['user']);
168 if (! empty($_sql_history)
169 && ($querydisplay_tab == 'history' || $querydisplay_tab == 'full')) {
170 $tab = $querydisplay_tab != 'full' ? 'sql' : 'full';
f8f47541 » lem9
2010-05-06 gettext conversion
171 echo __('SQL history') . ':<br />'
172 . '<ul>';
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
173 foreach ($_sql_history as $query) {
9889178b » lem9
2005-11-16 new query window behavior
174 echo '<li>' . "\n";
d27b8efa » Sebastian Mendel
2007-03-26 removed unnecessary JavaScript code (due to session based history)
175
9889178b » lem9
2005-11-16 new query window behavior
176 // edit link
d27b8efa » Sebastian Mendel
2007-03-26 removed unnecessary JavaScript code (due to session based history)
177 $url_params = array(
178 'querydisplay_tab' => $tab,
179 'sql_query' => $query['sqlquery'],
180 'db' => $query['db'],
181 'table' => $query['table'],
182 );
183 echo '<a href="querywindow.php' . PMA_generate_common_url($url_params)
184 . '">' . $titles['Change'] . '</a>';
185
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
186 // execute link
d27b8efa » Sebastian Mendel
2007-03-26 removed unnecessary JavaScript code (due to session based history)
187 $url_params['auto_commit'] = 'true';
188 echo '<a href="import.php' . PMA_generate_common_url($url_params) . '"'
189 . ' target="frame_content">';
190
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
191 if (! empty($query['db'])) {
192 echo '[';
193 echo htmlspecialchars(PMA_backquote($query['db']));
194 if (! empty($query['table'])) {
195 echo '.' . htmlspecialchars(PMA_backquote($query['table']));
196 }
197 echo '] ';
198 }
199 if (strlen($query['sqlquery']) > 120) {
200 echo '<span title="' . htmlspecialchars($query['sqlquery']) . '">';
201 echo htmlspecialchars(substr($query['sqlquery'], 0, 50)) . ' [...] ';
202 echo htmlspecialchars(substr($query['sqlquery'], -50));
203 echo '</span>';
204 } else {
205 echo htmlspecialchars($query['sqlquery']);
206 }
207 echo '</a>' . "\n";
9889178b » lem9
2005-11-16 new query window behavior
208 echo '</li>' . "\n";
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
209 }
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
210 unset($tab, $_sql_history, $query);
9889178b » lem9
2005-11-16 new query window behavior
211 echo '</ul>' . "\n";
212 }
213 ?>
e8f3519a » Sebastian Mendel
2007-03-22 documentation;
214 <form action="querywindow.php" method="post" name="hiddenqueryform"
215 id="hiddenqueryform">
216 <?php echo PMA_generate_common_hidden_inputs('', ''); ?>
217 <input type="hidden" name="db" value="<?php echo htmlspecialchars($db); ?>" />
218 <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)
219 <input type="hidden" name="sql_query" value="" />
4d878ae9 » Garvin Hicking
2003-02-27 See Changelog: Lightweight tabs, DB-based SQL history, tabbed querywi…
220 <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
221 </form>
64bd56df » nijel
2005-09-26 Support for browsing selected columns (RFE #1275909).
222 </div>
dd6345c9 » Garvin Hicking
2003-02-24 Display a (javascript) based query window as a new frame below the left
223 </body>
224 </html>
Something went wrong with that request. Please try again.