コード例 #1
0
ファイル: themeroute.php プロジェクト: herrify/iwebshop
 /**
  * @brief theme和skin进行选择
  */
 public static function onCreateController()
 {
     $controller = func_num_args() > 0 && func_get_arg(0) ? func_get_arg(0) : IWeb::$app->controller;
     /**
      * 对于theme和skin的判断流程
      * 1,直接从URL中获取是否已经设定了方案__theme,__skin
      * 2,从cookie获取数据
      */
     $urlTheme = IReq::get('__theme');
     $urlSkin = IReq::get('__skin');
     if ($urlTheme && $urlSkin && preg_match('|^\\w+$|', $urlTheme) && preg_match('|^\\w+$|', $urlSkin)) {
         ISafe::set('__theme', $theme = $urlTheme);
         ISafe::set('__skin', $skin = $urlSkin);
     } elseif (ISafe::get('__theme') && ISafe::get('__skin')) {
         $theme = ISafe::get('__theme');
         $skin = ISafe::get('__skin');
     }
     if (isset($theme) && isset($skin)) {
         $themePath = IWeb::$app->getViewPath() . $theme . "/" . IWeb::$app->controller->getId();
         if (is_dir($themePath)) {
             $controller->theme = $theme;
             $controller->skin = $skin;
         }
     }
 }
コード例 #2
0
ファイル: systemseller.php プロジェクト: yongge666/sunupedu
 /**
  * @brief 商家登录动作
  */
 public function login()
 {
     $seller_name = IFilter::act(IReq::get('username'));
     $password = IReq::get('password');
     $message = '';
     if ($seller_name == '') {
         $message = '登录名不能为空';
     } else {
         if ($password == '') {
             $message = '密码不能为空';
         } else {
             $sellerObj = new IModel('seller');
             $sellerRow = $sellerObj->getObj('seller_name = "' . $seller_name . '" and is_del = 0 and is_lock = 0');
             if ($sellerRow && $sellerRow['password'] == md5($password)) {
                 $dataArray = array('login_time' => ITime::getDateTime());
                 $sellerObj->setData($dataArray);
                 $where = 'id = ' . $sellerRow["id"];
                 $sellerObj->update($where);
                 //存入私密数据
                 ISafe::set('seller_id', $sellerRow['id']);
                 ISafe::set('seller_name', $sellerRow['seller_name']);
                 ISafe::set('seller_pwd', $sellerRow['password']);
                 $this->redirect('/seller/index');
             } else {
                 $message = '用户名与密码不匹配';
             }
         }
     }
     if ($message != '') {
         $this->redirect('index', false);
         Util::showMessage($message);
     }
 }
コード例 #3
0
ファイル: ucenter.php プロジェクト: Wen1750686723/utao
 function user_ico_upload()
 {
     $user_id = ISafe::get('user_id');
     $result = array('isError' => true);
     if (isset($_FILES['attach']['name']) && $_FILES['attach']['name'] != '') {
         $photoObj = new PhotoUpload();
         $photoObj->setThumb(100, 100, 'user_ico');
         $photo = $photoObj->run();
         if (!empty($photo['attach']['thumb']['user_ico'])) {
             $user_id = ISafe::get('user_id');
             $user_obj = new IModel('user');
             $dataArray = array('head_ico' => $photo['attach']['thumb']['user_ico']);
             $user_obj->setData($dataArray);
             $where = 'id = ' . $user_id;
             $isSuss = $user_obj->update($where);
             if ($isSuss !== false) {
                 $result['isError'] = false;
                 $result['data'] = IUrl::creatUrl() . $photo['attach']['thumb']['user_ico'];
                 ISafe::set('head_ico', $dataArray['head_ico']);
             } else {
                 $result['message'] = '上传失败';
             }
         } else {
             $result['message'] = '上传失败';
         }
     } else {
         $result['message'] = '请选择图片';
     }
     echo '<script type="text/javascript">parent.callback_user_ico(' . JSON::encode($result) . ');</script>';
 }
コード例 #4
0
ファイル: proxy.php プロジェクト: zhendeguoke1008/shop
 /**
  * 获取版权信息,存储到缓存中进行比对
  * @return boolean
  */
 public static function getAuthorize()
 {
     $iwebshopAuthorize = ISafe::get('iwebshopAuthorize');
     if ($iwebshopAuthorize === null) {
         $return = self::send('_c=system&_a=authorize&host=' . IUrl::getHost());
         $iwebshopAuthorize = isset($return['success']) && $return['success'] == 1 ? true : false;
         ISafe::set('iwebshopAuthorize', $iwebshopAuthorize);
     }
     return $iwebshopAuthorize;
 }
