mirror of
https://github.com/pi-hole/web.git
synced 2026-04-25 03:10:18 +01:00
Import legacy adlist.list and fix/remove debugging output
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -107,6 +107,16 @@ function add_to_table($db, $table, $domains, $comment, $wildcardstyle=false, $re
|
||||
return "Error: Unable to begin transaction for $table table.";
|
||||
}
|
||||
|
||||
// To which column should the record be added to?
|
||||
if ($table === "adlist")
|
||||
{
|
||||
$field = "address";
|
||||
}
|
||||
else
|
||||
{
|
||||
$field = "domain";
|
||||
}
|
||||
|
||||
// Get initial count of domains in this table
|
||||
if($type === -1)
|
||||
{
|
||||
@@ -121,11 +131,11 @@ function add_to_table($db, $table, $domains, $comment, $wildcardstyle=false, $re
|
||||
// Prepare INSERT SQLite statememt
|
||||
if($type === -1)
|
||||
{
|
||||
$querystr = "INSERT OR IGNORE INTO $table (domain,comment) VALUES (:domain, :comment);";
|
||||
$querystr = "INSERT OR IGNORE INTO $table ($field,comment) VALUES (:$field, :comment);";
|
||||
}
|
||||
else
|
||||
{
|
||||
$querystr = "INSERT OR IGNORE INTO $table (domain,comment,type) VALUES (:domain, :comment, $type);";
|
||||
$querystr = "INSERT OR IGNORE INTO $table ($field,comment,type) VALUES (:$field, :comment, $type);";
|
||||
}
|
||||
$stmt = $db->prepare($querystr);
|
||||
|
||||
@@ -135,7 +145,7 @@ function add_to_table($db, $table, $domains, $comment, $wildcardstyle=false, $re
|
||||
if($returnnum)
|
||||
return 0;
|
||||
else
|
||||
return "Error: Failed to prepare statement for $table table (type = $type).";
|
||||
return "Error: Failed to prepare statement for $table table (type = $type, field = $field).";
|
||||
}
|
||||
|
||||
// Loop over domains and inject the lines into the database
|
||||
@@ -149,7 +159,7 @@ function add_to_table($db, $table, $domains, $comment, $wildcardstyle=false, $re
|
||||
if($wildcardstyle)
|
||||
$domain = "(\\.|^)".str_replace(".","\\.",$domain)."$";
|
||||
|
||||
$stmt->bindValue(":domain", $domain, SQLITE3_TEXT);
|
||||
$stmt->bindValue(":$field", $domain, SQLITE3_TEXT);
|
||||
$stmt->bindValue(":comment", $comment, SQLITE3_TEXT);
|
||||
|
||||
if($stmt->execute() && $stmt->reset())
|
||||
|
||||
Reference in New Issue
Block a user