optimize.inc.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. //decode by http://dezend.qiling.org QQ 2859470
  3. if ($action == 'do_mymps') {
  4. if (!$optimize || !is_array($optimize)) {
  5. write_msg('未选择需要维护项,请返回至少选择一项。');
  6. exit;
  7. }
  8. $optimize_arr = array('check' => '检查', 'repair' => '修复', 'analyze' => '分析', 'optimize' => '优化');
  9. $goodresults = $tables = array();
  10. $query = $db->query('SHOW TABLE STATUS');
  11. while ($myval = $db->fetch_array($query)) {
  12. if (substr($myval['Name'], 0, strlen($dbpre)) == $dbpre) {
  13. $tables[] = $myval['Name'];
  14. }
  15. }
  16. foreach ($optimize as $val) {
  17. if (array_key_exists($val, $optimize_arr)) {
  18. $newtable =& $tables;
  19. foreach ($newtable as $table) {
  20. $result = $db->query($val . ' TABLE ' . $table) ? '<font color="#339900">成功</font>' : '<font color="#FF0000">失败</font>';
  21. $goodresults[] = array('do' => $optimize_arr[$val], 'table' => $table, 'result' => $result);
  22. }
  23. }
  24. }
  25. if ($goodresults && is_array($goodresults) && 0 < count($goodresults)) {
  26. $here = 'Mymps数据库维护';
  27. $mymps .= mymps_admin_tpl_global_head();
  28. $mymps .= '<div id=' . MPS_SOFTNAME . '><table class="vbm" border="0" cellspacing="0" cellpadding="0"><tr class="firstr"><td>操作</td><td>操作的数据表</td><td>结果</td></tr>';
  29. foreach ($goodresults as $result) {
  30. $mymps .= '<tr><td width="10%" bgcolor="white">' . $result['do'] . '</td><td width="80%" bgcolor="white">' . $result['table'] . '</td><td width="10%" bgcolor="white">' . $result['result'] . '</td></tr>';
  31. }
  32. $mymps .= '</table></div>';
  33. $mymps .= mymps_admin_tpl_global_foot();
  34. echo $mymps;
  35. } else {
  36. write_msg('操作失败!');
  37. exit;
  38. }
  39. } else {
  40. $query = $db->query('SHOW TABLE STATUS');
  41. $mymps_rows_total = $plugin_rows_total = $other_rows_total = $mymps_Index_length = $other_Index_length = $mymps_Data_free = $other_Data_free = $mymps_Data_length = $other_Data_length = 0;
  42. while ($info = $db->fetch_array($query)) {
  43. $info['Index_length_unit'] += sizeunit(@intval($info['Index_length']));
  44. $info['Data_free_unit'] += sizeunit(@intval($info['Data_free']));
  45. $info['Data_length_unit'] += sizeunit(@intval($info['Data_length']));
  46. if (substr($info['Name'], 0, strlen($db_mymps)) == $db_mymps) {
  47. $mymps_table_info[] = $info;
  48. $mymps_rows_total += $info['Rows'];
  49. $mymps_Index_length += $info['Index_length'];
  50. $mymps_Data_free += $info['Data_free'];
  51. $mymps_Data_length += $info['Data_length'];
  52. } else {
  53. $other_table_info[] = $info;
  54. $other_rows_total += $info['Rows'];
  55. $other_Index_length += $info['Index_length'];
  56. $other_Data_free += $info['Data_free'];
  57. $other_Data_length += $info['Data_length'];
  58. }
  59. }
  60. $here = '数据库维护';
  61. include mymps_tpl('mymps_optimize');
  62. }