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