function del() { global $_G; if (!$_GET['id']) { cpmsg('抱歉,要删除的评论ID不存在', 'error', "m=comment&a=main"); return false; } $id = intval($_GET['id']); if (!$_GET['ok']) { cpmsg('您确定要删除当前评论记录吗?删除后不可恢复?', 'error', "m=comment&a=del&ok=1&id=" . $id, '确定删除', "<p><a href='" . URL . "m=comment&a=main'>取消</a></p>"); } else { $rs = DB::fetch_first("SELECT * FROM " . DB::table('comment') . " WHERE id = " . $id); if ($rs[jf] > 0) { $jf = 0 - $rs[jf]; $org_jf = DB::fetch_first(" SELECT jf FROM " . DB::table('member') . " WHERE uid = " . $rs[uid]); $del = array('desc' => '删除评论扣除积分', 'type' => 'comment', 'org_jf' => $org_jf[jf], 'jf' => $jf, 'uid' => $rs[uid], 'username' => $rs[username]); insert_sign($del); update_member(array('jf' => $org_jf[jf] + $jf), $rs[uid]); } DB::delete("comment", "id=" . $id); cpmsg('删除成功', 'success', "m=comment&a=main"); } }
function band_user_order() { global $_G; if (!$this->user) { return; } //修改订单状态 $update = array(); $update['status'] = 3; //已认领 $update['uid'] = $this->user['uid']; $update['username'] = $this->user['username']; DB::update('order_list', $update, 'id=' . $this->order['id']); if ($this->order['status'] != 1) { return; } // 如果是订单付款,就再继续 //从日志中检查当前用户,是否有返利过 $res = DB::fetch_first("SELECT * FROM " . DB::table('money') . " WHERE order_id = " . $this->order['id'] . " AND uid = " . $this->user['uid']); if ($res['id'] > 0) { return; } //给用户增加返利积分 $jifen = intval($_G['setting']['order_jf_bili']); if ($jifen > 0 && $this->order['price'] > 0) { $result_jf = $this->order['price'] * ($jifen / 100); $jf = intval($result_jf); if ($jf < 1) { $jf = 1; } $add_jf = $this->user['jf'] + $jf; $msg = '通过淘客购买 ' . $this->order['title'] . " ,消费" . $this->order['price'] . "元,系统奖励" . $jf . "积分({$jifen}%)"; insert_sign(array('desc' => $msg, 'type' => 'fanli', 'org_jf' => $add_jf, 'jf' => $jf, 'uid' => $this->user['uid'], 'username' => $this->user['username'], 'aid' => $this->order['id'])); update_member(array('jf' => $add_jf), $this->user['uid']); $this->user = getuser($this->user['uid'], 'uid'); //检查当前用户是否需要升级用户组 } $groupid = $this->user['groupid']; if (!$groupid || $groupid == 3) { return; } //禁止用户 无法返利 $group = $_G['group'][$groupid]; $bili = $group['fanli']; //检查用户积分等级,得出奖劢的佣金比例 /*$bili = 0; foreach($_G['setting']['fanli_bili'] as $k=>$v){ list($down,$up,$bl) = $v; if($this->user['jf']>=$down && $this->user['jf']<$up ){ $bili = $bl; break; } }*/ //没有找到当前用户所属等级,则不返了.... if ($bili <= 0) { return; } //dump($bili.'---'.$this->user['groupid'].'---'.$this->user['username']); //用户(20)%+推荐人 (10)% + 20%的税 //将佣金分为4份 $money = $this->order['yongjin'] - $this->order['yongjin'] * (20 / 100); //先扣20%税 //给用户账户增加佣金 $member_arr = array(); $user_money = $money * ($bili / 100); //返给用户的实际佣金 $yingde_money = $money; //给推荐者返利 if ($this->user['t_uid'] > 0) { //扣税后佣金 - 用户所得的 = 站长的, 推荐者,也是分站长的 $money = $this->t_fanli($this->user['t_uid'], $money); //返回 减掉推荐者所得的,就是站长所得 } //剩下的money 就是站长所得的 if ($money <= 0) { return; } $org_money = $this->user['money']; $member_arr['money'] = $this->user['money'] + $user_money; update_member($member_arr, $this->user[uid]); $this->user['money'] = $member_arr['money']; //给佣金表,增加记录,供用户查询 $log = array(); $log['desc'] = '购物 ' . $this->order['title'] . ' 获得' . $user_money . '元' . '(' . $bili . '%)' . '返利'; $log['org_money'] = $org_money; $log['money'] = $user_money; $this->write_log($log); }
function zj_post() { global $_G; if ($_G[member][groupid] == 3) { msg('抱歉,您当前是禁止用户,无法使用', 'error', '?'); } else { if ($_G[member][check] == 0) { json('抱歉,您当前账号未审核无法使用', 'error', '?'); } } if (!$_G[setting][style_status]) { msg('抱歉,系统未开放专辑投稿功能', 'error', '?'); } if ($_GET[onsubmit] && check()) { $goods = get_filed('zj', $_GET[postdb], $_GET[id]); $goods['check'] = intval($_G[setting][zj_check]); $goods['sort'] = 0; $goods['keywords'] = $goods['keywords']; $goods['content'] = $goods['content']; $goods['title'] = $goods['title']; if (!$goods['title']) { msg('专辑标题不能为空'); } if (!$goods['picurl']) { msg('专辑主图不能为空'); } if (!$goods['tag']) { msg('专辑分类不能为空'); } if (!$goods['content']) { msg('专辑内容描述不能为空'); } if (strpos($goods[picurl], 'http:') === false) { msg('专辑的主图格式不正确'); } $goods['picurl'] = preg_replace('/_(\\d+)(.*?)$/', '', $goods['picurl']); if (!array_key_exists($goods['tag'], $_G[setting][zj_tags])) { msg('专辑的标签不存在'); } //单品 $goods[goods] = array(); foreach ($_GET[dp_num_iid] as $k => $v) { $arr = array(); $arr[title] = $_GET['dp_title'][$k]; $arr[price] = sprintf("%.1f", $_GET['dp_price'][$k]); $arr[num_iid] = get_goods_id($_GET['dp_num_iid'][$k]); $arr[content] = ''; $arr[picurl] = $_GET['dp_picurl'][$k]; if (!$arr[price] || !$arr[title] || !$arr[num_iid]) { continue; } $goods[goods][] = $arr; } $goods[length] = count($goods[goods]); if ($goods[length] > 0) { $goods[goods] = serialize($goods[goods]); } $goods['post'] = 1; $goods['like'] = 0; $url = ''; if ($_GET['id']) { $id = intval($_GET['id']); $url .= "&id=" . $id; DB::update('zj', $goods, "id=" . $id); $msg = '修改成功'; } else { $goods['dateline'] = TIMESTAMP; $goods['uid'] = $_G['uid']; $goods['username'] = $_G['username']; $r = DB::insert('zj', $goods, true); $msg = '发布成功'; $jf = intval($_G[setting][zj_jf]); if ($jf > 0 && $r > 0) { $msg .= ',恭喜您获得' . $jf . '积分'; insert_sign(array('desc' => '发布专辑信息', 'type' => 'zj', 'org_jf' => $_G[member][jf], 'jf' => $jf, 'aid' => $r)); update_member(array('jf' => $_G[member][jf] + $jf), $_G[uid]); } } msg($msg, 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . $url); } else { if ($_GET[id]) { $id = intval($_GET[id]); $goods = D(array('table' => 'zj', 'and' => ' AND id = ' . $id)); if (!$goods[id]) { msg('抱歉,未找到要编辑的专辑信息'); } if ($goods[uid] != $_G[uid]) { msg('抱歉,您无权编辑非自己发布的信息'); } if ($goods[check] == 1) { msg('已审核的信息无法再次编辑'); } } } $this->add(array('goods' => $goods)); $this->show(); }
function apply() { global $_G; $id = intval($_GET[id]); if (!is_login()) { return false; } if (!$_G[uid]) { msg('抱歉,未登录无法申请兑换', 'error', 'm=duihuan&id=' . $id); return false; } if ($_G[member][groupid] == 3) { msg('抱歉,您当前是禁止用户,无法使用', 'error', 'm=duihuan&id=' . $id); return false; } else { if ($_G[member][check] == 0) { msg('抱歉,您当前账号未审核无法使用', 'error', 'm=duihuan&id=' . $id); return false; } } $rs = D(array('table' => 'duihuan_apply', 'and' => " duihuan_id=" . $id . " AND uid=" . $_G[uid])); if ($rs[id] > 0) { $msg = '抱歉,您已申请了兑换过本商品,无法再次申请,申请时间: <span class="red">' . $rs[dateline] . '</span> <br/>'; $msg .= '当前申请状态为: <span class="red">' . $rs[status_text] . '</span>'; $msg .= '<br/>客服最后操作时间: <span class="red">' . $rs[statustime] . '</span>'; msg($msg, 'error', 'm=duihuan&id=' . $id); return false; } $goods = D(array('table' => 'duihuan', 'and' => 'id=' . $id)); if ($goods[hide] == 1) { msg('抱歉,当前兑换商品已下架', 'error', 'm=duihuan&id=' . $id); return false; } if ($goods[org_start_time] > 0 && $goods[org_start_time] > TIMESTAMP) { msg('抱歉,当前兑换未开始', 'error', 'm=duihuan&id=' . $id); return false; } if ($goods[org_end_time] > 0 && $goods[org_end_time] < TIMESTAMP) { msg('抱歉,当前兑换已结束', 'error', 'm=duihuan&id=' . $id); return false; } if ($goods[num] >= $goods[sum]) { msg('抱歉,当前兑换已申请完毕', 'error', 'm=duihuan&id=' . $id); return false; } $arr = get_filed('duihuan_apply', $_GET[postdb]); if (!$arr['wangwang']) { msg('抱歉,联系旺旺不能为空', 'error', 'm=duihuan&id=' . $id); return false; } if (!$arr['truename']) { msg('抱歉,联系人姓名不能为空', 'error', 'm=duihuan&id=' . $id); return false; } if (!$arr['address']) { msg('抱歉,收货地址不能为空', 'error', 'm=duihuan&id=' . $id); return false; } if (!$arr['phone']) { msg('抱歉,联系电话不能为空', 'error', 'm=duihuan&id=' . $id); } elseif (!is_phone($arr['phone'])) { msg('抱歉,联系电话格式不正确', 'error', 'm=duihuan&id=' . $id); } if ($arr[alipay]) { if (!is_email($arr[alipay]) && !is_phone($arr[alipay])) { msg('抱歉,支付宝账号不正确,只能为邮箱或手机号码', 'error', 'm=duihuan&id=' . $id); } } if ($goods[jf] > 0) { if ($_G[member][jf] < $goods[jf]) { msg('抱歉,当前兑换需要' . $goods[jf] . '积分,您当前积分为' . $_G[member][jf] . ',无法申请兑换', 'error', 'm=duihuan&id=' . $id); return false; } else { //更新用户积分.. $jf = 0 - $goods[jf]; $add_jf = $_G['member']['jf'] + $jf; $sid = insert_sign(array('desc' => '申请兑换-' . $goods[title] . '-id=' . $id, 'type' => 'duihuan', 'org_jf' => $add_jf, 'jf' => $jf)); if ($sid) { update_member(array('jf' => $_G[member][jf] - $goods[jf]), $_G[uid]); } } } $arr['uid'] = $_G[uid]; $arr['username'] = $_G[username]; $arr['dateline'] = TIMESTAMP; $arr['ip'] = $_G[clientip]; $arr['duihuan_id'] = $id; $arr = daddslashes($arr); DB::insert('duihuan_apply', $arr); msg('兑换申成功,请等待客服审核...', 'success', 'm=duihuan&id=' . $id); }
private function check_yaoqing($t, $arr) { global $_G; if ($t > 0 && $_G[setting][yaoqing] > 0) { //月限制 $day30 = TIMESTAMP - 3600 * 24 * 30; $count = getcount('member', ' AND t_uid=' . $t . " AND regdate>" . $day30); //天限制 $today = dmktime(dgmdate(TIMESTAMP, 'd')); $count_day = getcount('member', ' AND t_uid=' . $t . " AND regdate>" . $today); if ($count <= $_G[setting][yaoqing_num] && $count_day <= $_G[setting][yaoqing_day]) { $tmp = DB::fetch_first("SELECT * FROM " . DB::table('member') . " WHERE uid ='{$t}' "); if ($tmp[uid] > 0 && $tmp[groupid] != 3 && $tmp[check] == 1) { $update_arrr = array(); $jf = $_G[setting][yaoqing]; $add_jf = $tmp['jf'] + $jf; $sid = insert_sign(array('uid' => $tmp[uid], 'username' => $tmp[username], 'desc' => $tmp[username] . '邀请' . $arr[username] . '注册', 'type' => 'yaoqing', 'org_jf' => $add_jf, 'jf' => $jf)); //自动升级到推广组 if ($tmp['rank'] == 0 && $_GET['setting']['fanli'] == 1) { $update_arrr['rank'] = 1; } if ($sid) { $update_arrr['jf'] = $tmp[jf] + $jf; dsetcookie("t", '0', -1); } if (count($update_arrr) > 0) { update_member(array('jf' => $tmp[jf] + $jf), $tmp[uid]); } } } } }
function share_callback() { global $_G; //if($_G['inajax'] !=1) json('Eroor'); if (!is_login()) { return false; } if ($_G[member][groupid] == 3) { msg('抱歉,您当前是禁止用户,无法使用', 'error'); return false; } else { if ($_G[member][check] == 0) { msg('抱歉,您当前账号未审核无法使用', 'error'); return false; } } if (!$_GET['type']) { msg('分享类型不存在'); return; } $type = trim_html($_GET['type'], 1); if (!array_key_exists($type, $_G['setting']['share_type_callback'])) { msg('未定义的类型,无法分享', 'error'); } $id = intval($_GET[id]); if (!$id) { msg('抱歉,要分享的id不存在', 'error'); return false; } $name = $_G['setting']['share_type_callback'][$type]; $desc = '分享内容到 ' . $name . ' id=' . $id; //$count = getcount('sign'," uid = ".$_G[uid]." AND `desc`='".$desc."' AND type = '".$type."'"); $count = 0; $is_add = false; if ($count == 0) { $is_add = true; } else { $today = dmktime(dgmdate(TIMESTAMP, 'd')); $count_day = getcount('sign', " uid = " . $_G[uid] . " AND type = '" . $type . "' AND dateline >=" . $today); if ($count_day > $_G[setting][share_goods_num]) { $is_add = false; } } if ($is_add) { $jf = $_G[setting][share_goods]; $add_jf = $_G['member']['jf'] + $jf; $sid = insert_sign(array('desc' => $desc, 'type' => 'share', 'org_jf' => $add_jf, 'jf' => $jf)); if ($sid) { update_member(array('jf' => $_G[member][jf] + $jf), $_G[uid]); } } json(array('msg' => '分享成功', 'status' => 'success')); }
function reg($user) { global $_G; if ($_G[uid]) { return $_G[uid]; } $jf = intval($_G[setting][jf]); $member = get_filed('member', $member); $member[jf] = $jf; $member[login_ip] = $_G[clientip]; $member[login_time] = TIMESTAMP; $member[login_count] = 1; $user[username] = $user[username] ? $user[username] : $_G['username']; if (!$user[username]) { return false; } $u = getuser($user[username], 'username'); if ($u && $u[uid] > 0) { $_G[member] = $u; $_G[username] = $u[username]; $_G[uid] = $u['uid']; return $u['uid']; } foreach ($user as $k => $v) { $member[$k] = $v; } $member['regdate'] = TIMESTAMP; $member['regip'] = $_G[clientip]; $member['groupid'] = 10; $member['login_ip'] = $_G[clientip]; $member['login_time'] = TIMESTAMP; $member['login_count'] = 1; $member['email_check'] = intval($_G[setting][email_check]); $member['check'] = intval($_G[setting][reg_check]); $member['jf'] = intval($_G[setting][jf]); if ($_GET[type] == 'seller') { $arr[groupid] = 4; } $id = DB::insert('member', $member, true); if ($id > 0) { $_G[member] = $member; $_G[member][uid] = $id; $_G[uid] = $id; $_G[username] = $member[username]; if ($member['jf'] > 0) { insert_sign(array('desc' => '注册奖励积分', 'type' => 'system', 'org_jf' => $jf, 'jf' => $jf)); } } return $id; }
function post() { global $_G; if (!is_login()) { return false; } if (!$_G[uid]) { msg('未登录无法进行操作'); } if ($_G[member][groupid] == 3) { msg('抱歉,您当前是禁止用户,无法使用'); } else { if ($_G[member][check] == 0) { msg('抱歉,您当前账号未审核无法使用'); } } if ($_G[setting][say_status] != 1) { msg('系统已关闭评论功能'); } if ($_SESSION['comment'] && $_SESSION['comment']['time'] > 0) { $last_comment_time = $_SESSION['comment']['time'] > 0 ? TIMESTAMP - intval($_SESSION['comment']['time']) : 0; if ($last_comment_time < 5) { msg('发言太快,请休息一下吧'); } } $type = trim($_GET[type]); $id = intval($_GET[id]); if (!$id) { msg('抱歉,您要提交的id不能为空'); } if (!$type) { msg('抱歉,评论类型不能为空'); } if (!preg_match("/^[a-z_]+\$/", $type)) { msg('评论类型格式不正确'); } if (!array_key_exists($type, $_G[setting][comment_types])) { msg('当前模块不允许评论或留言'); } $content = trim($_GET[content]); if (!$content) { msg('您要评论的内容不能为空'); } $content = safe_filter($content); $comment_day = $_G[setting][comment_day] > 0 ? $_G[setting][comment_day] : 30; //天限制 $today = dmktime(dgmdate(TIMESTAMP, 'd')); $count_day = getcount('comment', " uid=" . $_G[uid] . " AND type = '" . $type . "' AND dateline>" . $today); if ($count_day > $comment_day) { msg('您今日发布的评论已超过' . $comment_day . '条,待明日再评论吧.'); } $comment_month_mod = $_G[setting][comment_month_mod] > 0 ? $_G[setting][comment_month_mod] : 300; //月限制 $day30 = dmktime(dgmdate(TIMESTAMP - 86400 * 30, 'd')); $count = getcount('comment', " uid=" . $_G[uid] . " AND type = '" . $type . "' AND dateline>" . $day30); if ($count_day > $comment_month_mod) { msg('您本月发布的 ' . $_G[setting][comment_types][$type] . ' 评论已超过' . $comment_month_mod . '条,待下月再来吧.'); } $comment_month_sum = $_G[setting][comment_month_sum] > 0 ? $_G[setting][comment_month_sum] : 1000; //不限制分类,月限制 $day30 = dmktime(dgmdate(TIMESTAMP - 86400 * 30, 'd')); $count = getcount('comment', " uid=" . $_G[uid] . " AND dateline>" . $day30); if ($count_day > $comment_month_sum) { msg('您本月发布的总评论已超过' . $comment_month_sum . '条,待下月再来吧.'); } //检查回复的主题id是否存在 $idname = $type == 'goods' ? 'aid' : 'id'; $count_len = getcount($type, $idname . '=' . $id); if (!$count_len) { msg('回复的主题不存在'); } if ($_G['setting']['comment_filter'] != 1) { $content = trim($content); // $html_arr = array('<p><img><a><b><strong><h1><h2><h3><h4><h5><h6><span><em><i><div><table><tr><td><th>'); //$html_arr = array('<p><img>'); $content = strip_tags($content); $content = str_replace(array('"', "'"), '', $content); $content = trim_html($content, 1); } $content = daddslashes($content); if ($_SESSION['comment'] && $_SESSION['comment']['time'] > 0) { $last_content = $_SESSION['comment']['content']; if ($last_content && $content == $last_content) { msg('请勿发布同样的内容'); } } $arr = array(); $arr['uid'] = $_G[uid]; $arr['username'] = $_G[username]; $arr['dateline'] = TIMESTAMP; $arr['ip'] = $_G[clientip]; $arr['type_id'] = $id; $arr['type'] = $type; $arr['content'] = $content; if ($_GET['num_iid']) { $arr['num_iid'] = trim_html($_GET['num_iid']); } if ($_GET[is_reply] && $_GET[reply_id] > 0) { $arr['is_reply'] = 1; $arr['reply_id'] = intval($_GET[reply_id]); } else { $arr['is_reply'] = 0; $arr['reply_id'] = 0; } $arr['picurl'] = ''; $arr['check'] = intval($_G[setting][comment_check]); $jf = intval($_G[setting][comment_jf]); $arr['jf'] = $jf; $insert_id = DB::insert('comment', $arr, 1); if (!$insert_id) { msg('评论失败'); } $msg = '评论成功'; if ($jf > 0) { $msg .= ',恭喜您获得' . $jf . '积分'; insert_sign(array('desc' => $msg, 'type' => 'comment', 'org_jf' => $_G[member][jf], 'jf' => $jf, 'aid' => $insert_id)); update_member(array('jf' => $_G[member][jf] + $jf), $_G[uid]); } $_SESSION['comment']['time'] = TIMESTAMP; $_SESSION['comment']['content'] = $arr['content']; $fd = table($type); if (isset($fd['comment_count'])) { $where = ''; if (isset($fd['id'])) { $where = 'id=' . $id; } else { if (isset($fd['aid'])) { $where = 'aid=' . $id; } } $count = getcount(__CLASS__, " AND type = '{$type}' AND type_id = " . $id . " AND `check` =1 "); if ($where) { $r = DB::update($type, array('comment_count' => $count), $where); } } /*$data = array('user_pic'=>$_G[member][picurl],'id'=>$insert_id,'username'=>$_G[username], 'dateline'=>TIMESTAMP,'content'=>$arr[content]); */ if ($arr[check] == 0) { $msg .= ' 需待审核后才能显示'; } if ($_G['inajax'] == 1) { json(array('status' => 'success', 'msg' => $msg, 'data' => $data)); } else { msg($msg, 'success'); } }
function share() { global $_G; $type = $_GET[type]; if ($_GET[id] || $_GET[aid]) { $aid = $_GET[id] ? intval($_GET[id]) : intval($_GET[aid]); $goods = D(array('and' => 'and aid = ' . $aid)); if ($goods[aid] > 0) { $share = get_share($goods); } $desc = '分享商品-' . $goods[title] . '-' . $type . '-aid=' . $aid; $share_type = 'share_goods'; } else { $share = get_share($goods); $desc = '分享站点'; $share_type = 'share_web'; } if (isset($share[$type]) && $share[$type]) { $url = $share[$type]; if ($_G[uid]) { $count = getcount('sign', " uid = " . $_G[uid] . " AND `desc`='" . $desc . "' AND type = '" . $share_type . "'"); $is_add = false; if ($count == 0) { $is_add = true; } $today = dmktime(dgmdate(TIMESTAMP, 'd')); $count_day = getcount('sign', " uid = " . $_G[uid] . " AND type = '" . $share_type . "' AND dateline >=" . $today); if ($share_type == 'web' || $share_type == 'share_web') { if ($count_day > $_G[setting][share_web_num]) { $is_add = false; } } elseif ($share_type == 'share_goods') { if ($count_day > $_G[setting][share_goods_num]) { $is_add = false; } } if ($is_add) { $jf = $_G[setting][share_goods]; $add_jf = $_G['member']['jf'] + $jf; $sid = insert_sign(array('desc' => $desc, 'type' => 'share_goods', 'org_jf' => $add_jf, 'jf' => $jf)); if ($sid) { update_member(array('jf' => $_G[member][jf] + $jf), $_G[uid]); } } } } else { $url = $share['weibo']; } _header("Location:" . $url); }