示例#1
0
 private function _validate_form()
 {
     // 先验证用户名和密码
     $this->load->library('form_validation');
     $this->form_validation->set_message('required', '请输入{field}');
     $this->form_validation->set_rules('username', '用户名', array('required', array('is_username', function ($str) {
         if (is_username($str) || is_email($str) || is_phone($str)) {
             return true;
         }
         $this->form_validation->set_message('is_username', '无效{field}');
         return false;
     })));
     $this->form_validation->set_rules('password', '密码', array('required', array('is_password', function ($str) {
         if (!is_password($str)) {
             $this->form_validation->set_message('is_password', '无效{field}');
             return false;
         }
         return true;
     })));
     if (!$this->form_validation->run()) {
         return FALSE;
     }
     $this->form_validation->reset_validation();
     $this->form_validation->set_message('required', '请输入{field}');
     $this->form_validation->set_rules('captcha', '验证码', 'trim|required|callback_check_captcha');
     return $this->form_validation->run();
 }
示例#2
0
 public function doemail()
 {
     global $_M;
     if (!load::sys_class('pin', 'new')->check_pin($_M['form']['code'])) {
         okinfo($_M['url']['getpassword'], $_M['word']['membercode']);
     }
     load::sys_func('str');
     if (is_email($_M['form']['username'])) {
         $user = $this->userclass->get_user_by_email($_M['form']['username']);
         if (!$user) {
             okinfo($_M['url']['getpassword'], $_M['word']['nouser']);
         }
         $valid = load::mod_class('user/class/valid', 'new');
         if ($valid->get_email($_M['form']['username'], 'getpassword')) {
             okinfo($_M['url']['login'], $_M['word']['emailsucpass']);
         } else {
             okinfo($_M['url']['login'], $_M['word']['emailfail']);
         }
     } elseif (is_phone($_M['form']['username'])) {
         $user = $this->userclass->get_user_by_tel($_M['form']['username']);
         if (!$user) {
             okinfo($_M['url']['getpassword'], $_M['word']['nouser']);
         }
         require_once $this->template('tem/getpassword_telset');
     } else {
         okinfo($_M['url']['getpassword'], $_M['word']['emailvildtips3']);
     }
 }
示例#3
0
 /**
  * 用户登录认证
  * @param  string  $username 用户名/邮箱/手机
  * @param  string  $password 用户密码
  * @return integer           登录成功-用户ID,登录失败-错误编号
  */
 public function uc_user_login($username, $password, $type = false)
 {
     $uc = new \Ucenter\Client\Client();
     if ($type == false) {
         if (is_email($username)) {
             $type = 2;
         } elseif (is_phone($username)) {
             $type = 3;
         } else {
             $type = 0;
         }
     }
     $re = $uc->__call('uc_user_login', array('username' => $username, 'password' => $password, 'isuid' => $type));
     return $re;
 }
示例#4
0
 public static function getIdentifierName($identifier)
 {
     if (is_email($identifier)) {
         return 'email';
     } else {
         if (is_phone($identifier)) {
             return 'phone';
         } else {
             if (is_numeric($identifier)) {
                 return 'id';
             } else {
                 return 'name';
             }
         }
     }
 }
示例#5
0
 function post($phone, $type, $password)
 {
     global $_G;
     if (!is_phone($phone)) {
         msg('手机号码不正确');
     }
     $this->init($type);
     include_once ROOT_PATH . 'top/baichuan/OpenSmsSendmsgRequest.php';
     $req = new OpenSmsSendmsgRequest();
     $arr['template_id'] = $this->tplid;
     $arr['signature_id'] = $this->signature_id;
     $arr['context'] = array('appName' => $_G['setting']['title'], 'code' => $password);
     $arr['external_id'] = 'change_password';
     $arr['mobile'] = $phone;
     $SendMessageRequest = json_encode($arr);
     $req->setSendMessageRequest($SendMessageRequest);
     $resp = $_G['TOP']->execute($req);
     top_check_error($resp, true);
     $rs = $resp->result;
     if (!$rs->successful) {
         $this->save_session('post_' . $type . '_' . $phone);
         if ($this->debug) {
             L('发送修改密码短信错误:' . $rs->message . ',手机号' . $phone . ',domain:' . $arr['domain']);
         }
         return $rs->message;
     } else {
         return true;
     }
 }
示例#6
0
 function phone_check()
 {
     global $_G;
     msg('系统未开启发送短信功能', 'error');
     if (!$_G[uid]) {
         msg('未登录无法进行验证操作', 'error');
         //}elseif(!$_G[setting][phone_status] || !$_G[setting][phone_username]||!$_G[setting][phone_password]){
         //	msg('系统未开启发送短信功能','error');
     } else {
         if ($_G[member][phone_check] == 1) {
             msg('您当前账号已经通过手机验证,无须再次进行验证', 'error');
         } elseif (!$_GET[phone]) {
             msg('手机号码不存在,无法进行验证', 'error');
         }
     }
     $phone = trim($_GET[phone]);
     if (!is_phone($phone)) {
         msg('手机号码格式不正确', 'error');
     }
     $p = DB::fetch_first("SELECT uid FROM " . DB::table('member') . " WHERE phone ='" . $phone . "' AND uid != " . $_G[uid]);
     if ($p[uid] > 0) {
         msg('手机号码已被注册', 'error');
     }
     if ($_GET[code]) {
         if ($_SESSION['verify_phone'] == $phone . '_' . intval($_GET[code])) {
             update_member(array('phone' => $phone, 'phone_check' => 1), $_G[uid]);
             unset($_SESSION['verify_phone'], $_SESSION['verify_phone_len']);
             msg('手机号码验证成功', 'success');
         } else {
             msg('您的验证码校验失败', 'error');
         }
         return false;
     }
     if ($_G[member][phone] != $phone) {
         update_member(array('phone' => $phone, 'phone_check' => 0), $_G[uid]);
     }
     $rs = send_verify_phone($phone);
     if ($rs['status'] == 'success') {
         $msg = '我们已向您的手机' . $arr['phone'] . '发送了一封验证短信,请在10分钟内查看并验证【' . $_G[setting][title] . '】';
         msg($msg, 'success');
     } else {
         msg($rs[msg], 'error');
     }
 }
示例#7
0
 function pay_setting()
 {
     global $_G;
     if ($_GET[onsubmit] && check()) {
         $url = URL . "m=home&a=pay_setting";
         $qq = implode(',', $_G['setting']['qq']);
         $arr = array();
         if (isset($_GET[postdb][order_number])) {
             if ($_G['member']['order_number']) {
                 msg('您当前已绑定了订单号,无法修改,如有疑问请咨询在线客服qq ' . $qq);
             }
             $number = trim($_GET[postdb][order_number]);
             if (!is_numeric($number)) {
                 msg('订单号码只能为4位或16位纯数字');
             }
             $len = dstrlen($number);
             if ($len == 4) {
                 $arr[order_number] = $number;
             } else {
                 if ($len == 16) {
                     $number = substr($number, -4);
                 } else {
                     msg('订单号码只能为4位或16位纯数字');
                 }
             }
             $arr[order_number] = $number;
             $count = getcount('member', "order_number='{$number}'");
             if ($count > 0) {
                 msg('订单号已被绑定,请更换新的淘宝账号');
             }
         }
         if (isset($_GET[postdb][alipay])) {
             $alipay = trim($_GET[postdb][alipay]);
             if (!is_email($alipay) && !is_phone($alipay)) {
                 msg('支付宝账号只能为邮箱或手机号码,请重新输入');
             }
             if ($_G['member']['alipay']) {
                 msg('您当前已绑定了支付宝,无法修改,如有疑问请咨询在线客服qq ' . $qq);
             }
             $member = DB::fetch_first("SELECT * FROM " . DB::table('member') . " WHERE alipay='{$alipay}'");
             if ($member['uid'] > 0) {
                 msg('当前支付宝已绑定了账号' . $member['username']);
             }
             $arr[alipay] = $alipay;
         }
         if (isset($_GET[postdb][alipay_name])) {
             $arr[alipay_name] = trim($_GET[postdb][alipay_name]);
         }
         if (count($arr) == 0) {
             msg('您提交的数据为空');
         }
         $arr = daddslashes($arr);
         update_member($arr);
         msg("修改成功", 'success', $url);
     }
     $this->show();
 }
