# 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.
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.
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);
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;}
<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">';
}
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;
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);
#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){
$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>
$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;
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.
$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;
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.
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.
# 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'};
#
# 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?
}
&populate($db);
}
- Settings::toLog($db, "Log accessed by $alias.") if(&Settings::trackLogins);
+ Settings::toLog($db, "Log accessed by $alias.") if(Settings::trackLogins());
#
$db->disconnect();
#
$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;
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;
}
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);
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 );
}
try{
-my $today = DateTime->now;
-$today->set_time_zone(&Settings::timezone);
+my $today = Settings->today();
$ENV{'HOME'} = "~/";
use CGI;
use CGI::Session '-ip_match';
use CGI::Carp qw ( fatalsToBrowser );
-
+use DateTime;
+use DateTime::Format::SQLite;
+use DateTime::Duration;
use DBI;
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';
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}
$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);
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(
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]}
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);