* ✔ Multi db driver type support. Earth stage requires same SQL related code to work on at least one more DBMS type other than SQLight.
* PostgreSQL is the candidate as MySQL is not easy to install and bulky for all systems.
* Developing and adopting to MySQL or any other system is not prerogative, as it works well as it is with inbuilt simplicity.
+* ✔ Single database, multi-user login.
* Static pages setting for the pages directory.
-* Search on multiple words should rank by encounter of words specified and display first. (That one is difficult)
* Provide markdown text functionality to html pages. For quick vanilla plain documentation.
+* Search on multiple words should rank by encounter of words specified and display first. (That one is difficult)
* Auto collapse/expand on multi line logs by 0-none as default. Setting to 1 or more shows only that number of lines. (That one is difficult)
### v.2.0 SUN RC2 Encountered
# Default database driver prefix, is SQLite.
<<DBI_SOURCE<DBI:SQLite:>
# ProgresSQL DB driver. Remove -> '!' prefix to tag name, to enable, and override the above SQLite one.
-<<!DBI_SOURCE<DBI:Pg:host=localhost;>
+<<DBI_SOURCE<DBI:Pg:host=localhost;>
# LOG actual variable size limit, - 1024 default, 128 minimum value.
-#<<DBI_LOG_VAR_SIZE<1024>
-# Set following to an database name, if multiple aliases connect to a single log database.
-# Users have to be set, and alias is then used for their userid to be able to login.
-# By default this setting is disabled with 0, making alias, its own log database.
-<<DBI_MULTI_USER_DB<0>
+<<!DBI_LOG_VAR_SIZE<1024>
+
+# Set the following to an database name, with external managed multiple users, that are to connect to a single database.
+# Users have to be externally set, and alias is then used for their userid to be able to login. (Add user roles to AUTH table).
+# By default this setting is disabled with 0, making alias name, its own log database, per user.
+<<DBI_MULTI_USER_DB<>
#Timezoning, if set to 1, country locale setting for timezone in config page is ignored.
<<AUTO_SET_TIMEZONE<0>
-# Public, enabled list of categories. Remove -> '!' prefix to tag name, to enable. Be careful what category you add/enable here.
+# Public, enabled list of categories. Remove -> '!' prefix before tag name, to enable. Be careful what category you add/enable here.
# Public records view feature only, it doesn't allow new log entries to be added and have pin point searching of all existing.
<<!PUBLIC_CATS<03,06,09>#File,System log and Event.
# Following is similar to AUTO_LOGIN setting above, and must be set.
<<CONFIG<4>
00|$RELEASE_VER = 2.1`LifeLog Application Version.
01|$REC_LIMIT = 25`Records shown per page.
-03|$TIME_ZONE = Australia/Sydney`Time zone of your country.
+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.
my $db = Settings::fetchDBSettings();
my $cgi = Settings->cgi();
my $sid = Settings::sid();
-my $dbname = Settings::dbname();
+my $dbname = Settings::dbName();
my $alias = Settings::alias();
my $rv;
my $dbs;
my $db = Settings::fetchDBSettings();
my $cgi = Settings->cgi();
-my $dbname = Settings::dbname();
+my $dbname = Settings::dbName();
my $imgw = 210;
my $imgh = 120;
my $human = DateTime::Format::Human::Duration->new();
my $BACKUP_ENABLED = 0;
my $AUTO_SET_TIMEZONE = 0;
my $TIME_ZONE_MAP = 0;
+my $DB_NAME;
try{
checkAutologinSet();
$session->param('passw', $passw);
$session->param('db_source', Settings::dbSrc());
$session->param('db_file', Settings::dbFile());
- $session->param('database', Settings::dbname());
+ $session->param('database', Settings::dbName());
$session->flush();
### To MAIN PAGE
print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie, -location=>"main.cgi");
if($v){$AUTO_SET_TIMEZONE = $v; next}
$v = Settings::parseAutonom('DBI_LOG_VAR_SIZE',$line);
if($v){Settings::dbVLSZ($v); next}
+ # From here are config file only autonoms. Don't need or harm being in database configuration.
+ $v = Settings::parseAutonom('DBI_MULTI_USER_DB',$line);
+ if($v){$DB_NAME=$v;Settings::dbName($v);next}
if($line =~ /<<TIME_ZONE_MAP</){
$TIME_ZONE_MAP = substr($line,16);
while ($line = <$fh>) {
return; # Note, we do assign entered password even passw as autologin is set. Not entering one bypasses this.
} # If stricter access is required set it to zero in main.cnf, or disable in config.
$passw = $cre[1] if (!$passw);
- $db = Settings::connectDB($alias, $passw);
+ $db = Settings::connectDB($DB_NAME, $alias, $passw);
#check if autologin enabled.
my $st = Settings::selectRecords($db,"SELECT VALUE FROM CONFIG WHERE NAME='AUTO_LOGIN';");
if($st){my @set = $st->fetchrow_array();
sub checkPreparePGDB {
my $create =1;
- $passw = $cgi->param('passw'); #PG handles password encryption itself.
+ $passw = $cgi->param('passw'); #We let PG handles password encryption (security) itself.
my @data_sources = DBI->data_sources("Pg");
foreach my $ln (@data_sources){
my $i = rindex $ln, '=';
# If brand new database, this sill returns fine an empty array.
my %curr_tables = ();
- if(Settings::isProgressDB()){
+ if(Settings::isProgressDB()){
$changed = checkPreparePGDB();
- $db = Settings::connectDB($alias, $passw);
+ $db = Settings::connectDB($DB_NAME, $alias, $passw);
my @tbls = $db->tables(undef, 'public');
foreach (@tbls){
my $t = uc substr($_,7);
}
}
else{
- $db = Settings::connectDB($alias, $passw);
+ $db = Settings::connectDB($DB_NAME, $alias, $passw);
$pst = Settings::selectRecords($db,"SELECT name FROM sqlite_master WHERE type='table' or type='view';");
while(my @r = $pst->fetchrow_array()){
$curr_tables{$r[0]} = 1;
$db->do('DROP VIEW VW_LOG;');delete($curr_tables{'VW_LOG'});
delete($curr_tables{'VW_LOG'});
$changed = 1;
- }
+ }elsif($SCRIPT_RELEASE > $DB_VERSION){$changed = 1;}
if(!$hasLogTbl) {
$alias = $session->param('alias');
$passw = $session->param('passw');
if($alias){
- my $db = Settings::connectDB($alias, $passw);
- Settings::toLog($db, "Log properly loged out by $alias.");
+ my $db = Settings::connectDB($DB_NAME, $alias, $passw);
+ Settings::toLog($db, "Log has properly been loged out by $alias.");
$db->disconnect();
}
}catch{
my $db = Settings::fetchDBSettings($cgi);
my $sss = Settings::session();
my $sid = Settings::sid();
-my $dbname = Settings::dbname();
+my $dbname = Settings::dbName();
my $alias = Settings::alias();
my $passw = Settings::pass();
return $DBI_SOURCE}
sub dbVLSZ {my $r = shift; if(!$r){$r = $DBI_LVAR_SZ}else{$r=128 if($r<128);$DBI_LVAR_SZ=$r} return $r}
sub dbFile {my $r = shift; if($r) {$DBFILE=$r} return $DBFILE}
-sub dbName {return $dbname}
+sub dbName {my $r = shift; if($r) {$dbname=$r} return $dbname}
sub dsn {return $DSN}
sub isProgressDB {return $IS_PG_DB}
sub sqlPubors {return $SQL_PUB}
sub cgi {return $cgi}
sub session {return $sss}
sub sid {return $sid}
-sub dbname {return $dbname}
sub alias {return $alias}
sub pass {return $pass}
sub pub {return $pub}
# if(!$alias){
# $alias = "admin"; $pass = $alias; dbSrc('dbi:Pg:host=localhost;');
# }
- if(!$alias){
+ if(!$alias){
print $cgi->redirect("login_ctr.cgi?CGISESSID=$sid");
exit;
- }
- my $ret = connectDB($alias, $pass);
+ }
+ my $ret = connectDB($dbname, $alias, $pass);
getConfiguration($ret);
getTheme();
$sss->expire($SESSN_EXPR);
}
sub connectDB {
- my ($a,$p) = @_;
- $a = $alias if(!$a);
+ my ($d,$u,$p) = @_;
+ $u = $alias if(!$u);
$p = $alias if(!$p);
- $dbname = 'data_'.$a.'_log.db';
- $DBFILE = $LOG_PATH.$dbname if(!$DBFILE);
- if ($IS_PG_DB) {
- $DSN = $DBI_SOURCE .'dbname='.$a; $DBFILE = $a;
- }else{
- $DSN = $DBI_SOURCE .'dbname='.$DBFILE;
- }
+ my $db =$u;
+ if(!$d){$db = 'data_'.$u.'_log.db';}
+ else{ $db = 'data_'.$d.'_log.db';}
+ $DBFILE = $LOG_PATH.'/'.$db;
+ if ($IS_PG_DB) {
+ $DSN = $DBI_SOURCE .'dbname='.$d;
+ }else{
+ $DSN = $DBI_SOURCE .'dbname='.$DBFILE;
+ }
try{
- return DBI->connect($DSN, $a, $p, {AutoCommit => 1, RaiseError => 1, PrintError => 0, show_trace=>1});
+ return DBI->connect($DSN, $u, $p, {AutoCommit => 1, RaiseError => 1, PrintError => 0, show_trace=>1});
}catch{
LifeLogException->throw(error=>"<p>Error->$@</p>", show_trace=>1);
}