Revert "Accept $token object, pass to renderTemplate()"

This reverts commit b3c6178274.
This commit is contained in:
billz
2025-03-25 13:23:58 -07:00
parent 48e492bf10
commit b0ba029c66
13 changed files with 54 additions and 72 deletions

View File

@@ -5,7 +5,7 @@ require_once "app/lib/Parsedown.php";
/** /**
* Displays info about the RaspAP project * Displays info about the RaspAP project
*/ */
function DisplayAbout($token) function DisplayAbout()
{ {
$Parsedown = new Parsedown(); $Parsedown = new Parsedown();
$strContent = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/BACKERS.md'); $strContent = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/BACKERS.md');
@@ -17,8 +17,7 @@ function DisplayAbout($token)
echo renderTemplate( echo renderTemplate(
"about", compact( "about", compact(
'sponsorsHtml', 'sponsorsHtml',
'contributingHtml', 'contributingHtml'
'token'
) )
); );
} }

View File

@@ -6,7 +6,7 @@ require_once 'config.php';
* Manages ad blocking (dnsmasq) configuration * Manages ad blocking (dnsmasq) configuration
* *
*/ */
function DisplayAdBlockConfig($token) function DisplayAdBlockConfig()
{ {
$status = new \RaspAP\Messages\StatusMessage; $status = new \RaspAP\Messages\StatusMessage;
$enabled = false; $enabled = false;
@@ -93,6 +93,7 @@ function DisplayAdBlockConfig($token)
$adblock_log = "Unable to open log file"; $adblock_log = "Unable to open log file";
} }
$logdata = getLogLimited(RASPI_DHCPCD_LOG, $adblock_log); $logdata = getLogLimited(RASPI_DHCPCD_LOG, $adblock_log);
echo renderTemplate( echo renderTemplate(
"adblock", compact( "adblock", compact(
"status", "status",
@@ -101,8 +102,7 @@ function DisplayAdBlockConfig($token)
"enabled", "enabled",
"custom_enabled", "custom_enabled",
"adblock_custom_content", "adblock_custom_content",
"logdata", "logdata"
"token"
) )
); );
} }

View File

@@ -1,6 +1,6 @@
<?php <?php
function DisplayAuthConfig($username, $token) function DisplayAuthConfig($username)
{ {
$status = new \RaspAP\Messages\StatusMessage; $status = new \RaspAP\Messages\StatusMessage;
$auth = new \RaspAP\Auth\HTTPAuth; $auth = new \RaspAP\Auth\HTTPAuth;
@@ -42,8 +42,7 @@ function DisplayAuthConfig($username, $token)
echo renderTemplate( echo renderTemplate(
"admin", compact( "admin", compact(
"status", "status",
"username", "username"
"token"
) )
); );
} }

View File

@@ -6,7 +6,7 @@ require_once 'includes/wifi_functions.php';
* *
* *
*/ */
function DisplayWPAConfig($token) function DisplayWPAConfig()
{ {
$status = new \RaspAP\Messages\StatusMessage; $status = new \RaspAP\Messages\StatusMessage;
$networks = []; $networks = [];
@@ -148,12 +148,5 @@ function DisplayWPAConfig($token)
preg_match('/state (UP|DOWN)/i', $stdoutIpWRepeatedSpaces, $matchesState) || $matchesState[1] = 'unknown'; preg_match('/state (UP|DOWN)/i', $stdoutIpWRepeatedSpaces, $matchesState) || $matchesState[1] = 'unknown';
$ifaceStatus = strtolower($matchesState[1]) ? "up" : "down"; $ifaceStatus = strtolower($matchesState[1]) ? "up" : "down";
echo renderTemplate( echo renderTemplate("configure_client", compact("status", "clientInterface", "ifaceStatus"));
"configure_client", compact(
"status",
"clientInterface",
"ifaceStatus",
"token"
)
);
} }

View File

@@ -7,7 +7,7 @@ require_once 'includes/functions.php';
/** /**
* Displays the dashboard * Displays the dashboard
*/ */
function DisplayDashboard(&$extraFooterScripts, $token): void function DisplayDashboard(&$extraFooterScripts): void
{ {
// instantiate RaspAP objects // instantiate RaspAP objects
$system = new \RaspAP\System\Sysinfo; $system = new \RaspAP\System\Sysinfo;
@@ -74,7 +74,9 @@ function DisplayDashboard(&$extraFooterScripts, $token): void
$varName = "freq" . str_replace('.', '', $frequency) . "active"; $varName = "freq" . str_replace('.', '', $frequency) . "active";
$$varName = "active"; $$varName = "active";
$vpnStatus = $vpn ? "active" : "inactive"; $vpnStatus = $vpn ? "active" : "inactive";
$vpnManaged = $vpn ? $dashboard->getVpnManaged($vpn) : null; if ($vpn) {
$vpnManaged = $dashboard->getVpnManged($vpn);
}
$firewallManaged = $firewallStatus = ""; $firewallManaged = $firewallStatus = "";
$firewallInstalled = array_filter($plugins, fn($p) => str_ends_with($p, 'Firewall')) ? true : false; $firewallInstalled = array_filter($plugins, fn($p) => str_ends_with($p, 'Firewall')) ? true : false;
if (!$firewallInstalled) { if (!$firewallInstalled) {
@@ -120,8 +122,7 @@ function DisplayDashboard(&$extraFooterScripts, $token): void
"wirelessActive", "wirelessActive",
"tetheringActive", "tetheringActive",
"cellularActive", "cellularActive",
"status", "status"
"token"
) )
); );
$extraFooterScripts[] = array('src'=>'app/js/dashboardchart.js', 'defer'=>false); $extraFooterScripts[] = array('src'=>'app/js/dashboardchart.js', 'defer'=>false);

