Ejemplo n.º 1
0
 /**
  * 生成JSSDK签名
  * @retrun array $data JSSDK签名所需参数
  */
 public function JSSDKSignature()
 {
     $string = new String();
     $jsapi_ticket = M('token')->where(['type' => 'js_ticket'])->getField('token');
     $data['jsapi_ticket'] = $jsapi_ticket;
     $data['noncestr'] = $string->randString();
     $data['timestamp'] = time();
     $data['url'] = 'http://' . $_SERVER['HTTP_HOST'] . __SELF__;
     //生成当前页面url
     $data['signature'] = sha1($this->ToUrlParams($data));
     return $data;
 }
Ejemplo n.º 2
0
 public function sendSMS($tel)
 {
     //>>1. 随机生成一个数字
     $randomNumber = String::randString(6, 1);
     session('SMS_CODE', $randomNumber);
     //为了和用户输入的短信验证码进行验证码
     //>>2.将该数字发送到$tel手机号D:\thinkphp\ThinkPHP\Library\Vendor\SMS
     vendor('SMS.TopSdk');
     $c = new \TopClient();
     date_default_timezone_set('Asia/Shanghai');
     //设置时区
     $c->appkey = '23268864';
     //创建应用上面的appkey
     $c->secretKey = '69f0728011dec573eb02f3f57583cb80';
     //创建应用上面的secretKey
     $req = new \AlibabaAliqinFcSmsNumSendRequest();
     // $req->setExtend("123456");
     $req->setSmsType("normal");
     //不改变
     $req->setSmsFreeSignName("注册验证");
     //用来验证
     $req->setSmsParam("{'code':'{$randomNumber}','product':'源代码商城'}");
     $req->setRecNum($tel);
     //接收的电话
     $req->setSmsTemplateCode("SMS_2345004");
     //模板id
     $resp = $c->execute($req);
     //判定发送的状态
     //        return ((string)$resp->result->success)==='true';
     return $resp->result->success;
 }
Ejemplo n.º 3
0
 /**
  * 获取或生成用户salt
  *
  * @param number $uid
  */
 public function salt($uid = 0)
 {
     if ($uid) {
         return $this->where('uid=' . intval($uid))->getField('salt');
     } else {
         return \Org\Util\String::randString(6);
     }
 }
 public function addAction()
 {
     $randToken = \Org\Util\String::randString(10, 5);
     $callbackUrl = 'http://' . $_SERVER['SERVER_NAME'] . '/index.php/api/' . $randToken;
     $this->assign('token', $randToken);
     $this->assign('callbackUrl', $callbackUrl);
     $this->display();
 }
Ejemplo n.º 5
0
 /**
  * 获取短信的验证码
  * @param $tel
  */
 public function getSMSCode($tel)
 {
     //随机码
     $str = String::randNumber(1000, 9999);
     //>>1.将验证码保存到redis中.保存30秒
     S($tel, $str, 300);
     //>>2.发送短信
     sendSMS('注册验证', '{"code":"' . $str . '","product":"京西商城"}', $tel, 'SMS_2245271');
 }
