-
Notifications
You must be signed in to change notification settings - Fork 0
/
movie.php
514 lines (484 loc) · 18.7 KB
/
movie.php
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
<!DOCTYPE HTML>
<html>
<head runat="server">
<meta charset="utf-8">
<title>微视频采购</title>
<?php date_default_timezone_set("Asia/Shanghai");?>
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/movie.js"></script>
<link rel="stylesheet" type="text/css" href="css/base.css" />
<link rel="stylesheet" type="text/css" href="css/movie.css" />
</head>
<style type="text/css">
body {
text-align:center;
background:#333 repeat 0px 1px;
}
.zzsc:hover img{ opacity:0.9;filter:alpha(opacity=50);-webkit-transition:all 0.2s linear;-moz-transition:all 0.2s linear;-ms-transition:all 0.2s linear;-o-transition:all 0.2s linear;transition:all 0.2s linear;}
.zzsc li:hover img{ opacity:1;-webkit-transition:all 0.2s linear;-moz-transition:all 0.2s linear;-ms-transition:all 0.2s linear;-o-transition:all 0.2s linear;transition:all 0.2s linear;}
</style>
<body>
<?php
session_start();
include "common/checkLog.php";
?>
<!--登录-->
<?php
if(!(isset($_SESSION['islogin']) && $_SESSION['islogin'] = true))
{
include "login.php";
//include "siteview.php";
}else{
include "LoginSuccess.php";
//include "userview.php";
};
?>
<!--登录-->
<br/><br/>
<div id="layout">
<?php
include "common/table1.php"; //索引标题栏
include('lib/connect.php'); //数据库连接文件
/*获取视频排序的参照字段START****/
//$field = "id";
$field = "is_on_shelf";
if (isset($_GET['field'])) {
$field = $_GET['field'];
}
/*获取视频排序的参照字段END*****/
/**获取筛选时所需要的参数START**/
$arr = array(
"type_id" => 0,
"dur" => 0,
"year" => 0
);
if (isset($_POST['videotype']) OR isset($_POST['videotype']) OR isset($_POST['videotype'])){
if (isset($_POST['videotype'])) {
$arr["type_id"] = $_POST['videotype'];
}
if (isset($_POST['dur'])) {
$arr["dur"] = $_POST['dur'];
}
if (isset($_POST['year'])) {
$arr["year"] = $_POST['year'];
}
}
else{
if (isset($_GET['videotype'])) {
$arr["type_id"] = $_GET['videotype'];
}
if (isset($_GET['dur'])) {
$arr["dur"] = $_GET['dur'];
}
if (isset($_GET['year'])) {
$arr["year"] = $_GET['year'];
}
}
/**if (isset($_GET['videotype'])) {
$arr["type_id"] = $_GET['videotype'];
}
if (isset($_GET['dur'])) {
$arr["dur"] = $_GET['dur'];
}
if (isset($_GET['year'])) {
$arr["year"] = $_GET['year'];
}
$arr = array(
"type_id" => 0,
"dur" => 0,
"year" => 0
);
if (isset($_POST['videotype'])) {
$arr["type_id"] = $_POST['videotype'];
}
if (isset($_POST['dur'])) {
$arr["dur"] = $_POST['dur'];
}
if (isset($_POST['year'])) {
$arr["year"] = $_POST['year'];
}**/
/**获取筛选时所需要的参数END**/
?>
<div>
<div style=" width:800px; height:80px; margin:0 auto; clear:both;border-radius: 2px;" class="search">
<br/>
<form action="searchList.php" method="get">
<input style="width:730px" type="text" name="keyWord" placeholder="输入名称查询" class="searchBlock"/>
<input type="submit" value="搜索" class="searchButton"/>
</form>
</div>
<div style="background-color:#FFFFFF; width:970px; height:260px; margin:0 auto; clear:both; border-radius: 2px;" >
<div style=" width:970px; height:230px; margin:0 auto;">
<br/>
<form id="form1" method="post" action="movie.php" runat="server">
<ul class="select">
<li class="select-list">
<dl id="select1">
<dt>视频类型:</dt>
<?php
$videotype = array('全部','微电影','微纪录','微栏目','微动漫','创意视频','信息视频');
foreach ($videotype as $key => $value) {
$class = array();
if ($key == 0) {
$class[] = "select-all";
}
if ($key == intval($arr['type_id'])) {
$class[] = "selected";
}
$class = implode(" ", $class);
echo <<<DD
<dd class="$class"><span tag="$key">$value</span></dd>
DD;
}
?>
<!--dd class="select-all selected"><span tag="0">全部</span></dd>
<dd><span tag="1">微电影</span></dd>
<dd><span tag="2">微纪录</span></dd>
<dd><span tag="3">微栏目</span></dd>
<dd><span tag="4">微动漫</span></dd>
<dd><span tag="5">创意视频</span></dd>
<dd><span tag="6">信息视频</span></dd-->
</dl>
</li>
<li class="select-list">
<dl id="select2">
<dt>视频时长:</dt>
<?php
$videodur = array(
"0" => "全部",
"300" => "5分钟内",
"900" => "5-15",
"1800" => "15-30",
"1801" => "30分钟以上"
);
foreach ($videodur as $key => $value) {
$class = array();
if ($key == 0) {
$class[] = "select-all";
}
if ($key == $arr['dur']) {
$class[] = "selected";
}
$class = implode(" ", $class);
echo <<<DD
<dd class="$class"><span tag="$key">$value</span></dd>
DD;
}
?>
<!--dd class="select-all selected"><span tag="0">全部</span></dd>
<dd><span tag="300">5分钟内</span></dd>
<dd><span tag="900">5-15</span></dd>
<dd><span tag="1800">15-30</span></dd>
<dd><span tag="1801">30分钟以上</span></dd-->
</dl>
</li>
<li class="select-list">
<dl id="select3">
<dt>上映时间:</dt>
<?php
$videoyear = array(
"0" => "全部",
"2014" => "2014",
"2013" => "2013",
"2012" => "2012",
"2011" => "其他"
);
foreach ($videoyear as $key => $value) {
$class = array();
if ($key == 0) {
$class[] = "select-all";
}
if ($key == $arr['year']) {
$class[] = "selected";
}
$class = implode(" ", $class);
echo <<<DD
<dd class="$class"><span tag="$key">$value</span></dd>
DD;
}
?>
<!--dd class="select-all selected"><span tag="0">全部</span></dd>
<dd><span tag="2014">2014</span></dd>
<dd><span tag="2013">2013</span></dd>
<dd><span tag="2012">2012</span></dd>
<dd><span tag="2011">其他</span></dd-->
</dl>
</li>
<li class="select-result">
<dl>
<dt>已选条件:</dt>
<?php
$isset = 0;
foreach ($arr as $key => $value) {
if ($value != 0) {
switch ($key) {
case 'type_id':
echo <<<DD
<dd class="selected" id="selectA"><span tag="$value">{$videotype[$value]}</span></dd>
DD;
break;
case 'dur':
echo <<<DD
<dd class="selected" id="selectB"><span tag="$value">{$videodur[$value]}</span></dd>
DD;
break;
case 'year':
echo <<<DD
<dd class="selected" id="selectC"><span tag="$value">{$videoyear[$value]}</span></dd>
DD;
break;
}
} else {
if ((++$isset) == 3) {
echo <<<DD
<dd class="select-no">暂时没有选择过滤条件</dd>
DD;
}
}
}
?>
<!--dd class="selected" id="selectB"><span tag="300">5分钟内</span></dd>
<dd class="select-no">暂时没有选择过滤条件</dd-->
</dl>
</li>
</ul>
<div><input type="submit" id="submit" style=" float:right" class="filterButton" value="提交筛选" /></div>
<?php
echo <<<HIDDEN
<input type="hidden" id="type" name="videotype" value="{$arr['type_id']}" />
<input type="hidden" id="dur" name="dur" value="{$arr['dur']}" />
<input type="hidden" id="year" name="year" value="{$arr['year']}" />
HIDDEN;
?>
</form>
</div>
</div>
<div style="height:15px;"></div>
<div style=" background-color:#FFFFFF; width:970px; height:1300px; margin:0 auto; clear:both; border-radius: 2px;" >
<!--选项卡开始-->
<div class="navList">
<ul>
<?php
$fieldArr = array(
//"id" => "最近更新",
"is_on_shelf" => "最近更新",
//"playNum" => "采购排行",
"playNum" => "观看排行",
"year" => "最新上映"
);
foreach ($fieldArr as $key => $value) {
$class = "navTitle";
if ($key == $field) {
$class = "selected";
}
else {
$class = "navTitle";
}
echo <<<LI
<li><a class="$class" href="movie.php?field=$key">$value</a></li>
LI;
}
?>
</ul>
</div>
<!--选项卡结束-->
<?php
/**根据筛选选项值,生成MySQL操作的condition**/
$tmp = array();
/*foreach ($arr as $key => $value) {
if ($value != 0) {
$tmp[] = "video.$key=$value";
}
}*/
function sec2time($sec){
$sec = round($sec/60);
if ($sec >= 60){
$hour = floor($sec/60);
$min = $sec%60;
$res = $hour.'小时';
$min != 0 && $res .= $min.'分';
}else{
$res = $sec.'分钟';
}
return $res;
}
if($arr["type_id"]!=0){
$tmp[0] ="video.type_id =".$arr["type_id"];
}
if($arr["dur"]!=0){
switch ($arr["dur"]) {
case '300': $tmp[1] ="video.dur < 300";
break;
case '900': $tmp[1] ="video.dur between 301 AND 900";
break;
case '1800': $tmp[1] ="video.dur between 901 AND 1800";
break;
case '1801': $tmp[1] ="video.dur >1800";
break;
default: $tmp[1] ="";
break;}
}
if($arr["year"]!=0){
switch ($arr["year"]) {
case '2014': $tmp[2] ="video.year = 2014";
break;
case '2013': $tmp[2] ="video.year = 2013";
break;
case '2012': $tmp[2] ="video.year = 2012";
break;
case '2011': $tmp[2] ="video.year <= 2011 or video.year is NULL";
break;
default: $tmp[2] ="";
break; }
//$tmp[2] ="year =".$arr[year];
}
$condition = implode(' and ', $tmp);
if (!$condition) {
$condition = 1;
}
$Page_size=20; //每页显示的条目数
$sql="select * from video where $condition";
// print_r($sql);
$result=mysql_query($sql);
//$row=mysql_fetch_array($result);
//print_r($row);
$count = mysql_num_rows($result);
$page_count = ceil($count/$Page_size); //总显示页数
if($page_count<=0){$page_count=1;}
$init=1;
$page_len=7;
$max_p=$page_count;
$pages=$page_count;
//判断当前页码
if (empty($_GET['page'])||$_GET['page']<1) {
$page=1;
} else {
$page=$_GET['page'];
}
$offset=$Page_size*($page-1);
if($field == "playNum"){
/*$sql="SELECT * FROM video LEFT JOIN video_view_statistics
ON video.id = video_view_statistics.video_id
where $condition
ORDER BY video_view_statistics.view_total DESC
limit $offset,$Page_size";
*/
$sql="SELECT `video_view_statistics`.`video_id`,`video_view_statistics`.`type_id`,count(`video_view_statistics`.`video_id`)
AS `view_total`,`video`.* from `video_view_statistics`,`video` where `video`.`id`=`video_view_statistics`.`video_id`
group by `video_view_statistics`.`video_id` ORDER BY count(`video_view_statistics`.`video_id`) DESC,`video`.`id` DESC
limit $offset,$Page_size";
}
else{
$sql="select * from video where $condition
group by title_cn
ORDER BY `$field` DESC,`id` DESC
limit $offset,$Page_size";
}
$result=mysql_query($sql);
//显示视频图片及名称列表List START
while ($row=mysql_fetch_array($result)) { ?>
<div style="width:200px; height:160px; margin:50px 20px 5px 22px; float:left; border-radius: 5px;" class="zzsc">
<div style="margin:0px auto;">
<a href="movieDetail.php?id=<?php echo $row['id']?>&typeId=<?php echo $row['type_id']?>">
<?php
/*是否存在id.jpg的文件
若存在$poster = $row['id'].".jpg"
否则 $poster = 0.jpg*/
$file = $config['posterH'].$row['id'].".jpg";
if(file_exists($file)){
$poster = $row['id'].".jpg";
//echo $poster;
//exit;
}
else{
$poster = "0.jpg";
//echo $poster;
//exit;
}
if(mb_strlen($row['stars'],'utf8')>13){
$stars=mb_substr($row['stars'],0,11,'utf-8')."...";
}else{
$stars= $row['stars'];
}
if(strlen($row['tags'])>25){
$tags=mb_substr($row['tags'],0,15,'utf-8')."...";
}else{
$tags= $row['tags'];
}
if($row['dur']){
$sec = $row['dur'];
$min = sec2time($sec);
}
?>
<center><img src="<?php echo $config['posterH'];echo $poster;?>" width="170px" height="120px" /></center>
</a>
</div>
<div style="width:200px; margin:0px auto;">
<a href="movieDetail.php?id=<?php echo $row['id']?>&typeId=<?php echo $row['type_id']?>">
<p align="center" class="black14"><?php echo mb_substr($row['title_cn'],0,14,'utf-8');?></p></a>
<a href="movieDetail.php?id=<?php echo $row['id']?>&typeId=<?php echo $row['type_id']?>">
<p align="center" class="stars">主演:<?php echo $stars; ?></p></a>
<p align="center" class="stars">时长:<?php echo $min ?></p></a>
<p align="center" class="black12"><?php echo $tags; ?></p>
</div>
</div>
<?php } ?>
<!--List END-->
<?php
$sql="select count(*) AS total from video";
$result=$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$total=$row['total'];
$page_len = ($page_len%2)?$page_len:$pagelen+1;//页码个数
$pageoffset = ($page_len-1)/2;//页码个数左右偏移量
$key='</br><div class="page">';
$key.="<span>$page/$pages </span> "; //第几页,共几页
if($page!=1){
$key.="<a href=\"".$_SERVER['PHP_SELF']."?page=1&field=".$field."&videotype=".$arr["type_id"]."&dur=".$arr["dur"]."&year=".$arr["year"]."\"><span> 第一页 </span></a> "; //第一页
$key.="<a href=\"".$_SERVER['PHP_SELF']."?page=".($page-1)."&field=".$field."&videotype=".$arr["type_id"]."&dur=".$arr["dur"]."&year=".$arr["year"]."\"><span> 上一页 </span></a>"; //上一页
}
else {
$key.=" 第一页 ";//第一页
$key.=" 上一页 "; //上一页
}
if($pages>$page_len){
//如果当前页小于等于左偏移
if($page<=$pageoffset){
$init=1;
$max_p = $page_len;
}
else{//如果当前页大于左偏移
//如果当前页码右偏移超出最大分页数
if($page+$pageoffset>=$pages+1){
$init = $pages-$page_len+1;
}
else{
//左右偏移都存在时的计算
$init = $page-$pageoffset;
$max_p = $page+$pageoffset;
}
}
}
for($i=$init;$i<=$max_p;$i++){
if($i==$page){
$key.=' <span class="currentPage">'.$i.'</span>';
}
else {
$key.=" <a href=\"".$_SERVER['PHP_SELF']."?page=".$i."&field=".$field."&videotype=".$arr["type_id"]."&dur=".$arr["dur"]."&year=".$arr["year"]."\"><span class='notCurPage'>".$i."</span></a>";
}
}
if($page!=$pages){
$key.="<a href=\"".$_SERVER['PHP_SELF']."?page=".($page+1)."&field=".$field."&videotype=".$arr["type_id"]."&dur=".$arr["dur"]."&year=".$arr["year"]."\"> 下一页 </a> ";//下一页
$key.="<a href=\"".$_SERVER['PHP_SELF']."?page={$pages}&field=".$field."&videotype=".$arr["type_id"]."&dur=".$arr["dur"]."&year=".$arr["year"]."\"> 最后一页 </a>(共 $total 部)"; //最后一页
}else {
$key.=" 下一页 ";//下一页
$key.=" 最后一页 (共 $total 部)"; //最后一页
}
$key.='</div>';
?>
<div class="page" style="margin:50px auto"><?php echo $key?></div>
</div>
</div>
<?php
require('common/footer.php');
?>