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.

328 lines
13 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
  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 (32-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.53 installed via apt)
  10. * php-cgi (version 7.3.19-1 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.5.1
  17. * @link https://github.com/billz/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/torproxy.php';
  46. $output = $return = 0;
  47. $page = $_GET['page'];
  48. $theme_url = getThemeOpt();
  49. $toggleState = getSidebarState();
  50. $bridgedEnabled = getBridgedState();
  51. ?><!DOCTYPE html>
  52. <html lang="en">
  53. <head>
  54. <meta charset="utf-8">
  55. <?php echo CSRFMetaTag() ?>
  56. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  57. <meta name="viewport" content="width=device-width, initial-scale=1">
  58. <meta name="description" content="">
  59. <meta name="author" content="">
  60. <title><?php echo _("RaspAP WiFi Configuration Portal"); ?></title>
  61. <!-- Bootstrap Core CSS -->
  62. <link href="dist/bootstrap/css/bootstrap.css" rel="stylesheet">
  63. <!-- SB-Admin-2 CSS -->
  64. <link href="dist/sb-admin-2/css/sb-admin-2.min.css" rel="stylesheet">
  65. <!-- DataTables CSS -->
  66. <link href="dist/datatables/dataTables.bootstrap4.min.css" rel="stylesheet">
  67. <!-- Huebee CSS -->
  68. <link href="dist/huebee/huebee.min.css" rel="stylesheet">
  69. <!-- Custom Fonts -->
  70. <link href="dist/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
  71. <!-- Custom CSS -->
  72. <link href="<?php echo $theme_url; ?>" title="main" rel="stylesheet">
  73. <link rel="shortcut icon" type="image/png" href="app/icons/favicon.png?ver=2.0">
  74. <link rel="apple-touch-icon" sizes="180x180" href="app/icons/apple-touch-icon.png">
  75. <link rel="icon" type="image/png" sizes="32x32" href="app/icons/favicon-32x32.png">
  76. <link rel="icon" type="image/png" sizes="16x16" href="app/icons/favicon-16x16.png">
  77. <link rel="icon" type="image/png" href="app/icons/favicon.png" />
  78. <link rel="manifest" href="app/icons/site.webmanifest">
  79. <link rel="mask-icon" href="app/icons/safari-pinned-tab.svg" color="#b91d47">
  80. <meta name="msapplication-config" content="app/icons/browserconfig.xml">
  81. <meta name="msapplication-TileColor" content="#b91d47">
  82. <meta name="theme-color" content="#ffffff">
  83. <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  84. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  85. <!--[if lt IE 9]>
  86. <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
  87. <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
  88. <![endif]-->
  89. </head>
  90. <body id="page-top">
  91. <!-- Page Wrapper -->
  92. <div id="wrapper">
  93. <!-- Sidebar -->
  94. <ul class="navbar-nav sidebar sidebar-light d-none d-md-block accordion <?php echo (isset($toggleState)) ? $toggleState : null ; ?>" id="accordionSidebar">
  95. <!-- Sidebar - Brand -->
  96. <a class="sidebar-brand d-flex align-items-center justify-content-center" href="index.php?page=wlan0_info">
  97. <div class="sidebar-brand-text ml-1"><?php echo RASPI_BRAND_TEXT; ?></div>
  98. </a>
  99. <!-- Divider -->
  100. <hr class="sidebar-divider my-0">
  101. <div class="row">
  102. <div class="col-xs ml-3 sidebar-brand-icon">
  103. <img src="app/img/raspAP-logo.php" class="navbar-logo" width="64" height="64">
  104. </div>
  105. <div class="col-xs ml-2">
  106. <div class="ml-1">Status</div>
  107. <div class="info-item-xs"><span class="icon">
  108. <i class="fas fa-circle <?php echo ($hostapd_led); ?>"></i></span> <?php echo _("Hotspot").' '. _($hostapd_status); ?>
  109. </div>
  110. <div class="info-item-xs"><span class="icon">
  111. <i class="fas fa-circle <?php echo ($memused_led); ?>"></i></span> <?php echo _("Memory Use").': '. htmlspecialchars($memused, ENT_QUOTES); ?>%
  112. </div>
  113. <div class="info-item-xs"><span class="icon">
  114. <i class="fas fa-circle <?php echo ($cputemp_led); ?>"></i></span> <?php echo _("CPU Temp").': '. htmlspecialchars($cputemp, ENT_QUOTES); ?>°C
  115. </div>
  116. </div>
  117. </div>
  118. <li class="nav-item">
  119. <a class="nav-link" href="index.php?page=wlan0_info"><i class="fas fa-tachometer-alt fa-fw mr-2"></i><span class="nav-label"><?php echo _("Dashboard"); ?></span></a>
  120. </li>
  121. <?php if (RASPI_HOTSPOT_ENABLED) : ?>
  122. <li class="nav-item">
  123. <a class="nav-link" href="index.php?page=hostapd_conf"><i class="far fa-dot-circle fa-fw mr-2"></i><span class="nav-label"><?php echo _("Hotspot"); ?></a>
  124. </li>
  125. <?php endif; ?>
  126. <?php if (RASPI_DHCP_ENABLED && !$bridgedEnabled) : ?>
  127. <li class="nav-item">
  128. <a class="nav-link" href="index.php?page=dhcpd_conf"><i class="fas fa-exchange-alt fa-fw mr-2"></i><span class="nav-label"><?php echo _("DHCP Server"); ?></a>
  129. </li>
  130. <?php endif; ?>
  131. <?php if (RASPI_ADBLOCK_ENABLED && !$bridgedEnabled) : ?>
  132. <li class="nav-item">
  133. <a class="nav-link" href="index.php?page=adblock_conf"><i class="far fa-hand-paper fa-fw mr-2"></i><span class="nav-label"><?php echo _("Ad Blocking"); ?></a>
  134. </li>
  135. <?php endif; ?>
  136. <?php if (RASPI_NETWORK_ENABLED) : ?>
  137. <li class="nav-item">
  138. <a class="nav-link" href="index.php?page=network_conf"><i class="fas fa-network-wired fa-fw mr-2"></i><span class="nav-label"><?php echo _("Networking"); ?></a>
  139. </li>
  140. <?php endif; ?>
  141. <?php if (RASPI_WIFICLIENT_ENABLED && !$bridgedEnabled) : ?>
  142. <li class="nav-item">
  143. <a class="nav-link" href="index.php?page=wpa_conf"><i class="fas fa-wifi fa-fw mr-2"></i><span class="nav-label"><?php echo _("WiFi client"); ?></span></a>
  144. </li>
  145. <?php endif; ?>
  146. <?php if (RASPI_OPENVPN_ENABLED) : ?>
  147. <li class="nav-item">
  148. <a class="nav-link" href="index.php?page=openvpn_conf"><i class="fas fa-key fa-fw mr-2"></i><span class="nav-label"><?php echo _("OpenVPN"); ?></a>
  149. </li>
  150. <?php endif; ?>
  151. <?php if (RASPI_TORPROXY_ENABLED) : ?>
  152. <li class="nav-item">
  153. <a class="nav-link" href="index.php?page=torproxy_conf"><i class="fas fa-eye-slash fa-fw mr-2"></i><span class="nav-label"><?php echo _("TOR proxy"); ?></a>
  154. </li>
  155. <?php endif; ?>
  156. <?php if (RASPI_CONFAUTH_ENABLED) : ?>
  157. <li class="nav-item">
  158. <a class="nav-link" href="index.php?page=auth_conf"><i class="fas fa-user-lock fa-fw mr-2"></i><span class="nav-label"><?php echo _("Authentication"); ?></a>
  159. </li>
  160. <?php endif; ?>
  161. <?php if (RASPI_CHANGETHEME_ENABLED) : ?>
  162. <li class="nav-item">
  163. <a class="nav-link" href="index.php?page=theme_conf"><i class="fas fa-paint-brush fa-fw mr-2"></i><span class="nav-label"><?php echo _("Change Theme"); ?></a>
  164. </li>
  165. <?php endif; ?>
  166. <?php if (RASPI_VNSTAT_ENABLED) : ?>
  167. <li class="nav-item">
  168. <a class="nav-link" href="index.php?page=data_use"><i class="fas fa-chart-bar fa-fw mr-2"></i><span class="nav-label"><?php echo _("Data usage"); ?></a>
  169. </li>
  170. <?php endif; ?>
  171. <?php if (RASPI_SYSTEM_ENABLED) : ?>
  172. <li class="nav-item">
  173. <a class="nav-link" href="index.php?page=system_info"><i class="fas fa-cube fa-fw mr-2"></i><span class="nav-label"><?php echo _("System"); ?></a>
  174. </li>
  175. <?php endif; ?>
  176. <li class="nav-item">
  177. <a class="nav-link" href="index.php?page=about"><i class="fas fa-info-circle fa-fw mr-2"></i><span class="nav-label"><?php echo _("About RaspAP"); ?></a>
  178. </li>
  179. <!-- Divider -->
  180. <hr class="sidebar-divider d-none d-md-block">
  181. <!-- Sidebar Toggler (Sidebar) -->
  182. <div class="text-center d-none d-md-block">
  183. <button class="rounded-circle border-0" id="sidebarToggle"></button>
  184. </div>
  185. </ul>
  186. <!-- End of Sidebar -->
  187. <!-- Content Wrapper -->
  188. <div id="content-wrapper" class="d-flex flex-column">
  189. <!-- Main Content -->
  190. <div id="content">
  191. <!-- Topbar -->
  192. <nav class="navbar navbar-expand navbar-light topbar mb-1 static-top">
  193. <!-- Sidebar Toggle (Topbar) -->
  194. <button id="sidebarToggleTopbar" class="btn btn-link d-md-none rounded-circle mr-3">
  195. <i class="fa fa-bars"></i>
  196. </button>
  197. <!-- Topbar Navbar -->
  198. <p class="text-left brand-title mt-3 ml-2"><?php //echo _("WiFi Configuration Portal"); ?></p>
  199. <ul class="navbar-nav ml-auto">
  200. <div class="topbar-divider d-none d-sm-block"></div>
  201. <!-- Nav Item - User -->
  202. <li class="nav-item dropdown no-arrow">
  203. <a class="nav-link" href="index.php?page=auth_conf">
  204. <span class="mr-2 d-none d-lg-inline small"><?php echo htmlspecialchars($config['admin_user'], ENT_QUOTES); ?></span>
  205. <i class="fas fa-user-circle fa-3x"></i>
  206. </a>
  207. </li>
  208. </ul>
  209. </nav>
  210. <!-- End of Topbar -->
  211. <!-- Begin Page Content -->
  212. <div class="container-fluid">
  213. <?php
  214. $extraFooterScripts = array();
  215. // handle page actions
  216. switch ($page) {
  217. case "wlan0_info":
  218. DisplayDashboard($extraFooterScripts);
  219. break;
  220. case "dhcpd_conf":
  221. DisplayDHCPConfig();
  222. break;
  223. case "wpa_conf":
  224. DisplayWPAConfig();
  225. break;
  226. case "network_conf":
  227. DisplayNetworkingConfig();
  228. break;
  229. case "hostapd_conf":
  230. DisplayHostAPDConfig();
  231. break;
  232. case "adblock_conf":
  233. DisplayAdBlockConfig();
  234. break;
  235. case "openvpn_conf":
  236. DisplayOpenVPNConfig();
  237. break;
  238. case "torproxy_conf":
  239. DisplayTorProxyConfig();
  240. break;
  241. case "auth_conf":
  242. DisplayAuthConfig($config['admin_user'], $config['admin_pass']);
  243. break;
  244. case "save_hostapd_conf":
  245. SaveTORAndVPNConfig();
  246. break;
  247. case "theme_conf":
  248. DisplayThemeConfig($extraFooterScripts);
  249. break;
  250. case "data_use":
  251. DisplayDataUsage($extraFooterScripts);
  252. break;
  253. case "system_info":
  254. DisplaySystem();
  255. break;
  256. case "about":
  257. DisplayAbout();
  258. break;
  259. default:
  260. DisplayDashboard($extraFooterScripts);
  261. }
  262. ?>
  263. </div><!-- /.container-fluid -->
  264. </div><!-- End of Main Content -->
  265. <!-- Footer -->
  266. <footer class="sticky-footer bg-grey-100">
  267. <div class="container my-auto">
  268. <div class="copyright text-center my-auto">
  269. <span></span>
  270. </div>
  271. </div>
  272. </footer>
  273. <!-- End Footer -->
  274. </div><!-- End of Content Wrapper -->
  275. </div><!-- End of Page Wrapper -->
  276. <!-- Scroll to Top Button-->
  277. <a class="scroll-to-top rounded" href="#page-top" style="display: inline;">
  278. <i class="fas fa-angle-up"></i>
  279. </a>
  280. <!-- jQuery -->
  281. <script src="dist/jquery/jquery.min.js"></script>
  282. <!-- Bootstrap Core JavaScript -->
  283. <script src="dist/bootstrap/js/bootstrap.bundle.min.js"></script>
  284. <!-- Core plugin JavaScript -->
  285. <script src="dist/jquery-easing/jquery.easing.min.js"></script>
  286. <!-- Chart.js JavaScript -->
  287. <script src="dist/chart.js/Chart.min.js"></script>
  288. <!-- SB-Admin-2 JavaScript -->
  289. <script src="dist/sb-admin-2/js/sb-admin-2.js"></script>
  290. <!-- Custom RaspAP JS -->
  291. <script src="app/js/custom.js"></script>
  292. <?php
  293. // Load non default JS/ECMAScript in footer.
  294. foreach ($extraFooterScripts as $script) {
  295. echo '<script type="text/javascript" src="' , $script['src'] , '"';
  296. if ($script['defer']) {
  297. echo ' defer="defer"';
  298. }
  299. echo '></script>' , PHP_EOL;
  300. }
  301. ?>
  302. </body>
  303. </html>