Ejemplo n.º 6
0
 /**
  * 根据注册用户的手机号,获取手机验证码
  * @param $tel
  */
 public function getSmsCode($tel)
 {
     //生成随机的短信验证码
     $smsCode = \Org\Util\String::randNumber(1000, 9999);
     //将手机验证码存入redis中,当前手机号作为键.用作后面的验证
     S($tel, $smsCode, 60);
     //发送验证信息
     sendSMS('注册验证', '{"code":"' . $smsCode . '","product":"京西商城"}', $tel, 'SMS_4730837');
 }
 public function register()
 {
     if (!IS_POST) {
         $this->error('405 method not allow');
     }
     $data = I('post.');
     $csrf_token = session('csrf_token');
     if ($csrf_token !== $data['csrf_token']) {
         $this->error('csrf');
     }
     if ($data['email'] == '' || $data['username'] == '' || $data['nickname'] == '') {
         $this->error('所有数据都要填...');
     }
     if (mb_strlen($data['username']) > 30 || mb_strlen($data['nickname']) > 30) {
         $this->error('参数过长');
     }
     if ($data['password'] !== $data['password_verify']) {
         $this->error('输入的两次密码不一致');
     }
     $num = M('user_member')->where(array('email' => $data['email'] . '@cqupt.edu.cn'))->count();
     if ($num != 0) {
         $this->error('你已注册, 如忘记密码请联系红岩网校工作站重置密码');
     }
     $str = new String();
     $salt = $str->randString(6);
     $verify_code = md5(sha1(time() + 1024) . $data['email']);
     $password = md5(md5($data['password']) . $salt);
     $row = array('time' => time(), 'salt' => $salt, 'stu_num' => $data['username'], 'email' => $data['email'] . '@cqupt.edu.cn', 'type_id' => 1, 'nickname' => $data['nickname'], 'verify_code' => $verify_code, 'password' => $password, 'gender' => $data['gender'], 'status' => 1);
     $post_data['subject'] = '=?UTF-8?B?' . base64_encode('认证邮件') . '?=';
     $url = 'http://' . $_SERVER['HTTP_HOST'] . U('TeacherRegister/emailVerify') . "?code=" . $verify_code;
     $post_data['content'] = "Account verify link: \r\n{$url}";
     $post_data['email'] = $data['email'] . '@cqupt.edu.cn';
     $post_data['string'] = '4bbb67';
     $post_data['secret'] = sha1('redrock' . md5($post_data['string']));
     $return = $this->curl_api('hongyan.cqupt.edu.cn/phpmail/test.php', $post_data);
     //        array('subject' => $subject, 'content' => $content, 'email' => $email)
     if ($return->status == 200) {
         M('email_verify')->add($row);
         $this->success('注册成功, 请在12小时内前往学校教师邮箱激活账号~', 'http://mail.cqupt.edu.cn/', 10);
         return;
     }
     $this->error('好像出了点小问题...');
 }
 public function add_user($scid, $yearid)
 {
     //IS_POST 表示当前请求为POST方式 即表单产生提交
     $model = D('Home/ClassResources');
     if (IS_POST) {
         $data = array();
         $data['SCID'] = $scid;
         $data['CnName'] = I('CnName');
         $data['StartDate'] = I('StartDate');
         $data['MP3Url'] = I('MP3Url');
         $data['VideoUrl'] = I('VideoUrl');
         $data['HightUrl'] = I('HightUrl');
         $data['SuperUrl'] = I('SuperUrl');
         $data['PPTUrl'] = I('PPTUrl');
         $data['ExamID'] = I('examid');
         $data['SubID'] = I('subid');
         $data['Year'] = $yearid;
         $data['create_time'] = date('Y-m-d H:i:s', time());
         $data['SortID'] = I('SortID');
         $data['TimeLen'] = I('TimeLen');
         $data['FreeTF'] = I('FreeTF');
         if (empty($data['CnName']) || empty($data['StartDate']) || empty($data['VideoUrl']) || empty($data['Year'])) {
             $this->error('课时名称、开放时间、标清视频、所属年份必须填写!');
         }
         if (empty($data['TimeLen']) || empty($data['SortID'])) {
             $this->error('课时编号、课时时长必须填写!');
         }
         if ($model->insert_user($data)) {
             $this->success('新增课时资源成功!', U('ClassResources/list_user', array('scid' => $scid, 'yearid' => I('yearid'))));
         } else {
             $this->error('新增课时资源失败!', U('ClassResources/add_user', array('scid' => $scid, 'yearid' => I('yearid'))));
         }
     } else {
         $ExamName = array();
         $ExamName = $model->get_examclassname($scid);
         $this->assign('ExamName', $ExamName);
         $DefClassNum = array();
         $DefClassNum = $model->get_defclassnum($scid, $yearid);
         if (count($DefClassNum) == 0) {
             $DefClassNum['sortid'] = 1;
         } else {
             $DefClassNum['sortid'] = $DefClassNum['sortid'] + 1;
         }
         $this->assign('DefClassNum', $DefClassNum);
         $data = array();
         $fileid = substr(String::uuid(), 1, -1);
         $data['fileid'] = $fileid;
         $data['filepath'] = '/' . $ExamName['enname'] . '/' . $ExamName['subid'] . '/' . $scid . '_' . substr($yearid, 2, 2) . '/' . $fileid . '/';
         $this->assign('info', $data);
         $this->display();
     }
 }
