cache.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /**
  3. * 清理缓存
  4. ***/
  5. defined('InShopNC') or exit('Access Invalid!');
  6. class cacheControl extends SystemControl
  7. {
  8. protected $cacheItems = array(
  9. 'setting', // 基本缓存
  10. 'seo', // SEO缓存
  11. 'groupbuy_price', // 抢购价格区间
  12. 'nav', // 底部导航缓存
  13. 'express', // 快递公司
  14. 'store_class', // 店铺分类
  15. 'store_grade', // 店铺等级
  16. 'store_msg_tpl', // 店铺消息
  17. 'member_msg_tpl', // 用户消息
  18. 'consult_type', // 咨询类型
  19. 'circle_level', // 圈子成员等级
  20. 'area', // 省市区地址
  21. );
  22. public function __construct()
  23. {
  24. parent::__construct();
  25. Language::read('cache');
  26. }
  27. /**
  28. * 清理缓存
  29. */
  30. public function clearOp()
  31. {
  32. if (!chksubmit()) {
  33. Tpl::showpage('cache.clear');
  34. return;
  35. }
  36. $lang = Language::getLangContent();
  37. // 清理所有缓存
  38. if ($_POST['cls_full'] == 1) {
  39. foreach ($this->cacheItems as $i) {
  40. dkcache($i);
  41. }
  42. // 表主键
  43. Model::dropTablePkArrayCache();
  44. // 商品分类
  45. dkcache('gc_class');
  46. dkcache('all_categories');
  47. dkcache('goods_class_seo');
  48. dkcache('class_tag');
  49. // 广告
  50. Model('adv')->makeApAllCache();
  51. // 首页
  52. Model('web_config')->getWebHtml('index', 1);
  53. delCacheFile('index');
  54. } else {
  55. $todo = (array) $_POST['cache'];
  56. foreach ($this->cacheItems as $i) {
  57. if (in_array($i, $todo)) {
  58. dkcache($i);
  59. }
  60. }
  61. // 表主键
  62. if (in_array('table', $todo)) {
  63. Model::dropTablePkArrayCache();
  64. }
  65. // 商品分类
  66. if (in_array('goodsclass', $todo)) {
  67. dkcache('gc_class');
  68. dkcache('all_categories');
  69. dkcache('goods_class_seo');
  70. dkcache('class_tag');
  71. }
  72. // 广告
  73. if (in_array('adv', $todo)) {
  74. Model('adv')->makeApAllCache();
  75. }
  76. // 首页
  77. if (in_array('index', $todo)) {
  78. Model('web_config')->getWebHtml('index', 1);
  79. delCacheFile('index');
  80. }
  81. // 省市区地址
  82. if (in_array('area', $todo)) {
  83. dkcache('area');
  84. dkcache('area_toplevelareas'); // 省级别缓存处理
  85. dkcache('area_cityprovince'); // 市级别缓存处理
  86. }
  87. }
  88. $this->log(L('cache_cls_operate'));
  89. showMessage($lang['cache_cls_ok']);
  90. }
  91. }