Page Blocks

Hosting sponsored by:

Point In Space

 

API: Log

Filename:
fwpLog_auth.ctag

Released With:
5.0.0

Current Version:
1.0.1

Status: Active

Min Lasso Tested: 8.1.0

Max Lasso Tested: 8.5.3

Related:

Still don't get it?

Check out the talk list archives, or join and ask your questions.

Documentation Error or Request?

Email documentation corrections or comments

API Reference

fwpLog_auth (Tag)

Description

Writes to a tab delimited log file or to a database table certain user and page information about an attempted login or session refresh. Once a user logs into the application, this ends up logging every page the user visits. The tag is automatically executed by the fwp_user data type. Logging can be turned on|off by setting the variable $fw_gLogAuth to true|false. Log rolling can be set to annual, monthly, weekly, or daily by setting the variable $fw_gLogAuthRoll to 'A|M|W|D'. The log can be directed to a text file or a data table by setting the variable $fw_gLogAuthTarget to 'file|database'.

The following items are logged (with tab separators if in a text file):

[server_date: -extended]
[server_time]
[client_IP]
status = "login," "session," or "logout"
usrAcct = the login name used
usrName = the user's full name if the login was successful
usrRcrd = the user's recordID if the login was successful
usrSession = the sessionID if the login was successful
[response_filePath]
pageInfo = arbitrary info about the current page
fwpInfo = arbitrary info about the framework status

Syntax

if: $fw_gLogAuth;
   fwpLog_auth: 
      -usrsession=string,
      -usrfwn=string,
      -usrAppvd=string,
      -usrRcrd=string,
      -usrName=string,
      -pageInfo=string,
      -fwpInfo = string;
/if;

Parameters & Member Tags

-status = the fwp_user custom type uses only "login," "session," or "logout," but if the application is tracking other actions, any text here is acceptable

-usrSession = the user's sessionID

-usrAcct = the user's login name

-usrRcrd = the user's account record number

-usrName = a concatenation of the the user's first and last name from the account record

-pageInfo - required : custom misc info about the page. This is picked up by setting the variable $fw_logPageInfo to whatever is desired throughout the application on a per page basis. The default entry is "n/a" unless changed. This is particularly useful in editing systems like the event driven pages (EDP) framework where the same page name is used, but actually several different displays are possible. This input can be used to identify exactly which display the current page is using.

-fwpInfo - required : custom misc info about the current framework tag (if applicable). This is set by the internal framework code by setting the variable $fw_logFWPInfo to reflect what tag is active which can provide additional debugging info. The default entry is "n/a" unless changed. This capability was added in version 3.2, but hasn't been fully utilized in all tags yet.

Examples

if: $fw_gLogAuth;
fwpLog_auth: 
   -status = 'login',
   -usrsession = (self->'fw_s'),
   -usrAcct = (self->'loginAccount'),
   -usrRcrd = (self->(getProfile:'userRcrdID')),
   -usrName = (self->(getProfile:'userName')),
   -pageInfo = $fw_logPageInfo,
   -fwpInfo = $fw_logFWPInfo;
/if;

Source Code

View in separate window

<?lassoscript
//............................................................................
//
//    pageblocks: (c) 2002-2007 http://www.pageblocks.org/
//
//............................................................................
/*

    {fileName=        fwpLog_auth.ctag }
    {rsrcType=        tag }
    {rsrcName=        fwpLog_auth }
    {rsrcHTTP=        www.pageblocks.org/refc/fwpLog_auth }

    {lassoVrsnMin=    8.1.0 }
    {lassoVrsnMax=    8.5.3 }

    {author=        Greg Willits }
    {authorEmail=    subscribe to pbTalk at www.pageblocks.org/talk/ }
    {authorHTTP=    www.pageblocks.org }

    {desc=            Creates a log of authentication attempts (successful
                    and failed. }

    {maintvsrn=        1.1.1 }
    {maintrelease=    5.2.4 }
    {maintdate=        2007-07-21 }
    {maintauthor=    Greg Willits }
    {maintnotes=    added tagTacer }

    {maintvsrn=        1.1 }
    {maintrelease=    5.2.0 }
    {maintdate=        2007-06-09 }
    {maintauthor=    Greg Willits }
    {maintnotes=    added log_critical }

    {maintvsrn=        1.0.1 }
    {maintrelease=    5.0.0 b5 }
    {maintdate=        2006-02-02 }
    {maintauthor=    Greg Willits }
    {maintnotes=    changed db/tbl references to use new vars }

    {maintvsrn=        1.0 }
    {maintrelease=    5.0.0 }
    {maintdate=        2006-01-16 }
    {maintauthor=    Greg Willits }
    {maintnotes=    initial release }

*/
//.............................................................................

define_tag:'fwpLog_auth', 
    -autooutput,
    -priority='replace',
    -optional='status',
    -optional='usrSession',
    -optional='usrAcct',
    -optional='usrName',
    -optional='usrRcrd',
    -optional='pageInfo',
    -optional='fwpInfo';

    $fw_debug >= fw_kChatty ? $fw_tagTracer->(add:'fwpLog_auth', -errorMsg=local:'errorMsg');

    local:'fw_logFileNm' = ($fw_sPath->'logs') + 'authlog_' + (date->year);
    
    //    backwards compatibility
    //    doesn`t require the declaration of fw_gLogAuthTarget

    if: !(global_defined:'fw_gLogAuthTarget');
        $fw_gLogAuthTarget = 'file';
    /if;

    if: $fw_gLogAuthTarget == 'file';

        inline:
            -username=$fw_gFilesUser,
            -password=$fw_gFilesPswd;
        
            select: $fw_gLogAuthRoll;
                case:'M';
                    #fw_logFileNm += '_m' + (date->month);
                case:'W';
                    #fw_logFileNm += '_w' + (date->week);
                case:'D';
                    #fw_logFileNm += '_d' + (date->dayofyear);
            /select;
        
            #fw_logFileNm += '.txt';
        
            log: #fw_logFileNm; 
                server_date: -extended;
                '\t';
                server_time;
                '\t';
                client_IP;
                '\t';
                #status;
                '\t';
                #usrAcct;
                '\t';
                #usrName;
                '\t';
                #usrRcrd;
                '\t';
                #usrSession;
                '\t';
                response_filepath;
                '\t';
                #pageInfo;
                '\n';
            /log;

            $fw_criticalLog && ((file_currentError: -errorcode)  != 0)
                ? log_critical:('pbError : fwpLog_auth -- ' + file_currentError);
        
        /inline;

    else: $fw_gLogAuthTarget == 'database';

        local:'logPairs' = (array:
            'logDate'         = server_date: -extended,
            'logTime'         = server_time,
            'logClientIP'     = client_IP,
            'logStatus'     = #status, 
            'logAccount'     = #usrAcct, 
            'logUser'         = #usrName, 
            'logUserID'     = #usrRcrd, 
            'logSessionID'     = #usrSession, 
            'logPageURL'     = response_filepath,
            'logPageInfo'     = #pageInfo);

        fwpLog_asyncSQL:
            -logPairs    = #logPairs,
            -user        = $fw_gQueryUser,
            -pswd        = $fw_gQueryPswd,
            -db            = $fw_gDatabases->find:'logs',
            -tbl        = $fw_gTables->find:'logauth',
            -keyfld        = 'id';

    /if;
/define_tag;
?>



© 2002-2013, pageblocks.org