2015-03-11 16:23 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* contrib/hbtip/hbtip.hbx
  * contrib/hbtip/httpcli.prg
  * contrib/hbtip/log.prg
  * contrib/hbtip/sessid.prg
  * contrib/hbtip/smtpcli.prg
  * contrib/hbtip/thtml.ch
  * contrib/hbtip/tip.ch
  * contrib/hbtip/url.prg
    * synced with Viktor's branch.
This commit is contained in:
Przemysław Czerpak
2015-03-11 16:23:04 +01:00
parent 7f80c2e286
commit 6c9d48495f
9 changed files with 326 additions and 345 deletions

View File

@@ -10,6 +10,17 @@
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
*/
2015-03-11 16:23 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* contrib/hbtip/hbtip.hbx
* contrib/hbtip/httpcli.prg
* contrib/hbtip/log.prg
* contrib/hbtip/sessid.prg
* contrib/hbtip/smtpcli.prg
* contrib/hbtip/thtml.ch
* contrib/hbtip/tip.ch
* contrib/hbtip/url.prg
* synced with Viktor's branch.
2015-03-10 18:06 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* contrib/hbtip/cgi.prg
* contrib/hbtip/client.prg

View File

@@ -21,11 +21,9 @@
#command DYNAMIC <fncs,...> => EXTERNAL <fncs>
#endif
DYNAMIC ACTIVATESSL
DYNAMIC ANSIToHtml
DYNAMIC hb_MailAssemble
DYNAMIC hb_SendMail
DYNAMIC hb_SetMimeType
DYNAMIC HtmlToANSI
DYNAMIC HtmlToOEM
DYNAMIC OEMToHtml
@@ -51,7 +49,6 @@ DYNAMIC TIPEncoderQP
DYNAMIC TIPEncoderUrl
DYNAMIC TIPLog
DYNAMIC TIPMail
DYNAMIC tip_Base64Encode
DYNAMIC tip_CheckSID
DYNAMIC tip_CRLF
DYNAMIC tip_DateToGMT
@@ -73,7 +70,9 @@ DYNAMIC tip_TimeStamp
DYNAMIC tip_URLDecode
DYNAMIC tip_URLEncode
DYNAMIC TUrl
DYNAMIC __tip_FAttrToUmask
DYNAMIC __tip_PStrCompI
DYNAMIC __tip_SSLConnectFD
#if defined( __HBEXTREQ__ ) .OR. defined( __HBEXTERN__HBTIP__REQUEST )
#uncommand DYNAMIC <fncs,...> => EXTERNAL <fncs>

View File

@@ -75,7 +75,7 @@ CREATE CLASS TIPClientHTTP FROM TIPClient
METHOD Head( xPostData, cQuery )
METHOD ReadHeaders( lClear )
METHOD Read( nLen )
METHOD UseBasicAuth() INLINE ::cAuthMode := "Basic"
METHOD UseBasicAuth() INLINE ::cAuthMode := "Basic"
METHOD ReadAll()
METHOD setCookie( cLine )
METHOD getcookies( cHost, cPath )
@@ -95,7 +95,7 @@ ENDCLASS
METHOD New( oUrl, xTrace, oCredentials ) CLASS TIPClientHTTP
::super:new( oUrl, iif( HB_ISLOGICAL( xTrace ) .AND. xTrace, "http", xTrace ), oCredentials )
::super:new( oUrl, iif( hb_defaultValue( xTrace, .F. ), "http", xTrace ), oCredentials )
::nDefaultPort := iif( ::oUrl:cProto == "https", 443, 80 )
::nConnTimeout := 5000

View File

@@ -60,7 +60,7 @@ CREATE CLASS TIPLog
PROTECTED:
VAR cFileName
VAR fhnd
VAR fhnd INIT F_ERROR
ENDCLASS
@@ -81,22 +81,17 @@ METHOD Add( cMsg ) CLASS TIPLog
LOCAL cDir, cName, cExt
LOCAL n
IF Empty( ::fhnd ) .OR. ::fhnd == F_ERROR
IF ::fhnd == F_ERROR
hb_FNameSplit( ::cFileName, @cDir, @cName, @cExt )
n := 1
DO WHILE .T.
::fhnd := hb_FCreate( hb_FNameMerge( cDir, cName + "-" + hb_ntos( n ), cExt ), NIL, FO_EXCL )
IF ::fhnd != F_ERROR .OR. ;
FError() == 3 /* path not found */
EXIT
ENDIF
n++
DO WHILE ( ::fhnd := hb_FCreate( hb_FNameMerge( cDir, cName + "-" + hb_ntos( n++ ), cExt ),, FO_EXCL ) ) == F_ERROR .AND. ;
FError() != 3 /* path not found */
ENDDO
ENDIF
IF ! Empty( ::fhnd ) .AND. ::fhnd != F_ERROR
IF ::fhnd != F_ERROR
RETURN FWrite( ::fhnd, cMsg ) == hb_BLen( cMsg )
ENDIF
@@ -106,13 +101,13 @@ METHOD Close() CLASS TIPLog
LOCAL lRetVal
IF ! Empty( ::fhnd ) .AND. ::fhnd != F_ERROR
IF ::fhnd != F_ERROR
lRetVal := FClose( ::fhnd )
::fhnd := NIL
::fhnd := F_ERROR
RETURN lRetVal
ENDIF
RETURN .F.
METHOD Clear() CLASS TIPLog
RETURN ::Close() .AND. FErase( ::cFileName ) == 0
RETURN ::Close() .AND. FErase( ::cFileName ) != F_ERROR

