mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 20:55:28 +00:00
34 lines
795 B
PHP
34 lines
795 B
PHP
<?php
|
|
if(!isset($_GET['list']))
|
|
die();
|
|
|
|
$type = $_GET['list'];
|
|
|
|
if($type !== "white" && $type !== "black")
|
|
die("Invalid list parameter");
|
|
|
|
$rawList = file_get_contents("/etc/pihole/${type}list.txt");
|
|
$list = explode("\n", $rawList);
|
|
|
|
// Get rid of empty lines
|
|
for($i = sizeof($list)-1; $i >= 0; $i--) {
|
|
if($list[$i] == "")
|
|
unset($list[$i]);
|
|
}
|
|
|
|
function filterArray(&$inArray) {
|
|
$outArray = array();
|
|
foreach ($inArray as $key=>$value) {
|
|
if (is_array($value)) {
|
|
$outArray[htmlspecialchars($key)] = filterArray($value);
|
|
} else {
|
|
$outArray[htmlspecialchars($key)] = htmlspecialchars($value);
|
|
}
|
|
}
|
|
return $outArray;
|
|
}
|
|
|
|
// Protect against XSS attacks
|
|
$list = filterArray($list);
|
|
echo json_encode(array_values($list));
|