]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Bugg 33, fix.
authorWill Budicm <redacted>
Sat, 26 Dec 2020 20:05:52 +0000 (07:05 +1100)
committerWill Budicm <redacted>
Sat, 26 Dec 2020 20:05:52 +0000 (07:05 +1100)
dbLifeLog/main.cnf
htdocs/cgi-bin/json.cgi
htdocs/cgi-bin/system/modules/Settings.pm
htdocs/cgi-bin/testSettings.pl

index 92c1a6a85cfcbf1410da2900f54cf00da7095200..20de50f4f437bbfcfd18c81e2454b9eb32577cb2 100644 (file)
@@ -53,7 +53,7 @@ America/Texas=America/Chicago
 03|$TIME_ZONE   = Australia/Sydney`Time zone of your country and city.
 05|$PRC_WIDTH   = 80`Default presentation width for pages.
 08|$LOG_PATH    = ../../dbLifeLog/`Path to folder containing data.
-10|$SESSN_EXPR  = +30m`Login session expiration time setting, can be minutes or hours.
+10|$SESSN_EXPR  = +30m`Login session expiration time setting, can be seconds, minutes or hours.
 12|$DATE_UNI    = 0`Setting of how dates are displayed, universal yyyy-mm-dd or local dd-mm-yyyy.
 14|$LANGUAGE   = English`Default language locale.
 18|$IMG_W_H     = 210x120`Default embedded image width.
index 46f0e9a61961bcde3e22c13499141010ec4a68e3..8260d226cfa8ec844fb6b7393fa8dc210e88f260 100755 (executable)
@@ -114,6 +114,7 @@ sub processSubmit {
                $st->execute($zip);
                $response = "Updated Document (id:$lid)!";
            }
+           
         }
         elsif($action eq 'load'){
            $st = $db->prepare("SELECT DOC FROM NOTES WHERE LID = $lid;");
index 069318211ec468a7ac98b0ab62094aef20bb1bf4..beae7a2cac47131857fe3a7c2e98a75ffe54cb15 100644 (file)
@@ -356,7 +356,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   = timeFormatValue($r[2])}
+                when ("SESSN_EXPR")  {$SESSN_EXPR   = timeFormatSessionValue($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.
@@ -420,13 +420,26 @@ sub getConfiguration {
     };
 }
 
-sub timeFormatValue {
+sub timeFormatSessionValue {
     my $v = shift;
-    if(!$v || $v==0){$v="+2m"}
-    if($v !~ /^\+/){$v='+'.$v.'m'}
-    return $v;
+    my $ret = "+2m";
+    if(!$v){$v=$ret}    
+    if($v !~ /^\+/){$v='+'.$v.'m'}# Must be positive added time
+    # Find first match in whatever passed.
+    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])/){
+        # 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"
+    }
+    return $ret;
 }
-
 sub getTheme {
     given ($THEME){
         when ("Sun")   { $BGCOL = '#D4AF37'; $TH_CSS = "main_sun.css"; }
index 0670058264fa23b824864bf3fd14a6d7d34cec70..d6fb46240942e5752c8e085a489cb08e4ba3413e 100755 (executable)
@@ -83,7 +83,67 @@ my $v3 = $' =~ qr/:/;
 # $`=DBI
 # $&=:
 # $'=Pg:host=elite;name=androi
+print $v2.'->'.$`,"\n";
+$v1 ="";
+
+print "[$v1]->".timeFormatValue($v1),"\n";
+$v1 ="1";
+print "[$v1]->".timeFormatValue($v1),"\n";
+$v1 ="+1m";
+print "[$v1]->".timeFormatValue($v1),"\n";
+$v1 ="+10minutes";
+print "[$v1]->".timeFormatValue($v1),"\n";
+#default
+$v1 ="+30m";
+print "[$v1]->".timeFormatValue($v1),"\n";
+
+#Let's try sneak in garbage.
+$v1 ="+20bitcons";
+print "[$v1]->".timeFormatValue($v1),"\n";
+$v1 ="+20hitcons";
+print "[$v1]->".timeFormatValue($v1),"\n";
+$v1 ="+30hr";
+print "[$v1]->".timeFormatValue($v1),"\n";
+$v1 ="+1hr";
+print "[$v1]->".timeFormatValue($v1),"\n";
+$v1 ="+8.2severe";
+print "[$v1]->".timeFormatValue($v1),"\n";
+$v1 ="+8severe";
+print "[$v1]->".timeFormatValue($v1),"\n";
+$v1 ="+2severe";
+print "[$v1]->".timeFormatValue($v1),"\n";
+$v1 ="+120severe";
+print "[$v1]->".timeFormatValue($v1),"\n";
+$v1 ="+119severe";
+print "[$v1]->".timeFormatValue($v1),"\n";
+$v1 ="+121severe";
+print "[$v1]->".timeFormatValue($v1),"\n";
+$v1 ="+280severe";
+print "[$v1]->".timeFormatValue($v1),"\n";
+$v1 ="+120";
+print "[$v1]->".timeFormatValue($v1),"\n";
+
+
+sub timeFormatValue {
+    my $v = shift;
+    my $ret = "+2m";
+    if(!$v){$v=$ret}    
+    if($v !~ /^\+/){$v='+'.$v.'m'}# Must be positive added time
+    # Find first match in whatever passed.
+    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])/){
+        # 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"
+    }
+    return $ret;
+}
 
 
-print $v2.'->'.$`,"\n";
 1;
\ No newline at end of file