Cita:
El codigo php es:HTTP/1.1 200 OK Date: Fri, 10 Jul 2009 09:15:53 GMT Server: Apache/2.2.4 (Unix) mod_ssl/2.2.4 OpenSSL/0.9.8b PHP/5.1.6 X-Powered-By: PHP/5.1.6 Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Transfer-Encoding: chunked Content-Type: text/html
Código PHP:
<?php
$enlace = $_GET['enlace'];
function curl($link, $postfields = '', $cookie = '')
{
$ch = curl_init($link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
if($postfields)
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
}
if($cookie)
{
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
}
$page = curl_exec($ch);
return($page);
curl_close($ch);
}
$postfields = array();
$postfields['uname'] = 'usuario';
$postfields['passwd'] = 'password';
//$postfields['d'] = 'Login'; Esto he probado a ponerlo y a no ponerlo. Es el valor del submit, pero no se si hay que ponerlo o no.
$postfields = http_build_query($postfields);
$cookie = 'php/cookie.txt'; //Create a random named cookie file
$page = curl('http://www.webjeemplo.com/login.php', $postfields, $cookie); //Call the curl function with our arguments
$page = curl($enlace, '', $cookie); //Go to the download page, with no postfields and premium cookie!
echo $page;
?>