From 139628f23578167af7d39ae3587e2ba307c10c9d Mon Sep 17 00:00:00 2001 From: wbudic Date: Tue, 9 Feb 2021 11:07:53 +1100 Subject: [PATCH] Upd. to v.2.2 --- dbLifeLog/main.cnf | 106 +++++++++------------- htdocs/cgi-bin/system/modules/Settings.pm | 39 +++++--- 2 files changed, 70 insertions(+), 75 deletions(-) diff --git a/dbLifeLog/main.cnf b/dbLifeLog/main.cnf index 36f3b51..8d7830b 100644 --- a/dbLifeLog/main.cnf +++ b/dbLifeLog/main.cnf @@ -41,36 +41,15 @@ America/Texas=America/Chicago >> -# Setting to modify the page view to exclude older log entries by a list of categories from today minus days back. -# This is to avoid and page only list relevant logs on logon. Searching by category will list them and still make visible. -# value: {days=}{category id},.. days default to zero, if you don't want from yesterday to the past category entries listed. -< <- (Diary,System Log,Poetry) category id's only, does set in the config page also work. - -/* - Global view overrides. These get generated in the db if set on logon. And used instead of the normal data view. - Overrides must always show todays log entries, regardless of criteria. - Overrides don't affect category and keywords desired searches and views. They are mainly useful to filter out - the not required to see on the main pages. - NOTE - These settings AND on VW_LOG_WITH_EXCLUDES if they are set. VW_ prefix signifies, database view, - meaning this will be created. Based on the settings bellow you make. An interesting concept, don't you think? -*/ +# @See help at bottom of config for all the following. -####################### -# VIEW_OVERRIDE_SYSLOGS overrides not to show system logs older than today. -# Default for 0, disabled. +< <- (Diary,System Log,Poetry) category id's only, does set in the config page also work. <>> - -####################### -# VIEW_OVERRIDE_WHERE overrides what to, or not to select. -# Default is not being used. OLDER_THAN keyword translates to appropriate SQL. -# By either months, days, hours. From current time. -# i.e VIEW_OVERRIDE_WHERE, this instructs skip older then to months logs and all sys logs. -# i.e VIEW_OVERRIDE_WHERE=6>, this instructs skip all categories bellow and including sys logs.. -<>> +<=6 AND >>> < -00|$RELEASE_VER = 2.1`LifeLog Application Version. +00|$RELEASE_VER = 2.2`LifeLog Application Version. 01|$REC_LIMIT = 25`Records shown per page. 03|$TIME_ZONE = Australia/Sydney`Time zone of your country and city. 05|$PRC_WIDTH = 80`Default presentation width for pages. @@ -111,51 +90,54 @@ America/Texas=America/Chicago NOTES|DROP TABLE NOTES;' ver. 1.5 fts4 virtual tables have been scratched as they require special SQLite compilation. LOG<5>|Run Query ' ver. 1.5 -## Following are historical migration changes. +## HELP SECTION ON OPTIONS -//ALTER TABLE LOG RENAME AMOUNT TO AMOUNT; -CREATE TABLE life_log_temp_table AS SELECT * FROM LOG; -DROP TABLE LOG; -//CREATE TABLE LOG ( ID_CAT TINY NOT NULL, DATE DATETIME NOT NULL, LOG VCHAR (128) NOT NULL, AMOUNT INTEGER, AFLAG TINY DEFAULT 0, RTF BOOL DEFAULT 0); -CREATE TABLE LOG ( - ID_CAT TINY NOT NULL, - DATE DATETIME NOT NULL, - LOG VCHAR (128) NOT NULL, - AMOUNT INTEGER, - AFLAG TINY DEFAULT 0, - RTF BOOL DEFAULT 0 -); + Global view overrides. These get generated in the db if set on logon. And used instead of the normal data view. + Overrides must always show todays log entries, regardless of criteria. + Overrides don't affect category and keywords desired searches and views. They are mainly useful to filter out + the not required to see on the main pages. + NOTE - These settings AND on VW_LOG_WITH_EXCLUDES if they are set. VW_ prefix signifies, database view, + meaning this will be created. Based on the settings bellow you make. An interesting concept, don't you think? + +### PAGE_VIEW_EXCLUDES + + Setting to modify the page view to exclude older log entries by a list of categories from today minus days back. + This is to avoid and page only list relevant logs on logon. Searching by category will list them and still make visible. + value: {days=}{category id},.. days default to zero, if you don't want from yesterday to the past category entries listed. + +< <- (Diary,System Log,Poetry) category id's only, does set in the config page also work. -INSERT INTO LOG ( - ID_CAT, - DATE, - LOG, - AMOUNT - ) - SELECT ID_CAT, - DATE, - LOG, - AMOUNT - FROM life_log_temp_table; -DROP TABLE life_log_temp_table; -PRAGMA foreign_keys = 1; +### VIEW_OVERRIDE_SYSLOGS overrides not to show system logs that are older than today. Same to CAT!=6 by default, +# Default is 0, disabled. -%INCOME_ID% = SELECT ID FROM CAT WHERE CAT.NAME LIKE 'Income'; -%EXPENSE_ID% = SELECT ID FROM CAT WHERE CAT.NAME LIKE 'Income'; +### VIEW_OVERRIDE_WHERE + This option overrides what log entries to filter out from the page view, in more detail. + It translated via keywords to appropriate required SQL. This filter by default is + not active on 24 hours old entries. PAGE_VIEW_EXCLUDES option entries are included. +#### CAT is the ID_CAT column, keyword. +* i.e VIEW_OVERRIDE_WHERE= 6>, selects all categories from and category id 6. +PAGE_VIEW_EXCLUDES and VIEW_OVERRIDE_SYSLOGS don't have to be set. But preside if set. -UPDATE LOG SET AFLAG=1 WHERE ID_CAT=%INCOME_ID%; -UPDATE LOG SET AFLAG=2 WHERE ID_CAT=%EXPENSE_ID%; +#### AND/OR keyword, logically joins the instructions. +* i.e VIEW_OVERRIDE_WHERE< CAT > 6 AND CAT != 'Personal' >, selects all categories from +category id 6, excluding resolved category entries. -LOG<6>|Run Query ' ver. 1.6 -ALTER TABLE LOG ADD STICKY BOOL DEFAULT 0; +#### OLDER_THAN keyword translates to date column older than from today up to an specified date in the past. +* This is assigned by either months, days, hours. +** i.e VIEW_OVERRIDE_WHERE, this instructs skip older then to months logs and all sys logs. -LOG<6>|Run Query ' ver. 1.8 +#### FROM/TO in either months, days, hours. +* Selects only FROM or TO an specified date only log entries. +** i.e VIEW_OVERRIDE_WHERE -CREATE TABLE notes_temp_table (LID INTEGER PRIMARY KEY NOT NULL, DOC TEXT); -INSERT INTO notes_temp_table SELECT `LID`,`DOC` FROM `NOTES`; -DROP TABLE `NOTES`; -ALTER TABLE `notes_temp_table` RENAME TO `NOTES`; +#### NOT keyword, logically negates. +** i.e VIEW_OVERRIDE_WHERE, select only log entries that contain attached RTF documents, if they +are older than 24 hours. Remember, the default filtering is on 24 hour and older log entries. +** i.e VIEW_OVERRIDE_WHERE, don't select log entries that contain attached RTF documents. +** i.e VIEW_OVERRIDE_WHERE, +category is not (!=), resolved category id by name. And also exclude all logs older than an year. +All is FROM to OLDER_THAN, affected. So from today (now) to FROM 'will' be paged, visible. \ No newline at end of file diff --git a/htdocs/cgi-bin/system/modules/Settings.pm b/htdocs/cgi-bin/system/modules/Settings.pm index 4f8dba9..62ea71a 100644 --- a/htdocs/cgi-bin/system/modules/Settings.pm +++ b/htdocs/cgi-bin/system/modules/Settings.pm @@ -1,11 +1,13 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl +# +# Web interaction, reusable tri state of configuration concerns, set of utilities. # # Programed by: Will Budic # Open Source License -> https://choosealicense.com/licenses/isc/ # package Settings; -use v5.10; +use v5.14; use strict; use warnings; use Exception::Class ('SettingsException','LifeLogException','SettingsLimitSizeException'); @@ -18,7 +20,7 @@ use DateTime::Format::SQLite; use DateTime::Duration; use DBI; -use experimental qw( switch ); +use experimental 'switch'; # This is the default developer release key, replace on istallation. As it is not secure. use constant CIPHER_KEY => '95d7a85ba891da'; @@ -40,7 +42,7 @@ use constant VW_LOG_WITH_EXCLUDES => 'VW_LOG_WITH_EXCLUDES'; use constant VW_LOG_OVERRIDE_WHERE => 'VW_LOG_OVR_WHERE'; #DEFAULT SETTINGS HERE! -our $RELEASE_VER = '2.1'; +our $RELEASE_VER = '2.2'; our $TIME_ZONE = 'Australia/Sydney'; our $LANGUAGE = 'English'; our $PRC_WIDTH = '60'; @@ -666,23 +668,34 @@ sub connectDB { LifeLogException->throw(error=>"

