init
This commit is contained in:
136
src/application/home/behavior/ViewFilterBehavior.php
Normal file
136
src/application/home/behavior/ViewFilterBehavior.php
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace app\home\behavior;
|
||||
|
||||
/**
|
||||
* 系统行为扩展:
|
||||
*/
|
||||
class ViewFilterBehavior {
|
||||
protected static $actionName;
|
||||
protected static $controllerName;
|
||||
protected static $moduleName;
|
||||
protected static $method;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
* @param Request $request Request对象
|
||||
* @access public
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// 行为扩展的执行入口必须是run
|
||||
public function run(&$params){
|
||||
self::$actionName = request()->action();
|
||||
self::$controllerName = request()->controller();
|
||||
self::$moduleName = request()->module();
|
||||
self::$method = request()->method();
|
||||
// file_put_contents ( DATA_PATH."log.txt", date ( "Y-m-d H:i:s" ) . " " . var_export('admin_CoreProgramBehavior',true) . "\r\n", FILE_APPEND );
|
||||
$this->_initialize($params);
|
||||
}
|
||||
|
||||
private function _initialize(&$params) {
|
||||
$this->thirdcode($params); // 自动加上第三方统计代码
|
||||
|
||||
// 自动追加阅读权限JS事件
|
||||
$this->AppEndJsCode($params);
|
||||
//自动追加足迹js事件
|
||||
$this->AppFootprintJsCode($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给模板加上第三方统计代码
|
||||
* @access public
|
||||
*/
|
||||
private function thirdcode(&$params)
|
||||
{
|
||||
// 排除小程序端,其他场景都显示统计代码和商桥代码
|
||||
if (!isWeixinApplets()) {
|
||||
$name = 'web_thirdcode_' . (isMobile() ? 'wap' : 'pc'); // PC端与手机端的变量名自适应,可彼此通用
|
||||
$web_thirdcode = tpCache('web.'.$name);
|
||||
if (!empty($web_thirdcode)) {
|
||||
$params = str_ireplace('</body>', htmlspecialchars_decode($web_thirdcode)."\n</body>", $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动追加足迹js事件
|
||||
* @access public
|
||||
*/
|
||||
private function AppFootprintJsCode(&$params)
|
||||
{
|
||||
$aid = request()->param('aid/d');
|
||||
if (!empty($aid)) {
|
||||
$root_dir = ROOT_DIR;
|
||||
$version = getCmsVersion();
|
||||
$JsHtml = <<<EOF
|
||||
<script type="text/javascript" src="{$root_dir}/public/static/common/js/footprint.js?v={$version}"></script>
|
||||
<script type="text/javascript">footprint_1606269933('{$aid}', '{$root_dir}');</script>
|
||||
EOF;
|
||||
// 追加替换JS
|
||||
$params = str_ireplace('</body>', htmlspecialchars_decode($JsHtml)."\n</body>", $params);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动追加阅读权限JS事件
|
||||
* @access public
|
||||
*/
|
||||
private function AppEndJsCode(&$params)
|
||||
{
|
||||
$aid = request()->param('aid/d');
|
||||
$admin_id = request()->param('admin_id/d');
|
||||
$ca = self::$controllerName.'@'.self::$actionName;
|
||||
$is_appendJs = false;
|
||||
$data['ClosePage'] = 0;
|
||||
if (!empty($aid) && ('View@index' == $ca || 'view' == self::$actionName)) {
|
||||
if (!empty($admin_id)) {
|
||||
$data['ClosePage'] = 1;
|
||||
}
|
||||
$is_appendJs = true;
|
||||
} else if ('Buildhtml@uphtml' == $ca && 'view' == request()->param('type')) {
|
||||
$is_appendJs = true;
|
||||
} else if ('Buildhtml@buildarticle' == $ca) {
|
||||
$is_appendJs = true;
|
||||
}
|
||||
|
||||
if (true === $is_appendJs) {
|
||||
// 加载JS需要的参数
|
||||
$channel = \think\Db::name('archives')->where(['aid'=>$aid])->getField('channel');
|
||||
$get_url = ROOT_DIR . "/index.php?m=api&c=Ajax&a=get_arcrank&aid={$aid}";
|
||||
if (!empty($admin_id)) {
|
||||
$get_url .= "&admin_id={$admin_id}";
|
||||
}
|
||||
$data['get_url'] = $get_url;
|
||||
$data['buy_url'] = ROOT_DIR . "/index.php?m=user&c=Media&a=media_order_buy&_ajax=1";
|
||||
$data['VideoLogicUrl'] = ROOT_DIR . "/index.php?m=api&c=Ajax&a=video_logic&_ajax=1";
|
||||
$data['LevelCentreUrl'] = ROOT_DIR . "/index.php?m=user&c=Level&a=level_centre";
|
||||
$data['aid'] = $aid;
|
||||
$data_json = json_encode($data);
|
||||
$version = getCmsVersion();
|
||||
$root_dir = ROOT_DIR;
|
||||
$JsHtml = <<<EOF
|
||||
<script type="text/javascript">var ey_1564127251 = {$data_json};</script>
|
||||
<script type="text/javascript" src="{$root_dir}/public/static/common/js/view_arcrank.js?v={$version}"></script>
|
||||
EOF;
|
||||
if (5 == $channel) { // 只针对视频模型
|
||||
$type = 'sp2';
|
||||
if (strstr($params, 'VipFreeLearn20210201')) { // 易而优
|
||||
$type = 'sp3';
|
||||
} else if (strstr($params, 'video-period-bottom')) {
|
||||
$type = 'sp1';
|
||||
}
|
||||
$JsHtml2 = "<script type='text/javascript'>video_sp_1618221427 = '{$type}';</script>";
|
||||
$params = str_ireplace('</head>', $JsHtml2."\n</head>", $params);
|
||||
|
||||
$JsHtml .= "<script type='text/javascript'>ey_1618221427('{$type}');</script>";
|
||||
$params = str_ireplace('</body>', htmlspecialchars_decode($JsHtml)."\n</body>", $params);
|
||||
} else {
|
||||
$params = str_ireplace('</head>', htmlspecialchars_decode($JsHtml)."\n</head>", $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
145
src/application/home/common.php
Normal file
145
src/application/home/common.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
// 模板错误提示
|
||||
switch_exception();
|
||||
|
||||
if (!function_exists('set_home_url_mode'))
|
||||
{
|
||||
// 设置前台URL模式
|
||||
function set_home_url_mode() {
|
||||
$uiset = I('param.uiset/s', 'off');
|
||||
$uiset = trim($uiset, '/');
|
||||
$seo_pseudo = tpCache('seo.seo_pseudo');
|
||||
if ($seo_pseudo == 1 || $uiset == 'on') {
|
||||
config('url_common_param', true);
|
||||
config('url_route_on', false);
|
||||
} elseif ($seo_pseudo == 2 && $uiset != 'on') {
|
||||
config('url_common_param', false);
|
||||
config('url_route_on', true);
|
||||
} elseif ($seo_pseudo == 3 && $uiset != 'on') {
|
||||
config('url_common_param', false);
|
||||
config('url_route_on', true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('set_arcseotitle'))
|
||||
{
|
||||
/**
|
||||
* 设置内容标题
|
||||
*/
|
||||
function set_arcseotitle($title = '', $seo_title = '', $typename = '', $typeid = 0)
|
||||
{
|
||||
/*针对没有自定义SEO标题的文档*/
|
||||
$title = trim($title);
|
||||
$seo_title = trim($seo_title);
|
||||
$typename = trim($typename);
|
||||
if (empty($seo_title)) {
|
||||
static $web_name = null;
|
||||
if (null === $web_name) {
|
||||
$web_name = tpCache('web.web_name');
|
||||
$web_name = trim($web_name);
|
||||
}
|
||||
static $seo_viewtitle_format = null;
|
||||
null === $seo_viewtitle_format && $seo_viewtitle_format = tpCache('seo.seo_viewtitle_format');
|
||||
switch ($seo_viewtitle_format) {
|
||||
case '1':
|
||||
$seo_title = $title;
|
||||
break;
|
||||
|
||||
case '3':
|
||||
$seo_title = $title;
|
||||
if (!empty($typename)) {
|
||||
$seo_title .= '_'.$typename;
|
||||
}
|
||||
$seo_title .= '_'.$web_name;
|
||||
break;
|
||||
|
||||
case '2':
|
||||
default:
|
||||
$opencodetype = config('global.opencodetype');
|
||||
if (1 == $opencodetype && in_array($typeid, [3,9,10])) {
|
||||
$seo_title = '';
|
||||
} else {
|
||||
$seo_title = $title.'_'.$web_name;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
return $seo_title;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('set_typeseotitle'))
|
||||
{
|
||||
/**
|
||||
* 设置栏目标题
|
||||
*/
|
||||
function set_typeseotitle($typename = '', $seo_title = '')
|
||||
{
|
||||
/*针对没有自定义SEO标题的列表*/
|
||||
if (empty($seo_title)) {
|
||||
$web_name = tpCache('web.web_name');
|
||||
$seo_liststitle_format = tpCache('seo.seo_liststitle_format');
|
||||
switch ($seo_liststitle_format) {
|
||||
case '1':
|
||||
$seo_title = $typename.'_'.$web_name;
|
||||
break;
|
||||
|
||||
case '2':
|
||||
default:
|
||||
$page = I('param.page/d', 1);
|
||||
if ($page > 1) {
|
||||
$typename .= "_第{$page}页";
|
||||
}
|
||||
$seo_title = $typename.'_'.$web_name;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$page = I('param.page/d', 1);
|
||||
if ($page > 1) {
|
||||
$seo_title .= "_第{$page}页";
|
||||
}
|
||||
}
|
||||
|
||||
return $seo_title;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('set_tagseotitle'))
|
||||
{
|
||||
/**
|
||||
* 设置Tag标题
|
||||
*/
|
||||
function set_tagseotitle($tag = '', $seo_title = '')
|
||||
{
|
||||
$page = I('param.page/d', 1);
|
||||
/*针对没有自定义SEO标题的Tag*/
|
||||
if (empty($seo_title)) {
|
||||
$web_name = tpCache('web.web_name');
|
||||
if ($page > 1) {
|
||||
$tag .= "_第{$page}页";
|
||||
}
|
||||
$seo_title = $tag.'_'.$web_name;
|
||||
} else {
|
||||
if ($page > 1) {
|
||||
$seo_title .= "_第{$page}页";
|
||||
}
|
||||
}
|
||||
|
||||
return $seo_title;
|
||||
}
|
||||
}
|
||||
40
src/application/home/config.php
Normal file
40
src/application/home/config.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
$home_config = array(
|
||||
//分页配置
|
||||
'paginate' => array(
|
||||
'type' => 'eyou',
|
||||
'var_page' => 'page',
|
||||
'list_rows' => 15,
|
||||
),
|
||||
|
||||
// +----------------------------------------------------------------------
|
||||
// | 异常及错误设置
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
// 异常页面的模板文件
|
||||
//'exception_tmpl' => ROOT_PATH.'public/static/errpage/404.html',
|
||||
// errorpage 错误页面
|
||||
//'error_tmpl' => ROOT_PATH.'public/static/errpage/404.html',
|
||||
|
||||
/**假设这个访问地址是 www.xxxxx.dev/index/goods/goodsInfo/id/1.html
|
||||
*就保存名字为 index_goods_goodsinfo_1.html
|
||||
*配置成这样, 指定 模块 控制器 方法名 参数名
|
||||
*/
|
||||
'HTML_CACHE_ARR'=> array(),
|
||||
);
|
||||
|
||||
$html_config = include_once 'html.php';
|
||||
return array_merge($home_config, $html_config);
|
||||
?>
|
||||
149
src/application/home/controller/Ajax.php
Normal file
149
src/application/home/controller/Ajax.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Config;
|
||||
use think\AjaxPage;
|
||||
use think\Request;
|
||||
|
||||
class Ajax extends Base
|
||||
{
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取评论列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function product_comment()
|
||||
{
|
||||
\think\Session::pause(); // 暂停session,防止session阻塞机制
|
||||
$post = input('post.');
|
||||
$post['aid'] = !empty($post['aid']) ? $post['aid'] : input('param.aid/d');
|
||||
|
||||
if (isMobile() && 1 < $post['p']) {
|
||||
$Result = [];
|
||||
} else {
|
||||
$Result = cache('EyouHomeAjaxComment_' . $post['aid']);
|
||||
if (empty($Result)) {
|
||||
/*商品评论数计算*/
|
||||
$where = [
|
||||
'is_show' => 1,
|
||||
'product_id' => $post['aid']
|
||||
];
|
||||
$count = Db::name('shop_order_comment')
|
||||
->field('count(*) as count, total_score')
|
||||
->group('total_score')
|
||||
->where($where)
|
||||
->select();
|
||||
|
||||
$Result['total'] = 0;
|
||||
$Result['good'] = 0;
|
||||
$Result['middle'] = 0;
|
||||
$Result['bad'] = 0;
|
||||
|
||||
foreach ($count as $k => $v) {
|
||||
$Result['total'] += $v['count'];
|
||||
switch ($v['total_score']) {
|
||||
case 1:
|
||||
$Result['good'] = $v['count'];
|
||||
break;
|
||||
case 2:
|
||||
$Result['middle'] = $v['count'];
|
||||
break;
|
||||
case 3:
|
||||
$Result['bad'] = $v['count'];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$Result['good_percent'] = $Result['good'] > 0 ? round($Result['good'] / $Result['total'] * 100) : 0;
|
||||
$Result['middle_percent'] = $Result['middle'] > 0 ? round($Result['middle'] / $Result['total'] * 100) : 0;
|
||||
$Result['bad_percent'] = $Result['bad'] > 0 ? 100 - $Result['good_percent'] - $Result['middle_percent'] : 0;
|
||||
// $Result['good_percent'] = $Result['good_percent'] . "%";
|
||||
// $Result['middle_percent'] = $Result['middle_percent'] . "%";
|
||||
// $Result['bad_percent'] = $Result['bad_percent'] . "%";
|
||||
// 存在评论则执行
|
||||
if (!empty($Result)) cache('EyouHomeAjaxComment_' . $post['aid'], $Result, null, 'shop_order_comment');
|
||||
}
|
||||
|
||||
/*选中状态*/
|
||||
$Result['Class_1'] = 0 == $post['score'] ? 'check' : '';
|
||||
$Result['Class_2'] = 1 == $post['score'] ? 'check' : '';
|
||||
$Result['Class_3'] = 2 == $post['score'] ? 'check' : '';
|
||||
$Result['Class_4'] = 3 == $post['score'] ? 'check' : '';
|
||||
}
|
||||
|
||||
// 调用评价列表
|
||||
$this->GetCommentList($post);
|
||||
$this->assign('Result', $Result);
|
||||
return $this->fetch('system/product_comment');
|
||||
}
|
||||
|
||||
// 手机端加载更多时调用
|
||||
public function comment_list()
|
||||
{
|
||||
\think\Session::pause(); // 暂停session,防止session阻塞机制
|
||||
// 调用评价列表
|
||||
$this->GetCommentList(input('post.'));
|
||||
return $this->fetch('system/comment_list');
|
||||
}
|
||||
|
||||
// 调用评价列表
|
||||
private function GetCommentList($post = [])
|
||||
{
|
||||
/*商品评论数据处理*/
|
||||
$field = 'a.*, u.nickname, u.head_pic, l.level_name';
|
||||
$where = [
|
||||
'is_show' => 1,
|
||||
'a.product_id' => $post['aid']
|
||||
];
|
||||
if (!empty($post['score'])) $where['a.total_score'] = $post['score'];
|
||||
|
||||
$count = Db::name('shop_order_comment')->alias('a')->where($where)->count();
|
||||
$Page = new AjaxPage($count, 5);
|
||||
$Comment = Db::name('shop_order_comment')
|
||||
->alias('a')
|
||||
->field($field)
|
||||
->where($where)
|
||||
->join('__USERS__ u', 'a.users_id = u.users_id', 'LEFT')
|
||||
->join('__USERS_LEVEL__ l', 'u.level = l.level_id', 'LEFT')
|
||||
->order('a.comment_id desc')
|
||||
->limit($Page->firstRow . ',' . $Page->listRows)
|
||||
->select();
|
||||
$Comment = !empty($Comment) ? $Comment : [];
|
||||
|
||||
foreach ($Comment as &$value) {
|
||||
// 会员头像处理
|
||||
$value['head_pic'] = handle_subdir_pic(get_head_pic($value['head_pic']));
|
||||
|
||||
// 评价转换星级评分
|
||||
$value['total_score'] = GetScoreArray($value['total_score']);
|
||||
|
||||
// 评价上传的图片
|
||||
$value['upload_img'] = !empty($value['upload_img']) ? explode(',', unserialize($value['upload_img'])) : '';
|
||||
|
||||
// 评价的内容
|
||||
$value['content'] = !empty($value['content']) ? htmlspecialchars_decode(unserialize($value['content'])) : '';
|
||||
}
|
||||
|
||||
// 加载渲染模板
|
||||
$this->assign('Page', $Page->show());
|
||||
$this->assign('Comment', $Comment);
|
||||
}
|
||||
}
|
||||
92
src/application/home/controller/Article.php
Normal file
92
src/application/home/controller/Article.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
class Article extends Base
|
||||
{
|
||||
// 模型标识
|
||||
public $nid = 'article';
|
||||
// 模型ID
|
||||
public $channeltype = '';
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$channeltype_list = config('global.channeltype_list');
|
||||
$this->channeltype = $channeltype_list[$this->nid];
|
||||
}
|
||||
|
||||
public function lists($tid)
|
||||
{
|
||||
$tid_tmp = $tid;
|
||||
$seo_pseudo = config('ey_config.seo_pseudo');
|
||||
if (empty($tid)) {
|
||||
$map = array(
|
||||
'channeltype' => $this->channeltype,
|
||||
'parent_id' => 0,
|
||||
'is_hidden' => 0,
|
||||
'status' => 1,
|
||||
);
|
||||
} else {
|
||||
if (3 == $seo_pseudo) {
|
||||
$map = array('dirname'=>$tid);
|
||||
} else {
|
||||
if (!is_numeric($tid) || strval(intval($tid)) !== strval($tid)) {
|
||||
abort(404,'页面不存在');
|
||||
}
|
||||
$map = array('id'=>$tid);
|
||||
}
|
||||
}
|
||||
$map['lang'] = $this->home_lang; // 多语言
|
||||
$row = M('arctype')->field('id,dirname')->where($map)->order('sort_order asc')->limit(1)->find();
|
||||
$tid = !empty($row['id']) ? intval($row['id']) : 0;
|
||||
$dirname = !empty($row['dirname']) ? $row['dirname'] : '';
|
||||
|
||||
/*301重定向到新的伪静态格式*/
|
||||
$this->jumpRewriteFormat($tid, $dirname, 'lists');
|
||||
/*--end*/
|
||||
|
||||
if (3 == $seo_pseudo) {
|
||||
$tid = $dirname;
|
||||
} else {
|
||||
$tid = $tid_tmp;
|
||||
}
|
||||
|
||||
return action('home/Lists/index', $tid);
|
||||
}
|
||||
|
||||
public function view($aid)
|
||||
{
|
||||
$result = model('Article')->getInfo($aid);
|
||||
if (empty($result)) {
|
||||
abort(404,'页面不存在');
|
||||
} elseif ($result['arcrank'] == -1) {
|
||||
$this->success('待审核稿件,你没有权限阅读!');
|
||||
exit;
|
||||
}
|
||||
// 外部链接跳转
|
||||
if ($result['is_jump'] == 1) {
|
||||
header('Location: '.$result['jumplinks']);
|
||||
exit;
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
$tid = $result['typeid'];
|
||||
$arctypeInfo = model('Arctype')->getInfo($tid);
|
||||
/*301重定向到新的伪静态格式*/
|
||||
$this->jumpRewriteFormat($aid, $arctypeInfo['dirname'], 'view');
|
||||
/*--end*/
|
||||
|
||||
return action('home/View/index', $aid);
|
||||
}
|
||||
}
|
||||
916
src/application/home/controller/Ask.php
Normal file
916
src/application/home/controller/Ask.php
Normal file
@@ -0,0 +1,916 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 陈风任 <491085389@qq.com>
|
||||
* Date: 2019-7-30
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Config;
|
||||
use app\home\logic\AskLogic;
|
||||
|
||||
class Ask extends Base
|
||||
{
|
||||
public $users = [
|
||||
'users_id' => 0,
|
||||
'admin_id' => 0,
|
||||
'nickname' => '游客',
|
||||
];
|
||||
public $users_id = 0;
|
||||
public $nickname = '游客';
|
||||
public $parent_id = -1;
|
||||
public $users_money = 0;
|
||||
public $AskModel;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->AskModel = new \app\home\model\Ask;
|
||||
|
||||
/*问答本身的URL模式*/
|
||||
$ask_seo_pseudo = tpCache('ask.seo_pseudo');
|
||||
/*切换伪静态之后,动态URL跳到伪静态问答首页*/
|
||||
// if ('index' == $this->request->action()) {
|
||||
// $url = $this->request->url();
|
||||
// if (3 == $ask_seo_pseudo && stristr($url, '&c=') && stristr($url, '&a=')) {
|
||||
// $url = url('home/Ask/index');
|
||||
// $this->redirect($url);
|
||||
// }
|
||||
// }
|
||||
/*end*/
|
||||
|
||||
// 头像处理
|
||||
$this->users['head_pic'] = get_head_pic();
|
||||
// 问题表
|
||||
$this->ask_db = Db::name('ask');
|
||||
// 答案表
|
||||
$this->ask_answer_db = Db::name('ask_answer');
|
||||
// 问题回答点赞表
|
||||
$this->ask_answer_like_db = Db::name('ask_answer_like');
|
||||
// 问答业务层
|
||||
$this->AskLogic = new AskLogic;
|
||||
// 问答数据层
|
||||
$this->AskModel = model('Ask');
|
||||
|
||||
/*获取最新的会员信息*/
|
||||
$LatestData = $this->GetUsersLatestData();
|
||||
if (!empty($LatestData)) {
|
||||
// 会员全部信息
|
||||
$this->users = $LatestData;
|
||||
// 会员ID
|
||||
$this->users_id = $LatestData['users_id'];
|
||||
// 会员昵称
|
||||
$this->nickname = $LatestData['nickname'];
|
||||
$this->users_money = $LatestData['users_money'];
|
||||
// 后台管理员信息
|
||||
$this->parent_id = session('admin_info.parent_id');
|
||||
} else {
|
||||
//过滤不需要登陆的行为
|
||||
$ctl_act = CONTROLLER_NAME . '@' . ACTION_NAME;
|
||||
$ctl_all = CONTROLLER_NAME . '@*';
|
||||
$filter_login_action = [
|
||||
'Lists@index', // 问答内容列表
|
||||
'Ask@index', // 问答内容列表
|
||||
'Ask@details', // 问答详情
|
||||
];
|
||||
if (!in_array($ctl_act, $filter_login_action) && !in_array($ctl_all, $filter_login_action)) {
|
||||
if (IS_AJAX) {
|
||||
if (empty($this->users)) {
|
||||
$this->error('请先登录!');
|
||||
}
|
||||
} else {
|
||||
if (isWeixin()) {
|
||||
//微信端
|
||||
$this->redirect('user/Users/users_select_login');
|
||||
exit;
|
||||
} else {
|
||||
// 其他端
|
||||
$this->redirect('user/Users/login');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* END */
|
||||
|
||||
/*加载到模板*/
|
||||
|
||||
$this->assign('users', $this->users);
|
||||
$this->assign('nickname', $this->nickname);
|
||||
$this->assign('AdminParentId', $this->parent_id);
|
||||
/* END */
|
||||
|
||||
/*会员功能是否开启*/
|
||||
$logut_redirect_url = '';
|
||||
$msg = '';
|
||||
$this->usersConfig = getUsersConfigData('all');
|
||||
$web_users_switch = tpCache('web.web_users_switch');
|
||||
if (empty($web_users_switch) || isset($this->usersConfig['users_open_register']) && $this->usersConfig['users_open_register'] == 1) {
|
||||
// 前台会员中心已关闭
|
||||
$logut_redirect_url = ROOT_DIR . '/';
|
||||
$msg = '会员中心尚未开启!';
|
||||
} else if (session('?users_id') && empty($this->users)) {
|
||||
// 登录的会员被后台删除,立马退出会员中心
|
||||
$logut_redirect_url = url('user/Users/centre');
|
||||
$msg = '当前用户名不存在!';
|
||||
}
|
||||
if (!empty($logut_redirect_url)) {
|
||||
// 清理session并回到首页
|
||||
session('users_id', null);
|
||||
session('users', null);
|
||||
$this->error($msg, $logut_redirect_url);
|
||||
exit;
|
||||
}
|
||||
/* END */
|
||||
}
|
||||
|
||||
/**
|
||||
* 问答首页
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$functionLogic = new \app\common\logic\FunctionLogic;
|
||||
$functionLogic->validate_authorfile(2);
|
||||
|
||||
$param = input('param.');
|
||||
|
||||
// 查询条件处理
|
||||
$Where = $this->AskLogic->GetAskWhere($param, $this->parent_id);
|
||||
// Url处理
|
||||
$UrlData = $this->AskLogic->GetUrlData($param);
|
||||
|
||||
// 最新问题,默认读取20条,可传入条数及字段名称进行获取
|
||||
$ResultAsk = $this->AskModel->GetNewAskData($Where);
|
||||
|
||||
// 栏目处理
|
||||
$TypeData = $this->AskModel->GetAskTypeData($param);
|
||||
//贡献榜(积分)score
|
||||
$ScoreList = $this->AskModel->GetOrderList();
|
||||
//财富榜(金币)money
|
||||
$MoneyList = $this->AskModel->GetOrderList('money');
|
||||
//QQ群信息
|
||||
$QqInfo = $this->AskModel->getQq();
|
||||
|
||||
// 主页SEO信息
|
||||
$type_id = !empty($param['type_id']) ? intval($param['type_id']) : 0;
|
||||
$SeoData = $this->AskLogic->GetSeoData($type_id);
|
||||
|
||||
// 数组合并加载到模板
|
||||
$result = array_merge($ResultAsk, $UrlData, $TypeData, $SeoData);
|
||||
// dump($result);exit();
|
||||
$result['ScoreList'] = $ScoreList;
|
||||
$result['MoneyList'] = $MoneyList;
|
||||
$result['Qq'] = $QqInfo;
|
||||
$eyou = array(
|
||||
'field' => $result,
|
||||
);
|
||||
|
||||
$this->assign('eyou', $eyou);
|
||||
return $this->fetch(TEMPLATE_PATH . $this->theme_style_path . DS . 'ask' . DS . 'index.' . $this->view_suffix);
|
||||
}
|
||||
|
||||
/**
|
||||
* 问题详情页
|
||||
*/
|
||||
public function details()
|
||||
{
|
||||
$param = input('param.');
|
||||
|
||||
if (empty($param['ask_id'])) $this->error('请选择浏览的问题');
|
||||
|
||||
// 增加问题浏览点击量
|
||||
$this->AskModel->UpdateAskClick($param['ask_id']);
|
||||
|
||||
// 问题详情数据
|
||||
$AskDetails = $this->AskModel->GetAskDetailsData($param, $this->parent_id, $this->users_id);
|
||||
if (0 == $AskDetails['code']) $this->error($AskDetails['msg']);
|
||||
|
||||
// 问题回答数据,包含最佳答案
|
||||
$AskReplyData = $this->AskModel->GetAskReplyData($param, $this->parent_id);
|
||||
|
||||
// 栏目处理
|
||||
$TypeData = $this->AskModel->GetAskTypeData($param);
|
||||
|
||||
// 热门帖子,周榜
|
||||
$WeekList = $this->AskModel->GetAskWeekListData();
|
||||
|
||||
// 热门帖子,总榜
|
||||
$TotalList = $this->AskModel->GetAskTotalListData();
|
||||
|
||||
// Url处理
|
||||
$UrlData = $this->AskLogic->GetUrlData($param);
|
||||
//QQ群信息
|
||||
$QqInfo = $this->AskModel->getQq();
|
||||
|
||||
// 数组合并加载到模板
|
||||
$result = array_merge($AskDetails, $AskReplyData, $TypeData, $WeekList, $TotalList, $UrlData);
|
||||
$result['Qq'] = $QqInfo;
|
||||
$eyou = array(
|
||||
'field' => $result,
|
||||
);
|
||||
$this->assign('eyou', $eyou);
|
||||
// return $this->fetch($this->Code . THEME_STYLE . '/details');
|
||||
return $this->fetch(TEMPLATE_PATH . $this->theme_style_path . DS . 'ask' . DS . 'details.' . $this->view_suffix);
|
||||
|
||||
}
|
||||
|
||||
// 提交问题
|
||||
public function add_ask()
|
||||
{
|
||||
if (IS_AJAX_POST || IS_POST) {
|
||||
$param = input('param.');
|
||||
// 是否登录、是否允许发布问题、数据判断及处理,返回内容数据
|
||||
$content = $this->ParamDealWith($param);
|
||||
|
||||
/*添加数据*/
|
||||
$AddAsk = [
|
||||
'type_id' => $param['ask_type_id'],
|
||||
'users_id' => $this->users_id,
|
||||
'ask_title' => $param['title'],
|
||||
'money' => $param['money'],
|
||||
'content' => $content,
|
||||
'users_ip' => clientIP(),
|
||||
'add_time' => getTime(),
|
||||
'update_time' => getTime(),
|
||||
];
|
||||
// 如果这个会员组属于需要审核的,则追加
|
||||
if (1 == $this->users['ask_is_review']) $AddAsk['is_review'] = 0;
|
||||
/* END */
|
||||
if ($param['money'] > 0 && $param['money'] > $this->users['users_money']){
|
||||
$this->error('余额不足以抵扣悬赏金额,请充值!');
|
||||
}
|
||||
$ResultId = $this->ask_db->add($AddAsk);
|
||||
if (!empty($ResultId)) {
|
||||
// //悬赏 积分奖励记录
|
||||
$this->AskModel->setScore($this->users_id, $ResultId,0,1,$param['money']);
|
||||
|
||||
$url = $this->AskLogic->GetUrlData($param, 'NewDateUrl');
|
||||
if (1 == $this->users['ask_is_review']) {
|
||||
$this->success('回答成功,但你的回答需要管理员审核!', $url, ['review' => true]);
|
||||
} else {
|
||||
$this->success('发布成功!', $url);
|
||||
}
|
||||
} else {
|
||||
$this->error('发布的信息有误,请检查!');
|
||||
}
|
||||
}
|
||||
|
||||
// 是否允许发布问题
|
||||
$this->IsRelease();
|
||||
|
||||
// 栏目处理
|
||||
$result = $this->AskModel->GetAskTypeData(null, 'add_ask');
|
||||
$result['SubmitAddAsk'] = $this->AskLogic->GetUrlData(null, 'SubmitAddAsk');
|
||||
$result['users_money'] = $this->users_money;
|
||||
|
||||
// 主页SEO信息
|
||||
$SeoData = $this->AskLogic->GetSeoData(0);
|
||||
|
||||
// 数组合并加载到模板
|
||||
$result = array_merge($result, $SeoData);
|
||||
$eyou = array(
|
||||
'field' => $result,
|
||||
);
|
||||
$this->assign('eyou', $eyou);
|
||||
|
||||
return $this->fetch(TEMPLATE_PATH . $this->theme_style_path . DS . 'ask' . DS . 'add_ask.' . $this->view_suffix);
|
||||
}
|
||||
|
||||
// 编辑问题
|
||||
public function edit_ask()
|
||||
{
|
||||
if (IS_AJAX_POST || IS_POST) {
|
||||
$param = input('param.');
|
||||
// 是否登录、是否允许发布问题、数据判断及处理,返回内容数据
|
||||
$content = $this->ParamDealWith($param, false);
|
||||
$ori_money = Db::name('ask')->where('ask_id', $param['ask_id'])->getField('money');
|
||||
if ($ori_money > $param['money']) {
|
||||
$this->error('悬赏金额不能小于' . $ori_money . '元!');
|
||||
}
|
||||
if ($param['money'] > 0 && $param['money'] > $this->users['users_money']){
|
||||
$this->error('余额不足以抵扣悬赏金额,请充值!');
|
||||
}
|
||||
|
||||
/*添加数据*/
|
||||
$UpAsk = [
|
||||
'type_id' => $param['ask_type_id'],
|
||||
'ask_title' => $param['title'],
|
||||
'money' => $param['money'],
|
||||
'content' => $content,
|
||||
'users_ip' => clientIP(),
|
||||
'update_time' => getTime(),
|
||||
];
|
||||
// 如果这个会员组属于需要审核的,则追加
|
||||
if (1 == $this->users['ask_is_review']) $UpAsk['is_review'] = 0;
|
||||
/* END */
|
||||
|
||||
/*条件处理*/
|
||||
$where['ask_id'] = $param['ask_id'];
|
||||
// 不是后台管理则只能修改自己的问题
|
||||
if (empty($this->users['admin_id'])) $where['users_id'] = $this->users_id;
|
||||
/* END */
|
||||
|
||||
$ResultId = $this->ask_db->where($where)->update($UpAsk);
|
||||
if (!empty($ResultId)) {
|
||||
if ($ori_money < $param['money']) {
|
||||
$this->AskModel->updateMoney($this->users_id, $param['money'], $ori_money, $param['ask_id']);
|
||||
}
|
||||
$url = $this->AskLogic->GetUrlData($param, 'AskDetailsUrl');
|
||||
$this->success('编辑成功!', $url);
|
||||
} else {
|
||||
$this->error('编辑的信息有误,请检查!');
|
||||
}
|
||||
}
|
||||
|
||||
// 是否允许发布问题
|
||||
$this->IsRelease(false);
|
||||
$ask_id = input('ask_id/d');
|
||||
|
||||
$where['ask_id'] = $ask_id;
|
||||
// 不是后台管理则只能修改自己的问题
|
||||
if (empty($this->users['admin_id'])) $where['users_id'] = $this->users_id;
|
||||
$Info = $this->ask_db->where($where)->find();
|
||||
if (empty($Info)) $this->error('请选择编辑的问题!');
|
||||
|
||||
// 栏目处理
|
||||
$result = $this->AskModel->GetAskTypeData($Info, 'edit_ask');
|
||||
$result['Info'] = $Info;
|
||||
$result['EditAskUrl'] = $this->AskLogic->GetUrlData(['ask_id' => $ask_id], 'EditAskUrl');
|
||||
$result['users_money'] = $this->users_money;
|
||||
$eyou = array(
|
||||
'field' => $result,
|
||||
);
|
||||
$this->assign('eyou', $eyou);
|
||||
|
||||
// return $this->fetch($this->Code . THEME_STYLE . '/edit_ask');
|
||||
return $this->fetch(TEMPLATE_PATH . $this->theme_style_path . DS . 'ask' . DS . 'edit_ask.' . $this->view_suffix);
|
||||
|
||||
}
|
||||
|
||||
// 采纳最佳答案
|
||||
public function ajax_best_answer()
|
||||
{
|
||||
if (IS_AJAX_POST) {
|
||||
if (!empty($this->users['admin_id']) || $this->users_id = input('post.users_id/d')) {
|
||||
$param = input('param.');
|
||||
|
||||
// 数据判断处理
|
||||
if (empty($param['answer_id']) || empty($param['ask_id'])) $this->error('请选择采纳的回答!');
|
||||
|
||||
// 更新问题数据表
|
||||
$Updata = [
|
||||
'ask_id' => $param['ask_id'],
|
||||
'status' => 1,
|
||||
'solve_time' => getTime(),
|
||||
'bestanswer_id' => $param['answer_id'],
|
||||
'update_time' => getTime(),
|
||||
];
|
||||
$ResultId = $this->ask_db->update($Updata);
|
||||
|
||||
if (!empty($ResultId)) {
|
||||
// 将这个问题下的所有答案设置为非最佳答案
|
||||
$this->ask_answer_db->where('ask_id', $param['ask_id'])->update(['is_bestanswer' => 0]);
|
||||
// 设置当前问题为最佳答案
|
||||
$this->ask_answer_db->where('answer_id', $param['answer_id'])->update(['is_bestanswer' => 1]);
|
||||
$money = $this->ask_db->where('ask_id', $param['ask_id'])->value('money');
|
||||
if (0 < $money) {
|
||||
$answer_user_id = $this->ask_answer_db->where('answer_id', $param['answer_id'])->value('users_id');
|
||||
//悬赏金额插入记录
|
||||
$this->AskModel->setMoney($answer_user_id, $money, $param['ask_id'], $param['answer_id']);
|
||||
}
|
||||
$this->success('已采纳!');
|
||||
} else {
|
||||
$this->error('请选择采纳的回答!');
|
||||
}
|
||||
} else {
|
||||
$this->error('无操作权限!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 添加回答
|
||||
public function ajax_add_answer()
|
||||
{
|
||||
if (IS_AJAX_POST || IS_POST) {
|
||||
$param = input('param.');
|
||||
// 是否登录、是否允许发布问题、数据判断及处理,返回内容数据
|
||||
$content = $this->AnswerDealWith($param, false);
|
||||
|
||||
/*添加数据*/
|
||||
$AddAnswer = [
|
||||
'ask_id' => $param['ask_id'],
|
||||
// 如果这个会员组属于需要审核的,则追加。 默认1为已审核
|
||||
'is_review' => 1 == $this->users['ask_is_review'] ? 0 : 1,
|
||||
'type_id' => $param['type_id'],
|
||||
'users_id' => $this->users_id,
|
||||
'username' => $this->users['username'],
|
||||
'users_ip' => clientIP(),
|
||||
'content' => $content,
|
||||
// 若是回答答案则追加数据
|
||||
'answer_pid' => !empty($param['answer_id']) ? $param['answer_id'] : 0,
|
||||
// 用户则追加数据
|
||||
'at_users_id' => !empty($param['at_users_id']) ? $param['at_users_id'] : 0,
|
||||
'at_answer_id' => !empty($param['at_answer_id']) ? $param['at_answer_id'] : 0,
|
||||
'add_time' => getTime(),
|
||||
'update_time' => getTime(),
|
||||
];
|
||||
$ResultId = $this->ask_answer_db->add($AddAnswer);
|
||||
/* END */
|
||||
|
||||
if (!empty($ResultId)) {
|
||||
$ask_users_id = Db::name('ask')->where('ask_id',$param['ask_id'])->getField('users_id');
|
||||
if ($ask_users_id != $this->users_id){
|
||||
//回答加积分 自问自答不加积分
|
||||
$this->AskModel->setScore($this->users_id, $param['ask_id'], $ResultId, 2);
|
||||
}
|
||||
// 增加问题回复数
|
||||
$this->AskModel->UpdateAskReplies($param['ask_id'], true);
|
||||
if (1 == $this->users['ask_is_review']) {
|
||||
$this->success('回答成功,但你的回答需要管理员审核!', null, ['review' => true]);
|
||||
} else {
|
||||
$AddAnswer['answer_id'] = $ResultId;
|
||||
$AddAnswer['head_pic'] = $this->users['head_pic'];
|
||||
$AddAnswer['at_usersname'] = '';
|
||||
if (!empty($AddAnswer['at_users_id'])) {
|
||||
$FindData = Db::name('users')->field('nickname, username')->where('users_id', $AddAnswer['at_users_id'])->find();
|
||||
$AddAnswer['at_usersname'] = empty($FindData['nickname']) ? $FindData['username'] : $FindData['nickname'];
|
||||
}
|
||||
$ResultData = $this->AskLogic->GetReplyHtml($AddAnswer);
|
||||
$this->success('回答成功!', null, $ResultData);
|
||||
}
|
||||
} else {
|
||||
$this->error('提交信息有误,请刷新重试!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 编辑回答
|
||||
public function ajax_edit_answer()
|
||||
{
|
||||
if (IS_AJAX_POST || IS_POST) {
|
||||
$param = input('param.');
|
||||
// 是否登录、是否允许发布问题、数据判断及处理,返回内容数据
|
||||
$content = $this->AnswerDealWith($param, false);
|
||||
|
||||
/*编辑数据*/
|
||||
$UpAnswerData = [
|
||||
'content' => $content,
|
||||
'users_ip' => clientIP(),
|
||||
'update_time' => getTime(),
|
||||
];
|
||||
// 如果这个会员组属于需要审核的,则追加
|
||||
if (1 == $this->users['ask_is_review']) $UpAnswerData['is_review'] = 0;
|
||||
/* END */
|
||||
|
||||
// 更新条件
|
||||
$where = [
|
||||
'answer_id' => $param['answer_id'],
|
||||
'ask_id' => $param['ask_id'],
|
||||
];
|
||||
if (empty($this->users['admin_id'])) $where['users_id'] = $this->users_id;
|
||||
|
||||
// 更新数据
|
||||
$ResultId = $this->ask_answer_db->where($where)->update($UpAnswerData);
|
||||
if (!empty($ResultId)) {
|
||||
$url = $this->AskLogic->GetUrlData($param, 'AskDetailsUrl');
|
||||
if (1 == $this->users['ask_is_review']) {
|
||||
$this->success('编辑成功,但你的回答需要管理员审核!', $url, ['review' => true]);
|
||||
} else {
|
||||
$this->success('编辑成功!', $url);
|
||||
}
|
||||
} else {
|
||||
$this->error('编辑的信息有误,请检查!');
|
||||
}
|
||||
}
|
||||
|
||||
// 是否允许发布问题
|
||||
$this->IsAnswer(false);
|
||||
|
||||
$answer_id = input('param.answer_id/d');
|
||||
$where = [
|
||||
'a.answer_id' => $answer_id,
|
||||
];
|
||||
if (empty($this->users['admin_id'])) {
|
||||
$where['a.users_id'] = $this->users_id;
|
||||
}
|
||||
$AnswerData = $this->ask_answer_db->field('a.answer_id, a.ask_id, a.content, b.ask_title')
|
||||
->alias('a')
|
||||
->join('ask b', 'a.ask_id = b.ask_id', 'LEFT')
|
||||
->where($where)
|
||||
->find();
|
||||
if (empty($AnswerData)) $this->error('要修改的回答不存在!');
|
||||
|
||||
// 更新人
|
||||
$AnswerData['nickname'] = $this->nickname;
|
||||
$result['Info'] = $AnswerData;
|
||||
$result['EditAnswerUrl'] = $this->AskLogic->GetUrlData(['answer_id' => $answer_id], 'EditAnswer');
|
||||
$eyou = array(
|
||||
'field' => $result,
|
||||
);
|
||||
$this->assign('eyou', $eyou);
|
||||
// return $this->fetch($this->Code . THEME_STYLE . '/edit_answer');
|
||||
return $this->fetch(TEMPLATE_PATH . $this->theme_style_path . DS . 'ask' . DS . 'edit_answer.' . $this->view_suffix);
|
||||
|
||||
}
|
||||
|
||||
// 删除问题、回答
|
||||
public function ajax_del_answer()
|
||||
{
|
||||
if (IS_AJAX_POST) {
|
||||
// 是否登录
|
||||
$this->UsersIsLogin();
|
||||
|
||||
/*数据判断*/
|
||||
$type = input('param.type/d');
|
||||
$ask_id = input('param.ask_id/d');
|
||||
$answer_id = input('param.answer_id/d');
|
||||
if (isset($type) && 3 == $type) {
|
||||
// 删除整条回复内容
|
||||
$answer_id = input('param.id/d');
|
||||
} else if (isset($type) && 1 == $type) {
|
||||
// 删除整个提问问题则执行
|
||||
$this->DelAsk(input('param.'));
|
||||
}
|
||||
if (empty($answer_id) || empty($ask_id)) $this->error('请选择删除信息!');
|
||||
/* END */
|
||||
|
||||
/*删除条件*/
|
||||
$Where = [
|
||||
'ask_id' => $ask_id,
|
||||
'answer_id' => $answer_id,
|
||||
];
|
||||
// 若操作人为后台管理员则允许删除所有人的评论回答
|
||||
if (empty($this->users['admin_id'])) $where['users_id'] = $this->users_id;
|
||||
/* END */
|
||||
|
||||
/*执行删除*/
|
||||
if (isset($type) && 3 == $type) {
|
||||
// 整条评论回答,算计整个评论有多少条数量
|
||||
$CountWhere['answer_pid'] = $answer_id;
|
||||
// 查询整条回答的评论数量
|
||||
$DelNum = $this->ask_answer_db->where($Where)->whereOr($CountWhere)->count();
|
||||
// 删除
|
||||
$ResultId = $this->ask_answer_db->where($Where)->whereOr($CountWhere)->delete();
|
||||
} else {
|
||||
$DelNum = 0;
|
||||
// 删除
|
||||
$ResultId = $this->ask_answer_db->where($Where)->delete();
|
||||
}
|
||||
/* END */
|
||||
|
||||
if (!empty($ResultId)) {
|
||||
// 减少问题回复数
|
||||
$this->AskModel->UpdateAskReplies($ask_id, false, $DelNum);
|
||||
$this->success('删除成功!');
|
||||
} else {
|
||||
$this->error('删除信息错误,请刷新重试!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 删除整个提问问题
|
||||
public function DelAsk($param = array())
|
||||
{
|
||||
if (empty($param['ask_id']) || empty($param['id'])) $this->error('请选择要删除的提问问题!');
|
||||
if (empty($this->users['admin_id'])) $this->error('无操作权限!');
|
||||
|
||||
/*执行删除*/
|
||||
$Where['ask_id'] = $param['ask_id'];
|
||||
$ResultId = $this->ask_db->where($Where)->delete();
|
||||
if (!empty($ResultId)) {
|
||||
// 同步删除对应问题下所有回答
|
||||
$this->ask_answer_db->where($Where)->delete();
|
||||
// 同步删除对应问题下所有点赞
|
||||
$this->ask_answer_like_db->where($Where)->delete();
|
||||
$url = $this->AskLogic->GetUrlData($param, 'NewDateUrl');
|
||||
$url = $this->AskModel->RebackDel($param['ask_id']);
|
||||
|
||||
$this->success('删除成功!', $url);
|
||||
} else {
|
||||
$this->error('删除信息错误,请刷新重试!');
|
||||
}
|
||||
/* END */
|
||||
}
|
||||
|
||||
// 点赞
|
||||
public function ajax_click_like()
|
||||
{
|
||||
if (IS_AJAX_POST) {
|
||||
// 是否登录
|
||||
$this->UsersIsLogin();
|
||||
|
||||
$ask_id = input('param.ask_id/d');
|
||||
$answer_id = input('param.answer_id/d');
|
||||
if (empty($answer_id) || empty($ask_id)) $this->error('请选择点赞信息!');
|
||||
|
||||
$Where = [
|
||||
'ask_id' => $ask_id,
|
||||
'users_id' => $this->users_id,
|
||||
'answer_id' => $answer_id,
|
||||
];
|
||||
$IsCount = $this->ask_answer_like_db->where($Where)->count();
|
||||
if (!empty($IsCount)) {
|
||||
$this->error('您已赞过!');
|
||||
} else {
|
||||
// 添加新的点赞记录
|
||||
$AddData = [
|
||||
'click_like' => 1,
|
||||
'users_ip' => clientIP(),
|
||||
'add_time' => getTime(),
|
||||
'update_time' => getTime(),
|
||||
];
|
||||
$AddData = array_merge($Where, $AddData);
|
||||
$ResultId = $this->ask_answer_like_db->add($AddData);
|
||||
|
||||
if (!empty($ResultId)) {
|
||||
unset($Where['users_id']);
|
||||
$LikeCount = $this->ask_answer_like_db->where($Where)->count();
|
||||
if (1 == $LikeCount) {
|
||||
$LikeName = '<a href="javascript:void(0);">' . $this->nickname . '</a>';
|
||||
} else {
|
||||
$LikeName = '<a href="javascript:void(0);">' . $this->nickname . '</a>、 ';
|
||||
}
|
||||
$data = [
|
||||
// 点赞数
|
||||
'LikeCount' => $LikeCount,
|
||||
// 点赞人
|
||||
'LikeName' => $LikeName,
|
||||
];
|
||||
|
||||
// 同步点赞次数到答案表
|
||||
$UpdataNew = [
|
||||
'click_like' => $LikeCount,
|
||||
'update_time' => getTime(),
|
||||
];
|
||||
$this->ask_answer_db->where($Where)->update($UpdataNew);
|
||||
$this->success('点赞成功!', null, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 审核问题,仅创始人有权限
|
||||
public function ajax_review_ask()
|
||||
{
|
||||
if (IS_AJAX_POST) {
|
||||
// 创始人才有权限在前台审核评论
|
||||
if (0 == $this->parent_id) {
|
||||
$this->UsersIsLogin();
|
||||
$param = input('param.');
|
||||
if (empty($param['ask_id'])) $this->error('请选择需要审核的问题!');
|
||||
// 更新审核问题
|
||||
$UpAakData = [
|
||||
'is_review' => 1,
|
||||
'update_time' => getTime(),
|
||||
];
|
||||
$ResultId = $this->ask_db->where('ask_id', $param['ask_id'])->update($UpAakData);
|
||||
if (!empty($ResultId)) $this->success('审核成功!');
|
||||
$this->error('审核失败!');
|
||||
} else {
|
||||
$this->error('没有操作权限!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 审核评论,仅管理员有权限
|
||||
public function ajax_review_comment()
|
||||
{
|
||||
if (IS_AJAX_POST) {
|
||||
// 创始人才有权限在前台审核评论
|
||||
if (0 == $this->parent_id) {
|
||||
$this->UsersIsLogin();
|
||||
$param = input('param.');
|
||||
if (empty($param['ask_id']) || empty($param['answer_id'])) $this->error('提交信息有误,请刷新重试!');
|
||||
// 更新审核评论
|
||||
$where = [
|
||||
'ask_id' => $param['ask_id'],
|
||||
'answer_id' => $param['answer_id'],
|
||||
];
|
||||
$UpAnswerData = [
|
||||
'is_review' => 1,
|
||||
'update_time' => getTime(),
|
||||
];
|
||||
$ResultId = $this->ask_answer_db->where($where)->update($UpAnswerData);
|
||||
if (!empty($ResultId)) $this->success('审核成功!');
|
||||
$this->error('审核失败!');
|
||||
} else {
|
||||
$this->error('没有操作权限!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取指定数量的评论数据(分页)
|
||||
public function ajax_show_comment()
|
||||
{
|
||||
if (IS_AJAX_POST) {
|
||||
$param = input('param.');
|
||||
$Comment = $this->AskModel->GetAskReplyData($param, $this->parent_id);
|
||||
$Data = !empty($param['is_comment']) ? $Comment['AnswerData'][0]['AnswerSubData'] : $Comment['BestAnswer'][0]['AnswerSubData'];
|
||||
if (!empty($Data)) {
|
||||
$ResultData = $this->AskLogic->ForeachReplyHtml($Data, $this->parent_id);
|
||||
if (empty($ResultData['htmlcode'])) $this->error('没有更多数据');
|
||||
$this->success('查询成功!', null, $ResultData);
|
||||
} else {
|
||||
$this->error('没有更多数据');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 加载会员中心所需数据
|
||||
private function AssignData($param = array())
|
||||
{
|
||||
// 是否登录
|
||||
$this->UsersIsLogin();
|
||||
|
||||
// 主题颜色
|
||||
$this->assign('usersConfig', $this->usersConfig);
|
||||
$this->usersConfig['theme_color'] = $theme_color = !empty($this->usersConfig['theme_color']) ? $this->usersConfig['theme_color'] : '#ff6565'; // 默认主题颜色
|
||||
$this->assign('theme_color', $theme_color);
|
||||
|
||||
// 是否为手机端
|
||||
$is_mobile = isMobile() ? 1 : 2;
|
||||
$this->assign('is_mobile', $is_mobile);
|
||||
|
||||
// 是否为端微信
|
||||
$is_wechat = isWeixin() ? 1 : 2;
|
||||
$this->assign('is_wechat', $is_wechat);
|
||||
|
||||
// 是否为微信端小程序
|
||||
$is_wechat_applets = isWeixinApplets() ? 1 : 0;
|
||||
$this->assign('is_wechat_applets', $is_wechat_applets);
|
||||
|
||||
// 焦点
|
||||
$Focus = empty($param['method']) ? 1 : 2;
|
||||
$this->assign('Focus', $Focus);
|
||||
|
||||
// 菜单名称
|
||||
$this->MenuTitle = Db::name('users_menu')->where([
|
||||
'mca' => 'home/Ask/ask_index',
|
||||
'lang' => $this->home_lang,
|
||||
])->getField('title');
|
||||
$this->assign('MenuTitle', $this->MenuTitle);
|
||||
}
|
||||
|
||||
// 是否登录
|
||||
private function UsersIsLogin()
|
||||
{
|
||||
if (empty($this->users) || empty($this->users_id)) $this->error('请先登录!');
|
||||
}
|
||||
|
||||
// 是否允许发布、编辑问题
|
||||
private function IsRelease($is_add = true)
|
||||
{
|
||||
if (empty($this->users['ask_is_release'])) {
|
||||
if (!empty($is_add)) {
|
||||
$this->error($this->users['level_name'] . '不允许发布问题!');
|
||||
} else {
|
||||
$this->error($this->users['level_name'] . '不允许编辑问题!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 问题数据判断及处理,返回问题内容数据
|
||||
private function ParamDealWith($param = [], $is_add = true)
|
||||
{
|
||||
// 是否登录
|
||||
$this->UsersIsLogin();
|
||||
// 是否允许发布、编辑
|
||||
$this->IsRelease($is_add);
|
||||
|
||||
/*数据判断*/
|
||||
$content = '';
|
||||
if (empty($param)) $this->error('请提交完整信息!');
|
||||
if (empty($param['title'])) $this->error('请填写问题标题!');
|
||||
if (empty($param['ask_type_id'])) $this->error('请选择问题分类!');
|
||||
$content = $this->AskLogic->ContentDealWith($param);
|
||||
if (empty($content)) $this->error('请填写问题描述!');
|
||||
|
||||
// 编辑时执行判断
|
||||
if (empty($is_add) && empty($param['ask_id'])) $this->error('请确认编辑问题!');
|
||||
/* END */
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
// 是否允许发布、编辑评论回复
|
||||
private function IsAnswer($is_add = true)
|
||||
{
|
||||
if (empty($this->users['ask_is_release'])) {
|
||||
if (!empty($is_add)) {
|
||||
$this->error($this->users['level_name'] . '不允许回复答案!');
|
||||
} else {
|
||||
$this->error($this->users['level_name'] . '不允许编辑答案!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 评论回复数据处理,返回评论回复内容数据
|
||||
private function AnswerDealWith($param = [], $is_add = true)
|
||||
{
|
||||
// 是否登录
|
||||
$this->UsersIsLogin();
|
||||
// 是否允许发布、编辑
|
||||
$this->IsAnswer($is_add);
|
||||
|
||||
/*数据判断*/
|
||||
if (!empty($is_add)) {
|
||||
// 添加时执行判断
|
||||
if (empty($param) || empty($param['ask_id'])) $this->error('提交信息有误,请刷新重试!');
|
||||
} else {
|
||||
// 编辑时执行判断
|
||||
if (empty($is_add) && empty($param['ask_id'])) $this->error('请确认编辑问题!');
|
||||
}
|
||||
|
||||
$content = '';
|
||||
$content = $this->AskLogic->ContentDealWith($param);
|
||||
if (empty($content)) $this->error('请写下你的回答!');
|
||||
/* END */
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录的会员最新数据
|
||||
*/
|
||||
private function GetUsersLatestData($users_id = null)
|
||||
{
|
||||
$users_id = empty($users_id) ? session('users_id') : $users_id;
|
||||
if (!empty($users_id)) {
|
||||
/*读取的字段*/
|
||||
$field = 'a.*, b.*, b.discount as level_discount';
|
||||
/* END */
|
||||
|
||||
/*查询数据*/
|
||||
$users = \think\Db::name('users')->field($field)
|
||||
->alias('a')
|
||||
->join('__USERS_LEVEL__ b', 'a.level = b.level_id', 'LEFT')
|
||||
->where([
|
||||
'a.users_id' => $users_id,
|
||||
'a.lang' => get_home_lang(),
|
||||
'a.is_activation' => 1,
|
||||
'a.is_del' => 0,
|
||||
])->find();
|
||||
// 会员不存在则返回空
|
||||
if (empty($users)) return false;
|
||||
/* END */
|
||||
|
||||
/*会员数据处理*/
|
||||
// 头像处理
|
||||
$users['head_pic'] = get_head_pic($users['head_pic']);
|
||||
// 昵称处理
|
||||
$users['nickname'] = empty($users['nickname']) ? $users['username'] : $users['nickname'];
|
||||
// 密码为空并且存在openid则表示微信注册登录,密码字段更新为0,可重置密码一次。
|
||||
$users['password'] = empty($users['password']) && !empty($users['open_id']) ? 0 : 1;
|
||||
// 删除登录密码及支付密码
|
||||
unset($users['paypwd']);
|
||||
// 级别处理
|
||||
$LevelData = [];
|
||||
if (intval($users['level_maturity_days']) >= 36600) {
|
||||
$users['maturity_code'] = 1;
|
||||
$users['maturity_date'] = '终身';
|
||||
} else if (0 == $users['open_level_time'] && 0 == $users['level_maturity_days']) {
|
||||
$users['maturity_code'] = 0;
|
||||
$users['maturity_date'] = '';// 没有升级会员,置空
|
||||
} else {
|
||||
/*计算剩余天数*/
|
||||
$days = $users['open_level_time'] + ($users['level_maturity_days'] * 86400);
|
||||
// 取整
|
||||
$days = ceil(($days - getTime()) / 86400);
|
||||
if (0 >= $days) {
|
||||
/*更新会员的级别*/
|
||||
$LevelData = model('EyouUsers')->UpUsersLevelData($users_id);
|
||||
/* END */
|
||||
$users['maturity_code'] = 2;
|
||||
$users['maturity_date'] = '';// 会员过期,置空
|
||||
} else {
|
||||
$users['maturity_code'] = 3;
|
||||
$users['maturity_date'] = $days . ' 天';
|
||||
}
|
||||
/* END */
|
||||
}
|
||||
/* END */
|
||||
|
||||
// 合并数据
|
||||
$LatestData = array_merge($users, $LevelData);
|
||||
/*更新session*/
|
||||
session('users', $LatestData);
|
||||
// session('open_id', $LatestData['open_id']);
|
||||
session('users_id', $LatestData['users_id']);
|
||||
setcookie('users_id', $LatestData['users_id'], null);
|
||||
/* END */
|
||||
// 返回数据
|
||||
return $LatestData;
|
||||
} else {
|
||||
// session中不存在会员ID则返回空
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
61
src/application/home/controller/Base.php
Normal file
61
src/application/home/controller/Base.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
use think\Controller;
|
||||
use app\common\controller\Common;
|
||||
use think\Db;
|
||||
use think\Request;
|
||||
use app\home\logic\FieldLogic;
|
||||
|
||||
class Base extends Common {
|
||||
|
||||
public $fieldLogic;
|
||||
|
||||
/**
|
||||
* 初始化操作
|
||||
*/
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
|
||||
$this->fieldLogic = new FieldLogic();
|
||||
|
||||
// 设置URL模式
|
||||
set_home_url_mode();
|
||||
|
||||
// 子目录
|
||||
$this->assign('RootDir', ROOT_DIR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 301重定向到新的伪静态格式(针对被搜索引擎收录的旧伪静态URL)
|
||||
* @param intval $id 栏目ID/文档ID
|
||||
* @param string $dirname 目录名称
|
||||
* @param string $type 栏目页/文档页
|
||||
* @return void
|
||||
*/
|
||||
public function jumpRewriteFormat($id, $dirname = null, $type = 'lists')
|
||||
{
|
||||
$seo_pseudo = config('ey_config.seo_pseudo');
|
||||
$seo_rewrite_format = config('ey_config.seo_rewrite_format');
|
||||
if (3 == $seo_pseudo && 1 == $seo_rewrite_format) {
|
||||
if ('lists' == $type) {
|
||||
$url = typeurl('home/Lists/index', array('dirname'=>$dirname));
|
||||
} else {
|
||||
$url = arcurl('home/View/index', array('dirname'=>$dirname, 'aid'=>$id));
|
||||
}
|
||||
//重定向到指定的URL地址 并且使用301
|
||||
$this->redirect($url, 301);
|
||||
}
|
||||
}
|
||||
}
|
||||
792
src/application/home/controller/Buildhtml.php
Normal file
792
src/application/home/controller/Buildhtml.php
Normal file
@@ -0,0 +1,792 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
use think\Db;
|
||||
use think\template\driver\File;
|
||||
|
||||
class Buildhtml extends Base
|
||||
{
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
/*
|
||||
* 清理缓存
|
||||
*/
|
||||
private function clearCache()
|
||||
{
|
||||
cache("channel_page_total_serialize", null);
|
||||
cache("channel_info_serialize", null);
|
||||
cache("has_children_Row_serialize", null);
|
||||
cache("article_info_serialize", null);
|
||||
cache("article_page_total_serialize", null);
|
||||
cache("article_tags_serialize", null);
|
||||
cache("article_attr_info_serialize", null);
|
||||
cache("article_children_row_serialize", null);
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取全站生成时,需要生成的页面的个数
|
||||
*/
|
||||
public function buildIndexAll()
|
||||
{
|
||||
$this->clearCache();
|
||||
$channelData = $this->getChannelData(0);
|
||||
$articleData = $this->getArticleData(0, 0);
|
||||
$msg = $this->handleBuildIndex();
|
||||
$allpagetotal = 1 + $channelData['pagetotal'] + $articleData['pagetotal'];
|
||||
|
||||
$this->success($msg, null, ["achievepage" => 1, "channelpagetotal" => $channelData['pagetotal']
|
||||
, "articlepagetotal" => $articleData['pagetotal'], "allpagetotal" => $allpagetotal]);
|
||||
}
|
||||
|
||||
/*
|
||||
* 生成首页静态页面
|
||||
*/
|
||||
public function buildIndex()
|
||||
{
|
||||
$msg = $this->handleBuildIndex();
|
||||
$this->success($msg);
|
||||
}
|
||||
|
||||
/*
|
||||
* 处理生成首页
|
||||
*/
|
||||
private function handleBuildIndex()
|
||||
{
|
||||
/*获取当前页面URL*/
|
||||
$result['pageurl'] = $this->request->domain() . ROOT_DIR;
|
||||
/*--end*/
|
||||
$eyou = array(
|
||||
'field' => $result,
|
||||
);
|
||||
$this->eyou = array_merge($this->eyou, $eyou);
|
||||
$this->assign('eyou', $this->eyou);
|
||||
$msg = '';
|
||||
try {
|
||||
$savepath = './index.html';
|
||||
$tpl = 'index';
|
||||
$this->request->get(['m' => 'Index']); // 首页焦点
|
||||
$this->filePutContents($savepath, $tpl, 'pc', 0, '/', 0, 1, $result);
|
||||
// $msg .= '<span>index.html生成成功</span><br>';
|
||||
} catch (\Exception $e) {
|
||||
$msg .= '<span>index.html生成失败!' . $e->getMessage() . '</span><br>';
|
||||
}
|
||||
|
||||
return $msg;
|
||||
}
|
||||
|
||||
/*
|
||||
* 写入静态页面
|
||||
*/
|
||||
private function filePutContents($savepath, $tpl, $model = 'pc', $pages = 0, $dir = '/', $tid = 0, $top = 1, $result = [])
|
||||
{
|
||||
ob_start();
|
||||
static $templateConfig = null;
|
||||
null === $templateConfig && $templateConfig = \think\Config::get('template');
|
||||
$templateConfig['view_path'] = "./template/".TPL_THEME."pc/";
|
||||
$template = "./template/".TPL_THEME."{$model}/{$tpl}.{$templateConfig['view_suffix']}";
|
||||
$content = $this->fetch($template, [], [], $templateConfig);
|
||||
|
||||
/*解决模板里没有设置编码的情况*/
|
||||
if (!stristr($content, 'utf-8')) {
|
||||
$content = str_ireplace('<head>', "<head>\n<meta charset='utf-8'>", $content);
|
||||
}
|
||||
/*end*/
|
||||
|
||||
if ($pages > 0) {
|
||||
$page = "/<a(.*?)href(\s*)=(\s*)[\'|\"](.*?)page=([0-9]*)(.*?)data-ey_fc35fdc=[\'|\"]html[\'|\"](.*?)>/i";
|
||||
preg_match_all($page, $content, $matchpage);
|
||||
|
||||
$dir = trim($dir, '.');
|
||||
foreach ($matchpage[0] as $key1 => $value1) {
|
||||
if ($matchpage[5][$key1] == 1) {
|
||||
if ($top == 1) {
|
||||
$url = $dir;
|
||||
} elseif ($top == 2) {
|
||||
$url = $dir . '/lists_' . $tid . '.html';
|
||||
} else {
|
||||
$url = $dir . '/lists_' . $tid . '.html';
|
||||
}
|
||||
} else {
|
||||
$url = $dir . '/lists_' . $tid . '_' . $matchpage[5][$key1] . '.html';
|
||||
}
|
||||
$url = ROOT_DIR . '/' . trim($url, '/');
|
||||
$value1_new = preg_replace('/href(\s*)=(\s*)[\'|\"]([^\'\"]*)[\'|\"]/i', '', $value1);
|
||||
$value1_new = str_replace('data-ey_fc35fdc=', " href=\"{$url}\" data-ey_fc35fdc=", $value1_new);
|
||||
$content = str_ireplace($value1, $value1_new, $content);
|
||||
}
|
||||
}
|
||||
$content = $this->pc_to_mobile_js($content, $result); // 生成静态模式下,自动加上PC端跳转移动端的JS代码
|
||||
echo $content;
|
||||
$_cache = ob_get_contents();
|
||||
ob_end_clean();
|
||||
static $File = null;
|
||||
null === $File && $File = new File;
|
||||
$File->fwrite($savepath, $_cache);
|
||||
}
|
||||
|
||||
/*
|
||||
* 生成文档静态页面
|
||||
*/
|
||||
public function buildArticle()
|
||||
{
|
||||
function_exists('set_time_limit') && set_time_limit(0);
|
||||
|
||||
$typeid = input("param.id/d", 0); // 栏目ID
|
||||
$fid = input("param.fid/d", 0);
|
||||
$achievepage = input("param.achieve/d", 0); // 已完成文档数
|
||||
$this->clearCache();
|
||||
$data = $this->handelBuildArticle($typeid, 0, $fid, $achievepage);
|
||||
|
||||
$this->success($data[0], null, $data[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取详情页数据
|
||||
* $typeid 栏目id
|
||||
* $aid 文章id
|
||||
* $type 类型,0:aid指定的内容,1:上一篇,2:下一篇
|
||||
*/
|
||||
private function getArticleData($typeid, $aid, $type = 0)
|
||||
{
|
||||
$info_serialize = cache("article_info_serialize", "");
|
||||
if (empty($info_serialize)) {
|
||||
if ($type == 0) {
|
||||
$data = getAllArchives($this->home_lang, $typeid, $aid);
|
||||
} else if ($type == 1) {
|
||||
$data = getPreviousArchives($this->home_lang, $typeid, $aid);
|
||||
} else if ($type == 2) {
|
||||
$data = getNextArchives($this->home_lang, $typeid, $aid);
|
||||
}
|
||||
$info = $data['info'];
|
||||
$pagetotal = count($info);
|
||||
$aid_arr = get_arr_column($info, 'aid');
|
||||
$allTags = getAllTags($aid_arr);
|
||||
$allAttrInfo = getAllAttrInfo($aid_arr);
|
||||
/*获取所有栏目是否有子栏目的数组*/
|
||||
$has_children_Row = model('Arctype')->hasChildren(get_arr_column($info, 'typeid'));
|
||||
cache("article_info_serialize", serialize($data));
|
||||
cache("article_page_total_serialize", $pagetotal);
|
||||
cache("article_tags_serialize", serialize($allTags));
|
||||
cache("article_attr_info_serialize", serialize($allAttrInfo));
|
||||
cache("article_children_row_serialize", serialize($has_children_Row));
|
||||
} else {
|
||||
$data = unserialize($info_serialize);
|
||||
$pagetotal = cache("article_page_total_serialize", "");
|
||||
$allTags = unserialize(cache("article_tags_serialize", ""));
|
||||
$allAttrInfo = unserialize(cache("article_attr_info_serialize", ""));
|
||||
$has_children_Row = unserialize(cache("article_children_row_serialize", ""));
|
||||
}
|
||||
|
||||
return ['data' => $data, 'pagetotal' => $pagetotal, 'allTags' => $allTags, 'allAttrInfo' => $allAttrInfo, 'has_children_Row' => $has_children_Row];
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理生成内容页
|
||||
* $typeid 栏目id
|
||||
* $aid 内容页id
|
||||
* $fid 下一次执行栏目id
|
||||
* $achievepage 已完成文档数
|
||||
* $batch 是否分批次执行,true:分批,false:不分批
|
||||
* limit 每次执行多少条数据
|
||||
* type 执行类型,0:aid指定的文档页,1:上一篇,2:下一篇
|
||||
*
|
||||
*/
|
||||
private function handelBuildArticle($typeid, $aid = 0, $nextid = 0, $achievepage = 0, $batch = true, $limit = 20, $type = 0)
|
||||
{
|
||||
$msg = "";
|
||||
$globalConfig = $this->eyou['global'];
|
||||
$result = $this->getArticleData($typeid, $aid, $type);
|
||||
$info = $result['data']['info'];
|
||||
$arctypeRow = $result['data']['arctypeRow'];
|
||||
$allTags = $result['allTags'];
|
||||
$has_children_Row = $result['has_children_Row'];
|
||||
$allAttrInfo = $result['allAttrInfo'];
|
||||
$data['allpagetotal'] = $pagetotal = $result['pagetotal'];
|
||||
$data['achievepage'] = $achievepage;
|
||||
$data['pagetotal'] = 0;
|
||||
|
||||
if ($batch && $pagetotal > $achievepage) {
|
||||
while ($limit && isset($info[$nextid])) {
|
||||
$row = $info[$nextid];
|
||||
$msg .= $msg_temp = $this->createArticle($row, $globalConfig, $arctypeRow, $allTags, $has_children_Row, $allAttrInfo);
|
||||
$data['achievepage'] += 1;
|
||||
$limit--;
|
||||
$nextid++;
|
||||
}
|
||||
$data['fid'] = $nextid;
|
||||
} else if (!$batch) {
|
||||
foreach ($info as $key => $row) {
|
||||
$msg .= $msg_temp = $this->createArticle($row, $globalConfig, $arctypeRow, $allTags, $has_children_Row, $allAttrInfo);
|
||||
$data['achievepage'] += 1;
|
||||
$data['fid'] = $key;
|
||||
}
|
||||
}
|
||||
if ($data['allpagetotal'] == $data['achievepage']) { //生成完全部页面,删除缓存
|
||||
cache("article_info_serialize", null);
|
||||
cache("article_page_total_serialize", null);
|
||||
cache("article_tags_serialize", null);
|
||||
cache("article_attr_info_serialize", null);
|
||||
cache("article_children_row_serialize", null);
|
||||
}
|
||||
|
||||
return [$msg, $data];
|
||||
}
|
||||
|
||||
/*
|
||||
* 生成详情页静态页面
|
||||
*/
|
||||
private function createArticle($result, $globalConfig, $arctypeRow, $allTags, $has_children_Row, $allAttrInfo)
|
||||
{
|
||||
$msg = "";
|
||||
$aid = $result['aid'];
|
||||
static $arc_seo_description_length = null;
|
||||
null === $arc_seo_description_length && $arc_seo_description_length = config('global.arc_seo_description_length');
|
||||
$this->request->post(['aid' => $aid]);
|
||||
$this->request->post(['tid' => $result['typeid']]);
|
||||
|
||||
// tags标签
|
||||
$result['tags'] = empty($allTags[$aid]) ? '' : implode(',', $allTags[$aid]);
|
||||
|
||||
$arctypeInfo = $arctypeRow[$result['typeid']];
|
||||
/*排除文档模型与栏目模型对不上的文档*/
|
||||
if ($arctypeInfo['current_channel'] != $result['channel']) {
|
||||
return false;
|
||||
}
|
||||
if (51 == $result['channel']) return false; // 问答模型
|
||||
/*--end*/
|
||||
$arctypeInfo = model('Arctype')->parentAndTopInfo($result['typeid'], $arctypeInfo);
|
||||
/*自定义字段的数据格式处理*/
|
||||
$arctypeInfo = $this->fieldLogic->getTableFieldList($arctypeInfo, config('global.arctype_channel_id'));
|
||||
/*是否有子栏目,用于标记【全部】选中状态*/
|
||||
$arctypeInfo['has_children'] = !empty($has_children_Row[$result['typeid']]) ? 1 : 0;
|
||||
/*--end*/
|
||||
// 文档模板文件,不指定文档模板,默认以栏目设置的为主
|
||||
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*/
|
||||
|
||||
$result = array_merge($arctypeInfo, $result);
|
||||
|
||||
// 获取当前页面URL
|
||||
$result['arcurl'] = $result['pageurl'] = '';
|
||||
if ($result['is_jump'] != 1) {
|
||||
$result['arcurl'] = $result['pageurl'] = arcurl('home/View/index', $result, true, true);
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
// seo
|
||||
$result['seo_title'] = set_arcseotitle($result['title'], $result['seo_title'], $result['typename']);
|
||||
$result['seo_description'] = @msubstr(checkStrHtml($result['seo_description']), 0, $arc_seo_description_length, false);
|
||||
|
||||
/*支持子目录*/
|
||||
$result['litpic'] = handle_subdir_pic($result['litpic']);
|
||||
/*--end*/
|
||||
|
||||
$result = view_logic($aid, $result['channel'], $result, $allAttrInfo); // 模型对应逻辑
|
||||
|
||||
/*自定义字段的数据格式处理*/
|
||||
$result = $this->fieldLogic->getChannelFieldList($result, $result['channel']);
|
||||
/*--end*/
|
||||
|
||||
$eyou = array(
|
||||
'type' => $arctypeInfo,
|
||||
'field' => $result,
|
||||
);
|
||||
$this->eyou = array_merge($this->eyou, $eyou);
|
||||
$this->assign('eyou', $this->eyou);
|
||||
|
||||
/*模板文件*/
|
||||
$tpl = !empty($result['tempview'])
|
||||
? str_replace('.' . $this->view_suffix, '', $result['tempview'])
|
||||
: 'view_' . $result['nid'];
|
||||
/*--end*/
|
||||
|
||||
$dir = $this->getArticleDir($result['dirpath']);
|
||||
if (!empty($result['htmlfilename'])) {
|
||||
$aid = $result['htmlfilename'];
|
||||
}
|
||||
$savepath = $dir . '/' . $aid . '.html';
|
||||
|
||||
try {
|
||||
$this->filePutContents('./' . $savepath, $tpl, 'pc', 0, '/', 0, 1, $result);
|
||||
} catch (\Exception $e) {
|
||||
$msg .= '<span>' . $savepath . '生成失败!' . $e->getMessage() . '</span><br>';
|
||||
}
|
||||
|
||||
return $msg;
|
||||
}
|
||||
|
||||
private function getArticleDir($dirpath)
|
||||
{
|
||||
$dir = "";
|
||||
$seo_html_pagename = $this->eyou['global']['seo_html_pagename'];
|
||||
$seo_html_arcdir = $this->eyou['global']['seo_html_arcdir'];
|
||||
if ($seo_html_pagename == 1) {//存放顶级目录
|
||||
$dirpath_arr = explode('/', $dirpath);
|
||||
if (count($dirpath_arr) > 2) {
|
||||
$dir = '.' . $seo_html_arcdir . '/' . $dirpath_arr[1];
|
||||
} else {
|
||||
$dir = '.' . $seo_html_arcdir . $dirpath;
|
||||
}
|
||||
} else if ($seo_html_pagename == 3) { //存放子级目录
|
||||
$dirpath_arr = explode('/', $dirpath);
|
||||
if (count($dirpath_arr) > 2) {
|
||||
$dir = '.' . $seo_html_arcdir . '/' . end($dirpath_arr);
|
||||
} else {
|
||||
$dir = '.' . $seo_html_arcdir . $dirpath;
|
||||
}
|
||||
} else { //存放父级目录
|
||||
$dir = '.' . $seo_html_arcdir . $dirpath;
|
||||
}
|
||||
|
||||
return $dir;
|
||||
}
|
||||
|
||||
/*
|
||||
* 生成栏目静态页面
|
||||
* $id tpyeid 栏目id
|
||||
* $fid 下一次执行栏目id
|
||||
* $achievepage 已完成页数
|
||||
*$batch 是否分批次执行,true:分批,false:不分批
|
||||
*
|
||||
*/
|
||||
public function buildChannel()
|
||||
{
|
||||
function_exists('set_time_limit') && set_time_limit(0);
|
||||
$id = input("param.id/d", 0); // 栏目ID
|
||||
$fid = input("param.fid/d", 0);
|
||||
$achievepage = input("param.achieve/d", 0);
|
||||
$this->clearCache();
|
||||
$data = $this->handleBuildChannel($id, $fid, $achievepage);
|
||||
|
||||
$this->success($data[0], null, $data[1]);
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取栏目数据
|
||||
* $id 栏目id
|
||||
* $parent 是否获取下级栏目 true:获取,false:不获取
|
||||
*/
|
||||
private function getChannelData($id, $parent = true, $aid = 0)
|
||||
{
|
||||
$info_serialize = cache("channel_info_serialize", "");
|
||||
if (empty($info_serialize)) {
|
||||
$result = getAllArctype($this->home_lang, $id, $this->view_suffix, $parent, $aid);
|
||||
$info = $result["info"];
|
||||
$pagetotal = $result["pagetotal"];
|
||||
$has_children_Row = model('Arctype')->hasChildren(get_arr_column($info, 'typeid'));
|
||||
|
||||
cache("channel_page_total_serialize", $pagetotal);
|
||||
cache("channel_info_serialize", serialize($info));
|
||||
cache("has_children_Row_serialize", serialize($has_children_Row));
|
||||
} else {
|
||||
$info = unserialize($info_serialize);
|
||||
$pagetotal = cache("channel_page_total_serialize", "");
|
||||
$has_children_Row = unserialize(cache("has_children_Row_serialize", ""));
|
||||
}
|
||||
|
||||
return ['info' => $info, 'pagetotal' => $pagetotal, 'has_children_Row' => $has_children_Row];
|
||||
}
|
||||
|
||||
/*
|
||||
* 处理生成栏目页
|
||||
* $id typeid
|
||||
* $fid 下一次执行栏目id
|
||||
* $achievepage 已完成页数
|
||||
* $batch 是否分批次执行,true:分批,false:不分批
|
||||
* $parent 是否获取下级栏目 true:获取,false:不获取
|
||||
* $aid 文章页id,不等于0时,表示只获取文章页所在的列表页重新生成静态(在添加或者编辑文档内容时使用)
|
||||
*/
|
||||
private function handleBuildChannel($id, $fid = 0, $achievepage = 0, $batch = true, $parent = true, $aid = 0)
|
||||
{
|
||||
$msg = '';
|
||||
$globalConfig = $this->eyou['global'];
|
||||
$result = $this->getChannelData($id, $parent, $aid);
|
||||
$info = $result['info'];
|
||||
$has_children_Row = $result['has_children_Row'];
|
||||
$data['allpagetotal'] = $pagetotal = $result['pagetotal'];
|
||||
$data['achievepage'] = $achievepage;
|
||||
/***********2020 05 19 过滤并删除外部链接生成的静态页面 s*************/
|
||||
foreach ($info as $k => $v) {
|
||||
if ($v['is_part'] == 1 || $v['nid'] == 'ask') {//外部链接或问答模型
|
||||
unset($info[$k]);//从数组里移除
|
||||
$dir = ROOT_PATH . trim($v['dirpath'], '/');
|
||||
if (!empty($v['dirpath']) && true == is_dir($dir)) {//判断是否生成过文件夹,文件夹存在则删除
|
||||
$this->deldir($dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
$info = array_values($info);//重组数组
|
||||
/***********2020 05 19 新增 e*************/
|
||||
if ($batch && $data['allpagetotal'] > $data['achievepage']) {
|
||||
$row = !empty($info[$fid]) ? $info[$fid] : [];
|
||||
!empty($row) && $msg .= $msg_temp = $this->createChannel($row, $globalConfig, $has_children_Row);
|
||||
$data['pagetotal'] = !empty($row['pagetotal']) ? $row['pagetotal'] : 1;
|
||||
$data['achievepage'] += !empty($row['pagetotal']) ? $row['pagetotal'] : 1;
|
||||
$data['fid'] = $fid + 1;
|
||||
$data['typeid'] = !empty($row['typeid']) ? $row['typeid'] : 0;
|
||||
} else if (!$batch) {
|
||||
foreach ($info as $key => $row) {
|
||||
$msg .= $msg_temp = $this->createChannel($row, $globalConfig, $has_children_Row, $aid);
|
||||
$data['pagetotal'] = $row['pagetotal'];
|
||||
$data['achievepage'] += $row['pagetotal'];
|
||||
$data['fid'] = $key;
|
||||
$data['typeid'] = $row['typeid'];
|
||||
}
|
||||
}
|
||||
if ($data['allpagetotal'] == $data['achievepage']) { //生成完全部页面,删除缓存
|
||||
cache("channel_page_total_serialize", null);
|
||||
cache("channel_info_serialize", null);
|
||||
cache("has_children_Row_serialize", null);
|
||||
}
|
||||
|
||||
return [$msg, $data];
|
||||
}
|
||||
|
||||
/*
|
||||
* 生成栏目页面
|
||||
*/
|
||||
private function createChannel($row, $globalConfig, $has_children_Row, $aid = 0)
|
||||
{
|
||||
$msg = "";
|
||||
$seo_html_listname = $this->eyou['global']['seo_html_listname'];
|
||||
$seo_html_arcdir = $this->eyou['global']['seo_html_arcdir'];
|
||||
$tid = $row['typeid'];
|
||||
$this->request->post(['tid' => $tid]);
|
||||
|
||||
$row = $this->lists_logic($row, $has_children_Row); // 模型对应逻辑
|
||||
$eyou = array(
|
||||
'field' => $row,
|
||||
);
|
||||
$this->eyou = array_merge($this->eyou, $eyou);
|
||||
$this->assign('eyou', $this->eyou);
|
||||
|
||||
$tpl = !empty($row['templist']) ? str_replace('.' . $this->view_suffix, '', $row['templist']) : 'lists_' . $row['nid'];
|
||||
|
||||
if (in_array($row['current_channel'], [6, 8])) { //留言模型或单页模型,不存在多页
|
||||
$this->request->get(['page' => '']);
|
||||
$dirpath = explode('/', $eyou['field']['dirpath']);
|
||||
$dirpath_end = end($dirpath);
|
||||
if ($seo_html_listname == 1) { //存放顶级目录
|
||||
$savepath = '.' . $seo_html_arcdir . '/' . $dirpath[1] . "/lists_" . $eyou['field']['typeid'] . ".html";
|
||||
} else if ($seo_html_listname == 3) { // //存放子级目录
|
||||
$savepath = '.' . $seo_html_arcdir . '/' . $dirpath_end . "/lists_" . $eyou['field']['typeid'] . ".html";
|
||||
} else {
|
||||
$savepath = '.' . $seo_html_arcdir . $eyou['field']['dirpath'] . '/' . 'lists_' . $eyou['field']['typeid'] . ".html";
|
||||
}
|
||||
try {
|
||||
$this->filePutContents($savepath, $tpl, 'pc', 0, '/', 0, 1, $row);
|
||||
if ($seo_html_listname == 3) {
|
||||
@copy($savepath, '.' . $seo_html_arcdir . '/' . $dirpath_end . '/index.html');
|
||||
@unlink($savepath);
|
||||
} else if ($seo_html_listname == 2 || count($dirpath) < 3) {
|
||||
@copy($savepath, '.' . $seo_html_arcdir . $eyou['field']['dirpath'] . '/index.html');
|
||||
@unlink($savepath);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$msg .= '<span>' . $savepath . '生成失败!' . $e->getMessage() . '</span><br>';
|
||||
}
|
||||
} else if (!empty($aid)) { //只更新aid所在的栏目页码
|
||||
$orderby = getOrderBy($row['orderby'], $row['orderway']);
|
||||
$limit = getLocationPages($tid, $aid, $orderby);
|
||||
$i = !empty($limit) ? ceil($limit / $row['pagesize']) : 1;
|
||||
$msg .= $this->createMultipageChannel($i, $tid, $row, $has_children_Row, $seo_html_listname, $seo_html_arcdir, $tpl);
|
||||
|
||||
} else { //多条信息的栏目
|
||||
$totalpage = $row['pagetotal'];
|
||||
for ($i = 1; $i <= $totalpage; $i++) {
|
||||
$msg .= $this->createMultipageChannel($i, $tid, $row, $has_children_Row, $seo_html_listname, $seo_html_arcdir, $tpl);
|
||||
}
|
||||
}
|
||||
|
||||
return $msg;
|
||||
}
|
||||
|
||||
/*
|
||||
* 创建有文档列表模型的静态栏目页面
|
||||
*/
|
||||
private function createMultipageChannel($i, $tid, $row, $has_children_Row, $seo_html_listname, $seo_html_arcdir, $tpl)
|
||||
{
|
||||
$msg = "";
|
||||
$this->request->get(['page' => $i]);
|
||||
$row = $this->lists_logic($row, $has_children_Row); // 模型对应逻辑
|
||||
$eyou = array(
|
||||
'field' => $row,
|
||||
);
|
||||
$this->eyou = array_merge($this->eyou, $eyou);
|
||||
$this->assign('eyou', $this->eyou);
|
||||
$dirpath = explode('/', $eyou['field']['dirpath']);
|
||||
$dirpath_end = end($dirpath);
|
||||
if ($seo_html_listname == 1) { //存放顶级目录
|
||||
$dir = '.' . $seo_html_arcdir . '/' . $dirpath[1];
|
||||
$savepath = '.' . $seo_html_arcdir . '/' . $dirpath[1] . "/lists_" . $eyou['field']['typeid'];
|
||||
} else if ($seo_html_listname == 3) { //存放子级目录
|
||||
$dir = '.' . $seo_html_arcdir . '/' . $dirpath_end;
|
||||
$savepath = '.' . $seo_html_arcdir . '/' . $dirpath_end . "/lists_" . $eyou['field']['typeid'];
|
||||
} else {
|
||||
$dir = '.' . $seo_html_arcdir . $eyou['field']['dirpath'];
|
||||
$savepath = '.' . $seo_html_arcdir . $eyou['field']['dirpath'] . '/' . 'lists_' . $eyou['field']['typeid'];
|
||||
}
|
||||
if ($i > 1) {
|
||||
$savepath .= '_' . $i . '.html';;
|
||||
} else {
|
||||
$savepath .= '.html';
|
||||
}
|
||||
$top = 1;
|
||||
if ($i > 1 && $seo_html_listname == 1 && count($dirpath) > 2) {
|
||||
$top = 2;
|
||||
} else if ($i > 1 && $seo_html_listname == 3) {
|
||||
$top = 1;
|
||||
}
|
||||
try {
|
||||
$this->filePutContents($savepath, $tpl, 'pc', $i, $dir, $tid, $top, $row);
|
||||
if ($i == 1 && $seo_html_listname == 3) {
|
||||
@copy($savepath, '.' . $seo_html_arcdir . '/' . $dirpath_end . '/index.html');
|
||||
@unlink($savepath);
|
||||
} else if ($i == 1 && ($seo_html_listname == 2 || count($dirpath) < 3)) {
|
||||
@copy($savepath, '.' . $seo_html_arcdir . $eyou['field']['dirpath'] . '/index.html');
|
||||
@unlink($savepath);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$msg .= '<span>' . $savepath . '生成失败!' . $e->getMessage() . '</span><br>';
|
||||
}
|
||||
|
||||
return $msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新静态生成页
|
||||
* @param int $aid 文章id
|
||||
* @param int $typeid 栏目id
|
||||
* @return boolean
|
||||
* $del_ids 删除的文章数组
|
||||
*/
|
||||
public function upHtml()
|
||||
{
|
||||
$aid = input("param.aid/d");
|
||||
$typeid = input("param.typeid/d");
|
||||
$del_ids = input('param.del_ids/a');
|
||||
$type = input('param.type/s');
|
||||
$lang = input("param.lang/s", 'cn');
|
||||
|
||||
/*由于全站共用删除JS代码,这里排除不能发布文档的模型的控制器*/
|
||||
$ctl_name = input("param.ctl_name/s");
|
||||
$channeltypeRow = Db::name('channeltype')
|
||||
->where('nid', 'NOT IN', ['guestbook', 'single'])
|
||||
->column('ctl_name');
|
||||
array_push($channeltypeRow, 'Archives', 'Arctype', 'Custom');
|
||||
if (!in_array($ctl_name, $channeltypeRow)) {
|
||||
$this->error("排除非发布文档的模型");
|
||||
}
|
||||
/*end*/
|
||||
|
||||
$seo_pseudo = $this->eyou['global']['seo_pseudo'];
|
||||
$this->clearCache();
|
||||
if ($seo_pseudo != 2) {
|
||||
$this->error("当前非静态模式,不做静态处理");
|
||||
}
|
||||
if (!empty($del_ids)) { //删除文章页面
|
||||
$info = Db::name('archives')->field('a.*,b.dirpath')
|
||||
->alias('a')
|
||||
->join('__ARCTYPE__ b', 'a.typeid = b.id', 'LEFT')
|
||||
->where([
|
||||
'a.aid' => ['in', $del_ids],
|
||||
'a.lang' => $lang,
|
||||
])
|
||||
->select();
|
||||
foreach ($info as $key => $row) {
|
||||
$dir = $this->getArticleDir($row['dirpath']);
|
||||
$filename = $row['aid'];
|
||||
$path = $dir . "/" . $filename . ".html";
|
||||
if (file_exists($path)) {
|
||||
@unlink($path);
|
||||
}
|
||||
}
|
||||
} else if (!empty($aid) && !empty($typeid)) { //变更文档信息,更新文档页及相关的栏目页
|
||||
if ('view' == $type) {
|
||||
$this->handelBuildArticle($typeid, $aid, 0, 0, false, 1, 0);
|
||||
$this->handelBuildArticle($typeid, $aid, 0, 0, false, 1, 1); // 更新上篇
|
||||
$this->handelBuildArticle($typeid, $aid, 0, 0, false, 1, 2); // 更新下篇
|
||||
} else if ('lists' == $type) {
|
||||
$data = $this->handleBuildChannel($typeid, 0, 0, false, false, $aid);
|
||||
// $this->handelBuildArticle($typeid,$aid,0,0,false,1,1); // 更新上篇
|
||||
// $this->handelBuildArticle($typeid,$aid,0,0,false,1,2); // 更新下篇
|
||||
} else {
|
||||
$this->handleBuildChannel($typeid, 0, 0, false, false, $aid);
|
||||
$this->handelBuildArticle($typeid, $aid, 0, 0, false);
|
||||
}
|
||||
} else if (!empty($typeid)) { //变更栏目信息,更新栏目页
|
||||
$this->handleBuildIndex();
|
||||
$data = $this->handleBuildChannel($typeid, 0, 0, false, false);
|
||||
}
|
||||
|
||||
$this->success("静态页面生成完成");
|
||||
}
|
||||
|
||||
/*
|
||||
* 拓展页面相关信息
|
||||
*/
|
||||
private function lists_logic($result = [], $has_children_Row = [])
|
||||
{
|
||||
if (empty($result)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$tid = $result['typeid'];
|
||||
|
||||
switch ($result['current_channel']) {
|
||||
case '6': // 单页模型
|
||||
{
|
||||
$arctype_info = model('Arctype')->parentAndTopInfo($tid, $result);
|
||||
if ($arctype_info) {
|
||||
// 读取当前栏目的内容,否则读取每一级第一个子栏目的内容,直到有内容或者最后一级栏目为止。
|
||||
$archivesModel = new \app\home\model\Archives();
|
||||
$result_new = $archivesModel->readContentFirst($tid);
|
||||
// 阅读权限 或 外部链接跳转
|
||||
if ($result_new['arcrank'] == -1 || $result_new['is_part'] == 1) {
|
||||
return false;
|
||||
}
|
||||
/*自定义字段的数据格式处理*/
|
||||
$result_new = $this->fieldLogic->getChannelFieldList($result_new, $result_new['current_channel']);
|
||||
/*--end*/
|
||||
|
||||
$result = array_merge($arctype_info, $result_new);
|
||||
|
||||
$result['templist'] = !empty($arctype_info['templist']) ? $arctype_info['templist'] : 'lists_' . $arctype_info['nid'];
|
||||
$result['dirpath'] = $arctype_info['dirpath'];
|
||||
$result['typeid'] = $arctype_info['typeid'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
$result = model('Arctype')->parentAndTopInfo($tid, $result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($result)) {
|
||||
/*自定义字段的数据格式处理*/
|
||||
$result = $this->fieldLogic->getTableFieldList($result, config('global.arctype_channel_id'));
|
||||
/*--end*/
|
||||
}
|
||||
|
||||
/*是否有子栏目,用于标记【全部】选中状态*/
|
||||
$result['has_children'] = !empty($has_children_Row[$tid]) ? 1 : 0;
|
||||
/*--end*/
|
||||
|
||||
// seo
|
||||
$result['seo_title'] = set_typeseotitle($result['typename'], $result['seo_title']);
|
||||
|
||||
/*获取当前页面URL*/
|
||||
$result['pageurl'] = $result['typeurl'];
|
||||
/*--end*/
|
||||
|
||||
/*给没有type前缀的字段新增一个带前缀的字段,并赋予相同的值*/
|
||||
foreach ($result as $key => $val) {
|
||||
if (!preg_match('/^type/i', $key)) {
|
||||
$key_new = 'type' . $key;
|
||||
!array_key_exists($key_new, $result) && $result[$key_new] = $val;
|
||||
}
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成静态模式下且PC和移动端模板分离,就自动给PC端加上跳转移动端的JS代码
|
||||
* @access public
|
||||
*/
|
||||
private function pc_to_mobile_js($html = '', $result = [])
|
||||
{
|
||||
if (file_exists('./template/'.TPL_THEME.'mobile')) { // 分离式模板
|
||||
|
||||
/*是否开启手机站域名,并且配置*/
|
||||
if (!empty($this->eyou['global']['web_mobile_domain_open']) && !empty($this->eyou['global']['web_mobile_domain'])) {
|
||||
$domain = $this->eyou['global']['web_mobile_domain'] . '.' . $this->request->rootDomain();
|
||||
}
|
||||
/*end*/
|
||||
|
||||
$aid = input('param.aid/d');
|
||||
$tid = input('param.tid/d');
|
||||
if (!empty($aid)) { // 内容页
|
||||
$url = url('home/View/index', ['aid' => $aid], true, true, 1, 1, 0);
|
||||
} else if (!empty($tid)) { // 列表页
|
||||
$url = url('home/Lists/index', ['tid' => $tid], true, true, 1, 1, 0);
|
||||
} else { // 首页
|
||||
$url = $this->request->domain() . ROOT_DIR . '/index.php';
|
||||
}
|
||||
|
||||
$jsStr = <<<EOF
|
||||
<meta http-equiv="mobile-agent" content="format=xhtml;url={$url}">
|
||||
<script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/applewebkit.*mobile/i.test(navigator.userAgent.toLowerCase()) || (/midp|symbianos|nokia|samsung|lg|nec|tcl|alcatel|bird|dbtel|dopod|philips|haier|lenovo|mot-|nokia|sonyericsson|sie-|amoi|zte/.test(navigator.userAgent.toLowerCase()))){try{if(/android|windows phone|webos|iphone|ipod|blackberry/i.test(navigator.userAgent.toLowerCase())){window.location.href="{$url}";}else if(/ipad/i.test(navigator.userAgent.toLowerCase())){}else{}}catch(e){}}}</script>
|
||||
EOF;
|
||||
$html = str_ireplace('</head>', $jsStr . "\n</head>", $html);
|
||||
} else { // 响应式模板
|
||||
// 开启手机站域名,且配置
|
||||
if (!empty($this->eyou['global']['web_mobile_domain_open']) && !empty($this->eyou['global']['web_mobile_domain'])) {
|
||||
if (empty($result['pageurl'])) {
|
||||
$url = $this->request->subDomain($this->eyou['global']['web_mobile_domain']) . ROOT_DIR . '/index.php';
|
||||
} else {
|
||||
$url = !preg_match('/^(http(s?):)?\/\/(.*)$/i', $result['pageurl']) ? $this->request->domain() . $result['pageurl'] : $result['pageurl'];
|
||||
$url = preg_replace('/^(.*)(\/\/)([^\/]*)(\.?)(' . $this->request->rootDomain() . ')(.*)$/i', '${1}${2}' . $this->eyou['global']['web_mobile_domain'] . '.${5}${6}', $url);
|
||||
}
|
||||
|
||||
$mobileDomain = $this->eyou['global']['web_mobile_domain'] . '.' . $this->request->rootDomain();
|
||||
$jsStr = <<<EOF
|
||||
<meta http-equiv="mobile-agent" content="format=xhtml;url={$url}">
|
||||
<script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/applewebkit.*mobile/i.test(navigator.userAgent.toLowerCase()) || (/midp|symbianos|nokia|samsung|lg|nec|tcl|alcatel|bird|dbtel|dopod|philips|haier|lenovo|mot-|nokia|sonyericsson|sie-|amoi|zte/.test(navigator.userAgent.toLowerCase()))){try{if(/android|windows phone|webos|iphone|ipod|blackberry/i.test(navigator.userAgent.toLowerCase())){if(window.location.toString().indexOf('{$mobileDomain}') == -1){window.location.href="{$url}";}}else if(/ipad/i.test(navigator.userAgent.toLowerCase())){}else{}}catch(e){}}}</script>
|
||||
EOF;
|
||||
$html = str_ireplace('</head>', $jsStr . "\n</head>", $html);
|
||||
}
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件夹
|
||||
* @param $dir
|
||||
* @return bool
|
||||
*/
|
||||
public function deldir($dir)
|
||||
{
|
||||
//先删除目录下的文件:
|
||||
$fileArr = glob($dir.'/*.html');
|
||||
if (!empty($fileArr)) {
|
||||
foreach ($fileArr as $key => $val) {
|
||||
!empty($val) && @unlink($val);
|
||||
}
|
||||
}
|
||||
|
||||
$fileArr = glob($dir.'/*');
|
||||
if(empty($fileArr)){ //目录为空
|
||||
rmdir($dir); // 删除空目录
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
97
src/application/home/controller/Download.php
Normal file
97
src/application/home/controller/Download.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
class Download extends Base
|
||||
{
|
||||
// 模型标识
|
||||
public $nid = 'download';
|
||||
// 模型ID
|
||||
public $channeltype = '';
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$channeltype_list = config('global.channeltype_list');
|
||||
$this->channeltype = $channeltype_list[$this->nid];
|
||||
}
|
||||
|
||||
public function lists($tid)
|
||||
{
|
||||
$tid_tmp = $tid;
|
||||
$seo_pseudo = config('ey_config.seo_pseudo');
|
||||
if (empty($tid)) {
|
||||
$map = array(
|
||||
'channeltype' => $this->channeltype,
|
||||
'parent_id' => 0,
|
||||
'is_hidden' => 0,
|
||||
'status' => 1,
|
||||
);
|
||||
} else {
|
||||
if (3 == $seo_pseudo) {
|
||||
$map = array('dirname'=>$tid);
|
||||
} else {
|
||||
if (!is_numeric($tid) || strval(intval($tid)) !== strval($tid)) {
|
||||
abort(404,'页面不存在');
|
||||
}
|
||||
$map = array('id'=>$tid);
|
||||
}
|
||||
}
|
||||
$map['lang'] = $this->home_lang; // 多语言
|
||||
$row = M('arctype')->field('id,dirname')->where($map)->order('sort_order asc')->limit(1)->find();
|
||||
$tid = !empty($row['id']) ? intval($row['id']) : 0;
|
||||
$dirname = !empty($row['dirname']) ? $row['dirname'] : '';
|
||||
|
||||
/*301重定向到新的伪静态格式*/
|
||||
$this->jumpRewriteFormat($tid, $dirname, 'lists');
|
||||
/*--end*/
|
||||
|
||||
if (3 == $seo_pseudo) {
|
||||
$tid = $dirname;
|
||||
} else {
|
||||
$tid = $tid_tmp;
|
||||
}
|
||||
|
||||
return action('home/Lists/index', $tid);
|
||||
}
|
||||
|
||||
public function view($aid)
|
||||
{
|
||||
$param = I('param.');
|
||||
$aid = !empty($param['aid']) ? intval($param['aid']) : '';
|
||||
if (empty($aid)) {
|
||||
abort(404,'页面不存在');
|
||||
}
|
||||
$result = model('Download')->getInfo($aid);
|
||||
if (empty($result)) {
|
||||
abort(404,'页面不存在');
|
||||
} elseif ($result['arcrank'] == -1) {
|
||||
$this->success('待审核稿件,你没有权限阅读!');
|
||||
exit;
|
||||
}
|
||||
// 外部链接跳转
|
||||
if ($result['is_jump'] == 1) {
|
||||
header('Location: '.$result['jumplinks']);
|
||||
exit;
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
$tid = $result['typeid'];
|
||||
$arctypeInfo = model('Arctype')->getInfo($tid);
|
||||
/*301重定向到新的伪静态格式*/
|
||||
$this->jumpRewriteFormat($aid, $arctypeInfo['dirname'], 'view');
|
||||
/*--end*/
|
||||
|
||||
return action('home/View/index', $aid);
|
||||
}
|
||||
}
|
||||
69
src/application/home/controller/Guestbook.php
Normal file
69
src/application/home/controller/Guestbook.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use think\Cache;
|
||||
|
||||
class Guestbook extends Base
|
||||
{
|
||||
// 模型标识
|
||||
public $nid = 'guestbook';
|
||||
// 模型ID
|
||||
public $channeltype = '';
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$channeltype_list = config('global.channeltype_list');
|
||||
$this->channeltype = $channeltype_list[$this->nid];
|
||||
}
|
||||
|
||||
public function lists($tid)
|
||||
{
|
||||
$tid_tmp = $tid;
|
||||
$seo_pseudo = config('ey_config.seo_pseudo');
|
||||
if (empty($tid)) {
|
||||
$map = array(
|
||||
'channeltype' => $this->channeltype,
|
||||
'parent_id' => 0,
|
||||
'is_hidden' => 0,
|
||||
'status' => 1,
|
||||
);
|
||||
} else {
|
||||
if (3 == $seo_pseudo) {
|
||||
$map = array('dirname'=>$tid);
|
||||
} else {
|
||||
if (!is_numeric($tid) || strval(intval($tid)) !== strval($tid)) {
|
||||
abort(404,'页面不存在');
|
||||
}
|
||||
$map = array('id'=>$tid);
|
||||
}
|
||||
}
|
||||
$map['lang'] = $this->home_lang; // 多语言
|
||||
$row = M('arctype')->field('id,dirname')->where($map)->order('sort_order asc')->limit(1)->find();
|
||||
$tid = !empty($row['id']) ? intval($row['id']) : 0;
|
||||
$dirname = !empty($row['dirname']) ? $row['dirname'] : '';
|
||||
|
||||
/*301重定向到新的伪静态格式*/
|
||||
$this->jumpRewriteFormat($tid, $dirname, 'lists');
|
||||
/*--end*/
|
||||
|
||||
if (3 == $seo_pseudo) {
|
||||
$tid = $dirname;
|
||||
} else {
|
||||
$tid = $tid_tmp;
|
||||
}
|
||||
|
||||
return action('home/Lists/index', $tid);
|
||||
}
|
||||
}
|
||||
92
src/application/home/controller/Images.php
Normal file
92
src/application/home/controller/Images.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
class Images extends Base
|
||||
{
|
||||
// 模型标识
|
||||
public $nid = 'images';
|
||||
// 模型ID
|
||||
public $channeltype = '';
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$channeltype_list = config('global.channeltype_list');
|
||||
$this->channeltype = $channeltype_list[$this->nid];
|
||||
}
|
||||
|
||||
public function lists($tid)
|
||||
{
|
||||
$tid_tmp = $tid;
|
||||
$seo_pseudo = config('ey_config.seo_pseudo');
|
||||
if (empty($tid)) {
|
||||
$map = array(
|
||||
'channeltype' => $this->channeltype,
|
||||
'parent_id' => 0,
|
||||
'is_hidden' => 0,
|
||||
'status' => 1,
|
||||
);
|
||||
} else {
|
||||
if (3 == $seo_pseudo) {
|
||||
$map = array('dirname'=>$tid);
|
||||
} else {
|
||||
if (!is_numeric($tid) || strval(intval($tid)) !== strval($tid)) {
|
||||
abort(404,'页面不存在');
|
||||
}
|
||||
$map = array('id'=>$tid);
|
||||
}
|
||||
}
|
||||
$map['lang'] = $this->home_lang; // 多语言
|
||||
$row = M('arctype')->field('id,dirname')->where($map)->order('sort_order asc')->limit(1)->find();
|
||||
$tid = !empty($row['id']) ? intval($row['id']) : 0;
|
||||
$dirname = !empty($row['dirname']) ? $row['dirname'] : '';
|
||||
|
||||
/*301重定向到新的伪静态格式*/
|
||||
$this->jumpRewriteFormat($tid, $dirname, 'lists');
|
||||
/*--end*/
|
||||
|
||||
if (3 == $seo_pseudo) {
|
||||
$tid = $dirname;
|
||||
} else {
|
||||
$tid = $tid_tmp;
|
||||
}
|
||||
|
||||
return action('home/Lists/index', $tid);
|
||||
}
|
||||
|
||||
public function view($aid)
|
||||
{
|
||||
$result = model('Images')->getInfo($aid);
|
||||
if (empty($result)) {
|
||||
abort(404,'页面不存在');
|
||||
} elseif ($result['arcrank'] == -1) {
|
||||
$this->success('待审核稿件,你没有权限阅读!');
|
||||
exit;
|
||||
}
|
||||
// 外部链接跳转
|
||||
if ($result['is_jump'] == 1) {
|
||||
header('Location: '.$result['jumplinks']);
|
||||
exit;
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
$tid = $result['typeid'];
|
||||
$arctypeInfo = model('Arctype')->getInfo($tid);
|
||||
/*301重定向到新的伪静态格式*/
|
||||
$this->jumpRewriteFormat($aid, $arctypeInfo['dirname'], 'view');
|
||||
/*--end*/
|
||||
|
||||
return action('home/View/index', $aid);
|
||||
}
|
||||
}
|
||||
159
src/application/home/controller/Index.php
Normal file
159
src/application/home/controller/Index.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use app\user\logic\PayLogic;
|
||||
|
||||
class Index extends Base
|
||||
{
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$this->wechat_return();
|
||||
$this->alipay_return();
|
||||
$this->Express100();
|
||||
$this->ey_agent();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
/*处理多语言首页链接最后带斜杆,进行301跳转*/
|
||||
$lang = input('param.lang/s');
|
||||
if (preg_match("/\?lang=".$this->home_lang."\/$/i", $this->request->url(true)) && $lang == $this->home_lang.'/') {
|
||||
$langurl = $this->request->url(true);
|
||||
$langurl = rtrim($langurl, '/');
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header('Location: '.$langurl);
|
||||
exit;
|
||||
}
|
||||
/*end*/
|
||||
|
||||
/*首页焦点*/
|
||||
$m = input('param.m/s');
|
||||
if (empty($m)) {
|
||||
$this->request->get(['m'=>'Index']);
|
||||
}
|
||||
/*end*/
|
||||
|
||||
$filename = 'index.html';
|
||||
|
||||
$seo_pseudo = config('ey_config.seo_pseudo');
|
||||
if (file_exists($filename) && 2 == $seo_pseudo && !isset($_GET['clear'])) {
|
||||
if ((isMobile() && !file_exists('./template/'.TPL_THEME.'mobile')) || !isMobile()) {
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header('Location:index.html');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/*获取当前页面URL*/
|
||||
$result['pageurl'] = request()->url(true);
|
||||
/*--end*/
|
||||
$eyou = array(
|
||||
'field' => $result,
|
||||
);
|
||||
//主流平台
|
||||
$list = M('platform')->field('*')->where([])->order('sort desc')->select();
|
||||
$this->assign('list', $list);
|
||||
//案例
|
||||
$case = M('casevideo')->field('*')->where([])->order('id asc')->select();
|
||||
$this->assign('case', $case);
|
||||
|
||||
$this->eyou = array_merge($this->eyou, $eyou);
|
||||
$this->assign('eyou', $this->eyou);
|
||||
|
||||
/*模板文件*/
|
||||
$viewfile = 'index';
|
||||
/*--end*/
|
||||
|
||||
/*多语言内置模板文件名*/
|
||||
if (!empty($this->home_lang)) {
|
||||
$viewfilepath = TEMPLATE_PATH.$this->theme_style_path.DS.$viewfile."_{$this->home_lang}.".$this->view_suffix;
|
||||
if (file_exists($viewfilepath)) {
|
||||
$viewfile .= "_{$this->home_lang}";
|
||||
}
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
$html = $this->fetch(":{$viewfile}");
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信支付回调
|
||||
*/
|
||||
private function wechat_return()
|
||||
{
|
||||
// 获取回调的参数
|
||||
$InputXml = file_get_contents("php://input");
|
||||
if (!empty($InputXml)) {
|
||||
// 解析参数
|
||||
$JsonXml = json_encode(simplexml_load_string($InputXml, 'SimpleXMLElement', LIBXML_NOCDATA));
|
||||
// 转换数组
|
||||
$JsonArr = json_decode($JsonXml, true);
|
||||
// 是否与支付成功
|
||||
if (!empty($JsonArr) && 'SUCCESS' == $JsonArr['result_code'] && 'SUCCESS' == $JsonArr['return_code']) {
|
||||
// 解析判断参数是否为微信支付
|
||||
$attach = explode('|,|', $JsonArr['attach']);
|
||||
if (!empty($attach) && 'wechat' == $attach[0] && 'is_notify' == $attach[1] && !empty($attach[2])) {
|
||||
// 跳转处理回调信息
|
||||
$pay_logic = new PayLogic();
|
||||
$pay_logic->wechat_return($JsonArr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付宝支付回调
|
||||
*/
|
||||
private function alipay_return()
|
||||
{
|
||||
$param = input('param.');
|
||||
if (isset($param['transaction_type']) && isset($param['is_notify'])) {
|
||||
// 跳转处理回调信息
|
||||
$pay_logic = new PayLogic();
|
||||
$pay_logic->alipay_return();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 快递100返回时,重定向关闭父级弹框
|
||||
*/
|
||||
private function Express100()
|
||||
{
|
||||
$coname = input('param.coname/s', '');
|
||||
$m = input('param.m/s', '');
|
||||
if (!empty($coname) || 'user' == $m) {
|
||||
if (isWeixin()) {
|
||||
$this->redirect(url('user/Shop/shop_centre'));
|
||||
exit;
|
||||
}else{
|
||||
$this->redirect(url('api/Rewrite/close_parent_layer'));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 无效链接跳转404
|
||||
*/
|
||||
private function ey_agent()
|
||||
{
|
||||
$ey_agent = input('param.ey_agent/d', 0);
|
||||
if (!IS_AJAX && !empty($ey_agent) && 'home' == MODULE_NAME) {
|
||||
abort(404, '页面不存在');
|
||||
}
|
||||
}
|
||||
}
|
||||
486
src/application/home/controller/Lists.php
Normal file
486
src/application/home/controller/Lists.php
Normal file
@@ -0,0 +1,486 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use think\Db;
|
||||
use think\Verify;
|
||||
|
||||
class Lists extends Base
|
||||
{
|
||||
// 模型标识
|
||||
public $nid = '';
|
||||
// 模型ID
|
||||
public $channel = '';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 栏目列表
|
||||
*/
|
||||
public function index($tid = '')
|
||||
{
|
||||
$param = input('param.');
|
||||
|
||||
/*获取当前栏目ID以及模型ID*/
|
||||
$page_tmp = input('param.page/s', 0);
|
||||
if (empty($tid) || !is_numeric($page_tmp)) {
|
||||
abort(404, '页面不存在');
|
||||
}
|
||||
|
||||
$map = [];
|
||||
/*URL上参数的校验*/
|
||||
/* $seo_pseudo = config('ey_config.seo_pseudo');
|
||||
$url_screen_var = config('global.url_screen_var');
|
||||
if (!isset($param[$url_screen_var]) && 3 == $seo_pseudo)
|
||||
{
|
||||
if (stristr($this->request->url(), '&c=Lists&a=index&')) {
|
||||
abort(404,'页面不存在');
|
||||
}
|
||||
$map = array('a.dirname'=>$tid);
|
||||
}
|
||||
else if (isset($param[$url_screen_var]) || 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=Lists&a=index&')) {
|
||||
abort(404,'页面不存在');
|
||||
} else if (!is_numeric($tid) || strval(intval($tid)) !== strval($tid)) {
|
||||
abort(404,'页面不存在');
|
||||
}
|
||||
$map = array('a.id'=>$tid);
|
||||
|
||||
}else if (2 == $seo_pseudo){ // 生成静态页面代码
|
||||
|
||||
$map = array('a.id'=>$tid);
|
||||
}*/
|
||||
/*--end*/
|
||||
if (!is_numeric($tid) || strval(intval($tid)) !== strval($tid)) {
|
||||
$map = array('a.dirname' => $tid);
|
||||
} else {
|
||||
$map = array('a.id' => intval($tid));
|
||||
}
|
||||
$map['a.is_del'] = 0; // 回收站功能
|
||||
$map['a.lang'] = $this->home_lang; // 多语言
|
||||
$row = M('arctype')->field('a.id, a.current_channel, b.nid')
|
||||
->alias('a')
|
||||
->join('__CHANNELTYPE__ b', 'a.current_channel = b.id', 'LEFT')
|
||||
->where($map)
|
||||
->find();
|
||||
if (empty($row)) {
|
||||
abort(404, '页面不存在');
|
||||
}
|
||||
$tid = $row['id'];
|
||||
$this->nid = $row['nid'];
|
||||
$this->channel = intval($row['current_channel']);
|
||||
/*--end*/
|
||||
|
||||
$result = $this->logic($tid); // 模型对应逻辑
|
||||
|
||||
$eyou = array(
|
||||
'field' => $result,
|
||||
);
|
||||
$this->eyou = array_merge($this->eyou, $eyou);
|
||||
$this->assign('eyou', $this->eyou);
|
||||
// dump($result);exit;
|
||||
/*模板文件*/
|
||||
$viewfile = !empty($result['templist'])
|
||||
? str_replace('.' . $this->view_suffix, '', $result['templist'])
|
||||
: 'lists_' . $this->nid;
|
||||
/*--end*/
|
||||
|
||||
/*多语言内置模板文件名*/
|
||||
if (!empty($this->home_lang)) {
|
||||
$viewfilepath = TEMPLATE_PATH . $this->theme_style_path . DS . $viewfile . "_{$this->home_lang}." . $this->view_suffix;
|
||||
if (file_exists($viewfilepath)) {
|
||||
$viewfile .= "_{$this->home_lang}";
|
||||
}
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
// /*模板文件*/
|
||||
// $viewfile = $filename = !empty($result['templist'])
|
||||
// ? str_replace('.'.$this->view_suffix, '',$result['templist'])
|
||||
// : 'lists_'.$this->nid;
|
||||
// /*--end*/
|
||||
|
||||
// /*每个栏目内置模板文件名*/
|
||||
// $viewfilepath = TEMPLATE_PATH.$this->theme_style_path.DS.$filename."_{$result['id']}.".$this->view_suffix;
|
||||
// if (file_exists($viewfilepath)) {
|
||||
// $viewfile = $filename."_{$result['id']}";
|
||||
// }
|
||||
// /*--end*/
|
||||
|
||||
// /*多语言内置模板文件名*/
|
||||
// if (!empty($this->home_lang)) {
|
||||
// $viewfilepath = TEMPLATE_PATH.$this->theme_style_path.DS.$filename."_{$this->home_lang}.".$this->view_suffix;
|
||||
// if (file_exists($viewfilepath)) {
|
||||
// $viewfile = $filename."_{$this->home_lang}";
|
||||
// }
|
||||
// /*每个栏目内置模板文件名*/
|
||||
// $viewfilepath = TEMPLATE_PATH.$this->theme_style_path.DS.$filename."_{$result['id']}_{$this->home_lang}.".$this->view_suffix;
|
||||
// if (file_exists($viewfilepath)) {
|
||||
// $viewfile = $filename."_{$result['id']}_{$this->home_lang}";
|
||||
// }
|
||||
// /*--end*/
|
||||
// }
|
||||
// /*--end*/
|
||||
|
||||
$view = ":{$viewfile}";
|
||||
if (51 == $this->channel) { // 问答模型
|
||||
$Ask = new \app\home\controller\Ask;
|
||||
return $Ask->index();
|
||||
}else{
|
||||
return $this->fetch($view);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型对应逻辑
|
||||
* @param intval $tid 栏目ID
|
||||
* @return array
|
||||
*/
|
||||
private function logic($tid = '')
|
||||
{
|
||||
$result = array();
|
||||
|
||||
if (empty($tid)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
switch ($this->channel) {
|
||||
case '6': // 单页模型
|
||||
{
|
||||
$arctype_info = model('Arctype')->getInfo($tid);
|
||||
if ($arctype_info) {
|
||||
// 读取当前栏目的内容,否则读取每一级第一个子栏目的内容,直到有内容或者最后一级栏目为止。
|
||||
$archivesModel = new \app\home\model\Archives();
|
||||
$result_new = $archivesModel->readContentFirst($tid);
|
||||
// 阅读权限
|
||||
if ($result_new['arcrank'] == -1) {
|
||||
$this->success('待审核稿件,你没有权限阅读!');
|
||||
exit;
|
||||
}
|
||||
// 外部链接跳转
|
||||
if ($result_new['is_part'] == 1) {
|
||||
$result_new['typelink'] = htmlspecialchars_decode($result_new['typelink']);
|
||||
if (!is_http_url($result_new['typelink'])) {
|
||||
$typeurl = '//'.$this->request->host();
|
||||
if (!preg_match('#^'.ROOT_DIR.'(.*)$#i', $result_new['typelink'])) {
|
||||
$typeurl .= ROOT_DIR;
|
||||
}
|
||||
$typeurl .= '/'.trim($result_new['typelink'], '/');
|
||||
$result_new['typelink'] = $typeurl;
|
||||
}
|
||||
$this->redirect($result_new['typelink']);
|
||||
exit;
|
||||
}
|
||||
/*自定义字段的数据格式处理*/
|
||||
$result_new = $this->fieldLogic->getChannelFieldList($result_new, $this->channel);
|
||||
/*--end*/
|
||||
$result = array_merge($arctype_info, $result_new);
|
||||
|
||||
$result['templist'] = !empty($arctype_info['templist']) ? $arctype_info['templist'] : 'lists_'. $arctype_info['nid'];
|
||||
$result['dirpath'] = $arctype_info['dirpath'];
|
||||
$result['typeid'] = $arctype_info['typeid'];
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
$result = model('Arctype')->getInfo($tid);
|
||||
/*外部链接跳转*/
|
||||
if ($result['is_part'] == 1) {
|
||||
$result['typelink'] = htmlspecialchars_decode($result['typelink']);
|
||||
if (!is_http_url($result['typelink'])) {
|
||||
$result['typelink'] = '//'.$this->request->host().ROOT_DIR.'/'.trim($result['typelink'], '/');
|
||||
}
|
||||
$this->redirect($result['typelink']);
|
||||
exit;
|
||||
}
|
||||
/*end*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($result)) {
|
||||
/*自定义字段的数据格式处理*/
|
||||
$result = $this->fieldLogic->getTableFieldList($result, config('global.arctype_channel_id'));
|
||||
/*--end*/
|
||||
}
|
||||
|
||||
/*是否有子栏目,用于标记【全部】选中状态*/
|
||||
$result['has_children'] = model('Arctype')->hasChildren($tid);
|
||||
/*--end*/
|
||||
|
||||
// seo
|
||||
$result['seo_title'] = set_typeseotitle($result['typename'], $result['seo_title']);
|
||||
|
||||
/*获取当前页面URL*/
|
||||
$result['pageurl'] = $this->request->url(true);
|
||||
/*--end*/
|
||||
|
||||
/*给没有type前缀的字段新增一个带前缀的字段,并赋予相同的值*/
|
||||
foreach ($result as $key => $val) {
|
||||
if (!preg_match('/^type/i', $key)) {
|
||||
$key_new = 'type' . $key;
|
||||
!array_key_exists($key_new, $result) && $result[$key_new] = $val;
|
||||
}
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 留言提交
|
||||
*/
|
||||
public function gbook_submit()
|
||||
{
|
||||
$typeid = input('post.typeid/d');
|
||||
|
||||
if (IS_POST && !empty($typeid)) {
|
||||
$gourl = input('post.gourl/s');
|
||||
$post = input('post.');
|
||||
unset($post['gourl']);
|
||||
|
||||
$token = '__token__';
|
||||
foreach ($post as $key => $val) {
|
||||
if (preg_match('/^__token__/i', $key)) {
|
||||
$token = $key;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$ip = clientIP();
|
||||
|
||||
/*留言间隔限制*/
|
||||
$channel_guestbook_interval = tpSetting('channel_guestbook.channel_guestbook_interval');
|
||||
$channel_guestbook_interval = is_numeric($channel_guestbook_interval) ? intval($channel_guestbook_interval) : 60;
|
||||
if (0 < $channel_guestbook_interval) {
|
||||
$map = array(
|
||||
'ip' => $ip,
|
||||
'typeid' => $typeid,
|
||||
'lang' => $this->home_lang,
|
||||
'add_time' => array('gt', getTime() - $channel_guestbook_interval),
|
||||
);
|
||||
$count = M('guestbook')->where($map)->count('aid');
|
||||
if ($count > 0) {
|
||||
$this->error('同一个IP在'.$channel_guestbook_interval.'秒之内不能重复提交!');
|
||||
}
|
||||
}
|
||||
/*end*/
|
||||
|
||||
//判断必填项
|
||||
$ContentArr = []; // 添加站内信所需参数
|
||||
foreach ($post as $key => $value) {
|
||||
if (stripos($key, "attr_") !== false) {
|
||||
//处理得到自定义属性id
|
||||
$attr_id = substr($key, 5);
|
||||
$attr_id = intval($attr_id);
|
||||
$ga_data = Db::name('guestbook_attribute')->where([
|
||||
'attr_id' => $attr_id,
|
||||
'lang' => $this->home_lang,
|
||||
])->find();
|
||||
if ($ga_data['required'] == 1) {
|
||||
if (empty($value)) {
|
||||
$this->error($ga_data['attr_name'] . '不能为空!');
|
||||
} else {
|
||||
if ($ga_data['validate_type'] == 6) {
|
||||
$pattern = "/^1\d{10}$/";
|
||||
if (!preg_match($pattern, $value)) {
|
||||
$this->error($ga_data['attr_name'] . '格式不正确!');
|
||||
}
|
||||
} elseif ($ga_data['validate_type'] == 7) {
|
||||
$pattern = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/i";
|
||||
if (preg_match($pattern, $value) == false) {
|
||||
$this->error($ga_data['attr_name'] . '格式不正确!');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 添加站内信所需参数
|
||||
array_push($ContentArr, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/* 处理判断验证码 */
|
||||
$is_vertify = 1; // 默认开启验证码
|
||||
$guestbook_captcha = config('captcha.guestbook');
|
||||
if (!function_exists('imagettftext') || empty($guestbook_captcha['is_on'])) {
|
||||
$is_vertify = 0; // 函数不存在,不符合开启的条件
|
||||
}
|
||||
if (1 == $is_vertify) {
|
||||
if (empty($post['vertify'])) {
|
||||
$this->error('图片验证码不能为空!');
|
||||
}
|
||||
|
||||
$verify = new Verify();
|
||||
if (!$verify->check($post['vertify'], $token)) {
|
||||
$this->error('图片验证码不正确!');
|
||||
}
|
||||
}
|
||||
/* END */
|
||||
|
||||
$channeltype_list = config('global.channeltype_list');
|
||||
$this->channel = !empty($channeltype_list['guestbook']) ? $channeltype_list['guestbook'] : 8;
|
||||
|
||||
$newData = array(
|
||||
'typeid' => $typeid,
|
||||
'channel' => $this->channel,
|
||||
'ip' => $ip,
|
||||
'lang' => $this->home_lang,
|
||||
'add_time' => getTime(),
|
||||
'update_time' => getTime(),
|
||||
);
|
||||
$data = array_merge($post, $newData);
|
||||
|
||||
// 数据验证
|
||||
$rule = [
|
||||
'typeid' => 'require|token:' . $token,
|
||||
];
|
||||
$message = [
|
||||
'typeid.require' => '表单缺少标签属性{$field.hidden}',
|
||||
];
|
||||
$validate = new \think\Validate($rule, $message);
|
||||
if (!$validate->batch()->check($data)) {
|
||||
$error = $validate->getError();
|
||||
$error_msg = array_values($error);
|
||||
$this->error($error_msg[0]);
|
||||
} else {
|
||||
$guestbookRow = [];
|
||||
/*处理是否重复表单数据的提交*/
|
||||
$formdata = $data;
|
||||
foreach ($formdata as $key => $val) {
|
||||
if (in_array($key, ['typeid', 'lang']) || preg_match('/^attr_(\d+)$/i', $key)) {
|
||||
continue;
|
||||
}
|
||||
unset($formdata[$key]);
|
||||
}
|
||||
$md5data = md5(serialize($formdata));
|
||||
$data['md5data'] = $md5data;
|
||||
$guestbookRow = M('guestbook')->field('aid')->where(['md5data' => $md5data])->find();
|
||||
/*--end*/
|
||||
$dataStr = '';
|
||||
if (empty($guestbookRow)) { // 非重复表单的才能写入数据库
|
||||
$aid = M('guestbook')->insertGetId($data);
|
||||
if ($aid > 0) {
|
||||
$res = $this->saveGuestbookAttr($aid, $typeid);
|
||||
if ($res){
|
||||
$this->error($res);
|
||||
}
|
||||
}
|
||||
/*插件 - 邮箱发送*/
|
||||
$data = [
|
||||
'gbook_submit',
|
||||
$typeid,
|
||||
$aid,
|
||||
];
|
||||
$dataStr = implode('|', $data);
|
||||
/*--end*/
|
||||
|
||||
/*发送站内信给后台*/
|
||||
SendNotifyMessage($ContentArr, 1, 1, 0);
|
||||
/* END */
|
||||
} else {
|
||||
// 存在重复数据的表单,将在后台显示在最前面
|
||||
Db::name('guestbook')->where('aid', $guestbookRow['aid'])->update([
|
||||
'add_time' => getTime(),
|
||||
'update_time' => getTime(),
|
||||
]);
|
||||
}
|
||||
$this->success('操作成功!', $gourl, $dataStr, 5);
|
||||
}
|
||||
}
|
||||
|
||||
$this->error('表单缺少标签属性{$field.hidden}');
|
||||
}
|
||||
|
||||
/**
|
||||
* 给指定留言添加表单值到 guestbook_attr
|
||||
* @param int $aid 留言id
|
||||
* @param int $typeid 留言栏目id
|
||||
*/
|
||||
private function saveGuestbookAttr($aid, $typeid)
|
||||
{
|
||||
// post 提交的属性 以 attr_id _ 和值的 组合为键名
|
||||
$post = input("post.");
|
||||
$arr = explode(',', config('global.image_ext'));
|
||||
/*上传图片或附件*/
|
||||
foreach ($_FILES as $fileElementId => $file) {
|
||||
try {
|
||||
if (!empty($file['name']) && !is_array($file['name'])) {
|
||||
$ext = pathinfo($file['name'], PATHINFO_EXTENSION);
|
||||
if (in_array($ext,$arr)){
|
||||
$uplaod_data = func_common($fileElementId, 'allimg');
|
||||
}else{
|
||||
$uplaod_data = func_common_doc($fileElementId, 'files');
|
||||
}
|
||||
if (0 == $uplaod_data['errcode']) {
|
||||
$post[$fileElementId] = $uplaod_data['img_url'];
|
||||
} else {
|
||||
return $uplaod_data['errmsg'];
|
||||
// $post[$fileElementId] = '';
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
/*end*/
|
||||
|
||||
$attrArr = [];
|
||||
|
||||
/*多语言*/
|
||||
if (is_language()) {
|
||||
foreach ($post as $key => $val) {
|
||||
if (preg_match_all('/^attr_(\d+)$/i', $key, $matchs)) {
|
||||
$attr_value = intval($matchs[1][0]);
|
||||
$attrArr[$attr_value] = [
|
||||
'attr_id' => $attr_value,
|
||||
];
|
||||
}
|
||||
}
|
||||
$attrArr = model('LanguageAttr')->getBindValue($attrArr, 'guestbook_attribute'); // 多语言
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
foreach ($post as $k => $v) {
|
||||
if (!strstr($k, 'attr_'))
|
||||
continue;
|
||||
|
||||
$attr_id = str_replace('attr_', '', $k);
|
||||
is_array($v) && $v = implode(PHP_EOL, $v);
|
||||
|
||||
/*多语言*/
|
||||
if (!empty($attrArr)) {
|
||||
$attr_id = $attrArr[$attr_id]['attr_id'];
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
//$v = str_replace('_', '', $v); // 替换特殊字符
|
||||
//$v = str_replace('@', '', $v); // 替换特殊字符
|
||||
$v = trim($v);
|
||||
$adddata = array(
|
||||
'aid' => $aid,
|
||||
'attr_id' => $attr_id,
|
||||
'attr_value' => $v,
|
||||
'lang' => $this->home_lang,
|
||||
'add_time' => getTime(),
|
||||
'update_time' => getTime(),
|
||||
);
|
||||
M('GuestbookAttr')->add($adddata);
|
||||
}
|
||||
}
|
||||
}
|
||||
135
src/application/home/controller/Media.php
Normal file
135
src/application/home/controller/Media.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use think\Db;
|
||||
|
||||
class Media extends Base
|
||||
{
|
||||
// 模型标识
|
||||
public $nid = 'media';
|
||||
// 模型ID
|
||||
public $channeltype = '';
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$channeltype_list = config('global.channeltype_list');
|
||||
$this->channeltype = $channeltype_list[$this->nid];
|
||||
}
|
||||
|
||||
public function lists($tid)
|
||||
{
|
||||
$tid_tmp = $tid;
|
||||
$seo_pseudo = config('ey_config.seo_pseudo');
|
||||
if (empty($tid)) {
|
||||
$map = array(
|
||||
'channeltype' => $this->channeltype,
|
||||
'parent_id' => 0,
|
||||
'is_hidden' => 0,
|
||||
'status' => 1,
|
||||
);
|
||||
} else {
|
||||
if (3 == $seo_pseudo) {
|
||||
$map = array('dirname'=>$tid);
|
||||
} else {
|
||||
if (!is_numeric($tid) || strval(intval($tid)) !== strval($tid)) {
|
||||
abort(404,'页面不存在');
|
||||
}
|
||||
$map = array('id'=>$tid);
|
||||
}
|
||||
}
|
||||
$map['lang'] = $this->home_lang; // 多语言
|
||||
$row = M('arctype')->field('id,dirname')->where($map)->order('sort_order asc')->limit(1)->find();
|
||||
$tid = !empty($row['id']) ? intval($row['id']) : 0;
|
||||
$dirname = !empty($row['dirname']) ? $row['dirname'] : '';
|
||||
|
||||
/*301重定向到新的伪静态格式*/
|
||||
$this->jumpRewriteFormat($tid, $dirname, 'lists');
|
||||
/*--end*/
|
||||
|
||||
if (3 == $seo_pseudo) {
|
||||
$tid = $dirname;
|
||||
} else {
|
||||
$tid = $tid_tmp;
|
||||
}
|
||||
|
||||
return action('home/Lists/index', $tid);
|
||||
}
|
||||
|
||||
public function view($aid)
|
||||
{
|
||||
$result = model('Media')->getInfo($aid);
|
||||
if (empty($result)) {
|
||||
abort(404,'页面不存在');
|
||||
} elseif ($result['arcrank'] == -1) {
|
||||
$this->success('待审核稿件,你没有权限阅读!');
|
||||
exit;
|
||||
}
|
||||
// 外部链接跳转
|
||||
if ($result['is_jump'] == 1) {
|
||||
header('Location: '.$result['jumplinks']);
|
||||
exit;
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
$tid = $result['typeid'];
|
||||
$arctypeInfo = model('Arctype')->getInfo($tid);
|
||||
/*301重定向到新的伪静态格式*/
|
||||
$this->jumpRewriteFormat($aid, $arctypeInfo['dirname'], 'view');
|
||||
/*--end*/
|
||||
|
||||
return action('home/View/index', $aid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录视频播放进程
|
||||
*/
|
||||
public function record_process()
|
||||
{
|
||||
\think\Session::pause(); // 暂停session,防止session阻塞机制
|
||||
|
||||
$aid = input('aid/d', 0);
|
||||
$file_id = input('file_id/d', 0);
|
||||
$timeDisplay = input('timeDisplay/d', 0);
|
||||
$users_id = session('users_id');
|
||||
if (empty($users_id)){
|
||||
return true;
|
||||
}
|
||||
if ( 0 == $timeDisplay ){
|
||||
exit;
|
||||
}
|
||||
$where = ['users_id' => $users_id,
|
||||
'aid' => $aid,
|
||||
'file_id' => $file_id];
|
||||
$count = Db::name('media_play_record')->where($where)->find();
|
||||
$data = [
|
||||
'users_id' => intval($users_id),
|
||||
'aid' => intval($aid),
|
||||
'file_id' => intval($file_id),
|
||||
'play_time' => $timeDisplay,
|
||||
'update_time' => getTime(),
|
||||
];
|
||||
if (!empty($count)) {
|
||||
$timeDisplay = $timeDisplay + $count['play_time'];
|
||||
$file_time = Db::name('media_file')->where('file_id',$file_id)->value('file_time');
|
||||
$data['play_time'] = $timeDisplay > $file_time ? $file_time : $timeDisplay;
|
||||
$data['play_time'] = intval($data['play_time']);
|
||||
//更新
|
||||
Db::name('media_play_record')->where($where)->update($data);
|
||||
}else{
|
||||
$data['add_time'] = getTime();
|
||||
Db::name('media_play_record')->insert($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
92
src/application/home/controller/Product.php
Normal file
92
src/application/home/controller/Product.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
class Product extends Base
|
||||
{
|
||||
// 模型标识
|
||||
public $nid = 'product';
|
||||
// 模型ID
|
||||
public $channeltype = '';
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$channeltype_list = config('global.channeltype_list');
|
||||
$this->channeltype = $channeltype_list[$this->nid];
|
||||
}
|
||||
|
||||
public function lists($tid)
|
||||
{
|
||||
$tid_tmp = $tid;
|
||||
$seo_pseudo = config('ey_config.seo_pseudo');
|
||||
if (empty($tid)) {
|
||||
$map = array(
|
||||
'channeltype' => $this->channeltype,
|
||||
'parent_id' => 0,
|
||||
'is_hidden' => 0,
|
||||
'status' => 1,
|
||||
);
|
||||
} else {
|
||||
if (3 == $seo_pseudo) {
|
||||
$map = array('dirname'=>$tid);
|
||||
} else {
|
||||
if (!is_numeric($tid) || strval(intval($tid)) !== strval($tid)) {
|
||||
abort(404,'页面不存在');
|
||||
}
|
||||
$map = array('id'=>$tid);
|
||||
}
|
||||
}
|
||||
$map['lang'] = $this->home_lang; // 多语言
|
||||
$row = M('arctype')->field('id,dirname')->where($map)->order('sort_order asc')->limit(1)->find();
|
||||
$tid = !empty($row['id']) ? intval($row['id']) : 0;
|
||||
$dirname = !empty($row['dirname']) ? $row['dirname'] : '';
|
||||
|
||||
/*301重定向到新的伪静态格式*/
|
||||
$this->jumpRewriteFormat($tid, $dirname, 'lists');
|
||||
/*--end*/
|
||||
|
||||
if (3 == $seo_pseudo) {
|
||||
$tid = $dirname;
|
||||
} else {
|
||||
$tid = $tid_tmp;
|
||||
}
|
||||
|
||||
return action('home/Lists/index', $tid);
|
||||
}
|
||||
|
||||
public function view($aid)
|
||||
{
|
||||
$result = model('Product')->getInfo($aid);
|
||||
if (empty($result)) {
|
||||
abort(404,'页面不存在');
|
||||
} elseif ($result['arcrank'] == -1) {
|
||||
$this->success('待审核稿件,你没有权限阅读!');
|
||||
exit;
|
||||
}
|
||||
// 外部链接跳转
|
||||
if ($result['is_jump'] == 1) {
|
||||
header('Location: '.$result['jumplinks']);
|
||||
exit;
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
$tid = $result['typeid'];
|
||||
$arctypeInfo = model('Arctype')->getInfo($tid);
|
||||
/*301重定向到新的伪静态格式*/
|
||||
$this->jumpRewriteFormat($aid, $arctypeInfo['dirname'], 'view');
|
||||
/*--end*/
|
||||
|
||||
return action('home/View/index', $aid);
|
||||
}
|
||||
}
|
||||
92
src/application/home/controller/Recruit.php
Normal file
92
src/application/home/controller/Recruit.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
class Recruit extends Base
|
||||
{
|
||||
// 模型标识
|
||||
public $nid = 'recruit';
|
||||
// 模型ID
|
||||
public $channeltype = '';
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$channeltype_list = config('global.channeltype_list');
|
||||
$this->channeltype = $channeltype_list[$this->nid];
|
||||
}
|
||||
|
||||
public function lists($tid)
|
||||
{
|
||||
$tid_tmp = $tid;
|
||||
$seo_pseudo = config('ey_config.seo_pseudo');
|
||||
if (empty($tid)) {
|
||||
$map = array(
|
||||
'channeltype' => $this->channeltype,
|
||||
'parent_id' => 0,
|
||||
'is_hidden' => 0,
|
||||
'status' => 1,
|
||||
);
|
||||
} else {
|
||||
if (3 == $seo_pseudo) {
|
||||
$map = array('dirname'=>$tid);
|
||||
} else {
|
||||
if (!is_numeric($tid) || strval(intval($tid)) !== strval($tid)) {
|
||||
abort(404,'页面不存在');
|
||||
}
|
||||
$map = array('id'=>$tid);
|
||||
}
|
||||
}
|
||||
$map['lang'] = $this->home_lang; // 多语言
|
||||
$row = M('arctype')->field('id,dirname')->where($map)->order('sort_order asc')->limit(1)->find();
|
||||
$tid = !empty($row['id']) ? intval($row['id']) : 0;
|
||||
$dirname = !empty($row['dirname']) ? $row['dirname'] : '';
|
||||
|
||||
/*301重定向到新的伪静态格式*/
|
||||
$this->jumpRewriteFormat($tid, $dirname, 'lists');
|
||||
/*--end*/
|
||||
|
||||
if (3 == $seo_pseudo) {
|
||||
$tid = $dirname;
|
||||
} else {
|
||||
$tid = $tid_tmp;
|
||||
}
|
||||
|
||||
return action('home/Lists/index', $tid);
|
||||
}
|
||||
|
||||
public function view($aid)
|
||||
{
|
||||
$result = model('Recruit')->getInfo($aid);
|
||||
if (empty($result)) {
|
||||
abort(404,'页面不存在');
|
||||
} elseif ($result['arcrank'] == -1) {
|
||||
$this->success('待审核稿件,你没有权限阅读!');
|
||||
exit;
|
||||
}
|
||||
// 外部链接跳转
|
||||
if ($result['is_jump'] == 1) {
|
||||
header('Location: '.$result['jumplinks']);
|
||||
exit;
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
$tid = $result['typeid'];
|
||||
$arctypeInfo = model('Arctype')->getInfo($tid);
|
||||
/*301重定向到新的伪静态格式*/
|
||||
$this->jumpRewriteFormat($aid, $arctypeInfo['dirname'], 'view');
|
||||
/*--end*/
|
||||
|
||||
return action('home/View/index', $aid);
|
||||
}
|
||||
}
|
||||
126
src/application/home/controller/Search.php
Normal file
126
src/application/home/controller/Search.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use think\Db;
|
||||
|
||||
class Search extends Base
|
||||
{
|
||||
private $searchword_db;
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$this->searchword_db = Db::name('search_word');
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索主页
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$result = $param = input('param.');
|
||||
|
||||
/*获取当前页面URL*/
|
||||
$result['pageurl'] = request()->url(true);
|
||||
/*--end*/
|
||||
!isset($result['keywords']) && $result['keywords'] = '';
|
||||
$eyou = array(
|
||||
'field' => $result,
|
||||
);
|
||||
$this->eyou = array_merge($this->eyou, $eyou);
|
||||
$this->assign('eyou', $this->eyou);
|
||||
|
||||
$viewfile = 'index_search';
|
||||
|
||||
/*多语言内置模板文件名*/
|
||||
if (!empty($this->home_lang)) {
|
||||
$viewfilepath = TEMPLATE_PATH.$this->theme_style_path.DS.$viewfile.".".$this->view_suffix;
|
||||
if (!file_exists($viewfilepath)) {
|
||||
$viewfilepath = TEMPLATE_PATH.$this->theme_style_path.DS.$viewfile."_{$this->home_lang}.".$this->view_suffix;
|
||||
if (file_exists($viewfilepath)) {
|
||||
$viewfile .= "_{$this->home_lang}";
|
||||
} else {
|
||||
return $this->lists();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$viewfilepath = TEMPLATE_PATH.$this->theme_style_path.DS.$viewfile.".".$this->view_suffix;
|
||||
if (!file_exists($viewfilepath)) {
|
||||
return $this->lists();
|
||||
}
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
return $this->fetch(":{$viewfile}");
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$param = input('param.');
|
||||
|
||||
/*记录搜索词*/
|
||||
$word = $this->request->param('keywords');
|
||||
$page = $this->request->param('page');
|
||||
if(!empty($word) && 2 > $page)
|
||||
{
|
||||
$word = addslashes($word);
|
||||
$nowTime = getTime();
|
||||
$row = $this->searchword_db->field('id')->where(['word'=>$word, 'lang'=>$this->home_lang])->find();
|
||||
if(empty($row))
|
||||
{
|
||||
$this->searchword_db->insert([
|
||||
'word' => $word,
|
||||
'sort_order' => 100,
|
||||
'lang' => $this->home_lang,
|
||||
'add_time' => $nowTime,
|
||||
'update_time' => $nowTime,
|
||||
]);
|
||||
}else{
|
||||
$this->searchword_db->where(['id'=>$row['id']])->update([
|
||||
'searchNum' => Db::raw('searchNum+1'),
|
||||
'update_time' => $nowTime,
|
||||
]);
|
||||
}
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
$result = $param;
|
||||
!isset($result['keywords']) && $result['keywords'] = '';
|
||||
$eyou = array(
|
||||
'field' => $result,
|
||||
);
|
||||
$this->eyou = array_merge($this->eyou, $eyou);
|
||||
$this->assign('eyou', $this->eyou);
|
||||
|
||||
/*模板文件*/
|
||||
$viewfile = 'lists_search';
|
||||
/*--end*/
|
||||
|
||||
/*多语言内置模板文件名*/
|
||||
if (!empty($this->home_lang)) {
|
||||
$viewfilepath = TEMPLATE_PATH.$this->theme_style_path.DS.$viewfile."_{$this->home_lang}.".$this->view_suffix;
|
||||
if (file_exists($viewfilepath)) {
|
||||
$viewfile .= "_{$this->home_lang}";
|
||||
}
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
return $this->fetch(":{$viewfile}");
|
||||
}
|
||||
}
|
||||
71
src/application/home/controller/Single.php
Normal file
71
src/application/home/controller/Single.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
class Single extends Base
|
||||
{
|
||||
// 模型标识
|
||||
public $nid = 'single';
|
||||
// 模型ID
|
||||
public $channeltype = '';
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$channeltype_list = config('global.channeltype_list');
|
||||
$this->channeltype = $channeltype_list[$this->nid];
|
||||
}
|
||||
|
||||
public function lists($tid)
|
||||
{
|
||||
$tid_tmp = $tid;
|
||||
$seo_pseudo = config('ey_config.seo_pseudo');
|
||||
if (empty($tid)) {
|
||||
$map = array(
|
||||
'channeltype' => $this->channeltype,
|
||||
'parent_id' => array('eq', 0),
|
||||
'is_hidden' => 0,
|
||||
'status' => 1,
|
||||
'lang' => $this->home_lang,
|
||||
);
|
||||
$res = M('arctype')->where($map)->order('sort_order asc')->limit(1)->find();
|
||||
$typeurl = model('Arctype')->getTypeUrl($res);
|
||||
header('Location: '.$typeurl);
|
||||
exit;
|
||||
} else {
|
||||
if (3 == $seo_pseudo) {
|
||||
$map = array('dirname'=>$tid);
|
||||
} else {
|
||||
if (!is_numeric($tid) || strval(intval($tid)) !== strval($tid)) {
|
||||
abort(404,'页面不存在');
|
||||
}
|
||||
$map = array('id'=>$tid);
|
||||
}
|
||||
$map['lang'] = $this->home_lang; // 多语言
|
||||
$row = M('arctype')->field('id,dirname')->where($map)->order('sort_order asc')->limit(1)->find();
|
||||
$tid = !empty($row['id']) ? intval($row['id']) : 0;
|
||||
$dirname = !empty($row['dirname']) ? $row['dirname'] : '';
|
||||
/*301重定向到新的伪静态格式*/
|
||||
$this->jumpRewriteFormat($tid, $dirname, 'lists');
|
||||
/*--end*/
|
||||
|
||||
if (3 == $seo_pseudo) {
|
||||
$tid = $dirname;
|
||||
} else {
|
||||
$tid = $tid_tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return action('home/Lists/index', $tid);
|
||||
}
|
||||
}
|
||||
92
src/application/home/controller/Special.php
Normal file
92
src/application/home/controller/Special.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
class Special extends Base
|
||||
{
|
||||
// 模型标识
|
||||
public $nid = 'special';
|
||||
// 模型ID
|
||||
public $channeltype = '';
|
||||
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
$channeltype_list = config('global.channeltype_list');
|
||||
$this->channeltype = $channeltype_list[$this->nid];
|
||||
}
|
||||
|
||||
public function lists($tid)
|
||||
{
|
||||
$tid_tmp = $tid;
|
||||
$seo_pseudo = config('ey_config.seo_pseudo');
|
||||
if (empty($tid)) {
|
||||
$map = array(
|
||||
'channeltype' => $this->channeltype,
|
||||
'parent_id' => 0,
|
||||
'is_hidden' => 0,
|
||||
'status' => 1,
|
||||
);
|
||||
} else {
|
||||
if (3 == $seo_pseudo) {
|
||||
$map = array('dirname'=>$tid);
|
||||
} else {
|
||||
if (!is_numeric($tid) || strval(intval($tid)) !== strval($tid)) {
|
||||
abort(404,'页面不存在');
|
||||
}
|
||||
$map = array('id'=>$tid);
|
||||
}
|
||||
}
|
||||
$map['lang'] = $this->home_lang; // 多语言
|
||||
$row = M('arctype')->field('id,dirname')->where($map)->order('sort_order asc')->limit(1)->find();
|
||||
$tid = !empty($row['id']) ? intval($row['id']) : 0;
|
||||
$dirname = !empty($row['dirname']) ? $row['dirname'] : '';
|
||||
|
||||
/*301重定向到新的伪静态格式*/
|
||||
$this->jumpRewriteFormat($tid, $dirname, 'lists');
|
||||
/*--end*/
|
||||
|
||||
if (3 == $seo_pseudo) {
|
||||
$tid = $dirname;
|
||||
} else {
|
||||
$tid = $tid_tmp;
|
||||
}
|
||||
|
||||
return action('home/Lists/index', $tid);
|
||||
}
|
||||
|
||||
public function view($aid)
|
||||
{
|
||||
$result = model('Special')->getInfo($aid);
|
||||
if (empty($result)) {
|
||||
abort(404,'页面不存在');
|
||||
} elseif ($result['arcrank'] == -1) {
|
||||
$this->success('待审核稿件,你没有权限阅读!');
|
||||
exit;
|
||||
}
|
||||
// 外部链接跳转
|
||||
if ($result['is_jump'] == 1) {
|
||||
header('Location: '.$result['jumplinks']);
|
||||
exit;
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
$tid = $result['typeid'];
|
||||
$arctypeInfo = model('Arctype')->getInfo($tid);
|
||||
/*301重定向到新的伪静态格式*/
|
||||
$this->jumpRewriteFormat($aid, $arctypeInfo['dirname'], 'view');
|
||||
/*--end*/
|
||||
|
||||
return action('home/View/index', $aid);
|
||||
}
|
||||
}
|
||||
144
src/application/home/controller/Tags.php
Normal file
144
src/application/home/controller/Tags.php
Normal file
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
class Tags extends Base
|
||||
{
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 标签主页
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
/*获取当前页面URL*/
|
||||
$result['pageurl'] = $this->request->url(true);
|
||||
/*--end*/
|
||||
$eyou = array(
|
||||
'field' => $result,
|
||||
);
|
||||
$this->eyou = array_merge($this->eyou, $eyou);
|
||||
$this->assign('eyou', $this->eyou);
|
||||
|
||||
/*模板文件*/
|
||||
$viewfile = 'index_tags';
|
||||
/*--end*/
|
||||
|
||||
/*多语言内置模板文件名*/
|
||||
if (!empty($this->home_lang)) {
|
||||
$viewfilepath = TEMPLATE_PATH.$this->theme_style_path.DS.$viewfile."_{$this->home_lang}.".$this->view_suffix;
|
||||
if (file_exists($viewfilepath)) {
|
||||
$viewfile .= "_{$this->home_lang}";
|
||||
}
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
return $this->fetch(":{$viewfile}");
|
||||
}
|
||||
|
||||
/**
|
||||
* 标签列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$param = I('param.');
|
||||
|
||||
$tagid = isset($param['tagid']) ? $param['tagid'] : '';
|
||||
$tag = isset($param['tag']) ? trim($param['tag']) : '';
|
||||
if (!empty($tag)) {
|
||||
$tagindexInfo = M('tagindex')->where([
|
||||
'tag' => $tag,
|
||||
'lang' => $this->home_lang,
|
||||
])->find();
|
||||
} elseif (intval($tagid) > 0) {
|
||||
$tagindexInfo = M('tagindex')->where([
|
||||
'id' => $tagid,
|
||||
'lang' => $this->home_lang,
|
||||
])->find();
|
||||
}
|
||||
|
||||
if (!empty($tagindexInfo)) {
|
||||
$tagid = $tagindexInfo['id'];
|
||||
$tag = $tagindexInfo['tag'];
|
||||
//更新浏览量和记录数
|
||||
$map = array(
|
||||
'tid' => array('eq', $tagid),
|
||||
'arcrank' => array('gt', -1),
|
||||
'lang' => $this->home_lang,
|
||||
);
|
||||
$total = M('taglist')->where($map)
|
||||
->count('tid');
|
||||
M('tagindex')->where([
|
||||
'id' => $tagid,
|
||||
'lang' => $this->home_lang,
|
||||
])->inc('count')
|
||||
->inc('weekcc')
|
||||
->inc('monthcc')
|
||||
->update(array('total'=>$total));
|
||||
|
||||
$ntime = getTime();
|
||||
$oneday = 24 * 3600;
|
||||
|
||||
//周统计
|
||||
if(ceil( ($ntime - $tagindexInfo['weekup'])/$oneday ) > 7)
|
||||
{
|
||||
M('tagindex')->where([
|
||||
'id' => $tagid,
|
||||
'lang' => $this->home_lang,
|
||||
])->update(array('weekcc'=>0, 'weekup'=>$ntime));
|
||||
}
|
||||
|
||||
//月统计
|
||||
if(ceil( ($ntime - $tagindexInfo['monthup'])/$oneday ) > 30)
|
||||
{
|
||||
M('tagindex')->where([
|
||||
'id' => $tagid,
|
||||
'lang' => $this->home_lang,
|
||||
])->update(array('monthcc'=>0, 'monthup'=>$ntime));
|
||||
}
|
||||
} else {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$field_data = array(
|
||||
'tag' => $tag,
|
||||
'tagid' => $tagid,
|
||||
'seo_title' => set_tagseotitle($tag, $tagindexInfo['seo_title']),
|
||||
'seo_keywords' => !empty($tagindexInfo['seo_keywords']) ? $tagindexInfo['seo_keywords'] : $tagindexInfo['seo_keywords'],
|
||||
'seo_description' => !empty($tagindexInfo['seo_description']) ? $tagindexInfo['seo_description'] : $tagindexInfo['seo_description'],
|
||||
);
|
||||
$eyou = array(
|
||||
'field' => $field_data,
|
||||
);
|
||||
$this->eyou = array_merge($this->eyou, $eyou);
|
||||
$this->assign('eyou', $this->eyou);
|
||||
|
||||
/*模板文件*/
|
||||
$viewfile = 'lists_tags';
|
||||
/*--end*/
|
||||
|
||||
/*多语言内置模板文件名*/
|
||||
if (!empty($this->home_lang)) {
|
||||
$viewfilepath = TEMPLATE_PATH.$this->theme_style_path.DS.$viewfile."_{$this->home_lang}.".$this->view_suffix;
|
||||
if (file_exists($viewfilepath)) {
|
||||
$viewfile .= "_{$this->home_lang}";
|
||||
}
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
return $this->fetch(":{$viewfile}");
|
||||
}
|
||||
}
|
||||
688
src/application/home/controller/View.php
Normal file
688
src/application/home/controller/View.php
Normal file
@@ -0,0 +1,688 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\controller;
|
||||
|
||||
use think\Db;
|
||||
|
||||
class View extends Base
|
||||
{
|
||||
// 模型标识
|
||||
public $nid = '';
|
||||
// 模型ID
|
||||
public $channel = '';
|
||||
// 模型名称
|
||||
public $modelName = '';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 内容页
|
||||
*/
|
||||
public function index($aid = '')
|
||||
{
|
||||
$seo_pseudo = config('ey_config.seo_pseudo');
|
||||
/*URL上参数的校验*/
|
||||
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*/
|
||||
|
||||
$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, 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, '页面不存在');
|
||||
// $this->redirect('/public/static/errpage/404.html', 301);
|
||||
}
|
||||
$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('待审核稿件,你没有权限阅读!');
|
||||
// }
|
||||
// }
|
||||
// 外部链接跳转
|
||||
if ($result['is_jump'] == 1) {
|
||||
header('Location: ' . $result['jumplinks']);
|
||||
exit;
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
$tid = $result['typeid'];
|
||||
$arctypeInfo = model('Arctype')->getInfo($tid);
|
||||
/*自定义字段的数据格式处理*/
|
||||
$arctypeInfo = $this->fieldLogic->getTableFieldList($arctypeInfo, config('global.arctype_channel_id'));
|
||||
/*--end*/
|
||||
if (!empty($arctypeInfo)) {
|
||||
|
||||
/*URL上参数的校验*/
|
||||
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'];
|
||||
}
|
||||
if ($dirname != $dirname2) {
|
||||
abort(404, '页面不存在');
|
||||
}
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
// 是否有子栏目,用于标记【全部】选中状态
|
||||
$arctypeInfo['has_children'] = model('Arctype')->hasChildren($tid);
|
||||
// 文档模板文件,不指定文档模板,默认以栏目设置的为主
|
||||
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'] = '';
|
||||
if ($result['is_jump'] != 1) {
|
||||
$result['arcurl'] = arcurl('home/'.$this->modelName.'/view', $result, true, true);
|
||||
$result['pageurl'] = $this->request->url(true);
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
// seo
|
||||
$result['seo_title'] = set_arcseotitle($result['title'], $result['seo_title'], $result['typename'], $result['typeid']);
|
||||
$result['seo_description'] = @msubstr(checkStrHtml($result['seo_description']), 0, config('global.arc_seo_description_length'), false);
|
||||
|
||||
/*支持子目录*/
|
||||
$result['litpic'] = handle_subdir_pic($result['litpic']);
|
||||
/*--end*/
|
||||
|
||||
$result = view_logic($aid, $this->channel, $result, true); // 模型对应逻辑
|
||||
|
||||
/*自定义字段的数据格式处理*/
|
||||
$result = $this->fieldLogic->getChannelFieldList($result, $this->channel);
|
||||
/*--end*/
|
||||
|
||||
$eyou = array(
|
||||
'type' => $arctypeInfo,
|
||||
'field' => $result,
|
||||
);
|
||||
|
||||
$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 (!empty($this->home_lang)) {
|
||||
$viewfilepath = TEMPLATE_PATH . $this->theme_style_path . DS . $viewfile . "_{$this->home_lang}." . $this->view_suffix;
|
||||
if (file_exists($viewfilepath)) {
|
||||
$viewfile .= "_{$this->home_lang}";
|
||||
}
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
$emptyhtml = '';
|
||||
if ($this->eyou['field']['arcrank'] > 0) { // 若需要会员权限则执行
|
||||
if (!session('?users_id')) {
|
||||
$url = url('user/Users/login');
|
||||
if (stristr($url, '.html')) {
|
||||
$url = $url."?referurl={$result['arcurl']}";
|
||||
} else {
|
||||
$url = url('user/Users/login', ['referurl'=>$result['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) {
|
||||
/*待审核稿件,是否有权限查阅的处理,登录的管理员可查阅*/
|
||||
$admin_id = input('param.admin_id/d');
|
||||
if (!session('?admin_id') || empty($admin_id)) {
|
||||
$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)) {
|
||||
/*尝试写入静态缓存*/
|
||||
write_html_cache($emptyhtml, $result);
|
||||
/*--end*/
|
||||
return $this->display($emptyhtml);
|
||||
} else {
|
||||
return $this->fetch(":{$viewfile}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*/
|
||||
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_id')
|
||||
->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;
|
||||
}
|
||||
|
||||
// 下载次数限制
|
||||
$this->down_num_access($result['aid']);
|
||||
|
||||
// 判断会员信息
|
||||
if (0 < intval($result['arc_level_id'])) {
|
||||
$UsersData = session('users');
|
||||
if (empty($UsersData['users_id'])) {
|
||||
$this->error('请登录后下载!', null, ['is_login'=>0, 'url'=>url('user/Users/login')]);
|
||||
exit;
|
||||
} else {
|
||||
/*判断会员是否可下载该文件--2019-06-21 陈风任添加*/
|
||||
// 查询会员信息
|
||||
$users = Db::name('users')
|
||||
->alias('a')
|
||||
->field('a.users_id,b.level_value,b.level_name')
|
||||
->join('__USERS_LEVEL__ b', 'a.level = b.level_id', 'LEFT')
|
||||
->where(['a.users_id' => $UsersData['users_id']])
|
||||
->find();
|
||||
// 查询下载所需等级值
|
||||
$file_level = Db::name('archives')
|
||||
->alias('a')
|
||||
->field('b.level_value,b.level_name')
|
||||
->join('__USERS_LEVEL__ b', 'a.arc_level_id = b.level_id', 'LEFT')
|
||||
->where(['a.aid' => $result['aid']])
|
||||
->find();
|
||||
if ($users['level_value'] < $file_level['level_value']) {
|
||||
$msg = '文件为【' . $file_level['level_name'] . '】可下载,您当前为【' . $users['level_name'] . '】,请先升级!';
|
||||
$this->error($msg, null, ['url'=>url('user/Level/level_centre')]);
|
||||
exit;
|
||||
}
|
||||
/*--end*/
|
||||
}
|
||||
}
|
||||
|
||||
// 外部下载链接
|
||||
if (is_http_url($result['file_url']) || !empty($result['is_remote'])) {
|
||||
if ($result['uhash'] != md5($result['file_url'])) {
|
||||
$this->error('下载地址出错!');
|
||||
}
|
||||
|
||||
// 记录下载次数
|
||||
$this->download_log($result['file_id'], $result['aid']);
|
||||
|
||||
$result['file_url'] = htmlspecialchars_decode($result['file_url']);
|
||||
if (IS_AJAX) {
|
||||
$this->success('正在跳转中……', $result['file_url']);
|
||||
} else {
|
||||
$this->redirect($result['file_url']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
// 本站链接
|
||||
else
|
||||
{
|
||||
if (md5_file('.' . $file_url_gbk) != $result['md5file']) {
|
||||
$this->error('下载文件包已损坏!');
|
||||
}
|
||||
|
||||
// 记录下载次数
|
||||
$this->download_log($result['file_id'], $result['aid']);
|
||||
|
||||
$uhash_mch = mchStrCode($uhash);
|
||||
$url = $this->root_dir . "/index.php?m=home&c=View&a=download_file&file_id={$file_id}&uhash={$uhash_mch}";
|
||||
cookie($file_id.$uhash_mch, 1);
|
||||
if (IS_AJAX) {
|
||||
$this->success('开始下载中……', $url);
|
||||
} else {
|
||||
$url = $this->request->domain() . $url;
|
||||
$this->redirect($url);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地附件下载
|
||||
*/
|
||||
public function download_file()
|
||||
{
|
||||
$file_id = input('param.file_id/d');
|
||||
$uhash_mch = input('param.uhash/s', '');
|
||||
$uhash = mchStrCode($uhash_mch, 'DECODE');
|
||||
$map = array(
|
||||
'file_id' => $file_id,
|
||||
);
|
||||
$result = Db::name('download_file')->field('aid,file_url,file_mime,uhash')->where($map)->find();
|
||||
if (!empty($result['uhash']) && $uhash != $result['uhash']) {
|
||||
$this->error('下载地址出错!');
|
||||
}
|
||||
|
||||
$value = cookie($file_id.$uhash_mch);
|
||||
if (empty($value)) {
|
||||
$result = Db::name('archives')
|
||||
->field("b.*, a.*")
|
||||
->alias('a')
|
||||
->join('__ARCTYPE__ b', 'b.id = a.typeid', 'LEFT')
|
||||
->where(['a.aid'=>$result['aid']])
|
||||
->find();
|
||||
$arcurl = arcurl('home/Download/view', $result);
|
||||
$this->error('下载地址已失效,请在下载详情页进行下载!', $arcurl);
|
||||
} else {
|
||||
cookie($file_id.$uhash_mch, null);
|
||||
}
|
||||
|
||||
download_file($result['file_url'], $result['file_mime']);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员每天下载次数的限制
|
||||
*/
|
||||
private function down_num_access($aid)
|
||||
{
|
||||
/*是否安装启用下载次数限制插件*/
|
||||
if (is_dir('./weapp/Downloads/')) {
|
||||
$DownloadsRow = model('Weapp')->getWeappList('Downloads');
|
||||
if (1 != $DownloadsRow['status']) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
/*end*/
|
||||
|
||||
$users = session('users');
|
||||
if (empty($users['users_id'])) {
|
||||
$this->error('请登录后下载!');
|
||||
}
|
||||
|
||||
$level_info = Db::name('users_level')->field('level_name,down_count')->where(['level_id' => $users['level']])->find();
|
||||
if (empty($level_info)) {
|
||||
$this->error('当前会员等级不存在!');
|
||||
}
|
||||
|
||||
$begin_mtime = strtotime(date('Y-m-d 00:00:00'));
|
||||
$end_mtime = strtotime(date('Y-m-d 23:59:59'));
|
||||
$downNum = Db::name('download_log')->where([
|
||||
'users_id' => $users['users_id'],
|
||||
'add_time' => ['between', [$begin_mtime, $end_mtime]],
|
||||
'aid' => ['NEQ', $aid],
|
||||
])->group('aid')->count('aid');
|
||||
if (intval($level_info['down_count']) <= intval($downNum)) {
|
||||
$msg = "{$level_info['level_name']}每天最多下载{$level_info['down_count']}个!";
|
||||
$this->error($msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录下载次数(重复下载不做记录,游客可重复记录)
|
||||
*/
|
||||
private function download_log($file_id = 0, $aid = 0)
|
||||
{
|
||||
try {
|
||||
$users_id = session('users_id');
|
||||
$users_id = intval($users_id);
|
||||
|
||||
$counts = Db::name('download_log')->where([
|
||||
'file_id' => $file_id,
|
||||
'aid' => $aid,
|
||||
'users_id' => $users_id,
|
||||
])->count();
|
||||
if (empty($users_id) || empty($counts)) {
|
||||
$saveData = [
|
||||
'users_id' => $users_id,
|
||||
'aid' => $aid,
|
||||
'file_id' => $file_id,
|
||||
'ip' => clientIP(),
|
||||
'add_time' => getTime(),
|
||||
];
|
||||
$r = Db::name('download_log')->insertGetId($saveData);
|
||||
if ($r !== false) {
|
||||
Db::name('download_file')->where(['file_id' => $file_id])->setInc('downcount');
|
||||
Db::name('archives')->where(['aid' => $aid])->setInc('downcount');
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取播放视频路径(仅限于早期第一套和第二套使用)
|
||||
*/
|
||||
public function pay_video_url()
|
||||
{
|
||||
$file_id = input('param.id/d', 0);
|
||||
$uhash = input('param.uhash/s', '');
|
||||
|
||||
if (empty($file_id) || empty($uhash)) $this->error('视频播放链接出错!');
|
||||
|
||||
// 查询信息
|
||||
$map = array(
|
||||
'a.file_id' => $file_id,
|
||||
'a.uhash' => $uhash
|
||||
);
|
||||
$result = Db::name('media_file')
|
||||
->alias('a')
|
||||
->field('a.*, b.arc_level_id, b.users_price, b.users_free')
|
||||
->join('__ARCHIVES__ b', 'a.aid = b.aid', 'LEFT')
|
||||
->where($map)
|
||||
->find();
|
||||
|
||||
if (preg_match('#^(/[\w]+)?(/uploads/media/)#i', $result['file_url'])) {
|
||||
$file_url = preg_replace('#^(/[\w]+)?(/uploads/media/)#i', '$2', $result['file_url']);
|
||||
} else {
|
||||
$file_url = preg_replace('#^(' . $this->root_dir . ')?(/)#i', '$2', $result['file_url']);
|
||||
}
|
||||
if (empty($result) || (!is_http_url($result['file_url']) && !file_exists('.' . $file_url))) {
|
||||
$this->error('视频文件不存在!');
|
||||
}
|
||||
|
||||
$UsersData = GetUsersLatestData();
|
||||
$UsersID = !empty($UsersData['users_id']) ? intval($UsersData['users_id']) : 0;
|
||||
|
||||
$upVip = "window.location.href = '" . url('user/Level/level_centre') . "'";
|
||||
$data['onclick'] = "if (document.getElementById('ey_login_id_1609665117')) {\$('#ey_login_id_1609665117').trigger('click');}else{window.location.href = '" . url('user/Users/login') . "';}";
|
||||
$data['button'] = '点击登录!';
|
||||
$data['users_id'] = $UsersID;
|
||||
// 未登录则提示
|
||||
if (empty($UsersID)) $this->error('请先登录!', url('user/Users/login'), $data);
|
||||
|
||||
if (empty($result['gratis'])) {
|
||||
$arc_level_id = !empty($result['arc_level_id']) ? intval($result['arc_level_id']) : 0;
|
||||
/*是否需要付费*/
|
||||
if (0 < $result['users_price'] && empty($result['users_free'])) {
|
||||
$Paid = 0; // 未付费
|
||||
$where = [
|
||||
'users_id' => $UsersID,
|
||||
'product_id' => $result['aid'],
|
||||
'order_status' => 1
|
||||
];
|
||||
// 存在数据则已付费
|
||||
$Paid = Db::name('media_order')->where($where)->count();
|
||||
// 未付费则执行
|
||||
if (empty($Paid)) {
|
||||
if (0 < $arc_level_id && $UsersData['level'] < $arc_level_id) {
|
||||
$data['onclick'] = $upVip;
|
||||
$data['button'] = '升级会员';
|
||||
$level_name = Db::name('users_level')->where(['level_id'=>$arc_level_id])->value('level_name');
|
||||
$this->error('未付费,需要【' . $level_name . '】付费才能播放', '', $data);
|
||||
} else {
|
||||
$data['onclick'] = 'MediaOrderBuy_1592878548();';
|
||||
$data['button'] = '立即购买';
|
||||
$this->error('未付费,视频需要付费才能播放', '', $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//会员
|
||||
if (0 < $arc_level_id && $UsersData['level'] < $arc_level_id) {
|
||||
$where = [
|
||||
'level_id' => $arc_level_id,
|
||||
'lang' => $this->home_lang
|
||||
];
|
||||
$arcLevel = Db::name('users_level')->where($where)->Field('level_value,level_name')->find();
|
||||
$data['onclick'] = $upVip;
|
||||
$data['button'] = '升级会员';
|
||||
$this->error('未付费,请升级会员至【' . $arcLevel['level_name'] . '】观看视频', '', $data);
|
||||
}
|
||||
}
|
||||
|
||||
// 外部视频链接
|
||||
if (is_http_url($result['file_url'])) {
|
||||
|
||||
// 记录播放次数
|
||||
$this->video_log($result['file_id'], $result['aid']);
|
||||
|
||||
if (IS_AJAX) {
|
||||
$this->success('准备播放中……', $result['file_url']);
|
||||
} else {
|
||||
$this->redirect($result['file_url']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
// 本站链接
|
||||
else
|
||||
{
|
||||
if (md5_file('.' . $file_url) != $result['md5file']) {
|
||||
$this->error('视频文件已损坏!');
|
||||
}
|
||||
|
||||
// 记录播放次数
|
||||
$this->video_log($result['file_id'], $result['aid']);
|
||||
|
||||
$url = $this->request->domain() . $this->root_dir . $file_url;
|
||||
if (IS_AJAX) {
|
||||
$this->success('准备播放中……', $url);
|
||||
} else {
|
||||
$this->redirect($url);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录播放次数(重复播放不做记录,游客可重复记录)
|
||||
*/
|
||||
private function video_log($file_id = 0, $aid = 0)
|
||||
{
|
||||
try {
|
||||
$users_id = session('users_id');
|
||||
$users_id = intval($users_id);
|
||||
|
||||
$counts = Db::name('media_log')->where([
|
||||
'file_id' => $file_id,
|
||||
'aid' => $aid,
|
||||
'users_id' => $users_id,
|
||||
])->count();
|
||||
if (empty($users_id) || empty($counts)) {
|
||||
$saveData = [
|
||||
'users_id' => $users_id,
|
||||
'aid' => $aid,
|
||||
'file_id' => $file_id,
|
||||
'ip' => clientIP(),
|
||||
'add_time' => getTime(),
|
||||
];
|
||||
$r = Db::name('media_log')->insertGetId($saveData);
|
||||
if ($r !== false) {
|
||||
Db::name('media_file')->where(['file_id' => $file_id])->setInc('playcount');
|
||||
Db::name('archives')->where(['aid' => $aid])->setInc('downcount');
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* 内容播放页【易而优视频模板专用】
|
||||
*/
|
||||
public function play($aid = '', $fid = '')
|
||||
{
|
||||
$aid = intval($aid);
|
||||
$fid = intval($fid);
|
||||
|
||||
$res = Db::name('archives')
|
||||
->alias('a')
|
||||
->field('a.*,b.*,c.typename,c.dirname')
|
||||
->join('media_content b', 'a.aid=b.aid')
|
||||
->join('arctype c', 'a.typeid=c.id')
|
||||
->where('a.aid', $aid)
|
||||
->find();
|
||||
if(!empty($res['courseware'])){
|
||||
$res['courseware'] = get_default_pic($res['courseware'],true);
|
||||
}
|
||||
|
||||
// 播放权限验证
|
||||
$redata = $this->check_auth($aid, $fid, $res, 1);
|
||||
if (!isset($redata['status']) || $redata['status'] != 2) {
|
||||
$url = null;
|
||||
if (!empty($redata['url'])) {
|
||||
$url = $redata['url'];
|
||||
}
|
||||
$this->error($redata['msg'], $url);
|
||||
}
|
||||
|
||||
Db::name('media_file')->where(['file_id' => $fid])->setInc('playcount');
|
||||
$res['seo_title'] = set_arcseotitle($res['title'], $res['seo_title'], $res['typename'], $res['typeid']);
|
||||
$res['seo_description'] = @msubstr(checkStrHtml($res['seo_description']), 0, config('global.arc_seo_description_length'), false);
|
||||
$eyou['field'] = $res;
|
||||
$eyou['field']['fid'] = $fid;
|
||||
$this->eyou = array_merge($this->eyou, $eyou);
|
||||
$this->assign('eyou', $this->eyou);
|
||||
|
||||
return $this->fetch(":view_media_play");
|
||||
}
|
||||
|
||||
/**
|
||||
* 播放权限验证【易而优视频模板专用】
|
||||
*/
|
||||
public function check_auth($aid = '', $fid = '', $res = [], $_ajax = 0)
|
||||
{
|
||||
if (IS_AJAX || $_ajax == 1){
|
||||
$is_mobile = isMobile() ? 1 : 0;
|
||||
if (empty($res)) {
|
||||
$res = Db::name('archives')
|
||||
->alias('a')
|
||||
->join('media_content b', 'a.aid=b.aid')
|
||||
->where('a.aid', $aid)
|
||||
->field('a.title,b.courseware,a.arc_level_id,a.users_price,a.users_free')
|
||||
->find();
|
||||
}
|
||||
if ((0 < $res['users_price'] && empty($res['users_free'])) || 0 < $res['arc_level_id']) {
|
||||
$UsersData = GetUsersLatestData();
|
||||
$UsersID = !empty($UsersData['users_id']) ? intval($UsersData['users_id']) : 0;
|
||||
if (empty($UsersID)) return ['status'=>1,'msg'=>'请先登录','url'=>url('user/Users/login','', true, false, 1, 1),'is_mobile'=>$is_mobile];
|
||||
|
||||
$gratis = Db::name('media_file')->where(['file_id' => $fid])->value('gratis');
|
||||
if ($gratis == 0) {
|
||||
$arc_level_id = !empty($res['arc_level_id']) ? intval($res['arc_level_id']) : 0;
|
||||
/*是否需要付费*/
|
||||
if (0 < $res['users_price'] && empty($res['users_free'])) {
|
||||
$Paid = 0; // 未付费
|
||||
if (!empty($UsersID)) {
|
||||
$where = [
|
||||
'users_id' => $UsersID,
|
||||
'product_id' => $aid,
|
||||
'order_status' => 1
|
||||
];
|
||||
// 存在数据则已付费
|
||||
$Paid = Db::name('media_order')->where($where)->count();
|
||||
}
|
||||
|
||||
// 未付费则执行
|
||||
if (empty($Paid)) {
|
||||
if (0 < $arc_level_id && $UsersData['level'] < $arc_level_id) {
|
||||
$where = [
|
||||
'level_id' => $arc_level_id,
|
||||
'lang' => $this->home_lang
|
||||
];
|
||||
$arcLevel = DB::name('users_level')->where($where)->Field('level_value,level_name')->find();
|
||||
return ['status'=>0,'msg'=>'尊敬的用户,该视频需要【' . $arcLevel['level_name'] . '】付费后才可观看全部内容!','price'=>$res['users_price'],'is_mobile'=>$is_mobile];
|
||||
} else {
|
||||
return ['status'=>0,'msg'=>'尊敬的用户,该视频需要付费后才可观看全部内容!','price'=>$res['users_price'],'is_mobile'=>$is_mobile];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 会员
|
||||
if (0 < $arc_level_id && $UsersData['level'] < $arc_level_id) {
|
||||
$where = [
|
||||
'level_id' => $arc_level_id,
|
||||
'lang' => $this->home_lang
|
||||
];
|
||||
$arcLevel = DB::name('users_level')->where($where)->Field('level_value,level_name')->find();
|
||||
return ['status'=>0,'url'=>url('user/Level/level_centre','', true, false, 1, 1),'msg'=>'尊敬的用户,该视频需要【' . $arcLevel['level_name'] . '】才可观看!','is_mobile'=>$is_mobile];
|
||||
}
|
||||
}
|
||||
}
|
||||
return ['status'=>2,'msg'=>'success!','is_mobile'=>$is_mobile];
|
||||
}
|
||||
}
|
||||
}
|
||||
55
src/application/home/html.php
Normal file
55
src/application/home/html.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
|
||||
$html_cache_arr = array();
|
||||
// 全局变量数组
|
||||
$global = config('tpcache');
|
||||
empty($global) && $global = tpCache('global');
|
||||
// 系统模式
|
||||
$web_cmsmode = isset($global['web_cmsmode']) ? $global['web_cmsmode'] : 2;
|
||||
/*页面缓存有效期*/
|
||||
$app_debug = true;
|
||||
$uiset = input('param.uiset/s', 'off');
|
||||
if (1 == $web_cmsmode && 'on' != $uiset) { // 运营模式
|
||||
$app_debug = false;
|
||||
$html_cache_arr = config('HTML_CACHE_ARR');
|
||||
}
|
||||
/*--end*/
|
||||
|
||||
return array(
|
||||
// 应用调试模式
|
||||
'app_debug' => $app_debug,
|
||||
// 模板设置
|
||||
'template' => array(
|
||||
// 模板路径
|
||||
'view_path' => './template/',
|
||||
// 模板后缀
|
||||
'view_suffix' => 'htm',
|
||||
// 模板引擎禁用函数
|
||||
'tpl_deny_func_list' => 'eval,echo,exit',
|
||||
// 默认模板引擎是否禁用PHP原生代码 苦恼啊! 鉴于百度统计使用原生php,这里暂时无法开启
|
||||
'tpl_deny_php' => false,
|
||||
),
|
||||
// 视图输出字符串内容替换
|
||||
'view_replace_str' => array(
|
||||
'__EVAL__' => '', // 过滤模板里的eval函数,防止被注入
|
||||
),
|
||||
|
||||
/**假设这个访问地址是 www.xxxxx.dev/home/goods/goodsInfo/id/1.html
|
||||
*就保存名字为 index_goods_goodsinfo_1.html
|
||||
*配置成这样, 指定 模块 控制器 方法名 参数名
|
||||
*/
|
||||
'HTML_CACHE_ARR'=> $html_cache_arr,
|
||||
);
|
||||
?>
|
||||
339
src/application/home/logic/AskLogic.php
Normal file
339
src/application/home/logic/AskLogic.php
Normal file
@@ -0,0 +1,339 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 陈风任 <491085389@qq.com>
|
||||
* Date: 2019-7-30
|
||||
*/
|
||||
|
||||
namespace app\home\logic;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
use app\home\model\Ask;
|
||||
|
||||
/**
|
||||
* 逻辑定义
|
||||
* Class CatsLogic
|
||||
* @package plugins\Logic
|
||||
*/
|
||||
class AskLogic extends Model
|
||||
{
|
||||
/**
|
||||
* 初始化操作
|
||||
*/
|
||||
public function _initialize() {
|
||||
parent::_initialize();
|
||||
}
|
||||
|
||||
// 查询条件处理
|
||||
public function GetAskWhere($param = array(), $parent_id = null)
|
||||
{
|
||||
// 查询条件
|
||||
$where = [
|
||||
// 0未解决,1已解决
|
||||
'a.status' => ['IN',[0, 1]],
|
||||
// 问题是否审核,1是,0否
|
||||
'a.is_review' => 1,
|
||||
'a.is_del' => 0,
|
||||
'SearchName' => null,
|
||||
];
|
||||
|
||||
// 创始人可以看到所有数据,包括未审核问题
|
||||
if (0 === $parent_id) unset($where['a.is_review']);
|
||||
|
||||
// 查询指定栏目分类下的问题
|
||||
if (!empty($param['type_id'])) $where['a.type_id'] = $param['type_id'];
|
||||
|
||||
// 不为空则表示查询--悬赏--待回答问题
|
||||
if (!empty($param['is_recom']) && 3 == intval($param['is_recom'])) $where['a.money'] = ['>',0];
|
||||
|
||||
// 不为空则表示查询待回答问题
|
||||
if (!empty($param['is_recom']) && 2 == intval($param['is_recom'])) $where['a.replies'] = 0;
|
||||
|
||||
// 推荐问题
|
||||
if (!empty($param['is_recom']) && 1 == intval($param['is_recom'])) $where['a.is_recom'] = 1;
|
||||
|
||||
// 搜索问题
|
||||
if (!empty($param['search_name'])) {
|
||||
$where['a.ask_title'] = ['LIKE', "%{$param['search_name']}%"];
|
||||
$where['SearchName'] = $param['search_name'];
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
// Url处理
|
||||
public function GetUrlData($param = array(), $SpecifyUrl = null)
|
||||
{
|
||||
if (empty($param['ask_id'])) $param['ask_id'] = 0;
|
||||
$result = [];
|
||||
// 最新问题url
|
||||
$result['NewDateUrl'] = askurl('home/Ask/index');
|
||||
|
||||
// 问题详情页url
|
||||
$result['AskDetailsUrl'] = askurl('home/Ask/details', ['ask_id'=>$param['ask_id']]);
|
||||
|
||||
// 推荐问题url
|
||||
$result['RecomDateUrl'] = askurl('home/Ask/index', ['type_id'=>0, 'is_recom'=>1]);
|
||||
|
||||
// 等待回答url
|
||||
$result['PendingAnswerUrl'] = askurl('home/Ask/index', ['type_id'=>0, 'is_recom'=>2]);
|
||||
|
||||
// 悬赏问题列表url
|
||||
$result['RewardUrl'] = askurl('home/Ask/index', ['type_id'=>0, 'is_recom'=>3]);
|
||||
|
||||
// 提交回答url
|
||||
$result['AddAnswerUrl'] = askurl('home/Ask/ajax_add_answer', ['ask_id'=>$param['ask_id'], '_ajax'=>1], true, false, 1, 1, 0);
|
||||
|
||||
// 删除回答url
|
||||
$result['DelAnswerUrl'] = askurl('home/Ask/ajax_del_answer', ['ask_id'=>$param['ask_id'], '_ajax'=>1], true, false, 1, 1, 0);
|
||||
|
||||
// 点赞回答url
|
||||
$result['ClickLikeUrl'] = askurl('home/Ask/ajax_click_like', ['_ajax'=>1], true, false, 1, 1, 0);
|
||||
|
||||
// 发布问题url
|
||||
$result['AddAskUrl'] = askurl('home/Ask/add_ask');
|
||||
// 提交问题url
|
||||
$result['SubmitAddAsk'] = askurl('home/Ask/add_ask', ['_ajax'=>1], true, false, 1, 1, 0);
|
||||
|
||||
// 编辑问题url
|
||||
$result['EditAskUrl'] = askurl('home/Ask/edit_ask', ['ask_id'=>$param['ask_id']]);
|
||||
|
||||
// 用户问题首页
|
||||
$result['UsersIndexUrl'] = askurl('home/Ask/ask_index');
|
||||
|
||||
// 编辑回答url
|
||||
$result['EditAnswer'] = askurl('home/Ask/ajax_edit_answer');
|
||||
if ('ajax_edit_answer' == request()->action()) {
|
||||
$result['EditAnswer'] = askurl('home/Ask/ajax_edit_answer', ['_ajax'=>1], true, false, 1, 1, 0);
|
||||
}
|
||||
|
||||
// 采纳最佳答案url
|
||||
$result['BestAnswerUrl'] = askurl('home/Ask/ajax_best_answer', ['ask_id'=>$param['ask_id'], '_ajax'=>1], true, false, 1, 1, 0);
|
||||
|
||||
// 获取指定数量的评论数据(分页)
|
||||
$result['ShowCommentUrl'] = askurl('home/Ask/ajax_show_comment', ['ask_id'=>$param['ask_id'], '_ajax'=>1], true, false, 1, 1, 0);
|
||||
|
||||
// 创始人审核评论URL(前台)
|
||||
$result['ReviewCommentUrl'] = askurl('home/Ask/ajax_review_comment', ['ask_id'=>$param['ask_id'], '_ajax'=>1], true, false, 1, 1, 0);
|
||||
|
||||
// 创始人审核问题URL(前台)
|
||||
$result['ReviewAskUrl'] = askurl('home/Ask/ajax_review_ask', ['_ajax'=>1], true, false, 1, 1, 0);
|
||||
|
||||
// 按点赞量排序url
|
||||
$result['AnswerLikeNum'] = askurl('home/Ask/details', ['ask_id' => $param['ask_id']], true, false, 1, 1, 0);
|
||||
|
||||
// 等待回答url
|
||||
if (!empty($param['type_id'])) {
|
||||
$result['PendingAnswerUrl'] = askurl('home/Ask/index', ['type_id'=>$param['type_id'], 'is_recom'=>2]);
|
||||
}
|
||||
|
||||
if (!empty($SpecifyUrl)) {
|
||||
if (!empty($result[$SpecifyUrl])) {
|
||||
return $result[$SpecifyUrl];
|
||||
}else{
|
||||
return $result['NewDateUrl'];
|
||||
}
|
||||
}else{
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 关键词标红
|
||||
public function GetRedKeyWord($SearchName, $ask_title)
|
||||
{
|
||||
$ks = explode(' ',$SearchName);
|
||||
foreach($ks as $k){
|
||||
$k = trim($k);
|
||||
if($k == '') continue;
|
||||
if(ord($k[0]) > 0x80 && strlen($k) < 1) continue;
|
||||
$ask_title = str_replace($k, "<font color='red'>$k</font>", $ask_title);
|
||||
}
|
||||
return $ask_title;
|
||||
}
|
||||
|
||||
// 内容转义处理
|
||||
public function ContentDealWith($param = null)
|
||||
{
|
||||
if (!empty($param['content'])) {
|
||||
$content = $param['content'];
|
||||
}else if(!empty($param['ask_content'])){
|
||||
$content = $param['ask_content'];
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
// 斜杆转义
|
||||
$content = addslashes($content);
|
||||
// 过滤内容的style属性
|
||||
$content = preg_replace('/style(\s*)=(\s*)[\'|\"](.*?)[\'|\"]/i', '', $content);
|
||||
// 过滤内容的class属性
|
||||
$content = preg_replace('/class(\s*)=(\s*)[\'|\"](.*?)[\'|\"]/i', '', $content);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
// 栏目分类格式化输出
|
||||
public function GetTypeHtmlCode($PidData = array(), $TidData = array(), $type_id = null)
|
||||
{
|
||||
// 下拉框拼装
|
||||
$HtmlCode = '<select name="ask_type_id" id="ask_type_id" class="input_reward">';
|
||||
$HtmlCode .= '<option value="0">请选择分类</option>';
|
||||
foreach ($PidData as $P_key => $PidValue) {
|
||||
/*是否默认选中*/
|
||||
$selected = '';
|
||||
if ($type_id == $PidValue['type_id']) $selected = 'selected';
|
||||
/* END */
|
||||
|
||||
/*一级下拉框*/
|
||||
$HtmlCode .= '<option value="'.$PidValue['type_id'].'" '.$selected.'>'.$PidValue['type_name'].'</option>';
|
||||
/* END */
|
||||
|
||||
foreach ($TidData as $T_key => $TidValue) {
|
||||
if ($TidValue['parent_id'] == $PidValue['type_id']) {
|
||||
/*是否默认选中*/
|
||||
$selected = '';
|
||||
if ($type_id == $TidValue['type_id']) $selected = 'selected';
|
||||
/* END */
|
||||
|
||||
/*二级下拉框*/
|
||||
$HtmlCode .= '<option value="'.$TidValue['type_id'].'" '.$selected.'> '.$TidValue['type_name'].'</option>';
|
||||
/* END */
|
||||
}
|
||||
}
|
||||
}
|
||||
$HtmlCode .= '</select>';
|
||||
return $HtmlCode;
|
||||
}
|
||||
|
||||
// 拼装html代码
|
||||
public function GetReplyHtml($data = array())
|
||||
{
|
||||
$ReplyHtml = '';
|
||||
// 如果是需要审核的评论则返回空
|
||||
if (empty($data['is_review'])) return $ReplyHtml;
|
||||
|
||||
/*拼装html代码*/
|
||||
// 友好显示时间
|
||||
$data['add_time'] = friend_date($data['add_time']);
|
||||
// 处理内容格式
|
||||
$data['content'] = htmlspecialchars_decode($data['content']);
|
||||
if (!empty($data['at_users_id'])) {
|
||||
$data['content'] = '回复 @'.$data['at_usersname'].': '.$data['content'];
|
||||
}
|
||||
// 删除评论回答URL
|
||||
$DelAnswerUrl = $this->GetUrlData($data, 'DelAnswerUrl');
|
||||
|
||||
// 拼装html
|
||||
$ReplyHtml = <<<EOF
|
||||
<li class="secend-li" id="{$data['answer_id']}_answer_li">
|
||||
<div class="head-secend">
|
||||
<a><img src="{$data['head_pic']}" style="width:30px;height:30px;border-radius:100%;margin-right: 16px;"></a>
|
||||
<strong>{$data['username']}</strong>
|
||||
<span style="margin:0 10px"> | </span>
|
||||
<span>{$data['add_time']}</span>
|
||||
<div style="flex-grow:1"></div>
|
||||
<span id="{$data['answer_id']}_replyA" onclick="replyUser('{$data['answer_pid']}','{$data['users_id']}','{$data['username']}','{$data['answer_id']}')" class="secend-huifu-btn" style="cursor: pointer;">回复</span>
|
||||
|
|
||||
<a data-url="{$DelAnswerUrl}" onclick="DataDel(this, '{$data['answer_id']}', 2)" class="secend-huifu-btn" style="cursor: pointer; color:red;">删除</a>
|
||||
</div>
|
||||
<div class="secend-huifu-text">
|
||||
{$data['content']}
|
||||
</div>
|
||||
</li>
|
||||
EOF;
|
||||
// 返回html
|
||||
$ReturnHtml = ['review' => false, 'htmlcode' => $ReplyHtml];
|
||||
return $ReturnHtml;
|
||||
}
|
||||
|
||||
// 获取指定条数的评论(分页)
|
||||
public function ForeachReplyHtml($data = array(), $parent_id = null)
|
||||
{
|
||||
$ReplyHtml = '';
|
||||
foreach ($data as $key => $value) {
|
||||
// 如果是需要审核的评论则返回空
|
||||
$review = '';
|
||||
if (empty($value['is_review']) && 0 == $parent_id) {
|
||||
// 创始人审核评论URL(前台)
|
||||
$ReviewCommentUrl = $this->GetUrlData($value, 'ReviewCommentUrl');
|
||||
$review = <<<EOF
|
||||
<span id='{$value['answer_id']}_Review'>
|
||||
<span data-url='{$ReviewCommentUrl}' onclick="Review(this, '{$value['answer_id']}')" class="secend-huifu-btn" style="cursor: pointer; color: red;" title="该评论未审核,可点击审核,仅创始人可操作">审核</span>
|
||||
<span style="margin:0 10px"> | </span>
|
||||
</span>
|
||||
EOF;
|
||||
} else if (empty($value['is_review'])) {
|
||||
// 其他人查询数据,去除未审核评论,跳过这条数据拼装
|
||||
unset($value); continue;
|
||||
}
|
||||
|
||||
/*拼装html代码*/
|
||||
if (!empty($value['at_users_id'])) {
|
||||
$value['content'] = '回复 @'.$value['at_usersname'].': '.$value['content'];
|
||||
}
|
||||
|
||||
// 删除评论回答URL
|
||||
$DelAnswerUrl = $this->GetUrlData($value, 'DelAnswerUrl');
|
||||
// 拼装html
|
||||
$ReplyHtml .= <<<EOF
|
||||
<li class="secend-li" id="{$value['answer_id']}_answer_li">
|
||||
<div class="head-secend">
|
||||
<a><img src="{$value['head_pic']}" style="width:30px;height:30px;border-radius:100%;margin-right: 16px;"></a>
|
||||
<strong>{$value['username']}</strong>
|
||||
<span style="margin:0 10px"> | </span>
|
||||
<span>{$value['add_time']}</span>
|
||||
<div style="flex-grow:1"></div>
|
||||
{$review}
|
||||
<span id="{$value['answer_id']}_replyA" onclick="replyUser('{$value['answer_pid']}','{$value['users_id']}','{$value['username']}','{$value['answer_id']}')" class="secend-huifu-btn" style="cursor: pointer;">回复</span>
|
||||
|
|
||||
<a data-url="{$DelAnswerUrl}" onclick="DataDel(this, '{$value['answer_id']}', 2)" class="secend-huifu-btn" style="cursor: pointer; color:red;">删除</a>
|
||||
</div>
|
||||
<div class="secend-huifu-text">
|
||||
{$value['content']}
|
||||
</div>
|
||||
</li>
|
||||
EOF;
|
||||
}
|
||||
|
||||
// 返回html
|
||||
$ReturnHtml = ['review' => false, 'htmlcode' => $ReplyHtml];
|
||||
return $ReturnHtml;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取SEO信息
|
||||
* @param string $inc_type [description]
|
||||
*/
|
||||
public function GetSeoData($type_id = 0)
|
||||
{
|
||||
$inc_type = !empty($type_id) ? 'lists' : 'index';
|
||||
|
||||
$seoInfo = [
|
||||
'seo_title' => '问答中心',
|
||||
'seo_keywords' => '',
|
||||
'seo_description' => '',
|
||||
];
|
||||
|
||||
$arctypeInfo = Db::name('arctype')->field('typename,seo_title,seo_keywords,seo_description')->where(['current_channel'=>51, 'lang'=>get_home_lang()])->order('id desc')->find();
|
||||
if ('index' == $inc_type) {
|
||||
$seoInfo['seo_title'] = !empty($arctypeInfo['seo_title']) ? $arctypeInfo['seo_title'] : $arctypeInfo['typename'];
|
||||
$seoInfo['seo_keywords'] = !empty($arctypeInfo['seo_keywords']) ? $arctypeInfo['seo_keywords'] : '';
|
||||
$seoInfo['seo_description'] = !empty($arctypeInfo['seo_description']) ? $arctypeInfo['seo_description'] : '';
|
||||
} else if ('lists' == $inc_type) {
|
||||
$result = Db::name('ask_type')->field('*')->where(['type_id'=>$type_id])->find();
|
||||
$seoInfo['seo_title'] = !empty($result['seo_title']) ? $result['seo_title'] : $result['type_name'] . ' - ' . $arctypeInfo['typename'];
|
||||
$seoInfo['seo_keywords'] = !empty($result['seo_keywords']) ? $result['seo_keywords'] : '';
|
||||
$seoInfo['seo_description'] = !empty($result['seo_description']) ? $result['seo_description'] : '';
|
||||
}
|
||||
|
||||
return $seoInfo;
|
||||
}
|
||||
}
|
||||
228
src/application/home/logic/FieldLogic.php
Normal file
228
src/application/home/logic/FieldLogic.php
Normal file
@@ -0,0 +1,228 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\logic;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
/**
|
||||
* 字段逻辑定义
|
||||
* Class CatsLogic
|
||||
* @package home\Logic
|
||||
*/
|
||||
class FieldLogic extends Model
|
||||
{
|
||||
/**
|
||||
* 查询解析模型数据用以页面展示
|
||||
* @param array $data 表数据
|
||||
* @param intval $channel_id 模型ID
|
||||
* @param array $batch 是否批量列表
|
||||
* @author 小虎哥 by 2018-7-25
|
||||
*/
|
||||
public function getChannelFieldList($data, $channel_id = '', $batch = false)
|
||||
{
|
||||
if (!empty($data) && !empty($channel_id)) {
|
||||
/*获取模型对应的附加表字段信息*/
|
||||
$map = array(
|
||||
'channel_id' => $channel_id,
|
||||
);
|
||||
$fieldInfo = model('Channelfield')->getListByWhere($map, '*', 'name');
|
||||
/*--end*/
|
||||
$data = $this->handleAddonFieldList($data, $fieldInfo, $batch);
|
||||
} else {
|
||||
$data = array();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询解析单个数据表的数据用以页面展示
|
||||
* @param array $data 表数据
|
||||
* @param intval $channel_id 模型ID
|
||||
* @param array $batch 是否批量列表
|
||||
* @author 小虎哥 by 2018-7-25
|
||||
*/
|
||||
public function getTableFieldList($data, $channel_id = '', $batch = false)
|
||||
{
|
||||
if (!empty($data) && !empty($channel_id)) {
|
||||
/*获取自定义表字段信息*/
|
||||
$map = array(
|
||||
'channel_id' => $channel_id,
|
||||
);
|
||||
$fieldInfo = model('Channelfield')->getListByWhere($map, '*', 'name');
|
||||
/*--end*/
|
||||
$data = $this->handleAddonFieldList($data, $fieldInfo, $batch);
|
||||
} else {
|
||||
$data = array();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理自定义字段的值
|
||||
* @param array $data 表数据
|
||||
* @param array $fieldInfo 自定义字段集合
|
||||
* @param array $batch 是否批量列表
|
||||
* @author 小虎哥 by 2018-7-25
|
||||
*/
|
||||
public function handleAddonFieldList($data, $fieldInfo, $batch = false)
|
||||
{
|
||||
if (false !== $batch) {
|
||||
return $this->handleBatchAddonFieldList($data, $fieldInfo);
|
||||
}
|
||||
|
||||
if (!empty($data) && !empty($fieldInfo)) {
|
||||
foreach ($data as $key => $val) {
|
||||
$dtype = !empty($fieldInfo[$key]) ? $fieldInfo[$key]['dtype'] : '';
|
||||
$dfvalue_unit = !empty($fieldInfo[$key]) ? $fieldInfo[$key]['dfvalue_unit'] : '';
|
||||
switch ($dtype) {
|
||||
case 'int':
|
||||
case 'float':
|
||||
case 'decimal':
|
||||
case 'text':
|
||||
{
|
||||
$data[$key.'_unit'] = $dfvalue_unit;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'imgs':
|
||||
{
|
||||
if (!is_array($val)) {
|
||||
$eyou_imgupload_list = @unserialize($val);
|
||||
if (false === $eyou_imgupload_list) {
|
||||
$eyou_imgupload_list = [];
|
||||
$eyou_imgupload_data = explode(',', $val);
|
||||
foreach ($eyou_imgupload_data as $k1 => $v1) {
|
||||
$eyou_imgupload_list[$k1] = [
|
||||
'image_url' => handle_subdir_pic($v1),
|
||||
'intro' => '',
|
||||
];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$eyou_imgupload_list = [];
|
||||
$eyou_imgupload_data = $val;
|
||||
foreach ($eyou_imgupload_data as $k1 => $v1) {
|
||||
$v1['image_url'] = handle_subdir_pic($v1['image_url']);
|
||||
isset($v1['intro']) && $v1['intro'] = htmlspecialchars_decode($v1['intro']);
|
||||
$eyou_imgupload_list[$k1] = $v1;
|
||||
}
|
||||
}
|
||||
$val = $eyou_imgupload_list;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'checkbox':
|
||||
case 'files':
|
||||
{
|
||||
if (!is_array($val)) {
|
||||
$val = !empty($val) ? explode(',', $val) : array();
|
||||
}
|
||||
/*支持子目录*/
|
||||
foreach ($val as $k1 => $v1) {
|
||||
$val[$k1] = handle_subdir_pic($v1);
|
||||
}
|
||||
/*--end*/
|
||||
break;
|
||||
}
|
||||
|
||||
case 'htmltext':
|
||||
{
|
||||
$val = htmlspecialchars_decode($val);
|
||||
|
||||
/*追加指定内嵌样式到编辑器内容的img标签,兼容图片自动适应页面*/
|
||||
$titleNew = !empty($data['title']) ? $data['title'] : '';
|
||||
$val = img_style_wh($val, $titleNew);
|
||||
/*--end*/
|
||||
|
||||
/*支持子目录*/
|
||||
$val = handle_subdir_pic($val, 'html');
|
||||
/*--end*/
|
||||
break;
|
||||
}
|
||||
|
||||
case 'decimal':
|
||||
{
|
||||
$val = number_format($val,'2','.',',');
|
||||
break;
|
||||
}
|
||||
|
||||
case 'region':
|
||||
{
|
||||
// 先在默认值里寻找是否存在对应区域ID的名称
|
||||
$dfvalue = !empty($fieldInfo[$key]['dfvalue']) ? $fieldInfo[$key]['dfvalue'] : '';
|
||||
if (!empty($dfvalue)) {
|
||||
$dfvalue_tmp = unserialize($dfvalue);
|
||||
$region_ids = !empty($dfvalue_tmp['region_ids']) ? explode(',', $dfvalue_tmp['region_ids']) : [];
|
||||
if (!empty($region_ids)) {
|
||||
$arr_index = array_search($val, $region_ids);
|
||||
if (false !== $arr_index && 0 <= $arr_index) {
|
||||
$dfvalue_tmp['region_names'] = str_replace(',', ',', $dfvalue_tmp['region_names']);
|
||||
$region_names = explode(',', $dfvalue_tmp['region_names']);
|
||||
$val = $region_names[$arr_index];
|
||||
}
|
||||
}
|
||||
}
|
||||
// 默认值里不存在,则去区域表里获取
|
||||
if (!empty($val) && is_numeric($val)) {
|
||||
$city_list = get_city_list();
|
||||
if (!empty($city_list[$val])) {
|
||||
$val = $city_list[$val]['name'];
|
||||
} else {
|
||||
$province_list = get_province_list();
|
||||
if (!empty($province_list[$val])) {
|
||||
$val = $province_list[$val]['name'];
|
||||
} else {
|
||||
$area_list = get_area_list();
|
||||
$val = !empty($area_list[$val]) ? $area_list[$val]['name'] : '';
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
/*支持子目录*/
|
||||
if (is_string($val)) {
|
||||
$val = handle_subdir_pic($val, 'html');
|
||||
$val = handle_subdir_pic($val);
|
||||
}
|
||||
/*--end*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
$data[$key] = $val;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表批量处理自定义字段的值
|
||||
* @param array $data 表数据
|
||||
* @param array $fieldInfo 自定义字段集合
|
||||
* @author 小虎哥 by 2018-7-25
|
||||
*/
|
||||
public function handleBatchAddonFieldList($data, $fieldInfo)
|
||||
{
|
||||
if (!empty($data) && !empty($fieldInfo)) {
|
||||
foreach ($data as $key => $subdata) {
|
||||
$data[$key] = $this->handleAddonFieldList($subdata, $fieldInfo);
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
183
src/application/home/model/Archives.php
Normal file
183
src/application/home/model/Archives.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Page;
|
||||
use think\Db;
|
||||
use app\home\logic\FieldLogic;
|
||||
|
||||
/**
|
||||
* 文档主表
|
||||
*/
|
||||
class Archives extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
$this->fieldLogic = new FieldLogic();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条文档记录
|
||||
* @author wengxianhu by 2017-7-26
|
||||
*/
|
||||
public function getViewInfo($aid, $litpic_remote = false, $where = [])
|
||||
{
|
||||
$result = array();
|
||||
$row = Db::name('archives')->field('*')->where($where)->find($aid);
|
||||
if (!empty($row)) {
|
||||
/*封面图*/
|
||||
if (empty($row['litpic'])) {
|
||||
$row['is_litpic'] = 0; // 无封面图
|
||||
} else {
|
||||
$row['is_litpic'] = 1; // 有封面图
|
||||
}
|
||||
$row['litpic'] = get_default_pic($row['litpic'], $litpic_remote); // 默认封面图
|
||||
|
||||
/*文档基本信息*/
|
||||
if (1 == $row['channel']) { // 文章模型
|
||||
$articleModel = new \app\home\model\Article();
|
||||
$extFields = Db::name('article_content')->getTableFields();
|
||||
$extFields = array_flip($extFields);
|
||||
unset($extFields['id']);
|
||||
$rowExt = $articleModel->getInfo($aid);
|
||||
$rowExt = array_diff_key($extFields, $row);
|
||||
} else if (2 == $row['channel']) { // 产品模型
|
||||
/*产品参数*/
|
||||
$productAttrModel = new \app\home\model\ProductAttr();
|
||||
$attr_list = $productAttrModel->getProAttr($aid);
|
||||
$row['attr_list'] = !empty($attr_list[$aid]) ? $attr_list[$aid] : [];
|
||||
// 产品相册
|
||||
$image_list = [];
|
||||
$productImgModel = new \app\home\model\ProductImg();
|
||||
$image_list_tmp = $productImgModel->getProImg($aid);
|
||||
if (!empty($image_list_tmp[$aid])) {
|
||||
foreach ($image_list_tmp[$aid] as $key => $val) {
|
||||
$val['image_url'] = get_default_pic($val['image_url'], $litpic_remote);
|
||||
isset($val['intro']) && $val['intro'] = htmlspecialchars_decode($val['intro']);
|
||||
$image_list[$key] = $val;
|
||||
}
|
||||
}
|
||||
$row['image_list'] = $image_list;
|
||||
|
||||
$productModel = new \app\home\model\Product();
|
||||
$extFields = Db::name('product_content')->getTableFields();
|
||||
$extFields = array_flip($extFields);
|
||||
unset($extFields['id']);
|
||||
$rowExt = $productModel->getInfo($aid);
|
||||
$rowExt = array_diff_key($extFields, $row);
|
||||
} else if (3 == $row['channel']) { // 图集模型
|
||||
// 图集相册
|
||||
$image_list = [];
|
||||
$imagesUploadModel = new \app\home\model\ImagesUpload();
|
||||
$image_list_tmp = $imagesUploadModel->getImgUpload($aid);
|
||||
if (!empty($image_list_tmp[$aid])) {
|
||||
foreach ($image_list_tmp[$aid] as $key => $val) {
|
||||
$val['image_url'] = get_default_pic($val['image_url'], $litpic_remote);
|
||||
isset($val['intro']) && $val['intro'] = htmlspecialchars_decode($val['intro']);
|
||||
$image_list[$key] = $val;
|
||||
}
|
||||
}
|
||||
$row['image_list'] = $image_list;
|
||||
|
||||
$imagesModel = new \app\home\model\Images();
|
||||
$extFields = Db::name('images_content')->getTableFields();
|
||||
$extFields = array_flip($extFields);
|
||||
unset($extFields['id']);
|
||||
$rowExt = $imagesModel->getInfo($aid);
|
||||
$rowExt = array_diff_key($extFields, $row);
|
||||
} else if (4 == $row['channel']) { // 下载模型
|
||||
$downloadModel = new \app\home\model\Download();
|
||||
$extFields = Db::name('download_content')->getTableFields();
|
||||
$extFields = array_flip($extFields);
|
||||
unset($extFields['id']);
|
||||
$rowExt = $downloadModel->getInfo($aid);
|
||||
$rowExt = array_diff_key($extFields, $row);
|
||||
}
|
||||
$rowExt = $this->fieldLogic->getChannelFieldList($rowExt, $row['channel']); // 自定义字段的数据格式处理
|
||||
/*--end*/
|
||||
|
||||
$result = array_merge($rowExt, $row);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单页栏目记录
|
||||
* @author wengxianhu by 2017-7-26
|
||||
*/
|
||||
public function getSingleInfo($typeid, $litpic_remote = false)
|
||||
{
|
||||
$result = array();
|
||||
/*文档基本信息*/
|
||||
$row = $this->readContentFirst($typeid);
|
||||
/*--end*/
|
||||
if (!empty($row)) {
|
||||
/*封面图*/
|
||||
if (empty($row['litpic'])) {
|
||||
$row['is_litpic'] = 0; // 无封面图
|
||||
} else {
|
||||
$row['is_litpic'] = 1; // 有封面图
|
||||
}
|
||||
$row['litpic'] = get_default_pic($row['litpic'], $litpic_remote); // 默认封面图
|
||||
/*--end*/
|
||||
|
||||
$row = $this->fieldLogic->getTableFieldList($row, config('global.arctype_channel_id')); // 自定义字段的数据格式处理
|
||||
/*--end*/
|
||||
$row = $this->fieldLogic->getChannelFieldList($row, $row['channel']); // 自定义字段的数据格式处理
|
||||
|
||||
$result = $row;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取指定栏目ID下有内容的栏目信息,只读取每一级的第一个栏目
|
||||
* @param intval $typeid 栏目ID
|
||||
* @return array
|
||||
*/
|
||||
public function readContentFirst($typeid)
|
||||
{
|
||||
$result = false;
|
||||
while (true)
|
||||
{
|
||||
$singleModel = new \app\home\model\Single();
|
||||
$result = $singleModel->getInfoByTypeid($typeid);
|
||||
if (empty($result['content']) && preg_match('/^lists_single(_(.*))?\.htm$/i', $result['templist'])) {
|
||||
$map = array(
|
||||
'parent_id' => $result['typeid'],
|
||||
'current_channel' => 6,
|
||||
'is_hidden' => 0,
|
||||
'status' => 1,
|
||||
'is_del' => 0,
|
||||
);
|
||||
$row = \think\Db::name('arctype')->where($map)->field('*')->order('sort_order asc')->find(); // 查找下一级的单页模型栏目
|
||||
if (empty($row)) { // 不存在并返回当前栏目信息
|
||||
break;
|
||||
} elseif (6 == $row['current_channel']) { // 存在且是单页模型,则进行继续往下查找,直到有内容为止
|
||||
$typeid = $row['id'];
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
75
src/application/home/model/Article.php
Normal file
75
src/application/home/model/Article.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Page;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 文章
|
||||
*/
|
||||
class Article extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条记录
|
||||
* @author wengxianhu by 2017-7-26
|
||||
*/
|
||||
public function getInfo($aid, $field = '', $isshowbody = true)
|
||||
{
|
||||
$data = array();
|
||||
if (!empty($field)) {
|
||||
$field_arr = explode(',', $field);
|
||||
foreach ($field_arr as $key => $val) {
|
||||
$val = trim($val);
|
||||
if (preg_match('/^([a-z]+)\./i', $val) == 0) {
|
||||
array_push($data, 'a.'.$val);
|
||||
} else {
|
||||
array_push($data, $val);
|
||||
}
|
||||
}
|
||||
$field = implode(',', $data);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
if ($isshowbody) {
|
||||
$field = !empty($field) ? $field : 'b.*, a.*';
|
||||
$result = Db::name('archives')->field($field)
|
||||
->alias('a')
|
||||
->join('__ARTICLE_CONTENT__ b', 'b.aid = a.aid', 'LEFT')
|
||||
->find($aid);
|
||||
} else {
|
||||
$field = !empty($field) ? $field : 'a.*';
|
||||
$result = Db::name('archives')->field($field)
|
||||
->alias('a')
|
||||
->find($aid);
|
||||
}
|
||||
|
||||
// 文章TAG标签
|
||||
if (!empty($result)) {
|
||||
$typeid = isset($result['typeid']) ? $result['typeid'] : 0;
|
||||
$tags = model('Taglist')->getListByAid($aid, $typeid);
|
||||
$result['tags'] = $tags;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
950
src/application/home/model/Ask.php
Normal file
950
src/application/home/model/Ask.php
Normal file
@@ -0,0 +1,950 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 陈风任 <491085389@qq.com>
|
||||
* Date: 2019-7-30
|
||||
*/
|
||||
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
use think\Page;
|
||||
use think\Config;
|
||||
use app\home\logic\AskLogic;
|
||||
|
||||
/**
|
||||
* 模型
|
||||
*/
|
||||
class Ask extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
|
||||
$this->users_db = Db::name('users'); // 会员表
|
||||
$this->ask_db = Db::name('ask'); // 问题表
|
||||
$this->ask_answer_db = Db::name('ask_answer'); // 答案表
|
||||
$this->ask_type_db = Db::name('ask_type'); // 问题栏目分类表
|
||||
$this->ask_answer_like_db = Db::name('ask_answer_like'); // 问题回答点赞表
|
||||
$this->AskLogic = new AskLogic;
|
||||
}
|
||||
|
||||
// 用户信息及问题回答数据
|
||||
public function GetUsersAskCount($view_uid = null)
|
||||
{
|
||||
// 返回参数
|
||||
$result = [];
|
||||
|
||||
// 查询会员信息
|
||||
$users = session('users');
|
||||
if (!empty($users) && $users['users_id'] == $view_uid) {
|
||||
$result = [
|
||||
'NickName' => $users['nickname'],
|
||||
'HeadPic' => $users['head_pic'],
|
||||
'IsLogin' => 1,
|
||||
];
|
||||
} else {
|
||||
$UsersInfo = $this->users_db->field('nickname,head_pic')->where('users_id', $view_uid)->find();
|
||||
if (!empty($UsersInfo)) {
|
||||
$result = [
|
||||
'NickName' => $UsersInfo['nickname'],
|
||||
'HeadPic' => $UsersInfo['head_pic'],
|
||||
'IsLogin' => 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// 问答数量
|
||||
if (!empty($result['NickName'])) {
|
||||
// 查询问题数量
|
||||
$result['AskCount'] = $this->ask_db->where('users_id', $view_uid)->count();
|
||||
// 查询回答数量
|
||||
$result['AnswerCount'] = $this->ask_answer_db->where('users_id', $view_uid)->count();
|
||||
}
|
||||
|
||||
// 拼装URL
|
||||
$result['UsersAskUrl'] = askurl('home/Ask/ask_index', ['view_uid' => $view_uid]);
|
||||
// ROOT_DIR.'/index.php?m=home&c=Ask&a=ask_index&view_uid='.$view_uid;
|
||||
$result['UsersAnswerUrl'] = askurl('home/Ask/ask_index', ['view_uid' => $view_uid, 'method' => 'answer']);
|
||||
// ROOT_DIR.'/index.php?m=home&c=Ask&a=ask_index&view_uid='.$view_uid.'&method=answer';
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 会员问题回答数据
|
||||
public function GetUsersAskData($view_uid = null, $is_ask = true)
|
||||
{
|
||||
// 返回参数
|
||||
$result = [];
|
||||
$field = 'a.ask_id, a.ask_title, a.click, a.replies, a.add_time, a.is_review, b.users_id, b.nickname';
|
||||
if (!empty($is_ask)) {
|
||||
// 提问问题查询列表
|
||||
$where = [
|
||||
'a.status' => ['IN', [0, 1]],
|
||||
'a.users_id' => $view_uid,
|
||||
];
|
||||
|
||||
/* 分页 */
|
||||
$count = $this->ask_db->alias('a')->where($where)->count('ask_id');
|
||||
$pageObj = new Page($count, 10);
|
||||
$result['pageStr'] = $pageObj->show();
|
||||
/* END */
|
||||
|
||||
/*问题表数据(问题表+会员表+问题分类表)*/
|
||||
$result['AskData'] = $this->ask_db->field($field)
|
||||
->alias('a')
|
||||
->join('__USERS__ b', 'a.users_id = b.users_id', 'LEFT')
|
||||
->where($where)
|
||||
->order('a.add_time desc')
|
||||
->limit($pageObj->firstRow . ',' . $pageObj->listRows)
|
||||
->select();
|
||||
/* END */
|
||||
|
||||
/*问题回答人查询*/
|
||||
$ask_id = get_arr_column($result['AskData'], 'ask_id');
|
||||
$RepliesData = $this->ask_answer_db->field('a.ask_id, a.users_id, b.nickname')
|
||||
->alias('a')
|
||||
->join('__USERS__ b', 'a.users_id = b.users_id', 'LEFT')
|
||||
->where('ask_id', 'IN', $ask_id)
|
||||
->select();
|
||||
/* END */
|
||||
} else {
|
||||
// 回答问题查询列表
|
||||
/*问题回答人查询*/
|
||||
$RepliesData = $this->ask_answer_db->field('a.ask_id, a.users_id, b.nickname')
|
||||
->alias('a')
|
||||
->join('__USERS__ b', 'a.users_id = b.users_id', 'LEFT')
|
||||
->select();
|
||||
/* END */
|
||||
|
||||
/* 查询条件 */
|
||||
$UsersIds = group_same_key($RepliesData, 'users_id');
|
||||
$ask_ids = get_arr_column($UsersIds[$view_uid], 'ask_id');
|
||||
// 按主键去重
|
||||
$ask_ids = array_unique($ask_ids, SORT_REGULAR);
|
||||
$where = [
|
||||
'a.status' => ['IN', [0, 1]],
|
||||
'a.ask_id' => ['IN', $ask_ids],
|
||||
];
|
||||
/* END */
|
||||
|
||||
/* 分页 */
|
||||
$count = $this->ask_db->alias('a')->where($where)->count('ask_id');
|
||||
$pageObj = new Page($count, 10);
|
||||
$result['pageStr'] = $pageObj->show();
|
||||
/* END */
|
||||
|
||||
/*问题表数据(问题表+会员表+问题分类表)*/
|
||||
$result['AskData'] = $this->ask_db->field($field)
|
||||
->alias('a')
|
||||
->join('__USERS__ b', 'a.users_id = b.users_id', 'LEFT')
|
||||
->where($where)
|
||||
->order('a.add_time desc')
|
||||
->limit($pageObj->firstRow . ',' . $pageObj->listRows)
|
||||
->select();
|
||||
/* END */
|
||||
}
|
||||
|
||||
// 取出提问问题的ID作为主键
|
||||
$RepliesData = group_same_key($RepliesData, 'ask_id');
|
||||
|
||||
/*数据处理*/
|
||||
foreach ($result['AskData'] as $key => $value) {
|
||||
// 时间友好显示处理
|
||||
$result['AskData'][$key]['add_time'] = friend_date($value['add_time']);
|
||||
// 问题内容Url
|
||||
$result['AskData'][$key]['AskUrl'] = askurl('home/Ask/details', ['ask_id' => $value['ask_id']]);
|
||||
// ROOT_DIR.'/index.php?m=home&c=Ask&a=details&ask_id='.$value['ask_id'];
|
||||
// 回复处理
|
||||
if (!empty($RepliesData[$value['ask_id']])) {
|
||||
$UsersConut = array_values(array_unique($RepliesData[$value['ask_id']], SORT_REGULAR));
|
||||
$result['AskData'][$key]['UsersConut'] = '等' . count($UsersConut) . '人参与讨论';
|
||||
} else {
|
||||
$UsersConut = ['0' => ['nickname' => $value['nickname']]];
|
||||
$result['AskData'][$key]['UsersConut'] = $value['nickname'];
|
||||
}
|
||||
// 处理参与讨论者的A标签跳转
|
||||
foreach ($UsersConut as $kkk => $vvv) {
|
||||
$nickname = $vvv['nickname'];
|
||||
if (($kkk + 1) == count($UsersConut) || 2 == $kkk) {
|
||||
$result['AskData'][$key]['NickName'] .= '<a href="javascript:void(0);">' . $nickname . '</a>';
|
||||
break;
|
||||
} else {
|
||||
$result['AskData'][$key]['NickName'] .= '<a href="javascript:void(0);">' . $nickname . '</a>、';
|
||||
}
|
||||
}
|
||||
}
|
||||
/* END */
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 问题数据
|
||||
public function GetNewAskData($where = array(), $limit = 20, $field = null)
|
||||
{
|
||||
// 返回参数
|
||||
$result = [];
|
||||
// 没有传入则默认查询这些字段
|
||||
if (empty($field)) {
|
||||
$field = 'a.*, b.nickname, b.head_pic, c.type_name';
|
||||
}
|
||||
|
||||
$result['PendingAsk'] = '';
|
||||
if (isset($where['a.replies']) && 0 == $where['a.replies']) {
|
||||
$result['PendingAsk'] = '待回答';
|
||||
}
|
||||
|
||||
// 提取搜索关键词
|
||||
if (!empty($where['SearchName']) || null == $where['SearchName']) {
|
||||
$SearchName = $where['SearchName'];
|
||||
unset($where['SearchName']);
|
||||
$result['SearchName'] = $SearchName;
|
||||
$result['SearchNameRed'] = "搜索 <font color='red'>" . $SearchName . "</font> 结果";
|
||||
}
|
||||
|
||||
if (!empty($where['a.type_id'])) {
|
||||
// 存在栏目ID则执行
|
||||
$TypeData = $this->ask_type_db->where('parent_id', $where['a.type_id'])->field('type_id')->select();
|
||||
if (!empty($TypeData)) {
|
||||
// 将顶级栏目ID合并到新条件中
|
||||
$type_id = get_arr_column($TypeData, 'type_id');
|
||||
$type_id = array_merge($type_id, array(0 => $where['a.type_id']));
|
||||
$where['a.type_id'] = ['IN', $type_id];
|
||||
}
|
||||
|
||||
// 查询满足要求的总记录数
|
||||
$count = $this->ask_db->alias('a')->where($where)->count('ask_id');
|
||||
// 实例化分页类 传入总记录数和每页显示的记录数
|
||||
$pageObj = new Page($count, 10);
|
||||
/*问题表数据(问题表+会员表+问题分类表)*/
|
||||
$result['AskData'] = $this->ask_db->field($field)
|
||||
->alias('a')
|
||||
->join('__USERS__ b', 'a.users_id = b.users_id', 'LEFT')
|
||||
->join('ask_type c', 'a.type_id = c.type_id', 'LEFT')
|
||||
->where($where)
|
||||
->order('a.ask_id desc')
|
||||
->limit($pageObj->firstRow . ',' . $pageObj->listRows)
|
||||
->select();
|
||||
// 分页显示输出
|
||||
$result['pageStr'] = $pageObj->show();
|
||||
} else {
|
||||
/*问题表数据(问题表+会员表+问题分类表)*/
|
||||
$result['AskData'] = $this->ask_db->field($field)
|
||||
->alias('a')
|
||||
->join('__USERS__ b', 'a.users_id = b.users_id', 'LEFT')
|
||||
->join('ask_type c', 'a.type_id = c.type_id', 'LEFT')
|
||||
->where($where)
|
||||
->order('a.ask_id desc')
|
||||
->limit($limit)
|
||||
->select();
|
||||
/* END */
|
||||
$result['pageStr'] = '';
|
||||
}
|
||||
|
||||
/*问题回答人查询*/
|
||||
$ask_id = get_arr_column($result['AskData'], 'ask_id');
|
||||
$RepliesData = $this->ask_answer_db->field('a.ask_id, a.users_id, b.head_pic, b.nickname')
|
||||
->alias('a')
|
||||
->join('__USERS__ b', 'a.users_id = b.users_id', 'LEFT')
|
||||
->where('ask_id', 'IN', $ask_id)
|
||||
->select();
|
||||
$RepliesDataNew = [];
|
||||
foreach ($RepliesData as $key => $value) {
|
||||
/*头像处理*/
|
||||
$value['head_pic'] = get_head_pic($value['head_pic']);
|
||||
/* END */
|
||||
// 将二维数组以ask_id值作为键,并归类数组,效果同等group_same_key
|
||||
$RepliesDataNew[$value['ask_id']][] = $value;
|
||||
}
|
||||
/* END */
|
||||
|
||||
/*数据处理*/
|
||||
foreach ($result['AskData'] as $key => $value) {
|
||||
/*头像处理*/
|
||||
$value['head_pic'] = get_head_pic($value['head_pic']);
|
||||
$result['AskData'][$key]['head_pic'] = $value['head_pic'];
|
||||
/* END */
|
||||
|
||||
// 若存在搜索关键词则标红关键词
|
||||
if (isset($SearchName) && !empty($SearchName)) {
|
||||
$result['AskData'][$key]['ask_title'] = $this->AskLogic->GetRedKeyWord($SearchName, $value['ask_title']);
|
||||
}
|
||||
|
||||
// 时间友好显示处理
|
||||
$result['AskData'][$key]['add_time'] = friend_date($value['add_time']);
|
||||
// 栏目分类Url
|
||||
$result['AskData'][$key]['TypeUrl'] = askurl('home/Ask/index', ['type_id' => $value['type_id']]);
|
||||
// 问题内容Url
|
||||
$result['AskData'][$key]['AskUrl'] = askurl('home/Ask/details', ['ask_id' => $value['ask_id']]);
|
||||
// 回复处理
|
||||
if (!empty($RepliesDataNew[$value['ask_id']])) {
|
||||
$UsersConut = array_unique($RepliesDataNew[$value['ask_id']], SORT_REGULAR);
|
||||
// 读取前三条数据
|
||||
$result['AskData'][$key]['HeadPic'] = array_slice($UsersConut, 0, 3);
|
||||
$result['AskData'][$key]['UsersConut'] = '等' . count($UsersConut) . '人参与讨论';
|
||||
} else {
|
||||
$result['AskData'][$key]['HeadPic'] = ['0' => ['head_pic' => $value['head_pic']]];
|
||||
$result['AskData'][$key]['UsersConut'] = $value['nickname'];
|
||||
}
|
||||
}
|
||||
/* END */
|
||||
|
||||
// 是否推荐
|
||||
if (!empty($where['a.is_recom'])) {
|
||||
$result['IsRecom'] = 1;
|
||||
} else {
|
||||
$result['IsRecom'] = 0;
|
||||
}
|
||||
if (!empty($where['a.money'])) {
|
||||
$result['IsRecom'] = 3;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 问题栏目分类数据
|
||||
public function GetAskTypeData($param = array(), $is_add = null)
|
||||
{
|
||||
// 数据初始化
|
||||
$result = [
|
||||
'IsTypeId' => 0,
|
||||
'ParentId' => 0,
|
||||
'TypeId' => 0,
|
||||
'TypeName' => '',
|
||||
'HtmlCode' => '<span style="color: red;">请先让管理员在插件栏目列表中添加分类!</span>',
|
||||
'TypeData' => []
|
||||
];
|
||||
|
||||
/*栏目处理*/
|
||||
$TypeData = $this->ask_type_db->order('sort_order asc, type_id asc')->select();
|
||||
if (empty($TypeData)) return [];
|
||||
|
||||
foreach ($TypeData as $key => $value) {
|
||||
/*若存在分类ID且和数据中的值相等则执行*/
|
||||
if (!empty($param['type_id']) && $value['type_id'] == $param['type_id']) {
|
||||
$result['TypeName'] = $value['type_name'];
|
||||
$result['TypeId'] = $value['type_id'];
|
||||
$result['ParentId'] = $value['parent_id'];
|
||||
|
||||
// 描点标记焦点
|
||||
if (!empty($value['parent_id'])) {
|
||||
$result['IsTypeId'] = $value['parent_id'];
|
||||
} else {
|
||||
$result['IsTypeId'] = $value['type_id'];
|
||||
}
|
||||
}
|
||||
/* END */
|
||||
|
||||
// 是否顶级栏目
|
||||
if ($value['parent_id'] == 0) {
|
||||
$value['SelectType'] = 0;
|
||||
$PidData[] = $value;
|
||||
} else {
|
||||
$value['SelectSubType'] = 0;
|
||||
$TidData[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// 调用来源
|
||||
if (isset($is_add) && 'add_ask' == $is_add) {
|
||||
// 问题发布调用
|
||||
$return['HtmlCode'] = $this->AskLogic->GetTypeHtmlCode($PidData, $TidData, $param['type_id']);
|
||||
return $return;
|
||||
} else if (isset($is_add) && 'edit_ask' == $is_add) {
|
||||
// 问题编辑调用
|
||||
$return['HtmlCode'] = $this->AskLogic->GetTypeHtmlCode($PidData, $TidData, $param['type_id']);
|
||||
return $return;
|
||||
} else {
|
||||
// 列表或内容页调用
|
||||
$TidData = group_same_key($TidData, 'parent_id');
|
||||
|
||||
// 一级栏目处理
|
||||
foreach ($PidData as $P_key => $PidValue) {
|
||||
$result['TypeData'][] = $PidValue;
|
||||
$result['TypeData'][$P_key]['Url'] = askurl('home/Ask/index', ['type_id' => $PidValue['type_id']]);
|
||||
// ROOT_DIR.'/index.php?m=home&c=Ask&a=index&type_id='.$PidValue['type_id'];
|
||||
|
||||
$result['TypeData'][$P_key]['SubType'] = [];
|
||||
|
||||
if (!empty($TidData[$PidValue['type_id']])) {
|
||||
// 所属子栏目处理
|
||||
foreach ($TidData[$PidValue['type_id']] as $T_key => $TidValue) {
|
||||
if ($TidValue['parent_id'] == $PidValue['type_id']) {
|
||||
array_push($result['TypeData'][$P_key]['SubType'], $TidValue);
|
||||
$result['TypeData'][$P_key]['SubType'][$T_key]['Url'] = askurl('home/Ask/index', ['type_id' => $TidValue['type_id']]);
|
||||
// ROOT_DIR.'/index.php?m=home&c=Ask&a=index&type_id='.$TidValue['type_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* END */
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
// 周榜
|
||||
public function GetAskWeekListData()
|
||||
{
|
||||
$time1 = strtotime(date('Y-m-d H:i:s', time()));
|
||||
$time2 = $time1 - (86400 * 7);
|
||||
$where = [
|
||||
'a.add_time' => ['between time', [$time2, $time1]],
|
||||
'a.is_review' => 1,
|
||||
];
|
||||
$result['WeekList'] = [];
|
||||
$WeekList = $this->ask_db->field('a.ask_id, a.ask_title, a.click, a.replies, b.head_pic')
|
||||
->alias('a')
|
||||
->join('__USERS__ b', 'a.users_id = b.users_id', 'LEFT')
|
||||
->order('click desc, replies desc')
|
||||
->where($where)
|
||||
->limit('0, 10')
|
||||
->select();
|
||||
if (empty($WeekList)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
foreach ($WeekList as $key => $value) {
|
||||
$result['WeekList'][$key]['AskUrl'] = askurl('home/Ask/details', ['ask_id' => $value['ask_id']]);
|
||||
$result['WeekList'][$key]['ask_title'] = $value['ask_title'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 总榜
|
||||
public function GetAskTotalListData()
|
||||
{
|
||||
$result['TotalList'] = [];
|
||||
$TotalList = $this->ask_db->field('a.ask_id, a.ask_title, a.click, a.replies, b.head_pic')
|
||||
->alias('a')
|
||||
->join('__USERS__ b', 'a.users_id = b.users_id', 'LEFT')
|
||||
->order('click desc, replies desc')
|
||||
->where('a.is_review', 1)
|
||||
->limit('0, 10')
|
||||
->select();
|
||||
if (empty($TotalList)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
foreach ($TotalList as $key => $value) {
|
||||
$result['TotalList'][$key]['AskUrl'] = askurl('home/Ask/details', ['ask_id' => $value['ask_id']]);
|
||||
$result['TotalList'][$key]['ask_title'] = $value['ask_title'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 问题详情数据
|
||||
public function GetAskDetailsData($param = array(), $parent_id = null, $users_id = null)
|
||||
{
|
||||
$ResultData['code'] = 1;
|
||||
$ResultData['info'] = $this->ask_db->field('a.*, b.username, b.nickname, b.head_pic, c.type_name')
|
||||
->alias('a')
|
||||
->join('ask_type c', 'c.type_id = a.type_id', 'LEFT')
|
||||
->join('__USERS__ b', 'a.users_id = b.users_id', 'LEFT')
|
||||
->where('ask_id', $param['ask_id'])
|
||||
->find();
|
||||
if (empty($ResultData['info'])) return ['code' => 0, 'msg' => '浏览的问题不存在!'];
|
||||
if (0 !== $parent_id) {
|
||||
if (0 == $ResultData['info']['is_review'] && $ResultData['info']['users_id'] !== $users_id) {
|
||||
return ['code' => 0, 'msg' => '问题未审核通过,暂时不可浏览!'];
|
||||
}
|
||||
}
|
||||
|
||||
// 头像处理
|
||||
$ResultData['info']['head_pic'] = get_head_pic($ResultData['info']['head_pic']);
|
||||
|
||||
// 时间友好显示处理
|
||||
$ResultData['info']['add_time'] = friend_date($ResultData['info']['add_time']);
|
||||
$ResultData['IsUsers'] = 0;
|
||||
if ($ResultData['info']['users_id'] == session('users_id')) $ResultData['IsUsers'] = 1;
|
||||
|
||||
// 处理格式
|
||||
$ResultData['info']['content'] = htmlspecialchars_decode($ResultData['info']['content']);
|
||||
|
||||
$ResultData['SearchName'] = null;
|
||||
|
||||
// seo信息
|
||||
$ResultData['info']['seo_title'] = $ResultData['info']['ask_title'] . ' - ' . $ResultData['info']['type_name'];
|
||||
$ResultData['info']['seo_keywords'] = $ResultData['info']['ask_title'];
|
||||
$ResultData['info']['seo_description'] = @msubstr(checkStrHtml($ResultData['info']['content']), 0, config('global.arc_seo_description_length'), false);
|
||||
|
||||
return $ResultData;
|
||||
}
|
||||
|
||||
// 问题回答数据
|
||||
public function GetAskReplyData($param = array(), $parent_id = null)
|
||||
{
|
||||
/*查询条件*/
|
||||
$bestanswer_id = $this->ask_db->where('ask_id', $param['ask_id'])->getField('bestanswer_id');
|
||||
$RepliesWhere = ['ask_id' => $param['ask_id'], 'is_review' => 1];
|
||||
$WhereOr = [];
|
||||
if (!empty($param['answer_id'])) {
|
||||
$RepliesWhere = ['answer_id' => $param['answer_id'], 'is_review' => 1];
|
||||
$WhereOr = ['answer_pid' => $param['answer_id']];
|
||||
}
|
||||
|
||||
// 若为则创始人则去除仅查询已审核评论这个条件,$parent_id = 0 表示为创始人
|
||||
if (0 == $parent_id) unset($RepliesWhere['is_review']);
|
||||
/* END */
|
||||
|
||||
/*评论读取条数*/
|
||||
$firstRow = !empty($param['firstRow']) ? $param['firstRow'] : 0;
|
||||
$listRows = !empty($param['listRows']) ? $param['listRows'] : 5;
|
||||
$result['firstRow'] = $firstRow;
|
||||
$result['listRows'] = $listRows;
|
||||
/* END */
|
||||
|
||||
/*排序*/
|
||||
$OrderBy = !empty($param['click_like']) ? 'a.click_like ' . $param['click_like'] . ', a.add_time asc' : 'a.add_time asc';
|
||||
$click_like = isset($param['click_like']) ? $param['click_like'] : '';
|
||||
$result['SortOrder'] = 'desc' == $click_like ? 'asc' : 'desc';
|
||||
/* END */
|
||||
|
||||
/*评论回答*/
|
||||
$RepliesData = $this->ask_answer_db->field('a.*, b.head_pic, b.nickname, c.nickname as `at_usersname`')
|
||||
->alias('a')
|
||||
->join('__USERS__ b', 'a.users_id = b.users_id', 'LEFT')
|
||||
->join('__USERS__ c', 'a.at_users_id = c.users_id', 'LEFT')
|
||||
->order($OrderBy)
|
||||
->where($RepliesWhere)
|
||||
->WhereOr($WhereOr)
|
||||
->select();
|
||||
if (empty($RepliesData)) return [];
|
||||
/* END */
|
||||
|
||||
/*点赞数据*/
|
||||
$AnswerIds = get_arr_column($RepliesData, 'answer_id');
|
||||
$AnswerLikeData = $this->ask_answer_like_db->field('a.*, b.nickname')
|
||||
->alias('a')
|
||||
->join('__USERS__ b', 'a.users_id = b.users_id', 'LEFT')
|
||||
->order('like_id desc')
|
||||
->where('answer_id', 'IN', $AnswerIds)
|
||||
->select();
|
||||
$AnswerLikeData = group_same_key($AnswerLikeData, 'answer_id');
|
||||
/* END */
|
||||
|
||||
/*回答处理*/
|
||||
$PidData = $AnswerData = [];
|
||||
foreach ($RepliesData as $key => $value) {
|
||||
// 友好显示时间
|
||||
$value['add_time'] = friend_date($value['add_time']);
|
||||
// 处理格式
|
||||
$value['content'] = htmlspecialchars_decode($value['content']);
|
||||
// 头像处理
|
||||
$value['head_pic'] = get_head_pic($value['head_pic']);
|
||||
// 会员昵称
|
||||
$value['nickname'] = !empty($value['nickname']) ? $value['nickname'] : $value['username'];
|
||||
|
||||
// 是否上一级回答
|
||||
if ($value['answer_pid'] == 0) {
|
||||
$PidData[] = $value;
|
||||
} else {
|
||||
$AnswerData[] = $value;
|
||||
}
|
||||
}
|
||||
/* END */
|
||||
|
||||
/*一级回答*/
|
||||
foreach ($PidData as $key => $PidValue) {
|
||||
$result['AnswerData'][] = $PidValue;
|
||||
// 子回答
|
||||
$result['AnswerData'][$key]['AnswerSubData'] = [];
|
||||
// 点赞数据
|
||||
$result['AnswerData'][$key]['AnswerLike'] = [];
|
||||
|
||||
/*所属子回答处理*/
|
||||
foreach ($AnswerData as $AnswerValue) {
|
||||
if ($AnswerValue['answer_pid'] == $PidValue['answer_id']) {
|
||||
array_push($result['AnswerData'][$key]['AnswerSubData'], $AnswerValue);
|
||||
}
|
||||
}
|
||||
/* END */
|
||||
|
||||
/*读取指定数据*/
|
||||
// 以是否审核排序,审核的优先
|
||||
array_multisort(get_arr_column($result['AnswerData'][$key]['AnswerSubData'], 'is_review'), SORT_DESC, $result['AnswerData'][$key]['AnswerSubData']);
|
||||
// 读取指定条数
|
||||
$result['AnswerData'][$key]['AnswerSubData'] = array_slice($result['AnswerData'][$key]['AnswerSubData'], $firstRow, $listRows);
|
||||
/* END */
|
||||
|
||||
$result['AnswerData'][$key]['AnswerLike']['LikeNum'] = null;
|
||||
$result['AnswerData'][$key]['AnswerLike']['LikeName'] = null;
|
||||
/*点赞处理*/
|
||||
foreach ($AnswerLikeData as $LikeKey => $LikeValue) {
|
||||
if ($PidValue['answer_id'] == $LikeKey) {
|
||||
// 点赞总数
|
||||
$LikeNum = count($LikeValue);
|
||||
$result['AnswerData'][$key]['AnswerLike']['LikeNum'] = $LikeNum;
|
||||
for ($i = 0; $i < $LikeNum; $i++) {
|
||||
// 获取前三个点赞人处理后退出本次for
|
||||
if ($i > 2) break;
|
||||
// 点赞人用户名\昵称
|
||||
$LikeName = $LikeValue[$i]['nickname'];
|
||||
// 在第二个数据前加入顿号,拼装a链接
|
||||
if ($i != 0) {
|
||||
$LikeName = ' 、<a href="javascript:void(0);">' . $LikeName . '</a>';
|
||||
} else {
|
||||
$LikeName = '<a href="javascript:void(0);">' . $LikeName . '</a>';
|
||||
}
|
||||
$result['AnswerData'][$key]['AnswerLike']['LikeName'] .= $LikeName;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* END */
|
||||
}
|
||||
/* END */
|
||||
|
||||
/*最佳答案数据*/
|
||||
foreach ($result['AnswerData'] as $key => $value) {
|
||||
if ($bestanswer_id == $value['answer_id']) {
|
||||
$result['BestAnswer'][$key] = $value;
|
||||
unset($result['AnswerData'][$key]);
|
||||
}
|
||||
}
|
||||
/* NED */
|
||||
|
||||
// 统计回答数
|
||||
$result['AnswerCount'] = count($RepliesData);
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 操作问题表回复数
|
||||
public function UpdateAskReplies($ask_id = null, $IsAdd = true, $DelNum = 0)
|
||||
{
|
||||
if (empty($ask_id)) return false;
|
||||
if (!empty($IsAdd)) {
|
||||
$Updata = [
|
||||
'replies' => Db::raw('replies+1'),
|
||||
'update_time' => getTime(),
|
||||
];
|
||||
} else {
|
||||
$Updata = [
|
||||
'replies' => Db::raw('replies-1'),
|
||||
'update_time' => getTime(),
|
||||
];
|
||||
if ($DelNum > 0) $Updata['replies'] = Db::raw('replies-' . $DelNum);
|
||||
}
|
||||
$this->ask_db->where('ask_id', $ask_id)->update($Updata);
|
||||
}
|
||||
|
||||
// 增加问题浏览点击量
|
||||
public function UpdateAskClick($ask_id = null)
|
||||
{
|
||||
if (empty($ask_id)) return false;
|
||||
$Updata = [
|
||||
'click' => Db::raw('click+1'),
|
||||
'update_time' => getTime(),
|
||||
];
|
||||
$this->ask_db->where('ask_id', $ask_id)->update($Updata);
|
||||
}
|
||||
|
||||
|
||||
// 会员中心--问题中心--我的问题\回复
|
||||
public function GetUsersAskDataNew($view_uid = null, $is_ask = true)
|
||||
{
|
||||
// 返回参数
|
||||
$result = [];
|
||||
if (!empty($is_ask)) {
|
||||
// 提问问题查询列表
|
||||
/*查询字段*/
|
||||
$field = 'a.ask_id, a.ask_title, a.click, a.replies, a.add_time, a.is_review, b.type_name';
|
||||
/* END */
|
||||
|
||||
/*查询条件*/
|
||||
$where = [
|
||||
'a.status' => ['IN', [0, 1]],
|
||||
'a.users_id' => $view_uid,
|
||||
];
|
||||
/* END */
|
||||
|
||||
/* 分页 */
|
||||
$count = $this->ask_db->alias('a')->where($where)->count('ask_id');
|
||||
$pageObj = new Page($count, 10);
|
||||
$result['pageStr'] = $pageObj->show();
|
||||
/* END */
|
||||
|
||||
/*问题表数据(问题表+会员表+问题分类表)*/
|
||||
$result['AskData'] = $this->ask_db->field($field)
|
||||
->alias('a')
|
||||
->join('ask_type b', 'a.type_id = b.type_id', 'LEFT')
|
||||
->where($where)
|
||||
->order('a.add_time desc')
|
||||
->limit($pageObj->firstRow . ',' . $pageObj->listRows)
|
||||
->select();
|
||||
/* END */
|
||||
} else {
|
||||
// 回答问题查询列表
|
||||
/*查询字段*/
|
||||
$field = 'a.*, b.ask_title';
|
||||
/* END */
|
||||
|
||||
/*查询条件*/
|
||||
$where = [
|
||||
'a.users_id' => $view_uid,
|
||||
];
|
||||
/* END */
|
||||
|
||||
/* 分页 */
|
||||
$count = $this->ask_answer_db->alias('a')->where($where)->count('answer_id');
|
||||
$pageObj = new Page($count, 5);
|
||||
$result['pageStr'] = $pageObj->show();
|
||||
/* END */
|
||||
|
||||
/*问题回答人查询*/
|
||||
$result['AskData'] = $this->ask_answer_db->field($field)
|
||||
->alias('a')
|
||||
->join('ask b', 'a.ask_id = b.ask_id', 'LEFT')
|
||||
->where($where)
|
||||
->order('a.add_time desc')
|
||||
->limit($pageObj->firstRow . ',' . $pageObj->listRows)
|
||||
->select();
|
||||
/* END */
|
||||
}
|
||||
|
||||
/*数据处理*/
|
||||
foreach ($result['AskData'] as $key => $value) {
|
||||
// 问题内容Url
|
||||
$result['AskData'][$key]['AskUrl'] = askurl('home/Ask/details', ['ask_id' => $value['ask_id']]);
|
||||
// ROOT_DIR.'/index.php?m=home&c=Ask&a=details&ask_id='.$value['ask_id'];
|
||||
if (empty($is_ask)) {
|
||||
$result['AskData'][$key]['AskUrl'] .= !empty($value['answer_pid']) ? '#ul_div_li_' . $value['answer_pid'] : '#ul_div_li_' . $value['answer_id'];
|
||||
}
|
||||
|
||||
if (isset($value['answer_id']) && !empty($value['answer_id'])) {
|
||||
$preg = '/<img.*?src=[\"|\']?(.*?)[\"|\']?\s.*?>/i';
|
||||
$value['content'] = htmlspecialchars_decode($value['content']);
|
||||
$value['content'] = preg_replace($preg, '[图片]', $value['content']);
|
||||
$value['content'] = strip_tags($value['content']);
|
||||
$result['AskData'][$key]['content'] = $value['content'];
|
||||
}
|
||||
}
|
||||
/* END */
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
//贡献榜(积分)score 财富榜(金币)money
|
||||
public function GetOrderList($type = 'score')
|
||||
{
|
||||
if ($type == 'score') {
|
||||
$list = Db::name('users')
|
||||
->field('nickname,head_pic,users_id,scores,devote')
|
||||
->order('scores desc')
|
||||
->limit(10)
|
||||
->select();
|
||||
$level = Db::name('ask_score_level')->order('min', 'asc')->select();
|
||||
foreach ($list as $key => $val) {
|
||||
foreach ($level as $k => $v) {
|
||||
if ($val['scores'] >= $v['min'] && ( $val['scores'] <= $v['max'] || $v['max'] == 0)) {
|
||||
$val['level'] = $v['name'];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!empty($val['head_pic'])) {
|
||||
$val['head_pic'] = handle_subdir_pic($val['head_pic']);
|
||||
} else {
|
||||
$val['head_pic'] = get_head_pic();
|
||||
}
|
||||
$list[$key] = $val;
|
||||
}
|
||||
} elseif ($type == 'money') {
|
||||
$list = Db::name('users_score')
|
||||
->field('sum(money) as money,users_id')
|
||||
->where('type', 3)
|
||||
->group('users_id')
|
||||
->order('money desc')
|
||||
->limit(10)
|
||||
->select();
|
||||
if (!empty($list)) {
|
||||
$ids = [];
|
||||
foreach ($list as $k => $v) {
|
||||
$ids[] = $v['users_id'];
|
||||
}
|
||||
$users_data = Db::name('users')
|
||||
->field('nickname,head_pic,users_id,devote,scores')
|
||||
->where('users_id', 'in', $ids)
|
||||
->getAllWithIndex('users_id');
|
||||
$level = Db::name('ask_score_level')->order('min', 'asc')->select();
|
||||
if (!empty($users_data)) {
|
||||
foreach ($list as $key => $val) {
|
||||
$val = array_merge($val, $users_data[$val['users_id']]);
|
||||
if (!empty($v['head_pic'])) {
|
||||
$val['head_pic'] = handle_subdir_pic($val['head_pic']);
|
||||
} else {
|
||||
$val['head_pic'] = get_head_pic();
|
||||
}
|
||||
foreach ($level as $k => $v) {
|
||||
if ($val['scores'] >= $v['min'] && ( $val['scores'] <= $v['max'] || $v['max'] == 0)) {
|
||||
$val['level'] = $v['name'];
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$list[$key] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加余额(设为最佳答案)$act='inc'
|
||||
*/
|
||||
public function setMoney($users_id = 0, $money = 0, $ask_id = 0, $reply_id = 0)
|
||||
{
|
||||
Db::name('users')->where('users_id', $users_id)->setInc('users_money', $money);
|
||||
$data = [
|
||||
'ask_id' => $ask_id,
|
||||
'reply_id' => $reply_id,
|
||||
'users_id' => $users_id,
|
||||
'money' => $money,
|
||||
'info' => '最佳答案',
|
||||
'type' => 3,
|
||||
'add_time' => getTime(),
|
||||
'update_time' => getTime(),
|
||||
];
|
||||
Db::name('users_score')->insert($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑问题增加悬赏金额
|
||||
*/
|
||||
public function updateMoney($users_id = 0, $money = 0, $ori_money = 0, $ask_id = 0)
|
||||
{
|
||||
Db::name('users')->where('users_id', $users_id)->setDec('users_money', $money - $ori_money);
|
||||
$data = [
|
||||
'money' => $money,
|
||||
'update_time' => getTime(),
|
||||
];
|
||||
Db::name('users_score')->where(['ask_id' => $ask_id, 'users_id' => $users_id, 'type' => 1])->update($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加赠送积分记录
|
||||
* $type 1-提问 2-回答
|
||||
*/
|
||||
public function setScore($users_id = 0, $ask_id = 0, $reply_id = 0, $type = 1, $money = 0)
|
||||
{
|
||||
//先判断是否开启问答送积分
|
||||
$data = getUsersConfigData('score');
|
||||
|
||||
if (empty($data['score_ask_status']) && $money == 0) {
|
||||
//未开启问答送积分+没有悬赏
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($type == 1) {
|
||||
$score = $data['score_ask_score'];
|
||||
$count = $data['score_ask_count'];
|
||||
$info = '问答提问';
|
||||
} elseif ($type == 2) {
|
||||
$score = $data['score_reply_score'];
|
||||
$count = $data['score_reply_count'];
|
||||
$info = '问答回答';
|
||||
}
|
||||
if (empty($data['score_ask_status'])) {
|
||||
$score = 0;
|
||||
}
|
||||
if (!empty($count) && 0 < $count) {
|
||||
//有次数限制 判断当日次数是是否已用完
|
||||
$counts = Db::name('users_score')
|
||||
->where('type', $type)
|
||||
->where('users_id', $users_id)
|
||||
->where('score', '>', 0)
|
||||
->whereTime('add_time', 'today')
|
||||
->count();
|
||||
if ($counts >= $count) {
|
||||
if ((1 == $type && $money == 0) || 2 == $type) {
|
||||
return false;
|
||||
} elseif (1 == $type && !empty($money)) {
|
||||
$score = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'ask_id' => $ask_id,
|
||||
'reply_id' => $reply_id,
|
||||
'users_id' => $users_id,
|
||||
'money' => -$money,
|
||||
'info' => $info,
|
||||
'score' => $score,
|
||||
'devote' => $score,
|
||||
'type' => $type,
|
||||
'add_time' => getTime(),
|
||||
'update_time' => getTime(),
|
||||
];
|
||||
Db::name('users_score')->insert($data);
|
||||
//会员表更新
|
||||
$update = [];
|
||||
if (!empty($score)) {
|
||||
$update['scores'] = Db::raw('scores+' . $score);
|
||||
$update['devote'] = Db::raw('devote+' . $score);
|
||||
}
|
||||
if (!empty($money)) {
|
||||
$update['users_money'] = Db::raw('users_money-' . $money);
|
||||
}
|
||||
Db::name('users')->where('users_id', $users_id)->update($update);
|
||||
}
|
||||
|
||||
public function RebackDel($ask_id = 0)
|
||||
{
|
||||
$ask = Db::name('ask')->where('ask_id', $ask_id)->find();
|
||||
$users_id = $ask['users_id'];
|
||||
$money = $ask['money'];
|
||||
if ($money > 0) {
|
||||
//退钱
|
||||
Db::name('users')->where('users_id', $users_id)->setInc('users_money', $money);
|
||||
adminLog($users_id . '删除问题,id:' . $ask_id . ',标题:' . $ask['ask_title']);
|
||||
$data = [
|
||||
'ask_id' => $ask_id,
|
||||
'users_id' => $users_id,
|
||||
'type' => 1,
|
||||
];
|
||||
Db::name('users_score')->where($data)->delete();
|
||||
}
|
||||
|
||||
$count_score = Db::name('users_score')->where(['ask_id' => $ask_id, 'users_id' => $users_id])->sum('score');
|
||||
Db::name('users_score')->where(['ask_id' => $ask_id, 'users_id' => $users_id])->delete();
|
||||
|
||||
$user_info = Db::name('users')->where('users_id', $users_id)->field('users_money,scores')->find();
|
||||
if (!empty($user_info)) {
|
||||
//更新
|
||||
$update['scores'] = ($user_info['scores'] - $count_score) > 0 ? $user_info['scores'] - $count_score : 0;
|
||||
if ($money > 0) {
|
||||
$update['users_money'] = ($user_info['users_money'] - $money) > 0 ? $user_info['users_money'] - $money : 0;
|
||||
}
|
||||
$update['update_time'] = getTime();
|
||||
Db::name('users')->where('users_id', $users_id)->update($update);
|
||||
}
|
||||
}
|
||||
|
||||
public function getQq()
|
||||
{
|
||||
$data = tpSetting('ask');
|
||||
if (!empty($data)) {
|
||||
$result['data'] = $data;
|
||||
$result['ask_qq'] = $data['ask_qq'];
|
||||
$result['ask_qq_link'] = $data['ask_qq_link'];
|
||||
$result['ask_intro'] = $data['ask_intro'];
|
||||
$result['score_name'] = getUsersConfigData('score.score_name');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
75
src/application/home/model/Download.php
Normal file
75
src/application/home/model/Download.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Page;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 下载
|
||||
*/
|
||||
class Download extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条记录
|
||||
* @author wengxianhu by 2017-7-26
|
||||
*/
|
||||
public function getInfo($aid, $field = '', $isshowbody = true)
|
||||
{
|
||||
$data = array();
|
||||
if (!empty($field)) {
|
||||
$field_arr = explode(',', $field);
|
||||
foreach ($field_arr as $key => $val) {
|
||||
$val = trim($val);
|
||||
if (preg_match('/^([a-z]+)\./i', $val) == 0) {
|
||||
array_push($data, 'a.'.$val);
|
||||
} else {
|
||||
array_push($data, $val);
|
||||
}
|
||||
}
|
||||
$field = implode(',', $data);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
if ($isshowbody) {
|
||||
$field = !empty($field) ? $field : 'b.*, a.*';
|
||||
$result = Db::name('archives')->field($field)
|
||||
->alias('a')
|
||||
->join('__DOWNLOAD_CONTENT__ b', 'b.aid = a.aid', 'LEFT')
|
||||
->find($aid);
|
||||
} else {
|
||||
$field = !empty($field) ? $field : 'a.*';
|
||||
$result = Db::name('archives')->field($field)
|
||||
->alias('a')
|
||||
->find($aid);
|
||||
}
|
||||
|
||||
// 文章TAG标签
|
||||
if (!empty($result)) {
|
||||
$typeid = isset($result['typeid']) ? $result['typeid'] : 0;
|
||||
$tags = model('Taglist')->getListByAid($aid, $typeid);
|
||||
$result['tags'] = $tags;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
135
src/application/home/model/DownloadFile.php
Normal file
135
src/application/home/model/DownloadFile.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*/
|
||||
class DownloadFile extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定下载文章的所有文件
|
||||
* @author 小虎哥 by 2018-4-3
|
||||
*/
|
||||
public function getDownFile($aids = [], $field = '*')
|
||||
{
|
||||
$where = [];
|
||||
!empty($aids) && $where['aid'] = ['IN', $aids];
|
||||
$result = Db::name('DownloadFile')->field($field)
|
||||
->where($where)
|
||||
->order('sort_order asc')
|
||||
->select();
|
||||
|
||||
if (!empty($result)) {
|
||||
$hidden = '';
|
||||
$n = 1;
|
||||
foreach ($result as $key => $val) {
|
||||
$downurl = ROOT_DIR."/index.php?m=home&c=View&a=downfile&id={$val['file_id']}&uhash={$val['uhash']}";
|
||||
|
||||
$result[$key]['title'] = $val['file_name'];
|
||||
if (!empty($val['extract_code'])) {
|
||||
$result[$key]['title'] = '提取码:'.$val['extract_code'];
|
||||
}
|
||||
if (is_http_url($val['file_url'])) {
|
||||
$result[$key]['server_name'] = !empty($val['server_name']) ? $val['server_name'] : "远程服务器({$n})";
|
||||
} else {
|
||||
$result[$key]['server_name'] = !empty($val['server_name']) ? $val['server_name'] : "本地服务器({$n})";
|
||||
}
|
||||
$n++;
|
||||
|
||||
$result[$key]['softlinks'] = $downurl;
|
||||
$result[$key]['downurl'] = "javascript:ey_1563185380({$val['file_id']});";
|
||||
$result[$key]['ey_1563185380'] = "<input type='hidden' id='ey_file_list_{$val['file_id']}' value='{$downurl}' /><form id='form_file_list_{$val['file_id']}' method='post' action='{$downurl}' target='_blank' style='display: none!important;'></form>";
|
||||
$result[$key]['ey_1563185376'] = $this->handleDownJs($hidden);
|
||||
}
|
||||
$result = group_same_key($result, 'aid');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function handleDownJs(&$hidden = '')
|
||||
{
|
||||
if (empty($hidden)) {
|
||||
$hidden = <<<EOF
|
||||
<script type="text/javascript">
|
||||
function ey_1563185380(file_id) {
|
||||
var downurl = document.getElementById("ey_file_list_"+file_id).value + "&_ajax=1";
|
||||
//创建异步对象
|
||||
var ajaxObj = new XMLHttpRequest();
|
||||
ajaxObj.open("get", downurl, true);
|
||||
ajaxObj.setRequestHeader("X-Requested-With","XMLHttpRequest");
|
||||
ajaxObj.setRequestHeader("Content-type","application/x-www-form-urlencoded");
|
||||
//发送请求
|
||||
ajaxObj.send();
|
||||
ajaxObj.onreadystatechange = function () {
|
||||
// 这步为判断服务器是否正确响应
|
||||
if (ajaxObj.readyState == 4 && ajaxObj.status == 200) {
|
||||
var json = ajaxObj.responseText;
|
||||
var res = JSON.parse(json);
|
||||
if (0 == res.code) {
|
||||
// 没有登录
|
||||
if (undefined != res.data.is_login && 0 == res.data.is_login) {
|
||||
if (document.getElementById('ey_login_id_1609665117')) {
|
||||
$('#ey_login_id_1609665117').trigger('click');
|
||||
} else {
|
||||
window.location.href = res.data.url;
|
||||
}
|
||||
} else {
|
||||
if (!window.layer) {
|
||||
alert(res.msg);
|
||||
if (undefined != res.data.url && res.data.url) {
|
||||
window.location.href = res.data.url;
|
||||
}
|
||||
} else {
|
||||
if (undefined != res.data.url && '' != res.data.url) {
|
||||
layer.confirm(res.msg, {
|
||||
title: false
|
||||
, icon: 5
|
||||
, closeBtn: false
|
||||
}, function (index) {
|
||||
layer.close(index);
|
||||
window.location.href = res.data.url;
|
||||
});
|
||||
} else {
|
||||
layer.alert(res.msg, {icon: 5, title: false, closeBtn: false});
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}else{
|
||||
// document.getElementById('form_file_list_'+file_id).submit();
|
||||
window.location.href = res.url;
|
||||
// window.open(res.url);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
</script>
|
||||
EOF;
|
||||
}
|
||||
|
||||
return $hidden;
|
||||
}
|
||||
}
|
||||
28
src/application/home/model/Field.php
Normal file
28
src/application/home/model/Field.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 字段
|
||||
*/
|
||||
class Field extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
}
|
||||
}
|
||||
75
src/application/home/model/Images.php
Normal file
75
src/application/home/model/Images.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Page;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 图集
|
||||
*/
|
||||
class Images extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条记录
|
||||
* @author wengxianhu by 2017-7-26
|
||||
*/
|
||||
public function getInfo($aid, $field = '', $isshowbody = true)
|
||||
{
|
||||
$data = array();
|
||||
if (!empty($field)) {
|
||||
$field_arr = explode(',', $field);
|
||||
foreach ($field_arr as $key => $val) {
|
||||
$val = trim($val);
|
||||
if (preg_match('/^([a-z]+)\./i', $val) == 0) {
|
||||
array_push($data, 'a.'.$val);
|
||||
} else {
|
||||
array_push($data, $val);
|
||||
}
|
||||
}
|
||||
$field = implode(',', $data);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
if ($isshowbody) {
|
||||
$field = !empty($field) ? $field : 'b.*, a.*';
|
||||
$result = Db::name('archives')->field($field)
|
||||
->alias('a')
|
||||
->join('__IMAGES_CONTENT__ b', 'b.aid = a.aid', 'LEFT')
|
||||
->find($aid);
|
||||
} else {
|
||||
$field = !empty($field) ? $field : 'a.*';
|
||||
$result = Db::name('archives')->field($field)
|
||||
->alias('a')
|
||||
->find($aid);
|
||||
}
|
||||
|
||||
// 文章TAG标签
|
||||
if (!empty($result)) {
|
||||
$typeid = isset($result['typeid']) ? $result['typeid'] : 0;
|
||||
$tags = model('Taglist')->getListByAid($aid, $typeid);
|
||||
$result['tags'] = $tags;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
47
src/application/home/model/ImagesUpload.php
Normal file
47
src/application/home/model/ImagesUpload.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 图集图片
|
||||
*/
|
||||
class ImagesUpload extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定图集的所有图片
|
||||
* @author 小虎哥 by 2018-4-3
|
||||
*/
|
||||
public function getImgUpload($aids = [], $field = '*')
|
||||
{
|
||||
$where = [];
|
||||
!empty($aids) && $where['aid'] = ['IN', $aids];
|
||||
$result = Db::name('ImagesUpload')->field($field)
|
||||
->where($where)
|
||||
->order('sort_order asc')
|
||||
->select();
|
||||
!empty($result) && $result = group_same_key($result, 'aid');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
75
src/application/home/model/Media.php
Normal file
75
src/application/home/model/Media.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 陈风任 <491085389@qq.com>
|
||||
* Date: 2019-1-7
|
||||
*/
|
||||
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Page;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 视频
|
||||
*/
|
||||
class Media extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条记录
|
||||
* @author wengxianhu by 2017-7-26
|
||||
*/
|
||||
public function getInfo($aid, $field = '', $isshowbody = true)
|
||||
{
|
||||
$data = array();
|
||||
if (!empty($field)) {
|
||||
$field_arr = explode(',', $field);
|
||||
foreach ($field_arr as $key => $val) {
|
||||
$val = trim($val);
|
||||
if (preg_match('/^([a-z]+)\./i', $val) == 0) {
|
||||
array_push($data, 'a.'.$val);
|
||||
} else {
|
||||
array_push($data, $val);
|
||||
}
|
||||
}
|
||||
$field = implode(',', $data);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
if ($isshowbody) {
|
||||
$field = !empty($field) ? $field : 'b.*, a.*';
|
||||
$result = db('archives')->field($field)
|
||||
->alias('a')
|
||||
->join('__MEDIA_CONTENT__ b', 'b.aid = a.aid', 'LEFT')
|
||||
->find($aid);
|
||||
} else {
|
||||
$field = !empty($field) ? $field : 'a.*';
|
||||
$result = db('archives')->field($field)
|
||||
->alias('a')
|
||||
->find($aid);
|
||||
}
|
||||
|
||||
// 文章TAG标签
|
||||
if (!empty($result)) {
|
||||
$typeid = isset($result['typeid']) ? $result['typeid'] : 0;
|
||||
$tags = model('Taglist')->getListByAid($aid, $typeid);
|
||||
$result['tags'] = $tags;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
91
src/application/home/model/MediaFile.php
Normal file
91
src/application/home/model/MediaFile.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 视频文件
|
||||
*/
|
||||
class MediaFile extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定下载文章的所有文件
|
||||
* @author 小虎哥 by 2018-4-3
|
||||
*/
|
||||
public function getMediaFile($aid, $field = '*')
|
||||
{
|
||||
$request = request();
|
||||
$result = Db::name('media_file')->field($field)
|
||||
->where('aid', $aid)
|
||||
->order('file_id asc')
|
||||
->select();
|
||||
foreach ($result as $key => $val) {
|
||||
if (!empty($val['file_url'])) {
|
||||
$result[$key]['file_url'] = handle_subdir_pic($val['file_url'], 'media');
|
||||
if (!is_http_url($result[$key]['file_url'])){
|
||||
$result[$key]['file_url'] = $request->domain() .$result[$key]['file_url'];
|
||||
}
|
||||
}
|
||||
if (!empty($val['file_time'])) {
|
||||
// 总秒数
|
||||
$time = intval($val['file_time']);
|
||||
// 可读时间
|
||||
$humanTime = '';
|
||||
if ($time > 3600) {// 判断小时
|
||||
$hours = intval(($time / 3600));
|
||||
$time = $time % 3600;
|
||||
if ($hours && $hours < 10) {
|
||||
$humanTime .= '0' . $hours . ':';
|
||||
} elseif ($hours && $hours > 10) {
|
||||
$humanTime .= $hours . ':';
|
||||
}
|
||||
} else {
|
||||
$humanTime .= '00:';
|
||||
}
|
||||
if ($time > 60) {// 判断分钟
|
||||
$minutes = intval(($time / 60));
|
||||
$time = $time % 60;
|
||||
if ($minutes && $minutes < 10) {
|
||||
$humanTime .= '0' . $minutes . ':';
|
||||
} elseif ($minutes && $minutes > 10) {
|
||||
$humanTime .= $minutes . ':';
|
||||
}
|
||||
} else {
|
||||
$humanTime .= '00:';
|
||||
}
|
||||
if ($time > 0) {// 判断秒钟
|
||||
$seconds = $time;
|
||||
if ($seconds && $seconds < 10) {
|
||||
$humanTime .= '0' . $seconds . '';
|
||||
} elseif ($seconds && $seconds > 10) {
|
||||
$humanTime .= $seconds . '';
|
||||
}
|
||||
} else {
|
||||
$humanTime .= '00';
|
||||
}
|
||||
$result[$key]['file_time'] = $humanTime;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
75
src/application/home/model/Product.php
Normal file
75
src/application/home/model/Product.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Page;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 产品
|
||||
*/
|
||||
class Product extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条记录
|
||||
* @author wengxianhu by 2017-7-26
|
||||
*/
|
||||
public function getInfo($aid, $field = '', $isshowbody = true)
|
||||
{
|
||||
$data = array();
|
||||
if (!empty($field)) {
|
||||
$field_arr = explode(',', $field);
|
||||
foreach ($field_arr as $key => $val) {
|
||||
$val = trim($val);
|
||||
if (preg_match('/^([a-z]+)\./i', $val) == 0) {
|
||||
array_push($data, 'a.'.$val);
|
||||
} else {
|
||||
array_push($data, $val);
|
||||
}
|
||||
}
|
||||
$field = implode(',', $data);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
if ($isshowbody) {
|
||||
$field = !empty($field) ? $field : 'b.*, a.*, a.aid as aid';
|
||||
$result = Db::name('archives')->field($field)
|
||||
->alias('a')
|
||||
->join('__PRODUCT_CONTENT__ b', 'b.aid = a.aid', 'LEFT')
|
||||
->find($aid);
|
||||
} else {
|
||||
$field = !empty($field) ? $field : 'c.*, a.*';
|
||||
$result = Db::name('archives')->field($field)
|
||||
->alias('a')
|
||||
->find($aid);
|
||||
}
|
||||
|
||||
// 文章TAG标签
|
||||
if (!empty($result)) {
|
||||
$typeid = isset($result['typeid']) ? $result['typeid'] : 0;
|
||||
$tags = model('Taglist')->getListByAid($aid, $typeid);
|
||||
$result['tags'] = $tags;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
70
src/application/home/model/ProductAttr.php
Normal file
70
src/application/home/model/ProductAttr.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 产品参数
|
||||
*/
|
||||
class ProductAttr extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定产品的所有参数
|
||||
* @author 小虎哥 by 2018-4-3
|
||||
*/
|
||||
public function getProAttr($aids = [], $field = 'b.*, a.*')
|
||||
{
|
||||
$where = [];
|
||||
!empty($aids) && $where['b.aid'] = ['IN', $aids];
|
||||
$where['a.is_del'] = 0;
|
||||
$result = Db::name('ProductAttribute')->field($field)
|
||||
->alias('a')
|
||||
->join('__PRODUCT_ATTR__ b', 'b.attr_id = a.attr_id', 'LEFT')
|
||||
->where($where)
|
||||
->order('a.sort_order asc, a.attr_id asc')
|
||||
->select();
|
||||
!empty($result) && $result = group_same_key($result, 'aid');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定产品的所有新版本参数
|
||||
* @author 小虎哥 by 2018-4-3
|
||||
*/
|
||||
public function getProAttrNew($aids = [], $field = 'b.*, a.*')
|
||||
{
|
||||
$where = [];
|
||||
!empty($aids) && $where['b.aid'] = ['IN', $aids];
|
||||
$where['a.is_del'] = 0;
|
||||
$result = Db::name('ShopProductAttribute')->field($field)
|
||||
->alias('a')
|
||||
->join('__SHOP_PRODUCT_ATTR__ b', 'b.attr_id = a.attr_id', 'LEFT')
|
||||
->where($where)
|
||||
->order('a.sort_order asc, a.attr_id asc')
|
||||
->select();
|
||||
!empty($result) && $result = group_same_key($result, 'aid');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
47
src/application/home/model/ProductImg.php
Normal file
47
src/application/home/model/ProductImg.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 产品图片
|
||||
*/
|
||||
class ProductImg extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定产品的所有图片
|
||||
* @author 小虎哥 by 2018-4-3
|
||||
*/
|
||||
public function getProImg($aids = [], $field = '*')
|
||||
{
|
||||
$where = [];
|
||||
!empty($aids) && $where['aid'] = ['IN', $aids];
|
||||
$result = Db::name('ProductImg')->field($field)
|
||||
->where($where)
|
||||
->order('sort_order asc')
|
||||
->select();
|
||||
!empty($result) && $result = group_same_key($result, 'aid');
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
75
src/application/home/model/Recruit.php
Normal file
75
src/application/home/model/Recruit.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 陈风任 <491085389@qq.com>
|
||||
* Date: 2019-1-7
|
||||
*/
|
||||
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Page;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 文章
|
||||
*/
|
||||
class Recruit extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条记录
|
||||
* @author wengxianhu by 2017-7-26
|
||||
*/
|
||||
public function getInfo($aid, $field = '', $isshowbody = true)
|
||||
{
|
||||
$data = array();
|
||||
if (!empty($field)) {
|
||||
$field_arr = explode(',', $field);
|
||||
foreach ($field_arr as $key => $val) {
|
||||
$val = trim($val);
|
||||
if (preg_match('/^([a-z]+)\./i', $val) == 0) {
|
||||
array_push($data, 'a.'.$val);
|
||||
} else {
|
||||
array_push($data, $val);
|
||||
}
|
||||
}
|
||||
$field = implode(',', $data);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
if ($isshowbody) {
|
||||
$field = !empty($field) ? $field : 'b.*, a.*';
|
||||
$result = db('archives')->field($field)
|
||||
->alias('a')
|
||||
->join('__RECRUIT_CONTENT__ b', 'b.aid = a.aid', 'LEFT')
|
||||
->find($aid);
|
||||
} else {
|
||||
$field = !empty($field) ? $field : 'a.*';
|
||||
$result = db('archives')->field($field)
|
||||
->alias('a')
|
||||
->find($aid);
|
||||
}
|
||||
|
||||
// 文章TAG标签
|
||||
if (!empty($result)) {
|
||||
$typeid = isset($result['typeid']) ? $result['typeid'] : 0;
|
||||
$tags = model('Taglist')->getListByAid($aid, $typeid);
|
||||
$result['tags'] = $tags;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
53
src/application/home/model/Single.php
Normal file
53
src/application/home/model/Single.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 简介
|
||||
*/
|
||||
class Single extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条记录
|
||||
* @author wengxianhu by 2017-7-26
|
||||
*/
|
||||
public function getInfoByTypeid($typeid)
|
||||
{
|
||||
$cacheKey = "home_model_Single_getInfoByTypeid_{$typeid}";
|
||||
$result = cache($cacheKey);
|
||||
if (empty($result)) {
|
||||
$field = 'c.*, b.*, a.*, b.aid, a.id as typeid';
|
||||
$result = M('arctype')->field($field)
|
||||
->alias('a')
|
||||
->join('__ARCHIVES__ b', 'b.typeid = a.id', 'LEFT')
|
||||
->join('__SINGLE_CONTENT__ c', 'c.aid = b.aid', 'LEFT')
|
||||
->where('b.channel', 6)
|
||||
->find($typeid);
|
||||
|
||||
cache($cacheKey, $result, null, "arctype");
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
75
src/application/home/model/Special.php
Normal file
75
src/application/home/model/Special.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Model;
|
||||
use think\Page;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 专题
|
||||
*/
|
||||
class Special extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单条记录
|
||||
* @author wengxianhu by 2017-7-26
|
||||
*/
|
||||
public function getInfo($aid, $field = '', $isshowbody = true)
|
||||
{
|
||||
$data = array();
|
||||
if (!empty($field)) {
|
||||
$field_arr = explode(',', $field);
|
||||
foreach ($field_arr as $key => $val) {
|
||||
$val = trim($val);
|
||||
if (preg_match('/^([a-z]+)\./i', $val) == 0) {
|
||||
array_push($data, 'a.'.$val);
|
||||
} else {
|
||||
array_push($data, $val);
|
||||
}
|
||||
}
|
||||
$field = implode(',', $data);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
if ($isshowbody) {
|
||||
$field = !empty($field) ? $field : 'b.*, a.*';
|
||||
$result = Db::name('archives')->field($field)
|
||||
->alias('a')
|
||||
->join('__SPECIAL_CONTENT__ b', 'b.aid = a.aid', 'LEFT')
|
||||
->find($aid);
|
||||
} else {
|
||||
$field = !empty($field) ? $field : 'a.*';
|
||||
$result = Db::name('archives')->field($field)
|
||||
->alias('a')
|
||||
->find($aid);
|
||||
}
|
||||
|
||||
// 专题TAG标签
|
||||
if (!empty($result)) {
|
||||
$typeid = isset($result['typeid']) ? $result['typeid'] : 0;
|
||||
$tags = model('Taglist')->getListByAid($aid, $typeid);
|
||||
$result['tags'] = $tags;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
44
src/application/home/model/UiConfig.php
Normal file
44
src/application/home/model/UiConfig.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 美化编辑
|
||||
*/
|
||||
class UiConfig extends Model
|
||||
{
|
||||
//初始化
|
||||
protected function initialize()
|
||||
{
|
||||
// 需要调用`Model`的`initialize`方法
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author 小虎哥 by 2018-4-3
|
||||
*/
|
||||
public function getInfo($theme_style, $page, $type, $name)
|
||||
{
|
||||
$md5key = md5($theme_style.$page.$name);
|
||||
$map = array(
|
||||
'md5key' => $md5key,
|
||||
'type' => $type,
|
||||
);
|
||||
$result = M('ui_config')->where($map)->cache(true,EYOUCMS_CACHE_TIME,"ui_config")->find();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
17
src/application/home/tags.php
Normal file
17
src/application/home/tags.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
// 应用行为扩展定义文件
|
||||
return array(
|
||||
// 模块初始化
|
||||
'module_init' => array(),
|
||||
// 操作开始执行
|
||||
'action_begin' => array(),
|
||||
// 视图内容过滤
|
||||
'view_filter' => array(
|
||||
'app\\home\\behavior\\ViewFilterBehavior',
|
||||
),
|
||||
// 日志写入
|
||||
'log_write' => array(),
|
||||
// 应用结束
|
||||
'app_end' => array(),
|
||||
);
|
||||
27
src/application/home/validate/Guestbook.php
Normal file
27
src/application/home/validate/Guestbook.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* 易优CMS
|
||||
* ============================================================================
|
||||
* 版权所有 2016-2028 海南赞赞网络科技有限公司,并保留所有权利。
|
||||
* 网站地址: http://www.eyoucms.com
|
||||
* ----------------------------------------------------------------------------
|
||||
* 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
|
||||
* ============================================================================
|
||||
* Author: 小虎哥 <1105415366@qq.com>
|
||||
* Date: 2018-4-3
|
||||
*/
|
||||
|
||||
namespace app\home\validate;
|
||||
use think\Validate;
|
||||
|
||||
class Guestbook extends Validate
|
||||
{
|
||||
// 验证规则
|
||||
protected $rule = array(
|
||||
'typeid' => 'require|token',
|
||||
);
|
||||
|
||||
protected $message = array(
|
||||
'typeid.require' => '表单缺少标签属性{$field.hidden}',
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user