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 review() { $uid = intval($_GET['uid']); if ($uid == '') { parent::error404(); } //分配根据GET传过来的uid用户的信息 $objUser = M('user'); $userMessage = $objUser->where('id=' . $uid)->field('id,username,face,introduce,point,exp')->find(); $userMessage = deep_htmlspecialchars_decode($userMessage); if ($userMessage == '') { parent::error404(); } $this->assign('userMessage', $userMessage); //分配该用户的评论 $objComment = M('comment'); import('ORG.Util.Page'); //导入分页类 $count = $objComment->where(array('comment_uid' => $uid))->count(); $page = new page($count, 20); $page->setConfig('theme', '%upPage% %first% %prePage% %linkPage% %downPage%'); $commentList = $objComment->where(array('comment_uid' => $uid))->field('aid,time,comment')->order('time desc')->limit($page->firstRow . ',' . $page->listRows)->select(); foreach ($commentList as $k1 => $v1) { $commentList[$k1]['url'] = '__APP__/List/detail/id/' . $v1['aid'] . '.html'; } $commentList = deep_htmlspecialchars_decode($commentList); $show = $page->show(); $this->assign('page', $show); $this->assign('commentList', $commentList); //分配Pagetitle $this->pageTitle = $userMessage['username'] . '的个人主页_支招网'; $this->display(); }
public function index() { $objAsk = M('ask'); $objUser = M('user'); $word = deep_htmlspecialchars($_GET["word"]); $this->assign('searchWord', $word); if ($word == '') { redirect($_SERVER['HTTP_REFERER']); } //如果没有输入关键字 就重定向到上一页面 import('ORG.Util.Page'); //导入分页类 $count = $objAsk->where('INSTR(ask_name, "' . $word . '")>0')->count(); //统计总数 $this->assign('countSearch', $count); $page = new page($count, 10); $page->setConfig('theme', '%upPage% %first% %prePage% %linkPage% %downPage%'); $resultList = $objAsk->where('INSTR(ask_name, "' . $word . '")>0')->order('add_time desc')->limit($page->firstRow . ',' . $page->listRows)->select(); foreach ($resultList as $k1 => $v1) { $resultList[$k1]['username'] = $objUser->where('id=' . $v1['uid'])->getField('username'); } $resultList = deep_htmlspecialchars_decode($resultList); $show = $page->show(); $this->assign('resultList', $resultList); $this->assign('page', $show); $this->display(); }
public function site() { $objSite = M('site'); if ($_POST) { $POST = deep_htmlspecialchars($_POST); $data = array(); $data['id'] = $POST['id']; $data['site_name'] = $POST['site_name']; $data['site_url'] = $POST['site_url']; $data['company'] = $POST['company']; $data['address'] = $POST['address']; $data['zipcode'] = $POST['zipcode']; $data['telephone'] = $POST['telephone']; $data['cellphone'] = $POST['cellphone']; $data['email'] = $POST['email']; $data['icp'] = $POST['icp']; $data['third_code'] = $POST['third_code']; $result = $objSite->data($data)->save(); if ($result) { $this->success('保存成功'); } else { $this->error('系统繁忙,请稍后再试'); } } else { $data = $objSite->where('id=1')->find(); $data = deep_htmlspecialchars_decode($data); $this->assign('data', $data); $this->display(); } }
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 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 indexAction() { $buffer["curNav"] = 1; $studyList = $this->m_study->getStudyList(10); $buffer["studyList"] = deep_htmlspecialchars_decode($studyList); $travelList = $this->m_travel->getTravelList(10); $buffer["travelList"] = deep_htmlspecialchars_decode($travelList); $discussList = $this->m_discuss->getDiscussList(10); $buffer["discussList"] = deep_htmlspecialchars_decode($discussList); $buffer['pageTitle'] = "泰语学习,泰国旅游,泰语在线词典,泰语问答_泰语导航网"; $this->getView()->assign($buffer); }
/** * @param int $uid 用户ID * @param int $different 所属类别 */ public function selectCollectById($uid, $different, $limit) { $sql = ""; if ($different == 1) { $sql = "select c.aid,c.time,s.study_name as name,concat('/study/detail?id=',c.aid) as url from " . TB_PREFIX . "collect as c left join " . TB_PREFIX . "study as s on c.aid=s.id where c.different=" . $different . " AND c.uid=" . $uid . " order by c.time desc limit " . $limit; } elseif ($different == 2) { $sql = "select c.aid,c.time,s.travel_name as name,concat('/travel/detail?id=',c.aid) as url from " . TB_PREFIX . "collect as c left join " . TB_PREFIX . "travel as s on c.aid=s.id where c.different=" . $different . " AND c.uid=" . $uid . " order by c.time desc limit " . $limit; } elseif ($different == 3) { $sql = "select c.aid,c.time,s.discuss_name as name,concat('/discuss/detail?id=',c.aid) as url from " . TB_PREFIX . "collect as c left join " . TB_PREFIX . "discuss as s on c.aid=s.id where c.different=" . $different . " AND c.uid=" . $uid . " order by c.time desc limit " . $limit; } return deep_htmlspecialchars_decode($this->Query($sql)); }
public function index() { //首页焦点图 $objAd = M('ad'); $indexFocus = $objAd->where('sort_id=3')->order('id asc')->select(); $indexFocus = deep_htmlspecialchars_decode($indexFocus); $this->assign('indexFocus', $indexFocus); // 待解决的问题 $idList = parent::getIdList('ask_sort', 0); //获取所有的顶级分类和其子分类 $objAsk = D('AskView'); $where1 = 'sort_id in (' . $idList . ')'; $where1 .= ' AND solve = "0"'; $noAnswerList = $objAsk->where($where1)->field('id,ask_name,add_time,comment_num,username,uid,sort_name,sort_id')->order('add_time desc')->limit(10)->select(); $noAnswerList = deep_htmlspecialchars_decode($noAnswerList); $this->assign('noAnswerList', $noAnswerList); //悬赏最高的问题 $where2 = 'sort_id in (' . $idList . ')'; $rewardList = $objAsk->where($where2)->field('id,ask_name,add_time,comment_num,username,uid,sort_name,sort_id')->order('reward desc')->limit(10)->select(); $rewardList = deep_htmlspecialchars_decode($rewardList); $this->assign('rewardList', $rewardList); $this->display(); }
public function getGlobal() { $m_user = $this->load("User"); //判断cookie是否有-自动登录 $cookie_auth = $this->getCookie('auth'); if ($cookie_auth) { $clean = array(); list($identifier, $token) = explode(':', $cookie_auth); if (ctype_alnum($identifier) && ctype_alnum($token)) { $clean['identifier'] = $identifier; $clean['token'] = $token; } $record = $m_user->Where(array("identifier" => $clean['identifier']))->Field("id,email,identifier,identifier_token,login_time,point,refuse")->SelectOne(); if ($record && $record["refuse"]) { if ($clean['token'] != $record['identifier_token']) { //$this->redirect("Login/index"); } elseif ($clean['identifier'] != md5("SALTISDIFFCULT" . md5($record["email"] . "SALTISDIFFCULT"))) { //$this->redirect("Login/index"); } else { //更新 if ($record["login_time"] < strtotime(date("Y-m-d"))) { $m_user->UpdateByID(array("login_time" => time(), "login_ip" => getClientIP(), "point" => $record["point"] + 2), $record["id"]); } $this->setSession('uid', $record["id"]); $this->setSession('email', $record["email"]); } } } //根据session uid 获取该用户的信息 $session_uid = $this->getSession("uid"); $session_email = $this->getSession("email"); if (isset($session_uid) && !empty($session_uid)) { $current_user_info = $m_user->Where(array("id" => $session_uid))->Field("id,email,username")->SelectOne(); $current_user_info = deep_htmlspecialchars_decode($current_user_info); $this->getView()->assign("current_user_info", $current_user_info); } }
public function indexAction() { $word = deep_htmlspecialchars($this->get("word")); if (!$word) { $where = "status=-1"; } else { $where = "status=1 AND title like '%" . $word . "%'"; } $total = $this->m_search->getSearchArticle(0, $where); //获取符合条件的总是 $page = $this->get('page'); $page = $page ? $page : 1; $size = 15; $start = ($page - 1) * $size; $limit = $start . ',' . $size; $url = '/search?word=' . $word . "&page="; $buffer["word"] = $word; $buffer['pageNav'] = buildPage($page, $total, $url, $size, 5); $buffer["list"] = $this->m_search->getSearchArticle(1, $where, $limit); $m_user = $this->load("User"); foreach ($buffer['list'] as $k => $v) { $buffer['list'][$k]["username"] = $m_user->SelectFieldByID("username", $v["user_id"]); $buffer['list'][$k]["avatar"] = $m_user->SelectFieldByID("avatar", $v["user_id"]); if ($v["table_name"] == "study") { $buffer['list'][$k]["url"] = "/study/detail?id=" . $v["id"]; } elseif ($v["table_name"] == "discuss") { $buffer['list'][$k]["url"] = "/discuss/detail?id=" . $v["id"]; } elseif ($v["table_name"] == "travel") { $buffer['list'][$k]["url"] = "/travel/detail?id=" . $v["id"]; } } $buffer["list"] = deep_htmlspecialchars_decode($buffer['list']); $buffer['pageTitle'] = $this->get("word") . "_泰语导航网"; $buffer["curNav"] = 5; $this->getView()->assign($buffer); }
function deep_htmlspecialchars_decode($mix, $quotestyle = ENT_QUOTES) { if (gettype($mix) == 'array') { foreach ($mix as $key => $value) { if (gettype($value) == 'array') { $mix[$key] = deep_htmlspecialchars_decode($value, $quotestyle); } else { $value = str_replace(' ', ' ', $value); $value = str_replace('\\r', "\r", $value); $value = str_replace('\\n', "\n", $value); $value = htmlspecialchars_decode($value, $quotestyle); $mix[$key] = $value; } } return $mix; } else { $mix = str_replace(' ', ' ', $mix); $mix = htmlspecialchars_decode($mix, $quotestyle); return $mix; } }
public function getStudy($id) { $sql = "select s.*,u.username from " . TB_PREFIX . "study as s left join " . TB_PREFIX . "user as u on s.uid = u.id where s.status = '1' and s.id=" . $id; return deep_htmlspecialchars_decode($this->Query($sql)); }
public function editDetails() { if ($_POST) { $id = I('id', 0, 'intval'); $db = M('discuss'); $data = array(); $data['id'] = $id; $data['status'] = I('status'); $data['tags'] = I('tags'); if ($db->data($data)->save()) { $this->success('修改成功', U(GROUP_NAME . '/Discuss/detailsList')); } else { $this->error('修改失败'); } } else { $id = I('id', 0, 'intval'); $this->assign('id', $id); $data = M('discuss')->where(array('id' => $id))->find(); $this->assign('data', $data); $data = deep_htmlspecialchars_decode($data); //import('Class.Category','./');//引入无限极分类 //$sortList = M('discuss_sort')->select();//先把图文分类读出来 //$sortList = Category::unlimitedForLevel($sortList,' ');//组合子分类与父分类 //$this->assign('sortList',$sortList);//把分类分配过去 $this->display(); } }
public function detail() { $aid = intval($_GET['id']); $objAsk = D('AskView'); $askCon = $objAsk->where('Ask.id=' . $aid)->field('id,sort_name,ask_name,content,add_time,click_number,comment_num,reward,solve,point,exp,username,face,uid')->find(); $askCon = deep_htmlspecialchars_decode($askCon); if ($askCon == '') { parent::error404(); } $this->assign('askCon', $askCon); //点击次数+1 M('ask')->where('id=' . $aid)->setInc('click_number', 1); //加载支招列表 $objComment = M('comment'); $objUser = M('user'); $commentList = $objComment->where(array('aid' => $aid))->order('time desc')->select(); foreach ($commentList as $k1 => $v1) { $cPeople = $objUser->where('id=' . $v1['comment_uid'])->field('username,face')->find(); $rPeople = $objUser->where('id=' . $v1['reply_uid'])->field('username,face')->find(); $commentList[$k1]['comment_username'] = $cPeople['username']; $commentList[$k1]['reply_username'] = $rPeople['username']; $commentList[$k1]['comment_face'] = $cPeople['face']; $commentList[$k1]['reply_face'] = $rPeople['face']; } $commentList = deep_htmlspecialchars_decode($commentList); $commentList = unlimitedForLayer($commentList); $this->assign('commentList', $commentList); //最佳支招 $objBest = D('BestView'); $bestList = $objBest->where(array('aid' => $aid))->field('face,username,time,comment')->find(); $bestList = deep_htmlspecialchars_decode($bestList); $this->assign('bestList', $bestList); $this->display(); }
protected function getSortList($table, $parent_id = 0, $maxGrade = -1, $extend = '', $order = '`sequence` asc, `id` asc', $limit = '', $grade = 1) { if ($maxGrade === -1 || $grade <= $maxGrade) { $obj = M($table); if ($extend === '') { $where = '`parent_id` = ' . $parent_id; } else { $where = $extend . ' AND `parent_id`=' . $parent_id; } $list = $obj->where($where)->order($order)->limit($limit)->select(); $list = deep_htmlspecialchars_decode($list); foreach ($list as $key => $value) { $list[$key]['child_sort'] = $this->getSortList($table, $value['id'], $maxGrade, $extend, $order, $limit, $grade + 1); } return $list; } }
public function toBest() { parent::isLogin(); //登录判断 $objBest = M('best'); $noticeBest = $objBest->where(array('uid' => $_SESSION['uid'], 'status' => "0"))->select(); foreach ($noticeBest as $k1 => $v1) { $noticeBest[$k1]['article_name'] = M('ask')->where(array('id' => $v1['aid']))->getField('ask_name'); } $noticeBest = deep_htmlspecialchars_decode($noticeBest); $this->assign('noticeBest', $noticeBest); $this->answerNumAll = $this->getAnswerNum(); $this->adoptNumAll = $this->getAdoptNum(); $this->display(); }
public function editArticleAction() { $uid = $this->getSession("uid"); $email = $this->getSession("email"); if (!isset($uid) || empty($uid) || !isset($email) || empty($email)) { $this->notify("请先登录", "http://" . $_SERVER["HTTP_HOST"] . "/login"); } $id = parent::get("id"); if (!$id) { $this->notify("页面不存在"); Yaf_Dispatcher::getInstance()->disableView(); return false; } $article = $this->m_study->Where("id=" . $id . " AND uid=" . $uid)->SelectOne(); if (!$article) { $this->notify("页面不存在"); Yaf_Dispatcher::getInstance()->disableView(); return false; } if (!intval($article["status"])) { $this->notify("页面不存在"); Yaf_Dispatcher::getInstance()->disableView(); return false; } //分类 $sort_list = $this->m_study_sort->Where("status='1'")->Field("id,sort_name")->Select(); $buffer['sort_list'] = $sort_list; $article["content"] = deep_htmlspecialchars_decode($article["content"]); $buffer['article'] = $article; $buffer['pageTitle'] = "编辑文章_泰语学习_泰语导航网"; $this->getView()->assign($buffer); }
public function addDetails() { import('Class.Category', './'); //引入无限极分类 $sortList = M('ad_sort')->select(); //先把广告分类读出来 $sortList = deep_htmlspecialchars_decode($sortList); //查询输出了数据库数据之后记得反转义 $sortList = Category::unlimitedForLevel($sortList, ' '); //组合子分类与父分类 $this->assign('sortList', $sortList); //把分类分配过去 $this->display(); }
public function memberList() { $objUser = M('user'); import('ORG.Util.Page'); //导入分页类 $count = $objUser->count(); //统计总数 $page = new page($count, 25); $list = $objUser->field('id,username,email,login_time,reg_time,lock')->order('reg_time desc')->limit($page->firstRow . ',' . $page->listRows)->select(); $list = deep_htmlspecialchars_decode($list); $show = $page->show(); $this->assign('list', $list); $this->assign('page', $show); $this->display(); }