You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

349 lines
14 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <?php
  2. /**
  3. * Raspbian WiFi Configuration Portal (RaspAP)
  4. *
  5. * Simple AP setup & WiFi management for Debian-based devices.
  6. * Enables use of simple web interface rather than SSH to control WiFi and related services on the Raspberry Pi.
  7. * Recommended distribution is Raspberry Pi OS (64-bit) Lite. Specific instructions to install the supported software are
  8. * in the README and original post by @SirLagz. For a quick run through, the packages required for the WebGUI are:
  9. * lighttpd (version 1.4.59 installed via apt)
  10. * php-cgi (version 7.4.28 installed via apt)
  11. * along with their supporting packages, php7.3 will also need to be enabled.
  12. *
  13. * @author Lawrence Yau <sirlagz@gmail.com>
  14. * @author Bill Zimmerman <billzimmerman@gmail.com>
  15. * @license GNU General Public License, version 3 (GPL-3.0)
  16. * @version 2.8.5
  17. * @link https://github.com/RaspAP/raspap-webgui/
  18. * @link https://raspap.com/
  19. * @see http://sirlagz.net/2013/02/08/raspap-webgui/
  20. *
  21. * You are not obligated to bundle the LICENSE file with your RaspAP projects as long
  22. * as you leave these references intact in the header comments of your source files.
  23. */
  24. require 'includes/csrf.php';
  25. ensureCSRFSessionToken();
  26. require_once 'includes/config.php';
  27. require_once 'includes/defaults.php';
  28. require_once RASPI_CONFIG.'/raspap.php';
  29. require_once 'includes/locale.php';
  30. require_once 'includes/functions.php';
  31. require_once 'includes/dashboard.php';
  32. require_once 'includes/authenticate.php';
  33. require_once 'includes/admin.php';
  34. require_once 'includes/dhcp.php';
  35. require_once 'includes/hostapd.php';
  36. require_once 'includes/adblock.php';
  37. require_once 'includes/system.php';
  38. require_once 'includes/sysstats.php';
  39. require_once 'includes/configure_client.php';
  40. require_once 'includes/networking.php';
  41. require_once 'includes/themes.php';
  42. require_once 'includes/data_usage.php';
  43. require_once 'includes/about.php';
  44. require_once 'includes/openvpn.php';
  45. require_once 'includes/wireguard.php';
  46. require_once 'includes/torproxy.php';
  47. $config = getConfig();
  48. $output = $return = 0;
  49. $page = $_SERVER['PATH_INFO'];
  50. $theme_url = getThemeOpt();
  51. $toggleState = getSidebarState();
  52. $bridgedEnabled = getBridgedState();
  53. ?><!DOCTYPE html>
  54. <html lang="en">
  55. <head>
  56. <meta charset="utf-8">
  57. <?php echo CSRFMetaTag() ?>
  58. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  59. <meta name="viewport" content="width=device-width, initial-scale=1">
  60. <meta name="description" content="">
  61. <meta name="author" content="">
  62. <title><?php echo _("RaspAP WiFi Configuration Portal"); ?></title>
  63. <!-- Bootstrap Core CSS -->
  64. <link href="dist/bootstrap/css/bootstrap.css" rel="stylesheet">
  65. <!-- SB-Admin-2 CSS -->
  66. <link href="dist/sb-admin-2/css/sb-admin-2.min.css" rel="stylesheet">
  67. <!-- DataTables CSS -->
  68. <link href="dist/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">
  69. <!-- Huebee CSS -->
  70. <link href="dist/huebee/huebee.min.css" rel="stylesheet">
  71. <!-- Custom Fonts -->
  72. <link href="dist/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
  73. <!-- RaspAP Fonts -->
  74. <link href="dist/raspap/css/style.css" rel="stylesheet" type="text/css">
  75. <!-- Custom CSS -->
  76. <link href="<?php echo $theme_url; ?>" title="main" rel="stylesheet">
  77. <link rel="shortcut icon" type="image/png" href="app/icons/favicon.png?ver=2.0">
  78. <link rel="apple-touch-icon" sizes="180x180" href="app/icons/apple-touch-icon.png">
  79. <link rel="icon" type="image/png" sizes="32x32" href="app/icons/favicon-32x32.png">
  80. <link rel="icon" type="image/png" sizes="16x16" href="app/icons/favicon-16x16.png">
  81. <link rel="icon" type="image/png" href="app/icons/favicon.png" />
  82. <link rel="manifest" href="app/icons/site.webmanifest">
  83. <link rel="mask-icon" href="app/icons/safari-pinned-tab.svg" color="#b91d47">
  84. <meta name="msapplication-config" content="app/icons/browserconfig.xml">
  85. <meta name="msapplication-TileColor" content="#b91d47">
  86. <meta name="theme-color" content="#ffffff">
  87. <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  88. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  89. <!--[if lt IE 9]>
  90. <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  91. <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
  92. <![endif]-->
  93. </head>
  94. <body id="page-top">
  95. <!-- Page Wrapper -->
  96. <div id="wrapper">
  97. <!-- Sidebar -->
  98. <ul class="navbar-nav sidebar sidebar-light d-none d-md-block accordion <?php echo (isset($toggleState)) ? $toggleState : null ; ?>" id="accordionSidebar">
  99. <!-- Sidebar - Brand -->
  100. <a class="sidebar-brand d-flex align-items-center justify-content-center" href="wlan0_info">
  101. <div class="sidebar-brand-text ml-1"><?php echo RASPI_BRAND_TEXT; ?></div>
  102. </a>
  103. <!-- Divider -->
  104. <hr class="sidebar-divider my-0">
  105. <div class="row">
  106. <div class="col-xs ml-3 sidebar-brand-icon">
  107. <img src="app/img/raspAP-logo.php" class="navbar-logo" width="64" height="64">
  108. </div>
  109. <div class="col-xs ml-2">
  110. <div class="ml-1">Status</div>
  111. <div class="info-item-xs"><span class="icon">
  112. <i class="fas fa-circle <?php echo ($hostapd_led); ?>"></i></span> <?php echo _("Hotspot").' '. _($hostapd_status); ?>
  113. </div>
  114. <div class="info-item-xs"><span class="icon">
  115. <i class="fas fa-circle <?php echo ($memused_led); ?>"></i></span> <?php echo _("Memory Use").': '. htmlspecialchars($memused, ENT_QUOTES); ?>%
  116. </div>
  117. <div class="info-item-xs"><span class="icon">
  118. <i class="fas fa-circle <?php echo ($cputemp_led); ?>"></i></span> <?php echo _("CPU Temp").': '. htmlspecialchars($cputemp, ENT_QUOTES); ?>°C
  119. </div>
  120. </div>
  121. </div>
  122. <li class="nav-item">
  123. <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>
  124. </li>
  125. <?php if (RASPI_HOTSPOT_ENABLED) : ?>
  126. <li class="nav-item">
  127. <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>
  128. </li>
  129. <?php endif; ?>
  130. <?php if (RASPI_DHCP_ENABLED && !$bridgedEnabled) : ?>
  131. <li class="nav-item">
  132. <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>
  133. </li>
  134. <?php endif; ?>
  135. <?php if (RASPI_ADBLOCK_ENABLED && !$bridgedEnabled) : ?>
  136. <li class="nav-item">
  137. <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>
  138. </li>
  139. <?php endif; ?>
  140. <?php if (RASPI_NETWORK_ENABLED) : ?>
  141. <li class="nav-item">
  142. <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>
  143. </li>
  144. <?php endif; ?>
  145. <?php if (RASPI_WIFICLIENT_ENABLED && !$bridgedEnabled) : ?>
  146. <li class="nav-item">
  147. <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>
  148. </li>
  149. <?php endif; ?>
  150. <?php if (RASPI_OPENVPN_ENABLED) : ?>
  151. <li class="nav-item">
  152. <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>
  153. </li>
  154. <?php endif; ?>
  155. <?php if (RASPI_WIREGUARD_ENABLED) : ?>
  156. <li class="nav-item">
  157. <a class="nav-link" href="wg_conf"><span class="ra-wireguard mr-2"></span><span class="nav-label"><?php echo _("WireGuard"); ?></a>
  158. </li>
  159. <?php endif; ?>
  160. <?php if (RASPI_TORPROXY_ENABLED) : ?>
  161. <li class="nav-item">
  162. <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>
  163. </li>
  164. <?php endif; ?>
  165. <?php if (RASPI_CONFAUTH_ENABLED) : ?>
  166. <li class="nav-item">
  167. <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>
  168. </li>
  169. <?php endif; ?>
  170. <?php if (RASPI_CHANGETHEME_ENABLED) : ?>
  171. <li class="nav-item">
  172. <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>
  173. </li>
  174. <?php endif; ?>
  175. <?php if (RASPI_VNSTAT_ENABLED) : ?>
  176. <li class="nav-item">
  177. <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>
  178. </li>
  179. <?php endif; ?>
  180. <?php if (RASPI_SYSTEM_ENABLED) : ?>
  181. <li class="nav-item">
  182. <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>
  183. </li>
  184. <?php endif; ?>
  185. <li class="nav-item">
  186. <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>
  187. </li>
  188. <!-- Divider -->
  189. <hr class="sidebar-divider d-none d-md-block">
  190. <!-- Sidebar Toggler (Sidebar) -->
  191. <div class="text-center d-none d-md-block">
  192. <button class="rounded-circle border-0" id="sidebarToggle"></button>
  193. </div>
  194. </ul>
  195. <!-- End of Sidebar -->
  196. <!-- Content Wrapper -->
  197. <div id="content-wrapper" class="d-flex flex-column">
  198. <!-- Main Content -->
  199. <div id="content">
  200. <!-- Topbar -->
  201. <nav class="navbar navbar-expand navbar-light topbar mb-1 static-top">
  202. <!-- Sidebar Toggle (Topbar) -->
  203. <button id="sidebarToggleTopbar" class="btn btn-link d-md-none rounded-circle mr-3">
  204. <i class="fa fa-bars"></i>
  205. </button>
  206. <!-- Topbar Navbar -->
  207. <p class="text-left brand-title mt-3 ml-2"></p>
  208. <ul class="navbar-nav ml-auto">
  209. <!-- Nav Item - Night mode -->
  210. <div class="custom-control custom-switch mt-4">
  211. <input type="checkbox" class="custom-control-input" id="night-mode" <?php echo getNightmode() ? 'checked' : null ; ?> >
  212. <label class="custom-control-label" for="night-mode"><i class="far fa-moon mr-1 text-muted"></i></label>
  213. </div>
  214. <div class="topbar-divider d-none d-sm-block"></div>
  215. <!-- Nav Item - User -->
  216. <li class="nav-item dropdown no-arrow">
  217. <a class="nav-link" href="auth_conf">
  218. <span class="mr-2 d-none d-lg-inline small"><?php echo htmlspecialchars($config['admin_user'], ENT_QUOTES); ?></span>
  219. <i class="fas fa-user-circle fa-3x"></i>
  220. </a>
  221. </li>
  222. </ul>
  223. </nav>
  224. <!-- End of Topbar -->
  225. <!-- Begin Page Content -->
  226. <div class="container-fluid">
  227. <?php
  228. $extraFooterScripts = array();
  229. // handle page actions
  230. switch ($page) {
  231. case "/wlan0_info":
  232. DisplayDashboard($extraFooterScripts);
  233. break;
  234. case "/dhcpd_conf":
  235. DisplayDHCPConfig();
  236. break;
  237. case "/wpa_conf":
  238. DisplayWPAConfig();
  239. break;
  240. case "/network_conf":
  241. DisplayNetworkingConfig();
  242. break;
  243. case "/hostapd_conf":
  244. DisplayHostAPDConfig();
  245. break;
  246. case "/adblock_conf":
  247. DisplayAdBlockConfig();
  248. break;
  249. case "/openvpn_conf":
  250. DisplayOpenVPNConfig();
  251. break;
  252. case "/wg_conf":
  253. DisplayWireGuardConfig();
  254. break;
  255. case "/torproxy_conf":
  256. DisplayTorProxyConfig();
  257. break;
  258. case "/torproxy_conf":
  259. DisplayTorProxyConfig();
  260. break;
  261. case "/auth_conf":
  262. DisplayAuthConfig($config['admin_user'], $config['admin_pass']);
  263. break;
  264. case "/save_hostapd_conf":
  265. SaveTORAndVPNConfig();
  266. break;
  267. case "/theme_conf":
  268. DisplayThemeConfig($extraFooterScripts);
  269. break;
  270. case "/data_use":
  271. DisplayDataUsage($extraFooterScripts);
  272. break;
  273. case "/system_info":
  274. DisplaySystem();
  275. break;
  276. case "/about":
  277. DisplayAbout();
  278. break;
  279. default:
  280. DisplayDashboard($extraFooterScripts);
  281. }
  282. ?>
  283. </div><!-- /.container-fluid -->
  284. </div><!-- End of Main Content -->
  285. <!-- Footer -->
  286. <footer class="sticky-footer bg-grey-100">
  287. <div class="container my-auto">
  288. <div class="copyright text-center my-auto">
  289. <span></span>
  290. </div>
  291. </div>
  292. </footer>
  293. <!-- End Footer -->
  294. </div><!-- End of Content Wrapper -->
  295. </div><!-- End of Page Wrapper -->
  296. <!-- Scroll to Top Button-->
  297. <a class="scroll-to-top rounded" href="#page-top" style="display: inline;">
  298. <i class="fas fa-angle-up"></i>
  299. </a>
  300. <!-- jQuery -->
  301. <script src="dist/jquery/jquery.min.js"></script>
  302. <!-- Bootstrap Core JavaScript -->
  303. <script src="dist/bootstrap/js/bootstrap.bundle.min.js"></script>
  304. <!-- Core plugin JavaScript -->
  305. <script src="dist/jquery-easing/jquery.easing.min.js"></script>
  306. <!-- Chart.js JavaScript -->
  307. <script src="dist/chart.js/Chart.min.js"></script>
  308. <!-- SB-Admin-2 JavaScript -->
  309. <script src="dist/sb-admin-2/js/sb-admin-2.js"></script>
  310. <!-- Custom RaspAP JS -->
  311. <script src="app/js/custom.js"></script>
  312. <?php
  313. // Load non default JS/ECMAScript in footer.
  314. foreach ($extraFooterScripts as $script) {
  315. echo '<script type="text/javascript" src="' , $script['src'] , '"';
  316. if ($script['defer']) {
  317. echo ' defer="defer"';
  318. }
  319. echo '></script>' , PHP_EOL;
  320. }
  321. ?>
  322. </body>
  323. </html>