]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Started work on updated of config file. Done page layout fixes.
authorwbudic <redacted>
Tue, 17 Aug 2021 08:21:16 +0000 (18:21 +1000)
committerwbudic <redacted>
Tue, 17 Aug 2021 08:21:16 +0000 (18:21 +1000)
htdocs/cgi-bin/config.cgi
htdocs/cgi-bin/login_ctr.cgi
htdocs/cgi-bin/main.cgi
htdocs/cgi-bin/stats.cgi
htdocs/cgi-bin/system/modules/Settings.pm
htdocs/cgi-bin/wsrc/main.js

index f07206cedc7dd140443dc4341c6b11fa44647a0b..e7610c61a6131ffadb56f085997683b53dec2e18 100755 (executable)
@@ -61,7 +61,7 @@ cats();
 ###############
 processSubmit();
 ###############
-Settings::getTheme();
+Settings::setupTheme();
 Settings::session()->param("theme", Settings::css());
 Settings::session()->param("bgcolor", Settings::bgcol());
 getHeader();
@@ -116,7 +116,7 @@ my $frmCats = qq(
          <td colspan="1" align="right"><b>Categories Configuration In -> $dbname</b>&nbsp;
          <input type="submit" value="Change" onclick="return checkConfigCatsChange()"/></td>
         </tr>
-        <tr class="r1">
+        <tr class="r2">
           <td colspan="3"><div style="text-align:left; float"><font color="red">WARNING!</font>
            Removing or changing categories is permanent! Each category one must have an unique ID.
              Blank a category name to remove it. LOG records will change to the
@@ -160,9 +160,9 @@ while(my @row = $dbs->fetchrow_array()) {
                  $u = "SELECTED"
                 }
         $v = qq(<select id="dumi" name="var$i">
-                         <option value="0" $l>Locale</option>
-                                 <option value="1" $u>Universal</option>
-                                </select>);
+                    <option value="0" $l>Locale</option>
+                    <option value="1" $u>Universal</option>
+                </select>);
          }
          elsif($n eq "AUTO_LOGIN"){
               my($l,$u)=("","");
@@ -241,20 +241,7 @@ while(my @row = $dbs->fetchrow_array()) {
                    <option$s2>Moon</option>
                    <option$s3>Earth</option>
                 </select>);
-        }
-        elsif($n eq "KEEP_EXCS" or $n eq 'TRACK_LOGINS' or $n eq 'DEBUG'){
-            my($l,$u)=("","");
-            if($v == 0){
-               $l = "SELECTED"
-            }
-            else{
-               $u = "SELECTED"
-            }
-            $v = qq(<select id="onoff" name="var$i">
-                   <option value="0" $l>Off</option>
-                   <option value="1" $u>On</option>
-                </select>);
-        }
+        }        
         elsif($n eq "RELEASE_VER"){
             $REL = qq(<td>$n</td>
                       <td>$v</td>
@@ -287,15 +274,32 @@ while(my @row = $dbs->fetchrow_array()) {
                     <option value="1" $u>True</option>
                     </select>);
         }
-        elsif(!defined(Settings::anon($n))){ #change into settable field to us found here unknown and not anon.
+        elsif($n eq "KEEP_EXCS" or 
+              $n eq 'TRACK_LOGINS' or 
+              $n eq 'DEBUG' or 
+              $n eq 'TRANSPARENCY' or 
+              $n eq 'AUTO_LOGOFF'){
+            my($l,$u)=("","");
+            if($v == 0){
+               $l = "SELECTED"
+            }
+            else{
+               $u = "SELECTED"
+            }
+            $v = qq(<select id="onoff" name="var$i">
+                    <option value="0" $l>Off</option>
+                    <option value="1" $u>On</option>
+                    </select>);
+        }
+        elsif($n eq 'SUBPAGEDIR' or 
+              !defined(Settings::anon($n))){ #change into settable field to us found here unknown and not anon.<td colspan="3"
             $v = '<input name="var'.$i.'" type="text" value="'.$v.'" size="12">';
         }
-
-       my $tr = qq(<tr class="r0" align="left">
-            <td>$n</td>
-            <td>$v</td>
-            <td>$d</td>
-        </tr>);
+        my $tr = qq(<tr class="r0" align="left">
+                        <td>$n</td>
+                        <td>$v</td>
+                        <td>$d</td>
+                   </tr>);
 
         if($i<300){$tbl.=$tr}else{$foot.=$tr}
 }
@@ -305,9 +309,13 @@ $tbl = qq($tbl$foot<tr class="r1" align="left">$REL</tr>); #RELEASE VERSION we m
 my  $frmVars = qq(
      <form id="frm_vars" action="config.cgi">$tbl
       <tr class="r1">
-         <td colspan="3" align=right><b>System Settings In -> $dbname</b>&nbsp;<input type="submit" value="Change"/></td>
-        </tr>
-        </table><input type="hidden" name="sys" value="1"/></form><br>);
+         <td colspan="3" align="right"><b>System Settings In -> $dbname</b>&nbsp;<input type="submit" value="Change"/></td>
+      </tr>
+      <tr class="r2">
+         <td colspan="3" align="right">Note - Use <a href="#dbsets">DB Fix</a> to reset this system settings to factory defaults.</td>
+      </tr>
+      </tr>
+    </table><input type="hidden" name="sys" value="1"/></form><br>);
 
 $tbl = qq(<table id="cnf_fix" class="tbl" border="0" width=").&Settings::pagePrcWidth.qq(%">
               <tr class="r0"><td colspan="2"><b>* DATA FIX *</b></td></tr>
@@ -316,9 +324,9 @@ $tbl = qq(<table id="cnf_fix" class="tbl" border="0" width=").&Settings::pagePrc
 my  $frmDB = qq(
      <form id="frm_DB" action="config.cgi">$tbl
         <tr class="r1" align="left"><th>Extra Action</th><th>Description</th></tr>
-        <tr class="r0" align="left"><td><input type="checkbox" name="reset_cats"/>Reset Categories</td><td>Resets Categories to factory values (will initiate logoff).</td></tr>
-        <tr class="r1" align="left"><td><input type="checkbox" name="reset_syst"/>Reset Settings</td><td>Resets system settings to default values.</td></tr>
-        <tr class="r0" align="left"><td><input type="checkbox" name="wipe_syst"/>Wipe Settings</td><td>Resets and wipes system settings for migration  (will initiate logoff).</td></tr>
+        <tr class="r0" align="left"><td><input type="checkbox" name="reset_syst"/>Reset Settings</td><td>Resets system settings to default values.</td></tr>
+        <tr class="r1" align="left"><td><input type="checkbox" name="wipe_syst"/>Wipe Settings</td><td>Wipes system settings to be forced from the config file (will initiate logoff).</td></tr>
+        <tr class="r0" align="left"><td><input type="checkbox" name="reset_cats"/>Reset Categories</td><td>Resets Categories to factory values (will initiate logoff).</td></tr>        
         <tr class="r1" align="left"><td><input type="checkbox" name="del_by_cats"/>Delete by Category <font color=red></font><br>
         $cats</td><td>Selects and displays by category logs to delete.</td></tr>
         <tr class="r0" align="left"><td><input type="checkbox" name="del_from"/>Delete from Date <br>
@@ -326,10 +334,13 @@ my  $frmDB = qq(
         <tr class="r1">
          <td colspan="2" align="right"><b>Data maintenance for -> $dbname</b>&nbsp;<input type="submit" value="Fix"/></td>
         </tr>
-        <tr class="r1" align="left">
+        <tr class="r2" align="left">
              <td colspan="2">Perform this change/check in the event of experiencing data problems. Or periodically for data check and maintenance. <br>
-                                 <font color="red">WARNING!</font> Checking any of the above extra actions will cause loss
-                                                  of your changes. Please, export/backup first.</td>
+             Use 'Reset Settings' option to revert to current stored configuration. Changes you made.<br>
+             Use the 'Wipe Settings' option if updating the application or need new defaults from main.cnf config file.<br>
+             Select both to reset and wipe, to overwrite all changes you made to config file settings.
+            <font color="red">WARNING!</font> Checking any of the above extra actions will cause loss
+                            of your changes. Please, export/backup first.</td>
         </tr>
         </table><input type="hidden" name="db_fix" value="1"/></form><br>
         );
@@ -344,6 +355,7 @@ my  $frmPASS = qq(
         <tr class="r1">
          <td colspan="2" align="right"><b>Pass change for -> $alias</b>&nbsp;<input type="submit" value="Change"/></td>
         </tr>
+        <tr class="r2"> <td colspan="2" align="right"><font color="red">WARNING!</font> Changing passwords will make past backups unusuable.</td></tr>
         </table><input type="hidden" name="pass_change" value="1"/></form><br>
         );
 $frmPASS = qq(<tr><td>Password changing has been dissabled!</td></tr>) if Settings::isProgressDB(); 
@@ -611,8 +623,8 @@ if($change > 1){
 
 
         if($cid==$caid || $cnm eq $canm){
-                        $valid = 0;
-                        last;
+           $valid = 0;
+           last;
         }
     }
 
@@ -778,6 +790,9 @@ try{
         getHeader() if(&Settings::debug);
         print "<h3>Database Records Fix Result</h3>\n<hr>" if &Settings::debug;
         print "<body><pre>Started transaction!\n" if &Settings::debug;
+        #Transaction work if driver is set properly!
+        my $p = Settings::pass(); 
+        $db = DBI->connect(Settings::dsn(), $alias, $p, {AutoCommit => 0, RaiseError => 1, PrintError => 0, show_trace=>1});
         $db->do('BEGIN TRANSACTION;');
         # Check for duplicates, which are possible during imports or migration as internal rowid is not primary in log.
         # @TODO This should be selecting an cross SQL compatibe view.
@@ -806,28 +821,32 @@ try{
             my $st_del = $db->prepare($sql);
             $st_del->execute();
         }
-        print "Doing renumerate next...\n" if &Settings::debug;
-        &renumerate;
-        print "done!\n" if &Settings::debug;
+        
+        &renumerate;        
         print "Doing removeOldSessions next..." if &Settings::debug;
         &Settings::removeOldSessions;
-        print "done!\n " if &Settings::debug;
+        print "done!\n" if &Settings::debug;
+        
         &resetCategories if $rs_cats;
         &resetSystemConfiguration($db) if $rs_syst;
         &wipeSystemConfiguration if $wipe_ss;
 
         $db->do('COMMIT;')if(&Settings::debug);
-        print "Commited ALL!<br>"if(&Settings::debug);
-       # $db->disconnect();
-        $db  = Settings::connectDB();
-        $dbs = $db->do("VACUUM;")if(&Settings::debug);
-        print "Issued  VACUUM!<br>"if(&Settings::debug);
+        print "Commited ALL!<br>"if(&Settings::debug);      
+        
+        if(&Settings::debug){
+            $db  = Settings::connectDB();
+            $dbs = $db->do("VACUUM;");
+            print "Issued  VACUUM!<br>"if(&Settings::debug);
+        }
         
         if($LOGOUT){
                 &logout;
         }
-
-        exit if(&Settings::debug);
+        if(&Settings::debug){
+            print "<hr><pre>You are in debug mode further actions are halted!</pre>";
+            exit;
+        }
 
 }
 catch{
@@ -840,7 +859,8 @@ sub renumerate {
 
     # NOTE: This is most likelly all performed under an transaction.
     my $sql; 
-    # Fetch list by date identified rtf attached logs, with possibly now an old LID, to be updated to new one.    
+    # Fetch list by date identified rtf attached logs, with possibly now an old LID, to be updated to new one.   
+    print "Doing renumerate next...\n" if &Settings::debug; 
     if(Settings::isProgressDB()){
         $sql = "SELECT ID, DATE FROM LOG WHERE RTF > 0;"
     }else{
@@ -905,24 +925,28 @@ sub renumerate {
                                         NOTES.LID = LOG.rowid WHERE LOG.rowid is NULL;");
     }
     if ($dbs) {  foreach (@row = $dbs->fetchrow_array()) {
-                $db->do("DELETE FROM NOTES WHERELID=$row[0];") if $row[0]; # 0 is the place keeper for the shared zero record
+                $db->do("DELETE FROM NOTES WHERE LID=$row[0];") if $row[0]; # 0 is the place keeper for the shared zero record, don't delete
     }}
-
+    print "done!\n" if &Settings::debug;
 }
 
 sub resetCategories {
+    print "Doing wipeCtegories next..." if &Settings::debug;
     $db->do("DELETE FROM CAT;");
     $db->do("DROP TABLE CAT;");
     $LOGOUT = 1;
+    print "done!\n" if &Settings::debug;
 }
 
 sub wipeSystemConfiguration {
+    print "Doing wipeSystemConfiguration next..." if &Settings::debug;
     $db->do("DELETE FROM CONFIG;");
     $db->do("DROP TABLE CONFIG;");
     $LOGOUT = 1;
+    print "done!\n" if &Settings::debug;
 }
 
-
+#@TODO Needs to be redone, use CNF 2.2
 sub resetSystemConfiguration {
 
         open(my $fh, '<', &Settings::logPath.'main.cnf') or die "Can't open ".&Settings::logPath."main.cnf! $!";
@@ -931,78 +955,81 @@ sub resetSystemConfiguration {
         my $inData = 0;
         my $err = "";
         my %vars = {};
-
+        print "Doing resetSystemConfiguration next..." if &Settings::debug;
 try{
         my $insert = $db->prepare('INSERT INTO CONFIG VALUES (?,?,?,?)');
         my $update = $db->prepare('UPDATE CONFIG SET VALUE=? WHERE ID=?;');
         my $updExs = $db->prepare('UPDATE CONFIG SET NAME=?, VALUE=? WHERE ID=?;');
         $dbs->finish();
-    while (my $line = <$fh>) {
-                    chomp $line;
-                    my @tick = split("`",$line);
-                    if(scalar(@tick)==2){
-                                    my %hsh = $tick[0] =~ m[(\S+)\s*=\s*(\S+)]g;
-                                    if(scalar(%hsh)==1){
-                                            for my $key (keys %hsh) {
-
-                                                    my %nash = $key =~ m[(\S+)\s*\|\$\s*(\S+)]g;
-                                                    if(scalar(%nash)==1){
-                                                            for my $id (keys %nash) {
-                                                                $name  = $nash{$id};
-                                                                $value = $hsh{$key};
-                                                                if($vars{$id}){
-                            $err .= "UID{$id} taken by $vars{$id}-> $line\n";
-                                                                }
-                                                                else{
-                                                                    $dbs = Settings::selectRecords($db,
-                                                                        "SELECT ID, NAME, VALUE, DESCRIPTION FROM CONFIG WHERE NAME LIKE '$name';");
-                                                                    $inData = 1;
-                                                                    my @row = $dbs->fetchrow_array();
-                                                                    if(scalar @row == 0){
-                                                                       #The id in config file has precedence to the one in the db,
-                                                                       #from a possible previous version.
-                                                                       $dbs = Settings::selectRecords($db, "SELECT ID FROM CONFIG WHERE ID = $id;");
-                                                                       @row = $dbs->fetchrow_array();
-                                                                       if(scalar @row == 0){
-                                                                            $insert->execute($id,$name,$value,$tick[1]);
-                                                                       }else{
-                                                                            #rename, revalue exsisting id
-                                                                            $updExs->execute($name,$value,$id);
-                                                                        }
-                                                                    }
-                                                                    else{
-                                                                            $update->execute($value,$id);
-                                                                    }
-                                                                }
-                                                            }
+        while (my $line = <$fh>) {
+            chomp $line;
+            my @tick = split("`",$line);
+            if(scalar(@tick)==2){
+                    my %hsh = $tick[0] =~ m[(\S+)\s*=\s*(\S+)]g;
+                    if(scalar(%hsh)==1){
+                            for my $key (keys %hsh) {
+
+                                    my %nash = $key =~ m[(\S+)\s*\|\$\s*(\S+)]g;
+                                    if(scalar(%nash)==1){
+                                            for my $id (keys %nash) {
+                                                $name  = $nash{$id};
+                                                $value = $hsh{$key};
+                                                if($vars{$id}){
+            $err .= "UID{$id} taken by $vars{$id}-> $line\n";
+                                                }
+                                                else{
+                                                    $dbs = Settings::selectRecords($db,
+                                                        "SELECT ID, NAME, VALUE, DESCRIPTION FROM CONFIG WHERE NAME LIKE '$name';");
+                                                    $inData = 1;
+                                                    my @row = $dbs->fetchrow_array();
+                                                    if(scalar @row == 0){
+                                                    #The id in config file has precedence to the one in the db,
+                                                    #from a possible previous version.
+                                                    $dbs = Settings::selectRecords($db, "SELECT ID FROM CONFIG WHERE ID = $id;");
+                                                    @row = $dbs->fetchrow_array();
+                                                    if(scalar @row == 0){
+                                                            $insert->execute($id,$name,$value,$tick[1]);
                                                     }else{
-                            $err .= "Invalid, spec'ed {uid}|{setting}`{description}-> $line\n";
+                                                            #rename, revalue exsisting id
+                                                            $updExs->execute($name,$value,$id);
+                                                        }
                                                     }
-
-                                            }#rof
-                                    }
-                                    else{
-                            $err .= "Invalid, speced entry -> $line\n";
+                                                    else{
+                                                            $update->execute($value,$id);
+                                                    }
+                                                }
+                                            }
+                                    }else{
+            $err .= "Invalid, spec'ed {uid}|{setting}`{description}-> $line\n";
                                     }
 
-                    }elsif($inData && length($line)>0){
-                    if(scalar(@tick)==1){
-                             $err .= "Corrupt Entry, no description supplied -> $line\n";
-                        }
-                        else{
-                           $err .= "Corrupt Entry -> $line\n";
-                        }
+                            }#rof
                     }
+                    else{
+            $err .= "Invalid, speced entry -> $line\n";
+                    }
+
+            }
+            elsif($line eq '>>'){last}
+            elsif($inData && length($line)>0){
+                if(scalar(@tick)==1){
+                        $err .= "Corrupt Entry, no description supplied -> $line\n";
+                }
+                else{
+                    $err .= "Corrupt Entry -> $line\n";
+                }
+            }
         }
-        die "Configuration script './main.cnf' [$fh] contains errors." if $err;
+        die "Configuration script ".&Settings::logPath."main.cnf' contains errors." if $err;
         close $fh;
         Settings::getConfiguration($db);
+        print "done!\n" if &Settings::debug;
  } catch{
       close $fh;
       print $cgi->header;
-        print "<font color=red><b>SERVER ERROR! [id:$id,name:$name,value:$value]/b></font><br> ".$_."<br><pre>$err</pre>";
-    print $cgi->end_html;
-        exit;
+        print "<font color=red><b>SERVER ERROR!</b></font>[id:$id,name:$name,value:$value]->$@<br> ".$_."<br><pre>$err</pre>";
+      print $cgi->end_html;
+      exit;
  }
 }
 
@@ -1015,17 +1042,24 @@ sub logout {
 
 sub changeSystemSettings {
     my $updated;
+    my $id_theme;
+try{    
+    $dbs = Settings::selectRecords($db, "SELECT ID FROM CONFIG WHERE NAME LIKE 'THEME';");    
+    while (my @r=$dbs->fetchrow_array()){$id_theme=$r[0]}    
     $dbs = Settings::selectRecords($db, "SELECT ID, NAME FROM CONFIG;");
     while (my @r=$dbs->fetchrow_array()){
         my $var = $cgi->param('var'.$r[0]);
         if(defined $var){
             Settings::configProperty($db, $r[0], undef, $var);
             $updated = 1;
+            Settings::saveCurrentTheme($var) if $r[0] == $id_theme;
         }
     }
     Settings::getConfiguration($db) if($updated);
+}catch{
+    die "\nException\@$0::changeSystemSettings() line ",__LINE__." failed ->\n $@"; #<- It is actually better to die than throw exception traces. Easier to find problem this way.
+}
 }
-
 
 sub backupDelete {
     my $n = $cgi->param('bck_del');
@@ -1502,14 +1536,17 @@ sub cats {
 
 sub error {
     my $url = $cgi->url(-path_info => 1);
-    print qq(<h2>Sorry Encountered Errors</h2><p>Page -> $url</p><p>$ERROR</p>);
-    print qq(<h3>CGI Parameters</h3>);
-    print "<ol>\n";
+    print qq(<div class="debug_output" style="font-size:large;"><div style="text-align: left; width:100%; overflow-x:wrap;">
+                <h2 style="color:tomato;">Sorry Encountered Errors</h2><p>Page -> $url</p><p>$ERROR</p>;
+                <h3>CGI Parameters</h3>
+    );
+    print "<ol>";
     foreach ($cgi->param){
         print '<li>'.$_.'=='. $cgi->param($_).'</li>';
     }
     print "</ol>\n";
-    print "<a href=$url>Return to -> $url</a>";
+    print "<div>Return to -> <a href=$url>$url</a></div><hr></div></div>";
+    
     print $cgi->end_html;
     $db->disconnect();
     exit;
index 65f8e2a07b336bc5d2b792e53b0fe697a3a7f60b..d1733f47be229ea34f04212815463eb056065364 100755 (executable)
@@ -36,24 +36,22 @@ my $VW_OVR_SYSLOGS=0;
 my $VW_OVR_WHERE="";
 my $LOGOUT_RELOGIN_TXT='No, no, NO! Log me In Again.';
 my $LOGOUT_IFRAME_ENABLED = 0;
-my $LOGOUT_IFRAME = qq|<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>
+my $LOGOUT_IFRAME = qq|
+    <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>|;
-
-try{
+try{    
     checkAutologinSet();
     logout() if($cgi->param('logout'));
-    if(processSubmit()==0){
-
+    if(processSubmit()==0){        
         print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie);
         print $cgi->start_html(
                     -title   => "Personal Log Login",
                     -BGCOLOR => &Settings::bgcol,
-                    -script=> [{-type => 'text/javascript', -src => 'wsrc/main.js'},
+                    -script=> [{-type  => 'text/javascript', -src => 'wsrc/main.js'},
                                 {-type => 'text/javascript', -src => 'wsrc/jquery.js'},
                                 {-type => 'text/javascript', -src => 'wsrc/jquery-ui.js'}],
-                    -style => [{-type => 'text/css', -src => "wsrc/".&Settings::css},
+                    -style => [{-type  => 'text/css', -src => "wsrc/".&Settings::css},
                                 {-type => 'text/css', -src => 'wsrc/jquery-ui.css'},
                                 {-type => 'text/css', -src => 'wsrc/jquery-ui.theme.css'},
                                 {-type => 'text/css', -src => 'wsrc/jquery-ui.theme.css'}],
@@ -83,12 +81,13 @@ try{
         <tr class="r0"><td colspan="2">Host -> <b>$hst</b></td><td><input type="submit" value="Login"/></td></tr>
         </table></form>);
 
-    print qq(<br><br><div id="rz">
+    print qq(<br><br><div class="rz">
             <center>
-                <h2>Welcome to Life Log</h2><div>$frm</div><br>
+                <h2>Welcome to Life Log</h2><div class="">$frm</div><br>
                 <a href="https://github.com/wbudic/LifeLog" 
                 target="_blank" style="font-size:small">LifeLog v.).Settings::release().qq(</a><br>
-            </center><div>);
+            </center>
+        </div>);
 
     Settings::printDebugHTML($DBG) if Settings::debug();
     print $cgi->end_html;
@@ -200,6 +199,7 @@ sub checkAutologinSet {
             }
             $db -> disconnect();
     }
+    Settings::loadLastUsedTheme();    
 }
 
 sub checkPreparePGDB {
@@ -718,7 +718,7 @@ sub toTokens {
 return @ret;
 }
 
-
+#@TODO Needs to be redone, use CNF 2.2, see also config.cgi
 sub populate {
 
     my $db = shift;
@@ -782,29 +782,29 @@ $err .= "Invalid, spec'ed {uid}|{variable}`{description}-> $line\n";
                                      elsif($tt==0){
 $err .= "Invalid, spec'd entry -> $line\n";
                                     }elsif($tt==1){
-                                                            my @pair = $tick[0] =~ m[(\S+)\s*\|\s*(\S+\s*\S*)]g;
-                                                            if ( scalar(@pair)==2 ) {
-                                                                        # In older DB versions the Category name could be different, user modified.
-                                                                        # The unique id and name interwined, changed. Hence we check on name first.
-                                                                        # Then check if the  ID is available. If not just skip, the import. Reseting can fix that latter.
-                                                                        if(!Settings::selectRecords($db, "SELECT ID FROM CAT WHERE NAME LIKE '$pair[1]';")->fetchrow_array()) {
-                                                                            if(!Settings::selectRecords($db, "SELECT ID FROM CAT WHERE ID = $pair[0];")->fetchrow_array()){
-                                                                                $DBG .= "cat.ins->".$pair[0].",".$pair[1].",".$tick[1]."\n";
-                                                                               $insCat->execute($pair[0],$pair[1],$tick[1]);
-                                                                            }
-                                                                        }
-                                                                        $inData = 1;
+                                            my @pair = $tick[0] =~ m[(\S+)\s*\|\s*(\S+\s*\S*)]g;
+                                            if ( scalar(@pair)==2 ) {
+                                                        # In older DB versions the Category name could be different, user modified.
+                                                        # The unique id and name interwined, changed. Hence we check on name first.
+                                                        # Then check if the  ID is available. If not just skip, the import. Reseting can fix that latter.
+                                                        if(!Settings::selectRecords($db, "SELECT ID FROM CAT WHERE NAME LIKE '$pair[1]';")->fetchrow_array()) {
+                                                            if(!Settings::selectRecords($db, "SELECT ID FROM CAT WHERE ID = $pair[0];")->fetchrow_array()){
+                                                                $DBG .= "cat.ins->".$pair[0].",".$pair[1].",".$tick[1]."\n";
+                                                                $insCat->execute($pair[0],$pair[1],$tick[1]);
                                                             }
-                                                            else {
+                                                        }
+                                                        $inData = 1;
+                                            }
+                                            else {
 $err .= "Invalid, spec'ed {uid}|{category}`{description}-> $line\n";
-                                                            }
-                                    }elsif($tt==2){
+                                            }
+                    }elsif($tt==2){
                                             #TODO Do we really want this? Insert into log from config script.
                                     }
                     }elsif($inData && length($line)>0){
 
                                         if(scalar(@tick)==1){
-                                            $err .= "Corrupt Entry, no description supplied -> $line\n";
+                                            $err .= "Corrupt Entry, (where is '\`' backtick for description?) -> $line\n";
                                         }
                                         else{
                                             $err .= "Corrupt Entry -> $line\n";
@@ -812,8 +812,7 @@ $err .= "Invalid, spec'ed {uid}|{category}`{description}-> $line\n";
 
                     }
         }
-    LifeLogException->throw(error=>"Configuration script ".&Settings::logPath."/main.cnf [$fh] contains errors. DSN:".
-                                Settings::dsn()." Err:$err", show_trace=>1) if $err;
+    LifeLogException->throw(error=>"Configuration script ".&Settings::logPath."/main.cnf contains errors.\nErr:$err", show_trace=>1) if $err;
     $db->commit();
 }
 
@@ -831,40 +830,40 @@ return "SELECT name FROM sqlite_master WHERE type='view' AND name='$name';"
 sub logout {
 
     if(Settings::trackLogins()){
-    try{
-        $alias = $session->param('alias');
-        $passw = $session->param('passw');
-        if($alias){
-            my $db = Settings::connectDB($DB_NAME, $alias, $passw);
-            Settings::toLog($db, "Log has properly been logged out by $alias.");
-            $db->disconnect();
-        }
-    }catch{
-        my $err = $@;
-        my $dbg = "" ;
-        my $pwd = `pwd`;
-        $pwd =~ s/\s*$//;
-        $dbg = "--DEBUG OUTPUT--\n$DBG" if Settings::debug();
-        print $cgi->header,
-        "<font color=red><b>SERVER ERROR</b></font> on ".DateTime->now().
-        "<pre>".$pwd."/$0 -> &".caller." -> [$err]","\n$dbg</pre>",
-        $cgi->end_html;
-        exit;
-    }
+            try{
+                $alias = $session->param('alias');
+                $passw = $session->param('passw');
+                if($alias){
+                    my $db = Settings::connectDB($DB_NAME, $alias, $passw);
+                    Settings::toLog($db, "Log has properly been logged out by $alias.");
+                    $db->disconnect();
+                }
+            }catch{
+                my $err = $@;
+                my $dbg = "" ;
+                my $pwd = `pwd`;
+                $pwd =~ s/\s*$//;
+                $dbg = "--DEBUG OUTPUT--\n$DBG" if Settings::debug();
+                print $cgi->header,
+                "<font color=red><b>SERVER ERROR</b></font> on ".DateTime->now().
+                "<pre>".$pwd."/$0 -> &".caller." -> [$err]","\n$dbg</pre>",
+                $cgi->end_html;
+                exit;
+            }
     }
 
 
     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'},
+                           -style =>{-type => 'text/css', -src => 'wsrc/'.Settings::css()},
             );
     $LOGOUT_IFRAME  = "" if not $LOGOUT_IFRAME_ENABLED;
-    print qq(<font color="white"><center><h2>You have properly logged out of the Life Log Application!</h2>
+    print qq(<div class="rz"><h2>You have properly logged out of the Life Log Application!</h2>
     <br>
     <form action="login_ctr.cgi"><input type="hidden" name="autologoff" value="1"/><input type="submit" value="$LOGOUT_RELOGIN_TXT"/></form><br>
     </br>
     $LOGOUT_IFRAME
-    </center></font>
+    </div>
     );
 
     print $cgi->end_html;
index 6c0fa7d230a30cd2608f4ccaf1d9ab68a0ac980d..8e6c23f0383e469c55fdee4bd93ff5b78f280946 100755 (executable)
@@ -36,7 +36,7 @@ my $VW_PAGE = Settings->VW_LOG;
 my $sssCDB  = $sss->param('cdb');
 my ($vmode, $imgw, $imgh );
 
-if ( !$alias ||  !$passw) {
+if ( !$alias ||  !$passw ) {
     print $cgi->redirect("alogin_ctr.cgi?CGISESSID=$sid");
     exit;
 }
@@ -84,14 +84,13 @@ my $BGCOL       = Settings::bgcol();
 my $DEBUG       = Settings::debug();
 #END OF SETTINGS
 my $rtf_buffer = 0;
-my $BUFFER;
-sub toBuf {
-    $BUFFER .= shift;        
-}
+my ($BUFFER, $D_BUFF);
 
 my $lang  = Date::Language->new(Settings::language());
 my $today = Settings->today();
+# We buffer the whole page creation, for speed and control send compressed or not to client.
+sub toBuf { if($DEBUG){$D_BUFF .= shift}else{$BUFFER .= shift} }
+
 if(!$prm_vc && &Settings::keepExcludes){
     if($prm_xc_lst){
         Settings::configProperty($db, 201, '^EXCLUDES', $prm_xc_lst);
@@ -670,12 +669,12 @@ sub buildLog {
         $log_output .= qq(<tr class="r$ssid">
                <td width="15%">$dtf<input id="y$id" type="hidden" value="$dty"/></td>
                <td id="t$id" width="10%" class="tbl">$dth</td>
-               <td id="v$id"><div class="log">$log</div></td>
+               <td id="v$id" ><div class="log">$log</div></td>
                <td id="a$id" width="10%" class="tbl">$am</td>
                <td id="c$id" width="10%" class="tbl">$ct</td>
         );
         if(!$isPUBViewMode){$log_output .= qq(
-               <td width="20%">
+               <td width="10%">
         <input id="r$id" type="hidden" value="$rtf"/>
         <input id="s$id" type="hidden" value="$sticky"/>
         <input id="f$id" type="hidden" value="$af"/>
@@ -683,8 +682,7 @@ sub buildLog {
                        <input name="chk" type="checkbox" value="$pid"/>
                </td></tr>)};
 
-        if ( $rtf > 0 ) {#max-width:1000px;
-        # style="max-height:480px; box-sizing: border-box; padding: 5px; background:#fffafa; overflow-x:scroll;scrollbar-width:none;"
+        if ( $rtf > 0 ) {        
              $log_output .= qq(<tr id="q-rtf$id" class="r$tfId" style="display:none;">
                          <td colspan="6">
                           <div id="q-scroll$id" class="ql-editor ql-snow" style="max-height:480px; overflow-x:scroll;">
@@ -789,9 +787,13 @@ $log_output .= qq(<form id="frm_srch" action="main.cgi"><TABLE class="tbl" borde
     $sp2 = '<span  class="ui-icon ui-icon-circle-triangle-s"></span>';
     $sp3 = '<span  class="ui-icon ui-icon-arrow-4-diag"></span>';
 
+    my $std_bck = "background-image:url('".&Settings::transimage."');";
+    $std_bck = "background-color:$BGCOL;" if !&Settings::transparent;
+    my $auto_logoff = &Settings::autoLogoff;
+
     my $frm = qq(<a name="top"></a>
 <form id="frm_entry" action="main.cgi" onSubmit="return formValidation();">
-       <table class="tbl" border="0" width=").&Settings::pagePrcWidth.qq(%">
+       <table class="tbl" border="0" style="$std_bck opacity: 0.9;" width=").&Settings::pagePrcWidth.qq(%">
        <tr class="r0">
     <td style="text-align:left;"><a id="to_bottom" href="#bottom" title="Go to bottom of page.">&#8615;</a></td>
     <td colspan="2"><b>* LOG ENTRY FORM *</b>
@@ -819,7 +821,7 @@ $log_output .= qq(<form id="frm_srch" action="main.cgi"><TABLE class="tbl" borde
             </div>
                        </td>
        </tr>
-       <tr class="collpsd"><td style="text-align:right; vertical-align:top">Log:</td>
+       <tr class="collpsd"><td style="text-align:right; vertical-align:top;">Log:</td>
                <td id="al" colspan="2" style="text-align:top;">
                        <textarea id="el" name="log" rows="3" style="float:left; width:99%;" onChange="toggleVisibility('cat_desc',true)"></textarea>
                </td>
@@ -859,6 +861,7 @@ $log_output .= qq(<form id="frm_srch" action="main.cgi"><TABLE class="tbl" borde
        <input type="hidden" name="rs_prev" value="$log_rc_prev"/>
        <input type="hidden" name="rs_page" value="$rs_page"/>
        <input type="hidden" name="CGISESSID" value="$sid"/>
+    <input type="hidden" id="auto_logoff" value="$auto_logoff"/>
     <input type="hidden" id="isInViewMode" value="$isInViewMode"/>
     <input type="hidden" id="rtf_buffer" value="$rtf_buffer"/>
        $tags
@@ -867,7 +870,7 @@ $log_output .= qq(<form id="frm_srch" action="main.cgi"><TABLE class="tbl" borde
 
     my $srh = qq(
        <form id="frm_srch" action="main.cgi">
-       <table class="tbl" border="0" width=").&Settings::pagePrcWidth.qq(%">
+       <table class="tbl" border="0" style="background-color:$BGCOL" width=").&Settings::pagePrcWidth.qq(%">
          <tr class="r0">
         <td colspan="2"><b>View By/Search</b>
             <a id="srch_close" href="#" onclick="return hide('#div_srh');">$sp1</a>
@@ -918,7 +921,7 @@ $log_output .= qq(<form id="frm_srch" action="main.cgi"><TABLE class="tbl" borde
     $srh .=
     qq(
     <tr class="collpsd">
-     <td align="right" style="width:20%">View by Category:</td>
+     <td align="right" style="width:20%;">View by Category:</td>
      <td align="left">
             <button class="bordered" data-dropdown="#dropdown-standard-v" style="margin: 0px; padding: 0; padding-right:8px;">
             <span id="lcat_v" class="ui-button">$catselected</span>
@@ -1002,7 +1005,7 @@ $log_output .= qq(<form id="frm_srch" action="main.cgi"><TABLE class="tbl" borde
 
 my $sideMenu;
 my $tail = q(<div><a class="a_" href="stats.cgi">View Statistics</a>&nbsp;&nbsp;<a class="a_" href="config.cgi">Configure Log</a></div><hr>
-             <div><a class="a_" href="login_ctr.cgi?logout=bye">LOGOUT</a><hr><a name="bottom"></a></div>);
+             <div><a class="a_" href="login_ctr.cgi?logout=bye" id="btnLogout">LOGOUT</a><hr><a name="bottom"></a></div>);
 if($isPUBViewMode){$sideMenu=$frm=$srh=$tail=""}else{ 
     my $sql = Settings::dbSrc(); my $s = $sql =~ qr/:/; $s = $`; $' =~ qr/:/; 
     if(lc $` eq 'pg'){$sql = $s.'&#10132;'.'PostgreSQL'}else{$sql = $s.'&#10132;'.$`};
@@ -1035,14 +1038,13 @@ if($isPUBViewMode){$sideMenu=$frm=$srh=$tail=""}else{
 }
 
 
-    my $quill = &quill( $cgi->param('submit_is_edit') );
-    my $help = &help;
+my $quill = &quill( $cgi->param('submit_is_edit') );
+my $help = &help;
 
 ##################################
 #  Final Page Output from here!  #
 ##################################
 
-
 toBuf (qq(
 $sideMenu
 <div id="div_log">$frm</div>
@@ -1567,7 +1569,7 @@ sub outputPage {
             { -type => 'text/javascript', -src => 'wsrc/moment-timezone-with-data.js' },
             { -type => 'text/javascript', -src => 'wsrc/jquery.sweet-dropdown.js'}
 
-        ]) . 
+        ]) . ($DEBUG ?"<div class='debug_output' date='$today'>$D_BUFF</div>":"").
     $BUFFER;
             
     if(Settings->compressPage() && $cgi->http('Accept-Encoding') =~ m/gzip/){        
index f2cc0e3a14fbc75caca7fa36fb693b225036ccfa..2a3183976bb03b564e002af6e981ee1aedcb08d6 100755 (executable)
@@ -44,19 +44,53 @@ my $CSS=<<_____CSS;
     font-family: Bookman;
     text-align: left;    
 }
-.spacer {
-        border: 10px;
-        border-left-width:0px;
 
-        margin:5 px;
-}
 .info span {
-    border: 1px solid black;
-    padding: 5px;
-    margin-top: 1px;
-    margin-right: 15px;
+    border: 1px solid black;    
+    margin-top: 5px;    
     float: left;
-    width:98%
+    width:97%
+}
+
+.table {
+    display:table;
+    border: 2px solid black;
+    margin-right: 15px;
+    width:45%;
+}
+.header {
+    display:table-header-group;
+    font-weight:bold;
+    border-bottom: 1px solid black;
+    margin-bottom: 2px;
+}
+.row {
+    display:table-row;
+}
+.rowGroup {
+    display:table-row-group;
+}
+.cell1 {
+       display: table-cell;    
+    padding: 5px;
+    border-bottom: solid 1px;  
+       border-right: solid 2px;
+    vertical-align: top;
+    width: 10%;
+}
+.cell2 {
+    display:table-cell;    
+    padding: 5px;
+    border-bottom: solid 1px;
+    vertical-align: top;
+    width:25%;
+}
+.cell3 {
+    display:table-cell;    
+    padding: 5px;
+    border-bottom: solid 1px;
+    vertical-align: top;
+    width:100%;
 }
 _____CSS
 
@@ -117,8 +151,9 @@ my $hardware_status = "<b>Host: </b>$hst<br>".join("\t", map { defined ? $_ : ''
    $hardware_status =~ s/up\s/<b>Server is up: <\/b>/g;
 
 my $log = "<span>".$hardware_status."</span>"."<pre>\n".`df -h -l -x tmpfs`."</pre>";   
-Settings::toLog($db, $log);   
-
+###
+   Settings::toLog($db, $log);   
+###
 my $prc = 'ps -eo size,pid,user,command --sort -size | awk \'{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }\'';
 my $processes = `$prc | sort -u -r -`;
 my @stat = stat Settings::dbFile();
@@ -132,23 +167,51 @@ my $year =$today->year();
 
 my $IPPublic  = `curl -s https://www.ifconfig.me`;
 my $IPPrivate = `hostname -I`; $IPPrivate =~ s/\s/<br>/g;
-
-my $tbl = qq(<table class="tbl" border="0" align="left"><tr class="r0"><td colspan="5" style="text-align:centered"><b>* Personal Log Data Statistics *</b></td></tr>
-          <tr class="r1"><td>LifeLog App. Version:</td><td>).Settings::release().qq(</td></tr>
-             <tr class="r0"><td>Number of Records:</td><td>$log_rc</td></tr>
-          <tr class="r1"><td>No. of Records This Year:</td><td>$log_this_year_rc</td></tr>
-          <tr class="r0"><td>No. of RTF Documents:</td><td>$notes_rc</td></tr>
-          <tr class="r1"><td># Sum of Expenses For Year $year</td><td>$expense</td></tr>
-          <tr class="r0"><td># Sum of Income For Year $year</td><td>$income</td></tr>
-          <tr class="r1"><td>Gross For Year $year</td><td>$gross</td></tr>
-          <tr class="r0"><td>$dbname<td>$dbSize</td></tr>
-          <tr class="r1"><td>Public IP</td><td>$IPPublic</td></tr>
-          <tr class="r0"><td>Private IP</td><td>$IPPrivate</td></tr>
-</table>);
-
-
-print qq(<div id="menu" title="Menu" style="border: 2px solid black; padding: 5px; margin-top: 25px;">
-<div style="border: 1px solid black; margin: 5px; margin-bottom: 10px; padding:5px;"><b>Menu</b></div>
+my $tbl = qq(
+<div class="table r0" style="text-align:centered; float:left;">
+  <div class="header">
+      <div class="cell2" style="border-right:0;">Personal Log Data Statistics</div>
+      <div class="cell2"></div>
+  </div>
+  <div class="row r1">
+    <div class="cell1">LifeLog App. Version:</div>
+    <div class="cell2">).Settings::release().qq(</div>
+  </div>
+  <div class="row r2">
+        <div class="cell1">Number of Records:</div><div class="cell2">$log_rc</div>
+  </div> 
+  <div class="row r3">
+        <div class="cell1">No. of Records This Year:</div><div class="cell2">$log_this_year_rc</div>
+  </div>
+    <div class="row r1">
+        <div class="cell1">No. of RTF Documents:</div><div class="cell2">$notes_rc</div>
+  </div>  <div class="row r0">
+        <div class="cell1"># Sum of Expenses For Year $year</div><div class="cell2">$expense</div>
+  </div>
+  <div class="row r2">
+        <div class="cell1"># Sum of Income For Year $year</div><div class="cell2">$income</div>
+  </div>
+  <div class="row r3">
+        <div class="cell1"># Gross For Year $year</div><div class="cell2">$gross</div>
+  </div>
+  <div class="row r1">
+        <div class="cell1">$dbname</div><div class="cell2">$dbSize</div>
+  </div>
+  <div class="row r2">
+        <div class="cell1">Public IP</div><div class="cell2">$IPPublic</div>
+  </div>
+  <div class="row r3">
+        <div class="cell1">Private IP</div><div class="cell2">$IPPrivate</div>
+  </div> 
+</div>
+<div class="table r0">
+    <div class="header"><div class="cell2">Server Info</div></div>
+    <div class="row r1"><div class="cell3">$hardware_status</div></div>
+</div>
+);
+
+print qq(<div id="menu" title="Menu" style="border: 2px solid black; padding: 5px; margin-top: 120px;">
+<div class="r0" style="border: 1px solid black; margin: 2px; margin-bottom: 10px; padding:5px;"><b>Menu</b></div>
 <div><a class="a_" href="main.cgi">Log</a><hr></div>
 <div><a class="a_" href="config.cgi">Config</a><hr></div>
 <div><a class="a_" href="login_ctr.cgi?logout=bye">LOGOUT</a></div>
@@ -158,25 +221,22 @@ print qq(
 <div class="main">
 
     <div class="info">
-    <span><h3>Life Log Server Statistics</h3></span>
+        <span class="r2" style="padding:5px;width:98%;"><h3>Life Log Server Statistics</h3></span>
     </div>
 
-    <div class="spacer">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
+    <div>&nbsp;</div>
     
     <div class="info">
-        <span><b>Log Status & Information</b></span>
-        <span><p>$tbl</p></span>
-    </div>
-    <div class="spacer">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>    
-    <div class="info">
-        <span><b>Server Info</b></span>
-        <span>$hardware_status</span>       
+        <span class="info r2" style="font-size:larger;padding:5px;width:98%;"><b>Status & Information</b></span>
+        <span style="font-size:larger;padding:5px;width:98%;">$tbl</span>
     </div>
-    <div class="spacer">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
+
+    <div>&nbsp;</div>
+
     <div class="info">    
-        <span><b>Server Side Processes</b></span>
-        <span class="ql-container ql-snow"  style="max-height:480px; overflow-x:scroll;">
-                <pre class="r1">$processes</pre>
+        <span class="r2" style="font-size:larger;padding:5px;width:98%;"><b>Server Side Processes</b></span>
+        <span style="border: 1px solid black; padding-right: 0px;  width:98%">
+                <pre class="ql-container r2" style="max-height:480px; width:100%; overflow-x:auto; margin-top:0; margin-bottom:0"">$processes</pre>
         </span>
     </div>
 </div>);
index 492dcee4ed416e76c818bac87c04acbfa9ccf53c..0690818e1eadf2fd57524661a9344122508ffee8 100644 (file)
@@ -51,7 +51,7 @@ use constant VW_LOG_WITH_EXCLUDES   => 'VW_LOG_WITH_EXCLUDES';
 #
 use constant VW_LOG_OVERRIDE_WHERE  => 'VW_LOG_OVR_WHERE';
 
-#DEFAULT SETTINGS HERE!
+# DEFAULT SETTINGS HERE! These settings kick in if not found in config file. i.e. wrong config file or has been altered, things got missing.
 our $RELEASE_VER  = '2.3';
 our $TIME_ZONE    = 'Australia/Sydney';
 our $LANGUAGE     = 'English';
@@ -64,29 +64,31 @@ our $IMG_W_H      = '210x120';
 our $REC_LIMIT    = 25;
 our $AUTO_WRD_LMT = 1000;
 our $AUTO_WRD_LEN = 17; #Autocompletion word length limit. Internal.
+our $AUTO_LOGOFF  = 0;
 our $VIEW_ALL_LMT = 1000;
 our $DISP_ALL     = 1;
 our $FRAME_SIZE   = 0;
 our $RTF_SIZE     = 0;
 our $THEME        = 'Standard';
+our $TRANSPARENCY = 1;
+our $TRANSIMAGE   = 'wsrc/images/std-log-lbl-bck.png';
 our $TRACK_LOGINS = 1;
 our $KEEP_EXCS    = 0;
 our $COMPRESS_ENC = 0; #HTTP Compressed encoding.
 our $DBI_SOURCE   = "DBI:SQLite:";
 our $DBI_LVAR_SZ  = 1024;
+
+my ($cgi, $sss, $sid, $alias, $pass, $dbname, $pub);
 our $DSN;
 our $DBFILE;
 our $IS_PG_DB     = 0;
-
-
-my ($cgi, $sss, $sid, $alias, $pass, $dbname, $pub);
-
-#Annons here, variables that could be overiden in  code or database, per need.
+#Annons here, variables that could be overriden in  code or in database, per need and will.
 our %anons = ();
 our %tz_map;
 
 ### Page specific settings Here
 our $TH_CSS        = 'main.css';
+our $JS            = 'main.js';
 our $BGCOL         = '#c8fff8';
 #Set to 1 to get debug help. Switch off with 0.
 our $DEBUG         = 1;
@@ -108,10 +110,12 @@ sub anon {$S_=shift; $S_ = $anons{$S_} if $S_;$S_}
 sub anonsSet {my $a = shift;%anons=%{$a}}
 
 sub release        {$RELEASE_VER}
-sub logPath        {$LOG_PATH}#<-something was calling as setter, can't replicate. On reset of categories in config.cgi.
-sub logPathSet     {$S_ = shift;$LOG_PATH = $S_ if $S_;return $LOG_PATH}#<-has now setter method nothing actually calls.
+sub logPath        {$LOG_PATH} # <-@2021-08-15 something was calling as setter, can't replicate. On reset of categories in config.cgi.
+sub logPathSet     {$S_ = shift;$LOG_PATH = $S_ if $S_;return $LOG_PATH}#<-has now setter method nothing it is actually calling.
 sub theme          {$THEME}                               
 sub timezone       {$TIME_ZONE}
+sub transparent    {$TRANSPARENCY}
+sub transimage     {$TRANSIMAGE}
 sub language       {$LANGUAGE}
 sub sessionExprs   {$SESSN_EXPR}
 sub imgWidthHeight {$IMG_W_H}
@@ -121,6 +125,7 @@ sub universalDate  {$DATE_UNI}
 sub recordLimit    {$REC_LIMIT}
 sub autoWordLimit  {$AUTO_WRD_LMT}
 sub autoWordLength {$AUTO_WRD_LEN}
+sub autoLogoff     {$AUTO_LOGOFF}
 sub viewAllLimit   {$VIEW_ALL_LMT}
 sub displayAll     {$DISP_ALL}
 sub trackLogins    {$TRACK_LOGINS}
@@ -128,6 +133,7 @@ sub windowRTFSize  {$RTF_SIZE}
 sub keepExcludes   {$KEEP_EXCS}
 sub bgcol          {$BGCOL}
 sub css            {$TH_CSS}
+sub js             {$JS}
 sub compressPage   {$COMPRESS_ENC}
 sub debug          {$S_ = shift; $DEBUG = $S_ if $S_; $DEBUG}
 sub dbSrc          {$S_= shift; if($S_) {$DBI_SOURCE=$S_; $IS_PG_DB = 1 if(index (uc $S_, 'DBI:PG') ==0)}  
@@ -147,7 +153,7 @@ sub pass    {$pass}
 sub pub     {$pub}
 
 sub trim {my $r=shift; $r=~s/^\s+|\s+$//g;  $r}
-#The following has to be called from an CGI seesions container that provides parameters.
+# The following has to be called from an CGI seesions container that provides parameters.
 sub fetchDBSettings {
 try {
     $CGI::POST_MAX = 1024 * 1024 * 5;  # max 5GB file post size limit.
@@ -202,11 +208,11 @@ try {
     }    
     my $ret  = connectDB($dbname, $alias, $pass);
     getConfiguration($ret);    
-    getTheme();
+    setupTheme();
     $sss->expire($SESSN_EXPR);
     return $ret;
 }catch{    
-    SettingsException->throw(error=>$@, show_trace=>$DEBUG);
+    SettingsException->throw(error=>"DSN<$DSN>".$@, show_trace=>$DEBUG);
     exit;
 }
 }
@@ -387,7 +393,7 @@ return qq(
     FOREIGN KEY (CID) REFERENCES CAT(ID)
     );
 )}
-#Selects the actual database set configuration for the application, not from the config file.
+#Selects the actual database set configuration for the application, these kick in overwritting those from the config file.
 sub getConfiguration {
     my ($db, $hsh) = @_;
     my $fh;
@@ -407,11 +413,14 @@ sub getConfiguration {
                 when ("IMG_W_H")     {$IMG_W_H      = $r[2]}
                 when ("REC_LIMIT")   {$REC_LIMIT    = $r[2]}
                 when ("AUTO_WRD_LMT"){$AUTO_WRD_LMT = $r[2]}
+                when ("AUTO_LOGOFF") {$AUTO_LOGOFF  = $r[2]}
                 when ("VIEW_ALL_LMT"){$VIEW_ALL_LMT = $r[2]}
                 when ("DISP_ALL")    {$DISP_ALL     = $r[2]}
                 when ("FRAME_SIZE")  {$FRAME_SIZE   = $r[2]}
                 when ("RTF_SIZE")    {$RTF_SIZE     = $r[2]}
                 when ("THEME")       {$THEME        = $r[2]}
+                when ("TRANSPARENCY"){$TRANSPARENCY = $r[2]}
+                when ("TRANSIMAGE")  {$TRANSIMAGE   = $r[2]}
                 when ("DEBUG")       {$DEBUG        = $r[2]}
                 when ("KEEP_EXCS")   {$KEEP_EXCS    = $r[2]}
                 when ("TRACK_LOGINS"){$TRACK_LOGINS = $r[2]}
@@ -473,22 +482,22 @@ sub timeFormatSessionValue {
     my @a = $v =~ m/(\+\d+[shm])/gis;    
     if(scalar(@a)>0){$v=$a[0]}
     # Test acceptable setting, which is any number from 2, having any s,m or h. 
-    if($v =~ m/(\+[2-9]\d*[smh])|(\+[1-9]+\d+[smh])/){
+    if($v =~ m/(\+*[2-9]\d*[smh])|(\+[1-9]+\d+[smh])/){
         # Next is actually, the dry booger in the nose. Let's pick it out!
         # Someone might try to set in seconds value to be under two minutes.
         @a = $v =~ m/(\d[2-9]\d+)/gs;        
         if(scalar(@a)>0 && int($a[0])<120){return $ret}else{return $v}
     }
-    elsif($v =~ m/\+\d+/){# is passedstill without time unit? Minutetise!
-        $ret=$v."m"
+    elsif($v =~ m/\+\d+/){# is passed still without time unit? Minutetise!
+        $ret=$v
     }
     return $ret;
 }
-sub getTheme {
+sub setupTheme {
     given ($THEME){
-        when ("Sun")   { $BGCOL = '#D4AF37'; $TH_CSS = "main_sun.css"; }
-        when ("Moon")  { $BGCOL = '#000000'; $TH_CSS = "main_moon.css"; }
-        when ("Earth") { $BGCOL = '#26ac0c'; $TH_CSS = "main_earth.css";} # Used to be $BGCOL = '#26be54';
+        when ("Sun")   { $BGCOL = 'goldenrod';   $TH_CSS = "main_sun.css"; }
+        when ("Moon")  { $BGCOL = '#000000';     $TH_CSS = "main_moon.css"; }
+        when ("Earth") { $BGCOL = 'forestgreen'; $TH_CSS = "main_earth.css";} # Used to be $BGCOL = '#26be54';
         default{
             # Standard;
             $BGCOL    = '#c8fff8';
@@ -755,4 +764,19 @@ sub toPropertyValue {
     return $prm;
 }
 
+sub saveCurrentTheme {
+    my $theme = shift;
+    if($theme){
+        open (my $fh, '>', $LOG_PATH.'current_theme') or die $!;
+        print $fh $theme;
+        close($fh);
+    }
+}
+sub loadLastUsedTheme {    
+    open my $fh, '<', $LOG_PATH.'current_theme' or return $THEME;
+    $THEME = <$fh>;
+    close($fh);    
+    &setupTheme;
+}
+
 1;
\ No newline at end of file
index c7d7306f74131de961b509b1c322937daeae6d5c..2ae18d9fcb1fc462e47fb0f3435bbf19a512de7a 100644 (file)
@@ -729,9 +729,6 @@ function toggleVisibility(target, ensureOff) {
 }
 
 
-
-
-
 function toggleDoc(whole) {
 
 
@@ -1303,7 +1300,14 @@ function setPageSessionTimer(expires) {
             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);}}
+            if(!WARNED){WARNED=1;
+                if($('#auto_logoff').val()=='0'){
+                   $('#au_door_chime').trigger('play');
+                }else{
+                    $('#btnLogout').click();
+                }
+                display("<span id='sss_expired'>Session is about to expire!</span>",10);}
+            }
             var dsp = "<font size='1px;'>[" + tim + "]</font><span "+sty+"> Session expires in " + out + "</span>";                
             $("#sss_status").html(dsp);
             if(now.isAfter(timeout)){
@@ -1312,6 +1316,9 @@ function setPageSessionTimer(expires) {
                 $("#ed").prop( "disabled", true );
                 $("#el").prop( "disabled", true );
                 $("#am").prop( "disabled", true );
+                if($('#auto_logoff').val()=='1'){                    
+                      dialogModal("Page Session has Expired","Please login again!", true);                    
+                }
             }
 
         }, 1000);
@@ -1327,21 +1334,41 @@ function setPageSessionTimer(expires) {
      return true;
  }
 
- function dialogModal(title, message) {
-    $('<div></div>').dialog({
-        modal: true,
-        title: title,
-        width: "40%",
-        show: { effect: "clip", duration: 400 },
-        open: function() {
-          $(this).html(message);
-        },
-        buttons: {
-          Ok: function() {
-            $( this ).dialog( "close" );
-          }
-        }
-    });
+ function dialogModal(title, message, logout) {
+    
+    if(logout) {
+        $('<div></div>').dialog({
+            modal: true,
+            title: title,
+            width: "40%",
+            show: { effect: "clip", duration: 400 },
+            open: function() {
+            $(this).html(message);
+            },
+            buttons: {
+                Logout: function() {
+                    $( this ).dialog( "close" );
+                    location.reload();
+                }
+            }    
+        });
+    }else {      
+    
+            $('<div></div>').dialog({
+                modal: true,
+                title: title,
+                width: "40%",
+                show: { effect: "clip", duration: 400 },
+                open: function() {
+                $(this).html(message);
+                },
+                buttons: {
+                    Ok: function() {
+                    $( this ).dialog( "close" );
+                    }
+                }
+            });
+    }
 return false;
  }