Skip to content

Commit

Permalink
basic access point detection
Browse files Browse the repository at this point in the history
  • Loading branch information
TrystanLea committed Feb 3, 2024
1 parent c9f8b16 commit bc92e36
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
13 changes: 10 additions & 3 deletions index.php
Expand Up @@ -168,7 +168,7 @@

// Captive portal (android working, no luck on iOS yet)
if ($route->controller=="generate_204" || $route->controller=="hotspot-detect") {
header('Location: /');
header('Location: http://192.168.42.1');
exit;
}
// if (get('q')=="library/test/success.html") { header('Location: /'); exit; }
Expand Down Expand Up @@ -206,11 +206,18 @@
if (file_exists("Modules/setup")) {
require "Modules/setup/setup_model.php";
$setup = new Setup($mysqli);

if ($setup->status()=="unconfigured") {
$settings["interface"]["default_controller"] = "setup";
$settings["interface"]["default_action"] = "";
// Provide special setup access to WIFI module functions
$_SESSION['setup_access'] = true;
} else {
$_SESSION['setup_access'] = false;
}

// Either show setup interface if unconfigured or if access point login
if ($setup->status()=="unconfigured" || $route->is_ap) {
$settings["interface"]["default_controller"] = "setup";
$settings["interface"]["default_action"] = "";
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions route.php
Expand Up @@ -57,6 +57,11 @@ class Route
*/
public $is_ajax = false;

/**
* @var bool
*/
public $is_ap = false;

/**
* @param string $q
* @param string $documentRoot
Expand All @@ -67,6 +72,11 @@ public function __construct($q, $documentRoot, $requestMethod)
$this->decode($q, $documentRoot, $requestMethod);
//this can be faked by the client. not to be trusted.
$this->is_ajax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';

// is this an access point login?
if ($_SERVER['SERVER_ADDR']=="192.168.42.1") {
$this->is_ap = true;
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion version.json
@@ -1,6 +1,6 @@
{
"name" : "Emoncms Core",
"version" : "11.4.9",
"version" : "11.4.10",
"location" : "/var/www",
"branches_available": ["stable","master"]
}

0 comments on commit bc92e36

Please sign in to comment.