Example #1
0
 function regester($email, $tname, $password, $phone, $group, $userlogo = '', $address = '', $cost = 0, $score = 0)
 {
     if (empty($email) && empty($phone)) {
         $this->error = '邮箱和手机不能同时为空';
         return false;
     }
     if (!empty($email)) {
         if (!IValidate::email($email)) {
             $this->error = '邮箱格式错误';
             return false;
         }
         $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where email='" . $email . "' ");
         if (!empty($userinfo)) {
             $this->error = '邮箱已存在,不可注册';
             return false;
         }
     }
     if (!empty($phone)) {
         if (!IValidate::suremobi($phone)) {
             $this->error = '手机格式错误';
             return false;
         }
         $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where phone='" . $phone . "' ");
         if (!empty($userinfo)) {
             $this->error = '手机已存在,不可注册';
             return false;
         }
     }
     if (!IValidate::len($tname, 3, 20)) {
         //$this->error = '用户名长度大于3小于20'.$tname;
         //return false;
     }
     if (!IValidate::len($password, 6, 20)) {
         $this->error = '密码长度大于6小于20';
         return false;
     }
     $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where username='******' ");
     if (!empty($userinfo)) {
         //$this->error = '用户名已存在,不可注册';
         //return false;
     }
     $arr['username'] = $tname;
     $arr['phone'] = $phone;
     $arr['address'] = $address;
     $arr['password'] = md5($password);
     $arr['email'] = $email;
     $arr['creattime'] = time();
     $arr['score'] = $score == 0 ? Mysite::$app->config['regesterscore'] : $score;
     $arr['logintime'] = time();
     $arr['logo'] = $userlogo;
     $arr['loginip'] = IClient::getIp();
     $arr['group'] = $group;
     $arr['cost'] = $cost;
     $arr['parent_id'] = intval(ICookie::get('logincode'));
     $this->mysql->insert(Mysite::$app->config['tablepre'] . 'member', $arr);
     $this->uid = $this->mysql->insertid();
     if ($arr['score'] > 0) {
         $this->addlog($this->uid, 1, 1, $arr['score'], '注册送积分', '注册送积分' . $arr['score'], $arr['score']);
     }
     $logintype = ICookie::get('adlogintype');
     $token = ICookie::get('adtoken');
     $openid = ICookie::get('adopenid');
     if (!empty($logintype)) {
         $apiinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "otherlogin where loginname='" . $logintype . "'  ");
         if (!empty($apiinfo)) {
             //更新
             $tempuid = $this->uid;
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'oauth', array('uid' => $tempuid), "openid='" . $openid . "' and type = '" . $logintype . "'");
             ICookie::set('logintype', $logintype, 86400);
         }
     }
     if (Mysite::$app->config['regester_juan'] == 1) {
         //注册送优惠券
         $nowtime = time();
         $endtime = $nowtime + Mysite::$app->config['regester_juanday'] * 24 * 60 * 60;
         $juandata['card'] = $nowtime . rand(100, 999);
         $juandata['card_password'] = substr(md5($juandata['card']), 0, 5);
         $juandata['status'] = 1;
         // 状态,0未使用,1已绑定,2已使用,3无效
         $juandata['creattime'] = $nowtime;
         // 制造时间
         $juandata['cost'] = Mysite::$app->config['regester_juancost'];
         // 优惠金额
         $juandata['limitcost'] = Mysite::$app->config['regester_juanlimit'];
         // 购物车限制金额下限
         $juandata['endtime'] = $endtime;
         // 失效时间
         $juandata['uid'] = $this->uid;
         // 用户ID
         $juandata['username'] = $arr['username'];
         // 用户名
         $juandata['name'] = '注册账号赠送优惠券';
         //  优惠券名称
         $this->mysql->insert(Mysite::$app->config['tablepre'] . 'juan', $juandata);
     }
     return true;
 }
