optimizer_log.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: optimizer_log.php 31344 2012-08-15 04:01:32Z zhangjie $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class optimizer_log {
  12. private $table = array();
  13. public function __construct() {
  14. global $_G;
  15. $this->table = array(
  16. 'common_magiclog' =>
  17. array( 'tablename' => 'common_magiclog',
  18. 'splitvalue' => $_G['timestamp'] - '365',
  19. 'splitfield' => 'dateline',
  20. 'splitglue' => '<',
  21. ),
  22. 'common_card_log' =>
  23. array('tablename' => 'common_card_log',
  24. 'splitvalue' => $_G['timestamp'] - '86400 * 365',
  25. 'splitfield' => 'dateline',
  26. 'splitglue' => '<',
  27. ),
  28. );
  29. }
  30. public function mergetable($tablename) {
  31. return C::t($tablename)->merge_table();
  32. }
  33. public function check() {
  34. $count = 0;
  35. foreach($this->table as $table) {
  36. $wheresql = $table['splitfield'].$table['splitglue'].$table['splitvalue'];
  37. if(C::t($table['tablename'])->split_check($wheresql)) {
  38. $count++;
  39. }
  40. }
  41. if($count) {
  42. return array('status' => '1','type' => 'view', 'lang' => lang('optimizer', 'optimizer_log_clean', array('count' => $count)));
  43. } else {
  44. return array('status' => '0', 'type' => 'view', 'lang' => lang('optimizer', 'optimizer_log_not_found'));
  45. }
  46. }
  47. public function optimizer() {
  48. $adminfile = defined(ADMINSCRIPT) ? ADMINSCRIPT : 'admin.php';
  49. dheader('Location: '.$_G['siteurl'].$adminfile.'?action=optimizer&operation=log_optimizer&type=optimizer_log');
  50. }
  51. public function get_option() {
  52. $return = array();
  53. foreach($this->table as $table) {
  54. $wheresql = $table['splitfield'].$table['splitglue'].$table['splitvalue'];
  55. if(C::t($table['tablename'])->split_check($wheresql)) {
  56. $status = C::t($table['tablename'])->tablestatus;
  57. $return[] = array(
  58. 'tablename' => $table['tablename'],
  59. 'name' => $status['Name'],
  60. 'rows' => $status['Rows'],
  61. 'moverows' => $status['Move_rows'],
  62. 'data_length' => $status['Data_length'],
  63. 'index_length' => $status['Index_length'],
  64. 'create_time' => $status['Create_time'],
  65. );
  66. }
  67. }
  68. return $return;
  69. }
  70. public function option_optimizer($tablename) {
  71. $table = $this->table[$tablename];
  72. $wheresql = $table['splitfield'].$table['splitglue'].$table['splitvalue'];
  73. return C::t($tablename)->split_table($wheresql);
  74. }
  75. }
  76. ?>