This version is not compatible in data structure to prior versions. Data migration is required, to transfer previous data (see ../dbLifeLog/main.cnf).
+
## LifeLog Development
### v.1.7 Encountered
-* Delete page updated to show better display of entries.
-* Login page to indentify host.
-* Invalid login only shows db error.
-* Session cleanup on autologin not clearing properly.
- * A dbfix, should clear older entris as well.
+* Delete page updated to show better display of entries.
+* Provide sub alias login that sets data visible to only a set of categories.
+ * View specific based login on a different password.
+* ✔ Login page to indentify host.
+* ✔ Session cleanup on autologin not clearing properly.
+ * A dbfix, should clear older entries as well.
### v.1.6 and less
### v. 1.7 Encountered/Fixed
-* Bug 12 - Migrated old data, linking to wrong id, db fix in config page seems to fix this.
-
+* ✔ Bug 13 - Migrated old data, linking to wrong id, db fix in config page seems to fix this.
+* ✔ Bug 12 - Invalid login only shows db error.
+
### v. 1.6 Encountered/Fixed
* ✔ Bug - 11 View runs, brocken since sticky feature implentation. Page record sets don't work.
***
-** Checked (✔) Are items that have been done and submitted to the branch.**
-**Project ->** https://github.com/wbudic/LifeLog/
+ Checked (✔) Are items that have been done and submitted to the branch.
+
+ Project -> <https://github.com/wbudic/LifeLog/>
Credential format:<<AUTO_LOGIN <{alias}/{password}> , dont enable here using AUTO_LOGIN option bellow, use config in app.
<<AUTO_LOGIN</>
<<CONFIG<4>
-00|$RELEASE_VER = 1.6`LifeLog Application Version.
+00|$RELEASE_VER = 1.7`LifeLog Application Version.
01|$REC_LIMIT = 25`Records shown per page.
03|$TIME_ZONE = Australia/Sydney`Time zone of your country.
05|$PRC_WIDTH = 80`Default presentation width for pages.
}
&renumerate;
+ &removeOldSessions;
&resetCategories if $rs_cats;
&resetSystemConfiguration($db) if $rs_syst;
&wipeSystemConfiguration if $wipe_ss;
+
+
$db->do('COMMIT;');
$db->disconnect();
$db = DBI->connect($dsn, $userid, $password, { RaiseError => 1 }) or die "<p>Error->"& $DBI::errstri &"</p>";
$dbs = $db->do("VACUUM;");
+
if($LOGOUT){
&logout;
}
-sub cats{
+sub cats {
$cats = qq(<select id="cats" name="cats"><option value="0">---</option>\n);
$dbs = dbExecute("SELECT ID, NAME FROM CAT ORDER BY ID;");
while ( my @row = $dbs->fetchrow_array() ) {
$cats .= '</select>';
}
-sub dbExecute{
+sub dbExecute {
my $ret = $db->prepare(shift);
$ret->execute() or die "<p>ERROR->"& $DBI::errstri &"</p>";
return $ret;
exit;
}
-sub getTheme{
+sub getTheme {
if ( $THEME eq 'Sun' ) {
SELECT ID_CAT, DATE, LOG, AMOUNT, AFLAG, RTF
FROM life_log_temp_table ORDER by DATE;');
$dbs = dbExecute('DROP TABLE life_log_temp_table;');
+}
+
+sub removeOldSessions {
+ opendir(DIR, $LOG_PATH);
+ my @files = grep(/cgisess_*/,readdir(DIR));
+ closedir(DIR);
+ my $now = time - (24 * 60 * 60);
+ foreach my $file (@files) {
+ my $mod = (stat("$LOG_PATH/$file"))[9];
+ if($mod<$now){
+ unlink "$LOG_PATH/$file";
+ }
+ }
}
\ No newline at end of file
# Programed by: Will Budic
# Open Source License -> https://choosealicense.com/licenses/isc/
#
-package main;
use strict;
use warnings;
use Try::Tiny;
our $LOG_PATH = '../../dbLifeLog/';
our $SESSN_EXPR = '+30m';
our $DATE_UNI = '0';
-our $RELEASE_VER = '1.6';
+our $RELEASE_VER = '1.7';
our $AUTHORITY = '';
our $IMG_W_H = '210x120';
our $AUTO_WRD_LMT= 200;
my $passw = $cgi->param('passw');
my $frm;
-
#This is the OS developer release key, replace on istallation. As it is not secure.
my $cipher_key = '95d7a85ba891da';
-style => { -type => 'text/css', -src => "wsrc/$TH_CSS" },
);
-
+my $ip =`hostname -I`;
+ $ip =~ s/\s/<br>/g;
$frm = qq(
<form id="frm_login" action="login_ctr.cgi" method="post"><table border="0" width="$PRC_WIDTH%">
<tr class="r0">
Alias will create a new database if it doesn't exist. Note down your password.
<input type="hidden" name="CGISESSID" value="$sid"/>
<input type="hidden" name="login" value="1"/></td></tr>
- <tr class="r0"><td colspan="2"></td><td><input type="submit" value="Login"/></td></tr>
+ <tr class="r0"><td colspan="2">You are on Server -> <b>$ip</b></td><td><input type="submit" value="Login"/></td></tr>
</table></form>);
print qq(<br><br><div id=rz>
$session->param('database', 'data_'.$alias.'_log.db');
$session->flush();
print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie, -location=>"main.cgi");
- return 1;
+ return 1; #activate redirect to main, main will check credentials.
}
- }
+ }
else{
- &removeOldSessions;
- }
+ $alias = $passw = "";
+ }
+ &removeOldSessions; #and prompt for login returning 0
return 0;
}
catch{
if(@set && $set[0]=="1"){
$alias = $cre[0];
$passw = $cre[1];
+ &removeOldSessions;
}
$db->disconnect();
}
}
}
-sub checkCreateTables{
+sub checkCreateTables {
try{
my $today = DateTime->now;
$today->set_time_zone( $TIME_ZONE );
$rv = $db->do($stmt);
if($rv < 0){print "<p>Error->"& $DBI::errstri &"</p>"};
-
+ $st = $db->prepare("SELECT ALIAS, PASSW, EMAIL, ACTION FROM AUTH WHERE alias='$alias' AND passw='$passw';");
+ $st->execute();
+ my @res = $st->fetchrow_array();
+ if(scalar @res == 0) {
+ $st = $db->prepare('INSERT INTO AUTH VALUES (?,?,?,?);');
+ $st->execute($alias, $passw,"",0);
+ }
}
#
# Scratch FTS4 implementation if present.
if($rv < 0){print "<p>Error->"& $DBI::errstri &"</p>"};
}
- $st = $db->prepare("SELECT ALIAS, PASSW, EMAIL, ACTION FROM AUTH WHERE alias='$alias' AND passw='$passw';");
- $st->execute();
- my @res = $st->fetchrow_array();
- if(scalar @res == 0) {
- $st = $db->prepare('INSERT INTO AUTH VALUES (?,?,?,?);');
- $st->execute($alias, $passw,"",0);
- }
$st = $db->prepare(selSQLTbl('CONFIG'));
$st->execute();
}elsif($table_type==1){
my @pair = $tick[0] =~ m[(\S+)\s*\|\s*(\S+)]g;
if ( scalar(@pair)==2 ) {
- my $st = $db->prepare("SELECT rowid FROM CONFIG WHERE NAME LIKE '$pair[1]';");
+ my $st = $db->prepare("SELECT ID FROM CAT WHERE NAME LIKE '$pair[1]';");
$st->execute();
$inData = 1;
if(!$st->fetchrow_array()) {
exit;
}
-sub getTheme{
+sub getTheme {
if ( $THEME eq 'Sun' ) {
print $cgi->header( -expires => "+0s", -charset => "UTF-8" );
print $cgi->start_html(
-title => "Personal Log Login",
+ -BGCOLOR => $BGCOL,
-script =>
{ -type => 'text/javascript', -src => 'wsrc/main.js' },
-style => { -type => 'text/css', -src => 'wsrc/main.css' },
);
-
- print $cgi->center(
- $cgi->div("<b>Access Denied!</b> alias:$userid pass:$password SQL->SELECT * FROM AUTH WHERE alias='$userid' and passw='$password'; ")
- );
+ if($DEBUG){
+ print $cgi->center(
+ $cgi->div("<b>Access Denied!</b> alias:$userid pass:$password SQL->SELECT * FROM AUTH WHERE alias='$userid' and passw='$password'; ")
+ );
+ }
+ else{
+ print $cgi->center(
+ $cgi->div('<h2>Sorry Access Denied!</h2><font color=red><b>You supplied wrong credentials.</b></font>'),
+ $cgi->div('<h3>[<a href="login_ctr.cgi">Login</a>]</h3>')
+ );
+ }
print $cgi->end_html;
$db->disconnect();
our $LOG_PATH = '../../dbLifeLog/';
our $SESSN_EXPR = '+30m';
our $DATE_UNI = '0';
-our $RELEASE_VER = '1.6';
+our $RELEASE_VER = '1.7';
our $AUTHORITY = '';
our $IMG_W_H = '210x120';
our $AUTO_WRD_LMT = 1000;