From 97d48cbd6dd6ca4650aad0bbccb3558b3188cb2a Mon Sep 17 00:00:00 2001 From: Francesco Saverio Giudice Date: Mon, 19 Jan 2009 23:19:32 +0000 Subject: [PATCH] 2009-01-20 00:20 UTC+0100 Francesco Saverio Giudice (info/at/fsgiudice.com) + harbour/contrib/examples/uhttpd/modules/info.prg + New sample showing server variables * harbour/contrib/examples/uhttpd/home/index.html * harbour/contrib/examples/uhttpd/readme.txt * harbour/contrib/examples/uhttpd/uhttpd.prg * updated for new sample --- harbour/ChangeLog | 8 ++ .../contrib/examples/uhttpd/home/index.html | 4 + .../contrib/examples/uhttpd/modules/info.prg | 112 ++++++++++++++++++ harbour/contrib/examples/uhttpd/readme.txt | 4 + harbour/contrib/examples/uhttpd/uhttpd.prg | 3 +- 5 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 harbour/contrib/examples/uhttpd/modules/info.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6a71bc2a1e..1ab970badb 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,14 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-01-20 00:20 UTC+0100 Francesco Saverio Giudice (info/at/fsgiudice.com) + + harbour/contrib/examples/uhttpd/modules/info.prg + + New sample showing server variables + * harbour/contrib/examples/uhttpd/home/index.html + * harbour/contrib/examples/uhttpd/readme.txt + * harbour/contrib/examples/uhttpd/uhttpd.prg + * updated for new sample + 2009-01-19 23:43 UTC+0100 Francesco Saverio Giudice (info/at/fsgiudice.com) * harbour/Changelog * fixed path of previous upload diff --git a/harbour/contrib/examples/uhttpd/home/index.html b/harbour/contrib/examples/uhttpd/home/index.html index a8b4ba3989..ebe21fc1be 100644 --- a/harbour/contrib/examples/uhttpd/home/index.html +++ b/harbour/contrib/examples/uhttpd/home/index.html @@ -16,5 +16,9 @@ Examples: Test Ajax XML Database
Test Ajax Counter +
+Server Status +
+Alias to /cgi-bin/info.hrb page with server variables diff --git a/harbour/contrib/examples/uhttpd/modules/info.prg b/harbour/contrib/examples/uhttpd/modules/info.prg new file mode 100644 index 0000000000..603949d9ff --- /dev/null +++ b/harbour/contrib/examples/uhttpd/modules/info.prg @@ -0,0 +1,112 @@ +/* + * $Id: rlcdx.prg 9754 2008-10-27 22:40:04Z vszakats $ + */ + +/* + * Harbour Project source code: + * uHTTPD info page + * + * Copyright 2009 Francesco Saverio Giudice + * www - http://www.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, or (at your option) + * any later version. + * + * 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 software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries 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 Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +/* + Show internal variables. + Call it with: /info +*/ + + +#include "common.ch" +#include "hbclass.ch" + +MEMVAR _SERVER, _REQUEST, _GET, _POST + +FUNCTION HRBMAIN() + LOCAL cHtml + + cHtml := ShowServerInfo() + + RETURN cHtml + +STATIC FUNCTION ShowServerInfo() + LOCAL cHtml := "" + + cHtml += DisplayVars( _Server , "SERVER Vars" ) + cHtml += "
" + cHtml += DisplayVars( _Get , "GET Vars" ) + cHtml += "
" + cHtml += DisplayVars( _Post , "POST Vars" ) + cHtml += "
" + //cHtml += DisplayVars( _Cookie , "COOKIE Vars" ) + //cHtml += "
" + //cHtml += DisplayVars( _Files , "FILE Vars" ) + //cHtml += "
" + cHtml += DisplayVars( _Request, "REQUEST Vars" ) + cHtml += "
" + //cHtml += DisplayVars( _Session, "SESSION Vars" ) + //cHtml += "
" + RETURN cHtml + +STATIC FUNCTION DisplayVars( hHash, cTitle ) + LOCAL cHtml := "" + cHtml += "" + cHtml += "" + cHtml += "" + cHtml += "" + cHtml += "" + cHtml += "" + cHtml += DisplayHash( hHash ) + cHtml += "
" + hb_cStr( cTitle ) + "
KEYVALUE
" +RETURN cHtml + +STATIC FUNCTION DisplayHash( hHash ) + LOCAL cHtml := "" + LOCAL cKey, cSubKey + + FOR EACH cKey IN hHash:Keys + cHtml += "" + cHtml += "" + hb_cStr( cKey ) + "" + cHtml += "" + hb_cStr( hHash[ cKey ] ) + "" + cHtml += "" + NEXT +RETURN cHtml diff --git a/harbour/contrib/examples/uhttpd/readme.txt b/harbour/contrib/examples/uhttpd/readme.txt index d1178241aa..7b263c8f49 100644 --- a/harbour/contrib/examples/uhttpd/readme.txt +++ b/harbour/contrib/examples/uhttpd/readme.txt @@ -7,6 +7,10 @@ uhttpd -? Before starting please build modules in modules folder using bldhrb.bat +Once started connect to uhttpd using: +http://localhost:8082 +to see default index page. + Francesco diff --git a/harbour/contrib/examples/uhttpd/uhttpd.prg b/harbour/contrib/examples/uhttpd/uhttpd.prg index a73681475b..39c4145f31 100644 --- a/harbour/contrib/examples/uhttpd/uhttpd.prg +++ b/harbour/contrib/examples/uhttpd/uhttpd.prg @@ -144,8 +144,9 @@ STATIC s_nServiceConnections, s_nMaxServiceConnections, s_nTotServiceConnections STATIC s_aRunningThreads := {} STATIC s_aServiceThreads := {} +// ALIASES: you can add here any alias to real file and call it // TODO: add aliases from ini file -STATIC s_hFileAliases := { "/info" => "/cgi-bin/info.hrb", "/wait" => "/cgi-bin/wait.hrb" } +STATIC s_hFileAliases := { "/info" => "/cgi-bin/info.hrb" } THREAD STATIC s_cResult, s_nStatusCode, s_aHeader, s_cErrorMsg