Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 /**
  * 更新评论的状态
  * @param string $commentid      评论ID 
  * @param integer $id            内容ID
  * @param integer $status        状态{1:通过 ,0:未审核, -1:不通过,将做删除操作}
  */
 public function status($commentid, $id, $status = -1)
 {
     if (!($comment = $this->comment_db->get_one(array('commentid' => $commentid), 'tableid, commentid'))) {
         $this->msg_code = 6;
         return false;
     }
     //为数据存储数据模型设置 数据表名。
     $this->comment_data_db->table_name($comment['tableid']);
     if (!($comment_data = $this->comment_data_db->get_one(array('id' => $id, 'commentid' => $commentid)))) {
         $this->msg_code = 6;
         return false;
     }
     //读取评论的站点配置信息
     $site = $this->comment_setting_db->get_one(array('siteid' => $comment_data['siteid']));
     if ($status == 1) {
         //通过的时候
         $sql['total'] = '+=1';
         switch ($comment_data['direction']) {
             case 1:
                 //正方
                 $sql['square'] = '+=1';
                 break;
             case 2:
                 //反方
                 $sql['anti'] = '+=1';
                 break;
             case 3:
                 //中立方
                 $sql['neutral'] = '+=1';
                 break;
         }
         //当评论被设置为通过的时候,更新评论总表的数量。
         $this->comment_db->update($sql, array('commentid' => $comment['commentid']));
         //更新评论内容状态
         $this->comment_data_db->update(array('status' => $status), array('id' => $id, 'commentid' => $commentid));
         //当评论用户ID不为空,而且站点配置了积分添加项,支付模块也存在的时候,为用户添加积分。
         if (!empty($comment_data['userid']) && !empty($site['add_point']) && module_exists('pay')) {
             pc_base::load_app_class('receipts', 'pay', 0);
             receipts::point($site['add_point'], $comment_data['userid'], $comment_data['username'], '', 'selfincome', 'Comment');
         }
     } elseif ($status == -1) {
         //删除数据
         //如果数据原有状态为已经通过,需要删除评论总表中的总数
         if ($comment_data['status'] == 1) {
             $sql['total'] = '-=1';
             switch ($comment_data['direction']) {
                 case '1':
                     //正方
                     $sql['square'] = '-=1';
                     break;
                 case '2':
                     //反方
                     $sql['anti'] = '-=1';
                     break;
                 case '3':
                     //中立方
                     $sql['neutral'] = '-=1';
                     break;
             }
             $this->comment_db->update($sql, array('commentid' => $comment['commentid']));
         }
         //删除存储表的数据
         $this->comment_data_db->delete(array('id' => $id, 'commentid' => $commentid));
         //删除存储表总数记录
         $this->comment_table_db->edit_total($comment['tableid'], '-=1');
         //当评论ID不为空,站点配置了删除的点数,支付模块存在的时候,删除用户的点数。
         if (!empty($comment_data['userid']) && !empty($site['del_point']) && module_exists('pay')) {
             pc_base::load_app_class('spend', 'pay', 0);
             $op_userid = param::get_cookie('userid');
             $op_username = param::get_cookie('admin_username');
             spend::point($site['del_point'], L('comment_point_del', '', 'comment'), $comment_data['userid'], $comment_data['username'], $op_userid, $op_username);
         }
     }
     //删除审核表中的数据
     $this->comment_check_db->delete(array('comment_data_id' => $id));
     $this->msg_code = 0;
     return true;
 }
