nkvob.php 24 KB

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