PHP Code:
function sendPOST(host, port, path, data) {
// new socket
temp.socket = new TSocket();
// delimeter
temp.delim = char(13) @ char(10);
// connect
socket.connect(host, port);
// headers
socket.send("POST " @ path @ " HTTP/1.0" @ delim);
socket.send("Host: " @ host @ delim);
socket.send("User-Agent: Mozilla/4.0 (compatible; euroCenterBot; EuroCenterGServer...lol)" @ delim);
socket.send("Content-Length: " @ data.length() @ delim);
socket.send("Content-Type: application/x-www-form-urlencoded" @ delim);
socket.send(delim);
// data
socket.send(data);
// wait for the socket to close
waitfor(socket, "onClose", 30);
/* for debugging
waitfor(socket, "onReceiveData", 5);
if (socket.error != null) {
echo("Error: " @ socket.error);
} else {
echo("Data:");
for (temp.line : socket.data.tokenize('\n')) {
echo(" " @ line);
}
}*/
}
Example usage:
PHP Code:
temp.data = urlencode("data") @ "=" @ urlencode("bar");
data @= "&";
data @= urlencode("data2") @ "=" @ urlencode("foo");
sendPOST("techxonline.net", 80, "/dosomething.php", data);
Stefan has to approve each host/port for each server, so good luck with that.