1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* PHPPgAdmin v6.0.0-beta.47 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace PHPPgAdmin\Controller; |
8
|
|
|
|
9
|
|
|
use PHPPgAdmin\Decorators\Decorator; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Base controller class. |
13
|
|
|
* |
14
|
|
|
* @package PHPPgAdmin |
15
|
|
|
*/ |
16
|
|
|
class DatabaseController extends BaseController |
17
|
|
|
{ |
18
|
|
|
use \PHPPgAdmin\Traits\AdminTrait; |
19
|
|
|
use \PHPPgAdmin\Traits\ExportTrait; |
20
|
|
|
public $table_place = 'database-variables'; |
21
|
|
|
public $fields; |
22
|
|
|
public $controller_title = 'strdatabase'; |
23
|
|
|
|
24
|
|
|
private function _highlight($string, $term) |
25
|
|
|
{ |
26
|
|
|
return str_replace($term, "<b>{$term}</b>", $string); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Default method to render the controller according to the action parameter. |
31
|
|
|
*/ |
32
|
|
|
public function render() |
33
|
|
|
{ |
34
|
|
|
if ('tree' == $this->action) { |
35
|
|
|
return $this->doTree(); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
if ('refresh_locks' == $this->action) { |
39
|
|
|
return $this->currentLocks(true); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
if ('refresh_processes' == $this->action) { |
43
|
|
|
return $this->currentProcesses(true); |
44
|
|
|
} |
45
|
|
|
$scripts = ''; |
46
|
|
|
// normal flow |
47
|
|
|
if ('locks' == $this->action || 'processes' == $this->action) { |
48
|
|
|
$scripts .= '<script src="' . \SUBFOLDER . '/assets/js/database.js" type="text/javascript"></script>'; |
49
|
|
|
|
50
|
|
|
$refreshTime = $this->conf['ajax_refresh'] * 1500; |
51
|
|
|
|
52
|
|
|
$scripts .= "<script type=\"text/javascript\">\n"; |
53
|
|
|
$scripts .= "var Database = {\n"; |
54
|
|
|
$scripts .= "ajax_time_refresh: {$refreshTime},\n"; |
55
|
|
|
$scripts .= "str_start: {text:'{$this->lang['strstart']}',icon: '" . $this->misc->icon('Execute') . "'},\n"; |
56
|
|
|
$scripts .= "str_stop: {text:'{$this->lang['strstop']}',icon: '" . $this->misc->icon('Stop') . "'},\n"; |
57
|
|
|
$scripts .= "load_icon: '" . $this->misc->icon('Loading') . "',\n"; |
58
|
|
|
$scripts .= "server:'{$_REQUEST['server']}',\n"; |
59
|
|
|
$scripts .= "dbname:'{$_REQUEST['database']}',\n"; |
60
|
|
|
$scripts .= "action:'refresh_{$this->action}',\n"; |
61
|
|
|
$scripts .= "errmsg: '" . str_replace("'", "\\'", $this->lang['strconnectionfail']) . "'\n"; |
62
|
|
|
$scripts .= "};\n"; |
63
|
|
|
$scripts .= "</script>\n"; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
$header_template = 'header.twig'; |
67
|
|
|
$footer_template = 'footer.twig'; |
68
|
|
|
// @todo convert all these methods to return text instead of print text |
69
|
|
|
ob_start(); |
70
|
|
|
switch ($this->action) { |
71
|
|
|
case 'find': |
72
|
|
|
if (isset($_REQUEST['term'])) { |
73
|
|
|
$this->printFindForm(false); |
74
|
|
|
} else { |
75
|
|
|
$this->printFindForm(true); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
break; |
79
|
|
|
case 'sql': |
80
|
|
|
$this->doSQL(); |
81
|
|
|
$header_template = 'header_sqledit.twig'; |
82
|
|
|
$footer_template = 'footer_sqledit.twig'; |
83
|
|
|
|
84
|
|
|
break; |
85
|
|
|
case 'variables': |
86
|
|
|
$this->doVariables(); |
87
|
|
|
|
88
|
|
|
break; |
89
|
|
|
case 'processes': |
90
|
|
|
$this->doProcesses(); |
91
|
|
|
|
92
|
|
|
break; |
93
|
|
|
case 'locks': |
94
|
|
|
$this->doLocks(); |
95
|
|
|
|
96
|
|
|
break; |
97
|
|
|
case 'export': |
98
|
|
|
$this->doExport(); |
99
|
|
|
|
100
|
|
|
break; |
101
|
|
|
case 'signal': |
102
|
|
|
$this->doSignal(); |
103
|
|
|
|
104
|
|
|
break; |
105
|
|
|
default: |
106
|
|
|
if (false === $this->adminActions($this->action, 'database')) { |
107
|
|
|
$header_template = 'header_sqledit.twig'; |
108
|
|
|
$footer_template = 'footer_sqledit.twig'; |
109
|
|
|
$this->doSQL(); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
break; |
113
|
|
|
} |
114
|
|
|
$output = ob_get_clean(); |
115
|
|
|
|
116
|
|
|
$this->printHeader($this->headerTitle(), $scripts, true, $header_template); |
117
|
|
|
$this->printBody(); |
118
|
|
|
|
119
|
|
|
echo $output; |
120
|
|
|
|
121
|
|
|
$this->printFooter(true, $footer_template); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function doTree($print = true) |
125
|
|
|
{ |
126
|
|
|
$reqvars = $this->misc->getRequestVars('database'); |
127
|
|
|
$tabs = $this->misc->getNavTabs('database'); |
128
|
|
|
$items = $this->adjustTabsForTree($tabs); |
129
|
|
|
|
130
|
|
|
$attrs = [ |
131
|
|
|
'text' => Decorator::field('title'), |
132
|
|
|
'icon' => Decorator::field('icon'), |
133
|
|
|
'action' => Decorator::actionurl( |
134
|
|
|
Decorator::field('url'), |
135
|
|
|
$reqvars, |
136
|
|
|
Decorator::field('urlvars'), |
137
|
|
|
[ |
138
|
|
|
'database' => $this->misc->getDatabase(), |
139
|
|
|
] |
140
|
|
|
), |
141
|
|
|
'branch' => Decorator::branchurl( |
142
|
|
|
Decorator::field('url'), |
143
|
|
|
$reqvars, |
144
|
|
|
Decorator::field('urlvars'), |
145
|
|
|
[ |
146
|
|
|
'action' => 'tree', |
147
|
|
|
'database' => $this->misc->getDatabase(), |
148
|
|
|
] |
149
|
|
|
), |
150
|
|
|
]; |
151
|
|
|
|
152
|
|
|
return $this->printTree($items, $attrs, 'database', $print); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
/** |
156
|
|
|
* Sends a signal to a process. |
157
|
|
|
*/ |
158
|
|
|
public function doSignal() |
159
|
|
|
{ |
160
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
161
|
|
|
|
162
|
|
|
$status = $data->sendSignal($_REQUEST['pid'], $_REQUEST['signal']); |
163
|
|
|
if (0 == $status) { |
164
|
|
|
$this->doProcesses($this->lang['strsignalsent']); |
165
|
|
|
} else { |
166
|
|
|
$this->doProcesses($this->lang['strsignalsentbad']); |
167
|
|
|
} |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Searches for a named database object. |
172
|
|
|
* |
173
|
|
|
* @param mixed $confirm |
174
|
|
|
* @param mixed $msg |
175
|
|
|
*/ |
176
|
|
|
public function printFindForm($confirm = true, $msg = '') |
177
|
|
|
{ |
178
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
179
|
|
|
|
180
|
|
|
$this->coalesceArr($_REQUEST, 'term', ''); |
181
|
|
|
|
182
|
|
|
$this->coalesceArr($_REQUEST, 'filter', ''); |
183
|
|
|
|
184
|
|
|
$this->printTrail('database'); |
185
|
|
|
$this->printTabs('database', 'find'); |
186
|
|
|
$this->printMsg($msg); |
187
|
|
|
|
188
|
|
|
echo '<form action="' . \SUBFOLDER . "/src/views/database\" method=\"post\">\n"; |
189
|
|
|
echo '<p><input name="term" value="', htmlspecialchars($_REQUEST['term']), |
190
|
|
|
"\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" />\n"; |
191
|
|
|
// Output list of filters. This is complex due to all the 'has' and 'conf' feature possibilities |
192
|
|
|
echo "<select name=\"filter\">\n"; |
193
|
|
|
/*echo "\t<option value=\"\"", ('' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['strallobjects']}</option>\n"; |
194
|
|
|
echo "\t<option value=\"COLUMN\"", ('COLUMN' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['strcolumns']}</option>\n"; |
195
|
|
|
echo "\t<option value=\"CONSTRAINT\"", ('CONSTRAINT' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['strconstraints']}</option>\n"; |
196
|
|
|
echo "\t<option value=\"DOMAIN\"", ('DOMAIN' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['strdomains']}</option>\n"; |
197
|
|
|
echo "\t<option value=\"FUNCTION\"", ('FUNCTION' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['strfunctions']}</option>\n"; |
198
|
|
|
echo "\t<option value=\"INDEX\"", ('INDEX' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['strindexes']}</option>\n"; |
199
|
|
|
echo "\t<option value=\"RULE\"", ('RULE' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['strrules']}</option>\n"; |
200
|
|
|
echo "\t<option value=\"SCHEMA\"", ('SCHEMA' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['strschemas']}</option>\n"; |
201
|
|
|
echo "\t<option value=\"SEQUENCE\"", ('SEQUENCE' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['strsequences']}</option>\n"; |
202
|
|
|
echo "\t<option value=\"TABLE\"", ('TABLE' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['strtables']}</option>\n"; |
203
|
|
|
echo "\t<option value=\"TRIGGER\"", ('TRIGGER' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['strtriggers']}</option>\n"; |
204
|
|
|
echo "\t<option value=\"VIEW\"", ('VIEW' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['strviews']}</option>\n"; |
205
|
|
|
|
206
|
|
|
if ($this->conf['show_advanced']) { |
207
|
|
|
echo "\t<option value=\"AGGREGATE\"", ('AGGREGATE' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['straggregates']}</option>\n"; |
208
|
|
|
echo "\t<option value=\"TYPE\"", ('TYPE' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['strtypes']}</option>\n"; |
209
|
|
|
echo "\t<option value=\"OPERATOR\"", ('OPERATOR' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['stroperators']}</option>\n"; |
210
|
|
|
echo "\t<option value=\"OPCLASS\"", ('OPCLASS' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['stropclasses']}</option>\n"; |
211
|
|
|
echo "\t<option value=\"CONVERSION\"", ('CONVERSION' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['strconversions']}</option>\n"; |
212
|
|
|
echo "\t<option value=\"LANGUAGE\"", ('LANGUAGE' == $_REQUEST['filter']) ? ' selected="selected"' : '', ">{$this->lang['strlanguages']}</option>\n"; |
213
|
|
|
}*/ |
214
|
|
|
|
215
|
|
|
echo $this->_printTypeOption(''); |
216
|
|
|
echo $this->_printTypeOption('COLUMN'); |
217
|
|
|
echo $this->_printTypeOption('CONSTRAINT'); |
218
|
|
|
echo $this->_printTypeOption('DOMAIN'); |
219
|
|
|
echo $this->_printTypeOption('FUNCTION'); |
220
|
|
|
echo $this->_printTypeOption('INDEX'); |
221
|
|
|
echo $this->_printTypeOption('RULE'); |
222
|
|
|
echo $this->_printTypeOption('SCHEMA'); |
223
|
|
|
echo $this->_printTypeOption('SEQUENCE'); |
224
|
|
|
echo $this->_printTypeOption('TABLE'); |
225
|
|
|
echo $this->_printTypeOption('TRIGGER'); |
226
|
|
|
echo $this->_printTypeOption('VIEW'); |
227
|
|
|
|
228
|
|
|
if ($this->conf['show_advanced']) { |
229
|
|
|
echo $this->_printTypeOption('AGGREGATE'); |
230
|
|
|
echo $this->_printTypeOption('TYPE'); |
231
|
|
|
echo $this->_printTypeOption('OPERATOR'); |
232
|
|
|
echo $this->_printTypeOption('OPCLASS'); |
233
|
|
|
echo $this->_printTypeOption('CONVERSION'); |
234
|
|
|
echo $this->_printTypeOption('LANGUAGE'); |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
echo "</select>\n"; |
238
|
|
|
echo "<input type=\"submit\" value=\"{$this->lang['strfind']}\" />\n"; |
239
|
|
|
echo $this->misc->form; |
240
|
|
|
echo '<input type="hidden" name="action" value="find" /></p>' . "\n"; |
241
|
|
|
echo '<input type="hidden" name="confirm" value="true" /></p>' . "\n"; |
242
|
|
|
echo "</form>\n"; |
243
|
|
|
|
244
|
|
|
// Default focus |
245
|
|
|
$this->setFocus('forms[0].term'); |
246
|
|
|
|
247
|
|
|
// If a search term has been specified, then perform the search |
248
|
|
|
// and display the results, grouped by object type |
249
|
|
|
if (!$confirm && '' != $_REQUEST['term']) { |
250
|
|
|
return $this->doFind(); |
251
|
|
|
} |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
private function _printTypeOption($curr) |
255
|
|
|
{ |
256
|
|
|
$filter = $_REQUEST['filter']; |
257
|
|
|
$optionhtml = sprintf('%s<option value="%s" %s>', "\t", $curr, ($curr === $filter) ? ' selected="selected"' : ''); |
258
|
|
|
$optionhtml .= $this->_translatedType($curr); |
259
|
|
|
$optionhtml .= "</option>\n"; |
260
|
|
|
return $optionhtml; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
private function _translatedType($curr) |
264
|
|
|
{ |
265
|
|
|
|
266
|
|
|
$types = [ |
267
|
|
|
'COLUMN' => $this->lang['strcolumns'], |
268
|
|
|
'CONSTRAINT' => $this->lang['strconstraints'], |
269
|
|
|
'COLUMNTABLE' => $this->lang['strcolumns'], |
270
|
|
|
'COLUMNVIEW' => $this->lang['strcolumns'], |
271
|
|
|
'CONSTRAINTDOMAIN' => $this->lang['strconstraints'], |
272
|
|
|
'CONSTRAINTTABLE' => $this->lang['strconstraints'], |
273
|
|
|
'DOMAIN' => $this->lang['strdomains'], |
274
|
|
|
'FUNCTION' => $this->lang['strfunctions'], |
275
|
|
|
'INDEX' => $this->lang['strindexes'], |
276
|
|
|
'RULE' => $this->lang['strrules'], |
277
|
|
|
'RULETABLE' => $this->lang['strrules'], |
278
|
|
|
'RULEVIEW' => $this->lang['strrules'], |
279
|
|
|
'SCHEMA' => $this->lang['strschemas'], |
280
|
|
|
'SEQUENCE' => $this->lang['strsequences'], |
281
|
|
|
'TABLE' => $this->lang['strtables'], |
282
|
|
|
'TRIGGER' => $this->lang['strtriggers'], |
283
|
|
|
'VIEW' => $this->lang['strviews'], |
284
|
|
|
|
285
|
|
|
'AGGREGATE' => $this->lang['straggregates'], |
286
|
|
|
'CONVERSION' => $this->lang['strconversions'], |
287
|
|
|
'LANGUAGE' => $this->lang['strlanguages'], |
288
|
|
|
'OPCLASS' => $this->lang['stropclasses'], |
289
|
|
|
'OPERATOR' => $this->lang['stroperators'], |
290
|
|
|
'TYPE' => $this->lang['strtypes'], |
291
|
|
|
|
292
|
|
|
]; |
293
|
|
|
if (array_key_exists($curr, $types)) { |
294
|
|
|
return $types[$curr]; |
295
|
|
|
} |
296
|
|
|
return $this->lang['strallobjects']; |
297
|
|
|
|
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
private function _printHtmlForType($curr, $rs) |
301
|
|
|
{ |
302
|
|
|
switch ($curr) { |
303
|
|
|
case 'SCHEMA': |
304
|
|
|
echo '<li><a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema="; |
305
|
|
|
echo $this->misc->printVal($rs->fields['name']), '">'; |
306
|
|
|
echo $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']); |
307
|
|
|
echo "</a></li>\n"; |
308
|
|
|
|
309
|
|
|
break; |
310
|
|
|
case 'TABLE': |
311
|
|
|
echo '<li>'; |
312
|
|
|
echo "<a href=\"tables?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
313
|
|
|
echo '<a href="' . \SUBFOLDER . "/redirect/table?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&table=', |
314
|
|
|
urlencode($rs->fields['name']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
315
|
|
|
|
316
|
|
|
break; |
317
|
|
|
case 'VIEW': |
318
|
|
|
echo '<li>'; |
319
|
|
|
echo "<a href=\"views?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
320
|
|
|
echo '<a href="' . \SUBFOLDER . "/redirect/view?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&view=', |
321
|
|
|
urlencode($rs->fields['name']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
322
|
|
|
|
323
|
|
|
break; |
324
|
|
|
case 'SEQUENCE': |
325
|
|
|
echo '<li>'; |
326
|
|
|
echo "<a href=\"sequences?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
327
|
|
|
echo "<a href=\"sequences?subject=sequence&action=properties&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), |
328
|
|
|
'&sequence=', urlencode($rs->fields['name']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
329
|
|
|
|
330
|
|
|
break; |
331
|
|
|
case 'COLUMNTABLE': |
332
|
|
|
echo '<li>'; |
333
|
|
|
echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
334
|
|
|
echo "<a href=\"tblproperties?subject=table&{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.'; |
335
|
|
|
echo "<a href=\"colproperties?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&table=', |
336
|
|
|
urlencode($rs->fields['relname']), '&column=', urlencode($rs->fields['name']), '">', |
337
|
|
|
$this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
338
|
|
|
|
339
|
|
|
break; |
340
|
|
|
case 'COLUMNVIEW': |
341
|
|
|
echo '<li>'; |
342
|
|
|
echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
343
|
|
|
echo "<a href=\"viewproperties?subject=view&{$this->misc->href}&view=", urlencode($rs->fields['relname']), '&schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.'; |
344
|
|
|
echo "<a href=\"colproperties?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&view=', |
345
|
|
|
urlencode($rs->fields['relname']), '&column=', urlencode($rs->fields['name']), '">', |
346
|
|
|
$this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
347
|
|
|
|
348
|
|
|
break; |
349
|
|
|
case 'INDEX': |
350
|
|
|
echo '<li>'; |
351
|
|
|
echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
352
|
|
|
echo '<a href="' . \SUBFOLDER . "/redirect/table?{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.'; |
353
|
|
|
echo "<a href=\"indexes?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&table=', urlencode($rs->fields['relname']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
354
|
|
|
|
355
|
|
|
break; |
356
|
|
|
case 'CONSTRAINTTABLE': |
357
|
|
|
echo '<li>'; |
358
|
|
|
echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
359
|
|
|
echo '<a href="' . \SUBFOLDER . "/redirect/table?{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.'; |
360
|
|
|
echo "<a href=\"constraints?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&table=', |
361
|
|
|
urlencode($rs->fields['relname']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
362
|
|
|
|
363
|
|
|
break; |
364
|
|
|
case 'CONSTRAINTDOMAIN': |
365
|
|
|
echo '<li>'; |
366
|
|
|
echo "<a href=\"domains?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
367
|
|
|
echo "<a href=\"domains?action=properties&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&domain=', urlencode($rs->fields['relname']), '">', |
368
|
|
|
$this->misc->printVal($rs->fields['relname']), '.', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
369
|
|
|
|
370
|
|
|
break; |
371
|
|
|
case 'TRIGGER': |
372
|
|
|
echo '<li>'; |
373
|
|
|
echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
374
|
|
|
echo '<a href="' . \SUBFOLDER . "/redirect/table?{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.'; |
375
|
|
|
echo "<a href=\"triggers?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&table=', urlencode($rs->fields['relname']), '">', |
376
|
|
|
$this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
377
|
|
|
|
378
|
|
|
break; |
379
|
|
|
case 'RULETABLE': |
380
|
|
|
echo '<li>'; |
381
|
|
|
echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
382
|
|
|
echo '<a href="' . \SUBFOLDER . "/redirect/table?{$this->misc->href}&table=", urlencode($rs->fields['relname']), '&schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.'; |
383
|
|
|
echo "<a href=\"rules?subject=table&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&reltype=table&table=', |
384
|
|
|
urlencode($rs->fields['relname']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
385
|
|
|
|
386
|
|
|
break; |
387
|
|
|
case 'RULEVIEW': |
388
|
|
|
echo '<li>'; |
389
|
|
|
echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
390
|
|
|
echo '<a href="' . \SUBFOLDER . "/redirect/view?{$this->misc->href}&view=", urlencode($rs->fields['relname']), '&schema=', urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['relname']), '</a>.'; |
391
|
|
|
echo "<a href=\"rules?subject=view&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&reltype=view&view=', |
392
|
|
|
urlencode($rs->fields['relname']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
393
|
|
|
|
394
|
|
|
break; |
395
|
|
|
case 'FUNCTION': |
396
|
|
|
echo '<li>'; |
397
|
|
|
echo "<a href=\"functions?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
398
|
|
|
echo "<a href=\"functions?action=properties&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&function=', |
399
|
|
|
urlencode($rs->fields['name']), '&function_oid=', urlencode($rs->fields['oid']), '">', |
400
|
|
|
$this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
401
|
|
|
|
402
|
|
|
break; |
403
|
|
|
case 'TYPE': |
404
|
|
|
echo '<li>'; |
405
|
|
|
echo "<a href=\"types?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
406
|
|
|
echo "<a href=\"types?action=properties&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&type=', |
407
|
|
|
urlencode($rs->fields['name']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
408
|
|
|
|
409
|
|
|
break; |
410
|
|
|
case 'DOMAIN': |
411
|
|
|
echo '<li>'; |
412
|
|
|
echo "<a href=\"domains?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
413
|
|
|
echo "<a href=\"domains?action=properties&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&domain=', |
414
|
|
|
urlencode($rs->fields['name']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
415
|
|
|
|
416
|
|
|
break; |
417
|
|
|
case 'OPERATOR': |
418
|
|
|
echo '<li>'; |
419
|
|
|
echo "<a href=\"operators?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
420
|
|
|
echo "<a href=\"operators?action=properties&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '&operator=', |
421
|
|
|
urlencode($rs->fields['name']), '&operator_oid=', urlencode($rs->fields['oid']), '">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
422
|
|
|
|
423
|
|
|
break; |
424
|
|
|
case 'CONVERSION': |
425
|
|
|
echo '<li>'; |
426
|
|
|
echo "<a href=\"conversions?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
427
|
|
|
echo "<a href=\"conversions?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), |
428
|
|
|
'">', $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
429
|
|
|
|
430
|
|
|
break; |
431
|
|
|
case 'LANGUAGE': |
432
|
|
|
echo "<li><a href=\"languages?{$this->misc->href}\">", $this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
433
|
|
|
|
434
|
|
|
break; |
435
|
|
|
case 'AGGREGATE': |
436
|
|
|
echo '<li>'; |
437
|
|
|
echo "<a href=\"aggregates?subject=schema&{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
438
|
|
|
echo "<a href=\"aggregates?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', |
439
|
|
|
$this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
440
|
|
|
|
441
|
|
|
break; |
442
|
|
|
case 'OPCLASS': |
443
|
|
|
echo '<li>'; |
444
|
|
|
echo '<a href="' . \SUBFOLDER . "/redirect/schema?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', $this->misc->printVal($rs->fields['schemaname']), '</a>.'; |
445
|
|
|
echo "<a href=\"opclasses?{$this->misc->href}&schema=", urlencode($rs->fields['schemaname']), '">', |
446
|
|
|
$this->_highlight($this->misc->printVal($rs->fields['name']), $_REQUEST['term']), "</a></li>\n"; |
447
|
|
|
|
448
|
|
|
break; |
449
|
|
|
} |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
public function doFind() |
453
|
|
|
{ |
454
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
455
|
|
|
$rs = $data->findObject($_REQUEST['term'], $_REQUEST['filter']); |
456
|
|
|
if ($rs->RecordCount() > 0) { |
457
|
|
|
$curr = ''; |
458
|
|
|
while (!$rs->EOF) { |
459
|
|
|
// Output a new header if the current type has changed, but not if it's just changed the rule type |
460
|
|
|
if ($rs->fields['type'] != $curr) { |
461
|
|
|
// Short-circuit in the case of changing from table rules to view rules; table cols to view cols; |
462
|
|
|
// table constraints to domain constraints |
463
|
|
|
if ('RULEVIEW' == $rs->fields['type'] && 'RULETABLE' == $curr) { |
464
|
|
|
$curr = $rs->fields['type']; |
465
|
|
|
} elseif ('COLUMNVIEW' == $rs->fields['type'] && 'COLUMNTABLE' == $curr) { |
466
|
|
|
$curr = $rs->fields['type']; |
467
|
|
|
} elseif ('CONSTRAINTTABLE' == $rs->fields['type'] && 'CONSTRAINTDOMAIN' == $curr) { |
468
|
|
|
$curr = $rs->fields['type']; |
469
|
|
|
} else { |
470
|
|
|
if ('' != $curr) { |
471
|
|
|
echo "</ul>\n"; |
472
|
|
|
} |
473
|
|
|
|
474
|
|
|
$curr = $rs->fields['type']; |
475
|
|
|
echo '<h3>'; |
476
|
|
|
echo $this->_translatedType($curr); |
477
|
|
|
echo '</h3>'; |
478
|
|
|
echo "<ul>\n"; |
479
|
|
|
} |
480
|
|
|
} |
481
|
|
|
|
482
|
|
|
$this->_printHtmlForType($curr, $rs); |
483
|
|
|
$rs->moveNext(); |
484
|
|
|
} |
485
|
|
|
echo "</ul>\n"; |
486
|
|
|
|
487
|
|
|
echo '<p>', $rs->recordCount(), ' ', $this->lang['strobjects'], "</p>\n"; |
488
|
|
|
} else { |
489
|
|
|
echo "<p>{$this->lang['strnoobjects']}</p>\n"; |
490
|
|
|
} |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
/** |
494
|
|
|
* Displays options for database download. |
495
|
|
|
* |
496
|
|
|
* @param mixed $msg |
497
|
|
|
*/ |
498
|
|
|
public function doExport($msg = '') |
499
|
|
|
{ |
500
|
|
|
$this->printTrail('database'); |
501
|
|
|
$this->printTabs('database', 'export'); |
502
|
|
|
$this->printMsg($msg); |
503
|
|
|
|
504
|
|
|
$subject = 'database'; |
505
|
|
|
$object = $_REQUEST['database']; |
506
|
|
|
|
507
|
|
|
echo $this->formHeader('dbexport'); |
508
|
|
|
|
509
|
|
|
echo $this->dataOnly(true, true); |
510
|
|
|
|
511
|
|
|
echo $this->structureOnly(); |
512
|
|
|
|
513
|
|
|
echo $this->structureAndData(true); |
514
|
|
|
|
515
|
|
|
echo $this->displayOrDownload(!(strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') && isset($_SERVER['HTTPS']))); |
516
|
|
|
|
517
|
|
|
echo $this->formFooter($subject, $object); |
518
|
|
|
} |
519
|
|
|
|
520
|
|
|
/** |
521
|
|
|
* Show the current status of all database variables. |
522
|
|
|
*/ |
523
|
|
|
public function doVariables() |
524
|
|
|
{ |
525
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
526
|
|
|
|
527
|
|
|
// Fetch the variables from the database |
528
|
|
|
$variables = $data->getVariables(); |
529
|
|
|
$this->printTrail('database'); |
530
|
|
|
$this->printTabs('database', 'variables'); |
531
|
|
|
|
532
|
|
|
$columns = [ |
533
|
|
|
'variable' => [ |
534
|
|
|
'title' => $this->lang['strname'], |
535
|
|
|
'field' => Decorator::field('name'), |
536
|
|
|
], |
537
|
|
|
'value' => [ |
538
|
|
|
'title' => $this->lang['strsetting'], |
539
|
|
|
'field' => Decorator::field('setting'), |
540
|
|
|
], |
541
|
|
|
]; |
542
|
|
|
|
543
|
|
|
$actions = []; |
544
|
|
|
|
545
|
|
|
echo $this->printTable($variables, $columns, $actions, $this->table_place, $this->lang['strnodata']); |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
/** |
549
|
|
|
* Show all current database connections and any queries they |
550
|
|
|
* are running. |
551
|
|
|
* |
552
|
|
|
* @param mixed $msg |
553
|
|
|
*/ |
554
|
|
|
public function doProcesses($msg = '') |
555
|
|
|
{ |
556
|
|
|
$this->printTrail('database'); |
557
|
|
|
$this->printTabs('database', 'processes'); |
558
|
|
|
$this->printMsg($msg); |
559
|
|
|
|
560
|
|
|
if (0 === strlen($msg)) { |
561
|
|
|
echo '<br /><a id="control" href=""><img src="' . $this->misc->icon('Refresh') . "\" alt=\"{$this->lang['strrefresh']}\" title=\"{$this->lang['strrefresh']}\"/> {$this->lang['strrefresh']}</a>"; |
562
|
|
|
} |
563
|
|
|
|
564
|
|
|
echo '<div id="data_block">'; |
565
|
|
|
$this->currentProcesses(); |
566
|
|
|
echo '</div>'; |
567
|
|
|
} |
568
|
|
|
|
569
|
|
|
public function currentProcesses($isAjax = false) |
570
|
|
|
{ |
571
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
572
|
|
|
|
573
|
|
|
// Display prepared transactions |
574
|
|
|
if ($data->hasPreparedXacts()) { |
575
|
|
|
echo "<h3>{$this->lang['strpreparedxacts']}</h3>\n"; |
576
|
|
|
$prep_xacts = $data->getPreparedXacts($_REQUEST['database']); |
577
|
|
|
|
578
|
|
|
$columns = [ |
579
|
|
|
'transaction' => [ |
580
|
|
|
'title' => $this->lang['strxactid'], |
581
|
|
|
'field' => Decorator::field('transaction'), |
582
|
|
|
], |
583
|
|
|
'gid' => [ |
584
|
|
|
'title' => $this->lang['strgid'], |
585
|
|
|
'field' => Decorator::field('gid'), |
586
|
|
|
], |
587
|
|
|
'prepared' => [ |
588
|
|
|
'title' => $this->lang['strstarttime'], |
589
|
|
|
'field' => Decorator::field('prepared'), |
590
|
|
|
], |
591
|
|
|
'owner' => [ |
592
|
|
|
'title' => $this->lang['strowner'], |
593
|
|
|
'field' => Decorator::field('owner'), |
594
|
|
|
], |
595
|
|
|
]; |
596
|
|
|
|
597
|
|
|
$actions = []; |
598
|
|
|
|
599
|
|
|
echo $this->printTable($prep_xacts, $columns, $actions, 'database-processes-preparedxacts', $this->lang['strnodata']); |
600
|
|
|
} |
601
|
|
|
|
602
|
|
|
// Fetch the processes from the database |
603
|
|
|
echo "<h3>{$this->lang['strprocesses']}</h3>\n"; |
604
|
|
|
$processes = $data->getProcesses($_REQUEST['database']); |
605
|
|
|
|
606
|
|
|
$columns = [ |
607
|
|
|
'user' => [ |
608
|
|
|
'title' => $this->lang['strusername'], |
609
|
|
|
'field' => Decorator::field('usename'), |
610
|
|
|
], |
611
|
|
|
'process' => [ |
612
|
|
|
'title' => $this->lang['strprocess'], |
613
|
|
|
'field' => Decorator::field('pid'), |
614
|
|
|
], |
615
|
|
|
'application_name' => [ |
616
|
|
|
'title' => 'application', |
617
|
|
|
'field' => Decorator::field('application_name'), |
618
|
|
|
], |
619
|
|
|
'client_addr' => [ |
620
|
|
|
'title' => 'address', |
621
|
|
|
'field' => Decorator::field('client_addr'), |
622
|
|
|
], |
623
|
|
|
'blocked' => [ |
624
|
|
|
'title' => $this->lang['strblocked'], |
625
|
|
|
'field' => Decorator::field('waiting'), |
626
|
|
|
], |
627
|
|
|
'query' => [ |
628
|
|
|
'title' => $this->lang['strsql'], |
629
|
|
|
'field' => Decorator::field('query'), |
630
|
|
|
], |
631
|
|
|
'start_time' => [ |
632
|
|
|
'title' => $this->lang['strstarttime'], |
633
|
|
|
'field' => Decorator::field('query_start'), |
634
|
|
|
], |
635
|
|
|
]; |
636
|
|
|
|
637
|
|
|
// Build possible actions for our process list |
638
|
|
|
$columns['actions'] = ['title' => $this->lang['stractions']]; |
639
|
|
|
|
640
|
|
|
$actions = []; |
641
|
|
|
if ($data->hasUserSignals() || $data->isSuperUser()) { |
642
|
|
|
$actions = [ |
643
|
|
|
'cancel' => [ |
644
|
|
|
'content' => $this->lang['strcancel'], |
645
|
|
|
'attr' => [ |
646
|
|
|
'href' => [ |
647
|
|
|
'url' => 'database', |
648
|
|
|
'urlvars' => [ |
649
|
|
|
'action' => 'signal', |
650
|
|
|
'signal' => 'CANCEL', |
651
|
|
|
'pid' => Decorator::field('pid'), |
652
|
|
|
], |
653
|
|
|
], |
654
|
|
|
], |
655
|
|
|
], |
656
|
|
|
'kill' => [ |
657
|
|
|
'content' => $this->lang['strkill'], |
658
|
|
|
'attr' => [ |
659
|
|
|
'href' => [ |
660
|
|
|
'url' => 'database', |
661
|
|
|
'urlvars' => [ |
662
|
|
|
'action' => 'signal', |
663
|
|
|
'signal' => 'KILL', |
664
|
|
|
'pid' => Decorator::field('pid'), |
665
|
|
|
], |
666
|
|
|
], |
667
|
|
|
], |
668
|
|
|
], |
669
|
|
|
]; |
670
|
|
|
|
671
|
|
|
// Remove actions where not supported |
672
|
|
|
if (!$data->hasQueryKill()) { |
673
|
|
|
unset($actions['kill']); |
674
|
|
|
} |
675
|
|
|
|
676
|
|
|
if (!$data->hasQueryCancel()) { |
677
|
|
|
unset($actions['cancel']); |
678
|
|
|
} |
679
|
|
|
} |
680
|
|
|
|
681
|
|
|
if (0 == count($actions)) { |
682
|
|
|
unset($columns['actions']); |
683
|
|
|
} |
684
|
|
|
|
685
|
|
|
echo $this->printTable($processes, $columns, $actions, 'database-processes', $this->lang['strnodata']); |
686
|
|
|
} |
687
|
|
|
|
688
|
|
|
public function currentLocks($isAjax = false) |
689
|
|
|
{ |
690
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
691
|
|
|
|
692
|
|
|
// Get the info from the pg_locks view |
693
|
|
|
$variables = $data->getLocks(); |
694
|
|
|
|
695
|
|
|
$columns = [ |
696
|
|
|
'namespace' => [ |
697
|
|
|
'title' => $this->lang['strschema'], |
698
|
|
|
'field' => Decorator::field('nspname'), |
699
|
|
|
], |
700
|
|
|
'tablename' => [ |
701
|
|
|
'title' => $this->lang['strtablename'], |
702
|
|
|
'field' => Decorator::field('tablename'), |
703
|
|
|
], |
704
|
|
|
'vxid' => [ |
705
|
|
|
'title' => $this->lang['strvirtualtransaction'], |
706
|
|
|
'field' => Decorator::field('virtualtransaction'), |
707
|
|
|
], |
708
|
|
|
'transactionid' => [ |
709
|
|
|
'title' => $this->lang['strtransaction'], |
710
|
|
|
'field' => Decorator::field('transaction'), |
711
|
|
|
], |
712
|
|
|
'processid' => [ |
713
|
|
|
'title' => $this->lang['strprocessid'], |
714
|
|
|
'field' => Decorator::field('pid'), |
715
|
|
|
], |
716
|
|
|
'mode' => [ |
717
|
|
|
'title' => $this->lang['strmode'], |
718
|
|
|
'field' => Decorator::field('mode'), |
719
|
|
|
], |
720
|
|
|
'granted' => [ |
721
|
|
|
'title' => $this->lang['strislockheld'], |
722
|
|
|
'field' => Decorator::field('granted'), |
723
|
|
|
'type' => 'yesno', |
724
|
|
|
], |
725
|
|
|
]; |
726
|
|
|
|
727
|
|
|
if (!$data->hasVirtualTransactionId()) { |
728
|
|
|
unset($columns['vxid']); |
729
|
|
|
} |
730
|
|
|
|
731
|
|
|
$actions = []; |
732
|
|
|
echo $this->printTable($variables, $columns, $actions, 'database-locks', $this->lang['strnodata']); |
733
|
|
|
} |
734
|
|
|
|
735
|
|
|
/** |
736
|
|
|
* Show the existing table locks in the current database. |
737
|
|
|
*/ |
738
|
|
|
public function doLocks() |
739
|
|
|
{ |
740
|
|
|
$this->printTrail('database'); |
741
|
|
|
$this->printTabs('database', 'locks'); |
742
|
|
|
|
743
|
|
|
echo '<br /><a id="control" href=""><img src="' . $this->misc->icon('Refresh') . "\" alt=\"{$this->lang['strrefresh']}\" title=\"{$this->lang['strrefresh']}\"/> {$this->lang['strrefresh']}</a>"; |
744
|
|
|
|
745
|
|
|
echo '<div id="data_block">'; |
746
|
|
|
$this->currentLocks(); |
747
|
|
|
echo '</div>'; |
748
|
|
|
} |
749
|
|
|
|
750
|
|
|
/** |
751
|
|
|
* Allow execution of arbitrary SQL statements on a database. |
752
|
|
|
*/ |
753
|
|
|
public function doSQL() |
754
|
|
|
{ |
755
|
|
|
if ((!isset($_SESSION['sqlquery'])) || isset($_REQUEST['new'])) { |
756
|
|
|
$_SESSION['sqlquery'] = ''; |
757
|
|
|
$_REQUEST['paginate'] = 'on'; |
758
|
|
|
} |
759
|
|
|
|
760
|
|
|
$this->printTrail('database'); |
761
|
|
|
$this->printTabs('database', 'sql'); |
762
|
|
|
echo "<p>{$this->lang['strentersql']}</p>\n"; |
763
|
|
|
echo '<form action="' . \SUBFOLDER . '/src/views/sql" method="post" enctype="multipart/form-data" id="sqlform">' . "\n"; |
764
|
|
|
echo "<p>{$this->lang['strsql']}<br />\n"; |
765
|
|
|
echo '<textarea style="width:95%;" rows="15" cols="50" name="query" id="query">', |
766
|
|
|
htmlspecialchars($_SESSION['sqlquery']), "</textarea></p>\n"; |
767
|
|
|
|
768
|
|
|
// Check that file uploads are enabled |
769
|
|
|
if (ini_get('file_uploads')) { |
770
|
|
|
// Don't show upload option if max size of uploads is zero |
771
|
|
|
$max_size = $this->misc->inisizeToBytes(ini_get('upload_max_filesize')); |
772
|
|
|
if (is_double($max_size) && $max_size > 0) { |
773
|
|
|
echo "<p><input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"{$max_size}\" />\n"; |
774
|
|
|
echo "<label for=\"script\">{$this->lang['struploadscript']}</label> <input id=\"script\" name=\"script\" type=\"file\" /></p>\n"; |
775
|
|
|
} |
776
|
|
|
} |
777
|
|
|
|
778
|
|
|
echo '<p><input type="checkbox" id="paginate" name="paginate"', (isset($_REQUEST['paginate']) ? ' checked="checked"' : ''), " /><label for=\"paginate\">{$this->lang['strpaginate']}</label></p>\n"; |
779
|
|
|
echo "<p><input type=\"submit\" name=\"execute\" accesskey=\"r\" value=\"{$this->lang['strexecute']}\" />\n"; |
780
|
|
|
echo $this->misc->form; |
781
|
|
|
echo "<input type=\"reset\" accesskey=\"q\" value=\"{$this->lang['strreset']}\" /></p>\n"; |
782
|
|
|
echo "</form>\n"; |
783
|
|
|
|
784
|
|
|
// Default focus |
785
|
|
|
$this->setFocus('forms[0].query'); |
786
|
|
|
} |
787
|
|
|
|
788
|
|
|
/** |
789
|
|
|
* This functions does pretty much nothing. It's meant to implement |
790
|
|
|
* an abstract method of AdminTrait. |
791
|
|
|
* |
792
|
|
|
* @param string $msg The message |
793
|
|
|
* |
794
|
|
|
* @return string The message |
795
|
|
|
*/ |
796
|
|
|
public function doDefault($msg = '') |
797
|
|
|
{ |
798
|
|
|
return $msg; |
799
|
|
|
} |
800
|
|
|
} |
801
|
|
|
|