<?php
//submit login form: (url, post data, extra headers (optional))
//do not put http into URL, just domain name
$mycookies = GetCookies("www.save.tv/STV/M/Index.cfm?sk=PREMIUM","DL=&sUsername=USERNAME&sPassword=PASSWORD&bAutoLoginActivate=1","");
//some extra params if you need them
echo "Cookies:<br><pre>\n".$mycookies."\n</pre>";
$body =PostPage("www.save.tv/STV/M/obj/user/usShowVideoArchive.cfm","action=zzz",$mycookies);
echo "<br>Body:<br>\n".$body."\n";
//im using get page - so it goes like this:
die();
$opts = array('http'=>array('method'=>"GET", 'header'=>"Accept-language: en\r\nCookie: ".$mycookies."\r\n" ));
$context = stream_context_create($opts);
$fp = fopen('http://www.save.tv/STV/M/obj/user/usShowVideoArchive.cfm?', 'r', false, $context);
fpassthru($fp);
$html = fread($fp, 1000000);
fclose($fp);
echo $html;
function PostPage($host,$query,$others=''){
$path=explode('/',$host);
$host=$path[0];
unset($path[0]);
$path='/'.(implode('/',$path));
$post="POST $path HTTP/1.1\r\nHost: $host\r\n";
$post.="Content-type: application/x-www-form-";
$post.="urlencoded\r\n${others}";
$post.="User-Agent: Mozilla 4.0\r\nContent-length: ";
$post.=strlen($query)."\r\nConnection: close\r\n\r\n$query";
$h=fsockopen($host,80);
fwrite($h,$post);
for($a=0,$r='';!$a;){
$b=fread($h,8192);
$r.=$b;
$a=(($b=='')?1:0);
}
fclose($h);
return $r;
}
function GetCookies($host,$query,$others=''){
$path=explode('/',$host);
$host=$path[0];
unset($path[0]);
$crlf = "\r\n";
$path='/'.(implode('/',$path));
$post="POST $path HTTP/1.1\r\nHost: $host\r\n";
$post.="Content-type: application/x-www-form-urlencoded\r\n${others}";
$post.="User-Agent: Mozilla 4.0\r\nContent-length: ";
$post.=strlen($query)."\r\nConnection: close\r\n\r\n$query";
$h=fsockopen($host,80);
fwrite($h,$post);
$r="";
for($a=0;!$a;){
$b=fread($h,512);
echo $b;
$r.=$b;
$gotSession=strpos($r,"ASPSESSION");
if($gotSession)
if(strpos($r, $crlf . $crlf,$gotSession)>0) break;
$a=(($b=='')?1:0);
}
fclose($h);
$arr = split("Set-Cookie:",$r);
$AllCookies="";$count=1;
while ($count < count($arr)) {
$AllCookies.=substr($arr[$count].";",
0,strpos($arr[$count].";",";")+1);
$count++;}
return $AllCookies;
}