2核1G3M服务器88一季度

腾讯云,阿里云百度云等 折扣价→点我←

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

游客1 游客组

bug显现:


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


修复:(复制以下全文内容到source/class/memory/memory_driver_file.php覆盖。)
<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: memory_driver_yac.php 27635 2017-02-02 17:02:46Z NaiXiaoxIN $
 */
if (!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

class memory_driver_file {

	public $cacheName = 'File';
	public $enable;
	public $path;

	public function env() {
		return true;
	}

	public function init($config) {
		$this->path = $config['server'].'/';
		if($config['server']) {
			$this->enable = is_dir(DISCUZ_ROOT.$this->path);
			if(!$this->enable) {
				dmkdir(DISCUZ_ROOT.$this->path);
				$this->enable = is_dir(DISCUZ_ROOT.$this->path);
			}
		} else {
			$this->enable = false;
		}
	}

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

	public function get($key) {
		$file = DISCUZ_ROOT.$this->path.$this->cachefile($key).'.php';
		if(!file_exists($file)) {
			return false;
		}
		$data = null;
		@include $file;
		if($data !== null) {
			if($data['exp'] && $data['exp'] < TIMESTAMP) {
				return false;
			} else {
				return $data['data'];
			}
		} else {
			return false;
		}
	}

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

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

	private function dir_clear($dir) {
		if($directory = @dir($dir)) {
			while($entry = $directory->read()) {
				$filename = $dir.'/'.$entry;
				if($entry != '.' && $entry != '..') {
					if(is_file($filename)) {
						@unlink($filename);
					} else {
						$this->dir_clear($filename);
						@rmdir($filename);
					}
				}
			}
			$directory->close();
		}
	}

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

	public function inc($key, $step = 1) {
		$old = $this->get($key);
		if (!$old) {
			return false;
		}
		return $this->set($key, $old + $step);
	}

	public function dec($key, $step = 1) {
		$old = $this->get($key);
		if (!$old) {
			return false;
		}
		return $this->set($key, $old - $step);
	}

}


站长窝论坛版权声明 1、本帖标题:最新版本 X3.3 R20170401+修复文件缓存删除方法 下载量始终为0不更新BUG
2、论坛网址:站长窝论坛
3、站长窝论坛的资源部分来源于网络,如有侵权,请联系站长进行删除处理。
4、会员发帖仅代表会员个人观点,并不代表本站赞同其观点和对其真实性负责。
5、站长窝论坛一律禁止以任何方式发布或转载任何违法的相关信息,访客发现请向站长举报
6、本帖由游客1在站长窝论坛《程序综合区》版块原创发布, 转载请注明出处!
评论
最新回复 (0)
返回
发新帖