Exemplo n.º 3
0
 /**
  * 更新评论的状态
  * @param string $reviewsid      评论ID 
  * @param integer $id            内容ID
  * @param integer $status        状态{1:通过 ,0:未审核, -1:不通过,将做删除操作}
  */
 public function status($reviewsid, $id, $status = -1)
 {
     if (!($reviews = $this->reviews_db->get_one(array('reviewsid' => $reviewsid), 'tableid, reviewsid'))) {
         $this->msg_code = 6;
         return false;
     }
     //为数据存储数据模型设置 数据表名。
     $this->reviews_data_db->table_name($reviews['tableid']);
     if (!($reviews_data = $this->reviews_data_db->get_one(array('id' => $id, 'reviewsid' => $reviewsid)))) {
         $this->msg_code = 6;
         return false;
     }
     //读取评论的站点配置信息
     $site = $this->reviews_setting_db->get_one(array('siteid' => $reviews_data['siteid']));
     if ($status == 1) {
         //通过的时候
         $sql['total'] = '+=1';
         $sql['star1'] = '+=' . $reviews_data['star1'];
         $sql['star2'] = '+=' . $reviews_data['star2'];
         $sql['star3'] = '+=' . $reviews_data['star3'];
         $sql['star4'] = '+=' . $reviews_data['star4'];
         $sql['star5'] = '+=' . $reviews_data['star5'];
         $sql['star6'] = '+=' . $reviews_data['star6'];
         $reviews = $this->reviews_db->get_one(array('reviewsid' => $reviewsid));
         $sql['allstar'] = $reviews['allstar'] + $reviews_data['star1'] + $reviews_data['star2'] + $reviews_data['star3'] + $reviews_data['star4'] + $reviews_data['star5'] + $reviews_data['star6'];
         //当评论被设置为通过的时候,更新评论总表的数量。
         $this->reviews_db->update($sql, array('reviewsid' => $reviews['reviewsid']));
         //更新评论内容状态
         $this->reviews_data_db->update(array('status' => $status), array('id' => $id, 'reviewsid' => $reviewsid));
         //当评论用户ID不为空,而且站点配置了积分添加项,支付模块也存在的时候,为用户添加积分。
         if (!empty($reviews_data['userid']) && !empty($site['add_point']) && module_exists('pay')) {
             pc_base::load_app_class('receipts', 'pay', 0);
             receipts::point($site['add_point'], $reviews_data['userid'], $reviews_data['username'], '', 'selfincome', 'reviews');
         }
     } elseif ($status == -1) {
         //删除数据
         //如果数据原有状态为已经通过,需要删除评论总表中的总数
         if ($reviews_data['status'] == 1) {
             $sql['total'] = '-=1';
             $sql['star1'] = '-=' . $reviews_data['star1'];
             $sql['star2'] = '-=' . $reviews_data['star2'];
             $sql['star3'] = '-=' . $reviews_data['star3'];
             $sql['star4'] = '-=' . $reviews_data['star4'];
             $sql['star5'] = '-=' . $reviews_data['star5'];
             $sql['star6'] = '-=' . $reviews_data['star6'];
             $reviews = $this->reviews_db->get_one(array('reviewsid' => $reviewsid));
             $sql['allstar'] = $reviews['allstar'] - $reviews_data['star1'] - $reviews_data['star2'] - $reviews_data['star3'] - $reviews_data['star4'] - $reviews_data['star5'] - $reviews_data['star6'];
             $this->reviews_db->update($sql, array('reviewsid' => $reviews['reviewsid']));
         }
         //删除存储表的数据
         $this->reviews_data_db->delete(array('id' => $id, 'reviewsid' => $reviewsid));
         //删除存储表总数记录
         $this->reviews_table_db->edit_total($reviews['tableid'], '-=1');
         //当评论ID不为空,站点配置了删除的点数,支付模块存在的时候,删除用户的点数。
         if (!empty($reviews_data['userid']) && !empty($site['del_point']) && module_exists('pay')) {
             pc_base::load_app_class('spend', 'pay', 0);
             $op_userid = param::get_cookie('userid');
             $op_username = param::get_cookie('admin_username');
             spend::point($site['del_point'], L('reviews_point_del', '', 'reviews'), $reviews_data['userid'], $reviews_data['username'], $op_userid, $op_username);
         }
     }
     //删除审核表中的数据
     $this->reviews_check_db->delete(array('reviews_data_id' => $id));
     $this->msg_code = 0;
     return true;
 }
