query($querystr); while($results !== false && $res = $results->fetchArray(SQLITE3_ASSOC)) { $utf8_domain = idn_to_utf8($res['domain']); // Convert domain name to international form // if applicable if($res['domain'] !== $utf8_domain) { $res['domain'] = $utf8_domain.' ('.$res['domain'].')'; } array_push($entries, $res); } return $entries; } 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; } switch ($listtype) { case "white": $exact = array("whitelist" => getTableContent(ListType::whitelist)); $regex = array("regex_whitelist" => getTableContent(ListType::regex_whitelist)); $list = array_merge($exact, $regex); break; case "black": $exact = array("blacklist" => getTableContent(ListType::blacklist)); $regex = array("regex_blacklist" => getTableContent(ListType::regex_blacklist)); $list = array_merge($exact, $regex); break; default: die("Invalid list parameter"); break; } // Protect against XSS attacks $output = filterArray($list); // Return results header('Content-type: application/json'); echo json_encode($output);