XOOPS  2.6.0
center.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
23 include __DIR__ . '/header.php';
24 // Get main instance
27 
28 // Get Action type
29 $op = $system->cleanVars($_REQUEST, 'op', 'list', 'string');
30 
31 // Call Header
32 $xoops->header('admin:maintenance/maintenance_center.tpl');
33 
34 $admin_page = new \Xoops\Module\Admin();
35 $admin_page->renderNavigation('center.php');
36 
37 switch ($op) {
38 
39  case 'list':
40  default:
41  // Define tips
43  $admin_page->renderTips();
44  $form = $xoops->getModuleForm(null, 'maintenance');
45  $form->getMaintenance();
46  $form->display();
47  break;
48 
49  case 'maintenance_save':
50  // Check security
51  if (!$xoops->security()->check()) {
52  $xoops->redirect('center.php', 3, implode('<br />', $xoops->security()->getErrors()));
53  }
54  $admin_page->addItemButton(_AM_MAINTENANCE_CENTER_RETURN, 'center.php', 'application-view-detail');
55  $admin_page->renderButton();
56 
57  $session = $system->cleanVars($_REQUEST, 'session', 1, 'int');
58  $cache = $system->cleanVars($_REQUEST, 'cache', array(), 'array');
59  $tables = $system->cleanVars($_REQUEST, 'tables', array(), 'array');
60  $tables_op = $system->cleanVars($_REQUEST, 'maintenance', array(), 'array');
61  $xoops->db();
62  global $xoopsDB;
63  $db = $xoopsDB;
64  //Cache
65  $res_cache = $system->CleanCache($cache);
66  if (!empty($cache)) {
67  for ($i = 0; $i < count($cache); ++$i) {
68  switch ($cache[$i]) {
69  case 1:
70  $xoops->tpl()->assign('smarty_cache', true);
71  $xoops->tpl()->assign('result_smarty_cache', sprintf(_AM_MAINTENANCE_CENTER_RESULT_SMARTY_CACHE, $res_cache['smarty_cache']));
72  break;
73 
74  case 2:
75  $xoops->tpl()->assign('smarty_compile', true);
76  $xoops->tpl()->assign('result_smarty_compile', sprintf(_AM_MAINTENANCE_CENTER_RESULT_SMARTY_COMPILE, $res_cache['smarty_compile']));
77  break;
78 
79  case 3:
80  $xoops->tpl()->assign('xoops_cache', true);
81  // TODO: this is no longer a count, now boolean. needs updated to be OK/FAILED
82  $xoops->tpl()->assign('result_xoops_cache', sprintf(_AM_MAINTENANCE_CENTER_RESULT_XOOPS_CACHE, $res_cache['xoops_cache']));
83  break;
84  }
85  }
86  }
87  //Session
88  if ($session == 1) {
89  $result = $db->queryF('TRUNCATE TABLE ' . $db->prefix('session'));
90  $result ? $result_session = true : $result_session = false;
91  $xoops->tpl()->assign('result_session', $result_session);
92  $xoops->tpl()->assign('session', true);
93  }
94  //Maintenance tables
95  if (!empty($tables) && !empty($tables_op)) {
96  $tab = array();
97  for ($i = 0; $i < 4; ++$i) {
98  $tab[$i] = $i + 1;
99  }
100  $tab1 = array();
101  for ($i = 0; $i < 4; ++$i) {
102  if (in_array($tab[$i], $tables_op)) {
103  $tab1[$i] = $tab[$i];
104  } else {
105  $tab1[$i] = '0';
106  }
107  }
108  unset($tab);
109  for ($i = 0; $i < count($tables); ++$i) {
110  $result_arr['table'] = $db->prefix . $tables[$i];
111  for ($j = 0; $j < 4; ++$j) {
112  switch ($tab1[$j]) {
113  case 1:
114  //Optimize
115  $result = $db->queryF('OPTIMIZE TABLE ' . $db->prefix . $tables[$i]);
116  $result ? $result_arr['optimize'] = true : $result_arr['optimize'] = false;
117  break;
118 
119  case 2:
120  //Tables
121  $result = $db->queryF('CHECK TABLE ' . $db->prefix . $tables[$i]);
122  $result ? $result_arr['check'] = true : $result_arr['check'] = false;
123  break;
124 
125  case 3:
126  //Repair
127  $result = $db->queryF('REPAIR TABLE ' . $db->prefix . $tables[$i]);
128  $result ? $result_arr['repair'] = true : $result_arr['repair'] = false;
129  break;
130 
131  case 4:
132  //Analyze
133  $result = $db->queryF('ANALYZE TABLE ' . $db->prefix . $tables[$i]);
134  $result ? $result_arr['analyse'] = true : $result_arr['analyse'] = false;
135  break;
136  }
137  }
138  $xoops->tpl()->appendByRef('result_arr', $result_arr);
139  unset($result_arr);
140  }
141  $xoops->tpl()->assign('maintenance', true);
142  }
143  break;
144 }
145 $xoops->footer();
$i
Definition: dialog.php:68
static getInstance()
Definition: system.php:46
static getInstance()
Definition: Xoops.php:160
$admin_page
Definition: center.php:34
$result
Definition: pda.php:33
const _AM_MAINTENANCE_CENTER_RESULT_SMARTY_CACHE
Definition: admin.php:41
const _AM_MAINTENANCE_CENTER_RETURN
Definition: admin.php:44
$op
Definition: center.php:29
$form
Definition: xoops_code.php:21
const _AM_MAINTENANCE_CENTER_TIPS
Definition: admin.php:80
global $xoopsDB
Definition: common.php:36
const _AM_MAINTENANCE_CENTER_RESULT_SMARTY_COMPILE
Definition: admin.php:42
$xoops
Definition: center.php:26
const _AM_MAINTENANCE_CENTER_RESULT_XOOPS_CACHE
Definition: admin.php:43
$system
Definition: center.php:25
$j
Definition: help.php:169