示例#8
0
 function apply()
 {
     global $_G;
     $id = intval($_GET[id]);
     if (!is_login()) {
         return false;
     }
     if (!$_G[uid]) {
         msg('抱歉,未登录无法申请兑换', 'error', 'm=duihuan&id=' . $id);
         return false;
     }
     if ($_G[member][groupid] == 3) {
         msg('抱歉,您当前是禁止用户,无法使用', 'error', 'm=duihuan&id=' . $id);
         return false;
     } else {
         if ($_G[member][check] == 0) {
             msg('抱歉,您当前账号未审核无法使用', 'error', 'm=duihuan&id=' . $id);
             return false;
         }
     }
     $rs = D(array('table' => 'duihuan_apply', 'and' => " duihuan_id=" . $id . " AND uid=" . $_G[uid]));
     if ($rs[id] > 0) {
         $msg = '抱歉,您已申请了兑换过本商品,无法再次申请,申请时间: <span class="red">' . $rs[dateline] . '</span> <br/>';
         $msg .= '当前申请状态为: <span class="red">' . $rs[status_text] . '</span>';
         $msg .= '<br/>客服最后操作时间: <span class="red">' . $rs[statustime] . '</span>';
         msg($msg, 'error', 'm=duihuan&id=' . $id);
         return false;
     }
     $goods = D(array('table' => 'duihuan', 'and' => 'id=' . $id));
     if ($goods[hide] == 1) {
         msg('抱歉,当前兑换商品已下架', 'error', 'm=duihuan&id=' . $id);
         return false;
     }
     if ($goods[org_start_time] > 0 && $goods[org_start_time] > TIMESTAMP) {
         msg('抱歉,当前兑换未开始', 'error', 'm=duihuan&id=' . $id);
         return false;
     }
     if ($goods[org_end_time] > 0 && $goods[org_end_time] < TIMESTAMP) {
         msg('抱歉,当前兑换已结束', 'error', 'm=duihuan&id=' . $id);
         return false;
     }
     if ($goods[num] >= $goods[sum]) {
         msg('抱歉,当前兑换已申请完毕', 'error', 'm=duihuan&id=' . $id);
         return false;
     }
     $arr = get_filed('duihuan_apply', $_GET[postdb]);
     if (!$arr['wangwang']) {
         msg('抱歉,联系旺旺不能为空', 'error', 'm=duihuan&id=' . $id);
         return false;
     }
     if (!$arr['truename']) {
         msg('抱歉,联系人姓名不能为空', 'error', 'm=duihuan&id=' . $id);
         return false;
     }
     if (!$arr['address']) {
         msg('抱歉,收货地址不能为空', 'error', 'm=duihuan&id=' . $id);
         return false;
     }
     if (!$arr['phone']) {
         msg('抱歉,联系电话不能为空', 'error', 'm=duihuan&id=' . $id);
     } elseif (!is_phone($arr['phone'])) {
         msg('抱歉,联系电话格式不正确', 'error', 'm=duihuan&id=' . $id);
     }
     if ($arr[alipay]) {
         if (!is_email($arr[alipay]) && !is_phone($arr[alipay])) {
             msg('抱歉,支付宝账号不正确,只能为邮箱或手机号码', 'error', 'm=duihuan&id=' . $id);
         }
     }
     if ($goods[jf] > 0) {
         if ($_G[member][jf] < $goods[jf]) {
             msg('抱歉,当前兑换需要' . $goods[jf] . '积分,您当前积分为' . $_G[member][jf] . ',无法申请兑换', 'error', 'm=duihuan&id=' . $id);
             return false;
         } else {
             //更新用户积分..
             $jf = 0 - $goods[jf];
             $add_jf = $_G['member']['jf'] + $jf;
             $sid = insert_sign(array('desc' => '申请兑换-' . $goods[title] . '-id=' . $id, 'type' => 'duihuan', 'org_jf' => $add_jf, 'jf' => $jf));
             if ($sid) {
                 update_member(array('jf' => $_G[member][jf] - $goods[jf]), $_G[uid]);
             }
         }
     }
     $arr['uid'] = $_G[uid];
     $arr['username'] = $_G[username];
     $arr['dateline'] = TIMESTAMP;
     $arr['ip'] = $_G[clientip];
     $arr['duihuan_id'] = $id;
     $arr = daddslashes($arr);
     DB::insert('duihuan_apply', $arr);
     msg('兑换申成功,请等待客服审核...', 'success', 'm=duihuan&id=' . $id);
 }
