]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Implemented logout.
authorMetabox <redacted>
Sat, 27 Apr 2019 21:42:59 +0000 (07:42 +1000)
committerMetabox <redacted>
Sat, 27 Apr 2019 21:42:59 +0000 (07:42 +1000)
htdocs/cgi-bin/login_ctr.cgi
htdocs/cgi-bin/main.cgi

index 8872887fcee03388fb58f089f11a3d1d79bbc066..1189c2312f33f621f898462d07c5a0294facf2a7 100755 (executable)
@@ -43,14 +43,15 @@ my $frm;
 #This is the OS developer release key, replace on istallation. As it is not secure.
 my $cipher_key = '95d7a85ba891da';
 
+if($cgi->param('logout')){&logout}
+
 if(&processSubmit==0){
 
   print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie);  
   print $cgi->start_html(-title => "Personal Log Login", -BGCOLOR=>"#c8fff8",
                                       -script=>{-type => 'text/javascript', -src => 'wsrc/main.js'},
                                     -style =>{-type => 'text/css', -src => 'wsrc/main.css'},
-                   );  
-
+                   );    
 
   $frm = qq(
         <form id="frm_login" action="login_ctr.cgi" method="post"><table border="0" width="$PRC_WIDTH%">
@@ -71,9 +72,11 @@ if(&processSubmit==0){
          <tr class="r0"><td colspan="2"></td><td><input type="submit" value="Login"/></td></tr>
     </table></form>);
 
-               print "<center>";
-                       print "\n<div>\n" . $frm ."\n</div>\n<br/>";
-               print "</center>";       
+               print qq(<br><br><div id=rz>
+                                               <center>
+                                                       <h2>Welcome to Life Log</h2><div>$frm</div><br/>
+                                                       <a href="https://github.com/wbudic/LifeLog" target="_blank">Get latest version of this application here!</a><br>
+                                               </center><div>);
                print $cgi->end_html;
 
 }
@@ -157,7 +160,6 @@ try{
                 insertDefCats($db);
        }
 
-
   $st = $db->prepare(selSQLTbl('AUTH'));
        $st->execute();
        if(!$st->fetchrow_array()) {
@@ -191,7 +193,7 @@ try{
                $rv = $db->do($stmt);
        }
   populateConfig($db);
-       
+       $db->disconnect();
 }
  catch{                
          print $cgi->header;
@@ -280,4 +282,28 @@ sub removeOldSessions{
        }
 }
 
-### CGI END
\ No newline at end of file
+sub logout{
+
+       $session->delete();
+       $session->flush();
+       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'},
+                   );  
+       
+       print qq(<font color="white"><center><h2>You have properly loged out of the Life Log Application!</h2>
+       <br>
+       <form action="login_ctr.cgi"><input type="submit" value="No, no, NO! Log me In Again."/></form><br>
+       </br>
+       <iframe width="60%" height="600px" src="https://www.youtube.com/embed/HQ5SEieVbSI?autoplay=1" 
+         frameborder="0" 
+               allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
+       </iframe>
+       </center></font>
+       );      
+
+       print $cgi->end_html;
+       exit;
+}
+
+### CGI END
index 2dddb1585a19e4c22cb5f514c3ed54f7e1f141c7..3ed0bd5da0885c742b931f2ac87ad2acb0599a7d 100755 (executable)
@@ -31,6 +31,7 @@ our $SESSN_EXPR  = '+30m';
 our $DATE_UNI    = '0';
 our $RELEASE_VER = '1.3';
 our $AUTHORITY   = '';
+our $IMG_W_H     = '210x120';
 #END OF SETTINGS
 
 my $cgi = CGI->new;
@@ -52,6 +53,8 @@ my $database = '../../dbLifeLog/'.$dbname;
 my $dsn= "DBI:SQLite:dbname=$database";
 my $db = DBI->connect($dsn, $userid, $password, { RaiseError => 1 }) or die "<p>Error->"& $DBI::errstri &"</p>";
 
+my ($imgw,$imgh);
+
 ### Authenticate session to alias password
 &authenticate;
 &getConfiguration($db);
