public function Action_register() { if (!$this->login()) { $model = new Model_user(' ', ' ', ' '); if ($model->new_user()) { header('Location: /user/sing_in'); } else { header('Location: /user/sing_up'); } } else { header('Location: /'); } }
private function display_profile() { global $rep, $views; $user = Model_user::getUserById($_SESSION["id"]); $adventures = Model_adventure::getUserAdventures($_SESSION["id"]); require $rep . $views["profile"]; }
public static function _validation_no_exit_username_in_db($data) { $options = array('where' => array(array('username', $data))); $alldata = Model_user::find('all', $options); if (count($alldata) >= 1) { return false; } return true; }
/** * 个人信息 */ public function userinfoAction() { if ($this->isPost()) { $aParam = $this->getParams(); $aParam['iUserID'] = $this->aCurrUser['iUserID']; $aUser = Model_User::getDetail($aParam['iUserID']); $aErr = array(); // if (empty($aParam['sEmail']) || ! Util_Validate::isEmail($aParam['sEmail'])) { // $aErr['sEmail'] = '邮箱格式不正确'; // } if (empty($aParam['sMobile']) || !Util_Validate::isMobile($aParam['sMobile'])) { $aErr['sMobile'] = '手机号码格式不正确'; } if ($aUser['sEmail'] != $aParam['sEmail'] && Model_User::getUserByEmail($aParam['sEmail'], $aParam['iType'], $aParam['iUserID'])) { $aErr['sEmail'] = '该邮箱已经被注册了'; } if ($aUser['sMobile'] != $aParam['sMobile'] && Model_User::getUserByMobile($aParam['sMobile'], $aParam['iType'], $aParam['iUserID'])) { $aErr['sMobile'] = '该手机号码已经被注册了'; } if (!Util_Validate::isCLength($aParam['sRealName'], 2, 5)) { $aErr['sRealName'] = '姓名长度为2-5个汉字!'; } if (!Util_Validate::isLength($aParam['sWeixin'], 4, 50)) { $aErr['sWeixin'] = '请输入正确的微信号'; } if (!Util_Validate::isQQ($aParam['sQQ'])) { $aErr['sQQ'] = 'QQ号码输入不正确'; } if (!empty($aErr)) { return $this->showMsg($aErr, false); } Model_User::updData($aParam); return $this->showMsg('个人信息修改成功!', true); } else { $aUser = Model_user::getDetail($this->aCurrUser['iUserID']); $this->assign('aUser', $aUser); $this->assign('iTabID', 2); $this->setMeta('mcenter_page', array('sTitle' => '自媒体中心 - 个人资料')); } }
public static function sign_up($username, $password, $role, $email, $country) { DAL::addUser(Cleaning::cleanString($username), Cleaning::cleanString($password), Cleaning::cleanEmail($email), $role, 0, $country); Model_user::sign_in($username, $password); }
private function display_addpage() { global $rep, $views; $countries = Model_user::get_countries(); require $rep . $views['add_adventure']; }
private function sign_out() { Model_user::sign_out(); $_REQUEST['action'] = NULL; //to make it easier to come back to the home page $cont = new FrontController(); }
private function display_profile() { global $rep, $views; $user_id = isset($_GET['id_user']) ? $_GET['id_user'] : ''; $user = Model_user::getUserById($user_id); $adventures = Model_adventure::getUserAdventures($user_id); require $rep . $views["profile"]; }
public function forgot_password() { $Model_user = new Model_user(); $this->customvalidateForgotForm(); $userkey = $this->superKey(); if (!$this->form_validation->run()) { $this->load->view('header'); $this->load->view('forgot_password'); $this->load->view('footer'); } else { $email = $this->input->post('email'); $password = random_string('alnum', 16); $superkey = $this->encrypt->sha1($userkey . $password); $ifUserActivated = $Model_user->userActivated($email); $captcha = $this->input->post('g-recaptcha-response'); if (!$captcha) { $form_message = '<div class="kode-alert kode-alert kode-alert-icon kode-alert-click alert6"><i class="fa fa-lock"></i>Please check the captcha form!.<a href="#" class="closed">×</a></div>'; $this->load->view('header'); $this->load->view('forgot_password', array('form_message' => $form_message)); $this->load->view('footer'); } else { $secretKey = "6LcMzRwTAAAAAMj1ENuYhur5H67mc8dXSfa_cFIy"; $ip = $_SERVER['REMOTE_ADDR']; $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=" . $secretKey . "&response=" . $captcha . "&remoteip=" . $ip); $responseKeys = json_decode($response, true); if (intval($responseKeys["success"]) !== 1) { echo '<h2></h2>'; } else { echo '<h2></h2>'; } if ($ifUserActivated > 0) { $regResult = $Model_user->forgotPassword($email, $superkey); if ($regResult == 1) { $resultSend = $this->forgotpassword_sendmail($email, $password); $form_message = ' <div class="kode-alert kode-alert kode-alert-icon kode-alert-click alert3"><i class="fa fa-lock"></i>' . $resultSend . '<a href="#" class="closed">×</a></div>'; $this->load->view('header'); $this->load->view('forgot_password', array('form_message' => $form_message)); $this->load->view('footer'); } else { $form_message = '<div class="kode-alert kode-alert kode-alert-icon kode-alert-click alert6"><i class="fa fa-lock"></i>Fail!<a href="#" class="closed">×</a></div>'; $this->load->view('header'); $this->load->view('forgot_password', array('form_message' => $form_message)); $this->load->view('footer'); } } else { $form_message = '<div class="kode-alert kode-alert kode-alert-icon kode-alert-click alert6"><i class="fa fa-lock"></i>Invalid Account/The account is not yet activated.!<a href="#" class="closed">×</a></div>'; $this->load->view('header'); $this->load->view('forgot_password', array('form_message' => $form_message)); $this->load->view('footer'); } } } }
/** * 修改用户信息 */ public function chginfoAction() { if ($this->isPost()) { $aParam = $this->getParams(); $aUser = Model_User::getDetail($aParam['iUserID']); $aErr = array(); if (empty($aParam['sEmail']) || !Util_Validate::isEmail($aParam['sEmail'])) { $aErr['sEmail'] = '登录邮箱格式不正确!'; } if (empty($aParam['sMobile']) || !Util_Validate::isMobile($aParam['sMobile'])) { $aErr['sMobile'] = '手机号码格式不正确!'; } if ($aUser['sEmail'] != $aParam['sEmail'] && Model_User::getUserByEmail($aParam['sEmail'], $aParam['iType'], $aParam['iUserID'])) { $aErr['sEmail'] = '该邮箱已经被注册了!'; } if ($aUser['sMobile'] != $aParam['sMobile'] && Model_User::getUserByMobile($aParam['sMobile'], $aParam['iType'], $aParam['iUserID'])) { $aErr['sMobile'] = '该手机号码已经被注册了!'; } if (!Util_Validate::isCLength($aParam['sCoName'], 1, 50)) { $aErr['sCoName'] = '企业名称长度为1-50个汉字!'; } if (!Util_Validate::isCLength($aParam['sRealName'], 2, 5)) { $aErr['sRealName'] = '联系人名称长度为2-5个汉字!'; } if (!Util_Validate::isAbsoluteUrl($aParam['sCoWebsite'])) { $aErr['sCoWebsite'] = '网址格式不正确!'; } if (!Util_Validate::isCLength($aParam['sCoDesc'], 2, 200)) { $aErr['sCoDesc'] = '公司介绍长度为2-500个汉字!'; } if (empty($aParam['sWeixin'])) { $aErr['sWeixin'] = '请输入你的微信号!'; } if (!Util_Validate::isQQ($aParam['sQQ'])) { $aErr['sQQ'] = 'QQ号码输入不正确!'; } if (!empty($aErr)) { return $this->showMsg($aErr, false); } Model_User::updData($aParam); return $this->showMsg('个人信息修改成功!', true); } else { $iType = $this->getParam('type'); $aUser = $this->getCurrUser($iType); if (empty($aUser)) { return $this->show404(); } $aUser = Model_user::getDetail($aUser['iUserID']); $aIndustry = Model_Domain::getOption(Model_Domain::TYPE_CO_INDUSTRY); $this->assign('aUser', $aUser); $this->assign('aIndustry', $aIndustry); } }