###############
processSubmit();
###############
-Settings::getTheme();
+Settings::setupTheme();
Settings::session()->param("theme", Settings::css());
Settings::session()->param("bgcolor", Settings::bgcol());
getHeader();
<td colspan="1" align="right"><b>Categories Configuration In -> $dbname</b>
<input type="submit" value="Change" onclick="return checkConfigCatsChange()"/></td>
</tr>
- <tr class="r1">
+ <tr class="r2">
<td colspan="3"><div style="text-align:left; float"><font color="red">WARNING!</font>
Removing or changing categories is permanent! Each category one must have an unique ID.
Blank a category name to remove it. LOG records will change to the
$u = "SELECTED"
}
$v = qq(<select id="dumi" name="var$i">
- <option value="0" $l>Locale</option>
- <option value="1" $u>Universal</option>
- </select>);
+ <option value="0" $l>Locale</option>
+ <option value="1" $u>Universal</option>
+ </select>);
}
elsif($n eq "AUTO_LOGIN"){
my($l,$u)=("","");
<option$s2>Moon</option>
<option$s3>Earth</option>
</select>);
- }
- elsif($n eq "KEEP_EXCS" or $n eq 'TRACK_LOGINS' or $n eq 'DEBUG'){
- my($l,$u)=("","");
- if($v == 0){
- $l = "SELECTED"
- }
- else{
- $u = "SELECTED"
- }
- $v = qq(<select id="onoff" name="var$i">
- <option value="0" $l>Off</option>
- <option value="1" $u>On</option>
- </select>);
- }
+ }
elsif($n eq "RELEASE_VER"){
$REL = qq(<td>$n</td>
<td>$v</td>
<option value="1" $u>True</option>
</select>);
}
- elsif(!defined(Settings::anon($n))){ #change into settable field to us found here unknown and not anon.
+ elsif($n eq "KEEP_EXCS" or
+ $n eq 'TRACK_LOGINS' or
+ $n eq 'DEBUG' or
+ $n eq 'TRANSPARENCY' or
+ $n eq 'AUTO_LOGOFF'){
+ my($l,$u)=("","");
+ if($v == 0){
+ $l = "SELECTED"
+ }
+ else{
+ $u = "SELECTED"
+ }
+ $v = qq(<select id="onoff" name="var$i">
+ <option value="0" $l>Off</option>
+ <option value="1" $u>On</option>
+ </select>);
+ }
+ elsif($n eq 'SUBPAGEDIR' or
+ !defined(Settings::anon($n))){ #change into settable field to us found here unknown and not anon.<td colspan="3"
$v = '<input name="var'.$i.'" type="text" value="'.$v.'" size="12">';
}
-
- my $tr = qq(<tr class="r0" align="left">
- <td>$n</td>
- <td>$v</td>
- <td>$d</td>
- </tr>);
+ my $tr = qq(<tr class="r0" align="left">
+ <td>$n</td>
+ <td>$v</td>
+ <td>$d</td>
+ </tr>);
if($i<300){$tbl.=$tr}else{$foot.=$tr}
}
my $frmVars = qq(
<form id="frm_vars" action="config.cgi">$tbl
<tr class="r1">
- <td colspan="3" align=right><b>System Settings In -> $dbname</b> <input type="submit" value="Change"/></td>
- </tr>
- </table><input type="hidden" name="sys" value="1"/></form><br>);
+ <td colspan="3" align="right"><b>System Settings In -> $dbname</b> <input type="submit" value="Change"/></td>
+ </tr>
+ <tr class="r2">
+ <td colspan="3" align="right">Note - Use <a href="#dbsets">DB Fix</a> to reset this system settings to factory defaults.</td>
+ </tr>
+ </tr>
+ </table><input type="hidden" name="sys" value="1"/></form><br>);
$tbl = qq(<table id="cnf_fix" class="tbl" border="0" width=").&Settings::pagePrcWidth.qq(%">
<tr class="r0"><td colspan="2"><b>* DATA FIX *</b></td></tr>
my $frmDB = qq(
<form id="frm_DB" action="config.cgi">$tbl
<tr class="r1" align="left"><th>Extra Action</th><th>Description</th></tr>
- <tr class="r0" align="left"><td><input type="checkbox" name="reset_cats"/>Reset Categories</td><td>Resets Categories to factory values (will initiate logoff).</td></tr>
- <tr class="r1" align="left"><td><input type="checkbox" name="reset_syst"/>Reset Settings</td><td>Resets system settings to default values.</td></tr>
- <tr class="r0" align="left"><td><input type="checkbox" name="wipe_syst"/>Wipe Settings</td><td>Resets and wipes system settings for migration (will initiate logoff).</td></tr>
+ <tr class="r0" align="left"><td><input type="checkbox" name="reset_syst"/>Reset Settings</td><td>Resets system settings to default values.</td></tr>
+ <tr class="r1" align="left"><td><input type="checkbox" name="wipe_syst"/>Wipe Settings</td><td>Wipes system settings to be forced from the config file (will initiate logoff).</td></tr>
+ <tr class="r0" align="left"><td><input type="checkbox" name="reset_cats"/>Reset Categories</td><td>Resets Categories to factory values (will initiate logoff).</td></tr>
<tr class="r1" align="left"><td><input type="checkbox" name="del_by_cats"/>Delete by Category <font color=red></font><br>
$cats</td><td>Selects and displays by category logs to delete.</td></tr>
<tr class="r0" align="left"><td><input type="checkbox" name="del_from"/>Delete from Date <br>
<tr class="r1">
<td colspan="2" align="right"><b>Data maintenance for -> $dbname</b> <input type="submit" value="Fix"/></td>
</tr>
- <tr class="r1" align="left">
+ <tr class="r2" align="left">
<td colspan="2">Perform this change/check in the event of experiencing data problems. Or periodically for data check and maintenance. <br>
- <font color="red">WARNING!</font> Checking any of the above extra actions will cause loss
- of your changes. Please, export/backup first.</td>
+ Use 'Reset Settings' option to revert to current stored configuration. Changes you made.<br>
+ Use the 'Wipe Settings' option if updating the application or need new defaults from main.cnf config file.<br>
+ Select both to reset and wipe, to overwrite all changes you made to config file settings.
+ <font color="red">WARNING!</font> Checking any of the above extra actions will cause loss
+ of your changes. Please, export/backup first.</td>
</tr>
</table><input type="hidden" name="db_fix" value="1"/></form><br>
);
<tr class="r1">
<td colspan="2" align="right"><b>Pass change for -> $alias</b> <input type="submit" value="Change"/></td>
</tr>
+ <tr class="r2"> <td colspan="2" align="right"><font color="red">WARNING!</font> Changing passwords will make past backups unusuable.</td></tr>
</table><input type="hidden" name="pass_change" value="1"/></form><br>
);
$frmPASS = qq(<tr><td>Password changing has been dissabled!</td></tr>) if Settings::isProgressDB();
if($cid==$caid || $cnm eq $canm){
- $valid = 0;
- last;
+ $valid = 0;
+ last;
}
}
getHeader() if(&Settings::debug);
print "<h3>Database Records Fix Result</h3>\n<hr>" if &Settings::debug;
print "<body><pre>Started transaction!\n" if &Settings::debug;
+ #Transaction work if driver is set properly!
+ my $p = Settings::pass();
+ $db = DBI->connect(Settings::dsn(), $alias, $p, {AutoCommit => 0, RaiseError => 1, PrintError => 0, show_trace=>1});
$db->do('BEGIN TRANSACTION;');
# Check for duplicates, which are possible during imports or migration as internal rowid is not primary in log.
# @TODO This should be selecting an cross SQL compatibe view.
my $st_del = $db->prepare($sql);
$st_del->execute();
}
- print "Doing renumerate next...\n" if &Settings::debug;
- &renumerate;
- print "done!\n" if &Settings::debug;
+
+ &renumerate;
print "Doing removeOldSessions next..." if &Settings::debug;
&Settings::removeOldSessions;
- print "done!\n " if &Settings::debug;
+ print "done!\n" if &Settings::debug;
+
&resetCategories if $rs_cats;
&resetSystemConfiguration($db) if $rs_syst;
&wipeSystemConfiguration if $wipe_ss;
$db->do('COMMIT;')if(&Settings::debug);
- print "Commited ALL!<br>"if(&Settings::debug);
- # $db->disconnect();
- $db = Settings::connectDB();
- $dbs = $db->do("VACUUM;")if(&Settings::debug);
- print "Issued VACUUM!<br>"if(&Settings::debug);
+ print "Commited ALL!<br>"if(&Settings::debug);
+
+ if(&Settings::debug){
+ $db = Settings::connectDB();
+ $dbs = $db->do("VACUUM;");
+ print "Issued VACUUM!<br>"if(&Settings::debug);
+ }
if($LOGOUT){
&logout;
}
-
- exit if(&Settings::debug);
+ if(&Settings::debug){
+ print "<hr><pre>You are in debug mode further actions are halted!</pre>";
+ exit;
+ }
}
catch{
# NOTE: This is most likelly all performed under an transaction.
my $sql;
- # Fetch list by date identified rtf attached logs, with possibly now an old LID, to be updated to new one.
+ # Fetch list by date identified rtf attached logs, with possibly now an old LID, to be updated to new one.
+ print "Doing renumerate next...\n" if &Settings::debug;
if(Settings::isProgressDB()){
$sql = "SELECT ID, DATE FROM LOG WHERE RTF > 0;"
}else{
NOTES.LID = LOG.rowid WHERE LOG.rowid is NULL;");
}
if ($dbs) { foreach (@row = $dbs->fetchrow_array()) {
- $db->do("DELETE FROM NOTES WHERELID=$row[0];") if $row[0]; # 0 is the place keeper for the shared zero record.
+ $db->do("DELETE FROM NOTES WHERE LID=$row[0];") if $row[0]; # 0 is the place keeper for the shared zero record, don't delete.
}}
-
+ print "done!\n" if &Settings::debug;
}
sub resetCategories {
+ print "Doing wipeCtegories next..." if &Settings::debug;
$db->do("DELETE FROM CAT;");
$db->do("DROP TABLE CAT;");
$LOGOUT = 1;
+ print "done!\n" if &Settings::debug;
}
sub wipeSystemConfiguration {
+ print "Doing wipeSystemConfiguration next..." if &Settings::debug;
$db->do("DELETE FROM CONFIG;");
$db->do("DROP TABLE CONFIG;");
$LOGOUT = 1;
+ print "done!\n" if &Settings::debug;
}
-
+#@TODO Needs to be redone, use CNF 2.2
sub resetSystemConfiguration {
open(my $fh, '<', &Settings::logPath.'main.cnf') or die "Can't open ".&Settings::logPath."main.cnf! $!";
my $inData = 0;
my $err = "";
my %vars = {};
-
+ print "Doing resetSystemConfiguration next..." if &Settings::debug;
try{
my $insert = $db->prepare('INSERT INTO CONFIG VALUES (?,?,?,?)');
my $update = $db->prepare('UPDATE CONFIG SET VALUE=? WHERE ID=?;');
my $updExs = $db->prepare('UPDATE CONFIG SET NAME=?, VALUE=? WHERE ID=?;');
$dbs->finish();
- while (my $line = <$fh>) {
- chomp $line;
- my @tick = split("`",$line);
- if(scalar(@tick)==2){
- my %hsh = $tick[0] =~ m[(\S+)\s*=\s*(\S+)]g;
- if(scalar(%hsh)==1){
- for my $key (keys %hsh) {
-
- my %nash = $key =~ m[(\S+)\s*\|\$\s*(\S+)]g;
- if(scalar(%nash)==1){
- for my $id (keys %nash) {
- $name = $nash{$id};
- $value = $hsh{$key};
- if($vars{$id}){
- $err .= "UID{$id} taken by $vars{$id}-> $line\n";
- }
- else{
- $dbs = Settings::selectRecords($db,
- "SELECT ID, NAME, VALUE, DESCRIPTION FROM CONFIG WHERE NAME LIKE '$name';");
- $inData = 1;
- my @row = $dbs->fetchrow_array();
- if(scalar @row == 0){
- #The id in config file has precedence to the one in the db,
- #from a possible previous version.
- $dbs = Settings::selectRecords($db, "SELECT ID FROM CONFIG WHERE ID = $id;");
- @row = $dbs->fetchrow_array();
- if(scalar @row == 0){
- $insert->execute($id,$name,$value,$tick[1]);
- }else{
- #rename, revalue exsisting id
- $updExs->execute($name,$value,$id);
- }
- }
- else{
- $update->execute($value,$id);
- }
- }
- }
+ while (my $line = <$fh>) {
+ chomp $line;
+ my @tick = split("`",$line);
+ if(scalar(@tick)==2){
+ my %hsh = $tick[0] =~ m[(\S+)\s*=\s*(\S+)]g;
+ if(scalar(%hsh)==1){
+ for my $key (keys %hsh) {
+
+ my %nash = $key =~ m[(\S+)\s*\|\$\s*(\S+)]g;
+ if(scalar(%nash)==1){
+ for my $id (keys %nash) {
+ $name = $nash{$id};
+ $value = $hsh{$key};
+ if($vars{$id}){
+ $err .= "UID{$id} taken by $vars{$id}-> $line\n";
+ }
+ else{
+ $dbs = Settings::selectRecords($db,
+ "SELECT ID, NAME, VALUE, DESCRIPTION FROM CONFIG WHERE NAME LIKE '$name';");
+ $inData = 1;
+ my @row = $dbs->fetchrow_array();
+ if(scalar @row == 0){
+ #The id in config file has precedence to the one in the db,
+ #from a possible previous version.
+ $dbs = Settings::selectRecords($db, "SELECT ID FROM CONFIG WHERE ID = $id;");
+ @row = $dbs->fetchrow_array();
+ if(scalar @row == 0){
+ $insert->execute($id,$name,$value,$tick[1]);
}else{
- $err .= "Invalid, spec'ed {uid}|{setting}`{description}-> $line\n";
+ #rename, revalue exsisting id
+ $updExs->execute($name,$value,$id);
+ }
}
-
- }#rof
- }
- else{
- $err .= "Invalid, speced entry -> $line\n";
+ else{
+ $update->execute($value,$id);
+ }
+ }
+ }
+ }else{
+ $err .= "Invalid, spec'ed {uid}|{setting}`{description}-> $line\n";
}
- }elsif($inData && length($line)>0){
- if(scalar(@tick)==1){
- $err .= "Corrupt Entry, no description supplied -> $line\n";
- }
- else{
- $err .= "Corrupt Entry -> $line\n";
- }
+ }#rof
}
+ else{
+ $err .= "Invalid, speced entry -> $line\n";
+ }
+
+ }
+ elsif($line eq '>>'){last}
+ elsif($inData && length($line)>0){
+ if(scalar(@tick)==1){
+ $err .= "Corrupt Entry, no description supplied -> $line\n";
+ }
+ else{
+ $err .= "Corrupt Entry -> $line\n";
+ }
+ }
}
- die "Configuration script './main.cnf' [$fh] contains errors." if $err;
+ die "Configuration script ".&Settings::logPath."main.cnf' contains errors." if $err;
close $fh;
Settings::getConfiguration($db);
+ print "done!\n" if &Settings::debug;
} catch{
close $fh;
print $cgi->header;
- print "<font color=red><b>SERVER ERROR! [id:$id,name:$name,value:$value]/b></font><br> ".$_."<br><pre>$err</pre>";
- print $cgi->end_html;
- exit;
+ print "<font color=red><b>SERVER ERROR!</b></font>[id:$id,name:$name,value:$value]->$@<br> ".$_."<br><pre>$err</pre>";
+ print $cgi->end_html;
+ exit;
}
}
sub changeSystemSettings {
my $updated;
+ my $id_theme;
+try{
+ $dbs = Settings::selectRecords($db, "SELECT ID FROM CONFIG WHERE NAME LIKE 'THEME';");
+ while (my @r=$dbs->fetchrow_array()){$id_theme=$r[0]}
$dbs = Settings::selectRecords($db, "SELECT ID, NAME FROM CONFIG;");
while (my @r=$dbs->fetchrow_array()){
my $var = $cgi->param('var'.$r[0]);
if(defined $var){
Settings::configProperty($db, $r[0], undef, $var);
$updated = 1;
+ Settings::saveCurrentTheme($var) if $r[0] == $id_theme;
}
}
Settings::getConfiguration($db) if($updated);
+}catch{
+ die "\nException\@$0::changeSystemSettings() line ",__LINE__." failed ->\n $@"; #<- It is actually better to die than throw exception traces. Easier to find problem this way.
+}
}
-
sub backupDelete {
my $n = $cgi->param('bck_del');
sub error {
my $url = $cgi->url(-path_info => 1);
- print qq(<h2>Sorry Encountered Errors</h2><p>Page -> $url</p><p>$ERROR</p>);
- print qq(<h3>CGI Parameters</h3>);
- print "<ol>\n";
+ print qq(<div class="debug_output" style="font-size:large;"><div style="text-align: left; width:100%; overflow-x:wrap;">
+ <h2 style="color:tomato;">Sorry Encountered Errors</h2><p>Page -> $url</p><p>$ERROR</p>;
+ <h3>CGI Parameters</h3>
+ );
+ print "<ol>";
foreach ($cgi->param){
print '<li>'.$_.'=='. $cgi->param($_).'</li>';
}
print "</ol>\n";
- print "<a href=$url>Return to -> $url</a>";
+ print "<div>Return to -> <a href=$url>$url</a></div><hr></div></div>";
+
print $cgi->end_html;
$db->disconnect();
exit;
my $VW_OVR_WHERE="";
my $LOGOUT_RELOGIN_TXT='No, no, NO! Log me In Again.';
my $LOGOUT_IFRAME_ENABLED = 0;
-my $LOGOUT_IFRAME = qq|<iframe width="60%" height="600px" src="https://www.youtube.com/embed/qTFojoffE78?autoplay=1"
- frameborder="0"
- allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
+my $LOGOUT_IFRAME = qq|
+ <iframe width="60%" height="600px" src="https://www.youtube.com/embed/qTFojoffE78?autoplay=1" frameborder="0" allow="accelerometer;
+ autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
</iframe>|;
-
-try{
+try{
checkAutologinSet();
logout() if($cgi->param('logout'));
- if(processSubmit()==0){
-
+ if(processSubmit()==0){
print $cgi->header(-expires=>"0s", -charset=>"UTF-8", -cookie=>$cookie);
print $cgi->start_html(
-title => "Personal Log Login",
-BGCOLOR => &Settings::bgcol,
- -script=> [{-type => 'text/javascript', -src => 'wsrc/main.js'},
+ -script=> [{-type => 'text/javascript', -src => 'wsrc/main.js'},
{-type => 'text/javascript', -src => 'wsrc/jquery.js'},
{-type => 'text/javascript', -src => 'wsrc/jquery-ui.js'}],
- -style => [{-type => 'text/css', -src => "wsrc/".&Settings::css},
+ -style => [{-type => 'text/css', -src => "wsrc/".&Settings::css},
{-type => 'text/css', -src => 'wsrc/jquery-ui.css'},
{-type => 'text/css', -src => 'wsrc/jquery-ui.theme.css'},
{-type => 'text/css', -src => 'wsrc/jquery-ui.theme.css'}],
<tr class="r0"><td colspan="2">Host -> <b>$hst</b></td><td><input type="submit" value="Login"/></td></tr>
</table></form>);
- print qq(<br><br><div id="rz">
+ print qq(<br><br><div class="rz">
<center>
- <h2>Welcome to Life Log</h2><div>$frm</div><br>
+ <h2>Welcome to Life Log</h2><div class="">$frm</div><br>
<a href="https://github.com/wbudic/LifeLog"
target="_blank" style="font-size:small">LifeLog v.).Settings::release().qq(</a><br>
- </center><div>);
+ </center>
+ </div>);
Settings::printDebugHTML($DBG) if Settings::debug();
print $cgi->end_html;
}
$db -> disconnect();
}
+ Settings::loadLastUsedTheme();
}
sub checkPreparePGDB {
return @ret;
}
-
+#@TODO Needs to be redone, use CNF 2.2, see also config.cgi
sub populate {
my $db = shift;
elsif($tt==0){
$err .= "Invalid, spec'd entry -> $line\n";
}elsif($tt==1){
- my @pair = $tick[0] =~ m[(\S+)\s*\|\s*(\S+\s*\S*)]g;
- if ( scalar(@pair)==2 ) {
- # In older DB versions the Category name could be different, user modified.
- # The unique id and name interwined, changed. Hence we check on name first.
- # Then check if the ID is available. If not just skip, the import. Reseting can fix that latter.
- if(!Settings::selectRecords($db, "SELECT ID FROM CAT WHERE NAME LIKE '$pair[1]';")->fetchrow_array()) {
- if(!Settings::selectRecords($db, "SELECT ID FROM CAT WHERE ID = $pair[0];")->fetchrow_array()){
- $DBG .= "cat.ins->".$pair[0].",".$pair[1].",".$tick[1]."\n";
- $insCat->execute($pair[0],$pair[1],$tick[1]);
- }
- }
- $inData = 1;
+ my @pair = $tick[0] =~ m[(\S+)\s*\|\s*(\S+\s*\S*)]g;
+ if ( scalar(@pair)==2 ) {
+ # In older DB versions the Category name could be different, user modified.
+ # The unique id and name interwined, changed. Hence we check on name first.
+ # Then check if the ID is available. If not just skip, the import. Reseting can fix that latter.
+ if(!Settings::selectRecords($db, "SELECT ID FROM CAT WHERE NAME LIKE '$pair[1]';")->fetchrow_array()) {
+ if(!Settings::selectRecords($db, "SELECT ID FROM CAT WHERE ID = $pair[0];")->fetchrow_array()){
+ $DBG .= "cat.ins->".$pair[0].",".$pair[1].",".$tick[1]."\n";
+ $insCat->execute($pair[0],$pair[1],$tick[1]);
}
- else {
+ }
+ $inData = 1;
+ }
+ else {
$err .= "Invalid, spec'ed {uid}|{category}`{description}-> $line\n";
- }
- }elsif($tt==2){
+ }
+ }elsif($tt==2){
#TODO Do we really want this? Insert into log from config script.
}
}elsif($inData && length($line)>0){
if(scalar(@tick)==1){
- $err .= "Corrupt Entry, no description supplied -> $line\n";
+ $err .= "Corrupt Entry, (where is '\`' backtick for description?) -> $line\n";
}
else{
$err .= "Corrupt Entry -> $line\n";
}
}
- LifeLogException->throw(error=>"Configuration script ".&Settings::logPath."/main.cnf [$fh] contains errors. DSN:".
- Settings::dsn()." Err:$err", show_trace=>1) if $err;
+ LifeLogException->throw(error=>"Configuration script ".&Settings::logPath."/main.cnf contains errors.\nErr:$err", show_trace=>1) if $err;
$db->commit();
}
sub logout {
if(Settings::trackLogins()){
- try{
- $alias = $session->param('alias');
- $passw = $session->param('passw');
- if($alias){
- my $db = Settings::connectDB($DB_NAME, $alias, $passw);
- Settings::toLog($db, "Log has properly been logged out by $alias.");
- $db->disconnect();
- }
- }catch{
- my $err = $@;
- my $dbg = "" ;
- my $pwd = `pwd`;
- $pwd =~ s/\s*$//;
- $dbg = "--DEBUG OUTPUT--\n$DBG" if Settings::debug();
- print $cgi->header,
- "<font color=red><b>SERVER ERROR</b></font> on ".DateTime->now().
- "<pre>".$pwd."/$0 -> &".caller." -> [$err]","\n$dbg</pre>",
- $cgi->end_html;
- exit;
- }
+ try{
+ $alias = $session->param('alias');
+ $passw = $session->param('passw');
+ if($alias){
+ my $db = Settings::connectDB($DB_NAME, $alias, $passw);
+ Settings::toLog($db, "Log has properly been logged out by $alias.");
+ $db->disconnect();
+ }
+ }catch{
+ my $err = $@;
+ my $dbg = "" ;
+ my $pwd = `pwd`;
+ $pwd =~ s/\s*$//;
+ $dbg = "--DEBUG OUTPUT--\n$DBG" if Settings::debug();
+ print $cgi->header,
+ "<font color=red><b>SERVER ERROR</b></font> on ".DateTime->now().
+ "<pre>".$pwd."/$0 -> &".caller." -> [$err]","\n$dbg</pre>",
+ $cgi->end_html;
+ exit;
+ }
}
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'},
+ -style =>{-type => 'text/css', -src => 'wsrc/'.Settings::css()},
);
$LOGOUT_IFRAME = "" if not $LOGOUT_IFRAME_ENABLED;
- print qq(<font color="white"><center><h2>You have properly logged out of the Life Log Application!</h2>
+ print qq(<div class="rz"><h2>You have properly logged out of the Life Log Application!</h2>
<br>
<form action="login_ctr.cgi"><input type="hidden" name="autologoff" value="1"/><input type="submit" value="$LOGOUT_RELOGIN_TXT"/></form><br>
</br>
$LOGOUT_IFRAME
- </center></font>
+ </div>
);
print $cgi->end_html;
my $sssCDB = $sss->param('cdb');
my ($vmode, $imgw, $imgh );
-if ( !$alias || !$passw) {
+if ( !$alias || !$passw ) {
print $cgi->redirect("alogin_ctr.cgi?CGISESSID=$sid");
exit;
}
my $DEBUG = Settings::debug();
#END OF SETTINGS
my $rtf_buffer = 0;
-my $BUFFER;
-sub toBuf {
- $BUFFER .= shift;
-}
+my ($BUFFER, $D_BUFF);
my $lang = Date::Language->new(Settings::language());
my $today = Settings->today();
-
+# We buffer the whole page creation, for speed and control send compressed or not to client.
+sub toBuf { if($DEBUG){$D_BUFF .= shift}else{$BUFFER .= shift} }
+
if(!$prm_vc && &Settings::keepExcludes){
if($prm_xc_lst){
Settings::configProperty($db, 201, '^EXCLUDES', $prm_xc_lst);
$log_output .= qq(<tr class="r$ssid">
<td width="15%">$dtf<input id="y$id" type="hidden" value="$dty"/></td>
<td id="t$id" width="10%" class="tbl">$dth</td>
- <td id="v$id"><div class="log">$log</div></td>
+ <td id="v$id" ><div class="log">$log</div></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%">
+ <td width="10%">
<input id="r$id" type="hidden" value="$rtf"/>
<input id="s$id" type="hidden" value="$sticky"/>
<input id="f$id" type="hidden" value="$af"/>
<input name="chk" type="checkbox" value="$pid"/>
</td></tr>)};
- if ( $rtf > 0 ) {#max-width:1000px;
- # style="max-height:480px; box-sizing: border-box; padding: 5px; background:#fffafa; overflow-x:scroll;scrollbar-width:none;"
+ if ( $rtf > 0 ) {
$log_output .= qq(<tr id="q-rtf$id" class="r$tfId" style="display:none;">
<td colspan="6">
<div id="q-scroll$id" class="ql-editor ql-snow" style="max-height:480px; overflow-x:scroll;">
$sp2 = '<span class="ui-icon ui-icon-circle-triangle-s"></span>';
$sp3 = '<span class="ui-icon ui-icon-arrow-4-diag"></span>';
+ my $std_bck = "background-image:url('".&Settings::transimage."');";
+ $std_bck = "background-color:$BGCOL;" if !&Settings::transparent;
+ my $auto_logoff = &Settings::autoLogoff;
+
my $frm = qq(<a name="top"></a>
<form id="frm_entry" action="main.cgi" onSubmit="return formValidation();">
- <table class="tbl" border="0" width=").&Settings::pagePrcWidth.qq(%">
+ <table class="tbl" border="0" style="$std_bck opacity: 0.9;" width=").&Settings::pagePrcWidth.qq(%">
<tr class="r0">
<td style="text-align:left;"><a id="to_bottom" href="#bottom" title="Go to bottom of page.">↧</a></td>
<td colspan="2"><b>* LOG ENTRY FORM *</b>
</div>
</td>
</tr>
- <tr class="collpsd"><td style="text-align:right; vertical-align:top">Log:</td>
+ <tr class="collpsd"><td style="text-align:right; vertical-align:top;">Log:</td>
<td id="al" colspan="2" style="text-align:top;">
<textarea id="el" name="log" rows="3" style="float:left; width:99%;" onChange="toggleVisibility('cat_desc',true)"></textarea>
</td>
<input type="hidden" name="rs_prev" value="$log_rc_prev"/>
<input type="hidden" name="rs_page" value="$rs_page"/>
<input type="hidden" name="CGISESSID" value="$sid"/>
+ <input type="hidden" id="auto_logoff" value="$auto_logoff"/>
<input type="hidden" id="isInViewMode" value="$isInViewMode"/>
<input type="hidden" id="rtf_buffer" value="$rtf_buffer"/>
$tags
my $srh = qq(
<form id="frm_srch" action="main.cgi">
- <table class="tbl" border="0" width=").&Settings::pagePrcWidth.qq(%">
+ <table class="tbl" border="0" style="background-color:$BGCOL" width=").&Settings::pagePrcWidth.qq(%">
<tr class="r0">
<td colspan="2"><b>View By/Search</b>
<a id="srch_close" href="#" onclick="return hide('#div_srh');">$sp1</a>
$srh .=
qq(
<tr class="collpsd">
- <td align="right" style="width:20%">View by Category:</td>
+ <td align="right" style="width:20%;">View by Category:</td>
<td align="left">
<button class="bordered" data-dropdown="#dropdown-standard-v" style="margin: 0px; padding: 0; padding-right:8px;">
<span id="lcat_v" class="ui-button">$catselected</span>
my $sideMenu;
my $tail = q(<div><a class="a_" href="stats.cgi">View Statistics</a> <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>);
+ <div><a class="a_" href="login_ctr.cgi?logout=bye" id="btnLogout">LOGOUT</a><hr><a name="bottom"></a></div>);
if($isPUBViewMode){$sideMenu=$frm=$srh=$tail=""}else{
my $sql = Settings::dbSrc(); my $s = $sql =~ qr/:/; $s = $`; $' =~ qr/:/;
if(lc $` eq 'pg'){$sql = $s.'➔'.'PostgreSQL'}else{$sql = $s.'➔'.$`};
}
- my $quill = &quill( $cgi->param('submit_is_edit') );
- my $help = &help;
+my $quill = &quill( $cgi->param('submit_is_edit') );
+my $help = &help;
##################################
# Final Page Output from here! #
##################################
-
toBuf (qq(
$sideMenu
<div id="div_log">$frm</div>
{ -type => 'text/javascript', -src => 'wsrc/moment-timezone-with-data.js' },
{ -type => 'text/javascript', -src => 'wsrc/jquery.sweet-dropdown.js'}
- ]) .
+ ]) . ($DEBUG ?"<div class='debug_output' date='$today'>$D_BUFF</div>":"").
$BUFFER;
if(Settings->compressPage() && $cgi->http('Accept-Encoding') =~ m/gzip/){
font-family: Bookman;
text-align: left;
}
-.spacer {
- border: 10px;
- border-left-width:0px;
- margin:5 px;
-}
.info span {
- border: 1px solid black;
- padding: 5px;
- margin-top: 1px;
- margin-right: 15px;
+ border: 1px solid black;
+ margin-top: 5px;
float: left;
- width:98%
+ width:97%
+}
+
+.table {
+ display:table;
+ border: 2px solid black;
+ margin-right: 15px;
+ width:45%;
+}
+.header {
+ display:table-header-group;
+ font-weight:bold;
+ border-bottom: 1px solid black;
+ margin-bottom: 2px;
+}
+.row {
+ display:table-row;
+}
+.rowGroup {
+ display:table-row-group;
+}
+.cell1 {
+ display: table-cell;
+ padding: 5px;
+ border-bottom: solid 1px;
+ border-right: solid 2px;
+ vertical-align: top;
+ width: 10%;
+}
+.cell2 {
+ display:table-cell;
+ padding: 5px;
+ border-bottom: solid 1px;
+ vertical-align: top;
+ width:25%;
+}
+.cell3 {
+ display:table-cell;
+ padding: 5px;
+ border-bottom: solid 1px;
+ vertical-align: top;
+ width:100%;
}
_____CSS
$hardware_status =~ s/up\s/<b>Server is up: <\/b>/g;
my $log = "<span>".$hardware_status."</span>"."<pre>\n".`df -h -l -x tmpfs`."</pre>";
-Settings::toLog($db, $log);
-
+###
+ Settings::toLog($db, $log);
+###
my $prc = 'ps -eo size,pid,user,command --sort -size | awk \'{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }\'';
my $processes = `$prc | sort -u -r -`;
my @stat = stat Settings::dbFile();
my $IPPublic = `curl -s https://www.ifconfig.me`;
my $IPPrivate = `hostname -I`; $IPPrivate =~ s/\s/<br>/g;
-
-my $tbl = qq(<table class="tbl" border="0" align="left"><tr class="r0"><td colspan="5" style="text-align:centered"><b>* Personal Log Data Statistics *</b></td></tr>
- <tr class="r1"><td>LifeLog App. Version:</td><td>).Settings::release().qq(</td></tr>
- <tr class="r0"><td>Number of Records:</td><td>$log_rc</td></tr>
- <tr class="r1"><td>No. of Records This Year:</td><td>$log_this_year_rc</td></tr>
- <tr class="r0"><td>No. of RTF Documents:</td><td>$notes_rc</td></tr>
- <tr class="r1"><td># Sum of Expenses For Year $year</td><td>$expense</td></tr>
- <tr class="r0"><td># Sum of Income For Year $year</td><td>$income</td></tr>
- <tr class="r1"><td>Gross For Year $year</td><td>$gross</td></tr>
- <tr class="r0"><td>$dbname<td>$dbSize</td></tr>
- <tr class="r1"><td>Public IP</td><td>$IPPublic</td></tr>
- <tr class="r0"><td>Private IP</td><td>$IPPrivate</td></tr>
-</table>);
-
-
-print qq(<div id="menu" title="Menu" style="border: 2px solid black; padding: 5px; margin-top: 25px;">
-<div style="border: 1px solid black; margin: 5px; margin-bottom: 10px; padding:5px;"><b>Menu</b></div>
+my $tbl = qq(
+<div class="table r0" style="text-align:centered; float:left;">
+ <div class="header">
+ <div class="cell2" style="border-right:0;">Personal Log Data Statistics</div>
+ <div class="cell2"></div>
+ </div>
+ <div class="row r1">
+ <div class="cell1">LifeLog App. Version:</div>
+ <div class="cell2">).Settings::release().qq(</div>
+ </div>
+ <div class="row r2">
+ <div class="cell1">Number of Records:</div><div class="cell2">$log_rc</div>
+ </div>
+ <div class="row r3">
+ <div class="cell1">No. of Records This Year:</div><div class="cell2">$log_this_year_rc</div>
+ </div>
+ <div class="row r1">
+ <div class="cell1">No. of RTF Documents:</div><div class="cell2">$notes_rc</div>
+ </div> <div class="row r0">
+ <div class="cell1"># Sum of Expenses For Year $year</div><div class="cell2">$expense</div>
+ </div>
+ <div class="row r2">
+ <div class="cell1"># Sum of Income For Year $year</div><div class="cell2">$income</div>
+ </div>
+ <div class="row r3">
+ <div class="cell1"># Gross For Year $year</div><div class="cell2">$gross</div>
+ </div>
+ <div class="row r1">
+ <div class="cell1">$dbname</div><div class="cell2">$dbSize</div>
+ </div>
+ <div class="row r2">
+ <div class="cell1">Public IP</div><div class="cell2">$IPPublic</div>
+ </div>
+ <div class="row r3">
+ <div class="cell1">Private IP</div><div class="cell2">$IPPrivate</div>
+ </div>
+</div>
+<div class="table r0">
+ <div class="header"><div class="cell2">Server Info</div></div>
+ <div class="row r1"><div class="cell3">$hardware_status</div></div>
+</div>
+);
+
+print qq(<div id="menu" title="Menu" style="border: 2px solid black; padding: 5px; margin-top: 120px;">
+<div class="r0" style="border: 1px solid black; margin: 2px; margin-bottom: 10px; padding:5px;"><b>Menu</b></div>
<div><a class="a_" href="main.cgi">Log</a><hr></div>
<div><a class="a_" href="config.cgi">Config</a><hr></div>
<div><a class="a_" href="login_ctr.cgi?logout=bye">LOGOUT</a></div>
<div class="main">
<div class="info">
- <span><h3>Life Log Server Statistics</h3></span>
+ <span class="r2" style="padding:5px;width:98%;"><h3>Life Log Server Statistics</h3></span>
</div>
- <div class="spacer"> </div>
+ <div> </div>
<div class="info">
- <span><b>Log Status & Information</b></span>
- <span><p>$tbl</p></span>
- </div>
- <div class="spacer"> </div>
- <div class="info">
- <span><b>Server Info</b></span>
- <span>$hardware_status</span>
+ <span class="info r2" style="font-size:larger;padding:5px;width:98%;"><b>Status & Information</b></span>
+ <span style="font-size:larger;padding:5px;width:98%;">$tbl</span>
</div>
- <div class="spacer"> </div>
+
+ <div> </div>
+
<div class="info">
- <span><b>Server Side Processes</b></span>
- <span class="ql-container ql-snow" style="max-height:480px; overflow-x:scroll;">
- <pre class="r1">$processes</pre>
+ <span class="r2" style="font-size:larger;padding:5px;width:98%;"><b>Server Side Processes</b></span>
+ <span style="border: 1px solid black; padding-right: 0px; width:98%">
+ <pre class="ql-container r2" style="max-height:480px; width:100%; overflow-x:auto; margin-top:0; margin-bottom:0"">$processes</pre>
</span>
</div>
</div>);
#
use constant VW_LOG_OVERRIDE_WHERE => 'VW_LOG_OVR_WHERE';
-#DEFAULT SETTINGS HERE!
+# DEFAULT SETTINGS HERE! These settings kick in if not found in config file. i.e. wrong config file or has been altered, things got missing.
our $RELEASE_VER = '2.3';
our $TIME_ZONE = 'Australia/Sydney';
our $LANGUAGE = 'English';
our $REC_LIMIT = 25;
our $AUTO_WRD_LMT = 1000;
our $AUTO_WRD_LEN = 17; #Autocompletion word length limit. Internal.
+our $AUTO_LOGOFF = 0;
our $VIEW_ALL_LMT = 1000;
our $DISP_ALL = 1;
our $FRAME_SIZE = 0;
our $RTF_SIZE = 0;
our $THEME = 'Standard';
+our $TRANSPARENCY = 1;
+our $TRANSIMAGE = 'wsrc/images/std-log-lbl-bck.png';
our $TRACK_LOGINS = 1;
our $KEEP_EXCS = 0;
our $COMPRESS_ENC = 0; #HTTP Compressed encoding.
our $DBI_SOURCE = "DBI:SQLite:";
our $DBI_LVAR_SZ = 1024;
+
+my ($cgi, $sss, $sid, $alias, $pass, $dbname, $pub);
our $DSN;
our $DBFILE;
our $IS_PG_DB = 0;
-
-
-my ($cgi, $sss, $sid, $alias, $pass, $dbname, $pub);
-
-#Annons here, variables that could be overiden in code or database, per need.
+#Annons here, variables that could be overriden in code or in database, per need and will.
our %anons = ();
our %tz_map;
### Page specific settings Here
our $TH_CSS = 'main.css';
+our $JS = 'main.js';
our $BGCOL = '#c8fff8';
#Set to 1 to get debug help. Switch off with 0.
our $DEBUG = 1;
sub anonsSet {my $a = shift;%anons=%{$a}}
sub release {$RELEASE_VER}
-sub logPath {$LOG_PATH}#<-something was calling as setter, can't replicate. On reset of categories in config.cgi.
-sub logPathSet {$S_ = shift;$LOG_PATH = $S_ if $S_;return $LOG_PATH}#<-has now setter method nothing actually calls.
+sub logPath {$LOG_PATH} # <-@2021-08-15 something was calling as setter, can't replicate. On reset of categories in config.cgi.
+sub logPathSet {$S_ = shift;$LOG_PATH = $S_ if $S_;return $LOG_PATH}#<-has now setter method nothing it is actually calling.
sub theme {$THEME}
sub timezone {$TIME_ZONE}
+sub transparent {$TRANSPARENCY}
+sub transimage {$TRANSIMAGE}
sub language {$LANGUAGE}
sub sessionExprs {$SESSN_EXPR}
sub imgWidthHeight {$IMG_W_H}
sub recordLimit {$REC_LIMIT}
sub autoWordLimit {$AUTO_WRD_LMT}
sub autoWordLength {$AUTO_WRD_LEN}
+sub autoLogoff {$AUTO_LOGOFF}
sub viewAllLimit {$VIEW_ALL_LMT}
sub displayAll {$DISP_ALL}
sub trackLogins {$TRACK_LOGINS}
sub keepExcludes {$KEEP_EXCS}
sub bgcol {$BGCOL}
sub css {$TH_CSS}
+sub js {$JS}
sub compressPage {$COMPRESS_ENC}
sub debug {$S_ = shift; $DEBUG = $S_ if $S_; $DEBUG}
sub dbSrc {$S_= shift; if($S_) {$DBI_SOURCE=$S_; $IS_PG_DB = 1 if(index (uc $S_, 'DBI:PG') ==0)}
sub pub {$pub}
sub trim {my $r=shift; $r=~s/^\s+|\s+$//g; $r}
-#The following has to be called from an CGI seesions container that provides parameters.
+# The following has to be called from an CGI seesions container that provides parameters.
sub fetchDBSettings {
try {
$CGI::POST_MAX = 1024 * 1024 * 5; # max 5GB file post size limit.
}
my $ret = connectDB($dbname, $alias, $pass);
getConfiguration($ret);
- getTheme();
+ setupTheme();
$sss->expire($SESSN_EXPR);
return $ret;
}catch{
- SettingsException->throw(error=>$@, show_trace=>$DEBUG);
+ SettingsException->throw(error=>"DSN<$DSN>".$@, show_trace=>$DEBUG);
exit;
}
}
FOREIGN KEY (CID) REFERENCES CAT(ID)
);
)}
-#Selects the actual database set configuration for the application, not from the config file.
+#Selects the actual database set configuration for the application, these kick in overwritting those from the config file.
sub getConfiguration {
my ($db, $hsh) = @_;
my $fh;
when ("IMG_W_H") {$IMG_W_H = $r[2]}
when ("REC_LIMIT") {$REC_LIMIT = $r[2]}
when ("AUTO_WRD_LMT"){$AUTO_WRD_LMT = $r[2]}
+ when ("AUTO_LOGOFF") {$AUTO_LOGOFF = $r[2]}
when ("VIEW_ALL_LMT"){$VIEW_ALL_LMT = $r[2]}
when ("DISP_ALL") {$DISP_ALL = $r[2]}
when ("FRAME_SIZE") {$FRAME_SIZE = $r[2]}
when ("RTF_SIZE") {$RTF_SIZE = $r[2]}
when ("THEME") {$THEME = $r[2]}
+ when ("TRANSPARENCY"){$TRANSPARENCY = $r[2]}
+ when ("TRANSIMAGE") {$TRANSIMAGE = $r[2]}
when ("DEBUG") {$DEBUG = $r[2]}
when ("KEEP_EXCS") {$KEEP_EXCS = $r[2]}
when ("TRACK_LOGINS"){$TRACK_LOGINS = $r[2]}
my @a = $v =~ m/(\+\d+[shm])/gis;
if(scalar(@a)>0){$v=$a[0]}
# Test acceptable setting, which is any number from 2, having any s,m or h.
- if($v =~ m/(\+[2-9]\d*[smh])|(\+[1-9]+\d+[smh])/){
+ if($v =~ m/(\+*[2-9]\d*[smh])|(\+[1-9]+\d+[smh])/){
# Next is actually, the dry booger in the nose. Let's pick it out!
# Someone might try to set in seconds value to be under two minutes.
@a = $v =~ m/(\d[2-9]\d+)/gs;
if(scalar(@a)>0 && int($a[0])<120){return $ret}else{return $v}
}
- elsif($v =~ m/\+\d+/){# is passedstill without time unit? Minutetise!
- $ret=$v."m"
+ elsif($v =~ m/\+\d+/){# is passed still without time unit? Minutetise!
+ $ret=$v
}
return $ret;
}
-sub getTheme {
+sub setupTheme {
given ($THEME){
- when ("Sun") { $BGCOL = '#D4AF37'; $TH_CSS = "main_sun.css"; }
- when ("Moon") { $BGCOL = '#000000'; $TH_CSS = "main_moon.css"; }
- when ("Earth") { $BGCOL = '#26ac0c'; $TH_CSS = "main_earth.css";} # Used to be $BGCOL = '#26be54';
+ when ("Sun") { $BGCOL = 'goldenrod'; $TH_CSS = "main_sun.css"; }
+ when ("Moon") { $BGCOL = '#000000'; $TH_CSS = "main_moon.css"; }
+ when ("Earth") { $BGCOL = 'forestgreen'; $TH_CSS = "main_earth.css";} # Used to be $BGCOL = '#26be54';
default{
# Standard;
$BGCOL = '#c8fff8';
return $prm;
}
+sub saveCurrentTheme {
+ my $theme = shift;
+ if($theme){
+ open (my $fh, '>', $LOG_PATH.'current_theme') or die $!;
+ print $fh $theme;
+ close($fh);
+ }
+}
+sub loadLastUsedTheme {
+ open my $fh, '<', $LOG_PATH.'current_theme' or return $THEME;
+ $THEME = <$fh>;
+ close($fh);
+ &setupTheme;
+}
+
1;
\ No newline at end of file
}
-
-
-
function toggleDoc(whole) {
var out = (min < 10 ? '0' : '') + min + ":" + (sec < 10 ? '0' : '') + sec;
var tim = new moment().tz(TIMEZONE).format("hh:mm:ss a");
var sty = "";if(min<2){sty="style='color:red'";
- if(!WARNED){WARNED=1;$('#au_door_chime').trigger('play');display("<font color='red'>Session is about to expire!</font>",10);}}
+ if(!WARNED){WARNED=1;
+ if($('#auto_logoff').val()=='0'){
+ $('#au_door_chime').trigger('play');
+ }else{
+ $('#btnLogout').click();
+ }
+ display("<span id='sss_expired'>Session is about to expire!</span>",10);}
+ }
var dsp = "<font size='1px;'>[" + tim + "]</font><span "+sty+"> Session expires in " + out + "</span>";
$("#sss_status").html(dsp);
if(now.isAfter(timeout)){
$("#ed").prop( "disabled", true );
$("#el").prop( "disabled", true );
$("#am").prop( "disabled", true );
+ if($('#auto_logoff').val()=='1'){
+ dialogModal("Page Session has Expired","Please login again!", true);
+ }
}
}, 1000);
return true;
}
- function dialogModal(title, message) {
- $('<div></div>').dialog({
- modal: true,
- title: title,
- width: "40%",
- show: { effect: "clip", duration: 400 },
- open: function() {
- $(this).html(message);
- },
- buttons: {
- Ok: function() {
- $( this ).dialog( "close" );
- }
- }
- });
+ function dialogModal(title, message, logout) {
+
+ if(logout) {
+ $('<div></div>').dialog({
+ modal: true,
+ title: title,
+ width: "40%",
+ show: { effect: "clip", duration: 400 },
+ open: function() {
+ $(this).html(message);
+ },
+ buttons: {
+ Logout: function() {
+ $( this ).dialog( "close" );
+ location.reload();
+ }
+ }
+ });
+ }else {
+
+ $('<div></div>').dialog({
+ modal: true,
+ title: title,
+ width: "40%",
+ show: { effect: "clip", duration: 400 },
+ open: function() {
+ $(this).html(message);
+ },
+ buttons: {
+ Ok: function() {
+ $( this ).dialog( "close" );
+ }
+ }
+ });
+ }
return false;
}