function insert($arr) { global $_G; return true; $image = get_filed(__CLASS__); $image[dateline] = TIMESTAMP; $image[uid] = $_G[uid]; foreach ($arr as $k => $v) { if (array_key_exists($k, $image)) { $image[$k] = $v; } } $image[uid] = intval($image[uid]); return DB::insert('images', $image, true); }
function post() { global $_G; if ($_GET['onsubmit']) { //dump($_GET,1); $article = get_filed(__CLASS__, $_GET['postdb'], $_GET['id']); $article['hide'] = intval($article['hide']); $article['sort'] = intval($article['sort']); $article['cate'] = intval($article['cate']); $article['views'] = intval($article['views']); if ($_FILES[file]) { $src = upload(); if ($src) { $article[picurl] = $src; } } if (!$article['keywords'] && $_G[setting][auto_keywords] == 1) { $article['keywords'] = get_keywords($article['title']); } if (!$article[description]) { $article[description] = cutstr(trim_html($article[message], 1), 250, ''); } $url = ''; if ($_GET['id']) { $id = intval($_GET['id']); DB::update(__CLASS__, $article, "id=" . $id); $url = '&id=' . $id; $msg = '修改'; api_post(array('a' => 'update', 'table' => 'article', 'data' => $article, 'pre_key' => 'id', 'id' => $id)); } else { $msg = '发布'; $article['dateline'] = TIMESTAMP; $r = DB::insert(__CLASS__, $article, true); if ($r > 0) { api_post(array('a' => 'insert', 'table' => 'article', 'data' => $article, 'id' => $r)); } } cpmsg($msg . '成功', 'success'); return false; } elseif ($_GET['id']) { $id = intval($_GET['id']); $article = DB::fetch_first("SELECT * FROM " . DB::table("article") . " WHERE id = " . $id); $article = dstripcslashes($article); } else { if (!$_GET[cate]) { $cate = $_G[__CLASS__ . '_cate']; $this->add(array('cate' => $cate)); $this->show('common_admin/select_post'); return; } else { $article = get_filed(__CLASS__); } } $this->add(array('article' => $article)); $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); }
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 post_img() { global $_G, $app; if (!$_GET['data']) { $this->json(array('msg' => '要同步的数据不能为空', 'code' => 2)); return false; } $data = $_GET['data']; $arr = json_decode($data, true); if (!is_array($arr) || !$arr) { $arr = json_decode(urldecode_utf8($data), true); } if (!is_array($arr) || !$arr) { $this->json(array('msg' => '要同步的数据解析失败', 'code' => 3)); return false; } $filed = table('img'); $img = get_filed('img', $arr); $img['hide'] = intval($img['hide']); $img['sort'] = intval($img['sort']); $img['hate'] = intval($img['hate']); $img['like'] = intval($img['like']); if ($arr['desc']) { $img[description] = $arr['desc']; } $img[message] = trim($img[message]); $img['dateline'] = TIMESTAMP; foreach ($img as $k1 => $v1) { if (!array_key_exists($k1, $filed)) { unset($img[$k1]); } if (is_string($v1)) { $img[$k1] = str_replace(array('¥', '¥'), array('', ''), $v1); } } if (preg_match("/^[0-9\\.]+\$/is", $img[description])) { $img[description] = ''; } if (!$img[description]) { if (strpos($img[message], '###{') !== false) { $img[description] = preg_replace("/###\\{(.*?)\\}###/is", '', $img[message]); $img[description] = cutstr(trim_html($img[description], 1), 250, ''); } } $count = getcount('img', "title='" . $img[title] . "'"); if ($count > 0) { $this->json(array('status' => 'error', 'id' => 0, 'msg' => '当前看图购已发布过')); return false; } if (!$img[title]) { $this->json(array('status' => 'error', 'id' => 0, 'msg' => '标题不能为空')); return false; } $id = DB::insert('img', $img, true); if ($id > 0) { $this->json(array('status' => 'success', 'id' => $id)); return false; } else { if (defined('ERROR') && ERROR === true) { if (DB::error()) { $msg = 'DB Error : ' . DB::error(); } else { $msg = urlencode_utf8($_G['error_msg']); } $this->json(array('status' => 'error', 'id' => $return_id, 'msg' => $msg)); return false; } else { $this->json(array('status' => 'error', 'id' => $id, 'msg' => '未成功,数据库未报错')); return false; } } }
function post() { global $_G; $login_type = array(); $t = array(); if ($_GET['onsubmit'] && check()) { $arr = get_filed(__CLASS__, $_GET['postdb'], $_GET[uid]); $arr['auto_update'] = intval($_GET['postdb']['auto_update']); $arr[jf] = intval($arr[jf]); if ($_GET[password]) { $password = trim($_GET[password]); $arr['key'] = random(10); $arr[password] = authcode($password, 'encode', $arr['key']); } else { unset($arr[password]); } if ($_FILES[file]) { // $pic = upload(); if ($pic) { $arr[picurl] = $pic; } } if ($_GET[uid] > 0) { unset($arr['username']); $uid = intval($_GET['uid']); update_member($arr, $uid); //DB::update('member',$arr,'uid='.$uid); cpmsg('编辑成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . '&uid=' . $uid); } else { DB::insert('member', $arr); cpmsg('添加会员成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__); } return false; } elseif ($_GET['uid'] > 0) { $uid = intval($_GET['uid']); $mb = getuser($uid, 'uid'); foreach ($mb as $k => $v) { $member[$k] = $v; } if ($member['org_login_time']) { $member['login_time'] = dgmdate($member['org_login_time'], 'dt'); } if ($member['org_regdate']) { $member['regdate'] = dgmdate($member['org_regdate'], 'dt'); } $login_type = array('qq' => 'qq', 'weibo' => '微博', 'taobao' => '淘宝'); if ($member['end_time']) { $member['end_time'] = dgmdate($member['end_time'], 'dt'); } if ($member[t_uid] > 0) { $t = getuser($member[t_uid], 'uid'); } } else { $member = get_filed(__CLASS__); } $this->add(array('member' => $member, 'login_type' => $login_type, 't' => $t)); $this->show(); }
function cate_add() { global $_G; if ($_GET['onsubmit'] && check()) { $cate = get_filed('cate', $_GET['postdb'], $_GET['id']); $cate['page'] = $cate['page'] ? intval($cate['page']) : 20; $url = ''; if ($_FILES[file]) { $pic = upload(); if ($pic) { $cate[picurl] = $pic; } } if ($_GET['id']) { $id = intval($_GET['id']); $r = DB::update('cate', $cate, "id=" . $id); if ($r > 0) { api_post(array('a' => 'update', 'table' => 'cate', 'data' => $cate, 'pre_key' => 'id', 'id' => $id, 'cache' => 'cate')); } $url = '&id=' . $id; $msg = '修改'; } else { $msg = '添加'; $cate['dateline'] = TIMESTAMP; $r = DB::insert('cate', $cate, true); if ($r > 0) { api_post(array('a' => 'insert', 'table' => 'cate', 'data' => $cate, 'cache' => 'cate', 'id' => $r)); } } loadcache("cate", 'update'); cpmsg($msg . '分类成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . $url); return false; } elseif ($_GET['id']) { $id = intval($_GET['id']); $cate = $_G['cate'][$id]; } else { $cate = get_filed('cate'); } $this->add(array('cate' => $cate)); $this->show(); }
function write_log($money_arr) { $arr = get_filed('money'); if ($this->user) { $arr['uid'] = $this->user['uid']; $arr['username'] = $this->user['username']; } $arr['status'] = 0; //佣金的状态 0=获得购物返利 $arr['order_id'] = $this->order['id']; $arr['is_add'] = 1; $arr['desc'] = ''; $arr['dateline'] = TIMESTAMP; foreach ($money_arr as $k => $v) { $arr[$k] = $v; } $id = DB::insert('money', $arr); return $id; }
function share() { global $_G; 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_types'])) { msg('未定义的分享', 'error'); } $id = intval($_GET[id]); if (!$id) { msg('抱歉,要分享的id不存在', 'error'); return false; } $and = ' AND type_id = ' . $id . " AND type = '" . $type . "'"; $table = $type; $num_iid = ''; if (strpos($type, "_goods") !== false) { $num_iid = get_goods_id($_GET['num_iid']); if (!$num_iid) { msg('抱歉,要分享的商品id不正确', 'error'); } $and .= " AND num_iid='{$num_iid}'"; $table = str_replace("_goods", '', $table); } $rs = DB::fetch_first("SELECT id,jf FROM " . DB::table(__FUNCTION__) . " WHERE uid=" . $_G[uid] . $and); $msg = ''; $jf = intval($_G[setting][like_jf]); //没喜欢过 if (!$rs || !$rs[id]) { $id_name = $table == 'goods' ? 'aid' : 'id'; $fd = 'title,picurl'; if (strpos($type, "_goods") !== false) { $fd .= ",goods"; } $data = DB::fetch_first("SELECT {$fd} FROM " . DB::table($table) . " WHERE {$id_name} =" . $id); if (!$data['title']) { msg('未找到待分享的商品'); } $arr = get_filed(__FUNCTION__); //if(isset($arr['groupid']) && $_GET['groupid']) $arr['groupid'] = intval($_GET['groupid']); $arr['jf'] = $jf; $arr['username'] = $_G['username']; $arr['uid'] = $_G['uid']; $arr['type_id'] = $id; $arr['type'] = $type; $arr['num_iid'] = $num_iid; $arr['title'] = $data['title']; $arr['picurl'] = $data['picurl']; $arr['url'] = '/index.php?m=' . $table . '&' . $id_name . '=' . $id; $arr['dateline'] = TIMESTAMP; if ($arr['jf'] > 0) { update_member(array('jf' => $_G[member][jf] + $jf), $_G[uid]); $msg = ",系统奖劢你" . $jf . "个积分"; } $rid = DB::insert(__FUNCTION__, $arr, 1); $count = getcount(__FUNCTION__, $and); $fd = table($table); if (isset($fd['share_count']) || isset($fd['share'])) { $where = ''; if (isset($fd['id'])) { $where = 'id=' . $id; } else { if (isset($fd['aid'])) { $where = 'aid=' . $id; } } $fd_name = isset($fd['share_count']) ? 'share_count' : 'share'; if ($where) { $update = array($fd_name => $count); if ($num_iid && strpos($type, "_goods") !== false) { //要将子商品来增加 $goods = stripcslashes($data['goods']); $goods = dunserialize($goods); $num = 0; $title = ''; foreach ($goods as $k => $v) { $v['share'] = intval($v['share']); if ($v['num_iid'] == $num_iid) { $title = $v['title']; if ($is_like) { $v['share']--; } else { $v['share']++; } if ($v['share'] < 0) { $v['share'] = 0; } $num = $v['share']; } $goods[$k] = $v; } $update[goods] = serialize($goods); if ($title && $rid) { DB::update(__FUNCTION__, array('title' => $title), 'id=' . $rid); } } DB::update($table, $update, $where); } } msg('增加分享成功' . $msg, 'success', '', $count); } msg('已分享无须再次分享', 'error', '', $count); }
function post() { global $_G; if ($_GET['onsubmit'] && check()) { $ad = get_filed(__CLASS__, $_GET['postdb'], $_GET['id']); $ad['start_time'] = dmktime($ad['start_time']); $ad['end_time'] = dmktime($ad['end_time']); $ad['width'] = intval($ad['width']); $ad['height'] = intval($ad['height']); $ad['hide'] = intval($ad['hide']); $ad['type'] = intval($ad['type']); $ad['target'] = intval($ad['target']); if ($_FILES[file]) { $pic = upload(); if ($pic) { $ad[picurl] = $pic; } } $url = ''; if ($_GET['id']) { $id = intval($_GET['id']); DB::update(__CLASS__, $ad, "id=" . $id); $url = '&id=' . $id; $msg = '修改'; api_post(array('a' => 'update', 'table' => 'ad', 'data' => $ad, 'pre_key' => 'id', 'id' => $id, 'cache' => 'ad')); } else { $msg = '添加'; $ad['dateline'] = TIMESTAMP; $r = DB::insert(__CLASS__, $ad, true); if ($r > 0) { api_post(array('a' => 'insert', 'table' => 'ad', 'data' => $ad, 'cache' => 'ad', 'id' => $r)); } } loadcache(__CLASS__, 'update'); cpmsg($msg . '成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . $url); } elseif ($_GET['id']) { $id = intval($_GET['id']); $ad = $_G['ad']['k' . $id]; } else { $ad = get_filed(__CLASS__); } $ad_types = array(1 => '文字', 2 => '图片', 3 => 'HTML代码'); $this->add(array('ad' => $ad, 'ad_types' => $ad_types)); $this->show(); }
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 insert_sign($arr) { global $_G; $sign = array(); $sign[uid] = $_G[uid]; $sign[username] = $_G[username]; $sign[jf] = $_G[setting][jf]; $sign[ip] = $_G[clientip]; $sign[org_jf] = 0; $sign = get_filed('sign', $sign); $sign[dateline] = TIMESTAMP; foreach ($arr as $k => $v) { if (array_key_exists($k, $sign)) { $sign[$k] = $v; } } $sign[jf] = intval($sign[jf]); if (!$sign[org_jf]) { $sign[org_jf] = $_G[member][jf] + $sign[jf]; } $sign[uid] = intval($sign[uid]); $sign['add'] = $sign[jf] < 0 ? 0 : '1'; $sign['aid'] = intval($sign['aid']); if ($sign[jf] > 0) { update_group($sign[uid]); } return DB::insert('sign', $sign, 1); }
function friend_link_add() { global $_G; //节省一个模板,就得先把这些字段给定义,不然在模板中显示都是NULL,正常的PHP是显示'',TAE的PHP与普通的PHP不一样 if ($_GET['onsubmit'] && check()) { $friend_link = get_filed('friend_link', $_GET['postdb'], $_GET['id']); if ($_FILES[file]) { $src = upload(); if ($src) { $friend_link[picurl] = $src; } } if ($_GET['id']) { $id = intval($_GET['id']); DB::update('friend_link', $friend_link, "id=" . $id); loadcache('friend_link', 'update'); api_post(array('a' => 'update', 'table' => 'friend_link', 'data' => $friend_link, 'pre_key' => 'id', 'id' => $id, 'cache' => 'friend_link')); cpmsg('修改成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . '&id=' . $id); return false; } else { $friend_link['dateline'] = TIMESTAMP; $r = DB::insert('friend_link', $friend_link, true); if ($r > 0) { api_post(array('a' => 'insert', 'table' => 'friend_link', 'data' => $friend_link, 'cache' => 'friend_link', 'id' => $r)); } loadcache('friend_link', 'update'); cpmsg('添加成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } } elseif ($_GET['id']) { //编辑 $id = intval($_GET['id']); if (!$_G['friend_link'][$id]) { cpmsg('抱歉,该友情链接不存在', 'error', 'm=' . __CLASS__ . '&a=friend_link'); return false; } else { $friend_link = $_G['friend_link'][$id]; } } else { $friend_link = get_filed('friend_link'); } $this->add(array('friend_link' => $friend_link)); $this->show(); }
function post() { global $_G; if ($_GET['onsubmit']) { $img = get_filed(__CLASS__, $_GET['postdb'], $_GET['id']); $img['hide'] = intval($img['hide']); $img['sort'] = intval($img['sort']); $img['like'] = intval($img['like']); $img['hate'] = intval($img['hate']); if ($_FILES[file]) { $src = upload(); if ($src) { $img[picurl] = $src; } } if (!$img['keywords'] && $_G[setting][auto_keywords] == 1) { $img['keywords'] = get_keywords($img['title']); } if (preg_match("/^[0-9\\.]+\$/is", $img[description])) { $img[description] = ''; } if (!$img[description]) { $tmp = preg_replace("/###\\{(.*?)\\}###/is", '', $img[message]); $img[description] = trim(cutstr(trim_html($tmp), 250, '')); } if (!$img[picurl] && preg_match("/<img.*?src=\"http:(.*?)\"/is", $img[message], $img_arr)) { if ($img_arr[1]) { $img[picurl] = "http:" . $img_arr[1]; } } $url = ''; if ($_GET['id']) { $id = intval($_GET['id']); DB::update(__CLASS__, $img, "id=" . $id); $url = '&id=' . $id; $msg = '修改'; } else { $msg = '发布'; $img['dateline'] = TIMESTAMP; if (!$img[description]) { $img[description] = cutstr(trim_html($img[message]), 250, ''); } $r = DB::insert(__CLASS__, $img, true); } cpmsg($msg . '成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . $url); return false; } elseif ($_GET['id']) { $id = intval($_GET['id']); $img = DB::fetch_first("SELECT * FROM " . DB::table("img") . " WHERE id = " . $id); $img = dstripcslashes($img); } else { $img = get_filed(__CLASS__); } $this->add(array('img' => $img)); $this->show(); }
function batpost() { global $_G, $app; if ($_GET['onsubmit'] && check()) { $cate = get_filed(__CLASS__); $all_cate = count($_G['chennels']); foreach ($_GET['tmp'] as $k => $v) { $arr = $cate; if ($_GET['fup'][$k]) { //一级分类 $arr['name'] = $_GET['fup'][$k]; $arr['sort'] = $all_cate + ($k + 1); $arr['type'] = $this->type; $arr['page'] = 120; $fup_id = DB::insert(__CLASS__, $arr, true); if ($fup_id > 0) { $arr['id'] = $fup_id; } } else { $fup_id = $_GET['fup2'][$k] ? intval($_GET['fup2'][$k]) : 0; } if ($_GET['name'][$k]) { $sub = explode(',', $_GET['name'][$k]); $sub = array_filter($sub); $sub = array_unique($sub); if ($sub) { foreach ($sub as $k1 => $v1) { $arr2 = $cate; if ($v1 != $v) { $arr2['name'] = $v1; $arr2['fup'] = $fup_id; $arr2['sort'] = 0; $arr2['type'] = $this->type; $arr2['page'] = 20; $id = DB::insert('cate', $arr2, true); if ($id > 0) { $arr2['id'] = $id; } } } } } } $this->update_cache(); cpmsg('批量添加成功', 'success', 'm=' . CURMODULE . '&a=cate'); return false; } $cate = $this->get_cate(); $this->add(array('cate' => $cate)); $this->show(__CLASS__ . '/' . __FUNCTION__); }
function post() { global $_G; $goods_id = ''; if ($_GET['onsubmit'] && check()) { $shop = get_filed(__CLASS__, $_GET['postdb'], $_GET[id]); if ($_FILES[file]) { $src = upload(); if ($src) { $shop[picurl] = $src; } } if ($_FILES['pic_path']['tmp_name']) { $src = upload($_FILES['pic_path']); if ($src) { $shop[pic_path] = $src; } } $url = ''; if ($_GET['id']) { $id = intval($_GET['id']); top('shop', 'insert', $shop, $id); $url = '&id=' . $id; $msg = '修改'; } else { $msg = '添加'; $top = top('shop', 'insert', $shop); } cpmsg($msg . '成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . $url); return false; } elseif ($_GET[get_submit] && $_GET['goods_id']) { $goods_id = get_goods_id($_GET['goods_id']); if (!$goods_id) { cpmsg('抓取失败,商品ID或链接不存在或填写错误', 'error', 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } $goods = top('goods', 'get_goods', $goods_id); if ($goods === false) { cpmsg('当前商品未成功获取,可能是商品未上线,请更换当前店铺中的其它一款商品再重试,或是请手动添加'); return false; } $query = top('shop', 'get_shop', $goods['sid']); $query[nick] = $goods[nick]; if ($query === false) { cpmsg('抱歉,获取失败,请检查用户名是否正确'); return false; } foreach ($query as $k => $v) { $shop[$k] = trim_html($v, 1); } $shop = get_filed(__CLASS__, $shop); } elseif ($_GET['id']) { $id = intval($_GET['id']); $shop = DB::fetch_first("SELECT * FROM " . DB::table('shop') . " WHERE id = {$id} "); $shop['start_time'] = dgmdate($shop['start_time'], 'dt'); $shop['end_time'] = dgmdate($shop['end_time'], 'dt'); } else { $shop = get_filed(__CLASS__); } $this->add(array('shop' => $shop, 'goods_id' => $goods_id)); $this->show(); }
function main() { global $_G; seo('商家报名'); if ($_G['setting']['bm'] == 0) { msg('抱歉,系统关闭了商家报名功能,暂时无法进行报名操作', 'error'); } if ($_G[setting][bm_login] == 1) { is_login(); } $goods = get_filed('goods'); $readonly = ''; if ($_GET['onsubmit'] && check()) { //发布商品 $picurl = trim($_GET['postdb']['picurl']); if (!preg_match("/^http:\\/\\//", $picurl)) { msg('抱歉,图片格式不正确,请重新提交', 'error', URL . 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } $title = trim($_GET['postdb']['title']); if (!$title) { msg('抱歉,商品标题不存在', 'error', URL . 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } $num_iid = $_GET['postdb']['num_iid']; if (!$num_iid) { msg('抱歉,商品ID不存在', 'error', URL . 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } else { $aid = DB::fetch_first("SELECT aid FROM " . DB::table('goods') . " WHERE num_iid='{$num_iid}'"); if ($aid['aid'] > 0) { msg('禁止重复报名,您所提交的商品已存在或已报名了', 'error', URL . 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } } $arr = get_filed('goods', $_GET['postdb']); $nick = trim($arr[nick]); if ($_G[setting][apply_user] == 1 && $nick) { if (!is_login(1) || !$_G['username']) { $web = '站点'; msg('您必须先登录' . $web . '后,才可进行报名', 'error', URL . 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } $s_name = mb_substr($_G['username'], 0, 1, 'utf-8'); $s_nick = mb_substr($nick, 0, 1, 'utf-8'); if ($s_name != $s_nick) { $msg = '您当前登录淘宝的账号和当前提交商品的卖家不属同一账号,请用当前商品的卖家主旺旺登录淘宝才可提交报名'; msg($msg, 'error', URL . 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } } if ($_G[setting][apply_max] > 0 && $nick) { $count = getcount('goods', " nick = '" . $nick . "'"); if ($count >= $_G[setting][apply_max]) { $msg = '抱歉,系统设置同一卖家店铺,最多能报名' . $_G[setting][apply_max] . '款商品,您已到达最多限制,无法报名'; msg($msg, 'error', URL . 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } } if ($_G[setting][bm_black] && $nick) { $user = explode(',', $_G[setting][bm_black]); if (in_array($nick, $user)) { msg('抱歉,当前店铺已被列为黑名单,禁止此店铺所有商品报名', 'error', URL . 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } } $arr['images'] = $_GET['images']; $arr['post'] = 1; $arr['check'] = 0; $arr['title'] = cutstr($arr[title], 60, ''); if ($_FILES[file]) { $pic = upload(); if ($pic) { $arr[picurl] = $pic; } } $picurl = trim($arr['picurl']); /*if(!preg_match("/^http:\/\//",$picurl)){ msg('抱歉,图片格式不正确,请重新提交','error',URL.'m='.__CLASS__.'&a='.__FUNCTION__); return false; }*/ top('goods', 'insert', $arr); msg('报名成功!请耐心等待审核(2个工作日内)', 'success', URL . 'm=' . __CLASS__ . '&a=' . __FUNCTION__); } elseif ($_GET['get_submit'] && check() && $_GET['goods_id']) { //提交ID采集商品 if (get_goods_id(trim($_GET['goods_id']))) { $goods_id = get_goods_id(trim($_GET['goods_id'])); } if (!$goods_id) { msg('抓取失败,商品ID或链接不存在或填写错误', 'error', URL . 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } $gd = top('goods', 'get_goods', $goods_id); $nick = trim($gd[nick]); //同一账号验证 if ($_G[setting][apply_user] == 1 && $nick) { if (!is_login() || !$_G['username']) { $web = '站点'; msg('您必须先登录' . $web . '后,才可进行报名', 'error', URL . 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } $s_name = mb_substr($_G['username'], 0, 1, 'utf-8'); $s_nick = mb_substr($nick, 0, 1, 'utf-8'); $msg = '您当前登录淘宝的账号和当前提交商品的卖家不属同一账号,请用当前商品的卖家主旺旺登录淘宝才可提交报名'; msg($msg, 'error', URL . 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } if ($_G[setting][apply_max] > 0 && $nick) { $count = getcount('goods', " nick = '" . $nick . "'"); if ($count >= $_G[setting][apply_max]) { $msg = '抱歉,系统设置同一卖家店铺,最多能报名' . $_G[setting][apply_max] . '款商品,您已到达最多限制,无法报名'; msg($msg, 'error', URL . 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } } if ($_G[setting][bm_black] && $nick) { $user = explode(',', $_G[setting][bm_black]); if (in_array($nick, $user)) { msg('抱歉,当前店铺已被列为黑名单,禁止报名', 'error', URL . 'm=' . __CLASS__ . '&a=' . __FUNCTION__); return false; } } $gd[goods_id] = $goods_id; $gd['start_time'] = dgmdate($gd['start_time'], 'dt'); $gd['end_time'] = dgmdate($gd['end_time'], 'dt'); foreach ($gd as $k => $v) { $goods[$k] = $v; } if ($_G['setting']['bm_edit'] == 0) { $readonly = "readonly='readonly'"; } } else { $_GET[goods_id] = ''; } $this->add(array('goods' => $goods, 'readonly' => $readonly)); $this->show(); }
function batpost() { global $_G; if ($_GET['onsubmit'] && check()) { $channel = get_filed(__CLASS__); $all_channel = count($_G['chennels']); foreach ($_GET['tmp'] as $k => $v) { $arr = $channel; if ($_GET['fup'][$k]) { //一级栏目 $arr['name'] = $_GET['fup'][$k]; $arr['sort'] = $all_channel + ($k + 1); $fup_id = DB::insert(__CLASS__, $arr, true); if ($fup_id > 0) { $arr['fid'] = $fup_id; } } else { $fup_id = $_GET['fup2'][$k] ? intval($_GET['fup2'][$k]) : 0; } if ($_GET['name'][$k]) { $sub = explode(',', $_GET['name'][$k]); $sub = array_filter($sub); $sub = array_unique($sub); if ($sub) { foreach ($sub as $k1 => $v1) { $arr2 = $channel; if ($v1 != $v) { $arr2['name'] = $v1; $arr2['fup'] = $fup_id; $arr2['sort'] = 0; $fid = DB::insert('channel', $arr2, true); if ($fid > 0) { $arr2['fid'] = $fid; } } } } } } loadcache("channels", 'update'); loadcache("all_channel", 'update'); cpmsg('批量添加成功', 'success', 'm=channel&a=batpost'); return false; } $this->show(); }
function reg() { global $_G; if ($_G[uid]) { msg('您已登录,请退出后再进行操作', 'error', 'm=index'); } if ($_GET['reg_submit'] && check()) { $arr = get_filed(__CLASS__); $arr[username] = trim($_GET['username']); $arr[password] = trim($_GET['password']); $password2 = trim($_GET['password2']); $arr[email] = trim($_GET['email']); $arr[qq] = isset($_GET['qq']) && trim($_GET['qq']) ? trim($_GET['qq']) : ''; $arr[phone] = isset($_GET['phone']) && trim($_GET['phone']) ? trim($_GET['phone']) : ''; if ($arr[username]) { //用户名注册 $name = 'username'; $tit = '用户名'; if (!$arr[email]) { msg('邮箱不能为空', 'error'); } if (!is_email($arr['email'])) { msg('邮箱格式不正确', 'error'); } } else { if ($arr[email]) { $name = 'email'; $tit = '邮箱'; if (empty($arr['email'])) { msg('邮箱不能为空', 'error'); } if (!is_email($arr['email'])) { msg('邮箱格式不正确', 'error'); } } elseif ($arr[phone]) { $name = 'phone'; $tit = '手机'; $phone = $_GET[phone]; if (!preg_match("/^1\\d{10}\$/", $phone)) { msg('手机号码格式不正确', 'error'); } } else { msg('抱歉,注册用户名不能为空', 'error'); } } $arr[username] = $arr[$name]; if (empty($arr['password'])) { msg('密码不能为空', 'error'); } if (empty($password2)) { msg('确认密码不能为空', 'error'); } if ($arr['password'] != $password2) { msg('两次输入密码不一致', 'error'); } if ($_G[setting][reg_yzm] && !check_yzm($_GET[yzm])) { msg('验证码效验失败,请重新输入', 'error'); return false; } $username = daddslashes($arr[username]); $p1 = DB::fetch_first("SELECT uid FROM " . DB::table('member') . " WHERE username='******' "); if ($p1[uid] > 0) { msg($tit . '已被注册', 'error'); } if ($arr[email]) { $email = daddslashes($arr[email]); $p = DB::fetch_first("SELECT uid FROM " . DB::table('member') . " WHERE email ='{$email}' "); if ($p[uid] > 0) { msg('邮箱已被注册', 'error'); } } if ($arr[phone]) { $phone = daddslashes($_GET[phone]); $p = DB::fetch_first("SELECT uid FROM " . DB::table('member') . " WHERE phone ='{$phone}' "); if ($p[uid] > 0) { msg('手机号码已被注册', 'error'); } $arr['phone'] = $phone; } $arr['key'] = random(10); $arr[password] = authcode($arr[password], 'encode', $arr['key']); $arr['groupid'] = 10; $arr['regip'] = $_G[clientip]; $arr['login_ip'] = $_G[clientip]; $arr['login_time'] = TIMESTAMP; $arr['login_count'] = 1; $arr['picurl'] = '/assets/global/images/avatar.png'; //注册时默认给定随机头象 $arr['regdate'] = TIMESTAMP; if ($_G[setting][email_check] == 1) { $arr['email_check'] = 0; } $arr['check'] = intval($_G[setting][reg_check]); if ($_G[setting][jf] > 0) { $arr['jf'] = $_G[setting][jf]; } if ($_GET[type] == 'seller') { $arr[groupid] = 4; } $t = intval(getcookie('t')); if ($t > 0) { $arr['t_uid'] = $t; } $arr = daddslashes($arr); $uid = DB::insert('member', $arr, 1); if ($uid > 0) { $_G[member] = $arr; $_G[member][group] = $_G[group][$arr[groupid]]; $_G[uid] = $uid; $_G[groupid] = $arr[groupid]; $_G[username] = $arr[username]; $auth = authcode($uid . '|' . $arr[password], 'encode', '', $this->login_time); dsetcookie("auth", $auth, $this->login_time); if ($_G[setting][jf] > 0) { $jf = $_G[setting][jf]; $sid = insert_sign(array('uid' => $uid, 'desc' => '新会员注册系统奖励', 'type' => 'system', 'org_jf' => $jf, 'jf' => $jf)); } $this->check_yaoqing($t, $arr); $referer = $_GET['referer'] ? $_GET['referer'] : dreferer(); if (preg_match("/member/is", $referer)) { $referer = URL . 'm=home'; } if ($_G[setting][email_check] == 1 && $_G[setting][email][status]) { $status = send_email($arr['email'], 'reg'); if ($status['status'] == 'success') { $msg = '恭喜您成功,您的账户还需要验证,我们已向您的邮箱' . $arr['email'] . '发送了一封验证邮件,请在15分钟内查看并验证'; msg($msg, 'success', $referer); } else { msg($status[msg], 'error', $referer); } return; } else { msg('恭喜您注册成功', 'success', $referer); return; } } else { msg('注册失败', 'error', 'm=member&a=reg'); } } $this->show('member/reg'); }
function type_post() { global $_G; if ($_GET['onsubmit'] && check()) { $type = get_filed('pics_type', $_GET['postdb'], $_GET['id']); $url = ''; if ($_GET['id']) { $id = intval($_GET['id']); DB::update('pics_type', $type, "id=" . $id); api_post(array('a' => 'update', 'table' => 'pics_type', 'data' => $type, 'pre_key' => 'id', 'id' => $id, 'cache' => 'pics_type')); $url = '&id=' . $id; $msg = '修改'; } else { $msg = '添加'; $r = DB::insert('pics_type', $type, true); if ($r > 0) { api_post(array('a' => 'insert', 'table' => 'pics_type', 'data' => $type, 'cache' => 'pics_type', 'id' => $r)); } } loadcache('pics', 'update'); loadcache('pics_type', 'update'); cpmsg($msg . '成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . $url); return false; } elseif ($_GET['id']) { $type = DB::fetch_first("SELECT * FROM " . DB::table('pics_type') . " WHERE id = " . intval($_GET['id'])); } else { $type = get_filed('pics_type'); } $this->add(array('type' => $type)); $this->show(); }
function apply_edit() { global $_G; global $_G; if ($_GET['onsubmit'] && check()) { $id = intval($_GET[id]); $arr = get_filed('duihuan_apply', $_GET[postdb], $_GET[id]); $arr['status'] = intval($_GET['postdb']['status']); $org_status = intval($_GET['org_status']); if ($arr[status]) { $arr['statustime'] = TIMESTAMP; } DB::update("duihuan_apply", $arr, "id=" . $id); cpmsg('修改成功', 'success', 'm=' . __CLASS__ . '&a=' . __FUNCTION__ . '&id=' . $id); return false; } $id = intval($_GET[id]); if (!$id) { cpmsg('id不能为空', 'error', 'm=' . __CLASS__ . '&a=apply'); return false; } $and = ' AND id = ' . $id; $goods = D(array('table' => 'duihuan_apply', 'and' => $and)); $this->add(array('goods' => $goods, 'referer' => dreferer())); $this->show(); }