please, how is it possible do „secure“ version of example below?
Instead of http protocol there must be used httpS version.
I need process sensitive data, e.g. name, eMail, address – I think this rule/regulation is not only in our country.
Next info I found in Alaska’s Xbase++ doc:
By default, websocket communication is unencrypted. However, the WebsocketClient class also supports establishing connections encrypted via a Secure Socket Layer (SSL). For this, 443 must be specified as the port number when creating the websocket client object via the method :new().
So, I searched on internet and found also free or trial version of SSL certificates – for first tests or basic security it is OK...
and all certificates/organizations are officially supported in Windows like accepted authorities too!
https://www.startssl.com/?app=1 - FREE
https://www.geotrust.com/ssl/free-ssl-certificate - 30-day trial
https://www.freessl.com - 30-day trial
TIA & Regards
Zdeno
Code: Select all
***********************
METHOD Cxp:TestRegister
***********************
Local cRemoteIP := ::HttpRequest:GetVariable("REMOTE_ADDR")
Local nPos := 0
*
Local cHtml := ''
Local i
Local aItems
Local cErrorMessage := ''
Local oForm
Local lSendForm := .T.
Local aVars
*
Local n, nMax
Local cLabel, cValue, nMaxSize, cVarName, cText
*
Local nPCount := 0
Local cGQC := IIf( ( nPCount != 0 ), ::httpRequest:getQueryString(), '' )
*
Local aRet, aLog, lError
*
* Local cPath := ( CurDrive() + ':\' + CurDir() + '\' )
*
Local aUser := {}
Local oMySession
Local cTxtKosik
Local cCWN
::setErrorBlock()
BEGIN SEQUENCE
cHtml += '<html>' + CRLF
cHtml += '<head>' + CRLF
cHtml += '<meta content="text/html; charset=windows-1250" http-equiv="content-type">' + CRLF
* cHtml += '<!--- <meta http-equiv="refresh" content="5"> --->' + CRLF
* cHtml += '<style type="text/css">' ;
cHtml += '<style> ' ;
+ 'body {font-family:Segoe UI,Helvetica,Arial,sans-serif;' ;
+ 'font-size:16px;' ;
+ '}' ;
+ '</style>' + CRLF
cHtml += '</head>' + CRLF
cHtml += '<body>' + CRLF
*
* cHtml += '<table border="1" style="width:100%">' + CRLF
/*
cHtml += '<table border="0">' + CRLF
cHtml += ' <tr>' + CRLF
cHtml += ' <td><a href = "/index.html">' + myLangMsg( MSG_HOME ) + '</a></td>' + CRLF
cHtml += ' <td>|</td>' + CRLF
cHtml += ' <td><a href = "/cxp/program">' + myLangMsg( MSG_PROGRAM ) + '</a></td>' + CRLF
cHtml += ' <td>|</td>' + CRLF
If ::MyGetValue( 'cCustomerName' ) == NIL .or. Empty( ::MyGetValue( 'cCustomerName' ) ) .or. ( ::MyGetValue( 'cCustomerName' ) == '(nikto)' )
cHtml += ' <td>' + myLangMsg( MSG_LOGGED ) + ': <b>Nikto</b></td>' + CRLF
cHtml += ' <td><a href = "/cxp/LogIn">' + myLangMsg( MSG_LOGIN ) + '</a></td>' + CRLF
cHtml += ' <td><a href = "/cxp/TestRegister">' + 'TEST-Reg' + '</a></td>' + CRLF
cHtml += ' <td>|</td>' + CRLF
Else
aUser := { ::MyGetValue( 'cCustomerICO' ), ;
::MyGetValue( 'cCustomerLogIn' ), ;
::MyGetValue( 'cCustomerName' ), ;
::MyGetValue( 'cCustomerWebNo' ) ;
}
::MySetValue( 'dDateAction', Date() )
::MySetValue( 'cTimeAction', Time() )
UpdateUziv( @::cPath, ::MyGetValue( 'cCustomerLogIn' ) )
cHtml += ' <td>' + myLangMsg( MSG_LOGIN ) + ': <b>' + Var2Char( ConvToAnsiCP( aUser[3] ) ) + '</b></td>' + CRLF
cHtml += ' <td><a href = "/cxp/LogOut">' + myLangMsg( MSG_LOGOUT ) + '</a></td>' + CRLF
cHtml += ' <td>|</td>' + CRLF
EndIf
cTxtKosik := IIf( Empty( ::MyGetValue( 'nSumKosik' ) ), ;
'', ;
( ' <b>' + AS( Len( ::MyGetValue( 'aKosik' ) ) ) + ' ks</b> za ' ;
+ '<b>' + AllTrim( Str( ::MyGetValue( 'nSumKosik' ), 12, 2 ) ) + ',- EUR</b>' ) ;
)
*/
cHtml += '<table border="0">' + CRLF
cHtml += ' <tr>' + CRLF
cHtml += ' <td><a href = "/index.html">Home</a></td>' + CRLF
cHtml += ' <td>|</td>' + CRLF
cHtml += ' <td><a href = "/cxp/program">Program</a></td>' + CRLF
cHtml += ' <td>|</td>' + CRLF
cHtml += ' <td>Logged: <b>None</b></td>' + CRLF
cHtml += ' <td><a href = "/cxp/LogIn">Login</a></td>' + CRLF
cHtml += ' <td>|</td>' + CRLF
cTxtKosik := ''
* cHtml += ' <td><a href = "/cxp/kosik">' + myLangMsg( MSG_BASKET ) + '</a> ' + cTxtKosik + '</td>' + CRLF
cHtml += ' <td><a href = "/cxp/kosik">' + 'Basket' + '</a> ' + cTxtKosik + '</td>' + CRLF
cHtml += ' </tr>' + CRLF
cHtml += '</table>' + CRLF
cHtml += '</br>' + CRLF
*
oForm := TestMyRegister():new()
aVars := oForm:getAllVars(::httpRequest:form)
// 1-label, 2-value, 3-maxsize, 4-varname, 5-text
aItems := { ;
{ 'Login',oForm:login,15,'login','' }, ;
{ 'Password',oForm:password,15,'password','' }, ;
{ 'Password (again)',oForm:rpassword,15,'rpassword','' }, ;
{ 'Surname',oForm:priezvisko,30,'priezvisko',''}, ;
{ 'Name',oForm:meno,30,'meno',''}, ;
{ 'Street',oForm:ulica,30,'ulica',''}, ;
{ 'ZIP',oForm:psc,5,'psc',''}, ;
{ 'City',oForm:obec,30,'obec',''}, ;
{ 'eMail',oForm:email,30,'email','' }, ;
{ 'Phone',oForm:telefon,15,'telefon','' }, ;
{ 'Mobil Phone',oForm:mobil,15,'mobil','' }, ;
{ 'Accepting <a href = "/cxp/vop" target="_blank">business conditions</a>',oForm:suhlas,1,'suhlas','' } ;
}
cErrorMessage := ''
lSendForm := TestRegisterValidateVars(@aItems,@cErrorMessage)
cHtml += '<span style="color: red;">' ;
+ '<small>' + Var2Char(cErrorMessage) + '</small>';
+ '</span>' + BRCRLF
If lSendForm
cHtml += '<form action="/cxp/testregister?submit" method="GET">' + CRLF
cHtml += '<table border="0">' + CRLF
nMax := Len( aItems )
* // 1-label, 2-value, 3-maxsize, 4-varname, 5-text
For n := 1 To nMax
cLabel := aItems[n,1]
cValue := aItems[n,2]
nMaxSize := aItems[n,3]
cVarName := aItems[n,4]
cText := aItems[n,5]
cHtml += '<tr>' + CRLF
cHtml += '<td align=right width=140>'+ cLabel + ':</td>' + CRLF
cHtml += '<td style="color:red"><small>' + CRLF
If ( n == 2 ) .or. ( n == 3 )
If Empty( aItems[n,2] )
cHtml += '<input type="password" name="' + cVarName + '" size=' + AS(nMaxSize) + ' maxlength=' + AS(nMaxSize) + '>' + cText + CRLF
Else
cHtml += '<input type="password" value="' + cValue + '" name="' + cVarName + '" size=' + AS(nMaxSize) + ' maxlength=' + AS(nMaxSize) + '>' + cText + CRLF
EndIf
ElseIf ( n == 12 )
cHtml += '<input type="checkbox" name="' + cVarName + '" value="A">' + cText + CRLF
Else
If Empty( aItems[n,2] )
cHtml += '<input type=text name="' + cVarName + '" size=' + AS(nMaxSize) + ' maxlength=' + AS(nMaxSize) + '>' + cText + CRLF
Else
cHtml += '<input type=text value="' + cValue + '" name="' + cVarName + '" size=' + AS(nMaxSize) + ' maxlength=' + AS(nMaxSize) + '>' + cText + CRLF
EndIf
EndIf
cHtml += '</small></td>' + CRLF
cHtml += '</tr>' + CRLF
If n==3 .or. n==11
cHtml += '<tr>' + CRLF
cHtml += '<td align=right width=140><br></td>' + CRLF
cHtml += '</tr>' + CRLF
EndIf
Next
cHtml += '<tr>' + CRLF
cHtml += '<td align=right width=140><br></td>' + CRLF
cHtml += '</tr>' + CRLF
cHtml += '<tr>' + CRLF
cHtml += '<td align=right width=140>' + CRLF
cHtml += '<input type="submit" value="Potvrï">' + CRLF
cHtml += '</td>' + CRLF
cHtml += '</tr>' + CRLF
cHtml += '</table>' + CRLF
cHtml += '</form>' + CRLF
cHtml += '</br>' + CRLF
*
cHtml += '</br>' + CRLF
cHtml += '<a href = "/cxp/register">New registration</a>' + CRLF
cHtml += '|' + CRLF
cHtml += '<a href = "/cxp/lostpassword">Lost password</a>' + CRLF
Else
* cHtml += 'OK, form validated, we can continue...' + '</br>' + CRLF
aRet := {}
ASize(aRet,Len(aItems))
aLog := {}
ASize(aLog,2)
* lError := SaveReg(@aItems,@cErrorMessage,@aRet,@aLog,::cPath)
lError := .F.
If ! lError
Else
EndIf
If lError
cHtml += Var2Char(cErrorMessage) + '<BR>' + CRLF
Else
* cHtml += PridajEmail( aLog[2] /*ICO*/, aItems[9,2] /*eMail*/, ::cPath, cRemoteIP, ::MyGetValue( 'cCustomerWebNo' ), ::MyGetValue( 'lSK' ) )
EndIf
*
EndIf
cHtml += '<br>' + CRLF
cHtml += '<hr>' + CRLF
cHtml += '<small>'+ CRLF
cHtml += '<td>Your IP address: ' + cRemoteIP + '</td>' + CRLF
cHtml += '<td>|</td>' + CRLF
cHtml += '<td><a href = "/cxp/LogIn">Your history</a></td>' + CRLF
cHtml += '</small>'+ CRLF
cHtml += '</body>' + CRLF
cHtml += '</html>' + CRLF
RECOVER USING cHtml
END SEQUENCE
RETURN cHtml
*
CLASS TestMyRegister
EXPORTED:
VAR cPath
VAR login
VAR password
VAR rpassword
VAR priezvisko
VAR meno
VAR ulica
VAR psc
VAR obec
VAR email
VAR telefon
VAR mobil
VAR suhlas
VAR wid
INLINE METHOD init
LOCAL aVars, i
aVars := ::classdescribe()[3]
FOR i := 1 TO Len(aVars)
::&(aVars[i,1]) := ''
NEXT
RETURN self
* ---------
INLINE METHOD getAllVars(oForm)
LOCAL aVars, i, c
aVars := ::classdescribe()[3]
FOR i := 1 TO Len(aVars)
aVars[i,1] := Lower(aVars[i,1])
aVars[i,2] := oForm:&(aVars[i,1])
::&(aVars[i,1]) := aVars[i,2]
aVars[i,3] := ''
NEXT
* ASort(aVars,,,{|a,b|a[1]<b[1]})
RETURN aVars
*
ENDCLASS
*
****************************************
Static FUNCTION TestRegisterValidateVars(aVars,cErrorMessage)
****************************************
LOCAL i, cVarName, cValue, lError := .f.
Local cTmpPassword := '*'
Local cTmpRPassword := '*'
* cErrorMessage := ''
* wtf aVars
/*
priezvisko, meno, email, login, password, rpassword,
1-label, 2-value, 3-maxsize, 4-varname, 5-text
*/
FOR i := 1 TO Len(aVars)
cVarName := aVars[i,4]
cValue := AllTrim(aVars[i,2])
*
If cVarName == 'password'
cTmpPassword := cValue
ElseIf cVarName == 'rpassword'
cTmpRPassword := cValue
EndIf
*
IF cVarName $ {'login','password','rpassword','priezvisko','meno','ulica','psc','obec','email',/*'telefon',*/'mobil','suhlas'} .AND. Empty(cValue)
aVars[i,5] := ' ***'
lError := .t.
ELSEIF cVarName = 'login' .AND. (Len(cValue) < 6 )
aVars[i,5] := ' Prihlasovacie meno musí ma minimálne 6 znakov'
lError := .t.
ELSEIF cVarName = 'login' .AND. NachadzaSaMedzera( cValue )
aVars[i,5] := ' Prihlasovacie meno nesmie obsahova medzeru!'
lError := .t.
ELSEIF cVarName = 'password' .AND. (Len(cValue) < 6 )
aVars[i,5] := ' Heslo musí ma minimálne 6 znakov'
lError := .t.
ELSEIF cVarName = 'password' .AND. NachadzaSaMedzera( cValue )
aVars[i,5] := ' Heslo nesmie obsahova medzeru!'
lError := .t.
ELSEIF cVarName = 'rpassword' .AND. (Len(cValue) < 6 )
aVars[i,5] := ' Heslo musí ma minimálne 6 znakov'
lError := .t.
ELSEIF cVarName = 'rpassword' .AND. NachadzaSaMedzera( cValue )
aVars[i,5] := ' Heslo nesmie obsahova medzeru!'
lError := .t.
ELSEIF cVarName = 'priezvisko' .AND. (Len(cValue) < 2 )
aVars[i,5] := ' Priezvizko musi mat minimalne 2 znaky'
lError := .t.
ELSEIF cVarName = 'meno' .AND. (Len(cValue) < 2 )
aVars[i,5] := ' Meno musí ma minimálne 2 znaky'
lError := .t.
ELSEIF cVarName = 'ulica' .AND. (Len(cValue) < 2 )
aVars[i,5] := ' Ulica musí ma minimálne 2 znaky'
lError := .t.
ELSEIF cVarName = 'psc' .AND. (Len(cValue) < 2 )
aVars[i,5] := ' Ulica musí ma 5 znakov'
lError := .t.
ELSEIF cVarName = 'obec' .AND. (Len(cValue) < 2 )
aVars[i,5] := ' Obec musí ma minimálne 2 znaky'
lError := .t.
ELSEIF cVarName = 'email' .AND. !('@'$cValue)
aVars[i,5] := ' eMail musí obsahova znak "@"!'
lError := .t.
ELSEIF cVarName = 'email' .AND. !('.'$cValue)
aVars[i,5] := ' eMail musí obsahova znak "."!'
lError := .t.
ELSEIF cVarName = 'email' .AND. (Len(cValue) < 6 )
aVars[i,5] := ' eMail musí obsahova aspoò 6 znakov!' /*+ Str(Len(cValue))*/
lError := .t.
ELSEIF cVarName = 'email' .AND. NachadzaSaMedzera( cValue )
aVars[i,5] := ' eMail nesmie obsahova medzeru!'
lError := .t.
* ELSEIF cVarName = 'telefon' .AND. (Len(cValue) < 10 )
* aVars[i,5] := ' Telefón musí ma minimálne 10 znakov! '
ELSEIF cVarName = 'mobil' .AND. ! TvarMobCis(cValue)
aVars[i,5] := ' Telefónne èíslo musí ma 11 znakov a tvar 09xx-xxxxxx!'
lError := .t.
ELSEIF cVarName = 'suhlas' .AND. !(Upper(cValue)$'AÁ')
aVars[i,5] := ' Povolená hodnota je A alebo Á!'
lError := .t.
ELSE
aVars[i,5] := ' '
ENDIF
NEXT
If ! Empty( cTmpPassword ) .and. ! Empty( cTmpRPassword )
If ! ( cTmpPassword == cTmpRPassword )
* cErrorMessage := ' Heslá sa nerovnajú !'
cErrorMessage := ' Passwords are NOT the same!'
EndIf
EndIf
IF lError
cErrorMessage += ' Položky oznaèené *** musia by vyplnené!'
ELSE
* cErrorMessage += ''
cErrorMessage := ''
ENDIF
RETURN lError
* ---------
**************************
Function NachadzaSaMedzera( _cText )
**************************
Local lRet := .F.
If ( At( " ", _cText ) > 0 )
lRet := .T.
EndIf
Return ( lRet )
*
*******************
Function TvarMobCis( _cTC )
*******************
Local lRet := .T.
If ( Len( _cTC ) != 11 ) && 09xx-123456
lRet := .F.
EndIf
If ! OnlyDigit( SubStr( _cTC, 1, 4 ) )
lRet := .F.
EndIf
If ! ( SubStr( _cTC, 5, 1 ) == '-' )
lRet := .F.
EndIf
If ! OnlyDigit( SubStr( _cTC, 6, 6 ) )
lRet := .F.
EndIf
Return ( lRet )
*
******************
Function OnlyDigit( _cText )
******************
Local cChar := ''
Local ix, nMax := Len( _cText )
Local lTemp := .T.
* wtf _cText
For ix := 1 To nMax
If ! IsDigit( SubStr( _cText, ix, 1 ) )
lTemp := .F.
ix := nMax
Loop
EndIf
Next
Return ( lTemp )
*
****************
Function IsDigit( _cChar )
****************
Local nAsc := Asc( _cChar )
* wtf nAsc
If ( nAsc >= 48 ) .and. ( nAsc <= 57 ) && 0..9
Return ( .T. )
EndIf
If ( _cChar == '.' )
Return ( .T. )
EndIf
Return ( .F. )
*