コード例 #5
0
ファイル: themeroute.php プロジェクト: yongge666/sunupedu
 /**
  * @brief theme和skin进行选择
  */
 public static function onCreateController()
 {
     $controller = func_num_args() > 0 ? func_get_arg(0) : IWeb::$app->controller;
     //判断是否为后台管理控制器
     if (in_array($controller->getId(), self::$syscontroller)) {
         defined("IWEB_SCENE") ? "" : define("IWEB_SCENE", self::SCENE_SYSDEFAULT);
         $controller->theme = self::$sysTheme;
         $controller->skin = self::$sysSkin;
     } elseif (in_array($controller->getId(), self::$sellercontroller)) {
         defined("IWEB_SCENE") ? "" : define("IWEB_SCENE", self::SCENE_SYSSELLER);
         $controller->theme = self::$sysSellerTheme;
         $controller->skin = self::$sysSellerSkin;
     } else {
         defined("IWEB_SCENE") ? "" : define("IWEB_SCENE", self::SCENE_SITE);
         /**
          * 对于theme和skin的判断流程
          * 1,直接从URL中获取是否已经设定了方案__theme,__skin
          * 2,获取cookie中的方案名称
          * 3,读取config配置中的默认方案
          */
         $urlTheme = IReq::get('__theme');
         $urlSkin = IReq::get('__skin');
         if ($urlTheme && $urlSkin && preg_match('|^\\w+$|', $urlTheme) && preg_match('|^\\w+$|', $urlSkin)) {
             ISafe::set('__theme', $controller->theme = $urlTheme);
             ISafe::set('__skin', $controller->skin = $urlSkin);
         } elseif (ISafe::get('__theme') && ISafe::get('__skin')) {
             $controller->theme = ISafe::get('__theme');
             $controller->skin = ISafe::get('__skin');
         } else {
             if (isset(IWeb::$app->config['theme'])) {
                 //根据不同的客户端进行智能选择
                 if (is_array(IWeb::$app->config['theme'])) {
                     $client = IClient::getDevice();
                     $controller->theme = isset(IWeb::$app->config['theme'][$client]) ? IWeb::$app->config['theme'][$client] : current(IWeb::$app->config['theme']);
                 } else {
                     $controller->theme = IWeb::$app->config['theme'];
                 }
             }
             if (isset(IWeb::$app->config['skin'])) {
                 //根据不同的客户端进行智能选择
                 if (is_array(IWeb::$app->config['skin'])) {
                     $client = IClient::getDevice();
                     $controller->skin = isset(IWeb::$app->config['skin'][$client]) ? IWeb::$app->config['skin'][$client] : current(IWeb::$app->config['skin']);
                 } else {
                     $controller->skin = IWeb::$app->config['skin'];
                 }
             }
         }
     }
     //修正runtime配置
     IWeb::$app->runtimePath = IWeb::$app->getRuntimePath() . $controller->theme . '/';
     IWeb::$app->webRunPath = IWeb::$app->getWebRunPath() . $controller->theme . '/';
 }
コード例 #6
0
ファイル: systemadmin.php プロジェクト: chenyongze/iwebshop
 function login_act()
 {
     $admin_name = IFilter::act(IReq::get('admin_name'));
     $password = IReq::get('password');
     $captcha = IReq::get('captcha', 'post');
     $message = '';
     if ($admin_name == '') {
         $message = '登录名不能为空';
     } else {
         if ($password == '') {
             $message = '密码不能为空';
         } else {
             if ($captcha != ISafe::get('Captcha')) {
                 $message = '验证码输入不正确';
             } else {
                 $adminObj = new IModel('admin');
                 $adminRow = $adminObj->getObj('admin_name = "' . $admin_name . '"');
                 if (!empty($adminRow) && $adminRow['password'] == md5($password) && $adminRow['is_del'] == 0) {
                     $dataArray = array('last_ip' => IClient::getIp(), 'last_time' => ITime::getDateTime());
                     $adminObj->setData($dataArray);
                     $where = 'id = ' . $adminRow["id"];
                     $adminObj->update($where);
                     //根据角色分配权限
                     if ($adminRow['role_id'] == 0) {
                         ISafe::set('admin_right', 'administrator');
                         ISafe::set('admin_role_name', '超级管理员');
                     } else {
                         $roleObj = new IModel('admin_role');
                         $where = 'id = ' . $adminRow["role_id"] . ' and is_del = 0';
                         $roleRow = $roleObj->getObj($where);
                         ISafe::set('admin_right', $roleRow['rights']);
                         ISafe::set('admin_role_name', $roleRow['name']);
                     }
                     ISafe::set('admin_id', $adminRow['id']);
                     ISafe::set('admin_name', $adminRow['admin_name']);
                     ISafe::set('admin_pwd', $adminRow['password']);
                     $this->redirect('/system/default');
                 } else {
                     $message = '用户名与密码不匹配';
                 }
             }
         }
     }
     if ($message != '') {
         $this->admin_name = $admin_name;
         $this->redirect('index', false);
         Util::showMessage($message);
     }
 }
コード例 #7
0
 /**
  * @brief 生成验证码
  * @return image图像
  */
 public function getCaptcha()
 {
     //清空布局
     $this->layout = '';
     //配置参数
     $width = IReq::get('w') ? IReq::get('w') : 130;
     $height = IReq::get('h') ? IReq::get('h') : 45;
     $wordLength = IReq::get('l') ? IReq::get('l') : 5;
     $fontSize = IReq::get('s') ? IReq::get('s') : 25;
     //创建验证码
     $ValidateObj = new Captcha();
     $ValidateObj->width = $width;
     $ValidateObj->height = $height;
     $ValidateObj->maxWordLength = $wordLength;
     $ValidateObj->minWordLength = $wordLength;
     $ValidateObj->fontSize = $fontSize;
     $ValidateObj->CreateImage($text);
     //设置验证码
     ISafe::set('captcha', $text);
 }
