Kyle Undefined
2012-01-10 18:03:58
Stopped development on this!
Ok, so here's a BETA version of my anti gold farming measures. It's messy and ugly, and could use a clean up.
Basically, what it does is, on startup it reaches out to my webserver and grabs the IP of the current autoer. Then, it returns their IP, Expiration Date (Now + 6 hours), and if there is already an IP in the database for the script name that you pass in with the "FAGF_Setup();" procedure.
If there is a record already, it returns the database row ID, IP, stored expiration date, and True for already in use. It then tells the user when they could run the script again and terminates.
Also, if it's a first entry, it adds a procedure to the OnTerminate procedure that will erase that record it added at startup when the script finishes.
Let me know what you think, I've included the zip file as long as posting the code here for a quick view. I also pasted a test script on how it would be run, although it won't do much use to you since I was using it to make sure all the calls were correct while tracing the database.
It goes in the Include folder, but I'm sure you already knew that :p
Also, hope you enjoy what I've gotten so far. Oh, and this can also be modified easily for the script authing.
EDIT: This is only a TESTING method, I had already written this code/documentation/name and it's more of a way to show that you "could" use a method like this for online script authing and could eliminate sharing as well. It literally takes 10 minutes to change it for that purpose.
I was just too lazy to change it around, so sorry for the confusion.
FAGF/FAGF.simba:
Test:
Ok, so here's a BETA version of my anti gold farming measures. It's messy and ugly, and could use a clean up.
Basically, what it does is, on startup it reaches out to my webserver and grabs the IP of the current autoer. Then, it returns their IP, Expiration Date (Now + 6 hours), and if there is already an IP in the database for the script name that you pass in with the "FAGF_Setup();" procedure.
If there is a record already, it returns the database row ID, IP, stored expiration date, and True for already in use. It then tells the user when they could run the script again and terminates.
Also, if it's a first entry, it adds a procedure to the OnTerminate procedure that will erase that record it added at startup when the script finishes.
Let me know what you think, I've included the zip file as long as posting the code here for a quick view. I also pasted a test script on how it would be run, although it won't do much use to you since I was using it to make sure all the calls were correct while tracing the database.
It goes in the Include folder, but I'm sure you already knew that :p
Also, hope you enjoy what I've gotten so far. Oh, and this can also be modified easily for the script authing.
EDIT: This is only a TESTING method, I had already written this code/documentation/name and it's more of a way to show that you "could" use a method like this for online script authing and could eliminate sharing as well. It literally takes 10 minutes to change it for that purpose.
I was just too lazy to change it around, so sorry for the confusion.
FAGF/FAGF.simba:
type
TFAGF = record
ID : Integer;
ScriptName : String;
UserIP : String;
ExpDate : String;
AlreadyConnected : Boolean;
end;
type
TFAGFArray = Array of TFAGF;
var
gSetup : TFAGF;
function OnSetup() : TFAGF;
var
responseArr : TStringArray;
begin
responseArr := Explode('|', GetPage('http://srl.kyleundefined.com/FAGF/setup.php'));
try
if(StrToBool(responseArr[3]))then
begin
with Result do
begin
ID := StrToInt(responseArr[0]);
UserIP := responseArr[1];
ExpDate := responseArr[2];
AlreadyConnected := StrToBool(responseArr[3]);
end;
end;
except
with Result do
begin
UserIP := responseArr[0];
ExpDate := responseArr[1];
AlreadyConnected := StrToBool(responseArr[2]);
end;
end;
end;
procedure OnTerminate();
var
FAGF_Client : Integer;
FAGF_PostData : String;
begin
try
FAGF_Client := InitializeHTTPClient(false, false);
FAGF_PostData := 'id=' + IntToStr(gSetup.ID);
PostHTTPPage(FAGF_Client, 'http://srl.kyleundefined.com/FAGF/remove.php', FAGF_PostData);
except
{Just eat it}
finally
FreeHTTPClient(FAGF_Client);
end;
end;
{Stolen from AddOnTerminate}
procedure FAGF_End(const proc : string);
var
OldProcs : TVariantArray;
i : integer;
begin
GetScriptProp(SP_OnTerminate,OldProcs);
for i := 0 to high(OldProcs) do
if lowercase(OldProcs[i]) = lowercase(proc) then
exit;
setlength(OldProcs,Length(OldProcs)+1);
OldProcs[high(OldProcs)] := proc;
SetScriptProp(SP_OnTerminate,oldprocs);
end;
procedure FAGF_Setup(script : String);
var
setup : TFAGF;
_id, FAGF_Client : Integer;
FAGF_PostData : String;
begin
setup := OnSetup();
setup.ScriptName := script;
if(not(setup.AlreadyConnected))then
begin
try
FAGF_Client := InitializeHTTPClient(false, false);
FAGF_PostData := 'script=' + script;
FAGF_PostData := PostHTTPPage(FAGF_Client, 'http://srl.kyleundefined.com/FAGF/add.php', FAGF_PostData);
_id := StrToInt(FAGF_PostData);
setup.ID := _id;
except
{Just eat it}
finally
FreeHTTPClient(FAGF_Client);
end;
gSetup := setup;
FAGF_End('OnTerminate');
end else
begin
WriteLn('You are already running this script from this IP, you can run ' +
'this script again at: ' + setup.ExpDate);
TerminateScript;
end;
end;
Test:
program new;
{$i srl/srl.simba}
{$i FAGF/FAGF.simba}
begin
SetupSRL();
FAGF_Setup('Test');
Wait(10000);
end.