Exemplo n.º 4
0
 function info_top_cost()
 {
     $amount = $msg = '';
     $memberinfo = $this->memberinfo;
     $_username = $this->memberinfo['username'];
     $_userid = $this->memberinfo['userid'];
     $infos = getcache('info_setting', 'commons');
     $toptype_arr = array(1, 2, 3);
     //置顶积分数组
     $toptype_price = array('1' => $infos['top_city'], '2' => $infos['top_zone'], '3' => $infos['top_district']);
     //置顶推荐位数组
     $toptype_posid = array('1' => $infos['top_city_posid'], '2' => $infos['top_zone_posid'], '3' => $infos['top_district_posid']);
     if (isset($_POST['dosubmit'])) {
         $posids = array();
         $push_api = pc_base::load_app_class('push_api', 'admin');
         $pos_data = pc_base::load_model('position_data_model');
         $catid = intval($_POST['catid']);
         $id = intval($_POST['id']);
         $flag = $catid . '_' . $id;
         $toptime = intval($_POST['toptime']);
         if ($toptime == 0 || empty($_POST['toptype'])) {
             showmessage(L('info_top_not_setting_toptime'));
         }
         //计算置顶扣费积分,时间
         if (is_array($_POST['toptype']) && !empty($_POST['toptype'])) {
             foreach ($_POST['toptype'] as $r) {
                 if (is_numeric($r) && in_array($r, $toptype_arr)) {
                     $posids[] = $toptype_posid[$r];
                     $amount += $toptype_price[$r];
                     $msg .= $r . '-';
                 }
             }
         }
         //应付总积分
         $amount = $amount * $toptime;
         //扣除置顶点数
         pc_base::load_app_class('spend', 'pay', 0);
         $pay_status = spend::point($amount, L('info_top') . $msg, $_userid, $_username, '', '', $flag);
         if ($pay_status == false) {
             $msg = spend::get_msg();
             showmessage($msg);
         }
         //置顶过期时间
         //TODO
         $expiration = SYS_TIME + $toptime * 3600;
         //获取置顶文章信息内容
         if (isset($catid) && $catid) {
             $siteids = getcache('category_content', 'commons');
             $siteid = $siteids[$catid];
             $CATEGORYS = getcache('category_content_' . $siteid, 'commons');
             $category = $CATEGORYS[$catid];
             if ($category['type'] == 0) {
                 $modelid = $category['modelid'];
                 $this->model = getcache('model', 'commons');
                 $this->content_db = pc_base::load_model('content_model');
                 $this->content_db->set_model($modelid);
                 $this->content_db->table_name = $this->content_db->db_tablepre . $this->model[$modelid]['tablename'];
                 $r = $this->content_db->get_one(array('id' => $id, 'username' => $_username, 'sysadd' => 0));
             }
         }
         if (!$r) {
             showmessage(L('illegal_operation'));
         }
         $push_api->position_update($id, $modelid, $catid, $posids, $r, $expiration, 1);
         $refer = $_POST['msg'] ? $r['url'] : '';
         if ($_POST['msg']) {
             showmessage(L('ding_success'), $refer);
         } else {
             showmessage(L('ding_success'), '', '', 'top');
         }
     } else {
         $toptype = trim($_POST['toptype']);
         $toptime = trim($_POST['toptime']);
         $types = explode('_', $toptype);
         if (is_array($types) && !empty($types)) {
             foreach ($types as $r) {
                 if (is_numeric($r) && in_array($r, $toptype_arr)) {
                     $amount += $toptype_price[$r];
                 }
             }
         }
         $amount = $amount * $toptime;
         echo $amount;
     }
 }
Exemplo n.º 5
0
 /**
  * 过审内容
  */
 public function pass()
 {
     $admin_username = param::get_cookie('admin_username');
     $catid = intval($_GET['catid']);
     if (!$catid) {
         showmessage(L('missing_part_parameters'));
     }
     $category = $this->categorys[$catid];
     $setting = string2array($category['setting']);
     $workflowid = $setting['workflowid'];
     //只有存在工作流才需要审核
     if ($workflowid) {
         $steps = intval($_GET['steps']);
         //检查当前用户有没有当前工作流的操作权限
         $workflows = getcache('workflow_' . $this->siteid, 'commons');
         $workflows = $workflows[$workflowid];
         $workflows_setting = string2array($workflows['setting']);
         //将有权限的级别放到新数组中
         $admin_privs = array();
         foreach ($workflows_setting as $_k => $_v) {
             if (empty($_v)) {
                 continue;
             }
             foreach ($_v as $_value) {
                 if ($_value == $admin_username) {
                     $admin_privs[$_k] = $_k;
                 }
             }
         }
         if ($_SESSION['roleid'] != 1 && $steps && !in_array($steps, $admin_privs)) {
             showmessage(L('permission_to_operate'));
         }
         //更改内容状态
         if (isset($_GET['reject'])) {
             //退稿
             $status = 0;
         } else {
             //工作流审核级别
             $workflow_steps = $workflows['steps'];
             if ($workflow_steps > $steps) {
                 $status = $steps + 1;
             } else {
                 $status = 99;
             }
         }
         $modelid = $this->categorys[$catid]['modelid'];
         $this->db->set_model($modelid);
         //审核通过,检查投稿奖励或扣除积分
         if ($status == 99) {
             $html = pc_base::load_app_class('html', 'content');
             $this->url = pc_base::load_app_class('url', 'content');
             $member_db = pc_base::load_model('member_model');
             if (isset($_POST['ids']) && !empty($_POST['ids'])) {
                 foreach ($_POST['ids'] as $id) {
                     $content_info = $this->db->get_content($catid, $id);
                     $memberinfo = $member_db->get_one(array('username' => $content_info['username']), 'userid, username');
                     $flag = $catid . '_' . $id;
                     if ($setting['presentpoint'] > 0) {
                         pc_base::load_app_class('receipts', 'pay', 0);
                         receipts::point($setting['presentpoint'], $memberinfo['userid'], $memberinfo['username'], $flag, 'selfincome', L('contribute_add_point'), $memberinfo['username']);
                     } else {
                         pc_base::load_app_class('spend', 'pay', 0);
                         spend::point($setting['presentpoint'], L('contribute_del_point'), $memberinfo['userid'], $memberinfo['username'], '', '', $flag);
                     }
                     if ($setting['content_ishtml'] == '1') {
                         //栏目有静态配置
                         $urls = $this->url->show($id, 0, $content_info['catid'], $content_info['inputtime'], '', $content_info, 'add');
                         $html->show($urls[1], $urls['data'], 0);
                     }
                 }
             } else {
                 if (isset($_GET['id']) && $_GET['id']) {
                     $id = intval($_GET['id']);
                     $content_info = $this->db->get_content($catid, $id);
                     $memberinfo = $member_db->get_one(array('username' => $content_info['username']), 'userid, username');
                     $flag = $catid . '_' . $id;
                     if ($setting['presentpoint'] > 0) {
                         pc_base::load_app_class('receipts', 'pay', 0);
                         receipts::point($setting['presentpoint'], $memberinfo['userid'], $memberinfo['username'], $flag, 'selfincome', L('contribute_add_point'), $memberinfo['username']);
                     } else {
                         pc_base::load_app_class('spend', 'pay', 0);
                         spend::point($setting['presentpoint'], L('contribute_del_point'), $memberinfo['userid'], $memberinfo['username'], '', '', $flag);
                     }
                     //单篇审核,生成静态
                     if ($setting['content_ishtml'] == '1') {
                         //栏目有静态配置
                         $urls = $this->url->show($id, 0, $content_info['catid'], $content_info['inputtime'], '', $content_info, 'add');
                         $html->show($urls[1], $urls['data'], 0);
                     }
                 }
             }
         }
         if (isset($_GET['ajax_preview'])) {
             $_POST['ids'] = $_GET['id'];
         }
         $this->db->status($_POST['ids'], $status);
     }
     showmessage(L('operation_success'), HTTP_REFERER);
 }
