From: Will Budic Date: Wed, 19 Feb 2020 10:19:15 +0000 (+1100) Subject: $TRACK_LOGINS and $VIEW_ALL_LMT implemented. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=42d51b4381aac964a769d088637831e1495a64b2;p=LifeLog.git $TRACK_LOGINS and $VIEW_ALL_LMT implemented. --- diff --git a/Current Development Check List.md b/Current Development Check List.md index 0237177..f5e4649 100644 --- a/Current Development Check List.md +++ b/Current Development Check List.md @@ -9,9 +9,14 @@ This version is not compatible in data structure to prior versions. Data migrati ### v.1.7 Encountered -* ✔ Sticky rows bg colour, to be a shade different to other normal rows. -* Login system log and out to be implemented. With system variable $TRACK_LOGINS to disable/enable. +* New Categories dropdown, grouping in ascending order and presenting in columns of five at a time. +* New CNF Development. + * Migration is currently hard to maintain and data export and import is wrongly reliant to CVS. + * CVS imports/exports are to be made obsolete in the future. It is not safe. + * This will be savailable via command line. * RTF Documents header lister page, to provide for, new log entry assignment, deletion, edits. +* ✔ Sticky rows bg colour, to be a shade different to other normal rows. +* ✔ Login system log and out to be implemented. With system variable $TRACK_LOGINS to disable/enable. * ✔Change all code to use Exceptions as project is becoming hard to manage. * The harder it is to foresee possible problems, the less likely you will add unnecessary complexity. -- bud@ * ✔ Notes to Log table should be other way in relationship direction. @@ -20,11 +25,6 @@ This version is not compatible in data structure to prior versions. Data migrati * Database backup tar ball 7zipped, upload and download button on config page. * You must have the password you logged in to unscramble the backup. * Alias -> pass -> backup password. Information required. -* New Categories dropdown, grouping in ascending order and presenting in columns of five at a time. -* New CNF Development. - * Migration is currently hard to maintain and data export and import is wrongly reliant to CVS. - * CVS imports/exports are to be made obsolete in the future. It is not safe. - * This will be savailable via command line. * ✔ In config page Categories section to appear after system settings. As less likelly to be changed. * System Configuration section is to be sorted. As in future it is more likelly to grow. * ✔ New system setting, $VIEW_ALL_LMT=1000. To limit view all records displayed on huge databases. @@ -77,6 +77,7 @@ This version is not compatible in data structure to prior versions. Data migrati ## Bugs ### v. 1.8 Encountered/Fixed + * Bug 18 - Same day datediff is displaying wrong report in time stack on the page. * ✔ Issue 18 - Setting excludes for views, deliveres page but long delays with server finished exchange (page doesn't hang). * The page is server delivered, if sections contain external internet links, this timeouts page browser delivery if the internet is down. diff --git a/dbLifeLog/main.cnf b/dbLifeLog/main.cnf index 94c58de..b8cebee 100644 --- a/dbLifeLog/main.cnf +++ b/dbLifeLog/main.cnf @@ -23,6 +23,7 @@ Credential format:< , dont enable here using AUT 30|$DEBUG = 0`Development page additional debug output, off (default) or on. 32|$KEEP_EXCS = 0`Cache excludes between sessions, off (default) or on. 34|$VIEW_ALL_LMT=1000`Limit of all records displayed for large logs. Set to 0, for unlimited. +36|$TRACK_LOGINS=1`Create system logs on login/logout of Life Log. < 01|Unspecified `For quick uncategorised entries. 03|File System `Operating file system/Application short log. diff --git a/htdocs/cgi-bin/login_ctr.cgi b/htdocs/cgi-bin/login_ctr.cgi index def3cb5..6d3372a 100755 --- a/htdocs/cgi-bin/login_ctr.cgi +++ b/htdocs/cgi-bin/login_ctr.cgi @@ -114,7 +114,9 @@ sub processSubmit { $session->param('passw', $passw); $session->param('database', 'data_'.$alias.'_log.db'); $session->flush(); + ### To MAIN PAGE print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie, -location=>"main.cgi"); + ### return 1; #activated redirect to main, main will check credentials. } } @@ -166,7 +168,7 @@ sub checkCreateTables { my $database = &Settings::logPath.'data_'.$alias.'_log.db'; my $dsn= "DBI:SQLite:dbname=$database"; my $db = DBI->connect($dsn, $alias, $passw, { RaiseError => 1 }) - or die "

