From d6128aa955be58f20a9ec9c3157b2f53b4098fbf Mon Sep 17 00:00:00 2001 From: Will Budicm Date: Mon, 21 Dec 2020 23:31:27 +1100 Subject: [PATCH] CGI object output fixed and layout. --- htdocs/cgi-bin/data.cgi | 61 ++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/htdocs/cgi-bin/data.cgi b/htdocs/cgi-bin/data.cgi index 60a41bf..5e0c753 100755 --- a/htdocs/cgi-bin/data.cgi +++ b/htdocs/cgi-bin/data.cgi @@ -4,8 +4,8 @@ # Open Source License -> https://choosealicense.com/licenses/isc/ # use v5.10; -use strict; use warnings; +use strict; use Exception::Class ('LifeLogException'); use Syntax::Keyword::Try; @@ -17,7 +17,7 @@ use lib "system/modules"; require Settings; my $db = Settings::fetchDBSettings(); -my $cgi = Settings->cgi(); +my $cgi = Settings::cgi(); my $dbname = Settings::dbName(); my $imgw = 210; my $imgh = 120; @@ -29,26 +29,17 @@ my $DEBUG = Settings::debug(); my $today = Settings::today(); my $tbl_rc =0; -my $tbl = '
- - '; - - my $opr = $cgi->param("opr"); my $confirmed = $cgi->param('confirmed'); if ($opr == 1){ DisplayDateDiffs(); }elsif ($confirmed){ - ConfirmedDelition(); + DeletionConfirmed(); }else{ print $cgi->redirect('main.cgi') if not $cgi->param('chk'); NotConfirmed(); } - - -print $cgi->end_html; $db->disconnect(); -exit; sub DisplayDateDiffs { @@ -61,7 +52,7 @@ sub DisplayDateDiffs { ); - $tbl = '
Date Time Log Category
+ my $tbl = '
'; $stm = 'SELECT DATE, LOG FROM VW_LOG WHERE '; @@ -130,21 +121,19 @@ return "".$d->ymd()." ".$d->hms; } -sub ConfirmedDelition { +sub DeletionConfirmed { -try{ - my $st; - my $SQLID = 'rowid'; $SQLID = 'ID' if( Settings::isProgressDB() ); +try{ + my $SQLID = 'rowid'; $SQLID = 'ID' if (Settings::isProgressDB()); + my $st1 = $db->prepare("DELETE FROM LOG WHERE $SQLID = ?;"); + my $st2 = $db->prepare("DELETE FROM NOTES WHERE LID = ?;"); + #print $cgi->header(-expires=>"+6os"); foreach my $id ($cgi->param('chk')){ - print $cgi->p("###[deleting:$id]") if(Settings::debug()); - $st = $db->prepare("DELETE FROM LOG WHERE $SQLID = '$id';"); - $st->execute() or die "

Error->"& $_ &"

"; - $st = $st = $db->prepare("DELETE FROM NOTES WHERE LID = '$id';"); - $st->execute(); + #print $cgi->p("###[deleting:$id]") if(Settings::debug()); + $st1->execute($id) or die "

Error->"& $_ &"

"; + $st2->execute($id); } - $st->finish; - - print $cgi->redirect('main.cgi'); + print $cgi->redirect('main.cgi'); }catch{ print $cgi->p("ERROR " . $@); @@ -177,7 +166,8 @@ try{ } $stm =~ s/ OR $//; $stm .= $stmE; $st = Settings::selectRecords($db, $stm); - + + if($opr == 0){ print $cgi->header(-expires=>"+6os"); print $cgi->start_html(-title => "Personal Log Record Removal", -BGCOLOR => $BGCOL, @@ -190,6 +180,10 @@ try{ my $r_cnt = 0; my $rs = "r1"; + my $tbl = ' +
* DATE DIFFERENCES *
+ '; + while(my @row = $st->fetchrow_array()) { @@ -216,19 +210,18 @@ try{ $tbl .= ' -
Date Time Log Category
-

Please Confirm You Want
The Above Record'.$plural.' Deleted?

+

Please Confirm You Want
The Above Record'.$plural.' Deleted?

(Or hit you Browsers Back Button!)
-
- +
'; + '; - print '
' . $tbl .'
'; + print "
\n$tbl\n
"; - + print $cgi->end_html(); } elsif($opr == 2){ my $csv = Text::CSV-> new ( { binary => 1, escape_char => "\\", strict => 1, eol => $/ } ); @@ -240,9 +233,9 @@ try{ my $out = $csv->print(*STDOUT, $row); print $out if(length $out>1); } + exit; } - $st->finish(); - exit; + $st->finish(); }catch{ print "SERVER ERROR-> Method NotConfirmed() Page Build Failed!.:
".$@."
"; } -- 2.34.1