Example #2
0
 function editaddress()
 {
     $this->checkmemberlogin();
     $what = trim(IFilter::act(IReq::get('what')));
     $addressid = intval(IReq::get('addressid'));
     if (empty($addressid)) {
         $this->message('编辑地址获取失败');
     }
     if ($what == 'default') {
         $arr['default'] = 0;
         $this->mysql->update(Mysite::$app->config['tablepre'] . 'address', $arr, "userid='" . $this->member['uid'] . "'");
         $arr['default'] = 1;
         $this->mysql->update(Mysite::$app->config['tablepre'] . 'address', $arr, "id='" . $addressid . "' and userid='" . $this->member['uid'] . "' ");
         $this->success('操作成功');
     } elseif ($what == 'addr') {
         $arr['address'] = IFilter::act(IReq::get('controlname'));
         if (!IValidate::len($arr['address'], 5, 50)) {
             $this->message('录入地址长度不能少于5个');
         }
         $this->mysql->update(Mysite::$app->config['tablepre'] . 'address', $arr, "id='" . $addressid . "' and userid='" . $this->member['uid'] . "' ");
         $this->success('操作成功');
     } elseif ($what == 'phone') {
         $arr['phone'] = IFilter::act(IReq::get('controlname'));
         if (!IValidate::phone($arr['phone'])) {
             $this->message('录入的联系电话不是手机或者座机正确');
         }
         $this->mysql->update(Mysite::$app->config['tablepre'] . 'address', $arr, "id='" . $addressid . "' and userid='" . $this->member['uid'] . "' ");
         $this->success('操作成功');
     } elseif ($what == 'bak_phone') {
         $arr['otherphone'] = IFilter::act(IReq::get('controlname'));
         if (!IValidate::phone($arr['otherphone'])) {
             $this->message('录入的备用电话不是手机或者座机正确');
         }
         $this->mysql->update(Mysite::$app->config['tablepre'] . 'address', $arr, "id='" . $addressid . "' and userid='" . $this->member['uid'] . "' ");
         $this->success('操作成功');
     } elseif ($what == 'recieve_name') {
         $arr['contactname'] = IFilter::act(IReq::get('controlname'));
         if (!IValidate::len($arr['contactname'], 2, 6)) {
             $this->message('联系人名长度不能小于2个大于6个');
         }
         $this->mysql->update(Mysite::$app->config['tablepre'] . 'address', $arr, "id='" . $addressid . "' and userid='" . $this->member['uid'] . "' ");
         $this->success('操作成功');
     } else {
         $this->message('未定义的操作');
     }
 }
Example #3
0
 function saveopen()
 {
     if (empty($this->member['uid'])) {
         $link = IUrl::creatUrl('member/index');
         $this->message('想开店请先注册为普通会员', $link);
     }
     $maphone = IFilter::act(IReq::get('maphone'));
     $shopname = IFilter::act(IReq::get('shopname'));
     $address = IFilter::act(IReq::get('address'));
     $shoptype = IFilter::act(IReq::get('shoptype'));
     if (!IValidate::phone($maphone)) {
         $this->message('联系电话格式错误');
     }
     if (!IValidate::len($shopname, 3, 30)) {
         $this->message('店铺名长度大于3小于30');
     }
     if (!IValidate::len($address, 6, 50)) {
         $this->message('店铺地址长度大于6小于50');
     }
     $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop where uid='" . $this->member['uid'] . "' ");
     if (!empty($userinfo)) {
         $this->message('您已绑定店铺不可操作');
     }
     $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop where maphone='" . $maphone . "' ");
     if (!empty($userinfo)) {
         $this->message('联系人电话已存在');
     }
     $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "shop where shopname='" . $shopname . "' ");
     if (!empty($userinfo)) {
         $this->message('店铺名称已重复');
     }
     $arr['shopname'] = $shopname;
     $arr['maphone'] = $maphone;
     $arr['uid'] = $this->member['uid'];
     $arr['address'] = $address;
     $arr['addtime'] = time();
     $arr['is_open'] = '0';
     $arr['shoptype'] = $shoptype;
     $nowday = 24 * 60 * 60 * 365;
     $data['endtime'] = time() + $nowday;
     $this->mysql->insert(Mysite::$app->config['tablepre'] . 'shop', $arr);
     $this->success('操作成功');
 }