View File

@@ -56,29 +56,25 @@
*
*/
#define SID_LENGTH 25
#define BASE_KEY_STRING "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
#define CRC_KEY_STRING "Ak3yStR1Ng" // Max Length must be 10 chars
#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 cSID, nSIDCRC, cSIDCRC, n, cTemp, nKey, nRand
LOCAL cBaseKeys := BASE_KEY_STRING
LOCAL nLenKeys := Len( cBaseKeys )
LOCAL cRet
LOCAL nRand, nKey := 0
hb_default( @cCRCKey, CRC_KEY_STRING )
cCRCKey := Left( cCRCKey, 10 ) // Max Lenght must to be of 10 chars
cCRCKey := Left( hb_defaultValue( cCRCKey, CRC_KEY_STRING ), 10 ) // Max Length 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
cSID := ""
nKey := 0
FOR n := 1 TO SID_LENGTH
nRand := hb_RandomInt( 1, nLenKeys )
cSID += SubStr( cBaseKeys, nRand, 1 )
nKey += nRand
NEXT
nSIDCRC := nKey * 51 // Max Value is 99603 a 5 chars number
@@ -88,30 +84,24 @@ FUNCTION tip_GenerateSID( cCRCKey )
cSIDCRC += SubStr( cCRCKey, Val( SubStr( cTemp, n, 1 ) ) + 1, 1 )
NEXT
cRet := cSID + cSIDCRC
RETURN cRet
RETURN cSID + cSIDCRC
FUNCTION tip_CheckSID( cSID, cCRCKey )
LOCAL nSIDCRC, cSIDCRC, n, cTemp
LOCAL nLenSID := SID_LENGTH
LOCAL cBaseKeys := BASE_KEY_STRING
LOCAL nRand, nKey := 0
LOCAL nSIDCRC, cSIDCRC, n, cTemp, nKey
hb_default( @cCRCKey, CRC_KEY_STRING )
cCRCKey := Left( cCRCKey, 10 ) // Max Lenght must to be of 10 chars
cCRCKey := Left( hb_defaultValue( cCRCKey, CRC_KEY_STRING ), 10 ) // Max Length must to be of 10 chars
/* Calculate the key */
FOR n := 1 TO nLenSID
nRand := At( SubStr( cSID, n, 1 ), cBaseKeys )
nKey += nRand
nKey := 0
FOR n := 1 TO SID_LENGTH
nKey += At( SubStr( cSID, n, 1 ), BASE_KEY_STRING )
NEXT
// Recalculate the CRC
/* 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 )

View File

@@ -167,7 +167,7 @@ METHOD StartTLS() CLASS TIPClientSMTP
IF ::GetOk() .AND. ::lHasSSL
::EnableSSL( .T. )
ActivateSSL( Self )
__tip_SSLConnectFD( ::ssl, ::SocketCon )
::inetSendAll( ::SocketCon, "EHLO " + iif( Empty( ::cClientHost ), "TIPClientSMTP", ::cClientHost ) + ::cCRLF )
RETURN ::DetectSecurity()
ENDIF
@@ -179,10 +179,8 @@ METHOD DetectSecurity() CLASS TIPClientSMTP
LOCAL lOk
DO WHILE .T.
IF ! ( lOk := ::GetOk() )
EXIT
ENDIF
IF ::cReply == NIL
IF !( lOk := ::GetOk() ) .OR. ;
::cReply == NIL
EXIT
ENDIF
IF "LOGIN" $ ::cReply

View File

@@ -46,248 +46,246 @@
*
*/
#ifndef _HB_THTML
#define _HB_THTML
#ifndef _HB_THTML
#define _HB_THTML
/*
content model shortcut encoding taken from Tidy library
(www.sourceforge.net/tidy)
*/
/* Content model shortcut encoding taken from Tidy library
http://www.html-tidy.org */
#define CM_UNKNOWN 0
#define CM_EMPTY 0x000001 /* Elements with no content. Map to HTML specification. */
#define CM_HTML 0x000002 /* Elements that appear outside of "BODY". */
#define CM_HEAD 0x000004 /* Elements that can appear within HEAD. */
#define CM_BLOCK 0x000008 /* HTML "block" elements. */
#define CM_INLINE 0x000010 /* HTML "inline" elements. */
#define CM_LIST 0x000020 /* Elements that mark list item ("LI"). */
#define CM_DEFLIST 0x000040 /* Elements that mark definition list item ("DL", "DT"). */
#define CM_TABLE 0x000080 /* Elements that can appear inside TABLE. */
#define CM_ROWGRP 0x000100 /* Used for "THEAD", "TFOOT" or "TBODY". */
#define CM_ROW 0x000200 /* Used for "TD", "TH" */
#define CM_FIELD 0x000400 /* Elements whose content must be protected against white space movement.
Includes some elements that can found in forms. */
#define CM_OBJECT 0x000800 /* Used to avoid propagating inline emphasis inside some elements
such as OBJECT or APPLET. */
#define CM_PARAM 0x001000 /* Elements that allows "PARAM". */
#define CM_FRAMES 0x002000 /* "FRAME", "FRAMESET", "NOFRAMES". Used in ParseFrameSet. */
#define CM_HEADING 0x004000 /* Heading elements (h1, h2, ...). */
#define CM_OPT 0x008000 /* Elements with an optional end tag. */
#define CM_IMG 0x010000 /* Elements that use "align" attribute for vertical position. */
#define CM_MIXED 0x020000 /* Elements with inline and block model. Used to avoid calling InlineDup. */
#define CM_NO_INDENT 0x040000 /* Elements whose content needs to be indented only if containing one
CM_BLOCK element. */
#define CM_OBSOLETE 0x080000 /* Elements that are obsolete (such as "dir", "menu"). */
#define CM_NEW 0x100000 /* User defined elements. Used to determine how attributes wihout value
should be printed. */
#define CM_OMITST 0x200000 /* Elements that cannot be omitted. */
#define CM_UNKNOWN 0
#define CM_EMPTY 0x000001 /* Elements with no content. Map to HTML specification. */
#define CM_HTML 0x000002 /* Elements that appear outside of "body". */
#define CM_HEAD 0x000004 /* Elements that can appear within HEAD. */
#define CM_BLOCK 0x000008 /* HTML "block" elements. */
#define CM_INLINE 0x000010 /* HTML "inline" elements. */
#define CM_LIST 0x000020 /* Elements that mark list item ("li"). */
#define CM_DEFLIST 0x000040 /* Elements that mark definition list item ("dl", "dt"). */
#define CM_TABLE 0x000080 /* Elements that can appear inside TABLE. */
#define CM_ROWGRP 0x000100 /* Used for "thead", "tfoot" or "tbody". */
#define CM_ROW 0x000200 /* Used for "td", "th" */
#define CM_FIELD 0x000400 /* Elements whose content must be protected against white space movement.
Includes some elements that can found in forms. */
#define CM_OBJECT 0x000800 /* Used to avoid propagating inline emphasis inside some elements
such as OBJECT or APPLET. */
#define CM_PARAM 0x001000 /* Elements that allows "PARAM". */
#define CM_FRAMES 0x002000 /* "FRAME", "FRAMESET", "NOFRAMES". Used in ParseFrameSet. */
#define CM_HEADING 0x004000 /* Heading elements (h1, h2, ...). */
#define CM_OPT 0x008000 /* Elements with an optional end tag. */
#define CM_IMG 0x010000 /* Elements that use "align" attribute for vertical position. */
#define CM_MIXED 0x020000 /* Elements with inline and block model. Used to avoid calling InlineDup. */
#define CM_NO_INDENT 0x040000 /* Elements whose content needs to be indented only if containing one
CM_BLOCK element. */
#define CM_OBSOLETE 0x080000 /* Elements that are obsolete (such as "dir", "menu"). */
#define CM_NEW 0x100000 /* User defined elements. Used to determine how attributes wihout value
should be printed. */
#define CM_OMITST 0x200000 /* Elements that cannot be omitted. */
/* Constants for HTML attributes adopted from Tidy library (www.sourceforge.net/tidy) */
/* Constants for HTML attributes adopted from Tidy library */
#define HTML_ATTR_ABBR 1
#define HTML_ATTR_ACCEPT 2
#define HTML_ATTR_ACCEPT_CHARSET 3
#define HTML_ATTR_ACCESSKEY 4
#define HTML_ATTR_ACTION 5
#define HTML_ATTR_ADD_DATE 6
#define HTML_ATTR_ALIGN 7
#define HTML_ATTR_ALINK 8
#define HTML_ATTR_ALT 9
#define HTML_ATTR_ARCHIVE 10
#define HTML_ATTR_AXIS 11
#define HTML_ATTR_BACKGROUND 12
#define HTML_ATTR_BGCOLOR 13
#define HTML_ATTR_BGPROPERTIES 14
#define HTML_ATTR_BORDER 15
#define HTML_ATTR_BORDERCOLOR 16
#define HTML_ATTR_BOTTOMMARGIN 17
#define HTML_ATTR_CELLPADDING 18
#define HTML_ATTR_CELLSPACING 19
#define HTML_ATTR_CHAR 20
#define HTML_ATTR_CHAROFF 21
#define HTML_ATTR_CHARSET 22
#define HTML_ATTR_CHECKED 23
#define HTML_ATTR_CITE 24
#define HTML_ATTR_CLASS 25
#define HTML_ATTR_CLASSID 26
#define HTML_ATTR_CLEAR 27
#define HTML_ATTR_CODE 28
#define HTML_ATTR_CODEBASE 29
#define HTML_ATTR_CODETYPE 30
#define HTML_ATTR_COLOR 31
#define HTML_ATTR_COLS 32
#define HTML_ATTR_COLSPAN 33
#define HTML_ATTR_COMPACT 34
#define HTML_ATTR_CONTENT 35
#define HTML_ATTR_COORDS 36
#define HTML_ATTR_DATA 37
#define HTML_ATTR_DATAFLD 38
#define HTML_ATTR_DATAFORMATAS 39
#define HTML_ATTR_DATAPAGESIZE 40
#define HTML_ATTR_DATASRC 41
#define HTML_ATTR_DATETIME 42
#define HTML_ATTR_DECLARE 43
#define HTML_ATTR_DEFER 44
#define HTML_ATTR_DIR 45
#define HTML_ATTR_DISABLED 46
#define HTML_ATTR_ENCODING 47
#define HTML_ATTR_ENCTYPE 48
#define HTML_ATTR_EVENT 49
#define HTML_ATTR_FACE 50
#define HTML_ATTR_FOR 51
#define HTML_ATTR_FRAME 52
#define HTML_ATTR_FRAMEBORDER 53
#define HTML_ATTR_FRAMESPACING 54
#define HTML_ATTR_GRIDX 55
#define HTML_ATTR_GRIDY 56
#define HTML_ATTR_HEADERS 57
#define HTML_ATTR_HEIGHT 58
#define HTML_ATTR_HREF 59
#define HTML_ATTR_HREFLANG 60
#define HTML_ATTR_HSPACE 61
#define HTML_ATTR_HTTP_EQUIV 62
#define HTML_ATTR_ID 63
#define HTML_ATTR_ISMAP 64
#define HTML_ATTR_LABEL 65
#define HTML_ATTR_LANG 66
#define HTML_ATTR_LANGUAGE 67
#define HTML_ATTR_LAST_MODIFIED 68
#define HTML_ATTR_LAST_VISIT 69
#define HTML_ATTR_LEFTMARGIN 70
#define HTML_ATTR_LINK 71
#define HTML_ATTR_LONGDESC 72
#define HTML_ATTR_LOWSRC 73
#define HTML_ATTR_MARGINHEIGHT 74
#define HTML_ATTR_MARGINWIDTH 75
#define HTML_ATTR_MAXLENGTH 76
#define HTML_ATTR_MEDIA 77
#define HTML_ATTR_METHOD 78
#define HTML_ATTR_METHODS 79
#define HTML_ATTR_MULTIPLE 80
#define HTML_ATTR_N 81
#define HTML_ATTR_NAME 82
#define HTML_ATTR_NOHREF 83
#define HTML_ATTR_NORESIZE 84
#define HTML_ATTR_NOSHADE 85
#define HTML_ATTR_NOWRAP 86
#define HTML_ATTR_OBJECT 87
#define HTML_ATTR_ONAFTERUPDATE 88
#define HTML_ATTR_ONBEFOREUNLOAD 89
#define HTML_ATTR_ONBEFOREUPDATE 90
#define HTML_ATTR_ONBLUR 91
#define HTML_ATTR_ONCHANGE 92
#define HTML_ATTR_ONCLICK 93
#define HTML_ATTR_ONDATAAVAILABLE 94
#define HTML_ATTR_ONDATASETCHANGED 95
#define HTML_ATTR_ONDATASETCOMPLETE 96
#define HTML_ATTR_ONDBLCLICK 97
#define HTML_ATTR_ONERRORUPDATE 98
#define HTML_ATTR_ONFOCUS 99
#define HTML_ATTR_ONKEYDOWN 100
#define HTML_ATTR_ONKEYPRESS 101
#define HTML_ATTR_ONKEYUP 102
#define HTML_ATTR_ONLOAD 103
#define HTML_ATTR_ONMOUSEDOWN 104
#define HTML_ATTR_ONMOUSEMOVE 105
#define HTML_ATTR_ONMOUSEOUT 106
#define HTML_ATTR_ONMOUSEOVER 107
#define HTML_ATTR_ONMOUSEUP 108
#define HTML_ATTR_ONRESET 109
#define HTML_ATTR_ONROWENTER 110
#define HTML_ATTR_ONROWEXIT 111
#define HTML_ATTR_ONSELECT 112
#define HTML_ATTR_ONSUBMIT 113
#define HTML_ATTR_ONUNLOAD 114
#define HTML_ATTR_PROFILE 115
#define HTML_ATTR_PROMPT 116
#define HTML_ATTR_RBSPAN 117
#define HTML_ATTR_READONLY 118
#define HTML_ATTR_REL 119
#define HTML_ATTR_REV 120
#define HTML_ATTR_RIGHTMARGIN 121
#define HTML_ATTR_ROWS 122
#define HTML_ATTR_ROWSPAN 123
#define HTML_ATTR_RULES 124
#define HTML_ATTR_SCHEME 125
#define HTML_ATTR_SCOPE 126
#define HTML_ATTR_SCROLLING 127
#define HTML_ATTR_SDAFORM 128
#define HTML_ATTR_SDAPREF 129
#define HTML_ATTR_SDASUFF 130
#define HTML_ATTR_SELECTED 131
#define HTML_ATTR_SHAPE 132
#define HTML_ATTR_SHOWGRID 133
#define HTML_ATTR_SHOWGRIDX 134
#define HTML_ATTR_SHOWGRIDY 135
#define HTML_ATTR_SIZE 136
#define HTML_ATTR_SPAN 137
#define HTML_ATTR_SRC 138
#define HTML_ATTR_STANDBY 139
#define HTML_ATTR_START 140
#define HTML_ATTR_STYLE 141
#define HTML_ATTR_SUMMARY 142
#define HTML_ATTR_TABINDEX 143
#define HTML_ATTR_TARGET 144
#define HTML_ATTR_TEXT 145
#define HTML_ATTR_TITLE 146
#define HTML_ATTR_TOPMARGIN 147
#define HTML_ATTR_TYPE 148
#define HTML_ATTR_UNKNOWN 149
#define HTML_ATTR_URN 150
#define HTML_ATTR_USEMAP 151
#define HTML_ATTR_VALIGN 152
#define HTML_ATTR_VALUE 153
#define HTML_ATTR_VALUETYPE 154
#define HTML_ATTR_VERSION 155
#define HTML_ATTR_VLINK 156
#define HTML_ATTR_VSPACE 157
#define HTML_ATTR_WIDTH 158
#define HTML_ATTR_WRAP 159
#define HTML_ATTR_XMLNS 160
#define HTML_ATTR_XML_LANG 161
#define HTML_ATTR_XML_SPACE 162
#define HTML_ATTR_ABBR 1
#define HTML_ATTR_ACCEPT 2
#define HTML_ATTR_ACCEPT_CHARSET 3
#define HTML_ATTR_ACCESSKEY 4
#define HTML_ATTR_ACTION 5
#define HTML_ATTR_ADD_DATE 6
#define HTML_ATTR_ALIGN 7
#define HTML_ATTR_ALINK 8
#define HTML_ATTR_ALT 9
#define HTML_ATTR_ARCHIVE 10
#define HTML_ATTR_AXIS 11
#define HTML_ATTR_BACKGROUND 12
#define HTML_ATTR_BGCOLOR 13
#define HTML_ATTR_BGPROPERTIES 14
#define HTML_ATTR_BORDER 15
#define HTML_ATTR_BORDERCOLOR 16
#define HTML_ATTR_BOTTOMMARGIN 17
#define HTML_ATTR_CELLPADDING 18
#define HTML_ATTR_CELLSPACING 19
#define HTML_ATTR_CHAR 20
#define HTML_ATTR_CHAROFF 21
#define HTML_ATTR_CHARSET 22
#define HTML_ATTR_CHECKED 23
#define HTML_ATTR_CITE 24
#define HTML_ATTR_CLASS 25
#define HTML_ATTR_CLASSID 26
#define HTML_ATTR_CLEAR 27
#define HTML_ATTR_CODE 28
#define HTML_ATTR_CODEBASE 29
#define HTML_ATTR_CODETYPE 30
#define HTML_ATTR_COLOR 31
#define HTML_ATTR_COLS 32
#define HTML_ATTR_COLSPAN 33
#define HTML_ATTR_COMPACT 34
#define HTML_ATTR_CONTENT 35
#define HTML_ATTR_COORDS 36
#define HTML_ATTR_DATA 37
#define HTML_ATTR_DATAFLD 38
#define HTML_ATTR_DATAFORMATAS 39
#define HTML_ATTR_DATAPAGESIZE 40
#define HTML_ATTR_DATASRC 41
#define HTML_ATTR_DATETIME 42
#define HTML_ATTR_DECLARE 43
#define HTML_ATTR_DEFER 44
#define HTML_ATTR_DIR 45
#define HTML_ATTR_DISABLED 46
#define HTML_ATTR_ENCODING 47
#define HTML_ATTR_ENCTYPE 48
#define HTML_ATTR_EVENT 49
#define HTML_ATTR_FACE 50
#define HTML_ATTR_FOR 51
#define HTML_ATTR_FRAME 52
#define HTML_ATTR_FRAMEBORDER 53
#define HTML_ATTR_FRAMESPACING 54
#define HTML_ATTR_GRIDX 55
#define HTML_ATTR_GRIDY 56
#define HTML_ATTR_HEADERS 57
#define HTML_ATTR_HEIGHT 58
#define HTML_ATTR_HREF 59
#define HTML_ATTR_HREFLANG 60
#define HTML_ATTR_HSPACE 61
#define HTML_ATTR_HTTP_EQUIV 62
#define HTML_ATTR_ID 63
#define HTML_ATTR_ISMAP 64
#define HTML_ATTR_LABEL 65
#define HTML_ATTR_LANG 66
#define HTML_ATTR_LANGUAGE 67
#define HTML_ATTR_LAST_MODIFIED 68
#define HTML_ATTR_LAST_VISIT 69
#define HTML_ATTR_LEFTMARGIN 70
#define HTML_ATTR_LINK 71
#define HTML_ATTR_LONGDESC 72
#define HTML_ATTR_LOWSRC 73
#define HTML_ATTR_MARGINHEIGHT 74
#define HTML_ATTR_MARGINWIDTH 75
#define HTML_ATTR_MAXLENGTH 76
#define HTML_ATTR_MEDIA 77
#define HTML_ATTR_METHOD 78
#define HTML_ATTR_METHODS 79
#define HTML_ATTR_MULTIPLE 80
#define HTML_ATTR_N 81
#define HTML_ATTR_NAME 82
#define HTML_ATTR_NOHREF 83
#define HTML_ATTR_NORESIZE 84
#define HTML_ATTR_NOSHADE 85
#define HTML_ATTR_NOWRAP 86
#define HTML_ATTR_OBJECT 87
#define HTML_ATTR_ONAFTERUPDATE 88
#define HTML_ATTR_ONBEFOREUNLOAD 89
#define HTML_ATTR_ONBEFOREUPDATE 90
#define HTML_ATTR_ONBLUR 91
#define HTML_ATTR_ONCHANGE 92
#define HTML_ATTR_ONCLICK 93
#define HTML_ATTR_ONDATAAVAILABLE 94
#define HTML_ATTR_ONDATASETCHANGED 95
#define HTML_ATTR_ONDATASETCOMPLETE 96
#define HTML_ATTR_ONDBLCLICK 97
#define HTML_ATTR_ONERRORUPDATE 98
#define HTML_ATTR_ONFOCUS 99
#define HTML_ATTR_ONKEYDOWN 100
#define HTML_ATTR_ONKEYPRESS 101
#define HTML_ATTR_ONKEYUP 102
#define HTML_ATTR_ONLOAD 103
#define HTML_ATTR_ONMOUSEDOWN 104
#define HTML_ATTR_ONMOUSEMOVE 105
#define HTML_ATTR_ONMOUSEOUT 106
#define HTML_ATTR_ONMOUSEOVER 107
#define HTML_ATTR_ONMOUSEUP 108
#define HTML_ATTR_ONRESET 109
#define HTML_ATTR_ONROWENTER 110
#define HTML_ATTR_ONROWEXIT 111
#define HTML_ATTR_ONSELECT 112
#define HTML_ATTR_ONSUBMIT 113
#define HTML_ATTR_ONUNLOAD 114
#define HTML_ATTR_PROFILE 115
#define HTML_ATTR_PROMPT 116
#define HTML_ATTR_RBSPAN 117
#define HTML_ATTR_READONLY 118
#define HTML_ATTR_REL 119
#define HTML_ATTR_REV 120
#define HTML_ATTR_RIGHTMARGIN 121
#define HTML_ATTR_ROWS 122
#define HTML_ATTR_ROWSPAN 123
#define HTML_ATTR_RULES 124
#define HTML_ATTR_SCHEME 125
#define HTML_ATTR_SCOPE 126
#define HTML_ATTR_SCROLLING 127
#define HTML_ATTR_SDAFORM 128
#define HTML_ATTR_SDAPREF 129
#define HTML_ATTR_SDASUFF 130
#define HTML_ATTR_SELECTED 131
#define HTML_ATTR_SHAPE 132
#define HTML_ATTR_SHOWGRID 133
#define HTML_ATTR_SHOWGRIDX 134
#define HTML_ATTR_SHOWGRIDY 135
#define HTML_ATTR_SIZE 136
#define HTML_ATTR_SPAN 137
#define HTML_ATTR_SRC 138
#define HTML_ATTR_STANDBY 139
#define HTML_ATTR_START 140
#define HTML_ATTR_STYLE 141
#define HTML_ATTR_SUMMARY 142
#define HTML_ATTR_TABINDEX 143
#define HTML_ATTR_TARGET 144
#define HTML_ATTR_TEXT 145
#define HTML_ATTR_TITLE 146
#define HTML_ATTR_TOPMARGIN 147
#define HTML_ATTR_TYPE 148
#define HTML_ATTR_UNKNOWN 149
#define HTML_ATTR_URN 150
#define HTML_ATTR_USEMAP 151
#define HTML_ATTR_VALIGN 152
#define HTML_ATTR_VALUE 153
#define HTML_ATTR_VALUETYPE 154
#define HTML_ATTR_VERSION 155
#define HTML_ATTR_VLINK 156
#define HTML_ATTR_VSPACE 157
#define HTML_ATTR_WIDTH 158
#define HTML_ATTR_WRAP 159
#define HTML_ATTR_XMLNS 160
#define HTML_ATTR_XML_LANG 161
#define HTML_ATTR_XML_SPACE 162
#define HTML_ATTR_COUNT 162
#define HTML_ATTR_COUNT 162
#define HTML_ATTR_TYPE_UNKNOWN 0
#define HTML_ATTR_TYPE_ACTION 1
#define HTML_ATTR_TYPE_ALIGN 2
#define HTML_ATTR_TYPE_BOOL 3
#define HTML_ATTR_TYPE_BORDER 4
#define HTML_ATTR_TYPE_CHARACTER 5
#define HTML_ATTR_TYPE_CHARSET 6
#define HTML_ATTR_TYPE_CLEAR 7
#define HTML_ATTR_TYPE_COLOR 8
#define HTML_ATTR_TYPE_COLS 9
#define HTML_ATTR_TYPE_COORDS 10
#define HTML_ATTR_TYPE_DATE 11
#define HTML_ATTR_TYPE_FBORDER 12
#define HTML_ATTR_TYPE_FSUBMIT 13
#define HTML_ATTR_TYPE_IDDEF 14
#define HTML_ATTR_TYPE_IDREF 15
#define HTML_ATTR_TYPE_IDREFS 16
#define HTML_ATTR_TYPE_LANG 17
#define HTML_ATTR_TYPE_LENGTH 18
#define HTML_ATTR_TYPE_LINKTYPES 19
#define HTML_ATTR_TYPE_MEDIA 20
#define HTML_ATTR_TYPE_NAME 21
#define HTML_ATTR_TYPE_NUMBER 22
#define HTML_ATTR_TYPE_PCDATA 23
#define HTML_ATTR_TYPE_SCOPE 24
#define HTML_ATTR_TYPE_SCRIPT 25
#define HTML_ATTR_TYPE_SCROLL 26
#define HTML_ATTR_TYPE_SHAPE 27
#define HTML_ATTR_TYPE_TARGET 28
#define HTML_ATTR_TYPE_TEXTDIR 29
#define HTML_ATTR_TYPE_TFRAME 30
#define HTML_ATTR_TYPE_TRULES 31
#define HTML_ATTR_TYPE_TYPE 32
#define HTML_ATTR_TYPE_URL 33
#define HTML_ATTR_TYPE_URLS 34
#define HTML_ATTR_TYPE_VALIGN 35
#define HTML_ATTR_TYPE_VTYPE 36
#define HTML_ATTR_TYPE_XTYPE 37
#define HTML_ATTR_TYPE_UNKNOWN 0
#define HTML_ATTR_TYPE_ACTION 1
#define HTML_ATTR_TYPE_ALIGN 2
#define HTML_ATTR_TYPE_BOOL 3
#define HTML_ATTR_TYPE_BORDER 4
#define HTML_ATTR_TYPE_CHARACTER 5
#define HTML_ATTR_TYPE_CHARSET 6
#define HTML_ATTR_TYPE_CLEAR 7
#define HTML_ATTR_TYPE_COLOR 8
#define HTML_ATTR_TYPE_COLS 9
#define HTML_ATTR_TYPE_COORDS 10
#define HTML_ATTR_TYPE_DATE 11
#define HTML_ATTR_TYPE_FBORDER 12
#define HTML_ATTR_TYPE_FSUBMIT 13
#define HTML_ATTR_TYPE_IDDEF 14
#define HTML_ATTR_TYPE_IDREF 15
#define HTML_ATTR_TYPE_IDREFS 16
#define HTML_ATTR_TYPE_LANG 17
#define HTML_ATTR_TYPE_LENGTH 18
#define HTML_ATTR_TYPE_LINKTYPES 19
#define HTML_ATTR_TYPE_MEDIA 20
#define HTML_ATTR_TYPE_NAME 21
#define HTML_ATTR_TYPE_NUMBER 22
#define HTML_ATTR_TYPE_PCDATA 23
#define HTML_ATTR_TYPE_SCOPE 24
#define HTML_ATTR_TYPE_SCRIPT 25
#define HTML_ATTR_TYPE_SCROLL 26
#define HTML_ATTR_TYPE_SHAPE 27
#define HTML_ATTR_TYPE_TARGET 28
#define HTML_ATTR_TYPE_TEXTDIR 29
#define HTML_ATTR_TYPE_TFRAME 30
#define HTML_ATTR_TYPE_TRULES 31
#define HTML_ATTR_TYPE_TYPE 32
#define HTML_ATTR_TYPE_URL 33
#define HTML_ATTR_TYPE_URLS 34
#define HTML_ATTR_TYPE_VALIGN 35
#define HTML_ATTR_TYPE_VTYPE 36
#define HTML_ATTR_TYPE_XTYPE 37
#define HTML_ATTR_TYPE_COUNT 37
#define HTML_ATTR_TYPE_COUNT 37
#endif /* _HB_THTML */