示例#9
0
 public function basic_save()
 {
     $uid = $this->_uinfo['uid'];
     $action = $this->input->post('action');
     if ($uid) {
         $old = StudentModel::get_student($uid);
         if (empty($old)) {
             StudentModel::studentAjaxLogout();
             message('信息不存在', 'student/index/login');
         }
     }
     $message = array();
     $student_fullname = trim($this->input->post('full_name'));
     $len = mb_strlen($student_fullname, 'utf-8');
     $student['last_name'] = mb_substr($student_fullname, 0, 1, 'utf-8');
     $student['first_name'] = mb_substr($student_fullname, 1, $len - 1, 'utf-8');
     $student['sex'] = intval($this->input->post('sex')) == 1 ? 1 : 2;
     $student['birthday'] = strtotime($this->input->post('birthday'));
     $student['idcard'] = trim($this->input->post('idcard'));
     $student['external_account'] = trim($this->input->post('student_ticket'));
     $student['email'] = trim($this->input->post('email'));
     $student['grade_id'] = intval($this->input->post('grade_id'));
     $student['school_id'] = intval($this->input->post('school_id'));
     $student['school_name'] = trim($this->input->post('school_name'));
     $student['mobile'] = trim($this->input->post('mobile'));
     if (empty($student['email']) or !is_email($student['email'])) {
         $message[] = '请正确填写Email地址';
     }
     if (!$uid) {
         $password = trim($this->input->post('password'));
         $password_confirm = trim($this->input->post('password_confirm'));
         if ($action == 'add') {
             if (is_string($passwd_msg = is_password($password))) {
                 $message[] = $passwd_msg;
             } else {
                 $student['password'] = $password;
             }
         } elseif (strlen($password) > 0) {
             $student['password'] = $password;
         }
         if (isset($student['password']) && $password !== $password_confirm) {
             $message[] = '两次密码输入不一致!';
         }
     }
     if (empty($student['first_name']) || empty($student['last_name'])) {
         $message[] = '请填写姓名';
     }
     if (empty($student['birthday'])) {
         $message[] = '请填写出生日期';
     }
     if (empty($student['idcard']) || !is_idcard($student['idcard'])) {
         message('请正确填写身份证号码!');
     }
     if ($student['grade_id'] < 1 or $student['grade_id'] > 12) {
         $message[] = '请选择就读年级';
     }
     if (empty($student['school_id'])) {
         $message[] = '请选择就读学校';
     }
     if (strlen($student['mobile']) > 0 && !is_phone($student['mobile'])) {
         $message[] = '请正确填写手机号码';
     }
     // 检查email是否已注册
     $tmp_student = $this->db->select('uid, email_validate')->get_where('student', array('email' => $student['email']))->row_array();
     if ($tmp_student && $tmp_student['uid'] != $uid) {
         $message[] = '该Email地址已被注册!';
     }
     //检查身份证否已注册
     $student_idcard = $this->db->select('uid')->get_where('student', array('idcard' => $student['idcard']))->row_array();
     if ($student_idcard && $student_idcard['uid'] != $uid) {
         $message[] = '该身份证号码已被注册';
     }
     if ($_FILES['picture']['name']) {
         if ($uid) {
             $config['upload_path'] = _UPLOAD_ROOT_PATH_ . 'uploads/student/' . date('Ym') . '/';
         } else {
             $config['upload_path'] = _UPLOAD_ROOT_PATH_ . 'uploads/student/temp/' . date('Ym') . '/';
         }
         $config['allowed_types'] = 'gif|jpg';
         $config['max_size'] = '1024';
         $config['max_width'] = '2000';
         $config['max_height'] = '2000';
         $config['encrypt_name'] = TRUE;
         $this->load->library('upload', $config);
         if ($this->upload->do_upload('picture')) {
             $student['picture'] = $this->upload->data('file_relative_path');
         } else {
             $msg = array("头像图片限制:", "1、图片大小小于 1M", "2、尺寸不超过2000 x 2000像素", "3、图片格式为 jpg 或 gif");
             $message[] = $this->upload->display_errors() . '<hr/><font style="font-weight:bold;font-size:12px;">' . implode('</br>', $msg) . '</font><hr/>';
         }
     }
     if ($message) {
         if (!empty($student['picture'])) {
             @unlink(_UPLOAD_ROOT_PATH_ . $student['picture']);
         }
         message(implode('<br/>', $message));
     }
     /*************** COPY FROM base_save() START ***********************/
     if ($uid) {
         $student2 = array();
         $student2['grade_id'] = intval($this->input->post('grade_id'));
         //$student2['address']   = trim($this->input->post('address'));
         $student2['zipcode'] = trim($this->input->post('zipcode'));
         $sbinfo = array();
         $sbinfo['sb_addr_provid'] = intval($this->input->post('sb_addr_provid'));
         $sbinfo['sb_addr_cityid'] = intval($this->input->post('sb_addr_cityid'));
         $sbinfo['sb_addr_areaid'] = intval($this->input->post('sb_addr_areaid'));
         $sbinfo['sb_addr_desc'] = trim($this->input->post('sb_addr_desc'));
         // 培训机构、培训课程、授课教师
         $sbcinfo = array();
         $sbcinfo['no_tiid'] = intval($this->input->post('no_tiid'));
         $sbcinfo['sbc_tiid'] = intval($this->input->post('sbc_tiid'));
         $sbcinfo['ti_name'] = trim($this->input->post('ti_name'));
         $sbcinfo['sbc_corsid'] = intval($this->input->post('sbc_corsid'));
         $sbcinfo['cors_cmid'] = intval($this->input->post('cors_cmid'));
         $sbcinfo['cors_name'] = trim($this->input->post('cors_name'));
         $sbcinfo['sbc_teachers'] = trim($this->input->post('sbc_teachers'));
         $sbs_stunumtype = $this->input->post('sbs_stunumtype');
         if (!is_array($sbs_stunumtype)) {
             $sbs_stunumtype = array();
         }
         $sbclassid_classid = $this->input->post('sbclassid_classid');
         if (!is_array($sbclassid_classid)) {
             $sbclassid_classid = array();
         }
         /*if (empty($student2['address']))
           {
               $message[] = '请填写家庭地址';
           }*/
         if (empty($student2['zipcode'])) {
             $message[] = '请填写邮编';
         }
         if ($sbinfo['sb_addr_provid'] == 0) {
             $message[] = '请填写家庭所在省市';
         }
         if ($sbinfo['sb_addr_desc'] == '') {
             $message[] = '请填写家庭住址';
         }
         if (empty($sbcinfo['no_tiid'])) {
             if ($sbcinfo['ti_name'] == '') {
                 $message[] = '请填写培训机构';
             }
             if ($sbcinfo['cors_name'] == '') {
                 $message[] = '请填写培训课程';
             }
             if ($sbcinfo['sbc_teachers'] == '') {
                 $message[] = '请填写授课教师';
             }
         }
         if (empty($sbs_stunumtype)) {
             $message[] = '请选择可接受授课模式';
         }
         if (empty($sbclassid_classid)) {
             $message[] = '请选择希望辅导难度';
         }
         if ($message) {
             message(implode('<br/>', $message));
         }
     }
     /*************** COPY FROM base() END ******************************/
     if ($uid) {
         // 在用户修改信息时才发,注册不发邮件
         if (empty($tmp_student) || !$tmp_student['email_validate']) {
             $student['email_validate'] = 0;
             // 发送邮件
             $email_tpl = C('email_template/register');
             $mail = array('student' => $student, 'hash' => email_hash('encode', $uid));
             send_email($email_tpl['subject'], $this->load->view($email_tpl['tpl'], $mail, TRUE), $student['email']);
         }
     }
     if ($uid) {
         unset($student['password']);
         if (isset($student['external_account'])) {
             unset($student['external_account']);
         }
         // 已注册,更新数据库
         if (isset($student['school_name'])) {
             unset($student['school_name']);
         }
         unset($student['uid']);
         Fn::db()->update('rd_student', $student, 'uid = ' . $uid);
         if (!empty($student['picture']) && $old['picture']) {
             @unlink(_UPLOAD_ROOT_PATH_ . $old['picture']);
         }
         StudentModel::studentUpdateSession();
         /****************** COPY FROM base_save() START ****************/
         unset($student2['grade_id']);
         // 已注册,更新数据库
         $db = Fn::db();
         $bOk = false;
         try {
             if ($db->beginTransaction()) {
                 $db->update('rd_student', $student2, "uid = {$uid}");
                 $db->delete('t_student_base', "sb_uid = {$uid}");
                 $sbinfo['sb_uid'] = $uid;
                 $db->insert('t_student_base', $sbinfo);
                 $db->delete('t_student_base_classid', "sbclassid_uid = {$uid}");
                 foreach ($sbclassid_classid as $v) {
                     $db->insert('t_student_base_classid', array('sbclassid_uid' => $uid, 'sbclassid_classid' => $v));
                 }
                 $db->delete('t_student_base_stunumtype', "sbs_uid = {$uid}");
                 foreach ($sbs_stunumtype as $v) {
                     $db->insert('t_student_base_stunumtype', array('sbs_uid' => $uid, 'sbs_stunumtype' => $v));
                 }
                 $db->delete('t_student_base_course', 'sbc_uid = ' . $uid);
                 if (empty($sbcinfo['no_tiid'])) {
                     $now_time = time();
                     if (!$sbcinfo['sbc_tiid']) {
                         $row = array('ti_name' => $sbcinfo['ti_name'], 'ti_typeid' => 1, 'ti_flag' => $now_time, 'ti_priid' => 0, 'ti_provid' => $sbinfo['sb_addr_provid'], 'ti_cityid' => $sbinfo['sb_addr_cityid'], 'ti_areaid' => $sbinfo['sb_addr_areaid'], 'ti_addtime' => date('Y-m-d H:i:s', $now_time), 'ti_adduid' => 1);
                         $db->insert('t_training_institution', $row);
                         $ti_id = $db->lastInsertId('t_training_institution', 'ti_id');
                         $sbcinfo['sbc_tiid'] = $ti_id;
                     }
                     if (!$sbcinfo['sbc_corsid']) {
                         if ($sbcinfo['cors_cmid'] != 1) {
                             $sbcinfo['cors_cmid'] = 2;
                         }
                         $row = array('cors_name' => $sbcinfo['cors_name'], 'cors_cmid' => $sbcinfo['cors_cmid'], 'cors_flag' => $now_time, 'cors_tiid' => $sbcinfo['sbc_tiid'], 'cors_stunumtype' => $sbcinfo['cors_cmid'], 'cors_addtime' => date('Y-m-d H:i:s', $now_time), 'cors_adduid' => 1, 'cors_lastmodify' => date('Y-m-d H:i:s', $now_time));
                         $db->insert('t_course', $row);
                         $cors_id = $db->lastInsertId('t_course', 'cors_id');
                         $sbcinfo['sbc_corsid'] = $cors_id;
                     }
                     $db->insert('t_student_base_course', array('sbc_uid' => $uid, 'sbc_idx' => 0, 'sbc_tiid' => $sbcinfo['sbc_tiid'], 'sbc_corsid' => $sbcinfo['sbc_corsid'], 'sbc_teachers' => $sbcinfo['sbc_teachers']));
                 }
                 $bOk = $db->commit();
                 if (!$bOk) {
                     $err = $db->errorInfo()[2];
                     $db->rollBack();
                     message('学习概况保存失败(' . $err . ')');
                 }
             }
             if (!$bOk) {
                 message('学习概况保存失败(执行事务处理失败)');
             }
         } catch (Exception $e) {
             message('学习概况保存失败(' . $e->getMessage() . ')');
         }
         /*************** COPY FROM base_save() END ********************/
     } else {
         isset($student['password']) && ($student['password'] = my_md5($student['password']));
         if (!isset($student['picture'])) {
             $student['picture'] = '';
         }
         $old = $this->session->userdata('student');
         if ($old) {
             if (empty($student['password'])) {
                 $student['password'] = $old['password'];
             }
             if (!empty($old['picture'])) {
                 if (empty($student['picture'])) {
                     $student['picture'] = $old['picture'];
                 } else {
                     @unlink(_UPLOAD_ROOT_PATH_ . $old['picture']);
                 }
             }
         }
         // 未注册,更新session
         $this->session->set_userdata(array('student' => $student));
     }
     if (!$uid && C('register_simple')) {
         $this->session->set_userdata('complete', 1);
         redirect('student/profile/submit_simple');
     } else {
         if ($uid or $this->session->userdata('complete')) {
             message('基本信息和学习概况修改成功', 'student/profile/preview', 'success');
         } else {
             redirect('student/profile/preview');
             //redirect('student/profile/base');
         }
     }
 }
