1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* Manage schemas within a database
|
5
|
*
|
6
|
* $Id: database.php,v 1.78 2005/11/09 09:05:58 jollytoad Exp $
|
7
|
*/
|
8
|
|
9
|
// Include application functions
|
10
|
include_once('./libraries/lib.inc.php');
|
11
|
|
12
|
$action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
|
13
|
if (!isset($msg)) $msg = '';
|
14
|
$PHP_SELF = $_SERVER['PHP_SELF'];
|
15
|
|
16
|
function _highlight($string, $term) {
|
17
|
return str_replace($term, "<b>{$term}</b>", $string);
|
18
|
}
|
19
|
|
20
|
/**
|
21
|
* Sends a signal to a process
|
22
|
*/
|
23
|
function doSignal() {
|
24
|
global $data, $lang;
|
25
|
|
26
|
$status = $data->sendSignal($_REQUEST['procpid'], $_REQUEST['signal']);
|
27
|
if ($status == 0)
|
28
|
doProcesses($lang['strsignalsent']);
|
29
|
else
|
30
|
doProcesses($lang['strsignalsentbad']);
|
31
|
}
|
32
|
|
33
|
/**
|
34
|
* Searches for a named database object
|
35
|
*/
|
36
|
function doFind($confirm = true, $msg = '') {
|
37
|
global $PHP_SELF, $data, $data, $misc;
|
38
|
global $lang, $conf;
|
39
|
|
40
|
if (!isset($_GET['term'])) $_GET['term'] = '';
|
41
|
if (!isset($_GET['filter'])) $_GET['filter'] = '';
|
42
|
|
43
|
$misc->printTrail('database');
|
44
|
$misc->printTabs('database','find');
|
45
|
$misc->printMsg($msg);
|
46
|
|
47
|
echo "<form action=\"$PHP_SELF\" method=\"get\">\n";
|
48
|
echo "<p><input name=\"term\" value=\"", htmlspecialchars($_GET['term']),
|
49
|
"\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" />\n";
|
50
|
// Output list of filters. This is complex due to all the 'has' and 'conf' feature possibilities
|
51
|
echo "<select name=\"filter\">\n";
|
52
|
echo "\t<option value=\"\"", ($_GET['filter'] == '') ? ' selected="selected"' : '', ">{$lang['strallobjects']}</option>\n";
|
53
|
if ($data->hasSchemas())
|
54
|
echo "\t<option value=\"SCHEMA\"", ($_GET['filter'] == 'SCHEMA') ? ' selected="selected"' : '', ">{$lang['strschemas']}</option>\n";
|
55
|
echo "\t<option value=\"TABLE\"", ($_GET['filter'] == 'TABLE') ? ' selected="selected"' : '', ">{$lang['strtables']}</option>\n";
|
56
|
echo "\t<option value=\"VIEW\"", ($_GET['filter'] == 'VIEW') ? ' selected="selected"' : '', ">{$lang['strviews']}</option>\n";
|
57
|
echo "\t<option value=\"SEQUENCE\"", ($_GET['filter'] == 'SEQUENCE') ? ' selected="selected"' : '', ">{$lang['strsequences']}</option>\n";
|
58
|
echo "\t<option value=\"COLUMN\"", ($_GET['filter'] == 'COLUMN') ? ' selected="selected"' : '', ">{$lang['strcolumns']}</option>\n";
|
59
|
echo "\t<option value=\"RULE\"", ($_GET['filter'] == 'RULE') ? ' selected="selected"' : '', ">{$lang['strrules']}</option>\n";
|
60
|
echo "\t<option value=\"INDEX\"", ($_GET['filter'] == 'INDEX') ? ' selected="selected"' : '', ">{$lang['strindexes']}</option>\n";
|
61
|
echo "\t<option value=\"TRIGGER\"", ($_GET['filter'] == 'TRIGGER') ? ' selected="selected"' : '', ">{$lang['strtriggers']}</option>\n";
|
62
|
echo "\t<option value=\"CONSTRAINT\"", ($_GET['filter'] == 'CONSTRAINT') ? ' selected="selected"' : '', ">{$lang['strconstraints']}</option>\n";
|
63
|
echo "\t<option value=\"FUNCTION\"", ($_GET['filter'] == 'FUNCTION') ? ' selected="selected"' : '', ">{$lang['strfunctions']}</option>\n";
|
64
|
if ($data->hasDomains())
|
65
|
echo "\t<option value=\"DOMAIN\"", ($_GET['filter'] == 'DOMAIN') ? ' selected="selected"' : '', ">{$lang['strdomains']}</option>\n";
|
66
|
if ($conf['show_advanced']) {
|
67
|
echo "\t<option value=\"AGGREGATE\"", ($_GET['filter'] == 'AGGREGATE') ? ' selected="selected"' : '', ">{$lang['straggregates']}</option>\n";
|
68
|
echo "\t<option value=\"TYPE\"", ($_GET['filter'] == 'TYPE') ? ' selected="selected"' : '', ">{$lang['strtypes']}</option>\n";
|
69
|
echo "\t<option value=\"OPERATOR\"", ($_GET['filter'] == 'OPERATOR') ? ' selected="selected"' : '', ">{$lang['stroperators']}</option>\n";
|
70
|
echo "\t<option value=\"OPCLASS\"", ($_GET['filter'] == 'OPCLASS') ? ' selected="selected"' : '', ">{$lang['stropclasses']}</option>\n";
|
71
|
if ($data->hasConversions())
|
72
|
echo "\t<option value=\"CONVERSION\"", ($_GET['filter'] == 'CONVERSION') ? ' selected="selected"' : '', ">{$lang['strconversions']}</option>\n";
|
73
|
echo "\t<option value=\"LANGUAGE\"", ($_GET['filter'] == 'LANGUAGE') ? ' selected="selected"' : '', ">{$lang['strlanguages']}</option>\n";
|
74
|
}
|
75
|
echo "</select>\n";
|
76
|
echo "<input type=\"submit\" value=\"{$lang['strfind']}\" />\n";
|
77
|
echo $misc->form;
|
78
|
echo "<input type=\"hidden\" name=\"action\" value=\"find\" />\n";
|
79
|
echo "</form>\n";
|
80
|
|
81
|
// Default focus
|
82
|
$misc->setFocus('forms[0].term');
|
83
|
|
84
|
// If a search term has been specified, then perform the search
|
85
|
// and display the results, grouped by object type
|
86
|
if ($_GET['term'] != '') {
|
87
|
$rs = $data->findObject($_GET['term'], $_GET['filter']);
|
88
|
if ($rs->recordCount() > 0) {
|
89
|
$curr = '';
|
90
|
while (!$rs->EOF) {
|
91
|
// Output a new header if the current type has changed, but not if it's just changed the rule type
|
92
|
if ($rs->f['type'] != $curr) {
|
93
|
// Short-circuit in the case of changing from table rules to view rules; table cols to view cols;
|
94
|
// table constraints to domain constraints
|
95
|
if ($rs->f['type'] == 'RULEVIEW' && $curr == 'RULETABLE') {
|
96
|
$curr = $rs->f['type'];
|
97
|
}
|
98
|
elseif ($rs->f['type'] == 'COLUMNVIEW' && $curr == 'COLUMNTABLE') {
|
99
|
$curr = $rs->f['type'];
|
100
|
}
|
101
|
elseif ($rs->f['type'] == 'CONSTRAINTTABLE' && $curr == 'CONSTRAINTDOMAIN') {
|
102
|
$curr = $rs->f['type'];
|
103
|
}
|
104
|
else {
|
105
|
if ($curr != '') echo "</ul>\n";
|
106
|
$curr = $rs->f['type'];
|
107
|
echo "<h3>";
|
108
|
switch ($curr) {
|
109
|
case 'SCHEMA':
|
110
|
echo $lang['strschemas'];
|
111
|
break;
|
112
|
case 'TABLE':
|
113
|
echo $lang['strtables'];
|
114
|
break;
|
115
|
case 'VIEW':
|
116
|
echo $lang['strviews'];
|
117
|
break;
|
118
|
case 'SEQUENCE':
|
119
|
echo $lang['strsequences'];
|
120
|
break;
|
121
|
case 'COLUMNTABLE':
|
122
|
case 'COLUMNVIEW':
|
123
|
echo $lang['strcolumns'];
|
124
|
break;
|
125
|
case 'INDEX':
|
126
|
echo $lang['strindexes'];
|
127
|
break;
|
128
|
case 'CONSTRAINTTABLE':
|
129
|
case 'CONSTRAINTDOMAIN':
|
130
|
echo $lang['strconstraints'];
|
131
|
break;
|
132
|
case 'TRIGGER':
|
133
|
echo $lang['strtriggers'];
|
134
|
break;
|
135
|
case 'RULETABLE':
|
136
|
case 'RULEVIEW':
|
137
|
echo $lang['strrules'];
|
138
|
break;
|
139
|
case 'FUNCTION':
|
140
|
echo $lang['strfunctions'];
|
141
|
break;
|
142
|
case 'TYPE':
|
143
|
echo $lang['strtypes'];
|
144
|
break;
|
145
|
case 'DOMAIN':
|
146
|
echo $lang['strdomains'];
|
147
|
break;
|
148
|
case 'OPERATOR':
|
149
|
echo $lang['stroperators'];
|
150
|
break;
|
151
|
case 'CONVERSION':
|
152
|
echo $lang['strconversions'];
|
153
|
break;
|
154
|
case 'LANGUAGE':
|
155
|
echo $lang['strlanguages'];
|
156
|
break;
|
157
|
case 'AGGREGATE':
|
158
|
echo $lang['straggregates'];
|
159
|
break;
|
160
|
case 'OPCLASS':
|
161
|
echo $lang['stropclasses'];
|
162
|
break;
|
163
|
}
|
164
|
echo "</h3>";
|
165
|
echo "<ul>\n";
|
166
|
}
|
167
|
}
|
168
|
|
169
|
// Generate schema prefix
|
170
|
if ($data->hasSchemas())
|
171
|
$prefix = $rs->f['schemaname'] . '.';
|
172
|
else
|
173
|
$prefix = '';
|
174
|
|
175
|
switch ($curr) {
|
176
|
case 'SCHEMA':
|
177
|
echo "<li><a href=\"database.php?{$misc->href}\">", _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
178
|
break;
|
179
|
case 'TABLE':
|
180
|
echo "<li><a href=\"tblproperties.php?{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&table=",
|
181
|
urlencode($rs->f['name']), "\">", $misc->printVal($prefix), _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
182
|
break;
|
183
|
case 'VIEW':
|
184
|
echo "<li><a href=\"views.php?action=properties&{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&view=",
|
185
|
urlencode($rs->f['name']), "\">", $misc->printVal($prefix), _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
186
|
break;
|
187
|
case 'SEQUENCE':
|
188
|
echo "<li><a href=\"sequences.php?action=properties&{$misc->href}&schema=", urlencode($rs->f['schemaname']),
|
189
|
"&sequence=", urlencode($rs->f['name']), "\">", $misc->printVal($prefix), _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
190
|
break;
|
191
|
case 'COLUMNTABLE':
|
192
|
echo "<li><a href=\"tblproperties.php?{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&table=",
|
193
|
urlencode($rs->f['relname']), "&column=", urlencode($rs->f['name']), "&action=properties\">",
|
194
|
$misc->printVal($prefix), $misc->printVal($rs->f['relname']), '.', _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
195
|
break;
|
196
|
case 'COLUMNVIEW':
|
197
|
echo "<li><a href=\"viewproperties.php?{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&view=",
|
198
|
urlencode($rs->f['relname']), "&column=", urlencode($rs->f['name']), "&action=properties\">",
|
199
|
$misc->printVal($prefix), $misc->printVal($rs->f['relname']), '.', _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
200
|
break;
|
201
|
case 'INDEX':
|
202
|
echo "<li><a href=\"indexes.php?{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&table=",
|
203
|
urlencode($rs->f['relname']), "\">",
|
204
|
$misc->printVal($prefix), $misc->printVal($rs->f['relname']), '.', _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
205
|
break;
|
206
|
case 'CONSTRAINTTABLE':
|
207
|
echo "<li><a href=\"constraints.php?{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&table=",
|
208
|
urlencode($rs->f['relname']), "\">",
|
209
|
$misc->printVal($prefix), $misc->printVal($rs->f['relname']), '.', _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
210
|
break;
|
211
|
case 'CONSTRAINTDOMAIN':
|
212
|
echo "<li><a href=\"domains.php?action=properties&{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&domain=",
|
213
|
urlencode($rs->f['relname']), "\">",
|
214
|
$misc->printVal($prefix), $misc->printVal($rs->f['relname']), '.', _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
215
|
break;
|
216
|
case 'TRIGGER':
|
217
|
echo "<li><a href=\"triggers.php?{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&table=",
|
218
|
urlencode($rs->f['relname']), "\">",
|
219
|
$misc->printVal($prefix), $misc->printVal($rs->f['relname']), '.', _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
220
|
break;
|
221
|
case 'RULETABLE':
|
222
|
echo "<li><a href=\"rules.php?{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&reltype=table&relation=",
|
223
|
urlencode($rs->f['relname']), "\">",
|
224
|
$misc->printVal($prefix), $misc->printVal($rs->f['relname']), '.', _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
225
|
break;
|
226
|
case 'RULEVIEW':
|
227
|
echo "<li><a href=\"rules.php?{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&reltype=view&relation=",
|
228
|
urlencode($rs->f['relname']), "\">",
|
229
|
$misc->printVal($prefix), $misc->printVal($rs->f['relname']), '.', _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
230
|
break;
|
231
|
case 'FUNCTION':
|
232
|
echo "<li><a href=\"functions.php?action=properties&{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&function=",
|
233
|
urlencode($rs->f['name']), "&function_oid=", urlencode($rs->f['oid']), "\">",
|
234
|
$misc->printVal($prefix), _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
235
|
break;
|
236
|
case 'TYPE':
|
237
|
echo "<li><a href=\"types.php?action=properties&{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&type=",
|
238
|
urlencode($rs->f['name']), "\">", $misc->printVal($prefix), _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
239
|
break;
|
240
|
case 'DOMAIN':
|
241
|
echo "<li><a href=\"domains.php?action=properties&{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&domain=",
|
242
|
urlencode($rs->f['name']), "\">", $misc->printVal($prefix), _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
243
|
break;
|
244
|
case 'OPERATOR':
|
245
|
echo "<li><a href=\"operators.php?{$misc->href}&schema=", urlencode($rs->f['schemaname']), "&operator=",
|
246
|
urlencode($rs->f['name']), "\">", $misc->printVal($prefix), _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
247
|
break;
|
248
|
case 'CONVERSION':
|
249
|
echo "<li><a href=\"conversions.php?{$misc->href}&schema=", urlencode($rs->f['schemaname']),
|
250
|
"\">", $misc->printVal($prefix), _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
251
|
break;
|
252
|
case 'LANGUAGE':
|
253
|
echo "<li><a href=\"languages.php?{$misc->href}\">", _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
254
|
break;
|
255
|
case 'AGGREGATE':
|
256
|
echo "<li><a href=\"aggregates.php?{$misc->href}&schema=", urlencode($rs->f['schemaname']), "\">",
|
257
|
$misc->printVal($prefix), _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
258
|
break;
|
259
|
case 'OPCLASS':
|
260
|
echo "<li><a href=\"opclasses.php?{$misc->href}&schema=", urlencode($rs->f['schemaname']), "\">",
|
261
|
$misc->printVal($prefix), _highlight($misc->printVal($rs->f['name']), $_GET['term']), "</a></li>\n";
|
262
|
break;
|
263
|
}
|
264
|
$rs->moveNext();
|
265
|
}
|
266
|
echo "</ul>\n";
|
267
|
|
268
|
echo "<p>", $rs->recordCount(), " ", $lang['strobjects'], "</p>\n";
|
269
|
}
|
270
|
else echo "<p>{$lang['strnoobjects']}</p>\n";
|
271
|
}
|
272
|
}
|
273
|
|
274
|
/**
|
275
|
* Displays options for database download
|
276
|
*/
|
277
|
function doExport($msg = '') {
|
278
|
global $data, $misc;
|
279
|
global $PHP_SELF, $lang;
|
280
|
|
281
|
$misc->printTrail('database');
|
282
|
$misc->printTabs('database','export');
|
283
|
$misc->printMsg($msg);
|
284
|
|
285
|
echo "<form action=\"dbexport.php\" method=\"post\">\n";
|
286
|
echo "<table>\n";
|
287
|
echo "<tr><th class=\"data\">{$lang['strformat']}</th><th class=\"data\" colspan=\"2\">{$lang['stroptions']}</th></tr>\n";
|
288
|
// Data only
|
289
|
echo "<tr><th class=\"data left\" rowspan=\"2\">";
|
290
|
echo "<input type=\"radio\" name=\"what\" value=\"dataonly\" checked=\"checked\" />{$lang['strdataonly']}</th>\n";
|
291
|
echo "<td>{$lang['strformat']}</td>\n";
|
292
|
echo "<td><select name=\"d_format\">\n";
|
293
|
echo "<option value=\"copy\">COPY</option>\n";
|
294
|
echo "<option value=\"sql\">SQL</option>\n";
|
295
|
echo "</select>\n</td>\n</tr>\n";
|
296
|
echo "<td>{$lang['stroids']}</td><td><input type=\"checkbox\" name=\"d_oids\" /></td>\n</tr>\n";
|
297
|
// Structure only
|
298
|
echo "<tr><th class=\"data left\"><input type=\"radio\" name=\"what\" value=\"structureonly\" />{$lang['strstructureonly']}</th>\n";
|
299
|
echo "<td>{$lang['strdrop']}</td><td><input type=\"checkbox\" name=\"s_clean\" /></td>\n</tr>\n";
|
300
|
// Structure and data
|
301
|
echo "<tr><th class=\"data left\" rowspan=\"3\">";
|
302
|
echo "<input type=\"radio\" name=\"what\" value=\"structureanddata\" />{$lang['strstructureanddata']}</th>\n";
|
303
|
echo "<td>{$lang['strformat']}</td>\n";
|
304
|
echo "<td><select name=\"sd_format\">\n";
|
305
|
echo "<option value=\"copy\">COPY</option>\n";
|
306
|
echo "<option value=\"sql\">SQL</option>\n";
|
307
|
echo "</select>\n</td>\n</tr>\n";
|
308
|
echo "<td>{$lang['strdrop']}</td><td><input type=\"checkbox\" name=\"sd_clean\" /></td>\n</tr>\n";
|
309
|
echo "<td>{$lang['stroids']}</td><td><input type=\"checkbox\" name=\"sd_oids\" /></td>\n</tr>\n";
|
310
|
echo "</table>\n";
|
311
|
|
312
|
echo "<h3>{$lang['stroptions']}</h3>\n";
|
313
|
echo "<p><input type=\"radio\" name=\"output\" value=\"show\" checked=\"checked\" />{$lang['strshow']}\n";
|
314
|
echo "<br/><input type=\"radio\" name=\"output\" value=\"download\" />{$lang['strdownload']}\n";
|
315
|
// MSIE cannot download gzip in SSL mode - it's just broken
|
316
|
if (!(strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') && isset($_SERVER['HTTPS']))) {
|
317
|
echo "<br /><input type=\"radio\" name=\"output\" value=\"gzipped\" />{$lang['strdownloadgzipped']}\n";
|
318
|
}
|
319
|
echo "</p>\n";
|
320
|
echo "<p><input type=\"hidden\" name=\"action\" value=\"export\" />\n";
|
321
|
echo "<input type=\"hidden\" name=\"subject\" value=\"database\" />\n";
|
322
|
echo $misc->form;
|
323
|
echo "<input type=\"submit\" value=\"{$lang['strexport']}\" /></p>\n";
|
324
|
echo "</form>\n";
|
325
|
}
|
326
|
|
327
|
/**
|
328
|
* Show the current status of all database variables
|
329
|
*/
|
330
|
function doVariables() {
|
331
|
global $PHP_SELF, $data, $misc;
|
332
|
global $lang;
|
333
|
|
334
|
// Fetch the variables from the database
|
335
|
$variables = $data->getVariables();
|
336
|
|
337
|
$misc->printTrail('database');
|
338
|
$misc->printTabs('database','variables');
|
339
|
|
340
|
$columns = array(
|
341
|
'variable' => array(
|
342
|
'title' => $lang['strname'],
|
343
|
'field' => 'name',
|
344
|
),
|
345
|
'value' => array(
|
346
|
'title' => $lang['strsetting'],
|
347
|
'field' => 'setting',
|
348
|
),
|
349
|
);
|
350
|
|
351
|
$actions = array();
|
352
|
|
353
|
$misc->printTable($variables, $columns, $actions, $lang['strnodata']);
|
354
|
}
|
355
|
|
356
|
/**
|
357
|
* Show all current database connections and any queries they
|
358
|
* are running.
|
359
|
*/
|
360
|
function doProcesses($msg = '') {
|
361
|
global $PHP_SELF, $data, $misc;
|
362
|
global $lang;
|
363
|
|
364
|
// Fetch the processes from the database
|
365
|
$processes = $data->getProcesses($_REQUEST['database']);
|
366
|
|
367
|
$misc->printTrail('database');
|
368
|
$misc->printTabs('database','processes');
|
369
|
$misc->printMsg($msg);
|
370
|
|
371
|
$columns = array(
|
372
|
'user' => array(
|
373
|
'title' => $lang['strusername'],
|
374
|
'field' => 'usename',
|
375
|
),
|
376
|
'process' => array(
|
377
|
'title' => $lang['strprocess'],
|
378
|
'field' => 'procpid',
|
379
|
),
|
380
|
'query' => array(
|
381
|
'title' => $lang['strsql'],
|
382
|
'field' => 'current_query',
|
383
|
),
|
384
|
'start_time' => array(
|
385
|
'title' => $lang['strstarttime'],
|
386
|
'field' => 'query_start',
|
387
|
),
|
388
|
);
|
389
|
|
390
|
if ($data->hasSignals()) {
|
391
|
$columns['actions'] = array('title' => $lang['stractions']);
|
392
|
|
393
|
$actions = array(
|
394
|
'cancel' => array(
|
395
|
'title' => $lang['strcancel'],
|
396
|
'url' => "{$PHP_SELF}?action=signal&signal=CANCEL&{$misc->href}&",
|
397
|
'vars' => array('procpid' => 'procpid')
|
398
|
)
|
399
|
);
|
400
|
}
|
401
|
else $actions = array();
|
402
|
|
403
|
// Remove query start time for <7.4
|
404
|
if (!isset($processes->f['query_start'])) unset($columns['start_time']);
|
405
|
|
406
|
$misc->printTable($processes, $columns, $actions, $lang['strnodata']);
|
407
|
}
|
408
|
|
409
|
/**
|
410
|
* Allow database administration and tuning tasks
|
411
|
*/
|
412
|
function doAdmin($action = '', $msg = '') {
|
413
|
global $PHP_SELF, $data, $misc;
|
414
|
global $lang;
|
415
|
switch ($action) {
|
416
|
case 'vacuum':
|
417
|
$status = $data->vacuumDB('', isset($_REQUEST['vacuum_analyze']), isset($_REQUEST['vacuum_full']), isset($_REQUEST['vacuum_freeze']) );
|
418
|
if ($status == 0) doAdmin('', $lang['strvacuumgood']);
|
419
|
else doAdmin('', $lang['strvacuumbad']);
|
420
|
break;
|
421
|
case 'analyze':
|
422
|
$status = $data->analyzeDB();
|
423
|
if ($status == 0) doAdmin('', $lang['stranalyzegood']);
|
424
|
else doAdmin('', $lang['stranalyzebad']);
|
425
|
break;
|
426
|
case 'recluster':
|
427
|
$status = $data->recluster();
|
428
|
if ($status == 0) doAdmin('', $lang['strclusteredgood']);
|
429
|
else doAdmin('', $lang['strclusteredbad']);
|
430
|
break;
|
431
|
case 'reindex';
|
432
|
$status = $data->reindex('DATABASE', $_REQUEST['database'], isset($_REQUEST['reindex_force']));
|
433
|
if ($status == 0) doAdmin('', $lang['strreindexgood']);
|
434
|
else doAdmin('', $lang['strreindexbad']);
|
435
|
break;
|
436
|
default:
|
437
|
$misc->printTrail('database');
|
438
|
$misc->printTabs('database','admin');
|
439
|
$misc->printMsg($msg);
|
440
|
|
441
|
// Vacuum
|
442
|
echo "<form name=\"adminfrm\" id=\"adminfrm\" action=\"{$PHP_SELF}\" method=\"post\">\n";
|
443
|
echo "<h3>";
|
444
|
$misc->printHelp($lang['strvacuum'],'pg.admin.vacuum');
|
445
|
echo "</h3>\n";
|
446
|
echo "<input type=\"checkbox\" id=\"vacuum_analyze\" name=\"vacuum_analyze\" />{$lang['stranalyze']}<br />\n";
|
447
|
if ($data->hasFullVacuum()) {
|
448
|
echo "<input type=\"checkbox\" id=\"vacuum_full\" name=\"vacuum_full\" />{$lang['strfull']}<br />\n";
|
449
|
echo "<input type=\"checkbox\" id=\"vacuum_freeze\" name=\"vacuum_freeze\" />{$lang['strfreeze']}<br />\n";
|
450
|
}
|
451
|
echo "<input type=\"submit\" value=\"{$lang['strvacuum']}\" />\n";
|
452
|
echo "<input type=\"hidden\" name=\"action\" value=\"vacuum\" />\n";
|
453
|
echo $misc->form;
|
454
|
echo "</form>\n";
|
455
|
|
456
|
// Analyze
|
457
|
echo "<form name=\"adminfrm\" id=\"adminfrm\" action=\"{$PHP_SELF}\" method=\"post\">\n";
|
458
|
echo "<h3>";
|
459
|
$misc->printHelp($lang['stranalyze'],'pg.admin.analyze');
|
460
|
echo "</h3>\n";
|
461
|
echo "<input type=\"submit\" value=\"{$lang['stranalyze']}\" />\n";
|
462
|
echo "<input type=\"hidden\" name=\"action\" value=\"analyze\" />\n";
|
463
|
echo $misc->form;
|
464
|
echo "</form>\n";
|
465
|
|
466
|
// Recluster
|
467
|
if ($data->hasRecluster()){
|
468
|
echo "<form name=\"adminfrm\" id=\"adminfrm\" action=\"{$PHP_SELF}\" method=\"post\">\n";
|
469
|
echo "<h3>";
|
470
|
$misc->printHelp($lang['strclusterindex'],'pg.index.cluster');
|
471
|
echo "</h3>\n";
|
472
|
echo "<input type=\"submit\" value=\"{$lang['strclusterindex']}\" />\n";
|
473
|
echo "<input type=\"hidden\" name=\"action\" value=\"recluster\" />\n";
|
474
|
echo $misc->form;
|
475
|
echo "</form>\n";
|
476
|
}
|
477
|
|
478
|
// Reindex
|
479
|
echo "<form name=\"adminfrm\" id=\"adminfrm\" action=\"{$PHP_SELF}\" method=\"post\">\n";
|
480
|
echo "<h3>";
|
481
|
$misc->printHelp($lang['strreindex'],'pg.index.reindex');
|
482
|
echo "</h3>\n";
|
483
|
echo "<input type=\"checkbox\" id=\"reindex_force\" name=\"reindex_force\" />{$lang['strforce']}<br />\n";
|
484
|
echo "<input type=\"submit\" value=\"{$lang['strreindex']}\" />\n";
|
485
|
echo "<input type=\"hidden\" name=\"action\" value=\"reindex\" />\n";
|
486
|
echo $misc->form;
|
487
|
echo "</form>\n";
|
488
|
break;
|
489
|
}
|
490
|
}
|
491
|
|
492
|
/**
|
493
|
* Allow execution of arbitrary SQL statements on a database
|
494
|
*/
|
495
|
function doSQL() {
|
496
|
global $PHP_SELF, $data, $misc;
|
497
|
global $lang;
|
498
|
|
499
|
if (!isset($_REQUEST['query'])) $_REQUEST['query'] = '';
|
500
|
|
501
|
$misc->printTrail('database');
|
502
|
$misc->printTabs('database','sql');
|
503
|
|
504
|
echo "<p>{$lang['strentersql']}</p>\n";
|
505
|
echo "<form action=\"sql.php\" method=\"post\" enctype=\"multipart/form-data\">\n";
|
506
|
echo "<p>{$lang['strsql']}<br />\n";
|
507
|
echo "<textarea style=\"width:100%;\" rows=\"20\" cols=\"50\" name=\"query\">",
|
508
|
htmlspecialchars($_REQUEST['query']), "</textarea>\n";
|
509
|
|
510
|
// Check that file uploads are enabled
|
511
|
if (ini_get('file_uploads')) {
|
512
|
// Don't show upload option if max size of uploads is zero
|
513
|
$max_size = $misc->inisizeToBytes(ini_get('upload_max_filesize'));
|
514
|
if (is_double($max_size) && $max_size > 0) {
|
515
|
echo "<br /><br /><input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"{$max_size}\" />\n";
|
516
|
echo " {$lang['struploadscript']} <input name=\"script\" type=\"file\" /></p>\n";
|
517
|
}
|
518
|
}
|
519
|
else echo "</p>\n";
|
520
|
|
521
|
echo "<input type=\"checkbox\" name=\"paginate\"", (isset($_REQUEST['paginate']) ? ' checked="checked"' : ''), " /> {$lang['strpaginate']}\n";
|
522
|
echo "<br />\n";
|
523
|
echo "<p><input type=\"submit\" value=\"{$lang['strrun']}\" />\n";
|
524
|
if ($data->hasFullExplain()) {
|
525
|
echo "<input type=\"submit\" name=\"explain\" value=\"{$lang['strexplain']}\" />\n";
|
526
|
echo "<input type=\"submit\" name=\"explain_analyze\" value=\"{$lang['strexplainanalyze']}\" />\n";
|
527
|
}
|
528
|
echo "<input type=\"reset\" value=\"{$lang['strreset']}\" /></p>\n";
|
529
|
|
530
|
echo $misc->form;
|
531
|
|
532
|
echo "</form>\n";
|
533
|
|
534
|
// Default focus
|
535
|
$misc->setFocus('forms[0].query');
|
536
|
}
|
537
|
|
538
|
function doTree() {
|
539
|
global $misc, $data, $lang, $PHP_SELF, $slony;
|
540
|
|
541
|
$reqvars = $misc->getRequestVars('database');
|
542
|
|
543
|
$tabs = $misc->getNavTabs('database');
|
544
|
|
545
|
$items = $misc->adjustTabsForTree($tabs);
|
546
|
|
547
|
$attrs = array(
|
548
|
'text' => noEscape(field('title')),
|
549
|
'icon' => field('icon', 'folder'),
|
550
|
'action' => url(field('url'),
|
551
|
$reqvars,
|
552
|
field('urlvars', array())
|
553
|
),
|
554
|
'branch' => url(field('url'),
|
555
|
$reqvars,
|
556
|
field('urlvars'),
|
557
|
array('action' => 'tree')
|
558
|
),
|
559
|
);
|
560
|
|
561
|
$misc->printTreeXML($items, $attrs);
|
562
|
|
563
|
exit;
|
564
|
}
|
565
|
|
566
|
if ($action == 'tree') doTree();
|
567
|
|
568
|
$misc->printHeader($lang['strschemas']);
|
569
|
$misc->printBody();
|
570
|
|
571
|
switch ($action) {
|
572
|
case 'find':
|
573
|
if (isset($_GET['term'])) doFind(false);
|
574
|
else doFind(true);
|
575
|
break;
|
576
|
case 'recluster':
|
577
|
case 'reindex':
|
578
|
case 'analyze':
|
579
|
case 'vacuum':
|
580
|
doAdmin($action);
|
581
|
break;
|
582
|
case 'admin':
|
583
|
doAdmin();
|
584
|
break;
|
585
|
case 'sql':
|
586
|
doSQL();
|
587
|
break;
|
588
|
case 'variables':
|
589
|
doVariables();
|
590
|
break;
|
591
|
case 'processes':
|
592
|
doProcesses();
|
593
|
break;
|
594
|
case 'export':
|
595
|
doExport();
|
596
|
break;
|
597
|
case 'signal':
|
598
|
doSignal();
|
599
|
break;
|
600
|
default:
|
601
|
doSQL();
|
602
|
break;
|
603
|
}
|
604
|
|
605
|
$misc->printFooter();
|
606
|
|
607
|
?>
|