Files
web/php/sub.php
Mcat12 8a33af6d6b Possible fix for FireFox and IE
Both failed CORS as both browsers, unlike Chrome,
do not send `Origin` headers for same-origin requests.
Now the scripts check if the `Host` header equals
the IP of the Pi-hole. IE may require more fixing,
as it's IE. :P
2016-05-10 20:30:28 -04:00

25 lines
699 B
PHP

<?php
if(!isset($_POST['domain'], $_POST['list'], $_POST['token']))
die("Missing POST variables");
// Check CORS
if($_SERVER['HTTP_ORIGIN'] != "http://pi.hole" && $_SERVER['HTTP_ORIGIN'] != "http://${_SERVER['SERVER_ADDR']}" || $_SERVER['HTTP_HOST'] != $_SERVER['SERVER_ADDR'])
die("Failed CORS");
header("Access-Control-Allow-Origin: ${_SERVER['HTTP_ORIGIN']}");
session_start();
// Check CSRF token
if(!hash_equals($_SESSION['token'], $_POST['token']))
die("Wrong token");
switch($_POST['list']) {
case "white":
exec("sudo pihole -w -q -d ${_POST['domain']}");
break;
case "black":
exec("sudo pihole -b -q -d ${_POST['domain']}");
break;
}