public function editDetails() { $objLinkTxt = M('linktxt'); $id = intval($_GET['id']); if ($_POST) { $POST = deep_htmlspecialchars($_POST); parent::checkField('link_name', $POST['link_name'], 'require', '友情链接名称不能为空'); parent::checkField('link_url', $POST['link_url'], 'require', '友情链接地址不能为空'); parent::checkField('explain', $POST['explain'], 'require', '友情链接备注不能为空'); $data = array(); $data['id'] = $POST['id']; $data['link_name'] = $POST['link_name']; $data['status'] = $POST['status']; $data['link_url'] = $POST['link_url']; $data['explain'] = $POST['explain']; $result = $objLinkTxt->data($data)->save(); if ($result) { $this->success('修改成功', U(GROUP_NAME . '/Link/detailslist')); } else { $this->error('修改失败'); } } else { $data = $objLinkTxt->where('id=' . $id)->find(); $data = deep_htmlspecialchars_decode($data); $this->assign('data', $data); $this->display(); } }
public function editAdmin() { $objAdmin = M('admin'); $id = intval($_GET['id']); if ($_POST) { $POST = deep_htmlspecialchars($_POST); parent::checkField('password', $POST['password'], 'require', '旧密码不能为空'); parent::checkField('newpassword', $POST['newpassword'], 'require', '新密码不能为空'); $password = $objAdmin->where('id=' . $POST['id'])->find(); if ($password['password'] != md5($POST['password'])) { $this->error('旧密码不正确,请重试'); } $result = $objAdmin->where('id=' . $POST['id'])->save(array('id' => $POST['ID'], 'password' => md5($POST['newpassword']))); if ($result) { $this->success('密码修改成功', U(APP_NAME . '/Admin/adminlist')); } else { $this->error('密码修改失败'); } } else { $data = $objAdmin->where(array('id' => $id))->find(); $data = deep_htmlspecialchars_decode($data); $this->assign('data', $data); $this->display(); } }
public function handleReg() { if (!IS_POST) { parent::error404(); } $POST = deep_htmlspecialchars_decode($_POST); parent::checkField('username', $POST['username'], 'require', '用户名不能为空'); parent::checkField('username', $POST['username'], 'twomore', '用户名在2-14个字符'); parent::checkField('email', $POST['email'], 'require', '邮箱不能为空'); parent::checkField('email', $POST['email'], 'email', '邮箱格式不对'); parent::checkField('password', $POST['password'], 'require', '密码不能为空'); parent::checkField('password', $POST['password'], 'password', '密码只能在6-20个字符'); parent::checkField('repassword', $POST['repassword'], 'require', '确认密码不能为空'); if ($POST['password'] != $POST['repassword']) { $this->error('前后密码不一致'); } parent::checkField('verify', $POST['verify'], 'require', '验证码不能为空'); if (md5($POST['verify']) != $_SESSION['verify']) { $this->error('验证码不正确'); } $objUser = M('user'); $data = array(); $data['username'] = $POST['username']; $data['email'] = $POST['email']; $data['password'] = md5($POST['password']); $data['reg_time'] = time(); $data['login_ip'] = get_client_ip(); $result = $objUser->data($data)->add(); if ($result) { $this->success('恭喜你,注册成功', U(APP_NAME . '/Login/index')); } else { $this->error('注册失败,请稍后再试'); } }
public function singleEdit() { $id = intval($_GET['id']); $objSingle = M('single'); if (IS_POST) { $POST = deep_htmlspecialchars($_POST); parent::checkField('title', $POST['title'], 'require', '单页标题不能为空'); parent::checkField('content', $POST['content'], 'require', '内容不能为空'); $data = array(); $data['id'] = $POST['id']; $data['title'] = $POST['title']; $data['status'] = $POST['status']; $data['content'] = $POST['content']; $result = $objSingle->save($data); if ($result) { $this->success('修改成功...', U(APP_NAME . '/Single/singlelist')); } else { $this->error('修改失败,请稍后再试'); } } else { $data = $objSingle->where('id=' . $id)->find(); $data = deep_htmlspecialchars_decode($data); $this->assign('data', $data); $this->display(); } }
public function runAddDetails() { $db = M('discuss'); parent::checkField('discuss_name', deep_htmlspecialchars($_POST['discuss_name']), 'require', '图文名称不能为空'); parent::checkField('content', deep_htmlspecialchars($_POST['content']), 'require', '内容不能为空'); $data = array(); $data['discuss_name'] = I('discuss_name'); $data['sort_id'] = I('parent_id'); $data['status'] = I('status'); $data['author'] = I('author'); $data['add_time'] = time(); $data['content'] = I('content'); if ($db->data($data)->add()) { $this->success('添加成功', U(GROUP_NAME . '/Discuss/detailslist')); } else { $this->error('添加失败'); } }
public function addLetter() { parent::isLogin(); //登录判断 $userId = intval($_GET['user_id']); $objLetter = M('letter'); $objUser = M('user'); if (IS_POST) { $POST = deep_htmlspecialchars($_POST); parent::checkField('username', $POST['username'], 'require', '私信的用户名不能为空!'); parent::checkField('title', $POST['title'], 'require', '私信标题不能为空'); parent::checkField('content', $POST['content'], 'require', '私信内容不能为空'); $result = $objUser->where(array('username' => $POST['username']))->field('id,username')->find(); if (!$result) { $this->error('私信的用户不存在!'); } if ($result['id'] == $_SESSION['uid']) { $this->error('不能跟自己私信!'); } $data = array(); $data['send_uid'] = $POST['uid']; $data['receive_uid'] = $result['id']; $data['receive_user'] = $POST['username']; $data['send_user'] = $POST['send_user']; $data['title'] = $POST['title']; $data['content'] = $POST['content']; $data['time'] = time(); $result2 = $objLetter->add($data); if ($result2) { $this->success('发送私信成功'); } else { $this->error('发送私信失败,请稍后再试!'); } } else { $username = $objUser->where('id=' . $userId)->getField('username'); $this->assign('username', $username); $this->display(); } }
public function editDetails() { if ($_POST) { $id = I('id', 0, 'intval'); $db = M('ad'); parent::checkField('ad_name', deep_htmlspecialchars($_POST['ad_name']), 'require', '广告名称不能为空'); //parent::checkField('content', deep_htmlspecialchars($_POST['content']), 'require', '内容不能为空'); $data = array(); $data['id'] = $id; $data['ad_name'] = I('ad_name'); $data['sort_id'] = I('parent_id'); $data['status'] = I('status'); $data['ad_pic'] = I('ad_pic'); $data['ad_url'] = I('ad_url'); $data['ad_explain'] = I('ad_explain'); $data['start_time'] = strtotime(I('start_time')); $data['end_time'] = strtotime(I('end_time')); if ($db->data($data)->save()) { $this->success('修改成功', U(GROUP_NAME . '/Ad/detailslist')); } else { $this->error('修改失败'); } } else { $id = I('id', 0, 'intval'); $this->assign('id', $id); $data = M('ad')->where(array('id' => $id))->find(); $this->assign('data', $data); import('Class.Category', './'); //引入无限极分类 $sortList = M('ad_sort')->select(); //先把广告分类读出来 $sortList = Category::unlimitedForLevel($sortList, ' '); //组合子分类与父分类 $this->assign('sortList', $sortList); //把分类分配过去 $this->display(); } }
public function handleEditAsk() { if (!IS_POST) { parent::error404(); } $POST = deep_htmlspecialchars($_POST); parent::checkField('title', $POST['title'], 'require', '标题不能为空'); if ($POST['sort_id'] == 0) { $this->error('请选择分类'); } if ($POST['reward'] == -1) { $this->error('请选择悬赏金币'); } parent::checkField('content', $POST['content'], 'require', '内容不能为空'); $objAsk = M('ask'); $data = array(); $data['id'] = $POST['aid']; $data['ask_name'] = $POST['title']; $data['uid'] = $POST['uid']; $data['sort_id'] = $POST['sort_id']; $data['reward'] = $POST['reward']; $data['content'] = $POST['content']; $result = $objAsk->data($data)->save(); if ($result) { $this->success('修改问题成功...', U(APP_NAME . '/List/detail', array('id' => $POST['aid']))); } else { $this->error('修改问题失败,请稍后再试..'); } }