/** * 发起反馈 */ public function create() { if (IS_POST) { $data['seller_id'] = $this->mid; $data['module'] = MODULE_NAME; $data['content'] = str_rp(trim($_POST['content'])); $data['contact'] = str_rp(trim($_POST['contact'])); $data['addtime'] = NOW_TIME; $data['has_reply'] = 0; //图片上传 if (!empty($_FILES['pic']['size'])) { $img = 'feedback_' . re_md5(NOW_TIME . nonce_str()); $param = array('savePath' => MODULE_NAME . '/feedback/', 'subName' => '', 'files' => $_FILES['pic'], 'saveName' => $img, 'saveExt' => ''); $up_return = upload_one($param); if ($up_return == 'error') { $this->error('图片上传失败'); exit; } else { $data['pic'] = $up_return; } } $res = $this->model->add($data); if ($res) { $this->success('谢谢您的意见及建议.', U('detail', array('id' => $res))); } else { $this->error('非常抱歉,您的意见及建议没有提交成功.'); } } elseif (IS_GET) { $this->h3_title = '发起反馈'; $this->display(); } }
public function resetpwd() { $member_id = intval($_GET['member_id']); if ($member_id) { $pwd = '123456'; //默认重置密码为123456 $pwd = re_md5($pwd); $this->model->where('member_id=' . $member_id)->setField('pwd', $pwd); $this->success("操作成功", U('member')); exit; } }
public function changepwd() { $Store = M('Store'); $store_id = intval($_REQUEST['store_id']); if (IS_POST && $store_id) { $pwd = re_md5(trim($_POST['pwd'])); $Store->where('store_id=' . $store_id)->setField('pwd', $pwd); $this->success("操作成功", U('storelist')); exit; } else { $vo = $Store->where('store_id=' . $store_id)->field('store_id,account')->find(); $this->assign('vo', $vo); $this->display(); } }
public function member_edit() { if (IS_POST) { $more_address = serialize($_POST['more_address']); $old_pwd = M('Member')->where(array('uid' => isLogin(), 'status' => 1))->getField('password'); if (empty($_POST['password'])) { $this->error('密码不能为空'); } if ($old_pwd == $_POST['password']) { $password = $_POST['password']; } else { $password = re_md5($_POST['password']); } $data = array('password' => $password, 'long_name' => str_rp(trim($_POST['long_name'])), 'nickname' => str_rp(trim($_POST['nickname'])), 'contact_phone' => str_rp(trim($_POST['contact_phone'])), 'contact_name' => str_rp(trim($_POST['contact_name'])), 'school_phone' => str_rp(trim($_POST['school_phone'])), 'school_address' => str_rp(trim($_POST['school_address'])), 'more_address' => serialize($_POST['more_address']), 'qq' => str_rp(trim($_POST['qq'])), 'email' => str_rp(trim($_POST['email'])), 'fax' => str_rp(trim($_POST['fax'])), 'school_desc' => str_replace('\'', ''', $_POST['school_desc'])); unset($lastpath); unset($up_return); unset($filename); if (!empty($_FILES['avatar']['size'])) { $lastpath = M('Member')->where(array('uid' => isLogin()))->getField('avatar'); $filename = 'avatar_' . nonce_str(8, 1, 1, 1); $param = array('savePath' => 'member/', 'subName' => isLogin(), 'exts' => '', 'files' => $_FILES['avatar'], 'saveName' => $filename, 'saveExt' => ''); $up_return = upload_one($param); if ($up_return) { @unlink(BasePath . '/Uploads/' . $lastpath); $data['avatar'] = $up_return; } else { $this->error('上传头像失败'); } } $res = M('Member')->where(array('uid' => isLogin()))->save($data); if ($res) { $this->success('操作成功', U('member')); } else { $this->error('操作失败'); } } else { $info = M('Member')->where(array('uid' => isLogin()))->find(); $info['more_address'] = unserialize($info['more_address']); $info['numAdd'] = count($info['more_address']); $this->vo = $info; $this->display(); } }
public function admin_login($name, $pwd) { $map = array(); $map['username'] = $name; $user = $this->where($map)->find(); if (is_array($user) && !empty($user)) { if (re_md5($pwd) === $user['password']) { $data = array(); $data['last_login_time'] = NOW_TIME; $data['last_login_ip'] = get_client_ip(); $this->where('uid=' . $user['uid'])->save($data); cookie('admin_id', encrypt($user['uid']), 3600 * 2); cookie('admin_name', encrypt($user['username']), 3600 * 2); return $user['uid']; } else { return -2; } } else { return -1; } }
/** * 修改密码 */ public function resetPassword() { if (IS_POST) { if (strtolower($_POST['smscode']) != session('smscode')) { $this->error('验证码错误'); } $where['member_id'] = $this->mid; $where['mobile'] = str_rp(trim($_POST['mobile'])); if ($_POST['pwd'] != $_POST['repwd']) { $this->error('两次输入的密码不一致'); } $data['pwd'] = re_md5($_POST['pwd']); $res = M('Member')->where($where)->save($data); if ($res) { $this->success('修改密码成功'); } else { $this->error('修改密码失败'); } } elseif (IS_GET) { $where['member_id'] = $this->mid; $this->info = M('Member')->where($where)->find(); $this->display(); } }
public function admin_list() { $Admin = M('Admin'); $op = trim($_GET['op']) ? trim($_GET['op']) : 'list'; switch ($op) { case 'list': $list = $Admin->where(array('admin_id' => isLogin()))->select(); $this->assign('list', $list); $this->display(); break; case 'del': $admin_id = intval($_GET['admin_id']); if ($admin_id && $admin_id != 1) { $Admin->where('admin_id=' . $admin_id)->delete(); $this->success("删除成功", U('admin_list')); exit; } break; case 'edit': if (IS_POST) { $admin_id = intval($_POST['admin_id']); $admin_pwd = re_md5(trim($_POST['admin_pwd'])); $Admin->where('admin_id=' . $admin_id)->setField('admin_pwd', $admin_pwd); if (!empty($_FILES)) { $filename = 'sign_' . $admin_id; $param = array('savePath' => 'signature/', 'subName' => '', 'files' => $_FILES['sign_pic'], 'saveName' => $filename, 'saveExt' => '', 'replace' => true); $path = upload_one($param); $image = new \Think\Image(); $image->open('./Uploads/' . $path); $image->thumb(150, 150)->save('./Uploads/' . $path); $Admin->where(array('admin_id' => $admin_id))->setField('admin_signature', $path); } $this->success("操作成功", U('admin_list')); exit; } else { $admin_id = intval($_GET['admin_id']); $vo = $Admin->where('admin_id=' . $admin_id)->find(); $this->assign('vo', $vo); $this->display('admin_edit'); } break; case 'add': if (IS_POST) { $data = array(); $data['admin_name'] = trim($_POST['admin_name']); $data['admin_pwd'] = re_md5(trim($_POST['admin_pwd'])); $data['admin_lg_time'] = NOW_TIME; $data['admin_lg_ip'] = get_client_ip(); $Admin->add($data); $this->success("添加成功", U('admin_list')); exit; } else { $this->display('admin_add'); } break; } }
public function register() { if (IS_POST) { $data = array('username' => trim($_POST['tbx_SchoolId']), 'password' => re_md5($_POST['tbx_PassWord']), 'long_name' => str_rp(trim($_POST['tbx_SchoolName'])), 'nickname' => str_rp(trim($_POST['tbx_SchoolShortName'])), 'contact_name' => str_rp(trim($_POST['tbx_LXR'])), 'contact_phone' => str_rp(trim($_POST['tbx_LXRPhone'])), 'school_phone' => str_rp(trim($_POST['tbx_SchoolTel'])), 'school_address' => str_rp(trim($_POST['tbx_SchoolAddress'])), 'province' => intval($_POST['province']), 'city' => intval($_POST['city']), 'qq' => str_rp(trim($_POST['tbx_QQ'])), 'email' => str_rp(trim($_POST['tbx_Email'])), 'fax' => str_rp(trim($_POST['tbx_Fax'])), 'reg_ip' => get_client_ip(), 'reg_time' => NOW_TIME, 'school_desc' => str_rp($_POST['tbx_SchoolDesc']), 'status' => 0); $uid = M('Member')->add($data); if ($uid) { session('uid', $uid); session('long_name', $data['long_name']); $this->success('注册成功', U('Index/index')); } else { $this->error('注册失败'); } } else { $this->province = M('District')->where(array('level' => 1))->select(); $this->display(); } }
public function admin_list() { $Admin = M('Admin'); $op = trim($_GET['op']) ? trim($_GET['op']) : 'list'; $admin_type = I('get.type', 0, 'int'); $this->search = $_GET; switch ($op) { case 'list': $list = $Admin->where(array('admin_type' => $admin_type))->select(); $this->assign('list', $list); $this->display(); break; case 'del': $admin_id = intval($_GET['admin_id']); if ($admin_id && $admin_id != 1) { $Admin->where('admin_id=' . $admin_id)->delete(); $this->success("删除成功", U('admin_list')); exit; } break; case 'edit': if (IS_POST) { $admin_id = intval($_POST['admin_id']); if (trim($_POST['admin_pwd'])) { $admin_pwd = re_md5(trim($_POST['admin_pwd'])); $Admin->where('admin_id=' . $admin_id)->setField('admin_pwd', $admin_pwd); $admin_type = intval($_POST['admin_type']); $Admin->where('admin_id=' . $admin_id)->setField('admin_type', $admin_type); } //权限 $admin_auth = $_POST['admin_auth']; $auth = ''; if (!empty($admin_auth)) { foreach ($admin_auth as $at) { $auth .= $at . ','; } } $auth_d = M('AdminAuth')->where('a_default=1')->select(); if (is_array($auth_d) && !empty($auth_d)) { foreach ($auth_d as $ad) { $auth .= $ad['a_id'] . ','; } } $auth = substr($auth, 0, -1); $Admin->where('admin_id=' . $admin_id)->setField('admin_auth', $auth); //权限END $this->success("操作成功", U('admin_list')); exit; } else { $admin_auths = M('AdminAuth')->where('a_default=0 and a_show=1')->order('a_sort asc')->select(); $admin_auth = array(); foreach ($admin_auths as $key => $val) { $admin_auth[$val['auth_class']][] = $val; } $this->admin_auth = $admin_auth; $admin_id = intval($_GET['admin_id']); $vo = $Admin->where('admin_id=' . $admin_id)->find(); $this->auth = explode(',', $vo['admin_auth']); //p($this->auth);p($vo);die; $this->assign('vo', $vo); $this->display('admin_edit'); } break; case 'add': if (IS_POST) { $data = array(); $data['admin_name'] = str_rp(trim($_POST['admin_name'])); $data['admin_pwd'] = re_md5(trim($_POST['admin_pwd'])); $data['admin_lg_time'] = NOW_TIME; $data['admin_lg_ip'] = get_client_ip(); $data['admin_type'] = intval($_POST['admin_type']); $admin_auth = $_POST['admin_auth']; $auth = ''; if (!empty($admin_auth)) { foreach ($admin_auth as $at) { $auth .= $at . ','; } } $auth_d = M('AdminAuth')->where('a_default=1')->select(); if (is_array($auth_d) && !empty($auth_d)) { foreach ($auth_d as $ad) { $auth .= $ad['a_id'] . ','; } } $auth = substr($auth, 0, -1); $data['admin_auth'] = $auth; $Admin->add($data); $this->success("添加成功", U('admin_list')); exit; } else { $admin_auths = M('AdminAuth')->where('a_default=0 and a_show=1')->order('a_sort asc')->select(); $admin_auth = array(); foreach ($admin_auths as $key => $val) { $admin_auth[$val['auth_class']][] = $val; } $this->admin_auth = $admin_auth; $this->display('admin_add'); } break; } }
/** * 找回密码 */ public function forgot() { if (IS_POST) { $map = array(); if ($_POST['s_class'] == 'mobile') { $map['mobile'] = trim($_POST['mobile']); $smscode = strtolower(trim($_POST['smscode'])); $data['pwd'] = re_md5($_POST['pwd']); $m_info = $this->model->where($map)->find(); if (!empty($m_info)) { if ($smscode == session('smscode') && session('codetype') == 'forgot' && session('mobile') == $map['mobile']) { $res = $this->model->where($map)->save($data); if ($res) { session(null); session('member_id', $m_info['member_id']); $this->success('密码修改成功.', U('Member/index')); } else { $this->error('密码修改失败'); } } else { $this->error('手机验证码错误.'); } } else { $this->error('该手机号没有注册过.'); } } elseif ($_POST['s_class']) { $map['email'] = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL); $smscode = strtolower(trim($_POST['smscode'])); $data['pwd'] = re_md5($_POST['pwd']); $m_info = $this->model->where($map)->find(); if (!empty($m_info)) { if ($smscode == session('smscode') && session('codetype') == 'forgot' && session('email') == $map['email']) { $res = $this->model->where($map)->save($data); if ($res) { session(null); session('member_id', $m_info['member_id']); $this->success('密码修改成功.', U('Member/index')); } else { $this->error('密码修改失败'); } } else { $this->error('邮箱验证码错误.'); } } else { $this->error('该邮箱没有注册过.'); } } } $this->display(); }
public function curdAdmin() { if (IS_POST) { $admin_id = intval($_POST['admin_id']); if (empty($admin_id)) { $data = array('admin_name' => trim($_POST['name']), 'admin_pwd' => re_md5(trim($_POST['password']))); $admin_id = M('admin')->add($data); if (!empty($_FILES)) { $filename = 'sign_' . $admin_id; $param = array('savePath' => 'signature/', 'subName' => '', 'files' => $_FILES['sign_pic'], 'saveName' => $filename, 'saveExt' => '', 'replace' => true); $path = upload_one($param); M('admin')->where(array('admin_id' => $admin_id))->setField('admin_signature', $path); } $group = $_POST['group']; if (is_array($group) && !empty($group)) { foreach ($group as $key => $val) { $access = array('uid' => $admin_id, 'group_id' => $val); M('AuthGroupAccess')->add($access); } } addLog('新增管理员ID-[' . $admin_id . ']'); $this->success('添加管理员成功', U('Auth/adminList')); } else { $data = array('admin_name' => trim($_POST['name']), 'admin_pwd' => re_md5(trim($_POST['password']))); M('admin')->where(array('admin_id' => $admin_id))->save($data); M('AuthGroupAccess')->where(array('uid' => $admin_id))->delete(); if (!empty($_FILES)) { $filename = 'sign_' . $admin_id; $param = array('savePath' => 'signature/', 'subName' => '', 'files' => $_FILES['sign_pic'], 'saveName' => $filename, 'saveExt' => '', 'replace' => true); $path = upload_one($param); $image = new \Think\Image(); $image->open('./Uploads/' . $path); $image->thumb(150, 150)->save('./Uploads/' . $path); M('admin')->where(array('admin_id' => $admin_id))->setField('admin_signature', $path); } $group = $_POST['group']; if (is_array($group) && !empty($group)) { foreach ($group as $key => $val) { $access = array('uid' => $admin_id, 'group_id' => $val); M('AuthGroupAccess')->add($access); } } addLog('编辑管理员ID-[' . $admin_id . ']'); $this->success('编辑管理员成功', U('Auth/adminList')); } } else { if ($_GET['admin_id']) { $type = trim($_GET['type']); $admin_id = intval($_GET['admin_id']); if ($type == 'edit') { $this->title = "编辑管理员"; $mod = D('admin'); $this->info = $mod->where(array('admin_id' => $admin_id))->field(array('admin_id', 'admin_name'))->find(); $group = M('AuthGroup')->select(); $acc = M('AuthGroupAccess')->where(array('uid' => $admin_id))->field(array('group_id'))->select(); if (is_array($acc) && !empty($acc)) { foreach ($acc as $key => $val) { $access[] = $val['group_id']; } foreach ($group as $key => $val) { if (in_array($val['id'], $access)) { $group[$key]['checked'] = 1; } } } $this->group = $group; $this->display(); } elseif ($type == 'del') { if ($admin_id == isLogin()) { $this->error('您不能删除自己的账号'); } else { $result = $this->model->where(array('admin_id' => $admin_id))->delete(); if ($result) { M('AuthGroupAccess')->where(array('uid' => $admin_id))->delete(); addLog('删除管理员ID-[' . $admin_id . ']'); $this->success('删除账号成功'); } else { $this->error('删除账号失败'); } } } else { $this->error('非法操作'); } } else { $this->title = "添加管理员"; $this->group = M('AuthGroup')->select(); $this->display(); } } }
/** * 修改密码 */ public function set_pwd() { if (IS_GET && trim($_GET['mcode'])) { $mcode = trim($_GET['mcode']); $mid = decrypt($mcode); $map = array(); $map['seller_id'] = array('eq', intval($mid)); $f_info = $this->model->where($map)->find(); if (is_array($f_info) && !empty($f_info)) { $this->assign('f_info', $f_info); $this->display(); } else { $this->error("非法请求!"); exit; } } if (IS_POST) { $seller_id = intval($_POST['seller_id']); $pwd = re_md5(trim($_POST['pwd'])); $rst = $this->model->where(array('seller_id' => $seller_id))->setField('pwd', $pwd); if ($rst) { $this->success("密码修改成功!", U('login')); exit; } else { $this->error("操作失败!"); exit; } } }