Ejemplo n.º 9
0
 public function saveAutoLogin($admin_id)
 {
     //>>1.生成一个随机的字符串,作为auto_key的值, 并且保存到数据库中
     $auto_key = String::randString();
     $adminModel = M('Admin');
     $adminModel->save(array('auto_key' => $auto_key, 'id' => $admin_id));
     //>>2. 将auto_key进行加密之后和  admin_id 保存到cookie中
     $salt = $adminModel->getFieldById($admin_id, 'salt');
     $auto_key = md5($auto_key . $salt);
     //让cookie的值在浏览器中保存一个星期
     cookie('admin_id', $admin_id, 60 * 60 * 24 * 7);
     cookie('auto_key', $auto_key, 60 * 60 * 24 * 7);
 }
Ejemplo n.º 10
0
 /**
  * @param $admin_id
  * 保存auto_key到数据库,并将auto_key,和id保存到cookie中
  */
 public function saveAutoInfo($admin_id)
 {
     //>>1.随机生成一个auto_key,并将auto_key保存到登录用户记录的数据库中
     $auto_key = String::randString();
     $result = M('admin')->where(array('id' => $admin_id))->save(array('auto_key' => $auto_key));
     if ($result === false) {
         return false;
     }
     //>>2.将auto_key以及用户的id一起保存到缓存中
     $arr = array();
     $arr['auto_key'] = $auto_key;
     $arr['id'] = $admin_id;
     saveAutoLogin($arr);
 }
Ejemplo n.º 11
0
 public function saveService($id)
 {
     //生成字符串
     $auto_key = String::randString();
     $adminModel = M('Admin');
     $result = $adminModel->save(array('atuo_key' => $auto_key, 'id' => $id));
     if ($result) {
         //把$auto_key加密后和$id保存到cookie
         $salt = $adminModel->getFieldById($id, 'salt');
         $auto_key = md5($auto_key . $salt);
         //让cookie的值在浏览器中保存一个星期
         cookie('admin_id', $id, 60 * 60 * 24 * 7);
         cookie('auto_key', $auto_key, 60 * 60 * 24 * 7);
     }
 }
Ejemplo n.º 12
0
 /**
  * @param $tel
  * 根据电话号码
  * 发送手机短信验证码
  */
 public function sendSMS($tel)
 {
     //随机生成一个6位数字的验证码
     $phoneverify = String::randString(6, 1);
     //将验证码存到session中
     session('PHONE_VERIFY', $phoneverify);
     //发送验证码给此手机用户
     vendor('SMS.TopSdk');
     date_default_timezone_set('Asia/Shanghai');
     $c = new \TopClient();
     $c->appkey = '23269098';
     $c->secretKey = '8f1dd873ef3e792eab786e8d2845f60d';
     $req = new \AlibabaAliqinFcSmsNumSendRequest();
     // $req->setExtend("123456");
     $req->setSmsType("normal");
     $req->setSmsFreeSignName("注册验证");
     $req->setSmsParam("{'code':'{$phoneverify}','product':'e商城'}");
     $req->setRecNum("{$tel}");
     $req->setSmsTemplateCode("SMS_2370004");
     $resp = $c->execute($req);
     return (string) $resp->result->success === 'true';
 }
