From 729b2c8f18ae18f99cbd22f04791d3cadcfa923b Mon Sep 17 00:00:00 2001 From: Will Budicm Date: Tue, 22 Dec 2020 13:31:16 +1100 Subject: [PATCH] Stable SUN release v.2.1 locally tested. --- Current Development Check List.md | 6 +- htdocs/cgi-bin/config.cgi | 60 ++++++++++------- htdocs/cgi-bin/main.cgi | 15 ++--- htdocs/cgi-bin/system/modules/Settings.pm | 17 +++-- htdocs/cgi-bin/wsrc/main.js | 80 +++++++++++------------ 5 files changed, 101 insertions(+), 77 deletions(-) diff --git a/Current Development Check List.md b/Current Development Check List.md index d6d095e..586d596 100644 --- a/Current Development Check List.md +++ b/Current Development Check List.md @@ -1,11 +1,15 @@ # 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. diff --git a/htdocs/cgi-bin/config.cgi b/htdocs/cgi-bin/config.cgi index a7eeba1..263ea42 100755 --- a/htdocs/cgi-bin/config.cgi +++ b/htdocs/cgi-bin/config.cgi @@ -40,11 +40,12 @@ my $csvp = $cgi->param('csv'); 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} @@ -356,17 +357,20 @@ next if $file eq '.' or $file eq '..' or index ($file , 'bck_') == -1; close $dir; foreach $file (sort @backups){ #my $n = substr $file, length(&Settings::logPath); - $bck_list .= "$file
"; + $bck_list .= "$file
"; } if(length $bck_list == 0){ -$bck_list = '

Restore will bring back and merge log entries from the time of backup.

'; +$bck_list = '

Restore will bring back and merge log entries from the time of backup.

+ + '; } else{ - $bck_list = qq(

Tick Select Backup to Restore or Delete

$bck_list

); + $bck_list = qq(

Tick Select Backup to Restore or Delete

$bck_list

+   ); } -my $inpRestore = qq( -  ); +my $inpRestore = qq(Local File:   +  ); my $inpCVS = qq(  ); if((Settings::anon("backup_enabled") == 0)){ @@ -388,12 +392,14 @@ print qq(
-
+ + + @@ -405,8 +411,8 @@ print qq( - +

Backup File Format


$bck_list

$inpRestore
Export Categories:   @@ -1039,21 +1045,30 @@ sub backup { 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 "
Reading->$hndl
"; - 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 "
Reading on server -> $file
"; + $tar = $dbck.$file; + } + else{ + print "
Reading-> $hndl
"; + $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 "
\n";
         my $m1 = "it is not permitted to restore another aliases log backup.";
@@ -1073,17 +1088,16 @@ sub restore {
 
         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";
             }
 
@@ -1126,7 +1140,7 @@ sub restore {
     }
     catch{
         $ERROR = "Restore Failed!hndl->$hndl $@ \n";
-        $ERROR = "br:[@br]" if(@br);
+        $ERROR .= "br:[@br]" if(@br);
     };
 
     my $back = $cgi->url( -relative => 1 );
diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi
index 1fad135..cbf9232 100755
--- a/htdocs/cgi-bin/main.cgi
+++ b/htdocs/cgi-bin/main.cgi
@@ -775,7 +775,7 @@ $log_output .= qq(
-	
Date:hms . qq(">   @@ -784,17 +784,16 @@ $log_output .= qq(Enter log... - - @@ -885,7 +884,7 @@ $log_output .= qq(
Category:  - +   «   -
Log:
- +
View by Category:View by Category: $catselected @@ -1020,7 +1019,7 @@ $tail -