XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
main.php
Go to the documentation of this file.
1 <?php
19 require_once XOOPS_ROOT_PATH.'/modules/system/class/maintenance.php';
20 
21 // Check users rights
22 if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) exit( _NOPERM );
23 // Check is active
24 if ( !xoops_getModuleOption('active_maintenance', 'system') ) redirect_header( 'admin.php', 2, _AM_SYSTEM_NOTACTIVE );
25 
26 // Get Action type
27 $op = system_CleanVars ( $_REQUEST, 'op', 'list', 'string' );
28 // Define main template
29 $xoopsOption['template_main'] = 'system_maintenance.html';
30 // Call Header
32 // Define Stylesheet
33 $xoTheme->addStylesheet( XOOPS_URL . '/modules/system/css/admin.css' );
34 // Define scripts
35 $xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js');
36 $xoTheme->addScript('modules/system/js/admin.js');
37 switch ($op) {
38 
39  case 'list': default:
40  // Define Breadcrumb and tips
41  $xoBreadCrumb->addLink(_AM_SYSTEM_MAINTENANCE_NAV_MANAGER, system_adminVersion('maintenance', 'adminpath'));
42  $xoBreadCrumb->addHelp( system_adminVersion('maintenance', 'help') );
44  $xoBreadCrumb->render();
45 
46  $maintenance = new SystemMaintenance();
47 
48  //Form Maintenance
49  $form_maintenance = new XoopsThemeForm(_AM_SYSTEM_MAINTENANCE, "maintenance_save", "admin.php?fct=maintenance", 'post', true);
50 
51  $cache = new XoopsFormSelect(_AM_SYSTEM_MAINTENANCE_CACHE, "cache", '', 3, true);
52  $cache->setDescription( XOOPS_VAR_PATH . "/cache/smarty_cache/<br />".XOOPS_VAR_PATH . "/cache/smarty_compile/<br />".XOOPS_VAR_PATH . "/cache/xoops_cache/" );
53  $cache_arr = array(1 => 'smarty_cache',
54  2 => 'smarty_compile',
55  3 => 'xoops_cache');
56  $cache->addOptionArray($cache_arr);
57  $form_maintenance->addElement($cache);
58 
59  $form_maintenance->addElement(new XoopsFormRadioYN(_AM_SYSTEM_MAINTENANCE_SESSION, 'session', '', _YES, _NO));
60 
62  $tables_tray->setDescription(_AM_SYSTEM_MAINTENANCE_TABLES_DESC);
63  $select_tables = new XoopsFormSelect('', "tables", '', 7, true);
64  $select_tables->addOptionArray($maintenance->displayTables(true));
65  $tables_tray->addElement($select_tables, false);
66  $tables_tray->addElement(new xoopsFormLabel('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'._AM_SYSTEM_MAINTENANCE_DUMP_AND.'&nbsp;'));
67  $choice = new XoopsFormSelect('&nbsp;&nbsp;', "maintenance", '', 4, true);
69  $choice->addOptionArray($options);
70  $tables_tray->addElement($choice, false);
71  $form_maintenance->addElement($tables_tray);
72 
73  $form_maintenance->addElement(new XoopsFormHidden("op", "maintenance_save"));
74  $form_maintenance->addElement(new XoopsFormButton("", "maintenance_save", _SEND, "submit"));
75 
76  //Form Dump
77  $form_dump = new XoopsThemeForm(_AM_SYSTEM_MAINTENANCE_DUMP, "dump_save", "admin.php?fct=maintenance", 'post', true);
78 
80  $select_tables1 = new XoopsFormSelect('', "dump_tables", '', 7, true);
81  $select_tables1->addOptionArray($maintenance->displayTables(true));
82  $dump_tray->addElement($select_tables1, false);
83 
84  $dump_tray->addElement(new xoopsFormLabel('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'._AM_SYSTEM_MAINTENANCE_DUMP_OR.'&nbsp;'));
85  $ele = new XoopsFormSelect('&nbsp;&nbsp;', 'dump_modules', '', 7, true);
86  $module_handler =& xoops_gethandler('module');
87  $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
88  $criteria->add(new Criteria('isactive', 1));
89  $moduleslist = $module_handler->getList($criteria, true);
90  $ele->addOptionArray($moduleslist);
91  $dump_tray->addElement($ele);
92  $form_dump->addElement($dump_tray);
93 
94  $form_dump->addElement(new XoopsFormRadioYN(_AM_SYSTEM_MAINTENANCE_DUMP_DROP, 'drop', 1, _YES, _NO));
95 
96  $form_dump->addElement(new XoopsFormHidden("op", "dump_save"));
97  $form_dump->addElement(new XoopsFormButton("", "dump_save", _SEND, "submit"));
98 
99  // Assign form
100  $xoopsTpl->assign('form_maintenance', $form_maintenance->render());
101  $xoopsTpl->assign('form_dump', $form_dump->render());
102  break;
103 
104  case 'maintenance_save':
105  // Check security
106  if ( !$GLOBALS['xoopsSecurity']->check() ) {
107  redirect_header( 'admin.php?fct=maintenance', 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors() ) );
108  exit();
109  }
110  //Define Breadcrumb and tips
111  $xoBreadCrumb->addLink(_AM_SYSTEM_MAINTENANCE_NAV_MANAGER, system_adminVersion('maintenance', 'adminpath'));
112  //$xoBreadCrumb->addLink(_AM_SYSTEM_MAINTENANCE_NAV_MAINTENANCE);
113  $xoBreadCrumb->render();
114 
115  $session = system_CleanVars ( $_REQUEST, 'session', 1, 'int' );
116  $cache = system_CleanVars ( $_REQUEST, 'cache', array(), 'array' );
117  $tables = system_CleanVars ( $_REQUEST, 'tables', array(), 'array' );
118  $tables_op = system_CleanVars ( $_REQUEST, 'maintenance', array(), 'array' );
119  $verif_cache = false;
120  $verif_session = false;
121  $verif_maintenance = false;
122  $result_cache = false;
123  $result_session = false;
124  $result_maintenance = false;
125 
126  $maintenance = new SystemMaintenance();
127  //Cache
128  if(!empty($cache)) {
129  $verif_cache = true;
130  if($maintenance->CleanCache($_REQUEST['cache'])) {
131  $result_cache = true;
132  //Set active modules in cache folder
134  }
135  }
136  //Session
137  if ( $session == 1 ) {
138  $verif_session = true;
139  if($maintenance->CleanSession()) {
140  $result_session = true;
141  }
142  }
143  //Maintenance tables
144  if(!empty($tables)) {
145  $verif_maintenance = true;
146  if(!empty($tables_op)) {
147  $result_maintenance = $maintenance->CheckRepairAnalyzeOptimizeQueries($tables, $tables_op);
148  }
149  }
150 
151  if( $result_cache == false && $result_session == false && $result_maintenance == false ) {
152  redirect_header("admin.php?fct=maintenance", 2, _AM_SYSTEM_MAINTENANCE_ERROR_MAINTENANCE);
153  }
154 
155  $xoopsTpl->assign('verif_cache', $verif_cache);
156  $xoopsTpl->assign('verif_session', $verif_session);
157  $xoopsTpl->assign('verif_maintenance', $verif_maintenance);
158  $xoopsTpl->assign('result_cache', $result_cache);
159  $xoopsTpl->assign('result_session', $result_session);
160  $xoopsTpl->assign('result_maintenance', $result_maintenance);
161  $xoopsTpl->assign('maintenance', true);
162  break;
163 
164  case 'dump_save':
165  // Check security
166  if ( !$GLOBALS['xoopsSecurity']->check() ) {
167  redirect_header( 'admin.php?fct=maintenance', 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors() ) );
168  exit();
169  }
170  //Define Breadcrumb and tips
171  $xoBreadCrumb->addLink(_AM_SYSTEM_MAINTENANCE_NAV_MANAGER, system_adminVersion('maintenance', 'adminpath'));
173  $xoBreadCrumb->render();
174 
175  $dump = new SystemMaintenance();
176  $dump_modules = isset($_REQUEST['dump_modules']) ? $_REQUEST['dump_modules'] : false;
177  $dump_tables = isset($_REQUEST['dump_tables']) ? $_REQUEST['dump_tables'] : false;
178  $drop = system_CleanVars ( $_REQUEST, 'drop', 1, 'int' );
179 
180  if( ( $dump_tables == true && $dump_modules == true ) || ( $dump_tables == false && $dump_modules == false ) ) {
182  }
183 
184  if( $dump_tables != false ) {
185  $result = $dump->dump_tables($dump_tables, $drop);
186  } else if ( $dump_modules != false ) {
187  $result = $dump->dump_modules($dump_modules, $drop);
188  }
189  $xoopsTpl->assign('result_dump', $result[1]);
190  break;
191 }
192 
194 ?>