Foros del Web » Programando para Internet » PHP »

problemas con php

Estas en el tema de problemas con php en el foro de PHP en Foros del Web. hola buenos dias tengo un problema con un script y me gustaria resolverlo para un proyecto de hobby para todo el mundo,pero tengo serios problemas ...
  #1 (permalink)  
Antiguo 10/09/2011, 04:53
Avatar de ahaugas  
Fecha de Ingreso: agosto-2011
Ubicación: Madrid
Mensajes: 249
Antigüedad: 12 años, 8 meses
Puntos: 21
problemas con php

hola buenos dias tengo un problema con un script y me gustaria resolverlo para un proyecto de hobby para todo el mundo,pero tengo serios problemas y de php se muy poco pero me defiendo en algo

si me pueden hechar unaa mano os lo agradecere

en primer lugar tengu un error



Código:
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /xxxxxxx/xxxx/xxxxxxxx/xxxxxx/xxxxx/xxxxxx/leader.php on line 46

Código:
Warning: file_get_contents(http://www.ejemplo.com/xml/link.php?v=C1ARCSL4&u=xxxxxxxxxxxxxxxxxxxxx--xxxxxxx) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /xxxxxxx/xxxx/xxxxxxxx/xxxxxx/xxxxx/xxxxxx/leader.php on line 46
y en la linea tengo

Código PHP:
// Obtain Megavideo XML playlist file
    
if ($content file_get_contents("http://www.megavideo.com/xml/videolink.php?v=".$megavideo_id."&u=xxxxxxxxxxxxxxxxxxxxx--xxxxxxx")){ 

habria la posibilidad de
Código PHP:
file_get_contents() 
pasar a
Código PHP:
curl() 
porque mi servidor no admite eso ni .htaccess ni php.ini

muchas gracias por vuestro tiempo como veis es un script de videos y lo voy a poner gratuito en mi pagina web, pero no solo coge de megavideo sino de todos los que alojen algo tipo google
  #2 (permalink)  
Antiguo 10/09/2011, 05:04
Avatar de hasdpk  
Fecha de Ingreso: agosto-2011
Ubicación: $spain->city( 'Arucas' );
Mensajes: 1.800
Antigüedad: 12 años, 7 meses
Puntos: 297
Respuesta: problemas con php

cURL es mucho más rápido que file_get_contents()

El primer error dice que no tienes acceso a ese archivo, seguramente por restricciones del servidor.

El segudo, por lo que yo entendí, es que el parámetro que le has pasado no es adecuado, y por lo tanto, no lo puede abrir.
  #3 (permalink)  
Antiguo 10/09/2011, 05:26
Avatar de ahaugas  
Fecha de Ingreso: agosto-2011
Ubicación: Madrid
Mensajes: 249
Antigüedad: 12 años, 8 meses
Puntos: 21
Respuesta: problemas con php

ok muchas gracias y como puedo pasarlo a curl y arreglar el problema porque llevo unos dias que no le veo ni los pies ni la cabeza
  #4 (permalink)  
Antiguo 10/09/2011, 06:47
Avatar de hasdpk  
Fecha de Ingreso: agosto-2011
Ubicación: $spain->city( 'Arucas' );
Mensajes: 1.800
Antigüedad: 12 años, 7 meses
Puntos: 297
Respuesta: problemas con php

- Iniciar: curl_init() - http://php.net/manual/es/function.curl-init.php
- Añadir las opciones: curl_setopt() - http://www.php.net/manual/es/function.curl-setopt.php
- Ejecutar: curl_exec() - http://www.php.net/manual/es/function.curl-exec.php
- Cerrar: curl_close() - http://www.php.net/manual/es/function.curl-close.php
  #5 (permalink)  
Antiguo 10/09/2011, 10:42
Avatar de ahaugas  
Fecha de Ingreso: agosto-2011
Ubicación: Madrid
Mensajes: 249
Antigüedad: 12 años, 8 meses
Puntos: 21
Respuesta: problemas con php

gracias, pero si no es mucho pedir me podrias poner algun ejemplo porque lo intento y no se como hacerlo funcionar
  #6 (permalink)  
Antiguo 10/09/2011, 11:42
Avatar de hasdpk  
Fecha de Ingreso: agosto-2011
Ubicación: $spain->city( 'Arucas' );
Mensajes: 1.800
Antigüedad: 12 años, 7 meses
Puntos: 297
Respuesta: problemas con php

Código PHP:
Ver original
  1. $curl = curl_init("http://www.direccion.com");
  2. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  3. $var = curl_exec($curl);
  4. curl_close($curl);
  #7 (permalink)  
Antiguo 10/09/2011, 14:31
Avatar de ahaugas  
Fecha de Ingreso: agosto-2011
Ubicación: Madrid
Mensajes: 249
Antigüedad: 12 años, 8 meses
Puntos: 21
Respuesta: problemas con php

NO ME FUNCIONA o no lo estoy poniendo bien HE PUESTO ESTO como me has dicho


Código PHP:
Ver original
  1. if ($content = curl_init("http://www.megavideo.com/xml/videolink.php?v=".$megavideo_id."&u=XXXXXXXXXXXXXXXXXXXXXXXX--XXXXX")){
  2.     curl_setopt($content, CURLOPT_RETURNTRANSFER, true);
  3.     $var = curl_exec($content);
  4.     curl_close($content);


el codigo original es este


Código PHP:
Ver original
  1. <?php
  2.     // For premium accounts
  3.     // It downlad the video in flv format
  4.     // It doesnt work if the file is hosted on free hosting, but works from hosting like dreamhost.
  5.     // The parameter that is after u= (in the line 46) is your megavideo premium cookie. To find it use firefox + temper data and watch a movie, you could find it there. Every user has a different cookie
  6.     // How to call the file: http://website.com/mvpremiumflv.php?video_id=IDOFTHEVIDEO
  7.     function mv_decrypt($str_hex, $key1, $key2){
  8.     $str_bin = "";
  9.     // 1. Convert hexadecimal string to binary string
  10.     for($i = 0; $i < 128; $i++){
  11.     $str_bin .= floor(hexdec($str_hex[floor($i/4)])/pow(2,(3-($i%4))))%2;
  12.     }
  13.     // 2. Generate switch and XOR keys
  14.     $key = Array();
  15.     for ($i = 0; $i < 384; $i++){
  16.     $key1 = ($key1 * 11 + 77213) % 81371;
  17.     $key2 = ($key2 * 17 + 92717) % 192811;
  18.     $key[$i] = ($key1 + $key2) % 128;
  19.     }
  20.     // 3. Switch bits positions
  21.     for ($i = 256; $i >= 0; $i--){
  22.     $temp = $str_bin[$key[$i]];
  23.     $str_bin[$key[$i]] = $str_bin[$i%128];
  24.     $str_bin[$i%128] = $temp;
  25.     }
  26.     // 4. XOR entire binary string
  27.     for ($i = 0; $i < 128; $i++){
  28.     $str_bin[$i] = $str_bin[$i] ^ $key[$i+256] & 1;
  29.     }
  30.     // 5. Convert binary string back to hexadecimal
  31.     $str_hex = "";
  32.     for($i = 0; $i < 32; $i++){
  33.     $str_hex .= dechex(bindec(substr($str_bin, $i*4, 4)));
  34.     }
  35.     // 6. Return counted string
  36.     return $str_hex;
  37.     }
  38.  
  39.     // Is set the "video_id" variable?
  40.     if(isset($_GET["video_id"])){
  41.     // Does player send video position?
  42.     $pos = (isset($_GET["pos"]) ? intval($_GET["pos"]) : "");
  43.     //Obtain Megavideo ID from link
  44.     $megavideo_id = $_GET["video_id"];
  45.     // Obtain Megavideo XML playlist file
  46.     if ($content = file_get_contents("http://www.megavideo.com/xml/videolink.php?v=".$megavideo_id."&u=XXXXXXXXXXXXXXXXXXXXXXXX--XXXXXX")){
  47.     // Parameters which I want to obtain from XML;
  48.     $parameters = Array("un", "k1", "k2", "s", "size");
  49.     $success = true;
  50.     // Obtain parameters from XML one by one
  51.     for($i=0; $i<Count($parameters); $i++){
  52.     $success = $success && preg_match('/ ' . $parameters[$i] . '="([^"]+)"/', $content, $match);
  53.     $$parameters[$i] = $match[1];
  54.     }
  55.     if($success){
  56.     // Count "dkey" from obtained parameters
  57.     $dkey=mv_decrypt($un,$k1,$k2);
  58.     // set URL address of video file
  59.     $video_url = "http://www".$s.".megavideo.com/files/".$dkey."/".$pos;
  60.     // Send headers to browser
  61.     header("Content-Type: video/flv");
  62.     header("Content-Disposition: attachment; filename=video.flv;" );
  63.     header("Content-Length: ".$size);
  64.     // Read video file from Megavideo server
  65.     readfile($video_url);
  66.     }
  67.     }
  68.     }
  69.     ?>
  #8 (permalink)  
Antiguo 10/09/2011, 19:52
Avatar de ahaugas  
Fecha de Ingreso: agosto-2011
Ubicación: Madrid
Mensajes: 249
Antigüedad: 12 años, 8 meses
Puntos: 21
Respuesta: problemas con php

y como se podria imprimir en la pagina en vez de generar la descarga??
  #9 (permalink)  
Antiguo 11/09/2011, 04:02
Avatar de hasdpk  
Fecha de Ingreso: agosto-2011
Ubicación: $spain->city( 'Arucas' );
Mensajes: 1.800
Antigüedad: 12 años, 7 meses
Puntos: 297
Respuesta: problemas con php

Por lo que veo lo que quieres es descargar contenido de megavideo ¿no? si es así, con cURL no lo vas a conseguir, al menos que yo sepa.
  #10 (permalink)  
Antiguo 11/09/2011, 17:29
Avatar de ahaugas  
Fecha de Ingreso: agosto-2011
Ubicación: Madrid
Mensajes: 249
Antigüedad: 12 años, 8 meses
Puntos: 21
Respuesta: problemas con php

yo creo que si se puede pero no se como, porque tengo otro script parecido y esta en curl pero lo he optimizado el caso es que no se donde porque si pongo lo del curl me salta error de pregmatch()
  #11 (permalink)  
Antiguo 11/09/2011, 17:40
Avatar de hasdpk  
Fecha de Ingreso: agosto-2011
Ubicación: $spain->city( 'Arucas' );
Mensajes: 1.800
Antigüedad: 12 años, 7 meses
Puntos: 297
Respuesta: problemas con php

Pon exactamente el error que te aparece.

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:27.