Error->"& $DBI::errstri &"

"; + or LifeLogException->throw($DBI::errstri); my $rv; my $changed = 0; # We live check database for available tables now only once. @@ -330,6 +332,7 @@ sub checkCreateTables { else{ &populate($db); } + Settings::toLog($db, "Log accessed by $alias.") if(&Settings::trackLogins); # $db->disconnect(); # @@ -443,8 +446,31 @@ return "SELECT name FROM sqlite_master WHERE type='view' AND name='$name';" sub logout { - $session->delete(); - $session->flush(); + if(&Settings::trackLogins){ + try{ + $alias = $session->param('alias'); + $passw = $session->param('passw'); + my $database = &Settings::logPath.'data_'.$alias.'_log.db'; + my $dsn= "DBI:SQLite:dbname=$database"; + my $db = DBI->connect($dsn, $alias, $passw, { RaiseError => 1 }) + or LifeLogException->throw($DBI::errstri); + Settings::toLog($db, "Log properly loged out by $alias."); + $db->disconnect(); + }catch{ + my $err = $@; + my $dbg = "" ; + my $pwd = `pwd`; + $pwd =~ s/\s*$//; + $dbg = "--DEBUG OUTPUT--\n$debug" if $debug; + print $cgi->header, + "SERVER ERROR on ".DateTime->now. + "
".$pwd."/$0 -> &".caller." -> [$err]","\n$dbg
", + $cgi->end_html; + exit; + } + } + + print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie); print $cgi->start_html(-title => "Personal Log Login", -BGCOLOR=>"black", -style =>{-type => 'text/css', -src => 'wsrc/main.css'}, @@ -462,6 +488,11 @@ sub logout { ); print $cgi->end_html; + + $session->delete(); + $session->flush(); + + exit; } diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index e4f7677..90ee53e 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -212,7 +212,7 @@ print $cgi->start_html( my $st; my $str_sqlCat = "SELECT ID, NAME, DESCRIPTION FROM CAT ORDER BY ID;"; -my $str_sql = "SELECT ID, ID_CAT, ID_RTF, DATE, LOG, AMOUNT, AFLAG, STICKY FROM VW_LOG WHERE STICKY = 1;"; +my $str_sql = "SELECT ID, ID_CAT, ID_RTF, DATE, LOG, AMOUNT, AFLAG, STICKY FROM VW_LOG WHERE STICKY = 1 LIMIT ".&Settings::viewAllLimit.";"; print qq(## Using db -> $dsn\n) if $DEBUG; @@ -379,7 +379,7 @@ qq(
buildLog(traceDBExe($str_sql)); if(index ($str_sql, 'PID <=') < 1 && !$prm_vc && !$prm_xc && !$rs_keys && !$rs_dat_from){ - $str_sql = "SELECT ID, ID_CAT, ID_RTF, DATE, LOG, AMOUNT, AFLAG, STICKY FROM VW_LOG WHERE STICKY != 1 ORDER BY DATE DESC;"; + $str_sql = "SELECT ID, ID_CAT, ID_RTF, DATE, LOG, AMOUNT, AFLAG, STICKY FROM VW_LOG WHERE STICKY != 1 ORDER BY DATE DESC LIMIT ".&Settings::viewAllLimit.";"; print $cgi->pre("###2 -> ".$str_sql) if $DEBUG; ; &buildLog(traceDBExe($str_sql)); @@ -989,7 +989,7 @@ try { } - $str_sql = qq(SELECT PID, ID_CAT, ID_RTF, DATE, LOG, AMOUNT, AFLAG, STICKY from VW_LOG where PID <= $rs_cur and STICKY != 1 $sand;); + $str_sql = qq(SELECT PID, ID_CAT, ID_RTF, DATE, LOG, AMOUNT, AFLAG, STICKY from VW_LOG where PID <= $rs_cur and STICKY != 1 $sand)." LIMIT ".&Settings::viewAllLimit.";"; return; } }