my $cats;
my %hshCats = {};
&cats;
+
###############
&processSubmit;
###############
<td align="left"><input type="text" name="cade" value="" size="64"/></td>
</tr>
<tr class="r1">
- <td colspan="2"><a href="#bottom">↡</a> <input type="submit" value="Add New Category First" onclick="return submitNewCategory()"/> or <input type="submit" value="Change"/></td>
- <td colspan="1" align="right"><b>Categories Configuration In -> $dbname</b> <input type="submit" value="Change" onclick="return checkConfigCatsChange()"/></td>
+ <td colspan="2"><a href="#bottom">↡</a>
+ <input type="submit" value="Add New Category First" onclick="return submitNewCategory()"/> or <input type="submit" value="Change"/></td>
+ <td colspan="1" align="right"><b>Categories Configuration In -> $dbname</b>
+ <input type="submit" value="Change" onclick="return checkConfigCatsChange()"/></td>
</tr>
<tr class="r1">
<td colspan="3"><div style="text-align:left; float"><font color="red">WARNING!</font>
);
+my @backups = ();
+my ($file,$bck_list) ="";
+opendir my $dir, &Settings::logPath;
+while($file = readdir $dir){
+next if $file eq '.' or $file eq '..' or index ($file , 'bck_') == -1;
+ push @backups, $file;
+}
+close $dir;
+foreach $file (sort @backups){
+ #my $n = substr $file, length(&Settings::logPath);
+ $bck_list .= "<input name='bck_file' type='radio' value='$file'>$file</input><br>";
+}
+if(length $bck_list == 0){
+$bck_list = '<p>Restore will bring back and merge log entries from the time of backup.</p>';
+}
+else{
+ $bck_list = qq(<p>Tick Select Backup to Restore or Delete</p><p>$bck_list</p>);
+}
+
+
#
# Page printout from here!
#
<tr><td><H3>Backup File Format</H3></td></tr>
<tr><td><input type="button" onclick="return fetchBackup();" value="Fetch"/><hr></td></tr>
- <tr><td><p>Restore will bring back and merge log entries from the time of backup.</p><hr></td></tr>
- <tr><td><input type="file" name="data_bck" /><input type="button" onclick="return restoreBackup();" value="Restore"/><hr></td></tr>
+ <tr><td><div id="div_backups">$bck_list</div><hr></td></tr>
+ <tr><td><input type="button" onclick="return deleteBackup();" value="Delete"/> <input type="file" name="data_bck" /><input type="button" onclick="return restoreBackup();" value="Restore"/><hr></td></tr>
<tr><td><H3>CSV File Format</H3></td></tr>
while (my @r=$dbs->fetchrow_array()){
my $var = $cgi->param('var'.$r[0]);
if(defined $var){
- updCnf($r[0],$var);
+ Settings::configProperty($db, $r[0], undef, $var);
$updated = 1;
}
}
Settings::getConfiguration($db) if($updated);
}
-sub updCnf {
- my ($id, $val, $s) = @_;
- $s = "UPDATE CONFIG SET VALUE='".$val."' WHERE ID=".$id.";";
- try{
- Settings::selectRecords($db, $s);
- }
- catch{
- print "<font color=red><b>SERVER ERROR</b>->updCnf[$s]</font>:".$_;
- }
-}
-
-
sub backup {
- # my $ball2 = qwq(tar -czf - data_*_log.db | openssl enc -e -des-ede3-cfb -out secured.tgz);
- #openssl enc -d -des-ede3-cfb -in secured.tar.gz | tar xz -C test
- my $ball = $today->strftime('%Y%m%d%H%M%S_')."$dbname.osz";
+ my $ball = 'bck_'.$today->strftime('%Y%m%d%H%M%S_')."$dbname.osz";
my $pipe = "tar czf - ".&Settings::logPath.'main.cnf' ."$database | openssl enc -k $pass:$userid -e -des-ede3-cfb -out ".Settings::logPath().$ball;
`$pipe`;
- # my $ball = $today->strftime('%Y%m%d%H%M%S_')."$dbname.tgz";
- # my $pipe = new IO::File("| openssl enc -k $pass:$userid -e -des-ede3-cfb | gzip -c >".Settings::logPath().$ball);
- # my @fls =(&Settings::logPath.'main.cnf',$database);
- # my $tar = Archive::Tar->new();
- # $tar-> add_files(@fls);
- # $tar->write($pipe);
- # $pipe->close;
-
- # my @tar = qw("tar -czf ");
- # push @tar, &Settings::logPath. "data_*_log.db";
- # push @tar, qw(|openssl enc -e -pbkdf2 -out);
- # push @tar, $ball;
- # my $res = run @tar;
-
-
-
-
- # my $tar = Archive::Tar->new();
- # my @fls =(&Settings::logPath.'main.cnf',$database);
- # $tar-> add_files(@fls);
- # $tar->write(Settings::logPath().$ball,9);
-
- # Not allowed following for now
- #
print $cgi->header(-type=>"application/octet-stream", -attachment=>"$ball");
select(STDOUT); $| = 1; #unbuffer STDOUT
binmode STDOUT;
print <TAR>;
close TAR;
- # LifeLogException->throw("Backup feature currently under development! Serverside created files is -> $ball");
+ #LifeLogException->throw("Backup feature currently under development! Serverside created files is -> $ball");
}
my $tbl_rc =0;
my ($stm,$st, $rv);
-my $tbl = '<form name="frm_log_del" action="data.cgi" onSubmit="return formDelValidation();">
+my $tbl = '<a name="top"></a><form name="frm_log_del" action="data.cgi" onSubmit="return formDelValidation();">
<table class="tbl_rem" width="'.$PRC_WIDTH.'%">
- <tr class="hdr" style="text-align:left;"><th>Date</th> <th>Time</th><th>Log</th><th>Category</th></tr>';
+ <tr class="hdr" style="text-align:left;"><th>Date <a href="#bottom">↡</a></th> <th>Time</th> <th>Log</th> <th>Category</th></tr>';
my $datediff = $cgi->param("datediff");
}
$tbl .= '</table>';
-print '<center><div>'.$tbl.'</div><br><div><a href="main.cgi">Back to Main Log</a></div></center>';
+print '<a name="top"></a><center><div>'.$tbl.'</div><br><div><a href="main.cgi">Back to Main Log</a></div></center>';
}
$plural = "s";
}
- $tbl = $tbl . '<tr class="r0"><td colspan="4">
+ $tbl = $tbl . '<tr class="r0"><td colspan="4"><a name="bottom"></a><a href="#top">↟</a>
<center>
<h2>Please Confirm You Want<br>The Above Record'.$plural.' Deleted?</h2>
(Or hit you Browsers Back Button!)</center>
sub configProperty {
my($db, $id, $name, $value) = @_;
$id = '0' if not $id;
- if(!$db || !$name|| not defined $value){
+ if($db eq undef || $value eq undef){
SettingsException->throw(
error => "ERROR Invalid number of arguments in call -> Settings::configProperty('$db',$id,'$name','$value')\n", show_trace=>$DEBUG
);
};
- my $dbs = selectRecords($db, "SELECT ID, NAME FROM CONFIG WHERE NAME IS '$name';");
- if($dbs->fetchrow_array()){
- $db->do("UPDATE CONFIG SET VALUE = '$value' WHERE NAME IS '$name';");
+ if($name eq undef && $id){
+
+ my $sql = "UPDATE CONFIG SET VALUE='".$value."' WHERE ID=".$id.";";
+ try{
+ $db->do($sql);
+ }
+ catch{
+
+ SettingsException->throw(
+ error => "ERROR with $sql -> Settings::configProperty('$db',$id,'$name','$value')\n",
+ show_trace=>$DEBUG
+ );
+ }
}
else{
- $db->do("INSERT INTO CONFIG (ID, NAME, VALUE) VALUES ($id, '$name', '$value');");
+ my $dbs = selectRecords($db, "SELECT ID, NAME FROM CONFIG WHERE NAME IS '$name';");
+ if($dbs->fetchrow_array()){
+ $db->do("UPDATE CONFIG SET VALUE = '$value' WHERE NAME IS '$name';");
+ }
+ else{
+ my $sql = "INSERT INTO CONFIG (ID, NAME, VALUE) VALUES ($id, '$name', '$value');";
+ try{
+ $db->do($sql);
+ }
+ catch{
+
+ SettingsException->throw(
+ error => "ERROR $@ with $sql -> Settings::configProperty('$db',$id,'$name','$value')\n",
+ show_trace=>$DEBUG
+ );
+ }
+ }
}
}