From b21e226322cbef12efb4f044b640d62e62bb847e Mon Sep 17 00:00:00 2001 From: Will Budic Date: Thu, 12 May 2022 05:15:56 +1000 Subject: [PATCH] upd. --- Current Development Check List.md | 4 +++ Installation_LightHTTPD.txt | 2 +- htdocs/cgi-bin/config.cgi | 46 ++++++++++++++++++------------- htdocs/cgi-bin/data.cgi | 12 ++++---- htdocs/cgi-bin/main.cgi | 33 ++++++++++++++-------- 5 files changed, 61 insertions(+), 36 deletions(-) diff --git a/Current Development Check List.md b/Current Development Check List.md index 6815e96..1224cac 100644 --- a/Current Development Check List.md +++ b/Current Development Check List.md @@ -6,6 +6,9 @@ ### New Development v.2.3+ +* [ ] Backup options revisited/retested. +* [ ] Categories display and intereaction to be bettered. +* [ ] Bug 37 Keywords only search not wotking on detecting very old items. * [x] Fix uninitialized $scalars and warnings. My style of programming uses this as a perl feature, as unutilized is also null or empty. Linter disagrees with that. Empty or null isn't also 0 for it. Null, empty, undef, and zero should be the same thing in scalar context and logic. * [ ] Stats and config page should check github for latest version, as background pull. * [ ] Implement template based CGI processing (slower but better separation of concerns). @@ -259,6 +262,7 @@ between 2018-08-22 04:13:55 **Moon Stable** production release and this ### v. 2.3+ Encountered/Fixed +* Bug 37 Keywords only search not wotking on detecting very old items. * ✔ Bug 36.1, Introduced bug, old backup delete not working. * ✔ Bug 36, DBFix not fully working on PG based install and restore not working from backups made with older versions of OpenSSL. * Also, restore not working on uploaded backups, from local computer. diff --git a/Installation_LightHTTPD.txt b/Installation_LightHTTPD.txt index fe8c4b7..6bb4e64 100644 --- a/Installation_LightHTTPD.txt +++ b/Installation_LightHTTPD.txt @@ -14,7 +14,7 @@ sudo apt-get install libpcre3-dev -y sudo apt-get install libbz2-dev -y sudo apt install libssl-dev -y -./configure --prefix=/usr/local/lighttpd --with-openssl --with-sqlite +./configure --prefix=/usr/local/lighttpd --with-openssl --with-sqlite --with-pgsql make sudo make install diff --git a/htdocs/cgi-bin/config.cgi b/htdocs/cgi-bin/config.cgi index c615dfe..183583d 100755 --- a/htdocs/cgi-bin/config.cgi +++ b/htdocs/cgi-bin/config.cgi @@ -110,7 +110,7 @@ while(my @row = $dbs->fetchrow_array()) { } my $frmCats = qq( -
).$tbl.qq( + ).$tbl.qq( @@ -1247,7 +1247,7 @@ sub backup { sub restore { my $file = shift; - my ($tar,$pipe,@br,$stdout,$b_db); + my ($tar,$pipe, @br,$stdout,$b_db); my $pass = Settings::pass(); my $hndl = $cgi->param('bck_upload'); my $dbck = &Settings::logPath."bck/"; `mkdir $dbck` if (!-d $dbck); @@ -1257,29 +1257,36 @@ sub restore { print $fhLog $stamp, "Started restore procedure.\n"; try{ - getHeader(); - print $cgi->start_html; - -my $stdout = capture_stdout { - print "Restore started: ".Settings::today(), "\n"; - if($file){ #Open handle on server where backup is to be restored. - my $f = &Settings::logPath.$file; - open($hndl, '<', $f) or die "Can't open $f: $!"; - print $fhLog $stamp, "Reading on server backup file -> $file\n"; - $tar = $dbck.$file; - } - else{ - print $fhLog $stamp, "Uploading to server backup file -> $hndl\n"; - $tar = $dbck.$hndl; - } + getHeader(); + print $cgi->start_html; + + + if($file){ #Open handle on server where backup is to be restored. + my $f = &Settings::logPath.$file; + open($hndl, '<', $f) or die "Can't open $f: $!"; + print $fhLog $stamp, "Reading on server backup file -> $file\n"; + $tar = $dbck.$file; + } + else{ + print $fhLog $stamp, "Uploading to server backup file -> $hndl\n"; + $tar = $dbck.$hndl; + } + + print $cgi->pre("Restore started: ".Settings::today(), "\n", "Reading $tar ..."); + + my $stdout = capture_stdout { $tar =~ s/osz$/tar/; my $srcIsPg = 0; my $passw = $pass; $passw = uc crypt $pass, hex Settings->CIPHER_KEY if &Settings::isProgressDB; - open (my $pipe, "|-", "openssl enc -aes-256-cbc -md sha512 -pbkdf2 -iter 100000 -d -salt -S ". - Settings->CIPHER_KEY." -pass pass:$passw-$alias -in /dev/stdin -out $tar 2>/dev/null") or die "Pipe Failed for $tar: $!"; + open ($pipe, "|-", "openssl enc -aes-256-cbc -md sha512 -pbkdf2 -iter 100000 -d -salt -S ". + Settings->CIPHER_KEY." -pass pass:$passw-$alias -in /dev/stdin -out $tar") + or die "Pipe Failed for $tar: $!"; + while(<$hndl>){print $pipe $_; die "bad decoding" if $?;}; close $pipe; close $hndl; + + #cat bck_20210819160848_SQLite_admin.osz | openssl enc -d -des-ede3-cfb -salt -S 95d7a85ba891da -pass pass:42FAP5H0JUSZM-admin -in /dev/stdin > extract.tar #openssl des-ede3-cfb -d -salt -S 95d7a85ba891da -pass pass:42FAP5H0JUSZM-admin -pbkdf2 -in bck_20210830133220_NUc_SQLite_admin.osz -out extract.tar @@ -1459,6 +1466,7 @@ catch{ $ERROR = "
Full Restore Failed!
$@ \n"; $ERROR .= "br:[@br]" if(@br); $ERROR .= "
Failed at stage: $stage"; + print $fhLog $stamp, "Error: $@ at:@br.\n"; openlog(Settings::dsn(), 'cons,pid', "user"); syslog('err', '%s', $ERROR); closelog(); diff --git a/htdocs/cgi-bin/data.cgi b/htdocs/cgi-bin/data.cgi index a7fd104..076bf58 100755 --- a/htdocs/cgi-bin/data.cgi +++ b/htdocs/cgi-bin/data.cgi @@ -20,7 +20,7 @@ use lib "system/modules"; require Settings; my $db = Settings::fetchDBSettings(); -my $cgi = Settings::cgi(); +my $cgi = Settings::cgi(); my $dbname = Settings::dbName(); my $human = DateTime::Format::Human::Duration->new(); my $PRC_WIDTH = Settings::pagePrcWidth(); @@ -31,6 +31,7 @@ my $imgw = 210; my $imgh = 120; my $opr = $cgi->param("opr"); my $confirmed = $cgi->param('confirmed'); + if ($opr == 1){ DisplayDateDiffs(); } @@ -168,7 +169,8 @@ try{ #Get ids and build confirm table and check my $stm = $stmS ." "; - foreach my $id ($cgi->param('chk')){ + my @chks= $cgi->param('chk'); + foreach my $id (@chks){ if($opr == 2){ $stm = $stm . "$SQLID = " . $id . " OR "; } @@ -182,7 +184,7 @@ try{ if($opr == 0){ printHeader('Confirm Deletion'); - print $cgi->pre("###NotConfirmed()->[stm:$stm]") if($DEBUG); + print $cgi->pre("###NotConfirmed()->[stm:$stm]\n]opr:$opr]") if($DEBUG); my $r_cnt = 0; my $rs = "r1"; @@ -338,8 +340,8 @@ try{ my $stmE = " ORDER BY DATE DESC, ID DESC;"; #Get ids and build confirm table and check - my $stm = " "; - foreach my $id ($cgi->param('chk')){ + my $stm = " "; my @chks= $cgi->param('chk'); + foreach my $id (@chks){ if($opr == 2){ $stm = $stm . "$SQLID = " . $id . " OR "; } diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index a2a65fe..3f88b08 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -3,7 +3,7 @@ # Programed by: Will Budic # Open Source License -> https://choosealicense.com/licenses/isc/ # -use v5.34; #use diagnostics; +use v5.30; #use diagnostics; use warnings; use strict; no warnings "experimental::smartmatch"; @@ -255,27 +255,38 @@ my %hshDesc = (); my $c_sel = 1; my $data_cats = ""; my $td_cat = ""; + + for my $key ( keys %hshDesc ) { my $kv = $hshDesc{$key}; next if !$kv; @@ -1054,8 +1065,9 @@ else{ $sideMenu = qq(