From a13a35a7054f6c22ec98eb3c6d6a1f7ae500bb92 Mon Sep 17 00:00:00 2001 From: Metabox Date: Sun, 2 Jun 2019 09:04:17 +1000 Subject: [PATCH] CSV fixes --- htdocs/cgi-bin/config.cgi | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/cgi-bin/config.cgi b/htdocs/cgi-bin/config.cgi index 797743a..04e3c55 100755 --- a/htdocs/cgi-bin/config.cgi +++ b/htdocs/cgi-bin/config.cgi @@ -53,7 +53,7 @@ if(!$userid||!$dbname){ exit; } -my $database = '../../dbLifeLog/'.$dbname; +my $database = $LOG_PATH.$dbname; my $dsn= "DBI:SQLite:dbname=$database"; my $db = DBI->connect($dsn, $userid, $password, { RaiseError => 1 }) or die "

Error->"& $DBI::errstri &"

"; @@ -631,7 +631,7 @@ catch{ } } -sub resetCategories{ +sub resetCategories { $dbs = $db->prepare("DELETE FROM CAT;"); $dbs->execute(); $dbs = $db->prepare("DROP TABLE CAT;"); @@ -639,7 +639,7 @@ sub resetCategories{ $LOGOUT = 1; } -sub wipeSystemConfiguration{ +sub wipeSystemConfiguration { $dbs = $db->prepare("DELETE FROM CONFIG;"); $dbs->execute(); $dbs = $db->prepare("DROP TABLE CONFIG;"); @@ -650,7 +650,7 @@ sub wipeSystemConfiguration{ sub resetSystemConfiguration { - open(my $fh, '<', './main.cnf' ) or die "Can't open main.cnf: $!"; + open(my $fh, '<', $LOG_PATH.'main.cnf' ) or die "Can't open main.cnf: $!"; my $db = shift; my ($did,$name, $value, $desc); my $inData = 0; @@ -778,7 +778,7 @@ sub updCnf { sub exportLogToCSV { try{ - my $csv = Text::CSV->new ( { binary => 1, strict => 1 } ); + my $csv = Text::CSV->new ( { binary => 1, strict => 1 , quote_space=>1, auto_diag => 1, eol => $/} ); $dbs = $db->prepare("SELECT * FROM LOG;"); $dbs->execute(); @@ -809,7 +809,7 @@ sub exportLogToCSV { sub exportCategoriesToCSV { try{ - my $csv = Text::CSV->new ( { binary => 1, strict => 1 } ); + my $csv = Text::CSV->new ( { binary => 1, strict => 1,eol => $/ } ); $dbs = $db->prepare("SELECT ID, NAME, DESCRIPTION FROM CAT ORDER BY ID;"); $dbs->execute(); @@ -840,7 +840,7 @@ sub exportCategoriesToCSV { sub importCatCSV { my $hndl = $cgi->upload("data_cat"); - my $csv = Text::CSV->new ( { binary => 1, strict => 1 } ); + my $csv = Text::CSV->new ( { binary => 1, strict => 1, eol => $/ } ); while (my $line = <$hndl>) { chomp $line; if ($csv->parse($line)) { @@ -880,7 +880,7 @@ sub updateCATDB { } sub importLogCSV { my $hndl = $cgi->upload("data_log"); - my $csv = Text::CSV->new ( { binary => 1, strict => 1 } ); + my $csv = Text::CSV->new ( { binary => 1, strict => 1, eol => $/ } ); while (my $line = <$hndl>) { chomp $line; if ($csv->parse($line)) { -- 2.34.1