From aed14f6f5f862355235817a3f3025aeef45b795f Mon Sep 17 00:00:00 2001 From: Metabox Date: Tue, 27 Aug 2019 13:11:08 +1000 Subject: [PATCH] fix:amf not being set. --- dbLifeLog/main.cnf | 2 + htdocs/cgi-bin/login_ctr.cgi | 108 +++++++++--------- htdocs/cgi-bin/main.cgi | 5 +- htdocs/cgi-bin/remove.cgi | 25 ++-- htdocs/cgi-bin/wsrc/main.js | 42 ++++--- .../tip-yellowsimple/tip-yellowsimple.css | 5 + 6 files changed, 107 insertions(+), 80 deletions(-) diff --git a/dbLifeLog/main.cnf b/dbLifeLog/main.cnf index 6563f7c..3f66822 100644 --- a/dbLifeLog/main.cnf +++ b/dbLifeLog/main.cnf @@ -75,3 +75,5 @@ UPDATE LOG SET AFLAG=1 WHERE ID_CAT=%INCOME_ID%; UPDATE LOG SET AFLAG=2 WHERE ID_CAT=%EXPENSE_ID%; + + diff --git a/htdocs/cgi-bin/login_ctr.cgi b/htdocs/cgi-bin/login_ctr.cgi index d7cc7b5..ca1021a 100755 --- a/htdocs/cgi-bin/login_ctr.cgi +++ b/htdocs/cgi-bin/login_ctr.cgi @@ -6,7 +6,7 @@ package main; use strict; use warnings; -use Try::Tiny; +use Try::Tiny; use CGI; use CGI::Session '-ip_match'; use DBI; @@ -25,7 +25,7 @@ our $PRC_WIDTH = '70'; our $LOG_PATH = '../../dbLifeLog/'; our $SESSN_EXPR = '+30m'; our $DATE_UNI = '0'; -our $RELEASE_VER = '1.5'; +our $RELEASE_VER = '1.6'; our $AUTHORITY = ''; our $IMG_W_H = '210x120'; our $AUTO_WRD_LMT= 200; @@ -58,13 +58,16 @@ if($cgi->param('logout')){&logout} if(&processSubmit==0){ &getTheme; - print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie); - print $cgi->start_html(-title => "Personal Log Login", -BGCOLOR=>"$BGCOL", - -script=>{-type => 'text/javascript', -src => 'wsrc/main.js'}, - -style =>{-type => 'text/css', -src => "wsrc/$TH_CSS"}, - ); + print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie); + print $cgi->start_html( + -title => "Personal Log Login", + -BGCOLOR => "$BGCOL", + -script => { -type => 'text/javascript', -src => 'wsrc/main.js' }, + -style => { -type => 'text/css', -src => "wsrc/$TH_CSS" }, +); - $frm = qq( + +$frm = qq(
@@ -77,18 +80,19 @@ if(&processSubmit==0){
LOGIN
NOTICE!   - Alias will create a new database if it doesn't exist. Note down your password. + Alias will create a new database if it doesn't exist. Note down your password.
); - print qq(

+print qq(

Welcome to Life Log

$frm

Get latest version of this application here!
); - print $cgi->end_html; + print $cgi->end_html; + } else{ @@ -102,14 +106,14 @@ sub processSubmit{ try{ if($alias&&$passw){ - + $passw = uc crypt $passw, hex $cipher_key; &checkCreateTables; $session->param('alias', $alias); $session->param('passw', $passw); - $session->param('database', 'data_'.$alias.'_log.db'); + $session->param('database', 'data_'.$alias.'_log.db'); $session->flush(); - print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie, -location=>"main.cgi"); + print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie, -location=>"main.cgi"); return 1; } else{ @@ -117,7 +121,7 @@ try{ } return 0; } - catch{ + catch{ print $cgi->header; print "SERVER ERROR dump ->". $session->dump(); print $cgi->end_html; @@ -128,7 +132,7 @@ sub checkAutologinSet { try{ #We don't need to slurp as it is expected setting in header. my @cre; - open(my $fh, '<', $LOG_PATH.'main.cnf' ) or die "Can't open main.cnf: $!"; + open(my $fh, '<', $LOG_PATH.'main.cnf' ) or die "Can't open main.cnf: $!"; while (my $line = <$fh>) { chomp $line; if(rindex ($line, "<1){ + if(@cre &&scalar(@cre)>1){ my $database = $LOG_PATH.'data_'.$cre[0].'_log.db'; my $dsn= "DBI:SQLite:dbname=$database"; - my $db = DBI->connect($dsn, $cre[0], $cre[1], { RaiseError => 1 }) + my $db = DBI->connect($dsn, $cre[0], $cre[1], { RaiseError => 1 }) or die "

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

"; - #check if enabled. + #check if enabled. my $st = $db->prepare("SELECT VALUE FROM CONFIG WHERE NAME='AUTO_LOGIN';"); $st->execute(); my @set = $st->fetchrow_array(); if(@set && $set[0]=="1"){ $alias = $cre[0]; - $passw = $cre[1]; + $passw = $cre[1]; } $db->disconnect(); } } - catch{ + catch{ print $cgi->header; print "SERVER ERROR:".$_; print $cgi->end_html; @@ -169,7 +173,7 @@ try{ $today->set_time_zone( $TIME_ZONE ); my $database = $LOG_PATH.'data_'.$alias.'_log.db'; my $dsn= "DBI:SQLite:dbname=$database"; - my $db = DBI->connect($dsn, $alias, $passw, { RaiseError => 1 }) + my $db = DBI->connect($dsn, $alias, $passw, { RaiseError => 1 }) or die "

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

"; my $rv; my $st = $db->prepare(selSQLTbl('LOG')); @@ -182,7 +186,7 @@ try{ CREATE TABLE LOG ( ID_CAT TINY NOT NULL, DATE DATETIME NOT NULL, - LOG VCHAR(128) NOT NULL, + LOG VCHAR(128) NOT NULL, AMOUNT INTEGER DEFAULT 0, AFLAG TINY DEFAULT 0, RTF BOOL DEFAULT 0 @@ -191,7 +195,7 @@ try{ ); $rv = $db->do($stmt); if($rv < 0){print "

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

";} - + $st = $db->prepare('INSERT INTO LOG VALUES (?,?,?,?,?,?)'); $st->execute( 3, $today, "DB Created!",0,0,0); } @@ -205,9 +209,9 @@ try{ DESCRIPTION VCHAR(64) ); CREATE INDEX idx_cat_name ON CAT (NAME); - ); + ); $rv = $db->do($stmt); - $changed = 1; + $changed = 1; } #Have cats been wiped out? $st = $db->prepare('SELECT count(ID) FROM CAT;'); @@ -221,23 +225,23 @@ try{ if(!$st->fetchrow_array()) { # # @TODO - # AUTH Action Flags + # AUTH Action Flags # 00|DEFAULT`No action idle use.| # 02|CONF_UPD`Configuration file update with db. # 03|EMAIL`Issue email.| # 06|DESTRUCT`Self destruct, remove alias and all data. - # 08|CHNG_PASS`Change password. - # 10|CHNG_ALIAS`Change alias. - + # 08|CHNG_PASS`Change password. + # 10|CHNG_ALIAS`Change alias. + my $stmt = qq( CREATE TABLE AUTH( alias varchar(20) PRIMARY KEY, passw TEXT, email varchar(44), - action TINY + action TINY ) WITHOUT ROWID; CREATE INDEX idx_auth_name_passw ON AUTH (ALIAS, PASSW); - ); + ); $rv = $db->do($stmt); @@ -261,7 +265,7 @@ try{ if(!$st->fetchrow_array()) { my $stmt = qq( CREATE TABLE NOTES (LID PRIMARY KEY NOT NULL, DOC TEXT); - ); + ); $rv = $db->do($stmt); if($rv < 0){print "

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

"}; } @@ -273,7 +277,7 @@ try{ $st = $db->prepare('INSERT INTO AUTH VALUES (?,?,?,?);'); $st->execute($alias, $passw,"",0); } - + $st = $db->prepare(selSQLTbl('CONFIG')); $st->execute(); if(!$st->fetchrow_array()) { @@ -308,14 +312,14 @@ try{ $st = $db->prepare('SELECT count(ID) FROM CONFIG;'); $st->execute(); $changed = 1 if($st->fetchrow_array()==0); - + } # &populate($db) if $changed; # $db->disconnect(); } - catch{ + catch{ print $cgi->header; print "SERVER ERROR:".$_; print $cgi->end_html; @@ -324,7 +328,7 @@ try{ } sub populate { - + my $db = shift; my ($did,$name, $value, $desc); my $inData = 0; @@ -337,15 +341,15 @@ sub populate { read $fh, my $content, -s $fh; @lines = split '\n', $content; close $fh; -#TODO Check if script id is unique to database? If not script prevails to database entry. +#TODO Check if script id is unique to database? If not script prevails to database entry. #So, if user settings from a previous release, must be migrated later. try{ - + my $insConfig = $db->prepare('INSERT INTO CONFIG VALUES (?,?,?,?)'); my $insCat = $db->prepare('INSERT INTO CAT VALUES (?,?,?)'); $db->begin_work(); foreach my $line (@lines) { - + last if ($line =~ //); my @tick = split("`",$line); @@ -386,7 +390,7 @@ $err .= "Invalid, spec'ed {uid}|{variable}`{description}-> $line\n"; $err .= "Invalid, spec'd entry -> $line\n"; }elsif($table_type==1){ my @pair = $tick[0] =~ m[(\S+)\s*\|\s*(\S+)]g; - if ( scalar(@pair)==2 ) { + if ( scalar(@pair)==2 ) { my $st = $db->prepare("SELECT rowid FROM CONFIG WHERE NAME LIKE '$pair[1]';"); $st->execute(); $inData = 1; @@ -399,21 +403,21 @@ $err .= "Invalid, spec'ed {uid}|{category}`{description}-> $line\n"; } }elsif($table_type==2){ #TODO Do we really want this? - } + } }elsif($inData && length($line)>0){ if(scalar(@tick)==1){ $err .= "Corrupt Entry, no description supplied -> $line\n"; } - else{ + else{ $err .= "Corrupt Entry -> $line\n"; } } - } + } die "Configuration script $LOG_PATH/main.cnf [$fh] contains errors." if $err; $db->commit(); - } catch{ + } catch{ print $cgi->header; print "SERVER ERROR!
".$_."
$err
"; print $cgi->end_html; @@ -445,20 +449,20 @@ 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", + 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; @@ -481,4 +485,6 @@ sub getTheme{ } + + ### CGI END diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index d873a9d..a9011b8 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -30,7 +30,7 @@ our $PRC_WIDTH = '60'; our $LOG_PATH = '../../dbLifeLog/'; our $SESSN_EXPR = '+30m'; our $DATE_UNI = '0'; -our $RELEASE_VER = '1.5'; +our $RELEASE_VER = '1.6'; our $AUTHORITY = ''; our $IMG_W_H = '210x120'; our $AUTO_WRD_LMT = 1000; @@ -321,7 +321,7 @@ qq(
); $ct + ); diff --git a/htdocs/cgi-bin/remove.cgi b/htdocs/cgi-bin/remove.cgi index a2c3fe1..a65593b 100755 --- a/htdocs/cgi-bin/remove.cgi +++ b/htdocs/cgi-bin/remove.cgi @@ -264,16 +264,19 @@ sub getConfigurationForRemove{ sub getTheme{ - if ( $THEME eq 'Sun' ) { - $BGCOL = '#D4AF37'; - $TH_CSS = "main_sun.css"; - }elsif ($THEME eq 'Moon'){ - $TH_CSS = "main_moon.css"; - $BGCOL = '#000000'; - - }elsif ($THEME eq 'Earth'){ - $TH_CSS = "main_earth.css"; - $BGCOL = 'green'; - } +if ( $THEME eq 'Sun' ) { + $BGCOL = '#D4AF37'; + $TH_CSS = "main_sun.css"; +} +elsif ( $THEME eq 'Moon' ) { + $TH_CSS = "main_moon.css"; + $BGCOL = '#000000'; +} +elsif ( $THEME eq 'Earth' ) { + $TH_CSS = "main_earth.css"; + $BGCOL = 'green'; +} + + } \ No newline at end of file diff --git a/htdocs/cgi-bin/wsrc/main.js b/htdocs/cgi-bin/wsrc/main.js index 893bfc9..dea3a6d 100644 --- a/htdocs/cgi-bin/wsrc/main.js +++ b/htdocs/cgi-bin/wsrc/main.js @@ -162,7 +162,7 @@ function loadedBody(toggle) { else if(data.item.value == 0 && (evv == 35||evv==32)){sel = 1; } if(sel){ ec.val(sel); - ec.selectmenu("refresh"); + // ec.selectmenu("refresh"); } } }}); @@ -288,11 +288,12 @@ function decodeToText(txt) { function edit(row) { var ed_v = $("#y" + row); //date - var et_v = $("#t" + row); //time + var et_v = $("#t" + row); //time var ea_v = $("#a" + row); //amount - var tag = $("#g" + row); //orig. tagged log text. - var log = $("#v" + row); //log - var rtf = $("#r" + row); //RTF doc + var tag = $("#g" + row); //orig. tagged log text. + var log = $("#v" + row); //log + var rtf = $("#r" + row); //RTF doc + var amf = $("#f" + row); //Amount type. var isRTF = (rtf.val()>0?true:false); if(!isRTF){ $('#rtf_doc').hide(); @@ -305,10 +306,10 @@ function edit(row) { if (tag.length) { $("#el").val(decodeToHTMLText(tag.val())); - } else { + } else { $("#el").val(decodeToText(log.text())); - } - + } + $("#ed").val(ed_v.val() + " " + et_v.html()); //Time field var val = ea_v.html(); val = val.replace(/\,/g,""); @@ -323,6 +324,13 @@ function edit(row) { var ec_v = $("#c" + row).text(); $("#ec option:contains(" + ec_v + ")").prop('selected', true); $("#submit_is_edit").val(row); + + + ec_v = amf.val(); + $("#amf").focus(); + $("#amf").val(ec_v); + $("#amf").selectmenu('refresh'); + $("#el").focus(); return false; @@ -584,13 +592,15 @@ function sumSelected() { var sum = 0; for (var i = 0, n = chks.length; i < n; i++) { if (chks[i].checked) { - var par = chks[i].parentNode.parentNode.childNodes; - for (var j = 0, nn = par.length; j < nn; j++) { - var el = par[j]; - if (el.id && el.id.indexOf('a', 0) == 0) { - sum = sum + Number(el.innerHTML); - break; - } + var id = chks[i].value; + var am = $("#a"+id).text(); + var ty = $("#c"+id).text(); + am = am.replace(/\,/g,"");//rem formatting + if(ty=='Expense'){ + sum = sum - Number(am); + } + else{ + sum = sum + Number(am); } } } @@ -713,7 +723,7 @@ function loadRTFResult(content, result, prms, quill) { -function editorBackground(reset){ +function editorBackground(reset){ var css = $("#editor-container").prop('style'); if(reset){ css.backgroundColor = DEF_BACKGROUND; diff --git a/htdocs/cgi-bin/wsrc/tip-yellowsimple/tip-yellowsimple.css b/htdocs/cgi-bin/wsrc/tip-yellowsimple/tip-yellowsimple.css index 9d7931b..f800f2b 100644 --- a/htdocs/cgi-bin/wsrc/tip-yellowsimple/tip-yellowsimple.css +++ b/htdocs/cgi-bin/wsrc/tip-yellowsimple/tip-yellowsimple.css @@ -19,6 +19,7 @@ } .tip-yellowsimple .tip-inner { font:12px/16px arial,helvetica,sans-serif; + color:#000; } /* Configure an arrow image - the script will automatically position it on the correct side of the tip */ @@ -29,6 +30,7 @@ left:50%; width:9px; height:6px; + color:#000; background:url(tip-yellowsimple_arrows.gif) no-repeat; } .tip-yellowsimple .tip-arrow-right { @@ -38,6 +40,7 @@ left:100%; width:6px; height:9px; + color:#000; background:url(tip-yellowsimple_arrows.gif) no-repeat -9px 0; } .tip-yellowsimple .tip-arrow-bottom { @@ -47,6 +50,7 @@ left:50%; width:9px; height:6px; + color:#000; background:url(tip-yellowsimple_arrows.gif) no-repeat -18px 0; } .tip-yellowsimple .tip-arrow-left { @@ -56,5 +60,6 @@ left:0; width:6px; height:9px; + color:#000; background:url(tip-yellowsimple_arrows.gif) no-repeat -27px 0; } \ No newline at end of file -- 2.34.1