-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzyapi.php
executable file
·253 lines (221 loc) · 8.49 KB
/
zyapi.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
<?php
/******************************
海洋CMS版权所有 www.seacms.org
功能:资源发布zyAPI模块
版本:1.0
开发:海洋
******************************/
require_once("include/common.php");
require_once("include/main.class.php");
require_once("data/config.cache.inc.php");
//判断是否开启api服务
$isopenapi=file_get_contents("data/admin/isapi.txt");
if($isopenapi=="0"){echo "服务已关闭";exit;}
$app_apipagenum=20; //每页显示条数
//接收相关参数
$action = addslashes($_GET['ac']);
$rtype = addslashes($_GET['t']);
$rpage = addslashes($_GET['pg']);
$rkey = addslashes($_GET['wd']);
$rday = addslashes($_GET['h']);
$ids =addslashes($_GET['ids']);
//判断相关参数并格式化
if (!isNum($rtype)) { $rtype=0;} else { $rtype= intval($rtype);}
if (!isNum($rpage)) { $rpage=1;} else { $rpage= intval($rpage);}
if ($rpage < 1){ $rpage=1;}
if (!isNum($rday)) { $rday=0;} else { $rday= intval($rday);}
$app_apiver="5.0";
//判断操作类型
switch($action)
{
case "videolist":
cj();
break;
default:
vlist();
break;
}
function cj()
{
global $dsql,$rtype,$rpage,$rkey,$rday,$action,$app_apiver,$app_apipagenum,$cfg_basehost,$ids;
$xmla = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
$xmla .= "<rss version=\"".$app_apiver."\">";
$sql = "select d.*,p.body as v_playdata,p.body1 as v_playdata1,t.tname from sea_data d left join `sea_type` t on t.tid=d.tid left join `sea_playdata` p on p.v_id=d.v_id where d.v_recycled=0 ";
$sql1 = "select count(*) as dd from sea_data where v_recycled=0 ";
if($ids!=""){
$ids = addslashes($ids);
$sql .= " AND d.v_id in (". $ids .")";
$sql1 .= " AND v_id in (". $ids .")";
}
if($rtype>0){
$sql .= " AND d.tid =".$rtype;
$sql1 .= " AND tid =".$rtype;
}
if($rday>0){
if (!isNum($rday)){ $rday=1; }
$whereStr=" AND d.v_addtime > UNIX_TIMESTAMP(date_sub(now(),interval ".$rday." hour)) " ;
$whereStr1=" AND v_addtime > UNIX_TIMESTAMP(date_sub(now(),interval ".$rday." hour)) " ;
$sql .= $whereStr;
$sql1 .= $whereStr1;
}
//获取页数
$row1 = $dsql->GetOne($sql1);
if(is_array($row1))
{$nums = $row1['dd'];}else{$nums = 0;}
$pagecount=ceil($nums/$app_apipagenum);
$sql = $sql ." limit ".($app_apipagenum * ($rpage-1)).",".$app_apipagenum;
$dsql->SetQuery($sql);
$dsql->Execute('video_c');
$xml .= "<list page=\"".$rpage."\" pagecount=\"".$pagecount."\" pagesize=\"".$app_apipagenum."\" recordcount=\"".$nums."\">";
while($row=$dsql->GetObject('video_c'))
{
//处理播放地址信息
if($row->v_playdata1 !=""){$allplayurl=$row->v_playdata."$$$".$row->v_playdata1;}else{$allplayurl=$row->v_playdata;}
$tempurl = getplayurl($allplayurl);
if (strpos(",".$row->v_pic,"http://")>0||strpos(",".$row->v_pic,"https://")>0) { $temppic = $row->v_pic; } elseif(strpos(",".$row->v_pic,"//")>0){ $temppic = "http:".$row->v_pic; }else { $temppic = $cfg_basehost."/".$row->v_pic; } //图片
$query = "select body from sea_content where v_id='$row->v_id' ";
$rowccc = $dsql->GetOne($query);
$ccc=$rowccc['body'];
$plink = $cfg_basehost."/detail/?".$row->v_id.".html"; //来源页面网址
$xml .= "<video>";
$xml .= "<last>".MyDate('Y-m-d H:i:s',$row->v_addtime)."</last>";
$xml .= "<id>".$row->v_id."</id>";
$xml .= "<tid>".$row->tid."</tid>";
$xml .= "<name><![CDATA[".$row->v_name."]]></name>";
$xml .= "<type>".$row->tname."</type>";
$xml .= "<pic>".$temppic."</pic>";
$xml .= "<lang>".$row->v_lang."</lang>";
$xml .= "<area>".$row->v_publisharea."</area>";
$xml .= "<year>".$row->v_publishyear."</year>";
$xml .= "<state>".$row->v_state."</state>";
$xml .= "<keywords>".$row->v_tags."</keywords>";
$xml .= "<len>".$row->v_len."</len>";
$xml .= "<total>".$row->v_total."</total>";
$xml .= "<jq>".$row->v_jq."</jq>";
$xml .= "<nickname>".$row->v_nickname."</nickname>";
$xml .= "<reweek>".$row->v_reweek."</reweek>";
$xml .= "<douban>".$row->v_douban."</douban>";
$xml .= "<mtime>".$row->v_mtime."</mtime>";
$xml .= "<imdb>".$row->v_imdb."</imdb>";
$xml .= "<tvs>".$row->v_tvs."</tvs>";
$xml .= "<company>".$row->v_company."</company>";
$xml .= "<ver>".$row->v_ver."</ver>";
$xml .= "<longtxt>".$row->v_longtxt."</longtxt>";
$xml .= "<note><![CDATA[".$row->v_note."]]></note>";
$xml .= "<actor><![CDATA[".$row->v_actor."]]></actor>";
$xml .= "<director><![CDATA[".$row->v_director."]]></director>";
$xml .= "<dl>".$tempurl."</dl>";
$xml .= "<des><![CDATA[".$ccc."]]></des>";
$xml .= "<reurl><![CDATA[".$plink."]]></reurl>";
$xml .= "</video>";
}
$xml .= "</list>";
unset($row);
$xmla .= $xml . "</rss>";
echo $xmla;
}
function vlist()
{
global $dsql,$rtype,$rpage,$rkey,$rday,$action,$app_apiver,$app_apipagenum,$cfg_basehost ;
$xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
$xml .= "<rss version=\"".$app_apiver."\">";
//视频列表开始
$sql ="select d.v_id,d.v_name,d.v_state,d.v_note,d.tid,d.v_addtime,p.body as v_playdata,p.body1 as v_playdata1,t.tname from sea_data d left join `sea_type` t on t.tid=d.tid left join `sea_playdata` p on p.v_id=d.v_id where d.v_recycled=0 ";
$sql1 = "select count(*) as dd from sea_data where v_recycled=0 ";
if ($rtype > 0) { $where .= " and d.tid=" . $rtype; $where1 .= " and tid=" . $rtype;}
if ($rkey !="") { $where .= " and d.v_name like '%".$rkey."%' "; $where1 .= " and v_name like '%".$rkey."%' "; }
$sql .= $where. " order by d.v_addtime desc";
$sql1 .= $where1;
//获取页数
$row1 = $dsql->GetOne($sql1);
if(is_array($row1)){$nums = $row1['dd'];}else{$nums = 0;}
$pagecount=ceil($nums/$app_apipagenum);
$sql = $sql ." limit ".($app_apipagenum * ($rpage-1)).",".$app_apipagenum;
$dsql->SetQuery($sql);
$dsql->Execute('video_list');
if($nums==0){
$xml .= "<list page=\"".$rpage."\" pagecount=\"0\" pagesize=\"".$app_apipagenum."\" recordcount=\"0\">";
}
else{
$xml .= "<list page=\"".$rpage."\" pagecount=\"".$pagecount."\" pagesize=\"".$app_apipagenum."\" recordcount=\"".$nums."\">";
while($row=$dsql->GetObject('video_list'))
{
$plink = $cfg_basehost."/detail/?".$row->v_id.".html"; //来源页面网址
$fromstr=getFromStr($row->v_playdata)." ".getFromStr($row->v_playdata1); //获取播放和下载组名
$xml .= "<video>";
$xml .= "<last>".MyDate('Y-m-d H:i:s',$row->v_addtime)."</last>";
$xml .= "<id>".$row->v_id."</id>";
$xml .= "<tid>".$row->tid."</tid>";
$xml .= "<name><![CDATA[".$row->v_name."]]></name>";
$xml .= "<type>".$row->tname."</type>";
$xml .= "<dt>".$fromstr."</dt>";
$xml .= "<note><![CDATA[".$row->v_note."]]></note>";
$xml .= "<reurl><![CDATA[".$plink."]]></reurl>";
$xml .= "</video>";
}
}
unset($row);
$xml .= "</list>";
//视频列表结束
//分类列表开始
$xml .= "<class>";
$sqltype = "select * from sea_type where tptype=0 ";
$dsql->SetQuery($sqltype);
$dsql->Execute('video_type');
while($rowtype=$dsql->GetObject('video_type'))
{
$xml .= "<ty id=\"". $rowtype->tid."\">". $rowtype->tname."</ty>";
}
unset($rowtype);
$xml .= "</class>";
//分类列表结束
$xml .= "</rss>";
echo $xml;
}
function getplayurl($urls)
{
$urls=str_replace('$','|*|',$urls);
$arr1 = explode("|*||*||*|",$urls);
$zzt=count($arr1);
$playerKindsfile="data/admin/playerKinds.xml";
$xml = simplexml_load_file($playerKindsfile);
if(!$xml){$xml = simplexml_load_string(file_get_contents($playerKindsfile));}
$z=array();
foreach($xml as $player){
$k=$player['flag'];
$z["$k"]=$player['postfix'];
}
foreach ($arr1 as $v){
$arr2=explode("|*||*|",$v);
for($i=0;$i<$zzt;$i++)
{
if($arr2['0']=='下载地址' or $arr2['0']=='下载地址一' or $arr2['0']=='下载地址二' or $arr2['0']=='下载地址三' or $arr2['0']=='下载地址四' or $arr2['0']=='下载地址五'){$flag= "down";}
else
{
$f=$arr2['0'];
$flag=$z["$f"];
}
}
$str = $str . "<dd flag=\"". $flag ."\"><![CDATA[" . $arr2['1']. "]]></dd>";
}
$str=str_replace('|*|','$',$str);
return $str;
}
function isnum($varnum){
$string_var = "0123456789";
$len_string = strlen($varnum);
if(substr($varnum,0,1)=="0"){
return false;
die();
}else{
for($i=0;$i<$len_string;$i++){
$checkint = strpos($string_var,substr($varnum,$i,1));
if($checkint===false){
return false;
die();
}
}
return true;
}
}
?>