Ejemplo n.º 13
0
 public function signature()
 {
     $url = "http://Hongyan.cqupt.edu.cn/MagicLoop/index.php?s=/addon/Api/Api/apiJsTicket";
     $timestamp = time();
     $string = "";
     $arr = "abcdefghijklmnopqistuvwxyz0123456789ABCDEFGHIGKLMNOPQISTUVWXYZ";
     for ($i = 0; $i < 16; $i++) {
         $y = rand(0, 41);
         $string .= $arr[$y];
     }
     $secret = sha1(sha1($timestamp) . md5($string) . 'redrock');
     $post_data = array("timestamp" => $timestamp, "string" => $string, "secret" => $secret, "token" => "gh_68f0a1ffc303");
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     // post数据
     curl_setopt($ch, CURLOPT_POST, 1);
     // post的变量
     curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
     $output = curl_exec($ch);
     curl_close($ch);
     //打印获得的数据
     $rel = json_decode($output);
     $string = new String();
     $jsapi_ticket = $rel->data;
     $data['jsapi_ticket'] = $jsapi_ticket;
     $data['noncestr'] = $string->randString();
     $data['timestamp'] = time();
     $data['url'] = 'http://' . $_SERVER['HTTP_HOST'] . __SELF__;
     //生成当前页面url
     $data['signature'] = sha1($this->ToUrlParams($data));
     return $data;
 }
Ejemplo n.º 14
0
    public function step4()
    {
        session('error', false);
        $this->assign('meta_title', "step4");
        $this->display();
        //连接数据库
        $db_config = session('db_config');
        $db_instance = Db::getInstance($db_config);
        //创建数据表
        create_tables($db_instance, $db_config['DB_PREFIX']);
        //生成加密字符串
        $add_chars .= '`~!@#$%^&*()_+-=[]{};:"|,.<>/?';
        $auth = \Org\Util\String::randString(64, '', $add_chars);
        //生成随机数
        //创建配置文件
        $conf = write_config($db_config, $auth);
        //根据加密字符串更新admin密码的加密结果
        $new_admin_password = user_md5('admin', $auth);
        $sql = <<<SQL
        UPDATE `{$db_config["DB_PREFIX"]}system_config` SET `value`='{$auth}' WHERE `name` = 'AUTH_KEY';
        UPDATE `{$db_config["DB_PREFIX"]}user` SET `password`='{$new_admin_password}' WHERE `id` = 1;
SQL;
        $result = $db_instance->execute($sql);
        if (!$result) {
            $this->error('写入系统加密KEY或管理员新密码出错!');
        }
        if (session('error')) {
            $this->error('安装出错', 'index');
        } else {
            session('step', 4);
            $this->redirect('complete');
        }
    }
Ejemplo n.º 15
0
function saveImage($folder, $content)
{
    $tmpId = \Org\Util\String::keyGen();
    $fileName = '/Uploads/' . $folder . '/' . array('date', 'Ymd') . '/' . $tmpId . '.jpg';
    list($type, $data) = explode(';', $content);
    list(, $data) = explode(',', $content);
    file_put_contents($fileName, base64_decode($content));
    return;
}
Ejemplo n.º 16
0
 public function usersave()
 {
     $userid = $this->_getUserid();
     $password = $this->_getPassword();
     if ($userid) {
         if ($password && !Filter::F_Password($password)) {
             $this->ajaxReturn(1, '请填写正确的密码!');
         }
     } else {
         if (!Filter::F_Password($password)) {
             $this->ajaxReturn(1, '请填写正确的密码!');
         }
     }
     $status = $this->_getStatus();
     $username = $this->_getUsername();
     $department = $this->_getDepartment();
     $position = $this->_getPosition();
     $dangzhibu = $this->_getDangzhibu();
     if ($password) {
         $ukey = String::randString(6, 3, '');
         $password = D('User')->passwordEncrypt($password, $ukey);
     }
     if ($userid) {
         $data = array('username' => $username, 'department' => $department, 'position' => $position, 'dangzhibu' => $dangzhibu, 'updatetime' => TIMESTAMP);
         if ($password) {
             $data['password'] = $password;
             $data['ukey'] = $ukey;
         }
         $userid = D('User')->usersave($userid, $data);
     } else {
         $account = $this->_getAccount();
         //查询account是否已存在
         $flag = M('user')->where(array('account' => $account))->count();
         if ($flag) {
             $this->ajaxReturn(1, '账号已存在!');
         }
         $data = array('account' => $account, 'password' => $password, 'username' => $username, 'department' => $department, 'position' => $position, 'dangzhibu' => $dangzhibu, 'ukey' => $ukey, 'status' => $status, 'loginnum' => 0, 'createtime' => TIMESTAMP, 'updatetime' => TIMESTAMP);
         $userid = D('User')->usersave(null, $data);
     }
     if ($userid) {
         $this->ajaxReturn(0, '党员账号保存成功!');
     } else {
         $this->ajaxReturn(1, '党员账号保存失败!');
     }
 }
