Пример #1
0
 protected function _orderleft($smarty)
 {
     //全部订单链接
     $all_url = url('admin', 'adminorder::all');
     $smarty->assign("all_url", $all_url);
     //无效链接
     $unorder_url = url('admin', 'adminorder::unorder');
     $smarty->assign('unorder_url', $unorder_url);
     //未确认链接
     $unconfirm_url = url('admin', 'adminorder::unconfirm');
     $smarty->assign('unconfirm_url', $unconfirm_url);
     //已确认链接
     $confirm_url = url('admin', 'adminorder::confirm');
     $smarty->assign('confirm_url', $confirm_url);
     //配货中链接
     $ready_url = url('admin', 'adminorder::ready');
     $smarty->assign('ready_url', $ready_url);
     //已发货链接
     $shipping_url = url('admin', 'adminorder::shipping');
     $smarty->assign('shipping_url', $shipping_url);
     //已收货链接
     $receive_url = url('admin', 'adminorder::receive');
     $smarty->assign('receive_url', $receive_url);
     //用户名
     $username = LuS::get('admin_order_username');
     $smarty->assign('username', $username);
     //退出登录
     $admin_outlogin_url = url('admin', 'adminorder::outlogin');
     $smarty->assign('admin_outlogin_url', $admin_outlogin_url);
 }
Пример #2
0
 public function _login()
 {
     if (!LuS::get('admin_order_uid')) {
         $login_url = url('admin', 'adminorder::login');
         header('Location:' . $login_url);
         throw new Exception('exit');
     }
 }
Пример #3
0
 public function _login()
 {
     if (!LuS::get('admin_goods_uid')) {
         $url = url('admin', 'admingoods::login');
         header('Location:' . $url);
         throw new Exception('exit');
     }
 }
Пример #4
0
 public function __construct()
 {
     $uid = LuS::get('admin_goods_uid');
     if (!$uid) {
         $url = url('admin', 'admingoods::login');
         header('Location:' . $url);
         throw new Exception('exit');
     }
 }
Пример #5
0
 public function _show($smarty)
 {
     $uid = LuS::get('uid');
     if ($uid) {
         $is_login = true;
     } else {
         $is_login = false;
     }
     $smarty->assign('is_login', $is_login);
     //首页
     $home_url = HOMEURL;
     $smarty->assign('home_url', $home_url);
     //登录
     $login_url = url('login', 'login::index');
     $smarty->assign('login_url', $login_url);
     //注册
     $reg_url = url('reg', 'reg::index');
     $smarty->assign('reg_url', $reg_url);
     //退出登录
     $outlogin_url = url('home', 'home::outlogin');
     $smarty->assign('outlogin_url', $outlogin_url);
     //个人中心
     $usercenter_url = url('usercenter', 'usercenter::index');
     $smarty->assign('usercenter_url', $usercenter_url);
     $my_order_url = url('usercenter', 'usercenter::orderlist');
     $smarty->assign('my_order_url', $my_order_url);
     //用户名
     $username = LuS::get('username');
     $smarty->assign('username', $username);
     //购物车数量
     $cart_num = Cart::getCount($uid);
     $smarty->assign('cart_num', $cart_num);
     //购物车
     $cart_url = url('goods', 'goods::cart');
     $smarty->assign('cart_url', $cart_url);
 }
Пример #6
0
 public function login()
 {
     var_dump(LuS::get());
 }
