I have a book 'Building internet app's with D2' and I tried
some examples from it, but they don't work.
I'm getting error :
-----------------------------------------------------
500 Server Error
The server encountered an internal error or misconfiguration and was unable
to complete your request.
Please contact the server administrator, [no address given] and inform them
of the time the error occurred, and anything you might have done that may
have caused the error.
---------------------------------------------------------
HTML page looks like that :
<HTML>
<BODY>
<H1>EXAMPLE 1</H1>
<FORM ACTION="HTTP://DEFAULT/CGI-BIN/QUECGI1.EXE" METHOD="POST">
<INPUT TYPE="SUBMIT" VALUE="PRITISNI TU !">
</FORM>
</BODY>
</HTML>
-------------------------------------------
I tried same HTML page at www.pacg.com/que/example1.htm and it works!!
Can anybody tell me if CGI works with Personal Web server and
if anybody can write me some example which will work on personal
web server.
HELPPPPP !!! Thank's DARKO
------=_NextPart_000_01BCEF7A.0F607700
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Hi Darko
PWS does support CGI - no problems!
Attached is an "Object Repository Application" allowing D2 to create CGI
apps. Just dump it in a subfolder below your ObjRepos folder and add a
section like the one below to the Delphi32.dro file...
---------------------
[C:\PROGRAM FILES\DELPHI 2.0\OBJREPOS\LOGOAPP\CGIAPP]
Type=ProjectTemplate
Name=CGI Application
Page=Projects
Icon=C:\PROGRAM FILES\DELPHI 2.0\OBJREPOS\LOGOAPP\CGIAPP.ICO
Description=Common Gateway Interface Application.
Author=Troels S Eriksen
DefaultProject=0
---------------------
Regards
Troels
------=_NextPart_000_01BCEF7A.0F607700
Content-Type: application/octet-stream; name="CGIAPP.res"
Content-Transfer-Encoding: base64
Content-Description: CGIAPP.res (Data resource)
Content-Disposition: attachment; filename="CGIAPP.res"
AAAAACAAAAD//wAA//8AAAAAAAAAAAAAAAAAAAAAAADoAgAAIAAAAP//AwD//wEAAAAAABAQBgQA
AAAAAAAAACgAAAAgAAAAQAAAAAEABAAAAAAAgAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAACA
AAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA/wD/AP//AAD///8AAAAA
AAAAAAAAAAAAAAAAAAAREREREARUVFQDMzMwAAAAkREREREFRUVAMzMzMzAAAJmZmZmRDNzcAzO7
u7MzAACZmZmZmQDNwDO7u7u7MwAAmZmZmZmRDNA7u7u7u7MAAJmQAAAJkQAAO7sAALu7AACZkAAA
0JkQALuwwAALuwAAmZAADcAJkAAABNwAO7sAAJmQAAzUCZAAAAXNA7u7AACZkAANxQmQAAAE3Au7
sAAAmZAADNQJkAADBc0LsAAAAJmQAA3FCZAAOwTcAAAAAACZkAAM1AmQALsFzQAAAAAAmZERDcUJ
kEC7BNwAAzMAAJmRERDcUABQu7AAADuzAACZmZmQzc3NwLu7u7u7uwAAmZmZkQzc3NQLu7u7u7AA
AJmZmZkQzc3NQLu7u7AAAAAAAAAAAAAAAAAAAAAAAAAAB4AABwAAeAAAd3d3gAAAAAeAAHdwAHgA
B3AAB3gAAAAHgAB4cAB4AAdwAAB4AAAAB4AHcHcAeAAAAAAHeAAAAAeAB4B3AHgAAAAAd4AAAAAH
gHcAB3B4AAAHd4AAAAAAB4h4AAd4eAAHiAAAAAAAAAeHcAAAd3gAB4AAAAAAAAAHd4AAAHd4AAeA
AAB4AAAAB3cAAAAHeAAHeAAHeAAAAAd4AAAAB3gAAAd3eAAAAAAAAAAAAAAAAAAAAAAAAADAGAgf
gAAAB4AAAAOAAAABgAAAAYAAAAGAAAABg4CAwYMAwAGDAPABgwDgA4MAwAeDAIAfgAAAY4AAAEGA
AAABgAAAAYAAAAOAAAAHgBAQH8MYYA/CCEAHwghDh8AARwfAAHgPwEBgH8BAQH/A4EOHwOBDh8Hw
QAfB8GAPw/h4PxQAAAAwAAAA//8OAE0AQQBJAE4ASQBDAE8ATgAAAAAAAAAAABAQBgQAAAAAAAAA
AAAAAQABACAgEGUBAAQA6AIAAAEA
------=_NextPart_000_01BCEF7A.0F607700
Content-Type: application/octet-stream; name="CGIAPP.ICO"
Content-Transfer-Encoding: base64
Content-Description: CGIAPP.ICO (Icon)
Content-Disposition: attachment; filename="CGIAPP.ICO"
AAABAAEAICAQAAAAAADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAgAIAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAICAgAAAAP8AAP8AAAD//wD/AAAA
/wD/AP//AAD///8AAAAAAAAAAAAAAAAAAAAAAAAREREREARUVFQDMzMwAAAAkREREREFRUVAMzMz
MzAAAJmZmZmRDNzcAzO7u7MzAACZmZmZmQDNwDO7u7u7MwAAmZmZmZmRDNA7u7u7u7MAAJmQAAAJ
kQAAO7sAALu7AACZkAAA0JkQALuwwAALuwAAmZAADcAJkAAABNwAO7sAAJmQAAzUCZAAAAXNA7u7
AACZkAANxQmQAAAE3Au7sAAAmZAADNQJkAADBc0LsAAAAJmQAA3FCZAAOwTcAAAAAACZkAAM1AmQ
ALsFzQAAAAAAmZERDcUJkEC7BNwAAzMAAJmRERDcUABQu7AAADuzAACZmZmQzc3NwLu7u7u7uwAA
mZmZkQzc3NQLu7u7u7AAAJmZmZkQzc3NQLu7u7AAAAAAAAAAAAAAAAAAAAAAAAAAB4AABwAAeAAA
d3d3gAAAAAeAAHdwAHgAB3AAB3gAAAAHgAB4cAB4AAdwAAB4AAAAB4AHcHcAeAAAAAAHeAAAAAeA
B4B3AHgAAAAAd4AAAAAHgHcAB3B4AAAHd4AAAAAAB4h4AAd4eAAHiAAAAAAAAAeHcAAAd3gAB4AA
AAAAAAAHd4AAAHd4AAeAAAB4AAAAB3cAAAAHeAAHeAAHeAAAAAd4AAAAB3gAAAd3eAAAAAAAAAAA
AAAAAAAAAAAAAADAGAgfgAAAB4AAAAOAAAABgAAAAYAAAAGAAAABg4CAwYMAwAGDAPABgwDgA4MA
wAeDAIAfgAAAY4AAAEGAAAABgAAAAYAAAAOAAAAHgBAQH8MYYA/CCEAHwghDh8AARwfAAHgPwEBg
H8BAQH/A4EOHwOBDh8HwQAfB8GAPw/h4Pw==
------=_NextPart_000_01BCEF7A.0F607700
Content-Type: application/octet-stream; name="CGIAPP.dpr"
Content-Transfer-Encoding: quoted-printable
Content-Description: CGIAPP.dpr (Delphi)
Content-Disposition: attachment; filename="CGIAPP.dpr"
program CGIAPP;
{$LONGSTRINGS ON}
{$APPTYPE CONSOLE}
uses
Classes, { Delphi Object Classes library interface }
Windows, { Windows API types and functions interface }
GateWay; { Common Gateway Interface unit (CGI) }
{$R *.RES}
type
TCGI =3D class (TGateway)
private
{ private parts.. (sorry) procedures }
protected
{ protected procedures }
public
{ public procedures }
procedure Run;
procedure MutexTimeout;
end;
procedure TCGI.run;
begin
{ Enter your code here
}
end;
procedure TCGI.MutexTimeout;
begin
{ Enter code to return a error message to the HTTP client here
}
WriteLn('Content-type: text/plain');
WriteLn;
WriteLn('Another instance is running. Try again in a moment');
end;
var
CGI : TCGI;
BEGIN
{ Do not change anything except the Mutex flag and TimeOut value in
this part
}
CGI:=3DTCGI.create; { Create the Gateway object }
With CGI do try
Mutex :=3DTRUE; { When TRUE only one instance is allowed }
TimeOut:=3D5; { Sec. to wait before returing error if Mutex is =
TRUE }
Execute; { Execute the CGI application }
finally
free; { Free the gateway object }
end;
END.
------=_NextPart_000_01BCEF7A.0F607700
Content-Type: application/octet-stream; name="GateWay.pas"
Content-Transfer-Encoding: quoted-printable
Content-Description: GateWay.pas (Delphi)
Content-Disposition: attachment; filename="GateWay.pas"
unit GateWay;
{$LONGSTRINGS ON}
{$APPTYPE CONSOLE}
{ CGI\1.1 Dependent implementation of GateWay unit }
{ FREEWARE -> But ALL RIGHTS RESERVED }
{ Copyrights by T Skovmand Eriksen, 1996-1997 }
{ Distribution of this file only allowed with }
{ the explicit permission of T Skovmand Eriksen }
{ EMail-address: TSEr...@Cyberdude.com }
{ Rev. 02 : Mutex protection added }
interface
uses
Classes;
type
{ type def of the CGI\1.1 Enviroment strings - or most of them }
TCgiEnv =3D (ceAUTH_PASS, ceAUTH_REALM, ceAUTH_TYPE,
ceCONTENT_LENGTH, ceCONTENT_TYPE, ceGATEWAY_INTERFACE,
ceHTTP_ACCEPT, ceHTTP_USER_AGENT, cePATH,
cePATH_INFO, cePATH_TRANSLATED, ceQUERY_STRING,
ceREMOTE_ADDR, ceREMOTE_HOST, ceREMOTE_IDENT,
ceREMOTE_USER, ceREQUEST_LINE, ceREQUEST_METHOD,
ceSCRIPT_NAME, ceSERVER_NAME, ceSERVER_PORT,
ceSERVER_PROTOCOL, ceSERVER_SOFTWARE, ceSECURITY_STATUS);
{ type def of the CGI\1.1 Content-types (MIME) }
TContents=3D(coAU, coDefault, coDOC, coGIF, coHTML, coJPEG, coMPEG,
coPDF, coPS, coRTF, coTXT, coUTF, coWAV, coXBM, coZIP);
TGateWay =3D class
private
DataBuffer: string;
protected
procedure ReadClientData;
public
{ Do not rewrite this to properties - it's tempting but they'll slow
down your final application
}
Mutex : boolean;
TimeOut : integer;
{ Input }
function GetRawData:string;
function IsParam(name:string):boolean;
function GetParamByName(name:string):string;
{ Utilities / tools }
function DeHex(s:string):string;
function WebRoot:string;
function AsDosPath(const path:string):string;
function AsWebPath(const path:string):string;
function CgiName:string;
function GetEnvStr(Name:TCgiEnv):string;
{ text formatting rutines }
function MakeParagraphs(s:string):string;
function LineBreaks(s:string):string;
{ Object Init, Exit and Execution }
constructor Create;
procedure Free;
procedure Run; { CGI standard code }
procedure Execute; { Executes the CGI standard code }
procedure MutexTimeout; { Errorhandling when timeout occurs using =
Mutex }
{ Output }
procedure ReturnURL (const URL:string);
procedure ReturnMsg (const Msg:string);
procedure ReturnFile(const FileName:string);
procedure ReturnText(var Text:TStringList);
procedure ReturnHTML(var HTML:TStringList);
procedure ReturnData(var Data;size:integer;style:TContents);
end;
implementation
{$D TGateWay - Common GateWay Interface Unit by T S Eriksen }
uses
sysutils,
Windows;
const
cEnvStr : array[ceAUTH_PASS..ceSECURITY_STATUS] of string =3D
('AUTH_PASS','AUTH_REALM','AUTH_TYPE','CONTENT_LENGTH',
'CONTENT_TYPE','GATEWAY_INTERFACE','HTTP_ACCEPT',
'HTTP_USER_AGENT','PATH','PATH_INFO','PATH_TRANSLATED',
'QUERY_STRING','REMOTE_ADDR','REMOTE_HOST',
'REMOTE_IDENT','REMOTE_USER','REQUEST_LINE',
'REQUEST_METHOD','SCRIPT_NAME','SERVER_NAME',
'SERVER_PORT','SERVER_PROTOCOL','SERVER_SOFTWARE',
{ further EnvStr's should be inserted here - rembember to
update the TCGIENV structure }
'SECURITY_STATUS');
cContents : array[coAU..coZIP] of string[25] =3D
('audio/basic','application/octet-stream',
'application/msword','image/gif','text/html',
'image/jpeg','video/mpeg','application/pdf',
'application/postscript','application/rtf',
'text/plain','text/plain; charset=3Dunicode-1-1',
'audio/wav','image/x-xbitmap','application/zip');
cDefaultContents =3D 'content-type : text/plain';
constructor TGateWay.Create;
begin
Inherited Create;
ReadClientData;
Mutex :=3DTRUE;
TimeOut :=3D5;
end; { Create }
procedure TGateWay.Free;
begin
inherited Free;
end; { Free }
procedure TGateWay.MutexTimeOut;
begin
{ This must be overridden by any descendant in order to create
an application using Mutex to protect itsself
}
end;
procedure TGateWay.Run;
begin
{ This must be overridden by any descendant in order to create
an application
}
end; { Run }
procedure TGateWay.Execute;
var
FMutex : Integer;
UniqueName : array[0..16] of char;
begin
Case Mutex of
TRUE : begin
{ Create unique named mutex using the script-name }
StrPCopy(UniqueName,'Delphi_'+CgiName);
FMutex :=3D CreateMutex(nil, False, UniqueName);
try
if WaitForSingleObject(FMutex, TimeOut*1000) =3D WAIT_TIMEOUT =
then
MutexTimeOut
else
run;
finally
{ Free mutex and close handle to it }
ReleaseMutex(FMutex);
CloseHandle(FMutex);
end;
end; { TRUE }
FALSE : Run;
end;
end; { Execute }
function TGateWay.GetEnvStr(Name:TCgiEnv):string;
{ Read an environment string and return it as a long string }
{ If any error or no data, an empty string is returned }
const
BufMax =3D $FFF0;
var
Buffer : pChar;
begin
result:=3D'';
try
GetMem(Buffer,BufMax);
If GetEnvironmentVariable(pChar(cEnvStr[Name]),Buffer,BufMax)>0 =
then
result:=3DBuffer;
finally
FreeMem(Buffer,BufMax);
end;
end; { GetEnvStr }
function TGateWay.AsWebPath(const path:string):string;
{ Converts a dos path (drive\path\file) to the
corresponding web path (HTTP://server/path/file) }
var
s : string;
begin
s:=3Dpath;
While pos('/',s)>0 do s[Pos('/',s)]:=3D'\';
if pos(lowercase(WebRoot),lowercase(s))>0 then begin
{ remove web-root - insert servername instead }
delete(s,1,length(webroot));
s:=3D'HTTP://'+GetEnvStr(ceSERVER_NAME)+'\'+s;
While pos('\\',s)>0 do delete(s,pos('\\',s),1);
end;
While pos('\',s)>0 do s[pos('\',s)]:=3D'/';
result:=3Ds;
end; { AsWebPath }
function TGateWay.AsDosPath(const path:string):string;
{ Converts a web path (HTTP://server/path/file) to the
corresponding dos path (drive\path\file) }
var
s : string;
begin
s:=3Dpath;
While pos('\',s)>0 do s[pos('\',s)]:=3D'/';
if pos(lowercase('http://'+getenvstr(ceSERVER_NAME)),lowercase(s))>0 =
then begin
delete(s,1,length('http://'+GetEnvStr(ceSERVER_NAME)));
s:=3DWebRoot+'\'+s;
end;
While pos('/',s)>0 do s[Pos('/',s)]:=3D'\';
While pos('\\',s)>0 do delete(s,pos('\\',s),1);
result:=3Ds;
end; { AsDosPath }
function TGateWay.DeHex(s:string):string;
{ removes hex codes and plus'es from string and inserts
normal characters }
function Resolve(c:char):integer;
{ Convert char to integer value }
begin
case byte(c) of
48..57 : Result:=3Dbyte(c)-48;
65..70 : Result:=3Dbyte(c)-55;
else Result:=3D0;
end;
end; { resolve }
var
a : integer;
begin
{ Change "+" to " " }
While Pos('+',s)>0 do s[pos('+',s)]:=3D' ';
{ Change hex codes to characters }
a:=3Dlength(s);
While (a>0) do try
if s[a]=3D'%' then begin
s[a]:=3DChar(Resolve(s[a+1])*16+Resolve(s[a+2]));
system.delete(s,a+1,2);
end;
finally
dec(a);
end;
result:=3Ds;
end; { DeHex }
function TGateWay.LineBreaks(s:string):string;
{ changes all line breaks to html-linebreaks -
should be called after MakeParagraph }
begin
While pos(#13#10,s)>0 do begin
Insert('<BR>'#13,s,pos(#13#10,s));
delete(s,pos(#13#10,s),2);
end;
result:=3Ds;
end; { LineBreaks }
function TGateWay.MakeParagraphs(s:string):string;
{ Changes double line breaks with paragraphs -
should be called before LineBreaks }
begin
While pos(#13#10#13#10,s)>0 do begin
Insert('</P>'#13'<P>',s,pos(#13#10#13#10,s));
delete(s,pos(#13#10#13#10,s),4);
end;
result:=3D'<P>'+s+'</P>';
end; { MakeParagraphs }
procedure TGateWay.ReadClientData;
{ Reads all data from client into a DataBuffer string
works for both GET and POST }
var
Len : integer;
c : char;
begin
DataBuffer:=3D'';
If UpperCase(GetEnvStr(ceREQUEST_METHOD))=3D'GET' then begin
{ Method was GET - just copy ceQUERY-STRING }
DataBuffer:=3DGetEnvStr(ceQUERY_STRING);
end else { if post then } begin
{ Method was POST - read data from "Standard Input" (StIn) }
{ Get data length - return ZERO if any error }
Len:=3DStrToIntDef(GetEnvStr(ceCONTENT_LENGTH),0);
While Len>0 do try
Read(c);
DataBuffer:=3DDataBuffer+c;
finally
Dec(len);
end;
end;
end; { ReadClientData }
function TGateWay.WebRoot:string;
var
s : string;
begin
result:=3DGetEnvStr(cePATH_TRANSLATED);
end; { WebRoot }
function TGateWay.CgiName:string;
{ Just like application.exename - this returns path to
the CGI script relative to webroot }
begin
result:=3DGetEnvStr(ceSCRIPT_NAME);
end; { Cginame }
function TGateWay.GetRawData:string;
{ returns raw data - spaces is plus'es, non-ascii-chars is hex codes =
etc }
begin
result:=3DDataBuffer;
end; { GetRawData }
function TGateWay.GetParamByName(name:string):string;
{ Search for a parameter named "name=3D" , returns any data pending or
an empty string }
var
s : string;
a : integer;
begin
s:=3DDataBuffer;
a:=3Dpos(lowercase(name)+'=3D',lowercase(s));
if a>0 then begin
{ Kopier fra pos til eol }
a:=3Da+length(name)+1;
s:=3DCopy(s,a,length(s));
{ Hvis flere strenge f=F8lger - slet dem }
if pos('&',s)>0 then delete(s,pos('&',s),length(s));
result:=3DDeHex(s);
end else
result:=3D'';
end; { GetParamByName }
function TGateWay.IsParam(name:string):boolean;
{ Returns TRUE if a param named "Name=3D" exists or if name equals the
full length of the databuffer }
begin
IsParam:=3D(Pos(lowercase(name)+'=3D',lowercase(Databuffer))>0) or
(lowercase(name)=3Dlowercase(databuffer));
end; { IsParam }
procedure TGateWay.ReturnURL(const URL:string);
{ Redirects the client to another server or page. URL should be full
protocol and adress - i.e. HTTP://server/path/page }
begin
WriteLn('location : '+URL);
WriteLn;
end; { Return URL }
procedure TGateWay.ReturnMsg(const Msg:string);
{ Redirects the client to another server or page. URL should be full
protocol and adress - i.e. HTTP://server/path/page }
begin
WriteLn(cDefaultContents);
WriteLn;
WriteLn(Msg);
end; { Return URL }
procedure TGateWay.ReturnFile(const FileName:string);
{ Sends a file from disk to client }
function DetectType(filename:string):TContents;
{ Detect type of file - if unknown set default "byte-stream" -
this could be made faster by converting the extension to
a DWORD before checking - but who cares... }
begin
FileName:=3DLowercase(ExtractFileExt(filename));
if Filename=3D'.au' then result:=3DcoAU else { audio/basic }
if Filename=3D'.doc' then result:=3DcoDOC else { =
application/msword }
if Filename=3D'.gif' then result:=3DcoGIF else { image/gif }
if Filename=3D'.htm' then result:=3DcoHTML else { text/html }
if Filename=3D'.html' then result:=3DcoHTML else { text/html }
if Filename=3D'.jpg' then result:=3DcoJPEG else { image/jpeg }
if Filename=3D'.jpeg' then result:=3DcoJPEG else { image/jpeg }
if Filename=3D'.mpg' then result:=3DcoMPEG else { video/mpeg }
if Filename=3D'.pdf' then result:=3DcoPDF else { application/pdf =
(acrobat reader) }
if Filename=3D'.ps' then result:=3DcoPS else { =
application/postscript }
if Filename=3D'.rtf' then result:=3DcoRTF else { application/rtf =
}
if Filename=3D'.txt' then result:=3DcoTXT else { text/plain }
if Filename=3D'.utf' then result:=3DcoUTF else { text/plain =
unicode }
if Filename=3D'.wav' then result:=3DcoWAV else { audio/wav }
if Filename=3D'.xbm' then result:=3DcoXBM else { image/x-xbitmap =
}
if Filename=3D'.zip' then result:=3DcoZIP else { application/zip =
}
result:=3DcoDefault; { =
application/octet-stream }
end;
var
Handle : THandle;
Out : integer;
Buffer : Array[0..16384] of Char;
a : integer;
begin
Handle:=3DFileOpen(FileName,0); { Open file for Read access }
If handle<0 then begin
{ This could be a status message - but which one ? }
WriteLn(cDefaultContents);
WriteLn;
WriteLn('Error reading file "'+Filename+'"');
end else try
{ Return file after advising client of type of data }
WriteLn('content-type : '+cContents[DetectType(FileName)]);
{
fprint(stdout,"Content-disposition: filename=3D\"%s\"\n",file);
fprint(stdout,"Content-length: %d\n\n",statbuf.st_size);
}
WriteLn;
Repeat
Out:=3DFileRead(Handle,Buffer,16384);
a:=3D0;
While a<out do try
Write(Buffer[a]);
finally
inc(a);
end;
until (out<>$FFF0);
finally
FileClose(Handle);
end;
end; { Return file }
procedure TGateWay.ReturnText(var Text:TStringList);
{ Sets output content to plain text and sends all data in the =
stringlist }
var
a : integer;
begin
WriteLn(cDefaultContents);
WriteLn;
a:=3D0;
While a<Text.count do try
WriteLn(Text.Strings[a]);
finally
inc(a);
end;
end; { Return Text }
procedure TGateWay.ReturnHTML(var HTML:TStringList);
{ Sets output content to html and sends all data in the stringlist }
var
a : integer;
begin
WriteLn(cDefaultContents);
WriteLn;
a:=3D0;
While a<HTML.count do try
WriteLn(HTML.Strings[a]);
finally
inc(a);
end;
end; { Return HTML }
procedure TGateWay.ReturnData(var Data;size:integer;style:TContents);
{ Read data from buffer and send them to the client - data has better
be less than 16 MB or problems will develop }
type
{ This structure is used for typecast to convert data to chars
- easy and fast }
TA =3D Array[0..$FFFFFF] of char;
var
a : integer;
begin
WriteLn('content-type : '+cContents[style]);
WriteLn('content-length: '+IntToStr(Size));
WriteLn;
a:=3D0;
While a<size do try
Write(TA(data)[a]);
finally
inc(a);
end;
end; { Return Data }
end.
{ Possible replys from CGI program:
'content-type : '
'location : '
'Status : '
}
------=_NextPart_000_01BCEF7A.0F607700--
Try to do following:
1.put the CGI program in SCRIPTS directory.
2.in HTML page
<FORM ACTION="HTTP://DEFAULT/SCRIPTS/QUECGI1.EXE" METHOD="POST">
hope it's help.
miles guo
Lars
Regards, -= Lou Rizzuto =-
--
Gordon Hamm
Voice Data Systems Inc.
Astoria Communications
360-686-8315
Louis Rizzuto wrote in message <347BB4...@bigfoot.com>...
I am relatively new to CGI stuff. In my limited understanding it seems
like the MS ISAPI is the equivalent of the CGI for UNIX right? Or, is there
such a thing as CGI for Win NT as well? Thanks.
Regards, -= Lou Rizzuto =-
Due to some performance and limited process functionality in MS IIS (NT
cannot do a real unix process fork) MS has decided only to use 32 bit
applications as CGI scripts.
Delphi 1.0 will not do, but Delphi 2.0 and 3.0 work just fine. To create a
CGI script you need to do the following.
1) Define functionality.
2) Define need an method (GET or POST).
3) In application do import the variables from IIS.
A suitable unit for this could be get at
http://www.regiolicht.nl/homepages/wbwaals1/index.html
look in the section The Dutch Software Support. And Get CGI32.
This full source code, and currently no limitations.
4) Your application can be a console application but it's better not.
My experience is to test it as console application and if it works
fine, disable
the console application.
5) Do not include {$R *.RES} because it kill's memory and performance under
IIS.
6) Do not make 16-bit api call's, there is toooooooo much overhead with the
WindowsOnWindows part of NT (WOWEXEC).
7) Plan your security.
In IIS you need to place your scripts in a cgi directory. There must be
read access defined in the ACL of the directory for the users SYSTEM,
CREATOR OWNER, IUSER_xxxx. There must be a virtual directory defined in the
internet Service manager.
The virtual directoy must have EXECUTE rights DO NOT GRANT READ RIGHTS.
If you grant read access in IIS, the cliƫnts do not want to execute the
script but try a download.
W.B. van der Waals
Could you explain 4) in more detail. What are the disadvantages of a
console app? BTW are you related to the scientist who gave us "Van
der Waals forces?"
--- Gary Wiltshire
Indeed, I'm related to dr. Van der Waals.
About the console application: This is told to me by a friend, i've asked
him what could be the problem with it. He told me that a console application
invoked cmd.exe. So i started to look after it myself and i couldn't find
any cmd.exe. So this cannot be true. So i don't see anything wrong with an
Console Application Script.
Sorry i told you this but i couldn't figure out myself what problem it would
be.
Friendly greetings by,
Double U Bee.
--
---------8=<----------------------------------------------------------------
------------
Life was ruined by internet, W.B.van der Waals
Life was ruined by Microsoft, Aka: UUBee
Then there was Novell, Aka: WB29
And life was better. wbw...@regiolicht.nl
-Better no Directory Services than MS Directory Services-
Gary A. Wiltshire <70523...@compuserve.com> wrote in message
<348efb87...@forums.borland.com>...
<gd&r>
--
Sun, 14 Dec 1997 22:29 EST
Jim O'Brien, R&D, PTT, Inc.
wiz...@ptti.com +1 (212) 972-1702
>Indeed, I'm related to dr. Van der Waals.
Do you find yourself weakly attracted to others? :)
-Steve
>I was going to say something nasty...then I thought it might be less
>than ideal to introduce a critical point.
I think it may be time for us to make a phase transition....
-Steve
--
Wed, 17 Dec 1997 10:25 EST