Exemplo n.º 6
0
 /**
  * 积分兑换
  */
 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');
     }
 }
Exemplo n.º 7
0
 /**
  * 用户升级
  */
 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');
     }
 }
Exemplo n.º 8
0
 /**
  * 检查支付状态
  */
 private function _check_payment($flag, $paytype)
 {
     $_userid = param::get_cookie('_userid');
     $_username = param::get_cookie('_username');
     if (!$_userid) {
         return false;
     }
     pc_base::load_app_class('spend', 'pay', 0);
     $setting = $this->category_setting;
     $repeatchargedays = intval($setting['repeatchargedays']);
     if ($repeatchargedays) {
         $fromtime = SYS_TIME - 86400 * $repeatchargedays;
         $r = spend::spend_time($_userid, $fromtime, $flag);
         if ($r['id']) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 9
0
 function addscore($id, $point = 0)
 {
     $M = getcache('ask', 'commons');
     $M = $M[1];
     $_username = param::get_cookie('_username');
     $_userid = param::get_cookie('_userid');
     $r_m = $this->db->get_one("point", $this->db_tablepre . "member", "userid='{$_userid}'");
     if (!$r_m) {
         return false;
     }
     $_point = $r_m['point'];
     if ($point > $_point) {
         return false;
     }
     $id = intval($id);
     $point = intval($point);
     $r = $this->db->get_one("userid,username", $this->table_name, "askid='{$id}'");
     if ($r['userid'] != $_userid) {
         showmessage(L('no_edit_other_people_info'), HTTP_REFERER);
     }
     $this->db->update("reward=reward+{$point},endtime=endtime+432000", $this->table_name, "askid='{$id}' AND userid={$_userid}");
     $this->db->update("flag=2", $this->table_name, "askid={$id} AND flag=0 AND reward >= {$M['height_score']}");
     $this->credit->update_credit($_userid, $_username, $point, 0);
     pc_base::load_app_class('spend', 'pay', 0);
     spend::point($point, L('enhances_credit'), $_userid, $_username, '', '', $flag);
     return true;
 }
Exemplo n.º 10
0
 /**
  * 积分兑换
  */
 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');
     }
 }