コード例 #8
0
ファイル: simple -6-29.php プロジェクト: yongge666/sunupedu
 public function bindUser($userInfo, $oauthId)
 {
     $oauthUserObj = new IModel('oauth_user');
     $oauthUserRow = $oauthUserObj->getObj("oauth_user_id = '{$userInfo['id']}' and oauth_id = '{$oauthId}' ", 'user_id');
     //没有绑定账号
     if (empty($oauthUserRow)) {
         $userObj = new IModel('user');
         $userCount = $userObj->getObj("username = '******'name']}'", 'count(*) as num');
         //没有重复的用户名
         if ($userCount['num'] == 0) {
             $username = $userInfo['name'];
         } else {
             //随即分配一个用户名
             $username = $userInfo['name'] . $userCount['num'];
         }
         ISafe::set('oauth_username', $username);
         ISession::set('oauth_id', $oauthId);
         ISession::set('oauth_userInfo', $userInfo);
         $this->redirect('bind_user');
     } else {
         $userObj = new IModel('user');
         $tempRow = $userObj->getObj("id = '{$oauthUserRow['user_id']}'");
         $userRow = CheckRights::isValidUser($tempRow['username'], $tempRow['password']);
         CheckRights::loginAfter($userRow);
         //自定义跳转页面
         $callback = ISafe::get('callback');
         if ($callback && !strpos($callback, 'reg') && !strpos($callback, 'login')) {
             $this->redirect($callback);
         } else {
             $this->redirect('/ucenter/index');
         }
     }
 }
コード例 #9
0
ファイル: ucenter.php プロジェクト: yongge666/sunupedu
 function password_edit()
 {
     $user_id = $this->user['user_id'];
     $fpassword = IReq::get('fpassword');
     $password = IReq::get('password');
     $repassword = IReq::get('repassword');
     $userObj = new IModel('user');
     $where = 'id = ' . $user_id;
     $userRow = $userObj->getObj($where);
     if (!preg_match('|\\w{6,32}|', $password)) {
         $message = '密码格式不正确,请重新输入';
     } else {
         if ($password != $repassword) {
             $message = '二次密码输入的不一致,请重新输入';
         } else {
             if (md5($fpassword) != $userRow['password']) {
                 $message = '原始密码输入错误';
             } else {
                 $passwordMd5 = md5($password);
                 $dataArray = array('password' => $passwordMd5);
                 $userObj->setData($dataArray);
                 $result = $userObj->update($where);
                 if ($result) {
                     ISafe::set('user_pwd', $passwordMd5);
                     $message = '密码修改成功';
                 } else {
                     $message = '密码修改失败';
                 }
             }
         }
     }
     $this->redirect('password', false);
     Util::showMessage($message);
 }
