Citation:
<?php
function ogame_login(){
ob_start("ob_gzhandler");
$curl = curl_init();
$user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.9 (Sombre Arc en Ciel";
$uni_id = "109"; /* Please set your ogame universe */ $uni_url = "uni$uni_id.ogame.fr";
$url = 'http://'.$uni_url; $host = $uni_url;
$referer = $_SERVER['HTTP_REFERER'];
$login = "Icare"; // set your ogame login
$pass = "Z0c9Gk3Fyq1ILoX7DHuQ"; // set your ogame password
$post_fields = array();
$post_fields['uni_id'] = $uni_id; // Id. Universe (view Source code for Id)
$post_fields['v'] = '2';
$post_fields['is_utf8'] = '0';
$post_fields['uni_url'] = $uni_url;
$post_fields['login'] = $login;
$post_fields['pass'] = $pass;
$post_fields['submitInput'] = 'Login';
$post = http_build_query($post_fields);
$login_url = "$url/game/reg/login2.php?$post";
$info_headers = fopen("headers.txt", "w+");
$cookies = fopen("cookies.txt", "w+");
$index = fopen("index.txt", "w+");
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, False);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, False);
curl_setopt($curl, CURLOPT_HEADER, True);
curl_setopt($curl, CURLOPT_NOBODY, 0);
curl_setopt($curl, CURLINFO_HEADER_OUT, True);
curl_setopt($curl, CURLOPT_WRITEHEADER, $info_headers);
curl_setopt($curl, CURLOPT_COOKIESESSION, True);
curl_setopt($curl, CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookies.txt');
curl_setopt($curl, CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookies.txt');
curl_setopt($curl, CURLOPT_COOKIE, $cookies);
curl_setopt($curl, CURLOPT_COOKIE, session_name() . '=' . session_id());
curl_setopt($curl, CURLOPT_ENCODING, "gzip,deflate");
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl, CURLOPT_URL, $login_url);
curl_setopt($curl, CURLOPT_AUTOREFERER, True);
curl_setopt($curl, CURLOPT_REFERER, $referer);
curl_setopt($curl, CURLOPT_USERAGENT, $user_agent);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, True);
curl_setopt($curl, CURLOPT_POST, True);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, True);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($curl, CURLOPT_MAXREDIRS, 10);
curl_setopt($curl, CURLOPT_FILE, $index);
$data = curl_exec($curl);
header("Location: $login_url");
}
/*
File : ogame_login.php
Description : This script login you on ogame.fr website using curl in php.
Written by : Sombre Arc en Ciel (sombrearcenciel@free.fr)
Languages : Php + cURL
Date Written : November 15, 2009
Version : V.1.0
Platform : Windows Xp Pro / Mozilla Firefox 3.5.x
Copyright : Open Source Code (GPL)
*/
$game_login = ogame_login(); echo $game_login;
?>