您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Redis功能缺失(密码认证)

2024/7/19 16:51:09发布39次查看
redis默认是明文存储,需要增加安全性要求是,必须对redis增加author认证,v3.2.3 library\think\cache\driver\redis.class.php 以及library\think\session\driver\redis.class.php 代码需要补充设置。
构造方法需要增加最后三行内容
public function __construct($options=array()) {
if ( !extension_loaded('redis') ) {
e(l('_not_support_').':redis');
}
$data_redis_db = c('redis_db');
$options = array_merge(array (
'host' => c('redis_host') ? : '127.0.0.1',
'port' => c('redis_port') ? : 6379,
'timeout' => c('data_cache_timeout') ? : false,
'persistent' => false,
'auth' => c('redis_auth') ? c('redis_auth') : false,
'db' => empty($data_redis_db) ? 0 : $data_redis_db,
),$options);
$this->options = $options;
$this->options['expire'] = isset($options['expire'])? $options['expire'] : c('data_cache_time');
$this->options['prefix'] = isset($options['prefix'])? $options['prefix'] : c('data_cache_prefix');
$this->options['length'] = isset($options['length'])? $options['length'] : 0;
$func = $options['persistent'] ? 'pconnect' : 'connect';
$this->handler = new \redis;
$options['timeout'] === false ?
$this->handler->$func($options['host'], $options['port']) :
$this->handler->$func($options['host'], $options['port'], $options['timeout']);
//增加代码,设置redis安全性,增加认证密码
if(isset($options['auth']) && $options['auth']){
$this->handler->auth($options['auth']);
}
}
ad:真正免费,域名+虚机+企业邮箱=0元
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product