📄 正在查看:admin/control/tool_control.class.php
大小:1,683 字节 · 修改:2014-04-10 07:30:54 · 行数:66
1<?php
2/**
3 * (C)2012-2014 twcms.com TongWang Inc.
4 * Author: wuzhaohuan <kongphp@gmail.com>
5 */
6
7defined('TWCMS_PATH') or exit;
8
9class tool_control extends admin_control {
10 // 清除缓存
11 public function index() {
12 if(!empty($_POST)) {
13 !empty($_POST['dbcache']) && $this->runtime->truncate();
14 !empty($_POST['filecache']) && $this->un_filecache();
15 E(0, '清除完成!');
16 }
17
18 $this->display();
19 }
20
21 // 重新统计
22 public function rebuild() {
23 if(!empty($_POST)) {
24 // 重新统计分类的内容数量
25 if(!empty($_POST['re_cate'])) {
26 $tables = $this->models->get_table_arr();
27 $cids = $this->category->get_category_db();
28
29 foreach($cids as $row) {
30 if($row['mid'] == 1) continue;
31
32 $this->cms_content->table = 'cms_'.(isset($tables[$row['mid']]) ? $tables[$row['mid']] : 'article');
33 $count = $this->cms_content->find_count(array('cid'=>$row['cid']));
34
35 $this->category->update(array('cid'=>$row['cid'], 'count'=>$count));
36 }
37 }
38
39 // 清空数据表的 count max 值,让其重新统计
40 if(!empty($_POST['re_table'])) {
41 $this->db->truncate('framework_count');
42 $this->db->truncate('framework_maxid');
43 }
44
45 E(0, '重新统计完成!');
46 }
47
48 $this->display();
49 }
50
51 // 删除文件缓存
52 private function un_filecache() {
53 try{ unlink(RUNTIME_PATH.'_runtime.php'); }catch(Exception $e) {}
54 $tpmdir = array('_control', '_model', '_view');
55 foreach($tpmdir as $dir) {
56 _rmdir(RUNTIME_PATH.APP_NAME.$dir);
57 }
58 foreach($tpmdir as $dir) {
59 _rmdir(RUNTIME_PATH.F_APP_NAME.$dir);
60 }
61 return TRUE;
62 }
63
64 // hook admin_tool_control_after.php
65}
66