lezhutv.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <?php
  2. header("Content-Type: text/html; charset=UTF-8");
  3. libxml_use_internal_errors(true);
  4. //建议php版本7 开启curl扩展
  5. $typeid =$_GET["t"];
  6. $page = $_GET["pg"];
  7. $ids = $_GET["ids"];
  8. $burl = $_GET["url"];
  9. $wd = $_GET["wd"];
  10. //通用模板要修改的东西只有:$web=网站链接 $movietype=影视分类 $url1=影视详情链接文本左 $url2=影视详情链接文本右
  11. //通用模板要修改的东西只有:$liebiao=影视列表链接 $num=影视列表单页多少个 $detail=影视详情链接
  12. //===============================================基础配置开始===========================================
  13. $web='http://www.lezhutv.com';
  14. //1=开启搜索 0=关闭搜索 默认关闭搜索(极品有验证码 开启无效,搜索框架仅供参考)
  15. $searchable=1;
  16. //====================以下内容可忽略不修改===================
  17. //1=curl访问 2=file_get_contents 真不卡用curl被屏蔽了,所以改为2. //$gettype仅在此模板有效(其他模板未添加这个设置) //如遇其他网站出现类似的【电脑可以访问,但是php打不开】也可以尝试用此模板
  18. $gettype=1;
  19. //$gettype=1时设置cookie有效,如不懂可以不填写(针对奈菲这样子的,就需要写入cookie才能访问)
  20. $cookie='';
  21. //当影视详情没有影视图片或取图片失败时,返回该指定的图片链接(不设置的话,缺图时历史记录的主图会空白)
  22. $historyimg='';
  23. //模拟ua 如非不要默认即可
  24. $UserAgent='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36';
  25. //1=开启直链分析 0=关闭直链分析 (直链也是通过本php页面解析) 测试极品关闭直链 大部分能通过webview解析
  26. //该模板的直链代码是针对极品影视的,每个站的直链代码都不同。其他网站请设置为0关闭
  27. $zhilian=0;
  28. //QQ iqiyi youku的VIP解析 没用直链的话,$vip设置无效
  29. $vip='https://jxapp.jpysvip.net/m3u8.php?url=';
  30. //====================以上内容可忽略不修改===================
  31. //===============================================基础配置结束===========================================
  32. //===============================================广告图片配置开始 可以不用修改=======================================
  33. //$adable=1开启广告 $adable=0关闭广告图片 可插入指定图片到每次读取第一页影视列表的开头,默认关闭
  34. $adable=0;
  35. $adpicurl='';
  36. $adtitle1='我是片名';
  37. $adtitle2='我是更新内容';
  38. //===============================================广告图片配置结束 可以不用修改============================================
  39. //===============================================影视分类相关配置开始===========================
  40. //例如 国产剧链接:https://www.jpysvip.net/vodshow/13-----------.html 那国产剧ID就等于13
  41. //例如 电影链接:https://www.jpysvip.net/vodtype/1.html 那电影ID就等于1
  42. //电影 连续剧 关键词中间要用1个空格隔开,否则无法显示
  43. $movietype = '{"class":[{"type_id":1,"type_name":"电影"},{"type_id":2,"type_name":"电视剧"},{"type_id":3,"type_name":"综艺"},{"type_id":4,"type_name":"动漫"},{"type_id":14,"type_name":"韩剧"},{"type_id":15,"type_name":"美剧"}]}';
  44. //支持类目ID非数字,type_id按照正常顺序排列 把catname写进去.注意$liebiao也要填写正确
  45. //$movietype ='{"class":[{"type_id":1,"type_name":"全部动漫","catname":"all-all-all-all-all-time-{pageid}"},{"type_id":2,"type_name":"日漫","catname":"all-all-all-all-all-time-{pageid}-日本-all-all"},{"type_id":3,"type_name":"国漫","catname":"all-all-all-all-all-time-{pageid}-中国-all-all"},{"type_id":4,"type_name":"欧美动漫","catname":"all-all-all-all-all-time-{pageid}-欧美-all-all"}]}';
  46. //===============================================影视分类相关配置结束===========================
  47. //===============================================影视列表相关配置开始===========================
  48. //=====================苹果CMS通用模板修改以下内容即可=============================
  49. //取出影片ID的文本左边
  50. $url1='/detail/';
  51. //取出影片ID的文本右边
  52. $url2='.html';
  53. //影视列表链接 {pageid}=页码 {typeid}=类目ID 如果$movietype的catname不为空的话,{typeid}会被自动替换为相应的catname内容
  54. $liebiao='http://www.lezhutv.com/type/{typeid}-{pageid}.html';
  55. //每页多少个影片
  56. $num=72;
  57. //=====================苹果CMS通用模板修改以上内容即可=============================
  58. //xpath列表
  59. $query="//ul[@class='tbox_m2']/li/a";
  60. //取出影片的图片
  61. $picAttr="//ul[@class='tbox_m2']/li/a/@data-original";
  62. //取出影片的图片 优先取$picAttr $picAttr无结果的话,从$picAttr2取
  63. //如果会xpath的话,只需设置$picAttr的即可
  64. $picAttr2="";
  65. //取出影片的标题
  66. $titleAttr="//ul[@class='tbox_m2']/li/a/@title";
  67. //取出影片的链接
  68. $linkAttr="//ul[@class='tbox_m2']/li/a/@href";
  69. //影视更新情况 例如:更新至*集
  70. $query2 = "//ul[@class='tbox_m2']/li/a/span/text()";
  71. //影视更新情况 例如:更新至*集 优先取$query2 $query2无结果的话,从$query3取
  72. //如果会xpath的话,只需设置$query2的即可
  73. $query3 = "";
  74. //===============================================影视列表相关配置结束===========================
  75. //===============================================影视详情相关配置开始===========================
  76. //=====================苹果CMS通用模板修改以下内容即可=============================
  77. //影片链接 {vodid}=影片ID
  78. $detail='http://www.lezhutv.com/detail/{vodid}.html';
  79. //=====================苹果CMS通用模板修改以上内容即可=============================
  80. //影片名称
  81. $vodtitle="//div[@class='data']/h4/text()[1]";
  82. //影片类型
  83. $vodtype="//p[@class='yac']/text()";
  84. //取出影片图片 猫的详情图片显示在历史记录里(历史记录图片没有的话,就是这个没取对)
  85. $vodimg="//div[contains(@class,'img')]/@data-original";
  86. //取出影片简介
  87. $vodtext="//div[@class='tbox_js']/text()";
  88. //取出影片年份
  89. $vodyear="";
  90. //取出影片主演
  91. $vodactor="//p[@class='act']/text()";
  92. //取出影片导演
  93. $voddirector="//p[@class='dir']/text()";
  94. //取出影片地区
  95. $vodarea="";
  96. //播放地址名称 //div[contains(@class,'-panel__head') and contains(@class, 'clearfix')]/ul/li/a
  97. //为了通用性,没有取出播放源名称,会xpath的可以自己填写进去 例子如上
  98. $playname="//div[@class='tbox_t']/h3";
  99. //播放地址 自动往下级尝试查找5次并取链接 如第二次就找到链接,就会从第二个下级中获取
  100. //$playurl="//div[@class='dbox']/following-sibling::div[1]";
  101. $playurl="//div[@class='tbox2 tabs'][1]";
  102. //取出影片的全部播放链接 链接标识一般为href,不用修改
  103. $linkAttr5="href";
  104. //===============================================影视详情相关配置结束===========================
  105. //===============================================影视搜索相关配置开始===========================
  106. //=========下面把xpath规则的搜索屏蔽了,极品采用json的搜索结果========
  107. //影片搜索返回结果 1=htm代码套用xpath规则 2=json结果
  108. $searchtype=1;
  109. //$searchtype=2;
  110. //影片搜索 {wd}=搜索文字
  111. //$searchtype=1的网址
  112. $search=$web.'/index.php?m=vod-search&wd={wd}';
  113. //$searchtype=2的网址
  114. //$search='https://www.jpysvip.net/index.php/ajax/suggest?mid=1&wd={wd}&limit=10';
  115. //通用模板 $web=前面设置的网址
  116. //$search=$web.'/index.php/ajax/suggest?mid=1&wd={wd}&limit=10';
  117. //htm代码分析用xpath取影片,取出影片ID的文本左边
  118. $searchurl1='/detail/';
  119. //$searchurl1='';
  120. //htm代码分析用xpath取影片,取出影片ID的文本右边
  121. $searchurl2='.html';
  122. //json直接返回影片ID,不用取值
  123. //$searchurl2='';
  124. //xpath列表
  125. $searchquery='//ul[@class="tbox_m"]/li/a';
  126. //json路径
  127. //$searchquery='list';
  128. //xpath规则取出影片的标题
  129. $searchtitleAttr='//ul[@class="tbox_m"]/li/a/@title';
  130. //json取影片标题
  131. //$searchtitleAttr='name';
  132. //xpath规则取出影片的链接
  133. $searchlinkAttr='//ul[@class="tbox_m"]/li/a/@href';
  134. //json取出影片的ID
  135. //$searchlinkAttr='id';
  136. //xpath规则取影视更新情况 例如:更新至*集
  137. $searchquery2 = '//ul[@class="tbox_m"]/li/a/span/text()';
  138. //json取影视更新情况 极品没有更新情况,所以留空
  139. //$searchquery2 ='';
  140. //===============================================影视搜索相关配置结束===========================
  141. //==============================================仅需修改以上代码↑=======================================
  142. //==============================================以下内容的代码无需修改↓=======================================
  143. $weburl='http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
  144. if ($typeid<> null && $page<>null){
  145. //==============================================读取影视列表开始=======================================
  146. $catname ='';
  147. $arr=json_decode($movietype,true);
  148. $arr_q1a=$arr['class'];
  149. $m=count($arr_q1a);
  150. for($i=0;$i<$m;$i++){
  151. $type_id = $arr_q1a[$i]["type_id"];
  152. if($typeid==$type_id){
  153. $catname = $arr_q1a[$i]["catname"];
  154. break;
  155. }
  156. }
  157. if($catname==null){
  158. $liebiao=str_replace("{typeid}",$typeid,$liebiao);
  159. }else{
  160. $liebiao=str_replace("{typeid}",$catname,$liebiao);
  161. }
  162. $liebiao=str_replace("{pageid}",$page,$liebiao);
  163. $html = curl_get($liebiao,$gettype,$cookie);
  164. $dom = new DOMDocument();
  165. $html= mb_convert_encoding($html ,'HTML-ENTITIES',"UTF-8");
  166. $dom->loadHTML($html);
  167. $dom->normalize();
  168. $xpath = new DOMXPath($dom);
  169. $texts = $xpath->query($query2);
  170. if($texts->length==0 && $query3<>null){
  171. $texts = $xpath->query($query3);
  172. }
  173. $events = $xpath->query($query);
  174. $picevents = $xpath->query($picAttr);
  175. if ($picevents->length==0 && $picAttr2<>null){
  176. $picevents = $xpath->query($picAttr2);
  177. }
  178. $titleevents= $xpath->query($titleAttr);
  179. $linkevents= $xpath->query($linkAttr);
  180. $length=$events->length;
  181. $guolv='';
  182. if ($adable==1 && $page==1){
  183. $length=$length+1;
  184. }
  185. if ($length<$num)
  186. {
  187. $page2=$page;
  188. }else{
  189. $length=$length+1;
  190. $page2=$page + 1;
  191. }
  192. $result='{"code":1,"page":'.$page.',"pagecount":'. $page2 .',"total":'. $length.',"list":[';
  193. if ($adable==1 && $page==1){
  194. $result=$result.'{"vod_id":1,"vod_name":"'.$adtitle1.'","vod_pic":"'.$adpicurl.'","vod_remarks":"'.$adtitle2.'"},';
  195. }
  196. for ($i = 0; $i < $events->length; $i++) {
  197. $event = $events->item($i);
  198. $text = $texts->item($i)->nodeValue;
  199. $text = replacestr($text);
  200. $link = $linkevents->item($i)->nodeValue;
  201. $title = $titleevents->item($i)->nodeValue;
  202. $title = replacestr($title);
  203. $pic = $picevents->item($i)->nodeValue;
  204. if($url1<>null){
  205. $link2 =getSubstr($link,$url1,$url2);
  206. }else{
  207. $link2 =$link;
  208. }
  209. if (substr($pic,0,2)=='//'){
  210. $pic = 'http:'.$pic;
  211. }else if (substr($pic,0,4)<>'http' && $pic<>null){
  212. $pic = $web.$pic;
  213. }
  214. if($guolv==null){
  215. $result=$result.'{"vod_id":"'.$link2.'","vod_name":"'.$title.'","vod_pic":"'.$pic.'","vod_remarks":"'.$text.'"},';
  216. $guolv=$guolv."{".$link2."}";
  217. }else if(strpos($guolv, "{".$link2."}")==0){
  218. $result=$result.'{"vod_id":"'.$link2.'","vod_name":"'.$title.'","vod_pic":"'.$pic.'","vod_remarks":"'.$text.'"},';
  219. $guolv=$guolv."{".$link2."}";
  220. }
  221. }
  222. $result=substr($result, 0, strlen($result)-1).']}';
  223. echo $result;
  224. //==============================================读取影视列表结束=======================================
  225. }else if ($ids<> null){
  226. //==============================================读取影视信息开始=======================================
  227. $detail=str_replace("{vodid}",$ids,$detail);
  228. $html = curl_get($detail,$gettype,$cookie);
  229. $dom = new DOMDocument();
  230. $html= mb_convert_encoding($html ,'HTML-ENTITIES',"UTF-8");
  231. $dom->loadHTML($html);
  232. $dom->normalize();
  233. $xpath = new DOMXPath($dom);
  234. if($vodtitle<>null){
  235. $texts = $xpath->query($vodtitle);
  236. $text = $texts->item(0)->nodeValue;
  237. $text = replacestr($text);
  238. }
  239. if($vodtype<>null){
  240. $texts = $xpath->query($vodtype);
  241. $type = $texts->item(0)->nodeValue;
  242. $type = replacestr($type);
  243. }
  244. if($vodtext<>null){
  245. $texts = $xpath->query($vodtext);
  246. $vodtext2 = $texts->item(0)->nodeValue;
  247. $vodtext2 = replacestr($vodtext2);
  248. }
  249. if($vodyear<>null){
  250. $texts = $xpath->query($vodyear);
  251. $year = $texts->item(0)->nodeValue;
  252. $year = replacestr($year);
  253. }
  254. if($vodimg<>null){
  255. $texts = $xpath->query($vodimg);
  256. $img = $texts->item(0)->nodeValue;
  257. if (substr($img,0,2)=='//'){
  258. $img = 'http:'.$img;
  259. }else if (substr($img,0,4)<>'http' && $img<>null){
  260. $img = $web.$img;
  261. }
  262. }
  263. if($img==null){
  264. $img =$historyimg;
  265. }
  266. if($vodarea<>null){
  267. $texts = $xpath->query($vodarea);
  268. $area = $texts->item(0)->nodeValue;
  269. $area = replacestr($area);
  270. }
  271. if($vodactor<>null){
  272. $texts = $xpath->query($vodactor);
  273. $actor ='';
  274. for ($i = 0; $i < $texts->length; $i++) {
  275. $event1 = $texts->item($i);
  276. $actor = $actor.$event1->nodeValue.' ';
  277. }
  278. }
  279. if($voddirector<>null){
  280. $texts = $xpath->query($voddirector);
  281. $director ='';
  282. for ($i = 0; $i < $texts->length; $i++) {
  283. $event1 = $texts->item($i);
  284. $director = $director.$event1->nodeValue.' ';
  285. }
  286. }
  287. $result='{"list":[{"vod_id":"'.$ids.'",';
  288. if($text<>null){
  289. $result=$result.'"vod_name":"'.$text.'",';
  290. }
  291. if($text==null){
  292. $result=$result.'"vod_name":"'."片名获取失败".'",';
  293. }
  294. if($img<>null){
  295. $result=$result.'"vod_pic":"'.$img.'",';
  296. }
  297. if($type<>null){
  298. $result=$result.'"type_name":"'.$type.'",';
  299. }
  300. if($year<>null){
  301. $result=$result.'"vod_year":"'.$year.'",';
  302. }
  303. if($actor<>null){
  304. $result=$result.'"vod_actor":"'.$actor.'",';
  305. }
  306. if($director<>null){
  307. $result=$result.'"vod_director":"'.$director.'",';
  308. }
  309. if($area<>null){
  310. $result=$result.'"vod_area":"'.$area.'",';
  311. }
  312. if($vodtext2<>null){
  313. $vodtext2=str_replace('"','\"',$vodtext2);
  314. $result=$result.'"vod_content":"'.$vodtext2.'",';
  315. }
  316. $yuan = '';
  317. $dizhi = '';
  318. $text1 = $xpath->query($playname);
  319. $text2 = $xpath->query($playurl);
  320. if($text2->length==0){
  321. $result= $result.'"vod_play_from":"'."原页面".'",';
  322. $result= $result.'"vod_play_url":"'.$detail.'"}]}';
  323. }else{
  324. if($playname<>null){
  325. for ($i = 0; $i < $text2->length; $i++) {
  326. $event1 = $text1->item($i);
  327. $bfyuan = $event1->nodeValue;
  328. $bfyuan = replacestr($bfyuan);
  329. $yuan = $yuan.$bfyuan.'$$$';
  330. }
  331. }
  332. if($yuan==''){
  333. for ($i = 0; $i < $text2->length; $i++) {
  334. $bfyuan =$i+1;
  335. $yuan = $yuan."播放源".$bfyuan.'$$$';
  336. }
  337. }
  338. foreach ($text2 as $oObject) {
  339. $dizhi2 = '';
  340. foreach($oObject->childNodes as $col){
  341. if ($col->hasChildNodes()){
  342. $link4 = $col->getAttribute($linkAttr5);
  343. if($link4<>null){
  344. $text4 = $col->nodeValue;
  345. $text4 = replacestr($text4);
  346. if (substr($link4,0,4)<>'http' && $link4<>null){
  347. $link4 = $web.$link4;
  348. }
  349. if($zhilian==1){
  350. $dizhi2 = $dizhi2.$text4.'$'.$weburl.'?url='.$link4.'#';
  351. }else{
  352. $dizhi2 = $dizhi2.$text4.'$'.$link4.'#';
  353. }
  354. }else{
  355. foreach($col->childNodes as $col2){
  356. if ($col2->hasChildNodes()){
  357. $link4 = $col2->getAttribute($linkAttr5);
  358. if($link4<>null){
  359. $text4 = $col2->nodeValue;
  360. $text4 = replacestr($text4);
  361. if (substr($link4,0,4)<>'http' && $link4<>null){
  362. $link4 = $web.$link4;
  363. }
  364. if($zhilian==1){
  365. $dizhi2 = $dizhi2.$text4.'$'.$weburl.'?url='.$link4.'#';
  366. }else{
  367. $dizhi2 = $dizhi2.$text4.'$'.$link4.'#';
  368. }
  369. }else{
  370. foreach($col2->childNodes as $col3){
  371. if ($col3->hasChildNodes()){
  372. $link4 = $col3->getAttribute($linkAttr5);
  373. if($link4<>null){
  374. $text4 = $col3->nodeValue;
  375. $text4 = replacestr($text4);
  376. if (substr($link4,0,4)<>'http' && $link4<>null){
  377. $link4 = $web.$link4;
  378. }
  379. if($zhilian==1){
  380. $dizhi2 = $dizhi2.$text4.'$'.$weburl.'?url='.$link4.'#';
  381. }else{
  382. $dizhi2 = $dizhi2.$text4.'$'.$link4.'#';
  383. }
  384. }else{
  385. foreach($col3->childNodes as $col4){
  386. if ($col4->hasChildNodes()){
  387. $link4 = $col4->getAttribute($linkAttr5);
  388. if($link4<>null){
  389. $text4 = $col4->nodeValue;
  390. $text4 = replacestr($text4);
  391. if (substr($link4,0,4)<>'http' && $link4<>null){
  392. $link4 = $web.$link4;
  393. }
  394. if($zhilian==1){
  395. $dizhi2 = $dizhi2.$text4.'$'.$weburl.'?url='.$link4.'#';
  396. }else{
  397. $dizhi2 = $dizhi2.$text4.'$'.$link4.'#';
  398. }
  399. }else{
  400. foreach($col4->childNodes as $col5){
  401. if ($col5->hasChildNodes()){
  402. $link4 = $col5->getAttribute($linkAttr5);
  403. if($link4<>null){
  404. $text4 = $col5->nodeValue;
  405. $text4 = replacestr($text4);
  406. if (substr($link4,0,4)<>'http' && $link4<>null){
  407. $link4 = $web.$link4;
  408. }
  409. if($zhilian==1){
  410. $dizhi2 = $dizhi2.$text4.'$'.$weburl.'?url='.$link4.'#';
  411. }else{
  412. $dizhi2 = $dizhi2.$text4.'$'.$link4.'#';
  413. }}}}}}}}}}}}}}}}
  414. if($dizhi2==null){
  415. $dizhi=$dizhi.'无播放地址 请更换其他源$http'.'$$$';
  416. }else{
  417. $dizhi=$dizhi.substr($dizhi2, 0, strlen($dizhi2)-1).'$$$';
  418. }
  419. }
  420. $result= $result.'"vod_play_from":"'.substr($yuan, 0, strlen($yuan)-3).'",';
  421. $result= $result.'"vod_play_url":"'.substr($dizhi, 0, strlen($dizhi)-3).'"}]}';
  422. }
  423. echo $result;
  424. //==============================================读取影视信息结束=======================================
  425. }else if ($burl<> null){
  426. //=============================以下是直链分析代码=======================================================
  427. $html = curl_get($burl,$gettype,$cookie);
  428. $content=getSubstr($html,'var player','</script>');
  429. $content=getSubstr($content,'"url":"','",');
  430. $content=str_replace("\/","/",$content);
  431. if(strpos($content,"qq.com")>0 or strpos($content,"youku.com")>0 or strpos($content,"iqiyi.com")>0 or strpos($content,"mgtv.com")>0){
  432. $content=$vip.$content;
  433. }
  434. echo '<iframe src="'.$content.'" class="iframeStyle" id="myiframe" ></iframe>';
  435. //==============================以上是直链分析代码=======================================================
  436. }else if ($wd<> null){
  437. //=============================以下是搜索代码=======================================================
  438. if($searchable==0){
  439. echo 'php中未开启搜索';
  440. exit;
  441. }
  442. if($page==null){
  443. $page=1;
  444. }
  445. $geturl =str_replace("{wd}",urlencode($wd),$search);
  446. $geturl =str_replace("{page}",$page,$geturl);
  447. $html = curl_get($geturl,$gettype,$cookie);
  448. if($searchtype==1){
  449. $dom = new DOMDocument();
  450. $html= mb_convert_encoding($html ,'HTML-ENTITIES',"UTF-8");
  451. $dom->loadHTML($html);
  452. $dom->normalize();
  453. $xpath = new DOMXPath($dom);
  454. $texts = $xpath->query($searchquery2);
  455. $events = $xpath->query($searchquery);
  456. $titleevents= $xpath->query($searchtitleAttr);
  457. $linkevents= $xpath->query($searchlinkAttr);
  458. $length=$events->length;
  459. $result='{"code":1,"page":'.$page.',"pagecount":'. $page.',"total":'. $length.',"list":[';
  460. for ($i = 0; $i < $events->length; $i++) {
  461. $event = $events->item($i);
  462. $text = $texts->item($i)->nodeValue;
  463. $link = $linkevents->item($i)->nodeValue;
  464. $title = $titleevents->item($i)->nodeValue;
  465. if($searchurl1<>null){
  466. $link2 =getSubstr($link,$searchurl1,$searchurl2);
  467. }else{
  468. $link2 =$link;
  469. }
  470. $result=$result.'{"vod_id":'.$link2.',"vod_name":"'.$title.'","vod_remarks":"'.$text.'"},';
  471. }
  472. $result=substr($result, 0, strlen($result)-1).']}';
  473. echo $result;
  474. }else{
  475. $arr=json_decode($html,true);
  476. $arr_q1a=$arr[$searchquery];
  477. $m=count($arr_q1a);
  478. $result='{"code":1,"page":'.$page.',"pagecount":'. $page.',"total":'. $m.',"list":[';
  479. for($i=0;$i<$m;$i++){
  480. $title = $arr_q1a[$i][$searchtitleAttr];
  481. $link = $arr_q1a[$i][$searchlinkAttr];
  482. if($searchquery2<>null){
  483. $text = $arr_q1a[$i][$searchquery2];
  484. $result=$result.'{"vod_id":'.$link.',"vod_name":"'.$title.'","vod_remarks":"'.$text.'"},';
  485. }else{
  486. $result=$result.'{"vod_id":'.$link.',"vod_name":"'.$title.'"},';
  487. }
  488. }
  489. $result=substr($result, 0, strlen($result)-1).']}';
  490. echo $result;
  491. }
  492. //==============================以上是搜索代码=======================================================
  493. }else{
  494. echo $movietype;
  495. }
  496. function curl_get($url,$gettype2,$cookie2){
  497. // $header = array(
  498. // 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36',
  499. //);
  500. if($gettype2==2){
  501. $data = file_get_contents($url);
  502. return $data;
  503. }else{
  504. $curl = curl_init();
  505. curl_setopt($curl, CURLOPT_URL, $url);
  506. curl_setopt($curl, CURLOPT_HEADER, 0);
  507. curl_setopt($curl, CURLOPT_TIMEOUT, 20);
  508. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  509. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  510. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  511. curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
  512. if($cookie2<>null){
  513. curl_setopt($curl, CURLOPT_COOKIE, $cookie2);
  514. }
  515. $ip=Rand_IP();
  516. curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:'.$ip, 'CLIENT-IP:'.$ip));
  517. $data = curl_exec($curl);
  518. if (curl_error($curl)) {
  519. return "Error: ".curl_error($curl);
  520. } else {
  521. curl_close($curl);
  522. return $data;
  523. }
  524. }
  525. }
  526. function Rand_IP(){
  527. $ip2id= round(rand(600000, 2550000) / 10000);
  528. $ip3id= round(rand(600000, 2550000) / 10000);
  529. $ip4id= round(rand(600000, 2550000) / 10000);
  530. $arr_1 = array("218","218","66","66","218","218","60","60","202","204","66","66","66","59","61","60","222","221","66","59","60","60","66","218","218","62","63","64","66","66","122","211");
  531. $randarr= mt_rand(0,count($arr_1)-1);
  532. $ip1id = $arr_1[$randarr];
  533. return $ip1id.".".$ip2id.".".$ip3id.".".$ip4id;
  534. }
  535. function getSubstr($str, $leftStr, $rightStr)
  536. {
  537. if($leftStr<>null && $rightStr<>null){
  538. $left = strpos($str, $leftStr);
  539. $right = strpos($str, $rightStr,$left+strlen($left));
  540. if($left < 0 or $right < $left){
  541. return '';
  542. }
  543. return substr($str, $left + strlen($leftStr),$right-$left-strlen($leftStr));
  544. }else{
  545. $str2=$str;
  546. if($leftStr<>null){
  547. $str2=str_replace($leftStr,'',$str2);
  548. }
  549. if($rightStr<>null){
  550. $str2=str_replace($rightStr,'',$str2);
  551. }
  552. return $str2;
  553. }
  554. }
  555. function replacestr($str2){
  556. $test2=$str2;
  557. $test2=str_replace(" ","",$test2);
  558. $test2=str_replace(" ","",$test2);
  559. $test2 = preg_replace('/\s*/', '', $test2);
  560. return $test2;
  561. }
  562. ?>