home *** CD-ROM | disk | FTP | other *** search
/ IT.SOFT 22 / ITSOFTCD_22.iso / pc / shareware22 / file3 / VQSERVER.ZIP / cgi / get / get.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1998-10-30  |  3.3 KB  |  156 lines

  1. program get;
  2. {
  3. get version 1.06.
  4. get is a demonstration CGI script supplied with vqServer.
  5. get is written in Borland Pascal version 7.
  6. get.exe runs on MS-DOS systems only.
  7. get and vqServer are copyright vqSoft and Steve Shering 1997-98.
  8. }
  9. uses
  10.   dos;
  11.  
  12.  
  13. const
  14.   endfield='=';
  15.   enddata='&';
  16.  
  17. var
  18.   querystring:string;
  19.  
  20.   tnf:integer;
  21.   tfield:array[1..10]of string;
  22.   tdata:array[1..10]of string;
  23.  
  24.   fname:string;
  25.   fnum:longint;
  26.   fref:text;
  27.  
  28.   chrsread:integer;
  29.   datalength:integer;
  30.  
  31.   i:integer;
  32.  
  33.   year,month,day,dow,hour,min,sec,sec100:word;
  34.  
  35.  
  36. function strof(tnum:longint):string;
  37. var
  38.   tstr:string;
  39. begin
  40.   str(tnum,tstr);
  41.   strof:=tstr;
  42. end;
  43.  
  44. function numof(tstr:string):integer;
  45. var
  46.   tnum:integer;
  47.   errcode:integer;
  48. begin
  49.   val(tstr,tnum,errcode);
  50.   numof:=tnum;
  51. end;
  52.  
  53. function readchar:char;
  54. var
  55.   tchar:char;
  56. begin
  57.   if chrsread<datalength then
  58.     begin
  59.       chrsread:=chrsread+1;
  60.       tchar:=querystring[chrsread];
  61.     end
  62.   else
  63.     tchar:=chr(0);
  64.   readchar:=tchar;
  65. end;
  66.  
  67. function readword(endchar:char):string;
  68. var
  69.   done:boolean;
  70.   tword:string;
  71.   i1:char;
  72. begin
  73.   done:=false;
  74.   tword:='';
  75.   while (not done) do
  76.     begin
  77.       i1:=readchar;
  78.       if i1='%' then
  79.         tword:=tword+chr(numof('$'+readchar+readchar))
  80.       else if i1='+' then
  81.         tword:=tword+' '
  82.       else if (i1=endchar) or (i1=chr(0)) then
  83.         done:=true
  84.       else
  85.         tword:=tword+i1;
  86.     end;
  87.   readword:=tword;
  88. end;
  89.  
  90. procedure readpair(tpair:integer);
  91. begin
  92.   tfield[tpair]:=readword(endfield);
  93.   tdata[tpair]:=readword(enddata);
  94. end;
  95.  
  96. procedure readdata;
  97. var
  98.   datalengthstring:string;
  99. begin
  100.   querystring:=getenv('query_string');
  101.   datalength:=length(querystring);
  102.   chrsread:=0;
  103.   tnf:=0;
  104.   while chrsread<datalength do
  105.     begin
  106.       tnf:=tnf+1;
  107.       readpair(tnf);
  108.     end;
  109. end;
  110.  
  111. begin
  112.  
  113. writeln('Content-type: text/html');
  114. writeln;
  115. writeln('<html>');
  116. writeln('<head>');
  117. writeln('<title>Demo CGI script (GET method)<TITLE>');
  118. writeln('</head>');
  119. writeln('<body bgcolor=#add8af>');
  120. writeln('<table border=0 cellspacing=0 cellpadding=2 cols=3 width=100%>');
  121. writeln('<tr>');
  122. writeln('<td valign=top>');
  123. writeln('<center>');
  124. writeln('<H1>Demo CGI script (GET method)</H1>');
  125. writeln('</center>');
  126. writeln('<P><HR></P>');
  127.  
  128. readdata;
  129.  
  130. writeln('<P>This is some of the information your browser sent.</p>');
  131. writeln('<LI>','Your name: ',getenv('REMOTE_HOST'),'</LI>');
  132. writeln('<LI>','Your IP address: ',getenv('REMOTE_ADDR'),'</LI>');
  133. writeln('<LI>','Bytes of data: ',getenv('CONTENT_LENGTH'),'</LI>');
  134.  
  135. i:=1;
  136. writeln('<P>The following information was received by the server.</P>');
  137. while i<=tnf do
  138.   begin
  139.     writeln('<LI>',tfield[i],': ',tdata[i],'</LI>');
  140.     i:=i+1;
  141.   end;
  142.  
  143. writeln('<P><hr></P>');
  144. writeln('<P>This page was generated by <i>get.exe</i> version 1.06.');
  145. writeln(' <i>get.exe</i> and <i>vq</i>Server are copyright © <i>vq</i>Soft and Steve Shering 1997-8.</p>');
  146. writeln('</td>');
  147. writeln('<td width=20></td>');
  148. writeln('<td valign=top width=150>');
  149. writeln('<A HREF=/index.html><IMG WIDTH=15 HEIGHT=15 BORDER=0 SRC=/vq/server/icons/utab.gif>Home page</A>');
  150. writeln('</td>');
  151. writeln('</tr>');
  152. writeln('</table>');
  153. writeln('</body>');
  154. writeln('</html>');
  155.  
  156. end.