View File

@@ -1,4 +1,4 @@
/*
*/*
* xHarbour Project source code:
* TIP Class oriented Internet protocol library (header)
*
@@ -49,8 +49,8 @@
#ifndef TIP_CH
#define TIP_CH
#define TIP_RO 0 /* Tip read only protocol */
#define TIP_WO 1 /* Tip write only protocol */
#define TIP_RW 2 /* Tip read/write protocol */
#define TIP_RO 0 /* TIP read only protocol */
#define TIP_WO 1 /* TIP write only protocol */
#define TIP_RW 2 /* TIP read/write protocol */
#endif

View File

@@ -48,28 +48,27 @@
#include "hbclass.ch"
/*
* An URL:
* http://gian:passwd@www.niccolai.ws/mypages/mysite/page.html?avar=0&avar1=1
* ^--^ ^--^ ^----^ ^-------------^ ^----------------------^ ^------------^
* cProto UID PWD cServer cPath cQuery
* ^------------^ ^-------^
* cDirectory cFile
* ^--^ ^--^
* cFname cExt
*/
/* An URL:
https://user:passwd@example.com/mypages/mysite/page.html?avar=0&avar1=1
^---^ ^--^ ^----^ ^---------^ ^----------------------^ ^------------^
cProto UID PWD cServer cPath cQuery
^------------^ ^-------^
cDirectory cFile
^--^ ^--^
cFname cExt
*/
CREATE CLASS TUrl
VAR cAddress
VAR cProto
VAR cServer
VAR cPath
VAR cQuery
VAR cFile
VAR nPort
VAR cUserid
VAR cPassword
VAR cAddress INIT ""
VAR cProto INIT ""
VAR cUserid INIT ""
VAR cPassword INIT ""
VAR cServer INIT ""
VAR cPath INIT ""
VAR cQuery INIT ""
VAR cFile INIT ""
VAR nPort INIT -1
METHOD New( cUrl )
METHOD SetAddress( cUrl )
@@ -96,13 +95,17 @@ METHOD SetAddress( cUrl ) CLASS TUrl
LOCAL aMatch, cServer, cPath
IF ! HB_ISSTRING( cUrl )
RETURN .F.
ENDIF
::cAddress := cUrl
::cProto := ""
::cUserid := ""
::cPassword := ""
::cServer := ""
::cPath := ""
::cQuery := ""
::cProto := ;
::cUserid := ;
::cPassword := ;
::cServer := ;
::cPath := ;
::cQuery := ;
::cFile := ""
::nPort := -1
@@ -123,7 +126,7 @@ METHOD SetAddress( cUrl ) CLASS TUrl
cPath := aMatch[ 4 ]
::cQuery := aMatch[ 5 ]
// server parsing (can't fail)
// server parsing (never fails)
aMatch := hb_regex( ::cREServ, cServer )
::cUserId := aMatch[ 2 ]
::cPassword := aMatch[ 3 ]
@@ -133,7 +136,7 @@ METHOD SetAddress( cUrl ) CLASS TUrl
::nPort := -1
ENDIF
// Parse path and file (can't fail)
// Parse path and file (never fails)
aMatch := hb_regex( ::cREFile, cPath )
::cPath := aMatch[ 2 ]
::cFile := aMatch[ 3 ]
@@ -177,13 +180,7 @@ METHOD BuildAddress() CLASS TUrl
cRet += "?" + ::cQuery
ENDIF
IF Len( cRet ) == 0
cRet := NIL
ELSE
::cAddress := cRet
ENDIF
RETURN cRet
RETURN iif( Len( cRet ) == 0, NIL, ::cAddress := cRet )
METHOD BuildQuery() CLASS TUrl
@@ -200,28 +197,24 @@ METHOD BuildQuery() CLASS TUrl
RETURN cLine
METHOD AddGetForm( xPostData )
METHOD AddGetForm( xPostData ) CLASS TUrl
LOCAL cData := ""
LOCAL nI
LOCAL y
LOCAL cRet
LOCAL item
IF HB_ISHASH( xPostData )
y := Len( xPostData )
FOR nI := 1 TO y
cData += tip_URLEncode( AllTrim( hb_CStr( hb_HKeyAt( xPostData, nI ) ) ) ) + "="
cData += tip_URLEncode( AllTrim( hb_CStr( hb_HValueAt( xPostData, nI ) ) ) )
IF nI != y
FOR EACH item IN xPostData
cData += tip_URLEncode( AllTrim( hb_CStr( item:__enumKey() ) ) ) + "=" + ;
tip_URLEncode( AllTrim( hb_CStr( item ) ) )
IF ! item:__enumIsLast()
cData += "&"
ENDIF
NEXT
ELSEIF HB_ISARRAY( xPostData )
y := Len( xPostData )
FOR nI := 1 TO y
cData += tip_URLEncode( AllTrim( hb_CStr( xPostData[ nI, 1 ] ) ) ) + "="
cData += tip_URLEncode( AllTrim( hb_CStr( xPostData[ nI, 2 ] ) ) )
IF nI != y
FOR EACH item IN xPostData
cData += tip_URLEncode( AllTrim( hb_CStr( item[ 1 ] ) ) ) + "=" + ;
tip_URLEncode( AllTrim( hb_CStr( item[ 2 ] ) ) )
IF ! item:__enumIsLast()
cData += "&"
ENDIF
NEXT
@@ -229,8 +222,5 @@ METHOD AddGetForm( xPostData )
cData := xPostData
ENDIF
IF ! Empty( cData )
cRet := ::cQuery += iif( Empty( ::cQuery ), "", "&" ) + cData
ENDIF
RETURN cRet
RETURN iif( Empty( cData ), NIL, ;
::cQuery += iif( Empty( ::cQuery ), "", "&" ) + cData )