+ tests/stripeol.hb
+ added script to strip spaces at EOL
* contrib/gtalleg/tests/test.prg
* contrib/gtwvg/tests/demoxbp.prg
* contrib/gtwvg/tests/wvgactivex.prg
* contrib/gtwvg/tests/wvgxbp.prg
* contrib/gtwvg/wvgclass.prg
* contrib/hbamf/tests/tstendin.prg
* contrib/hbbz2/tests/test.prg
* contrib/hbcairo/tests/fancytxt.prg
* contrib/hbcairo/tests/table.prg
* contrib/hbct/ctrand.prg
* contrib/hbct/doc/en/addascii.txt
* contrib/hbct/doc/en/atadjust.txt
* contrib/hbct/doc/en/count.txt
* contrib/hbct/doc/en/ct.txt
* contrib/hbct/doc/en/ctc.txt
* contrib/hbct/doc/en/ctmath.txt
* contrib/hbct/doc/en/ctmath2.txt
* contrib/hbct/doc/en/ctpad.txt
* contrib/hbct/doc/en/ctstr.txt
* contrib/hbct/doc/en/datetime.txt
* contrib/hbct/doc/en/dattime2.txt
* contrib/hbct/doc/en/exponent.txt
* contrib/hbct/doc/en/finan.txt
* contrib/hbct/doc/en/ftoc.txt
* contrib/hbct/doc/en/justify.txt
* contrib/hbct/doc/en/keyset.txt
* contrib/hbct/doc/en/misc1.txt
* contrib/hbct/doc/en/num1.txt
* contrib/hbct/doc/en/numat.txt
* contrib/hbct/doc/en/numconv.txt
* contrib/hbct/doc/en/pos1.txt
* contrib/hbct/doc/en/pos2.txt
* contrib/hbct/doc/en/posdiff.txt
* contrib/hbct/doc/en/print.txt
* contrib/hbct/doc/en/range.txt
* contrib/hbct/doc/en/relation.txt
* contrib/hbct/doc/en/remove.txt
* contrib/hbct/doc/en/replace.txt
* contrib/hbct/doc/en/screen1.txt
* contrib/hbct/doc/en/strdiff.txt
* contrib/hbct/doc/en/strswap.txt
* contrib/hbct/doc/en/token1.txt
* contrib/hbct/doc/en/token2.txt
* contrib/hbct/doc/en/trig.txt
* contrib/hbct/doc/en/video.txt
* contrib/hbct/doc/en/wordtoch.txt
* contrib/hbct/getinfo.prg
* contrib/hbfimage/tests/fitest.prg
* contrib/hbgd/gdimage.prg
* contrib/hbgd/tests/counter.prg
* contrib/hbgd/tests/gdtest.prg
* contrib/hbgd/tests/gdtestcl.prg
* contrib/hbgd/tests/test_out.prg
* contrib/hbide/idetags.prg
* contrib/hblzf/tests/test2.prg
* contrib/hbmisc/doc/en/ht_conv.txt
* contrib/hbmisc/fcomma.prg
* contrib/hbmisc/fileread.prg
* contrib/hbmisc/hbedit.prg
* contrib/hbnf/anomatch.prg
* contrib/hbnf/calendar.prg
* contrib/hbnf/clrsel.prg
* contrib/hbnf/dispmsg.prg
* contrib/hbnf/doc/en/aading.txt
* contrib/hbnf/doc/en/aavg.txt
* contrib/hbnf/doc/en/acctadj.txt
* contrib/hbnf/doc/en/acctmnth.txt
* contrib/hbnf/doc/en/acctqtr.txt
* contrib/hbnf/doc/en/acctweek.txt
* contrib/hbnf/doc/en/acctyear.txt
* contrib/hbnf/doc/en/adessort.txt
* contrib/hbnf/doc/en/aemaxlen.txt
* contrib/hbnf/doc/en/aeminlen.txt
* contrib/hbnf/doc/en/amedian.txt
* contrib/hbnf/doc/en/anomatch.txt
* contrib/hbnf/doc/en/any2any.txt
* contrib/hbnf/doc/en/aredit.txt
* contrib/hbnf/doc/en/asum.txt
* contrib/hbnf/doc/en/at2.txt
* contrib/hbnf/doc/en/bitclr.txt
* contrib/hbnf/doc/en/bitset.txt
* contrib/hbnf/doc/en/blink.txt
* contrib/hbnf/doc/en/byt2bit.txt
* contrib/hbnf/doc/en/byt2hex.txt
* contrib/hbnf/doc/en/byteand.txt
* contrib/hbnf/doc/en/byteneg.txt
* contrib/hbnf/doc/en/bytenot.txt
* contrib/hbnf/doc/en/bytexor.txt
* contrib/hbnf/doc/en/calendar.txt
* contrib/hbnf/doc/en/chdir.txt
* contrib/hbnf/doc/en/cntryset.txt
* contrib/hbnf/doc/en/color2n.txt
* contrib/hbnf/doc/en/d2e.txt
* contrib/hbnf/doc/en/datecnfg.txt
* contrib/hbnf/doc/en/dayofyr.txt
* contrib/hbnf/doc/en/daytobow.txt
* contrib/hbnf/doc/en/dfile.txt
* contrib/hbnf/doc/en/diskfunc.txt
* contrib/hbnf/doc/en/dispc.txt
* contrib/hbnf/doc/en/dispmsg.txt
* contrib/hbnf/doc/en/dosver.txt
* contrib/hbnf/doc/en/e2d.txt
* contrib/hbnf/doc/en/easter.txt
* contrib/hbnf/doc/en/elapsed.txt
* contrib/hbnf/doc/en/findith.txt
* contrib/hbnf/doc/en/floptst.txt
* contrib/hbnf/doc/en/ftattr.txt
* contrib/hbnf/doc/en/ftidle.txt
* contrib/hbnf/doc/en/ftisprn.txt
* contrib/hbnf/doc/en/ftround.txt
* contrib/hbnf/doc/en/fttext.txt
* contrib/hbnf/doc/en/gcd.txt
* contrib/hbnf/doc/en/getenvrn.txt
* contrib/hbnf/doc/en/hex2dec.txt
* contrib/hbnf/doc/en/iamidle.txt
* contrib/hbnf/doc/en/isbit.txt
* contrib/hbnf/doc/en/isbiton.txt
* contrib/hbnf/doc/en/isshare.txt
* contrib/hbnf/doc/en/kspeed.txt
* contrib/hbnf/doc/en/linked.txt
* contrib/hbnf/doc/en/madd.txt
* contrib/hbnf/doc/en/menutonf.txt
* contrib/hbnf/doc/en/metaph.txt
* contrib/hbnf/doc/en/miltime.txt
* contrib/hbnf/doc/en/month.txt
* contrib/hbnf/doc/en/netpv.txt
* contrib/hbnf/doc/en/nooccur.txt
* contrib/hbnf/doc/en/ntow.txt
* contrib/hbnf/doc/en/nwlstat.txt
* contrib/hbnf/doc/en/nwsem.txt
* contrib/hbnf/doc/en/nwuid.txt
* contrib/hbnf/doc/en/ontick.txt
* contrib/hbnf/doc/en/origin.txt
* contrib/hbnf/doc/en/page.txt
* contrib/hbnf/doc/en/pchr.txt
* contrib/hbnf/doc/en/peek.txt
* contrib/hbnf/doc/en/pending.txt
* contrib/hbnf/doc/en/poke.txt
* contrib/hbnf/doc/en/popadder.txt
* contrib/hbnf/doc/en/proper.txt
* contrib/hbnf/doc/en/prtesc.txt
* contrib/hbnf/doc/en/putkey.txt
* contrib/hbnf/doc/en/qtr.txt
* contrib/hbnf/doc/en/rand1.txt
* contrib/hbnf/doc/en/savearr.txt
* contrib/hbnf/doc/en/scregion.txt
* contrib/hbnf/doc/en/setdate.txt
* contrib/hbnf/doc/en/setkeys.txt
* contrib/hbnf/doc/en/setlastk.txt
* contrib/hbnf/doc/en/settime.txt
* contrib/hbnf/doc/en/sinkey.txt
* contrib/hbnf/doc/en/sleep.txt
* contrib/hbnf/doc/en/sqzn.txt
* contrib/hbnf/doc/en/sysmem.txt
* contrib/hbnf/doc/en/tbwhile.txt
* contrib/hbnf/doc/en/tempfile.txt
* contrib/hbnf/doc/en/vertmenu.txt
* contrib/hbnf/doc/en/vidcur.txt
* contrib/hbnf/doc/en/vidmode.txt
* contrib/hbnf/doc/en/wda.txt
* contrib/hbnf/doc/en/week.txt
* contrib/hbnf/doc/en/workdays.txt
* contrib/hbnf/doc/en/woy.txt
* contrib/hbnf/doc/en/xbox.txt
* contrib/hbnf/doc/en/year.txt
* contrib/hbnf/ftround.prg
* contrib/hbnf/metaph.prg
* contrib/hbnf/nwsem.prg
* contrib/hbnf/nwuid.prg
* contrib/hbnf/pending.prg
* contrib/hbnf/popadder.prg
* contrib/hbnf/scregion.prg
* contrib/hbnf/tbwhile.prg
* contrib/hbnf/workdays.prg
* contrib/hbodbc/browodbc.prg
* contrib/hbqt/tests/browqt.prg
* contrib/hbqt/tests/dbfbrowserclass.prg
* contrib/hbqt/tests/testbrow.prg
* contrib/hbsqlit3/tests/blob.prg
* contrib/hbsqlit3/tests/sl3_test.prg
* contrib/hbxbp/tests/demoxbp.prg
* contrib/hbxbp/tests/dialogqt.prg
* contrib/hbxbp/xbpdataref.prg
* contrib/hbxbp/xbpmenubar.prg
* contrib/hbxbp/xbpprintdialog.prg
* contrib/hbxbp/xbpprinter.prg
* contrib/hbxbp/xbprtf.prg
* contrib/hbxbp/xbpscrollbar.prg
* contrib/xhb/cstruct.prg
* contrib/xhb/hblog.prg
* contrib/xhb/hterrsys.prg
* contrib/xhb/htjlist.prg
* contrib/xhb/sprintf.prg
* contrib/xhb/stream.prg
* contrib/xhb/tcgi.prg
* contrib/xhb/tedit.prg
* contrib/xhb/tfile.prg
* contrib/xhb/thtm.prg
* contrib/xhb/trpc.prg
* contrib/xhb/trpccli.prg
* contrib/xhb/ttable.prg
* contrib/xhb/txml.prg
* contrib/xhb/xcstr.prg
* contrib/xhb/xhberr.prg
* contrib/xhb/xhbmt.prg
* doc/cmpopt.txt
* doc/en/dbstrux.txt
* examples/hbapollo/array.prg
* examples/hbvpdf/hbvpdf.prg
* examples/hbvpdf/hbvpdft.prg
* examples/hbxlsxml/xlsxml_s.prg
* examples/hbxlsxml/xlsxml_y.prg
* examples/httpsrv/cgifunc.prg
* examples/httpsrv/cookie.prg
* examples/httpsrv/modules/cookie.prg
* examples/httpsrv/modules/info.prg
* examples/httpsrv/modules/showcounter.prg
* examples/httpsrv/modules/tableservletdb.prg
* examples/httpsrv/modules/testajax.prg
* examples/httpsrv/session.prg
* examples/httpsrv/uhttpd.prg
* include/hbclass.ch
* include/hbtrace.ch
* src/debug/dbgtinp.prg
* src/debug/debugger.prg
* src/debug/tbrwtext.prg
* src/rdd/usrrdd/rdds/hscdx.prg
* src/rtl/hbi18n2.prg
* src/rtl/valtoexp.prg
* formatting, fixed indentation, cleanups, deleting system specific information,
optimizing out platform dependent code, using hb_ntos()
266 lines
7.0 KiB
Plaintext
266 lines
7.0 KiB
Plaintext
/*
|
|
* $Id$
|
|
*/
|
|
|
|
/*
|
|
* Harbour Project source code:
|
|
* Cgi Class
|
|
*
|
|
* Copyright 2000 Manos Aspradakis <maspr@otenet.gr>
|
|
* www - http://harbour-project.org
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version, with one exception:
|
|
*
|
|
* The exception is that if you link the Harbour Runtime Library (HRL)
|
|
* and/or the Harbour Virtual Machine (HVM) with other files to produce
|
|
* an executable, this does not by itself cause the resulting executable
|
|
* to be covered by the GNU General Public License. Your use of that
|
|
* executable is in no way restricted on account of linking the HRL
|
|
* and/or HVM code into it.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
|
|
* their web site at http://www.gnu.org/).
|
|
*
|
|
*/
|
|
|
|
/*
|
|
* The following parts are Copyright of the individual authors.
|
|
* www - http://harbour-project.org
|
|
*
|
|
* Copyright 2000 Luiz Rafael Culik <culik@sl.conex.net>
|
|
* Porting this library to Harbour
|
|
*
|
|
* See doc/license.txt for licensing terms.
|
|
*
|
|
*/
|
|
|
|
#include "hbclass.ch"
|
|
#include "common.ch"
|
|
#include "cgi.ch"
|
|
|
|
CLASS TCgi FROM THtml
|
|
|
|
DATA nH
|
|
DATA Server_Software
|
|
DATA Server_Name
|
|
DATA Gateway_Interface
|
|
DATA Server_Protocol
|
|
DATA Server_Port
|
|
DATA Request_Method
|
|
DATA Http_Accept
|
|
DATA Http_User_agent
|
|
DATA Http_Referer
|
|
DATA Path_Info
|
|
DATA Path_Translated
|
|
DATA Script_Name
|
|
DATA Query_String
|
|
DATA Remote_Host
|
|
DATA Remote_Addr
|
|
DATA ipAddress
|
|
DATA Remote_User
|
|
DATA Auth_Type
|
|
DATA Auth_User
|
|
DATA Auth_Pass
|
|
DATA Content_Type
|
|
DATA Content_Length
|
|
DATA Annotation_Server
|
|
|
|
DATA aQueryFields INIT {}
|
|
|
|
METHOD New( cInBuffer )
|
|
|
|
METHOD Field( cQueryName )
|
|
|
|
METHOD ToObject()
|
|
|
|
ENDCLASS
|
|
|
|
METHOD New( cInBuffer ) CLASS TCgi
|
|
|
|
LOCAL i
|
|
LOCAL aTemp
|
|
LOCAL aVar
|
|
|
|
::nH := HtmlPageHandle()
|
|
|
|
::Server_Software := Getenv( "SERVER_SOFTWARE" )
|
|
::Server_Name := Getenv( "SERVER_NAME" )
|
|
::Gateway_Interface := Getenv( "GATEWAY_INTERFACE" )
|
|
::Server_Protocol := Getenv( "SERVER_PROTOCOL" )
|
|
::Server_Port := Getenv( "SERVER_PORT" )
|
|
::Request_Method := Getenv( "REQUEST_METHOD" )
|
|
::Http_Accept := Getenv( "HTTP_ACCEPT" )
|
|
::Http_User_agent := Getenv( "HTTP_USER_AGENT" )
|
|
::Http_Referer := Getenv( "HTTP_REFERER" )
|
|
::Path_Info := Getenv( "PATH_INFO" )
|
|
::Path_Translated := Getenv( "PATH_TRANSLATED" )
|
|
::Script_Name := Getenv( "SCRIPT_NAME" )
|
|
::Query_String := Getenv( "QUERY_STRING" )
|
|
::Remote_Host := Getenv( "REMOTE_HOST" )
|
|
::Remote_Addr := Getenv( "REMOTE_ADDR" )
|
|
::ipAddress := Getenv( "REMOTE_ADDR" )
|
|
::Remote_User := Getenv( "REMOTE_USER" )
|
|
::Auth_Type := Getenv( "AUTH_TYPE" )
|
|
::Auth_User := Getenv( "AUTH_USER" )
|
|
::Auth_Pass := Getenv( "AUTH_PASS" )
|
|
::Content_Type := Getenv( "CONTENT_TYPE" )
|
|
::Content_Length := Getenv( "CONTENT_LENGTH" )
|
|
::Annotation_Server := Getenv( "ANNOTATION_SERVER" )
|
|
|
|
IF cInBuffer != NIL
|
|
::Query_String := Rtrim( cInBuffer )
|
|
ELSE
|
|
IF "POST" $ Upper( ::Request_Method )
|
|
::Query_String := Rtrim( Freadstr( STD_IN, Val( ::CONTENT_LENGTH ) ) )
|
|
ENDIF
|
|
ENDIF
|
|
|
|
IF !Empty( ::Query_String )
|
|
|
|
::aQueryFields := {}
|
|
|
|
aTemp := hb_atokens( ::Query_String, "&" ) // separate fields
|
|
|
|
FOR i := 1 TO Len( aTemp )
|
|
aVar := hb_atokens( aTemp[ i ], "=" )
|
|
IF Len( aVar ) == 2
|
|
Aadd( ::aQueryFields, { aVar[ 1 ], HtmlDecodeUrl( aVar[ 2 ] ) } )
|
|
ENDIF
|
|
NEXT
|
|
|
|
ENDIF
|
|
|
|
RETURN ::ToObject()
|
|
|
|
/****
|
|
*
|
|
* TCgi():ToObject()
|
|
*
|
|
* Creates instance variables out of CGI FORM return values
|
|
* or URL encoded content.
|
|
*
|
|
* It subclasses the TCgi class to a *new* class
|
|
*/
|
|
|
|
METHOD ToObject() CLASS TCgi
|
|
|
|
LOCAL i
|
|
LOCAL nScope := 1
|
|
LOCAL aDb
|
|
LOCAL oNew
|
|
STATIC sn := 0
|
|
|
|
// --> create new oObject class from this one...
|
|
sn ++
|
|
aDb := hbClass():New( "NewCgi" + Strzero( sn, 3 ), { "TCgi" } )
|
|
|
|
FOR i := 1 TO Len( ::aQueryFields )
|
|
|
|
IF ::aQueryFields[ i, 2 ] == NIL .or. Empty( ::aQueryFields[ i, 2 ] )
|
|
::aQueryFields[ i, 2 ] := ""
|
|
ENDIF
|
|
|
|
adb:AddData( ::aQueryFields[ i, 1 ], ::aQueryFields[ i, 2 ],, nScope )
|
|
NEXT
|
|
|
|
adb:Create()
|
|
oNew := adb:Instance()
|
|
oNew:aQueryFields := ::aQueryFields
|
|
oNew:Server_Software := ::Server_Software
|
|
oNew:Server_Name := ::Server_Name
|
|
oNew:Gateway_Interface := ::Gateway_Interface
|
|
oNew:Server_Protocol := ::Server_Protocol
|
|
oNew:Server_Port := ::Server_Port
|
|
oNew:Request_Method := ::Request_Method
|
|
oNew:Http_Accept := ::Http_Accept
|
|
oNew:Http_User_agent := ::Http_User_agent
|
|
oNew:Http_Referer := ::Http_Referer
|
|
oNew:Path_Info := ::Path_Info
|
|
oNew:Path_Translated := ::Path_Translated
|
|
oNew:Script_Name := ::Script_Name
|
|
oNew:Query_String := ::Query_String
|
|
oNew:Remote_Host := ::Remote_Host
|
|
oNew:Remote_Addr := ::Remote_Addr
|
|
oNew:ipAddress := ::ipAddress
|
|
oNew:Remote_User := ::Remote_User
|
|
oNew:Auth_Type := ::Auth_Type
|
|
oNew:Content_Type := ::Content_Type
|
|
oNew:Content_Length := ::Content_Length
|
|
oNew:Annotation_Server := ::Annotation_Server
|
|
oNew:nH := iif( HtmlPageHandle() == NIL, STD_OUT, HtmlPageHandle() )
|
|
|
|
RETURN oNew
|
|
|
|
METHOD Field( cQueryName ) CLASS TCgi
|
|
|
|
LOCAL cRet := ""
|
|
LOCAL nRet
|
|
|
|
DEFAULT cQueryName TO ""
|
|
|
|
nRet := Ascan( ::aQueryFields, ;
|
|
{| x | Upper( x[ 1 ] ) == Upper( cQueryName ) } )
|
|
|
|
IF nRet > 0
|
|
cRet := ::aQueryFields[ nRet, 2 ]
|
|
ENDIF
|
|
|
|
RETURN cRet
|
|
|
|
FUNCTION ParseString( cString, cDelim, nRet )
|
|
|
|
LOCAL cBuf
|
|
LOCAL aElem
|
|
LOCAL nPosFim
|
|
LOCAL nSize
|
|
LOCAL i
|
|
|
|
nSize := Len( cString ) - Len( Strtran( cString, cDelim, '' ) ) + 1
|
|
aElem := Array( nSize )
|
|
|
|
cBuf := cString
|
|
FOR i := 1 TO nSize
|
|
nPosFim := At( cDelim, cBuf )
|
|
|
|
IF nPosFim > 0
|
|
aElem[ i ] := Substr( cBuf, 1, nPosFim - 1 )
|
|
ELSE
|
|
aElem[ i ] := cBuf
|
|
ENDIF
|
|
|
|
cBuf := Substr( cBuf, nPosFim + 1, Len( cBuf ) )
|
|
|
|
NEXT i
|
|
|
|
RETURN aElem[ nRet ]
|
|
|
|
/****
|
|
*
|
|
* CgiParseVar()
|
|
*
|
|
* Separates elements of a CGI query environment variable
|
|
*
|
|
*/
|
|
|
|
FUNCTION CgiParseVar( cEnvVar )
|
|
|
|
cEnvVar := HtmlDecodeURL( cEnvVar )
|
|
|
|
IF "=" $ cEnvVar .and. Len( cEnvVar ) > At( "=", cEnvVar )
|
|
cEnvVar := Alltrim( Substr( cEnvVar, At( "=", cEnvVar ) + 1 ) )
|
|
ELSE
|
|
cEnvVar := ""
|
|
ENDIF
|
|
|
|
RETURN cEnvVar
|