From: Will Budicm Date: Sun, 6 Dec 2020 06:49:27 +0000 (+1100) Subject: log varchar limit was overun. Resized to 1024. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=531c2ef493586a11ab05945061379b14dac17383;p=LifeLog.git log varchar limit was overun. Resized to 1024. --- diff --git a/htdocs/cgi-bin/stats.cgi b/htdocs/cgi-bin/stats.cgi index a961395..c731cbc 100755 --- a/htdocs/cgi-bin/stats.cgi +++ b/htdocs/cgi-bin/stats.cgi @@ -8,9 +8,9 @@ use warnings; #no warnings 'uninitialized'; use CGI; -use CGI::Pretty ":standard"; #Influde style subroutine for inline CSS use CGI::Session '-ip_match'; use CGI::Carp qw ( fatalsToBrowser ); +use CGI::Pretty ":standard"; #Includes style subroutine for inline CSS use DBI; use DateTime::Format::SQLite; use Number::Bytes::Human qw(format_bytes); @@ -123,7 +123,6 @@ my $hardware_status = "Host: $hst
".join("\t", map { defined ? $_ : '' $hardware_status =~ s/\t+/
/gm; #TODO: This temp. resolves the regex needs to be adjusted so we join with
$hardware_status =~ s/Memory:/
Memory: <\/b>/g; $hardware_status =~ s/up\s/Server is up: <\/b>/g; - 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 -`; @@ -174,8 +173,11 @@ print qq( ); print $cgi->end_html; -my $syslog = "$hardware_status"."
\n".`df -h -l -x tmpfs`."
"; -&Settings::toLog($db, $syslog); + +$hardware_status = "$hardware_status"."
\n".`df -h -l -x tmpfs`."
"; +Settings::toLog($db, $$hardware_status); + + $db->disconnect(); } diff --git a/htdocs/cgi-bin/system/modules/Settings.pm b/htdocs/cgi-bin/system/modules/Settings.pm index f825b6a..1d21b57 100644 --- a/htdocs/cgi-bin/system/modules/Settings.pm +++ b/htdocs/cgi-bin/system/modules/Settings.pm @@ -116,33 +116,35 @@ try { $alias = $sss->param('alias'); $pass = $sss->param('passw'); $pub = $cgi->param('pub'); + + ##From here we have data source set, currently Progress DB SQL and SQLite SQL compatible. + dbSrc($sss->param('db_source')); + + if($pub){#we override session to obtain pub(alias)/pass from file main 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); + my $v = 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); + $v = 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); + last if parseAutonom('CONFIG',$line); } close $fh; if(!$SQL_PUB){$alias=undef} } if(!$alias){ - print $cgi->redirect("login_ctr.cgi?CGISESSID=$sid"); - exit; + $alias = "admin"; $pass = $alias; dbSrc('dbi:Pg:host=localhost;'); } - ##From here we have data source set, currently Progress DB SQL and SQLite SQL compatible. - dbSrc($sss->param('db_source')); my $ret = connectDB($alias, $pass); getConfiguration($ret); @@ -241,7 +243,7 @@ if($IS_PG_DB){ ID_CAT INT NOT NULL, ID_RTF INTEGER DEFAULT 0, DATE TIMESTAMP NOT NULL, - LOG VARCHAR (128) NOT NULL, + LOG VARCHAR (1024) NOT NULL, AMOUNT INTEGER, AFLAG INT DEFAULT 0, STICKY BOOL DEFAULT FALSE, @@ -479,6 +481,7 @@ sub printDebugHTML { sub toLog { my ($db,$log,$cat) = @_; + if(!$db){SettingsException->throw("Database handle not passed!")} my $stamp = getCurrentSQLTimeStamp(); if(!$cat){ my @arr = selectRecords($db,"SELECT ID FROM CAT WHERE NAME LIKE 'System Log' or NAME LIKE 'System';")->fetchrow_array();