]> lifelog.hopto.org Git - LifeLog.git/commitdiff
bug 30 fix
authorWill Budicm <redacted>
Thu, 5 Nov 2020 05:56:17 +0000 (16:56 +1100)
committerWill Budicm <redacted>
Thu, 5 Nov 2020 05:56:17 +0000 (16:56 +1100)
dbLifeLog/main.cnf
htdocs/cgi-bin/config.cgi
htdocs/cgi-bin/login_ctr.cgi
htdocs/cgi-bin/main.cgi
htdocs/cgi-bin/stats.cgi
htdocs/cgi-bin/system/modules/Settings.pm

index 1ffa565588aa3f9a81ad0b1079615d0c766cc350..4b78277c4f05dceb799ef9a6b51e1a3eddbe9caa 100644 (file)
@@ -17,6 +17,9 @@ Credential format:<<AUTO_LOGIN <{alias}/{password}> , don't enable here using AU
 # By default this setting is disabled with 0, making alias, its own log database.
 <<DBI_MULTI_USER_DB<0>
 
+#Timezoning, if set to 1, country locale setting for timezone in config page is ignored.
+<<AUTO_SET_TIMEZONE<0>
+
 <<CONFIG<4>
 00|$RELEASE_VER = 2.1`LifeLog Application Version.
 01|$REC_LIMIT   = 25`Records shown per page.
@@ -38,6 +41,7 @@ Credential format:<<AUTO_LOGIN <{alias}/{password}> , don't enable here using AU
 36|$TRACK_LOGINS=1`Create system logs on login/logout of Life Log.
 38|$COMPRESS_ENC=0`Compress Encode pages, default -> 0=false, 1=true.
 40|$SUBPAGEDIR  =docs`Directory to scan for subpages like documents.
+42|$DISP_ALL    = 1`Display whole log entry, default -> 1=true, 0=false for display single line only.
 <<CAT<3>
 01|Unspecified `For quick uncategorised entries.
 03|File System `Operating file system/Application short log.
index 29e7db86ea33e8ea21722bfc81df81329a45da4a..b629d90d968450599f6c963d0601781595a0fbc0 100755 (executable)
@@ -13,9 +13,7 @@ use DBI;
 use Exception::Class ('LifeLogException');
 use Syntax::Keyword::Try;
 
-use DateTime;
 use DateTime::Format::SQLite;
-use DateTime::Duration;
 use Date::Language;
 use Text::CSV;
 use Scalar::Util qw(looks_like_number);
@@ -37,13 +35,12 @@ my $dbname  = Settings::dbname();
 my $alias   = Settings::alias();
 my $rv;
 my $dbs;
-my $lang    = Date::Language->new(&Settings::language);
-my $today   = DateTime->now;
-   $today->set_time_zone( &Settings::timezone );
+my $lang    = Date::Language->new(Settings::language());
+my $today   = Settings::today();   
 my $tz      = $cgi->param('tz');
 my $csvp    = $cgi->param('csv');
 
-&exportToCSV if ($csvp);
+exportToCSV() if ($csvp);
 
 if($cgi->param('bck'))        {&backup;}
 elsif($cgi->param('bck_del')) {&backupDelete;}
@@ -274,6 +271,19 @@ while(my @row = $dbs->fetchrow_array()) {
                     <option value="1" $u>True</option>
                     </select>);
         }
+        elsif($n eq "DISP_ALL"){
+            my($l,$u)=("","");
+            if($v == 0){
+                    $l = "SELECTED"
+            }
+            else{
+                $u = "SELECTED"
+            }
+            $v = qq(<select id="log_disp" name="var$i">
+                    <option value="0" $l>False</option>
+                    <option value="1" $u>True</option>
+                    </select>);
+        }
         elsif(!defined(Settings::anon($n))){ #change into settable field to us found here unknown and not anon.
             $v = '<input name="var'.$i.'" type="text" value="'.$v.'" size="12">';
         }