示例#10
0
 public function postSendVerify($type = null, RateLimiter $rateLimiter)
 {
     $user = auth()->user();
     $request = request();
     $response = response();
     if (!$type) {
         $type = $request->input('type');
     }
     if ($type != 'phone' && $type != 'email') {
         $response->json(['status' => false, 'message' => '发送失败,Type参数错误!']);
     }
     $typeValue = $request->input('input_value');
     if ($type == 'email') {
         if ($typeValue == $user->email || !is_email($typeValue) || strlen($typeValue) > 64) {
             return $response->json(['status' => false, 'message' => '请输入正确的新邮箱']);
         }
     } elseif ($type == 'phone') {
         if ($typeValue == $user->phone || !is_phone($typeValue)) {
             return $response->json(['status' => false, 'message' => '请输入正确的新手机号']);
         }
     }
     // 60秒发送一次
     $sessionKey = 'send_verify_last_time';
     $sessionKey .= ".change.{$type}";
     $sessionValue = session($sessionKey);
     $currentTime = time();
     if ($sessionValue && $sessionValue + 60 > $currentTime) {
         return $response->json(['status' => false, 'message' => '发送失败,请不要频繁获取验证码']);
     }
     // 一个IP一个小时可以发送10次
     $rateLimiterKey = 'send_verify_rate_limiter';
     $rateLimiterKey .= ":change:{$type}_" . $user->id;
     if ($rateLimiter->tooManyAttempts($rateLimiterKey, 60, 10)) {
         return $response->json(['status' => false, 'message' => '当前网络环境获取已达上限,请一小时后再试']);
     }
     if (User::hasBeenUsed($type, $typeValue, true)->exists()) {
         $typeName = $type == 'phone' ? '手机号' : '邮箱';
         return $response->json(['status' => false, 'message' => '此' . $typeName . '已被其他用户使用']);
     }
     $code = rand(100000, 999999);
     $value = ['type' => $type, 'code' => $code, 'value' => $typeValue, 'attempt' => 0, 'user_id' => $user->id];
     $cacheKey = md5("send_verify_detail.change.{$typeValue}" . config('key'));
     if ($type == 'phone') {
         require app_path('Services/Taobao/TopSdk.php');
         $status = sendSms('phone_change', $typeValue, ['code' => $code, 'product' => '积木']);
     } elseif ($type == 'email') {
         $vars = ['email' => $typeValue, 'code' => $code, 'link' => url('account/set/change-confirm') . '?key=' . urlencode($cacheKey)];
         $view = 'user.set.change_verify_mail';
         $status = \Mail::send($view, $vars, function ($message) use($typeValue) {
             $message->to($typeValue);
             $message->subject('[积木] 邮箱绑定验证码');
         });
     }
     if (empty($status)) {
         $status = false;
     } else {
         Cache::put($cacheKey, $value, 60);
         session([$sessionKey => $currentTime]);
         $rateLimiter->hit($rateLimiterKey);
     }
     $typeName = $type == 'phone' ? '短信' : '邮件';
     return $response->json(['status' => (bool) $status, 'message' => $status ? '' : 'Oh. 验证' . $typeName . '发送失败,请稍后重试']);
 }
