1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2025-07-06 17:17:41 +02:00

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

This reverts commit b3c61782749559ae710b2bcc608ecf6f000650f5.
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
*/
function DisplayAbout($token)
function DisplayAbout()
{
$Parsedown = new Parsedown();
$strContent = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/BACKERS.md');
@ -17,8 +17,7 @@ function DisplayAbout($token)
echo renderTemplate(
"about", compact(
'sponsorsHtml',
'contributingHtml',
'token'
'contributingHtml'
)
);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@ require_once 'config.php';
/**
* Handler for RestAPI settings
*/
function DisplayRestAPI($token)
function DisplayRestAPI()
{
// initialize status object
$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);
}
echo renderTemplate(
"restapi", compact(
"status",
"apiKey",
"serviceStatus",
"serviceLog",
"docMsg",
"token"
)
);
echo renderTemplate("restapi", compact(
"status",
"apiKey",
"serviceStatus",
"serviceLog",
"docMsg"
));
}
/**

View File

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

View File

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