1
|
|
|
<?php |
2
|
|
|
|
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* PHPPgAdmin v6.0.0-beta.30 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace PHPPgAdmin\Controller; |
8
|
|
|
|
9
|
|
|
use PHPPgAdmin\Decorators\Decorator; |
10
|
|
|
|
11
|
|
|
trait AdminTrait |
|
|
|
|
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Show confirmation of cluster and perform cluster. |
15
|
|
|
* |
16
|
|
|
* @param mixed $type |
|
|
|
|
17
|
|
|
* @param mixed $confirm |
|
|
|
|
18
|
|
|
*/ |
19
|
|
|
public function doCluster($type, $confirm = false) |
20
|
|
|
{ |
21
|
|
|
$this->script = ('database' == $type) ? 'database.php' : 'tables.php'; |
22
|
|
|
|
23
|
|
|
$script = $this->script; |
24
|
|
|
|
25
|
|
|
$lang = $this->lang; |
|
|
|
|
26
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
27
|
|
|
|
28
|
|
|
if (('table' == $type) && empty($_REQUEST['table']) && empty($_REQUEST['ma'])) { |
29
|
|
|
$this->doDefault($lang['strspecifytabletocluster']); |
30
|
|
|
|
31
|
|
|
return; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
if ($confirm) { |
35
|
|
|
if (isset($_REQUEST['ma'])) { |
36
|
|
|
$this->printTrail('schema'); |
37
|
|
|
$this->printTitle($lang['strclusterindex'], 'pg.index.cluster'); |
38
|
|
|
|
39
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/{$script}\" method=\"post\">\n"; |
40
|
|
|
foreach ($_REQUEST['ma'] as $v) { |
41
|
|
|
$a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES)); |
42
|
|
|
echo '<p>', sprintf($lang['strconfclustertable'], $this->misc->printVal($a['table'])), "</p>\n"; |
43
|
|
|
echo '<input type="hidden" name="table[]" value="', htmlspecialchars($a['table']), "\" />\n"; |
44
|
|
|
} |
45
|
|
|
} // END if multi cluster |
46
|
|
|
else { |
|
|
|
|
47
|
|
|
$this->printTrail($type); |
48
|
|
|
$this->printTitle($lang['strclusterindex'], 'pg.index.cluster'); |
49
|
|
|
|
50
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/{$script}\" method=\"post\">\n"; |
51
|
|
|
|
52
|
|
|
if ('table' == $type) { |
53
|
|
|
echo '<p>', sprintf($lang['strconfclustertable'], $this->misc->printVal($_REQUEST['object'])), "</p>\n"; |
54
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['object']), "\" />\n"; |
55
|
|
|
} else { |
56
|
|
|
echo '<p>', sprintf($lang['strconfclusterdatabase'], $this->misc->printVal($_REQUEST['object'])), "</p>\n"; |
57
|
|
|
echo "<input type=\"hidden\" name=\"table\" value=\"\" />\n"; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"cluster\" />\n"; |
61
|
|
|
|
62
|
|
|
echo $this->misc->form; |
63
|
|
|
|
64
|
|
|
echo "<input type=\"submit\" name=\"cluster\" value=\"{$lang['strcluster']}\" />\n"; //TODO |
65
|
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n"; |
66
|
|
|
echo "</form>\n"; |
67
|
|
|
} // END single cluster |
68
|
|
|
else { |
|
|
|
|
69
|
|
|
//If multi table cluster |
70
|
|
|
if ('table' == $type) { |
71
|
|
|
// cluster one or more table |
72
|
|
|
if (is_array($_REQUEST['table'])) { |
73
|
|
|
$msg = ''; |
74
|
|
|
foreach ($_REQUEST['table'] as $o) { |
75
|
|
|
$status = $data->clusterIndex($o); |
76
|
|
|
if (0 == $status) { |
77
|
|
|
$msg .= sprintf('%s: %s<br />', htmlentities($o, ENT_QUOTES, 'UTF-8'), $lang['strclusteredgood']); |
78
|
|
|
} else { |
79
|
|
|
$this->doDefault($type, sprintf('%s%s: %s<br />', $msg, htmlentities($o, ENT_QUOTES, 'UTF-8'), $lang['strclusteredbad'])); |
|
|
|
|
80
|
|
|
|
81
|
|
|
return; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
// Everything went fine, back to the Default page.... |
85
|
|
|
$this->doDefault($msg); |
86
|
|
|
} else { |
87
|
|
|
$status = $data->clusterIndex($_REQUEST['object']); |
88
|
|
|
if (0 == $status) { |
89
|
|
|
$this->doAdmin($type, $lang['strclusteredgood']); |
90
|
|
|
} else { |
91
|
|
|
$this->doAdmin($type, $lang['strclusteredbad']); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
} else { |
95
|
|
|
// Cluster all tables in database |
96
|
|
|
$status = $data->clusterIndex(); |
97
|
|
|
if (0 == $status) { |
98
|
|
|
$this->doAdmin($type, $lang['strclusteredgood']); |
99
|
|
|
} else { |
100
|
|
|
$this->doAdmin($type, $lang['strclusteredbad']); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Show confirmation of reindex and perform reindex. |
108
|
|
|
* |
109
|
|
|
* @param mixed $type |
|
|
|
|
110
|
|
|
* @param mixed $confirm |
|
|
|
|
111
|
|
|
*/ |
112
|
|
|
public function doReindex($type, $confirm = false) |
113
|
|
|
{ |
114
|
|
|
$this->script = ('database' == $type) ? 'database.php' : 'tables.php'; |
115
|
|
|
$script = $this->script; |
116
|
|
|
$this->misc = $this->misc; |
117
|
|
|
$lang = $this->lang; |
|
|
|
|
118
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
119
|
|
|
|
120
|
|
|
if (('table' == $type) && empty($_REQUEST['table']) && empty($_REQUEST['ma'])) { |
121
|
|
|
$this->doDefault($lang['strspecifytabletoreindex']); |
122
|
|
|
|
123
|
|
|
return; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
if ($confirm) { |
127
|
|
|
if (isset($_REQUEST['ma'])) { |
128
|
|
|
$this->printTrail('schema'); |
129
|
|
|
$this->printTitle($lang['strreindex'], 'pg.reindex'); |
130
|
|
|
|
131
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/{$script}\" method=\"post\">\n"; |
132
|
|
|
foreach ($_REQUEST['ma'] as $v) { |
133
|
|
|
$a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES)); |
134
|
|
|
echo '<p>', sprintf($lang['strconfreindextable'], $this->misc->printVal($a['table'])), "</p>\n"; |
135
|
|
|
echo '<input type="hidden" name="table[]" value="', htmlspecialchars($a['table']), "\" />\n"; |
136
|
|
|
} |
137
|
|
|
} // END if multi reindex |
138
|
|
|
else { |
|
|
|
|
139
|
|
|
$this->printTrail($type); |
140
|
|
|
$this->printTitle($lang['strreindex'], 'pg.reindex'); |
141
|
|
|
|
142
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/{$script}\" method=\"post\">\n"; |
143
|
|
|
|
144
|
|
|
if ('table' == $type) { |
145
|
|
|
echo '<p>', sprintf($lang['strconfreindextable'], $this->misc->printVal($_REQUEST['object'])), "</p>\n"; |
146
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['object']), "\" />\n"; |
147
|
|
|
} else { |
148
|
|
|
echo '<p>', sprintf($lang['strconfreindexdatabase'], $this->misc->printVal($_REQUEST['object'])), "</p>\n"; |
149
|
|
|
echo "<input type=\"hidden\" name=\"table\" value=\"\" />\n"; |
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"reindex\" />\n"; |
153
|
|
|
|
154
|
|
|
if ($data->hasForceReindex()) { |
155
|
|
|
echo "<p><input type=\"checkbox\" id=\"reindex_force\" name=\"reindex_force\" /><label for=\"reindex_force\">{$lang['strforce']}</label></p>\n"; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
echo $this->misc->form; |
159
|
|
|
|
160
|
|
|
echo "<input type=\"submit\" name=\"reindex\" value=\"{$lang['strreindex']}\" />\n"; //TODO |
161
|
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n"; |
162
|
|
|
echo "</form>\n"; |
163
|
|
|
} // END single reindex |
164
|
|
|
else { |
|
|
|
|
165
|
|
|
//If multi table reindex |
166
|
|
|
if (('table' == $type) && is_array($_REQUEST['table'])) { |
167
|
|
|
$msg = ''; |
168
|
|
|
foreach ($_REQUEST['table'] as $o) { |
169
|
|
|
$status = $data->reindex(strtoupper($type), $o, isset($_REQUEST['reindex_force'])); |
170
|
|
|
if (0 == $status) { |
171
|
|
|
$msg .= sprintf('%s: %s<br />', htmlentities($o, ENT_QUOTES, 'UTF-8'), $lang['strreindexgood']); |
172
|
|
|
} else { |
173
|
|
|
$this->doDefault($type, sprintf('%s%s: %s<br />', $msg, htmlentities($o, ENT_QUOTES, 'UTF-8'), $lang['strreindexbad'])); |
|
|
|
|
174
|
|
|
|
175
|
|
|
return; |
176
|
|
|
} |
177
|
|
|
} |
178
|
|
|
// Everything went fine, back to the Default page.... |
179
|
|
|
$this->misc->setReloadBrowser(true); |
180
|
|
|
$this->doDefault($msg); |
181
|
|
|
} else { |
182
|
|
|
$status = $data->reindex(strtoupper($type), $_REQUEST['object'], isset($_REQUEST['reindex_force'])); |
183
|
|
|
if (0 == $status) { |
184
|
|
|
$this->misc->setReloadBrowser(true); |
185
|
|
|
$this->doAdmin($type, $lang['strreindexgood']); |
186
|
|
|
} else { |
187
|
|
|
$this->doAdmin($type, $lang['strreindexbad']); |
188
|
|
|
} |
189
|
|
|
} |
190
|
|
|
} |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Show confirmation of analyze and perform analyze. |
195
|
|
|
* |
196
|
|
|
* @param mixed $type |
|
|
|
|
197
|
|
|
* @param mixed $confirm |
|
|
|
|
198
|
|
|
*/ |
199
|
|
|
public function doAnalyze($type, $confirm = false) |
200
|
|
|
{ |
201
|
|
|
$this->script = ('database' == $type) ? 'database.php' : 'tables.php'; |
202
|
|
|
|
203
|
|
|
$script = $this->script; |
204
|
|
|
|
205
|
|
|
$lang = $this->lang; |
|
|
|
|
206
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
207
|
|
|
|
208
|
|
|
if (('table' == $type) && empty($_REQUEST['table']) && empty($_REQUEST['ma'])) { |
209
|
|
|
$this->doDefault($lang['strspecifytabletoanalyze']); |
210
|
|
|
|
211
|
|
|
return; |
212
|
|
|
} |
213
|
|
|
|
214
|
|
|
if ($confirm) { |
215
|
|
|
if (isset($_REQUEST['ma'])) { |
216
|
|
|
$this->printTrail('schema'); |
217
|
|
|
$this->printTitle($lang['stranalyze'], 'pg.analyze'); |
218
|
|
|
|
219
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/{$script}\" method=\"post\">\n"; |
220
|
|
|
foreach ($_REQUEST['ma'] as $v) { |
221
|
|
|
$a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES)); |
222
|
|
|
\Kint::dump($a); |
223
|
|
|
echo '<p>', sprintf($lang['strconfanalyzetable'], $this->misc->printVal($a['table'])), "</p>\n"; |
224
|
|
|
echo '<input type="hidden" name="table[]" value="', htmlspecialchars($a['table']), "\" />\n"; |
225
|
|
|
} |
226
|
|
|
} // END if multi analyze |
227
|
|
|
else { |
|
|
|
|
228
|
|
|
$this->printTrail($type); |
229
|
|
|
$this->printTitle($lang['stranalyze'], 'pg.analyze'); |
230
|
|
|
|
231
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/{$script}\" method=\"post\">\n"; |
232
|
|
|
|
233
|
|
|
if ('table' == $type) { |
234
|
|
|
echo '<p>', sprintf($lang['strconfanalyzetable'], $this->misc->printVal($_REQUEST['object'])), "</p>\n"; |
235
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['object']), "\" />\n"; |
236
|
|
|
} else { |
237
|
|
|
echo '<p>', sprintf($lang['strconfanalyzedatabase'], $this->misc->printVal($_REQUEST['object'])), "</p>\n"; |
238
|
|
|
echo "<input type=\"hidden\" name=\"table\" value=\"\" />\n"; |
239
|
|
|
} |
240
|
|
|
} |
241
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"analyze\" />\n"; |
242
|
|
|
echo $this->misc->form; |
243
|
|
|
|
244
|
|
|
echo "<input type=\"submit\" name=\"analyze\" value=\"{$lang['stranalyze']}\" />\n"; //TODO |
245
|
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n"; |
246
|
|
|
echo "</form>\n"; |
247
|
|
|
} // END single analyze |
248
|
|
|
else { |
|
|
|
|
249
|
|
|
//If multi table analyze |
250
|
|
|
if (('table' == $type) && is_array($_REQUEST['table'])) { |
251
|
|
|
$msg = ''; |
252
|
|
|
foreach ($_REQUEST['table'] as $o) { |
253
|
|
|
$status = $data->analyzeDB($o); |
254
|
|
|
if (0 == $status) { |
255
|
|
|
$msg .= sprintf('%s: %s<br />', htmlentities($o, ENT_QUOTES, 'UTF-8'), $lang['stranalyzegood']); |
256
|
|
|
} else { |
257
|
|
|
$this->doDefault($type, sprintf('%s%s: %s<br />', $msg, htmlentities($o, ENT_QUOTES, 'UTF-8'), $lang['stranalyzebad'])); |
|
|
|
|
258
|
|
|
|
259
|
|
|
return; |
260
|
|
|
} |
261
|
|
|
} |
262
|
|
|
// Everything went fine, back to the Default page.... |
263
|
|
|
$this->misc->setReloadBrowser(true); |
264
|
|
|
$this->doDefault($msg); |
265
|
|
|
} else { |
266
|
|
|
//we must pass table here. When empty, analyze the whole db |
267
|
|
|
$status = $data->analyzeDB($_REQUEST['table']); |
268
|
|
|
if (0 == $status) { |
269
|
|
|
$this->misc->setReloadBrowser(true); |
270
|
|
|
$this->doAdmin($type, $lang['stranalyzegood']); |
271
|
|
|
} else { |
272
|
|
|
$this->doAdmin($type, $lang['stranalyzebad']); |
273
|
|
|
} |
274
|
|
|
} |
275
|
|
|
} |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
/** |
279
|
|
|
* Show confirmation of vacuum and perform actual vacuum. |
280
|
|
|
* |
281
|
|
|
* @param mixed $type |
|
|
|
|
282
|
|
|
* @param mixed $confirm |
|
|
|
|
283
|
|
|
*/ |
284
|
|
|
public function doVacuum($type, $confirm = false) |
285
|
|
|
{ |
286
|
|
|
$script = ('database' == $type) ? 'database.php' : 'tables.php'; |
287
|
|
|
|
288
|
|
|
$lang = $this->lang; |
|
|
|
|
289
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
290
|
|
|
|
291
|
|
|
if (('table' == $type) && empty($_REQUEST['table']) && empty($_REQUEST['ma'])) { |
292
|
|
|
$this->doDefault($lang['strspecifytabletovacuum']); |
293
|
|
|
|
294
|
|
|
return; |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
if ($confirm) { |
298
|
|
|
if (isset($_REQUEST['ma'])) { |
299
|
|
|
$this->printTrail('schema'); |
300
|
|
|
$this->printTitle($lang['strvacuum'], 'pg.vacuum'); |
301
|
|
|
|
302
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/{$script}\" method=\"post\">\n"; |
303
|
|
|
foreach ($_REQUEST['ma'] as $v) { |
304
|
|
|
$a = unserialize(htmlspecialchars_decode($v, ENT_QUOTES)); |
305
|
|
|
echo '<p>', sprintf($lang['strconfvacuumtable'], $this->misc->printVal($a['table'])), "</p>\n"; |
306
|
|
|
echo '<input type="hidden" name="table[]" value="', htmlspecialchars($a['table']), "\" />\n"; |
307
|
|
|
} |
308
|
|
|
} else { |
309
|
|
|
// END if multi vacuum |
310
|
|
|
$this->printTrail($type); |
311
|
|
|
$this->printTitle($lang['strvacuum'], 'pg.vacuum'); |
312
|
|
|
|
313
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/{$script}\" method=\"post\">\n"; |
314
|
|
|
|
315
|
|
|
if ('table' == $type) { |
316
|
|
|
echo '<p>', sprintf($lang['strconfvacuumtable'], $this->misc->printVal($_REQUEST['object'])), "</p>\n"; |
317
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['object']), "\" />\n"; |
318
|
|
|
} else { |
319
|
|
|
echo '<p>', sprintf($lang['strconfvacuumdatabase'], $this->misc->printVal($_REQUEST['object'])), "</p>\n"; |
320
|
|
|
echo "<input type=\"hidden\" name=\"table\" value=\"\" />\n"; |
321
|
|
|
} |
322
|
|
|
} |
323
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"vacuum\" />\n"; |
324
|
|
|
echo $this->misc->form; |
325
|
|
|
echo "<p><input type=\"checkbox\" id=\"vacuum_full\" name=\"vacuum_full\" /> <label for=\"vacuum_full\">{$lang['strfull']}</label></p>\n"; |
326
|
|
|
echo "<p><input type=\"checkbox\" id=\"vacuum_analyze\" name=\"vacuum_analyze\" /> <label for=\"vacuum_analyze\">{$lang['stranalyze']}</label></p>\n"; |
327
|
|
|
echo "<p><input type=\"checkbox\" id=\"vacuum_freeze\" name=\"vacuum_freeze\" /> <label for=\"vacuum_freeze\">{$lang['strfreeze']}</label></p>\n"; |
328
|
|
|
echo "<input type=\"submit\" name=\"vacuum\" value=\"{$lang['strvacuum']}\" />\n"; |
329
|
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n"; |
330
|
|
|
echo "</form>\n"; |
331
|
|
|
} // END single vacuum |
332
|
|
|
else { |
|
|
|
|
333
|
|
|
//If multi drop |
334
|
|
|
if (is_array($_REQUEST['table'])) { |
335
|
|
|
$msg = ''; |
336
|
|
|
foreach ($_REQUEST['table'] as $t) { |
337
|
|
|
$status = $data->vacuumDB($t, isset($_REQUEST['vacuum_analyze']), isset($_REQUEST['vacuum_full']), isset($_REQUEST['vacuum_freeze'])); |
338
|
|
|
if (0 == $status) { |
339
|
|
|
$msg .= sprintf('%s: %s<br />', htmlentities($t, ENT_QUOTES, 'UTF-8'), $lang['strvacuumgood']); |
340
|
|
|
} else { |
341
|
|
|
$this->doDefault($type, sprintf('%s%s: %s<br />', $msg, htmlentities($t, ENT_QUOTES, 'UTF-8'), $lang['strvacuumbad'])); |
342
|
|
|
|
343
|
|
|
return; |
344
|
|
|
} |
345
|
|
|
} |
346
|
|
|
// Everything went fine, back to the Default page.... |
347
|
|
|
$this->misc->setReloadBrowser(true); |
348
|
|
|
$this->doDefault($msg); |
349
|
|
|
} else { |
350
|
|
|
//we must pass table here. When empty, vacuum the whole db |
351
|
|
|
$status = $data->vacuumDB($_REQUEST['table'], isset($_REQUEST['vacuum_analyze']), isset($_REQUEST['vacuum_full']), isset($_REQUEST['vacuum_freeze'])); |
352
|
|
|
if (0 == $status) { |
353
|
|
|
$this->misc->setReloadBrowser(true); |
354
|
|
|
$this->doAdmin($type, $lang['strvacuumgood']); |
355
|
|
|
} else { |
356
|
|
|
$this->doAdmin($type, $lang['strvacuumbad']); |
357
|
|
|
} |
358
|
|
|
} |
359
|
|
|
} |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
/** |
363
|
|
|
* Add or Edit autovacuum params and save them. |
364
|
|
|
* |
365
|
|
|
* @param mixed $type |
|
|
|
|
366
|
|
|
* @param mixed $confirm |
|
|
|
|
367
|
|
|
* @param mixed $msg |
|
|
|
|
368
|
|
|
*/ |
369
|
|
|
public function doEditAutovacuum($type, $confirm, $msg = '') |
370
|
|
|
{ |
371
|
|
|
$this->script = ('database' == $type) ? 'database.php' : 'tables.php'; |
372
|
|
|
$script = $this->script; |
|
|
|
|
373
|
|
|
|
374
|
|
|
$lang = $this->lang; |
|
|
|
|
375
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
376
|
|
|
|
377
|
|
|
if (empty($_REQUEST['table'])) { |
378
|
|
|
$this->doAdmin($type, '', $lang['strspecifyeditvacuumtable']); |
|
|
|
|
379
|
|
|
|
380
|
|
|
return; |
381
|
|
|
} |
382
|
|
|
|
383
|
|
|
$script = ('database' == $type) ? 'database.php' : 'tables.php'; |
384
|
|
|
|
385
|
|
|
if ($confirm) { |
386
|
|
|
$this->printTrail($type); |
387
|
|
|
$this->printTitle(sprintf($lang['streditvacuumtable'], $this->misc->printVal($_REQUEST['table']))); |
388
|
|
|
$this->printMsg(sprintf($msg, $this->misc->printVal($_REQUEST['table']))); |
389
|
|
|
|
390
|
|
|
if (empty($_REQUEST['table'])) { |
391
|
|
|
$this->doAdmin($type, '', $lang['strspecifyeditvacuumtable']); |
392
|
|
|
|
393
|
|
|
return; |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
$old_val = $data->getTableAutovacuum($_REQUEST['table']); |
397
|
|
|
$defaults = $data->getAutovacuum(); |
398
|
|
|
$old_val = $old_val->fields; |
399
|
|
|
|
400
|
|
|
if (isset($old_val['autovacuum_enabled']) and ('off' == $old_val['autovacuum_enabled'])) { |
401
|
|
|
$enabled = ''; |
402
|
|
|
$disabled = 'checked="checked"'; |
403
|
|
|
} else { |
404
|
|
|
$enabled = 'checked="checked"'; |
405
|
|
|
$disabled = ''; |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
if (!isset($old_val['autovacuum_vacuum_threshold'])) { |
409
|
|
|
$old_val['autovacuum_vacuum_threshold'] = ''; |
410
|
|
|
} |
411
|
|
|
|
412
|
|
|
if (!isset($old_val['autovacuum_vacuum_scale_factor'])) { |
413
|
|
|
$old_val['autovacuum_vacuum_scale_factor'] = ''; |
414
|
|
|
} |
415
|
|
|
|
416
|
|
|
if (!isset($old_val['autovacuum_analyze_threshold'])) { |
417
|
|
|
$old_val['autovacuum_analyze_threshold'] = ''; |
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
if (!isset($old_val['autovacuum_analyze_scale_factor'])) { |
421
|
|
|
$old_val['autovacuum_analyze_scale_factor'] = ''; |
422
|
|
|
} |
423
|
|
|
|
424
|
|
|
if (!isset($old_val['autovacuum_vacuum_cost_delay'])) { |
425
|
|
|
$old_val['autovacuum_vacuum_cost_delay'] = ''; |
426
|
|
|
} |
427
|
|
|
|
428
|
|
|
if (!isset($old_val['autovacuum_vacuum_cost_limit'])) { |
429
|
|
|
$old_val['autovacuum_vacuum_cost_limit'] = ''; |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/{$script}\" method=\"post\">\n"; |
433
|
|
|
echo $this->misc->form; |
434
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"editautovac\" />\n"; |
435
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), "\" />\n"; |
436
|
|
|
|
437
|
|
|
echo "<br />\n<br />\n<table>\n"; |
438
|
|
|
echo "\t<tr><td> </td>\n"; |
439
|
|
|
echo "<th class=\"data\">{$lang['strnewvalues']}</th><th class=\"data\">{$lang['strdefaultvalues']}</th></tr>\n"; |
440
|
|
|
echo "\t<tr><th class=\"data left\">{$lang['strenable']}</th>\n"; |
441
|
|
|
echo "<td class=\"data1\">\n"; |
442
|
|
|
echo "<label for=\"on\">on</label><input type=\"radio\" name=\"autovacuum_enabled\" id=\"on\" value=\"on\" {$enabled} />\n"; |
443
|
|
|
echo "<label for=\"off\">off</label><input type=\"radio\" name=\"autovacuum_enabled\" id=\"off\" value=\"off\" {$disabled} /></td>\n"; |
444
|
|
|
echo "<th class=\"data left\">{$defaults['autovacuum']}</th></tr>\n"; |
445
|
|
|
echo "\t<tr><th class=\"data left\">{$lang['strvacuumbasethreshold']}</th>\n"; |
446
|
|
|
echo "<td class=\"data1\"><input type=\"text\" name=\"autovacuum_vacuum_threshold\" value=\"{$old_val['autovacuum_vacuum_threshold']}\" /></td>\n"; |
447
|
|
|
echo "<th class=\"data left\">{$defaults['autovacuum_vacuum_threshold']}</th></tr>\n"; |
448
|
|
|
echo "\t<tr><th class=\"data left\">{$lang['strvacuumscalefactor']}</th>\n"; |
449
|
|
|
echo "<td class=\"data1\"><input type=\"text\" name=\"autovacuum_vacuum_scale_factor\" value=\"{$old_val['autovacuum_vacuum_scale_factor']}\" /></td>\n"; |
450
|
|
|
echo "<th class=\"data left\">{$defaults['autovacuum_vacuum_scale_factor']}</th></tr>\n"; |
451
|
|
|
echo "\t<tr><th class=\"data left\">{$lang['stranalybasethreshold']}</th>\n"; |
452
|
|
|
echo "<td class=\"data1\"><input type=\"text\" name=\"autovacuum_analyze_threshold\" value=\"{$old_val['autovacuum_analyze_threshold']}\" /></td>\n"; |
453
|
|
|
echo "<th class=\"data left\">{$defaults['autovacuum_analyze_threshold']}</th></tr>\n"; |
454
|
|
|
echo "\t<tr><th class=\"data left\">{$lang['stranalyzescalefactor']}</th>\n"; |
455
|
|
|
echo "<td class=\"data1\"><input type=\"text\" name=\"autovacuum_analyze_scale_factor\" value=\"{$old_val['autovacuum_analyze_scale_factor']}\" /></td>\n"; |
456
|
|
|
echo "<th class=\"data left\">{$defaults['autovacuum_analyze_scale_factor']}</th></tr>\n"; |
457
|
|
|
echo "\t<tr><th class=\"data left\">{$lang['strvacuumcostdelay']}</th>\n"; |
458
|
|
|
echo "<td class=\"data1\"><input type=\"text\" name=\"autovacuum_vacuum_cost_delay\" value=\"{$old_val['autovacuum_vacuum_cost_delay']}\" /></td>\n"; |
459
|
|
|
echo "<th class=\"data left\">{$defaults['autovacuum_vacuum_cost_delay']}</th></tr>\n"; |
460
|
|
|
echo "\t<tr><th class=\"data left\">{$lang['strvacuumcostlimit']}</th>\n"; |
461
|
|
|
echo "<td class=\"datat1\"><input type=\"text\" name=\"autovacuum_vacuum_cost_limit\" value=\"{$old_val['autovacuum_vacuum_cost_limit']}\" /></td>\n"; |
462
|
|
|
echo "<th class=\"data left\">{$defaults['autovacuum_vacuum_cost_limit']}</th></tr>\n"; |
463
|
|
|
echo "</table>\n"; |
464
|
|
|
echo '<br />'; |
465
|
|
|
echo '<br />'; |
466
|
|
|
echo "<input type=\"submit\" name=\"save\" value=\"{$lang['strsave']}\" />\n"; |
467
|
|
|
echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" /></p>\n"; |
468
|
|
|
|
469
|
|
|
echo "</form>\n"; |
470
|
|
|
} else { |
471
|
|
|
$status = $data->saveAutovacuum( |
472
|
|
|
$_REQUEST['table'], |
473
|
|
|
$_POST['autovacuum_enabled'], |
474
|
|
|
$_POST['autovacuum_vacuum_threshold'], |
475
|
|
|
$_POST['autovacuum_vacuum_scale_factor'], |
476
|
|
|
$_POST['autovacuum_analyze_threshold'], |
477
|
|
|
$_POST['autovacuum_analyze_scale_factor'], |
478
|
|
|
$_POST['autovacuum_vacuum_cost_delay'], |
479
|
|
|
$_POST['autovacuum_vacuum_cost_limit'] |
480
|
|
|
); |
481
|
|
|
|
482
|
|
|
if (0 == $status) { |
483
|
|
|
$this->doAdmin($type, '', sprintf($lang['strsetvacuumtablesaved'], $_REQUEST['table'])); |
484
|
|
|
} else { |
485
|
|
|
$this->doEditAutovacuum($type, true, $lang['strsetvacuumtablefail']); |
486
|
|
|
} |
487
|
|
|
} |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
/** |
491
|
|
|
* confirm drop autovacuum params for a table and drop it. |
|
|
|
|
492
|
|
|
* |
493
|
|
|
* @param mixed $type |
|
|
|
|
494
|
|
|
* @param mixed $confirm |
|
|
|
|
495
|
|
|
*/ |
496
|
|
|
public function doDropAutovacuum($type, $confirm) |
497
|
|
|
{ |
498
|
|
|
$this->script = ('database' == $type) ? 'database.php' : 'tables.php'; |
499
|
|
|
$script = $this->script; |
|
|
|
|
500
|
|
|
|
501
|
|
|
$lang = $this->lang; |
|
|
|
|
502
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
503
|
|
|
|
504
|
|
|
if (empty($_REQUEST['table'])) { |
505
|
|
|
$this->doAdmin($type, '', $lang['strspecifydelvacuumtable']); |
|
|
|
|
506
|
|
|
|
507
|
|
|
return; |
508
|
|
|
} |
509
|
|
|
|
510
|
|
|
if ($confirm) { |
511
|
|
|
$this->printTrail($type); |
512
|
|
|
$this->printTabs($type, 'admin'); |
513
|
|
|
|
514
|
|
|
$script = ('database' == $type) ? 'database.php' : 'tables.php'; |
515
|
|
|
|
516
|
|
|
printf( |
517
|
|
|
"<p>{$lang['strdelvacuumtable']}</p>\n", |
518
|
|
|
$this->misc->printVal("\"{$_GET['schema']}\".\"{$_GET['table']}\"") |
519
|
|
|
); |
520
|
|
|
|
521
|
|
|
echo "<form style=\"float: left\" action=\"{$script}\" method=\"post\">\n"; |
522
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"delautovac\" />\n"; |
523
|
|
|
echo $this->misc->form; |
524
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), "\" />\n"; |
525
|
|
|
echo '<input type="hidden" name="rel" value="', htmlspecialchars(serialize([$_REQUEST['schema'], $_REQUEST['table']])), "\" />\n"; |
526
|
|
|
echo "<input type=\"submit\" name=\"yes\" value=\"{$lang['stryes']}\" />\n"; |
527
|
|
|
echo "</form>\n"; |
528
|
|
|
|
529
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/{$script}\" method=\"post\">\n"; |
530
|
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"admin\" />\n"; |
531
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['table']), "\" />\n"; |
532
|
|
|
echo $this->misc->form; |
533
|
|
|
echo "<input type=\"submit\" name=\"no\" value=\"{$lang['strno']}\" />\n"; |
534
|
|
|
echo "</form>\n"; |
535
|
|
|
} else { |
536
|
|
|
$status = $data->dropAutovacuum($_POST['table']); |
537
|
|
|
|
538
|
|
|
if (0 == $status) { |
539
|
|
|
$this->doAdmin($type, '', sprintf($lang['strvacuumtablereset'], $this->misc->printVal($_POST['table']))); |
540
|
|
|
} else { |
541
|
|
|
$this->doAdmin($type, '', sprintf($lang['strdelvacuumtablefail'], $this->misc->printVal($_POST['table']))); |
542
|
|
|
} |
543
|
|
|
} |
544
|
|
|
} |
545
|
|
|
|
546
|
|
|
/** |
547
|
|
|
* database/table administration and tuning tasks. |
|
|
|
|
548
|
|
|
* |
549
|
|
|
* $Id: admin.php |
550
|
|
|
* |
551
|
|
|
* @param mixed $type |
|
|
|
|
552
|
|
|
* @param mixed $msg |
|
|
|
|
553
|
|
|
*/ |
554
|
|
|
public function doAdmin($type, $msg = '') |
555
|
|
|
{ |
556
|
|
|
$this->script = ('database' == $type) ? 'database.php' : 'tables.php'; |
557
|
|
|
|
558
|
|
|
$script = $this->script; |
559
|
|
|
|
560
|
|
|
$lang = $this->lang; |
|
|
|
|
561
|
|
|
|
562
|
|
|
$data = $this->misc->getDatabaseAccessor(); |
563
|
|
|
|
564
|
|
|
$this->printTrail($type); |
565
|
|
|
$this->printTabs($type, 'admin'); |
566
|
|
|
$this->printMsg($msg); |
567
|
|
|
|
568
|
|
|
if ('database' == $type) { |
569
|
|
|
printf("<p>{$lang['stradminondatabase']}</p>\n", $this->misc->printVal($_REQUEST['object'])); |
570
|
|
|
} else { |
571
|
|
|
printf("<p>{$lang['stradminontable']}</p>\n", $this->misc->printVal($_REQUEST['object'])); |
572
|
|
|
} |
573
|
|
|
|
574
|
|
|
echo "<table style=\"width: 50%\">\n"; |
575
|
|
|
echo "<tr>\n"; |
576
|
|
|
echo '<th class="data">'; |
577
|
|
|
$this->misc->printHelp($lang['strvacuum'], 'pg.admin.vacuum')."</th>\n"; |
578
|
|
|
echo '</th>'; |
579
|
|
|
echo '<th class="data">'; |
580
|
|
|
$this->misc->printHelp($lang['stranalyze'], 'pg.admin.analyze'); |
581
|
|
|
echo '</th>'; |
582
|
|
|
if ($data->hasRecluster()) { |
583
|
|
|
echo '<th class="data">'; |
584
|
|
|
$this->misc->printHelp($lang['strclusterindex'], 'pg.index.cluster'); |
585
|
|
|
echo '</th>'; |
586
|
|
|
} |
587
|
|
|
echo '<th class="data">'; |
588
|
|
|
$this->misc->printHelp($lang['strreindex'], 'pg.index.reindex'); |
589
|
|
|
echo '</th>'; |
590
|
|
|
echo '</tr>'; |
591
|
|
|
|
592
|
|
|
// Vacuum |
593
|
|
|
echo "<tr class=\"row1\">\n"; |
594
|
|
|
echo "<td style=\"text-align: center; vertical-align: bottom\">\n"; |
595
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/{$script}\" method=\"post\">\n"; |
596
|
|
|
|
597
|
|
|
echo "<p><input type=\"hidden\" name=\"action\" value=\"confirm_vacuum\" />\n"; |
598
|
|
|
echo $this->misc->form; |
599
|
|
|
if ('table' == $type) { |
600
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['object']), "\" />\n"; |
601
|
|
|
echo "<input type=\"hidden\" name=\"subject\" value=\"table\" />\n"; |
602
|
|
|
} |
603
|
|
|
echo "<input type=\"submit\" value=\"{$lang['strvacuum']}\" /></p>\n"; |
604
|
|
|
echo "</form>\n"; |
605
|
|
|
echo "</td>\n"; |
606
|
|
|
|
607
|
|
|
// Analyze |
608
|
|
|
echo "<td style=\"text-align: center; vertical-align: bottom\">\n"; |
609
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/{$script}\" method=\"post\">\n"; |
610
|
|
|
echo "<p><input type=\"hidden\" name=\"action\" value=\"confirm_analyze\" />\n"; |
611
|
|
|
echo $this->misc->form; |
612
|
|
|
if ('table' == $type) { |
613
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['object']), "\" />\n"; |
614
|
|
|
echo "<input type=\"hidden\" name=\"subject\" value=\"table\" />\n"; |
615
|
|
|
} |
616
|
|
|
echo "<input type=\"submit\" value=\"{$lang['stranalyze']}\" /></p>\n"; |
617
|
|
|
echo "</form>\n"; |
618
|
|
|
echo "</td>\n"; |
619
|
|
|
|
620
|
|
|
// Cluster |
621
|
|
|
if ($data->hasRecluster()) { |
622
|
|
|
$disabled = ''; |
623
|
|
|
echo "<td style=\"text-align: center; vertical-align: bottom\">\n"; |
624
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/{$script}\" method=\"post\">\n"; |
625
|
|
|
echo $this->misc->form; |
626
|
|
|
if ('table' == $type) { |
627
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['object']), "\" />\n"; |
628
|
|
|
echo "<input type=\"hidden\" name=\"subject\" value=\"table\" />\n"; |
629
|
|
|
if (!$data->alreadyClustered($_REQUEST['object'])) { |
630
|
|
|
$disabled = 'disabled="disabled" '; |
631
|
|
|
echo "{$lang['strnoclusteravailable']}<br />"; |
632
|
|
|
} |
633
|
|
|
} |
634
|
|
|
echo "<p><input type=\"hidden\" name=\"action\" value=\"confirm_cluster\" />\n"; |
635
|
|
|
echo "<input type=\"submit\" value=\"{$lang['strclusterindex']}\" ${disabled}/></p>\n"; |
636
|
|
|
echo "</form>\n"; |
637
|
|
|
echo "</td>\n"; |
638
|
|
|
} |
639
|
|
|
|
640
|
|
|
// Reindex |
641
|
|
|
echo "<td style=\"text-align: center; vertical-align: bottom\">\n"; |
642
|
|
|
echo '<form action="'.\SUBFOLDER."/src/views/{$script}\" method=\"post\">\n"; |
643
|
|
|
echo "<p><input type=\"hidden\" name=\"action\" value=\"confirm_reindex\" />\n"; |
644
|
|
|
echo $this->misc->form; |
645
|
|
|
if ('table' == $type) { |
646
|
|
|
echo '<input type="hidden" name="table" value="', htmlspecialchars($_REQUEST['object']), "\" />\n"; |
647
|
|
|
echo "<input type=\"hidden\" name=\"subject\" value=\"table\" />\n"; |
648
|
|
|
} |
649
|
|
|
echo "<input type=\"submit\" value=\"{$lang['strreindex']}\" /></p>\n"; |
650
|
|
|
echo "</form>\n"; |
651
|
|
|
echo "</td>\n"; |
652
|
|
|
echo "</tr>\n"; |
653
|
|
|
echo "</table>\n"; |
654
|
|
|
|
655
|
|
|
// Autovacuum |
656
|
|
|
if ($data->hasAutovacuum()) { |
657
|
|
|
// get defaults values for autovacuum |
658
|
|
|
$defaults = $data->getAutovacuum(); |
659
|
|
|
// Fetch the autovacuum properties from the database or table if != '' |
660
|
|
|
if ('table' == $type) { |
661
|
|
|
$autovac = $data->getTableAutovacuum($_REQUEST['table']); |
662
|
|
|
} else { |
663
|
|
|
$autovac = $data->getTableAutovacuum(); |
664
|
|
|
} |
665
|
|
|
|
666
|
|
|
echo "<br /><br /><h2>{$lang['strvacuumpertable']}</h2>"; |
667
|
|
|
echo '<p>'.(('on' == $defaults['autovacuum']) ? $lang['strturnedon'] : $lang['strturnedoff']).'</p>'; |
668
|
|
|
echo "<p class=\"message\">{$lang['strnotdefaultinred']}</p>"; |
669
|
|
|
|
670
|
|
|
$enlight = function ($f, $p) { |
671
|
|
|
if (isset($f[$p[0]]) and ($f[$p[0]] != $p[1])) { |
672
|
|
|
return '<span style="color:#F33;font-weight:bold">'.htmlspecialchars($f[$p[0]]).'</span>'; |
673
|
|
|
} |
674
|
|
|
|
675
|
|
|
return htmlspecialchars($p[1]); |
676
|
|
|
}; |
677
|
|
|
|
678
|
|
|
$columns = [ |
679
|
|
|
'namespace' => [ |
680
|
|
|
'title' => $lang['strschema'], |
681
|
|
|
'field' => Decorator::field('nspname'), |
682
|
|
|
'url' => \SUBFOLDER."/redirect/schema?{$this->misc->href}&", |
683
|
|
|
'vars' => ['schema' => 'nspname'], |
684
|
|
|
], |
685
|
|
|
'relname' => [ |
686
|
|
|
'title' => $lang['strtable'], |
687
|
|
|
'field' => Decorator::field('relname'), |
688
|
|
|
'url' => \SUBFOLDER."/redirect/table?{$this->misc->href}&", |
689
|
|
|
'vars' => ['table' => 'relname', 'schema' => 'nspname'], |
690
|
|
|
], |
691
|
|
|
'autovacuum_enabled' => [ |
692
|
|
|
'title' => $lang['strenabled'], |
693
|
|
|
'field' => Decorator::callback($enlight, ['autovacuum_enabled', $defaults['autovacuum']]), |
694
|
|
|
'type' => 'verbatim', |
695
|
|
|
], |
696
|
|
|
'autovacuum_vacuum_threshold' => [ |
697
|
|
|
'title' => $lang['strvacuumbasethreshold'], |
698
|
|
|
'field' => Decorator::callback($enlight, ['autovacuum_vacuum_threshold', $defaults['autovacuum_vacuum_threshold']]), |
699
|
|
|
'type' => 'verbatim', |
700
|
|
|
], |
701
|
|
|
'autovacuum_vacuum_scale_factor' => [ |
702
|
|
|
'title' => $lang['strvacuumscalefactor'], |
703
|
|
|
'field' => Decorator::callback($enlight, ['autovacuum_vacuum_scale_factor', $defaults['autovacuum_vacuum_scale_factor']]), |
704
|
|
|
'type' => 'verbatim', |
705
|
|
|
], |
706
|
|
|
'autovacuum_analyze_threshold' => [ |
707
|
|
|
'title' => $lang['stranalybasethreshold'], |
708
|
|
|
'field' => Decorator::callback($enlight, ['autovacuum_analyze_threshold', $defaults['autovacuum_analyze_threshold']]), |
709
|
|
|
'type' => 'verbatim', |
710
|
|
|
], |
711
|
|
|
'autovacuum_analyze_scale_factor' => [ |
712
|
|
|
'title' => $lang['stranalyzescalefactor'], |
713
|
|
|
'field' => Decorator::callback($enlight, ['autovacuum_analyze_scale_factor', $defaults['autovacuum_analyze_scale_factor']]), |
714
|
|
|
'type' => 'verbatim', |
715
|
|
|
], |
716
|
|
|
'autovacuum_vacuum_cost_delay' => [ |
717
|
|
|
'title' => $lang['strvacuumcostdelay'], |
718
|
|
|
'field' => Decorator::concat(Decorator::callback($enlight, ['autovacuum_vacuum_cost_delay', $defaults['autovacuum_vacuum_cost_delay']]), 'ms'), |
719
|
|
|
'type' => 'verbatim', |
720
|
|
|
], |
721
|
|
|
'autovacuum_vacuum_cost_limit' => [ |
722
|
|
|
'title' => $lang['strvacuumcostlimit'], |
723
|
|
|
'field' => Decorator::callback($enlight, ['autovacuum_vacuum_cost_limit', $defaults['autovacuum_vacuum_cost_limit']]), |
724
|
|
|
'type' => 'verbatim', |
725
|
|
|
], |
726
|
|
|
]; |
727
|
|
|
|
728
|
|
|
// Maybe we need to check permissions here? |
729
|
|
|
$columns['actions'] = ['title' => $lang['stractions']]; |
730
|
|
|
|
731
|
|
|
$actions = [ |
732
|
|
|
'edit' => [ |
733
|
|
|
'content' => $lang['stredit'], |
734
|
|
|
'attr' => [ |
735
|
|
|
'href' => [ |
736
|
|
|
'url' => $script, |
737
|
|
|
'urlvars' => [ |
738
|
|
|
'subject' => $type, |
739
|
|
|
'action' => 'confeditautovac', |
740
|
|
|
'schema' => Decorator::field('nspname'), |
741
|
|
|
'table' => Decorator::field('relname'), |
742
|
|
|
], |
743
|
|
|
], |
744
|
|
|
], |
745
|
|
|
], |
746
|
|
|
'delete' => [ |
747
|
|
|
'content' => $lang['strdelete'], |
748
|
|
|
'attr' => [ |
749
|
|
|
'href' => [ |
750
|
|
|
'url' => $script, |
751
|
|
|
'urlvars' => [ |
752
|
|
|
'subject' => $type, |
753
|
|
|
'action' => 'confdelautovac', |
754
|
|
|
'schema' => Decorator::field('nspname'), |
755
|
|
|
'table' => Decorator::field('relname'), |
756
|
|
|
], |
757
|
|
|
], |
758
|
|
|
], |
759
|
|
|
], |
760
|
|
|
]; |
761
|
|
|
|
762
|
|
|
if ('table' == $type) { |
763
|
|
|
unset($actions['edit']['vars']['schema'], |
|
|
|
|
764
|
|
|
$actions['delete']['vars']['schema'], |
765
|
|
|
$columns['namespace'], |
766
|
|
|
$columns['relname'] |
767
|
|
|
); |
768
|
|
|
} |
769
|
|
|
|
770
|
|
|
echo $this->printTable($autovac, $columns, $actions, 'admin-admin', $lang['strnovacuumconf']); |
771
|
|
|
|
772
|
|
|
if (('table' == $type) and (0 == $autovac->recordCount())) { |
773
|
|
|
echo '<br />'; |
774
|
|
|
echo "<a href=\"tables.php?action=confeditautovac&{$this->misc->href}&table=", htmlspecialchars($_REQUEST['table']) |
775
|
|
|
, "\">{$lang['straddvacuumtable']}</a>"; |
776
|
|
|
} |
777
|
|
|
} |
778
|
|
|
} |
779
|
|
|
|
780
|
|
|
public function adminActions($action, $type) |
|
|
|
|
781
|
|
|
{ |
782
|
|
|
if ('database' == $type) { |
783
|
|
|
$_REQUEST['object'] = $_REQUEST['database']; |
784
|
|
|
$this->script = 'database.php'; |
785
|
|
|
} else { |
786
|
|
|
// $_REQUEST['table'] is no set if we are in the schema page |
787
|
|
|
$_REQUEST['object'] = (isset($_REQUEST['table']) ? $_REQUEST['table'] : ''); |
788
|
|
|
$this->script = 'tables.php'; |
789
|
|
|
} |
790
|
|
|
|
791
|
|
|
$script = $this->script; |
|
|
|
|
792
|
|
|
|
793
|
|
|
switch ($action) { |
794
|
|
|
case 'confirm_cluster': |
795
|
|
|
$this->doCluster($type, true); |
796
|
|
|
|
797
|
|
|
break; |
798
|
|
|
case 'confirm_reindex': |
799
|
|
|
$this->doReindex($type, true); |
800
|
|
|
|
801
|
|
|
break; |
802
|
|
|
case 'confirm_analyze': |
803
|
|
|
$this->doAnalyze($type, true); |
804
|
|
|
|
805
|
|
|
break; |
806
|
|
|
case 'confirm_vacuum': |
807
|
|
|
$this->doVacuum($type, true); |
808
|
|
|
|
809
|
|
|
break; |
810
|
|
|
case 'cluster': |
811
|
|
|
if (isset($_POST['cluster'])) { |
812
|
|
|
$this->doCluster($type); |
813
|
|
|
} |
814
|
|
|
|
815
|
|
|
// if multi-action from table canceled: back to the schema default page |
816
|
|
|
elseif (('table' == $type) && is_array($_REQUEST['object'])) { |
|
|
|
|
817
|
|
|
$this->doDefault(); |
818
|
|
|
} else { |
819
|
|
|
$this->doAdmin($type); |
820
|
|
|
} |
821
|
|
|
|
822
|
|
|
break; |
823
|
|
|
case 'reindex': |
824
|
|
|
if (isset($_POST['reindex'])) { |
825
|
|
|
$this->doReindex($type); |
826
|
|
|
} |
827
|
|
|
|
828
|
|
|
// if multi-action from table canceled: back to the schema default page |
829
|
|
|
elseif (('table' == $type) && is_array($_REQUEST['object'])) { |
|
|
|
|
830
|
|
|
$this->doDefault(); |
831
|
|
|
} else { |
832
|
|
|
$this->doAdmin($type); |
833
|
|
|
} |
834
|
|
|
|
835
|
|
|
break; |
836
|
|
|
case 'analyze': |
837
|
|
|
if (isset($_POST['analyze'])) { |
838
|
|
|
$this->doAnalyze($type); |
839
|
|
|
} |
840
|
|
|
|
841
|
|
|
// if multi-action from table canceled: back to the schema default page |
842
|
|
|
elseif (('table' == $type) && is_array($_REQUEST['object'])) { |
|
|
|
|
843
|
|
|
$this->doDefault(); |
844
|
|
|
} else { |
845
|
|
|
$this->doAdmin($type); |
846
|
|
|
} |
847
|
|
|
|
848
|
|
|
break; |
849
|
|
|
case 'vacuum': |
850
|
|
|
if (isset($_POST['vacuum'])) { |
851
|
|
|
$this->doVacuum($type); |
852
|
|
|
} |
853
|
|
|
|
854
|
|
|
// if multi-action from table canceled: back to the schema default page |
855
|
|
|
elseif (('table' == $type) && is_array($_REQUEST['object'])) { |
|
|
|
|
856
|
|
|
$this->doDefault(); |
857
|
|
|
} else { |
858
|
|
|
$this->doAdmin($type); |
859
|
|
|
} |
860
|
|
|
|
861
|
|
|
break; |
862
|
|
|
case 'admin': |
863
|
|
|
$this->doAdmin($type); |
864
|
|
|
|
865
|
|
|
break; |
866
|
|
|
case 'confeditautovac': |
867
|
|
|
$this->doEditAutovacuum($type, true); |
868
|
|
|
|
869
|
|
|
break; |
870
|
|
|
case 'confdelautovac': |
871
|
|
|
$this->doDropAutovacuum($type, true); |
872
|
|
|
|
873
|
|
|
break; |
874
|
|
|
case 'confaddautovac': |
875
|
|
|
$this->// @scrutinizer ignore-call |
876
|
|
|
doAddAutovacuum(true); |
|
|
|
|
877
|
|
|
|
878
|
|
|
break; |
879
|
|
|
case 'editautovac': |
880
|
|
|
if (isset($_POST['save'])) { |
881
|
|
|
$this->doEditAutovacuum($type, false); |
882
|
|
|
} else { |
883
|
|
|
$this->doAdmin($type); |
884
|
|
|
} |
885
|
|
|
|
886
|
|
|
break; |
887
|
|
|
case 'delautovac': |
888
|
|
|
$this->doDropAutovacuum($type, false); |
889
|
|
|
|
890
|
|
|
break; |
891
|
|
|
default: |
892
|
|
|
return false; |
893
|
|
|
} |
894
|
|
|
|
895
|
|
|
return true; |
896
|
|
|
} |
897
|
|
|
|
898
|
|
|
abstract public function doDefault($msg = ''); |
|
|
|
|
899
|
|
|
|
900
|
|
|
abstract public function printTrail($trail = [], $do_print = true); |
|
|
|
|
901
|
|
|
|
902
|
|
|
abstract public function printTitle($title, $help = null, $do_print = true); |
|
|
|
|
903
|
|
|
|
904
|
|
|
abstract public function printMsg($msg, $do_print = true); |
|
|
|
|
905
|
|
|
|
906
|
|
|
abstract public function printTabs($tabs, $activetab, $do_print = true); |
|
|
|
|
907
|
|
|
|
908
|
|
|
abstract public function printTable(&$tabledata, &$columns, &$actions, $place, $nodata = null, $pre_fn = null); |
|
|
|
|
909
|
|
|
} |
910
|
|
|
|