Gamestudio Links
Zorro Links
Newest Posts
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 715 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 4 1 2 3 4
Re: GS_HTTP/Peacekeeper-plugin [Re: broozar] #97467
11/15/06 16:31
11/15/06 16:31
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
no, $_FILES is a predefined dictionnary. well, if that's the case, use 'file' and change $_FILE[0] to $_FILE['file'] in the php script.

Re: GS_HTTP/Peacekeeper-plugin [Re: Joey] #97468
11/15/06 23:58
11/15/06 23:58
Joined: Jun 2005
Posts: 4,875
broozar Offline OP
Expert
broozar  Offline OP
Expert

Joined: Jun 2005
Posts: 4,875
tried, without success.

Re: GS_HTTP/Peacekeeper-plugin [Re: broozar] #97469
11/16/06 00:05
11/16/06 00:05
Joined: Jun 2005
Posts: 4,875
broozar Offline OP
Expert
broozar  Offline OP
Expert

Joined: Jun 2005
Posts: 4,875
this is the code that comes along with the dll in a *.pas file, i guess it's what you'd call the source code:

Quote:

function HTTP_PostFile(id: gsfixed; URL,Filename, pVar: PA4_STRING): gsfixed;
const
LR : String[2] = #13#10;
var
Buf,Boundry,ContentTypePost,PostVar: String;
FileToSend : TMemoryStream;
Error: Integer;
function Inputtext(Name,Value: String): string;
begin
result := format(lr+'%s%sContent-Disposition: form-data; name="%s"%s%s%s%s'+#13#10,[boundry,lr,name,lr,lr,lowercase( value ),lr] );
end;
begin
Error := 0;
try
PostVar := StrPas(pVar^.chars);
THTTPCli(HTTPList[FIX2INT(id)]).SendStream := TMemoryStream.Create;

Boundry := '-----------------------------7cf29e12c04'; { Specified in Multipart/form-data RFC }
ContentTypePost := 'multipart/form-data; boundary=' + copy(Boundry,3,length(boundry));

Buf := Boundry + LR + 'Content-Disposition: form-data; name="uploadFile1"; filename="' + ExtractFileName(ExtractFilePath(ParamStr(0)) + StrPas(filename^.chars)) + '"'
+ LR + 'Content-Type: application/x-compress' + LR + LR;
//i don't think the IMAGE/PJPEG matters much
//my opinion on this would be that once it's set as this
//the file will be uploaded in BINARY

THTTPCli(HTTPList[FIX2INT(id)]).SendStream.Write(Buf[1], Length(Buf));

FileToSend := TMemoryStream.Create;
// Open File with TMemorystream
FileToSend.LoadFromFile(ExtractFilePath(ParamStr(0)) + StrPas(filename^.chars));
// load it up
FileToSend.SaveToStream(THTTPCli(HTTPList[FIX2INT(id)]).SendStream);
// Dump out file to TMemorystream
FileToSend.Free;
// andddd free it up
if PostVar<>'' then Buf := InputText('variable',PostVar);
Buf := ConCat(buf,Boundry+'--'); {This is to signify the END of our transactions }
THTTPCli(HTTPList[FIX2INT(id)]).SendStream.Write(Buf[1], Length(Buf));

TMemoryStream(ResultList[FIX2INT(id)]).Clear;
THTTPCli(HTTPList[FIX2INT(id)]).RcvdStream := TMemoryStream(ResultList[FIX2INT(id)]);
THTTPCli(HTTPList[FIX2INT(id)]).SendStream.Seek(0,0);
THTTPCli(HTTPList[FIX2INT(id)]).URL := StrPas(URL^.chars);
WorkList[FIX2INT(id)] := '1';
THTTPCli(HTTPList[FIX2INT(id)]).PostAsync;
except
Error := 1;
end;
result := INT2FIX(Error);
end;




Re: GS_HTTP/Peacekeeper-plugin [Re: broozar] #97470
11/16/06 03:49
11/16/06 03:49
Joined: Nov 2003
Posts: 108
Oklahoma, USA
FixxeR Offline
Member
FixxeR  Offline
Member

Joined: Nov 2003
Posts: 108
Oklahoma, USA
This may be a stupid question to ask, but since you're executing a PHP file from the A6 Engine I thought I should. Do you have Apache/PHP running, or a background PHP interpreter, to execute the PHP code?

Edit:
Okay, I see now that you're executing the PHP file from a server. I'll start testing it to see if I can get it to work.

FixxeR

Last edited by FixxeR; 11/16/06 03:56.

John Dies at the End - One of the best fictional stories online. Join the fight for Internet Freedom
Re: GS_HTTP/Peacekeeper-plugin [Re: FixxeR] #97471
11/16/06 10:33
11/16/06 10:33
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
good that i can read object pascal... uum, i don't see a reason for the fourth parameter, the string. it's not that obvious what it does, and i'm not that much into the http protocol to decipher what it actually does. i think that this gives you the possibility to actually post variables as with the html input fields. the rest seems clear to me since i've once written an asynchronous upload script in phython and php, writing the uploaded form data as-is (the raw multipart upload) in a file. your form field name is 'uploadFile1', so try $_FILE['uploadFile1'].

are you really sure that you have given the filename as relative path to your gamestudio exe?

could you post the return code of the function call? just curious wether the delphi dll throws an error or not.

joey.

ps: is it just me or has the coder of this dll an awful coding style?

Re: GS_HTTP/Peacekeeper-plugin [Re: Joey] #97472
11/18/06 01:53
11/18/06 01:53
Joined: Nov 2003
Posts: 108
Oklahoma, USA
FixxeR Offline
Member
FixxeR  Offline
Member

Joined: Nov 2003
Posts: 108
Oklahoma, USA
I think that the fourth variable is for the post method but, like Joey said, it isn't really used so it's difficult to tell.

FixxeR


John Dies at the End - One of the best fictional stories online. Join the fight for Internet Freedom
Re: GS_HTTP/Peacekeeper-plugin [Re: FixxeR] #97473
11/19/06 18:04
11/19/06 18:04

A
Anonymous
Unregistered
Anonymous
Unregistered
A



Has someone an idea how to pass (set up) a proxy with GS_HTTP/Peacekeeper-plugin?

thanx, mercuryus

Re: GS_HTTP/Peacekeeper-plugin [Re: ] #97474
11/26/06 09:53
11/26/06 09:53
Joined: Jun 2005
Posts: 4,875
broozar Offline OP
Expert
broozar  Offline OP
Expert

Joined: Jun 2005
Posts: 4,875
well, nothing changed. http_return does not return anything, just an empty string, no error code.
i decided to write a mail directly to the creator, see if it helps.

Re: GS_HTTP/Peacekeeper-plugin [Re: broozar] #97475
11/27/06 21:02
11/27/06 21:02
Joined: Jun 2005
Posts: 4,875
broozar Offline OP
Expert
broozar  Offline OP
Expert

Joined: Jun 2005
Posts: 4,875
this is the official answer:

Quote:


Just use HTTP_PostFile2()? The forth variable in HTTP_PostFile() is for
sending name=value pairs in addition to the file.

The path of the file is:

ExtractFilePath(ParamStr(0)) + StrPas(filename^.chars)

Which means ExtractFilePath(c:\whatever\whatever\myacknex.exe) + filename.

In the case of preview or whatever in A6 the file would need to be in
the same directory as the acknex EXE which is the gstudio\bin dir. Also
if you include directory slashs in that filename you have to double them up.

So:
c:\program files\gstudio\bin\acknex.exe
c:\program files\gstudio\bin\gshttp.dll
c:\program files\gstudio\bin\images\myfile.jpg
c:\program files\gstudio\bin\myfile2.jpg
c:\program files\gstudio\myproject\whatever.wdl

HTTP_PostFile2(0,
'http://www.whatever.com/whatever.php','images\\myfile.jpg');


HTTP_PostFile2(0, 'http://www.whatever.com/whatever.php','myfile2.jpg');

Published it would be something like:
c:\program files\myproject\acknex.exe
c:\program files\myproject\gshttp.dll
c:\program files\myproject\images\myfile.jpg
c:\program files\myproject\myfile2.jpg
c:\program files\myproject\whatever.wdl


Something like that.

Also, the GS_Python plugin provides more robust HTTP stuff.

Thanks,
Cellulaer





now i do get a string back, it says "FAILURE", which is certainly fron the php script. something must be wrong there.

now, this is my code:

Code:

dll_handle = dll_open("GSHTTP.dll");
HTTP_Create(0);
HTTP_PostFile2 (0, "http://whateverurl/anonymus-upload.php", serversettings); //serversettings is a file namend "workstation1.bz3", a plain text file
while (HTTP_IsWorking(0)==1) {
wait(1);
}
HTTP_Results(0,results_str);
HTTP_Free(0);
dll_close(dll_handle);
wait(1);

////////////////////////////////////////////////this was the wdl code, now the php:

<?php
if (count($_FILES) && $_FILES['name']['error'])
{
$filename = $_FILES['name']['name'];
if (move_uploaded_file($_FILES['name']['tmp_name'], $filename)) {
echo "SUCCESS";
} else {
echo "FAILURE";
}
} else {
echo "FAILURE";
}
?>



Re: GS_HTTP/Peacekeeper-plugin [Re: broozar] #97476
11/28/06 20:39
11/28/06 20:39
Joined: Jun 2005
Posts: 4,875
broozar Offline OP
Expert
broozar  Offline OP
Expert

Joined: Jun 2005
Posts: 4,875
after changing everything into 'uploadFile1' (not everything of course, just the important vars) i still get the error and i am really lost. please help me once more. this is drivin me crazy...

Page 3 of 4 1 2 3 4

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1