]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Stable SUN release v.2.1 locally tested.
authorWill Budicm <redacted>
Tue, 22 Dec 2020 02:31:16 +0000 (13:31 +1100)
committerWill Budicm <redacted>
Tue, 22 Dec 2020 02:31:16 +0000 (13:31 +1100)
Current Development Check List.md
htdocs/cgi-bin/config.cgi
htdocs/cgi-bin/main.cgi
htdocs/cgi-bin/system/modules/Settings.pm
htdocs/cgi-bin/wsrc/main.js

index d6d095efc41ba3ac7d643f6f4d3a794923a6d8f1..586d5962367d63a60e01651874cd0bef08af1df3 100644 (file)
@@ -1,11 +1,15 @@
 # Branch Development Life Log in Perl
 
-*This page lists current development and issues being worked on in the LifeLog app. Being in the **Sun** stage, means there is a production environment. And usable, and in use. When, the project reaches **Earth** stage. It will be at its final specification. No data structures or major new features can be added or requested anymore. Only bug fixes, enhancements and efficiency fixes, if any at the **Earth** stage.*
+*This page lists current development and issues being worked on in the LifeLog app.*
 
 ## Life Log Development
 
 ### v.2.1 SUN STABLE New Features in Works
 
+*It has been 2 years, 4 months, 8 hours, 56 minutes, and 55 seconds
+between 2018-08-22 04:13:55 **Moon Stable** production release and this
+2020-12-22 13:10:50 **Sun Stable v.2.1**, next and final is the Earth release stage.*
+
 * &#10004; Config. page set session expires times has to be validated not to be under 2 minutes.
 * &#10004; Implement mapped provision of named timezones via main.inf, for cities not available in global zone list.
   * Javascript also needs to be updated to translate this properly.
index a7eeba13a72245885addae5f492be2fab4f40fb8..263ea42faed08da2fe534936b1afbc86726dd935 100755 (executable)
@@ -40,11 +40,12 @@ my $csvp    = $cgi->param('csv');
 
 exportToCSV() if ($csvp);
 
-if($cgi->param('bck'))        {&backup;}
-elsif($cgi->param('bck_del')) {&backupDelete;}
+if($cgi->param('bck'))        {&backup}
+elsif($cgi->param('bck_del')) {&backupDelete}
 elsif($cgi->param('data_bck')){&restore;}
-elsif($cgi->param('data_cat')){&importCatCSV;}
-elsif($cgi->param('data_log')){&importLogCSV;}
+elsif($cgi->param('bck_file')){restore($cgi->param('bck_file'))}
+elsif($cgi->param('data_cat')){&importCatCSV}
+elsif($cgi->param('data_log')){&importLogCSV}
 
 
 
@@ -356,17 +357,20 @@ next if $file eq '.' or $file eq '..' or index ($file , 'bck_') == -1;
 close $dir;
 foreach $file (sort @backups){
     #my $n = substr $file, length(&Settings::logPath);
-    $bck_list .=  "<input name='bck_file' type='radio' value='$file'>$file</input><br>";
+    $bck_list .=  "<input name='bck_file' type='radio' value='$file' onclick='setBackupFile(this);'>$file</input><br>";
 }
 if(length $bck_list == 0){
-$bck_list = '<p>Restore will bring back and merge log entries from the time of backup.</p>';
+$bck_list = '<p>Restore will bring back and merge log entries from the time of backup.</p>
+                        <input type="submit" name="Submit" value="Submit"/></td>
+                </tr>';
 }
 else{
-    $bck_list = qq(<p>Tick Select Backup to Restore or Delete</p><p>$bck_list</p>);
+    $bck_list = qq(<p>Tick Select Backup to Restore or Delete</p><p>$bck_list</p>
+    <input type="submit" onclick="deleteBackup();return false;" value="Delete"/>&nbsp;&nbsp;<input type="Submit" value="Restore"/></form>);
 }
 
