1 |
<?php |
2 |
function Forbidden() { |
3 |
Header("HTTP/1.0 403"); |
4 |
echo "You are not allowed to access this document.\n"; |
5 |
exit; |
6 |
} |
7 |
function Error($errno) { |
8 |
echo "<b>GreĀ¹ka!</b><br>".strerror($errno)." (".$errno.")<BR>\n"; |
9 |
exit; |
10 |
} |
11 |
$host = $HTTP_REFERER; |
12 |
if (!$host) Forbidden(); |
13 |
$host2 = ereg_replace("^http://([^/]+)/.*$", "\\1", $host); |
14 |
if ($host2) $host = $host2; |
15 |
$host = gethostbyname($host); |
16 |
if (strpos("195.29.208.", $host) != 0) Forbidden(); |
17 |
$fd = fsockopen(gethostbyname("www.harrisonsonline.com"), 80, &$errno); |
18 |
if (!$fd) Error($errno); |
19 |
$qry = "id=pliva&password=harrisons"; |
20 |
fputs($fd, "POST /server-java/Arknoid/amed/harrisons/co_chapters/ch001/ch001_p01.html HTTP/1.0\r\n"); |
21 |
fputs($fd, "Host: www.harrisonsonline.com\r\n"); |
22 |
fputs($fd, "Content-Type: application/x-www-form-urlencoded\r\n"); |
23 |
fputs($fd, "Content-Length: ".strlen($qry)."\r\n"); |
24 |
fputs($fd, "Connection: keep-alive\r\n"); |
25 |
fputs($fd, "\r\n"); |
26 |
fputs($fd, $qry); |
27 |
$cookies = array(); |
28 |
while (!feof($fd)) { |
29 |
$line = chop(fgets($fd, 4096)); |
30 |
if ($line == "") break; |
31 |
$pos = strpos(strtoupper($line), "SET-COOKIE:"); |
32 |
if ($pos === false) continue; |
33 |
if ($pos == 0) array_push($cookies, $line"); |
34 |
} |
35 |
fclose($fd); |
36 |
Header("Location: http://www.harrisonsonline.com/"); |
37 |
for ($i = 0; $i < count($cookies); $i++) Header($cookies[$i]); |
38 |
?> |