From d78575eb912b2bd4e50d703910e832fb1cabb054 Mon Sep 17 00:00:00 2001 From: whatsns <617035918@qq.com> Date: Thu, 10 Sep 2020 10:39:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8A=E6=AC=A1=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E6=96=B0=E5=A2=9Eurl=E6=A0=8F=E7=9B=AE=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=8A=9F=E8=83=BD=E8=A6=86=E7=9B=96=E9=94=99?= =?UTF-8?q?=E8=AF=AF=EF=BC=8C=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=87=BA=E7=8E=B0html=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../contorllers/Admin/Admin_category.php | 420 ------ application/contorllers/Category.php | 292 ----- application/contorllers/Topic.php | 1131 ----------------- .../controllers/Admin/Admin_category.php | 3 +- application/controllers/Category.php | 27 +- application/controllers/Question.php | 4 +- application/controllers/Topic.php | 28 +- 7 files changed, 47 insertions(+), 1858 deletions(-) delete mode 100644 application/contorllers/Admin/Admin_category.php delete mode 100644 application/contorllers/Category.php delete mode 100644 application/contorllers/Topic.php diff --git a/application/contorllers/Admin/Admin_category.php b/application/contorllers/Admin/Admin_category.php deleted file mode 100644 index 24832a5..0000000 --- a/application/contorllers/Admin/Admin_category.php +++ /dev/null @@ -1,420 +0,0 @@ -load->model ( 'category_model' ); - } - function index($_message = '') { - $message = $_message; - $category ['grade'] = $pid = 0; - $tcategorylist = $this->category_model->list_by_pid ( $pid ); - $categorylist = array (); - foreach ( $tcategorylist as $cat ) { - if ($cat ['isshowindex'] == null || $cat ['isshowindex'] == 0) { - $cat ['isshowindex'] = "首页显示"; - } else { - $cat ['isshowindex'] = "首页不显示"; - } - if ($cat ['isusearticle'] == null || $cat ['isusearticle'] == 0) { - $cat ['isusearticle'] = "不应用到文章发布"; - } else { - $cat ['isusearticle'] = "应用到文章发布"; - } - if ($cat ['isuseask'] == null || $cat ['isuseask'] == 0) { - $cat ['isuseask'] = "不应用到问答发布"; - } else { - $cat ['isuseask'] = "应用到问答发布"; - } - if (! isset ( $cat ['onlybackground'] ) || $cat ['onlybackground'] == 0) { - $cat ['onlybackground'] = "前端可发布"; - } else { - $cat ['onlybackground'] = "只后台发布"; - } - $categorylist [] = $cat; - } - - include template ( 'categorylist', 'admin' ); - } - function updateCatTmplate() { - // $tmpname='catlist_topic';//htmlspecialchars( $this->input->post ('tmpname')); - $id = intval ( htmlspecialchars ( $this->input->post ( 'id' ) ) ); - $tmpname = htmlspecialchars ( $this->input->post ( 'tmpname' ) ); - $cat = $this->category_model->get ( $id ); - if ($cat ['template'] != null && $cat ['template'] != '') { - $tmpname = ''; - } - $this->category_model->update_by_id_tmplate ( $id, $tmpname ); - cleardir ( FCPATH . '/data/cache' ); // 清除缓存文件 - echo "1"; - } - // 更新首页是否显示分类 - function updatecatbyindex() { - if (null !== $this->input->post ( 'cid' )) { - $cids = implode ( ",", $this->input->post ( 'cid' ) ); - $pid = intval ( $this->input->post ( 'hiddencid' ) ); - foreach ( $this->input->post ( 'cid' ) as $val ) { - $type = 'isshowindex'; - $category = $this->category [$val]; - // 状态值 - $typevalue = $category ['isshowindex'] == 1 ? 0 : 1; - $this->category_model->update_by_type ( $val, $type, $typevalue ); - } - cleardir ( FCPATH . '/data/cache' ); // 清除缓存文件 - $this->index ( "设置成功" ); - } - } - // 更新问答是否显示分类 - function updatecatbywenda() { - if (null !== $this->input->post ( 'cid' )) { - $cids = implode ( ",", $this->input->post ( 'cid' ) ); - $pid = intval ( $this->input->post ( 'hiddencid' ) ); - foreach ( $this->input->post ( 'cid' ) as $val ) { - $type = 'isuseask'; - $category = $this->category [$val]; - // 状态值 - $typevalue = $category ['isuseask'] == 1 ? 0 : 1; - $this->category_model->update_by_type ( $val, $type, $typevalue ); - } - cleardir ( FCPATH . '/data/cache' ); // 清除缓存文件 - $this->index ( "设置成功" ); - } - } - function updatecatbyorder() { - if (null !== $this->input->post ( 'cid' )) { - $cids = implode ( ",", $this->input->post ( 'cid' ) ); - $pid = intval ( $this->input->post ( 'hiddencid' ) ); - $orders = $this->input->post ( 'corder' ); - // var_dump($orders);exit(); - - foreach ( $this->input->post ( 'cid' ) as $val ) { - // echo $val.'--'.$orders[$i].'--'.$i."
"; - $orderval = $this->input->post ( 'corder' . $val ); - $this->category_model->order_category ( intval ( $val ), intval ( $orderval ) ); - } - // exit(); - cleardir ( FCPATH . '/data/cache' ); // 清除缓存文件 - $this->message ( "设置成功" ); - } - } - // 更新问答是否显示分类 - function updatecatbywenzhang() { - if (null !== $this->input->post ( 'cid' )) { - $cids = implode ( ",", $this->input->post ( 'cid' ) ); - $pid = intval ( $this->input->post ( 'hiddencid' ) ); - foreach ( $this->input->post ( 'cid' ) as $val ) { - $type = 'isusearticle'; - $category = $this->category [$val]; - // 状态值 - $typevalue = $category ['isusearticle'] == 1 ? 0 : 1; - $this->category_model->update_by_type ( $val, $type, $typevalue ); - } - cleardir ( FCPATH . '/data/cache' ); // 清除缓存文件 - $this->message ( "设置成功" ); - } - } - // 更新问答是否只在后台发布分类 - function updatecatbybackground() { - if (null !== $this->input->post ( 'cid' )) { - $cids = implode ( ",", $this->input->post ( 'cid' ) ); - $pid = intval ( $this->input->post ( 'hiddencid' ) ); - foreach ( $this->input->post ( 'cid' ) as $val ) { - $type = 'onlybackground'; - $category = $this->category [$val]; - // 状态值 - $typevalue = $category ['onlybackground'] == 1 ? 0 : 1; - $this->category_model->update_by_type ( $val, $type, $typevalue ); - } - cleardir ( FCPATH . '/data/cache' ); // 清除缓存文件 - $this->message ( "设置成功" ); - } - } - function updatecatbytype() { - $cid = intval ( $this->input->post ( 'cid' ) ); - // type 1:是否首页显示,2:是否应用问答,3:是否应用文章 - $type = intval ( $this->input->post ( 'type' ) ); - // 状态值 - $typevalue = intval ( $this->input->post ( 'typevalue' ) ); - $typevalue = $typevalue == 1 ? 0 : 1; - switch ($type) { - case 1 : - $type = 'isshowindex'; - break; - case 2 : - $type = 'isuseask'; - break; - case 3 : - $type = 'isusearticle'; - break; - } - $this->category_model->update_by_type ( $cid, $type, $typevalue ); - cleardir ( FCPATH . '/data/cache' ); // 清除缓存文件 - echo "1"; - } - function postadd() { - if (null !== $this->input->post ( 'submit' )) { - $pid = 0; - $category1 = $this->input->post ( 'category1' ); - $category2 = $this->input->post ( 'category2' ); - - if (isset ( $category2 ) && trim ( $category2 ) != '') { - $pid = $category2; - } else if (isset ( $category1 ) && trim ( $category1 ) != '') { - $pid = $category1; - } - $lines = explode ( "\n", $this->input->post ( 'categorys' ) ); - $this->category_model->add ( $lines, $pid ); - cleardir ( FCPATH . '/data/cache' ); // 清除缓存文件 - - exit ( '1' ); - } else { - exit ( '0' ); - } - } - function add() { - $id = intval ( $this->uri->segment ( 3 ) ); - $selectedarray = array (); - if ($id) { - $category = $this->category [$id]; - $item = $category; - for($grade = $category ['grade']; $grade > 0; $grade --) { - $selectedarray [] = $item ['id']; - $item ['pid'] && $item = $this->category [$item ['pid']]; - } - } - - if (isset ( $selectedarray ) && count ( $selectedarray ) > 0) { - switch (count ( $selectedarray )) { - case 1 : - list ( $category1 ) = array_reverse ( $selectedarray ); - break; - case 2 : - list ( $category1, $category2 ) = array_reverse ( $selectedarray ); - break; - case 3 : - list ( $category1, $category2, $category3 ) = array_reverse ( $selectedarray ); - break; - } - } - $categoryjs = $this->category_model->get_js (); - include template ( 'addcategory', 'admin' ); - } - // 获取分类描述 - function getmiaosu() { - $id = intval ( htmlspecialchars ( $this->input->post ( 'id' ) ) ); - $category = $this->category [$id]; - echo $category ['miaosu']; - exit (); - } - function editalias() { - $alias = htmlspecialchars ( $this->input->post ( 'alias' ) ); - $id = intval ( htmlspecialchars ( $this->input->post ( 'id' ) ) ); - $this->category_model->update_by_id_alias ( $id, $alias ); - cleardir ( FCPATH . '/data/cache' ); // 清除缓存文件 - echo "更新成功"; - } - function editmiaosu() { - $miaosu = $this->input->post ( 'miaosu' ); - - $id = intval ( $this->input->post ( 'id' ) ); - // runlog('miaosu.txt', $id.'----.'.$miaosu); - $this->category_model->update_by_id_miaosu ( $id, $miaosu ); - cleardir ( FCPATH . '/data/cache' ); // 清除缓存文件 - echo "更新成功"; - } - function edit() { - $id = intval ( $this->uri->segment ( 3 ) ) == 0 ? intval ( $this->input->post ( 'id' ) ) : intval ( $this->uri->segment ( 3 ) ); - if (null !== $this->input->post ( 'submit' )) { - $name = trim ( $this->input->post ( 'name' ) ); // 分类名称 - $aliasname = trim ( $this->input->post ( 'aliasname' ) ); // 分类别名 - $edit_miaosu = trim ( $this->input->post ( 'edit_miaosu' ) ); // 分类描述 - $s_tmplist = trim ( $this->input->post ( 's_tmplist' ) ); // 文章分类模板名字 - $s_articletmplist = trim ( $this->input->post ( 's_articletmplist' ) ); // 文章详情模板名字 - $dir= trim ( $this->input->post ( 'dir' ) ); // 分类目录名称 - $categorydir = ''; - $categorydir = empty($dir) ? '':$dir; - $cid = 0; - $category1 = $this->input->post ( 'category1' ); - $category2 = $this->input->post ( 'category2' ); - $category3 = $this->input->post ( 'category3' ); - if ($category3) { - $cid = $category3; - } else if ($category2) { - $cid = $category2; - } else if ($category1) { - $cid = $category1; - } - if ($cid > 0) { - $category = $this->category [$cid]; // 得到分类信息 - } else { - $category = $this->category [$id]; // 得到分类信息 - } - if ($_FILES ["catimage"] ['name'] != '') { - $uid = $id; - - $avatardir = "/data/category/"; - $extname = extname ( $_FILES ["catimage"] ["name"] ); - if (! isimage ( $extname )) - $this->message ( "图片扩展名不正确!", 'admin_category/editimg' ); - $upload_tmp_file = FCPATH . '/data/tmp/cat_' . $uid . '.' . $extname; - $uid = abs ( $uid ); - $uid = sprintf ( "%09d", $uid ); - $dir1 = $avatardir . substr ( $uid, 0, 3 ); - $dir2 = $dir1 . '/' . substr ( $uid, 3, 2 ); - $dir3 = $dir2 . '/' . substr ( $uid, 5, 2 ); - (! is_dir ( FCPATH . $dir1 )) && forcemkdir ( FCPATH . $dir1 ); - (! is_dir ( FCPATH . $dir2 )) && forcemkdir ( FCPATH . $dir2 ); - (! is_dir ( FCPATH . $dir3 )) && forcemkdir ( FCPATH . $dir3 ); - $bigimg = $dir3 . "/big_" . $uid . '.' . $extname; - $smallimg = $dir3 . "/small_" . $uid . '.' . $extname; - unlink ( FCPATH . $dir3 . "/big_" . $uid . '.jpg' ); - unlink ( FCPATH . $dir3 . "/big_" . $uid . '.png' ); - unlink ( FCPATH . "/small_" . $uid . '.png' ); - unlink ( FCPATH . "/small_" . $uid . '.jpg' ); - if (move_uploaded_file ( $_FILES ["catimage"] ["tmp_name"], $upload_tmp_file )) { - - $avatar_dir = glob ( FCPATH . $dir3 . "/small_{$uid}.*" ); - - foreach ( $avatar_dir as $imgfile ) { - - if (strtolower ( $extname ) != extname ( $imgfile )) - unlink ( $imgfile ); - } - - image_resize ( $upload_tmp_file, FCPATH . $bigimg, 195, 195, 1 ); - - image_resize ( $upload_tmp_file, FCPATH . $smallimg, 32, 32, 1 ); - } - } - $data=array( - 'name'=>$name, - 'dir'=>$categorydir, - 'alias'=>$aliasname, - 'miaosu'=>$edit_miaosu, - 'template'=>$s_tmplist, - 'articletemplate'=>$s_articletmplist, - ); - $this->db->where(array('id'=>$id))->update('category',$data); - //$this->category_model->update_by_id ( $id, $name, $categorydir, $category ['pid'], $aliasname, $edit_miaosu, $s_tmplist ); - cleardir ( FCPATH . '/data/cache' ); // 清除缓存文件 - $pid = $category ['pid']; - if ($pid != 0) { - $this->input->post ( 'cid' ) ? $this->myview ( $this->input->post ( 'cid' ) ) : $this->message ( "操作成功", "admin_category/myview/$pid" ); - } else { - $this->input->post ( 'cid' ) ? $this->myview ( $this->input->post ( 'cid' ) ) : $this->message ( "操作成功", "admin_category" ); - } - } else { - $category = $this->category_model->get ( $id ); - $item = $category; - $selectedarray = array (); - for($grade = $category ['grade']; $grade > 1; $grade --) { - $selectedarray [] = $item ['pid']; - $item = $this->category [$item ['pid']]; - } - if (isset ( $selectedarray ) && count ( $selectedarray ) > 0) { - switch (count ( $selectedarray )) { - case 1 : - list ( $category1 ) = array_reverse ( $selectedarray ); - break; - case 2 : - list ( $category1, $category2 ) = array_reverse ( $selectedarray ); - break; - case 3 : - list ( $category1, $category2, $category3 ) = array_reverse ( $selectedarray ); - break; - } - } - - $categoryjs = $this->category_model->get_js (); - $file_dir = APPPATH . "views/" . $this->setting ['tpl_dir']; - $files = scandir ( $file_dir ); - $catlistfiles = array (); - $articlelistfiles = array (); - foreach ( $files as $file ) { - if (strstr ( $file, 'catlist' )) { - array_push ( $catlistfiles, $file ); - } - if (strstr ( $file, 'topicone' )) { - array_push ( $articlelistfiles, $file ); - } - } - - include template ( 'editcategory', 'admin' ); - } - } - - // 后台分类管理查看一个分类 - function myview($cid = 0, $msg = '') { - $cid = $cid ? $cid : intval ( $this->uri->segment ( 3 ) ); - $navlist = $this->category_model->get_navigation ( $cid ); // 获取导航 - if (isset ( $this->category [$cid] )) { - $category = $this->category [$cid]; - } else { - $category = null; - } - - $categorylist = $this->category_model->list_by_cid ( $cid, $category ['pid'] ); // 获取子分类 - $pid = $cid; - $msg && $message = $msg; - include template ( 'categorylist', 'admin' ); - } - - // 删除分类 - function remove() { - if (null !== $this->input->post ( 'cid' )) { - $cids = implode ( ",", $this->input->post ( 'cid' ) ); - $pid = intval ( $this->input->post ( 'hiddencid' ) ); - $this->category_model->remove ( $cids ); - $this->message ( '分类删除成功!' ); - } - } - - /* 后台分类排序 */ - function reorder() { - $orders = explode ( ",", $this->input->post ( 'order' ) ); - foreach ( $orders as $order => $cid ) { - $this->category_model->order_category ( intval ( $cid ), $order ); - } - $this->cache->remove ( 'category' ); - } - // 修改封面图 - function editimg() { - if (isset ( $_FILES ["catimage"] )) { - $uid = intval ( $this->input->post ( 'catid' ) ); - - $avatardir = "/data/category/"; - $extname = extname ( $_FILES ["catimage"] ["name"] ); - if (! isimage ( $extname )) - $this->message ( "图片扩展名不正确!", 'admin_category/editimg' ); - $upload_tmp_file = FCPATH . '/data/tmp/cat_' . $uid . '.' . $extname; - $uid = abs ( $uid ); - $uid = sprintf ( "%09d", $uid ); - $dir1 = $avatardir . substr ( $uid, 0, 3 ); - $dir2 = $dir1 . '/' . substr ( $uid, 3, 2 ); - $dir3 = $dir2 . '/' . substr ( $uid, 5, 2 ); - (! is_dir ( FCPATH . $dir1 )) && forcemkdir ( FCPATH . $dir1 ); - (! is_dir ( FCPATH . $dir2 )) && forcemkdir ( FCPATH . $dir2 ); - (! is_dir ( FCPATH . $dir3 )) && forcemkdir ( FCPATH . $dir3 ); - $bigimg = $dir3 . "/big_" . $uid . '.' . $extname; - $smallimg = $dir3 . "/small_" . $uid . '.' . $extname; - - if (move_uploaded_file ( $_FILES ["catimage"] ["tmp_name"], $upload_tmp_file )) { - - $avatar_dir = glob ( FCPATH . $dir3 . "/small_{$uid}.*" ); - - foreach ( $avatar_dir as $imgfile ) { - - if (strtolower ( $extname ) != extname ( $imgfile )) - unlink ( $imgfile ); - } - - image_resize ( $upload_tmp_file, FCPATH . $bigimg, 195, 195, 1 ); - - image_resize ( $upload_tmp_file, FCPATH . $smallimg, 32, 32, 1 ); - } - } - header ( "Location:" . SITE_URL . 'index.php?admin_category.html' ); - } -} - -?> \ No newline at end of file diff --git a/application/contorllers/Category.php b/application/contorllers/Category.php deleted file mode 100644 index 30e36c2..0000000 --- a/application/contorllers/Category.php +++ /dev/null @@ -1,292 +0,0 @@ -whitelist = "attentto,search,viewtopic,clist"; - parent::__construct (); - $this->load->model ( 'category_model' ); - $this->load->model ( 'question_model' ); - $this->load->model ( "topic_model" ); - } - - function viewtopic() { - $navtitle = "热门专题"; - $status = null!== $this->uri->segment ( 3 ) ? $this->uri->segment ( 3 ) : 'hot'; - @$page = max ( 1, intval ( $this->uri->segment ( 4 ) ) ); - $pagesize = 21; - $startindex = ($page - 1) * $pagesize; - - $where = "and grade=1 "; - switch ($status) { - - case 'question' : - $where=$where." and isuseask=1 "; - break; - } - - $rownum = returnarraynum ( $this->db->query ( getwheresql ( 'category', " 1=1 $where ", $this->db->dbprefix ) )->row_array () ); - //$userarticle = $this->topic_model->get_user_articles ( 0, 5 ); - $catlist = $this->category_model->listtopic ( $status, $startindex, $pagesize ); - $departstr = page ( $rownum, $pagesize, $page, "category/viewtopic/$status" ); - include template ( 'category_all' ); - } -function view() { - $this->load->model ( "expert_model" ); - - if(intval ( $this->uri->rsegments[3] )==0){ - $catdir=addslashes(strip_tags($this->uri->rsegments[3]));//获取目录 - - $_cat=$this->db->get_where('category',array('dir'=>$catdir))->row_array(); - if($_cat){ - $cid=$_cat['id']; - }else{ - show_404(); - } - }else{ - $cid = intval ( $this->uri->rsegments[3] ) ? intval ( $this->uri->rsegments[3]) : 'all'; - } - - $status = null!== $this->uri->rsegments[4] ? $this->uri->rsegments[4]: 'all'; - @$page = max ( 1, intval ( $this->uri->rsegments[5]) ); - $pagesize = $this->setting ['list_default']; - $startindex = ($page - 1) * $pagesize; //每页面显示$pagesize条 - if ($cid != 'all') { - $category = $this->category [$cid]; //得到分类信息 - $navtitle = $category ['name']; - $cfield = 'cid' . $category ['grade']; - } else { - $category = $this->category; - $navtitle = '全部分类'; - $cfield = ''; - $category ['pid'] = 0; - } - - if ($category ['name'] == '') { - header ( 'HTTP/1.1 404 Not Found' ); - header ( "status: 404 Not Found" ); - echo '404-您访问的页面不存在'; - echo "

404

抱歉,话题不存在!⊂((δ⊥δ))⊃返回主页

'; - exit (); - } - $statusword = ""; - switch ($status) { - case '1' : - $statusword = '待解决'; - break; - case '2' : - $statusword = '已解决'; - break; - case '4' : - $statusword = '高悬赏'; - break; - case '6' : - $statusword = '推荐'; - break; - case 'all' : - $statusword = '全部'; - break; - } - $is_followed = $this->category_model->is_followed ( $cid, $this->user ['uid'] ); - - $rownum = $this->question_model->rownum_by_cfield_cvalue_status ( $cfield, $cid, $status ); //获取总的记录数 - $questionlist = $this->question_model->list_by_cfield_cvalue_status ( $cfield, $cid, $status, $startindex, $pagesize ); //问题列表数据 - $topiclist = $this->topic_model->get_bycatid ( $cid, 0, 8 ); - $followerlist = $this->category_model->get_followers ( $cid, 0, 8 ); //获取导航 - if($catdir){ - $departstr = page ( $rownum, $pagesize, $page, "category/view/$catdir/$status" ); //得到分页字符串 - }else{ - $departstr = page ( $rownum, $pagesize, $page, "category/view/$cid/$status" ); //得到分页字符串 - } - - $navlist = $this->category_model->get_navigation ( $cid ); //获取导航 - $sublist = $this->category_model->list_by_cid_pid ( $cid, $category ['pid'] ); //获取子分类 - $expertlist = $this->expert_model->get_by_cid ( $cid ); //分类专家 - - $cids = array (); - //如果这是顶级分类 - if ($category ['pid'] == 0) { - - //获取当前分类下的子分类--二级分类 - $catlist = $this->category_model->list_by_pid ( $cid ); - - //把顶级分类id写入数组 - array_push ( $cids, $cid ); - //循环获取顶级分类下的子分类 - foreach ( $catlist as $key => $val ) { - - //子分类写入数组 - array_push ( $cids, $val ['id'] ); - //获取子分类下的三级分类 - $catlist1 = $this->category_model->list_by_pid ( $val ['id'] ); - foreach ( $catlist1 as $key1 => $val1 ) { - array_push ( $cids, $val1 ['id'] ); - } - - } - - } else { - - //如果不是顶级分类,先将分类id写入数组 - array_push ( $cids, $cid ); - - //获取该分类下的父亲级别的分类 - // $catlist=$this->category_model->list_by_pid($catmodel['pid']); - - - //获取该分类下的子分类 - $catlist = $this->category_model->list_by_pid ( $cid ); - - if ($catlist) { - - //遍历子分类写入数组 - foreach ( $catlist as $key => $val ) { - array_push ( $cids, $val ['id'] ); - } - - } - - - - // var_dump($catmodel);exit(); - } - - $cidsp = implode ( ',', $cids ); - $trownum = returnarraynum ( $this->db->query ( getwheresql ( 'topic', " articleclassid in($cidsp) ", $this->db->dbprefix ) )->row_array () ); - /* SEO */ - if ($category ['alias']) { - $navtitle = $category ['alias']; - } - $seo_keywords = $navtitle; - $seo_description = $this->setting ['site_name'] . $navtitle . '频道,提供' . $navtitle . '相关问题及答案,' . $statusword . '问题,第' . $page . "页。"; - ; - /* SEO */ - if ($category ['miaosu']) { - $seo_description =strip_tags( $category ['miaosu']); - } - if ($this->setting ['seo_category_title']) { - $seo_title = str_replace ( "{wzmc}", $this->setting ['site_name'], $this->setting ['seo_category_title'] ); - $seo_title = str_replace ( "{flmc}", $navtitle, $seo_title ); - - $seo_title = $seo_title . '_' . $statusword . '_第' . $page . "页"; - } else { - $navtitle = $navtitle . '_' . $statusword . '_第' . $page . "页"; - } - - if ($this->setting ['seo_category_description']) { - $seo_description = str_replace ( "{wzmc}", $this->setting ['site_name'], $this->setting ['seo_category_description'] ); - $seo_description = str_replace ( "{flmc}", $navtitle, $seo_description ); - } - if ($this->setting ['seo_category_keywords']) { - $seo_keywords = str_replace ( "{wzmc}", $this->setting ['site_name'], $this->setting ['seo_category_keywords'] ); - $seo_keywords = str_replace ( "{flmc}", $navtitle, $seo_keywords ); - } - $category['bigimage'] = get_cid_dir ( $category['id'], 'big' ); - - //相关分类标签 - $this->load->model ( "tag_model" ); - $relativetags = $this->tag_model->gettaglistbycid ( $cid ); - include template ( 'category' ); - } - -function search() { - - $hidefooter = 'hidefooter'; - $type = "category"; - $this->load->helper ( 'security' ); - if ($_GET ['word']) { - $word = xss_clean ( $_GET ['word'] ); - } else { - $word = xss_clean ( $_GET [0] ); - } - $word = str_replace ( array ("\\", "'", " ", "/", "&" ), "", $word ); - $word = strip_tags ( $word ); - $word = htmlspecialchars ( $word ); - if (isset ( $_SERVER ['HTTP_X_REWRITE_URL'] )&&$_GET ['word']==null) { - - if (function_exists ( "iconv" ) && $this->uri->rsegments [3] != null) { - $word = iconv ( "GB2312", "UTF-8//IGNORE",$this->uri->rsegments [3] ); - - } - }else if(isset($_SERVER['ORIG_PATH_INFO'])&&$_GET ['word']==null) { - $word = iconv ( "GB2312", "UTF-8//IGNORE",$this->uri->rsegments [3] ); - } - $word = taddslashes ( $word, 1 ); - (! $word) && $this->message ( "搜索关键词不能为空!", 'BACK' ); - $navtitle = $word; - @$page = max ( 1, intval ( $this->uri->rsegments [4] ) ); - $pagesize = $this->setting ['list_default']; - $startindex = ($page - 1) * $pagesize; - $seo_description = $word; - $seo_keywords = $word; - $word=addslashes($word); - $rownum = returnarraynum ( $this->db->query ( getwheresql ( 'category', " `name` like '%$word%' ", $this->db->dbprefix ) )->row_array () ); - - $catlist = $this->category_model->list_by_name ( $word, $startindex, $pagesize ); - - $departstr = page ( $rownum, $pagesize, $page, "category/search/$word" ); - include template ( 'serach_category' ); - } - function clist() { - $status = null!== $this->uri->segment ( 3 ) ? $this->uri->segment ( 3 ) : 'all'; - $navtitle = $statustitle = $this->statusarray [$status]; - @$page = max ( 1, intval ( $this->uri->segment ( 4 ) ) ); - $pagesize = $this->setting ['list_default']; - $startindex = ($page - 1) * $pagesize; //每页面显示$pagesize条 - - - $rownum = $this->question_model->rownum_by_cfield_cvalue_status ( '', 0, $status ); //获取总的记录数 - $questionlist = $this->question_model->list_by_cfield_cvalue_status ( '', 0, $status, $startindex, $pagesize ); //问题列表数据 - $departstr = page ( $rownum, $pagesize, $page, "category/list/$status" ); //得到分页字符串 - $metakeywords = $navtitle; - $metadescription = '问题列表' . $navtitle; - include template ( 'list' ); - } - - function recommend() { - $this->load ( 'topic' ); - $navtitle = '专题列表'; - @$page = max ( 1, intval ( $this->uri->segment ( 3 ) ) ); - $pagesize = $this->setting ['list_default']; - $startindex = ($page - 1) * $pagesize; - $rownum = returnarraynum ( $this->db->query ( getwheresql ( 'topic', ' 1=1 ', $this->db->dbprefix ) )->row_array () ); - ; - $topiclist = $this->topic_model->get_list ( 2, $startindex, $pagesize ); - $departstr = page ( $rownum, $pagesize, $page, "category/recommend" ); - $metakeywords = $navtitle; - $metadescription = '精彩推荐列表'; - include template ( 'recommendlist' ); - } - function attentto() { - $cid = intval ( $this->input->post ( 'cid' ) ); - if (! $cid) { - exit ( 'error' ); - } - if ($this->user ['uid'] == 0) { - exit ( "-1" ); - } - $is_followed = $this->category_model->is_followed ( $cid, $this->user ['uid'] ); - if ($is_followed) { - $this->category_model->unfollow ( $cid, $this->user ['uid'] ); - $this->load->model ( "doing_model" ); - $this->doing_model->deletedoing ( $this->user ['uid'], 10, $cid ); - } else { - $this->load->model ( "doing_model" ); - $category = $this->category [$cid]; //得到分类信息 - $this->doing_model->add ( $this->user ['uid'], $this->user ['username'], 10, $cid, $category ['name'] ); - $this->category_model->follow ( $cid, $this->user ['uid'] ); - - } - exit ( 'ok' ); - } - -} - -?> \ No newline at end of file diff --git a/application/contorllers/Topic.php b/application/contorllers/Topic.php deleted file mode 100644 index 2625069..0000000 --- a/application/contorllers/Topic.php +++ /dev/null @@ -1,1131 +0,0 @@ -whitelist = "articlelist,putyuyin,paylist,wappayarticle,deletearticlecomment,getuserarticles,getnewlist,getbycatidanduid,posttopicreward"; - parent::__construct (); - $this->load->model ( 'topic_model' ); - $this->load->model ( 'topic_tag_model' ); - $this->load->model ( 'articlecomment_model' ); - $this->load->model ( 'category_model' ); - $this->load->model ( 'question_model' ); - } - - // 文章点赞 - function ajaxhassupport() { - $answerid = intval ( $this->uri->segment ( 3 ) ); - $supports = $this->topic_model->get_support_by_sid_aid ( $this->user ['sid'], $answerid ); - $ret = $supports ? '1' : '-1'; - exit ( $ret ); - } - function ajaxaddsupport() { - $tid = intval ( $this->uri->segment ( 3 ) ); - $article = $this->topic_model->get ( $tid ); - $this->topic_model->add_support ( $this->user ['sid'], $tid, $article ['authorid'] ); - $answer = $this->topic_model->getcomment ( $tid ); - - exit ( $answer ['supports'] ); - } - // 添加文章评论 - function ajaxaddarticlecomment() { - $tid = isset ( $_POST ['tid'] ) ? intval ( $_POST ['tid'] ) : 0; - if ($tid == 0) { - $message ['code'] = 201; - $message ['msg'] = '文章不存在'; - echo json_encode ( $message ); - exit (); - } - $aid = isset ( $_POST ['aid'] ) ? intval ( $_POST ['aid'] ) : 0; - if ($aid == 0) { - $message ['code'] = 201; - $message ['msg'] = '文章评论不存在'; - echo json_encode ( $message ); - exit (); - } - if ($this->user ['uid'] == 0) { - $message ['code'] = 201; - $message ['msg'] = '请先登录'; - echo json_encode ( $message ); - exit (); - } - if (isset ( $this->setting ['register_on'] ) && $this->setting ['register_on'] == '1') { - if ($this->user ['active'] != 1) { - $message ['code'] = 201; - $message ['msg'] = "必须激活邮箱才能评论!"; - echo json_encode ( $message ); - exit (); - } - } - $touid = isset ( $_POST ['touid'] ) ? intval ( $_POST ['touid'] ) : 0; - - $content = $this->input->post ( 'content' ) != null ? strip_tags ( $this->input->post ( 'content' ) ) : ''; - if ($content == '') { - $message ['code'] = 201; - $message ['msg'] = '评论不能为空'; - echo json_encode ( $message ); - exit (); - } - if (strlen ( $content ) > 300) { - $message ['code'] = 201; - $message ['msg'] = '评论不能超过100字'; - echo json_encode ( $message ); - exit (); - } - // 获取当前的文章 - $article = $this->topic_model->get ( $tid ); - if (! $article) { - $message ['code'] = 201; - $message ['msg'] = '文章不存在'; - echo json_encode ( $message ); - exit (); - } - // 检查评论内容 - $mywords = checkwords ( $content ); - if ($mywords [0] == 2) { - $message ['code'] = 201; - $message ['msg'] = '评论包含敏感信息'; - echo json_encode ( $message ); - exit (); - } - if ($touid) { - if ($touid == $this->user ['uid']) { - $message ['code'] = 201; - $message ['msg'] = '不能@自己'; - echo json_encode ( $message ); - exit (); - } - $this->load->model ( 'user_model' ); - $touser = $this->user_model->get_by_uid ( $touid ); - $userspaceurl = url ( 'user/space/' . $touser ['uid'] ); - $tousername = $touser ['username']; - $content = "@$tousername " . $content; - } - $data ['tid'] = intval ( $tid ); - $data ['aid'] = intval ( $aid ); - $data ['authorid'] = $this->user ['uid']; - $data ['author'] = $this->user ['username']; - $data ['content'] = $content; - $data ['time'] = time (); - - $id = $this->articlecomment_model->addarticlecomment ( $data ); - if ($id) { - if ($touid) { - // 如果有@别,发私信过去 - $this->load->model ( "message_model" ); - $subject = "您的文章评论有新回复"; - $title = $article ['title']; - $aurl = url ( "topic/getone/" . $article ['id'] ); - $contentmsg = "您对文章[$title]的评论,对方回复:
$content" . "点击查看详情"; - $this->message_model->add ( $this->user ['username'], $this->user ['uid'], $touser ['uid'], $subject, $contentmsg, 'questioncomment' ); - - //发送邮件通知 - $quser=$this->user_model->get_by_uid($article['authorid']); - //如果作者开启文章评论邮件通知,且评论不是作者本人 - if($quser['notify']['comment_reply']==1&&$quser['uid']!=$this->user ['uid']){ - $subject = "文章[".$title."]有新评论![评论回复通知]"; - $sendmessage = $content. '

现在您可以点击查看最新评论回复

'; - sendmail ( $quser, $subject, $sendmessage ); - - } - - } - $message ['code'] = 200; - $message ['msg'] = '评论成功'; - echo json_encode ( $message ); - exit (); - } - } - // 获取文章评论的回复 - function ajaxgetcommentlist() { - $tid = isset ( $_POST ['tid'] ) ? intval ( $_POST ['tid'] ) : 0; - if ($tid == 0) { - $message ['code'] = 201; - $message ['msg'] = '文章不存在'; - echo json_encode ( $message ); - exit (); - } - $aid = isset ( $_POST ['aid'] ) ? intval ( $_POST ['aid'] ) : 0; - if ($aid == 0) { - $message ['code'] = 201; - $message ['msg'] = '文章评论不存在'; - echo json_encode ( $message ); - exit (); - } - $commentlist = $this->articlecomment_model->getarticlecommentlist ( $tid, $aid ); - $message ['code'] = 200; - $message ['msg'] = json_encode ( $commentlist ); - echo json_encode ( $message ); - exit (); - } - // 删除文章评论回复 - function ajaxdelartcomment() { - $id = isset ( $_POST ['id'] ) ? intval ( $_POST ['id'] ) : 0; - if ($id == 0) { - $message ['code'] = 201; - $message ['msg'] = '文章评论不存在'; - echo json_encode ( $message ); - exit (); - } - // 获取当前评论 - $comment = $this->articlecomment_model->getoneartcomment ( $id ); - if (! $comment) { - $message ['code'] = 201; - $message ['msg'] = '文章评论回复不存在'; - echo json_encode ( $message ); - exit (); - } else { - if ($this->user ['grouptype'] != 1) { - if ($comment ['authorid'] != $this->user ['uid']) { - $message ['code'] = 201; - $message ['msg'] = '只有作者本人才能删除评论'; - echo json_encode ( $message ); - exit (); - } - } - - $this->articlecomment_model->delartcomment ( $id, $comment ['aid'] ); - $message ['code'] = 200; - $message ['msg'] = '删除成功'; - echo json_encode ( $message ); - exit (); - } - } - // 删除评论 - function deletearticlecomment() { - if ($this->user ['uid'] == 0) { - $this->message ( "你还没登录!", 'user/login' ); - } - $tid = intval ( $this->uri->segment ( 4 ) ); - $id = intval ( $this->uri->segment ( 3 ) ); - $viewurl = urlmap ( 'topic/getone/' . $tid, 2 ); - $article = $this->topic_model->getcomment ( $id ); - if ($this->user ['grouptype'] != 1) { - if ($article ['authorid'] != $this->user ['uid']) { - $this->message ( "非法操作!", $viewurl ); - } - } - $this->topic_model->remove_by_tid ( $id, $tid ); - $this->message ( "文章评论删除成功!", $viewurl ); - } - function ajaxviewtopic() { - $tid = intval ( $this->uri->segment ( 3 ) ); - - $topic = $this->topic_model->get ( $tid ); - if ($topic ['price'] == 0) - exit ( '-1' ); - - include template ( "viewtopic" ); - } - function posttopicreward() { - $tid = intval ( $this->input->post ( 'tid' ) ); - $topic = $this->topic_model->get ( $tid ); - $readmode = $topic ['readmode']; - // 用户没登录 - if ($this->user ['uid'] == 0) - exit ( '-2' ); - - // 此文章不需要付费 - if ($topic ['price'] == 0) - exit ( '-1' ); - - $cash_fee = $topic ['price']; - if ($readmode == '2') { - if ($this->user ['credit2'] < $topic ['price']) { - // 用户积分不足 - exit ( '0' ); - } - } - if ($readmode == '3') { - if (round ( $this->user ['jine'] / 100 ) < $topic ['price']) { - // 用户账户余额不足 - exit ( '7' ); - } - } - - if ($this->user ['uid'] == $topic ['authorid']) { - // 偷看的是本人 - exit ( '-3' ); - } - - $readuid = $this->user ['uid']; - $authorid = $topic ['authorid']; - $one = $this->topic_model->getreaduser ( $readuid, $tid ); - if ($one != null) { - // 已经付费过了 - exit ( '2' ); - } - // addtopicviewhistory - $id = $this->topic_model->addtopicviewhistory ( $this->user ['uid'], $this->user ['username'], $tid ); - if ($id > 0) { - if ($readmode == '2') { - // 阅读的人积分扣减 - $this->db->query ( "UPDATE " . $this->db->dbprefix . "user SET `credit2`=credit2-$cash_fee WHERE `uid`=$readuid" ); - - // 作者获得积分 - - $this->db->query ( "UPDATE " . $this->db->dbprefix . "user SET `credit2`=credit2+$cash_fee WHERE `uid`=$authorid" ); - - $this->load->model ( "doing_model" ); - $this->doing_model->add ( $this->user ['uid'], $this->user ['username'], 15, $tid, $topic ['title'] ); - } - if ($readmode == '3') { - $paycash_fee = $cash_fee * 100; - // 阅读的人金额扣减 - $this->db->query ( "UPDATE " . $this->db->dbprefix . "user SET `jine`=jine-$paycash_fee WHERE `uid`=$readuid" ); - $useruid = $this->user ['uid']; - $time = time (); - $authorid = $topic ['authorid']; - // 作者获得金额 - $this->db->query ( "UPDATE " . $this->db->dbprefix . "user SET `jine`=jine+$paycash_fee WHERE `uid`=$authorid" ); - $this->db->query ( "INSERT INTO " . $this->db->dbprefix . "paylog SET type='topayarticle',typeid=$tid,money=$cash_fee,openid='',fromuid=$authorid,touid=$useruid,`time`=$time" ); - $this->db->query ( "INSERT INTO " . $this->db->dbprefix . "paylog SET type='payarticle',typeid=$tid,money=$cash_fee,openid='',fromuid=$useruid,touid=$authorid,`time`=$time" ); - } - exit ( '1' ); - } else { - exit ( '-4' ); - } - } - - function search() { - $hidefooter = 'hidefooter'; - - $type = "topic"; - $this->load->helper ( 'security' ); - if ($_GET ['word']) { - $word = xss_clean ( $_GET ['word'] ); - } else { - $word = xss_clean ( $_GET [0] ); - } - - - - if (isset ( $_SERVER ['HTTP_X_REWRITE_URL'] ) && $_GET ['word'] == null) { - - if (function_exists ( "iconv" ) && $this->uri->rsegments [3] != null) { - $word = iconv ( "GB2312", "UTF-8//IGNORE", $this->uri->rsegments [3] ); - } - } else if (isset ( $_SERVER ['ORIG_PATH_INFO'] ) && $_GET ['word'] == null) { - $word = iconv ( "GB2312", "UTF-8//IGNORE", $this->uri->rsegments [3] ); - } - - if ($word == null) { - if ($this->uri->segment ( 3 ) != null) { - $word = urldecode ( $this->uri->rsegments [3] ); - } - } - if ($word == null) { - $word = trim ( $this->input->post ( 'word' ) ) ? trim ( $this->input->post ( 'word' ) ) : urldecode ( $_word ); - } - (! $word) && $this->message ( "搜索关键词不能为空!", 'BACK' ); - - $navtitle = $word; - if($_GET['pageindex']){ - @$page = max ( 1, intval ($_GET['pageindex']) ); - }else{ - @$page = max ( 1, intval ( $this->uri->rsegments [4] ) ); - } - - $pagesize = $this->setting ['list_default']; - $startindex = ($page - 1) * $pagesize; - $seo_description = $word; - $seo_keywords = $word; - $topiclist = null; // 定义空文章数组 - // $rownum = $this->topic_model->rownum_by_tag($word); - - // $topiclist = $this->topic_model->list_by_tag($word, $startindex, $pagesize); - // if($topiclist==null){ - - $topiclist = $this->topic_model->get_bylikename ( $word, $startindex, $pagesize ); - // } - $rownum = $this->topic_model->rownum_by_title ( $word ); - foreach ( $topiclist as $key => $val ) { - - $taglist = $this->topic_tag_model->get_by_aid ( $val ['id'] ); - - $topiclist [$key] ['tags'] = $taglist; - } - $pageurl = url ( 'topic/search' ) . "?word=$word"; - $departstr = cpage ( $rownum, $pagesize, $page, $pageurl ); - - - include template ( 'topictag' ); - } - function cancelhot() { - $id = intval ( $this->uri->segment ( 3 ) ); - $this->topic_model->updatetopichot ( $id, '0' ); - $this->message ( "取消顶置成功!", urlmap ( 'topic/hotlist' ) ); - } - function pushhot() { - $id = intval ( $this->uri->segment ( 3 ) ); - $this->topic_model->updatetopichot ( $id, '1' ); - $this->message ( "推荐到首页成功!", urlmap ( 'topic/hotlist' ) ); - } - function ajaxpostsupportcomment() { - $message = array (); - $cmid = intval ( $this->input->post ( 'cmid' ) ); - $this->load->model ( "articlecomment_model" ); - $this->articlecomment_model->updatecmsupport ( $cmid ); - - $message ['state'] = 1; - - echo json_encode ( $message ); - exit (); - } - function ajaxpostcomment() { - $message = array (); - if ($this->user ['uid'] <= 0) { - $message ['state'] = - 1; - $message ['msg'] = "登录后可发布评论"; - echo json_encode ( $message ); - exit (); - } - if (isset ( $this->setting ['register_on'] ) && $this->setting ['register_on'] == '1') { - if ($this->user ['active'] != 1) { - $message ['code'] = 201; - $message ['msg'] = "必须激活邮箱才能评论!"; - echo json_encode ( $message ); - exit (); - } - } - $content = $this->input->post ( 'content' ); - $title = strip_tags ( $this->input->post ( 'title' ) ); - $tid = intval ( $this->input->post ( 'tid' ) ); - $this->load->model ( "articlecomment_model" ); - - $onecorder = $this->articlecomment_model->checkhascomment ( $tid, $this->user ['uid'] ); - if ($onecorder != null) { - $message ['state'] = 0; - $message ['msg'] = "您已经评论过了!"; - echo json_encode ( $message ); - exit (); - } - // 检查评论内容 - $mywords = checkwords ( $content ); - if ($mywords [0] == 2) { - $message ['code'] = 201; - $message ['msg'] = '评论包含敏感信息'; - echo json_encode ( $message ); - exit (); - } - $status = 1; - $supports = rand ( 1, 5 ); - $id = $this->articlecomment_model->add_seo ( $tid, $title, $content, $this->user ['uid'], $this->user ['username'], $status, $supports ); - if ($id > 0) { - $message ['state'] = 1; - $message ['msg'] = "评论成功!"; - - $state = intval ( $this->setting ['publisharticlecommentcheck'] ) > 0 ? 0 : 1; - if ($state == 1) { - $topicone = $this->topic_model->get ( $tid ); - - $message ['msg'] = "评论成功!"; - $this->load->model ( "doing_model" ); - - $this->doing_model->add ( $this->user ['uid'], $this->user ['username'], 14, $tid, $content ); - - //发送邮件通知 - $quser=$this->user_model->get_by_uid($topicone['authorid']); - //如果作者开启文章评论邮件通知,且评论不是作者本人 - if($quser['notify']['comment']==1&&$quser['uid']!=$this->user ['uid']){ - $subject = "文章[".$title."]有新评论!"; - $sendmessage = $content. '

现在您可以点击查看最新评论

'; - sendmail ( $quser, $subject, $sendmessage ); - - } - - - } else { - - $message ['msg'] = "评论成功,等待审核!"; - } - } else { - $message ['state'] = 0; - $message ['msg'] = "评论失败!"; - } - - echo json_encode ( $message ); - exit (); - } - function paylist() { - $navtitle = "付费阅读文章专栏"; - $typename="pay"; - @$page = max ( 1, intval ( $this->uri->segment ( 4 ) ) ); - $pagesize = $this->setting ['list_default']; - $startindex = ($page - 1) * $pagesize; - $readmode=$this->uri->segment ( 3 )=='money' ? 3:2; - $rownum = returnarraynum ( $this->db->query ( getwheresql ( 'topic', ' readmode='.$readmode.' and state=1 ', $this->db->dbprefix ) )->row_array () ); - - $topiclist = $this->topic_model->get_paylist ( $startindex, $pagesize,$readmode ); - - $departstr = page ( $rownum, $pagesize, $page, "topic/paylist" ); - - $sublist = $this->category_model->list_by_cid_pid_all ( 0, 0 ); // 获取子分类 - include template ( 'topic' ); - } - function hotlist() { - $navtitle = "最新文章推荐"; - $typename="top"; - @$page = max ( 1, intval ( $this->uri->segment ( 3 ) ) ); - $pagesize = $this->setting ['list_default']; - $startindex = ($page - 1) * $pagesize; - $rownum = returnarraynum ( $this->db->query ( getwheresql ( 'topic', ' ispc=1 and state=1 ', $this->db->dbprefix ) )->row_array () ); - - - $topiclist = $this->topic_model->get_hotlist ( 1, $startindex, $pagesize, 12 ); - $departstr = page ( $rownum, $pagesize, $page, "topic/hotlist" ); - - $sublist = $this->category_model->list_by_cid_pid_all ( 0, 0 ); // 获取子分类 - include template ( 'topic' ); - } - function weeklist() { - $navtitle = "热门文章"; - $typename="hot"; - @$page = max ( 1, intval ( $this->uri->segment ( 3 ) ) ); - $pagesize = $this->setting ['list_default']; - $startindex = ($page - 1) * $pagesize; - $timeweekstart = time() - 7 * 24 * 3600; - $timedaystart = time()- 1 * 24 * 3600; - $timemonthstart = time() - 30 * 24 * 3600; - $timeyearstart = time() - 365 * 24 * 3600; - $timeend = time(); - $query = null; - $rownum=0; - // 先看一天内文章是否超过10条 - $dayrownum = returnarraynum ( $this->db->query ( getwheresql ( 'topic', " state=1 AND `viewtime`>$timedaystart AND `viewtime`<$timeend ", $this->db->dbprefix ) )->row_array () ); - if ($dayrownum >= 10) { - $rownum=$dayrownum; - } else { - - // 看这一周是否超过10条 - $weekrownum = returnarraynum ( $this->db->query ( getwheresql ( 'topic', " state=1 AND `viewtime`>$timeweekstart AND `viewtime`<$timeend ", $this->db->dbprefix ) )->row_array () ); - if ($weekrownum >= 10) { - $rownum=$weekrownum; - } else { - // 看这一月是否超过10条 - $monthrownum = returnarraynum ( $this->db->query ( getwheresql ( 'topic', " state=1 AND `viewtime`>$timemonthstart AND `viewtime`<$timeend ", $this->db->dbprefix ) )->row_array () ); - - if ($monthrownum >= 10) { - $rownum=$monthrownum; - }else{ - // 看这一月是否超过10条 - $rownum = returnarraynum ( $this->db->query ( getwheresql ( 'topic', " state=1 AND `viewtime`>$timeyearstart AND `viewtime`<$timeend ", $this->db->dbprefix ) )->row_array () ); - - - } - } - } - - $topiclist = $this->topic_model->get_weeklist ( $startindex, $pagesize ); - $departstr = page ( $rownum, $pagesize, $page, "topic/weeklist" ); - - $sublist = $this->category_model->list_by_cid_pid_all ( 0, 0 ); // 获取子分类 - - include template ( 'topic' ); - } - // 获取最新文章 - function getnewlist() { - @$page = max ( 1, intval ( $this->uri->segment ( 3 ) ) ); - $pagesize = 6; - $startindex = ($page - 1) * $pagesize; - $wzrownum = returnarraynum ( $this->db->query ( getwheresql ( 'topic', '1=1 and state=1 ', $this->db->dbprefix ) )->row_array () ); - $topiclist = $this->topic_model->get_list ( 2, $startindex, $pagesize ); - - echo json_encode ( $topiclist ); - exit (); - } - function getbycatidanduid() { - $pagesize = 6; - $muid = intval ( $this->uri->segment ( 3 ) ); - - @$page = max ( 1, intval ( $this->uri->segment ( 5 ) ) ); - $startindex = ($page - 1) * $pagesize; - if ($this->uri->segment ( 4 ) == 'all') { - - $topiclist = $this->topic_model->get_list_byuid ( $muid, $startindex, $pagesize ); - echo json_encode ( $topiclist ); - exit (); - } - $cid = intval ( $this->uri->segment ( 4 ) ); - - $topiclist = $this->topic_model->get_list_bycidanduid ( $cid, $muid, $startindex, $pagesize ); - - echo json_encode ( $topiclist ); - exit (); - } - - // 获取用户相关的文章数和关注数 - function getuserarticles() { - @$page = max ( 1, intval ( $this->uri->segment ( 3 ) ) ); - $pagesize = 8; - $startindex = ($page - 1) * $pagesize; - $userrownum = $this->topic_model->rownum_by_user_article (); - - $topiclist = $this->topic_model->get_user_articles ( $startindex, $pagesize ); - echo json_encode ( $topiclist ); - exit (); - } - function index() { - $url=url("seo/index"); -header("Location: $url"); -exit(); - $navtitle = "最新文章专栏推荐"; - $seo_description = "推荐问答最新文章专栏,热门文章和最新文章推荐。"; - $seo_keywords = "问答文章专栏"; - $typename="new"; - @$page = max ( 1, intval ( $this->uri->segment ( 3 ) ) ); - $pagesize = $this->setting ['list_default']; - $startindex = ($page - 1) * $pagesize; - - $rownum = returnarraynum ( $this->db->query ( getwheresql ( 'topic', ' id>0 and state=1 ', $this->db->dbprefix ) )->row_array () ); - $pages = @ceil ( $rownum / $pagesize ); - $topiclist = $this->topic_model->get_list ( 2, $startindex, $pagesize ); - - $departstr = page ( $rownum, $pagesize, $page, "topic/default" ); - $metakeywords = $navtitle; - $metadescription = '精彩推荐列表'; - $sublist = $this->category_model->list_by_cid_pid_all ( 0, 0 ); // 获取子分类 - - include template ( 'topic' ); - } - /** - - * 获取文章列表根据分类 - - * @date: 2019年5月19日 下午1:38:33 - - * @author: 61703 - - * @param: variable - - * @return: - - */ - function articlelist(){ - $catid = intval ( $this->uri->rsegments [3] ); - - @$page = max ( 1, intval ( $this->uri->rsegments [4] ) ); - $catmodel = $this->category_model->get ( $catid ); - $navtitle = $catmodel ['name']; - $cids = array (); - $pid=0; - // 如果这是顶级分类 - if ($catmodel ['pid'] == 0) { - - // 获取当前分类下的子分类--二级分类 - $catlist = $this->category_model->list_by_pid ( $catid ); - - // 把顶级分类id写入数组 - array_push ( $cids, $catid ); - // 循环获取顶级分类下的子分类 - foreach ( $catlist as $key => $val ) { - - // 子分类写入数组 - array_push ( $cids, $val ['id'] ); - // 获取子分类下的三级分类 - $catlist1 = $this->category_model->list_by_pid ( $val ['id'] ); - foreach ( $catlist1 as $key1 => $val1 ) { - array_push ( $cids, $val1 ['id'] ); - } - } - } else { - - $pid=$catmodel['pid']; - // 如果不是顶级分类,先将分类id写入数组 - array_push ( $cids, $catid ); - - - // 获取该分类下的子分类 - $catlist = $this->category_model->list_by_pid ( $catid ); - - if ($catlist) { - - // 遍历子分类写入数组 - foreach ( $catlist as $key => $val ) { - array_push ( $cids, $val ['id'] ); - } - } - - if ($catmodel ['grade'] == 3) { - - $catlist = $this->category_model->list_by_pid ( $catmodel ['pid'] ); - - $catmodel = $this->category_model->get ( $catmodel ['pid'] ); - } - - - } - - $cid = implode ( ',', $cids ); - - $pagesize = $catmodel ['template'] == 'catlist_text' ? 40 : $this->setting ['list_default']; - $startindex = ($page - 1) * $pagesize; - $rownum = returnarraynum ( $this->db->query ( getwheresql ( 'topic', "articleclassid in($cid) and state=1 ", $this->db->dbprefix ) )->row_array () ); - $trownum = returnarraynum ( $this->db->query ( getwheresql ( 'topic', " articleclassid in($cid) and state=1 ", $this->db->dbprefix ) )->row_array () ); - $topiclist = $this->topic_model->get_bycatid ( $cid, $startindex, $pagesize ); - - - $departstr = page ( $rownum, $pagesize, $page, "topic/catlist/$catid" ); - - /* SEO */ - $seo_keywords = $navtitle; - $seo_description = $this->setting ['site_name'] . $navtitle . '频道,提供' . $navtitle . '相关文章。'; - if ($this->setting ['seo_category_title']) { - $seo_title = str_replace ( "{wzmc}", $this->setting ['site_name'], $this->setting ['seo_category_title'] ); - $seo_title = str_replace ( "{flmc}", $navtitle, $seo_title ); - if ($page == 1) { - } else { - $seo_title = $seo_title . '_第' . $page . "页"; - } - } else { - if ($page == 1) { - } else { - $navtitle = $navtitle . '_第' . $page . "页"; - } - } - - if ($this->setting ['seo_category_description']) { - $seo_description = str_replace ( "{wzmc}", $this->setting ['site_name'], $this->setting ['seo_category_description'] ); - $seo_description = str_replace ( "{flmc}", $navtitle, $seo_description ); - } - if ($this->setting ['seo_category_keywords']) { - $seo_keywords = str_replace ( "{wzmc}", $this->setting ['site_name'], $this->setting ['seo_category_keywords'] ); - $seo_keywords = str_replace ( "{flmc}", $navtitle, $seo_keywords ); - } - - include template ( 'topic' ); - } - function catlist() { - if(intval ( $this->uri->rsegments[3] )==0){ - $catdir=addslashes(strip_tags($this->uri->rsegments[3]));//获取目录 - $_cat=$this->db->get_where('category',array('dir'=>$catdir))->row_array(); - if($_cat){ - $catid=$_cat['id']; - }else{ - show_404(); - } - }else{ - $catid = intval ( $this->uri->rsegments [3] ); - } - - //相关分类标签 - $this->load->model ( "tag_model" ); - $relativetags = $this->tag_model->gettaglistbycid ( $catid ); - - $is_followed = $this->category_model->is_followed ( $catid, $this->user ['uid'] ); - $followerlist = $this->category_model->get_followers ( $catid, 0, 8 ); // 获取导航 - @$page = max ( 1, intval ( $this->uri->rsegments [4] ) ); - $catmodel = $this->category_model->get ( $catid ); - $navtitle = $catmodel ['name']; - $cids = array (); - - // 如果这是顶级分类 - if ($catmodel ['pid'] == 0) { - - // 获取当前分类下的子分类--二级分类 - $catlist = $this->category_model->list_by_pid ( $catid ); - - // 把顶级分类id写入数组 - array_push ( $cids, $catid ); - // 循环获取顶级分类下的子分类 - foreach ( $catlist as $key => $val ) { - - // 子分类写入数组 - array_push ( $cids, $val ['id'] ); - // 获取子分类下的三级分类 - $catlist1 = $this->category_model->list_by_pid ( $val ['id'] ); - foreach ( $catlist1 as $key1 => $val1 ) { - array_push ( $cids, $val1 ['id'] ); - } - } - } else { - - // 如果不是顶级分类,先将分类id写入数组 - array_push ( $cids, $catid ); - - // 获取该分类下的父亲级别的分类 - // $catlist=$this->category_model->list_by_pid($catmodel['pid']); - - - - if ($catmodel ['grade'] == 3) { - - //$catlist = $this->category_model->list_by_pid ( $catmodel ['pid'] ); - - $parentcatmodel = $this->category_model->get ( $catmodel ['pid'] ); - }else{ - // 获取该分类下的子分类 - $catlist = $this->category_model->list_by_pid ( $catid ); - - if ($catlist) { - - // 遍历子分类写入数组 - foreach ( $catlist as $key => $val ) { - array_push ( $cids, $val ['id'] ); - } - } - } - - // var_dump($catmodel);exit(); - } - - $cid = implode ( ',', $cids ); - - $pagesize = $catmodel ['template'] == 'catlist_text' ? 40 : $this->setting ['list_default']; - $startindex = ($page - 1) * $pagesize; - $rownum = returnarraynum ( $this->db->query ( getwheresql ( 'topic', "articleclassid in($cid) and state=1 ", $this->db->dbprefix ) )->row_array () ); - $trownum = returnarraynum ( $this->db->query ( getwheresql ( 'topic', " articleclassid in($cid) and state=1 ", $this->db->dbprefix ) )->row_array () ); - $topiclist = $this->topic_model->get_bycatid ( $cid, $startindex, $pagesize ); - - foreach ( $topiclist as $key => $val ) { - - $taglist = $this->topic_tag_model->get_by_aid ( $val ['id'] ); - - $topiclist [$key] ['tags'] = $taglist; - } - if($catdir){ - $departstr = page ( $rownum, $pagesize, $page, "topic/catlist/$catdir" ); - }else{ - $departstr = page ( $rownum, $pagesize, $page, "topic/catlist/$catid" ); - } - - - /* SEO */ - $seo_keywords = $navtitle; - $seo_description = $this->setting ['site_name'] . $navtitle . '频道,提供' . $navtitle . '相关文章。'; - if ($this->setting ['seo_category_title']) { - $seo_title = str_replace ( "{wzmc}", $this->setting ['site_name'], $this->setting ['seo_category_title'] ); - $seo_title = str_replace ( "{flmc}", $navtitle, $seo_title ); - if ($page == 1) { - } else { - $seo_title = $seo_title . '_第' . $page . "页"; - } - } else { - if ($page == 1) { - } else { - $navtitle = $navtitle . '_第' . $page . "页"; - } - } - - if ($this->setting ['seo_category_description']) { - $seo_description = str_replace ( "{wzmc}", $this->setting ['site_name'], $this->setting ['seo_category_description'] ); - $seo_description = str_replace ( "{flmc}", $navtitle, $seo_description ); - } - if ($this->setting ['seo_category_keywords']) { - $seo_keywords = str_replace ( "{wzmc}", $this->setting ['site_name'], $this->setting ['seo_category_keywords'] ); - $seo_keywords = str_replace ( "{flmc}", $navtitle, $seo_keywords ); - } - - // 如果分类模板没有为空,就应用新模板 - if ($catmodel ['template'] == null || trim ( $catmodel ['template'] ) == '') { - include template ( 'catlist' ); - } else { - include template ( trim ( $catmodel ['template'] ) ); - } - } - - - function convertUrlQuery($query) { - $queryParts = explode ( '&', $query ); - $params = array (); - foreach ( $queryParts as $param ) { - $item = explode ( '=', $param ); - $params [$item [0]] = $item [1]; - } - return $params; - } - /** - * 将参数变为字符串 - * - * @param - * $array_query - * @return string string 'm=content&c=index&a=lists&catid=6&area=0&author=0&h=0®ion=0&s=1&page=1' (length=73) - */ - function getUrlQuery($array_query) { - $key = ''; - foreach ( $array_query as $k => $param ) { - $key = $k; - break; - } - - return $key; - } - function getone() { - $topicid = intval ( $this->uri->rsegments [3] ); - $panneltype = "hidefixed"; - $useragent = $_SERVER ['HTTP_USER_AGENT']; - - - $menu = "topic"; - - $topicone = $this->topic_model->get ( $topicid ); - if ($topicone == null) { - header ( 'HTTP/1.1 404 Not Found' ); - header ( "status: 404 Not Found" ); - echo '404-您访问的页面不存在'; - echo "

404

问题已经被删除!⊂((δ⊥δ))⊃返回主页

'; - exit (); - } - if (intval ( $topicone ['state'] ) == 0) { - $this->message ( "文章在审核中", "topic/default" ); - } - $readuid = $this->user ['uid']; - $haspayprice = 0; - $one = $this->topic_model->getreaduser ( $readuid, $topicid ); - if ($one != null) { - // 已经付费过了 - $haspayprice = 1; - } - - $topicone ['describtion'] = $topicone ['describtion']; - - $cat_model = $this->category_model->get ( $topicone ['articleclassid'] ); - $taglist = $this->topic_tag_model->get_by_aid ( $topicone ['id'] ); - $cid = $topicone ['articleclassid']; - $category = $this->category [$cid]; // 得到分类信息 - $ctopiclist = $this->topic_model->get_bycatid ( $cid ); - $cfield = 'cid' . $category ['grade']; - // $questionlist=$this->question_model->list_by_condition(" "); - $questionlist = $this->question_model->list_by_cfield_cvalue_status ( $cfield, $cid, 'all', 0, 8 ); // 问题列表数据 - $topicone ['tags'] = $taglist; - $views = $topicone ['views'] + 1; - $topic_price = $topicone ['price']; - $this->db->query ( "UPDATE `" . $this->db->dbprefix . "topic` SET `views`=$views WHERE `id`=$topicid" ); - - $navtitle = $topicone ['title']; - $this->load->model ( "favorite_model" ); - $followerlist = $this->favorite_model->get_list_bytid ( $topicid ); // 收藏的人 - - $tagkeystr=''; - if ($taglist) { - $tagkeystr=''; - foreach ( $taglist as $tag ) { - $tagkeystr .= $tag['tagname'].","; - } - - } - $seo_keywords =trim($tagkeystr,','); - if ($topicone ['price'] != 0 && $haspayprice == 0 && $this->user ['uid'] != $topicone ['authorid']) { - $seo_description = "付费后可查看文章内容"; - } else { - $seo_description = cutstr ( trim ( clearhtml ( $topicone ['describtion'] ) ), 240 ); - } - - $member = $this->user_model->get_by_uid ( $topicone ['authorid'], 2 ); - // $is_followed = $this->user_model->is_followed($member['uid'], $this->user['uid']); - $topiclist1 = $this->topic_model->get_list_byuid ( $member ['uid'], 0, 8 ); - // $topiclist3 = $this->topic_model->get_list ( 1, 8 ); - $is_followedauthor = $this->user_model->is_followed ( $member ['uid'], $this->user ['uid'] ); - $this->load->model ( "articlecomment_model" ); - $tid = $topicone ['id']; - $isfollowarticle=$this->favorite_model->get_by_tid($tid); - // 评论分页 - @$page = 0; - if (strpos ( $this->uri->rsegments [5], 'a' ) !== false) { - @$page = 1; - } else { - @$page = max ( 1, intval ( $this->uri->rsegments [4]) ); - } - $pagesize = 5; // $this->setting['list_default']; - $startindex = ($page - 1) * $pagesize; - - $commentlist = $this->articlecomment_model->list_by_tid ( $tid, 1, $startindex, $pagesize ); - - $commentrownum = returnarraynum ( $this->db->query ( getwheresql ( "articlecomment", " tid=$tid AND state=1 ", $this->db->dbprefix ) )->row_array () ); - //更新评论数 - $this->db->where(array('id'=>$tid))->update('topic',array('articles'=>$commentrownum)); - $departstr = page ( $commentrownum, $pagesize, $page, "topic/getone/$topicid" ); - // if(is_mobile()){ - // include template('getonetopic','wap'); - // }else{ - $this->load->model ( "paylog_model" ); - $shanglist = $this->paylog_model->getlist_bytype ( 'tid', $topicone ['id'] ); - $totalmoney = $this->paylog_model->gettotalmoney ( 'tid', $topicone ['id'] ); // 获取全部的钱 - $totalmoney = doubleval ( $totalmoney ); - $message ['type'] = 'article'; - $message ['touid'] = $member ['uid']; - $message ['content'] = "给" . $member ['username'] . "的文章打赏"; - $_SESSION ["type"] = json_encode ( $message ); - $desc=$topicone['describtion']; - - $newct = $this->get_img_thumb_url($desc,SITE_URL."static/images/pcload.jpg"); - - $topicone['describtion']=$newct; - - //定义熊掌号推送的url数组 - $tuiurls=array(); - $_url=url("topic/getone/$tid"); //此问题的url - array_push($tuiurls, $_url); - - //推送给熊掌号 - xiongzhangtuisong($tuiurls); - - if($cat_model['articletemplate']&&$cat_model['articletemplate']!=''){ - include template ( $cat_model['articletemplate']); - }else{ - - include template ( 'topicone' ); - } - - - // ob_start (); - // include template ( 'topicone' ); - // - // $content = ob_get_contents (); //取得php页面输出的全部内容 - // $fp = fopen ( "./article/$topicid.html", "w" ); - // fwrite ( $fp, $content ); - // fclose ( $fp ); - } - - function get_img_thumb_url($content="",$suffix="") - { - $pregRule = "//"; - $content = preg_replace($pregRule, '', $content); - return $content; - } - - // 打印输出数组信息 - function printf_info($data) { - foreach ( $data as $key => $value ) { - echo "$key : $value
"; - } - } - function userxinzhi() { - $uid = intval ( $this->uri->rsegments [3] ); - - if ($uid == null) { - exit ( "非法操作" ); - } - $member = $this->user_model->get_by_uid ( $uid, 2 ); - if($member['isblack']||!$member){ - show_404(); - exit(); - } - $is_followed = $this->user_model->is_followed ( $member ['uid'], $this->user ['uid'] ); - $navtitle = $member ['username'] . '的专栏列表'; - - @$page = max ( 1, intval ( $this->uri->rsegments [4] ) ); - $pagesize = 5; // $this->setting['list_default']; - $startindex = ($page - 1) * $pagesize; - $rownum = returnarraynum ( $this->db->query ( getwheresql ( 'topic', "authorid=$uid", $this->db->dbprefix ) )->row_array () ); - $topiclist = $this->topic_model->get_list_byuid ( $uid, $startindex, $pagesize ); - $pages = @ceil ( $rownum / $pagesize ); - $catags = $this->topic_model->get_article_by_uid ( $uid ); - foreach ( $topiclist as $key => $val ) { - - $taglist = $this->topic_tag_model->get_by_aid ( $val ['id'] ); - - $topiclist [$key] ['tags'] = $taglist; - } - $departstr = page ( $rownum, 5, $page, "topic/userxinzhi/$uid" ); - $metakeywords = $navtitle; - $metadescription = $member ['username'] . '的专栏列表'; - - if ($uid == $this->user ['uid']) { - include template ( 'myuserxinzhi' ); - } else { - include template ( 'userxinzhi' ); - } - } - - /** - - * 语音文字合成处理 - - * @date: 2019年1月3日 下午4:37:59 - - * @author: 61703 - - * @param: variable - - * @return: - - */ - function putyuyin(){ - set_time_limit(0); - require_once FCPATH.'lib/apispeech/AipSpeech.php'; - $str=$_POST['content']; - $tid=intval($_POST['tid']); - $paystr=$_POST['paycontent']? $_POST['paycontent']:''; - if(!$this->user['uid']){ - $message['code']=201; - $message['msg']="游客先登录后在生成"; - echo json_encode($message); - exit(); - } - $strword=strip_tags($str); - $len=strlen($strword); - - $maxlen=200; - $pages= @ceil ( $len / $maxlen ); - - $result=''; - for($i=0;$i<$pages;$i++){ - if(($i+1)>=$pages){ - $result .= $client->synthesis(substr($strword,$i*$maxlen), 'zh', 1, array( - 'vol' => 5, - )); - }else{ - $result .= $client->synthesis(substr($strword,$i*$maxlen,$maxlen), 'zh', 1, array( - 'vol' => 5, - )); - } - - } - - - // 识别正确返回语音二进制 错误则返回json 参照下面错误码 - if(!is_array($result)){ - $yuyinfile=FCPATH."data/weixinrecord/free".$tid.".mp3"; - file_put_contents($yuyinfile, $result); - if($paystr==''){ - $message['code']=200; - $message['msg']="语音生成成功"; - echo json_encode($message); - exit(); - } - - } - - - $strword=strip_tags($paystr); - $len=strlen($strword); - - $maxlen=200; - $pages= @ceil ( $len / $maxlen ); - - $result=''; - for($i=0;$i<$pages;$i++){ - if(($i+1)>=$pages){ - $result .= $client->synthesis(substr($strword,$i*$maxlen), 'zh', 1, array( - 'vol' => 5, - )); - }else{ - $result .= $client->synthesis(substr($strword,$i*$maxlen,$maxlen), 'zh', 1, array( - 'vol' => 5, - )); - } - - } - - // 识别正确返回语音二进制 错误则返回json 参照下面错误码 - if(!is_array($result)){ - $yuyinfile=FCPATH."data/weixinrecord/pay".$tid.".mp3"; - file_put_contents($yuyinfile, $result); - if($paystr!=''){ - $message['code']=200; - $message['msg']="语音生成成功"; - echo json_encode($message); - exit(); - } - - } - } -} - -?> \ No newline at end of file diff --git a/application/controllers/Admin/Admin_category.php b/application/controllers/Admin/Admin_category.php index f515c69..24832a5 100644 --- a/application/controllers/Admin/Admin_category.php +++ b/application/controllers/Admin/Admin_category.php @@ -230,8 +230,9 @@ class Admin_category extends ADMIN_Controller { $edit_miaosu = trim ( $this->input->post ( 'edit_miaosu' ) ); // 分类描述 $s_tmplist = trim ( $this->input->post ( 's_tmplist' ) ); // 文章分类模板名字 $s_articletmplist = trim ( $this->input->post ( 's_articletmplist' ) ); // 文章详情模板名字 - + $dir= trim ( $this->input->post ( 'dir' ) ); // 分类目录名称 $categorydir = ''; + $categorydir = empty($dir) ? '':$dir; $cid = 0; $category1 = $this->input->post ( 'category1' ); $category2 = $this->input->post ( 'category2' ); diff --git a/application/controllers/Category.php b/application/controllers/Category.php index 3e71f8a..30e36c2 100644 --- a/application/controllers/Category.php +++ b/application/controllers/Category.php @@ -10,7 +10,6 @@ class Category extends CI_Controller { $this->load->model ( 'category_model' ); $this->load->model ( 'question_model' ); $this->load->model ( "topic_model" ); - } function viewtopic() { @@ -34,11 +33,22 @@ class Category extends CI_Controller { $departstr = page ( $rownum, $pagesize, $page, "category/viewtopic/$status" ); include template ( 'category_all' ); } - //category/view/1/2/10 - //cid,status,第几页? - function view() { +function view() { $this->load->model ( "expert_model" ); - $cid = intval ( $this->uri->rsegments[3] ) ? intval ( $this->uri->rsegments[3]) : 'all'; + + if(intval ( $this->uri->rsegments[3] )==0){ + $catdir=addslashes(strip_tags($this->uri->rsegments[3]));//获取目录 + + $_cat=$this->db->get_where('category',array('dir'=>$catdir))->row_array(); + if($_cat){ + $cid=$_cat['id']; + }else{ + show_404(); + } + }else{ + $cid = intval ( $this->uri->rsegments[3] ) ? intval ( $this->uri->rsegments[3]) : 'all'; + } + $status = null!== $this->uri->rsegments[4] ? $this->uri->rsegments[4]: 'all'; @$page = max ( 1, intval ( $this->uri->rsegments[5]) ); $pagesize = $this->setting ['list_default']; @@ -90,7 +100,12 @@ class Category extends CI_Controller { $questionlist = $this->question_model->list_by_cfield_cvalue_status ( $cfield, $cid, $status, $startindex, $pagesize ); //问题列表数据 $topiclist = $this->topic_model->get_bycatid ( $cid, 0, 8 ); $followerlist = $this->category_model->get_followers ( $cid, 0, 8 ); //获取导航 - $departstr = page ( $rownum, $pagesize, $page, "category/view/$cid/$status" ); //得到分页字符串 + if($catdir){ + $departstr = page ( $rownum, $pagesize, $page, "category/view/$catdir/$status" ); //得到分页字符串 + }else{ + $departstr = page ( $rownum, $pagesize, $page, "category/view/$cid/$status" ); //得到分页字符串 + } + $navlist = $this->category_model->get_navigation ( $cid ); //获取导航 $sublist = $this->category_model->list_by_cid_pid ( $cid, $category ['pid'] ); //获取子分类 $expertlist = $this->expert_model->get_by_cid ( $cid ); //分类专家 diff --git a/application/controllers/Question.php b/application/controllers/Question.php index 12a1478..d0b10d8 100644 --- a/application/controllers/Question.php +++ b/application/controllers/Question.php @@ -2922,7 +2922,7 @@ class Question extends CI_Controller { echo json_encode ( $message ); exit (); } - $content = $this->input->post ( 'content', FALSE ); + $content = $this->input->post ( 'content' ); // 更新问题详情 $tags = trim ( $this->input->post ( 'tags' ), ',' ); @@ -2941,7 +2941,7 @@ class Question extends CI_Controller { 'cid1' => $cid1, 'cid2' => $cid2, 'cid3' => $cid3, - 'description' => htmlspecialchars ( $content ) + 'description' => $content ); $this->db->where ( array ( diff --git a/application/controllers/Topic.php b/application/controllers/Topic.php index 0aeea07..2625069 100644 --- a/application/controllers/Topic.php +++ b/application/controllers/Topic.php @@ -696,7 +696,18 @@ exit(); include template ( 'topic' ); } function catlist() { - $catid = intval ( $this->uri->rsegments [3] ); + if(intval ( $this->uri->rsegments[3] )==0){ + $catdir=addslashes(strip_tags($this->uri->rsegments[3]));//获取目录 + $_cat=$this->db->get_where('category',array('dir'=>$catdir))->row_array(); + if($_cat){ + $catid=$_cat['id']; + }else{ + show_404(); + } + }else{ + $catid = intval ( $this->uri->rsegments [3] ); + } + //相关分类标签 $this->load->model ( "tag_model" ); $relativetags = $this->tag_model->gettaglistbycid ( $catid ); @@ -735,7 +746,8 @@ exit(); // 获取该分类下的父亲级别的分类 // $catlist=$this->category_model->list_by_pid($catmodel['pid']); - + + if ($catmodel ['grade'] == 3) { //$catlist = $this->category_model->list_by_pid ( $catmodel ['pid'] ); @@ -752,9 +764,7 @@ exit(); array_push ( $cids, $val ['id'] ); } } - } - // var_dump($catmodel);exit(); } @@ -773,7 +783,12 @@ exit(); $topiclist [$key] ['tags'] = $taglist; } - $departstr = page ( $rownum, $pagesize, $page, "topic/catlist/$catid" ); + if($catdir){ + $departstr = page ( $rownum, $pagesize, $page, "topic/catlist/$catdir" ); + }else{ + $departstr = page ( $rownum, $pagesize, $page, "topic/catlist/$catid" ); + } + /* SEO */ $seo_keywords = $navtitle; @@ -800,7 +815,7 @@ exit(); $seo_keywords = str_replace ( "{wzmc}", $this->setting ['site_name'], $this->setting ['seo_category_keywords'] ); $seo_keywords = str_replace ( "{flmc}", $navtitle, $seo_keywords ); } - + // 如果分类模板没有为空,就应用新模板 if ($catmodel ['template'] == null || trim ( $catmodel ['template'] ) == '') { include template ( 'catlist' ); @@ -809,6 +824,7 @@ exit(); } } + function convertUrlQuery($query) { $queryParts = explode ( '&', $query ); $params = array (); -- GitLab