-my $inpRestore = qq(<input type="button" onclick="return deleteBackup();" value="Delete"/>
-<input type="file" name="data_bck" />&nbsp;&nbsp;<input type="Submit" onclick="return true;restoreBackup();" value="Restore"/>);
+my $inpRestore = qq(<b>Local File:</b>&nbsp;&nbsp;
+<input type="file" name="data_bck" />&nbsp;&nbsp;<input type="Submit" value="Restore"/>);
 my $inpCVS = qq(<input type="button" onclick="return exportToCSV('log',0);" value="Export"/>&nbsp;
 <input type="button" onclick="return exportToCSV('log',1);" value="View"/>);
 if((Settings::anon("backup_enabled") == 0)){
@@ -388,12 +392,14 @@ print qq(
     </div>
     <br>
     <div id="rz" style="text-align:left; width:640px; padding:10px; background-color:).&Settings::bgcol.qq(">
-            <form id="bck" action="config.cgi" method="post" enctype="multipart/form-data">
+            <form id="bck" action="config.cgi" method="post">
             <table border="0" width="100%">
                 <tr><td><a name="backup"></a><H3>Backup File Format</H3></td></tr>
                 <tr><td><input type="button" onclick="return fetchBackup();" value="Fetch"/><hr></td></tr>
 
                 <tr><td><div id="div_backups">$bck_list</div><hr></td></tr>
+
+                <form id="bck_file" action="config.cgi" method="post" enctype="multipart/form-data">
                 <tr><td>
                 $inpRestore
                 <hr></td></tr>
@@ -405,8 +411,8 @@ print qq(
                 <tr style="border-left: 1px solid black;"><td style="text-align:right;">
                         <input type="submit" name="Submit" value="Submit"/></td>
                 </tr>
-
                 </form>
+
                 <form action="config.cgi" method="post" enctype="multipart/form-data">
                 <tr><td><b>Export Categories:</b>
                        <input type="button" onclick="return exportToCSV('cat',0);" value="Export"/>&nbsp;
@@ -1039,21 +1045,30 @@ sub backup {
 
 
 sub restore {
-
-    my $hndl = $cgi->upload("data_bck");
-    my ($pipe,@br);
+    my $file = shift;
+    my ($tar,$pipe,@br);
     my $pass = Settings::pass();
+    my $hndl = $cgi->param('data_bck');
+    my $dbck = &Settings::logPath."bck/"; `mkdir $dbck` if (!-d $dbck);
     try{
-
         getHeader();
         print $cgi->start_html;
-        print "<pre>Reading->$hndl</pre>";
-        my $dbck = &Settings::logPath."bck/"; `mkdir $dbck` if (!-d $dbck);
-        my $tar = $dbck.$hndl; $tar =~ s/osz$/tar/;
+        if($file){ #Open handle on server to backup to be restored.
+            my $f = &Settings::logPath.$file;
+            open($hndl, '<', $f) or die "Can't open $f: $!";            
+            print "<pre>Reading on server -> $file</pre>";
+            $tar = $dbck.$file;
+        }        
+        else{
+            print "<pre>Reading-> $hndl</pre>";
+            $tar = $dbck.$hndl;
+        }
+
+        $tar =~ s/osz$/tar/;
         my $pipe;
         open ($pipe, "| openssl enc -d -des-ede3-cfb -salt -S ".Settings->CIPHER_KEY." -pass pass:$pass-$alias -in /dev/stdin 2>/dev/null > $tar");
             while(<$hndl>){print $pipe $_;};
-        close $pipe;
+        close $pipe; close $hndl;
 
         print "<pre>\n";
         my $m1 = "it is not permitted to restore another aliases log backup.";
@@ -1073,17 +1088,16 @@ sub restore {
 
         print "Merging from backup categories table...\n";
         my $insCAT   = $db->prepare('INSERT INTO CAT (ID, NAME, DESCRIPTION) VALUES(?,?,?);') or die "Failed CAT prepare.";
-
         my $b_pst = Settings::selectRecords($b_db,'SELECT ID, NAME, DESCRIPTION FROM CAT;');
         while ( @br = $b_pst->fetchrow_array() ) {
-            my $pst = Settings::selectRecords($db, "SELECT ID,NAME,DESCRIPTION FROM CAT WHERE ID='".$br[0]."';");
+            my $pst = Settings::selectRecords($db, "SELECT ID,NAME,DESCRIPTION FROM CAT WHERE ID=".$br[0].";");
             my @ext = $pst->fetchrow_array();
             if(scalar(@ext)==0){
                 $insCAT->execute($br[0],$br[1],$br[2]);
                 print "Added CAT->".$br[0]."|".$br[1]."\n";
             }
             elsif($br[0] ne $ext[0] or $br[1] ne $ext[1]){
-                $db->do("UPDATE CAT SET NAME='".$br[1]."', DESCRIPTION='".$br[2]."' WHERE ID=?;") or die "Cat update failed!";
+                $db->do("UPDATE CAT SET NAME='".$br[1]."', DESCRIPTION='".$br[2]."' WHERE ID=$br[0];") or die "Cat update failed!";
                 print "Updated->".$br[0]."|".$br[1]."|".$br[2]."\n";
             }
 
@@ -1126,7 +1140,7 @@ sub restore {
     }
     catch{
         $ERROR = "<font color='red'><b>Restore Failed!</b></font>hndl->$hndl $@ \n";
-        $ERROR = "br:[@br]" if(@br);
+        $ERROR .= "br:[@br]" if(@br);
     };
 
     my $back = $cgi->url( -relative => 1 );
index 1fad135630b12a337b893aef8bac586a399c5ce4..cbf923281aeb77534254df27c980489094e84ee9 100755 (executable)
@@ -775,7 +775,7 @@ $log_output .= qq(<form id="frm_srch" action="main.cgi"><TABLE class="tbl" borde
     </td></tr>
        <tr class="collpsd">
        <td style="text-align:right; vertical-align:top; width:10%;">Date:</td>
-       <td id="al" colspan="1" style="text-align:top; vertical-align:top"><input id="ed" type="text" name="date" size="18" value=")
+       <td id="al" colspan="2" style="text-align:top; vertical-align:top"><input id="ed" type="text" name="date" size="18" value=")
       . $today->ymd . " " . $today->hms . qq(">
 
        &nbsp;<button type="button" onclick="return setNow();">Now</button>
@@ -784,17 +784,16 @@ $log_output .= qq(<form id="frm_srch" action="main.cgi"><TABLE class="tbl" borde
 
                 <span id="cat_desc" name="cat_desc">Enter log...</span>
 
-            </td>
-                       <td style="text-align:top; vertical-align:top">Category:&nbsp;
             
-                <button data-dropdown="#dropdown-standard">
+                       &nbsp;&nbsp;&nbsp;Category:&nbsp;
+            
+                <button data-dropdown="#dropdown-standard" style="margin: 0px; padding: 0;">
                 <span id="lcat" class="ui-button">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i><font size=1>--Select --</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</i></span>                
-               &nbsp; &#171;</button>
+               &nbsp; &#171; &nbsp;</button>
 
             <div class="dropdown-menu dropdown-anchor-top-right dropdown-has-anchor" id="dropdown-standard">
                         <table class="tbl">$td_cat</table>
             </div>
-<!-- OLD -> \$cats was here -->
                        </td>
        </tr>
        <tr class="collpsd"><td style="text-align:right; vertical-align:top">Log:</td>
@@ -885,7 +884,7 @@ $log_output .= qq(<form id="frm_srch" action="main.cgi"><TABLE class="tbl" borde
     $srh .=
     qq(
     <tr class="collpsd">
-     <td align="right">View by Category:</td>
+     <td align="right" style="width:20%">View by Category:</td>
      <td align="left">
             <span id="lcat_v" class="ui-button">$catselected</span>
             <button class="bordered" data-dropdown="#dropdown-standard-v">&#171;</button>
@@ -1020,7 +1019,7 @@ $tail
 <script type="text/javascript">
         var AUTOWORDS = [$autowords];
 </script>
-<audio id="au_door_chime"   preload="true
+<audio id="au_door_chime"   preload="auto
     src="wsrc/Store_Door_Chime-Mike_Koenig-570742973.mp3">
         Your browser does not support the
         <code>audio</code> element.
index c3c137b3d8b7df97dce5b7a489f55909c4fdade5..2838d0de00751defd5fc61685dce600472ddc189 100644 (file)
@@ -254,8 +254,8 @@ if($IS_PG_DB){
             ID_RTF INTEGER    DEFAULT 0,
             DATE TIMESTAMP    NOT NULL,
             LOG VARCHAR ($DBI_LVAR_SZ) NOT NULL,
-            AMOUNT INTEGER,
-            AFLAG INT         DEFAULT 0,
+            AMOUNT money,
+            AFLAG  INT         DEFAULT 0,
             STICKY BOOL       DEFAULT FALSE,
             PRIMARY KEY(ID)
         );)} 
@@ -266,8 +266,8 @@ if($IS_PG_DB){
         ID_RTF INTEGER    DEFAULT 0,
         DATE DATETIME     NOT NULL,
         LOG VARCHAR ($DBI_LVAR_SZ) NOT NULL,
-        AMOUNT INTEGER,
-        AFLAG INT         DEFAULT 0,
+        AMOUNT DOUBLE,
+        AFLAG  INT         DEFAULT 0,
         STICKY BOOL       DEFAULT 0
     );
 )}
@@ -352,7 +352,7 @@ sub getConfiguration {
                 when ("RELEASE_VER") {$RELEASE_VER  = $r[2]}
                 when ("TIME_ZONE")   {$TIME_ZONE    = $r[2]}
                 when ("PRC_WIDTH")   {$PRC_WIDTH    = $r[2]}
-                when ("SESSN_EXPR")  {$SESSN_EXPR   = $r[2]}
+                when ("SESSN_EXPR")  {$SESSN_EXPR   = timeFormatValue($r[2])}
                 when ("DATE_UNI")    {$DATE_UNI     = $r[2]}
                 when ("LANGUAGE")    {$LANGUAGE     = $r[2]}
                 when ("LOG_PATH")    {} # Ommited and code static can't change for now.
@@ -416,6 +416,13 @@ sub getConfiguration {
     };
 }
 
+sub timeFormatValue {
+    my $v = shift;
+    if(!$v || $v==0){$v="+2m"}
+    if($v !~ /^\+/){$v='+'.$v.'m'}
+    return $v;
+}
+
 sub getTheme {
     given ($THEME){
         when ("Sun")   { $BGCOL = '#D4AF37'; $TH_CSS = "main_sun.css"; }
index 3ecda5a439b64f8ea1f7eb3418d1e0b439782e89..64e767d0963883d3506228c36bf831340cb71487 100644 (file)
@@ -1151,49 +1151,48 @@ function deleteBackup() {
 
 function setPageSessionTimer(expires) {
 
-            var timeout;
+    var timeout;
+    var now = new moment();
+    var val = expires.replace(/\+|[A-Z]|[a-z]/g, '');
+    
+    if(expires.indexOf("h")>0){
+        timeout = moment(now).add(val, "h");
+    }
+    else
+    if(expires.indexOf("m")>0){
+        if(val<2){val=2};
+        timeout = moment(now).add(val, "m");
+    }
+    else
+    if(expires.indexOf("s")>0){
+        if(val<60){val=2}; 
+        timeout = moment(now).add(val, "s");
+    }
+    else{
+        if(val<2){val=2};
+        timeout = moment(now).add(val, "m");
+    }
+    var WARNED =0;
+    var timer   =  setInterval(function() {
             var now = new moment();
-            var val = expires.replace(/\+|[A-Z]|[a-z]/g, '');
-            
-            if(expires.indexOf("h")>0){
-                timeout = moment(now).add(val, "h");
+            var dif = timeout.diff(now);
+            var min = Math.floor(dif / 60000);
+            var sec = ((dif % 60000) / 1000).toFixed(0);
+            var out = (min < 10 ? '0' : '') + min + ":" + (sec < 10 ? '0' : '') + sec;
+            var tim = new moment().tz(TIMEZONE).format("hh:mm:ss a");
+            var sty = "";if(min<2){sty="style='color:red'";
+            if(!WARNED){WARNED=1;$('#au_door_chime').trigger('play');display("<font color='red'>Session is about to expire!</font>",10);}}
+            var dsp = "<font size='1px;'>[" + tim + "]</font><span "+sty+"> Session expires in " + out + "</span>";                
+            $("#sss_status").html(dsp);
+            if(now.isAfter(timeout)){
+                $("#sss_status").html("<span id='sss_expired'><a href='login_ctr.cgi'>Page Session has Expired!</a></span>");
+                clearInterval(timer);
+                $("#ed").prop( "disabled", true );
+                $("#el").prop( "disabled", true );
+                $("#am").prop( "disabled", true );
             }
-            else
-            if(expires.indexOf("m")>0){
-                if(val<2){val=2};
-                timeout = moment(now).add(val, "m");
-            }
-            else
-            if(expires.indexOf("s")>0){
-               if(val<60){val=2}; 
-               timeout = moment(now).add(val, "s");
-            }
-            else{
-                if(val<2){val=2};
-                timeout = moment(now).add(val, "m");
-            }
-            var WARNED =0;
-               var timer   =  setInterval(function() {
-                var now = new moment();
-                var dif = timeout.diff(now);
-                var min = Math.floor(dif / 60000);
-                var sec = ((dif % 60000) / 1000).toFixed(0);
-                var out = (min < 10 ? '0' : '') + min + ":" + (sec < 10 ? '0' : '') + sec;
-                var tim = new moment().tz(TIMEZONE).format("hh:mm:ss a");
-                var sty = "";if(min<2){sty="style='color:red'";
-                if(!WARNED){WARNED=1;$('#au_door_chime').trigger('play');display("<font color='red'>Session is about to expire!</font>",10);}}
-                var dsp = "<font size='1px;'>[" + tim + "]</font><span "+sty+"> Session expires in " + out + "</span>";                
-                $("#sss_status").html(dsp);
-                if(now.isAfter(timeout)){
-                    $("#sss_status").html("<span id='sss_expired'><a href='login_ctr.cgi'>Page Session has Expired!</a></span>");
-                    clearInterval(timer);
-                    $("#ed").prop( "disabled", true );
-                    $("#el").prop( "disabled", true );
-                    $("#am").prop( "disabled", true );
-                }
-
-                                        }, 1000);
 
+        }, 1000);
        }
 
  function  checkConfigCatsChange(){
@@ -1223,3 +1222,4 @@ function setPageSessionTimer(expires) {
     });
 return false;
  }
+