@@ -79,6 +82,17 @@ if($rs_dat_from && $rs_dat_to){
 my $toggle =""; if($rs_keys||$rs_cat_idx||$stmD){$toggle=1;};
 
 $session->expire($SESSN_EXPR);
+
+#tag related framed sizing.
+my @arrwh = $IMG_W_H = ~m((\S+)\s*x\$\s*(\S+))gi;
+if(@arrwh==2){
+       $imgw = $arrwh[0];
+       $imgh = $arrwh[1];
+}
+else{
+       $imgw = 210;
+       $imgh = 120;
+}
        
 print $cgi->header(-expires=>"0s", -charset=>"UTF-8"); 
 print $cgi->start_html(-title => "Personal Log", -BGCOLOR=>"#c8fff8",
@@ -271,10 +285,10 @@ while(my @row = $st->fetchrow_array()) {
                                }
                        }
                        $lnk = qq(\n<a href="./images/$lnk" style="border=0;" target="_IMG">
-                       <img src="./images/$sub" width="210" height="120" class="tag_FRM"/></a>);
+                       <img src="./images/$sub" width="$imgw" height="$imgh" class="tag_FRM"/></a>);
                  }else{
                        #TODO fetch from web locally the original image.
-                       $lnk = qq(\n<img src="$lnk" width="210" height="120" class="tag_FRM"/>);
+                       $lnk = qq(\n<img src="$lnk" width="$imgw" height="$imgh" class="tag_FRM"/>);
                  }     
                  $tags .= qq(<input id="tag$id" type="hidden" value="$log"/>\n);       
            $log=~s/<<FRM<(.*?)>/$lnk/o;
@@ -297,8 +311,12 @@ while(my @row = $st->fetchrow_array()) {
           my $sub =  "<b>".substr($log,$idx+4,$len-$idx)."</b>";
              $log=~s/<<B<(.*?)>/$sub/o;        
        }
-
-
+       while ($log =~ /<<I</){
+          my $idx = $-[0];
+          my $len = index($log, '>', $idx)-4;
+          my $sub =  "<i>".substr($log,$idx+4,$len-$idx)."</i>";
+             $log=~s/<<I<(.*?)>/$sub/o;        
+       }
        while($log =~ /<<TITLE</){
           my $idx = $-[0];
           my $len = index($log, '>', $idx)-8;
@@ -457,12 +475,14 @@ $srh.='</table></form><br>';
 #
 #Page printout from here!
 #
-print "<center>";
-       print "\n<div>\n" . $frm ."\n</div>\n<br>\n";
-       print '<div id="div_srh">' . $srh .'</div>';
-       print "\n<div>\n" . $tbl ."\n</div>";
-       print '<br><div><a href="stats.cgi">View Statistics</a></div>';
-       print '<br><div><a href="config.cgi">Configure Log (Careful)</a><a name="bottom"/></div>';
+print qq(<center>\n
+         <div>\n$frm\n</div>\n<br>\n
+         <div id="div_srh">$srh</div>
+         <div>\n$tbl\n</div><br>
+         <div><a href="stats.cgi">View Statistics</a></div><br>
+         <div><a href="config.cgi">Configure Log</a></div><hr>
+               <div><a href="login_ctr.cgi?logout=bye">LOGOUT</a><a name="bottom"/></div>
+       );
 print qq(</center>
         <ul id="cat_lst">
                                $cat_descriptions
@@ -679,7 +699,8 @@ sub getConfiguration{
                                case "PRC_WIDTH" {$PRC_WIDTH=$r[2]}             
                                case "SESSN_EXPR" {$SESSN_EXPR=$r[2]}
                                case "DATE_UNI"  {$DATE_UNI=$r[2]}
-                               case "LANGUAGE"  {$LANGUAGE=$r[2]}                              
+                               case "LANGUAGE"  {$LANGUAGE=$r[2]}
+                               case "IMG_W_H"  {$IMG_W_H=$r[2]}
                                else {print "Unknow variable setting: ".$r[1]. " == ". $r[2]}
                        }