function auth() { $code = g('code'); require_once ST_MODEL_DIR . 'UserModel.php'; $userModel = new UserModel(); $user = $userModel->loginOrRegisterUserByCode($code); if ($userModel->getError()) { die($userModel->getErrorMessage()); } if ($user) { Http::redirect('/'); } else { Http::redirect('loginError'); } }
public function testModifyUserById() { $table = new UserModel(); $ret = $table->getUserByPhone('222222'); $table->modifyUserById($ret['id'], null, '李四改', '武汉', 'abc123', 'abc123', 'tmp.jpg'); $ret = $table->getUserById($ret['id']); $this->assertTrue($ret['phone'] == '222222' && $ret['nickname'] == '李四改' && $ret['address'] == '武汉' && $ret['img'] == 'tmp.jpg'); $ret = $table->getUserByPhone('222222'); $ret = $table->modifyUserById($ret['id'], '111111'); $this->assertTrue($ret == false); $this->assertTrue($table->getError()['phone'] == '手机号码已被注册'); $ret = $table->modifyUserById($ret['id'], null, '真图'); $this->assertTrue($ret == false); $this->assertTrue($table->getError()['nickname'] == '昵称不能用'); $ret = $table->getUserByPhone('222222'); $table->modifyUserById($ret['id'], null, '李四改改', '武汉', 'abc123', 'bb', 'tmp.jpg'); $this->assertTrue($table->getError()['repassword'] == '两次输入密码不一致'); }
public function saveuserinfo() { $id = session('userid'); if (!empty($id)) { $user = new UserModel(); $data = $user->create(); if (false !== $user->save()) { $this->message2('编辑成功', 'reinfo'); } else { $this->message2('编辑失败' . $user->getError(), 'reinfo'); } } else { $this->message2('请选择编辑对象', __URL__ . '/index'); } }
public function passsave() { $user = new UserModel(); $id = I('id', 0); if ($data = $user->create()) { if (0 < $id) { $data['password'] = md5($data['password']); if (false !== $user->where('id=\'' . $id . '\'')->data($data)->save()) { $this->message('操作成功', __URL__ . '/index'); } else { $this->message('操作失败:' . $user->getDbError(), __URL__ . '/index'); } } else { $this->message('请选择编辑用户', __URL__ . '/index'); } } else { $this->message('操作失败:数据验证( ' . $user->getError() . ' )', __URL__ . '/index'); } }
/** * 更新 个人资料 */ function update_profile() { $user = new UserModel(); $username = $_SESSION['username']; $userinfo = $user->getByUsername($username); //如果旧密码正确 if (md5($_POST['old_password']) == $userinfo['password']) { if (!!($data = $user->create())) { if ($user->save() !== false) { $this->assign('jumpUrl', __APP__ . '/Manage/index'); $this->success('修改个人资料成功'); } else { $this->assign('jumpUrl', __URL__ . '/profile'); $this->error('更新失败' . $user->getDbError()); } } else { $this->assign('jumpUrl', __URL__ . '/profile'); $this->error('更新失败' . $user->getError()); } } else { $this->assign('jumpUrl', __URL__ . '/profile'); $this->error('您输入的旧密码不正确'); } }
public function saveuserinfo() { $id = session('userid'); if (!empty($id)) { $postData = array_intersect_key($_POST, array_flip(['id', 'nickname', 'email', 'telphone'])); $user = new UserModel(); $data = $user->create($postData); if (false !== $user->save()) { $this->message2('编辑成功', 'reinfo'); } else { $this->message2('编辑失败' . $user->getError(), 'reinfo'); } } else { $this->message2('请选择编辑对象', __URL__ . '/index'); } }
public function adding() { $data['username'] = $this->_post('username'); $data['yourname'] = $this->_post('yourname'); $data['password'] = md5($this->_post('password')); $data['status'] = $this->_post('status'); $user = new UserModel('user'); if (!$user->create()) { // 如果创建失败 表示验证没有通过 输出错误提示信息 $this->error($user->getError()); } else { $list = $user->add($data); $id['role_id'] = $this->_post('role_id'); $id['user_id'] = $list; $role = M('roleUser')->add($id); $shiyong = M('shiyong'); $data_id['pid'] = $list; $data_id['tsj'] = '143'; $data_id['xsq'] = '136'; $slist = $shiyong->add($data_id); $testuser = M('testuser'); $test['pid'] = $list; $testlist = $testuser->add($test); if ($list and $role and $slist and $testlist) { $this->success('注册成功!', U('User/index')); } else { $this->error('注册失败!'); } } /* if($data['username']!='' and $data['yourname']!=''){ if($pwd==$pwds and $pwd!='' and $pwds!=''){ $user = M('user'); $data['password'] = md5($pwds); $list=$user->data($data)->add(); if($list){ $this->success('添加成功','index'); }else{ $this->error('添加失败,清理联系管理员!'); } }else{ $this->error('密码有误!!!'); } }else{ $this->error('员工账号和用户姓名不能为空!!!'); } */ }
public function shebei_save() { $data['id'] = $this->_post('id'); $data['num'] = $this->_post('num'); $data['home'] = $this->_post('home'); $data['tsj'] = $this->_post('tsj'); $data['xsq'] = $this->_post('xsq'); $shiyong = new UserModel('shiyong'); if (!$shiyong->create()) { $this->error($shiyong->getError()); } else { $list = $shiyong->save($data); if ($list) { $this->success('修改成功!', U('User/index')); } else { $this->error('修改失败!'); } } }
define('ACC', true); require './include/init.php'; /** * regAct.php * 接受用户注册的表单信息,完成注册 * @authors zhangyang (zy1123581321@qq.com) * @date 2015-08-09 16:24:11 */ $user = new UserModel(); $data = $user->_facade($_POST); $data = $user->_autoFill($data); /* * 需要验证用户名、邮箱、密码等 */ if (!$user->_validate($_POST)) { $msg = implode('<br />', $user->getError()); include './view/front/msg.html'; exit; } /* * 检验用户名是否已存在 */ if ($user->checkUser($data['username'])) { $msg = '用户名已存在'; include './view/front/msg.html'; exit; } if ($user->reg($data)) { $msg = "注册成功"; } else { $msg = "注册失败";