示例#11
0
文件: login.php 项目: rallm008/wzz
if ($config['fangwen'] == 4) {
    exit('网站正在更新');
}
$ip = GetIP();
$day = date("Y-m-d", time());
$time = time();
if ($_SESSION['login'] == 1) {
    _location("ucenter.php", 301);
    exit;
}
//登录验证
if ($_POST) {
    $phone = guolv(trim($_POST['phone']));
    $password = guolv(trim($_POST['password']));
    //$code=guolv(trim($_POST['code']));
    if (is_phone($phone) == false) {
        echo "<script>alert('请输入正确的手机号');location.href='login.php'</script>";
        exit;
    }
    if ($password == '') {
        echo "<script>alert('请输入密码');location.href='login.php'</script>";
        exit;
    }
    // if($code!==$_SESSION['code']){
    // echo "<script>alert('验证码错误,请重新输入');location.href='login.php'</script>";
    // exit;
    // }
    $row = $mysql->query("select * from `userdata` where `phone`='{$phone}' and `pass`='{$password}' limit 1");
    if ($row) {
        //登录赠送金额
        $row_login_ip = $mysql->query("select * from `refererdata` where `uid`='{$row[0]['id']}' and `aid`='0' and `ip`='{$ip}' and `day`='{$day}' limit 1");
示例#12
0
 /**
  * 根据excel导入学生并将导入的学生加入考场中
  */
 public function import_student_save()
 {
     set_time_limit(0);
     $place_id = intval($this->input->post('place_id'));
     if (!$place_id) {
         message('考场不存在');
     }
     if ($this->db->get_where('exam_place', array('start_time <=' => time(), 'place_id' => $place_id))->row_array()) {
         message('该考场正在考试或已结束,无法做此操作', '/admin/place_student/index/' . $place_id);
     }
     $message = array();
     $school_id = intval($this->input->post('school_id'));
     if (!$school_id) {
         $message[] = '考场地址有错误';
     }
     $start_line = intval($this->input->post('start_line'));
     if ($start_line < 1) {
         $message[] = '请输入学生信息在Excel文件开始的行';
     }
     $fullname_column = intval($this->input->post('fullname_column'));
     if ($fullname_column < 1) {
         $message[] = '请输入姓名在Excel文件的列';
     }
     $exam_ticket_column = intval($this->input->post('exam_ticket_column'));
     if ($exam_ticket_column < 1) {
         $message[] = '请输入准考证号在Excel文件的列';
     }
     if ($fullname_column && $exam_ticket_column && $fullname_column == $exam_ticket_column) {
         $message[] = '姓名和准考证号在Excel文件中不能为同一列';
     }
     if (!$_FILES['file']) {
         $message[] = '请选择导入的Excel文件';
     }
     $grade_id = intval($this->input->post('grade_id'));
     $mobile_column = intval($this->input->post('mobile_column'));
     $school_column = intval($this->input->post('school_column'));
     $auto_set_paper = intval($this->input->post('auto_set_paper'));
     $import_tables = array_filter(explode(',', $this->input->post('import_table')));
     $schools = array();
     $school_names = $this->input->post('school_key');
     if ($school_names) {
         $school_ids = $this->input->post('school_ids');
         foreach ($school_names as $key => $name) {
             $name = str_replace(' ', '', $name);
             $sch_id = isset($school_ids[$key]) ? intval($school_ids[$key]) : 0;
             if ($sch_id > 0) {
                 $schools[$name] = $sch_id;
             } else {
                 $message[] = $name . "对应的学校ID不能为空";
             }
         }
     }
     if ($message) {
         message(implode('<br>', $message));
     }
     /**
      * 上传文件
      */
     $upload_path = '../../cache/excel/';
     $file_name = microtime(true) . '.' . end(explode('.', $_FILES['file']['name']));
     $upload_file = $upload_path . $file_name;
     if (!is_dir($upload_path)) {
         mkdir($upload_path, '0777', true);
     }
     if (!@move_uploaded_file($_FILES['file']['tmp_name'], $upload_file)) {
         message('导入文件失败,请重新导入!');
     } else {
         $exam = $this->db->from('rd_exam e')->join('rd_exam_place ep', "e.exam_id=ep.exam_pid", 'left')->where('place_id', $place_id)->get()->row_array();
         $grade_id = $grade_id ? $grade_id : $exam['grade_id'];
         if (!$school_column) {
             $school = $this->db->get_where('school', array('school_id' => $school_id))->row_array();
         }
         $place_student = $this->db->get_where('rd_exam_place_student', array('place_id' => $place_id))->result_array();
         $place_uids = array();
         foreach ($place_student as $val) {
             $place_uids[] = $val['uid'];
         }
         $uids = array();
         //未加入考场的学生
         //导入结果信息统计
         $stat = array('total' => 0, 'success' => 0, 'fail' => 0, 'exist' => 0);
         /**
          * 读取excel
          */
         $this->load->library('PHPExcel');
         $this->load->library('PHPExcel/IOFactory');
         $inputFileType = IOFactory::identify($upload_file);
         $objReader = IOFactory::createReader($inputFileType);
         $objPHPExcel = $objReader->load($upload_file);
         $sheetcount = $objPHPExcel->getSheetCount();
         for ($i = 0; $i < $sheetcount; $i++) {
             if ($import_tables && !in_array($i + 1, $import_tables)) {
                 continue;
             }
             $list = array_filter($objPHPExcel->getSheet($i)->toArray());
             if (!empty($list)) {
                 $line_count = count($list);
                 for ($j = $start_line - 1; $j < $line_count; $j++) {
                     $list[$j] = array_filter($list[$j]);
                     if (empty($list[$j])) {
                         continue;
                     }
                     $student_name = str_replace(' ', '', $list[$j][$fullname_column - 1]);
                     $external_exam_ticket = trim($list[$j][$exam_ticket_column - 1]);
                     if (!$student_name || !$external_exam_ticket) {
                         continue;
                     }
                     $stat['total']++;
                     if (empty($student_name)) {
                         $message['fail']['student_name'][] = $external_exam_ticket;
                         $stat['fail']++;
                         continue;
                     }
                     if (empty($external_exam_ticket)) {
                         $message['fail']['exam_ticket'][] = $student_name;
                         $stat['fail']++;
                         continue;
                     }
                     $exam_ticket = exam_ticket_maprule_encode($external_exam_ticket, $exam['exam_ticket_maprule']);
                     if (!is_numeric($exam_ticket)) {
                         $message['fail']['exam_ticket_error'][] = $student_name . "-" . $external_exam_ticket;
                         $stat['fail']++;
                         continue;
                     }
                     //判断准考证号是否已注册
                     if ($tmp_student = $this->db->select('uid')->from('student')->where('exam_ticket', $exam_ticket)->get()->row_array()) {
                         $message['exist'][] = $student_name . "-" . $external_exam_ticket;
                         $stat['exist']++;
                         if (!in_array($tmp_student['uid'], $place_uids)) {
                             $this->db->replace('exam_place_student', array('place_id' => $place_id, 'uid' => $tmp_student['uid']));
                             $uids[] = $tmp_student['uid'];
                         }
                     } else {
                         $mobile = '';
                         if ($mobile_column && is_phone($list[$j][$mobile_column - 1])) {
                             $mobile = $list[$j][$mobile_column - 1];
                         }
                         if ($school_column && $schools) {
                             $sch_name = str_replace(' ', '', $list[$j][$school_column - 1]);
                             $school_id = intval($schools[$sch_name]);
                             if (!isset($school_info[$school_id])) {
                                 $school_info[$school_id] = $this->db->get_where('school', array('school_id' => $school_id))->row_array();
                             }
                             $school = $school_info[$school_id];
                             if (!$school) {
                                 message('学校“' . $sch_name . '”信息不存在,请设置学校对应的学校ID!');
                             }
                         }
                         $insert_data = array('email' => $exam_ticket . "@mail.exam.new-steps.com", 'first_name' => mb_substr($student_name, 1, strlen($student_name), 'utf-8'), 'last_name' => mb_substr($student_name, 0, 1, 'utf-8'), 'exam_ticket' => $exam_ticket, 'external_account' => $external_exam_ticket, 'maprule' => $exam['exam_ticket_maprule'], 'password' => my_md5($exam['exam_ticket_maprule'] ? $external_exam_ticket : '123456'), 'mobile' => $mobile, 'grade_id' => $grade_id, 'province' => $school['province'], 'city' => $school['city'], 'area' => $school['area'], 'school_id' => $school_id, 'source_from' => '2', 'addtime' => time());
                         $this->db->insert('student', $insert_data);
                         $uid = $this->db->insert_id();
                         if ($uid) {
                             $stat['success']++;
                             $this->db->replace('exam_place_student', array('place_id' => $place_id, 'uid' => $uid));
                             $uids[] = $uid;
                         } else {
                             $stat['fail']++;
                             $message['fail']['insert_fail'][] = $student_name . "-" . $external_exam_ticket;
                             // . '(' . $this->db->last_query() . ')';
                         }
                     }
                 }
             }
         }
         //新加入考场的学生加入分配试卷计划任务中
         if ($auto_set_paper && $uids) {
             $insert_data = array();
             $insert_data['place_id'] = $place_id;
             $insert_data['uid_data'] = json_encode($uids);
             $insert_data['status'] = 0;
             $insert_data['c_time'] = time();
             $insert_data['u_time'] = time();
             $this->db->insert('cron_task_place_student_paper', $insert_data);
         }
         @unlink($upload_file);
         $data = array();
         $data['place_id'] = $place_id;
         $data['message'] = $message;
         $data['stat'] = $stat;
         $this->load->view('place_student/import_student_result', $data);
     }
 }
示例#13
0
 public function ajax_profile()
 {
     if (!$this->input->is_ajax_request()) {
         return;
     }
     header('Content-Type:application/json; charset=utf-8');
     $fields = array('nickname', 'email', 'phone', 'qq', 'wechat');
     $updates = array();
     foreach ($fields as $field) {
         if (!isset($_POST[$field])) {
             echo json_encode(array('ack' => true, 'msg' => '缺少' . $field));
             return;
         } elseif ($_POST[$field] == $_SESSION[$field]) {
             // 如果提交数据无修改
             unset($_POST[$field]);
             unset($fields[$field]);
         } else {
             $updates[$field] = $_POST[$field];
         }
     }
     if (empty($updates)) {
         echo json_encode(array('ack' => false, 'msg' => '个人资料无修改'));
         return;
     }
     // 验证
     $this->load->library('form_validation');
     $this->form_validation->set_message('required', '必须填写{field}');
     $this->form_validation->set_message('min_length', '{field}至少{param}个字符');
     $this->form_validation->set_message('max_length', '{field}至多{param}个字符');
     $this->form_validation->set_message('valid_email', '{field}无效');
     $this->form_validation->set_message('is_unique', '{field}已存在');
     $this->form_validation->set_error_delimiters('', '');
     // 为了is_unique载入db
     $this->load->database();
     isset($_POST['nickname']) && $this->form_validation->set_rules('nickname', '昵称', 'trim|min_length[2]|max_length[20]|is_unique[admin_user.username]|is_unique[admin_user.nickname]');
     isset($_POST['email']) && $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
     isset($_POST['phone']) && $this->form_validation->set_rules('phone', '手机', array('required', 'is_natural', 'exact_length[11]', 'is_unique[admin_user.phone]', array('is_phone', function ($str) {
         if (!is_phone($str)) {
             $this->form_validation->set_message('is_phone', '{field}无效');
             return false;
         }
         return true;
     })));
     isset($_POST['qq']) && $this->form_validation->set_rules('qq', 'QQ', array('is_qq', function ($str) {
         if (empty($str)) {
             $updates['qq'] = 0;
         } elseif (!is_qq($str)) {
             $this->form_validation->set_message('is_qq', '{field}无效');
             return false;
         }
         return true;
     }));
     isset($_POST['wechat']) && $this->form_validation->set_rules('wechat', '微信', array('is_wechat', function ($str) {
         if (!is_wechat($str)) {
             $this->form_validation->set_message('is_wechat', '{field}无效');
             return false;
         }
         return true;
     }));
     if (!$this->form_validation->run()) {
         echo json_encode(array('ack' => false, 'msg' => $this->form_validation->error_string()));
         return;
     }
     $this->load->model('user_model');
     $this->user_model->update($_SESSION['uid'], $updates);
     // 修改了个人资料,需要更新session
     $this->user_model->update_session();
     echo json_encode(array('ack' => true, 'msg' => '修改成功'));
     return;
 }
示例#14
0
 /**
  *
  * 修改手机号码
  **/
 function edit_phone()
 {
     $user_id = $this->visitor->get('user_id');
     if (!IS_POST) {
         /* 当前位置 */
         $this->_curlocal(LANG::get('member_center'), 'index.php?app=buyer_admin', "修改手机号码");
         $model_user =& m('member');
         $profile = $model_user->get_info(intval($user_id));
         $profile['phone'] = substr_replace($profile['phone_mob'], '*****', 3, 5);
         $this->assign("phone", $profile['phone']);
         $this->assign("phone_mob", $profile['phone_mob']);
         $_SESSION['send_code'] = $this->random(6, 1);
         $this->assign('send_code', $_SESSION['send_code']);
         /* 当前用户中心菜单 */
         $this->_curitem('my_profile');
         /* 当前所处子菜单 */
         $this->_curmenu('修改手机号码');
         $this->_config_seo('title', Lang::get('user_center') . ' - ' . "修改手机号码");
         $this->display('member.editphone.html');
     } else {
         $phone_mob = isset($_POST['phone_mob']) ? trim($_POST['phone_mob']) : '';
         if ($_SESSION['send_code'] != $_POST['send_code']) {
             $this->assign('msg', '验证码错误');
             $this->display('member.editphone.html');
             return;
         }
         if (!$phone_mob) {
             $this->assign('msg', '手机号码不能为空');
             $this->display('member.editphone.html');
             return;
         }
         if (!is_phone($phone_mob)) {
             $this->assign('msg', '手机号码格式错误');
             $this->display('member.editphone.html');
             return;
         }
         if ($profile['phone_mob'] != $_POST['phone_moble']) {
             $this->assign('msg', '手机号码错误');
             $this->display('member.editphone.html');
         }
         header("location:/index.php?app=member&act=add_phone");
     }
 }
示例#15
0
 /**
  * 检查学生是否已完善信息
  */
 private function check_perfect_student()
 {
     $uid = $this->_uinfo['uid'];
     if (!$uid) {
         // 登录失效
         redirect('student/index/login');
     }
     // 学生基本信息
     $student = $this->db->where('uid', $uid)->get('rd_student')->row_array();
     $basic = true;
     if (!is_email($student['email']) || !is_phone($student['mobile'])) {
         $basic = false;
     }
     if ($basic) {
         $fileds = array('last_name', 'first_name', 'idcard', 'sex', 'birthday', 'school_id', 'grade_id');
         foreach ($fileds as $filed) {
             if (!$student[$filed]) {
                 $basic = false;
                 break;
             }
         }
     }
     $message = array();
     $uri = '';
     if (!$basic) {
         $message[] = '<a href="' . site_url('student/profile/basic') . '" target="_blank">请完善你的基本信息</a>';
         $uri = 'student/profile/basic';
     }
     // 学生学习成绩
     if (!$this->db->select('id')->from('rd_student_ranking')->where('uid', $uid)->get()->row_array()) {
         $message[] = '<a href="' . site_url('student/profile/awards') . '" target="_blank">请填写你的学习成绩</a>';
         !$uri && ($uri = 'student/profile/awards');
     }
     // 学生发展意愿
     if (!$this->db->select('id')->from('rd_student_wish')->where('uid', $uid)->get()->row_array()) {
         $message[] = '<a href="' . site_url('student/profile/wish') . '" target="_blank">请填写你自己的发展意愿</a>';
         !$uri && ($uri = 'student/profile/wish');
     }
     // 学生家长意愿
     if (!$this->db->select('id')->from('rd_student_parent_wish')->where('uid', $uid)->get()->row_array()) {
         $message[] = '<a href="' . site_url('student/profile/pwish') . '" target="_blank">请填写完整家长意愿</a>';
         !$uri && ($uri = 'student/profile/pwish');
     }
     if ($message) {
         return array('message' => implode('<br/>', $message), 'url' => $uri);
     } else {
         return false;
     }
 }
示例#16
0
 public function postSendVerify($type = null, RateLimiter $rateLimiter)
 {
     $request = request();
     $response = response();
     if (!$type) {
         $type = $request->input('type');
     }
     if ($type != 'register' && $type != 'forgot_password') {
         $response->json(['status' => false, 'message' => '发送失败,Type参数错误!']);
     }
     $identifier = $request->input('identifier');
     if (!is_email($identifier) || strlen($identifier) > 64) {
         if (!is_phone($identifier)) {
             return $response->json(['status' => false, 'message' => '请输入正确的手机号或邮箱']);
         }
         $verifyType = 'phone';
     } else {
         $verifyType = 'email';
     }
     // 60秒发送一次
     $sessionKey = 'send_verify_last_time';
     $sessionKey .= ".{$type}.{$verifyType}";
     $sessionValue = session($sessionKey);
     $currentTime = time();
     if ($sessionValue && $sessionValue + 60 > $currentTime) {
         return $response->json(['status' => false, 'message' => '发送失败,请不要频繁获取验证码']);
     }
     // 一个IP一个小时可以发送20次
     $rateLimiterKey = 'send_verify_rate_limiter';
     $rateLimiterKey .= ":{$type}:{$verifyType}_" . request()->ip();
     if ($rateLimiter->tooManyAttempts($rateLimiterKey, 60, 20)) {
         return $response->json(['status' => false, 'message' => '当前网络环境获取已达上限,请一小时后再试']);
     }
     if ($type == 'register') {
         if (User::hasBeenUsed($verifyType, $identifier, true)->exists()) {
             $verifyTypeName = $verifyType == 'phone' ? '手机号' : '邮箱';
             $loginUrl = url('account/login', [$identifier]);
             $forgotPasswordUrl = url('account/forgot-password', [$identifier]);
             return $response->json(['status' => false, 'message' => '此' . $verifyTypeName . '已被注册,你可以 <a href="' . $loginUrl . '">尝试登陆</a> 或 <a href="' . $forgotPasswordUrl . '">找回密码</a>']);
         }
     } elseif ($type == 'forgot_password') {
         if (!User::hasBeenUsed($verifyType, $identifier, false)->exists()) {
             $verifyTypeName = $verifyType == 'phone' ? '手机号' : '邮箱';
             $createUrl = url('account/create', [$identifier]);
             return $response->json(['status' => false, 'message' => '此' . $verifyTypeName . '还没注册,<a href="' . $createUrl . '">现在去注册</a>']);
         }
     }
     $code = rand(100000, 999999);
     $value = ['type' => $type, 'code' => $code, 'identifier' => $identifier, 'verify_type' => $verifyType, 'attempt' => 0];
     $cacheKey = md5("send_verify_detail.{$type}.{$identifier}" . config('key'));
     if ($verifyType == 'phone') {
         require app_path('Services/Taobao/TopSdk.php');
         $status = sendSms($type . '_verify', $identifier, ['code' => $code, 'product' => '积木']);
     } elseif ($verifyType == 'email') {
         $action = $type == 'register' ? 'create' : 'forgot-password';
         $vars = ['email' => $identifier, 'code' => $code, 'link' => url('account/' . $action) . '?key=' . urlencode($cacheKey)];
         $view = 'user.account.' . $type . '_verify_mail';
         $subject = $type == 'register' ? '[积木] 账户注册验证码' : '[积木] 账户密码找回验证码';
         $status = \Mail::send($view, $vars, function ($message) use($identifier, $subject) {
             $message->to($identifier);
             $message->subject($subject);
         });
     }
     if (empty($status)) {
         $status = false;
     } else {
         Cache::put($cacheKey, $value, 60);
         session([$sessionKey => $currentTime]);
         $rateLimiter->hit($rateLimiterKey);
     }
     $typeName = $verifyType == 'phone' ? '短信' : '邮件';
     return $response->json(['status' => (bool) $status, 'message' => $status ? '' : 'Oh. 验证' . $typeName . '发送失败,请稍后重试']);
 }
示例#17
0
/**
 * Checks if the phone number is valid
 *
 * @param string phone number to check
 * @return string error message if phone number is not valid
 */
function check_is_phone($phone)
{
    if (!is_phone($phone)) {
        return sprintf(T_('Please enter a valid phone number like for example: %s.'), '+1 401-555-1234');
    }
}
 public function sendSms()
 {
     if ($this->isPost()) {
         $phoneNum = trim($_POST['phoneNum']);
         $message = trim($_POST['smsContent']);
         if ($_POST['settime']) {
             $send_time = strtotime(trim($_POST['sendtime']));
             if ($send_time > time()) {
                 $sendtime = date('YmdHis', $send_time);
             }
         }
         $current_sms_num = getSmsNum();
         if (!F('sms')) {
             alert('success', L('SEND_SMS_FAILED'), $_SERVER['HTTP_REFERER']);
         }
         $phoneNum = str_replace(" ", "", $phoneNum);
         $phone_array = explode(chr(10), $phoneNum);
         if (sizeof($phone_array) > 0) {
             //if(sizeof($phone_array) > $current_sms_num) alert('error','短信余额不足,请联系管理员,及时充值!',$_SERVER['HTTP_REFERER']);
         }
         $fail_array = array();
         $success_array = array();
         if ($phoneNum && $message) {
             if (strpos($message, '{$name}', 0) === false) {
                 foreach ($phone_array as $k => $v) {
                     if ($v) {
                         $phone = substr($v, 0, 11);
                         if (is_phone($phone)) {
                             $success_array[] = $phone;
                         } else {
                             $fail_array[] = $v;
                         }
                     }
                 }
                 if (!empty($fail_array)) {
                     $fail_message = L('PART_OF_NUMBER_SEND_FAILED') . implode(',', $fail_array);
                 }
                 //echo '发送成功!';die();
                 $result = sendGroupSMS(implode(',', $success_array), $message, 'sign_name', $sendtime);
                 if ($result == 1) {
                     $m_sms_record = M('smsRecord');
                     $data['role_id'] = session('role_id');
                     $data['telephone'] = implode(',', $success_array);
                     $data['content'] = $message;
                     $data['sendtime'] = time();
                     $m_sms_record->add($data);
                     alert('success', L('SEND_SUCCESS_MAY_DELAY_BY_BAD_NETWORK') . $fail_message, $_SERVER['HTTP_REFERER']);
                 } else {
                     alert('error', L('SMS_NOTIFICATION_FAILS_CODE', array($result)), $_SERVER['HTTP_REFERER']);
                 }
             } else {
                 foreach ($phone_array as $k => $v) {
                     $real_message = $message;
                     $name = '';
                     if ($v) {
                         $no = str_replace(" ", "", $v);
                         $phone = substr($no, 0, 11);
                         if (is_phone($phone)) {
                             if (strpos($v, ',', 0) === false) {
                                 $info_array = explode(',', $v);
                             } else {
                                 $info_array = explode(',', $v);
                             }
                             $real_message = str_replace('{$name}', $info_array[1], $real_message);
                             $result = sendSMS($phone, $real_message, 'sign_name', $sendtime);
                             $m_sms_record = M('smsRecord');
                             $data['role_id'] = session('role_id');
                             $data['telephone'] = $phone;
                             $data['content'] = $real_message;
                             $data['sendtime'] = time();
                             $m_sms_record->add($data);
                             if ($result < 0 && $k == 0) {
                                 alert('error', L('SMS_NOTIFICATION_FAILS_CODE', array($result)), $_SERVER['HTTP_REFERER']);
                             }
                         } else {
                             $fail_array[] = $v;
                         }
                     }
                 }
                 if (!empty($fail_array)) {
                     $fail_message = L('PART_OF_NUMBER_SEND_FAILED') . implode(',', $fail_array);
                 }
                 alert('success', L('SEND_SUCCESS_MAY_DELAY_BY_BAD_NETWORK') . $fail_message, U('setting/sendsms'));
             }
         } else {
             alert('error', L('INCOMPLETE_INFORMATION'), $_SERVER['HTTP_REFERER']);
         }
     } else {
         $current_sms_num = getSmsNum();
         $model = trim($_GET['model']);
         if ($model == 'customer') {
             $customer_ids = trim($_GET['customer_ids']);
             if ($customer_ids) {
                 $contacts_ids = M('RContactsCustomer')->where('customer_id in (%s)', $customer_ids)->getField('contacts_id', true);
                 $contacts_ids = implode(',', $contacts_ids);
                 $contacts = D('ContactsView')->where('contacts.contacts_id in (%s)', $contacts_ids)->select();
                 $this->contacts = $contacts;
             } else {
                 alert('error', L('SELECT_CUSTOMER_TO_SEND'), $_SERVER['HTTP_REFERER']);
             }
         } elseif ($model == 'contacts') {
             $contacts_ids = trim($_GET['contacts_ids']);
             if (!$contacts_ids) {
                 alert('error', L('SELECT_CONTACTS_TO_SEND'), $_SERVER['HTTP_REFERER']);
             }
             $contacts = D('ContactsView')->where('contacts.contacts_id in (%s)', $contacts_ids)->select();
             $this->contacts = $contacts;
         } elseif ($model == 'leads') {
             $d_v_leads = D('LeadsView');
             $leads_ids = trim($_GET['leads_ids']);
             $where['leads_id'] = array('in', $leads_ids);
             $customer_list = $d_v_leads->where($where)->select();
             $contacts = array();
             foreach ($customer_list as $k => $v) {
                 $contacts[] = array('name' => $v['contacts_name'], 'customer_name' => $v['name'], 'telephone' => trim($v['mobile']));
             }
             $this->contacts = $contacts;
         }
         $this->templateList = M('SmsTemplate')->order('order_id')->select();
         $this->alert = parseAlert();
         $this->current_sms_num = $current_sms_num;
         $this->display();
     }
 }
示例#19
0
function buddyboss_body_classes($classes)
{
    // Default layout class
    if (is_phone()) {
        $classes[] = 'is-mobile';
    } elseif (wp_is_mobile()) {
        if (get_option('boss_layout_tablet') == 'desktop') {
            $classes[] = 'is-desktop';
        } else {
            $classes[] = 'is-mobile';
        }
        $classes[] = 'tablet';
    } else {
        if (get_option('boss_layout_desktop') == 'mobile') {
            $classes[] = 'is-mobile';
        } else {
            $classes[] = 'is-desktop';
        }
    }
    // Switch layout class
    if (isset($_COOKIE['switch_mode']) && get_option('boss_layout_switcher') != 'no') {
        if ($_COOKIE['switch_mode'] == 'mobile') {
            if (($key = array_search('is-desktop', $classes)) !== false) {
                unset($classes[$key]);
            }
            $classes[] = 'is-mobile';
        } else {
            if (($key = array_search('is-mobile', $classes)) !== false) {
                unset($classes[$key]);
            }
            $classes[] = 'is-desktop';
        }
    }
    // is bbpress active
    if (buddyboss_is_bp_active()) {
        $classes[] = 'bp-active';
    }
    // is panel active
    if (isset($_COOKIE['left-panel-status'])) {
        if ($_COOKIE['left-panel-status'] == 'open') {
            $classes[] = 'left-menu-open';
        }
    } elseif (get_option('buddyboss_panel_state') != 'closed') {
        $classes[] = 'left-menu-open';
    }
    // is global media page
    if (function_exists('buddyboss_media') && buddyboss_media()->option('all-media-page') && is_page(buddyboss_media()->option('all-media-page'))) {
        $classes[] = 'buddyboss-media-all-media';
    }
    //hide buddypanel
    if (get_option('buddyboss_panel_hide') == '0' && !is_user_logged_in()) {
        $classes[] = 'page-template-page-no-buddypanel';
        $classes[] = 'left-menu-open';
    }
    if (is_page_template('page-no-buddypanel.php')) {
        $classes[] = 'left-menu-open';
    }
    return array_unique($classes);
}
示例#20
0
        <h2><a href="<?php 
the_permalink(' ');
?>
" title="<?php 
the_title();
?>
"><span class="masonry-post-title"> <?php 
the_title();
?>
</span></a></h2>

        <?php 
//put the excerpt markup in variable so we don't have to repeat it multiple times.
$excerpt = '<div class="masonry-post-excerpt">';
$excerpt .= the_excerpt();
$excerpt .= '</div><!--.masonry-post-excerpt-->';
//if we can only skip for phones, else skip for all mobile devices
if (function_exists('is_phone')) {
    if (!is_phone()) {
        echo $excerpt;
    }
} else {
    if (!wp_is_mobile()) {
        echo $excerpt;
    }
}
?>
    </div><!--/.masonry-entry-details -->  
</article><!--/.masonry-entry-->
示例#21
0
    function login()
    {
        global $app, $_G;
        if ($_G[uid]) {
            msg('您已登录,请退出后再进行操作', 'error', 'm=index');
        }
        if ($_GET[username] && $_GET[login_submit] && check()) {
            $username = daddslashes(trim($_GET[username]));
            $password = daddslashes(trim($_GET[password]));
            if (!$username || trim($username) == '') {
                msg('抱歉,用户名不能为空', 'error', '?');
                return false;
            }
            if (!$password) {
                msg('抱歉,密码不能为空', 'error', '?');
                return false;
            }
            if ($_G[setting][login_yzm] && !check_yzm($_GET[yzm])) {
                msg('验证码效验失败,请重新输入', 'error', '?');
                return false;
            }
            if (strpos($username, '@') !== false) {
                $name = 'email';
            } elseif (is_phone($username)) {
                $name = 'phone';
            } else {
                $name = 'username';
            }
            $user = getuser($username, $name);
            if (!$user[uid]) {
                msg('账号不存在', 'error', '?');
            }
            if ($user[groupid] == 3) {
                msg('抱歉,您的账户已禁止,无法登录,如有疑问,请联系客服', 'error', '?');
                return false;
            } elseif ($user[check] == 0) {
                msg('抱歉,您的账户未审核,无法登录', 'error', '?');
                return false;
            } elseif ($user['end_time'] > 0 && $user['end_time'] < TIMESTAMP) {
                msg('登录失败,您当前账号已到期,无法登录');
            }
            if ($_GET[type] == 'seller' && $user[groupid] != 4) {
                msg('抱歉,您的账户非商家用户,无法登录', 'error', '?');
            }
            if (!$user['password'] && $user['login_id']) {
                msg('登录失败,您当前账号为' . $user['login_name'] . '登录账号,需要从' . $user['login_name'] . '登录');
            }
            if ($user[uid] > 0 && authcode($user[password], 'decode', $user['key']) == $password) {
                $update = array('login_time' => TIMESTAMP, 'login_ip' => $_G['clientip'], 'login_count' => $user[login_count] + 1);
                $_G[member] = $user;
                $_G[member][group] = $_G[group][$user[groupid]];
                $_G[uid] = $user[uid];
                $_G[groupid] = $user[groupid];
                if ($user[groupid] == 1) {
                    $_G[adminid] = 1;
                }
                $_G[username] = $user[username];
                update_group($user);
                $auth = authcode($user[uid] . '|' . $user[password], 'encode', '', $this->login_time);
                DB::update('member', $update, "uid=" . $user[uid]);
                dsetcookie("auth", $auth, $this->login_time);
                $referer = $_GET['referer'] ? $_GET['referer'] : dreferer();
                if (preg_match("/member/is", $referer)) {
                    $referer = URL . 'm=home';
                }
                $ext = '<script type="text/javascript">											
												setTimeout(function(){
													location.href = "' . $referer . '";
												},2000);
											</script>';
                msg('登录成功,欢迎您回来 ' . $user[username], 'success', $referer, $ext);
            } else {
                msg('用户不存在或密码不正确', 'error', 'm=member&a=login');
            }
        }
        $this->show('member/login');
    }
 public function checkPhone()
 {
     $phone = I('phone', '');
     if (empty($phone)) {
         $this->ajaxReturn(array('code' => 0, 'msg' => '手机号码不存在'));
         return;
     }
     if (!is_phone($phone)) {
         $this->ajaxReturn(array('code' => 0, '手机号码格式不正确'));
         return;
     }
     $count = $this->userModel->where("phone={$phone}")->count();
     if ($count) {
         $this->ajaxReturn(array('code' => 1, 'msg' => '该手机号已被注册'));
         return;
     } else {
         $this->ajaxReturn(array('code' => 0, 'msg' => '该手机号未被注册'));
         return;
     }
 }
示例#23
0
 private function _validate_userinfo(&$data)
 {
     if (isset($data['username'])) {
         $data['username'] = strtolower(trim($data['username']));
         if (!is_username($data['username'])) {
             return '用户名不合法';
         }
     }
     if (isset($data['email'])) {
         $data['email'] = strtolower(trim($data['email']));
         if (!$data['email']) {
             return 'Email不合法';
         }
     }
     if (isset($data['phone'])) {
         $data['phone'] = (int) $data['phone'];
         if (!is_phone($data['phone'])) {
             return '手机号不合法';
         }
     }
     if (isset($data['password'])) {
         if (!is_password($data['password'])) {
             return '密码不合法';
         }
     }
     if (isset($data['qq'])) {
         $data['qq'] = (int) $data['qq'];
         !is_qq($data['qq']) && ($data['qq'] = 0);
     }
     isset($data['wechat']) && !is_wechat($data['wechat']) && ($data['wechat'] = '');
     return true;
 }
示例#24
0
文件: user.class.php 项目: nanfs/lt
 public function get_user_by_username($username)
 {
     global $_M;
     $user = $this->get_user_by_username_sql($username);
     if (!$user) {
         load::sys_func('str');
         if (is_email($username)) {
             $user = $this->get_user_by_email($username);
         }
         if (is_phone($username)) {
             $user = $this->get_user_by_tel($username);
         }
         //if($user)$this->get_user_by_username($user['username']);
     }
     return $this->analyze($user);
 }
示例#25
0
 public function postInvite($id)
 {
     $this->projectId = $id = (int) $id;
     if (!$this->getProjectPermission('setting')) {
         return response()->json(['status' => false, 'message' => '没有权限进行此操作']);
     }
     $input = (string) request()->input('input');
     if (is_email($input)) {
         $type = 'email';
     } else {
         if (is_phone($input)) {
             $type = 'phone';
         } else {
             return response()->json(['status' => false, 'message' => '请输入正确的手机号或邮箱']);
         }
     }
     $user = User::hasBeenUsed($type, $input)->first();
     $invite = new ProjectInvite();
     $invite->user_id = auth()->id();
     $invite->project_id = $this->projectId;
     $invite->invite_code = substr(str_shuffle('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'), rand(0, 27), 8);
     $invite->{'invited_user_' . $type} = $input;
     if ($user) {
         $invite->invited_user_id = $user->id;
         if ($type == 'email' && $user->phone) {
             $invite->invited_user_phone = $user->phone;
         } else {
             if ($type == 'phone' && $user->email) {
                 $invite->invited_user_email = $user->email;
             }
         }
     }
     $invite->save();
     if ($user) {
         if (!ProjectMember::where('project_id', $this->projectId)->where('user_id', $user->id)->exists()) {
             $projectMember = new ProjectMember();
             $projectMember->user_id = $user->id;
             $projectMember->user_name = $user->realname;
             $projectMember->project_id = $this->projectId;
             $projectMember->save();
             return response()->json(['status' => true, 'message' => '受邀用户成功加入项目组', 'data' => ['home' => url('user/' . $user->id), 'face' => oss_face_url($user->face, 's'), 'name' => $user->realname, 'id' => $user->id, 'isMaster' => $this->getProject()->user_id == auth()->id()], 'send' => url('project/' . $this->projectId . '/send-invite'), 'send_data' => ['invite_id' => $invite->id]]);
         } else {
             $invite->delete();
             return response()->json(['status' => false, 'message' => '受邀用户已经在项目组了']);
         }
     } else {
         return response()->json(['status' => true, 'message' => '你的邀请已发送', 'send' => url('project/' . $this->projectId . '/send-invite'), 'send_data' => ['invite_id' => $invite->id]]);
     }
 }
 function checkphone()
 {
     $phone = isset($_POST['phone']) ? $_POST['phone'] : 0;
     if (!$phone) {
         $this->json_error("手机号码不存在");
         return;
     }
     if (!is_phone($phone)) {
         $this->json_error("手机号码格式不正确");
         return;
     }
     $member =& m("member");
     $info = $member->get("phone_mob='{$phone}'");
     if (!$info) {
         $this->json_error("手机号码不存在");
         return;
     } else {
         $this->json_result("手机验证码发送成功");
     }
 }
示例#27
0
function is_wechat($str)
{
    return is_phone($str) || preg_match('/^\\w[\\w\\d\\-\\_]{5,19}$/', $str);
}