ShowerThoughts
2009-05-08 22:47:37
Hey, scripters!
Tootoot222 and me created a PictureDatabase script.
It uses PHP for connection to the database.
You have to fill in 2 cons, then you can put your picture in the database.
The script can add it and get it and preview the picture.
In your script your probably only need the GetPFromDatabase function.
Which works like this:
[ScreenShot of the script in action ^^.]

Scar Add and Get Script + Preview.
The Get Function.
Add this to your script for the getting part(few lines).
Note:
We don't need credits. Since this is not so spectacular.
The only thing you have to do is adding the get function to your script,
fill in the Name:string; parameter.
We hope you enjoy it!
~Hermen & Tootoot222
Tootoot222 and me created a PictureDatabase script.
It uses PHP for connection to the database.
You have to fill in 2 cons, then you can put your picture in the database.
const
Name = 'Example';
Path = 'C:\Picture.bmp';
One line to add it to the database.
AddPToDatabase(Name, Width, height, BMPString: string);
Note: you need a small procedure to perform ^.The script can add it and get it and preview the picture.
In your script your probably only need the GetPFromDatabase function.
Which works like this:
var
BMP: integer;
BMP := GetPFromDatabase('PictureName');//Name.
Note: you need a small function to perform ^.[ScreenShot of the script in action ^^.]

Scar Add and Get Script + Preview.
program New;
var
W, H, BMP: Integer;
const
Name = 'Flag2';//My P0wnage flag
Path = 'C:\Afbeeldingen\B.bmp';//Path to picture.
CheckWorking = true;//Preview if true.
procedure AddPToDatabase(Name, Width, height, BMPString: string);//Adds the BMP.
var
HTTPClient: Integer;
Code:string;
begin
Writeln(Length(BMPString));
HTTPClient := InitializeHTTPClient(False, False);
AddPostVariable(HTTPClient, 'Name', Name);
AddPostVariable(HTTPClient, 'Width', Width);
AddPostVariable(HTTPClient, 'Height', Height);
AddPostVariable(HTTPClient, 'BMPString', BMPString);
Code := PostHTTPPageEx(HTTPClient, 'http://server01.impsoft.info/IN.php');
Writeln(Code);
end;
function GetPFromDatabase(Name: string): integer;//Gets the BMP.
var
HTTPClient, P: Integer;
Code, D: String;
A :array of string;
begin
HTTPClient := InitializeHTTPClient(False, False);
AddPostVariable(HTTPClient, 'Name', Name);
Code := PostHTTPPageEx(HTTPClient, 'http://server01.impsoft.info/OUT.php');
A:= Explode(#10, Code);
if StartsWith('GOOD', A[0]) then
begin
P:= Pos(':', A[1]);
W := StrToIntDef(Trim(Copy(A[1], P + 1, Length(A[1]) - P)), 0);
P:= Pos(':', A[2]);
H := StrToIntDef(Trim(Copy(A[2], P + 1, Length(A[2]) - P)), 0);
P:= Pos(':', A[3]);
D := Trim(Copy(A[3], Pos(':', A[3]) + 1, Length(A[3]) - P));
Result := BitmapFromString(W, H, D);
Exit;
end;
end;
procedure PreviewPicture;
var
Bmp: Integer;
begin
Bmp:= GetPFromDatabase(Name);//Gets
DisplayDebugImgWindow(W, H);
SafeCopyCanvas(GetBitmapCanvas(Bmp), GetDebugCanvas, 0, 0, W, H, 0, 0, W, H);
end;
begin
if (not (Path = '')) then
begin
BMP := LoadBitmap(Path);
GetBitmapSize(BMP, W, H);
AddPToDatabase(Name, IntToStr(W), IntToStr(H), BitmapToString(BMP));//Adds
FreeBitmap(BMP);
end;
if CheckWorking then PreviewPicture;//Preview
writeln('DONE!');
end.
The Get Function.
Add this to your script for the getting part(few lines).
function GetPFromDatabase(Name: string): integer;//Gets the BMP.
var
HTTPClient, P: Integer;
Code, D: String;
A :array of string;
begin
HTTPClient := InitializeHTTPClient(False, False);
AddPostVariable(HTTPClient, 'Name', Name);
Code := PostHTTPPageEx(HTTPClient, 'http://server01.impsoft.info/OUT.php');
A:= Explode(#10, Code);
if StartsWith('GOOD', A[0]) then
begin
P:= Pos(':', A[1]);
W := StrToIntDef(Trim(Copy(A[1], P + 1, Length(A[1]) - P)), 0);
P:= Pos(':', A[2]);
H := StrToIntDef(Trim(Copy(A[2], P + 1, Length(A[2]) - P)), 0);
P:= Pos(':', A[3]);
D := Trim(Copy(A[3], Pos(':', A[3]) + 1, Length(A[3]) - P));
Result := BitmapFromString(W, H, D);
Exit;
end;
end;
Note:
We don't need credits. Since this is not so spectacular.
The only thing you have to do is adding the get function to your script,
fill in the Name:string; parameter.
We hope you enjoy it!
~Hermen & Tootoot222