コード例 #10
0
ファイル: site.php プロジェクト: Wen1750686723/utao
 function products()
 {
     $date = array();
     //接收商品id
     if (IReq::get('id') === null) {
         IError::show(403, "传递的参数不正确");
     }
     $goods_id = IFilter::act(IReq::get('id'), 'int');
     //使用商品id获得商品信息
     $tb_goods = new IModel('goods');
     $goods_info = $tb_goods->query('id=' . $goods_id . " AND is_del=0");
     if (count($goods_info) > 0) {
         $date = $goods_info[0];
         $date['content1'] = $goods_info[0]['content'];
         //品牌名称
         $tb_brand = new IModel('brand');
         $brand_info = $tb_brand->query('id=' . $date['brand_id']);
         if (count($brand_info) > 0) {
             $date['brand'] = $brand_info[0]['name'];
         }
     } else {
         IError::show(403, "这件商品不存在");
     }
     //获取商品分类
     $categoryObj = new IModel('category_extend as ca,category as c');
     $categoryRow = $categoryObj->getObj('ca.goods_id = ' . $goods_id . ' and ca.category_id = c.id', 'c.id,c.name');
     $date['category'] = $categoryRow;
     //获得省份
     $tb_areas = new IQuery('areas');
     $tb_areas->where = 'parent_id=0';
     $areas_info = $tb_areas->find();
     $date['city'] = $areas_info;
     //获得规格
     $tb_goods_attribute = new IQuery('goods_attribute');
     $tb_goods_attribute->fields = ' spec_id ';
     $tb_goods_attribute->group = ' spec_id ';
     $tb_goods_attribute->where = " goods_id='" . $goods_id . "' and spec_id!='' ";
     $attribute_info = $tb_goods_attribute->find();
     if (count($attribute_info) > 0) {
         $spec_ids = array();
         $i = 0;
         $tb_attribute = new IQuery('goods_attribute');
         $ids = '';
         foreach ($attribute_info as $value) {
             $tb_attribute->fields = ' spec_value,spec_id ';
             $tb_attribute->where = ' goods_id=' . $date['id'] . ' and spec_id=' . $value['spec_id'];
             $tb_info = $tb_attribute->find();
             $spec_ids[$i]['value'] = $tb_info;
             //获得规格名
             $tb_spec = new IQuery('spec');
             $tb_spec->fields = 'name';
             $tb_spec->where = 'id=' . $value['spec_id'];
             $spec_info = $tb_spec->find();
             if (count($spec_info) > 0) {
                 $spec_ids[$i]['name'] = $spec_info[0]['name'];
             }
             $i++;
             $ids .= $value['spec_id'] . ',';
         }
         $date['spec_ids'] = $spec_ids;
         $date['ids'] = $ids;
     }
     //商品图片
     $tb_goods_photo = new IQuery('goods_photo_relation as g');
     $tb_goods_photo->fields = 'p.id AS photo_id,p.img ';
     $tb_goods_photo->join = 'left join goods_photo as p on p.id=g.photo_id ';
     $tb_goods_photo->where = ' g.goods_id=' . $goods_id;
     $photo_info = $tb_goods_photo->find();
     //清除已经不存在的图片
     foreach ($photo_info as $key => $value) {
         if (!isset($value['photo_id']) || !isset($value['img']) || $value['photo_id'] == null || $value['img'] == null) {
             unset($photo_info[$key]);
         }
         $absolute_img = IWeb::$app->getBasePath();
         $absolute_img = $absolute_img . "./" . $value['img'];
         if (!file_exists($absolute_img)) {
             unset($photo_info[$key]);
         }
     }
     if (count($photo_info) > 0) {
         //把默认图片调到第一个
         $goods_img = $goods_info[0]['img'];
         $tmp = array();
         foreach ($photo_info as $key => $value) {
             if ($value['img'] == $goods_img) {
                 $tmp[] = $value;
                 unset($photo_info[$key]);
             }
         }
         $tmp = array_merge($tmp, $photo_info);
         $photo_info = $tmp;
     }
     $date['photo'] = $photo_info;
     //商品是否参加活动 ---抢购
     $date['active'] = IReq::get('promo') ? IReq::get('promo') : '';
     if ($date['active']) {
         //商品参加活动 ---抢购
         $tb_promotion = new IQuery('promotion as p');
         $tb_promotion->fields = ' award_value,end_time,user_group ';
         $tb_promotion->where = 'type=1 and `condition`=' . $goods_id . ' and  NOW() between start_time and end_time';
         $promotion_info = $tb_promotion->find();
         if (count($promotion_info) > 0) {
             $date['promotion'] = $promotion_info[0];
         }
         //商品是否参加活动 ---团购
         $tb_regiment = new IQuery('regiment');
         $tb_regiment->fields = 'id,start_time,end_time,regiment_price,least_count,store_nums';
         $tb_regiment->where = 'goods_id = ' . $goods_id . ' and NOW() between start_time and end_time';
         $regiment_info = $tb_regiment->find();
         if (count($regiment_info) > 0) {
             $date['regiment'] = $regiment_info[0];
         }
     }
     //获得扩展属性
     $tb_attribute_goods = new IQuery('goods_attribute as g ');
     $tb_attribute_goods->join = 'left join attribute as a on a.id=g.attribute_id ';
     $tb_attribute_goods->fields = ' a.name,g.attribute_value ';
     $tb_attribute_goods->where = " goods_id='" . $goods_id . "' and attribute_id!=''";
     $attribute_goods_info = $tb_attribute_goods->find();
     $date['attribute'] = $attribute_goods_info;
     //用户最终购买
     $tb_good = new IQuery('order_goods as og ');
     $tb_good->fields = 'DISTINCT o.user_id';
     $tb_good->join = ' left join order as o on og.order_id=o.id ';
     $tb_good->where = 'og.goods_id=' . $goods_id;
     $good_info = $tb_good->find();
     $date['shop_goods'] = '';
     if (count($good_info) > 0) {
         foreach ($good_info as $value) {
             if (!isset($value['user_id'])) {
                 $date['shop_goods'] .= '0,';
             } else {
                 $date['shop_goods'] .= $value['user_id'] . ',';
             }
         }
         $date['shop_goods'] = substr($date['shop_goods'], 0, -1);
     } else {
         $date['shop_goods'] = '0';
     }
     //评论
     $tb_comment = new IQuery('comment');
     $tb_comment->fields = ' sum(point) as po ,count(id) as numbers ';
     $tb_comment->where = 'goods_id=' . $goods_id . ' and status=1';
     $comment_info = $tb_comment->find();
     $date['comment_point'] = 0;
     $date['comment_num'] = 0;
     if (count($comment_info) > 0) {
         $date['comment_point'] = $comment_info[0]['po'];
         $date['comment_num'] = $comment_info[0]['numbers'];
     }
     //购买记录
     $tb_shop = new IQuery('order_goods as og');
     $tb_shop->join = 'left join order as o on o.id=og.order_id';
     $tb_shop->fields = 'sum(goods_nums) as numb';
     $tb_shop->where = 'og.goods_id=' . $goods_id . ' and o.status = 5 and (to_days(now())-to_days(o.completion_time)) < 31';
     $shop_info = $tb_shop->find();
     $date['shop_num'] = 0;
     if (isset($shop_info[0]['numb']) > 0) {
         $date['shop_num'] = $shop_info[0]['numb'];
     }
     //购买前咨询
     $tb_refer = new IQuery('refer');
     $tb_refer->fields = 'count(id) as rid';
     $tb_refer->where = 'goods_id=' . $goods_id;
     $refeer_info = $tb_refer->find();
     $date['refer'] = 0;
     if (count($refeer_info) > 0) {
         $date['refer'] = $refeer_info[0]['rid'];
     }
     //网友讨论
     $tb_discussion = new IQuery('discussion');
     $tb_discussion->fields = 'count(id) as did';
     $tb_discussion->where = 'goods_id=' . $goods_id;
     $discussion_info = $tb_discussion->find();
     $date['discussion'] = 0;
     if (count($discussion_info) > 0) {
         $date['discussion'] = $discussion_info[0]['did'];
     }
     //获得登陆用户id
     $date['u_id'] = ISafe::get('user_id');
     //获得商品的最大值和最小值
     $tb_product = new IQuery('products');
     $tb_product->fields = 'max(sell_price) as ma ,min(sell_price) as mi,max(market_price) as mpa,min(market_price) as mpi';
     $tb_product->where = 'goods_id=' . $goods_id;
     $product_info = $tb_product->find();
     $date['ma'] = '';
     $date['mi'] = '';
     $date['mpa'] = '';
     $date['mpi'] = '';
     if (count($product_info) > 0) {
         $date['ma'] = $product_info[0]['ma'];
         $date['mi'] = $product_info[0]['mi'];
         $date['mpa'] = $product_info[0]['mpa'];
         $date['mpi'] = $product_info[0]['mpi'];
     }
     //url
     $date['url'] = IUrl::creatUrl();
     //获得会员价
     if ($date['u_id']) {
         $tb_group_price = new IQuery('group_price as g');
         $tb_group_price->join = 'left join member as m on m.group_id=g.group_id';
         $tb_group_price->fields = 'g.price';
         $tb_group_price->where = 'g.goods_id=' . $goods_id . ' and g.products_id=0 and m.user_id=' . $date['u_id'];
         $group_price_info = $tb_group_price->find();
         $date['group_price'] = 0;
         if (count($group_price_info) > 0) {
             $date['group_price'] = $group_price_info[0]['price'];
         } else {
             //如果没有添加会员价格,则查看是否有折扣率
             $u_query = new IQuery('user_group as u');
             $u_query->join = 'left join member as m on m.group_id=u.id ';
             $u_query->where = 'm.user_id=' . $date['u_id'];
             $user_info = $u_query->find();
             if (count($user_info) > 0) {
                 $date['group_price'] = $date['sell_price'] * ($user_info[0]['discount'] / 100);
             }
         }
     }
     //增加浏览次数
     if (!ISafe::get('visit' . $goods_id)) {
         $tb_goods->setData(array('visit' => 'visit + 1'));
         $tb_goods->update('id = ' . $goods_id, 'visit');
         ISafe::set('visit' . $goods_id, '1');
     }
     $this->setRenderData($date);
     $this->redirect('products');
 }