Exemplo n.º 11
0
	public function del() {
		if (isset($_GET['dosubmit']) && $_GET['dosubmit']) {
			$ids = $_GET['ids'];
			$tableid = isset($_GET['tableid']) ? intval($_GET['tableid']) : 0;
			$r = $this->comment_db->get_one(array(), 'MAX(tableid) AS tableid');
			$max_table = $r['tableid'];
			if (!$tableid || $max_table<$tableid) showmessage(L('illegal_operation'));
			$this->comment_data_db->table_name($tableid);
			$site = $this->comment_setting_db->site($this->siteid);
			if (is_array($ids)) {
				foreach ($ids as $id) {
					$comment_info = $this->comment_data_db->get_one(array('id'=>$id), 'commentid, userid, username');
					$this->comment_db->update(array('total'=>'-=1'), array('commentid'=>$comment_info['commentid']));
					$this->comment_data_db->delete(array('id'=>$id));

					//当评论ID不为空,站点配置了删除的点数,支付模块存在的时候,删除用户的点数。
					if (!empty($comment_info['userid']) && !empty($site['del_point']) && module_exists('pay')) {
						pc_base::load_app_class('receipts', 'pay', 0);
						$op_userid = param::get_cookie('userid');
						$op_username = param::get_cookie('admin_username');
						spend::point($site['del_point'], L('comment_point_del', '', 'comment'), $comment_info['userid'], $comment_info['username'], $op_userid, $op_username);
					}
				}
				$ids = implode(',', $ids);
			} elseif (is_numeric($ids)) {
				$id = intval($ids);
				$comment_info = $this->comment_data_db->get_one(array('id'=>$id), 'commentid, userid, username');
				$this->comment_db->update(array('total'=>'-=1'), array('commentid'=>$comment_info['commentid']));
				$this->comment_data_db->delete(array('id'=>$id));

				//当评论ID不为空,站点配置了删除的点数,支付模块存在的时候,删除用户的点数。
				if (!empty($comment_info['userid']) && !empty($site['del_point']) && module_exists('pay')) {
					pc_base::load_app_class('spend', 'pay', 0);
					$op_userid = param::get_cookie('userid');
					$op_username = param::get_cookie('admin_username');
					spend::point($site['del_point'], L('comment_point_del', '', 'comment'), $comment_info['userid'], $comment_info['username'], $op_userid, $op_username);
				}
			} else {
				showmessage(L('illegal_operation'));
			}
			showmessage(L('operation_success'), HTTP_REFERER);
		}
	}
