1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| <?php
class LOCConnection {
var $pseudo;
var $password;
var $phpsessid;
function LOCConnection($pseudo, $password) {
$this->pseudo = $pseudo;
$this->password = $password;
}
function setPseudo($pseudo) {
$this->pseudo = $pseudo;
}
function setPassword($password) {
$this->password = $password;
}
function getPseudo() {
return $this->pseudo;
}
function getPassword() {
return $this->password;
}
function connect() {
}
function getSessionID() {
return $this->phpsessid;
}
function setSessionID() {
$socket = fsockopen("www.lordofcastle.com", 80, $errno, $errstr, 10);
if (!$socket) {
echo "Error : $errstr ($errno)<br />\n";
} else {
$in = "GET /index.php HTTP/1.1\r\n";
$in .= "Host: www.lordofcastle.com\r\n";
$in .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1\r\n";
$in .= "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n";
$in .= "Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3\r\n";
$in .= "Accept-Encoding: gzip,deflate\r\n";
$in .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
$in .= "Keep-Alive: 300\r\n";
$in .= "Connection: keep-alive\r\n";
$in .= "Referer: http://www.lordofcastle.com/\r\n";
print "$in";
$out = '';
while (!feof($socket)) {
fwrite($socket, $in);
$out = fgets($socket, 4096);
print "$out";
if(($start = stripos($out, "Set-Cookie: PHPSESSID=")) != false) {
$this->phpsessid = substr($out, $start + 22, 32);
break;
}
}
fclose($socket);
}
}
}
?> |
Partager