View File

@@ -5,7 +5,7 @@ require_once 'config.php';
/** /**
* Manage DHCP configuration * Manage DHCP configuration
*/ */
function DisplayDHCPConfig($token) function DisplayDHCPConfig()
{ {
$status = new \RaspAP\Messages\StatusMessage; $status = new \RaspAP\Messages\StatusMessage;
if (!RASPI_MONITOR_ENABLED) { if (!RASPI_MONITOR_ENABLED) {
@@ -74,8 +74,7 @@ function DisplayDHCPConfig($token)
"upstreamServers", "upstreamServers",
"interfaces", "interfaces",
"leases", "leases",
"logdata", "logdata"
"token"
) )
); );
} }

View File

@@ -9,7 +9,7 @@ getWifiInterface();
* Initialize hostapd values, display interface * Initialize hostapd values, display interface
* *
*/ */
function DisplayHostAPDConfig($token) function DisplayHostAPDConfig()
{ {
$status = new \RaspAP\Messages\StatusMessage; $status = new \RaspAP\Messages\StatusMessage;
$system = new \RaspAP\System\Sysinfo; $system = new \RaspAP\System\Sysinfo;
@@ -165,8 +165,7 @@ function DisplayHostAPDConfig($token)
"operatingSystem", "operatingSystem",
"selectedHwMode", "selectedHwMode",
"countryCodes", "countryCodes",
"logdata", "logdata"
"token"
) )
); );
} }

View File

@@ -6,7 +6,7 @@ require_once 'includes/functions.php';
/** /**
* Handler for administrative user login * Handler for administrative user login
*/ */
function DisplayLogin($token) function DisplayLogin()
{ {
// initialize auth object // initialize auth object
$auth = new \RaspAP\Auth\HTTPAuth; $auth = new \RaspAP\Auth\HTTPAuth;
@@ -33,8 +33,7 @@ function DisplayLogin($token)
echo renderTemplate( echo renderTemplate(
"login", compact( "login", compact(
"status", "status",
"redirectUrl", "redirectUrl"
"token"
) )
); );
} }

View File

@@ -8,7 +8,7 @@ getWifiInterface();
/** /**
* Manage OpenVPN configuration * Manage OpenVPN configuration
*/ */
function DisplayOpenVPNConfig($token) function DisplayOpenVPNConfig()
{ {
$status = new \RaspAP\Messages\StatusMessage; $status = new \RaspAP\Messages\StatusMessage;
if (!RASPI_MONITOR_ENABLED) { if (!RASPI_MONITOR_ENABLED) {
@@ -79,8 +79,7 @@ function DisplayOpenVPNConfig($token)
"authUser", "authUser",
"authPassword", "authPassword",
"clients", "clients",
"conf_default", "conf_default"
"token"
) )
); );
} }

View File

