'''To support the execution of''' '''''wikit.kit''''' '''via CGI''' under tclhttpd on windows, I've written a little wrapper script''' (Yes, sometimes it is required or simply better or faster to not use tcl... but only in very rare cases....) This PowerBASIC-program addresses some difficulties under windows to get things running, and does the following: * checks if it is been called as a cgi-process, aborting otherwise * does a minimal authentification by checking the requestors IP-address against an auth-file (if present); if env(remote_addr) is not in this ''allowed-table'', aborting * constructing the .TKD-database filename from it's own name (same path, same name, but .tkd extension) * allocating and calling an appropiate tclkit-interpreter with wikit.kit and database.tkd as arguments (note: wikit.kit should be in the same directory) The programcode is as follows and not yet translated to the english language. To compile it, you need to buy the PB/CC-Compiler from www.powerbasic.com :-(, but if anyone is interested, I'll compile a general usable, much more documented version and post it to my personal homepage with a link to it here... '******************************************************************************* '* wikiwrap.bas 1.2 -- Aufrufschale für TCLKIT w/WIKIT für WebSrv M.Hoffmann * '* Compiler: PB/CC 3.x * '******************************************************************************* '* Stand: 27.09.2002 - 1.0: erste Version * '* Stand: 09.04.2003 - 1.1: Autentifizierung anhand REMOTE_USER; * '* DBName anhand EXE-Name! * '* Stand: 14.07.2003 - 1.2: Auch tclkit-win32-sh.exe als Prognamen versuchen; * '* #option version 5; Systemfehler melden.- * '* Stand: 14.10.2003 - 1.3: Erst tclkit-win32-sh.upx.exe als Prog versuchen. * '******************************************************************************* ' '******************************************************************************* '* Compiler-Optionen * '******************************************************************************* #compile exe ' Standard #debug error off ' keine erweiterten Fehlerpr��fungen #dim all ' Alle Variablen deklarieren #option version5 ' Win/NT4 und 95/98 (sonst 5) #register default ' Vorgabe #tools off ' Kein Ballast '******************************************************************************* '* Konstanten * '******************************************************************************* %ccwin = 0 ' keine GUI-Calls $release = "1.3 14.10.2003" '******************************************************************************* '* Externe Module * '******************************************************************************* #include "win32api.inc" ' für exeName() '******************************************************************************* '* Unterprogramme * '******************************************************************************* '------------------------------------------------------------------------------- ' Hilfsroutine zur Bestimmung des Programmnames ' function exeName () as string local mfn as asciiz*256 static buf as string local ret as long if len(buf) = 0 then ' Caching ret = GetModuleFileName(%NULL,mfn,sizeof(mfn)) if ret then buf = left$(mfn,ret) buf = mid$(buf,instr(-1,buf,"\")+1) buf = extract$(buf$,".") end if end if function = buf end function '******************************************************************************* '* Einsprungpunkt * '******************************************************************************* function pbmain () local path_info as string local path_translated as string local ipallow as string path_translated = environ$("PATH_TRANSLATED") path_info = environ$("PATH_INFO") if isfalse(len(path_translated)) then stdout exeName() & $spc & $release & " - Wrapper-Aufruf tclkit/wikit" stdout "Dieses Programm muss als CGI-Prozess vom Webserver aufgerufen werden:" stdout "http://xxxx/cgi-bin/.../" & exeName() & "/" stdout "Es fuehrt dann folgende Operation aus:" stdout "(tclkit-win32-sh.upx|tclkitsh-win32|tclkit-win32-sh).exe wikit.kit " & exeName() & ".tkd" stdout "Aufruf nur von PCs mit IP-Adressen aus " & exeName() & ".auth, wenn vorhanden." stdout "Um verschiedenen Wiki's anzulegen, einfach eine umbenannte Kopie dieses" stdout "Programms aufrufen!" stdout "rc(1)" function = 1 exit function end if path_translated = rtrim$(path_translated, path_info) path_translated = left$(path_translated, instr(-1,path_translated,"/")-1) ' replace "/" with "\" in path_translated ' nicht notwendig, Win32 arbeitet auch mit '/'! chdrive left$(path_translated,2) chdir path_translated ' Neu v1.1: Autentifizierung (momentan anhand IP-Addr; siehe identusr.tcl!) ' Evtl. auch cmdauth vorschleifen; aber: Cookies erforderlich! open exeName() & ".auth" for binary access read as #1 get$ #1,lof(1),ipallow close #1 if len(ipallow) then if isfalse(instr(ipallow,environ$("REMOTE_ADDR"))) then stdout "Content-Type: text/html" stdout "" stdout "" stdout " " stdout " Fehler-Hinweis: stdout " " stdout " " stdout "

" stdout " IP " & environ$("REMOTE_ADDR") & " ist nicht berechtigt, diese Seite aufzurufen!" stdout "

" stdout " " stdout "" function = 2 exit function end if end if ' tclkit muss aus PATH heraus aufrufbar sein! function = shell("tclkit-win32-sh.upx.exe wikit.kit " & exeName() & ".tkd",0) if errclear then function = shell("tclkit-win32-sh.exe wikit.kit " & exeName() & ".tkd",0) if errclear then function = shell("tclkitsh-win32.exe wikit.kit " & exeName() & ".tkd",0) if errclear then stdout "Content-Type: text/html" stdout "" stdout "" stdout " " stdout " System-Fehler: stdout " " stdout " " stdout "

" stdout " Der TCLKIT-Kommando-Interpreter ist nicht aufrufbar!" stdout "

" stdout " " stdout "" function = 3 exit function end if end if end if end function ---- URLs to my wiki-web now are in the form '''http://host/cgi-bin/wiki/wikiwrap1.exe/''', etc.