本文整理汇总了PHP中user_md5函数的典型用法代码示例。如果您正苦于以下问题:PHP user_md5函数的具体用法?PHP user_md5怎么用?PHP user_md5使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_md5函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
/**
* 用户登录
* @author jry <598821125@qq.com>
*/
public function login($username, $password, $map)
{
//去除前后空格
$username = trim($username);
//匹配登录方式
if (preg_match("/^([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+\$/", $username)) {
$map['email'] = array('eq', $username);
// 邮箱登陆
} elseif (preg_match("/^1\\d{10}\$/", $username)) {
$map['mobile'] = array('eq', $username);
// 手机号登陆
} else {
$map['username'] = array('eq', $username);
// 用户名登陆
}
$map['status'] = array('eq', 1);
$user_info = $this->where($map)->find();
//查找用户
if (!$user_info) {
$this->error = '用户不存在或被禁用!';
} else {
if (user_md5($password) !== $user_info['password']) {
$this->error = '密码错误!';
} else {
return $user_info;
}
}
return false;
}
示例2: edit
/**
* 编辑用户
* @author jry <598821125@qq.com>
*/
public function edit($id)
{
//获取用户信息
$info = D('User')->find($id);
if (IS_POST) {
$user_object = D('User');
//不修改密码时销毁变量
if ($_POST['password'] == '' || $info['password'] == $_POST['password']) {
unset($_POST['password']);
} else {
$_POST['password'] = user_md5($_POST['password']);
}
//不允许更改超级管理员用户组
if ($_POST['id'] == 1) {
unset($_POST['group']);
}
if ($_POST['extend']) {
$_POST['extend'] = json_encode($_POST['extend']);
}
if ($user_object->save($_POST)) {
$this->success('更新成功', U('index'));
} else {
$this->error('更新失败', $user_object->getError());
}
} else {
$user_object = D('User');
$info = $user_object->find($id);
//使用FormBuilder快速建立表单页面。
$builder = new \Common\Builder\FormBuilder();
$builder->setMetaTitle('编辑用户')->setPostUrl(U('edit'))->addFormItem('id', 'hidden', 'ID', 'ID')->addFormItem('usertype', 'radio', '用户类型', '用户类型', $user_object->user_type())->addFormItem('group', 'select', '部门', '所属部门', select_list_as_tree('UserGroup', null, '默认部门'))->addFormItem('username', 'text', '用户名', '用户名')->addFormItem('email', 'text', '邮箱', '邮箱')->addFormItem('mobile', 'text', '手机号码', '手机号码')->addFormItem('password', 'password', '密码', '密码')->addFormItem('avatar', 'picture', '用户头像', '用户头像')->addFormItem('vip', 'radio', 'VIP等级', 'VIP等级', $user_object->user_vip_level())->setFormData($info)->display();
}
}
示例3: signin
public function signin()
{
if (IS_POST) {
$username = $this->_post('username');
$password = $this->_post('password');
$verify = $this->_post('verify');
if (!$username || !$password || !$verify) {
$this->error('参数错误!');
}
/* 检测验证码 TODO: */
if (!Verify::check(@$verify)) {
$this->error('验证码输入错误!');
}
$db = M('admins');
$map['username'] = $username;
$map['status'] = 1;
$user = $db->where($map)->find();
if (!$user) {
$this->error('帐号不存在或被禁用');
}
if ($user['password'] != user_md5($password . $user['salt'])) {
$this->error('密码错误');
}
$data = array('id' => $user['id'], 'login' => array('exp', '`login`+1'), 'last_login_time' => NOW_TIME, 'last_login_ip' => get_client_ip());
$db->save($data);
/* 记录登录SESSION和COOKIES */
$auth = array('uid' => $user['id'], 'username' => $user['username'], 'last_login_time' => $data['last_login_time']);
session('admins', $auth);
session('admins_sign', data_auth_sign($auth));
$this->success('登录成功,正在进入...', U('index/index'));
} else {
$this->redirect('index');
exit;
}
}
示例4: changePassword
/**
* 修改密码
*/
public function changePassword()
{
if (IS_POST) {
$A = M('Advertiser');
$oldPw = I('post.old_pw');
$pw = I('post.ad_pw');
$pw2 = I('post.ad_pw2');
$ad_seq = $this->getId();
$ad = $A->find($ad_seq);
if (user_md5($oldPw) !== $ad['ad_pw']) {
$this->error('旧密码输入有误', U('Advertiser/changePassword'));
}
if ($pw != $pw2) {
$this->error('新密码输入有误', U('Advertiser/changePassword'));
}
$pw = user_md5($pw);
$w = array();
$w['ad_seq'] = $this->getId();
$w['ad_pw'] = $pw;
if ($A->save($w)) {
$this->success('修改成功', U('Advertiser/changePassword'));
} else {
$this->error('修改失败', U('Advertiser/changePassword'));
}
} else {
$this->assign('changePassword', 'on');
$this->display();
}
}
示例5: reg
function reg($data)
{
if (!$data['email']) {
return array('status' => 0, 'msg' => L('email_require'));
}
if (!$data['password']) {
return array('status' => 0, 'msg' => L('password_require'));
}
if ($this->check_user($data['email']) > 0) {
return array('status' => 0, 'msg' => '用户已经存在,登录邮箱不能重复。');
}
// 用于写入的数组
$indata = array();
$indata = $data;
$indata['regtime'] = time();
$indata['regip'] = get_client_ip();
$indata['status'] = 1;
$indata['salt'] = user_salt();
$indata['password'] = user_md5($data['password'], $indata['salt']);
$insertId = $this->add($indata);
// 写入记录
if ($insertId) {
return array('status' => 1, 'msg' => '注册成功!', 'userid' => $insertId);
}
return array('status' => 0, 'msg' => '注册失败,请重试。');
}
示例6: login
/**
* 用户登录
* @author jry <598821125@qq.com>
*/
public function login($username, $password, $map)
{
//去除前后空格
$username = trim($username);
//匹配登录方式
if (preg_match("/^([a-zA-Z0-9_\\.\\-])+\\@(([a-zA-Z0-9\\-])+\\.)+([a-zA-Z0-9]{2,4})+\$/", $username)) {
$map['email'] = array('eq', $username);
//邮箱登陆
} elseif (preg_match("/^1\\d{10}\$/", $username)) {
$map['mobile'] = array('eq', $username);
//手机号登陆
} else {
$map['username'] = array('eq', $username);
//用户名登陆
}
$map['status'] = array('eq', 1);
$user = $this->where($map)->find();
//查找用户
if (!$user) {
$this->error = '用户不存在或被禁用!';
} else {
if (user_md5($password) !== $user['password']) {
$this->error = '密码错误!';
} else {
//更新登录信息
$data = array('id' => $user['id'], 'login' => array('exp', '`login`+1'), 'last_login_time' => NOW_TIME, 'last_login_ip' => get_client_ip(1));
$this->save($data);
$this->autoLogin($user);
return $user['id'];
}
}
return false;
}
示例7: register_administrator
function register_administrator($db, $prefix, $admin, $auth)
{
$sql = "INSERT INTO `[PREFIX]ucenter_member` VALUES " . "('1', '[NAME]', '[PASS]', '[EMAIL]', '', '[TIME]', '[IP]', 0, 0, '[TIME]', '1')";
$password = user_md5($admin['admin_pass'], $auth);
$sql = str_replace(array('[PREFIX]', '[NAME]', '[PASS]', '[EMAIL]', '[TIME]', '[IP]'), array($prefix, $admin['admin_user'], $password, $admin['admin_email'], NOW_TIME, get_client_ip(1)), $sql);
//执行sql
$db->execute($sql);
$sql = "INSERT INTO `[PREFIX]member` VALUES " . "('1', '[NAME]', '0', '0000-00-00', '', '0', '1', '0', '[TIME]', '0', '[TIME]', '1','',0,0,0,0,0);";
$sql = str_replace(array('[PREFIX]', '[NAME]', '[TIME]'), array($prefix, $admin['admin_user'], NOW_TIME), $sql);
$db->execute($sql);
return true;
}
示例8: _before_update
public function _before_update($data)
{
if ($data['id'] == '1' and $data['status'] == 0) {
$this->error('最后一个了,状态不能禁用哦');
exit;
}
$info = $this->_mod->find($data['id']);
if ($info['password'] != $data['password']) {
!$info['salt'] && ($data['salt'] = $info['salt'] = user_salt());
$data['password'] = user_md5($data['password'] . $info['salt']);
}
return $data;
}
示例9: download
/**
* 下载
* @author jry <598821125@qq.com>
*/
public function download($token)
{
if (empty($token)) {
$this->error('token参数错误!');
}
//解密下载token
$file_md5 = \Think\Crypt::decrypt($token, user_md5(is_login()));
if (!$file_md5) {
$this->error('下载链接已过期,请刷新页面!');
}
$public_upload_object = D('PublicUpload');
$file_id = $public_upload_object->getFieldByMd5($file_md5, 'id');
if (!$public_upload_object->download($file_id)) {
$this->error($public_upload_object->getError());
}
}
示例10: add_user
public function add_user($data)
{
if (in_array('', $data)) {
return array('status' => 0, 'msg' => '内容不完整');
}
// 再次检查是否重复
if ($this->field_exists($data['username'])) {
return array('status' => 0, 'msg' => sprintf(L('is_exist'), L('username')));
}
// 处理密码
$data['salt'] = user_salt();
$data['password'] = user_md5($data['password'], $data['salt']);
if ($this->add($data)) {
return array('status' => 1, 'msg' => L('operation_success'));
}
}
示例11: login
/**
* 用户登录
*/
public function login($mb_tel, $mb_pw, $map)
{
$mb_tel = trim($mb_tel);
$map['mb_tel'] = array('eq', $mb_tel);
$mb = $this->where($map)->find();
if (!$mb) {
$this->error = '用户名不存在或被禁用!';
} else {
if (user_md5($mb_pw) !== $mb['mb_pw']) {
$this->error = '密码错误!';
} else {
$data = array('mb_seq' => $mb['mb_seq'], 'mb_login' => NOW_TIME, 'mb_login_ip' => get_client_ip(1));
$this->save($data);
$this->autoLogin($mb);
return $mb['mb_seq'];
}
}
return false;
}
示例12: login
/**
* 用户登录
*/
public function login($ad_id, $ad_pw, $map)
{
$ad_id = trim($ad_id);
$map['ad_id'] = array('eq', $ad_id);
$map['ad_status'] = array('eq', 1);
$adv = $this->where($map)->find();
if (!$adv) {
$this->error = '用户不存在或被禁用!';
} else {
if (user_md5($ad_pw) !== $adv['ad_pw']) {
$this->error = '密码错误!';
} else {
# 更新登录信息
$data = array('ad_seq' => $adv['ad_seq'], 'ad_login_times' => array('exp', '`ad_login_times`+1'), 'ad_login' => NOW_TIME, 'ad_login_ip' => get_client_ip(1));
$this->save($data);
$this->autoLogin($adv);
return $adv['ad_seq'];
}
}
return false;
}
示例13: login
/**
* 用户登录
*/
public function login($adm_id, $adm_pw, $map)
{
$adm_id = trim($adm_id);
$map['adm_id'] = array('eq', $adm_id);
# 查找用户
$admin = $this->where($map)->find();
if (!$admin) {
$this->error = '管理员不存在或被禁用!';
} else {
if (user_md5($adm_pw) !== $admin['adm_pw']) {
$this->error = '密码错误!';
} else {
# 更新登录信息
$data = array('adm_seq' => $admin['adm_seq'], 'adm_login' => NOW_TIME, 'adm_login_ip' => get_client_ip(1));
$this->save($data);
$this->autoLogin($admin);
return $admin['adm_seq'];
}
}
return false;
}
示例14: register_administrator
function register_administrator($db, $prefix, $admin, $auth)
{
show_msg('开始注册创始人帐号...');
$sql = "UPDATE `[PREFIX]ucenter_member` " . "set `username`='[NAME]', `password`='[PASS]', `email`='[EMAIL]', `last_login_time`= '[TIME]', `last_login_ip`='[IP]', `update_time`='[TIME]'";
$password = user_md5($admin['password'], $auth);
$sql = str_replace(array('[PREFIX]', '[NAME]', '[PASS]', '[EMAIL]', '[TIME]', '[IP]'), array($prefix, $admin['username'], $password, $admin['email'], NOW_TIME, get_client_ip(1)), $sql);
//执行sql
$db->execute($sql);
// $sql = "INSERT INTO `[PREFIX]member` VALUES ".
// "('1', '[NAME]','', '[NAME]', '0', '0', '', '0', '1', '0', '[TIME]', '0', '[TIME]','[TIME]', '1');";
// $sql = str_replace(
// array('[PREFIX]', '[NAME]', '[TIME]'),
// array("common_", $admin['username'], NOW_TIME),
// $sql);
// $db->execute($sql);
show_msg('创始人帐号注册完成!');
}
示例15: find
/**
*
* 找回密码
*/
public function find()
{
if (IS_POST) {
$code = $_POST['verify_code'];
unset($_POST['verify_code']);
// 验证码判断
$verify = session('shop_verify_find_code');
if (empty($verify)) {
$this->error('没有获取验证码');
}
$verifyCode = $verify['code'];
$verifyTime = $verify['time'];
if (time() > $verifyTime + 60) {
//$this->error('验证码过期');
}
// 验证码判断
if ($code != $verifyCode) {
$this->error('验证码不正确');
}
$ad_tel = I('post.ad_tel');
// 验证码判断
//echo '='.$ad_tel.'='.$verify['mobile'].'=';exit;
if ($ad_tel != $verify['mobile']) {
$this->error('验证码与手机号不匹配');
session('shop_verify_find_code', null);
}
session('shop_verify_find_code', null);
$Ad = D('Advertiser');
$tel = I('post.ad_tel');
$pw = I('post.ad_pw');
$pw2 = I('post.ad_pw2');
if (!$tel) {
$this->error('请输入手机号', U('Login/find'));
}
if (mb_strlen($pw) < 6 || mb_strlen($pw) > 24) {
$this->error('密码长度为6-24位', U('Login/find'));
}
if ($pw != $pw2) {
$this->error('两次输入的密码不一致', U('Login/find'));
}
if (!preg_match("/^1\\d{10}\$/", $tel)) {
$this->error("手机格式不正确", U('Login/find'));
}
$pattern = '/(?!^(\\d+|[a-zA-Z]+|[~!@#$%^&*()_+{}:"<>?\\-=[\\];\',.\\/]+)$)^[\\w~!@#$%^&*()_+{}:"<>?\\-=[\\];\',.\\/]+$/';
if (!preg_match($pattern, $pw)) {
$this->error('密码至少由数字、字符、特殊字符三种中的两种组成', U('Login/find'));
}
$where = array('ad_tel' => $tel);
$adInfo = $Ad->where($where)->find();
if (count($adInfo)) {
$data = array();
$data['ad_seq'] = $adInfo['ad_seq'];
$data['ad_pw'] = user_md5($pw);
$result = $Ad->save($data);
if ($result) {
$this->success("修改密码成功", U('Login/login'));
} else {
$this->error("修改密码失败", U('Login/find'));
}
} else {
$this->error("不存在此手机号", U('Login/find'));
}
} else {
//$verify = session('shop_verify_find_code');
//p($verify);
$this->display();
}
}