コード例 #11
0
ファイル: frontend.php プロジェクト: Wen1750686723/utao
 /**
  *	列表展示
  *	@author keenhome@126.com
  *	@date 2013-4-30
  */
 public function buy()
 {
     $gid = IFilter::act(IReq::get('gid'), 'int');
     $tb_goods = new IModel('goods');
     //增加点击次数
     if (!ISafe::get('visit' . $gid)) {
         $tb_goods->setData(array('click' => 'click + 1'));
         $tb_goods->update('id = ' . $gid, 'click');
         ISafe::set('click' . $gid, '1');
     }
     $goodsRow = $tb_goods->getObj('ID = ' . $gid, 'url');
     if (count($goodsRow) > 0 && $goodsRow['url']) {
         header("Location:" . $goodsRow['url']);
     } else {
         header("Location:/");
     }
 }
コード例 #12
0
ファイル: checkrights.php プロジェクト: xzdesk/iwebshop.com
 /**
  * @brief 登录后的处理
  * @param array $userRow 用户数组信息
  */
 public static function loginAfter($userRow)
 {
     //用户私密数据
     ISafe::set('user_id', $userRow['id']);
     ISafe::set('username', $userRow['username']);
     ISafe::set('head_ico', $userRow['head_ico']);
     ISafe::set('user_pwd', $userRow['password']);
     ISafe::set('last_login', isset($userRow['last_login']) ? $userRow['last_login'] : '');
     //更新最后一次登录时间
     $memberObj = new IModel('member');
     $dataArray = array('last_login' => ITime::getDateTime());
     $memberObj->setData($dataArray);
     $where = 'user_id = ' . $userRow["id"];
     $memberObj->update($where);
     $memberRow = $memberObj->getObj($where, 'exp');
     //根据经验值分会员组
     $groupObj = new IModel('user_group');
     $groupRow = $groupObj->getObj($memberRow['exp'] . ' between minexp and maxexp and minexp > 0 and maxexp > 0', 'id', 'discount', 'desc');
     if (!empty($groupRow)) {
         $dataArray = array('group_id' => $groupRow['id']);
         $memberObj->setData($dataArray);
         $memberObj->update('user_id = ' . $userRow["id"]);
     }
 }
