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