From 6b0cf28f5b7e832e35b0ff0d44a2a94e7dcb49f8 Mon Sep 17 00:00:00 2001 From: Metabox Date: Sun, 28 Apr 2019 07:42:59 +1000 Subject: [PATCH] Implemented logout. --- htdocs/cgi-bin/login_ctr.cgi | 42 ++++++++++++++++++++++++++++------- htdocs/cgi-bin/main.cgi | 43 +++++++++++++++++++++++++++--------- 2 files changed, 66 insertions(+), 19 deletions(-) diff --git a/htdocs/cgi-bin/login_ctr.cgi b/htdocs/cgi-bin/login_ctr.cgi index 8872887..1189c23 100755 --- a/htdocs/cgi-bin/login_ctr.cgi +++ b/htdocs/cgi-bin/login_ctr.cgi @@ -43,14 +43,15 @@ my $frm; #This is the OS developer release key, replace on istallation. As it is not secure. my $cipher_key = '95d7a85ba891da'; +if($cgi->param('logout')){&logout} + if(&processSubmit==0){ print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie); print $cgi->start_html(-title => "Personal Log Login", -BGCOLOR=>"#c8fff8", -script=>{-type => 'text/javascript', -src => 'wsrc/main.js'}, -style =>{-type => 'text/css', -src => 'wsrc/main.css'}, - ); - + ); $frm = qq(
@@ -71,9 +72,11 @@ if(&processSubmit==0){
); - print "
"; - print "\n
\n" . $frm ."\n
\n
"; - print "
"; + print qq(

+
+

Welcome to Life Log

$frm

+ Get latest version of this application here!
+
); print $cgi->end_html; } @@ -157,7 +160,6 @@ try{ insertDefCats($db); } - $st = $db->prepare(selSQLTbl('AUTH')); $st->execute(); if(!$st->fetchrow_array()) { @@ -191,7 +193,7 @@ try{ $rv = $db->do($stmt); } populateConfig($db); - + $db->disconnect(); } catch{ print $cgi->header; @@ -280,4 +282,28 @@ sub removeOldSessions{ } } -### CGI END \ No newline at end of file +sub logout{ + + $session->delete(); + $session->flush(); + print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie); + print $cgi->start_html(-title => "Personal Log Login", -BGCOLOR=>"black", + -style =>{-type => 'text/css', -src => 'wsrc/main.css'}, + ); + + print qq(

You have properly loged out of the Life Log Application!

+
+

+
+ +
+ ); + + print $cgi->end_html; + exit; +} + +### CGI END diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index 2dddb15..3ed0bd5 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -31,6 +31,7 @@ our $SESSN_EXPR = '+30m'; our $DATE_UNI = '0'; our $RELEASE_VER = '1.3'; our $AUTHORITY = ''; +our $IMG_W_H = '210x120'; #END OF SETTINGS my $cgi = CGI->new; @@ -52,6 +53,8 @@ my $database = '../../dbLifeLog/'.$dbname; my $dsn= "DBI:SQLite:dbname=$database"; my $db = DBI->connect($dsn, $userid, $password, { RaiseError => 1 }) or die "

Error->"& $DBI::errstri &"

"; +my ($imgw,$imgh); + ### Authenticate session to alias password &authenticate; &getConfiguration($db); @@ -79,6 +82,17 @@ if($rs_dat_from && $rs_dat_to){ my $toggle =""; if($rs_keys||$rs_cat_idx||$stmD){$toggle=1;}; $session->expire($SESSN_EXPR); + +#tag related framed sizing. +my @arrwh = $IMG_W_H = ~m((\S+)\s*x\$\s*(\S+))gi; +if(@arrwh==2){ + $imgw = $arrwh[0]; + $imgh = $arrwh[1]; +} +else{ + $imgw = 210; + $imgh = 120; +} print $cgi->header(-expires=>"0s", -charset=>"UTF-8"); print $cgi->start_html(-title => "Personal Log", -BGCOLOR=>"#c8fff8", @@ -271,10 +285,10 @@ while(my @row = $st->fetchrow_array()) { } } $lnk = qq(\n - ); + ); }else{ #TODO fetch from web locally the original image. - $lnk = qq(\n); + $lnk = qq(\n); } $tags .= qq(\n); $log=~s/</$lnk/o; @@ -297,8 +311,12 @@ while(my @row = $st->fetchrow_array()) { my $sub = "".substr($log,$idx+4,$len-$idx).""; $log=~s/</$sub/o; } - - + while ($log =~ /<', $idx)-4; + my $sub = "".substr($log,$idx+4,$len-$idx).""; + $log=~s/</$sub/o; + } while($log =~ /<', $idx)-8; @@ -457,12 +475,14 @@ $srh.='
'; # #Page printout from here! # -print "
"; - print "\n
\n" . $frm ."\n
\n
\n"; - print '
' . $srh .'
'; - print "\n
\n" . $tbl ."\n
"; - print '
'; - print '
'; +print qq(
\n +
\n$frm\n
\n
\n +
$srh
+
\n$tbl\n

+

+
+ + ); print qq(
    $cat_descriptions @@ -679,7 +699,8 @@ sub getConfiguration{ case "PRC_WIDTH" {$PRC_WIDTH=$r[2]} case "SESSN_EXPR" {$SESSN_EXPR=$r[2]} case "DATE_UNI" {$DATE_UNI=$r[2]} - case "LANGUAGE" {$LANGUAGE=$r[2]} + case "LANGUAGE" {$LANGUAGE=$r[2]} + case "IMG_W_H" {$IMG_W_H=$r[2]} else {print "Unknow variable setting: ".$r[1]. " == ". $r[2]} } -- 2.34.1