コード例 #13
0
ファイル: system.php プロジェクト: yongge666/sunupedu
 /**
  *修改管理员密码
  */
 function admin_repwd_act()
 {
     //提取密码 [ 密码设置 ]
     $password = IReq::get('password', 'post');
     $repassword = IReq::get('repassword', 'post');
     if ($password && $password === $repassword) {
         $passwordMd5 = md5($password);
         $adminObj = new IModel('admin');
         $adminObj->setData(array('password' => $passwordMd5));
         $adminObj->update('id = ' . $this->admin['admin_id']);
         //同步更新safe
         ISafe::set('admin_pwd', $passwordMd5);
         $this->redirect('default');
     } else {
         $message = '密码不能为空,并且二次输入的必须一致';
         $this->redirect('admin_repwd', false);
         Util::showMessage($message);
     }
 }
コード例 #14
0
ファイル: simple.php プロジェクト: Wen1750686723/utao
 public function bindUser($userInfo, $oauthId)
 {
     $oauthUserObj = new IModel('oauth_user');
     $oauthUserRow = $oauthUserObj->getObj("oauth_user_id = '{$userInfo['id']}' and oauth_id = '{$oauthId}' ", 'user_id');
     //没有绑定账号
     if (empty($oauthUserRow)) {
         $userObj = new IModel('user');
         $userCount = $userObj->getObj("username = '******'name']}'", 'count(*) as num');
         //没有重复的用户名
         if ($userCount['num'] == 0) {
             $username = $userInfo['name'];
         } else {
             //随即分配一个用户名
             $username = $userInfo['name'] . $userCount['num'];
         }
         ISafe::set('oauth_username', $username);
         ISession::set('oauth_id', $oauthId);
         ISession::set('oauth_userInfo', $userInfo);
         $this->redirect('bind_user');
     } else {
         $userObj = new IModel('user');
         $userRow = $userObj->getObj("id = '{$oauthUserRow['user_id']}'");
         $this->loginAfter($userRow);
         //自定义跳转页面
         $callback = ISafe::get('callback');
         if ($callback != null && $callback != '' && $callback != "/simple/reg" && $callback != "/simple/login") {
             $this->redirect($callback);
         } else {
             $this->redirect('/ucenter/index');
         }
     }
 }
コード例 #15
0
ファイル: system.php プロジェクト: Wen1750686723/utao
 function admin_edit_act()
 {
     $id = IFilter::act(IReq::get('id', 'post'));
     $adminObj = new IModel('admin');
     //错误信息
     $message = null;
     $dataArray = array('id' => $id, 'admin_name' => IFilter::string(IReq::get('admin_name', 'post')), 'role_id' => IFilter::act(IReq::get('role_id', 'post')), 'email' => IFilter::string(IReq::get('email', 'post')));
     //检查管理员name唯一性
     $isPass = $this->check_admin($dataArray['admin_name'], $id);
     if ($isPass == false) {
         $message = $dataArray['admin_name'] . '管理员已经存在,请更改名字';
     }
     //提取密码 [ 密码设置 ]
     $password = IReq::get('password', 'post');
     $repassword = IReq::get('repassword', 'post');
     //修改操作
     if ($id) {
         if ($password != null || $repassword != null) {
             if ($password == null || $repassword == null || $password != $repassword) {
                 $message = '密码不能为空,并且二次输入的必须一致';
             } else {
                 $dataArray['password'] = md5($password);
             }
         }
         //有错误
         if ($message != null) {
             $this->adminRow = $dataArray;
             $this->redirect('admin_edit', false);
             Util::showMessage($message);
         } else {
             $where = 'id = ' . $id;
             $adminObj->setData($dataArray);
             $adminObj->update($where);
             //同步更新safe
             ISafe::set('admin_name', $dataArray['admin_name']);
             ISafe::set('admin_pwd', $dataArray['password']);
         }
     } else {
         if ($password == null || $repassword == null || $password != $repassword) {
             $message = '密码不能为空,并且二次输入的必须一致';
         } else {
             $dataArray['password'] = md5($password);
         }
         if ($message != null) {
             $this->adminRow = $dataArray;
             $this->redirect('admin_edit', false);
             Util::showMessage($message);
         } else {
             $dataArray['create_time'] = ITime::getDateTime();
             $adminObj->setData($dataArray);
             $adminObj->add();
         }
     }
     $this->redirect('admin_list');
 }
