]> lifelog.hopto.org Git - LifeLog.git/commitdiff
fix:amf not being set.
authorMetabox <redacted>
Tue, 27 Aug 2019 03:11:08 +0000 (13:11 +1000)
committerMetabox <redacted>
Tue, 27 Aug 2019 03:11:08 +0000 (13:11 +1000)
dbLifeLog/main.cnf
htdocs/cgi-bin/login_ctr.cgi
htdocs/cgi-bin/main.cgi
htdocs/cgi-bin/remove.cgi
htdocs/cgi-bin/wsrc/main.js
htdocs/cgi-bin/wsrc/tip-yellowsimple/tip-yellowsimple.css

index 6563f7cde5170b00f10531026210670020091d1c..3f66822d1aa00c42478bbf71ccd314d1aa7a8c90 100644 (file)
@@ -75,3 +75,5 @@ UPDATE LOG SET AFLAG=1 WHERE ID_CAT=%INCOME_ID%;
 UPDATE LOG SET AFLAG=2 WHERE ID_CAT=%EXPENSE_ID%;
 
 
+
+
index d7cc7b56d7c85d3176626269bfa4acfac557db66..ca1021a49d66757642fa711d3a5121e2801b0b38 100755 (executable)
@@ -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(
      <form id="frm_login" action="login_ctr.cgi" method="post"><table border="0" width="$PRC_WIDTH%">
       <tr class="r0">
          <td colspan="3"><center>LOGIN</center></td>
@@ -77,18 +80,19 @@ if(&processSubmit==0){
         </tr>
         <tr class="r1">
          <td colspan="3" style="border-left:1px solid black; border-right:1px solid black;"><font color="red">NOTICE!</font> &nbsp;
-         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.
          <input type="hidden" name="CGISESSID" value="$sid"/>
          <input type="hidden" name="login" value="1"/></td></tr>
       <tr class="r0"><td colspan="2"></td><td><input type="submit" value="Login"/></td></tr>
     </table></form>);
 
-        print qq(<br><br><div id=rz>
+print qq(<br><br><div id=rz>
                         <center>
                             <h2>Welcome to Life Log</h2><div>$frm</div><br/>
                             <a href="https://github.com/wbudic/LifeLog" target="_blank">Get latest version of this application here!</a><br>
                         </center><div>);
-        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 "<font color=red><b>SERVER ERROR</b></font> 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, "<<AUTO_LOGIN<", 0)==0){
@@ -139,23 +143,23 @@ try{
                     }
         }
     close $fh;
-        if(@cre &&scalar(@cre)>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 "<p>Error->"& $DBI::errstri &"</p>";
-                    #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 "<font color=red><b>SERVER ERROR</b></font>:".$_;
       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 "<p>Error->"& $DBI::errstri &"</p>";
     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 "<p>Error->"& $DBI::errstri &"</p>";}
-        
+
         $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 "<p>Error->"& $DBI::errstri &"</p>"};
     }
@@ -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 "<font color=red><b>SERVER ERROR</b></font>:".$_;
     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 =~ /<MIG<>/);
                     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 "<font color=red><b>SERVER ERROR!</b></font><br> ".$_."<br><pre>$err</pre>";
       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(<font color="white"><center><h2>You have properly loged out of the Life Log Application!</h2>
     <br>
     <form action="login_ctr.cgi"><input type="submit" value="No, no, NO! Log me In Again."/></form><br>
     </br>
-    <iframe width="60%" height="600px" src="https://www.youtube.com/embed/qTFojoffE78?autoplay=1" 
-      frameborder="0" 
+    <iframe width="60%" height="600px" src="https://www.youtube.com/embed/qTFojoffE78?autoplay=1"
+      frameborder="0"
         allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
     </iframe>
     </center></font>
-    ); 
+    );
 
     print $cgi->end_html;
     exit;
@@ -481,4 +485,6 @@ sub getTheme{
 
 }
 
+
+
 ### CGI END
index d873a9d6265de0fa9517d1ade48c3507e92839fc..a9011b8e4cd56309589dded8eb17484cbce65c4a 100755 (executable)
@@ -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(<form id="frm_log" action="remove.cgi" onSubmit="return formDelValidation();"
         if ( $af == 1 ) { #AFLAG Income
             $sum += $am;
         }
-        elsif ( $af == 2 ) {            
+        elsif ( $af == 2 ) {
             $exp -= $am;
         }
         else{
@@ -536,6 +536,7 @@ qq(\n<img src="$lnk" width="$imgw" height="$imgh" class="tag_FRM"/>);
                <td id="c$id" width="10%" class="tbl">$ct</td>
                <td width="20%">
         <input id="r$id" type="hidden" value="$rtf"/>
+        <input id="f$id" type="hidden" value="$af"/>
                        <button class="edit" value="Edit" onclick="return edit($id);">Edit</button>
                        <input name="chk" type="checkbox" value="$id"/>
                </td></tr>);
index a2c3fe1f174da16523bc523c13081eb202fdac7c..a65593b9f420b64b9c09b97c7b3a1f975c8daab8 100755 (executable)
@@ -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
index 893bfc919d58171a5874913aba802e8b99870c4b..dea3a6d69b9122f4773a5d2162796ca3f277526c 100644 (file)
@@ -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;
index 9d7931b5ed93c9536260a7e6bf25c87eca4501d6..f800f2b202d3123b927232e42f8b2c0a19703e86 100644 (file)
@@ -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