Fix audit log page.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2020-02-21 19:05:09 +01:00
parent dd7b2b20ef
commit 1300b5411a
3 changed files with 23 additions and 15 deletions

View File

@@ -91,7 +91,7 @@ function SQLite3_connect($filename, $mode=SQLITE3_OPEN_READONLY)
* @param $type integer The target type (0 = exact whitelist, 1 = exact blacklist, 2 = regex whitelist, 3 = regex blacklist)
* @return string Success/error and number of processed domains
*/
function add_to_table($db, $table, $domains, $comment, $wildcardstyle=false, $returnnum=false, $type=-1)
function add_to_table($db, $table, $domains, $comment=null, $wildcardstyle=false, $returnnum=false, $type=-1)
{
if(!is_int($type))
{
@@ -129,13 +129,15 @@ function add_to_table($db, $table, $domains, $comment, $wildcardstyle=false, $re
$initialcount = intval($db->querySingle($countquery));
// Prepare INSERT SQLite statememt
if($type === -1)
{
$bindcomment = false;
if($table === "domain_audit") {
$querystr = "INSERT OR IGNORE INTO $table ($field) VALUES (:$field);";
} elseif($type === -1) {
$querystr = "INSERT OR IGNORE INTO $table ($field,comment) VALUES (:$field, :comment);";
}
else
{
$bindcomment = true;
} else {
$querystr = "INSERT OR IGNORE INTO $table ($field,comment,type) VALUES (:$field, :comment, $type);";
$bindcomment = true;
}
$stmt = $db->prepare($querystr);
@@ -160,7 +162,9 @@ function add_to_table($db, $table, $domains, $comment, $wildcardstyle=false, $re
$domain = "(\\.|^)".str_replace(".","\\.",$domain)."$";
$stmt->bindValue(":$field", $domain, SQLITE3_TEXT);
$stmt->bindValue(":comment", $comment, SQLITE3_TEXT);
if($bindcomment) {
$stmt->bindValue(":comment", $comment, SQLITE3_TEXT);
}
if($stmt->execute() && $stmt->reset())
$num++;