mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Processed with phpcbf
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Displays info about the RaspAP project
|
||||
*
|
||||
*/
|
||||
function DisplayAbout()
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
include_once('includes/status_messages.php');
|
||||
require_once 'includes/status_messages.php';
|
||||
|
||||
function DisplayAuthConfig($username, $password)
|
||||
{
|
||||
|
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
include_once('includes/status_messages.php');
|
||||
include_once('includes/wifi_functions.php');
|
||||
require_once 'includes/status_messages.php';
|
||||
require_once 'includes/wifi_functions.php';
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
*
|
||||
*
|
||||
*/
|
||||
function DisplayWPAConfig()
|
||||
{
|
||||
$status = new StatusMessages();
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
include_once('functions.php');
|
||||
include_once('session.php');
|
||||
require_once 'functions.php';
|
||||
require_once 'session.php';
|
||||
|
||||
if (csrfValidateRequest() && !CSRFValidate()) {
|
||||
handleInvalidCSRFToken();
|
||||
|
@@ -3,8 +3,8 @@
|
||||
require_once 'config.php';
|
||||
|
||||
/**
|
||||
* Show dashboard page.
|
||||
*/
|
||||
* Show dashboard page.
|
||||
*/
|
||||
function DisplayDashboard(&$extraFooterScripts)
|
||||
{
|
||||
|
||||
@@ -179,25 +179,27 @@ function DisplayDashboard(&$extraFooterScripts)
|
||||
}
|
||||
}
|
||||
|
||||
echo renderTemplate("dashboard", compact(
|
||||
"status",
|
||||
"ipv4Addrs",
|
||||
"ipv4Netmasks",
|
||||
"ipv6Addrs",
|
||||
"macAddr",
|
||||
"strRxPackets",
|
||||
"strRxBytes",
|
||||
"strTxPackets",
|
||||
"strTxBytes",
|
||||
"connectedSSID",
|
||||
"connectedBSSID",
|
||||
"bitrate",
|
||||
"signalLevel",
|
||||
"txPower",
|
||||
"frequency",
|
||||
"strLinkQuality",
|
||||
"wlan0up"
|
||||
));
|
||||
echo renderTemplate(
|
||||
"dashboard", compact(
|
||||
"status",
|
||||
"ipv4Addrs",
|
||||
"ipv4Netmasks",
|
||||
"ipv6Addrs",
|
||||
"macAddr",
|
||||
"strRxPackets",
|
||||
"strRxBytes",
|
||||
"strTxPackets",
|
||||
"strTxBytes",
|
||||
"connectedSSID",
|
||||
"connectedBSSID",
|
||||
"bitrate",
|
||||
"signalLevel",
|
||||
"txPower",
|
||||
"frequency",
|
||||
"strLinkQuality",
|
||||
"wlan0up"
|
||||
)
|
||||
);
|
||||
$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.
|
||||
*
|
||||
* @param long $numbytes The number of bytes.
|
||||
* @param int $precision The number of numbers to round to after the dot/comma.
|
||||
* @param long $numbytes The number of bytes.
|
||||
* @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.
|
||||
*/
|
||||
function getHumanReadableDatasize($numbytes, $precision = 2)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
if (!defined('RASPI_CONFIG')) {
|
||||
define('RASPI_CONFIG', '/etc/raspap');
|
||||
define('RASPI_CONFIG', '/etc/raspap');
|
||||
}
|
||||
|
||||
$defaults = [
|
||||
@@ -45,9 +45,9 @@ $defaults = [
|
||||
];
|
||||
|
||||
foreach ($defaults as $setting => $value) {
|
||||
if (!defined($setting)) {
|
||||
define($setting, $value);
|
||||
}
|
||||
if (!defined($setting)) {
|
||||
define($setting, $value);
|
||||
}
|
||||
}
|
||||
|
||||
unset($defaults);
|
||||
|
@@ -1,13 +1,11 @@
|
||||
<?php
|
||||
|
||||
include_once('includes/status_messages.php');
|
||||
require_once 'includes/status_messages.php';
|
||||
require_once 'config.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* Manage DHCP configuration
|
||||
*
|
||||
*/
|
||||
* Manage DHCP configuration
|
||||
*/
|
||||
function DisplayDHCPConfig()
|
||||
{
|
||||
|
||||
@@ -16,18 +14,21 @@ function DisplayDHCPConfig()
|
||||
if (isset($_POST['savedhcpdsettings'])) {
|
||||
$errors = '';
|
||||
define('IFNAMSIZ', 16);
|
||||
if (!preg_match('/^[a-zA-Z0-9]+$/', $_POST['interface']) ||
|
||||
strlen($_POST['interface']) >= IFNAMSIZ) {
|
||||
if (!preg_match('/^[a-zA-Z0-9]+$/', $_POST['interface'])
|
||||
|| strlen($_POST['interface']) >= IFNAMSIZ
|
||||
) {
|
||||
$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']) &&
|
||||
!empty($_POST['RangeStart'])) { // allow ''/null ?
|
||||
if (!preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/', $_POST['RangeStart'])
|
||||
&& !empty($_POST['RangeStart'])
|
||||
) { // allow ''/null ?
|
||||
$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']) &&
|
||||
!empty($_POST['RangeEnd'])) { // allow ''/null ?
|
||||
if (!preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/', $_POST['RangeEnd'])
|
||||
&& !empty($_POST['RangeEnd'])
|
||||
) { // allow ''/null ?
|
||||
$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'];
|
||||
if ($_POST['DNS2']){
|
||||
if ($_POST['DNS2']) {
|
||||
$config .= ','.$_POST['DNS2'];
|
||||
}
|
||||
$config .= PHP_EOL;
|
||||
@@ -126,13 +127,13 @@ function DisplayDHCPConfig()
|
||||
|
||||
$DNS1 = '';
|
||||
$DNS2 = '';
|
||||
if (isset($conf['dhcp-option'])){
|
||||
if (isset($conf['dhcp-option'])) {
|
||||
$arrDns = explode(",", $conf['dhcp-option']);
|
||||
if ($arrDns[0] == '6'){
|
||||
if (count($arrDns) > 1){
|
||||
if ($arrDns[0] == '6') {
|
||||
if (count($arrDns) > 1) {
|
||||
$DNS1 = $arrDns[1];
|
||||
}
|
||||
if (count($arrDns) > 2){
|
||||
if (count($arrDns) > 2) {
|
||||
$DNS2 = $arrDns[2];
|
||||
}
|
||||
}
|
||||
@@ -147,37 +148,39 @@ function DisplayDHCPConfig()
|
||||
$infiniteselected = ' selected="selected"';
|
||||
} else {
|
||||
switch ($arrRangeLeaseTime[2]) {
|
||||
case 'h':
|
||||
$hselected = ' selected="selected"';
|
||||
break;
|
||||
case 'm':
|
||||
$mselected = ' selected="selected"';
|
||||
break;
|
||||
case 'd':
|
||||
$dselected = ' selected="selected"';
|
||||
break;
|
||||
case 'h':
|
||||
$hselected = ' selected="selected"';
|
||||
break;
|
||||
case 'm':
|
||||
$mselected = ' selected="selected"';
|
||||
break;
|
||||
case 'd':
|
||||
$dselected = ' selected="selected"';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
|
||||
exec('cat ' . RASPI_DNSMASQ_LEASES, $leases);
|
||||
|
||||
echo renderTemplate("dhcp", compact(
|
||||
"status",
|
||||
"serviceStatus",
|
||||
"RangeStart",
|
||||
"RangeEnd",
|
||||
"DNS1",
|
||||
"DNS2",
|
||||
"arrRangeLeaseTime",
|
||||
"mselected",
|
||||
"hselected",
|
||||
"dselected",
|
||||
"infiniteselected",
|
||||
"dnsmasq_state",
|
||||
"conf",
|
||||
"dhcpHost",
|
||||
"interfaces",
|
||||
"leases"
|
||||
));
|
||||
echo renderTemplate(
|
||||
"dhcp", compact(
|
||||
"status",
|
||||
"serviceStatus",
|
||||
"RangeStart",
|
||||
"RangeEnd",
|
||||
"DNS1",
|
||||
"DNS2",
|
||||
"arrRangeLeaseTime",
|
||||
"mselected",
|
||||
"hselected",
|
||||
"dselected",
|
||||
"infiniteselected",
|
||||
"dnsmasq_state",
|
||||
"conf",
|
||||
"dhcpHost",
|
||||
"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()
|
||||
{
|
||||
if (empty($_SESSION['csrf_token'])) {
|
||||
@@ -65,10 +65,8 @@ function ensureCSRFSessionToken()
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Add CSRF Token to form
|
||||
*
|
||||
*/
|
||||
* Add CSRF Token to form
|
||||
*/
|
||||
function CSRFTokenFieldTag()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$token = htmlspecialchars($_SESSION['csrf_token']);
|
||||
@@ -85,10 +83,8 @@ function CSRFMetaTag()
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Validate CSRF Token
|
||||
*
|
||||
*/
|
||||
* Validate CSRF Token
|
||||
*/
|
||||
function CSRFValidate()
|
||||
{
|
||||
$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()
|
||||
{
|
||||
$request_method = strtolower($_SERVER['REQUEST_METHOD']);
|
||||
@@ -121,8 +117,8 @@ function csrfValidateRequest()
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle invalid CSRF
|
||||
*/
|
||||
* Handle invalid CSRF
|
||||
*/
|
||||
function handleInvalidCSRFToken()
|
||||
{
|
||||
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)
|
||||
{
|
||||
return array_keys($arr) !== range(0, count($arr) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Display a selector field for a form. Arguments are:
|
||||
* @param string $name: Field name
|
||||
* @param array $options: Array of options
|
||||
* @param string $selected: Selected option (optional)
|
||||
* @param string $id: $options is an associative array this should be the key
|
||||
* @param string $event: onChange event (optional)
|
||||
* @param string $disabled (optional)
|
||||
*/
|
||||
* Display a selector field for a form. Arguments are:
|
||||
*
|
||||
* @param string $name: Field name
|
||||
* @param array $options: Array of options
|
||||
* @param string $selected: Selected option (optional)
|
||||
* @param string $id: $options is an associative array this should be the key
|
||||
* @param string $event: onChange event (optional)
|
||||
* @param string $disabled (optional)
|
||||
*/
|
||||
function SelectorOptions($name, $options, $selected = null, $id = null, $event = null, $disabled = null)
|
||||
{
|
||||
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 $string
|
||||
* @param int $offset
|
||||
* @param string $separator
|
||||
* @return $string
|
||||
*/
|
||||
*
|
||||
* @param string $input
|
||||
* @param string $string
|
||||
* @param int $offset
|
||||
* @param string $separator
|
||||
* @return $string
|
||||
*/
|
||||
function GetDistString($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
|
||||
* @return $config
|
||||
*/
|
||||
*
|
||||
* @param array $arrConfig
|
||||
* @return $config
|
||||
*/
|
||||
function ParseConfig($arrConfig)
|
||||
{
|
||||
$config = array();
|
||||
@@ -218,10 +214,10 @@ function ParseConfig($arrConfig)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $freq
|
||||
* @return $channel
|
||||
*/
|
||||
*
|
||||
* @param string $freq
|
||||
* @return $channel
|
||||
*/
|
||||
function ConvertToChannel($freq)
|
||||
{
|
||||
if ($freq >= 2412 && $freq <= 2484) {
|
||||
@@ -241,10 +237,11 @@ function ConvertToChannel($freq)
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts WPA security string to readable format
|
||||
* @param string $security
|
||||
* @return string
|
||||
*/
|
||||
* Converts WPA security string to readable format
|
||||
*
|
||||
* @param string $security
|
||||
* @return string
|
||||
*/
|
||||
function ConvertToSecurity($security)
|
||||
{
|
||||
$options = array();
|
||||
|
@@ -1,17 +1,17 @@
|
||||
<?php
|
||||
|
||||
include_once('includes/status_messages.php');
|
||||
include_once('app/lib/system.php');
|
||||
require_once 'includes/status_messages.php';
|
||||
require_once 'app/lib/system.php';
|
||||
require_once 'config.php';
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
*
|
||||
*
|
||||
*/
|
||||
function DisplayHostAPDConfig()
|
||||
{
|
||||
$status = new StatusMessages();
|
||||
$system = new System();
|
||||
$system = new System();
|
||||
$arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini');
|
||||
$arrConfig = array();
|
||||
$arr80211Standard = [
|
||||
@@ -20,7 +20,7 @@ function DisplayHostAPDConfig()
|
||||
'g' => '802.11g - 2.4 GHz',
|
||||
'n' => '802.11n - 2.4 GHz',
|
||||
'ac' => '802.11.ac - 5 GHz'
|
||||
];
|
||||
];
|
||||
$arrSecurity = array(1 => 'WPA', 2 => 'WPA2', 3 => 'WPA+WPA2', 'none' => _("None"));
|
||||
$arrEncType = array('TKIP' => 'TKIP', 'CCMP' => 'CCMP', 'TKIP CCMP' => 'TKIP+CCMP');
|
||||
$managedModeEnabled = false;
|
||||
@@ -50,7 +50,7 @@ function DisplayHostAPDConfig()
|
||||
|
||||
exec('cat '. RASPI_HOSTAPD_CONFIG, $hostapdconfig);
|
||||
exec('iwgetid '. RASPI_WIFI_CLIENT_INTERFACE. ' -r', $wifiNetworkID);
|
||||
if ( !empty($wifiNetworkID[0])) {
|
||||
if (!empty($wifiNetworkID[0])) {
|
||||
$managedModeEnabled = true;
|
||||
}
|
||||
$hostapdstatus = $system->hostapdStatus();
|
||||
@@ -62,33 +62,36 @@ function DisplayHostAPDConfig()
|
||||
}
|
||||
|
||||
if ($hostapdconfigline[0] != "#") {
|
||||
$arrLine = explode("=", $hostapdconfigline) ;
|
||||
$arrLine = explode("=", $hostapdconfigline);
|
||||
$arrConfig[$arrLine[0]]=$arrLine[1];
|
||||
}
|
||||
};
|
||||
|
||||
echo renderTemplate("hostapd", compact(
|
||||
"status",
|
||||
"serviceStatus",
|
||||
"hostapdstatus",
|
||||
"managedModeEnabled",
|
||||
"interfaces",
|
||||
"arrConfig",
|
||||
"arr80211Standard",
|
||||
"selectedHwMode",
|
||||
"arrSecurity",
|
||||
"arrEncType",
|
||||
"arrHostapdConf"
|
||||
));
|
||||
echo renderTemplate(
|
||||
"hostapd", compact(
|
||||
"status",
|
||||
"serviceStatus",
|
||||
"hostapdstatus",
|
||||
"managedModeEnabled",
|
||||
"interfaces",
|
||||
"arrConfig",
|
||||
"arr80211Standard",
|
||||
"selectedHwMode",
|
||||
"arrSecurity",
|
||||
"arrEncType",
|
||||
"arrHostapdConf"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
||||
{
|
||||
// It should not be possible to send bad data for these fields so clearly
|
||||
// someone is up to something if they fail. Fail silently.
|
||||
if (!(array_key_exists($_POST['wpa'], $wpa_array) &&
|
||||
array_key_exists($_POST['wpa_pairwise'], $enc_types) &&
|
||||
array_key_exists($_POST['hw_mode'], $modes))) {
|
||||
if (!(array_key_exists($_POST['wpa'], $wpa_array)
|
||||
&& array_key_exists($_POST['wpa_pairwise'], $enc_types)
|
||||
&& 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
|
||||
return false;
|
||||
}
|
||||
@@ -147,8 +150,9 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
||||
$good_input = false;
|
||||
}
|
||||
|
||||
if ($_POST['wpa'] !== 'none' &&
|
||||
(strlen($_POST['wpa_passphrase']) < 8 || strlen($_POST['wpa_passphrase']) > 63)) {
|
||||
if ($_POST['wpa'] !== 'none'
|
||||
&& (strlen($_POST['wpa_passphrase']) < 8 || strlen($_POST['wpa_passphrase']) > 63)
|
||||
) {
|
||||
$status->addMessage('WPA passphrase must be between 8 and 63 characters', 'danger');
|
||||
$good_input = false;
|
||||
}
|
||||
|
@@ -1,77 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Sets locale information for i18n support
|
||||
*
|
||||
*/
|
||||
* Sets locale information for i18n support
|
||||
*/
|
||||
|
||||
/**
|
||||
* Rudimentary language detection via the browser.
|
||||
* 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
|
||||
* the languages supported by our platform.
|
||||
*
|
||||
* Refer to: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
|
||||
* Rudimentary language detection via the browser.
|
||||
* 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
|
||||
* the languages supported by our platform.
|
||||
*
|
||||
* Refer to: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
|
||||
*/
|
||||
if (empty($_SESSION['locale']) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) >= 2) {
|
||||
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
|
||||
switch ($lang) {
|
||||
case "de":
|
||||
$locale = "de_DE.UTF-8";
|
||||
break;
|
||||
case "fr":
|
||||
$locale = "fr_FR.UTF-8";
|
||||
break;
|
||||
case "it":
|
||||
$locale = "it_IT.UTF-8";
|
||||
break;
|
||||
case "pt":
|
||||
$locale = "pt_BR.UTF-8";
|
||||
break;
|
||||
case "sv":
|
||||
$locale = "sv_SE.UTF-8";
|
||||
break;
|
||||
case "nl":
|
||||
$locale = "nl_NL.UTF-8";
|
||||
break;
|
||||
case "zh":
|
||||
$locale = "zh_CN.UTF-8";
|
||||
break;
|
||||
case "cs":
|
||||
$locale = "cs_CZ.UTF-8";
|
||||
break;
|
||||
case "ru":
|
||||
$locale = "ru_RU.UTF-8";
|
||||
break;
|
||||
case "es":
|
||||
$locale = "es_MX.UTF-8";
|
||||
break;
|
||||
case "fi":
|
||||
$locale = "fi_FI.UTF-8";
|
||||
break;
|
||||
case "si":
|
||||
$locale = "si_LK.UTF-8";
|
||||
break;
|
||||
case "tr":
|
||||
$locale = "tr_TR.UTF-8";
|
||||
break;
|
||||
case "id":
|
||||
$locale = "id_ID.UTF-8";
|
||||
break;
|
||||
case "ko":
|
||||
$locale = "ko_KR.UTF-8";
|
||||
break;
|
||||
case "ja":
|
||||
$locale = "ja_JP.UTF-8";
|
||||
break;
|
||||
case "vi":
|
||||
$locale = "vi_VN.UTF-8";
|
||||
break;
|
||||
case "el":
|
||||
$locale = "el_GR.UTF-8";
|
||||
break;
|
||||
default:
|
||||
$locale = "en_GB.UTF-8";
|
||||
break;
|
||||
case "de":
|
||||
$locale = "de_DE.UTF-8";
|
||||
break;
|
||||
case "fr":
|
||||
$locale = "fr_FR.UTF-8";
|
||||
break;
|
||||
case "it":
|
||||
$locale = "it_IT.UTF-8";
|
||||
break;
|
||||
case "pt":
|
||||
$locale = "pt_BR.UTF-8";
|
||||
break;
|
||||
case "sv":
|
||||
$locale = "sv_SE.UTF-8";
|
||||
break;
|
||||
case "nl":
|
||||
$locale = "nl_NL.UTF-8";
|
||||
break;
|
||||
case "zh":
|
||||
$locale = "zh_CN.UTF-8";
|
||||
break;
|
||||
case "cs":
|
||||
$locale = "cs_CZ.UTF-8";
|
||||
break;
|
||||
case "ru":
|
||||
$locale = "ru_RU.UTF-8";
|
||||
break;
|
||||
case "es":
|
||||
$locale = "es_MX.UTF-8";
|
||||
break;
|
||||
case "fi":
|
||||
$locale = "fi_FI.UTF-8";
|
||||
break;
|
||||
case "si":
|
||||
$locale = "si_LK.UTF-8";
|
||||
break;
|
||||
case "tr":
|
||||
$locale = "tr_TR.UTF-8";
|
||||
break;
|
||||
case "id":
|
||||
$locale = "id_ID.UTF-8";
|
||||
break;
|
||||
case "ko":
|
||||
$locale = "ko_KR.UTF-8";
|
||||
break;
|
||||
case "ja":
|
||||
$locale = "ja_JP.UTF-8";
|
||||
break;
|
||||
case "vi":
|
||||
$locale = "vi_VN.UTF-8";
|
||||
break;
|
||||
case "el":
|
||||
$locale = "el_GR.UTF-8";
|
||||
break;
|
||||
default:
|
||||
$locale = "en_GB.UTF-8";
|
||||
break;
|
||||
}
|
||||
|
||||
$_SESSION['locale'] = $locale;
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
include_once('includes/status_messages.php');
|
||||
require_once 'includes/status_messages.php';
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
*
|
||||
*
|
||||
*/
|
||||
function DisplayNetworkingConfig()
|
||||
{
|
||||
|
||||
|
@@ -1,12 +1,10 @@
|
||||
<?php
|
||||
|
||||
include_once('includes/status_messages.php');
|
||||
require_once 'includes/status_messages.php';
|
||||
require_once 'config.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* Manage OpenVPN configuration
|
||||
*
|
||||
*/
|
||||
function DisplayOpenVPNConfig()
|
||||
{
|
||||
@@ -48,26 +46,27 @@ function DisplayOpenVPNConfig()
|
||||
$authPassword = $auth[1];
|
||||
}
|
||||
|
||||
echo renderTemplate("openvpn", compact(
|
||||
"status",
|
||||
"serviceStatus",
|
||||
"openvpnstatus",
|
||||
"public_ip",
|
||||
"authUser",
|
||||
"authPassword"
|
||||
));
|
||||
echo renderTemplate(
|
||||
"openvpn", compact(
|
||||
"status",
|
||||
"serviceStatus",
|
||||
"openvpnstatus",
|
||||
"public_ip",
|
||||
"authUser",
|
||||
"authPassword"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Validates uploaded .ovpn file, adds auth-user-pass and
|
||||
* stores auth credentials in login.conf. Copies files from
|
||||
* tmp to OpenVPN
|
||||
*
|
||||
* @param object $status
|
||||
* @param object $file
|
||||
* @param string $authUser
|
||||
* @param string $authPassword
|
||||
* @param object $status
|
||||
* @param object $file
|
||||
* @param string $authUser
|
||||
* @param string $authPassword
|
||||
* @return object $status
|
||||
*/
|
||||
function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
|
||||
@@ -84,15 +83,15 @@ function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
|
||||
|
||||
// Parse returned errors
|
||||
switch ($file['error']) {
|
||||
case UPLOAD_ERR_OK:
|
||||
break;
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
throw new RuntimeException('OpenVPN configuration file not sent');
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
throw new RuntimeException('Exceeded filesize limit');
|
||||
default:
|
||||
throw new RuntimeException('Unknown errors');
|
||||
case UPLOAD_ERR_OK:
|
||||
break;
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
throw new RuntimeException('OpenVPN configuration file not sent');
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
throw new RuntimeException('Exceeded filesize limit');
|
||||
default:
|
||||
throw new RuntimeException('Unknown errors');
|
||||
}
|
||||
|
||||
// Validate extension
|
||||
@@ -109,7 +108,8 @@ function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
|
||||
'ovpn' => 'text/plain'
|
||||
),
|
||||
true
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
throw new RuntimeException('Invalid file format');
|
||||
}
|
||||
|
||||
@@ -127,7 +127,8 @@ function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
|
||||
'ovpnclient',
|
||||
$ext
|
||||
)
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
throw new RuntimeException('Unable to move uploaded file');
|
||||
}
|
||||
// Good file upload, update auth credentials if present
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
include_once('app/lib/system.php');
|
||||
require_once 'app/lib/system.php';
|
||||
|
||||
$system = new System();
|
||||
|
||||
|
@@ -1,13 +1,11 @@
|
||||
<?php
|
||||
|
||||
include_once('includes/status_messages.php');
|
||||
require_once 'includes/status_messages.php';
|
||||
require_once 'config.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* Find the version of the Raspberry Pi
|
||||
* Currently only used for the system information page but may useful elsewhere
|
||||
*
|
||||
*/
|
||||
|
||||
function RPiVersion()
|
||||
@@ -98,7 +96,7 @@ function DisplaySystem()
|
||||
}
|
||||
|
||||
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('cat '. RASPI_LIGHTTPD_CONFIG, $return);
|
||||
|
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
*
|
||||
*
|
||||
*/
|
||||
function DisplayThemeConfig()
|
||||
{
|
||||
$themes = [
|
||||
|
@@ -1,12 +1,10 @@
|
||||
<?php
|
||||
|
||||
include_once('includes/status_messages.php');
|
||||
require_once 'includes/status_messages.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* Manage Tor Proxy configuration
|
||||
*
|
||||
*/
|
||||
* Manage Tor Proxy configuration
|
||||
*/
|
||||
function DisplayTorProxyConfig()
|
||||
{
|
||||
|
||||
@@ -16,21 +14,23 @@ function DisplayTorProxyConfig()
|
||||
$arrConfig = array();
|
||||
foreach ($return as $a) {
|
||||
if ($a[0] != "#") {
|
||||
$arrLine = explode(" ", $a) ;
|
||||
$arrLine = explode(" ", $a);
|
||||
$arrConfig[$arrLine[0]]=$arrLine[1];
|
||||
}
|
||||
}
|
||||
|
||||
echo renderTemplate("torproxy", compact(
|
||||
"status",
|
||||
"torproxystatus"
|
||||
));
|
||||
echo renderTemplate(
|
||||
"torproxy", compact(
|
||||
"status",
|
||||
"torproxystatus"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
*
|
||||
*
|
||||
*/
|
||||
function SaveTORAndVPNConfig()
|
||||
{
|
||||
if (isset($_POST['SaveTORProxySettings'])) {
|
||||
|
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
include_once('functions.php');
|
||||
require_once 'functions.php';
|
||||
|
||||
function knownWifiStations(&$networks)
|
||||
{
|
||||
@@ -16,26 +16,26 @@ function knownWifiStations(&$networks)
|
||||
$ssid = null;
|
||||
} elseif ($lineArr = preg_split('/\s*=\s*/', trim($line))) {
|
||||
switch (strtolower($lineArr[0])) {
|
||||
case 'ssid':
|
||||
$ssid = trim($lineArr[1], '"');
|
||||
break;
|
||||
case 'psk':
|
||||
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], '"');
|
||||
case 'ssid':
|
||||
$ssid = trim($lineArr[1], '"');
|
||||
break;
|
||||
case 'psk':
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,15 +51,17 @@ function nearbyWifiStations(&$networks, $cached = true)
|
||||
deleteCache($cacheKey);
|
||||
}
|
||||
|
||||
$scan_results = cache($cacheKey, function () {
|
||||
exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan');
|
||||
sleep(3);
|
||||
$scan_results = cache(
|
||||
$cacheKey, function () {
|
||||
exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan');
|
||||
sleep(3);
|
||||
|
||||
exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan_results', $stdout);
|
||||
array_shift($stdout);
|
||||
exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan_results', $stdout);
|
||||
array_shift($stdout);
|
||||
|
||||
return implode("\n", $stdout);
|
||||
});
|
||||
return implode("\n", $stdout);
|
||||
}
|
||||
);
|
||||
|
||||
foreach (explode("\n", $scan_results) as $network) {
|
||||
$arrNetwork = preg_split("/[\t]+/", $network); // split result into array
|
||||
|
Reference in New Issue
Block a user