示例#1
0
文件: hsms.php 项目: herrify/iwebshop
 /**
  * @brief 发送短信
  * @param string $mobile 手机号
  * @param string $content 短信内容
  * @param int $delay 延迟设置
  * @return success or fail
  */
 public static function send($mobile, $content, $delay = 1)
 {
     if (self::$smsInstance == null) {
         $platform = self::getPlatForm();
         switch ($platform) {
             case "zhutong":
                 $classFile = IWeb::$app->getBasePath() . 'plugins/hsms/zhutong.php';
                 require $classFile;
                 self::$smsInstance = new zhutong();
                 break;
             default:
                 $classFile = IWeb::$app->getBasePath() . 'plugins/hsms/haiyan.php';
                 require $classFile;
                 self::$smsInstance = new haiyan();
         }
     }
     if (IValidate::mobi($mobile) && $content) {
         $ip = IClient::getIp();
         if ($ip) {
             if ($delay == 1) {
                 $mobileKey = md5($ip);
                 $sendTime = ISession::get($mobileKey);
                 if ($sendTime && time() - $sendTime < 60) {
                     return false;
                 }
                 ISession::set($mobileKey, time());
             }
             return self::$smsInstance->send($mobile, $content);
         }
     }
     return false;
 }
示例#2
0
 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);
     }
 }
示例#3
0
 function adminlogin()
 {
     $signup_name = IFilter::act(IReq::get('signup_name'));
     $signup_password = IFilter::act(IReq::get('signup_password'));
     if (!empty($signup_name)) {
         $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "admin where username ='******'");
         if (empty($signup_password)) {
             $this->message('signup_password_tip');
         }
         if ($userinfo['password'] != md5($signup_password)) {
             $this->message('signup_password_tip');
         }
         $data['loginip'] = IClient::getIp();
         $data['logintime'] = time();
         $this->mysql->update(Mysite::$app->config['tablepre'] . 'admin', $data, "uid='" . $userinfo['uid'] . "'");
         ICookie::set('adminname', $userinfo['username'], 86400);
         ICookie::set('adminpwd', $signup_password, 86400);
         ICookie::set('adminuid', $userinfo['uid'], 86400);
         $this->success('操作成功');
     }
 }
示例#4
0
 function Iptoposition($coor = 'bd09ll')
 {
     //样式   若需要返回百度墨卡托坐标  则初始化值时候  new baidumap(''); new baidumap() 则返回百度百度经纬度坐标
     $this->shorturl = '/location/ip';
     $this->intparam();
     //初始化参数
     $this->param['ip'] = IClient::getIp();
     // $this->caculateAKSN();//获取SN 不要签名
     ksort($this->param);
     $this->param['coor'] = $coor;
     //设置返坐标
     $info = $this->dolink();
     if (isset($info['status'])) {
         if ($info['status'] == 0) {
             return $info['content']['address_detail']['city'];
         } else {
             return '';
         }
     } else {
         return '';
     }
 }
示例#5
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;
 }
示例#6
0
     } else {
         ICookie::set('adlogintype', $logintype, 86400);
         ICookie::set('adtoken', $acs, 86400);
         ICookie::set('adopenid', $opid, 86400);
         ICookie::set('nickname', $opid, 86400);
     }
 } else {
     if ($uid > 0) {
         $link = IUrl::creatUrl('member/base');
         /*跳转到用户中心*/
     } else {
         $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where  uid  = '" . $oauthinfo['uid'] . "'");
         if (empty($userinfo)) {
             $this->message('账号未查找到,关联账号是否被删除');
         }
         $data['loginip'] = IClient::getIp();
         $data['logintime'] = time();
         $checktime = date('Y-m-d', time());
         $checktime = strtotime($checktime);
         if ($userinfo['logintime'] < $checktime) {
             if (Mysite::$app->config['loginscore'] > 0) {
                 $data['score'] = $userinfo['score'] + Mysite::$app->config['loginscore'];
                 $mess['content'] = '用户登陆赠送积分' . Mysite::$app->config['loginscore'] . '总积分' . $data['score'];
                 $this->memberCls->addlog($userinfo['uid'], 1, 1, Mysite::$app->config['loginscore'], '每天登陆', $mess['content'], $data['score']);
                 // $this->mysql->insert(Mysite::$app->config['tablepre']."message",$mess);
             }
         }
         $this->mysql->update(Mysite::$app->config['tablepre'] . 'member', $data, "uid='" . $userinfo['uid'] . "'");
         ICookie::set('logintype', $logintype, 86400);
         ICookie::set('uid', $userinfo['uid'], 86400);
         $link = IUrl::creatUrl('member/base');
示例#7
0
 function regesterTem($email = "", $mobile, $group = "5", $userlogo = '', $addressdet, $cost = 0, $score = 0)
 {
     if (!empty($mobile)) {
         $userinfo = $this->mysql->select_one("select * from " . Mysite::$app->config['tablepre'] . "member where phone='" . $mobile . "' ");
         if (!empty($userinfo)) {
             return false;
         }
     }
     $password = '******' . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9) . rand(0, 9);
     $arr['username'] = $mobile;
     $arr['phone'] = $mobile;
     $arr['address'] = $addressdet;
     $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, 31536000);
         }
     }
     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'] = '注册账号赠送优惠券';
         //  优惠券名称
         $res = $this->mysql->insert(Mysite::$app->config['tablepre'] . 'juan', $juandata);
     }
     ICookie::set('memberpwd', $password, 86400 * 365);
     ICookie::set('membername', $mobile, 86400 * 365);
     ICookie::set('uid', $this->uid, 86400 * 365);
     return true;
 }