Update fetch remote blocklists

This commit is contained in:
billz 2023-10-06 10:58:54 +02:00
parent 1f5d4b0830
commit 3e491c17f4
1 changed files with 40 additions and 11 deletions

View File

@ -4,21 +4,50 @@ require '../../includes/csrf.php';
require_once '../../includes/config.php'; require_once '../../includes/config.php';
if (isset($_POST['blocklist_id'])) { if (isset($_POST['blocklist_id'])) {
$blocklist_id = $_POST['blocklist_id']; $blocklist_id = escapeshellcmd($_POST['blocklist_id']);
$notracking_url = "https://raw.githubusercontent.com/notracking/hosts-blocklists/master/";
switch ($blocklist_id) { switch ($blocklist_id) {
case "notracking-hostnames": case "StevenBlack/hosts \(default\)":
$file = "hostnames.txt"; $list_url = "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts";
break; $dest_file = "hostnames.txt";
case "notracking-domains": break;
$file = "domains.txt"; case "badmojr/1Hosts \(Mini\)":
break; $list_url = "https://badmojr.github.io/1Hosts/mini/hosts.txt";
$dest_file = "hostnames.txt";
break;
case "badmojr/1Hosts \(Lite\)":
$list_url = "https://badmojr.github.io/1Hosts/Lite/hosts.txt";
$dest_file = "hostnames.txt";
break;
case "badmojr/1Hosts \(Pro\)":
$list_url = "https://badmojr.github.io/1Hosts/Pro/hosts.txt";
$dest_file = "hostnames.txt";
break;
case "badmojr/1Hosts \(Xtra\)":
$list_url = "https://badmojr.github.io/1Hosts/Xtra/hosts.txt";
$dest_file = "hostnames.txt";
break;
case "oisd/big \(default\)":
$list_url = "https://big.oisd.nl/dnsmasq";
$dest_file = "domains.txt";
break;
case "oisd/small":
$list_url = "https://small.oisd.nl/dnsmasq";
$dest_file = "domains.txt";
break;
case "oisd/nsfw":
$list_url = "https://nsfw.oisd.nl/dnsmasq";
$dest_file = "domains.txt";
break;
} }
$blocklist = $notracking_url . $file; $blocklist = $list_url . $dest_file;
$dest = substr($dest_file, 0, strrpos($dest_file, "."));
exec("sudo /etc/raspap/adblock/update_blocklist.sh $blocklist $file " .RASPI_ADBLOCK_LISTPATH, $return); exec("sudo /etc/raspap/adblock/update_blocklist.sh $list_url $dest_file " .RASPI_ADBLOCK_LISTPATH, $return);
$jsonData = ['return'=>$return]; $jsonData = ['return'=>$return,'list'=>$dest];
echo json_encode($jsonData);
} else {
$jsonData = ['return'=>2,'output'=>['Error getting data']];
echo json_encode($jsonData); echo json_encode($jsonData);
} }