Пример #7
0
 public static function createWeiboUser()
 {
     if (!self::$_config) {
         self::$_config = (require_once WEIBO_PATH . 'config/config.php');
     }
     //获取用户的资料
     if (!$_SESSION['token']['uid']) {
         return false;
     }
     $uid = $_SESSION['token']['uid'];
     //获取用户的信息
     $c = new SaeTClientV2(self::$_config['WB_AKEY'], self::$_config['WB_SKEY'], self::$_config['WB_ACCESS_TOKEN']);
     $info = $c->request_with_uid('https://api.weibo.com/2/users/show.json', $uid);
     if ($info) {
         //检查是否已经建立过用户了
         $db = self::_db();
         $check = $db->where(array('uid' => $_SESSION['token']['uid']))->limit(1)->select();
         if ($check && $check[0]['uid']) {
             //已经建立过用户了
             LuS::set('uid', $check[0]['user_id']);
             LuS::set('username', $check[0]['screen_name']);
             return true;
         }
         //建立用户
         $email = $info['screen_name'] . '@sina.com';
         $username = $info['screen_name'];
         $password = md5(rand(100, 9999) . time());
         $user_id = User::addUser($username, $password, $email);
         if (!$user_id) {
             echo '登录失败';
             throw new Exception('exit');
         }
         //存储用户信息
         $rs = self::addWeiboUserInfo($user_id);
         if ($rs) {
             LuS::set('uid', $user_id);
             LuS::set('username', $username);
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Пример #8
0
 protected function getaddrdata()
 {
     $msg = array();
     //名字
     $data['consignee'] = empty($_POST['consignee']) ? '' : htmlspecialchars(trim($_POST['consignee']));
     if (!$data['consignee']) {
         // $msg = '请输入姓名!\r\n';
         $msg['error'] = '-1';
         $msg['msg'] = '请输入姓名!';
         echo json_encode($msg);
         throw new Exception('exit');
     }
     //手机
     $data['mobile'] = empty($_POST['mobile']) ? 0 : htmlspecialchars(trim($_POST['mobile']));
     if ($data['mobile']) {
         $exp = "/^1\\d{10}\$/";
         if (!preg_match($exp, $data['mobile'])) {
             // $msg .= '输入的手机格式错误!\r\n';
             $msg['error'] = '-2';
             $msg['msg'] = '输入的手机格式错误!';
             echo json_encode($msg);
             throw new Exception('exit');
         }
     } else {
         // $msg .= '请输入手机号码!\r\n';
         $msg['error'] = '-3';
         $msg['msg'] = '请输入手机号码!';
         echo json_encode($msg);
         throw new Exception('exit');
     }
     //电话
     $tel_area = empty($_POST['tel_area']) ? '' : htmlspecialchars(trim($_POST['tel_area']));
     $data['tel'] = empty($_POST['tel']) ? '' : htmlspecialchars(trim($_POST['tel']));
     if ($data['tel']) {
         //填写了区号
         if ($tel_area) {
             $data['tel'] = $tel_area . $data['tel'];
         }
         $exp = '/^(0?(([1-9]\\d)|([3-9]\\d{2}))-?)?\\d{7,8}$/';
         if (!preg_match($exp, $data['tel'])) {
             // $msg .= '输入的固定电话错误!\r\n';
             $msg['error'] = '-4';
             $msg['msg'] = '输入的固定电话错误!';
             echo json_encode($msg);
             throw new Exception('exit');
         }
     }
     //省份
     $data['province'] = empty($_POST['province']) ? 0 : htmlspecialchars(trim($_POST['province']));
     if (!$data['province']) {
         // $msg .= '省不能为空!\r\n';
         // $msg['error'] = '-5';
         // $msg['msg'] = '省不能为空!';
         // echo json_encode( $msg );
         // throw new Exception('exit');
     }
     // Assert::num_gt_zero($data['province'], '省份不能为空');
     //城市
     $data['city'] = empty($_POST['city']) ? 0 : htmlspecialchars(trim($_POST['city']));
     if (!$data['city']) {
         // $msg .= '市不能为空!\r\n';
         // $msg['error'] = '-6';
         // $msg['msg'] = '市不能为空!';
         // echo json_encode( $msg );
         // throw new Exception('exit');
     }
     // Assert::num_gt_zero($data['city'], '城市不能为空');
     //地区
     $data['district'] = empty($_POST['district']) ? 0 : htmlspecialchars(trim($_POST['district']));
     // if( !$data['district'] ){
     // 	// $msg .= '区不能为空!\r\n';
     // 	$msg['error'] = '-7';
     // 	$msg['msg'] = '区不能为空!';
     // 	echo json_encode( $msg );
     // 	throw new Exception('exit');
     // }
     // Assert::num_gt_zero($data['district'], '区县不能为空');
     //详细地址
     $data['address'] = empty($_POST['address']) ? '' : htmlspecialchars(trim($_POST['address']));
     if (!$data['address']) {
         // $msg .= '请输入详细地址!\r\n';
         $msg['error'] = '-8';
         $msg['msg'] = '请输入详细地址!';
         echo json_encode($msg);
         throw new Exception('exit');
     }
     //是否默认地址
     $data['is_default'] = isset($_POST['is_default']) && !empty($_POST['is_default']) ? "yes" : 'no';
     //用户id
     $data['uid'] = User::getLoginUid();
     //如果有跳转地址,用户下单的时候添加地址,默认设置为默认地址
     $addr_jump_url = LuS::get('addr_jump_url');
     if (isset($addr_jump_url) && !empty($addr_jump_url)) {
         UserAddress::setDefaultAddressToNull($data['uid']);
         //去掉默认地址
         $data['is_default'] = 'yes';
         //设置当前为默认地址
     }
     if ($msg) {
         // echo "$msg";
         $msg['error'] = '-9';
         $msg['msg'] = $msg;
         echo json_encode($msg);
         throw new Exception('exit');
     }
     return $data;
 }
Пример #9
0
 public static function modify($uid)
 {
     //没有登录
     $data['uid'] = $uid;
     if (!$data['uid']) {
         return false;
     }
     //从购物车取出没有对应用户的商品
     $sid_where['sid'] = session_id();
     $sid_where['uid'] = '0';
     $sid_cart_goods_info = self::_list($sid_where);
     if (!$sid_cart_goods_info) {
         return false;
     }
     //检查用户是否已经存在商品,如果存在添加数量,并删除该条没有对应用户的数据
     foreach ($sid_cart_goods_info as $key => $value) {
         $goods_id = $value['goods_id'];
         $rs = Cart::getCartGoodsInfoByGoodsId($uid, $goods_id);
         if ($rs) {
             $add_data['goods_id'] = $goods_id;
             $add_data['goods_num'] = $value['goods_num'];
             Cart::add($uid, $add_data);
             //删除没有登录情况下的购物车商品
             $del_where['sid'] = session_id();
             $del_where['uid'] = '0';
             $del_where['goods_id'] = $goods_id;
             Cart::delete($del_where);
         }
     }
     $data['username'] = LuS::get('username');
     $where['sid'] = session_id();
     $where['uid'] = '0';
     return Cart::update($data, $where);
 }
Пример #10
0
 /**
  *	根据用户点击找回密码的url来寻找是哪一个email
  *	并且检查是否过期,是否被使用过了
  */
 protected function _checkCode($code)
 {
     $code = htmlspecialchars($code);
     $info = Code::getCodeInfoByCode($code);
     if ($info) {
         $info = $info[0];
         if ($info['is_use'] == 'no' && $info['expire'] > time()) {
             return true;
         }
     }
     LuS::set('email_save_msg', "该链接已使用或已过期!!!点我重新验证!");
     LuS::set('email_save_url', url("login", "passwd::index"));
     $url = url("login", "passwd::prompt");
     header("location:{$url}");
     throw new Exception('exit');
 }
Пример #11
0
 public function addtoorder()
 {
     //是否已经登录
     User::isLogin();
     if (!$_POST) {
         $url = url('goods', 'goods::balance');
         header('Location:' . $url);
         throw new Exception('exit');
     }
     $default_address_id = isset($_POST['shipping']) ? htmlspecialchars($_POST['shipping']) : 0;
     $payment = isset($_POST['payment']) ? htmlspecialchars($_POST['payment']) : '';
     $is_mobile = isset($_POST['mobile']) ? htmlspecialchars($_POST['mobile']) : '';
     $uid = LuS::get('uid');
     $username = LuS::get('username');
     $order_id = Cart::addOrder($uid, $username, $payment, $default_address_id);
     //订单详情页
     $order_detail_url = url('usercenter', 'usercenter::detail', $order_id);
     //首页
     $home_url = HOMEURL;
     //订单号
     $order_info = OrderInfo::getUserOrderInfoByOrderId($uid, $order_id);
     //获取支付链接
     $pay = GoodsM::getPayList($order_info['sn']);
     //货到付款
     $hdfkpay_url = $order_detail_url;
     $smarty = get_smarty();
     $smarty->assign('order_detail_url', $order_detail_url);
     $smarty->assign('home_url', $home_url);
     $str = $smarty->fetch('goods/order_success.html');
     //增加一个订单id
     $return_arr = array(true, $str, $pay['alipay'], $pay['wxpay'], $pay['wxsaomapay'], $hdfkpay_url, $order_id);
     echo json_encode($return_arr);
     throw new Exception('exit');
 }
Пример #12
0
 * 默认禁止错误信息
 */
define("QQDEBUG", true);
if (defined("QQDEBUG") && QQDEBUG) {
    @ini_set("error_reporting", 0);
    @ini_set("display_errors", false);
}
/**
 * session
 */
// include_once("session.php");
/**
 * 在你运行本demo之前请到 http://connect.opensns.qq.com/申请appid, appkey, 并注册callback地址
 */
//申请到的appid
// $_SESSION["appid"]    = 101244934;
// //申请到的appkey
// $_SESSION["appkey"]   = "c97f1e6026bdef1a2ca31431e6a08a6f";
// //QQ登录成功后跳转的地址,请确保地址真实可用,否则会导致登录失败。
// $_SESSION["callback"] = HOMEURL . 'qq_callback.php';
// //QQ授权api接口.按需调用
// $_SESSION["scope"] = "get_user_info";
// 申请到的appid
LuS::set('appid', 101244934);
//申请到的appkey
LuS::set('appkey', "c97f1e6026bdef1a2ca31431e6a08a6f");
//QQ登录成功后跳转的地址,请确保地址真实可用,否则会导致登录失败。
LuS::set('callback', HOMEURL . 'qq_callback.php');
//QQ授权api接口.按需调用
LuS::set('scope', "get_user_info");
//print_r ($_SESSION);
Пример #13
0
 public static function getUserInfo()
 {
     $getUserInfo = "https://graph.qq.com/user/get_user_info?" . "access_token=" . LuS::get('access_token') . "&oauth_consumer_key=" . LuS::get("appid") . "&openid=" . LuS::get("openid") . "&format=json";
     $info = file_get_contents($getUserInfo);
     $arr = json_decode($info, true);
     return $arr;
 }
Пример #14
0
 protected static function addUserInfo()
 {
     // error_reporting(E_ALL);
     //是否已经存在
     $db = self::_db();
     $data['openid'] = htmlspecialchars(trim($_SESSION['openid']));
     $userinfo = $db->where(array("openid" => $data['openid']))->select();
     // var_dump($userinfo);
     if ($userinfo) {
         LuS::set('uid', $userinfo[0]['uid']);
         LuS::set('username', $userinfo[0]['nickname']);
         return true;
     }
     $rs = self::getUserInfo();
     $data['nickname'] = htmlspecialchars(trim($rs['nickname']));
     $data['access_token'] = htmlspecialchars(trim($_SESSION['access_token']));
     $data['refresh_token'] = htmlspecialchars(trim($_SESSION['refresh_token']));
     $data['expires_in'] = htmlspecialchars(trim($_SESSION['expires_in']));
     //添加到user表
     $uid = User::addUser($data['nickname'], md5(rand(100, 9999) . time()), $data['nickname'] . '@qq.com');
     if (!$uid) {
         return false;
     }
     $data['uid'] = $uid;
     $addrs = $db->data($data)->insert();
     if ($addrs) {
         LuS::set('uid', $uid);
         LuS::set('username', $data['nickname']);
         return true;
     }
     return false;
 }
Пример #15
0
 public static function outLogin()
 {
     LuS::del('uid');
     LuS::del('username');
     LuS::del('addr_jump_url');
     //结算时添加地址后跳转的地址
     unset($_SESSION);
     unset($_COOKIE);
     return true;
 }