diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 0d33342d6d..46959716ba 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,18 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2008-01-26 10:10 UTC+0100 Lorenzo Fiorini (lorenzo.fiorini/at/gmail.com) + * contrib/hbtip/utils.c + added .ico support to TIP_MIMETYPE + * contrib/hbtip/cgi.prg + + contrib/hbtip/sessid.prg + moved statis funcs GenerateSID, CheckSID, DateToGmt from cgi.prg + to new sessid.prg and renamed to TIP_* + * contrib/hbtip/httpcln.prg + fixed few typos that generated RT errors + * source/rtl/gtxwc/gtxwc.c + added missed K_SH_keys + 2008-01-26 09:54 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/make_b32_all.bat * contrib/make_vc_all.bat diff --git a/harbour/contrib/hbtip/Makefile b/harbour/contrib/hbtip/Makefile index eaccbde303..bcea20ad63 100644 --- a/harbour/contrib/hbtip/Makefile +++ b/harbour/contrib/hbtip/Makefile @@ -24,7 +24,8 @@ PRG_SOURCES= \ mail.prg \ cgi.prg \ thtml.prg \ - sendmail.prg + sendmail.prg \ + sessid.prg PRG_HEADERS= \ thtml.ch \ diff --git a/harbour/contrib/hbtip/cgi.prg b/harbour/contrib/hbtip/cgi.prg index d1dc648ad9..fe18e08eaa 100644 --- a/harbour/contrib/hbtip/cgi.prg +++ b/harbour/contrib/hbtip/cgi.prg @@ -71,10 +71,6 @@ #define _CRLF chr(13)+chr(10) #define _BR '
' -#define SID_LENGTH 25 -#define BASE_KEY_STRING "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" -#define CRC_KEY_STRING "Ak3yStR1Ng" // Max Length must be 10 chars - CLASS TIpCgi DATA HTTP_RAW_POST_DATA @@ -106,8 +102,8 @@ CLASS TIpCgi METHOD StartSession() METHOD DestroySession() - METHOD CreateSID( cCRCKey ) INLINE ::cSID := GenerateSID( cCrcKey ) - METHOD CheckCrcSID( cSID, cCRCKey ) INLINE CheckSID( cSID, cCRCKey ) + METHOD CreateSID( cCRCKey ) INLINE ::cSID := TIP_GenerateSID( cCrcKey ) + METHOD CheckCrcSID( cSID, cCRCKey ) INLINE TIP_CheckSID( cSID, cCRCKey ) METHOD SessionEncode() METHOD SessionDecode( cData ) @@ -275,7 +271,7 @@ METHOD DestroySession( cID ) CLASS TIpCgi if !( lRet := ( FErase( cFile ) == 0 ) ) ::Print( "ERROR: On deleting session file : " + cFile + ", File error : " + hb_cStr( FError() ) ) else - ::hCookies[ 'SESSIONID' ] := cSID + "; expires= " + DateToGMT( DATE() - 1 ) + ::hCookies[ 'SESSIONID' ] := cSID + "; expires= " + TIP_DateToGMT( DATE() - 1 ) ::CreateSID() cSID := ::cSID ::hCookies[ 'SESSIONID' ] := cSID @@ -393,12 +389,12 @@ METHOD StartSession( cSID ) CLASS TIpCgi if empty( cSID ) - if ( nH := hb_HPos( ::hGets, 'SESSIONID' ) ) != 0 - cSID := hb_HValueAt( ::hGets, nH ) - elseif ( nH := hb_HPos( ::hPosts, 'SESSIONID' ) ) != 0 - cSID := hb_HValueAt( ::hPosts, nH ) - elseif ( nH := hb_HPos( ::hCookies, 'SESSIONID' ) ) != 0 - cSID := hb_HValueAt( ::hCookies, nH ) + if ( nH := hb_HPos( ::hGets, 'SESSIONID' ) ) != 0 + cSID := hb_HValueAt( ::hGets, nH ) + elseif ( nH := hb_HPos( ::hPosts, 'SESSIONID' ) ) != 0 + cSID := hb_HValueAt( ::hPosts, nH ) + elseif ( nH := hb_HPos( ::hCookies, 'SESSIONID' ) ) != 0 + cSID := hb_HValueAt( ::hCookies, nH ) endif endif @@ -632,84 +628,4 @@ STATIC FUNCTION HtmlStyle( xVal, cKey ) return cVal -STATIC FUNCTION GenerateSID( cCRCKey ) - local cSID, nSIDCRC, cSIDCRC, n, cTemp - local nLenSID := SID_LENGTH - local cBaseKeys := BASE_KEY_STRING - local nLenKeys := Len( cBaseKeys ) - local cRet - local nRand, nKey := 0 - - DEFAULT cCRCKey TO CRC_KEY_STRING - - cCRCKey := Left( cCRCKey, 10 ) // Max Lenght must to be of 10 chars - - /* Let's generate the sequence */ - cSID := Space( nLenSID ) - for n := 1 TO nLenSID - nRand := HB_RandomInt( 1, nLenKeys ) - cSID := Stuff( cSID, n, 1, SubStr( cBaseKeys, nRand, 1 ) ) - nKey += nRand - next - - nSIDCRC := nKey * 51 // Max Value is 99603 a 5 chars number - cTemp := StrZero( nSIDCRC, 5 ) - cSIDCRC := "" - for n := 1 to Len( cTemp ) - cSIDCRC += SubStr( cCRCKey, Val( SubStr( cTemp, n, 1 ) ) + 1, 1 ) - next - - cRet := cSID + cSIDCRC - - RETURN cRet - -STATIC FUNCTION CheckSID( cSID, cCRCKey ) - - local nSIDCRC, cSIDCRC, n, cTemp - local nLenSID := SID_LENGTH - local cBaseKeys := BASE_KEY_STRING - local nLenKeys := Len( cBaseKeys ) - local nRand, nKey := 0 - - DEFAULT cCRCKey TO CRC_KEY_STRING - - cCRCKey := Left( cCRCKey, 10 ) // Max Lenght must to be of 10 chars - - /* Calculate the key */ - for n := 1 to nLenSID - nRand := At( SubStr( cSID, n, 1), cBaseKeys ) - nKey += nRand - next - - // Recalculate the CRC - nSIDCRC := nKey * 51 // Max Value is 99603. a 5 chars number - cTemp := StrZero( nSIDCRC, 5 ) - cSIDCRC := "" - for n := 1 to Len( cTemp ) - cSIDCRC += SubStr( cCRCKey, Val( SubStr( cTemp, n, 1 ) ) + 1, 1 ) - next - - RETURN ( Right( cSID, 5 ) == cSIDCRC ) - -STATIC FUNCTION DateToGMT( dDate, cTime ) - LOCAL cStr := "" - LOCAL cOldDateFormat := Set( _SET_DATEFORMAT, "dd-mm-yy" ) - LOCAL nDay, nMonth, nYear, nDoW - LOCAL aDays := { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } - LOCAL aMonths := { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" } - - DEFAULT dDate TO DATE() - DEFAULT cTime TO TIME() - - nDay := Day( dDate ) - nMonth := Month( dDate ) - nYear := Year( dDate) - nDoW := Dow( dDate ) - - cStr := aDays[ nDow ] + ", " + StrZero( nDay, 2 ) + "-" + aMonths[ nMonth ] + "-" + ; - Right( StrZero( nYear, 4 ), 2 ) + " " + cTime + " GMT" - - Set( _SET_DATEFORMAT, cOldDateFormat ) - - RETURN cStr diff --git a/harbour/contrib/hbtip/httpcln.prg b/harbour/contrib/hbtip/httpcln.prg index 646e966fe5..d20ce14838 100644 --- a/harbour/contrib/hbtip/httpcln.prg +++ b/harbour/contrib/hbtip/httpcln.prg @@ -439,7 +439,7 @@ METHOD getcookies(cHost,cPath) CLASS tIPClientHTTP ENDIF //tail matching the domain - aKeys:=hb_hkeyat(::hCookies) + aKeys:=hb_hkeys(::hCookies) y:=len(aKeys) z:=len(cHost) cHost:=upper(cHost) @@ -455,7 +455,7 @@ METHOD getcookies(cHost,cPath) CLASS tIPClientHTTP //now that we have the domain matches we have to do path matchine nPath:=len(cPath) FOR x := 1 TO y - aKeys:=hb_hkeyat(::hCookies[aDomKeys[x]]) + aKeys:=hb_hkeys(::hCookies[aDomKeys[x]]) aPathKeys:={} b:=len(aKeys) FOR a:= 1 TO b diff --git a/harbour/contrib/hbtip/sessid.prg b/harbour/contrib/hbtip/sessid.prg new file mode 100644 index 0000000000..9900444987 --- /dev/null +++ b/harbour/contrib/hbtip/sessid.prg @@ -0,0 +1,148 @@ +/* + * xHarbour Project source code: + * Functions to create session id and some utils + * + * Copyright 2008 Lorenzo Fiorini + * + * code from: + * TIP Class oriented Internet protocol library + * + * Copyright 2003 Giancarlo Niccolai + * + * www - http://www.harbour-project.org + * + * CGI Session Manager Class + * + * Copyright 2003-2006 Francesco Saverio Giudice + * www - http://www.xharbour.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. + * + */ + +#include 'tip.ch' +#include 'common.ch' + +#define SID_LENGTH 25 +#define BASE_KEY_STRING "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" +#define CRC_KEY_STRING "Ak3yStR1Ng" // Max Length must be 10 chars + +FUNCTION TIP_GENERATESID( cCRCKey ) + + local cSID, nSIDCRC, cSIDCRC, n, cTemp + local nLenSID := SID_LENGTH + local cBaseKeys := BASE_KEY_STRING + local nLenKeys := Len( cBaseKeys ) + local cRet + local nRand, nKey := 0 + + DEFAULT cCRCKey TO CRC_KEY_STRING + + cCRCKey := Left( cCRCKey, 10 ) // Max Lenght must to be of 10 chars + + /* Let's generate the sequence */ + cSID := Space( nLenSID ) + for n := 1 TO nLenSID + nRand := HB_RandomInt( 1, nLenKeys ) + cSID := Stuff( cSID, n, 1, SubStr( cBaseKeys, nRand, 1 ) ) + nKey += nRand + next + + nSIDCRC := nKey * 51 // Max Value is 99603 a 5 chars number + cTemp := StrZero( nSIDCRC, 5 ) + cSIDCRC := "" + for n := 1 to Len( cTemp ) + cSIDCRC += SubStr( cCRCKey, Val( SubStr( cTemp, n, 1 ) ) + 1, 1 ) + next + + cRet := cSID + cSIDCRC + + RETURN cRet + +FUNCTION TIP_CHECKSID( cSID, cCRCKey ) + + local nSIDCRC, cSIDCRC, n, cTemp + local nLenSID := SID_LENGTH + local cBaseKeys := BASE_KEY_STRING + local nLenKeys := Len( cBaseKeys ) + local nRand, nKey := 0 + + DEFAULT cCRCKey TO CRC_KEY_STRING + + cCRCKey := Left( cCRCKey, 10 ) // Max Lenght must to be of 10 chars + + /* Calculate the key */ + for n := 1 to nLenSID + nRand := At( SubStr( cSID, n, 1), cBaseKeys ) + nKey += nRand + next + + // Recalculate the CRC + nSIDCRC := nKey * 51 // Max Value is 99603. a 5 chars number + cTemp := StrZero( nSIDCRC, 5 ) + cSIDCRC := "" + for n := 1 to Len( cTemp ) + cSIDCRC += SubStr( cCRCKey, Val( SubStr( cTemp, n, 1 ) ) + 1, 1 ) + next + + RETURN ( Right( cSID, 5 ) == cSIDCRC ) + +FUNCTION TIP_DATETOGMT( dDate, cTime ) + LOCAL cStr := "" + LOCAL cOldDateFormat := Set( _SET_DATEFORMAT, "dd-mm-yy" ) + LOCAL nDay, nMonth, nYear, nDoW + LOCAL aDays := { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } + LOCAL aMonths := { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" } + + DEFAULT dDate TO DATE() + DEFAULT cTime TO TIME() + + nDay := Day( dDate ) + nMonth := Month( dDate ) + nYear := Year( dDate) + nDoW := Dow( dDate ) + + cStr := aDays[ nDow ] + ", " + StrZero( nDay, 2 ) + "-" + aMonths[ nMonth ] + "-" + ; + Right( StrZero( nYear, 4 ), 2 ) + " " + cTime + " GMT" + + Set( _SET_DATEFORMAT, cOldDateFormat ) + + RETURN cStr + diff --git a/harbour/contrib/hbtip/utils.c b/harbour/contrib/hbtip/utils.c index c905133e02..12451171e4 100644 --- a/harbour/contrib/hbtip/utils.c +++ b/harbour/contrib/hbtip/utils.c @@ -226,7 +226,7 @@ typedef struct tag_mime #define MIME_FLAG_TRIMTABS 0x0002 #define MIME_FLAG_CASEINSENS 0x0004 #define MIME_FLAG_CONTINUE 0x0008 -#define MIME_TABLE_SIZE 67 +#define MIME_TABLE_SIZE 68 static MIME_ENTRY s_mimeTable[ MIME_TABLE_SIZE ] = { @@ -333,7 +333,11 @@ static MIME_ENTRY s_mimeTable[ MIME_TABLE_SIZE ] = /* 65*/ { 0, "GIF", "image/gif", 0, 0, 0 }, /* JPEG image */ - /* 66*/ { 0, "\xff\xd8", "image/jpg", 0, 0, 0 } + /* 66*/ { 0, "\xff\xd8", "image/jpeg", 0, 0, 0 }, + + /* ICO image */ + /* 67*/ { 2, "\x01\x00", "image/x-icon", 0, 0, 0 } + }; /* Find mime by extension */ diff --git a/harbour/source/rtl/gtxwc/gtxwc.c b/harbour/source/rtl/gtxwc/gtxwc.c index c29d266002..4cee422a6f 100644 --- a/harbour/source/rtl/gtxwc/gtxwc.c +++ b/harbour/source/rtl/gtxwc/gtxwc.c @@ -192,17 +192,17 @@ static const ClipKeyCode extKeyTab[CLIP_EXTKEY_COUNT] = { {K_F10, K_ALT_F10, K_CTRL_F10, K_SH_F10}, /* 09 */ {K_F11, K_ALT_F11, K_CTRL_F11, K_SH_F11}, /* 10 */ {K_F12, K_ALT_F12, K_CTRL_F12, K_SH_F12}, /* 11 */ - {K_UP, K_ALT_UP, K_CTRL_UP, 0}, /* 12 */ - {K_DOWN, K_ALT_DOWN, K_CTRL_DOWN, 0}, /* 13 */ - {K_LEFT, K_ALT_LEFT, K_CTRL_LEFT, 0}, /* 14 */ - {K_RIGHT, K_ALT_RIGHT, K_CTRL_RIGHT, 0}, /* 15 */ - {K_INS, K_ALT_INS, K_CTRL_INS, 0}, /* 16 */ - {K_DEL, K_ALT_DEL, K_CTRL_DEL, 0}, /* 17 */ - {K_HOME, K_ALT_HOME, K_CTRL_HOME, 0}, /* 18 */ - {K_END, K_ALT_END, K_CTRL_END, 0}, /* 19 */ - {K_PGUP, K_ALT_PGUP, K_CTRL_PGUP, 0}, /* 20 */ - {K_PGDN, K_ALT_PGDN, K_CTRL_PGDN, 0}, /* 21 */ - {K_BS, K_ALT_BS, 127, 0}, /* 22 */ + {K_UP, K_ALT_UP, K_CTRL_UP, K_SH_UP}, /* 12 */ + {K_DOWN, K_ALT_DOWN, K_CTRL_DOWN, K_SH_DOWN}, /* 13 */ + {K_LEFT, K_ALT_LEFT, K_CTRL_LEFT, K_SH_LEFT}, /* 14 */ + {K_RIGHT, K_ALT_RIGHT, K_CTRL_RIGHT, K_SH_RIGHT}, /* 15 */ + {K_INS, K_ALT_INS, K_CTRL_INS, K_SH_INS}, /* 16 */ + {K_DEL, K_ALT_DEL, K_CTRL_DEL, K_SH_DEL}, /* 17 */ + {K_HOME, K_ALT_HOME, K_CTRL_HOME, K_SH_HOME}, /* 18 */ + {K_END, K_ALT_END, K_CTRL_END, K_SH_END}, /* 19 */ + {K_PGUP, K_ALT_PGUP, K_CTRL_PGUP, K_SH_PGUP}, /* 20 */ + {K_PGDN, K_ALT_PGDN, K_CTRL_PGDN, K_SH_PGDN}, /* 21 */ + {K_BS, K_ALT_BS, 127, K_SH_BS}, /* 22 */ {K_TAB, K_ALT_TAB, K_CTRL_TAB, K_SH_TAB}, /* 23 */ {K_ESC, K_ALT_ESC, K_ESC, 0}, /* 24 */ {K_ENTER, K_ALT_ENTER, K_CTRL_ENTER, 0}, /* 25 */