From: Metabox Date: Wed, 24 Apr 2019 07:18:36 +0000 (+1000) Subject: Accounting now on changed category list. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=eb44dcc1be260d1710ec6055a664fd97eebc5c37;p=LifeLog.git Accounting now on changed category list. --- diff --git a/htdocs/cgi-bin/login_ctr.cgi b/htdocs/cgi-bin/login_ctr.cgi index 359e7ef..a78298c 100755 --- a/htdocs/cgi-bin/login_ctr.cgi +++ b/htdocs/cgi-bin/login_ctr.cgi @@ -147,18 +147,16 @@ try{ ); ); $rv = $db->do($stmt); - - $st = $db->prepare('INSERT INTO CAT VALUES (?,?,?)'); - $st->execute(1,"Unspecified", "For quick uncategorised entries."); - $st->execute(3,"File System", "Operating file system short log."); - $st->execute(6,"System Log", "Operating system important log."); - $st->execute(9,"Event", "Event that occured, meeting, historically important."); - $st->execute(28,"Personal", "Personal log of historical importants, diary type."); - $st->execute(32, "Expense", "Significant yearly expense."); - $st->execute(35, "Income", "Significant yearly income."); - $st->execute(40, "Work", "Work related entry, worth monitoring."); - $st->execute(45, "Food", "Quick reference to recepies, observations."); + insertDefCats($db); } + #Have cats been wiped out? + $st = $db->prepare('SELECT count(ID) FROM CAT;'); + $st->execute(); + if($st->fetchrow_array()==0) { + insertDefCats($db); + } + + $st = $db->prepare(selSQLTbl('AUTH')); $st->execute(); if(!$st->fetchrow_array()) { @@ -215,6 +213,21 @@ sub selSQLTbl{ return "SELECT name FROM sqlite_master WHERE type='table' AND name='$name';" } +sub insertDefCats{ + my + $st = $_[0]->prepare('INSERT INTO CAT VALUES (?,?,?)'); + $st->execute(1,"Unspecified", "For quick uncategorised entries."); + $st->execute(3,"File System", "Operating file system short log."); + $st->execute(6,"System Log", "Operating system important log."); + $st->execute(9,"Event", "Event that occured, meeting, historically important."); + $st->execute(28,"Personal", "Personal log of historical importants, diary type."); + $st->execute(32, "Expense", "Significant yearly expense."); + $st->execute(35, "Income", "Significant yearly income."); + $st->execute(40, "Work", "Work related entry, worth monitoring."); + $st->execute(45, "Food", "Quick reference to recepies, observations."); + $st->finish(); +} + sub populateConfig{ my $db = shift; my $st = $db->prepare('INSERT INTO CONFIG VALUES (?,?,?)');