Error->$@


$DSN

", show_trace=>1); } } -my $reg_autonom = qr/(^<<)(.+?<)(.+)(>{3,})/mp; - -sub parseAutonom { #Parses autonom tag for its crest value, returns undef if tag not found or wrong for passed line. - my $t = shift; +my @F = ('', '""', 'false', 'off', 'no', 0);# Placed 0 last, as never will be checked for in toPropertyValue. +my @T = (1, 'true', 'on', 'yes'); +my $reg_autonom = qr/(<<)(.+?)(<)(\n*.+\s*)(>{3,})/mp; - if($t =~ /$reg_autonom/g){ - my ($tag,$val) = ($2,$3); - $tag =~ s/<$//g; +sub parseAutonom { #Parses autonom tag for its crest value, returns undef if tag not found or wrong for passed line. + my $tag = shift; + my $line = shift; + if($line =~ /$reg_autonom/g){ + my ($t,$val) = ($2,$4); $val =~ s/""$//g; #empty is like not set $val =~ s/^"|"$//g; - if($tag&&$val){ - return $val; + if($t eq $tag&&$val){ + return toPropertyValue( $val ); } } return; } +sub toPropertyValue { + my $prm = shift; + if($prm){ + my $p = lc $prm; + foreach(@T){return 1 if $_ eq $p;} + foreach(@F){return 0 if $_ eq $p;} + } + return $prm; +} + 1; \ No newline at end of file -- 2.34.1