Ejemplo n.º 17
0
 public function managersave()
 {
     $managerid = $this->_getManagerID();
     $password = $this->_getPassword();
     if (!Filter::F_Password($password)) {
         $this->ajaxReturn(1, '请填写正确的密码!');
     }
     $mkey = String::randString(6, 3, '');
     $password = D('User')->passwordEncrypt($password, $mkey);
     $status = $this->_getStatus();
     if ($managerid) {
         $data = array('password' => $password, 'mkey' => $mkey, 'updatetime' => TIMESTAMP);
         $managerid = D('Manager')->saveManager($managerid, $data);
     } else {
         $account = $this->_getAccount();
         if (!Filter::F_Account($account)) {
             $this->ajaxReturn(1, '请填写正确的账号!');
         }
         //查询account是否已存在
         $flag = M('manager')->where(array('account' => $account))->count();
         if ($flag) {
             $this->ajaxReturn(1, '账号已存在!');
         }
         $data = array('account' => $account, 'password' => $password, 'mkey' => $mkey, 'status' => $status, 'supre' => 0, 'createtime' => TIMESTAMP, 'updatetime' => TIMESTAMP, 'createip' => get_client_ip(0, true), 'lastlogintime' => 0, 'loginnum' => 0, 'isdelete' => 0);
         $managerid = D('Manager')->saveManager(null, $data);
     }
     if ($managerid) {
         $this->ajaxReturn(0, '保存成功!');
     } else {
         $this->ajaxReturn(1, '保存失败!');
     }
 }
Ejemplo n.º 18
0
 /**
  * 短信验证码,用于注册
  * @author jry <*****@*****.**>
  */
 public function sendMobileVerify()
 {
     $receiver = I('post.mobile');
     $user_object = D('User');
     $result = $user_object->create($_POST, 5);
     //调用自动验证
     if (!$result) {
         $this->error($user_object->getError());
     }
     $reg_verify = \Org\Util\String::randString(6, 1);
     //生成验证码
     session('reg_verify', user_md5($reg_verify, $receiver));
     $body = $title . '验证码:' . $reg_verify;
     if (send_mobile_message($receiver, $title, $body)) {
         $this->success('发送成功,请查收!');
     } else {
         $this->error('发送失败!');
     }
 }
 public function listdep()
 {
     session("code2", array());
     $m = M("Department");
     $res = $m->select();
     $mng_id = $_GET['mng_id'];
     $v = "";
     $this->assign("mng_id", $mng_id);
     $mng = M("Manager");
     $w['mng_id'] = $_GET['mng_id'];
     $r = $mng->field("mng_deplist")->where($w)->select();
     if (!empty($r)) {
         $arr = split(",", $r[0]["mng_deplist"]);
         $v .= $this->prn($this->tree(removePre($res, "dep_"), 0), $arr);
     } else {
         $v .= $this->prn($this->tree(removePre($res, "dep_"), 0), array());
     }
     $v = $this->tree3($arr);
     //	print_r($this->tree3($arr));exit(0);
     //	print_r($arr);
     //二维码
     vendor('phpqrcode.phpqrcode');
     $pic_code = "Public/Code2/code.jpg";
     $uuid = md5(\Org\Util\String::uuid()) . session_id();
     \QRcode::png($uuid, $pic_code, 'M', 16);
     session("sgn_code2", $uuid);
     //		print_r(session("code2"));exit(0);
     $this->assign("pic_code", $pic_code);
     $this->assign("listdep", $v);
     $this->display("Index/signcode");
 }