Exemplo n.º 12
0
 /**
  * 检查支付状态
  */
 private function _check_payment($flag, $paytype, $catid)
 {
     $_userid = cookie('_userid');
     $_username = cookie('_username');
     $CATEGORYS = S('common/category_content');
     $this->category = $CATEGORYS[$catid];
     $this->category_setting = string2array($this->category['setting']);
     if (!$_userid) {
         return false;
     }
     Loader::lib('pay:spend', false);
     $setting = $this->category_setting;
     $repeatchargedays = intval($setting['repeatchargedays']);
     if ($repeatchargedays) {
         $fromtime = TIME - 86400 * $repeatchargedays;
         $r = spend::spend_time($_userid, $fromtime, $flag);
         if ($r['id']) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 13
0
 /**
  * 过审内容
  */
 public function pass()
 {
     $admin_username = cookie('admin_username');
     $catid = intval($_GET['catid']);
     if (!$catid) {
         showmessage(L('missing_part_parameters'));
     }
     $category = $this->categorys[$catid];
     $setting = string2array($category['setting']);
     $workflowid = $setting['workflowid'];
     // 只有存在工作流才需要审核
     if ($workflowid) {
         $steps = intval($_GET['steps']);
         // 检查当前用户有没有当前工作流的操作权限
         $workflows = S('common/workflow');
         $workflows = $workflows[$workflowid];
         $workflows_setting = string2array($workflows['setting']);
         // 将有权限的级别放到新数组中
         $admin_privs = array();
         foreach ($workflows_setting as $_k => $_v) {
             if (empty($_v)) {
                 continue;
             }
             foreach ($_v as $_value) {
                 if ($_value == $admin_username) {
                     $admin_privs[$_k] = $_k;
                 }
             }
         }
         if ($_SESSION['roleid'] != 1 && $steps && !in_array($steps, $admin_privs)) {
             showmessage(L('permission_to_operate'));
         }
         // 更改内容状态
         if (isset($_GET['reject'])) {
             // 退稿
             $status = 0;
         } else {
             // 工作流审核级别
             $workflow_steps = $workflows['steps'];
             if ($workflow_steps > $steps) {
                 $status = $steps + 1;
             } else {
                 $status = 99;
             }
         }
         $modelid = $this->categorys[$catid]['modelid'];
         $this->db->set_model($modelid);
         // 审核通过,检查投稿奖励或扣除积分
         if ($status == 99) {
             $member_db = Loader::model('member_model');
             foreach ($_POST['ids'] as $id) {
                 $content_info = $this->db->where(array('id' => $id))->field('username')->find();
                 $memberinfo = $member_db->where(array('username' => $content_info['username']))->field('userid, username')->find();
                 $flag = $catid . '_' . $id;
                 if ($setting['presentpoint'] > 0) {
                     Loader::lib('pay:receipts', false);
                     receipts::point($setting['presentpoint'], $memberinfo['userid'], $memberinfo['username'], $flag, 'selfincome', L('contribute_add_point'), $memberinfo['username']);
                 } else {
                     Loader::lib('pay:spend', false);
                     spend::point($setting['presentpoint'], L('contribute_del_point'), $memberinfo['userid'], $memberinfo['username'], '', '', $flag);
                 }
             }
         }
         if (isset($_GET['ajax_preview'])) {
             $_POST['ids'] = $_GET['id'];
         }
         $this->db->status($_POST['ids'], $status);
     }
     showmessage(L('operation_success'), HTTP_REFERER);
 }
Exemplo n.º 14
0
	/**
	 * 检查支付状态
	 */
	protected function _check_payment($flag,$paytype) {
		$_userid = $this->_userid;
		$_username = $this->_username;
		if(!$_userid) return false;
		pc_base::load_app_class('spend','pay',0);
		$setting = $this->category_setting;
		$repeatchargedays = intval($setting['repeatchargedays']);
		if($repeatchargedays) {
			$fromtime = SYS_TIME - 86400 * $repeatchargedays;
			$r = spend::spend_time($_userid,$fromtime,$flag);
			if($r['id']) return true;
		}
		return false;
	}
Exemplo n.º 15
0
 /**
  * 检查支付状态
  */
 private function _check_payment($flag, $paytype, $catid)
 {
     $_userid = param::get_cookie('_userid');
     $_username = param::get_cookie('_username');
     $siteids = getcache('category_content', 'commons');
     $siteid = $siteids[$catid];
     $CATEGORYS = getcache('category_content_' . $siteid, 'commons');
     $this->category = $CATEGORYS[$catid];
     $this->category_setting = string2array($this->category['setting']);
     if (!$_userid) {
         return false;
     }
     pc_base::load_app_class('spend', 'pay', 0);
     $setting = $this->category_setting;
     $repeatchargedays = intval($setting['repeatchargedays']);
     if ($repeatchargedays) {
         $fromtime = SYS_TIME - 86400 * $repeatchargedays;
         $r = spend::spend_time($_userid, $fromtime, $flag);
         if ($r['id']) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 16
0
 /**
  * 检查支付状态
  */
 protected function _check_payment($flag, $paytype)
 {
     $_userid = $this->_userid;
     $_username = $this->_username;
     if (!$_userid) {
         return false;
     }
     Loader::lib('pay:spend');
     $setting = $this->category_setting;
     $repeatchargedays = intval($setting['repeatchargedays']);
     if ($repeatchargedays) {
         $fromtime = TIME - 86400 * $repeatchargedays;
         $r = spend::spend_time($_userid, $fromtime, $flag);
         if ($r['id']) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 17
0
 public function show()
 {
     pc_base::load_sys_class('form', '', 0);
     $M = getcache('ask', 'commons');
     $M = $M[1];
     $_username = param::get_cookie('_username', L('phpcms_friends'));
     $_userid = param::get_cookie('_userid');
     $r_m = $this->db_m->get_one(array('userid' => $_userid, 'siteid' => SITEID));
     $_point = $r_m['point'];
     $id = intval($_GET['id']);
     if (!$id) {
         showmessage(L('illegal_parameters'), HTTP_REFERER);
     }
     $array = array();
     $a = $this->db->get_one(array('askid' => $id, 'siteid' => SITEID));
     $posts_table_name = $this->db2->posts_table($a['catid']);
     $this->db2->table_name = $posts_table_name;
     if (!$this->db2->table_exists(str_replace($this->db2->db_tablepre, '', $posts_table_name))) {
         showmessage(L('info_does_not_exists'), HTTP_REFERER);
     }
     $result = $this->db2->select("askid={$id} AND status>2 AND siteid=" . SITEID, '*');
     foreach ($result as $r) {
         if ($r['isask']) {
             $arr = $this->db->get_one(array('askid' => $id, 'siteid' => SITEID));
             $r['title'] = $arr['title'];
             $r['reward'] = $arr['reward'];
             $r['status'] = $arr['status'];
             $r['answercount'] = $arr['answercount'];
             $r['flag'] = $arr['flag'];
             $r['endtime'] = $arr['endtime'];
             $r['catid'] = $arr['catid'];
             $r['hits'] = $arr['hits'];
             $r['anonymity'] = $arr['anonymity'];
             $rs['keywords'] = $arr['keywords'];
             $r['keywords'] = explode(' ', $arr['keywords']);
             if (SYS_TIME > $r['endtime'] && !$arr['ischeck']) {
                 $this->db->update(array('ischeck' => '1'), array('askid' => $id));
                 $this->db->update(array('flag' => '3'), 'askid=' . $id . ' AND answercount>1');
                 $this->db2->update(array('candidate' => '1'), array('askid' => $id));
                 $this->db_credit->update($arr['userid'], $arr['username'], $M['del_day15_credit'], 0);
                 pc_base::load_app_class('spend', 'pay', 0);
                 spend::point($M['del_day15_credit'], L('ask_15days_no_deal_with'), $arr['userid'], $arr['username'], '', '', $flag);
             }
         }
         $userids[] = $r['userid'];
         $array[] = $r;
     }
     if ($userids) {
         $userids = implode(',', $userids);
         $data = $this->db_m->select("userid IN ({$userids}) AND siteid=" . SITEID, '*');
         foreach ($data as $r) {
             $userinfo[$r['userid']]['actortype'] = $r['actortype'];
             $userinfo[$r['userid']]['point'] = $r['point'];
         }
         foreach ($array as $arr) {
             $arr['actortype'] = $userinfo[$arr['userid']]['actortype'];
             $arr['point'] = $userinfo[$arr['userid']]['point'];
             $_array[] = $arr;
         }
         $array = $_array;
     } else {
         $array = $array;
     }
     if ($array) {
         $have_answer = false;
         foreach ($array as $k => $v) {
             if ($v['isask']) {
                 $title = $v['title'];
                 $message = $this->M[1]['use_editor'] ? $v['message'] : trim_textarea($v['message']);
                 $reward = $v['reward'];
                 $userid = $v['userid'];
                 $username = $v['username'];
                 $nickname = get_nickname($v['userid']);
                 $status = $v['status'];
                 $hits = $v['hits'];
                 $flag = $v['flag'];
                 $addtime = $v['addtime'];
                 $actor = actor($v['actortype'], $v['point']);
                 $answercount = $v['answercount'];
                 $result = count_down($v['endtime']);
                 $day = $result[0];
                 $hour = $result[1];
                 $minute = $result[2];
                 $catid = $v['catid'];
                 $anonymity = $v['anonymity'];
                 $keywords = $v['keywords'];
             } elseif ($v['optimal']) {
                 $best_answer_pid = $v['pid'];
                 $best_answer_vote_1 = $v['best_answer_vote_1'];
                 $best_answer_vote_2 = $v['best_answer_vote_2'];
                 $totalnum = $best_answer_vote_1 + $best_answer_vote_2;
                 $best_answer_vote_1_per = round($best_answer_vote_1 / $totalnum * 100, 1) . "%";
                 $best_answer_vote_2_per = round($best_answer_vote_2 / $totalnum * 100, 1) . "%";
                 $solvetime = $v['solvetime'];
                 $answer = $v['message'];
                 $answertime = $v['addtime'];
                 $answer = trim_textarea($v['message']);
                 $optimail_username = $v['username'];
                 $optimail_userid = $v['userid'];
                 $optimail_nickname = get_nickname($v['userid']);
                 $optimal_actor = actor($v['actortype'], $v['point']);
             } else {
                 if ($v['userid'] == $_userid) {
                     $have_answer = true;
                 }
                 $infos[$k]['pid'] = $v['pid'];
                 $infos[$k]['userid'] = $v['userid'];
                 $infos[$k]['username'] = $v['username'];
                 $infos[$k]['nickname'] = get_nickname($v['userid']);
                 $infos[$k]['addtime'] = $v['addtime'];
                 $infos[$k]['candidate'] = $v['candidate'];
                 $infos[$k]['anonymity'] = $v['anonymity'];
                 $infos[$k]['actor'] = actor($v['actortype'], $v['point']);
                 $infos[$k]['message'] = $this->M[1]['use_editor'] ? $v['message'] : trim_textarea($v['message']);
             }
         }
         if ($v['optimal']) {
             $answercount = $answercount - 1;
         }
         if ($userid == $_userid) {
             $isask = 1;
         } else {
             $isask = 0;
         }
         if (isset($action) && $action == 'vote') {
             if ($flag == 1) {
                 exit;
             }
             $tpl = 'vote';
         } else {
             $tpl = 'show';
         }
         if ($status == 1) {
             showmessage(L('info_does_not_exists'), HTTP_REFERER);
         }
         if ($userid != $_userid) {
             $this->db->update(array('hits' => '+=1'), array('askid' => $id));
         }
         $description = $answer ? str_cut($answer, '200') : str_cut($message, '200');
         $SEO = seo(SITEID, $catid, $title, $description, $seo_keywords);
         include template('ask', $tpl);
     } else {
         showmessage(L('info_does_not_exists'), HTTP_REFERER);
     }
 }
Exemplo n.º 18
0
	/**
	 * 添加消费记录
	 * @param array $data 添加消费记录参数
	 */
	private static function _add($data) {
		$data['userid'] = isset($data['userid']) && intval($data['userid']) ? intval($data['userid']) : 0;
		$data['username'] = isset($data['username']) ? trim($data['username']) : '';
		$data['op_userid'] = isset($data['op_userid']) && intval($data['op_userid']) ? intval($data['op_userid']) : 0;
		$data['op_username'] = isset($data['op_username']) ? trim($data['op_username']) : '';
		$data['type'] = isset($data['type']) && intval($data['type']) ? intval($data['type']) : 0;
		$data['value'] = isset($data['value']) && intval($data['value']) ? abs(intval($data['value'])) : 0;
		$data['msg'] = isset($data['msg']) ? trim($data['msg']) : '';
		$data['logo'] = isset($data['logo']) ? trim($data['logo']) : '';
		$data['creat_at'] = SYS_TIME;
		
		//检察消费类型
		if (!in_array($data['type'], array(1,2))) {
			return false;
		}
		
		//检察消费描述
		if (empty($data['msg'])) {
			self::$msg = 1;
			return false;
		}
		
		//检察消费金额
		if (empty($data['value'])) {
			self::$msg = 2;
			return false;
		}
		
		//检察userid和username并偿试再次的获取
		if (empty($data['userid']) || empty($data['username'])) {
			if (defined('IN_ADMIN')) {
				self::$msg = 3;
				return false;
			} elseif (!$data['userid'] = param::get_cookie('_userid') || !$data['username'] = param::get_cookie('_username')) {
				self::$msg = 3;
				return false;
			} else {
				self::$msg = 3;
				return false;
			}
		}
		
		//检察op_userid和op_username并偿试再次的获取
		if (defined('IN_ADMIN') && (empty($data['op_userid']) || empty($data['op_username']))) {
			$data['op_username'] = param::get_cookie('admin_username');
			$data['op_userid'] = param::get_cookie('userid');
		}
		
		//数据库连接
		if (empty(self::$db)) {
			self::connect();
		}
		$member_db = pc_base::load_model('member_model');
		
		//判断用户的金钱或积分是否足够。
		if (!self::_check_user($data['userid'], $data['type'], $data['value'], $member_db)) {
			self::$msg = 6;
			return false;
		} 
				
		$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;
		}
		
		//进入数据库操作
		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;
		}
	}
Exemplo n.º 19
0
 /**
  * 更新评论的状态
  *
  * @param string $commentid 评论ID
  * @param integer $id 内容ID
  * @param integer $status 状态{1:通过 ,0:未审核, -1:不通过,将做删除操作}
  */
 public function status($commentid, $id, $status = -1)
 {
     if (!($comment = $this->comment_db->where(array('commentid' => $commentid))->field('tableid, commentid')->find())) {
         $this->msg_code = 6;
         return false;
     }
     // 为数据存储数据模型设置 数据表名。
     $this->comment_data_db->table_name($comment['tableid']);
     if (!($comment_data = $this->comment_data_db->where(array('id' => $id, 'commentid' => $commentid))->find())) {
         $this->msg_code = 6;
         return false;
     }
     // 读取评论的站点配置信息
     $site = S('common/comment');
     if ($status == 1) {
         // 通过的时候
         $sql['total'] = '+=1';
         // 当评论被设置为通过的时候,更新评论总表的数量。
         $this->comment_db->where(array('commentid' => $comment['commentid']))->update($sql);
         // 更新评论内容状态
         $this->comment_data_db->where(array('id' => $id, 'commentid' => $commentid))->update(array('status' => $status));
         // 当评论用户ID不为空,而且站点配置了积分添加项,支付模块也存在的时候,为用户添加积分。
         if (!empty($comment_data['userid']) && !empty($site['add_point']) && app_exists('pay')) {
             Loader::lib('pay:receipts', false);
             receipts::point($site['add_point'], $comment_data['userid'], $comment_data['username'], '', 'selfincome', 'Comment');
         }
     } elseif ($status == -1) {
         // 删除数据
         // 如果数据原有状态为已经通过,需要删除评论总表中的总数
         if ($comment_data['status'] == 1) {
             $sql['total'] = '-=1';
             $this->comment_db->where(array('commentid' => $comment['commentid']))->update($sql);
         }
         // 删除存储表的数据
         $this->comment_data_db->where(array('id' => $id, 'commentid' => $commentid))->delete();
         // 删除存储表总数记录
         $this->comment_table_db->edit_total($comment['tableid'], '-=1');
         // 当评论ID不为空,站点配置了删除的点数,支付模块存在的时候,删除用户的点数。
         if (!empty($comment_data['userid']) && !empty($site['del_point']) && app_exists('pay')) {
             Loader::lib('pay:receipts', false);
             $op_userid = cookie('userid');
             $op_username = cookie('admin_username');
             spend::point($site['del_point'], L('comment_point_del', '', 'comment'), $comment_data['userid'], $comment_data['username'], $op_userid, $op_username);
         }
     }
     // 删除审核表中的数据
     $this->comment_check_db->where(array('comment_data_id' => $id))->delete();
     $this->msg_code = 0;
     return true;
 }