Blockland Forums > Modification Help
HTTPObject PHP parameters
Bauklotz:
Well, I tried looking at TorquePowered.com, and it seems that TGE has problems encoding the "&" character (before I tried using multiple variables), and if I try stuff like ?variable=nothing&cookies=impossible, then in PHP, the variable 'variable' will contain 'nothing&cookies=impossible'.
Kalphiter:
--- Quote from: Bauklotz on October 03, 2010, 12:57:11 AM ---Well, I tried looking at TorquePowered.com, and it seems that TGE has problems encoding the "&" character (before I tried using multiple variables), and if I try stuff like ?variable=nothing&cookies=impossible, then in PHP, the variable 'variable' will contain 'nothing&cookies=impossible'.
--- End quote ---
Try just going to TCPObject.
Matter of fact, I made some functions some time ago for easy packet making. You have to send() whatever these functions return.
--- Code: ---package Cloud_TCPObjects
{
function TCPObject::createPostPacket(%this, %host, %path, %data)
{
return "POST "@ %path @" HTTP/1.1\r\nHost: "@ %host @"\r\nUser-Agent: Torque/1.0\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: "@ strlen(%data) @"\r\n\n"@ %data;
}
function TCPObject::createGetPacket(%this, %host, %path)
{
return "GET "@ %path @" HTTP/1.1\r\nHost: "@ %host @"\r\nUser-Agent: Torque/1.0\r\n\r\n";
}
};
--- End code ---
Examples:
--- Code: ---%packet = %tcp.createGetPacket("google.com", "/lol/asdf.txt");
%tcp.send(%packet);
//Your variable sending with POST
%packet = %tcp.createPostPacket("google.com", "/submit.php", "variable=nothing&cookies=impossible");
%tcp.send(%packet);
//Your variable sending with GET
%packet = %tcp.createGetPacket("google.com", "/submit.php?variable=nothing&cookies=impossible");
%tcp.send(%packet);
--- End code ---
I also suggest making these into regular functions, they shouldn't be in every TCPObject like I did.
Bauklotz:
Why are the functions in a package (Cloud_TCPObjects)?
otto-san:
--- Quote from: Bauklotz on October 03, 2010, 02:15:48 AM ---Why are the functions in a package (Cloud_TCPObjects)?
--- End quote ---
why not? :cookieMonster:
Pew446:
--- Quote from: Bauklotz on October 03, 2010, 02:15:48 AM ---Why are the functions in a package (Cloud_TCPObjects)?
--- End quote ---
Because he is making some kind of mod that is supposed to be better than rtb. I think he just cloned it.