Ejemplo n.º 20
0
 /**
  * 得到随机的6位盐
  * @return string
  */
 protected function randString()
 {
     $strObj = new String();
     return $strObj->randString();
 }
Ejemplo n.º 21
0
 public function step4()
 {
     $this->assign('meta_title', "step4");
     $this->display();
     //连接数据库
     $db_config = session('db_config');
     $db_instance = Db::getInstance($db_config);
     //创建数据表
     create_tables($db_instance, $db_config['DB_PREFIX']);
     //生成加密字符串
     $add_chars .= '`~!@#$%^&*()_+-=[]{};:"|,.<>/?';
     $auth = \Org\Util\String::randString(64, '', $add_chars);
     //生成随机数
     //创建配置文件
     $conf = write_config($db_config, $auth);
     //根据加密字符串更新admin密码的加密结果
     $sql = 'UPDATE `' . $db_config["DB_PREFIX"] . 'user` SET `password`="' . user_md5('admin', $auth) . '" WHERE `id` = 1';
     $result = $db_instance->execute($sql);
     if (!$result) {
         $this->error('写入加密后密码出错!');
     }
     if (session('error')) {
         $this->error('安装出错', 'step1');
     } else {
         session('step', 4);
         $this->redirect('complete');
     }
 }
Ejemplo n.º 22
0
 /**
  * 创建预支付订单
  */
 public function createPrePay()
 {
     if (is_login()) {
         $adb = M('account');
         $cdb = D('cart');
         $agdb = M('AccountGoods');
         $result['status'] = -1;
         $adb->startTrans();
         $uid = get_temp_uid();
         $payid = \Org\Util\String::keyGen();
         $accountData = array('payid' => $payid, 'uid' => $uid, 'type' => -1, 'status' => 0);
         if ($adb->add($accountData) !== FALSE) {
             $map['uid'] = $uid;
             $list = $cdb->where($map)->select();
             $result['status'] = 0;
             // 复制购物车
             foreach ($list as $cart) {
                 $cart['payid'] = $payid;
                 if ($agdb->add($cart) === FALSE) {
                     $result['status'] = -1;
                     break;
                 }
             }
             // 清空购物车
             if ($result['status'] == 0 && $cdb->where($map)->delete() === FALSE) {
                 $result['status'] = -1;
                 // 失败
                 $result['message'] = $cdb->getLastSql();
             }
         }
         if ($result['status'] == 0) {
             $adb->commit();
             $result['rst'] = $payid;
             empty_cart();
         } else {
             $adb->rollback();
         }
     } else {
         // 未登录
         $result['status'] = -2;
     }
     $this->ajaxReturn($result, 'JSON');
 }
Ejemplo n.º 23
0
 /**
  * 发送短信验证码,放到redis中
  * @param $tel
  */
 public function sendSMS($tel)
 {
     //得到随机6位数字
     $strObj = new String();
     $telCode = $strObj->randNumber(100000, 999999);
     //保存在redis中  5分钟有效期
     S($tel, $telCode, 300);
     //构建短信参数
     $str = '{"code":"' . $telCode . '","product":"京西商城"}';
     //发送短信
     sendSMS($str, $tel);
     $this->ajaxReturn(true);
 }
