Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP]Kolejny błąd skryptu mp3
Forum PHP.pl > Forum > Przedszkole
Vays
Mam problem mam skrypt do pobierania mp3 z YT i kiedy już chce go użyc wyskakuje mi taki błąd.
  1. Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set in /home/u387243255/public_html/curl.php on line 93
Kshyhoo
Cytat(Vays @ 5.06.2015, 20:12:50 ) *
Mam problem mam skrypt do pobierania mp3 z YT i kiedy już chce go użyc wyskakuje mi taki błąd.
  1. Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set in /home/u387243255/public_html/curl.php on line 93

Masz błąd w 93 linii skryptu smile.gif
Vays
Cytat(Kshyhoo @ 5.06.2015, 20:17:51 ) *
Masz błąd w 93 linii skryptu smile.gif

To już sam wiem biggrin.gif a możesz mi pomóc i powiedzieć jak go naprawić? nerdsmiley.png
Kshyhoo
A kod gdzie?
Vays
Cytat(Kshyhoo @ 5.06.2015, 20:22:49 ) *
A kod gdzie?

Juś podaje spokojnie ;3
  1. <?php
  2. /*******************************************************************************
  3.  * CURL Class
  4.  ***************************************************************************
    ****
  5.  * Author: Vikas Patial
  6.  * Email: admin@ngcoders.com
  7.  * Website: <a href="http://www.ngcoders.com" target="_blank">http://www.ngcoders.com</a>
  8.  *
  9.  * File: curl.php
  10.  * Version: 1.0.0
  11.  * Copyright: (c) 2008 - Vikas Patial
  12.  * You are free to use, distribute, and modify this software
  13.  * under the terms of the GNU General Public License. See the
  14.  * included license.txt file.
  15.  *
  16.  ***************************************************************************
    ****
  17.  * VERION HISTORY:
  18.  *
  19.  * v1.1.0 [1.1.2010] - Streaming and getSize Added
  20.  * v1.0.0 [18.9.2008] - Initial Version
  21.  *
  22.  ***************************************************************************
    ****
  23.  * DESCRIPTION:
  24.  *
  25.  * NOTE: See www.ngcoders.com for the most recent version of this script
  26.  * and its usage.
  27.  *
  28.  ***************************************************************************
    ****
  29. */
  30.  
  31. class Curl {
  32. var $callback = false;
  33. var $secure = false;
  34. var $conn = false;
  35. var $cookiefile =false;
  36. var $header = false;
  37. var $cookie = false;
  38. var $follow = true;
  39. var $dump = false;
  40. var $range = false;
  41. var $timeout = false;
  42. var $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
  43.  
  44. function Curl($u = false) {
  45. $this->conn = curl_init();
  46. if (!$u) {
  47. $u = rand(0,100000);
  48. }
  49.  
  50. $file = dirname(__FILE__).'/temp/'.md5($u);
  51. $file = str_replace('\\','/', $file);
  52. $this->cookiefile= $file;
  53.  
  54. }
  55.  
  56. function setCallback($func_name) {
  57. $this->callback = $func_name;
  58. }
  59.  
  60. function close() {
  61. curl_close($this->conn);
  62. if (is_file($this->cookiefile)) {
  63. //unlink($this->cookiefile);
  64. }
  65.  
  66. }
  67.  
  68. function doRequest($method, $url, $vars) {
  69.  
  70. $ch = $this->conn;
  71.  
  72. curl_setopt($ch, CURLOPT_URL, $url);
  73. if ($this->header) {
  74. curl_setopt($ch, CURLOPT_HEADER, 1);
  75. } else {
  76. curl_setopt($ch, CURLOPT_HEADER, 0);
  77. }
  78. curl_setopt($ch, CURLOPT_USERAGENT,$this->user_agent);
  79. curl_setopt( $ch, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: ".$_SERVER['REMOTE_ADDR'], "HTTP_X_FORWARDED_FOR: ".$_SERVER['REMOTE_ADDR'])); // send users ip questionmark.gif?
  80.  
  81.  
  82. if($this->secure) {
  83. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  84. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  85. }
  86.  
  87. if ($this->cookie)
  88. {
  89. curl_setopt($ch, CURLOPT_COOKIE,$this->cookie);
  90. }
  91.  
  92. if ($this->follow) {
  93. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  94. } else {
  95. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  96. }
  97.  
  98. if($this->dump) {
  99. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
  100. } else {
  101. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  102. }
  103.  
  104. if($this->range)
  105. {
  106. curl_setopt($ch, CURLOPT_RANGE,$this->range);
  107. }
  108.  
  109. if($this->timeout)
  110. {
  111. curl_setopt($ch, CURLOPT_TIMEOUT,$this->timeout);
  112. } else {
  113. curl_setopt($ch, CURLOPT_TIMEOUT,false);
  114. }
  115.  
  116. curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookiefile);
  117. curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookiefile);
  118.  
  119. if ($method == 'POST') {
  120. curl_setopt($ch, CURLOPT_POST, 1);
  121. curl_setopt($ch, CURLOPT_POSTFIELDS, $vars);
  122. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect: ')); // lighttpd fix
  123. }
  124.  
  125. $data = curl_exec($ch);
  126.  
  127. if ($data) {
  128. if ($this->callback)
  129. {
  130. $callback = $this->callback;
  131. $this->callback = false;
  132. return call_user_func($callback, $data);
  133. } else {
  134. return $data;
  135. }
  136. } else {
  137. return false;
  138. }
  139. }
  140.  
  141. function get($url) {
  142. return $this->doRequest('GET', $url, 'NULL');
  143. }
  144.  
  145.  
  146. function processHeader($ch,$string)
  147. {
  148. if(preg_match('%Content-Range: bytes 0-1024/([0-9]+)%', $string,$match))
  149. {
  150. $this->size = $match[1];
  151. return false;
  152. }
  153.  
  154. if(preg_match('%Content-Length: ([0-9]+)%', $string,$match))
  155. {
  156. $this->size = $match[1];
  157. return false;
  158. }
  159.  
  160. return strlen($string);
  161. }
  162.  
  163. function getSize($url) {
  164.  
  165. $this->size = false;
  166.  
  167. $this->header = true;
  168. $this->range = "0-1024";
  169. $this->dump = true; // some sites dont echo in curl
  170.  
  171. curl_setopt($this->conn,CURLOPT_HEADERFUNCTION,array($this,processHeader));
  172. $this->doRequest('GET', $url,false);
  173. $result = ob_get_contents();
  174.  
  175. $this->dump = false;
  176. $this->header = false;
  177. $this->range = false;
  178.  
  179. return $this->size;
  180. }
  181.  
  182.  
  183. function getError()
  184. {
  185. return curl_error($this->conn);
  186. }
  187.  
  188. function post($url, $params = false) {
  189.  
  190. $post_data = '';
  191.  
  192. if (is_array($params)) {
  193.  
  194. foreach($params as $var=>$val) {
  195. if(!empty($post_data))$post_data.='&';
  196. $post_data.= $var.'='.urlencode($val);
  197. }
  198.  
  199. } else {
  200. $post_data = $params;
  201. }
  202.  
  203. return $this->doRequest('POST', $url, $post_data);
  204. }
  205.  
  206. function streamHeader($ch,$string)
  207. {
  208. if(empty ($string)) return;
  209.  
  210. header($string);
  211. return strlen($string);
  212. }
  213.  
  214. function stream($url)
  215. {
  216. $this->dump = true;
  217. curl_setopt($this->conn,CURLOPT_HEADERFUNCTION,array($this,"streamHeader"));
  218. $this->doRequest('GET', $url,false);
  219.  
  220. }
  221.  
  222. function getRedirect($url)
  223. {
  224. $this->follow = false;
  225. $this->header = true;
  226.  
  227. $html = $this->get($url);
  228.  
  229. if(preg_match('/Location: (.*?)[\r\n]+/',$html,$match) || preg_match('/http-equiv=\'Refresh\' content=\'[0-9]+;url=(.*?)\'/s',$html,$match))
  230. {
  231. return $match[1];
  232. }
  233.  
  234. $this->follow = true;
  235. $this->header = false;
  236. }
  237.  
  238. }
  239.  
  240. function getPage($url,$post = false,$cookie = false)
  241. {
  242. $pURL = parse_url($url);
  243.  
  244. $curl = new Curl($pURL['host']);
  245.  
  246. if (strstr($url,'https://'))
  247. {
  248. $curl->secure = true;
  249. }
  250.  
  251. if ($post) {
  252. return $curl->post($url,$post);
  253. } else {
  254. return $curl->get($url);
  255. }
  256.  
  257. }
Vays
Znalazłem kolejny skrypt do pobierania mp3 z YT i znowu jakiś tzn. taki:
  1. file_get_contents(http://gdata.youtube.com/feeds/api/videos/eOofWzI3flA?v=2&alt=jsonc): failed to open stream: HTTP request failed! HTTP/1.0 410 Gone in /home/u387243255/public_html/index.php on line 69

Da się to naprawić? :'(
rad11
Ale co Ty probujesz wogole osiagnac? Bo nie wie czy sobie zdajesz z tego sprawe ale YT posiada API PHP.
Kshyhoo
Cytat(Vays @ 5.06.2015, 21:28:47 ) *
Znalazłem kolejny skrypt do pobierania mp3 z YT i znowu jakiś tzn. taki:
  1. file_get_contents(http://gdata.youtube.com/feeds/api/videos/eOofWzI3flA?v=2&alt=jsonc): failed to open stream: HTTP request failed! HTTP/1.0 410 Gone in /home/u387243255/public_html/index.php on line 69

Da się to naprawić? :'(

Za każdym wykopaliskiem będziesz zakładał nowy wątek?
Łączę tematy.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.