Migration to the new mod_harbour fastCGI

mod_harbour is an Apache module that allows to run PRGs directly on the web !!!

Re: Migration to the new mod_harbour fastCGI

Postby Massimo Linossi » Wed Jul 22, 2020 8:11 am

Thanks a lot my friend.
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Migration to the new mod_harbour fastCGI

Postby Antonio Linares » Thu Jul 23, 2020 9:08 am

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42084
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Migration to the new mod_harbour fastCGI

Postby Massimo Linossi » Sat Jul 25, 2020 8:11 am

Hi Antonio.
I've installed the new mod-harbour fcgi but I have an error.
The compiled prg seem not loaded.

This is the main.prg made for testing:
Code: Select all  Expand view

// {% LoadHRB( "retedb.hrb" ) %}

memvar hForm

**************************************************************************
Function main()

local mv_username:="" , mv_password:="" , nErr:=0 , zMail:="" , cUserName:=""
local link_intra:=""  , pagina_arrivo:="" , controllo_web:=""
local cookie_stringa

Setting_db()

SetCookie( 'blu1', "cookie numero 1" + "|" + "2020|1|1|", 90000, '' )
SetCookie( 'blu2', "cookie numero 2" + "|" + "2020|2|2|", 90000, '' )
SetCookie( 'blu3', "cookie numero 3" + "|" + "2020|3|3|", 90000, '' )
SetCookie( 'blu4', "cookie numero 4" + "|" + "2020|4|4|", 90000, '' )
SetCookie( 'blu5', "cookie numero 5" + "|" + "2020|5|5|", 90000, '' )
SetCookie( 'blu6', "cookie numero 6" + "|" + "2020|6|6|", 90000, '' )
SetCookie( 'blu7', "cookie numero 7" + "|" + "2020|7|7|", 90000, '' )
SetCookie( 'blu8', "cookie numero 8" + "|" + "2020|8|8|", 90000, '' )

Return nil

**************************************************************************
function msgAlert( cMsg )
?  "<script>alert('"+cMsg+"');</script>"
Return nil
 


The retedb.prg contains 2 functions :

Code: Select all  Expand view

**************************************************************************

Function BLR(wait)   // BLOCCA IL RECORD

** wait = i secondi di attesa dopodiche' la funzione ritorna .F.
**        se non riesce ad aprire il file

local forever

IF RLOCK()
   Return .T.
ENDIF

forever=(wait=0)

Do while ( forever .or. wait > 0 )
   SecondsSleep(1)
   wait-=0.50
   IF RLOCK()
      Return .T.
   ENDIF
   IF INT(wait) = wait
      EXIT
   ENDIF
Enddo

Return .F.

**************************************************************************

Function Setting_db()

REQUEST HB_LANG_IT
HB_LANGSELECT("IT")
REQUEST DBFCDX
REQUEST DBFFPT
REQUEST ADS
RddRegister( "ADS", 1 )
RddSetDefault("ADS")
SET SERVER REMOTE
SET FILETYPE TO ADT
SET(_SET_AUTORDER,1)
SET AUTOPEN ON
set(_SET_OPTIMIZE,.T.)
ADSLOCKING(.T.)

SET DATE BRITISH
SET DELETED ON
SET CENTURY ON

Return nil


But the I try to run the main.prg I have this error :

Code: Select all  Expand view

Error: Undefined function
operation: SETTING_DB
called from: pcode.hrb, SETTING_DB, line: 0
called from: pcode.hrb, MAIN, line: 12
called from: HB_HRBDO, line: 0
called from: ..\source\exec.prg, EXECUTE, line: 70

Source:
0010: local cookie_stringa
0011:
0012 =>Setting_db()
0013:
0014: SetCookie( "blu1", "cookie numero 1" + "|" + "2020|1|1|", 90000, "" )
 


With the previous mod-harbour the program runs without problems.
What could be wrong ?
Thanks a lot.
Massimo
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Migration to the new mod_harbour fastCGI

Postby Antonio Linares » Sat Jul 25, 2020 6:39 pm

Massimo,

Please have all the source code in one single PRG file.

Try it without HRB files (for now)

many thanks for your feedback
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42084
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Migration to the new mod_harbour fastCGI

Postby Massimo Linossi » Sun Jul 26, 2020 11:16 am

Antonio,
tested with everything inside one prg without HRB and it's working.
But I cannot convert a big procedure in FastCGI that is made of several prg and 4 HRB files.
I wait for your future suggestions.
Thanks a lot.
Massimo
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Migration to the new mod_harbour fastCGI

Postby Antonio Linares » Sun Jul 26, 2020 12:24 pm

