FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour mod harbour session js session object
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: mod harbour session js session object
Posted: Tue Jul 30, 2019 07:56 AM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: mod harbour session js session object
Posted: Tue Jul 30, 2019 08:12 AM

Dear Antonio,
would you be so kind to explain how #xtranslate <matchPattern> => <resultPattern> works.
Does this work on BLOCKS too.
Best regards
Otto

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: mod harbour session js session object
Posted: Tue Jul 30, 2019 09:31 AM
Otto,

Here you have some examples to understand it from apache.prg (mod_harbour)
Code (fw): Select all Collapse
   __pp_addRule( hPP, "#xcommand ? [<explist,...>] => AP_RPuts( '<br>' [,<explist>] )" )
   __pp_addRule( hPP, "#xcommand ?? [<explist,...>] => AP_RPuts( [<explist>] )" )
   __pp_addRule( hPP, "#define CRLF hb_OsNewLine()" )
   __pp_addRule( hPP, "#xcommand TEXT <into:TO,INTO> <v> => #pragma __cstream|<v>:=%s" )
   __pp_addRule( hPP, "#xcommand TEXT <into:TO,INTO> <v> ADDITIVE => #pragma __cstream|<v>+=%s" )
   __pp_addRule( hPP, "#xcommand TEMPLATE [ USING <x> ] [ PARAMS [<v1>] [,<vn>] ] => " + ;
                      '#pragma __cstream | AP_RPuts( InlinePrg( %s, [@<x>] [,<(v1)>][+","+<(vn)>] [, @<v1>][, @<vn>] ) )' )
   __pp_addRule( hPP, "#xcommand BLOCKS [ PARAMS [<v1>] [,<vn>] ] => " + ;
                      '#pragma __cstream | AP_RPuts( ReplaceBlocks( %s, "{{", "}}" [,<(v1)>][+","+<(vn)>] [, @<v1>][, @<vn>] ) )' )   
   __pp_addRule( hPP, "#command ENDTEMPLATE => #pragma __endtext" )


function ReplaceBlocks() does the magic for the "{{ ... }}". In fact this function allows you to use any starting and ending characters to replace blocks:
Code (fw): Select all Collapse
function ReplaceBlocks( cCode, cStartBlock, cEndBlock, cParams, ... )

   local nStart, nEnd, cBlock
   local lReplaced := .F.
   
   hb_default( @cStartBlock, "{{" )
   hb_default( @cEndBlock, "}}" )
   hb_default( @cParams, "" )

   while ( nStart := At( cStartBlock, cCode ) ) != 0 .and. ;
         ( nEnd := At( cEndBlock, cCode ) ) != 0
      cBlock = SubStr( cCode, nStart + Len( cStartBlock ), nEnd - nStart - Len( cEndBlock ) )
      cCode = SubStr( cCode, 1, nStart - 1 ) + ;
              ValToChar( Eval( &( "{ |" + cParams + "| " + cBlock + " }" ), ... ) ) + ;
              SubStr( cCode, nEnd + Len( cEndBlock ) )
      lReplaced = .T.
   end
   
return If( HB_PIsByRef( 1 ), lReplaced, cCode )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Re: mod harbour session js session object
Posted: Wed Aug 07, 2019 05:52 PM
Antonio,
is it possible to save sessions data from the mod_harbour code and not inside the HTML ?
like :

Code (fw): Select all Collapse
Function Main()
LOCAL nome_utente
use "data" shared new readonly alias infos 
set order to tag CODICE
nome_utente = ""
seek "test"
if found()
     nome_utente = alltrim(infos->NOME)
endif
use
sessionsave(nome_utente)     <---- 
return nil
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: mod harbour session js session object
Posted: Wed Aug 07, 2019 08:42 PM

Massimo,

The PRG code runs on the server, so whatever you may want to save as a session identifier, it will be saved on the server.

You could store the "session" id info in a file, inside a DBF, on a SQL table, etc, but always on the remote server if PRG is being used for it

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Re: mod harbour session js session object
Posted: Thu Aug 08, 2019 06:47 AM
Antonio,
even if I call a javascript that make this ?
https://www.w3schools.com/jsref/prop_win_sessionstorage.asp

Continue the discussion