返回列表 发新帖
查看: 239|回复: 0

最新版本 X3.3 R20170401+修复文件缓存删除方法 下载量始终为0不更新BUG

[复制链接]

1万

热度

1万

元宝

1万

贡献

金牌草根

发表于 2017-6-8 16:52:22 | 显示全部楼层 |阅读模式
bug显现:
bug显现.png

bug文件:source/class/memory/memory_driver_file.php


修复:(复制以下全文内容到source/class/memory/memory_driver_file.php覆盖。
  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: memory_driver_yac.php 27635 2017-02-02 17:02:46Z NaiXiaoxIN $
  7. */
  8. if (!defined('IN_DISCUZ')) {
  9.         exit('Access Denied');
  10. }

  11. class memory_driver_file {

  12.         public $cacheName = 'File';
  13.         public $enable;
  14.         public $path;

  15.         public function env() {
  16.                 return true;
  17.         }

  18.         public function init($config) {
  19.                 $this->path = $config['server'].'/';
  20.                 if($config['server']) {
  21.                         $this->enable = is_dir(DISCUZ_ROOT.$this->path);
  22.                         if(!$this->enable) {
  23.                                 dmkdir(DISCUZ_ROOT.$this->path);
  24.                                 $this->enable = is_dir(DISCUZ_ROOT.$this->path);
  25.                         }
  26.                 } else {
  27.                         $this->enable = false;
  28.                 }
  29.         }

  30.         private function cachefile($key) {
  31.                 return str_replace('_', '/', $key).'/'.$key;
  32.         }

  33.         public function get($key) {
  34.                 $file = DISCUZ_ROOT.$this->path.$this->cachefile($key).'.php';
  35.                 if(!file_exists($file)) {
  36.                         return false;
  37.                 }
  38.                 $data = null;
  39.                 @include $file;
  40.                 if($data !== null) {
  41.                         if($data['exp'] && $data['exp'] < TIMESTAMP) {
  42.                                 return false;
  43.                         } else {
  44.                                 return $data['data'];
  45.                         }
  46.                 } else {
  47.                         return false;
  48.                 }
  49.         }

  50.         public function set($key, $value, $ttl = 0) {
  51.                 $file = DISCUZ_ROOT.$this->path.$this->cachefile($key).'.php';
  52.                 dmkdir(dirname($file));
  53.                 $data = array(
  54.                     'exp' => $ttl ? TIMESTAMP + $ttl : 0,
  55.                     'data' => $value,
  56.                 );
  57.                 file_put_contents($file, "<?php\n\$data = ".var_export($data, 1).";\n");
  58.                 return true;
  59.         }

  60.         public function rm($key) {
  61.                 return @unlink(DISCUZ_ROOT.$this->path.$this->cachefile($key).'.php');
  62.         }

  63.         private function dir_clear($dir) {
  64.                 if($directory = @dir($dir)) {
  65.                         while($entry = $directory->read()) {
  66.                                 $filename = $dir.'/'.$entry;
  67.                                 if($entry != '.' && $entry != '..') {
  68.                                         if(is_file($filename)) {
  69.                                                 @unlink($filename);
  70.                                         } else {
  71.                                                 $this->dir_clear($filename);
  72.                                                 @rmdir($filename);
  73.                                         }
  74.                                 }
  75.                         }
  76.                         $directory->close();
  77.                 }
  78.         }

  79.         public function clear() {
  80.                 return $this->dir_clear(DISCUZ_ROOT.$this->path);
  81.         }

  82.         public function inc($key, $step = 1) {
  83.                 $old = $this->get($key);
  84.                 if (!$old) {
  85.                         return false;
  86.                 }
  87.                 return $this->set($key, $old + $step);
  88.         }

  89.         public function dec($key, $step = 1) {
  90.                 $old = $this->get($key);
  91.                 if (!$old) {
  92.                         return false;
  93.                 }
  94.                 return $this->set($key, $old - $step);
  95.         }

  96. }
复制代码


本文来源于网友学习研究交流 www.caogen8.co,请以学习研究交流为主。
如果您没有贡献积分,可以直接免费领取,免费领取
如果你需要加入本学习研究交流,请以学习研究交流为目的,免责声明
如果找不到您要的资源,请搜索一下,点击搜索
返回列表 发新帖
 懒得打字嘛,点击右侧快捷回复【最新发布】   【赞助草根吧享更多权益】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

收藏帖子 返回列表 搜索

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

小黑屋|手机版|草根吧