mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-21 15:10:22 +00:00
Processed with phpcbf
This commit is contained in:
parent
c0af41a53b
commit
457da91008
28 changed files with 1062 additions and 969 deletions
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require('../../includes/csrf.php');
|
require '../../includes/csrf.php';
|
||||||
|
|
||||||
require_once '../../includes/config.php';
|
require_once '../../includes/config.php';
|
||||||
require_once RASPI_CONFIG.'/raspap.php';
|
require_once RASPI_CONFIG.'/raspap.php';
|
||||||
|
@ -30,10 +30,12 @@ if (strlen($interface) > IFNAMSIZ) {
|
||||||
|
|
||||||
require_once './get_bandwidth_hourly.php';
|
require_once './get_bandwidth_hourly.php';
|
||||||
|
|
||||||
exec(sprintf('vnstat -i %s --json ', escapeshellarg($interface)), $jsonstdoutvnstat,
|
exec(
|
||||||
$exitcodedaily);
|
sprintf('vnstat -i %s --json ', escapeshellarg($interface)), $jsonstdoutvnstat,
|
||||||
|
$exitcodedaily
|
||||||
|
);
|
||||||
if ($exitcodedaily !== 0) {
|
if ($exitcodedaily !== 0) {
|
||||||
exit('vnstat error');
|
exit('vnstat error');
|
||||||
}
|
}
|
||||||
|
|
||||||
$jsonobj = json_decode($jsonstdoutvnstat[0], true);
|
$jsonobj = json_decode($jsonstdoutvnstat[0], true);
|
||||||
|
@ -53,12 +55,16 @@ echo '[ ';
|
||||||
$firstelm = true;
|
$firstelm = true;
|
||||||
for ($i = count($jsonData) - 1; $i >= 0; --$i) {
|
for ($i = count($jsonData) - 1; $i >= 0; --$i) {
|
||||||
if ($timeunits === 'm') {
|
if ($timeunits === 'm') {
|
||||||
$dt = DateTime::createFromFormat('Y n', $jsonData[$i]['date']['year'].' '.
|
$dt = DateTime::createFromFormat(
|
||||||
$jsonData[$i]['date']['month']);
|
'Y n', $jsonData[$i]['date']['year'].' '.
|
||||||
|
$jsonData[$i]['date']['month']
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$dt = DateTime::createFromFormat('Y n j', $jsonData[$i]['date']['year'].' '.
|
$dt = DateTime::createFromFormat(
|
||||||
|
'Y n j', $jsonData[$i]['date']['year'].' '.
|
||||||
$jsonData[$i]['date']['month'].' '.
|
$jsonData[$i]['date']['month'].' '.
|
||||||
$jsonData[$i]['date']['day']);
|
$jsonData[$i]['date']['day']
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($firstelm) {
|
if ($firstelm) {
|
||||||
|
|
|
@ -1,66 +1,66 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require('../../includes/csrf.php');
|
require '../../includes/csrf.php';
|
||||||
|
|
||||||
if (filter_input(INPUT_GET, 'tu') == 'h') {
|
if (filter_input(INPUT_GET, 'tu') == 'h') {
|
||||||
|
|
||||||
header('X-Content-Type-Options: nosniff');
|
header('X-Content-Type-Options: nosniff');
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
$data_template = array(
|
$data_template = array(
|
||||||
0 => array('date' => '00:00', 'rx' => 0, 'tx' => 0),
|
0 => array('date' => '00:00', 'rx' => 0, 'tx' => 0),
|
||||||
1 => array('date' => '01:00', 'rx' => 0, 'tx' => 0),
|
1 => array('date' => '01:00', 'rx' => 0, 'tx' => 0),
|
||||||
2 => array('date' => '02:00', 'rx' => 0, 'tx' => 0),
|
2 => array('date' => '02:00', 'rx' => 0, 'tx' => 0),
|
||||||
3 => array('date' => '03:00', 'rx' => 0, 'tx' => 0),
|
3 => array('date' => '03:00', 'rx' => 0, 'tx' => 0),
|
||||||
4 => array('date' => '04:00', 'rx' => 0, 'tx' => 0),
|
4 => array('date' => '04:00', 'rx' => 0, 'tx' => 0),
|
||||||
5 => array('date' => '05:00', 'rx' => 0, 'tx' => 0),
|
5 => array('date' => '05:00', 'rx' => 0, 'tx' => 0),
|
||||||
6 => array('date' => '06:00', 'rx' => 0, 'tx' => 0),
|
6 => array('date' => '06:00', 'rx' => 0, 'tx' => 0),
|
||||||
7 => array('date' => '07:00', 'rx' => 0, 'tx' => 0),
|
7 => array('date' => '07:00', 'rx' => 0, 'tx' => 0),
|
||||||
8 => array('date' => '08:00', 'rx' => 0, 'tx' => 0),
|
8 => array('date' => '08:00', 'rx' => 0, 'tx' => 0),
|
||||||
9 => array('date' => '09:00', 'rx' => 0, 'tx' => 0),
|
9 => array('date' => '09:00', 'rx' => 0, 'tx' => 0),
|
||||||
10 => array('date' => '10:00', 'rx' => 0, 'tx' => 0),
|
10 => array('date' => '10:00', 'rx' => 0, 'tx' => 0),
|
||||||
11 => array('date' => '11:00', 'rx' => 0, 'tx' => 0),
|
11 => array('date' => '11:00', 'rx' => 0, 'tx' => 0),
|
||||||
12 => array('date' => '12:00', 'rx' => 0, 'tx' => 0),
|
12 => array('date' => '12:00', 'rx' => 0, 'tx' => 0),
|
||||||
13 => array('date' => '13:00', 'rx' => 0, 'tx' => 0),
|
13 => array('date' => '13:00', 'rx' => 0, 'tx' => 0),
|
||||||
14 => array('date' => '14:00', 'rx' => 0, 'tx' => 0),
|
14 => array('date' => '14:00', 'rx' => 0, 'tx' => 0),
|
||||||
15 => array('date' => '15:00', 'rx' => 0, 'tx' => 0),
|
15 => array('date' => '15:00', 'rx' => 0, 'tx' => 0),
|
||||||
16 => array('date' => '16:00', 'rx' => 0, 'tx' => 0),
|
16 => array('date' => '16:00', 'rx' => 0, 'tx' => 0),
|
||||||
17 => array('date' => '17:00', 'rx' => 0, 'tx' => 0),
|
17 => array('date' => '17:00', 'rx' => 0, 'tx' => 0),
|
||||||
18 => array('date' => '18:00', 'rx' => 0, 'tx' => 0),
|
18 => array('date' => '18:00', 'rx' => 0, 'tx' => 0),
|
||||||
19 => array('date' => '19:00', 'rx' => 0, 'tx' => 0),
|
19 => array('date' => '19:00', 'rx' => 0, 'tx' => 0),
|
||||||
20 => array('date' => '20:00', 'rx' => 0, 'tx' => 0),
|
20 => array('date' => '20:00', 'rx' => 0, 'tx' => 0),
|
||||||
21 => array('date' => '21:00', 'rx' => 0, 'tx' => 0),
|
21 => array('date' => '21:00', 'rx' => 0, 'tx' => 0),
|
||||||
22 => array('date' => '22:00', 'rx' => 0, 'tx' => 0),
|
22 => array('date' => '22:00', 'rx' => 0, 'tx' => 0),
|
||||||
23 => array('date' => '23:00', 'rx' => 0, 'tx' => 0)
|
23 => array('date' => '23:00', 'rx' => 0, 'tx' => 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
exec(sprintf('vnstat -i %s --json h', escapeshellarg($interface)), $jsonstdoutvnstat, $exitcodedaily);
|
exec(sprintf('vnstat -i %s --json h', escapeshellarg($interface)), $jsonstdoutvnstat, $exitcodedaily);
|
||||||
if ($exitcodedaily !== 0) {
|
if ($exitcodedaily !== 0) {
|
||||||
exit('vnstat error');
|
exit('vnstat error');
|
||||||
}
|
}
|
||||||
|
|
||||||
$jsonobj = json_decode($jsonstdoutvnstat[0], true)['interfaces'][0];
|
$jsonobj = json_decode($jsonstdoutvnstat[0], true)['interfaces'][0];
|
||||||
$jsonData = $jsonobj['traffic']['hours'];
|
$jsonData = $jsonobj['traffic']['hours'];
|
||||||
for ($i = count($jsonData) - 1; $i >= 0; --$i) {
|
for ($i = count($jsonData) - 1; $i >= 0; --$i) {
|
||||||
$data_template[$jsonData[$i]['id']]['rx'] = round($jsonData[$i]['rx'] / 1024, 0);
|
$data_template[$jsonData[$i]['id']]['rx'] = round($jsonData[$i]['rx'] / 1024, 0);
|
||||||
$data_template[$jsonData[$i]['id']]['tx'] = round($jsonData[$i]['tx'] / 1024, 0);
|
$data_template[$jsonData[$i]['id']]['tx'] = round($jsonData[$i]['tx'] / 1024, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
$hour = $jsonobj['updated']['time']['hour'];
|
$hour = $jsonobj['updated']['time']['hour'];
|
||||||
foreach ($data_template as $key => $value) {
|
foreach ($data_template as $key => $value) {
|
||||||
if ($key > $hour) {
|
if ($key > $hour) {
|
||||||
array_push($data, $value);
|
array_push($data, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($data_template as $key => $value) {
|
foreach ($data_template as $key => $value) {
|
||||||
if ($key <= $hour) {
|
if ($key <= $hour) {
|
||||||
array_push($data, $value);
|
array_push($data, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo json_encode($data);
|
echo json_encode($data);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require('../../includes/csrf.php');
|
require '../../includes/csrf.php';
|
||||||
|
|
||||||
include_once('../../includes/config.php');
|
require_once '../../includes/config.php';
|
||||||
include_once('../../includes/functions.php');
|
require_once '../../includes/functions.php';
|
||||||
|
|
||||||
if (isset($_POST['generate'])) {
|
if (isset($_POST['generate'])) {
|
||||||
$cnfNetworking = array_diff(scandir(RASPI_CONFIG_NETWORKING, 1), array('..','.','dhcpcd.conf'));
|
$cnfNetworking = array_diff(scandir(RASPI_CONFIG_NETWORKING, 1), array('..','.','dhcpcd.conf'));
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require('../../includes/csrf.php');
|
require '../../includes/csrf.php';
|
||||||
|
|
||||||
exec("ls /sys/class/net | grep -v lo", $interfaces);
|
exec("ls /sys/class/net | grep -v lo", $interfaces);
|
||||||
echo json_encode($interfaces);
|
echo json_encode($interfaces);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require('../../includes/csrf.php');
|
require '../../includes/csrf.php';
|
||||||
include_once('../../includes/config.php');
|
require_once '../../includes/config.php';
|
||||||
|
|
||||||
exec('cat '. RASPI_HOSTAPD_CONFIG, $hostapdconfig);
|
exec('cat '. RASPI_HOSTAPD_CONFIG, $hostapdconfig);
|
||||||
$arrConfig = array();
|
$arrConfig = array();
|
||||||
|
@ -10,7 +10,7 @@ foreach ($hostapdconfig as $hostapdconfigline) {
|
||||||
if (strlen($hostapdconfigline) === 0) {
|
if (strlen($hostapdconfigline) === 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$arrLine = explode("=", $hostapdconfigline) ;
|
$arrLine = explode("=", $hostapdconfigline);
|
||||||
$arrConfig[$arrLine[0]]=$arrLine[1];
|
$arrConfig[$arrLine[0]]=$arrLine[1];
|
||||||
};
|
};
|
||||||
$channel = intval($arrConfig['channel']);
|
$channel = intval($arrConfig['channel']);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require('../../includes/csrf.php');
|
require '../../includes/csrf.php';
|
||||||
|
|
||||||
include_once('../../includes/config.php');
|
require_once '../../includes/config.php';
|
||||||
include_once('../../includes/functions.php');
|
require_once '../../includes/functions.php';
|
||||||
|
|
||||||
|
|
||||||
if (isset($_POST['interface'])) {
|
if (isset($_POST['interface'])) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require('../../includes/csrf.php');
|
require '../../includes/csrf.php';
|
||||||
|
|
||||||
include_once('../../includes/functions.php');
|
require_once '../../includes/functions.php';
|
||||||
|
|
||||||
if (isset($_POST['interface'])) {
|
if (isset($_POST['interface'])) {
|
||||||
$int = preg_replace('/[^a-z0-9]/', '', $_POST['interface']);
|
$int = preg_replace('/[^a-z0-9]/', '', $_POST['interface']);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require('../../includes/csrf.php');
|
require '../../includes/csrf.php';
|
||||||
|
|
||||||
include_once('../../includes/config.php');
|
require_once '../../includes/config.php';
|
||||||
include_once('../../includes/functions.php');
|
require_once '../../includes/functions.php';
|
||||||
|
|
||||||
if (isset($_POST['interface'])) {
|
if (isset($_POST['interface'])) {
|
||||||
$int = $_POST['interface'];
|
$int = $_POST['interface'];
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require('../../includes/csrf.php');
|
require '../../includes/csrf.php';
|
||||||
include_once('../../includes/config.php');
|
require_once '../../includes/config.php';
|
||||||
include_once('../../includes/defaults.php');
|
require_once '../../includes/defaults.php';
|
||||||
include_once('../../includes/functions.php');
|
require_once '../../includes/functions.php';
|
||||||
include_once('../../includes/wifi_functions.php');
|
require_once '../../includes/wifi_functions.php';
|
||||||
|
|
||||||
$networks = [];
|
$networks = [];
|
||||||
$network = null;
|
$network = null;
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Displays info about the RaspAP project
|
* Displays info about the RaspAP project
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
function DisplayAbout()
|
function DisplayAbout()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once('includes/status_messages.php');
|
require_once 'includes/status_messages.php';
|
||||||
|
|
||||||
function DisplayAuthConfig($username, $password)
|
function DisplayAuthConfig($username, $password)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once('includes/status_messages.php');
|
require_once 'includes/status_messages.php';
|
||||||
include_once('includes/wifi_functions.php');
|
require_once 'includes/wifi_functions.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function DisplayWPAConfig()
|
function DisplayWPAConfig()
|
||||||
{
|
{
|
||||||
$status = new StatusMessages();
|
$status = new StatusMessages();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once('functions.php');
|
require_once 'functions.php';
|
||||||
include_once('session.php');
|
require_once 'session.php';
|
||||||
|
|
||||||
if (csrfValidateRequest() && !CSRFValidate()) {
|
if (csrfValidateRequest() && !CSRFValidate()) {
|
||||||
handleInvalidCSRFToken();
|
handleInvalidCSRFToken();
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
require_once 'config.php';
|
require_once 'config.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show dashboard page.
|
* Show dashboard page.
|
||||||
*/
|
*/
|
||||||
function DisplayDashboard(&$extraFooterScripts)
|
function DisplayDashboard(&$extraFooterScripts)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -179,25 +179,27 @@ function DisplayDashboard(&$extraFooterScripts)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo renderTemplate("dashboard", compact(
|
echo renderTemplate(
|
||||||
"status",
|
"dashboard", compact(
|
||||||
"ipv4Addrs",
|
"status",
|
||||||
"ipv4Netmasks",
|
"ipv4Addrs",
|
||||||
"ipv6Addrs",
|
"ipv4Netmasks",
|
||||||
"macAddr",
|
"ipv6Addrs",
|
||||||
"strRxPackets",
|
"macAddr",
|
||||||
"strRxBytes",
|
"strRxPackets",
|
||||||
"strTxPackets",
|
"strRxBytes",
|
||||||
"strTxBytes",
|
"strTxPackets",
|
||||||
"connectedSSID",
|
"strTxBytes",
|
||||||
"connectedBSSID",
|
"connectedSSID",
|
||||||
"bitrate",
|
"connectedBSSID",
|
||||||
"signalLevel",
|
"bitrate",
|
||||||
"txPower",
|
"signalLevel",
|
||||||
"frequency",
|
"txPower",
|
||||||
"strLinkQuality",
|
"frequency",
|
||||||
"wlan0up"
|
"strLinkQuality",
|
||||||
));
|
"wlan0up"
|
||||||
|
)
|
||||||
|
);
|
||||||
$extraFooterScripts[] = array('src'=>'app/js/dashboardchart.js', 'defer'=>false);
|
$extraFooterScripts[] = array('src'=>'app/js/dashboardchart.js', 'defer'=>false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,8 +207,8 @@ function DisplayDashboard(&$extraFooterScripts)
|
||||||
/**
|
/**
|
||||||
* Get a human readable data size string from a number of bytes.
|
* Get a human readable data size string from a number of bytes.
|
||||||
*
|
*
|
||||||
* @param long $numbytes The number of bytes.
|
* @param long $numbytes The number of bytes.
|
||||||
* @param int $precision The number of numbers to round to after the dot/comma.
|
* @param int $precision The number of numbers to round to after the dot/comma.
|
||||||
* @return string Data size in units: PB, TB, GB, MB or KB otherwise an empty string.
|
* @return string Data size in units: PB, TB, GB, MB or KB otherwise an empty string.
|
||||||
*/
|
*/
|
||||||
function getHumanReadableDatasize($numbytes, $precision = 2)
|
function getHumanReadableDatasize($numbytes, $precision = 2)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (!defined('RASPI_CONFIG')) {
|
if (!defined('RASPI_CONFIG')) {
|
||||||
define('RASPI_CONFIG', '/etc/raspap');
|
define('RASPI_CONFIG', '/etc/raspap');
|
||||||
}
|
}
|
||||||
|
|
||||||
$defaults = [
|
$defaults = [
|
||||||
|
@ -45,9 +45,9 @@ $defaults = [
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($defaults as $setting => $value) {
|
foreach ($defaults as $setting => $value) {
|
||||||
if (!defined($setting)) {
|
if (!defined($setting)) {
|
||||||
define($setting, $value);
|
define($setting, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($defaults);
|
unset($defaults);
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once('includes/status_messages.php');
|
require_once 'includes/status_messages.php';
|
||||||
require_once 'config.php';
|
require_once 'config.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Manage DHCP configuration
|
||||||
* Manage DHCP configuration
|
*/
|
||||||
*
|
|
||||||
*/
|
|
||||||
function DisplayDHCPConfig()
|
function DisplayDHCPConfig()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -16,18 +14,21 @@ function DisplayDHCPConfig()
|
||||||
if (isset($_POST['savedhcpdsettings'])) {
|
if (isset($_POST['savedhcpdsettings'])) {
|
||||||
$errors = '';
|
$errors = '';
|
||||||
define('IFNAMSIZ', 16);
|
define('IFNAMSIZ', 16);
|
||||||
if (!preg_match('/^[a-zA-Z0-9]+$/', $_POST['interface']) ||
|
if (!preg_match('/^[a-zA-Z0-9]+$/', $_POST['interface'])
|
||||||
strlen($_POST['interface']) >= IFNAMSIZ) {
|
|| strlen($_POST['interface']) >= IFNAMSIZ
|
||||||
|
) {
|
||||||
$errors .= _('Invalid interface name.').'<br />'.PHP_EOL;
|
$errors .= _('Invalid interface name.').'<br />'.PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/', $_POST['RangeStart']) &&
|
if (!preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/', $_POST['RangeStart'])
|
||||||
!empty($_POST['RangeStart'])) { // allow ''/null ?
|
&& !empty($_POST['RangeStart'])
|
||||||
|
) { // allow ''/null ?
|
||||||
$errors .= _('Invalid DHCP range start.').'<br />'.PHP_EOL;
|
$errors .= _('Invalid DHCP range start.').'<br />'.PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/', $_POST['RangeEnd']) &&
|
if (!preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/', $_POST['RangeEnd'])
|
||||||
!empty($_POST['RangeEnd'])) { // allow ''/null ?
|
&& !empty($_POST['RangeEnd'])
|
||||||
|
) { // allow ''/null ?
|
||||||
$errors .= _('Invalid DHCP range end.').'<br />'.PHP_EOL;
|
$errors .= _('Invalid DHCP range end.').'<br />'.PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,9 +59,9 @@ function DisplayDHCPConfig()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST['DNS1']){
|
if ($_POST['DNS1']) {
|
||||||
$config .= "dhcp-option=6," . $_POST['DNS1'];
|
$config .= "dhcp-option=6," . $_POST['DNS1'];
|
||||||
if ($_POST['DNS2']){
|
if ($_POST['DNS2']) {
|
||||||
$config .= ','.$_POST['DNS2'];
|
$config .= ','.$_POST['DNS2'];
|
||||||
}
|
}
|
||||||
$config .= PHP_EOL;
|
$config .= PHP_EOL;
|
||||||
|
@ -126,13 +127,13 @@ function DisplayDHCPConfig()
|
||||||
|
|
||||||
$DNS1 = '';
|
$DNS1 = '';
|
||||||
$DNS2 = '';
|
$DNS2 = '';
|
||||||
if (isset($conf['dhcp-option'])){
|
if (isset($conf['dhcp-option'])) {
|
||||||
$arrDns = explode(",", $conf['dhcp-option']);
|
$arrDns = explode(",", $conf['dhcp-option']);
|
||||||
if ($arrDns[0] == '6'){
|
if ($arrDns[0] == '6') {
|
||||||
if (count($arrDns) > 1){
|
if (count($arrDns) > 1) {
|
||||||
$DNS1 = $arrDns[1];
|
$DNS1 = $arrDns[1];
|
||||||
}
|
}
|
||||||
if (count($arrDns) > 2){
|
if (count($arrDns) > 2) {
|
||||||
$DNS2 = $arrDns[2];
|
$DNS2 = $arrDns[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,37 +148,39 @@ function DisplayDHCPConfig()
|
||||||
$infiniteselected = ' selected="selected"';
|
$infiniteselected = ' selected="selected"';
|
||||||
} else {
|
} else {
|
||||||
switch ($arrRangeLeaseTime[2]) {
|
switch ($arrRangeLeaseTime[2]) {
|
||||||
case 'h':
|
case 'h':
|
||||||
$hselected = ' selected="selected"';
|
$hselected = ' selected="selected"';
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
$mselected = ' selected="selected"';
|
$mselected = ' selected="selected"';
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
$dselected = ' selected="selected"';
|
$dselected = ' selected="selected"';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
|
exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
|
||||||
exec('cat ' . RASPI_DNSMASQ_LEASES, $leases);
|
exec('cat ' . RASPI_DNSMASQ_LEASES, $leases);
|
||||||
|
|
||||||
echo renderTemplate("dhcp", compact(
|
echo renderTemplate(
|
||||||
"status",
|
"dhcp", compact(
|
||||||
"serviceStatus",
|
"status",
|
||||||
"RangeStart",
|
"serviceStatus",
|
||||||
"RangeEnd",
|
"RangeStart",
|
||||||
"DNS1",
|
"RangeEnd",
|
||||||
"DNS2",
|
"DNS1",
|
||||||
"arrRangeLeaseTime",
|
"DNS2",
|
||||||
"mselected",
|
"arrRangeLeaseTime",
|
||||||
"hselected",
|
"mselected",
|
||||||
"dselected",
|
"hselected",
|
||||||
"infiniteselected",
|
"dselected",
|
||||||
"dnsmasq_state",
|
"infiniteselected",
|
||||||
"conf",
|
"dnsmasq_state",
|
||||||
"dhcpHost",
|
"conf",
|
||||||
"interfaces",
|
"dhcpHost",
|
||||||
"leases"
|
"interfaces",
|
||||||
));
|
"leases"
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,8 @@ function safefilerewrite($fileName, $dataToSave)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves a CSRF token in the session
|
* Saves a CSRF token in the session
|
||||||
*/
|
*/
|
||||||
function ensureCSRFSessionToken()
|
function ensureCSRFSessionToken()
|
||||||
{
|
{
|
||||||
if (empty($_SESSION['csrf_token'])) {
|
if (empty($_SESSION['csrf_token'])) {
|
||||||
|
@ -65,10 +65,8 @@ function ensureCSRFSessionToken()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Add CSRF Token to form
|
||||||
* Add CSRF Token to form
|
*/
|
||||||
*
|
|
||||||
*/
|
|
||||||
function CSRFTokenFieldTag()
|
function CSRFTokenFieldTag()
|
||||||
{
|
{
|
||||||
$token = htmlspecialchars($_SESSION['csrf_token']);
|
$token = htmlspecialchars($_SESSION['csrf_token']);
|
||||||
|
@ -76,8 +74,8 @@ function CSRFTokenFieldTag()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retuns a CSRF meta tag (for use with xhr, for example)
|
* Retuns a CSRF meta tag (for use with xhr, for example)
|
||||||
*/
|
*/
|
||||||
function CSRFMetaTag()
|
function CSRFMetaTag()
|
||||||
{
|
{
|
||||||
$token = htmlspecialchars($_SESSION['csrf_token']);
|
$token = htmlspecialchars($_SESSION['csrf_token']);
|
||||||
|
@ -85,10 +83,8 @@ function CSRFMetaTag()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Validate CSRF Token
|
||||||
* Validate CSRF Token
|
*/
|
||||||
*
|
|
||||||
*/
|
|
||||||
function CSRFValidate()
|
function CSRFValidate()
|
||||||
{
|
{
|
||||||
$post_token = $_POST['csrf_token'];
|
$post_token = $_POST['csrf_token'];
|
||||||
|
@ -112,8 +108,8 @@ function CSRFValidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should the request be CSRF-validated?
|
* Should the request be CSRF-validated?
|
||||||
*/
|
*/
|
||||||
function csrfValidateRequest()
|
function csrfValidateRequest()
|
||||||
{
|
{
|
||||||
$request_method = strtolower($_SERVER['REQUEST_METHOD']);
|
$request_method = strtolower($_SERVER['REQUEST_METHOD']);
|
||||||
|
@ -121,8 +117,8 @@ function csrfValidateRequest()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle invalid CSRF
|
* Handle invalid CSRF
|
||||||
*/
|
*/
|
||||||
function handleInvalidCSRFToken()
|
function handleInvalidCSRFToken()
|
||||||
{
|
{
|
||||||
header('HTTP/1.1 500 Internal Server Error');
|
header('HTTP/1.1 500 Internal Server Error');
|
||||||
|
@ -132,23 +128,23 @@ function handleInvalidCSRFToken()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether array is associative
|
* Test whether array is associative
|
||||||
*/
|
*/
|
||||||
function isAssoc($arr)
|
function isAssoc($arr)
|
||||||
{
|
{
|
||||||
return array_keys($arr) !== range(0, count($arr) - 1);
|
return array_keys($arr) !== range(0, count($arr) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Display a selector field for a form. Arguments are:
|
||||||
* Display a selector field for a form. Arguments are:
|
*
|
||||||
* @param string $name: Field name
|
* @param string $name: Field name
|
||||||
* @param array $options: Array of options
|
* @param array $options: Array of options
|
||||||
* @param string $selected: Selected option (optional)
|
* @param string $selected: Selected option (optional)
|
||||||
* @param string $id: $options is an associative array this should be the key
|
* @param string $id: $options is an associative array this should be the key
|
||||||
* @param string $event: onChange event (optional)
|
* @param string $event: onChange event (optional)
|
||||||
* @param string $disabled (optional)
|
* @param string $disabled (optional)
|
||||||
*/
|
*/
|
||||||
function SelectorOptions($name, $options, $selected = null, $id = null, $event = null, $disabled = null)
|
function SelectorOptions($name, $options, $selected = null, $id = null, $event = null, $disabled = null)
|
||||||
{
|
{
|
||||||
echo '<select class="form-control" name="'.htmlspecialchars($name, ENT_QUOTES).'"';
|
echo '<select class="form-control" name="'.htmlspecialchars($name, ENT_QUOTES).'"';
|
||||||
|
@ -176,13 +172,13 @@ function SelectorOptions($name, $options, $selected = null, $id = null, $event =
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param string $input
|
* @param string $input
|
||||||
* @param string $string
|
* @param string $string
|
||||||
* @param int $offset
|
* @param int $offset
|
||||||
* @param string $separator
|
* @param string $separator
|
||||||
* @return $string
|
* @return $string
|
||||||
*/
|
*/
|
||||||
function GetDistString($input, $string, $offset, $separator)
|
function GetDistString($input, $string, $offset, $separator)
|
||||||
{
|
{
|
||||||
$string = substr($input, strpos($input, $string)+$offset, strpos(substr($input, strpos($input, $string)+$offset), $separator));
|
$string = substr($input, strpos($input, $string)+$offset, strpos(substr($input, strpos($input, $string)+$offset), $separator));
|
||||||
|
@ -190,10 +186,10 @@ function GetDistString($input, $string, $offset, $separator)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param array $arrConfig
|
* @param array $arrConfig
|
||||||
* @return $config
|
* @return $config
|
||||||
*/
|
*/
|
||||||
function ParseConfig($arrConfig)
|
function ParseConfig($arrConfig)
|
||||||
{
|
{
|
||||||
$config = array();
|
$config = array();
|
||||||
|
@ -218,10 +214,10 @@ function ParseConfig($arrConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param string $freq
|
* @param string $freq
|
||||||
* @return $channel
|
* @return $channel
|
||||||
*/
|
*/
|
||||||
function ConvertToChannel($freq)
|
function ConvertToChannel($freq)
|
||||||
{
|
{
|
||||||
if ($freq >= 2412 && $freq <= 2484) {
|
if ($freq >= 2412 && $freq <= 2484) {
|
||||||
|
@ -241,10 +237,11 @@ function ConvertToChannel($freq)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts WPA security string to readable format
|
* Converts WPA security string to readable format
|
||||||
* @param string $security
|
*
|
||||||
* @return string
|
* @param string $security
|
||||||
*/
|
* @return string
|
||||||
|
*/
|
||||||
function ConvertToSecurity($security)
|
function ConvertToSecurity($security)
|
||||||
{
|
{
|
||||||
$options = array();
|
$options = array();
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once('includes/status_messages.php');
|
require_once 'includes/status_messages.php';
|
||||||
include_once('app/lib/system.php');
|
require_once 'app/lib/system.php';
|
||||||
require_once 'config.php';
|
require_once 'config.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function DisplayHostAPDConfig()
|
function DisplayHostAPDConfig()
|
||||||
{
|
{
|
||||||
$status = new StatusMessages();
|
$status = new StatusMessages();
|
||||||
$system = new System();
|
$system = new System();
|
||||||
$arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini');
|
$arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini');
|
||||||
$arrConfig = array();
|
$arrConfig = array();
|
||||||
$arr80211Standard = [
|
$arr80211Standard = [
|
||||||
|
@ -20,7 +20,7 @@ function DisplayHostAPDConfig()
|
||||||
'g' => '802.11g - 2.4 GHz',
|
'g' => '802.11g - 2.4 GHz',
|
||||||
'n' => '802.11n - 2.4 GHz',
|
'n' => '802.11n - 2.4 GHz',
|
||||||
'ac' => '802.11.ac - 5 GHz'
|
'ac' => '802.11.ac - 5 GHz'
|
||||||
];
|
];
|
||||||
$arrSecurity = array(1 => 'WPA', 2 => 'WPA2', 3 => 'WPA+WPA2', 'none' => _("None"));
|
$arrSecurity = array(1 => 'WPA', 2 => 'WPA2', 3 => 'WPA+WPA2', 'none' => _("None"));
|
||||||
$arrEncType = array('TKIP' => 'TKIP', 'CCMP' => 'CCMP', 'TKIP CCMP' => 'TKIP+CCMP');
|
$arrEncType = array('TKIP' => 'TKIP', 'CCMP' => 'CCMP', 'TKIP CCMP' => 'TKIP+CCMP');
|
||||||
$managedModeEnabled = false;
|
$managedModeEnabled = false;
|
||||||
|
@ -50,7 +50,7 @@ function DisplayHostAPDConfig()
|
||||||
|
|
||||||
exec('cat '. RASPI_HOSTAPD_CONFIG, $hostapdconfig);
|
exec('cat '. RASPI_HOSTAPD_CONFIG, $hostapdconfig);
|
||||||
exec('iwgetid '. RASPI_WIFI_CLIENT_INTERFACE. ' -r', $wifiNetworkID);
|
exec('iwgetid '. RASPI_WIFI_CLIENT_INTERFACE. ' -r', $wifiNetworkID);
|
||||||
if ( !empty($wifiNetworkID[0])) {
|
if (!empty($wifiNetworkID[0])) {
|
||||||
$managedModeEnabled = true;
|
$managedModeEnabled = true;
|
||||||
}
|
}
|
||||||
$hostapdstatus = $system->hostapdStatus();
|
$hostapdstatus = $system->hostapdStatus();
|
||||||
|
@ -62,33 +62,36 @@ function DisplayHostAPDConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($hostapdconfigline[0] != "#") {
|
if ($hostapdconfigline[0] != "#") {
|
||||||
$arrLine = explode("=", $hostapdconfigline) ;
|
$arrLine = explode("=", $hostapdconfigline);
|
||||||
$arrConfig[$arrLine[0]]=$arrLine[1];
|
$arrConfig[$arrLine[0]]=$arrLine[1];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
echo renderTemplate("hostapd", compact(
|
echo renderTemplate(
|
||||||
"status",
|
"hostapd", compact(
|
||||||
"serviceStatus",
|
"status",
|
||||||
"hostapdstatus",
|
"serviceStatus",
|
||||||
"managedModeEnabled",
|
"hostapdstatus",
|
||||||
"interfaces",
|
"managedModeEnabled",
|
||||||
"arrConfig",
|
"interfaces",
|
||||||
"arr80211Standard",
|
"arrConfig",
|
||||||
"selectedHwMode",
|
"arr80211Standard",
|
||||||
"arrSecurity",
|
"selectedHwMode",
|
||||||
"arrEncType",
|
"arrSecurity",
|
||||||
"arrHostapdConf"
|
"arrEncType",
|
||||||
));
|
"arrHostapdConf"
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
||||||
{
|
{
|
||||||
// It should not be possible to send bad data for these fields so clearly
|
// It should not be possible to send bad data for these fields so clearly
|
||||||
// someone is up to something if they fail. Fail silently.
|
// someone is up to something if they fail. Fail silently.
|
||||||
if (!(array_key_exists($_POST['wpa'], $wpa_array) &&
|
if (!(array_key_exists($_POST['wpa'], $wpa_array)
|
||||||
array_key_exists($_POST['wpa_pairwise'], $enc_types) &&
|
&& array_key_exists($_POST['wpa_pairwise'], $enc_types)
|
||||||
array_key_exists($_POST['hw_mode'], $modes))) {
|
&& array_key_exists($_POST['hw_mode'], $modes))
|
||||||
|
) {
|
||||||
error_log("Attempting to set hostapd config with wpa='".$_POST['wpa']."', wpa_pairwise='".$_POST['wpa_pairwise']."' and hw_mode='".$_POST['hw_mode']."'"); // FIXME: log injection
|
error_log("Attempting to set hostapd config with wpa='".$_POST['wpa']."', wpa_pairwise='".$_POST['wpa_pairwise']."' and hw_mode='".$_POST['hw_mode']."'"); // FIXME: log injection
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -147,8 +150,9 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
||||||
$good_input = false;
|
$good_input = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST['wpa'] !== 'none' &&
|
if ($_POST['wpa'] !== 'none'
|
||||||
(strlen($_POST['wpa_passphrase']) < 8 || strlen($_POST['wpa_passphrase']) > 63)) {
|
&& (strlen($_POST['wpa_passphrase']) < 8 || strlen($_POST['wpa_passphrase']) > 63)
|
||||||
|
) {
|
||||||
$status->addMessage('WPA passphrase must be between 8 and 63 characters', 'danger');
|
$status->addMessage('WPA passphrase must be between 8 and 63 characters', 'danger');
|
||||||
$good_input = false;
|
$good_input = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,77 +1,76 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Sets locale information for i18n support
|
* Sets locale information for i18n support
|
||||||
*
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rudimentary language detection via the browser.
|
* Rudimentary language detection via the browser.
|
||||||
* Accept-Language returns a list of weighted values with a quality (or 'q') parameter.
|
* Accept-Language returns a list of weighted values with a quality (or 'q') parameter.
|
||||||
* A better method would parse the list of preferred languages and match this with
|
* A better method would parse the list of preferred languages and match this with
|
||||||
* the languages supported by our platform.
|
* the languages supported by our platform.
|
||||||
*
|
*
|
||||||
* Refer to: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
|
* Refer to: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
|
||||||
*/
|
*/
|
||||||
if (empty($_SESSION['locale']) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) >= 2) {
|
if (empty($_SESSION['locale']) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) >= 2) {
|
||||||
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
|
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
|
||||||
switch ($lang) {
|
switch ($lang) {
|
||||||
case "de":
|
case "de":
|
||||||
$locale = "de_DE.UTF-8";
|
$locale = "de_DE.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "fr":
|
case "fr":
|
||||||
$locale = "fr_FR.UTF-8";
|
$locale = "fr_FR.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "it":
|
case "it":
|
||||||
$locale = "it_IT.UTF-8";
|
$locale = "it_IT.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "pt":
|
case "pt":
|
||||||
$locale = "pt_BR.UTF-8";
|
$locale = "pt_BR.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "sv":
|
case "sv":
|
||||||
$locale = "sv_SE.UTF-8";
|
$locale = "sv_SE.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "nl":
|
case "nl":
|
||||||
$locale = "nl_NL.UTF-8";
|
$locale = "nl_NL.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "zh":
|
case "zh":
|
||||||
$locale = "zh_CN.UTF-8";
|
$locale = "zh_CN.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "cs":
|
case "cs":
|
||||||
$locale = "cs_CZ.UTF-8";
|
$locale = "cs_CZ.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "ru":
|
case "ru":
|
||||||
$locale = "ru_RU.UTF-8";
|
$locale = "ru_RU.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "es":
|
case "es":
|
||||||
$locale = "es_MX.UTF-8";
|
$locale = "es_MX.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "fi":
|
case "fi":
|
||||||
$locale = "fi_FI.UTF-8";
|
$locale = "fi_FI.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "si":
|
case "si":
|
||||||
$locale = "si_LK.UTF-8";
|
$locale = "si_LK.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "tr":
|
case "tr":
|
||||||
$locale = "tr_TR.UTF-8";
|
$locale = "tr_TR.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "id":
|
case "id":
|
||||||
$locale = "id_ID.UTF-8";
|
$locale = "id_ID.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "ko":
|
case "ko":
|
||||||
$locale = "ko_KR.UTF-8";
|
$locale = "ko_KR.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "ja":
|
case "ja":
|
||||||
$locale = "ja_JP.UTF-8";
|
$locale = "ja_JP.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "vi":
|
case "vi":
|
||||||
$locale = "vi_VN.UTF-8";
|
$locale = "vi_VN.UTF-8";
|
||||||
break;
|
break;
|
||||||
case "el":
|
case "el":
|
||||||
$locale = "el_GR.UTF-8";
|
$locale = "el_GR.UTF-8";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$locale = "en_GB.UTF-8";
|
$locale = "en_GB.UTF-8";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$_SESSION['locale'] = $locale;
|
$_SESSION['locale'] = $locale;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once('includes/status_messages.php');
|
require_once 'includes/status_messages.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function DisplayNetworkingConfig()
|
function DisplayNetworkingConfig()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once('includes/status_messages.php');
|
require_once 'includes/status_messages.php';
|
||||||
require_once 'config.php';
|
require_once 'config.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Manage OpenVPN configuration
|
* Manage OpenVPN configuration
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
function DisplayOpenVPNConfig()
|
function DisplayOpenVPNConfig()
|
||||||
{
|
{
|
||||||
|
@ -48,26 +46,27 @@ function DisplayOpenVPNConfig()
|
||||||
$authPassword = $auth[1];
|
$authPassword = $auth[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
echo renderTemplate("openvpn", compact(
|
echo renderTemplate(
|
||||||
"status",
|
"openvpn", compact(
|
||||||
"serviceStatus",
|
"status",
|
||||||
"openvpnstatus",
|
"serviceStatus",
|
||||||
"public_ip",
|
"openvpnstatus",
|
||||||
"authUser",
|
"public_ip",
|
||||||
"authPassword"
|
"authUser",
|
||||||
));
|
"authPassword"
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Validates uploaded .ovpn file, adds auth-user-pass and
|
* Validates uploaded .ovpn file, adds auth-user-pass and
|
||||||
* stores auth credentials in login.conf. Copies files from
|
* stores auth credentials in login.conf. Copies files from
|
||||||
* tmp to OpenVPN
|
* tmp to OpenVPN
|
||||||
*
|
*
|
||||||
* @param object $status
|
* @param object $status
|
||||||
* @param object $file
|
* @param object $file
|
||||||
* @param string $authUser
|
* @param string $authUser
|
||||||
* @param string $authPassword
|
* @param string $authPassword
|
||||||
* @return object $status
|
* @return object $status
|
||||||
*/
|
*/
|
||||||
function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
|
function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
|
||||||
|
@ -84,15 +83,15 @@ function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
|
||||||
|
|
||||||
// Parse returned errors
|
// Parse returned errors
|
||||||
switch ($file['error']) {
|
switch ($file['error']) {
|
||||||
case UPLOAD_ERR_OK:
|
case UPLOAD_ERR_OK:
|
||||||
break;
|
break;
|
||||||
case UPLOAD_ERR_NO_FILE:
|
case UPLOAD_ERR_NO_FILE:
|
||||||
throw new RuntimeException('OpenVPN configuration file not sent');
|
throw new RuntimeException('OpenVPN configuration file not sent');
|
||||||
case UPLOAD_ERR_INI_SIZE:
|
case UPLOAD_ERR_INI_SIZE:
|
||||||
case UPLOAD_ERR_FORM_SIZE:
|
case UPLOAD_ERR_FORM_SIZE:
|
||||||
throw new RuntimeException('Exceeded filesize limit');
|
throw new RuntimeException('Exceeded filesize limit');
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException('Unknown errors');
|
throw new RuntimeException('Unknown errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate extension
|
// Validate extension
|
||||||
|
@ -109,7 +108,8 @@ function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
|
||||||
'ovpn' => 'text/plain'
|
'ovpn' => 'text/plain'
|
||||||
),
|
),
|
||||||
true
|
true
|
||||||
)) {
|
)
|
||||||
|
) {
|
||||||
throw new RuntimeException('Invalid file format');
|
throw new RuntimeException('Invalid file format');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,8 @@ function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
|
||||||
'ovpnclient',
|
'ovpnclient',
|
||||||
$ext
|
$ext
|
||||||
)
|
)
|
||||||
)) {
|
)
|
||||||
|
) {
|
||||||
throw new RuntimeException('Unable to move uploaded file');
|
throw new RuntimeException('Unable to move uploaded file');
|
||||||
}
|
}
|
||||||
// Good file upload, update auth credentials if present
|
// Good file upload, update auth credentials if present
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once('app/lib/system.php');
|
require_once 'app/lib/system.php';
|
||||||
|
|
||||||
$system = new System();
|
$system = new System();
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once('includes/status_messages.php');
|
require_once 'includes/status_messages.php';
|
||||||
require_once 'config.php';
|
require_once 'config.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Find the version of the Raspberry Pi
|
* Find the version of the Raspberry Pi
|
||||||
* Currently only used for the system information page but may useful elsewhere
|
* Currently only used for the system information page but may useful elsewhere
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function RPiVersion()
|
function RPiVersion()
|
||||||
|
@ -98,7 +96,7 @@ function DisplaySystem()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST['RestartLighttpd'])) {
|
if (isset($_POST['RestartLighttpd'])) {
|
||||||
$status->addMessage('Restarting lighttpd in 3 seconds...','info');
|
$status->addMessage('Restarting lighttpd in 3 seconds...', 'info');
|
||||||
exec('sudo /etc/raspap/lighttpd/configport.sh --restart');
|
exec('sudo /etc/raspap/lighttpd/configport.sh --restart');
|
||||||
}
|
}
|
||||||
exec('cat '. RASPI_LIGHTTPD_CONFIG, $return);
|
exec('cat '. RASPI_LIGHTTPD_CONFIG, $return);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function DisplayThemeConfig()
|
function DisplayThemeConfig()
|
||||||
{
|
{
|
||||||
$themes = [
|
$themes = [
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once('includes/status_messages.php');
|
require_once 'includes/status_messages.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Manage Tor Proxy configuration
|
||||||
* Manage Tor Proxy configuration
|
*/
|
||||||
*
|
|
||||||
*/
|
|
||||||
function DisplayTorProxyConfig()
|
function DisplayTorProxyConfig()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -16,21 +14,23 @@ function DisplayTorProxyConfig()
|
||||||
$arrConfig = array();
|
$arrConfig = array();
|
||||||
foreach ($return as $a) {
|
foreach ($return as $a) {
|
||||||
if ($a[0] != "#") {
|
if ($a[0] != "#") {
|
||||||
$arrLine = explode(" ", $a) ;
|
$arrLine = explode(" ", $a);
|
||||||
$arrConfig[$arrLine[0]]=$arrLine[1];
|
$arrConfig[$arrLine[0]]=$arrLine[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo renderTemplate("torproxy", compact(
|
echo renderTemplate(
|
||||||
"status",
|
"torproxy", compact(
|
||||||
"torproxystatus"
|
"status",
|
||||||
));
|
"torproxystatus"
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function SaveTORAndVPNConfig()
|
function SaveTORAndVPNConfig()
|
||||||
{
|
{
|
||||||
if (isset($_POST['SaveTORProxySettings'])) {
|
if (isset($_POST['SaveTORProxySettings'])) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once('functions.php');
|
require_once 'functions.php';
|
||||||
|
|
||||||
function knownWifiStations(&$networks)
|
function knownWifiStations(&$networks)
|
||||||
{
|
{
|
||||||
|
@ -16,26 +16,26 @@ function knownWifiStations(&$networks)
|
||||||
$ssid = null;
|
$ssid = null;
|
||||||
} elseif ($lineArr = preg_split('/\s*=\s*/', trim($line))) {
|
} elseif ($lineArr = preg_split('/\s*=\s*/', trim($line))) {
|
||||||
switch (strtolower($lineArr[0])) {
|
switch (strtolower($lineArr[0])) {
|
||||||
case 'ssid':
|
case 'ssid':
|
||||||
$ssid = trim($lineArr[1], '"');
|
$ssid = trim($lineArr[1], '"');
|
||||||
break;
|
break;
|
||||||
case 'psk':
|
case 'psk':
|
||||||
if (array_key_exists('passphrase', $network)) {
|
if (array_key_exists('passphrase', $network)) {
|
||||||
break;
|
|
||||||
}
|
|
||||||
case '#psk':
|
|
||||||
$network['protocol'] = 'WPA';
|
|
||||||
case 'wep_key0': // Untested
|
|
||||||
$network['passphrase'] = trim($lineArr[1], '"');
|
|
||||||
break;
|
|
||||||
case 'key_mgmt':
|
|
||||||
if (! array_key_exists('passphrase', $network) && $lineArr[1] === 'NONE') {
|
|
||||||
$network['protocol'] = 'Open';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'priority':
|
|
||||||
$network['priority'] = trim($lineArr[1], '"');
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case '#psk':
|
||||||
|
$network['protocol'] = 'WPA';
|
||||||
|
case 'wep_key0': // Untested
|
||||||
|
$network['passphrase'] = trim($lineArr[1], '"');
|
||||||
|
break;
|
||||||
|
case 'key_mgmt':
|
||||||
|
if (! array_key_exists('passphrase', $network) && $lineArr[1] === 'NONE') {
|
||||||
|
$network['protocol'] = 'Open';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'priority':
|
||||||
|
$network['priority'] = trim($lineArr[1], '"');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,15 +51,17 @@ function nearbyWifiStations(&$networks, $cached = true)
|
||||||
deleteCache($cacheKey);
|
deleteCache($cacheKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
$scan_results = cache($cacheKey, function () {
|
$scan_results = cache(
|
||||||
exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan');
|
$cacheKey, function () {
|
||||||
sleep(3);
|
exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan');
|
||||||
|
sleep(3);
|
||||||
|
|
||||||
exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan_results', $stdout);
|
exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan_results', $stdout);
|
||||||
array_shift($stdout);
|
array_shift($stdout);
|
||||||
|
|
||||||
return implode("\n", $stdout);
|
return implode("\n", $stdout);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
foreach (explode("\n", $scan_results) as $network) {
|
foreach (explode("\n", $scan_results) as $network) {
|
||||||
$arrNetwork = preg_split("/[\t]+/", $network); // split result into array
|
$arrNetwork = preg_split("/[\t]+/", $network); // split result into array
|
||||||
|
|
148
index.php
148
index.php
|
@ -10,36 +10,36 @@
|
||||||
* php-cgi (I have version 7.1.20-1+b2 installed via apt)
|
* php-cgi (I have version 7.1.20-1+b2 installed via apt)
|
||||||
* along with their supporting packages, php7.1 will also need to be enabled.
|
* along with their supporting packages, php7.1 will also need to be enabled.
|
||||||
*
|
*
|
||||||
* @author Lawrence Yau <sirlagz@gmail.com>
|
* @author Lawrence Yau <sirlagz@gmail.com>
|
||||||
* @author Bill Zimmerman <billzimmerman@gmail.com>
|
* @author Bill Zimmerman <billzimmerman@gmail.com>
|
||||||
* @license GNU General Public License, version 3 (GPL-3.0)
|
* @license GNU General Public License, version 3 (GPL-3.0)
|
||||||
* @version 2.2
|
* @version 2.2
|
||||||
* @link https://github.com/billz/raspap-webgui
|
* @link https://github.com/billz/raspap-webgui
|
||||||
* @see http://sirlagz.net/2013/02/08/raspap-webgui/
|
* @see http://sirlagz.net/2013/02/08/raspap-webgui/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require('includes/csrf.php');
|
require 'includes/csrf.php';
|
||||||
ensureCSRFSessionToken();
|
ensureCSRFSessionToken();
|
||||||
|
|
||||||
include_once('includes/config.php');
|
require_once 'includes/config.php';
|
||||||
include_once('includes/defaults.php');
|
require_once 'includes/defaults.php';
|
||||||
include_once(RASPI_CONFIG.'/raspap.php');
|
require_once RASPI_CONFIG.'/raspap.php';
|
||||||
include_once('includes/locale.php');
|
require_once 'includes/locale.php';
|
||||||
include_once('includes/functions.php');
|
require_once 'includes/functions.php';
|
||||||
include_once('includes/dashboard.php');
|
require_once 'includes/dashboard.php';
|
||||||
include_once('includes/authenticate.php');
|
require_once 'includes/authenticate.php';
|
||||||
include_once('includes/admin.php');
|
require_once 'includes/admin.php';
|
||||||
include_once('includes/dhcp.php');
|
require_once 'includes/dhcp.php';
|
||||||
include_once('includes/hostapd.php');
|
require_once 'includes/hostapd.php';
|
||||||
include_once('includes/system.php');
|
require_once 'includes/system.php';
|
||||||
include_once('includes/sysstats.php');
|
require_once 'includes/sysstats.php';
|
||||||
include_once('includes/configure_client.php');
|
require_once 'includes/configure_client.php';
|
||||||
include_once('includes/networking.php');
|
require_once 'includes/networking.php';
|
||||||
include_once('includes/themes.php');
|
require_once 'includes/themes.php';
|
||||||
include_once('includes/data_usage.php');
|
require_once 'includes/data_usage.php';
|
||||||
include_once('includes/about.php');
|
require_once 'includes/about.php';
|
||||||
include_once('includes/openvpn.php');
|
require_once 'includes/openvpn.php';
|
||||||
include_once('includes/torproxy.php');
|
require_once 'includes/torproxy.php';
|
||||||
|
|
||||||
$output = $return = 0;
|
$output = $return = 0;
|
||||||
$page = $_GET['page'];
|
$page = $_GET['page'];
|
||||||
|
@ -131,7 +131,7 @@ if ($_COOKIE['sidebarToggled'] == 'true' ) {
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<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 _("Configure WiFi client"); ?></span></a>
|
<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 _("Configure WiFi client"); ?></span></a>
|
||||||
</li>
|
</li>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if (RASPI_HOTSPOT_ENABLED) : ?>
|
<?php if (RASPI_HOTSPOT_ENABLED) : ?>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<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 _("Configure hotspot"); ?></a>
|
<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 _("Configure hotspot"); ?></a>
|
||||||
|
@ -219,52 +219,52 @@ if ($_COOKIE['sidebarToggled'] == 'true' ) {
|
||||||
<!-- Begin Page Content -->
|
<!-- Begin Page Content -->
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<?php
|
<?php
|
||||||
$extraFooterScripts = array();
|
$extraFooterScripts = array();
|
||||||
// handle page actions
|
// handle page actions
|
||||||
switch ($page) {
|
switch ($page) {
|
||||||
case "wlan0_info":
|
case "wlan0_info":
|
||||||
DisplayDashboard($extraFooterScripts);
|
DisplayDashboard($extraFooterScripts);
|
||||||
break;
|
break;
|
||||||
case "dhcpd_conf":
|
case "dhcpd_conf":
|
||||||
DisplayDHCPConfig();
|
DisplayDHCPConfig();
|
||||||
break;
|
break;
|
||||||
case "wpa_conf":
|
case "wpa_conf":
|
||||||
DisplayWPAConfig();
|
DisplayWPAConfig();
|
||||||
break;
|
break;
|
||||||
case "network_conf":
|
case "network_conf":
|
||||||
DisplayNetworkingConfig();
|
DisplayNetworkingConfig();
|
||||||
break;
|
break;
|
||||||
case "hostapd_conf":
|
case "hostapd_conf":
|
||||||
DisplayHostAPDConfig();
|
DisplayHostAPDConfig();
|
||||||
break;
|
break;
|
||||||
case "openvpn_conf":
|
case "openvpn_conf":
|
||||||
DisplayOpenVPNConfig();
|
DisplayOpenVPNConfig();
|
||||||
break;
|
break;
|
||||||
case "torproxy_conf":
|
case "torproxy_conf":
|
||||||
DisplayTorProxyConfig();
|
DisplayTorProxyConfig();
|
||||||
break;
|
break;
|
||||||
case "auth_conf":
|
case "auth_conf":
|
||||||
DisplayAuthConfig($config['admin_user'], $config['admin_pass']);
|
DisplayAuthConfig($config['admin_user'], $config['admin_pass']);
|
||||||
break;
|
break;
|
||||||
case "save_hostapd_conf":
|
case "save_hostapd_conf":
|
||||||
SaveTORAndVPNConfig();
|
SaveTORAndVPNConfig();
|
||||||
break;
|
break;
|
||||||
case "theme_conf":
|
case "theme_conf":
|
||||||
DisplayThemeConfig();
|
DisplayThemeConfig();
|
||||||
break;
|
break;
|
||||||
case "data_use":
|
case "data_use":
|
||||||
DisplayDataUsage($extraFooterScripts);
|
DisplayDataUsage($extraFooterScripts);
|
||||||
break;
|
break;
|
||||||
case "system_info":
|
case "system_info":
|
||||||
DisplaySystem();
|
DisplaySystem();
|
||||||
break;
|
break;
|
||||||
case "about":
|
case "about":
|
||||||
DisplayAbout();
|
DisplayAbout();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DisplayDashboard($extraFooterScripts);
|
DisplayDashboard($extraFooterScripts);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div><!-- /.container-fluid -->
|
</div><!-- /.container-fluid -->
|
||||||
</div><!-- End of Main Content -->
|
</div><!-- End of Main Content -->
|
||||||
<!-- Footer -->
|
<!-- Footer -->
|
||||||
|
@ -317,6 +317,6 @@ if ($_COOKIE['sidebarToggled'] == 'true' ) {
|
||||||
}
|
}
|
||||||
echo '></script>' , PHP_EOL;
|
echo '></script>' , PHP_EOL;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in a new issue