I don’t know if this will be interesting for you, but it was very interesting for me when i found that it is very easy to modify header information and send POST/GET variables through header using php. Anyway with CURL you are able to do much more that just modify the header information etc., but we wont have that time-frame
I will give you simple example where i login through script on localhost on some site – in this example: “gametrailers.com” – without actually enter any username and password
, i think this will be the easiest way to understand it.
so here is the example:
on your localhost create php file – “loadUrl.php”
<base href=”http://www.gametrailers.com/” />
<!– we use base href to be able to load the css and the js paths correctly on the site –>
$port = 80;
//usually this is default http port so probably u won’t have to change this
$server= ‘www.gametrailers.com’;
//i tested thet with this host, but i guess it will work on many other URLs as well
$url = ‘/index.php?’; //this is the index file of the url
$content = ‘userlog’;
//these are custom variables especially for gametrailers – probably you won’t have to use them
$content .= ‘&try=1′;
//these are custom variables especially for gametrailers – probably you won’t have to use them
//enter your site login name
$content .= ‘&username=your_username’;
//enter your site pass
$content .= ‘&password=your_pass’;
$content_length = strlen($content);
//don’t touch this one – the header has to have valid lenght
$headers = “POST $url HTTP/1.0\r\n”;
$headers.= “Content-type: application/x-www-form-urlencoded\r\n”;
$headers.= “Host: $server\r\n”;
$headers.= “Content-length: $content_length\r\n\r\n”;
$fp = fsockopen($server, $port, $errno, $errstr);
//we open connection to our URL
if (!$fp) return false;
fputs($fp, $headers);
fputs($fp, $content);
$ret = “”;
while (!feof($fp)) {
$ret.= fgets($fp, 1024);
//we get the content of the URL
}
fclose($fp);
print “<pre style=”position:absolute;z-index:100;”>”.$ret.”</pre>”;
//we print the actual content of the website, and finally we are logged as user ![]()
?>
You see – succeed to login on this URL (gametrailers), but on for some other URL you will have to make some more custom solution. For example you will have to check the login form – what are the “name” properties for the html input elements, and to change that in the script, but after that everything should be fine
recent comments