]> lifelog.hopto.org Git - LifeLog.git/commitdiff
$TRACK_LOGINS and $VIEW_ALL_LMT implemented.
authorWill Budic <redacted>
Wed, 19 Feb 2020 10:19:15 +0000 (21:19 +1100)
committerWill Budic <redacted>
Wed, 19 Feb 2020 10:19:15 +0000 (21:19 +1100)
Current Development Check List.md
dbLifeLog/main.cnf
htdocs/cgi-bin/login_ctr.cgi
htdocs/cgi-bin/main.cgi

index 0237177717b0050e4f79601b885fb532d54dafbe..f5e4649389e905ff38322233204350870eb404da 100644 (file)
@@ -9,9 +9,14 @@ This version is not compatible in data structure to prior versions. Data migrati
 
 ### v.1.7 Encountered
 
-* &#10004; 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.
+* &#10004; Sticky rows bg colour, to be a shade different to other normal rows.
+* &#10004; Login system log and out to be implemented. With system variable $TRACK_LOGINS to disable/enable.
 * &#10004;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@
 * &#10004; 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.
 * &#10004; 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.
 * &#10004; 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.
 * &#10004; 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.
index 94c58de4ef51cf9473584874a812d3209cb13739..b8cebee540a5a5dddf99884b8c7fb81c74f409f0 100644 (file)
@@ -23,6 +23,7 @@ Credential format:<<AUTO_LOGIN <{alias}/{password}> , 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.
 <<CAT<3>
 01|Unspecified `For quick uncategorised entries.
 03|File System `Operating file system/Application short log.
index def3cb516e8a971df11d08cef51b1b0bae658ebf..6d3372af6d1d67d960a8d870160f9891eba4b20d 100755 (executable)
@@ -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 "<p>Error->"& $DBI::errstri &"</p>";
+                    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,
+        "<font color=red><b>SERVER ERROR</b></font> on ".DateTime->now.
+        "<pre>".$pwd."/$0 -> &".caller." -> [$err]","\n$dbg</pre>",
+        $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;
 }
 
index e4f7677be575ccfedb1f1ef5d4dc549c485550b3..90ee53e09948632f4de9a8836f8d953de1f23984 100755 (executable)
@@ -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(<form id="frm_log" action="data.cgi" onSubmit="return formDelValidation();">
     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;
                 }
             }