]> lifelog.hopto.org Git - LifeLog.git/commitdiff
AUTO_LOGIN
authorMetabox <redacted>
Fri, 31 May 2019 03:18:01 +0000 (13:18 +1000)
committerMetabox <redacted>
Fri, 31 May 2019 03:18:01 +0000 (13:18 +1000)
Current Development Check List.md
htdocs/cgi-bin/login_ctr.cgi
htdocs/cgi-bin/main.cnf
htdocs/cgi-bin/tempCodeRunnerFile.cgi

index 33e29d740b1c0225784cbd9729f2e52cde85c95b..331a64690bb7158b9f8fcee83ec7c9f4e7d717d8 100644 (file)
@@ -1,5 +1,6 @@
 # Current Branch Development Moon-Stable-1.4
 ## Urgent
+* Autologin feature, that expires on logout.
 *&#10004; Data/Login control updated to read the configuration file.
 >> Configuration file to be updated to carry also categories.
 * &#10004; Configuration page to be updated, system variables description field to be implemented.
index 1c3288ad8e3f1c867033601da155b3494c42ffd6..27bf2b3e9d577d218b0df35076634800b2a83329 100755 (executable)
@@ -29,6 +29,7 @@ our $RELEASE_VER = '1.4';
 our $AUTHORITY   = '';
 our $IMG_W_H     = '210x120';
 our $AUTO_WRD_LMT= 200;
+our $AUTO_LOGIN  = 0;
 #END OF SETTINGS
 
 
@@ -93,6 +94,7 @@ exit;
 
 sub processSubmit{
 try{
+       &checkAutologinSet;
        if($alias&&$passw){
                        
                        $passw = uc crypt $passw, hex $cipher_key;
@@ -101,7 +103,7 @@ try{
                        $session->param('alias', $alias);
                        $session->param('passw', $passw);
                        $session->param('database', 'data_'.$alias.'_log.db');  
-                       $session->flush();                                              
+                       $session->flush();
                        print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie, -location=>"main.cgi");  
                        return 1;
        }
@@ -117,7 +119,37 @@ return 0;
  }
 }
 
-sub checkCreateTables{
+sub checkAutologinSet {
+               #We don't need to slurp as it is expected setting in header.
+               my @cre;
+               open(my $fh, '<', './main.cnf' ) or die "Can't open main.cnf: $!";              
+               while (my $line = <$fh>) {
+                                       chomp $line;
+                                       if(rindex ($line, "<<AUTO_LOGIN<", 0)==0){
+                                                my $end = index $line, ">", 14;
+                                                my $crest = substr $line, 13, $end - 13;
+                                                @cre = split '/', $crest;
+                                                last;
+                                       }
+               }
+    close $fh;
+               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 }) 
+                                                               or die "<p>Error->"& $DBI::errstri &"</p>";
+                                       #check if enabled.      
+                        my $st = $db->prepare("SELECT NAME, VALUE FROM CONF WHERE NAME='$AUTO_LOGIN';");
+                                       $st->execute();
+                        my @set = $st->fetchrow_array();
+                                       if(@set && $set[0]=="1"){
+                                                $alias = $cre[0];
+                                                $passw = $cre[1];
+                                       }
+               }
+}
+
+sub checkCreateTables {
 try{
        my $today = DateTime->now;
           $today->set_time_zone( $TIME_ZONE );
@@ -373,7 +405,7 @@ sub insertDefCats {
          my
          $st = $_[0]->prepare('INSERT INTO CAT VALUES (?,?,?)'); 
                $st->execute(1, "Unspecified", "For quick uncategorised entries.");
-               $st->execute(3, "File System", "Operating file system short log.");
+               $st->execute(3, "File", "Operating file system short log.");
                $st->execute(6, "System Log", "Operating system important log.");
                $st->execute(9, "Event", "Event that occured, meeting, historically important.");
                $st->execute(28,"Personal", "Personal log of historical importance, diary type.");
index 589669de8f690a758445df6ef03db382736c99a5..a3d60647086d0e59aa53391173da27e9ca8e7455 100644 (file)
@@ -2,6 +2,7 @@
 This the main configuration file for the LifeLog application settings.
 https://github.com/wbudic/LifeLog
 This is an Open Source License project -> https://choosealicense.com/licenses/isc/
+<<AUTO_LOGIN<>
 <<CONFIG<4>
 00|$RELEASE_VER = 1.3`LifeLog Application Version.
 01|$REC_LIMIT   = 25`Records shown per page.
@@ -13,6 +14,7 @@ This is an Open Source License project -> https://choosealicense.com/licenses/is
 14|$LANGUAGE   = English`Default language locale.
 18|$IMG_W_H     = 210x120`Default embedded image width.
 20|$AUTO_WRD_LMT= 200`Autocomplete word gathering limit.
+22|$AUTO_LOGIN  = 0`Autologin option, that expires only if login out. Enter Credentials in main.cnf.
 <<CAT<3>
 01|Unspecified `For quick uncategorised entries.
 03|File System `Operating file system short log.
index 22990391adcbf3f3f248d5eacedcacc313e39915..494187fd52b72d6deb5951a07f54bd8790c634de 100644 (file)
@@ -6,6 +6,23 @@
 use strict;
 use warnings;
 
+
+
+               open(my $fh, '<', '/home/will/dev/LifeLog/htdocs/cgi-bin/main.cnf' ) or die "Can't open main.cnf: $!";
+               while (my $line = <$fh>) {
+                                       chomp $line;
+                                       if(rindex ($line, "<<AUTO_LOGIN<", 0)==0){
+                                                my $end = index $line, ">", 14;
+                                                my $crest = substr $line, 13, $end - 13;
+                         my @cre = split '/', $crest;
+                         if(@cre &&scalar(@cre)>1){
+                         print @cre;
+                         }
+
+                                       }
+               }
+       close $fh;
+=Comm
 my $fh;
 my $inData = 0;
 open( $fh, "<:perlio", '/home/will/dev/LifeLog/htdocs/cgi-bin/main.cnf' )
@@ -77,6 +94,7 @@ foreach my $line (@lines) {
 
 }
 close $fh;
+=cut
 
 =comment