コード例 #16
0
ファイル: site.php プロジェクト: xzdesk/iwebshop.com
 function products()
 {
     $goods_id = IFilter::act(IReq::get('id'), 'int');
     if (!$goods_id) {
         IError::show(403, "传递的参数不正确");
         exit;
     }
     //使用商品id获得商品信息
     $tb_goods = new IModel('goods');
     $goods_info = $tb_goods->getObj('id=' . $goods_id . " AND is_del=0");
     if (!$goods_info) {
         IError::show(403, "这件商品不存在");
         exit;
     }
     //品牌名称
     if ($goods_info['brand_id']) {
         $tb_brand = new IModel('brand');
         $brand_info = $tb_brand->getObj('id=' . $goods_info['brand_id']);
         if ($brand_info) {
             $goods_info['brand'] = $brand_info['name'];
         }
     }
     //获取商品分类
     $categoryObj = new IModel('category_extend as ca,category as c');
     $categoryRow = $categoryObj->getObj('ca.goods_id = ' . $goods_id . ' and ca.category_id = c.id', 'c.id,c.name');
     $goods_info['category'] = $categoryRow ? $categoryRow['id'] : 0;
     //商品图片
     $tb_goods_photo = new IQuery('goods_photo_relation as g');
     $tb_goods_photo->fields = 'p.id AS photo_id,p.img ';
     $tb_goods_photo->join = 'left join goods_photo as p on p.id=g.photo_id ';
     $tb_goods_photo->where = ' g.goods_id=' . $goods_id;
     $goods_info['photo'] = $tb_goods_photo->find();
     foreach ($goods_info['photo'] as $key => $val) {
         //对默认第一张图片位置进行前置
         if ($val['img'] == $goods_info['img']) {
             $temp = $goods_info['photo'][0];
             $goods_info['photo'][0] = $val;
             $goods_info['photo'][$key] = $temp;
         }
     }
     //商品是否参加促销活动(团购,抢购)
     $goods_info['promo'] = IReq::get('promo') ? IReq::get('promo') : '';
     $goods_info['active_id'] = IReq::get('active_id') ? IFilter::act(IReq::get('active_id'), 'int') : '';
     if ($goods_info['promo']) {
         switch ($goods_info['promo']) {
             //团购
             case 'groupon':
                 $goods_info['regiment'] = Api::run("getRegimentRowById", array("#id#", $goods_info['active_id']));
                 if (isset($goods_info['regiment']['goods_id']) && $goods_info['regiment']['goods_id'] != $goods_id) {
                     IError::show(403, "该商品未参与活动");
                 }
                 break;
                 //抢购
             //抢购
             case 'time':
                 $goods_info['promotion'] = Api::run("getPromotionRowById", array("#id#", $goods_info['active_id']));
                 if (isset($goods_info['regiment']['goods_id']) && $goods_info['promotion']['condition'] != $goods_id) {
                     IError::show(403, "该商品未参与活动");
                 }
                 break;
             default:
                 IError::show(403, "活动不存在或者已经过期");
                 exit;
         }
     }
     //获得扩展属性
     $tb_attribute_goods = new IQuery('goods_attribute as g');
     $tb_attribute_goods->join = 'left join attribute as a on a.id=g.attribute_id ';
     $tb_attribute_goods->fields = ' a.name,g.attribute_value ';
     $tb_attribute_goods->where = "goods_id='" . $goods_id . "' and attribute_id!=''";
     $tb_attribute_goods->order = "g.id asc";
     $goods_info['attribute'] = $tb_attribute_goods->find();
     //[数据挖掘]最终购买此商品的用户ID列表
     $tb_good = new IQuery('order_goods as og');
     $tb_good->join = 'left join order as o on og.order_id=o.id ';
     $tb_good->fields = 'DISTINCT o.user_id';
     $tb_good->where = 'og.goods_id = ' . $goods_id;
     $tb_good->limit = 5;
     $bugGoodInfo = $tb_good->find();
     if ($bugGoodInfo) {
         $shop_goods_array = array();
         foreach ($bugGoodInfo as $key => $val) {
             $shop_goods_array[] = $val['user_id'];
         }
         $goods_info['buyer_id'] = join(',', $shop_goods_array);
     }
     //购买记录
     $tb_shop = new IQuery('order_goods as og');
     $tb_shop->join = 'left join order as o on o.id=og.order_id';
     $tb_shop->fields = 'count(*) as totalNum';
     $tb_shop->where = 'og.goods_id=' . $goods_id . ' and o.status = 5';
     $shop_info = $tb_shop->find();
     $goods_info['buy_num'] = 0;
     if ($shop_info) {
         $goods_info['buy_num'] = $shop_info[0]['totalNum'];
     }
     //购买前咨询
     $tb_refer = new IModel('refer');
     $refeer_info = $tb_refer->getObj('goods_id=' . $goods_id, 'count(*) as totalNum');
     $goods_info['refer'] = 0;
     if ($refeer_info) {
         $goods_info['refer'] = $refeer_info['totalNum'];
     }
     //网友讨论
     $tb_discussion = new IModel('discussion');
     $discussion_info = $tb_discussion->getObj('goods_id=' . $goods_id, 'count(*) as totalNum');
     $goods_info['discussion'] = 0;
     if ($discussion_info) {
         $goods_info['discussion'] = $discussion_info['totalNum'];
     }
     //获得商品的价格区间
     $tb_product = new IModel('products');
     $product_info = $tb_product->getObj('goods_id=' . $goods_id, 'max(sell_price) as maxSellPrice ,min(sell_price) as minSellPrice,max(market_price) as maxMarketPrice,min(market_price) as minMarketPrice');
     $goods_info['maxSellPrice'] = '';
     $goods_info['minSellPrice'] = '';
     $goods_info['minMarketPrice'] = '';
     $goods_info['maxMarketPrice'] = '';
     if ($product_info) {
         $goods_info['maxSellPrice'] = $product_info['maxSellPrice'];
         $goods_info['minSellPrice'] = $product_info['minSellPrice'];
         $goods_info['minMarketPrice'] = $product_info['minMarketPrice'];
         $goods_info['maxMarketPrice'] = $product_info['maxMarketPrice'];
     }
     //获得会员价
     $countsumInstance = new countsum();
     $goods_info['group_price'] = $countsumInstance->getGroupPrice($goods_id, 'goods');
     //获取商家信息
     if ($goods_info['seller_id']) {
         $sellerDB = new IModel('seller');
         $goods_info['seller'] = $sellerDB->getObj('id = ' . $goods_info['seller_id']);
     }
     //增加浏览次数
     $visit = ISafe::get('visit');
     $checkStr = "#" . $goods_id . "#";
     if ($visit && strpos($visit, $checkStr) !== false) {
     } else {
         $tb_goods->setData(array('visit' => 'visit + 1'));
         $tb_goods->update('id = ' . $goods_id, 'visit');
         $visit = $visit === null ? $checkStr : $visit . $checkStr;
         ISafe::set('visit', $visit);
     }
     $this->setRenderData($goods_info);
     $this->redirect('products');
 }
