public function register($email, $uname, $password, $is_init = 0) { // 检查站点是否关闭注册 $register_option = model('Xdata')->get('register:register_type'); if (strtolower($register_option) == 'closed') { $this->last_error = '网站关闭注册'; return false; } // 检查参数合法性 if (!isEmailAvailable($email)) { $this->last_error = 'Email不合法或已存在'; return false; } if (!isUnameAvailable($uname)) { $this->last_error = '昵称不合法或已存在'; return false; } if (!isValidPassword($password)) { $this->last_error = '密码不合法'; return false; } // 参数合法. So, continue... $uid = $this->_addUser($email, $uname, $password, $is_init); if (!$uid) { $this->last_error = 'Có lỗi phát sinh khi lưu'; return false; } $this->_addUserToMyopLog($uid); $this->_syncUCenter($uid, $email, $uname, $password); return $uid; }
require 'model/functions.fn.php'; /******************************** PROCESS ********************************/ if (isset($_POST) && !empty($_POST)) { $email = $_POST['email']; $password = $_POST['password']; $username = $_POST['username']; /* isEmailAvailable return : true if available false if not available $db -> database object $email -> field value : email */ $email_ok = isEmailAvailable($db, $email); /* isUsernameAvailable return : true if available false if not available $db -> database object $username -> field value : username */ $username_ok = isUsernameAvailable($db, $username); if ($email_ok && $username_ok) { /* userRegistration return : true for registration OK false for fail $db -> database object
<?php require 'config/config.php'; require 'model/functions.fn.php'; session_start(); if (isset($_POST['username']) && isset($_POST['email']) && isset($_POST['password']) && !empty($_POST['username']) && !empty($_POST['email']) && !empty($_POST['password'])) { if (isUsernameAvailable($db, $_POST['username']) === true) { if (isEmailAvailable($db, $_POST['email']) === true) { userRegistration($db, $_POST['username'], $_POST['email'], $_POST['password']); } else { echo "l'email n'est pas disponible"; } } else { echo 'l\'username est deja n\'est pas disponible'; } } else { $_SESSION['message'] = 'Erreur : Formulaire incomplet'; header('Location: register.php'); } echo 'salut ';
session_start(); require 'config/config.php'; require 'model/functions.fn.php'; /******************************** PROCESS ********************************/ if (isset($_POST)) { if (isset($_POST['email']) && !empty($_POST['email']) && isset($_POST['username']) && !empty($_POST['username']) && isset($_POST['password']) && !empty($_POST['password'])) { /* isEmailAvailable return : true if available false if not available $db -> database object $email -> field value : email */ $email_ok = isEmailAvailable($db, $_POST['email']); /* isUsernameAvailable return : true if available false if not available $db -> database object $username -> field value : username */ $username_ok = isUsernameAvailable($db, $_POST['username']); if ($email_ok == true && $username_ok == true) { /* userRegistration return : true for registration OK false for fail $db -> database object $username -> field value : username
<?php require 'config/config.php'; require 'model/functions.fn.php'; session_start(); if (isset($_POST['username']) && isset($_POST['email']) && isset($_POST['password']) && !empty($_POST['username']) && !empty($_POST['email']) && !empty($_POST['password'])) { if (isUsernameAvailable($db, $_POST['username']) && isEmailAvailable($db, $_POST['email'])) { userRegistration($db, $_POST['username'], $_POST['email'], $_POST['password']); header('Location: login.php'); } else { header('Location: register.php'); $_SESSION['message'] = 'Erreur: username ou email déjà pris.'; } } else { $_SESSION['message'] = 'Erreur : Formulaire incomplet'; header('Location: register.php'); }
<?php require 'config/config.php'; require 'model/functions.fn.php'; session_start(); if (isset($_POST['username']) && isset($_POST['email']) && isset($_POST['password']) && !empty($_POST['username']) && !empty($_POST['email']) && !empty($_POST['password'])) { // TODO $username = $_POST["username"]; $password = $_POST["password"]; $email = $_POST["email"]; if (isUsernameAvailable($db, $username) === true) { if (isEmailAvailable($db, $email) === true) { userRegistration($db, $username, $email, $password); $_SESSION['message'] = "bravo !"; header('Location: login.php'); } else { $_SESSION['message'] = "email deja utilisé"; header('Location: register.php'); } } else { $_SESSION['message'] = "username deja utilisé"; header('Location: register.php'); } } else { $_SESSION['message'] = 'Erreur : Formulaire incomplet'; header('Location: register.php'); }
public function modifyEmail() { $_POST['email'] = t($_POST['email']); $_POST['oldemail'] = t($_POST['oldemail']); if (!isValidEmail($_POST['email']) || !isValidEmail($_POST['oldemail'])) { echo -1; return; //$this->error('Email格式错误'); } $map['uid'] = $this->mid; $map['email'] = $_POST['oldemail']; if (!M('user')->where($map)->find()) { echo -2; return; //原始Email错误 } if (!isEmailAvailable($_POST['email'])) { echo -3; return; //$this->error('新Emai已存在'); } $opt_email_activate = model('Xdata')->lget('register'); // 不需要验证邮件时, 直接修改帐号 if (!$opt_email_activate['register_email_activate']) { if (M('user')->where($map)->setField('email', $_POST['email'])) { service('Passport')->logoutLocal(); echo 1; } else { echo 0; } unset($opt_email_activate); exit; } unset($opt_email_activate); // 邮件验证 //添加验证 $data = array('oldemail' => $_POST['oldemail'], 'email' => $_POST['email']); if ($url = service('Validation')->addValidation($this->mid, '', U('home/Public/doModifyEmail'), 'modify_account', serialize($data))) { // 发送验证邮件 global $ts; $body = <<<EOD <strong>{$ts['user']['uname']},你好:</strong><br/> 您只需通过点击下面的链接重置您的帐号:<br/> <a href="{$url}">{$url}</a><br/> 如果通过点击以上链接无法访问,请将该网址复制并粘贴至新的浏览器窗口中。<br/> 如果你错误地收到了此电子邮件,你无需执行任何操作来取消帐号!此帐号将不会启动。 EOD; if (service('Mail')->send_email($_POST['email'], "重置{$ts['site']['site_name']}帐号", $body)) { echo '2'; } else { echo '-4'; } } else { echo '0'; } }
<?php require 'config/config.php'; require 'model/functions.fn.php'; session_start(); if (isset($_POST['username']) && isset($_POST['email']) && isset($_POST['password']) && !empty($_POST['username']) && !empty($_POST['email']) && !empty($_POST['password'])) { // TODO $username = $_POST['username']; $email = $_POST['email']; $password = $_POST['password']; if (isUsernameAvailable($db, $username)) { if (isEmailAvailable($db, $email)) { userRegistration($db, $username, $email, $password); $_SESSION['message'] = 'Successful !'; } else { $_SESSION['message'] = 'email deja utilis�'; } } else { $_SESSION['message'] = 'username deja utilis�'; } header('Location: register.php'); } else { $_SESSION['message'] = 'Erreur : Formulaire incomplet'; header('Location: register.php'); }
session_start(); require 'config/config.php'; require 'model/functions.fn.php'; /******************************** PROCESS ********************************/ if (isset($_POST) && !empty($_POST)) { /* isEmailAvailable return : true if available false if not available $db -> database object $email -> field value : email */ $email_ok = isEmailAvailable($db, "*****@*****.**"); /* isUsernameAvailable return : true if available false if not available $db -> database object $username -> field value : username */ $username_ok = isUsernameAvailable($db, "Git"); if ($email_ok && $username_ok) { /* userRegistration return : true for registration OK false for fail $db -> database object $username -> field value : username
public function doEditUser() { //参数合法性检查 $_POST['uid'] = intval($_POST['uid']); $required_field = array('uid' => '指定用户', 'email' => 'Email', 'uname' => '姓名'); foreach ($required_field as $k => $v) { if (empty($_POST[$k])) { $this->error($v . '不可为空'); } } if (!isValidEmail($_POST['email'])) { $this->error('Email格式错误,请重新输入'); } if (!empty($_POST['password']) && strlen($_POST['password']) < 6 || strlen($_POST['password']) > 16) { $this->error('密码必须为6-16位'); } if (!isEmailAvailable($_POST['email'], $_POST['uid'])) { $this->error('Email已经被使用,请重新输入'); } if (mb_strlen($_POST['uname'], 'UTF8') > 10) { $this->error('昵称不能超过10个字符'); } //保存修改 $_POST['uname'] = escape($_POST['uname']); $key = array('email', 'uname', 'sex', 'is_active', 'domain'); $value = array($_POST['email'], $_POST['uname'], intval($_POST['sex']), intval($_POST['is_active']), h($_POST['domain'])); if (!empty($_POST['password'])) { $key[] = 'password'; $value[] = md5($_POST['password']); } $map['uid'] = $_POST['uid']; $res = M('user')->where($map)->setField($key, $value); //保存积分设置 $credit = X('Credit'); $credit_type = $credit->getCreditType(); foreach ($credit_type as $v) { $credit_action[$v['name']] = intval($_POST[$v['name']]); } $credit->setUserCredit($map['uid'], $credit_action, 'reset'); //添加用户组信息 model('UserGroup')->addUserToUserGroup($_POST['uid'], t($_POST['user_group_id'])); $this->assign('jumpUrl', U('admin/User/user')); $this->success('保存成功'); }
<?php require_once 'config/config.php'; require_once 'model/functions.fn.php'; $postdata = file_get_contents("php://input"); $request = json_decode($postdata); $email = $request->email; $name = $request->name; $password = md5($request->password); $password2 = md5($request->password2); $email_check = isEmailAvailable($db, $email); if (isset($email) && isset($password) && isset($password2) && isset($name)) { if (!empty($email) && !empty($password) && !empty($password2) && !empty($name)) { if ($password === $password2) { if ($email_check !== false) { $connect = userRegistration($db, $name, $email, $password); if ($connect == true) { $result = array('success' => utf8_encode('true'), 'error' => ''); } else { $result = array('success' => utf8_encode('false'), 'error' => utf8_encode('E-mail ou mot de passe incorrect')); } } else { $result = array('success' => utf8_encode('false'), 'error' => utf8_encode('E-mail déjà utilisé !')); } } else { $result = array('success' => utf8_encode('false'), 'error' => utf8_encode('Les mots de passes ne correspondent pas !')); } } else { $result = array('success' => utf8_encode('false'), 'error' => utf8_encode('Vous devez remplir tous les champs !')); } } else {
public function doEditUser() { //参数合法性检查 $_POST['uid'] = intval($_POST['uid']); if (!M('user')->getField('email', "uid={$_POST['uid']}")) { // 非本地Email帐号(即第三方)的用户 unset($_POST['email']); // 无法编辑其Email unset($_POST['password']); // 无法编辑其密码 $required_field = array('uid' => '指定用户', 'uname' => '姓名'); foreach ($required_field as $k => $v) { if (empty($_POST[$k])) { $this->error($v . '不可为空'); } } } else { $required_field = array('uid' => '指定用户', 'email' => 'Email', 'uname' => '姓名'); foreach ($required_field as $k => $v) { if (empty($_POST[$k])) { $this->error($v . '不可为空'); } } if (!isValidEmail($_POST['email'])) { $this->error('Email格式错误,请重新输入'); } if (!isEmailAvailable($_POST['email'], $_POST['uid'])) { $this->error('Email已经被使用,请重新输入'); } if (!empty($_POST['password']) && strlen($_POST['password']) < 6 || strlen($_POST['password']) > 16) { $this->error('密码必须为6-16位'); } } if (mb_strlen($_POST['uname'], 'UTF8') > 10) { $this->error('昵称不能超过10个字符'); } //保存修改 $key = array('email', 'uname', 'sex', 'is_active', 'domain'); $value = array($_POST['email'], escape(h(t($_POST['uname']))), intval($_POST['sex']), intval($_POST['is_active']), h($_POST['domain'])); if (!empty($_POST['password'])) { $key[] = 'password'; $value[] = md5($_POST['password']); } $map['uid'] = $_POST['uid']; $_LOG['uid'] = $this->mid; $_LOG['type'] = '3'; $data[] = '用户 - 用户管理 '; $data[] = M('user')->where($map)->field('uid,email,password,uname,domain,sex,is_active')->find(); $CreditInfo = M('CreditUser')->where($map)->find(); $data['1']["scorea"] = $CreditInfo['scorea'] ? $CreditInfo['scorea'] : '0'; $data['1']["experience"] = $CreditInfo['experience'] ? $CreditInfo['experience'] : '0'; $GroupInfo = M('UserGroupLink')->where($map)->find(); $data['1']['user_group_id'] = $GroupInfo['user_group_id'] ? $GroupInfo['user_group_id'] : '0'; if ($_POST['__hash__']) { unset($_POST['__hash__']); } if (!$_POST['password']) { $_POST['password'] = $data['1']['password']; } $data[] = $_POST; $_LOG['data'] = serialize($data); $_LOG['ctime'] = time(); M('AdminLog')->add($_LOG); $res = M('user')->where($map)->setField($key, $value); //保存积分设置 $credit = X('Credit'); $credit_type = $credit->getCreditType(); foreach ($credit_type as $v) { $credit_action[$v['name']] = intval($_POST[$v['name']]); } $credit->setUserCredit($map['uid'], $credit_action, 'reset'); //添加用户组信息 model('UserGroup')->addUserToUserGroup($_POST['uid'], t($_POST['user_group_id'])); S('UserGroupIds_' . $_POST['uid'], null); $this->assign('jumpUrl', U('admin/User/user')); $this->success('Lưu lại thành công'); }