3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php //include_once 'curl.php'; class my_vod{ private $t; //私有成员,输出的视频地址,是数组,在使用前必须调用get_html_vod 或者get_db_vod来初始化它 public $url; //公用成员,要采集的网址; private function get_html_vod(){ $html=file_get_contents($this->url); $html = iconv("gbk", "UTF-8", $html); $pat = "/<a(.*?)href=\"(.*?)\"(.*?)>(.*?MP4)<\/a>/i"; //$pat = "/<a(.*?)href=\"(.*?)\"(.*?)>(.*?".$w.")<\/a>/i"; preg_match_all($pat, $html, $tmp); $this->t=$tmp[2]; } private function get_db_vod(){ include 'conn.php'; $row=mysql_query('select url from vod_zp order by id desc',$con); while ($arr=mysql_fetch_array($row)){ $this->t[]=$arr[0]; } } private function insert_db($t){ include 'conn.php'; $t1=urlencode($t); $qry=mysql_query("select url from vod_zp where url='$t'",$con); if (mysql_num_rows($qry)<1){ mysql_query("insert into vod_zp(url,urlen,createtime) values('$t','$t1',now())",$con); } } function download_all(){ $this->get_html_vod(); //初始化成员T的内容; $ssh_name=date("His").".ssh"; $ssh_path="/usr/local/nginx/html/file/".$ssh_name; $f=fopen($ssh_path,"w"); fwrite ($f,"#!/bin/sh"); fwrite ($f,"\n"); for ($i=0;$i<sizeof($this->t);$i++) { $t=$this->t[$i]; //$t=str_replace('cn2.dvd9.me','192.168.1.221',$t); if (!file_exists("/usr/local/nginx/html/file/".md5($t).".MP4")) { fwrite ($f,"wget '$t' -O /usr/local/nginx/html/file/".md5($t).".MP4"); fwrite ($f,"\n"); } } fwrite($f,"rm -f ".$ssh_path); fclose($f); // exec("chmod 711 $ssh_path"); // exec($ssh_path); } function echo_vod($sleep=1,$db=1){ if ($db===1){ $this->get_db_vod(); }else{ $this->get_html_vod(); } $i=0; for ($i=0;$i<sizeof($this->t);$i++){ $i=$i++; $ar=$this->t[$i]; $this->insert_db($ar); echo $i.":".$ar; if ($sleep===1){ $md5file="/file/".md5($ar).".MP4"; echo "<a href=http://$_SERVER[HTTP_HOST]$md5file>播放</a>"; }else{ echo "<a href=\"$ar\">播放</a>"; } echo " || "; echo "<a href=http://$_SERVER[HTTP_HOST]/tools/curl.php?url=$ar>缓存到服务器</a>"; echo "<br>"; } } } $obj=new my_vod(); $obj->url="http://free.yoyokiss.com/vod/"; if ($_GET[db]){ if ($_GET[sleep]){ $obj->echo_vod(1,1); }else{ $obj->echo_vod(0,1); } }else{ if ($_GET[sleep]){ $obj->echo_vod(1,0); }else if ($_GET[c]){ $obj->download_all(); }else{ $obj->echo_vod(0,0); } } ?>
Output for 5.3.0 - 5.5.34, 5.6.0 - 5.6.20, 5.6.28 - 7.0.5, 7.0.14 - 7.1.0
Notice: Use of undefined constant db - assumed 'db' in /in/3fNGv on line 76 Notice: Undefined index: db in /in/3fNGv on line 76 Notice: Use of undefined constant sleep - assumed 'sleep' in /in/3fNGv on line 83 Notice: Undefined index: sleep in /in/3fNGv on line 83 Notice: Use of undefined constant c - assumed 'c' in /in/3fNGv on line 85 Notice: Undefined index: c in /in/3fNGv on line 85 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/3fNGv on line 7 Warning: file_get_contents(http://free.yoyokiss.com/vod/): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/3fNGv on line 7
Output for 7.0.6 - 7.0.10
Notice: Use of undefined constant db - assumed 'db' in /in/3fNGv on line 76 Notice: Undefined index: db in /in/3fNGv on line 76 Notice: Use of undefined constant sleep - assumed 'sleep' in /in/3fNGv on line 83 Notice: Undefined index: sleep in /in/3fNGv on line 83 Notice: Use of undefined constant c - assumed 'c' in /in/3fNGv on line 85 Notice: Undefined index: c in /in/3fNGv on line 85 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/3fNGv on line 7 Warning: file_get_contents(http://free.yoyokiss.com/vod/): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/3fNGv on line 7 Fatal error: Uncaught Error: Call to undefined function iconv() in /in/3fNGv:8 Stack trace: #0 /in/3fNGv(53): my_vod->get_html_vod() #1 /in/3fNGv(88): my_vod->echo_vod(0, 0) #2 {main} thrown in /in/3fNGv on line 8
Process exited with code 255.
Output for 5.5.35 - 5.5.38, 5.6.21 - 5.6.25
Notice: Use of undefined constant db - assumed 'db' in /in/3fNGv on line 76 Notice: Undefined index: db in /in/3fNGv on line 76 Notice: Use of undefined constant sleep - assumed 'sleep' in /in/3fNGv on line 83 Notice: Undefined index: sleep in /in/3fNGv on line 83 Notice: Use of undefined constant c - assumed 'c' in /in/3fNGv on line 85 Notice: Undefined index: c in /in/3fNGv on line 85 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/3fNGv on line 7 Warning: file_get_contents(http://free.yoyokiss.com/vod/): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/3fNGv on line 7 Fatal error: Call to undefined function iconv() in /in/3fNGv on line 8
Process exited with code 255.
Output for 5.2.6 - 5.2.17
Notice: Use of undefined constant db - assumed 'db' in /in/3fNGv on line 76 Notice: Undefined index: db in /in/3fNGv on line 76 Notice: Use of undefined constant sleep - assumed 'sleep' in /in/3fNGv on line 83 Notice: Undefined index: sleep in /in/3fNGv on line 83 Notice: Use of undefined constant c - assumed 'c' in /in/3fNGv on line 85 Notice: Undefined index: c in /in/3fNGv on line 85 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/3fNGv on line 7 Warning: file_get_contents(http://free.yoyokiss.com/vod/): failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/3fNGv on line 7
Output for 5.0.3 - 5.2.5
Notice: Use of undefined constant db - assumed 'db' in /in/3fNGv on line 76 Notice: Undefined index: db in /in/3fNGv on line 76 Notice: Use of undefined constant sleep - assumed 'sleep' in /in/3fNGv on line 83 Notice: Undefined index: sleep in /in/3fNGv on line 83 Notice: Use of undefined constant c - assumed 'c' in /in/3fNGv on line 85 Notice: Undefined index: c in /in/3fNGv on line 85 Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /in/3fNGv on line 7 Warning: file_get_contents(http://free.yoyokiss.com/vod/): failed to open stream: Connection refused in /in/3fNGv on line 7
Output for 5.0.1 - 5.0.2
Notice: Use of undefined constant db - assumed 'db' in /in/3fNGv on line 76 Notice: Undefined index: db in /in/3fNGv on line 76 Notice: Use of undefined constant sleep - assumed 'sleep' in /in/3fNGv on line 83 Notice: Undefined index: sleep in /in/3fNGv on line 83 Notice: Use of undefined constant c - assumed 'c' in /in/3fNGv on line 85 Notice: Undefined index: c in /in/3fNGv on line 85 Warning: file_get_contents(): php_network_getaddresses: gethostbyname failed in /in/3fNGv on line 7 Warning: file_get_contents(http://free.yoyokiss.com/vod/): failed to open stream: Success in /in/3fNGv on line 7
Output for 5.0.0
Notice: Use of undefined constant db - assumed 'db' in /in/3fNGv on line 76 Notice: Undefined index: db in /in/3fNGv on line 76 Notice: Use of undefined constant sleep - assumed 'sleep' in /in/3fNGv on line 83 Notice: Undefined index: sleep in /in/3fNGv on line 83 Notice: Use of undefined constant c - assumed 'c' in /in/3fNGv on line 85 Notice: Undefined index: c in /in/3fNGv on line 85 Warning: file_get_contents(): php_network_getaddresses: gethostbyname failed in /in/3fNGv on line 7 Warning: file_get_contents(http://free.yoyokiss.com/vod/): failed to open stream: Bad file descriptor in /in/3fNGv on line 7
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/3fNGv on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/3fNGv on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/3fNGv on line 4
Process exited with code 255.