public function init() { $allow_visitor = htmlspecialchars($_GET['allow_visitor']); $auth = sys_auth($allow_visitor, 'DECODE'); if (strpos($auth, '|') === false) { showmessage(L('illegal_operation')); } $auth_str = explode('|', $auth); $flag = $auth_str[0]; if (!preg_match('/^([0-9]+)|([0-9]+)/', $flag)) { showmessage(L('illegal_operation')); } $readpoint = intval($auth_str[1]); $paytype = intval($auth_str[2]); $http_referer = urldecode($_GET['http_referer']); if (!$readpoint) { showmessage(L('illegal_operation')); } pc_base::load_app_class('spend', 'pay', 0); $flag_arr = explode('_', $flag); $catid = $flag_arr[0]; $siteids = getcache('category_content', 'commons'); $siteid = $siteids[$catid]; $CATEGORYS = getcache('category_content_' . $siteid, 'commons'); if (isset($CATEGORYS[$catid])) { $setting = string2array($CATEGORYS[$catid]['setting']); $repeatchargedays = intval($setting['repeatchargedays']); if ($repeatchargedays) { $fromtime = SYS_TIME - 86400 * $repeatchargedays; $r = spend::spend_time($this->userid, $fromtime, $flag); if ($r) { showmessage(L('have_pay'), $http_referer, 1000); } } } if ($paytype) { if (spend::amount($readpoint, L('msg_readpoint'), $this->userid, $this->username, '', '', $flag) == false) { $msg = spend::get_msg(); $http_referer = APP_PATH . 'index.php?m=pay&c=deposit&a=pay'; } else { $msg = L('readpoint_pay', array('readpoint' => $readpoint)); } } else { if (spend::point($readpoint, L('msg_readpoint'), $this->userid, $this->username, '', '', $flag) == false) { $msg = spend::get_msg(); $http_referer = APP_PATH . 'index.php?m=pay&c=deposit&a=pay'; } else { $msg = L('readpoint_pay_point', array('readpoint' => $readpoint)); } } showmessage($msg, $http_referer, 3000); }
/** * 积分兑换 */ public function change_credit() { $memberinfo = $this->memberinfo; //加载用户模块配置 $member_setting = getcache('member_setting'); $this->_init_phpsso(); $setting = $this->client->ps_getcreditlist(); $outcredit = unserialize($setting); $setting = $this->client->ps_getapplist(); $applist = unserialize($setting); if (isset($_POST['dosubmit'])) { //本系统积分兑换数 $fromvalue = intval($_POST['fromvalue']); //本系统积分类型 $from = $_POST['from']; $toappid_to = explode('_', $_POST['to']); //目标系统appid $toappid = $toappid_to[0]; //目标系统积分类型 $to = $toappid_to[1]; if ($from == 1) { if ($memberinfo['point'] < $fromvalue) { showmessage(L('need_more_point'), HTTP_REFERER); } } elseif ($from == 2) { if ($memberinfo['amount'] < $fromvalue) { showmessage(L('need_more_amount'), HTTP_REFERER); } } else { showmessage(L('credit_setting_error'), HTTP_REFERER); } $status = $this->client->ps_changecredit($memberinfo['phpssouid'], $from, $toappid, $to, $fromvalue); if ($status == 1) { if ($from == 1) { $this->db->update(array('point' => "-={$fromvalue}"), array('userid' => $memberinfo['userid'])); } elseif ($from == 2) { $this->db->update(array('amount' => "-={$fromvalue}"), array('userid' => $memberinfo['userid'])); } showmessage(L('operation_success'), HTTP_REFERER); } else { showmessage(L('operation_failure'), HTTP_REFERER); } } elseif (isset($_POST['buy'])) { if (!is_numeric($_POST['money']) || $_POST['money'] < 0) { showmessage(L('money_error'), HTTP_REFERER); } else { $money = intval($_POST['money']); } if ($memberinfo['amount'] < $money) { showmessage(L('short_of_money'), HTTP_REFERER); } //此处比率读取用户配置 $point = $money * $member_setting['rmb_point_rate']; $this->db->update(array('point' => "+={$point}"), array('userid' => $memberinfo['userid'])); //加入消费记录,同时扣除金钱 pc_base::load_app_class('spend', 'pay', 0); spend::amount($money, L('buy_point'), $memberinfo['userid'], $memberinfo['username']); showmessage(L('operation_success'), HTTP_REFERER); } else { $credit_list = pc_base::load_config('credit'); include template('member', 'change_credit'); } }
/** * 积分兑换 */ public function change_credit() { $memberinfo = $this->memberinfo; //加载用户模块配置 $member_setting = S('member/member_setting'); $outcredit = S('member/creditchange'); $applist = S('member/applist'); if (isset($_POST['dosubmit'])) { //本系统积分兑换数 $fromvalue = intval($_POST['fromvalue']); //本系统积分类型 $from = $_POST['from']; $toappid_to = explode('_', $_POST['to']); //目标系统appid $toappid = $toappid_to[0]; //目标系统积分类型 $to = $toappid_to[1]; if ($from == 1) { if ($memberinfo['point'] < $fromvalue) { showmessage(L('need_more_point'), HTTP_REFERER); } } elseif ($from == 2) { if ($memberinfo['amount'] < $fromvalue) { showmessage(L('need_more_amount'), HTTP_REFERER); } } else { showmessage(L('credit_setting_error'), HTTP_REFERER); } //UCenter应用间积分兑换 $status = Loader::lib('Ucenter')->uc_credit_exchange_request($memberinfo['ucuserid'], $from, $to, $toappid, $fromvalue); if ($status == 1) { if ($from == 1) { $this->db->where(array('userid' => $memberinfo['userid']))->update(array('point' => "-={$fromvalue}")); } elseif ($from == 2) { $this->db->where(array('userid' => $memberinfo['userid']))->update(array('amount' => "-={$fromvalue}")); } showmessage(L('operation_success'), HTTP_REFERER); } else { showmessage(L('operation_failure'), HTTP_REFERER); } } elseif (isset($_POST['buy'])) { if (!is_numeric($_POST['money']) || $_POST['money'] < 0) { showmessage(L('money_error'), HTTP_REFERER); } else { $money = intval($_POST['money']); } if ($memberinfo['amount'] < $money) { showmessage(L('short_of_money'), HTTP_REFERER); } //此处比率读取用户配置 $point = $money * $member_setting['rmb_point_rate']; $this->db->where(array('userid' => $memberinfo['userid']))->update(array('point' => "+={$point}")); //加入消费记录,同时扣除金钱 Loader::lib('pay:spend', false); spend::amount($money, L('buy_point'), $memberinfo['userid'], $memberinfo['username']); showmessage(L('operation_success'), HTTP_REFERER); } else { $credit_list = C('credit'); include template('member', 'change_credit'); } }
/** * 用户升级 */ public function account_manage_upgrade() { $memberinfo = $this->memberinfo; $grouplist = S('member/grouplist'); if (empty($grouplist[$memberinfo['groupid']]['allowupgrade'])) { showmessage(L('deny_upgrade'), HTTP_REFERER); } if (isset($_POST['upgrade_type']) && intval($_POST['upgrade_type']) < 0) { showmessage(L('operation_failure'), HTTP_REFERER); } if (isset($_POST['upgrade_date']) && intval($_POST['upgrade_date']) < 0) { showmessage(L('operation_failure'), HTTP_REFERER); } if (isset($_POST['dosubmit'])) { $groupid = isset($_POST['groupid']) ? intval($_POST['groupid']) : showmessage(L('operation_failure'), HTTP_REFERER); $upgrade_type = isset($_POST['upgrade_type']) ? intval($_POST['upgrade_type']) : showmessage(L('operation_failure'), HTTP_REFERER); $upgrade_date = !empty($_POST['upgrade_date']) ? intval($_POST['upgrade_date']) : showmessage(L('operation_failure'), HTTP_REFERER); // 消费类型,包年、包月、包日,价格 $typearr = array($grouplist[$groupid]['price_y'], $grouplist[$groupid]['price_m'], $grouplist[$groupid]['price_d']); // 消费类型,包年、包月、包日,时间 $typedatearr = array('366', '31', '1'); // 消费的价格 $cost = $typearr[$upgrade_type] * $upgrade_date; // 购买时间 $buydate = $typedatearr[$upgrade_type] * $upgrade_date * 86400; $overduedate = $memberinfo['overduedate'] > TIME ? $memberinfo['overduedate'] + $buydate : TIME + $buydate; if ($memberinfo['amount'] >= $cost) { $this->db->where(array('userid' => $memberinfo['userid']))->update(array('groupid' => $groupid, 'overduedate' => $overduedate, 'vip' => 1)); // 消费记录 Loader::lib('pay:spend', false); spend::amount($cost, L('allowupgrade'), $memberinfo['userid'], $memberinfo['username']); showmessage(L('operation_success'), U('member/index/init')); } else { showmessage(L('operation_failure'), HTTP_REFERER); } } else { $groupid = isset($_GET['groupid']) ? intval($_GET['groupid']) : ''; // 获取头像数组 $avatar = get_memberavatar($this->memberinfo['userid'], false); $memberinfo['groupname'] = $grouplist[$memberinfo[groupid]]['name']; $memberinfo['grouppoint'] = $grouplist[$memberinfo[groupid]]['point']; unset($grouplist[$memberinfo['groupid']]); include template('member', 'account_manage_upgrade'); } }