Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion application/api/controller/Vod.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public function get_detail(Request $request)
}

$res = Db::table('mac_vod')->where(['vod_id' => $param['vod_id']])->select();

// 返回
return json([
'code' => 1,
Expand Down
7 changes: 6 additions & 1 deletion application/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ function slog($logs)
{
$ymd = date('Y-m-d-H');
$now = date('Y-m-d H:i:s');
$toppath = "./log/$ymd.txt";
$log_dir = "./log/";
// 自动创建日志目录
if (!is_dir($log_dir)) {
@mkdir($log_dir, 0755, true);
}
$toppath = $log_dir . $ymd . ".txt";
$ts = @fopen($toppath,"a+");
@fputs($ts, $now .' '. $logs ."\r\n");
@fclose($ts);
Expand Down
108 changes: 108 additions & 0 deletions application/common/model/Ulog.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,114 @@ public function listData($where,$order,$page=1,$limit=20,$start=0)
return ['code'=>1,'msg'=>lang('data_list'),'page'=>$page,'pagecount'=>ceil($total/$limit),'limit'=>$limit,'total'=>$total,'list'=>$list];
}

public function listData_new($where,$order,$offset=0,$limit=20)
{
$offset = $offset > 0 ? (int)$offset : 0;
$limit = $limit ? (int)$limit : 20;

if(!is_array($where)){
$where = json_decode($where,true);
}
$limit_str = $offset .",".$limit;
$total = $this->where($where)->count();
$list = Db::name('Ulog')->where($where)->order($order)->limit($limit_str)->select();

$user_ids=[];
foreach($list as $k=>&$v){
if($v['user_id'] >0){
$user_ids[$v['user_id']] = $v['user_id'];
}

if($v['ulog_mid']==1){
$vod_info = model('Vod')->infoData(['vod_id'=>['eq',$v['ulog_rid']]],'*',1);

if($v['ulog_sid']>0 && $v['ulog_nid']>0){
if($v['ulog_type']==5){
$vod_info['info']['link'] = mac_url_vod_down($vod_info['info'],['sid'=>$v['ulog_sid'],'nid'=>$v['ulog_nid']]);
}
else{
$vod_info['info']['link'] = mac_url_vod_play($vod_info['info'],['sid'=>$v['ulog_sid'],'nid'=>$v['ulog_nid']]);
}
}
else{
$vod_info['info']['link'] = mac_url_vod_detail($vod_info['info']);
}
$v['data'] = [
'id'=>$vod_info['info']['vod_id'],
'name'=>$vod_info['info']['vod_name'],
'pic'=>mac_url_img($vod_info['info']['vod_pic']),
'link'=>$vod_info['info']['link'],
'type'=>[
'type_id'=>$vod_info['info']['type']['type_id'],
'type_name'=>$vod_info['info']['type']['type_name'],
'link'=>mac_url_type($vod_info['info']['type']),
],

];
}
elseif($v['ulog_mid']==2){
$art_info = model('Art')->infoData(['art_id'=>['eq',$v['ulog_rid']]],'*',1);
$art_info['info']['link'] = mac_url_art_detail($art_info['info']);
$v['data'] = [
'id'=>$art_info['info']['art_id'],
'name'=>$art_info['info']['art_name'],
'pic'=>mac_url_img($art_info['info']['art_pic']),
'link'=>$art_info['info']['link'],
'type'=>[
'type_id'=>$art_info['info']['type']['type_id'],
'type_name'=>$art_info['info']['type']['type_name'],
'link'=>mac_url_type($art_info['info']['type']),
],

];
}
elseif($v['ulog_mid']==3){
$topic_info = model('Topic')->infoData(['topic_id'=>['eq',$v['ulog_rid']]],'*',1);
$topic_info['info']['link'] = mac_url_topic_detail($topic_info['info']);
$v['data'] = [
'id'=>$topic_info['info']['topic_id'],
'name'=>$topic_info['info']['topic_name'],
'pic'=>mac_url_img($topic_info['info']['topic_pic']),
'link'=>$topic_info['info']['link'],
'type'=>[],
];
}
elseif($v['ulog_mid']==8){
$actor_info = model('Actor')->infoData(['actor_id'=>['eq',$v['ulog_rid']]],'*',1);
$actor_info['info']['link'] = mac_url_actor_detail($actor_info['info']);
$v['data'] = [
'id'=>$actor_info['info']['actor_id'],
'name'=>$actor_info['info']['actor_name'],
'pic'=>mac_url_img($actor_info['info']['actor_pic']),
'link'=>$actor_info['info']['link'],
'type'=>[],
];
}
}

if(!empty($user_ids)){
$where2=[];
$where['user_id'] = ['in', $user_ids];
$order='user_id desc';
$user_list = model('User')->listData($where2,$order,1,999);
$user_list = mac_array_rekey($user_list['list'],'user_id');

foreach($list as $k=>&$v){
$list[$k]['user_name'] = $user_list[$v['user_id']]['user_name'];
}
}
return [
'code' => 1,
'msg' => '获取成功',
'info' => [
'offset' => $offset,
'limit' => $limit,
'total' => $total,
'rows' => $list,
],
] ;
//return ['code'=>1,'msg'=>lang('data_list'),'page'=>$page,'pagecount'=>ceil($total/$limit),'limit'=>$limit,'total'=>$total,'list'=>$list];
}
public function infoData($where,$field='*')
{
if(empty($where) || !is_array($where)){
Expand Down
30 changes: 30 additions & 0 deletions application/common/validate/Ajax.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
namespace app\common\validate;
use think\Validate;

class Ajax extends Validate
{
protected $rule = [
'type_id' => 'number|between:1,' . PHP_INT_MAX,
'vod_id' => 'require|number|between:0,' . PHP_INT_MAX,
'id' => 'number|between:0,' . PHP_INT_MAX,
'offset' => 'number|between:0,' . PHP_INT_MAX,
'limit' => 'number|between:1,500',
'orderby' => 'in:hits,up,pubdate,hits_week,hits_month,hits_day,score',
'vod_letter' => 'max:1',
'vod_name' => 'max:50',
'vod_tag' => 'max:20',
'vod_blurb' => 'max:20',
'vod_class' => 'max:10',
// year,area,class
'type_id_1' => 'require|number|between:0,' . PHP_INT_MAX,
];

protected $message = [

];

protected $scene = [

];
}
10 changes: 10 additions & 0 deletions application/common/validate/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class Comment extends Validate
'comment_content' => 'require',
'comment_mid' => 'require',
'comment_rid' => 'require',
'offset' => 'number|between:0,' . PHP_INT_MAX,
'limit' => 'number|between:1,' . PHP_INT_MAX,
'rid' => 'number|between:1,' . PHP_INT_MAX,
'orderby' => 'in:time,up,down'
];

protected $message = [
Expand All @@ -21,5 +25,11 @@ class Comment extends Validate
protected $scene = [
'add'=> ['comment_name','comment_content','comment_mid','comment_rid'],
'edit'=> ['comment_name','comment_content'],
'get_list' => [
'offset',
'limit',
'rid',
'orderby',
],
];
}
4 changes: 4 additions & 0 deletions application/common/validate/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class Type extends Validate
{
protected $rule = [
'type_id' => 'number|between:1,' . PHP_INT_MAX,
'type_name' => 'require',

];
Expand All @@ -14,6 +15,9 @@ class Type extends Validate
];

protected $scene = [
'get_list' => [
'type_id',
],
'add'=> ['type_name'],
'edit'=> ['type_name'],
];
Expand Down
26 changes: 26 additions & 0 deletions application/common/validate/Vod.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ class Vod extends Validate
protected $rule = [
'vod_name' => 'require',
'type_id' => 'require',
'type_id' => 'number|between:1,' . PHP_INT_MAX,
'vod_id' => 'require|number|between:0,' . PHP_INT_MAX,
'id' => 'number|between:0,' . PHP_INT_MAX,
'offset' => 'number|between:0,' . PHP_INT_MAX,
'limit' => 'number|between:1,500',
'orderby' => 'in:hits,up,pubdate,hits_week,hits_month,hits_day,score',
'vod_letter' => 'max:1',
'vod_name' => 'max:50',
'vod_tag' => 'max:20',
'vod_blurb' => 'max:20',
'vod_class' => 'max:10',
];

protected $message = [
Expand All @@ -17,6 +28,21 @@ class Vod extends Validate
protected $scene = [
'add' => ['vod_name','type_id'],
'edit' => ['vod_name','type_id'],
'get_vod_list' => [
'id',
'offset',
'limit',
'orderby',
'type_id',
'vod_letter',
'vod_name',
'vod_tag',
'vod_blurb',
'vod_class',
],
'get_vod_detail' => [
'vod_id',
],
];


Expand Down
4 changes: 2 additions & 2 deletions application/index/controller/Ajax.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace app\index\controller;


use think\Db;
use think\Request;
class Ajax extends Base
{
var $_param;
Expand Down
Loading