# Branch Development Life Log in Perl
-*This page lists current development and issues being worked on in the LifeLog app. Being in the **Sun** stage, means there is a production environment. And usable, and in use. When, the project reaches **Earth** stage. It will be at its final specification. No data structures or major new features can be added or requested anymore. Only bug fixes, enhancements and efficiency fixes, if any at the **Earth** stage.*
+*This page lists current development and issues being worked on in the LifeLog app.*
## Life Log Development
### v.2.1 SUN STABLE New Features in Works
+*It has been 2 years, 4 months, 8 hours, 56 minutes, and 55 seconds
+between 2018-08-22 04:13:55 **Moon Stable** production release and this
+2020-12-22 13:10:50 **Sun Stable v.2.1**, next and final is the Earth release stage.*
+
* ✔ Config. page set session expires times has to be validated not to be under 2 minutes.
* ✔ Implement mapped provision of named timezones via main.inf, for cities not available in global zone list.
* Javascript also needs to be updated to translate this properly.
exportToCSV() if ($csvp);
-if($cgi->param('bck')) {&backup;}
-elsif($cgi->param('bck_del')) {&backupDelete;}
+if($cgi->param('bck')) {&backup}
+elsif($cgi->param('bck_del')) {&backupDelete}
elsif($cgi->param('data_bck')){&restore;}
-elsif($cgi->param('data_cat')){&importCatCSV;}
-elsif($cgi->param('data_log')){&importLogCSV;}
+elsif($cgi->param('bck_file')){restore($cgi->param('bck_file'))}
+elsif($cgi->param('data_cat')){&importCatCSV}
+elsif($cgi->param('data_log')){&importLogCSV}
close $dir;
foreach $file (sort @backups){
#my $n = substr $file, length(&Settings::logPath);
- $bck_list .= "<input name='bck_file' type='radio' value='$file'>$file</input><br>";
+ $bck_list .= "<input name='bck_file' type='radio' value='$file' onclick='setBackupFile(this);'>$file</input><br>";
}
if(length $bck_list == 0){
-$bck_list = '<p>Restore will bring back and merge log entries from the time of backup.</p>';
+$bck_list = '<p>Restore will bring back and merge log entries from the time of backup.</p>
+ <input type="submit" name="Submit" value="Submit"/></td>
+ </tr>';
}
else{
- $bck_list = qq(<p>Tick Select Backup to Restore or Delete</p><p>$bck_list</p>);
+ $bck_list = qq(<p>Tick Select Backup to Restore or Delete</p><p>$bck_list</p>
+ <input type="submit" onclick="deleteBackup();return false;" value="Delete"/> <input type="Submit" value="Restore"/></form>);
}
-my $inpRestore = qq(<input type="button" onclick="return deleteBackup();" value="Delete"/>
-<input type="file" name="data_bck" /> <input type="Submit" onclick="return true;restoreBackup();" value="Restore"/>);
+my $inpRestore = qq(<b>Local File:</b>
+<input type="file" name="data_bck" /> <input type="Submit" value="Restore"/>);
my $inpCVS = qq(<input type="button" onclick="return exportToCSV('log',0);" value="Export"/>
<input type="button" onclick="return exportToCSV('log',1);" value="View"/>);
if((Settings::anon("backup_enabled") == 0)){
</div>
<br>
<div id="rz" style="text-align:left; width:640px; padding:10px; background-color:).&Settings::bgcol.qq(">
- <form id="bck" action="config.cgi" method="post" enctype="multipart/form-data">
+ <form id="bck" action="config.cgi" method="post">
<table border="0" width="100%">
<tr><td><a name="backup"></a><H3>Backup File Format</H3></td></tr>
<tr><td><input type="button" onclick="return fetchBackup();" value="Fetch"/><hr></td></tr>
<tr><td><div id="div_backups">$bck_list</div><hr></td></tr>
+
+ <form id="bck_file" action="config.cgi" method="post" enctype="multipart/form-data">
<tr><td>
$inpRestore
<hr></td></tr>
<tr style="border-left: 1px solid black;"><td style="text-align:right;">
<input type="submit" name="Submit" value="Submit"/></td>
</tr>
-
</form>
+
<form action="config.cgi" method="post" enctype="multipart/form-data">
<tr><td><b>Export Categories:</b>
<input type="button" onclick="return exportToCSV('cat',0);" value="Export"/>
sub restore {
-
- my $hndl = $cgi->upload("data_bck");
- my ($pipe,@br);
+ my $file = shift;
+ my ($tar,$pipe,@br);
my $pass = Settings::pass();
+ my $hndl = $cgi->param('data_bck');
+ my $dbck = &Settings::logPath."bck/"; `mkdir $dbck` if (!-d $dbck);
try{
-
getHeader();
print $cgi->start_html;
- print "<pre>Reading->$hndl</pre>";
- my $dbck = &Settings::logPath."bck/"; `mkdir $dbck` if (!-d $dbck);
- my $tar = $dbck.$hndl; $tar =~ s/osz$/tar/;
+ if($file){ #Open handle on server to backup to be restored.
+ my $f = &Settings::logPath.$file;
+ open($hndl, '<', $f) or die "Can't open $f: $!";
+ print "<pre>Reading on server -> $file</pre>";
+ $tar = $dbck.$file;
+ }
+ else{
+ print "<pre>Reading-> $hndl</pre>";
+ $tar = $dbck.$hndl;
+ }
+
+ $tar =~ s/osz$/tar/;
my $pipe;
open ($pipe, "| openssl enc -d -des-ede3-cfb -salt -S ".Settings->CIPHER_KEY." -pass pass:$pass-$alias -in /dev/stdin 2>/dev/null > $tar");
while(<$hndl>){print $pipe $_;};
- close $pipe;
+ close $pipe; close $hndl;
print "<pre>\n";
my $m1 = "it is not permitted to restore another aliases log backup.";
print "Merging from backup categories table...\n";
my $insCAT = $db->prepare('INSERT INTO CAT (ID, NAME, DESCRIPTION) VALUES(?,?,?);') or die "Failed CAT prepare.";
-
my $b_pst = Settings::selectRecords($b_db,'SELECT ID, NAME, DESCRIPTION FROM CAT;');
while ( @br = $b_pst->fetchrow_array() ) {
- my $pst = Settings::selectRecords($db, "SELECT ID,NAME,DESCRIPTION FROM CAT WHERE ID='".$br[0]."';");
+ my $pst = Settings::selectRecords($db, "SELECT ID,NAME,DESCRIPTION FROM CAT WHERE ID=".$br[0].";");
my @ext = $pst->fetchrow_array();
if(scalar(@ext)==0){
$insCAT->execute($br[0],$br[1],$br[2]);
print "Added CAT->".$br[0]."|".$br[1]."\n";
}
elsif($br[0] ne $ext[0] or $br[1] ne $ext[1]){
- $db->do("UPDATE CAT SET NAME='".$br[1]."', DESCRIPTION='".$br[2]."' WHERE ID=?;") or die "Cat update failed!";
+ $db->do("UPDATE CAT SET NAME='".$br[1]."', DESCRIPTION='".$br[2]."' WHERE ID=$br[0];") or die "Cat update failed!";
print "Updated->".$br[0]."|".$br[1]."|".$br[2]."\n";
}
}
catch{
$ERROR = "<font color='red'><b>Restore Failed!</b></font>hndl->$hndl $@ \n";
- $ERROR = "br:[@br]" if(@br);
+ $ERROR .= "br:[@br]" if(@br);
};
my $back = $cgi->url( -relative => 1 );
</td></tr>
<tr class="collpsd">
<td style="text-align:right; vertical-align:top; width:10%;">Date:</td>
- <td id="al" colspan="1" style="text-align:top; vertical-align:top"><input id="ed" type="text" name="date" size="18" value=")
+ <td id="al" colspan="2" style="text-align:top; vertical-align:top"><input id="ed" type="text" name="date" size="18" value=")
. $today->ymd . " " . $today->hms . qq(">
<button type="button" onclick="return setNow();">Now</button>
<span id="cat_desc" name="cat_desc">Enter log...</span>
- </td>
- <td style="text-align:top; vertical-align:top">Category:
- <button data-dropdown="#dropdown-standard">
+ Category:
+
+ <button data-dropdown="#dropdown-standard" style="margin: 0px; padding: 0;">
<span id="lcat" class="ui-button"> <i><font size=1>--Select --</font> </i></span>
- «</button>
+ « </button>
<div class="dropdown-menu dropdown-anchor-top-right dropdown-has-anchor" id="dropdown-standard">
<table class="tbl">$td_cat</table>
</div>
-<!-- OLD -> \$cats was here -->
</td>
</tr>
<tr class="collpsd"><td style="text-align:right; vertical-align:top">Log:</td>
$srh .=
qq(
<tr class="collpsd">
- <td align="right">View by Category:</td>
+ <td align="right" style="width:20%">View by Category:</td>
<td align="left">
<span id="lcat_v" class="ui-button">$catselected</span>
<button class="bordered" data-dropdown="#dropdown-standard-v">«</button>
<script type="text/javascript">
var AUTOWORDS = [$autowords];
</script>
-<audio id="au_door_chime" preload="true"
+<audio id="au_door_chime" preload="auto"
src="wsrc/Store_Door_Chime-Mike_Koenig-570742973.mp3">
Your browser does not support the
<code>audio</code> element.
ID_RTF INTEGER DEFAULT 0,
DATE TIMESTAMP NOT NULL,
LOG VARCHAR ($DBI_LVAR_SZ) NOT NULL,
- AMOUNT INTEGER,
- AFLAG INT DEFAULT 0,
+ AMOUNT money,
+ AFLAG INT DEFAULT 0,
STICKY BOOL DEFAULT FALSE,
PRIMARY KEY(ID)
);)}
ID_RTF INTEGER DEFAULT 0,
DATE DATETIME NOT NULL,
LOG VARCHAR ($DBI_LVAR_SZ) NOT NULL,
- AMOUNT INTEGER,
- AFLAG INT DEFAULT 0,
+ AMOUNT DOUBLE,
+ AFLAG INT DEFAULT 0,
STICKY BOOL DEFAULT 0
);
)}
when ("RELEASE_VER") {$RELEASE_VER = $r[2]}
when ("TIME_ZONE") {$TIME_ZONE = $r[2]}
when ("PRC_WIDTH") {$PRC_WIDTH = $r[2]}
- when ("SESSN_EXPR") {$SESSN_EXPR = $r[2]}
+ when ("SESSN_EXPR") {$SESSN_EXPR = timeFormatValue($r[2])}
when ("DATE_UNI") {$DATE_UNI = $r[2]}
when ("LANGUAGE") {$LANGUAGE = $r[2]}
when ("LOG_PATH") {} # Ommited and code static can't change for now.
};
}
+sub timeFormatValue {
+ my $v = shift;
+ if(!$v || $v==0){$v="+2m"}
+ if($v !~ /^\+/){$v='+'.$v.'m'}
+ return $v;
+}
+
sub getTheme {
given ($THEME){
when ("Sun") { $BGCOL = '#D4AF37'; $TH_CSS = "main_sun.css"; }
function setPageSessionTimer(expires) {
- var timeout;
+ var timeout;
+ var now = new moment();
+ var val = expires.replace(/\+|[A-Z]|[a-z]/g, '');
+
+ if(expires.indexOf("h")>0){
+ timeout = moment(now).add(val, "h");
+ }
+ else
+ if(expires.indexOf("m")>0){
+ if(val<2){val=2};
+ timeout = moment(now).add(val, "m");
+ }
+ else
+ if(expires.indexOf("s")>0){
+ if(val<60){val=2};
+ timeout = moment(now).add(val, "s");
+ }
+ else{
+ if(val<2){val=2};
+ timeout = moment(now).add(val, "m");
+ }
+ var WARNED =0;
+ var timer = setInterval(function() {
var now = new moment();
- var val = expires.replace(/\+|[A-Z]|[a-z]/g, '');
-
- if(expires.indexOf("h")>0){
- timeout = moment(now).add(val, "h");
+ var dif = timeout.diff(now);
+ var min = Math.floor(dif / 60000);
+ var sec = ((dif % 60000) / 1000).toFixed(0);
+ var out = (min < 10 ? '0' : '') + min + ":" + (sec < 10 ? '0' : '') + sec;
+ var tim = new moment().tz(TIMEZONE).format("hh:mm:ss a");
+ var sty = "";if(min<2){sty="style='color:red'";
+ if(!WARNED){WARNED=1;$('#au_door_chime').trigger('play');display("<font color='red'>Session is about to expire!</font>",10);}}
+ var dsp = "<font size='1px;'>[" + tim + "]</font><span "+sty+"> Session expires in " + out + "</span>";
+ $("#sss_status").html(dsp);
+ if(now.isAfter(timeout)){
+ $("#sss_status").html("<span id='sss_expired'><a href='login_ctr.cgi'>Page Session has Expired!</a></span>");
+ clearInterval(timer);
+ $("#ed").prop( "disabled", true );
+ $("#el").prop( "disabled", true );
+ $("#am").prop( "disabled", true );
}
- else
- if(expires.indexOf("m")>0){
- if(val<2){val=2};
- timeout = moment(now).add(val, "m");
- }
- else
- if(expires.indexOf("s")>0){
- if(val<60){val=2};
- timeout = moment(now).add(val, "s");
- }
- else{
- if(val<2){val=2};
- timeout = moment(now).add(val, "m");
- }
- var WARNED =0;
- var timer = setInterval(function() {
- var now = new moment();
- var dif = timeout.diff(now);
- var min = Math.floor(dif / 60000);
- var sec = ((dif % 60000) / 1000).toFixed(0);
- var out = (min < 10 ? '0' : '') + min + ":" + (sec < 10 ? '0' : '') + sec;
- var tim = new moment().tz(TIMEZONE).format("hh:mm:ss a");
- var sty = "";if(min<2){sty="style='color:red'";
- if(!WARNED){WARNED=1;$('#au_door_chime').trigger('play');display("<font color='red'>Session is about to expire!</font>",10);}}
- var dsp = "<font size='1px;'>[" + tim + "]</font><span "+sty+"> Session expires in " + out + "</span>";
- $("#sss_status").html(dsp);
- if(now.isAfter(timeout)){
- $("#sss_status").html("<span id='sss_expired'><a href='login_ctr.cgi'>Page Session has Expired!</a></span>");
- clearInterval(timer);
- $("#ed").prop( "disabled", true );
- $("#el").prop( "disabled", true );
- $("#am").prop( "disabled", true );
- }
-
- }, 1000);
+ }, 1000);
}
function checkConfigCatsChange(){
});
return false;
}
+