From 03c8e00e418b89517fcd4011003b4d8f0cdb16c1 Mon Sep 17 00:00:00 2001 From: Metabox Date: Sat, 1 Jun 2019 13:53:39 +1000 Subject: [PATCH] Autologin implemented and tested. --- Current Development Check List.md | 2 +- htdocs/cgi-bin/login_ctr.cgi | 7 +++--- htdocs/cgi-bin/tempCodeRunnerFile.cgi | 31 +++++++++++++++++++++++++-- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Current Development Check List.md b/Current Development Check List.md index 331a646..8709a0e 100644 --- a/Current Development Check List.md +++ b/Current Development Check List.md @@ -1,6 +1,6 @@ # Current Branch Development Moon-Stable-1.4 ## Urgent -* Autologin feature, that expires on logout. +*✔ Autologin feature, that expires on logout. *✔ Data/Login control updated to read the configuration file. >> Configuration file to be updated to carry also categories. * ✔ Configuration page to be updated, system variables description field to be implemented. diff --git a/htdocs/cgi-bin/login_ctr.cgi b/htdocs/cgi-bin/login_ctr.cgi index 1221cc8..7094fc9 100755 --- a/htdocs/cgi-bin/login_ctr.cgi +++ b/htdocs/cgi-bin/login_ctr.cgi @@ -50,6 +50,7 @@ my $cipher_key = '95d7a85ba891da'; if($cgi->param('logout')){&logout} +&checkAutologinSet; if(&processSubmit==0){ print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie); @@ -94,7 +95,7 @@ exit; sub processSubmit{ try{ - &checkAutologinSet; + if($alias&&$passw){ $passw = uc crypt $passw, hex $cipher_key; @@ -140,12 +141,12 @@ try{ my $db = DBI->connect($dsn, $cre[0], $cre[1], { RaiseError => 1 }) or die "

Error->"& $DBI::errstri &"

"; #check if enabled. - my $st = $db->prepare("SELECT NAME, VALUE FROM CONFIG WHERE NAME='$AUTO_LOGIN';"); + 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]; } } } diff --git a/htdocs/cgi-bin/tempCodeRunnerFile.cgi b/htdocs/cgi-bin/tempCodeRunnerFile.cgi index 494187f..58ddcc1 100644 --- a/htdocs/cgi-bin/tempCodeRunnerFile.cgi +++ b/htdocs/cgi-bin/tempCodeRunnerFile.cgi @@ -5,8 +5,15 @@ # use strict; use warnings; +use DBI; +#DEFAULT SETTINGS HERE! +our $LOG_PATH = '/home/will/dev/LifeLog/dbLifeLog/'; +#END OF SETTINGS + + +my @cre; open(my $fh, '<', '/home/will/dev/LifeLog/htdocs/cgi-bin/main.cnf' ) or die "Can't open main.cnf: $!"; while (my $line = <$fh>) { @@ -14,14 +21,34 @@ use warnings; if(rindex ($line, "<", 14; my $crest = substr $line, 13, $end - 13; - my @cre = split '/', $crest; + @cre = split '/', $crest; if(@cre &&scalar(@cre)>1){ - print @cre; + print @cre; last; } } } close $fh; + + if(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 "

Error->

"; + #check if enabled. + my $st = $db->prepare("SELECT VALUE FROM CONFIG WHERE NAME='AUTO_LOGIN';"); + $st->execute(); + my @set = $st->fetchrow_array(); + print $set[0]; + if($set[0] eq "0"){ + my $alias = $cre[0]; + my $passw = $cre[1]; + } + else{ + print "sucks cock!" + } + } =Comm my $fh; my $inData = 0; -- 2.34.1