Ejemplo n.º 24
0
 /**
  * 学员用户登录。
  * @param  string $agencyId 机构ID
  * @param  string $username 用户名
  * @param  string $pwd      加密密码:md5(学员用户账号+学员用户输入明文密码)
  * @param  int    $terminal 终端(2-苹果,3-安卓,4-其他)
  * @return json             反馈数据
  */
 public function login($agencyId, $username, $pwd, $terminal = 2)
 {
     if (APP_DEBUG) {
         trace("学员用户登录[agencyId=>{$agencyId}][username=>{$username}][pwd=>{$pwd}]...");
     }
     //检查所属机构ID
     if (!isset($agencyId) || empty($agencyId)) {
         return build_callback_error(-300, '机构ID为空!');
     }
     //检查用户名
     if (!isset($username) || empty($username)) {
         return build_callback_error(-301, '用户名为空!');
     }
     //检查密码
     if (!isset($pwd) || empty($pwd)) {
         return build_callback_error(-302, '密码为空!');
     }
     //查询数据
     $_data = $this->field('userid,realname,passwords,lock')->where("`jgid` = '%s' and username = '******'", array($agencyId, $username))->find();
     if (!$_data) {
         if (APP_DEBUG) {
             trace("用户名[{$username}]不存在!");
         }
         return build_callback_error(-303, '用户名不存在!');
     } else {
         if (isset($_data['lock']) && !empty($_data['lock'])) {
             if (APP_DEBUG) {
                 trace("用户账号[{$username}]已被锁定!");
             }
             return build_callback_error(-304, '用户已被锁定!');
         } else {
             if (isset($_data['passwords'])) {
                 //0.校验密码
                 //1.加密计算
                 $_encypt_pwd = md5($username . $_data['passwords']);
                 if ($_encypt_pwd != $pwd) {
                     if (APP_DEBUG) {
                         trace("密码错误[{$_encypt_pwd} != {$pwd}]..");
                     }
                     return build_callback_error(-305, '密码错误!');
                 } else {
                     $_userId = $_data['userid'];
                     //验证成功,生成随机用户ID(用于限制一个账号多处登录)
                     $_rand_user_id = String::uuid();
                     //更新成功
                     if ($this->save(array('UserID' => $_userId, 'app_random_id' => $_rand_user_id, 'LoginTime' => date('Y-m-d H:i:s', time())))) {
                         //更新登录次数
                         $this->where("`userid`='%s'", array($_userId))->setInc('loginnum');
                         //写入登录日志
                         M('UserLog')->add(array('UID' => $_userId, 'LoginType' => intval($terminal), 'LoginIP' => get_client_ip(), 'create_time' => date('Y-m-d H:i:s', time())));
                         //返回数据
                         return build_callback_success(array('agencyId' => $agencyId, 'randUserId' => $_rand_user_id, 'realName' => $_data['realname'], 'download' => 1));
                     } else {
                         if (APP_DEBUG) {
                             trace("随机用户ID[{$_rand_user_id}=>{$_userId}]写入数据失败:{$_update}");
                         }
                         return build_callback_error(-306, '更新随机用户ID失败,请联系管理员!');
                     }
                 }
             } else {
                 return build_callback_error(-307, '未知错误,请联系管理员!');
             }
         }
     }
 }
Ejemplo n.º 25
0
 /**
  * 短信验证码,用于注册
  * @author jry <*****@*****.**>
  */
 public function sendMobileVerify()
 {
     $user_object = D('User');
     $result = $user_object->create($_POST, 5);
     //调用自动验证
     if (!$result) {
         $this->error($user_object->getError());
     }
     //生成验证码
     $reg_verify = \Org\Util\String::randString(6, 1);
     session('reg_verify', user_md5($reg_verify, I('post.mobile')));
     //构造短信数据
     $msg_data['receiver'] = I('post.mobile');
     $msg_data['message'] = '短信验证码:' . $reg_verify;
     if (send_mobile_message($msg_data)) {
         $this->success('发送成功,请查收!');
     } else {
         $this->error('发送失败!');
     }
 }
