19 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
38 $this->prefix = $this->db->prefix.
'_';
49 $result = $this->db->queryF(
'SHOW TABLES');
50 while ($myrow = $this->db->fetchArray(
$result)) {
51 $value = array_values($myrow);
68 $result = $this->db->queryF(
'TRUNCATE TABLE '.$this->db->prefix(
'session'));
79 for(
$i=0;
$i<count($cache);
$i++) {
81 $files = glob(XOOPS_VAR_PATH.
'/caches/smarty_cache/*.*');
82 foreach ($files as $filename) {
83 if(basename(strtolower($filename)) !=
'index.html') {
87 }
else if($cache[
$i] == 2) {
88 $files = glob(XOOPS_VAR_PATH.
'/caches/smarty_compile/*.*');
89 foreach ($files as $filename) {
90 if(basename(strtolower($filename)) !=
'index.html') {
94 }
else if($cache[
$i] == 3) {
95 $files = glob(XOOPS_VAR_PATH.
'/caches/xoops_cache/*.*');
96 foreach ($files as $filename) {
97 if(basename(strtolower($filename)) !=
'index.html') {
121 if (in_array ($tab[
$i], $maintenance) ) {
122 $tab1[
$i] = $tab[
$i];
130 $ret .=
'<tr class="'.$class.
'"><td align="center">'.$this->prefix.$tables[
$i].
'</td>';
132 if( $tab1[
$j] == 1 ) {
134 $result = $this->db->queryF(
'OPTIMIZE TABLE '.$this->prefix.$tables[
$i]);
136 $ret .=
'<td class="xo-actions txtcenter"><img src="'.system_AdminIcons(
'success.png').
'" /></td>';
138 $ret .=
'<td class="xo-actions txtcenter"><img src="'.system_AdminIcons(
'cancel.png').
'" /></td>';
140 }
else if ( $tab1[
$j] == 2 ) {
142 $result = $this->db->queryF(
'CHECK TABLE '.$this->prefix.$tables[
$i]);
144 $ret .=
'<td class="xo-actions txtcenter"><img src="'.system_AdminIcons(
'success.png').
'" /></td>';
146 $ret .=
'<td class="xo-actions txtcenter"><img src="'.system_AdminIcons(
'cancel.png').
'" /></td>';
148 }
else if ( $tab1[
$j] == 3 ) {
150 $result = $this->db->queryF(
'REPAIR TABLE '.$this->prefix.$tables[
$i]);
152 $ret .=
'<td class="xo-actions txtcenter"><img src="'.system_AdminIcons(
'success.png').
'" /></td>';
154 $ret .=
'<td class="xo-actions txtcenter"><img src="'.system_AdminIcons(
'cancel.png').
'" /></td>';
156 }
else if ( $tab1[
$j] == 4 ) {
158 $result = $this->db->queryF(
'ANALYZE TABLE '.$this->prefix.$tables[
$i]);
160 $ret .=
'<td class="xo-actions txtcenter"><img src="'.system_AdminIcons(
'success.png').
'" /></td>';
162 $ret .=
'<td class="xo-actions txtcenter"><img src="'.system_AdminIcons(
'cancel.png').
'" /></td>';
165 $ret .=
'<td> </td>';
169 $class = ($class ==
'even') ?
'odd' :
'even';
185 $ret[0] .=
"# Dump SQL, Generate by Xoops \n";
186 $ret[0] .=
"# Date : ".date(
'd-m-Y � H:i').
" \n";
191 $ret = $this->dump_table_structure(
$ret, $this->prefix.$tables[
$i], $drop, $class);
193 $ret = $this->dump_table_datas(
$ret, $this->prefix.$tables[
$i]);
194 $class = ($class ==
'even') ?
'odd' :
'even';
197 $ret[1] .=
'</table>';
211 $ret[0] .=
"# Dump SQL, Generate by Xoops \n";
212 $ret[0] .=
"# Date : ".date(
'd-m-Y � H:i').
" \n";
216 for(
$i=0;
$i<count($modules);
$i++) {
219 $ret[1] .=
'<tr><th colspan="3" align="left">'.ucfirst($modules[$i]).
'</th></tr>';
220 $modtables =
$module->getInfo(
'tables');
221 if ($modtables !=
false && is_array($modtables)) {
222 foreach ($modtables as $table) {
224 $ret = $this->dump_table_structure(
$ret, $this->prefix.$table, $drop, $class);
226 $ret = $this->dump_table_datas(
$ret, $this->prefix.$table);
227 $class = ($class ==
'even') ?
'odd' :
'even';
230 $ret[1] .=
'<tr><td colspan="3" align="center">'._AM_SYSTEM_MAINTENANCE_DUMP_NO_TABLES.
'</td></tr>';
233 $ret[1] .=
'</table>';
247 function dump_table_structure(
$ret, $table, $drop, $class)
250 $result = $this->db->queryF(
'SHOW create table `'.$table.
'`;');
252 if( $row = $this->db->fetchArray(
$result) ) {
253 $ret[0] .=
"# Table structure for table `".$table.
"` \n\n";
255 $ret[0] .=
"DROP TABLE IF EXISTS `".$table.
"`;\n\n";
258 $ret[0] .= $row[
'Create Table'].
";\n\n";
261 $ret[1] .=
'<tr class="'.$class.
'"><td align="center">'.$table.
'</td><td class="xo-actions txtcenter">';
262 $ret[1] .= ( $verif ==
true ) ?
'<img src="'.
system_AdminIcons(
'success.png').
'" />' :
'<img src="'.system_AdminIcons(
'cancel.png').
'" />';
264 $this->db->freeRecordSet(
$result);
275 function dump_table_datas(
$ret, $table)
278 $result = $this->db->queryF(
'SELECT * FROM '.$table.
';');
280 $num_rows= $this->db->getRowsNum(
$result);
281 $num_fields= $this->db->getFieldsNum(
$result);
284 $field_type = array();
286 while(
$i < $num_fields ) {
288 array_push($field_type, $meta->type);
292 $ret[0] .=
"INSERT INTO `".$table.
"` values\n";
294 while( $row = $this->db->fetchRow(
$result) ) {
297 for(
$i=0;
$i < $num_fields;
$i++ ) {
298 if( is_null( $row[
$i] ) ) {
301 switch( $field_type[$i]) {
306 $ret[0] .=
"'".mysql_real_escape_string($row[$i]).
"'";
309 if( $i < $num_fields-1) {
315 if(
$index < $num_rows-1 ) {
325 $ret[1] .=
'<td align="center">';
328 $this->db->freeRecordSet(
$result);
340 $file_name =
"dump_".date(
"Y.m.d").
"_".date(
"H.i.s").
".sql";
341 $path_file =
"./admin/maintenance/dump/".$file_name;
342 if( file_put_contents($path_file,
$ret[0]) ) {
343 $ret[1] .=
'<table class="outer"><tr><th colspan="2" align="center">'._AM_SYSTEM_MAINTENANCE_DUMP_FILE_CREATED.
'</th><th>'.
_AM_SYSTEM_MAINTENANCE_DUMP_RESULT.
'</th></tr><tr><td colspan="2" align="center"><a href="'.XOOPS_URL.
'/modules/system/admin/maintenance/dump/'.$file_name.
'">'.$file_name.
'</a></td><td class="xo-actions txtcenter"><img src="'.
system_AdminIcons(
'success.png').
'" /></td><tr></table>';
345 $ret[1] .=
'<table class="outer"><tr><th colspan="2" align="center">'._AM_SYSTEM_MAINTENANCE_DUMP_FILE_CREATED.
'</th><th>'.
_AM_SYSTEM_MAINTENANCE_DUMP_RESULT.
'</th></tr><tr><td colspan="2" class="xo-actions txtcenter">'.$file_name.
'</td><td class="xo-actions txtcenter"><img src="'.
system_AdminIcons(
'cancel.png').
'" /></td><tr></table>';