@@ -702,11 +712,11 @@ elsif($chdbfix){
             my $log = $row[3];
             my ( $dty, $dtf ) = $dt->ymd;
             my $dth = $dt->hms;
-            if ( &Settings::universalDate == 1 ) {
+            if ( Settings::universalDate() == 1 ) {
                 $dtf = $dty;
             }
             else {
-                $dtf = $lang->time2str( "%d %b %Y", $dt->epoch, &Settings::timezone );
+                $dtf = $lang->time2str( "%d %b %Y", $dt->epoch, Settings::timezone() );
             }
 
                 $log =~ s/''/'/g;
index 01fef9ad23adc45159f1c83200061f0d2ad17bf4..5e5b5577663fe28f65526029bf20dbcc0b3cf835 100755 (executable)
@@ -11,20 +11,12 @@ use CGI;
 use CGI::Session '-ip_match';
 use DBI;
 
-use DateTime;
-use DateTime::Format::SQLite;
-use DateTime::Duration;
-#Bellow perl 5.28+
-#use experimental 'smartmatch';
-
-#DEFAULT SETTINGS HERE!
 use lib "system/modules";
 require Settings;
-my $BACKUP_ENABLED = 0;
 
 my $cgi = CGI->new();
-my $session = new CGI::Session("driver:File",$cgi, {Directory=>&Settings::logPath});
-   $session->expire(&Settings::sessionExprs);
+my $session = new CGI::Session("driver:File",$cgi, {Directory=>Settings::logPath()});
+   $session->expire(Settings::sessionExprs());
 my $sssCreatedDB = $session->param("cdb");
 my $sid=$session->id();
 my $cookie = $cgi->cookie(CGISESSID => $sid);
@@ -36,7 +28,12 @@ my ($debug,$frm) = "";
 #Codebase release version. Release in the created db or existing one can be different, through time.
 my $SCRIPT_RELEASE = Settings::release();
 
+#anons - Are parsed end obtained only here, to be transfered to the DB config.
+my $BACKUP_ENABLED = 0;
+my $AUTO_SET_TIMEZONE = 0;
+
 try{
+
     logout() if($cgi->param('logout'));
     checkAutologinSet();
     if(&processSubmit==0){
@@ -57,7 +54,7 @@ try{
        $hst = `hostname` . "($ht[0])" if (@ht);
 
     $frm = qq(
-        <form id="frm_login" action="login_ctr.cgi" method="post"><table border="0" width=").&Settings::pagePrcWidth.qq(%">
+        <form id="frm_login" action="login_ctr.cgi" method="post"><table border="0" width=").Settings::pagePrcWidth().qq(%">
         <tr class="r0">
             <td colspan="3"><center>LOGIN</center></td>
             </tr>
@@ -97,8 +94,8 @@ try{
             $pwd =~ s/\s*$//;
             $dbg = "--DEBUG OUTPUT--\n$debug" if $debug;
             print $cgi->header,
-            "<hr><font color=red><b>SERVER ERROR</b></font> on ".DateTime->now.
-            "<pre>".$pwd."/$0 -> &".caller." -> [$err]","\n$dbg</pre>",
+            "<hr><font color=red><b>SERVER ERROR</b></font> on ".DateTime->now().
+            "<pre>".$pwd."/$0 -> &".caller." -> [\n$err]","\n$dbg</pre>",
             $cgi->end_html;
  };
 exit;
@@ -124,21 +121,10 @@ sub processSubmit {
     else{
         $alias = $passw = "";
     }
-    &Settings::removeOldSessions;  #and prompt for login returning 0
+    Settings::removeOldSessions();  #and prompt for login returning 0
     return 0;
 }
 
-sub parseAutonom { #Parses autonom tag for its crest value, returns undef if tag not found or wrong for passed line.
-    my $t = '<<'.shift.'<';
-    my $line = shift;
-    if(rindex ($line, $t, 0)==0){#@TODO change the following to regex parsing:
-        my $l = length $t;
-        my $e = index $line, ">", $l + 1;
-        return substr $line, $l, $e - $l;
-    }
-    return undef;
-}
-
 sub checkAutologinSet {
     my (@cre, $v);
     # We don't need to slurp whole file as next are expected settings in begining of the config file.
@@ -150,7 +136,9 @@ sub checkAutologinSet {
                 $v = parseAutonom('BACKUP_ENABLED',$line);
                 if($v){ $BACKUP_ENABLED = $v; next}
                 $v = parseAutonom('DBI_SOURCE',$line);
-                if($v){Settings::dbSrc($v); next} 
+                if($v){Settings::dbSrc($v); next}
+                $v = parseAutonom('AUTO_SET_TIMEZONE',$line);
+                if($v){$AUTO_SET_TIMEZONE = $v; next}
                 last if parseAutonom('CONFIG',$line); #By specs the config tag, is not an autonom, if found we stop reading. So better be last one spec. in file.
     }
     close $fh;
@@ -167,12 +155,23 @@ sub checkAutologinSet {
             if($set[0]=="1"){
                     $alias = $cre[0];
                     $passw = $passw; 
-                    &Settings::removeOldSessions;
+                    Settings::removeOldSessions();
             }            
     }
 
 }
 
+sub parseAutonom { #Parses autonom tag for its crest value, returns undef if tag not found or wrong for passed line.
+    my $t = '<<'.shift.'<';
+    my $line = shift;
+    if(rindex ($line, $t, 0)==0){#@TODO change the following to regex parsing:
+        my $l = length $t;
+        my $e = index $line, ">", $l + 1;
+        return substr $line, $l, $e - $l;
+    }
+    return undef;
+}
+
 sub checkPreparePGDB {
     my $create =1;
     $passw = $cgi->param('passw'); #PG handles password encryption itself.
@@ -213,8 +212,7 @@ sub checkPreparePGDB {
 
 sub checkCreateTables {
 
-    my $today = DateTime->now;
-       $today-> set_time_zone( &Settings::timezone );
+    my $today = Settings::today();
     my ($pst, $sql,$rv, $changed) = 0;
     
     # We live check database for available tables now only once.
@@ -250,7 +248,7 @@ sub checkCreateTables {
     # Default version is the scripted current one, which could have been updated.
     # We need to maybe update further, if these versions differ.
     # Source default and the one from the CONFIG table in the (present) database.
-    Settings::getConfiguration($db,{backup_enabled=>$BACKUP_ENABLED});
+    Settings::getConfiguration($db,{backup_enabled=>$BACKUP_ENABLED,auto_set_timezone=>$AUTO_SET_TIMEZONE});
     my $DB_VERSION  = Settings::release();
     my $hasLogTbl   = $curr_tables{'LOG'};
     my $hasNotesTbl = $curr_tables{'NOTES'};
@@ -396,7 +394,7 @@ sub checkCreateTables {
     #
     # New Implementation as of 1.5, cross SQLite Database compatible.
     #
-    if(!$hasNotesTbl) {$db->do(&Settings::createNOTEStmt);}
+    if(!$hasNotesTbl) {$db->do(Settings::createNOTEStmt())}
 
     if($changed){
         #It is also good to run db fix (config page) to renum if this is an release update?
@@ -425,7 +423,7 @@ sub checkCreateTables {
         }
         &populate($db);
     }
-    Settings::toLog($db, "Log accessed by $alias.") if(&Settings::trackLogins);
+    Settings::toLog($db, "Log accessed by $alias.") if(Settings::trackLogins());
     #
         $db->disconnect();
     #
@@ -562,7 +560,7 @@ sub logout {
         $pwd =~ s/\s*$//;
         $dbg = "--DEBUG OUTPUT--\n$debug" if $debug;
         print $cgi->header,
-        "<font color=red><b>SERVER ERROR</b></font> on ".DateTime->now.
+        "<font color=red><b>SERVER ERROR</b></font> on ".DateTime->now().
         "<pre>".$pwd."/$0 -> &".caller." -> [$err]","\n$dbg</pre>",
         $cgi->end_html;
         exit;
index f016951d095c13cfe036726ea1ae7e6d57e6a845..94b87c34f3c7667f744fac08eb25fa384e80789d 100755 (executable)
@@ -8,12 +8,7 @@ use strict;
 use Exception::Class ('LifeLogException');
 use Syntax::Keyword::Try;
 use Switch;
-
 use DBI;
-
-use DateTime;
-use DateTime::Format::SQLite;
-use DateTime::Duration;
 use Date::Language;
 use Date::Parse;
 use Time::localtime;
@@ -81,9 +76,8 @@ sub toBuf {
 }
 
 my $lang  = Date::Language->new(Settings::language());
-my $today = DateTime->now;
-   $today -> set_time_zone(Settings::timezone());
-
+my $today = Settings->today();
 if(!$prm_vc && &Settings::keepExcludes){
     if($prm_xc_lst){
         &Settings::configProperty($db, 201, '^EXCLUDES', $prm_xc_lst);
index bd70b24a0f1b38fe2940d80d6c85248be795cc87..9372e34a429a56756241b605a7b867a9ec0d3554 100755 (executable)
@@ -12,7 +12,6 @@ use CGI::Pretty ":standard"; #Influde style subroutine for inline CSS
 use CGI::Session '-ip_match';
 use CGI::Carp qw ( fatalsToBrowser );
 use DBI;
-use DateTime;
 use DateTime::Format::SQLite;
 use Number::Bytes::Human qw(format_bytes);
 use IPC::Run qw( run );
@@ -43,8 +42,7 @@ if(!$alias||!$dbname){
 }
 try{
 
-my $today = DateTime->now;
-$today->set_time_zone(&Settings::timezone);
+my $today = Settings->today();
 
 $ENV{'HOME'} = "~/";
 
index beafd0bfe6409c92eb71a72d819b587338275118..5bb3e4139925a1fe53169f0555510828cd80bc62 100644 (file)
@@ -13,7 +13,9 @@ use Syntax::Keyword::Try;
 use CGI;
 use CGI::Session '-ip_match';
 use CGI::Carp qw ( fatalsToBrowser );
-
+use DateTime;
+use DateTime::Format::SQLite;
+use DateTime::Duration;
 
 use DBI;
 
@@ -34,6 +36,7 @@ our $REC_LIMIT    = 25;
 our $AUTO_WRD_LMT = 1000;
 our $AUTO_WRD_LEN = 17; #Autocompletion word length limit. Internal.
 our $VIEW_ALL_LMT = 1000;
+our $DISP_ALL     = 1;
 our $FRAME_SIZE   = 0;
 our $RTF_SIZE     = 0;
 our $THEME        = 'Standard';
@@ -80,6 +83,7 @@ sub recordLimit    {return $REC_LIMIT}
 sub autoWordLimit  {return $AUTO_WRD_LMT}
 sub autoWordLength {return $AUTO_WRD_LEN}
 sub viewAllLimit   {return $VIEW_ALL_LMT}
+sub displayAll     {return $DISP_ALL}
 sub trackLogins    {return $TRACK_LOGINS}
 sub windowRTFSize  {return $RTF_SIZE}
 sub keepExcludes   {return $KEEP_EXCS}
@@ -104,7 +108,7 @@ try {
     $alias   = $sss->param('alias');
     $pass    = $sss->param('passw');
     if(!$alias||!$dbname){
-        print $cgi->redirect("login_ctr.cgi?CGISESSID=$sid&alias=$alias&dbname=$dbname");
+        print $cgi->redirect("login_ctr.cgi?CGISESSID=$sid");
         exit;
     }
     my $ret  = connectDB($alias, $pass);
@@ -125,6 +129,12 @@ sub dbname  {return $dbname}
 sub alias   {return $alias}
 sub pass    {return $pass}
 
+sub today {
+    my $ret = DateTime->now();
+       $ret -> set_time_zone(Settings::timezone()) if(!anon('auto_set_timezone'));
+return $ret;
+}
+
 sub createCONFIGStmt {
 if($IS_PG_DB){qq(
     CREATE TABLE CONFIG(
@@ -284,6 +294,7 @@ sub getConfiguration {
                 case "REC_LIMIT"    { $REC_LIMIT    = $r[2]}
                 case "AUTO_WRD_LMT" { $AUTO_WRD_LMT = $r[2]}
                 case "VIEW_ALL_LMT" { $VIEW_ALL_LMT = $r[2]}
+                case "DISP_ALL"     { $DISP_ALL     = $r[2]}
                 case "FRAME_SIZE"   { $FRAME_SIZE   = $r[2]}
                 case "RTF_SIZE"     { $RTF_SIZE     = $r[2]}
                 case "THEME"        { $THEME        = $r[2]}
@@ -447,7 +458,9 @@ sub countRecordsIn {
 
 sub getCurrentSQLTimeStamp {
 
-     my $dt = DateTime->from_epoch(epoch => time(), time_zone=> $TIME_ZONE);
+     my $dt;
+     if(anon('auto_set_timezone')){$dt = DateTime->from_epoch(epoch => time())}
+     else{                         $dt = DateTime->from_epoch(epoch => time(), time_zone=> $TIME_ZONE)}     
      # 20200225  Found that SQLite->format_datetime, changes internally to UTC timezone, which is wrong.
      # Strange that this format_datetime will work from time to time, during day and some dates. (A Pitfall)
     #return DateTime::Format::SQLite->format_datetime($dt);