-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
watch.php
151 lines (131 loc) · 6.46 KB
/
watch.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
<?php
include('./lib.php');
if(!is_array($_GET)&&count($_GET)>0){
exit();
}
$videodata=get_video_info($_GET['v'],APIKEY);
$headtitle=$videodata['items']['0']['snippet']['title'].' - '.SITE_NAME;
include("./header.php");
if($videodata['pageInfo']['totalResults'] == '0' && $videodata['pageInfo']['resultsPerPage']== '0'){
header("Location: ./error.php");
exit();
}
//记录历史浏览观看记录
$tt=time()+1814400;
if(!isset($_COOKIE['history'])){
setcookie("history",$videodata['items']['0']['id'], $tt);
}else{
$history=$_COOKIE['history'];
$histmp=explode('@',$history);
//重复的浏览历史只记录最新一次
if (in_array($videodata['items']['0']['id'] ,$histmp)){
$akey=array_search($videodata['items']['0']['id'],$histmp);
unset($histmp[$akey]);
array_unshift($histmp,$videodata['items']['0']['id']);
}else{
array_unshift($histmp,$videodata['items']['0']['id']);
}
//最大观看记录条数,超出的删除
if(count($histmp)==30){
array_pop($histmp);
}
//防止cookies字节溢出
if(count($histmp)==40){
$histmp=array_slice($histmp,20);
}
$histmp1=implode('@',$histmp);
setcookie('history',$histmp1, $tt);
}
?>
<div class="container container-top">
<div class="row">
<div class="col-md-8 col-sm-12 col-xs-12 col-lg-8 leffix">
<div id="videoplayer" class="w-100">
<?php html5_player($videodata['items']['0']['id']);?>
</div>
<div class="vinfo fsize2 clearfix">
<h1 class="fsize1 pt-4 pb-2 d-block text-dark"><?php echo $videodata['items']['0']['snippet']['title'] ?></h1>
<span class="pull-left"><i class="fa fa-clock-o"></i> <?php echo str2time($videodata['items']['0']['snippet']['publishedAt']) ?></span>
<span class="pull-right"><i class="fa fa-eye"></i> <?php echo convertviewCount($videodata['items']['0']['statistics']['viewCount']) ?></span>
<div class="pt-3" style="clear: both;">
<p id="des"><?php
if(!empty($videodata['items']['0']['snippet']['description'])){
preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $videodata['items']['0']['snippet']['description'], $match);
$description=$videodata['items']['0']['snippet']['description'];
foreach ($match[0] as $v) {
$k='<a href="./link.php?u='.strencode($v,EN2DEKEY).'" target="_blank">'. $v.'</a>';
$description=str_replace($v,$k,$description);
}
echo $description;
} else {
echo '这个人很懒,简介都不写....';
};
?>
</p>
<div id="gradient"></div>
<div id="read-more"></div>
</div>
<span class="pull-left ">类别<a href="./content.php?cont=category&sortid=<?php echo $videodata['items']['0']['snippet']['categoryId']?>" class="pl-2 d-inline" target="_blank"><?php echo categorieslist($videodata['items']['0']['snippet']['categoryId'])?></a>
</span>
<span class="pull-right">
<span id="fxs" data-toggle="popover" title="分享" data-html="true" data-placement="left" data-content="<?php echo shareit($videodata['items']['0']['id'],$videodata['items']['0']['snippet']['title']);?>">
<i class="fa fa-share-square-o pr-1"></i>分享
</span>
<span class="pr-1">
<a href="./content.php?cont=video&v=<?php echo $videodata['items']['0']['id'] ?>" target="_blank" class="fsize2"><i class="fa fa-share-square-o pr-1"></i>下载</a>
</span>
</span>
</div>
<div id="accdiv" class="px-3 py-2 mt-2 fsize2 clearfix ">
<span class="d-inline-block pull-left ">
<a href="./channel.php?channelid=<?php echo $videodata['items']['0']['snippet']['channelId'] ?>"> <img src="./thumbnail.php?type=photo&vid=<?php echo $videodata['items']['0']['snippet']['channelId']?>" id="touxiang"></a>
<a href="./channel.php?channelid=<?php echo $videodata['items']['0']['snippet']['channelId'] ?>" title="<?php echo $videodata['items']['0']['snippet']['channelTitle'] ?>" id="touaianga" class="text-dark">
<?php echo $videodata['items']['0']['snippet']['channelTitle'] ?></a>
</span>
<a href="./channel.php?channelid=<?php echo $videodata['items']['0']['snippet']['channelId'] ?>" class="btn btn-sm btn-c pull-right fsize2 my-1"><p class="text-primary m-0 px-2">主页</p></a>
</div>
<div id="tags" class="w-100 pb-2 vinfo">
<?php
foreach ($videodata['items'][0]['snippet']['tags'] as $v) {
echo '<span><a href="./search.php?q='.$v.'" target="_blank">'.$v.'</a></span>';
}?>
</div></div>
<div class="col-md-4 col-sm-12 col-xs-12 col-lg-4 related">
<div class="font-weight-bold h6 pb-1">相关内容</div>
<div id="videocontent"></div>
<script>$("#videocontent").load('<?php echo './ajax/ajax.php?v='.$_GET['v'].'&type=related'?>');</script>
</div>
</div>
</div>
<script>
$(function(){
var slideHeight = 60; // px
var defHeight = $('#des').height();
if(defHeight >= slideHeight){
$('#des').css('height' , slideHeight + 'px');
$('#read-more').append('<i class="fa d-inline fa-lg fa-caret-down"></i>');
$('#read-more').click(function(){
var curHeight = $('#des').height();
if(curHeight == slideHeight){
$('#des').animate({
height: defHeight
}, "normal");
$('#read-more').html('<i class="fa d-inline fa-caret-up fa-lg">');
$('#gradient').fadeOut();
}else{
$('#des').animate({
height: slideHeight
}, "normal");
$('#read-more').html('<i class="fa d-inline fa-lg fa-caret-down"></i>');
$('#gradient').fadeIn();
}
return false;
});
}
});
videojs('h5player').videoJsResolutionSwitcher();
$(function () {$('[data-toggle="popover"]').popover()});
</script>
<?php
include("./footer.php");
?>