From: Will Budicm Date: Thu, 5 Nov 2020 05:56:17 +0000 (+1100) Subject: bug 30 fix X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=847ffe71e9f466b045a59e619ce8555dca0e2bb0;p=LifeLog.git bug 30 fix --- diff --git a/dbLifeLog/main.cnf b/dbLifeLog/main.cnf index 1ffa565..4b78277 100644 --- a/dbLifeLog/main.cnf +++ b/dbLifeLog/main.cnf @@ -17,6 +17,9 @@ Credential format:< , don't enable here using AU # By default this setting is disabled with 0, making alias, its own log database. < +#Timezoning, if set to 1, country locale setting for timezone in config page is ignored. +< + < 00|$RELEASE_VER = 2.1`LifeLog Application Version. 01|$REC_LIMIT = 25`Records shown per page. @@ -38,6 +41,7 @@ Credential format:< , 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. < 01|Unspecified `For quick uncategorised entries. 03|File System `Operating file system/Application short log. diff --git a/htdocs/cgi-bin/config.cgi b/htdocs/cgi-bin/config.cgi index 29e7db8..b629d90 100755 --- a/htdocs/cgi-bin/config.cgi +++ b/htdocs/cgi-bin/config.cgi @@ -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()) { ); } + elsif($n eq "DISP_ALL"){ + my($l,$u)=("",""); + if($v == 0){ + $l = "SELECTED" + } + else{ + $u = "SELECTED" + } + $v = qq(); + } elsif(!defined(Settings::anon($n))){ #change into settable field to us found here unknown and not anon. $v = ''; } @@ -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; diff --git a/htdocs/cgi-bin/login_ctr.cgi b/htdocs/cgi-bin/login_ctr.cgi index 01fef9a..5e5b557 100755 --- a/htdocs/cgi-bin/login_ctr.cgi +++ b/htdocs/cgi-bin/login_ctr.cgi @@ -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( -
+
@@ -97,8 +94,8 @@ try{ $pwd =~ s/\s*$//; $dbg = "--DEBUG OUTPUT--\n$debug" if $debug; print $cgi->header, - "
SERVER ERROR on ".DateTime->now. - "
".$pwd."/$0 -> &".caller." -> [$err]","\n$dbg
", + "
SERVER ERROR on ".DateTime->now(). + "
".$pwd."/$0 -> &".caller." -> [\n$err]","\n$dbg
", $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, - "SERVER ERROR on ".DateTime->now. + "SERVER ERROR on ".DateTime->now(). "
".$pwd."/$0 -> &".caller." -> [$err]","\n$dbg
", $cgi->end_html; exit; diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index f016951..94b87c3 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -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); diff --git a/htdocs/cgi-bin/stats.cgi b/htdocs/cgi-bin/stats.cgi index bd70b24..9372e34 100755 --- a/htdocs/cgi-bin/stats.cgi +++ b/htdocs/cgi-bin/stats.cgi @@ -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'} = "~/"; diff --git a/htdocs/cgi-bin/system/modules/Settings.pm b/htdocs/cgi-bin/system/modules/Settings.pm index beafd0b..5bb3e41 100644 --- a/htdocs/cgi-bin/system/modules/Settings.pm +++ b/htdocs/cgi-bin/system/modules/Settings.pm @@ -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);
LOGIN