参考资料:http://bbs.phpcms.cn/forum.php?mod=viewthread&tid=878092&highlight=%BB%FD%B7%D6
测试版本:phpcms v9.5.2
配置说明:
1、修改phpcms\modules\content\index.php 和down.php文件;
将
function __construct() {
$this->db = pc_base::load_model('content_model');
}
修改为
function __construct() {
$this->db = pc_base::load_model('content_model');
$this->_userid = param::get_cookie('_userid');
$this->_username = param::get_cookie('_username');
$this->_groupid = param::get_cookie('_groupid');
}
在阅读收费 类型上粘贴如下代码,获取发布内容的会员id和会员名
//获得该资源的表(_data)的内容
$this->db->table_name = $tablename.'_data';
$rs = $this->db->get_one(array('id'=>$id));
//获得该资源的表的内容
$this->db->table_name = $tablename;
$rs_head = $this->db->get_one(array('id'=>$id));
//获得用户的id号
$memberInfo = pc_base::load_model('member_model');
$where['username']=$rs_head['username'];
$memberResult=$memberInfo->get_one($where,'`userid`');
将
//检查是否支付过
$allow_visitor = self::_check_payment($catid.'_'.$id,$paytype);
if(!$allow_visitor) {
$http_referer = urlencode(get_url());
$allow_visitor = sys_auth($catid.'_'.$id.'|'.$readpoint.'|'.$paytype).'&http_referer='.$http_referer;
} else {
$allow_visitor = 1;
}
修改为:
//检查是否支付过
$allow_visitor = self::_check_payment($catid.'_'.$id,$paytype);
if(!$allow_visitor) {
if($rs_head['username']==$this->_username){
$allow_visitor = 1;
}else{
$http_referer = urlencode(get_url());
$allow_visitor = sys_auth($catid.'_'.$id.'|'.$readpoint.'|'.$paytype.'|'.$memberResult['userid'].'|'.$rs_head['username']).'&http_referer='.$http_referer;
}
} else {
$allow_visitor = 1;
}
2、修改phpcms\modules\content\readpoint.php文件,将会员ID与会员名传递给spend.class.php页面
将
if(spend::point($readpoint, L('msg_readpoint'), $this->userid, $this->username, '', '', $flag)==false)
修改为:
if(spend::point($readpoint, L('msg_readpoint'), $this->userid, $this->username, '', '', $flag,$auth_str[3],$auth_str[4])==false)
3、修改phpcms\modules\pay\classes\spend.class.php文件
将
public static function point($value, $msg, $userid = '', $username = '', $op_userid = '', $op_username = '', $logo = '') {
return self::_add(array('username'=>$username, 'userid'=>$userid, 'type'=>2, 'value'=>$value, 'op_userid'=>$op_userid, 'op_username'=>$op_username, 'msg'=>$msg,'logo'=>$logo));
}
修改为:
public static function point($value, $msg, $userid = '', $username = '', $op_userid = '', $op_username = '', $logo = '',$pub_uid='',$pub_name='') {
return self::_add(array('username'=>$username, 'userid'=>$userid, 'type'=>2, 'value'=>$value, 'op_userid'=>$op_userid, 'op_username'=>$op_username, 'msg'=>$msg,'logo'=>$logo,'pub_uid'=>$pub_uid,'pub_name'=>$pub_name));
}
将
$sql = array();
if ($data['type'] == 1) {//金钱方式消费
$sql = array('amount'=>"-=".$data['value']);
} elseif ($data['type'] == 2) { //积分方式消费
$sql = array('point'=>'-='.$data['value']);
} else {
self::$msg = 7;
return false;
}
修改为
$sql = array();
if ($data['type'] == 1) {//金钱方式消费
$sql = array('amount'=>"-=".$data['value']);
$sqlJia = array('amount'=>'+='.$data['value']);
} elseif ($data['type'] == 2) { //积分方式消费
$sql = array('point'=>'-='.$data['value']);
$sqlJia = array('point'=>'+='.$data['value']);
} else {
self::$msg = 7;
return false;
}
将
//进入数据库操作
if ($member_db->update($sql, array('userid'=>$data['userid'], 'username'=>$data['username'])) && self::$db->insert($data)) {
self::$msg = 0;
return true;
} else {
self::$msg = 8;
return false;
}
修改为:
//进入数据库操作
if ($member_db->update($sql, array('userid'=>$data['userid'], 'username'=>$data['username'])) && self::$db->insert($data)) {
$member_db->update($sqlJia, array('userid'=>$pub_uid, 'username'=>$pub_name));
self::$msg = 0;
return true;
} else {
self::$msg = 8;
return false;
}
4、在数据库中根据情况执行以下2句SQL语句;(注意标的前缀,你的可能不是v9_)
alter table v9_pay_spend add column pub_id int(10);
alter table v9_pay_spend add column pub_name varchar(20);
觉得麻烦的可以基于V9.5.2的GBK版本直接覆盖安装。