# Branch Development Life Log in Perl
-*This page lists current development and issues being worked on in the LifeLog app. Being in the **Sun** stage, means there is a production environment. And usable, used. When, the project reaches **Earth** stage. It will be at its final specification. No data structures or major new features can be added or requested anymore. Only bug fixes, enhancements and efficiency fixes, if any at the **Earth** stage.*
+*This page lists current development and issues being worked on in the LifeLog app. Being in the **Sun** stage, means there is a production environment. And usable, and in use. When, the project reaches **Earth** stage. It will be at its final specification. No data structures or major new features can be added or requested anymore. Only bug fixes, enhancements and efficiency fixes, if any at the **Earth** stage.*
## Life Log Development
### v.2.1 SUN STABLE New Features in Works
-* Provide office share link for main.inf linked categories, No login required but not log creation or search is possible.
-* ✔ Make the dbname uniform across all source types with Settings, as backups use the file format, not the database name.
+* Implement mapped provision of named timezones via main.inf, for towns not available in global list.
+* ✔ Provide office share public link for main.inf linked categories, No login required but no log creation or search is possible.
+* ✔ main.inf - Make the dbname uniform across all source types with Settings, as backups use the file format, not the database name.
* 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)
-* Search button should be an and on previous views settings. Otherwise lists entries of other categories containing an word.
* Provide markdown text functionality to html pages. For quick vanilla plain documentation.
* 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)
* ✔ Edit button to show if hidden is the log entry section.
# ProgresSQL DB driver. Remove -> '!' prefix to tag name, to enable.
<<!DBI_SOURCE<DBI:Pg:host=localhost;>
-# Set folowing to an database name, if multiple aliases connect to a single log database.
+# 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>
#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 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.
+<<!PUBLIC_LOGIN<admin/admin>
+
<<CONFIG<4>
00|$RELEASE_VER = 2.1`LifeLog Application Version.
01|$REC_LIMIT = 25`Records shown per page.
my @backups = ();
-my ($bck_list) ="";
+my ($file, $bck_list) ="";
opendir my $dir, &Settings::logPath;
-while(my $file = readdir $dir){
+while($file = readdir $dir){
next if $file eq '.' or $file eq '..' or index ($file , 'bck_') == -1;
push @backups, $file;
}
close $dir;
-foreach my $file (sort @backups){
+foreach $file (sort @backups){
#my $n = substr $file, length(&Settings::logPath);
$bck_list .= "<input name='bck_file' type='radio' value='$file'>$file</input><br>";
}
open(my $fh, '<', Settings::logPath().'main.cnf' ) or LifeLogException->throw("Can't open main.cnf: $!");
while (my $line = <$fh>) {
chomp $line;
- $v = parseAutonom('AUTO_LOGIN',$line);
- if($v){ @cre = split '/', $v; next}
- $v = parseAutonom('BACKUP_ENABLED',$line);
- if($v){ $BACKUP_ENABLED = $v; next}
- $v = parseAutonom('DBI_SOURCE',$line);
+ $v = Settings::parseAutonom('AUTO_LOGIN',$line);
+ if($v){@cre = split '/', $v; next}
+ $v = Settings::parseAutonom('BACKUP_ENABLED',$line);
+ if($v){$BACKUP_ENABLED = $v; next}
+ $v = Settings::parseAutonom('DBI_SOURCE',$line);
if($v){Settings::dbSrc($v); next}
- $v = parseAutonom('AUTO_SET_TIMEZONE',$line);
+ $v = Settings::parseAutonom('AUTO_SET_TIMEZONE',$line);
if($v){$AUTO_SET_TIMEZONE = $v; next}
- last if parseAutonom('CONFIG',$line); #By specs the config tag, is not an autonom, if found we stop reading. So better be last one spec. in file.
+ last if Settings::parseAutonom('CONFIG',$line); #By specs the config tag, is not an autonom, if found we stop reading. So better be last one spec. in file.
}
close $fh;
if(@cre &&scalar(@cre)>1){
$passw = $cre[1] if (!$passw);
$db = Settings::connectDB($alias, $passw);
#check if autologin enabled.
- my $st = Settings::selectRecords($db,"SELECT VALUE FROM CONFIG WHERE NAME='AUTO_LOGIN';");
- my @set = $st->fetchrow_array() if $st;
- if($set[0]=="1"){
- $alias = $cre[0];
- $passw = $passw;
- Settings::removeOldSessions();
- }
+ my $st = Settings::selectRecords($db,"SELECT VALUE FROM CONFIG WHERE NAME='AUTO_LOGIN';");
+ if($st){my @set = $st->fetchrow_array();
+ if($set[0]=="1"){
+ $alias = $cre[0];
+ $passw = $passw;
+ Settings::removeOldSessions();
+ }
+ }
}
}
-sub parseAutonom { #Parses autonom tag for its crest value, returns undef if tag not found or wrong for passed line.
- my $t = '<<'.shift.'<';
- my $line = shift;
- if(rindex ($line, $t, 0)==0){#@TODO change the following to regex parsing:
- my $l = length $t;
- my $e = index $line, ">", $l + 1;
- return substr $line, $l, $e - $l;
- }
- return undef;
-}
sub checkPreparePGDB {
my $create =1;
my ($vmode, $imgw, $imgh );
if ( !$alias || !$passw) {
- print $cgi->redirect("login_ctr.cgi?CGISESSID=$sid");
+ print $cgi->redirect("alogin_ctr.cgi?CGISESSID=$sid");
exit;
}
-
### Authenticate session to alias passw
&authenticate;
#
+
+
my $log_rc = 0;
my $log_rc_prev = 0;
my $log_cur_id = 0;
my $stmE = ' LIMIT '.&Settings::viewAllLimit.';';
my $stmD = "";
my $sm_reset_all;
-my $rec_limit = &Settings::recordLimit;
+my $rec_limit = Settings::recordLimit();
### Page specific settings Here
-my $TH_CSS = &Settings::css;
-my $BGCOL = &Settings::bgcol;
+my $TH_CSS = Settings::css();
+my $BGCOL = Settings::bgcol();
#Set to 1 to get debug help. Switch off with 0.
-my $DEBUG = &Settings::debug;
+my $DEBUG = Settings::debug();
#END OF SETTINGS
my $BUFFER;
my $st;
my $sqlCAT = "SELECT ID, NAME, DESCRIPTION FROM CAT ORDER BY ID;";
my $sqlVWL = "$stmS STICKY = true $stmE";
+my $isPUBViewMode = Settings::pub() && Settings::sqlPubors();
toBuf ("## Using db ->". Settings::dsn(). "\n") if $DEBUG;
$data_cats .= qq(<meta id="cats[$key]" name="$n" content="$kv">\n);
}
}
+my $eh;
+if($isPUBViewMode){$eh = ""}else{$eh='<th>Edit</th>'}
my $log_output =
qq(<FORM id="frm_log" action="data.cgi" onSubmit="return formDelValidation();">
<TABLE class="tbl" border="0" width=").&Settings::pagePrcWidth.qq(%">
<th>Time</th>
<th>Log</th><th>#</th>
<th>Category</th>
- <th>Edit</th>
+ $eh
</tr>);
#We use js+perl, trickery to filter by amount type, as well.
- if ($prm_aa >0){my $s = $prm_aa - 1;$prm_aa = " AFLAG=$s AND";}else{$prm_aa=""}
+ if($prm_aa >0){my $s = $prm_aa - 1;$prm_aa = " AFLAG=$s AND";}else{$prm_aa=""}
+ if($prm_rtf){$stmS .= " ID_RTF>0 AND";}
- $stmS .= " ID_RTF>0 AND" if($prm_rtf);
-
- if ( $rs_keys && $rs_keys ne '*' ) {
+ if($isPUBViewMode){
+ $sqlVWL = $stmS." ".Settings::sqlPubors().$stmE;
+ }
+ elsif ( $rs_keys && $rs_keys ne '*' ) {
my @keywords = split / /, $rs_keys;
if ($prm_vc && $prm_vc != $prm_xc) {
$sqlVWL = "$stmS STICKY = false $stmE";
toBuf $cgi->pre("###2 -> ".$sqlVWL) if $DEBUG;
;
- &buildLog(traceDBExe($sqlVWL));
+ buildLog(traceDBExe($sqlVWL));
}
<td id="v$id" class="log" width="40%">$log</td>
<td id="a$id" width="10%" class="tbl">$am</td>
<td id="c$id" width="10%" class="tbl">$ct</td>
+ );
+ if(!$isPUBViewMode){$log_output .= qq(
<td width="20%">
<input id="r$id" type="hidden" value="$rtf"/>
<input id="s$id" type="hidden" value="$sticky"/>
<input id="f$id" type="hidden" value="$af"/>
<button class="edit" value="Edit" onclick="return edit($id);">$ssymb</button>
<input name="chk" type="checkbox" value="$pid"/>
- </td></tr>);
+ </td></tr>)};
if ( $rtf > 0 ) {
$log_output .= qq(<tr id="q-rtf$id" class="r$tfId" style="display:none;">
}else{ $log_output .= '<tr id="brw_row"><td colspan="5"><b>Database is New or Empty!</b></td></tr>'}
}
}
+if($isPUBViewMode){
+}
+else{
$log_output .= <<_TXT;
<tr class="r0" id="brw_row"><td colspan="2">Show All hidden with ➔
<a id="menu_close" href="#" onclick="return showAll();"><span class="ui-icon ui-icon-heart" style="float:none;"></span></a>
<input type="submit" value="Search"/></td></tr>
</TABLE>
</form>);
-
+};
my ( $sp1, $sp2, $sp3 );
$sp1 = '<span class="ui-icon ui-icon-heart"></span>';
$sp2 = '<span class="ui-icon ui-icon-circle-triangle-s"></span>';
else {$srh .= '</tr>'};
$srh .= '</table></form>';
+
+my $sideMenu;
+my $tail = q(<div><a class="a_" href="stats.cgi">View Statistics</a></div><br>
+<div><a class="a_" href="config.cgi">Configure Log</a></div><hr>
+<div><a class="a_" href="login_ctr.cgi?logout=bye">LOGOUT</a><hr><a name="bottom"></a></div>);
+if($isPUBViewMode){$sideMenu=$frm=$srh=$tail=""}else{
+ $sideMenu = qq(
+ <div id="menu" title="To close this menu click on its heart, and wait.">
+ <div class="hdr" style="marging=0;padding:0px;">
+ <a id="to_top" href="#top" title="Go to top of page."><span class="ui-icon ui-icon-arrowthick-1-n" style="float:none;"></span></a>
+ <a id="to_bottom" href="#bottom" title="Go to bottom of page."><span class="ui-icon ui-icon-arrowthick-1-s" style="float:none;"></span></a>
+ <a id="menu_close" href="#" onclick="return hideLog();"><span class="ui-icon ui-icon-heart" style="float:none;"></span></a>
+ </div>
+ <hr>
+ <a class="a_" onclick="return toggle('#div_log',true);">Log</a><br>
+ <a href="#" title="TOP" onclick="return submitTop();" ><span class="ui-icon ui-icon-triangle-1-w" style="float:none;"></span></a>
+ <a href="#" title="PREVIOUS" onclick="return submitPrev($log_rc_prev, $rec_limit);"><span class="ui-icon ui-icon-arrowthick-1-w" style="float:none;"></span></a>
+ <a href="#" title="NEXT" onclick="return submitNext($log_cur_id, $rec_limit);"><span class="ui-icon ui-icon-arrowthick-1-e" style="float:none;"></span></a>
+ <a href="#" title="END" onclick="return submitEnd($rec_limit);"><span class="ui-icon ui-icon-triangle-1-e" style="float:none;"></span></a>
+ <hr>
+ <a class="a_" onclick="return toggle('#div_srh',true);">Search</a><hr>
+ <a class="a_" onclick="return deleteSelected();">Delete</a><hr>
+ <a class="a_" onclick="return toggle('#tbl_hlp',true);">Help</a><hr>
+ <a class="a_" href="stats.cgi">Stats</a><hr>
+ <a class="a_" href="config.cgi">Config</a><hr>
+ <a class="a_" id="lnk_show_all" onclick="return showAll();">Show All <span class="ui-icon ui-icon-heart"></span></a><hr>
+ $sm_reset_all
+ <a class="a_" href="login_ctr.cgi?logout=bye">LOGOUT</a><br><hr>
+ <span style="font-size: x-small; font-weight: bold;">$vmode</span><br>
+ </div>
+ );
+}
+
+
my $quill = &quill( $cgi->param('submit_is_edit') );
my $help = &help;
- ##################################
- # Final Page Output from here! #
- ##################################
+##################################
+# Final Page Output from here! #
+##################################
+
toBuf (qq(
-<div id="menu" title="To close this menu click on its heart, and wait.">
-<div class="hdr" style="marging=0;padding:0px;">
-<a id="to_top" href="#top" title="Go to top of page."><span class="ui-icon ui-icon-arrowthick-1-n" style="float:none;"></span></a>
-<a id="to_bottom" href="#bottom" title="Go to bottom of page."><span class="ui-icon ui-icon-arrowthick-1-s" style="float:none;"></span></a>
-<a id="menu_close" href="#" onclick="return hideLog();"><span class="ui-icon ui-icon-heart" style="float:none;"></span></a>
-</div>
-<hr>
-<a class="a_" onclick="return toggle('#div_log',true);">Log</a><br>
-<a href="#" title="TOP" onclick="return submitTop();" ><span class="ui-icon ui-icon-triangle-1-w" style="float:none;"></span></a>
-<a href="#" title="PREVIOUS" onclick="return submitPrev($log_rc_prev, $rec_limit);"><span class="ui-icon ui-icon-arrowthick-1-w" style="float:none;"></span></a>
-<a href="#" title="NEXT" onclick="return submitNext($log_cur_id, $rec_limit);"><span class="ui-icon ui-icon-arrowthick-1-e" style="float:none;"></span></a>
-<a href="#" title="END" onclick="return submitEnd($rec_limit);"><span class="ui-icon ui-icon-triangle-1-e" style="float:none;"></span></a>
-<hr>
-<a class="a_" onclick="return toggle('#div_srh',true);">Search</a><hr>
-<a class="a_" onclick="return deleteSelected();">Delete</a><hr>
-<a class="a_" onclick="return toggle('#tbl_hlp',true);">Help</a><hr>
-<a class="a_" href="stats.cgi">Stats</a><hr>
-<a class="a_" href="config.cgi">Config</a><hr>
-<a class="a_" id="lnk_show_all" onclick="return showAll();">Show All <span class="ui-icon ui-icon-heart"></span></a><hr>
-$sm_reset_all
-<a class="a_" href="login_ctr.cgi?logout=bye">LOGOUT</a><br><hr>
-<span style="font-size: x-small; font-weight: bold;">$vmode</span><br>
-</div>
- <div id="div_log">$frm</div>
- <div id="div_srh">$srh</div>
- $quill
- <div id="div_hlp">$help</div>
- <div>\n$log_output\n</div><br>
- <div><a class="a_" href="stats.cgi">View Statistics</a></div><br>
- <div><a class="a_" href="config.cgi">Configure Log</a></div><hr>
- <div><a class="a_" href="login_ctr.cgi?logout=bye">LOGOUT</a><hr><a name="bottom"></a></div>
+$sideMenu
+<div id="div_log">$frm</div>
+<div id="div_srh">$srh</div>
+$quill
+<div id="div_hlp">$help</div>
+<div>\n$log_output\n</div><br>
+$tail
<!-- Cat Data Start -->
<span id="meta_cats">
$data_cats
$vmode = "[In Page Mode] ";
$vmode = "<font color='red'>[In View Mode]</font> " if$isInViewMode;
-
- if($rec_limit == 0){
+ if($isPUBViewMode){
+ $log_output .=qq!<tr class="r$tfId" id="brw_row"><td>$vmode</td><td colspan="3"></td>!;
+ }
+ elsif($rec_limit == 0){
$log_output .= qq!<tr class="r$tfId" id="brw_row"><td>$vmode</td><td colspan="3">
<input class="ui-button" type="button" onclick="submitTop($log_top);return false;" value="Back To Page View"/>!;
our $DBFILE;
our $IS_PG_DB = 0;
-my ($cgi, $sss, $sid, $alias, $pass, $dbname);
+my ($cgi, $sss, $sid, $alias, $pass, $dbname, $pub);
#Annons here, variables that could be overiden in code or database, per need.
#200 -> '^REL_RENUM' : this.$RELEASE_VER (Used in login_ctr.cgi)
#201 -> '^EXCLUDES' : 0 (Used in main.cgi)
-sub anons {return sort keys %anons}
+our $SQL_PUB = "";
+
+sub anons {my @ret=sort(keys %anons); return @ret;}
#Check call with defined(Settings::anon('my_anon'))
sub anon {my $n=shift; return $anons{$n}}
sub dbName {return $dbname;}
sub dsn {return $DSN}
sub isProgressDB {return $IS_PG_DB}
+sub sqlPubors {return $SQL_PUB}
+
+sub trim {my $r=shift; $r=~s/^\s+|\s+$//g; return $r}
sub fetchDBSettings {
try {
$dbname = $sss->param('database');
$alias = $sss->param('alias');
$pass = $sss->param('passw');
- if(!$alias||!$dbname){
+ $pub = $cgi->param('pub');
+ if($pub){#we override session to obtain pub(alias)/pass from config.
+ open(my $fh, '<', logPath().'main.cnf' ) or LifeLogException->throw("Can't open main.cnf: $!");
+ while (my $line = <$fh>) {
+ chomp $line;
+ my $v = Settings::parseAutonom('PUBLIC_LOGIN',$line);
+ if($v){my @cre = split '/', $v;
+ $alias = $cre[0];
+ $pass = uc crypt $cre[1], hex Settings->CIPHER_KEY;
+ }
+ $v = Settings::parseAutonom('PUBLIC_CATS',$line);
+ if($v){my @cats= split(',',$v);
+ foreach(@cats){
+ $SQL_PUB .= "ID_CAT=".trim($_)." OR ";
+ }
+ $SQL_PUB =~ s/\s+OR\s+$//;
+ }
+ last if Settings::parseAutonom('CONFIG',$line);
+ }
+ close $fh;
+ }
+ elsif(!$alias||!$dbname){
print $cgi->redirect("login_ctr.cgi?CGISESSID=$sid");
exit;
}
- my $ret = connectDB($alias, $pass);
+
+ print "a:$alias/p:$pass";
+ my $ret = connectDB($alias, $pass);
dbSrc($sss->param('db_source'));
getConfiguration($ret);
+
getTheme();
$sss->expire($SESSN_EXPR);
return $ret;
sub dbname {return $dbname}
sub alias {return $alias}
sub pass {return $pass}
+sub pub {return $pub}
sub today {
my $ret = DateTime->now();
}
sub createCONFIGStmt {
-if($IS_PG_DB){qq(
+if($IS_PG_DB){return qq(
CREATE TABLE CONFIG(
ID INT NOT NULL UNIQUE GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
NAME VARCHAR(16) UNIQUE,
$st->execute();
while ( my @r = $st->fetchrow_array() ){
switch ( $r[1] ) {
- case "RELEASE_VER" { $RELEASE_VER = $r[2]}
- case "TIME_ZONE" { $TIME_ZONE = $r[2]}
- 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 "RELEASE_VER" {$RELEASE_VER = $r[2]}
+ case "TIME_ZONE" {$TIME_ZONE = $r[2]}
+ 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 "LOG_PATH" {} #ommited and code static can't change for now.
- case "IMG_W_H" { $IMG_W_H = $r[2]}
- case "REC_LIMIT" { $REC_LIMIT = $r[2]}
- case "AUTO_WRD_LMT" { $AUTO_WRD_LMT = $r[2]}
- case "VIEW_ALL_LMT" { $VIEW_ALL_LMT = $r[2]}
- case "DISP_ALL" { $DISP_ALL = $r[2]}
- case "FRAME_SIZE" { $FRAME_SIZE = $r[2]}
- case "RTF_SIZE" { $RTF_SIZE = $r[2]}
- case "THEME" { $THEME = $r[2]}
- case "DEBUG" { $DEBUG = $r[2]}
- case "KEEP_EXCS" { $KEEP_EXCS = $r[2]}
- case "TRACK_LOGINS" { $TRACK_LOGINS = $r[2]}
- case "COMPRESS_ENC" { $COMPRESS_ENC = $r[2]}
- else { $anons{$r[1]} = $r[2]}
+ case "IMG_W_H" {$IMG_W_H = $r[2]}
+ case "REC_LIMIT" {$REC_LIMIT = $r[2]}
+ case "AUTO_WRD_LMT" {$AUTO_WRD_LMT = $r[2]}
+ case "VIEW_ALL_LMT" {$VIEW_ALL_LMT = $r[2]}
+ case "DISP_ALL" {$DISP_ALL = $r[2]}
+ case "FRAME_SIZE" {$FRAME_SIZE = $r[2]}
+ case "RTF_SIZE" {$RTF_SIZE = $r[2]}
+ case "THEME" {$THEME = $r[2]}
+ case "DEBUG" {$DEBUG = $r[2]}
+ case "KEEP_EXCS" {$KEEP_EXCS = $r[2]}
+ case "TRACK_LOGINS" {$TRACK_LOGINS = $r[2]}
+ case "COMPRESS_ENC" {$COMPRESS_ENC = $r[2]}
+ else {$anons{$r[1]} = $r[2]}
}
}
#Anons are murky grounds. -- @bud
LifeLogException->throw(error=>"<p>Error->$@</p>", show_trace=>1);
}
}
+
+sub parseAutonom { #Parses autonom tag for its crest value, returns undef if tag not found or wrong for passed line.
+ my $t = '<<'.shift.'<';
+ my $line = shift;
+ if(rindex ($line, $t, 0)==0){#@TODO change the following to regex parsing:
+ my $l = length $t;
+ my $e = index $line, ">", $l + 1;
+ return substr $line, $l, $e - $l;
+ }
+ return undef;
+}
+
1;
\ No newline at end of file