1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00
raspap-webgui/index.php

347 lines
14 KiB
PHP
Raw Normal View History

2015-02-16 10:30:58 +01:00
<?php
2015-02-25 14:06:48 +01:00
/**
2020-02-03 11:13:57 +01:00
* Raspbian WiFi Configuration Portal (RaspAP)
2015-02-25 14:06:48 +01:00
*
2020-07-29 18:12:04 +02:00
* Simple AP setup & WiFi management for Debian-based devices.
* Enables use of simple web interface rather than SSH to control WiFi and related services on the Raspberry Pi.
* Recommended distribution is Raspberry Pi OS (32-bit) Lite. Specific instructions to install the supported software are
2015-02-25 14:06:48 +01:00
* in the README and original post by @SirLagz. For a quick run through, the packages required for the WebGUI are:
2020-03-25 17:54:06 +01:00
* lighttpd (version 1.4.53 installed via apt)
2020-07-29 18:12:04 +02:00
* php-cgi (version 7.3.19-1 installed via apt)
2020-03-25 17:54:06 +01:00
* along with their supporting packages, php7.3 will also need to be enabled.
*
2020-02-15 18:57:46 +01:00
* @author Lawrence Yau <sirlagz@gmail.com>
* @author Bill Zimmerman <billzimmerman@gmail.com>
* @license GNU General Public License, version 3 (GPL-3.0)
2021-06-08 21:16:34 +02:00
* @version 2.7.4-beta
2021-02-10 17:23:56 +01:00
* @link https://github.com/raspap/raspap-insiders/
2020-07-29 18:12:04 +02:00
* @link https://raspap.com/
2020-02-15 18:57:46 +01:00
* @see http://sirlagz.net/2013/02/08/raspap-webgui/
2020-07-29 18:12:04 +02:00
*
* You are not obligated to bundle the LICENSE file with your RaspAP projects as long
* as you leave these references intact in the header comments of your source files.
2015-02-25 14:06:48 +01:00
*/
2020-02-15 18:57:46 +01:00
require 'includes/csrf.php';
2019-08-07 23:53:04 +02:00
ensureCSRFSessionToken();
2018-05-29 20:52:41 +02:00
2020-02-15 18:57:46 +01:00
require_once 'includes/config.php';
require_once 'includes/defaults.php';
require_once RASPI_CONFIG.'/raspap.php';
require_once 'includes/locale.php';
require_once 'includes/functions.php';
require_once 'includes/dashboard.php';
require_once 'includes/authenticate.php';
require_once 'includes/admin.php';
require_once 'includes/dhcp.php';
require_once 'includes/hostapd.php';
2020-03-26 20:45:39 +01:00
require_once 'includes/adblock.php';
2020-02-15 18:57:46 +01:00
require_once 'includes/system.php';
require_once 'includes/sysstats.php';
require_once 'includes/configure_client.php';
require_once 'includes/networking.php';
require_once 'includes/themes.php';
require_once 'includes/data_usage.php';
require_once 'includes/about.php';
require_once 'includes/openvpn.php';
2020-04-20 13:52:03 +02:00
require_once 'includes/wireguard.php';
2020-02-15 18:57:46 +01:00
require_once 'includes/torproxy.php';
2015-02-25 14:06:48 +01:00
2021-02-02 11:03:09 +01:00
$config = getConfig();
2015-02-16 10:30:58 +01:00
$output = $return = 0;
2021-03-02 18:27:40 +01:00
$page = $_SERVER['PATH_INFO'];
2016-06-24 23:39:39 +02:00
2020-06-30 17:52:18 +02:00
$theme_url = getThemeOpt();
2020-07-01 00:37:08 +02:00
$toggleState = getSidebarState();
$bridgedEnabled = getBridgedState();
?><!DOCTYPE html>
2015-02-25 14:06:48 +01:00
<html lang="en">
<head>
<meta charset="utf-8">
<?php echo CSRFMetaTag() ?>
2015-02-25 14:06:48 +01:00
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
2015-02-16 10:30:58 +01:00
2019-08-20 11:18:12 +02:00
<title><?php echo _("RaspAP WiFi Configuration Portal"); ?></title>
2015-02-16 10:30:58 +01:00
2015-02-25 14:06:48 +01:00
<!-- Bootstrap Core CSS -->
2019-10-11 21:37:59 +02:00
<link href="dist/bootstrap/css/bootstrap.css" rel="stylesheet">
2015-02-16 10:30:58 +01:00
<!-- SB-Admin-2 CSS -->
2019-10-08 19:35:32 +02:00
<link href="dist/sb-admin-2/css/sb-admin-2.min.css" rel="stylesheet">
2015-02-16 10:30:58 +01:00
2019-10-20 00:26:35 +02:00
<!-- DataTables CSS -->
<link href="dist/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">
2020-06-30 01:28:39 +02:00
<!-- Huebee CSS -->
<link href="dist/huebee/huebee.min.css" rel="stylesheet">
2015-02-25 14:06:48 +01:00
<!-- Custom Fonts -->
2019-10-11 21:37:59 +02:00
<link href="dist/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
2015-02-16 10:30:58 +01:00
2020-04-20 23:36:03 +02:00
<!-- RaspAP Fonts -->
<link href="dist/raspap/css/style.css" rel="stylesheet" type="text/css">
2015-02-25 14:06:48 +01:00
<!-- Custom CSS -->
2017-10-07 01:08:06 +02:00
<link href="<?php echo $theme_url; ?>" title="main" rel="stylesheet">
2015-02-16 10:30:58 +01:00
2019-10-08 19:35:32 +02:00
<link rel="shortcut icon" type="image/png" href="app/icons/favicon.png?ver=2.0">
<link rel="apple-touch-icon" sizes="180x180" href="app/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="app/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="app/icons/favicon-16x16.png">
<link rel="icon" type="image/png" href="app/icons/favicon.png" />
<link rel="manifest" href="app/icons/site.webmanifest">
<link rel="mask-icon" href="app/icons/safari-pinned-tab.svg" color="#b91d47">
<meta name="msapplication-config" content="app/icons/browserconfig.xml">
<meta name="msapplication-TileColor" content="#b91d47">
<meta name="theme-color" content="#ffffff">
2015-02-25 14:06:48 +01:00
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
2019-10-11 21:37:59 +02:00
<body id="page-top">
2019-10-13 01:25:35 +02:00
<!-- Page Wrapper -->
<div id="wrapper">
2019-10-11 21:37:59 +02:00
<!-- Sidebar -->
2020-03-24 19:48:35 +01:00
<ul class="navbar-nav sidebar sidebar-light d-none d-md-block accordion <?php echo (isset($toggleState)) ? $toggleState : null ; ?>" id="accordionSidebar">
2019-10-11 21:37:59 +02:00
<!-- Sidebar - Brand -->
<a class="sidebar-brand d-flex align-items-center justify-content-center" href="wlan0_info">
2020-07-01 10:13:38 +02:00
<div class="sidebar-brand-text ml-1"><?php echo RASPI_BRAND_TEXT; ?></div>
2020-02-02 09:37:15 +01:00
</a>
2019-10-11 21:37:59 +02:00
<!-- Divider -->
<hr class="sidebar-divider my-0">
2020-02-02 12:33:09 +01:00
<div class="row">
<div class="col-xs ml-3 sidebar-brand-icon">
2020-07-01 00:37:08 +02:00
<img src="app/img/raspAP-logo.php" class="navbar-logo" width="64" height="64">
2020-02-02 12:33:09 +01:00
</div>
<div class="col-xs ml-2">
<div class="ml-1">Status</div>
2020-04-11 09:59:21 +02:00
<div class="info-item-xs"><span class="icon">
<i class="fas fa-circle <?php echo ($hostapd_led); ?>"></i></span> <?php echo _("Hotspot").' '. _($hostapd_status); ?>
</div>
<div class="info-item-xs"><span class="icon">
<i class="fas fa-circle <?php echo ($memused_led); ?>"></i></span> <?php echo _("Memory Use").': '. htmlspecialchars($memused, ENT_QUOTES); ?>%
</div>
<div class="info-item-xs"><span class="icon">
<i class="fas fa-circle <?php echo ($cputemp_led); ?>"></i></span> <?php echo _("CPU Temp").': '. htmlspecialchars($cputemp, ENT_QUOTES); ?>°C
</div>
2020-02-02 12:33:09 +01:00
</div>
2020-02-02 09:37:15 +01:00
</div>
2020-02-03 10:48:58 +01:00
<li class="nav-item">
<a class="nav-link" href="wlan0_info"><i class="fas fa-tachometer-alt fa-fw mr-2"></i><span class="nav-label"><?php echo _("Dashboard"); ?></span></a>
2020-02-03 10:48:58 +01:00
</li>
<?php if (RASPI_HOTSPOT_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="hostapd_conf"><i class="far fa-dot-circle fa-fw mr-2"></i><span class="nav-label"><?php echo _("Hotspot"); ?></a>
2020-03-26 19:21:59 +01:00
</li>
<?php endif; ?>
<?php if (RASPI_DHCP_ENABLED && !$bridgedEnabled) : ?>
<li class="nav-item">
<a class="nav-link" href="dhcpd_conf"><i class="fas fa-exchange-alt fa-fw mr-2"></i><span class="nav-label"><?php echo _("DHCP Server"); ?></a>
2020-03-26 20:45:39 +01:00
</li>
<?php endif; ?>
2020-05-19 14:47:31 +02:00
<?php if (RASPI_ADBLOCK_ENABLED && !$bridgedEnabled) : ?>
2020-03-26 20:45:39 +01:00
<li class="nav-item">
<a class="nav-link" href="adblock_conf"><i class="far fa-hand-paper fa-fw mr-2"></i><span class="nav-label"><?php echo _("Ad Blocking"); ?></a>
2020-02-03 10:48:58 +01:00
</li>
<?php endif; ?>
<?php if (RASPI_NETWORK_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="network_conf"><i class="fas fa-network-wired fa-fw mr-2"></i><span class="nav-label"><?php echo _("Networking"); ?></a>
2020-02-03 10:48:58 +01:00
</li>
<?php endif; ?>
2020-03-26 19:21:59 +01:00
<?php if (RASPI_WIFICLIENT_ENABLED && !$bridgedEnabled) : ?>
2020-02-03 10:48:58 +01:00
<li class="nav-item">
<a class="nav-link" href="wpa_conf"><i class="fas fa-wifi fa-fw mr-2"></i><span class="nav-label"><?php echo _("WiFi client"); ?></span></a>
2020-02-03 10:48:58 +01:00
</li>
<?php endif; ?>
<?php if (RASPI_OPENVPN_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="openvpn_conf"><i class="fas fa-key fa-fw mr-2"></i><span class="nav-label"><?php echo _("OpenVPN"); ?></a>
2020-04-20 13:52:03 +02:00
</li>
<?php endif; ?>
<?php if (RASPI_WIREGUARD_ENABLED) : ?>
<li class="nav-item">
2021-02-24 00:22:13 +01:00
<a class="nav-link" href="wg_conf"><span class="ra-wireguard mr-2"></span><span class="nav-label"><?php echo _("WireGuard"); ?></a>
2020-02-03 10:48:58 +01:00
</li>
<?php endif; ?>
<?php if (RASPI_TORPROXY_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="torproxy_conf"><i class="fas fa-eye-slash fa-fw mr-2"></i><span class="nav-label"><?php echo _("TOR proxy"); ?></a>
2020-02-03 10:48:58 +01:00
</li>
<?php endif; ?>
<?php if (RASPI_CONFAUTH_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="auth_conf"><i class="fas fa-user-lock fa-fw mr-2"></i><span class="nav-label"><?php echo _("Authentication"); ?></a>
2020-02-03 10:48:58 +01:00
</li>
<?php endif; ?>
<?php if (RASPI_CHANGETHEME_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="theme_conf"><i class="fas fa-paint-brush fa-fw mr-2"></i><span class="nav-label"><?php echo _("Change Theme"); ?></a>
2020-02-03 10:48:58 +01:00
</li>
<?php endif; ?>
<?php if (RASPI_VNSTAT_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="data_use"><i class="fas fa-chart-bar fa-fw mr-2"></i><span class="nav-label"><?php echo _("Data usage"); ?></a>
2020-02-03 10:48:58 +01:00
</li>
<?php endif; ?>
<?php if (RASPI_SYSTEM_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="system_info"><i class="fas fa-cube fa-fw mr-2"></i><span class="nav-label"><?php echo _("System"); ?></a>
2020-02-03 10:48:58 +01:00
</li>
<?php endif; ?>
<li class="nav-item">
<a class="nav-link" href="about"><i class="fas fa-info-circle fa-fw mr-2"></i><span class="nav-label"><?php echo _("About RaspAP"); ?></a>
2020-02-03 10:48:58 +01:00
</li>
<!-- Divider -->
<hr class="sidebar-divider d-none d-md-block">
<!-- Sidebar Toggler (Sidebar) -->
<div class="text-center d-none d-md-block">
<button class="rounded-circle border-0" id="sidebarToggle"></button>
</div>
</ul>
<!-- End of Sidebar -->
2020-02-03 10:56:30 +01:00
<!-- Content Wrapper -->
<div id="content-wrapper" class="d-flex flex-column">
2020-02-03 10:56:30 +01:00
<!-- Main Content -->
<div id="content">
<!-- Topbar -->
<nav class="navbar navbar-expand navbar-light topbar mb-1 static-top">
<!-- Sidebar Toggle (Topbar) -->
<button id="sidebarToggleTopbar" class="btn btn-link d-md-none rounded-circle mr-3">
<i class="fa fa-bars"></i>
</button>
<!-- Topbar Navbar -->
<p class="text-left brand-title mt-3 ml-2"></p>
2020-02-03 10:56:30 +01:00
<ul class="navbar-nav ml-auto">
<!-- Nav Item - Night mode -->
<div class="custom-control custom-switch mt-4">
2021-02-18 08:03:58 +01:00
<input type="checkbox" class="custom-control-input" id="night-mode" <?php echo getNightmode() ? 'checked' : null ; ?> >
<label class="custom-control-label" for="night-mode"><i class="far fa-moon mr-1 text-muted"></i></label>
</div>
2020-02-03 10:56:30 +01:00
<div class="topbar-divider d-none d-sm-block"></div>
<!-- Nav Item - User -->
<li class="nav-item dropdown no-arrow">
<a class="nav-link" href="auth_conf">
2020-02-03 10:56:30 +01:00
<span class="mr-2 d-none d-lg-inline small"><?php echo htmlspecialchars($config['admin_user'], ENT_QUOTES); ?></span>
<i class="fas fa-user-circle fa-3x"></i>
</a>
</li>
</ul>
</nav>
<!-- End of Topbar -->
<!-- Begin Page Content -->
<div class="container-fluid">
<?php
2020-02-15 18:57:46 +01:00
$extraFooterScripts = array();
// handle page actions
switch ($page) {
case "/wlan0_info":
2020-02-15 18:57:46 +01:00
DisplayDashboard($extraFooterScripts);
break;
case "/dhcpd_conf":
2020-02-15 18:57:46 +01:00
DisplayDHCPConfig();
break;
case "/wpa_conf":
2020-02-15 18:57:46 +01:00
DisplayWPAConfig();
break;
case "/network_conf":
2020-02-15 18:57:46 +01:00
DisplayNetworkingConfig();
break;
case "/hostapd_conf":
2020-02-15 18:57:46 +01:00
DisplayHostAPDConfig();
break;
case "/adblock_conf":
2020-03-26 20:45:39 +01:00
DisplayAdBlockConfig();
break;
case "/openvpn_conf":
2020-02-15 18:57:46 +01:00
DisplayOpenVPNConfig();
break;
case "/wg_conf":
2020-04-20 13:52:03 +02:00
DisplayWireGuardConfig();
break;
case "/torproxy_conf":
2020-02-15 18:57:46 +01:00
DisplayTorProxyConfig();
break;
case "/auth_conf":
2020-02-15 18:57:46 +01:00
DisplayAuthConfig($config['admin_user'], $config['admin_pass']);
break;
case "/save_hostapd_conf":
2020-02-15 18:57:46 +01:00
SaveTORAndVPNConfig();
break;
case "/theme_conf":
2020-06-30 17:52:18 +02:00
DisplayThemeConfig($extraFooterScripts);
2020-02-15 18:57:46 +01:00
break;
case "/data_use":
2020-02-15 18:57:46 +01:00
DisplayDataUsage($extraFooterScripts);
break;
case "/system_info":
2020-02-15 18:57:46 +01:00
DisplaySystem();
break;
case "/about":
2020-02-15 18:57:46 +01:00
DisplayAbout();
break;
default:
DisplayDashboard($extraFooterScripts);
}
?>
2020-02-03 10:56:30 +01:00
</div><!-- /.container-fluid -->
</div><!-- End of Main Content -->
<!-- Footer -->
<footer class="sticky-footer bg-grey-100">
<div class="container my-auto">
<div class="copyright text-center my-auto">
<span></span>
</div>
</div>
</footer>
<!-- End Footer -->
</div><!-- End of Content Wrapper -->
2019-10-13 01:25:35 +02:00
</div><!-- End of Page Wrapper -->
<!-- Scroll to Top Button-->
<a class="scroll-to-top rounded" href="#page-top" style="display: inline;">
<i class="fas fa-angle-up"></i>
</a>
2015-02-25 14:06:48 +01:00
<!-- jQuery -->
2019-10-08 19:35:32 +02:00
<script src="dist/jquery/jquery.min.js"></script>
2015-02-25 14:06:48 +01:00
<!-- Bootstrap Core JavaScript -->
2019-10-13 01:25:35 +02:00
<script src="dist/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Core plugin JavaScript -->
<script src="dist/jquery-easing/jquery.easing.min.js"></script>
2015-02-25 14:06:48 +01:00
2019-10-11 21:37:59 +02:00
<!-- Chart.js JavaScript -->
<script src="dist/chart.js/Chart.min.js"></script>
2015-02-25 14:06:48 +01:00
<!-- SB-Admin-2 JavaScript -->
2019-10-08 19:35:32 +02:00
<script src="dist/sb-admin-2/js/sb-admin-2.js"></script>
<!-- Custom RaspAP JS -->
2019-10-08 19:35:32 +02:00
<script src="app/js/custom.js"></script>
2020-06-30 17:52:18 +02:00
<?php
2019-12-29 20:30:55 +01:00
// Load non default JS/ECMAScript in footer.
foreach ($extraFooterScripts as $script) {
2020-06-30 17:52:18 +02:00
echo '<script type="text/javascript" src="' , $script['src'] , '"';
2019-12-29 20:30:55 +01:00
if ($script['defer']) {
2020-02-03 11:13:57 +01:00
echo ' defer="defer"';
2019-12-29 20:30:55 +01:00
}
echo '></script>' , PHP_EOL;
}
2020-02-15 18:57:46 +01:00
?>
</body>
2015-02-25 14:06:48 +01:00
</html>