Skip to content

Commit

Permalink
Tried to fix various issues that came up with the new bookworm image
Browse files Browse the repository at this point in the history
  • Loading branch information
JavanXD committed Mar 6, 2024
1 parent bf9936d commit bd9302d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
42 changes: 21 additions & 21 deletions backend/_headers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type");
$request_headers = apache_request_headers();
$http_origin = $request_headers['Origin'];
$allowed_http_origins = array(
"http://192.168.178.4.1",
"https://192.168.178.4.1",
"http://honeypi.local",
"https://honeypi.local",
"http://honeypi.fritz.box",
"https://honeypi.fritz.box",
"http://localhost:4200",
"https://localhost:4200"
);
$host = parse_url($http_origin, PHP_URL_HOST);
$tmp = explode('.',$host); $n = count($tmp);
$tld = $tmp[($n-2)].".".$tmp[($n-1)]; //top-level domain
$isHomeNetwork = strpos($host, "192.168.");

if (in_array($http_origin, $allowed_http_origins) || in_array($tld, array("local", "honeypi")) || $isHomeNetwork !== false) {
// This function is actually not bullet-proof
@header("Access-Control-Allow-Origin: " . $http_origin);
if( isset($request_headers['Origin'])) {
$http_origin = $request_headers['Origin'];
$allowed_http_origins = array(
"http://192.168.178.4.1",
"https://192.168.178.4.1",
"http://honeypi.local",
"https://honeypi.local",
"http://honeypi.fritz.box",
"https://honeypi.fritz.box",
"http://localhost:4200",
"https://localhost:4200"
);
$host = parse_url($http_origin, PHP_URL_HOST);
$tmp = explode('.',$host); $n = count($tmp);
$tld = $tmp[($n-2)].".".$tmp[($n-1)]; //top-level domain
$isHomeNetwork = strpos($host, "192.168.");
if (in_array($http_origin, $allowed_http_origins) || in_array($tld, array("local", "honeypi")) || $isHomeNetwork !== false) {
// This function is actually not bullet-proof
@header("Access-Control-Allow-Origin: " . $http_origin);
}
header("Vary: Origin");
}
header("Vary: Origin");

// nocache
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
Expand Down
2 changes: 1 addition & 1 deletion backend/control.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function shutdown() {
shell_exec("sudo systemctl disable hostapd.service");
shell_exec("sudo systemctl stop dnsmasq.service");
shell_exec("sudo systemctl disable dnsmasq.service");
shell_exec("sudo shutdown -h 0");
shell_exec("sudo shutdown -h now");
}
function stop_honeypi() {
shell_exec("sudo systemctl stop honeypi.service");
Expand Down
15 changes: 9 additions & 6 deletions backend/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@

// function for shell script
function updateGit() {
return shell_exec("sudo git reset HEAD --hard && sudo git pull");
chdir($GLOBALS['honeyPiHome']);
$out = shell_exec("cd ".$GLOBALS['honeyPiHome']." 2>&1");
$out .= shell_exec("cd ".$GLOBALS['honeyPiHome']." && sudo git config --global --add safe.directory ".$GLOBALS['honeyPiHome']." 2>&1");
$out .= shell_exec("cd ".$GLOBALS['honeyPiHome']." && sudo git reset HEAD --hard 2>&1");
$out .= shell_exec("cd ".$GLOBALS['honeyPiHome']." && sudo git pull 2>&1");
return $out;
}
function update($stable) {
return shell_exec("sudo sh ".$GLOBALS['honeyPiHome']."/update.sh ".(INT)$stable."");
Expand Down Expand Up @@ -118,12 +123,10 @@ function getVersionInfo($isStable) {
return $obj;
}

# Add Working dir to output
$output = new \stdClass();
// switch working dir
$output->chdir = "Changed working dir from ";
$output->chdir .= getcwd() . "\n";
chdir($GLOBALS['honeyPiHome']);
$output->chdir .= " to " . getcwd() . "\n";
$output->chdir = "Working dir: ";
$output->chdir .= getcwd();

if (isset($_GET['mode']))
{
Expand Down

0 comments on commit bd9302d

Please sign in to comment.