optimizer_post.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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_post.php 31344 2012-08-15 04:01:32Z zhangjie $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class optimizer_post {
  12. public function __construct() {
  13. }
  14. public function check() {
  15. global $_G;
  16. loadcache('posttable_info');
  17. $count = 0;
  18. $posttableids = array_keys($_G['cache']['posttable_info']);
  19. foreach ($posttableids as $id) {
  20. $table = empty($id) ? 'forum_post' : (is_numeric($id) ? 'forum_post_'.$id : $id);
  21. $status = helper_dbtool::gettablestatus(DB::table($table), false);
  22. if($status && $status['Data_length'] > 400 * 1048576) {
  23. $count++;
  24. }
  25. }
  26. if($count) {
  27. $return = array('status' => '1','type' => 'header', 'lang' => lang('optimizer', 'optimizer_post_need_split', array('count' => $count)));
  28. } else {
  29. $return = array('status' => '0', 'type' => 'header', 'lang' => lang('optimizer', 'optimizer_post_not_need'));
  30. }
  31. return $return;
  32. }
  33. public function optimizer() {
  34. $adminfile = defined(ADMINSCRIPT) ? ADMINSCRIPT : 'admin.php';
  35. dheader('Location: '.$_G['siteurl'].$adminfile.'?action=postsplit');
  36. }
  37. }
  38. ?>