I can't figure out what I'm missing. I've tried mimicking the firefox request headers, but it doesn't work.
Also, the frame page reaches the end page using a javascript ajax request. It posts the data to $post_to_link
(see code below) then navigates to the expected result
(not my current result
), where the megaupload link is located.
Expected output:
/membersonly/components/com_iceplayer/GMorBMlet.php?url=http%3A%2F%2Fwww.megaupload.com%2F%3Fd%3DVNICBFWL&
Current output:
file_get_contents
outputs 3
Here is my code:
// call it like so...
echo GetHosterLink( 1148, 252636, '', '37fn8Oklq', 15, -75 );
// $s is incremented every second you are 'visiting' the referer page
// $m decreases below zero when you move your mouse `down` on the start page
function GetHosterLink( $id, $link_id, $cap, $sec, $s, $m )
{
$link_page = str_replace( '[ID]', $id, 'http://www.icefilms.info/membersonly/components/com_iceplayer/video.php?vid=[ID]' );
$post = "id={$link_id}&s={$s}&iqs=&url=&m={$m}&cap=&sec={$sec}&t={$id}";
$header = implode( "\r\n", array(
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept-Encoding: gzip, deflate",
"Accept-Language: en-us,en;q=0.5",
"Cache-Control: no-cache",
"Connection: keep-alive",
"Content-Length: " . strlen( $post ),
"Content-Type: application/x-www-form-urlencoded; charset=UTF-8",
"Host: www.icefilms.info",
"Pragma: no-cache",
"Referer: http://www.icefilms.info/membersonly/components/com_iceplayer/video.php?h=374&w=631&vid={$id}&img=",
"User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0"
));
$opts = array('http' =>
array(
'method' => 'POST',
'header' => implode("\r\n",
array(
'Content-type: application/x-www-form-urlencoded',
'Content-length: ' . strlen( $post ),
'Referer: ' . $link_page . '&h=374&w=631',
'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0',
'Host: www.icefilms.info'
)
),
'content' => http_build_query(
array(
'id' => $link_id,
's' => $s,
'sec' => $sec,
't' => $id,
'm' => $m,
'iqs' => '',
'url' => '',
'cap' => ''
)
)
)
);
$context = stream_context_create($opts);
$post_to_link = 'http://www.icefilms.info/membersonly/components/com_iceplayer/video.phpAjaxResp.php';
$get_result = file_get_contents( $post_to_link, false, $context );
$f_result = cURL::DoRequest( $post_to_link, $post, '',
array( array( CURLOPT_HTTPHEADER, $header ) ) );
$f_r = array(
'result' => $f_result,
'get_result' => $get_result,
'get_opts' => $opts,
'get_response' => $http_response_header,
'req_post' => $post,
'req_href' => $post_to_link,
'req_header' => $header
);
return ( $f_r );
}
Here is my curl.php
file:
class cURL
{
public static function DoRequest( $url, $post = '',
$cookie_file = '', $variables = array() )
{
$curl = curl_init();
@session_start();
$cookie = ( 'PHPSESSID=' . session_id() . '; path=/' );
@session_write_close();
curl_setopt( $curl, CURLOPT_URL, $url );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $curl, CURLOPT_COOKIE, $cookie );
if ( !empty( $cookie_file ) )
{
curl_setopt( $curl, CURLOPT_COOKIEFILE, $cookie_file );
curl_setopt( $curl, CURLOPT_COOKIEJAR, $cookie_file );
}
if ( !empty( $post ) )
{
//curl_setopt( $curl, CURLOPT_POST, 1 );
curl_setopt( $curl, CURLOPT_POSTFIELDS, $post );
}
foreach ( $variables as $var )
curl_setopt( $curl, $var[0], $var[1] );
$result = curl_exec( $curl );
curl_close( $curl );
return ( $result );
}
}
Try visiting initial page (the one's url you have in $link_page
) with curl and make sure the file you point to in:
curl_setopt( $curl, CURLOPT_COOKIE, $cookie );
exists and is writeable.
Then request the $post_to_link
url with same curl resource.
By visiting the initial page you are getting cookies and making sure there is a valid session for your next request. That also secures the referer you then provide in headers. There are many ways to figure "automatic" requests, and things like checking cookie and if you actually visited "referer"-ed link are quite common.