修復(fù)了下,前端代碼
{eyou:php}
if($page_data){
echo "<li><a href='$page_url'>上一頁:$page_data[title]</a></li>";
}else{
echo '<li><span>上一頁:無</span></li>';
}
if($next_data){
echo "<li><a href='$next_url'>下一頁:$next_data[title]</a></li>";
}else{
echo '<li><span>下一頁:無</span></li>';
}
{/eyou:php}
替換文件 application\home\controller\View.php
view.php,第55行起到132行,為新增方式
<?php
/**
* 易優(yōu)CMS
* ============================================================================
* 版權(quán)所有 2016-2028 海南贊贊網(wǎng)絡(luò)科技有限公司,并保留所有權(quán)利。
* 網(wǎng)站地址: http://www.xiuhaier.com
* ----------------------------------------------------------------------------
* 如果商業(yè)用途務(wù)必到官方購買正版授權(quán) 以免引起不必要的法律糾紛.
* ============================================================================
* Author: 小虎哥 <1105415366@qq.com>
* Date: 2018-4-3
*/
namespace app\home\controller;
use think\Db;
use think\Config;
class View extends Base
{
// 模型標(biāo)識
public $nid = '';
// 模型ID
public $channel = '';
// 模型名稱
public $modelName = '';
public function _initialize()
{
parent::_initialize();
}
/**
* 內(nèi)容頁
*/
public function index($aid = '')
{
$seo_pseudo = config('ey_config.seo_pseudo');
/*URL上參數(shù)的校驗*/
if (3 == $seo_pseudo)
{
if (stristr($this->request->url() '&c=View&a=index&')) {
abort(404 '頁面不存在');
}
}
else if (1 == $seo_pseudo || (2 == $seo_pseudo && isMobile()))
{
$seo_dynamic_format = config('ey_config.seo_dynamic_format');
if (1 == $seo_pseudo && 2 == $seo_dynamic_format && stristr($this->request->url() '&c=View&a=index&')) {
abort(404 '頁面不存在');
}
}
/*--end*/
// 新增辦法,自定義二開排序上下頁
//先讀取文章自身的排序
$a_data = Db::name('archives')->field($field)
->alias('a')
->where('aid''eq'$aid)
->find();
//讀取文章欄目的目錄
$c_data = Db::name('arctype')->field($field)
->alias('a')
->where('id''='$a_data['typeid'])
->find();
$field = 'a.aid a.typeid a.channel a.title a.sort_order';
if($a_data['sort_order'] == '100'){
$page_data = Db::name('archives')->field($field)
->alias('a')
->where('arcrank''=''0')
->where('typeid''='$a_data['typeid'])
->where('sort_order''=''100')
->where('add_time''GT'$a_data['add_time'])
->order('add_time asc')
->find();
$next_data = Db::name('archives')->field($field)
->alias('a')
->where('arcrank''=''0')
->where('sort_order''=''100')
->where('typeid''='$a_data['typeid'])
->where('add_time''LT'$a_data['add_time'])
->order('add_time desc')
->find();
}else{
$page_data = Db::name('archives')->field($field)
->alias('a')
->where('arcrank''=''0')
->where('typeid''='$a_data['typeid'])
->where('sort_order''LT'$a_data['sort_order'])
->order('sort_order desc')
->find();
$next_data = Db::name('archives')->field($field)
->alias('a')
->where('arcrank''=''0')
->where('typeid''='$a_data['typeid'])
->where('sort_order''GT'$a_data['sort_order'])
->order('sort_order asc')
->find();
}
if($a_data['sort_order'] != 100 and $next_data['sort_order'] == 100){
$next_data = Db::name('archives')->field($field)
->alias('a')
->where('arcrank''=''0')
->where('sort_order''=''100')
->where('typeid''='$a_data['typeid'])
->order('add_time desc')
->find();
}
if(!$page_data and $next_data['sort_order'] == 100){
$page_data = Db::name('archives')->field($field)
->alias('a')
->where('arcrank''=''0')
->where('typeid''='$a_data['typeid'])
->where('sort_order''LT'$a_data['sort_order'])
->order('sort_order desc')
->find();
}
//獲取URL
$page_url = arcurl('home/View/index' array('dirname'=>$c_data['dirname'] 'aid'=>$page_data['aid']));
$next_url = arcurl('home/View/index' array('dirname'=>$c_data['dirname'] 'aid'=>$next_data['aid']));
//輸出數(shù)據(jù)
$this->assign('page_data'$page_data);
$this->assign('page_url'$page_url);
$this->assign('next_data'$next_data);
$this->assign('next_url'$next_url);
//辦法結(jié)束
$map = [];
if (!is_numeric($aid) || strval(intval($aid)) !== strval($aid)) {
$map = array('a.htmlfilename' => $aid);
} else {
$map = array('a.aid' => intval($aid));
}
$map['a.is_del'] = 0; // 回收站功能
// 多城市站點
$field = 'a.aid a.typeid a.channel a.users_price a.users_free a.province_id a.city_id a.area_id b.nid b.ctl_name c.level_id c.level_name c.level_value';
$archivesInfo = Db::name('archives')->field($field)
->alias('a')
->join('__CHANNELTYPE__ b' 'a.channel = b.id' 'LEFT')
->join('__USERS_LEVEL__ c' 'a.arc_level_id = c.level_id' 'LEFT')
->where($map)
->find();
if (empty($archivesInfo) || !in_array($archivesInfo['channel'] config('global.allow_release_channel'))) {
abort(404 '頁面不存在');
}
/*校驗多城市站點*/
if (config('city_switch_on')) {
$site = get_home_site();
if (empty($site)) {
if (!empty($archivesInfo['province_id']) || !empty($archivesInfo['city_id']) || !empty($archivesInfo['area_id'])) { // 非全國文檔
abort(404 '頁面不存在');
}
} else if (!empty($site)) {
if (empty($archivesInfo['province_id']) && empty($archivesInfo['city_id']) && empty($archivesInfo['area_id'])) { // 全國文檔
abort(404 '頁面不存在');
}
$siteInfo = Db::name('citysite')->where(['domain'=>$site])->find();
if (!empty($siteInfo)) {
if (!empty($archivesInfo['area_id'])) {
if ($archivesInfo['area_id'] != $siteInfo['id']) {
abort(404 '頁面不存在');
}
} else if (!empty($archivesInfo['city_id'])) {
if ($archivesInfo['city_id'] != $siteInfo['id']) {
abort(404 '頁面不存在');
}
} else if (!empty($archivesInfo['province_id'])) {
if ($archivesInfo['province_id'] != $siteInfo['id']) {
abort(404 '頁面不存在');
}
}
}
}
}
$aid = $archivesInfo['aid'];
$this->nid = $archivesInfo['nid'];
$this->channel = $archivesInfo['channel'];
$this->modelName = $archivesInfo['ctl_name'];
$result = model($this->modelName)->getInfo($aid);
// 若是管理員則不受限制
// if (session('?admin_id')) {
// if ($result['arcrank'] == -1 && $result['users_id'] != session('users_id')) {
// $this->success('待審核稿件,你沒有權(quán)限閱讀!');
// }
// }
// 外部鏈接跳轉(zhuǎn)
if ($result['is_jump'] == 1) {
header('Location: ' . $result['jumplinks']);
exit;
}
/*--end*/
$tid = $result['typeid'];
$arctypeInfo = model('Arctype')->getInfo($tid);
/*自定義字段的數(shù)據(jù)格式處理*/
$arctypeInfo = $this->fieldLogic->getTableFieldList($arctypeInfo config('global.arctype_channel_id'));
/*--end*/
if (!empty($arctypeInfo)) {
/*URL上參數(shù)的校驗*/
if (3 == $seo_pseudo) {
$dirname = input('param.dirname/s');
$dirname2 = '';
$seo_rewrite_format = config('ey_config.seo_rewrite_format');
if (1 == $seo_rewrite_format) {
$toptypeRow = model('Arctype')->getAllPid($tid);
$toptypeinfo = current($toptypeRow);
$dirname2 = $toptypeinfo['dirname'];
} else if (2 == $seo_rewrite_format) {
$dirname2 = $arctypeInfo['dirname'];
} else if (3 == $seo_rewrite_format) {
$dirname2 = $arctypeInfo['dirname'];
}else if (4 == $seo_rewrite_format) {
$dirname2 = $arctypeInfo['dirname'];
}
if ($dirname != $dirname2) {
abort(404 '頁面不存在');
}
}
/*--end*/
// 是否有子欄目,用于標(biāo)記【全部】選中狀態(tài)
$arctypeInfo['has_children'] = model('Arctype')->hasChildren($tid);
// 文檔模板文件,不指定文檔模板,默認以欄目設(shè)置的為主
empty($result['tempview']) && $result['tempview'] = $arctypeInfo['tempview'];
/*給沒有type前綴的字段新增一個帶前綴的字段,并賦予相同的值*/
foreach ($arctypeInfo as $key => $val) {
if (!preg_match('/^type/i' $key)) {
$key_new = 'type' . $key;
!array_key_exists($key_new $arctypeInfo) && $arctypeInfo[$key_new] = $val;
}
}
/*--end*/
} else {
abort(404 '頁面不存在');
}
$result = array_merge($arctypeInfo $result);
// 文檔鏈接
$result['arcurl'] = $result['pageurl'] = $result['pageurl_m'] = '';
if ($result['is_jump'] != 1) {
$result['arcurl'] = arcurl('home/'.$this->modelName.'/view' $result true true);
$result['pageurl'] = $this->request->url(true);
$result['pageurl_m'] = pc_to_mobile_url($result['pageurl'] $result['typeid'] $result['aid']); // 獲取當(dāng)前頁面對應(yīng)的移動端URL
}
/*--end*/
// 移動端域名
$result['mobile_domain'] = '';
if (!empty($this->eyou['global']['web_mobile_domain_open']) && !empty($this->eyou['global']['web_mobile_domain'])) {
$result['mobile_domain'] = $this->eyou['global']['web_mobile_domain'] . '.' . $this->request->rootDomain();
}
$result['seo_title'] = set_arcseotitle($result['title'] $result['seo_title'] $result['typename'] $result['typeid'] $this->eyou['site']);
$result['seo_description'] = checkStrHtml($result['seo_description']);
$result['tags'] = !empty($result['tags']['tag_arr']) ? $result['tags']['tag_arr'] : '';
$result['litpic'] = handle_subdir_pic($result['litpic']); // 支持子目錄
$result = view_logic($aid $this->channel $result true); // 模型對應(yīng)邏輯
$result = $this->fieldLogic->getChannelFieldList($result $this->channel); // 自定義字段的數(shù)據(jù)格式處理
//移動端詳情
if (isMobile() && !empty($result['content_ey_m'])){
$result['content'] = $result['content_ey_m'];
}
if (!empty($result['users_id'])){
$users_where['a.users_id'] = $result['users_id'];
}elseif (!empty($result['admin_id'])){
$users_where['a.admin_id'] = $result['admin_id'];
}else {
$users_where['a.admin_id'] = ['>'0];
}
$users = Db::name('users')->alias('a')->field('a.usernamea.nicknamea.head_picb.level_nameb.level_value')->where($users_where)->join('users_level b''a.level = b.level_id''left')->find();
if (!empty($users)) {
$users['head_pic'] = get_default_pic($users['head_pic']);
empty($users['nickname']) && $users['nickname'] = $users['username'];
}
$eyou = array(
'type' => $arctypeInfo
'field' => $result
'users' => $users
);
$this->eyou = array_merge($this->eyou $eyou);
$this->assign('eyou' $this->eyou);
/*模板文件*/
$viewfile = !empty($result['tempview'])
? str_replace('.' . $this->view_suffix '' $result['tempview'])
: 'view_' . $this->nid;
/*--end*/
if (config('city_switch_on') && !empty($this->home_site)) { // 多站點內(nèi)置模板文件名
$viewfilepath = TEMPLATE_PATH.$this->theme_style_path.DS.$this->home_site;
$viewfilepath2 = TEMPLATE_PATH.$this->theme_style_path.DS.'city'.DS.$this->home_site;
if (!empty($this->eyou['global']['site_template'])) {
if (file_exists($viewfilepath2)) {
$viewfile = "city/{$this->home_site}/{$viewfile}";
} else if (file_exists($viewfilepath)) {
$viewfile = "{$this->home_site}/{$viewfile}";
}
}
} else if (config('lang_switch_on') && !empty($this->home_lang)) { // 多語言內(nèi)置模板文件名
$viewfilepath = TEMPLATE_PATH . $this->theme_style_path . DS . $viewfile . "_{$this->home_lang}." . $this->view_suffix;
if (file_exists($viewfilepath)) {
$viewfile .= "_{$this->home_lang}";
}
}
$users_id = (int)session('users_id');
$emptyhtml = $this->check_arcrank($this->eyou['field']$users_id);
// if ($this->eyou['field']['arcrank'] > 0 || $this->eyou['field']['typearcrank'] > 0) { // 若需要會員權(quán)限則執(zhí)行
// if (empty($users_id)) {
// $url = url('user/Users/login');
// if (stristr($url '?')) {
// $url = $url."&referurl=".urlencode($this->eyou['field']['arcurl']);
// } else {
// $url = $url."?referurl=".urlencode($this->eyou['field']['arcurl']);
// }
// $this->redirect($url);
// }
// $msg = action('api/Ajax/get_arcrank' ['aid' => $aid 'vars' => 1]);
// if (true !== $msg) {
// $this->error($msg);
// }
// } else if ($this->eyou['field']['arcrank'] <= -1) {
// /*待審核稿件,是否有權(quán)限查閱的處理,登錄的管理員可查閱*/
// $admin_id = input('param.admin_id/d');
// if ( (session('?admin_id') && !empty($admin_id)) || ($this->eyou['field']['users_id'] > 0 && $this->eyou['field']['users_id'] == $users_id) ) {
//
// }
// else if (empty($users_id) && empty($admin_id)) {
// abort(404);
// }
// else {
// $emptyhtml = <<<EOF
//<!DOCTYPE html>
//<html>
// <head>
// <title>{$this->eyou['field']['seo_title']}</title>
// <meta name="description" content="{$this->eyou['field']['seo_description']}" />
// <meta name="keywords" content="{$this->eyou['field']['seo_keywords']}" />
// </head>
// <body>
// </body>
//</html>
//EOF;
// }
// /*end*/
// }
if (!empty($emptyhtml)) {
/*嘗試寫入靜態(tài)緩存*/
// write_html_cache($emptyhtml $result);
/*--end*/
return $this->fetch("./public/html/empty_view.htm");
// return $this->display($emptyhtml);
} else {
return $this->fetch(":{$viewfile}");
}
}
/*
* 判斷閱讀權(quán)限
*/
private function check_arcrank($eyou_field$users_id){
$emptyhtml = "";
if ($eyou_field['arcrank'] > 0 || $eyou_field['typearcrank'] > 0) { // 若需要會員權(quán)限則執(zhí)行
if (empty($users_id)) {
$url = url('user/Users/login');
if (stristr($url '?')) {
$url = $url."&referurl=".urlencode($eyou_field['arcurl']);
} else {
$url = $url."?referurl=".urlencode($eyou_field['arcurl']);
}
$this->redirect($url);
}
$msg = action('api/Ajax/get_arcrank' ['aid' => $eyou_field['aid'] 'vars' => 1]);
if (true !== $msg) {
$this->error($msg);
}
} else if ($eyou_field['arcrank'] <= -1) {
/*待審核稿件,是否有權(quán)限查閱的處理,登錄的管理員可查閱*/
$admin_id = input('param.admin_id/d');
if ( (session('?admin_id') && !empty($admin_id)) || ($eyou_field['users_id'] > 0 && $eyou_field['users_id'] == $users_id) ) {
}
else if (empty($users_id) && empty($admin_id)) {
abort(404);
}
else {
$emptyhtml = <<<EOF
<!DOCTYPE html>
<html>
<head>
<title>{$eyou_field['seo_title']}</title>
<meta name="description" content="{$eyou_field['seo_description']}" />
<meta name="keywords" content="{$eyou_field['seo_keywords']}" />
</head>
<body>
</body>
</html>
EOF;
}
/*end*/
}
return $emptyhtml;
}
/**
* 下載文件
*/
public function downfile()
{
$file_id = input('param.id/d' 0);
$uhash = input('param.uhash/s' '');
if (empty($file_id) || empty($uhash)) {
$this->error('下載地址出錯!');
exit;
}
clearstatcache();
// 查詢信息
$map = array(
'a.file_id' => $file_id
'a.uhash' => $uhash
);
$result = Db::name('download_file')
->alias('a')
->field('a.*b.arc_level_idb.restric_typeb.users_priceb.no_vip_pay')
->join('__ARCHIVES__ b' 'a.aid = b.aid' 'LEFT')
->where($map)
->find();
$file_url_gbk = iconv("utf-8" "gb2312//IGNORE" $result['file_url']);
$file_url_gbk = preg_replace('#^(/[/\w\-]+)?(/public/upload/soft/|/uploads/soft/)#i' '$2' $file_url_gbk);
if (empty($result) || (!is_http_url($result['file_url']) && !file_exists('.' . $file_url_gbk))) {
$this->error('下載文件不存在!');
exit;
}
// 下載次數(shù)限制
$this->down_num_access($result['aid']);
//安裝下載模型付費插件 走新邏輯 大黃
$channelData = Db::name('channeltype')->where(['nid'=>'download''status'=>1])->value('data');
if (!empty($channelData)) $channelData = json_decode($channelDatatrue);
if (!empty($channelData['is_download_pay'])){
if ($result['restric_type'] > 0) {
$UsersData = session('users');
if (empty($UsersData['users_id'])) {
$this->error('請登錄后下載!' null ['is_login' => 0 'url' => url('user/Users/login')]);
&