Index.php
8.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<?php
namespace app\index\controller;
use app\api\controller\Message;
use app\common\controller\Frontend;
use think\Db;
class Index extends Frontend
{
protected $noNeedLogin = '*';
protected $noNeedRight = '*';
protected $layout = '';
public function index()
{
return $this->view->fetch();
}
//会有到期提醒 添加信息记录
public function mess()
{
$data = Db::name('user')
->field('id,identity,audit,expirationtime')
->where('identity','neq',1)
->where('audit',1)
->select();
foreach ($data as &$v){
if(time() > $v['expirationtime']){
$message = new Message();
$message->add($v['id'],'会员到期');
}else{
if(time()+86400 >= $v['expirationtime']){
$message = new Message();
$message->add($v['id'],'会员1天后到期');
}else{
if(time()+2*86400 >= $v['expirationtime']){
$message = new Message();
$message->add($v['id'],'会员2天后到期');
}else{
if (time()+3*86400 >= $v['expirationtime']){
$message = new Message();
$message->add($v['id'],'会员3天后到期');
}
}
}
}
}
}
//文件详情
public function detail()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$user_id = $this->request->param('user_id');
$file_id = $this->request->param('file_id');
$data = Db::name('savemes')
->where('id',$file_id)
->find();
if($data['type'] == 2){
$data['video'] = '';
$data['video_image'] = '';
$data['content'] = '';
$data['images'] = $qiniu.$data['images'];
}elseif ($data['type'] == 3){
$data['images'] = '';
$data['content'] = '';
$data['video'] = $qiniu.$data['video'];
// 获取视频第一帧图片
$video_info = json_decode(file_get_contents($data['video'] . '?avinfo'), true);
$data['video_image'] = $this->get_video_first_image($data['video'], $video_info);
$data_video = Db::name('open')->where('id',1)->find();
$data['switch'] = $data_video['switch'];
}elseif ($data['type'] == 1){
$data['images'] = '';
$data['video'] = '';
$data['video_image'] = '';
}
$text = Db::name('official')->where('id',1)->find();
$data['introduce'] = $text['introduce'];
$this->assign('data',$data);
return $this->fetch();
}
//文件夹详情
public function filedetail()
{
$qiniu = get_addon_config('qiniu')['cdnurl'];
$user_id = $this->request->param('user_id');
$file_id = $this->request->param('file_id');
//文件夹
$folder = Db::name('folder')
->where('pid',$file_id)
->where('is_up',1)
->select();
foreach ($folder as &$v){
$v['createtime'] = date('Y-m-d',$v['createtime']);
}
$times = array_values(array_unique(array_column($folder,'createtime')));
//将数据放到对应的时间分段
$arrs = [];
foreach ($times as $t_k=> $t_v){
$arrs[$t_k]['times'] = $t_v;
$k = 0;
foreach ($folder as $value){
$k+=0;
if($t_v == $value['createtime']){
$arrs[$t_k]['info'][$k] = $value;
$k++;
}
}
}
$data['folder'] = $arrs;
//笔记
$note['folder_id'] = ['eq',$file_id];
$note['is_up'] = ['eq',1];
$z_tiao['a.folder_id'] = ['eq',$file_id];
$z_tiao['b.is_up'] = ['eq',1];
$note = $this->myfile(1,$note);
$zhuan_note = $this->zhuan(1,$z_tiao);
$gong = $this->gong(1,$note,$zhuan_note);
$data['note'] = $this->sundry($gong);
//图片
$pic['folder_id'] = ['eq',$file_id];
$pic_tiao['a.folder_id'] = ['eq',$file_id];
$pic = $this->myfile(2,$pic);
$zhuan_pic = $this->zhuan(2,$pic_tiao);
$gong1 = $this->gong(2,$pic,$zhuan_pic);
$data['pic'] = $this->sundry($gong1);
//视频
$video['folder_id'] = ['eq',$file_id];
$video_tiao['a.folder_id'] = ['eq',$file_id];
$video = $this->myfile(3,$video);
$zhuan_video = $this->zhuan(3,$video_tiao);
$gong2 = $this->gong(3,$video,$zhuan_video);
$data['video'] = $this->sundry($gong2);
$text = Db::name('official')->where('id',1)->find();
$data['introduce'] = $text['introduce'];
$this->assign('data',$data);
return $this->fetch();
}
public function get_video_first_image($video_url,$video_info){
if(empty($video_info['streams'][0]['width'])) {
$width = $video_info['streams'][1]['width'];
$height = $video_info['streams'][1]['height'];
} else {
$width = $video_info['streams'][0]['width'];
$height = $video_info['streams'][0]['height'];
}
return $video_url.'?vframe/jpg/offset/1/w/'.$width.'/h/'.$height;
}
//通过传入类型获取我自己的不同文件
public function myfile($type,$where){
$data = Db::name('savemes')
->where($where)
->where('type',$type)
->field('id,user_id,type,name,share_url,images,video,content,is_open,is_up,createtime')
->order('createtime desc')
->select();
return $data;
}
//通过传入类型获取转存的不同文件
public function zhuan($type,$tiao){
$rotor = Db::name('rotor')
->alias('a')
->join('savemes b','a.savemes_id = b.id')
->field('a.id,a.user_id as unloading_user_id,a.savemes_id,a.folder_id,b.user_id,b.share_url,b.name,b.type,b.images,b.video,b.content,b.is_open,b.is_up,a.createtime')
->where('b.type',$type)
->where($tiao)
->order('a.createtime desc')
->select();
return $rotor;
}
//各种类型的文件 转存以及自己的文件
public function gong($type,$arr1,$arr2){
$qiniu = get_addon_config('qiniu')['cdnurl'];
if(!empty($arr2)){
foreach ($arr2 as &$v_1){
$v_1['is_zhuan'] = 1;
$v_1['is_real'] = 2;
}
$arr = array_merge($arr1,$arr2);
}else{
$arr = $arr1;
}
//笔记类型
if($type == 1){
foreach ($arr as &$v){
$v['nowtime'] = date('Y-m-d',$v['createtime']);
$v['createtime'] = date('m-d',$v['createtime']);
$v['images'] = '';
$v['video'] = '';
$v['video_image'] = '';
}
} elseif ($type == 2){
//图片类型
foreach ($arr as &$v){
$v['nowtime'] = date('Y-m-d',$v['createtime']);
$v['createtime'] = date('m-d',$v['createtime']);
$v['images'] = $qiniu.$v['images'];
$v['video'] = '';
$v['video_image'] = '';
$v['content'] = '';
}
}elseif ($type == 3){
//视频类型
foreach ($arr as &$v){
$v['nowtime'] = date('Y-m-d',$v['createtime']);
$v['createtime'] = date('m-d',$v['createtime']);
$v['video'] = $qiniu.$v['video'];
// 获取视频第一帧图片
$video_info = json_decode(file_get_contents($v['video'] . '?avinfo'), true);
$v['video_image'] = $this->get_video_first_image($v['video'], $video_info);
$v['images'] = '';
$v['content'] = '';
}
}
return $arr;
}
//合并完数据按时间分段
public function sundry($arr){
$times = array_values(array_unique(array_column($arr,'createtime')));
//将数据放到对应的时间分段
$arrs = [];
foreach ($times as $t_k=> $t_v){
$arrs[$t_k]['times'] = $t_v;
$k = 0;
foreach ($arr as $value){
$k+=0;
if($t_v == $value['createtime']){
$arrs[$t_k]['info'][$k] = $value;
$k++;
}
}
}
return $arrs;
}
}