コード例 #17
0
ファイル: system.php プロジェクト: chenyongze/iwebshop
 public function upgrade_4()
 {
     $version = IReq::get('version');
     if ($version == null) {
         die;
     }
     $current_version = (include IWeb::$app->getBasePath() . "docs/version.php");
     if ($current_version == $version) {
         $this->redirect('/system/upgrade_1');
     }
     $upgrade = new IWebUpgrade('shop', $version);
     $re = $upgrade->download($current_version);
     echo $re ? "success" : "";
     ISafe::set("upgrade_version", $version);
     ISafe::set("upgrade_zip_path", $re);
     exit;
 }
コード例 #18
0
ファイル: block.php プロジェクト: chenyongze/iwebshop
 function add_download_ticket()
 {
     $isError = true;
     $ticket_num = IFilter::act(IReq::get('ticket_num'));
     $ticket_pwd = IFilter::act(IReq::get('ticket_pwd'));
     $propObj = new IModel('prop');
     $propRow = $propObj->getObj('card_name = "' . $ticket_num . '" and card_pwd = "' . $ticket_pwd . '" and type = 0 and is_userd = 0 and is_send = 1 and is_close = 0 and NOW() between start_time and end_time');
     if (empty($propRow)) {
         $message = '代金券不可用,请确认代金券的卡号密码并且此代金券从未被使用过';
     } else {
         //登录用户
         if ($this->user['user_id']) {
             $memberObj = new IModel('member');
             $memberRow = $memberObj->getObj('user_id = ' . $this->user['user_id'], 'prop');
             if (stripos($memberRow['prop'], ',' . $propRow['id'] . ',') !== false) {
                 $message = '代金券已经存在,不能重复添加';
             } else {
                 $isError = false;
                 $message = '添加成功';
                 if ($memberRow['prop'] == '') {
                     $propUpdate = ',' . $propRow['id'] . ',';
                 } else {
                     $propUpdate = $memberRow['prop'] . $propRow['id'] . ',';
                 }
                 $dataArray = array('prop' => $propUpdate);
                 $memberObj->setData($dataArray);
                 $memberObj->update('user_id = ' . $this->user['user_id']);
             }
         } else {
             $isError = false;
             $message = '添加成功';
             ISafe::set("ticket_" . $propRow['id'], $propRow['id']);
         }
     }
     $result = array('isError' => $isError, 'data' => $propRow, 'message' => $message);
     echo JSON::encode($result);
 }
コード例 #19
0
 /**
  * @brief 生成验证码
  * @return image图像
  */
 public function getCaptcha()
 {
     //清空布局
     $this->layout = '';
     //配置参数
     $width = intval(IReq::get('w')) == 0 ? 130 : IReq::get('w');
     $height = intval(IReq::get('h')) == 0 ? 45 : IReq::get('h');
     $wordLength = intval(IReq::get('l')) == 0 ? 5 : IReq::get('l');
     $fontSize = intval(IReq::get('s')) == 0 ? 25 : IReq::get('s');
     //创建验证码
     $ValidateObj = new Captcha();
     $ValidateObj->width = $width;
     $ValidateObj->height = $height;
     $ValidateObj->maxWordLength = $wordLength;
     $ValidateObj->minWordLength = $wordLength;
     $ValidateObj->fontSize = $fontSize;
     $ValidateObj->CreateImage($text);
     //设置验证码
     ISafe::set('Captcha', $text);
 }