Massimo,

Please use this function MyLoadHRB() and change the value 1 (twice in the code) from 1 up to 4 and check
if with some of those values it works as expected, many thanks

Code: Select all  Expand view
function MyLoadHRB( cHrbFile_or_oHRB )

   local lResult := .F.

   if ValType( cHrbFile_or_oHRB ) == "C"
      if File( hb_GetEnv( "PRGPATH" ) + "/" + cHrbFile_or_oHRB )
         AAdd( M->getList,;
            hb_HrbLoad( 1, hb_GetEnv( "PRGPATH" ) + "/" + cHrbFile_or_oHRB ) )
         lResult = .T.  
      endif      
   endif
   
   if ValType( cHrbFile_or_oHRB ) == "P"
      AAdd( M->getList, hb_HrbLoad( 1, cHrbFile_or_oHRB ) )
      lResult = .T.
   endif
   
return lResult  
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42084
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Migration to the new mod_harbour fastCGI

Postby Massimo Linossi » Sun Jul 26, 2020 5:18 pm

Hi Antonio.
I put your function at the end of the prg and wrote this line at the beginning :

Code: Select all  Expand view

// {% MyLoadHRB( "retedb.hrb" ) %}
 


But when I run the prg I receive this error :

Code: Select all  Expand view

Error: Undefined function
operation: MYLOADHRB
[ 1] = C retedb.hrb
called from: pcode.hrb, MYLOADHRB, line: 0
called from: ..\source\exec.prg, (b)REPLACEBLOCKS, line: 143
called from: ..\source\exec.prg, REPLACEBLOCKS, line: 143
called from: ..\source\exec.prg, EXECUTE, line: 63

Source:
 
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Migration to the new mod_harbour fastCGI

Postby Antonio Linares » Sun Jul 26, 2020 6:29 pm

Massimo,

Please download modharbour.exe from here:
https://github.com/FiveTechSoft/mod_harbour/blob/master/fastcgi/windows/win64/ADS/modharbour.exe

And try to use LoadHRB() as usual

many thanks for your very valuable feedback
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42084
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Migration to the new mod_harbour fastCGI

Postby Massimo Linossi » Mon Jul 27, 2020 7:23 am

Antonio,
this is the hrb file
Code: Select all  Expand view


Function Setting_db()

REQUEST HB_LANG_IT
HB_LANGSELECT("IT")
REQUEST DBFCDX
REQUEST DBFFPT
REQUEST ADS
RddRegister( "ADS", 1 )
RddSetDefault("ADS")
SET SERVER REMOTE
SET FILETYPE TO ADT
SET(_SET_AUTORDER,1)
SET AUTOPEN ON
set(_SET_OPTIMIZE,.T.)
ADSLOCKING(.T.)

SET DATE BRITISH
SET DELETED ON
SET CENTURY ON

Return nil

*****************************************************************************
function SetCookie( cName, cValue, nSecs, cPath, cDomain, lHttps, lOnlyHttp )
local cCookie := ''

hb_default( @cName, '' )
hb_default( @cValue, '' )
hb_default( @nSecs, 86400 )
hb_default( @cPath, '/' )
hb_default( @cDomain    , '' )
hb_default( @lHttps, .F. )
hb_default( @lOnlyHttp, .F. )

cCookie += cName + '=' + cValue + ';'
if nSecs # 0
    cCookie += 'max-age=' + alltrim(str( nSecs )) + ';'
endif
if !empty(cPath)
    cCookie += 'path=' + cPath + ';'
endif

MH_Header( "Set-Cookie", cCookie )

return nil

*********************
function GetCookies()

   local hHeadersIn := MH_HeadersIn()
   local cCookies := If( hb_HHasKey( hHeadersIn, "Cookie" ), hb_hGet( hHeadersIn, "Cookie" ), "" )
   local aCookies := hb_aTokens( cCookies, ";" )
   local cCookie, hCookies := {=>}

   for each cCookie in aCookies
      hb_HSet( hCookies, SubStr( alltrim(cCookie), 1, At( "=", alltrim(cCookie) ) - 1 ),;
               SubStr( alltrim(cCookie), At( "=", alltrim(cCookie)) + 1 ) )
   next

return hCookies

 


And this the simple prg
Code: Select all  Expand view


// {% LoadHRB( "retedb.hrb" ) %}

**************************************************************************
Function main()

Setting_db()

SetCookie( 'blu1', "cookie numero 1", 90000 )

Return nil

 


Running this simple prg I have this error

Code: Select all  Expand view


Errore del server!
Il server ha generato un errore interno e non è in grado di soddisfare la richiesta.

