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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
| <?
&lt;?
function get_site($site, $go_post=0, $referer="none", $form="")
{
// nu met proxy support :)
global $koekje;
global $host;
global $proxy_server;
global $proxy_port;
//global $form;
if ((strlen($proxy_server) &gt; 1) && is_int($proxy_port)) $use_proxy=true;
if ($use_proxy)
{
$fp = fsockopen( $proxy_server , $proxy_port , $err_num, $err_string, 20);
$site = "http://".$host."/".$site;
//echo "connection through proxy&lt;br&gt;";
}
else
{
$fp = fsockopen($host , 80 , $err_num, $err_string, 20);
$site ="/".$site;
//echo "connection without proxy&lt;br&gt;";
}
$body ="";
settype($form, "array");
if ($go_post==1)
{
while(list($key,$val) = each($form))
$body .= urlencode($key)."=".urlencode($val)."&";
//unset($form);
//settype($form, "array");
$request="POST";
//echo $body;
}
else
{
$request="GET";
}
settype($koekje, "array");
@reset($koekje);
while(list($key,$val) = @each($koekje)) $koekje_string .= $key."=".$val."; ";
$koekje_string=preg_replace("/;\s*\Z/" , "" , $koekje_string);
$req = $request." ".$site." HTTP/1.1\n";
$req .= "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */*\n";
if ($referer!="none") $req .= "Referer: [url=http://".$host."/".$referer."\n";]http://".$host."/".$referer."\n";[/url]
$req .= "Accept-Language: en-us\n";
$req .= "Accept-Encoding: gzip, deflate\n";
$req .= "User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)\n";
$req .= "Host: ".$host."\n";
$req .= "Connection: Keep-Alive\n";
$req .= "Cookie: ".$koekje_string."\n";
// checken of er ook data gepost moet worden;
if ($go_post==1)
{
$req .= "Content-type: application/x-www-form-urlencoded\n";
$req .= "Content-length: ".strlen($body)."\n";
}
$req .= "\n";
//echo nl2br($req.$body)."&lt;hr&gt;";
//usleep(50);
fwrite($fp, $req.$body,strlen($req.$body)) || die("error");
$retries = 0;
while(!feof($fp))
{
$string = fgets($fp,1024);
$retries = 0;
$comp_response[]=$string;
if(preg_match("/^set-cookie:[\s]+([^=]+)=([^;]+)/i", $string , $match))
{
$koekje[$match[1]] = $match[2];
}
}
fclose($fp);
return $comp_response;
}
?&gt;
$koekje = array met koekjes, heb je verder niets mee nodig
$host = de host, bijv muon.nl
$proxy_server = proxy server, niet noodzakelijk
$proxy_port = dus ook niet nodig.
post data zet je in een array (of was het nu hash)
bijv $p_data[naam]='blaat';
$p_data[datum]=time();
functie aanroepen: voor muon.nl/blaat/index.htm
$host= 'muon.nl';
$site = get_site('blaat/index.htm', 1, , $p_data);
als je geen data post:
$site = get_site('blaat/index.htm'');
en als je er nog een referen in wilt proppen
$site = get_site('blaat/index.htm', 1,'http///weetikveelwatvoorsite' , $p_data);
response laten zien: echo imlpode("" , $site) (het is een array)
?> |