function weixin_oauth($callback, $scope = 'BASE') { global $db; $rs = $db->getRow("SELECT * FROM `wxch_config` WHERE `id` = 1"); $param['appid'] = $rs['appid']; $oauth = intval($_REQUEST['oauth']); if ($oauth == 0) { $param['redirect_uri'] = $callback . (strpos($callback, '?') > 0 ? '&' : '?') . 'oauth=1'; $param['response_type'] = 'code'; if ($scope == 'INFO') { $param['scope'] = 'snsapi_userinfo'; } else { $param['scope'] = 'snsapi_base'; } $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?' . http_build_query($param) . '#wechat_redirect'; ecs_header("Location: {$url}\n"); exit; } elseif ($oauth == 1) { $param['secret'] = $rs['appsecret']; $param['code'] = $_REQUEST['code']; $param['grant_type'] = 'authorization_code'; $url = 'https://api.weixin.qq.com/sns/oauth2/access_token?' . http_build_query($param); $content = file_get_contents($url); $token = json_decode($content, true); $user_info = $db->getRow("SELECT * FROM `wxch_user` WHERE `wxid` = '{$token[openid]}'"); if (empty($user_info)) { //register if (register_openid($token['openid'])) { $user_info = $GLOBALS['user']->get_user_info($user_info['openid']); } else { return false; } } else { //login $user_info = $GLOBALS['user']->get_profile_by_id($user_info['uid']); if (!empty($user_info) && $user_info['status'] == 1) { $GLOBALS['user']->set_session($user_info); $GLOBALS['user']->set_cookie($user_info, TRUE); update_user_info(); // 更新用户信息 update_user_cart(); recalculate_price(); // 重新计算购物车中的商品价格 } else { return false; } } if ($token['scope'] == 'snsapi_userinfo') { $url = "https://api.weixin.qq.com/sns/userinfo?access_token={$token[access_token]}&openid={$token[openid]}&lang=zh_CN"; $content = file_get_contents($url); $info = json_decode($content, true); // 更新微信用户数据 $db->autoExecute('wxch_user', array('nickname' => $info['nickname'], 'sex' => $info['sex'], 'city' => $info['city'], 'country' => $info['country'], 'province' => $info['province'], 'language' => $info['language'], 'headimgurl' => $info['headimgurl'], 'dateline' => time()), 'UPDATE', 'uid = ' . $user_info['uid']); } $_SESSION['openid'] = $token['openid']; return $user_info; } }
/** * 构造函数 */ public function __construct() { parent::__construct(); /* 只有在没有提交评论内容以及没有act的情况下才跳转 */ $this->cmt = I('request.cmt'); $this->act = I('request.act'); if (!isset($this->cmt) && !isset($this->act)) { ecs_header("Location: ./\n"); } }
/** * 检查版本升级 */ public function upgrade() { global $_CFG; /* 如果有新版本,升级 */ if (!isset($_CFG['ecs_version'])) { $_CFG['ecs_version'] = 'v1.0.0'; } if (preg_replace('/(?:\\.|\\s+)[a-z]*$/i', '', $_CFG['ecs_version']) != preg_replace('/(?:\\.|\\s+)[a-z]*$/i', '', VERSION) && file_exists('../upgrade/index.php')) { // 转到升级文件 ecs_header("Location: ../upgrade/index.php\n"); exit; } }
ecs_header("Location: user.php?act=order_detail&order_id={$order_id}\n"); exit; } $order_amount = $order['order_amount'] - $order['pay_fee']; $pay_fee = pay_fee($pay_id, $order_amount); $order_amount += $pay_fee; $sql = "UPDATE " . $ecs->table('order_info') . " SET pay_id='{$pay_id}', pay_name='{$payment_info['pay_name']}', pay_fee='{$pay_fee}', order_amount='{$order_amount}'" . " WHERE order_id = '{$order_id}'"; $db->query($sql); /* 跳转 */ ecs_header("Location: user.php?act=order_detail&order_id={$order_id}\n"); exit; } elseif ($action == 'save_order_address') { include_once ROOT_PATH . 'includes/lib_transaction.php'; $address = array('consignee' => isset($_POST['consignee']) ? trim($_POST['consignee']) : '', 'email' => isset($_POST['email']) ? trim($_POST['email']) : '', 'address' => isset($_POST['address']) ? trim($_POST['address']) : '', 'zipcode' => isset($_POST['zipcode']) ? make_semiangle(trim($_POST['zipcode'])) : '', 'tel' => isset($_POST['tel']) ? trim($_POST['tel']) : '', 'mobile' => isset($_POST['mobile']) ? trim($_POST['mobile']) : '', 'sign_building' => isset($_POST['sign_building']) ? trim($_POST['sign_building']) : '', 'best_time' => isset($_POST['best_time']) ? trim($_POST['best_time']) : '', 'order_id' => isset($_POST['order_id']) ? intval($_POST['order_id']) : 0); if (save_order_address($address, $user_id)) { ecs_header('Location: user.php?act=order_detail&order_id=' . $address['order_id'] . "\n"); exit; } else { $err->show($_LANG['order_list_lnk'], 'user.php?act=order_list'); } } elseif ($action == 'bonus') { include_once ROOT_PATH . 'includes/lib_transaction.php'; $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1; $record_count = $db->getOne("SELECT COUNT(*) FROM " . $ecs->table('user_bonus') . " WHERE user_id = '{$user_id}'"); $pager = get_pager('user.php', array('act' => $action), $record_count, $page); $bonus = get_user_bouns_list($user_id, $pager['size'], $pager['start']); $smarty->assign('pager', $pager); $smarty->assign('bonus', $bonus); $smarty->display('user_transaction.dwt'); } elseif ($action == 'group_buy') { include_once ROOT_PATH . 'includes/lib_transaction.php';
function action_tg_login_act() { $user = $GLOBALS['user']; $_CFG = $GLOBALS['_CFG']; $_LANG = $GLOBALS['_LANG']; $smarty = $GLOBALS['smarty']; $db = $GLOBALS['db']; $ecs = $GLOBALS['ecs']; $user_id = $_SESSION['user_id']; include_once ROOT_PATH . 'includes/lib_clips.php'; $nowtime = gmtime(); $tg_sn = isset($_POST['tcard']) ? trim($_POST['tcard']) : ''; $tg_pwd = isset($_POST['pwd']) ? trim($_POST['pwd']) : ''; if (empty($tg_sn) || empty($tg_pwd)) { show_message('卡号或密码都不能为空', '返回重新登录', 'user.php?act=tg_login'); } $sql = "select tg.*, tt.type_money, tt.type_money_count, tt.use_start_date, tt.use_end_date from " . $ecs->table('takegoods') . " AS tg " . " left join " . $ecs->table('takegoods_type') . " AS tt " . "on tg.type_id = tt.type_id where tg.tg_sn= '{$tg_sn}' "; $tgrow = $db->getRow($sql); if (!$tgrow) { show_message('该提货券不存在', '请查证后重新登录', 'user.php?act=tg_login'); } if ($tg_pwd != $tgrow['tg_pwd']) { show_message('密码错误', '请查证后重新登录', 'user.php?act=tg_login'); } if ($nowtime < $tgrow['use_start_date']) { show_message('对不起,该提货券 开始使用日期为 ' . local_date('Y-m-d H:i:s', $tgrow['use_start_date']), '请过几天再登录试试', 'user.php?act=tg_login'); } if ($nowtime > $tgrow['use_end_date']) { show_message('对不起,该提货券已过期', '请换个券号重新登录', 'user.php?act=tg_login'); } if ($tgrow['used_time'] and count(explode('@', $tgrow['used_time'])) >= $tgrow['type_money_count']) { show_message('对不起,该提货券使用次数已用尽', '请换个券号重新登录', 'user.php?act=tg_login'); } $_SESSION['takegoods_sn_68ecshop'] = $tg_sn; $_SESSION['takegoods_id_68ecshop'] = $tgrow['tg_id']; ecs_header("Location:takegoods.php"); }
$result['ctype'] = 2; } die($json->encode($result)); } else { $goods_id = isset($_REQUEST['id']) ? $_REQUEST['id'] : ''; if ($goods_id) { //16:25 2013-07-13 //clear_cart(); $_LANG['shortage'] = "对不起,该商品已经库存不足暂停销售。\n你现在要进行缺货登记来预订该商品吗?"; if (!addto_cart($goods_id)) { //16:25 2013-07-13 echo '购买失败,请重新购买!'; exit; } else { $goods_order = 1; //16:25 2013-07-13 if ($cp == "add_cart") { $Loaction = 'cart.php'; } else { $Loaction = 'buy.php?act=checkout'; } ecs_header("Location: {$Loaction}\n"); exit; } } else { ecs_header("Location:index.php\n"); exit; } } $smarty->assign('footer', get_footer()); $smarty->display('buy.dwt');
public function buy() { /* 查询:判断是否登录 */ if ($_SESSION['user_id'] <= 0) { $this->redirect(url('user/login')); } /* 查询:取得参数:团购活动id */ $group_buy_id = isset($_POST['group_buy_id']) ? intval($_POST['group_buy_id']) : 0; if ($group_buy_id <= 0) { ecs_header("Location: ./\n"); exit; } /* 查询:取得数量 */ $number = isset($_POST['number']) ? intval($_POST['number']) : 1; $number = $number < 1 ? 1 : $number; /* 查询:取得团购活动信息 */ $group_buy = model('GroupBuyBase')->group_buy_info($group_buy_id, $number); if (empty($group_buy)) { ecs_header("Location: ./\n"); exit; } /* 查询:检查团购活动是否是进行中 */ if ($group_buy['status'] != GBS_UNDER_WAY) { show_message(L('gb_error_status'), '', '', 'error'); } /* 查询:取得团购商品信息 */ $goods = model('Goods')->get_goods_info($group_buy['goods_id']); if (empty($goods)) { ecs_header("Location: ./\n"); exit; } /* 查询:判断数量是否足够 */ if ($group_buy['restrict_amount'] > 0 && $number > $group_buy['restrict_amount'] - $group_buy['valid_goods'] || $number > $goods['goods_number']) { show_message(L('gb_error_goods_lacking'), '', '', 'error'); } /* 查询:取得规格 */ $specs = ''; foreach ($_POST as $key => $value) { if (strpos($key, 'spec_') !== false) { $specs .= ',' . intval($value); } } $specs = trim($specs, ','); /* 查询:如果商品有规格则取规格商品信息 配件除外 */ if ($specs) { $_specs = explode(',', $specs); $product_info = model('ProductsBase')->get_products_info($goods['goods_id'], $_specs); } empty($product_info) ? $product_info = array('product_number' => 0, 'product_id' => 0) : ''; /* 查询:判断指定规格的货品数量是否足够 */ if ($specs && $number > $product_info['product_number']) { show_message(L('gb_error_goods_lacking'), '', '', 'error'); } /* 查询:查询规格名称和值,不考虑价格 */ $attr_list = array(); $sql = "SELECT a.attr_name, g.attr_value " . "FROM " . $this->model->pre . "goods_attr AS g, " . $this->model->pre . "attribute AS a " . "WHERE g.attr_id = a.attr_id " . "AND g.goods_attr_id " . db_create_in($specs); $res = $this->model->query($sql); foreach ($res as $row) { $attr_list[] = $row['attr_name'] . ': ' . $row['attr_value']; } $goods_attr = join(chr(13) . chr(10), $attr_list); /* 更新:清空购物车中所有团购商品 */ model('Order')->clear_cart(CART_GROUP_BUY_GOODS); /* 更新:加入购物车 */ $goods_price = $group_buy['deposit'] > 0 ? $group_buy['deposit'] : $group_buy['cur_price']; $cart = array('user_id' => $_SESSION['user_id'], 'session_id' => SESS_ID, 'goods_id' => $group_buy['goods_id'], 'product_id' => $product_info['product_id'], 'goods_sn' => addslashes($goods['goods_sn']), 'goods_name' => addslashes($goods['goods_name']), 'market_price' => $goods['market_price'], 'goods_price' => $goods_price, 'goods_number' => $number, 'goods_attr' => addslashes($goods_attr), 'goods_attr_id' => $specs, 'is_real' => $goods['is_real'], 'extension_code' => addslashes($goods['extension_code']), 'parent_id' => 0, 'rec_type' => CART_GROUP_BUY_GOODS, 'is_gift' => 0); $new_cart = model('Common')->filter_field('cart', $cart); $this->model->table('cart')->data($new_cart)->insert(); /* 更新:记录购物流程类型:团购 */ $_SESSION['flow_type'] = CART_GROUP_BUY_GOODS; $_SESSION['extension_code'] = 'group_buy'; $_SESSION['extension_id'] = $group_buy_id; /* 进入收货人页面 */ $this->redirect(url('flow/consignee_list')); exit; }
if (!empty($_REQUEST['is_ajax'])) { make_json_error($_LANG['priv_error']); } else { ecs_header("Location: privilege.php?act=login\n"); } exit; } } $smarty->assign('token', $_CFG['token']); if ($_REQUEST['act'] != 'login' && $_REQUEST['act'] != 'signin' && $_REQUEST['act'] != 'forget_pwd' && $_REQUEST['act'] != 'reset_pwd' && $_REQUEST['act'] != 'check_order') { $admin_path = preg_replace('/:\\d+/', '', $ecs->url()) . ADMIN_PATH; if (!empty($_SERVER['HTTP_REFERER']) && strpos(preg_replace('/:\\d+/', '', $_SERVER['HTTP_REFERER']), $admin_path) === false) { if (!empty($_REQUEST['is_ajax'])) { make_json_error($_LANG['priv_error']); } else { ecs_header("Location: privilege.php?act=login\n"); } exit; } } /* 管理员登录后可在任何页面使用 act=phpinfo 显示 phpinfo() 信息 */ if ($_REQUEST['act'] == 'phpinfo' && function_exists('phpinfo')) { phpinfo(); exit; } //header('Cache-control: private'); header('content-type: text/html; charset=' . EC_CHARSET); header('Expires: Fri, 14 Mar 1980 20:53:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache');
$_GET[$arr2[0]] = $arr2[1]; $pay_code = $arr1[0]; } /* 判断是否启用 */ $sql = "SELECT COUNT(*) FROM " . $ecs->table('payment') . " WHERE pay_code = '{$pay_code}' AND enabled = 1"; if ($db->getOne($sql) == 0) { $msg = $_LANG['pay_disabled']; } else { $plugin_file = ROOT_PATH . 'includes/modules/payment/' . $pay_code . '.php'; /* 检查插件文件是否存在,如果存在则验证支付是否成功,否则则返回失败信息 */ if (file_exists($plugin_file)) { /* 根据支付方式代码创建支付类的对象并调用其响应操作方法 */ include_once $plugin_file; $payment = new $pay_code(); $msg = @$payment->respond() ? '成功' : '失败'; ecs_header("Location:user.php?act=order_list\n"); } else { $msg = $_LANG['pay_not_exist']; } } } assign_template(); $position = assign_ur_here(); $smarty->assign('page_title', $position['title']); // 页面标题 $smarty->assign('ur_here', $position['ur_here']); // 当前位置 $smarty->assign('page_title', $position['title']); // 页面标题 $smarty->assign('ur_here', $position['ur_here']); // 当前位置
check_authz_json('shophelp_manage'); $cat_name = trim($_POST['cat_name']); if (!empty($cat_name)) { if ($exc_cat->num("cat_name", $cat_name) != 0) { make_json_error($_LANG['catname_exist']); } else { $sql = "INSERT INTO " . $ecs->table('article_cat') . " (cat_name, cat_type) VALUES ('{$cat_name}', 0)"; $db->query($sql); admin_log($cat_name, 'add', 'shophelpcat'); ecs_header("Location: shophelp.php?act=query\n"); exit; } } else { make_json_error($_LANG['js_languages']['no_catname']); } ecs_header("Location: shophelp.php?act=list_cat\n"); exit; } elseif ($_REQUEST['act'] == 'edit_title') { check_authz_json('shophelp_manage'); $id = intval($_POST['id']); $title = json_str_iconv(trim($_POST['val'])); /* 检查文章标题是否有重名 */ if ($exc_article->num('title', $title, $id) == 0) { if ($exc_article->edit("title = '{$title}'", $id)) { clear_cache_files(); admin_log($title, 'edit', 'shophelp'); make_json_result(stripslashes($title)); } } else { make_json_error(sprintf($_LANG['articlename_exist'], $title)); }
} else { $links[] = array('text' => $_LANG['go_url'], 'href' => 'flashplay.php?act=list'); sys_msg($_LANG['id_error'], 0, $links); } if (strpos($rt['src'], 'http') === false) { @unlink(ROOT_PATH . $rt['src']); } $temp = array(); foreach ($flashdb as $key => $val) { if ($key != $id) { $temp[] = $val; } } put_flash_xml($temp); set_flash_data($_CFG['flash_theme'], $error_msg = ''); ecs_header("Location: flashplay.php?act=list\n"); exit; } elseif ($_REQUEST['act'] == 'add') { admin_priv('flash_manage'); if (empty($_POST['step'])) { $url = isset($_GET['url']) ? $_GET['url'] : 'http://'; $src = isset($_GET['src']) ? $_GET['src'] : ''; $rt = array('act' => 'add', 'img_url' => $url, 'img_src' => $src); $width_height = get_width_height(); $smarty->assign('width_height', sprintf($_LANG['width_height'], $width_height['width'], $width_height['height'])); $smarty->assign('action_link', array('text' => $_LANG['go_url'], 'href' => 'flashplay.php?act=list')); $smarty->assign('rt', $rt); $smarty->display('flashplay_add.htm'); } elseif ($_POST['step'] == 2) { if (!empty($_FILES['img_file_src']['name'])) { if (!get_file_suffix($_FILES['img_file_src']['name'], $allow_suffix)) {
$result['content'] = insert_cart_info(); $result['one_step_buy'] = $_CFG['one_step_buy']; } else { $result['message'] = $err->last_message(); $result['error'] = $err->error_no; $result['package_id'] = stripslashes($package->package_id); } } $result['confirm_type'] = !empty($_CFG['cart_confirm']) ? $_CFG['cart_confirm'] : 2; die($json->encode($result)); } else { /* 标记购物流程为普通商品 */ $_SESSION['flow_type'] = CART_GENERAL_GOODS; /* 如果是一步购物,跳到结算中心 */ if ($_CFG['one_step_buy'] == '1') { ecs_header("Location: flow.php?step=checkout\n"); exit; } /* 取得商品列表,计算合计 */ $cart_goods = get_cart_goods(); $smarty->assign('goods_list', $cart_goods['goods_list']); $smarty->assign('total', $cart_goods['total']); //购物车的描述的格式化 $smarty->assign('shopping_money', sprintf($_LANG['shopping_money'], $cart_goods['total']['goods_price'])); $smarty->assign('market_price_desc', sprintf($_LANG['than_market_price'], $cart_goods['total']['market_price'], $cart_goods['total']['saving'], $cart_goods['total']['save_rate'])); // 显示收藏夹内的商品 if ($_SESSION['user_id'] > 0) { require_once ROOT_PATH . 'includes/lib_clips.php'; $collection_goods = get_collection_goods($_SESSION['user_id']); $smarty->assign('collection_goods', $collection_goods); }
/** * 用户进行密码找回操作时,发送一封确认邮件 * * @access public * @param string $uid 用户ID * @param string $user_name 用户帐号 * @param string $email 用户Email * @param string $code key * * @return boolen $result; */ function send_pwd_email($uid, $user_name, $email, $code) { global $config; if (empty($uid) || empty($user_name) || empty($email) || empty($code)) { ecs_header("Location: user.php?act=get_password\n"); exit; } /* 设置重置邮件模板所需要的内容信息 */ $template = get_mail_template('send_password'); //$reset_email = $GLOBALS['ecs']->url() . 'user.php?act=get_password&uid=' . $uid . '&code=' . $code; $reset_email = $config['site_url'] . 'user.php?act=get_password&uid=' . $uid . '&code=' . $code; $GLOBALS['smarty']->assign('user_name', $user_name); $GLOBALS['smarty']->assign('reset_email', $reset_email); $GLOBALS['smarty']->assign('shop_name', $GLOBALS['_CFG']['shop_name']); $GLOBALS['smarty']->assign('send_date', date('Y-m-d')); $GLOBALS['smarty']->assign('sent_date', date('Y-m-d')); $content = $GLOBALS['smarty']->fetch('str:' . $template['template_content']); /* 发送确认重置密码的确认邮件 */ if (send_mail($user_name, $email, $template['template_subject'], $content, $template['is_html'])) { return true; } else { return false; } }
$config['item'][$key]['level_money'] = $val; $config['on'] = 1; put_affiliate($config); make_json_result(stripcslashes($val)); } elseif ($_REQUEST['act'] == 'del') { $key = trim($_GET['id']) - 1; unset($config['item'][$key]); $temp = array(); foreach ($config['item'] as $key => $val) { $temp[] = $val; } $config['item'] = $temp; $config['on'] = 1; $config['config']['separate_by'] = 0; put_affiliate($config); ecs_header("Location: affiliate.php?act=list\n"); exit; } function get_affiliate() { $config = unserialize($GLOBALS['_CFG']['affiliate']); empty($config) && ($config = array()); return $config; } function put_affiliate($config) { $temp = serialize($config); $sql = "UPDATE " . $GLOBALS['ecs']->table('shop_config') . "SET value = '{$temp}'" . "WHERE code = 'affiliate'"; $GLOBALS['db']->query($sql); clear_all_files(); }
/* 如果不存在实体商品,退出 */ if (!exist_real_goods($order_id)) { die('Hacking Attemp'); } /* 保存订单 */ $shipping_id = $_POST['shipping']; $shipping = shipping_info($shipping_id); $invoice_no = trim($_POST['invoice_no']); $invoice_no = str_replace(',', '<br>', $invoice_no); $order = array('shipping_id' => $shipping_id, 'shipping_name' => addslashes($shipping['shipping_name']), 'invoice_no' => $invoice_no); update_order($order_id, $order); /* todo 记录日志 */ $sn = $old_order['order_sn']; admin_log($sn, 'edit', 'order'); if (isset($_POST['finish'])) { ecs_header("Location: order.php?act=info&order_id=" . $order_id . "\n"); exit; } } } elseif ($act == 'quick_delivery') { global $ecs, $db; $order_id = empty($_REQUEST['order_id']) ? 0 : intval($_REQUEST['order_id']); $express_no = empty($_REQUEST['express_no']) ? 0 : intval($_REQUEST['express_no']); if (empty($express_no)) { sys_msg('请输入快递单号!', 1); } if (empty($order_id)) { sys_msg('请输入订单号!', 1); } //检测订单是否属于该商户、检测订单是否处于待发货状态 $sql = 'SELECT COUNT(*) FROM ' . $ecs->table('order_info') . ' WHERE supplier_id=' . $_SESSION['supplier_id'] . order_query_sql('await_ship');
$id = intval($_REQUEST['id']); $smarty->assign('booking', get_booking_info($id)); $smarty->assign('ur_here', $_LANG['detail']); $smarty->assign('action_link', array('text' => $_LANG['06_undispose_booking'], 'href' => 'goods_booking.php?act=list_all')); $smarty->display('booking_info.htm'); } /*------------------------------------------------------ */ //-- 处理提交数据 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'update') { /* 权限判断 */ admin_priv('booking'); $dispose_note = !empty($_POST['dispose_note']) ? trim($_POST['dispose_note']) : ''; $sql = "UPDATE " . $ecs->table('booking_goods') . " SET is_dispose='1', dispose_note='{$dispose_note}', " . "dispose_time='" . gmtime() . "', dispose_user='******'admin_name'] . "'" . " WHERE rec_id='{$_REQUEST['rec_id']}'"; $db->query($sql); ecs_header("Location: ?act=detail&id=" . $_REQUEST['rec_id'] . "\n"); exit; } /** * 获取订购信息 * * @access public * * @return array */ function get_bookinglist() { /* 查询条件 */ $filter['keywords'] = empty($_REQUEST['keywords']) ? '' : trim($_REQUEST['keywords']); if ($_REQUEST['is_ajax'] == 1) { $filter['keywords'] = json_str_iconv($filter['keywords']);
$goods_attr = join('', $attr_list); } else { $snatch['product_id'] = 0; } /* 清空购物车中所有商品 */ include_once ROOT_PATH . 'includes/lib_order.php'; clear_cart(CART_SNATCH_GOODS); /* 加入购物车 */ $cart = array('user_id' => $_SESSION['user_id'], 'session_id' => SESS_ID, 'goods_id' => $snatch['goods_id'], 'product_id' => $snatch['product_id'], 'goods_sn' => addslashes($snatch['goods_sn']), 'goods_name' => addslashes($snatch['goods_name']), 'market_price' => $snatch['market_price'], 'goods_price' => $result['buy_price'], 'goods_number' => 1, 'goods_attr' => $goods_attr, 'goods_attr_id' => $goods_attr_id, 'is_real' => $snatch['is_real'], 'extension_code' => addslashes($snatch['extension_code']), 'parent_id' => 0, 'rec_type' => CART_SNATCH_GOODS, 'is_gift' => 0); $db->autoExecute($ecs->table('cart'), $cart, 'INSERT'); /* 记录购物流程类型:夺宝奇兵 */ $_SESSION['flow_type'] = CART_SNATCH_GOODS; $_SESSION['extension_code'] = 'snatch'; $_SESSION['extension_id'] = $id; /* 进入收货人页面 */ ecs_header("Location: ./flow.php?step=consignee\n"); exit; } /** * 取得用户对当前活动的所出过的价格 * * @access public * @param * * @return void */ function get_myprice($id) { $my_only_price = array(); $my_price = array(); $pay_points = 0;
if ($act != 'checkout' && $act != 'consignee') { $goods_id = isset($_REQUEST['id']) ? $_REQUEST['id'] : ''; if ($goods_id) { clear_cart(); $_LANG['shortage'] = "对不起,该商品已经库存不足暂停销售。\n你现在要进行缺货登记来预订该商品吗?"; if (!addto_cart($goods_id)) { echo '购买失败,请重新购买!'; } else { $goods_order = 1; ecs_header("Location: buy.php?act=checkout"); exit; } } else { echo '参数错误!'; $Loaction = 'index.php'; ecs_header("Location: {$Loaction}\n"); } } elseif ($act == 'checkout' || $act == 'consignee') { if ($_SESSION['user_id'] > 0) { $act = 'consignee'; } if ($act == 'consignee') { include_once 'includes/lib_transaction.php'; /* * 收货人信息填写界面 */ if (isset($_REQUEST['direct_shopping'])) { $_SESSION['direct_shopping'] = 1; } /* 取得国家列表、商店所在国家、商店所在国家的省列表 */ $smarty->assign('country_list', get_regions());
/* 发送邮件 */ if (send_mail($message_info['user_name'], $message_info['user_email'], $template['template_subject'], $content, $template['is_html'])) { $send_ok = 0; } else { $send_ok = 1; } } ecs_header("Location: ?act=view&id=" . $_REQUEST['msg_id'] . "&send_ok={$send_ok}\n"); exit; } elseif ($_REQUEST['act'] == 'drop_file') { /* 删除上传的文件 */ $file = $_GET['file']; @unlink('../' . DATA_DIR . '/feedbackimg/' . $file); /* 更新数据库 */ $db->query("UPDATE " . $ecs->table('feedback') . " SET message_img = '' WHERE msg_id = '{$_GET['id']}'"); ecs_header("Location: user_msg.php?act=view&id=" . $_GET['id'] . "\n"); exit; } /** * * * @access public * @param * * @return void */ function msg_list() { /* 过滤条件 */ $filter['keywords'] = empty($_REQUEST['keywords']) ? '' : trim($_REQUEST['keywords']); if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) {
} $db->query($sql); clear_cache_files(); $links[] = array('text' => $_LANG['navigator'], 'href' => 'navigator.php?act=list'); sys_msg($_LANG['edit_ok'], 0, $links); } } elseif ($_REQUEST['act'] == 'del') { $id = (int) $_GET['id']; $row = $db->getRow("SELECT ctype,cid,type FROM " . $GLOBALS['ecs']->table('nav') . " WHERE id = '{$id}' LIMIT 1"); if ($row['type'] == 'middle' && $row['ctype'] && $row['cid']) { set_show_in_nav($row['ctype'], $row['cid'], 0); } $sql = " DELETE FROM " . $GLOBALS['ecs']->table('nav') . " WHERE id='{$id}' LIMIT 1"; $db->query($sql); clear_cache_files(); ecs_header("Location: navigator.php?act=list\n"); exit; } elseif ($_REQUEST['act'] == 'edit_sort_order') { check_authz_json('nav'); $id = intval($_POST['id']); $order = json_str_iconv(trim($_POST['val'])); /* 检查输入的值是否合法 */ if (!preg_match("/^[0-9]+\$/", $order)) { make_json_error(sprintf($_LANG['enter_int'], $order)); } else { if ($exc->edit("vieworder = '{$order}'", $id)) { clear_cache_files(); make_json_result(stripslashes($order)); } else { make_json_error($db->error()); }
//促销信息 $smarty->assign('comment_percent', comment_percent($goods_id)); //获取评分 $smarty->assign('promotion_info', get_promotion_info()); $goods = get_goods_info($goods_id); //获得商品的信息 $bidrecord = get_goods_bid($goods_id); //获得投标记录 //$repayrecord = get_goods_repay($goods_id); //获得还款记录 /* 获取所属大类的名称 */ /*$sql = 'select a.cat_name from'.$ecs->table("category").' as a,'.$ecs->table("category").' as b where a.cat_id = b.parent_id and b.cat_id='.$goods["cat_id"]; $goods_row = $db->getRow($sql); $goods_row_catname = $goods_row['cat_name'];*/ if ($goods === false) { /* 如果没有找到任何记录则跳回到首页 */ ecs_header("Location: ./\n"); exit; } else { if ($goods['brand_id'] > 0) { $goods['goods_brand_url'] = build_uri('brand', array('bid' => $goods['brand_id']), $goods['goods_brand']); } $shop_price = $goods['shop_price']; $linked_goods = get_linked_goods($goods_id); $goods['goods_style_name'] = add_style($goods['goods_name'], $goods['goods_name_style']); /* 购买该商品可以得到多少钱的红包 */ if ($goods['bonus_type_id'] > 0) { $time = gmtime(); $sql = "SELECT type_money FROM " . $ecs->table('bonus_type') . " WHERE type_id = '{$goods['bonus_type_id']}' " . " AND send_type = '" . SEND_BY_GOODS . "' " . " AND send_start_date <= '{$time}'" . " AND send_end_date >= '{$time}'"; $goods['bonus_money'] = floatval($db->getOne($sql)); if ($goods['bonus_money'] > 0) { $goods['bonus_money'] = price_format($goods['bonus_money']);
/* 文章详情 */ if ($_REQUEST['type'] == 'sjs') { $article = get_article_info_sjs($article_id); } else { if ($_REQUEST['type'] == 'fu') { $article = get_article_info0($article_id); } else { $article = get_article_info($article_id); } } if (empty($article)) { ecs_header("Location: ./\n"); exit; } if (!empty($article['link']) && $article['link'] != 'http://' && $article['link'] != 'https://') { ecs_header("location:{$article['link']}\n"); exit; } $smarty->assign('article_categories', article_categories_tree($article_id)); //文章分类树 $smarty->assign('categories', get_categories_tree()); // 分类树 $smarty->assign('helps', get_shop_help()); // 网店帮助 $smarty->assign('top_goods', get_top10()); // 销售排行 $smarty->assign('best_goods', get_recommend_goods('best')); // 推荐商品 $smarty->assign('new_goods', get_recommend_goods('new')); // 最新商品 $smarty->assign('hot_goods', get_recommend_goods('hot'));
/** * 第三方登录 */ public function third_login() { $type = I('get.type'); $file = ROOT_PATH . 'plugins/connect/' . $type . '.php'; if (file_exists($file)) { include_once $file; } else { show_message(L('process_false'), L('relogin_lnk'), url('login', array('referer' => urlencode($this->back_act))), 'error'); } $url = __URL__ . '/index.php?m=default&c=user&a=third_login&type=' . $type; $info = model('ClipsBase')->get_third_user_info($type); // 判断是否安装 if (!$info) { show_message(L('no_register_auth'), L('relogin_lnk'), url('login', array('referer' => urlencode($this->back_act))), 'error'); } $obj = new $type($info); if ($_GET['code'] && $_GET['code'] != '') { // 授权成功 返回登录 if ($obj->call_back($info, $url, $_GET['code'])) { if ($_SESSION['access_token']) { $res = new $type($info, $_SESSION['access_token']); $openid = $res->get_openid(); // 获取用户信息 $userinfo = $res->get_user_info($openid); // 处理数据 $userinfo['aite_id'] = $type . '_' . $openid; // 添加登录标示 if ($userinfo['user_name'] = model('Users')->get_one_user($userinfo['aite_id'])) { // 已有记录 self::$user->set_session($userinfo['user_name']); self::$user->set_cookie($userinfo['user_name']); model('Users')->update_user_info(); model('Users')->recalculate_price(); $jump_url = empty($this->back_act) ? url('index') : $this->back_act; $this->redirect($jump_url); } $userinfo['user_name'] = substr($openid, -6); if (self::$user->check_user($userinfo['user_name'])) { $userinfo['user_name'] = $userinfo['user_name'] . rand(1000, 9999); // 重名处理 } $userinfo['email'] = empty($userinfo['email']) ? $userinfo['user_name'] . '@' . get_top_domain() : $userinfo['email']; // 插入数据库 model('Users')->third_reg($userinfo); self::$user->set_session($userinfo['user_name']); self::$user->set_cookie($userinfo['user_name']); model('Users')->update_user_info(); model('Users')->recalculate_price(); $jump_url = empty($this->back_act) ? url('index') : $this->back_act; $this->redirect($jump_url); } } else { show_message(L('process_false'), L('relogin_lnk'), url('login', array('referer' => urlencode($this->back_act))), 'error'); } } else { // 开始授权登录 $url = $obj->act_login($info, $url); ecs_header("Location: " . $url . "\n"); exit; } }
/** * 用户进行密码找回操作时,发送一封确认邮件 * * @access public * @param string $uid 用户ID * @param string $user_name 用户帐号 * @param string $email 用户Email * @param string $code key * * @return boolen $result; */ function send_pwd_email($uid, $user_name, $email, $code) { if (empty($uid) || empty($user_name) || empty($email) || empty($code)) { ecs_header("Location: " . url('user/get_password_phone') . "\n"); exit; } /* 设置重置邮件模板所需要的内容信息 */ $template = model('Base')->get_mail_template('send_password'); $reset_email = __HOST__ . url('user/get_password_email', array('uid' => $uid, 'code' => $code)); ECTouch::view()->assign('user_name', $user_name); ECTouch::view()->assign('reset_email', $reset_email); ECTouch::view()->assign('shop_name', C('shop_name')); ECTouch::view()->assign('send_date', date('Y-m-d')); ECTouch::view()->assign('sent_date', date('Y-m-d')); $content = ECTouch::view()->fetch('str:' . $template['template_content']); /* 发送确认重置密码的确认邮件 */ if (send_mail($user_name, $email, $template['template_subject'], $content, $template['is_html'])) { return true; } else { return false; } }
} $smarty->assign('menus', $menus); $smarty->assign('no_help', $_LANG['no_help']); $smarty->assign('help_lang', $_CFG['lang']); $smarty->assign('charset', EC_CHARSET); $smarty->assign('admin_id', $_SESSION['admin_id']); $smarty->display('menu.htm'); } elseif ($_REQUEST['act'] == 'clear_cache') { clear_all_files(); sys_msg($_LANG['caches_cleared']); } elseif ($_REQUEST['act'] == 'main') { //开店向导第一步 if (isset($_SESSION['shop_guide']) && $_SESSION['shop_guide'] === true) { unset($_SESSION['shop_guide']); //销毁session ecs_header("Location: ./index.php?act=first\n"); exit; } $gd = gd_version(); /* 检查文件目录属性 */ $warning = array(); if ($_CFG['shop_closed']) { $warning[] = $_LANG['shop_closed_tips']; } if (file_exists('../install')) { $warning[] = $_LANG['remove_install']; } if (file_exists('../upgrade')) { $warning[] = $_LANG['remove_upgrade']; } $open_basedir = ini_get('open_basedir');
/** * 异步加载品牌列表 */ public function list_asynclist() { $this->parameter(); $this->assign('show_marketprice', C('show_marketprice')); $brand_id = I('request.brand'); $brand_info = model('BrandBase')->get_brand_info($brand_id); if (empty($brand_info)) { ecs_header("Location: ./\n"); exit; } $asyn_last = intval(I('post.last')) + 1; $this->size = I('post.amount'); $this->page = $asyn_last > 0 ? ceil($asyn_last / $this->size) : 1; $list = model('Brand')->brand_get_goods($brand_id, '', $this->sort, $this->order, $this->size, $this->page); foreach ($list as $key => $value) { $this->assign('brand_goods', $value); $sayList[] = array('single_item' => ECTouch::view()->fetch('library/asynclist_info.lbi')); } die(json_encode($sayList)); exit; }
$goods_link = $ecs->url() . 'goods.php?id=' . $booking_info['goods_id']; $smarty->assign('user_name', $booking_info['link_man']); $smarty->assign('goods_link', $goods_link); $smarty->assign('goods_name', $booking_info['goods_name']); $smarty->assign('dispose_note', $dispose_note); $smarty->assign('shop_name', "<a href='" . $ecs->url() . "'>" . $_CFG['shop_name'] . '</a>'); $smarty->assign('send_date', date('Y-m-d')); $content = $smarty->fetch('str:' . $template['template_content']); /* 发送邮件 */ if (send_mail($booking_info['link_man'], $booking_info['email'], $template['template_subject'], $content, $template['is_html'])) { $send_ok = 0; } else { $send_ok = 1; } } ecs_header("Location: ?act=detail&id=" . $_REQUEST['rec_id'] . "&send_ok={$send_ok}\n"); exit; } /** * 获取订购信息 * * @access public * * @return array */ function get_bookinglist() { /* 查询条件 */ $filter['keywords'] = empty($_REQUEST['keywords']) ? '' : trim($_REQUEST['keywords']); if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) { $filter['keywords'] = json_str_iconv($filter['keywords']);
<?php define('IN_ECS', true); require dirname(__FILE__) . '/includes/init.php'; if (empty($_SESSION['user_id'])) { ecs_header('Location:./'); } uc_call("uc_pm_location", array($_SESSION['user_id'])); //$ucnewpm = uc_pm_checknew($_SESSION['user_id']); //setcookie('checkpm', '');
/* 当前分类下是否存在商品 */ $goods_count = $db->getOne('SELECT COUNT(*) FROM ' . $ecs->table('goods') . " WHERE cat_id='{$cat_id}'"); /* 如果不存在下级子分类和商品,则删除之 */ if ($cat_count == 0 && $goods_count == 0) { /* 删除分类 */ $sql = 'DELETE FROM ' . $ecs->table('category') . " WHERE cat_id = '{$cat_id}'"; if ($db->query($sql)) { $db->query("DELETE FROM " . $ecs->table('nav') . "WHERE ctype = 'c' AND cid = '" . $cat_id . "' AND type = 'middle'"); clear_cache_files(); admin_log($cat_name, 'remove', 'category'); } } else { make_json_error($cat_name . ' ' . $_LANG['cat_isleaf']); } $url = 'category.php?act=query&' . str_replace('act=remove', '', $_SERVER['QUERY_STRING']); ecs_header("Location: {$url}\n"); exit; } /*------------------------------------------------------ */ //-- PRIVATE FUNCTIONS /*------------------------------------------------------ */ // ///** // * 检查分类是否已经存在 // * // * @param string $cat_name 分类名称 // * @param integer $parent_cat 上级分类 // * @param integer $exclude 排除的分类ID // * // * @return boolean // */
clear_cart(); $state = is_stock($goods_id, $number, $spec); if ($state == false) { mobile_error('返回上一页', '', '库存不足'); } elseif ($state === 2) { mobile_error('返回上一页', '', '配件不允许单独销售'); } elseif ($state === 3) { mobile_error('返回上一页', '', '商品信息错误'); } elseif ($state === 4) { mobile_error('返回上一页', '', '商品已经下架,无法购买'); } if (!addto_cart($goods_id, $number, $spec)) { mobile_error('返回上一页', '', '购买失败,请重新购买'); } else { $goods_order = 1; ecs_header('Location: flow.php?act=add_order'); exit; } } else { mobile_error('返回上一页', '', '参数错误'); } } elseif ($_REQUEST['act'] == 'add_order') { $cart_goods = cart_goods($flow_type); if (empty($cart_goods)) { mobile_error('返回首页', 'index.php', '购物车里面无商品'); } else { $smarty->assign('cart_goods', $cart_goods); } $consignee = get_consignee($_SESSION['user_id']); if ($consignee['address_id']) { $_SESSION['mobile_flow_consignee'] = $consignee;