@@ -9,7 +9,7 @@ $page = $_SERVER['PATH_INFO'];
// Check if any plugin wants to handle the request // Check if any plugin wants to handle the request
if (!$pluginManager->handlePageAction($page)) { if (!$pluginManager->handlePageAction($page)) {
// If no plugin is available fall back to core page action handlers // If no plugin is available fall back to core page action handlers
handleCorePageAction($page, $extraFooterScripts, $token); handleCorePageAction($page, $extraFooterScripts);
} }
/** /**
@@ -17,65 +17,64 @@ if (!$pluginManager->handlePageAction($page)) {
* *
* @param string $page * @param string $page
* @param array $extraFooterScripts * @param array $extraFooterScripts
* @param object $token
* @return void * @return void
*/ */
function handleCorePageAction(string $page, array &$extraFooterScripts, object $token): void function handleCorePageAction(string $page, array &$extraFooterScripts): void
{ {
switch ($page) { switch ($page) {
case "/wlan0_info": case "/wlan0_info":
DisplayDashboard($extraFooterScripts, $token); DisplayDashboard($extraFooterScripts);
break; break;
case "/dhcpd_conf": case "/dhcpd_conf":
DisplayDHCPConfig($token); DisplayDHCPConfig();
break; break;
case "/wpa_conf": case "/wpa_conf":
DisplayWPAConfig($token); DisplayWPAConfig();
break; break;
case "/network_conf": case "/network_conf":
DisplayNetworkingConfig($token); DisplayNetworkingConfig();
break; break;
case "/hostapd_conf": case "/hostapd_conf":
DisplayHostAPDConfig($token); DisplayHostAPDConfig();
break; break;
case "/adblock_conf": case "/adblock_conf":
DisplayAdBlockConfig($token); DisplayAdBlockConfig();
break; break;
case "/openvpn_conf": case "/openvpn_conf":
DisplayOpenVPNConfig($token); DisplayOpenVPNConfig();
break; break;
case "/wg_conf": case "/wg_conf":
DisplayWireGuardConfig($token); DisplayWireGuardConfig();
break; break;
case "/provider_conf": case "/provider_conf":
DisplayProviderConfig($token); DisplayProviderConfig();
break; break;
case "/torproxy_conf": case "/torproxy_conf":
DisplayTorProxyConfig($token); DisplayTorProxyConfig();
break; break;
case "/auth_conf": case "/auth_conf":
DisplayAuthConfig($_SESSION['user_id'], $token); DisplayAuthConfig($_SESSION['user_id']);
break; break;
case "/save_hostapd_conf": case "/save_hostapd_conf":
SaveTORAndVPNConfig($token); SaveTORAndVPNConfig();
break; break;
case "/data_use": case "/data_use":
DisplayDataUsage($extraFooterScripts, $token); DisplayDataUsage($extraFooterScripts);
break; break;
case "/system_info": case "/system_info":
DisplaySystem($extraFooterScripts, $token); DisplaySystem($extraFooterScripts);
break; break;
case "/restapi_conf": case "/restapi_conf":
DisplayRestAPI($token); DisplayRestAPI();
break; break;
case "/about": case "/about":
DisplayAbout($token); DisplayAbout();
break; break;
case "/login": case "/login":
DisplayLogin($token); DisplayLogin();
break; break;
default: default:
DisplayDashboard($extraFooterScripts, $token); DisplayDashboard($extraFooterScripts);
} }
} }

View File

@@ -6,7 +6,7 @@ require_once 'config.php';
/** /**
* Handler for RestAPI settings * Handler for RestAPI settings
*/ */
function DisplayRestAPI($token) function DisplayRestAPI()
{ {
// initialize status object // initialize status object
$status = new \RaspAP\Messages\StatusMessage; $status = new \RaspAP\Messages\StatusMessage;
@@ -59,16 +59,13 @@ function DisplayRestAPI($token)
$docMsg = sprintf(_("RestAPI docs are accessible <a href=\"%s\" target=\"_blank\">here %s</a>"),$docUrl, $faicon); $docMsg = sprintf(_("RestAPI docs are accessible <a href=\"%s\" target=\"_blank\">here %s</a>"),$docUrl, $faicon);
} }
echo renderTemplate( echo renderTemplate("restapi", compact(
"restapi", compact( "status",
"status", "apiKey",
"apiKey", "serviceStatus",
"serviceStatus", "serviceLog",
"serviceLog", "docMsg"
"docMsg", ));
"token"
)
);
} }
/** /**

View File

@@ -6,7 +6,7 @@ require_once 'config.php';
/** /**
* *
*/ */
function DisplaySystem(&$extraFooterScripts, $token) function DisplaySystem(&$extraFooterScripts)
{ {
$status = new \RaspAP\Messages\StatusMessage; $status = new \RaspAP\Messages\StatusMessage;
$dashboard = new \RaspAP\UI\Dashboard; $dashboard = new \RaspAP\UI\Dashboard;
@@ -146,8 +146,7 @@ function DisplaySystem(&$extraFooterScripts, $token)
"themes", "themes",
"selectedTheme", "selectedTheme",
"logLimit", "logLimit",
"pluginsTable", "pluginsTable"
"token"
)); ));
} }

View File

@@ -5,7 +5,7 @@ require_once 'config.php';
/** /**
* Displays wireguard server & peer configuration * Displays wireguard server & peer configuration
*/ */
function DisplayWireGuardConfig($token) function DisplayWireGuardConfig()
{ {
$status = new \RaspAP\Messages\StatusMessage; $status = new \RaspAP\Messages\StatusMessage;
$parseFlag = true; $parseFlag = true;
@@ -98,8 +98,7 @@ function DisplayWireGuardConfig($token)
"wg_pendpoint", "wg_pendpoint",
"wg_pallowedips", "wg_pallowedips",
"wg_pkeepalive", "wg_pkeepalive",
"wg_log", "wg_log"
"token"
) )
); );
} }