Ejemplo n.º 26
0
 public function changePass()
 {
     $old_pass = I('post.old_pass');
     $new_pass = I('post.new_pass');
     $conf_pass = I('post.conf_pass');
     $where['stu_num'] = session('stunum');
     $user = M('user_member')->where($where)->find();
     if (!$user['password']) {
         //password字段为空,说明没有修改过,密码仍是后5,6位
         if (substr($user['stu_idcard'], -6) == strtolower($old_pass) || substr($user['stu_idcard'], -5) == strtolower($old_pass)) {
             if ($new_pass == $conf_pass) {
                 $str = new String();
                 $save['salt'] = $str->randString(6);
                 $save['password'] = md5(md5($new_pass) . $save['salt']);
                 M('user_member')->where($where)->save($save);
                 $this->ajaxReturn(true);
             }
         } else {
             $this->ajaxReturn(false);
         }
         //原密码错误
     } else {
         if ($user['password'] == md5(md5($old_pass) . $user['salt'])) {
             if ($new_pass == $conf_pass) {
                 $save['password'] = md5(md5($new_pass) . $user['salt']);
                 M('user_member')->where($where)->save($save);
                 $this->ajaxReturn(true);
             }
         } else {
             $this->ajaxReturn(false);
         }
         //原密码错误
     }
 }
Ejemplo n.º 27
0
 public function createUUID()
 {
     return trim(\Org\Util\String::uuid(), "{}");
 }
Ejemplo n.º 28
0
                     <?php 
$Copy = \Org\Helper\TMP::SINGLEPAGE(11);
echo \Org\Util\String::msubstr(strip_tags($Copy['content']), 0, 100);
?>
                </p>
                 <p><a href="<?php 
echo \Org\Helper\Route::CUrl('Content/Content/page', array('cid' => 11));
?>
">Read more...</a></p>
            </div>
            <div class="widget span3">
                <h4>商务合作</h4>
                <p>
                 <?php 
$Business = \Org\Helper\TMP::SINGLEPAGE(12);
echo \Org\Util\String::msubstr(strip_tags($Business['content']), 0, 100);
?>
                </p>
                <p><a href="<?php 
echo \Org\Helper\Route::CUrl('Content/Content/page', array('cid' => 12));
?>
">Read more...</a></p>
            </div>
            <div class="widget span3">
                <h4>联系我们</h4>
                <p><i class="icon-map-marker"></i> Address: 江苏省 镇江市</p>
                <p><i class="icon-user"></i> QQ: 284909375</p>
                <p><i class="icon-envelope-alt"></i> Email: <a href="">284909375@qq.com</a></p>
                <p><i class="icon-envelope-alt"></i> Email: <a href="">hot12121212@163.com</a></p>
            </div>
        </div>
 /**
  * 短信验证码,用于注册
  * @author jry <*****@*****.**>
  */
 public function sendMobileVerify()
 {
     // 生成验证码
     $reg_verify = \Org\Util\String::randString(6, 1);
     session('reg_verify', user_md5($reg_verify, I('post.mobile')));
     // 构造短信数据
     $msg_data['receiver'] = I('post.mobile');
     $msg_data['message'] = '短信验证码:' . $reg_verify;
     $result = D('Addons://Message/Message')->sendMessage($msg_data);
     if ($result) {
         $this->success('发送成功,请查收!');
     } else {
         $this->error('发送失败!');
     }
 }
 private function mail($email, $stunum)
 {
     $str = new String();
     $salt = $str->randString(6);
     $verify_code = md5(sha1(time() + 1024) . $email);
     $row = array('time' => time(), 'salt' => $salt, 'stu_num' => $stunum, 'email' => '', 'type_id' => 2, 'nickname' => '', 'verify_code' => $verify_code, 'password' => '', 'gender' => '', 'status' => 1);
     $data['subject'] = '=?UTF-8?B?' . base64_encode('重置密码') . '?=';
     $url = 'http://' . $_SERVER['HTTP_HOST'] . U('ForgetPassword/reset') . "?code=" . $verify_code;
     $data['content'] = "link: \r\n{$url}";
     $data['email'] = $email;
     $data['string'] = 'er4g7d';
     $data['secret'] = sha1('redrock' . md5($data['string']));
     $return = $this->curl_api('http://hongyan.cqupt.edu.cn/phpmail/test.php', $data);
     //array('subject' => $subject, 'content' => $content, 'email' => $email)
     if ($return->status == 200) {
         M('email_verify')->add($row);
         return true;
     } else {
         return false;
     }
 }