Example #4
0
 function saveuser()
 {
     //$this->checkmemberlogin();
     $controlname = IFilter::act(IReq::get('controlname'));
     switch ($controlname) {
         case 'username':
             $arra['username'] = trim(IFilter::act(IReq::get('obj')));
             if (!IValidate::len($arra['username'], 2, 20)) {
                 $this->message('联系人名长度不能小于2个大于20个');
             }
             $checkinfo = $this->mysql->counts("select * from " . Mysite::$app->config['tablepre'] . "member where username='******'username'] . "'");
             if ($checkinfo > 0) {
                 $this->message('用户名已存在修改失败');
             }
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', $arra, 'uid = ' . $this->member['uid'] . ' ');
             $this->success('操作成功');
             break;
         case 'email':
             $arra['email'] = trim(IFilter::act(IReq::get('obj')));
             if (!empty($this->member['email'])) {
                 $this->message('邮箱已录入不可修改');
             }
             if (!IValidate::email($arra['email'])) {
                 $this->message('请录入正确的邮箱格式');
             }
             $checkinfo = $this->mysql->counts("select * from " . Mysite::$app->config['tablepre'] . "member where email='" . $arra['email'] . "'");
             if ($checkinfo > 0) {
                 $this->message('邮箱已存在修改失败');
             }
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', $arra, 'uid = ' . $this->member['uid'] . ' ');
             $this->success('操作成功');
             break;
         case 'mobile':
             $arra['phone'] = trim(IFilter::act(IReq::get('obj')));
             if (!empty($this->member['phone'])) {
                 $this->message('手机号已录入不可修改');
             }
             if (!IValidate::suremobi($arra['phone'])) {
                 $this->message('请录入正确的手机号码');
             }
             $checkinfo = $this->mysql->counts("select * from " . Mysite::$app->config['tablepre'] . "member where phone='" . $arra['phone'] . "'");
             if ($checkinfo > 0) {
                 $this->message('手机号已存在修改失败');
             }
             $checkinfo = $this->mysql->counts("select * from " . Mysite::$app->config['tablepre'] . "member where phone='" . $arra['phone'] . "'");
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', $arra, 'uid = ' . $this->member['uid'] . ' ');
             $this->success('操作成功');
             break;
         case 'pwd':
             $pwd = IFilter::act(IReq::get('pwd'));
             $newpwd = IFilter::act(IReq::get('newpwd'));
             $newpwd2 = IFilter::act(IReq::get('newpwd2'));
             if (empty($pwd)) {
                 $this->message('原始密码不能为空');
             }
             $checkpass = md5($pwd);
             if ($checkpass != $this->member['password']) {
                 $this->message('原密码和帐号密码不一致');
             }
             if (empty($newpwd)) {
                 $this->message('新密码不能为空');
             }
             if ($newpwd != $newpwd2) {
                 $this->message('新密码和确认密码不一致');
             }
             $arr['password'] = md5($newpwd);
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', $arr, "uid='" . $this->member['uid'] . "'");
             $this->memberCls->loginout();
             $this->success('操作成功');
             break;
         case 'repwd':
             $phone = IFilter::act(IReq::get('phone'));
             $shoid = IFilter::act(IReq::get('shopid'));
             $phone = IFilter::act(IReq::get('phone'));
             $newpwd = IFilter::act(IReq::get('newpwd'));
             $newpwd2 = IFilter::act(IReq::get('newpwd2'));
             $code = IFilter::act(IReq::get('code'));
             $regphonecode = ICookie::get('regphonecode');
             if (empty($phone)) {
                 $this->message("手机号不能为空");
             }
             if (empty($code)) {
                 $this->message('验证码不能为空');
             }
             if (empty($newpwd)) {
                 $this->message('新密码不能为空');
             }
             if ($newpwd != $newpwd2) {
                 $this->message('新密码和确认密码不一致');
             }
             if ($code != $regphonecode) {
                 $this->message('验证码错误');
             }
             $arr['password'] = md5($newpwd);
             if (!IValidate::suremobi($phone)) {
                 $this->message('联系手机格式错误');
             }
             $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', $arr, "phone='" . $phone . "'");
             $link = IUrl::creatUrl('wxsite/login');
             $this->success('操作成功', $link);
         default:
             $this->message('未定义的操作');
             break;
     }
 }