Messaggio di errore:
malformed header from script 'test_cookie.prg': Bad header: Set-Cookie

Se pensi che questo sia un errore del server, per favore contatta il webmaster.

Error 500
localhost
Apache/2.4.39 (Win64) OpenSSL/1.0.2s PHP/7.1.30 mod_fcgid/2.3.9

 
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Migration to the new mod_harbour fastCGI

Postby Antonio Linares » Mon Jul 27, 2020 10:19 am

ok, we are checking it. thanks!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42084
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Migration to the new mod_harbour fastCGI

Postby Antonio Linares » Tue Jul 28, 2020 6:55 am

Massimo,

Please remove the functions SetCookie() and GetCookies() from your HRB file, build it and try it again

many thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42084
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Migration to the new mod_harbour fastCGI

Postby Massimo Linossi » Tue Jul 28, 2020 3:34 pm

Hi Antonio.
This is the prg, with the Setcookie function (taken from the samples) inside the prg
Code: Select all  Expand view

Function main()

SetCookie( 'blu', "cookienumber1" )

Return nil

function SetCookie( cName, cValue, nSecs, cPath, cDomain, lHttps, lOnlyHttp )

   local cCookie := ''
   
   // check parameters
   hb_default( @cName, '' )
   hb_default( @cValue, '' )
   hb_default( @nSecs, 3600 )   // Session will expire in Seconds 60 * 60 = 3600
   hb_default( @cPath, '/' )
   hb_default( @cDomain , '' )
   hb_default( @lHttps, .F. )
   hb_default( @lOnlyHttp, .F. )   
   
   // we build the cookie
   cCookie += cName + '=' + cValue + ';'
   cCookie += 'expires=' + CookieExpire( nSecs ) + ';'
   cCookie += 'path=' + cPath + ';'
   cCookie += 'domain=' + cDomain + ';'
       
   // pending logical values for https y OnlyHttp

   // we send the cookie
   MH_Header( "Set-Cookie", cCookie )

return nil

//----------------------------------------------------------------//
// CookieExpire( nSecs ) builds the time format for the cookie
// Using this model: 'Sun, 09 Jun 2019 16:14:00'

function CookieExpire( nSecs )

   local tNow := hb_datetime() 
   local tExpire   // TimeStampp
   local cExpire   // TimeStamp to String
   
   hb_default( @nSecs, 60 ) // 60 seconds for this test
   
   tExpire = hb_ntot( ( hb_tton( tNow ) * 86400 - hb_utcoffset() + nSecs ) / 86400 )

   cExpire = cdow( tExpire ) + ', '
         cExpire += AllTrim( Str( Day( hb_TtoD( tExpire ) ) ) ) + ;
         ' ' + cMonth( tExpire ) + ' ' + AllTrim( Str( Year( hb_TtoD( tExpire ) ) ) ) + ' '
   cExpire += AllTrim( Str( hb_Hour( tExpire ) ) ) + ':' + AllTrim( Str( hb_Minute( tExpire ) ) ) + ;
              ':' + AllTrim( Str( hb_Sec( tExpire ) ) )

return cExpire
 


and this is the result
Code: Select all  Expand view

Errore del server!
Il server ha generato un errore interno e non è in grado di soddisfare la richiesta.

Messaggio di errore:
malformed header from script 'test_cookie.prg': Bad header: Set-Cookie

Se pensi che questo sia un errore del server, per favore contatta il webmaster.

Error 500
localhost
Apache/2.4.39 (Win64) OpenSSL/1.0.2s PHP/7.1.30 mod_fcgid/2.3.9
 
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Migration to the new mod_harbour fastCGI

Postby Antonio Linares » Wed Jul 29, 2020 5:50 am

Massimo,

function SetCookie() and CookieExpire() are already inside modharbour.exe

thats why I am asking you to remove them from your code, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42084
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Migration to the new mod_harbour fastCGI

Postby Massimo Linossi » Wed Jul 29, 2020 6:16 pm

Antonio,
sorry, I misunderstood your advice. I was thinking that I must remove that functions from the HRB and place them in the prg.
I've removed them and now everything seems to work correctly. I'll make some more tests. And the speed is really better.
You must change the name in Fivetech & Furious
User avatar
Massimo Linossi
 
Posts: 498
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Migration to the new mod_harbour fastCGI

Postby Antonio Linares » Thu Jul 30, 2020 8:25 am

Massimo,

great!

thanks so much for your great feedback :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42084
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

PreviousNext

Return to mod_harbour

Who is online

Users browsing this forum: No registered users and 4 guests