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

Merge First Edition of RaspAP/raspap-insiders

This commit is contained in:
billz 2021-11-25 09:02:59 +00:00
parent bf5de0a81d
commit 2ca5f25dff
15 changed files with 177 additions and 379 deletions

View File

@ -378,7 +378,7 @@ tspan, rect {
fill: #d2d2d2;
}
text-muted {
.text-muted {
font-size: 0.8rem;
}

View File

@ -10,12 +10,25 @@ if (!isset($_SERVER['HTTP_REFERER'])) {
exit;
}
function qr_encode($str)
{
return preg_replace('/(?<!\\\)([\":;,])/', '\\\\\1', $str);
}
$hostapd = parse_ini_file(RASPI_HOSTAPD_CONFIG, false, INI_SCANNER_RAW);
// assume wpa encryption and get the passphrase
$type = "WPA";
$password = isset($hostapd['wpa_psk']) ? $hostapd['wpa_psk'] : $hostapd['wpa_passphrase'];
// use wep if configured
$wep_default_key = intval($hostapd['wep_default_key']);
$wep_key = 'wep_key' . $wep_default_key;
if (array_key_exists($wep_key, $hostapd)) {
$type = "WEP";
$password = $hostapd[$wep_key];
}
// if password is still empty, assume nopass
if (empty($password)) {
$type = "nopass";

View File

@ -1,6 +1,5 @@
function msgShow(retcode,msg) {
if(retcode == 0) {
var alertType = 'success';
if(retcode == 0) { var alertType = 'success';
} else if(retcode == 2 || retcode == 1) {
var alertType = 'danger';
}
@ -138,8 +137,7 @@ function setupBtns() {
$('#btnSummaryRefresh').click(function(){getAllInterfaces();});
$('.intsave').click(function(){
var int = $(this).data('int');
var opts = $(this).data('opts');
saveNetDeviceSettings(int,opts);
saveNetworkSettings(int);
});
$('.intapply').click(function(){
applyNetworkSettings();
@ -182,24 +180,6 @@ function loadWifiStations(refresh) {
}
$(".js-reload-wifi-stations").on("click", loadWifiStations(true));
function saveNetDeviceSettings(int,opts="") {
var frmInt = $('#frm-'+int).find(':input');
var arrFormData = {};
$.each(frmInt,function(i3,v3){
if($(v3).attr('type') == 'radio') {
arrFormData[$(v3).attr('id')] = $(v3).prop('checked');
} else {
arrFormData[$(v3).attr('id')] = $(v3).val();
}
});
arrFormData['interface'] = int;
arrFormData['opts'] = opts;
$.post('ajax/networking/save_net_dev_config.php',arrFormData,function(data){
var jsonData = JSON.parse(data);
$('#msgNetworking').html(msgShow(jsonData['return'],jsonData['output']));
});
}
/*
Populates the DHCP server form fields
Option toggles are set dynamically depending on the loaded configuration

View File

@ -24,15 +24,10 @@ define('RASPI_OPENVPN_CLIENT_CONFIG', '/etc/openvpn/client/client.conf');
define('RASPI_OPENVPN_CLIENT_LOGIN', '/etc/openvpn/client/login.conf');
define('RASPI_WIREGUARD_PATH', '/etc/wireguard/');
define('RASPI_WIREGUARD_CONFIG', RASPI_WIREGUARD_PATH.'wg0.conf');
define('RASPI_FIREWALL_CONF', RASPI_CONFIG.'/networking/firewall/firewall.conf');
define('RASPI_IPTABLES_CONF', RASPI_CONFIG.'/networking/firewall/iptables_rules.json');
define('RASPI_TORPROXY_CONFIG', '/etc/tor/torrc');
define('RASPI_LIGHTTPD_CONFIG', '/etc/lighttpd/lighttpd.conf');
define('RASPI_ACCESS_CHECK_IP', '1.1.1.1');
define('RASPI_ACCESS_CHECK_DNS', 'one.one.one.one');
define('RASPI_CLIENT_CONFIG_PATH', RASPI_CONFIG.'/networking/client_udev_prototypes.json');
define('RASPI_MOBILEDATA_CONFIG', RASPI_CONFIG.'/networking/mobiledata.ini');
define('RASPI_CLIENT_SCRIPT_PATH', '/usr/local/sbin');
// Constant for the 5GHz wireless regulatory domain
define('RASPI_5GHZ_ISO_ALPHA2', array('NL','US'));
@ -46,7 +41,6 @@ define('RASPI_DHCP_ENABLED', true);
define('RASPI_ADBLOCK_ENABLED', false);
define('RASPI_OPENVPN_ENABLED', false);
define('RASPI_WIREGUARD_ENABLED', false);
define('RASPI_FIREWALL_ENABLED', true);
define('RASPI_TORPROXY_ENABLED', false);
define('RASPI_CONFAUTH_ENABLED', true);
define('RASPI_CHANGETHEME_ENABLED', true);

View File

@ -78,7 +78,7 @@ function DisplayAdBlockConfig()
$adblock_custom_content = file_get_contents(RASPI_ADBLOCK_LISTPATH .'custom.txt');
$adblock_log = '';
exec('sudo chmod o+r '.RASPI_DHCPCD_LOG);
exec('sudo chmod o+r '. RASPI_DHCPCD_LOG);
$handle = fopen("/tmp/dnsmasq.log", "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {

View File

@ -3,7 +3,6 @@
require_once 'includes/config.php';
require_once 'includes/wifi_functions.php';
require_once 'includes/functions.php';
require_once 'includes/get_clients.php';
/**
* Show dashboard page.
@ -24,27 +23,6 @@ function DisplayDashboard(&$extraFooterScripts)
$status->showMessages();
return;
}
// ------------------------- Button pressed to switch client on/off ---------------------------------------------------------
$switchedOn = false;
if (!RASPI_MONITOR_ENABLED) {
if (isset($_POST['ifdown_wlan0'])) {
// Pressed stop button
$status->addMessage(sprintf(_('Interface is going %s.'), _('down')), 'warning');
setClientState("down");
$status->addMessage(sprintf(_('Interface is now %s.'), _('down')), 'success');
} elseif (isset($_POST['ifup_wlan0'])) {
// Pressed start button
$status->addMessage(sprintf(_('Interface is going %s.'), _('up')), 'warning');
setClientState("up");
$status->addMessage(sprintf(_('Interface is now %s.'), _('up')), 'success');
$switchedOn = true;
}
}
// ----------------------------- INFOS ABOUT THE ACCESS POINT -------------------------------------------------------------
exec('ip a show '.$_SESSION['ap_interface'], $stdoutIp);
$stdoutIpAllLinesGlued = implode(" ", $stdoutIp);
$stdoutIpWRepeatedSpaces = preg_replace('/\s\s+/', ' ', $stdoutIpAllLinesGlued);
@ -110,40 +88,103 @@ function DisplayDashboard(&$extraFooterScripts)
$strTxBytes .= getHumanReadableDatasize($strTxBytes);
}
// ------------------------ INFOS ABOUT THE CLIENT---------------------------------------------------------------
$clientinfo=array("name"=>"none","type"=>-1,"connected"=>"n");
$raspi_client=$_SESSION['wifi_client_interface'];
loadClientConfig();
$all_clients = getClients(false);
$clientinfo = array("name" => "none", "connected" => "n");
if ( ($idx = findCurrentClientIndex($all_clients)) >= 0) $clientinfo = $all_clients["device"][$idx];
if ($clientinfo["name"] != "none") $raspi_client = $clientinfo["name"];
$interfaceState = $clientinfo["connected"] == "y" ? 'UP' : 'DOWN';
$txPower="";
if ($clientinfo["type"] == "wlan") {
// txpower is now displayed on iw dev(..) info command, not on link command.
exec('iw dev '.$clientinfo["name"].' info | sed -rn "s/.*txpower ([0-9]*)[0-9\.]*( dBm).*/\1\2/p"', $stdoutIwInfo);
if (!empty($stdoutIwInfo)) $txPower=$stdoutIwInfo[0];
define('SSIDMAXLEN', 32);
// Warning iw comes with: "Do NOT screenscrape this tool, we don't consider its output stable."
exec('iw dev ' .$_SESSION['wifi_client_interface']. ' link ', $stdoutIw);
$stdoutIwAllLinesGlued = implode('+', $stdoutIw); // Break lines with character illegal in SSID and MAC addr
$stdoutIwWRepSpaces = preg_replace('/\s\s+/', ' ', $stdoutIwAllLinesGlued);
preg_match('/Connected to (([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2}))/', $stdoutIwWRepSpaces, $matchesBSSID) || $matchesBSSID[1] = '';
$connectedBSSID = $matchesBSSID[1];
$connectedBSSID = empty($connectedBSSID) ? "-" : $connectedBSSID;
$wlanHasLink = false;
if ($interfaceState === 'UP') {
$wlanHasLink = true;
}
if (!preg_match('/SSID: ([^+]{1,'.SSIDMAXLEN.'})/', $stdoutIwWRepSpaces, $matchesSSID)) {
$wlanHasLink = false;
$matchesSSID[1] = 'None';
}
$connectedSSID = $matchesSSID[1];
preg_match('/freq: (\d+)/i', $stdoutIwWRepSpaces, $matchesFrequency) || $matchesFrequency[1] = '';
$frequency = $matchesFrequency[1].' MHz';
preg_match('/signal: (-?[0-9]+ dBm)/i', $stdoutIwWRepSpaces, $matchesSignal) || $matchesSignal[1] = '';
$signalLevel = $matchesSignal[1];
$signalLevel = empty($signalLevel) ? "-" : $signalLevel;
preg_match('/tx bitrate: ([0-9\.]+ [KMGT]?Bit\/s)/', $stdoutIwWRepSpaces, $matchesBitrate) || $matchesBitrate[1] = '';
$bitrate = $matchesBitrate[1];
$bitrate = empty($bitrate) ? "-" : $bitrate;
// txpower is now displayed on iw dev(..) info command, not on link command.
exec('iw dev '.$_SESSION['wifi_client_interface'].' info ', $stdoutIwInfo);
$stdoutIwInfoAllLinesGlued = implode(' ', $stdoutIwInfo);
$stdoutIpInfoWRepSpaces = preg_replace('/\s\s+/', ' ', $stdoutIwInfoAllLinesGlued);
preg_match('/txpower ([0-9\.]+ dBm)/i', $stdoutIpInfoWRepSpaces, $matchesTxPower) || $matchesTxPower[1] = '';
$txPower = $matchesTxPower[1];
// iw does not have the "Link Quality". This is a is an aggregate value,
// and depends on the driver and hardware.
// Display link quality as signal quality for now.
$strLinkQuality = 0;
if ($signalLevel > -100 && $wlanHasLink) {
if ($signalLevel >= 0) {
$strLinkQuality = 100;
} else {
$strLinkQuality = 100 + intval($signalLevel);
}
}
$wlan0up = false;
$classMsgDevicestatus = 'warning';
if ($interfaceState === 'UP') {
$wlan0up = true;
$classMsgDevicestatus = 'success';
}
if ($switchedOn) exec('sudo ip -s a f label ' . $raspi_client);
if (!RASPI_MONITOR_ENABLED) {
if (isset($_POST['ifdown_wlan0'])) {
// Pressed stop button
if ($interfaceState === 'UP') {
$status->addMessage(sprintf(_('Interface is going %s.'), _('down')), 'warning');
exec('sudo ip link set '.$_SESSION['wifi_client_interface'].' down');
$wlan0up = false;
$status->addMessage(sprintf(_('Interface is now %s.'), _('down')), 'success');
} elseif ($interfaceState === 'unknown') {
$status->addMessage(_('Interface state unknown.'), 'danger');
} else {
$status->addMessage(sprintf(_('Interface already %s.'), _('down')), 'warning');
}
} elseif (isset($_POST['ifup_wlan0'])) {
// Pressed start button
if ($interfaceState === 'DOWN') {
$status->addMessage(sprintf(_('Interface is going %s.'), _('up')), 'warning');
exec('sudo ip link set ' .$_SESSION['wifi_client_interface']. ' up');
exec('sudo ip -s a f label ' . $_SESSION['wifi_client_interface']);
$wlan0up = true;
$status->addMessage(sprintf(_('Interface is now %s.'), _('up')), 'success');
} elseif ($interfaceState === 'unknown') {
$status->addMessage(_('Interface state unknown.'), 'danger');
} else {
$status->addMessage(sprintf(_('Interface already %s.'), _('up')), 'warning');
}
} else {
$status->addMessage(sprintf(_('Interface is %s.'), strtolower($interfaceState)), $classMsgDevicestatus);
}
}
// brought in from template
$arrHostapdConf = parse_ini_file(RASPI_CONFIG.'/hostapd.ini');
$bridgedEnable = $arrHostapdConf['BridgedEnable'];
if ($arrHostapdConf['WifiAPEnable'] == 1) {
$client_interface = 'uap0';
} else {
$client_interface = $clientinfo["name"];
}
$clientInterface = $_SESSION['wifi_client_interface'];
$apInterface = $_SESSION['ap_interface'];
$clientInterface = $raspi_client;
$MACPattern = '"([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}"';
if (getBridgedState()) {
$moreLink = "hostapd_conf";
exec('iw dev ' . $apInterface . ' station dump | grep -oE ' . $MACPattern, $clients);
@ -151,39 +192,11 @@ function DisplayDashboard(&$extraFooterScripts)
$moreLink = "dhcpd_conf";
exec('cat ' . RASPI_DNSMASQ_LEASES . '| grep -E $(iw dev ' . $apInterface . ' station dump | grep -oE ' . $MACPattern . ' | paste -sd "|")', $clients);
}
$ifaceStatus = $clientinfo["connected"]=="y" ? "up" : "down";
$isClientConfigured = true;
switch($clientinfo["type"]) {
case "eth":
case "usb":
$client_title = "Client: Ethernet cable";
$type_name = "Ethernet";
break;
case "phone":
$client_title = "Client: Smartphone (USB tethering)";
$type_name = "Smartphone";
break;
case "wlan":
$client_title = "Wireless Client";
$type_name = "Wifi";
break;
case "ppp":
case "hilink":
$client_title = "Mobile Data Client";
$type_name = "Mobile Data";
break;
default:
$client_title = "No information available";
$type_name = "Not configured";
$ifaceStatus = "warn";
$isClientConfigured = false;
}
$ifaceStatus = $wlan0up ? "up" : "down";
echo renderTemplate(
"dashboard", compact(
"clients",
"client_title",
"type_name",
"moreLink",
"apInterface",
"clientInterface",
@ -198,9 +211,14 @@ function DisplayDashboard(&$extraFooterScripts)
"strRxBytes",
"strTxPackets",
"strTxBytes",
"connectedSSID",
"connectedBSSID",
"bitrate",
"signalLevel",
"txPower",
"clientinfo",
"isClientConfigured"
"frequency",
"strLinkQuality",
"wlan0up"
)
);
$extraFooterScripts[] = array('src'=>'app/js/dashboardchart.js', 'defer'=>false);

View File

@ -6,7 +6,7 @@ if (!defined('RASPI_CONFIG')) {
$defaults = [
'RASPI_BRAND_TEXT' => 'RaspAP',
'RASPI_VERSION' => '2.8.0',
'RASPI_VERSION' => '2.7.1',
'RASPI_CONFIG_NETWORK' => RASPI_CONFIG.'/networking/defaults.json',
'RASPI_ADMIN_DETAILS' => RASPI_CONFIG.'/raspap.auth',
'RASPI_WIFI_AP_INTERFACE' => 'wlan0',

View File

@ -180,9 +180,7 @@ function compareIPs($ip1, $ip2)
function updateDnsmasqConfig($iface,$status)
{
$config = '# RaspAP '.$iface.' configuration'.PHP_EOL;
$config .= 'interface='.$iface.PHP_EOL.
'dhcp-range='.$_POST['RangeStart'].','.$_POST['RangeEnd'].
',255.255.255.0,';
$config .= 'interface='.$iface.PHP_EOL.'dhcp-range='.$_POST['RangeStart'].','.$_POST['RangeEnd'].','.$_POST['SubnetMask'].',';
if ($_POST['RangeLeaseTimeUnits'] !== 'infinite') {
$config .= $_POST['RangeLeaseTime'];
}

View File

@ -757,8 +757,12 @@ function qr_encode($str)
return preg_replace('/(?<!\\\)([\":;,])/', '\\\\\1', $str);
}
function evalHexSequence($string)
{
// Validates a host or FQDN
function validate_host($host) {
return preg_match('/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i', $host);
}
function evalHexSequence($string) {
$evaluator = function ($input) {
return hex2bin($input[1]);
};

View File

@ -2,8 +2,6 @@
require_once 'includes/status_messages.php';
require_once 'includes/internetRoute.php';
require_once 'includes/functions.php';
require_once 'includes/get_clients.php';
/**
*
@ -19,18 +17,10 @@ function DisplayNetworkingConfig()
$arrHostapdConf = parse_ini_file(RASPI_CONFIG.'/hostapd.ini');
$bridgedEnabled = $arrHostapdConf['BridgedEnable'];
foreach ($interfaces as $interface) {
exec("ip a show $interface", $$interface);
}
loadClientConfig();
$clients=getClients();
echo renderTemplate("networking", compact(
"status",
"interfaces",
"routeInfo",
"bridgedEnabled",
"clients")
"bridgedEnabled")
);
}
?>

View File

@ -14,8 +14,8 @@
* @author Lawrence Yau <sirlagz@gmail.com>
* @author Bill Zimmerman <billzimmerman@gmail.com>
* @license GNU General Public License, version 3 (GPL-3.0)
* @version 2.8.0
* @link https://github.com/raspap/raspap-insiders/
* @version 2.7.1
* @link https://github.com/raspap/raspap-webgui/
* @link https://raspap.com/
* @see http://sirlagz.net/2013/02/08/raspap-webgui/
*
@ -41,7 +41,6 @@ require_once 'includes/system.php';
require_once 'includes/sysstats.php';
require_once 'includes/configure_client.php';
require_once 'includes/networking.php';
require_once 'includes/firewall.php';
require_once 'includes/themes.php';
require_once 'includes/data_usage.php';
require_once 'includes/about.php';
@ -176,11 +175,6 @@ $bridgedEnabled = getBridgedState();
<?php if (RASPI_TORPROXY_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="torproxy_conf"><i class="fas fa-eye-slash fa-fw mr-2"></i><span class="nav-label"><?php echo _("TOR proxy"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_FIREWALL_ENABLED) : ?>
<li class="nav-item">
<a class="nav-link" href="firewall_conf"><i class="fas fa-shield-alt fa-fw mr-2"></i><span class="nav-label"><?php echo _("Firewall"); ?></a>
</li>
<?php endif; ?>
<?php if (RASPI_CONFAUTH_ENABLED) : ?>
@ -280,8 +274,8 @@ $bridgedEnabled = getBridgedState();
case "/torproxy_conf":
DisplayTorProxyConfig();
break;
case "/firewall_conf":
DisplayFirewallConfig();
case "/torproxy_conf":
DisplayTorProxyConfig();
break;
case "/auth_conf":
DisplayAuthConfig($config['admin_user'], $config['admin_pass']);

View File

@ -142,7 +142,7 @@ function _set_php_package() {
18.04|19.10|11*) # Ubuntu Server & Debian 11
php_package="php7.4-cgi"
phpcgiconf="/etc/php/7.4/cgi/php.ini" ;;
10*)
10*|11*)
php_package="php7.3-cgi"
phpcgiconf="/etc/php/7.3/cgi/php.ini" ;;
9*)

View File

@ -62,9 +62,4 @@ www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wireguard/*.conf
www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wireguard/wg-*.key
www-data ALL=(ALL) NOPASSWD:/bin/rm /etc/wireguard/*.conf
www-data ALL=(ALL) NOPASSWD:/bin/rm /etc/wireguard/wg-*.key
www-data ALL=(ALL) NOPASSWD:/tmp/iptables_raspap.sh
www-data ALL=(ALL) NOPASSWD:/tmp/ip6tables_raspap.sh
www-data ALL=(ALL) NOPASSWD:/usr/sbin/iptables-save
www-data ALL=(ALL) NOPASSWD:/usr/sbin/ip6tables-save
www-data ALL=(ALL) NOPASSWD:/usr/bin/tee /etc/iptables/rules.v4
www-data ALL=(ALL) NOPASSWD:/usr/bin/tee /etc/iptables/rules.v6

View File

@ -9,11 +9,12 @@
<div class="col">
<button class="btn btn-light btn-icon-split btn-sm service-status float-right">
<span class="icon"><i class="fas fa-circle service-status-<?php echo $ifaceStatus ?>"></i></span>
<span class="text service-status"><?php echo $type_name; if ( $isClientConfigured ) echo ' '. _($ifaceStatus); ?></span>
<span class="text service-status"><?php echo strtolower($apInterface) .' '. _($ifaceStatus) ?></span>
</button>
</div>
</div><!-- /.row -->
</div><!-- /.card-header -->
<div class="card-body">
<div class="row">
@ -32,97 +33,37 @@
<div class="col-sm-6 align-items-stretch">
<div class="card h-100">
<div class="card-body wireless">
<h4 class="card-title"><?php echo _("$client_title"); ?></h4>
<h4 class="card-title"><?php echo _("Wireless Client"); ?></h4>
<div class="row ml-1">
<div class="col-sm">
<?php $valEcho=function($cl,$id) {$val = isset($cl[$id])&& !empty($cl[$id]) ? $cl[$id] : "-"; echo htmlspecialchars($val,ENT_QUOTES);} ?>
<?php if ($clientinfo["type"] == "wlan") : // WIRELESS ?>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Connected To"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"ssidutf8"); ?></div>
<div class="info-item col-xs-3"><?php echo _("Connected To"); ?></div><div class="info-value col-xs-3"><?php echo htmlspecialchars($connectedSSID, ENT_QUOTES); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("AP Mac Address"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"ap-mac"); ?></div>
<div class="info-item col-xs-3"><?php echo _("Interface"); ?></div><div class="info-value col-xs-3"><?php echo htmlspecialchars($clientInterface); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Bitrate"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"bitrate"); ?></div>
<div class="info-item col-xs-3"><?php echo _("AP Mac Address"); ?></div><div class="info-value col-xs-3"><?php echo htmlspecialchars($connectedBSSID, ENT_QUOTES); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Signal Level"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"signal"); ?></div>
<div class="info-item col-xs-3"><?php echo _("Bitrate"); ?></div><div class="info-value col-xs-3"><?php echo htmlspecialchars($bitrate, ENT_QUOTES); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Signal Level"); ?></div><div class="info-value col-xs-3"><?php echo htmlspecialchars($signalLevel, ENT_QUOTES); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Transmit Power"); ?></div><div class="info-value col-xs-3"><?php echo htmlspecialchars($txPower, ENT_QUOTES); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Frequency"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"freq"); ?></div>
<div class="info-item col-xs-3"><?php echo _("Frequency"); ?></div><div class="info-value col-xs-3"><?php echo htmlspecialchars($frequency, ENT_QUOTES); ?></div>
</div>
<?php elseif ($clientinfo["type"] == "phone" ) : // Smartphones (tethering over USB) ?>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Device"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"vendor")." ". $valEcho($clientinfo,"model"); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("IP Address"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"ipaddress"); ?></div>
</div>
<?php elseif ($clientinfo["type"] == "hilink" ) : // MOBILE DATA - ROUTER MODE (HILINK) ?>
<?php
exec('ip route list | sed -rn "s/default via (([0-9]{1,3}\.){3}[0-9]{1,3}).*dev '.$clientinfo["name"].'.*/\1/p"',$gw); // get gateway
$gw=empty($gw) ? "" : $gw[0];
?>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Device"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"model")." (Hilink)"; ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Connection mode"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"mode"); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Signal quality"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"signal"); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Network"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"operator"); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("WAN IP"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"wan_ip"); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Web-GUI"); ?></div><div class="info-value col-xs-3"><?php if(!empty($gw)) echo '<a href="http://'.$gw.'" >'.$gw."</a>"; ?></div>
</div>
<?php elseif ($clientinfo["type"] == "ppp" ) : // MOBILE DATA MODEM) ?>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Device"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"model"); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Connection mode"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"mode"); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Signal strength"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"signal"); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Network"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"operator"); ?></div>
</div>
<?php elseif ($clientinfo["type"] == "eth" ) : // ETHERNET ?>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("Device"); ?></div><div class="info-value col-xs-3"><?php $valEcho($clientinfo,"vendor")." ".$valEcho($clientinfo,"model"); ?></div>
</div>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("IP Address"); ?></div><div class="info-value col-xs-3"><?php echo $valEcho($clientinfo,"ipaddress"); ?></div>
</div>
<?php else : // NO CLIENT ?>
<div class="row mb-1">
<div class="info-item col-xs-3"><?php echo _("No Client device or not yet configured"); ?></div>
</div>
<?php endif; ?>
</div>
<?php if ($isClientConfigured) : ?>
<div class="col-md d-flex">
<?php
preg_match("/.*\((\s*\d*)\s*%\s*\)/",$clientinfo["signal"],$match);
$strLinkQuality=array_key_exists(1,$match) ? $match[1] : 0;
?>
<script>var linkQ = <?php echo json_encode($strLinkQuality); ?>;</script>
<div class="chart-container">
<canvas id="divChartLinkQ"></canvas>
</div>
</div>
<?php endif; ?>
</div><!--row-->
</div><!-- /.card-body -->
</div><!-- /.card -->
@ -152,7 +93,7 @@
<?php endif; ?>
<?php foreach (array_slice($clients,0, 2) as $client) : ?>
<tr>
<?php if ($bridgedEnable == 1): ?>
<?php if ($arrHostapdConf['BridgedEnable'] == 1): ?>
<td><?php echo htmlspecialchars($client, ENT_QUOTES) ?></td>
<?php else : ?>
<?php $props = explode(' ', $client) ?>
@ -176,41 +117,28 @@
</div><!-- /.card -->
</div><!-- /.col-md-6 -->
</div><!-- /.row -->
<div class="col-lg-12 mt-3">
<div class="row">
<form action="wlan0_info" method="POST">
<?php echo CSRFTokenFieldTag(); ?>
<?php echo CSRFTokenFieldTag() ?>
<?php if (!RASPI_MONITOR_ENABLED) : ?>
<?php if ($ifaceStatus == "down") : ?>
<input type="submit" class="btn btn-success" value="<?php echo _("Start").' '.$type_name ?>" name="ifup_wlan0" data-toggle="modal" data-target="#switchClientModal"/>
<?php elseif ($ifaceStatus == "up") : ?>
<input type="submit" class="btn btn-warning" value="<?php echo _("Stop").' '.$type_name ?>" name="ifdown_wlan0" data-toggle="modal" data-target="#switchClientModal"/>
<?php if (!$wlan0up) : ?>
<input type="submit" class="btn btn-success" value="<?php echo _("Start").' '.$clientInterface ?>" name="ifup_wlan0" />
<?php else : ?>
<input type="submit" class="btn btn-warning" value="<?php echo _("Stop").' '.$clientInterface ?>" name="ifdown_wlan0" />
<?php endif ?>
<?php endif ?>
<button type="button" onClick="window.location.reload();" class="btn btn-outline btn-primary"><i class="fas fa-sync-alt"></i> <?php echo _("Refresh") ?></button>
<button type="button" onClick="window.location.reload();" class="btn btn-outline btn-primary"><i class="fas fa-sync-alt"></i> <?php echo _("Refresh") ?></a>
</form>
</div>
</div>
</div><!-- /.card-body -->
<div class="card-footer"><?php echo _("Information provided by ip and iw and from system"); ?></div>
</div><!-- /.card -->
</div><!-- /.col-lg-12 -->
</div><!-- /.row -->
<!-- Modal -->
<div class="modal fade" id="switchClientModal" tabindex="-1" role="dialog" aria-labelledby="ModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title" id="ModalLabel">
<i class="fas fa-sync-alt mr-2"></i>
<?php if($ifaceStatus=="down") echo _("Waiting for the interface to start ..."); else echo _("Stop the Interface"); ?>
</div>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">&times;</span>
</div>
</div>
</div>
<script type="text/javascript"<?php //echo ' nonce="'.$csp_page_nonce.'"'; ?>>
// js translations:
var t = new Array();

View File

@ -1,6 +1,7 @@
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<div class="row">
<div class="col">
@ -8,14 +9,11 @@
</div>
</div><!-- ./row -->
</div><!-- ./card-header -->
<div class="card-body">
<div id="msgNetworking"></div>
<ul class="nav nav-tabs">
<li role="presentation" class="nav-item"><a class="nav-link active" href="#summary" aria-controls="summary" role="tab" data-toggle="tab"><?php echo _("Summary"); ?></a></li>
<?php if (!$bridgedEnabled) : // no interface details when bridged ?>
<li role="presentation" class="nav-item"><a class="nav-link" href="#netdevices" aria-controls="netdevices" role="tab" data-toggle="tab"><?php echo _("Network Devices"); ?></a></li>
<li role="presentation" class="nav-item"><a class="nav-link" href="#mobiledata" aria-controls="mobiledata" role="tab" data-toggle="tab"><?php echo _("Mobile Data Settings"); ?></a></li>
<?php endif ?>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="summary">
@ -77,120 +75,6 @@
<button type="button" onClick="window.location.reload();" class="btn btn-outline btn-primary"><i class="fas fa-sync-alt"></i> <?php echo _("Refresh") ?></a>
</div>
<?php $arrMD = file_exists(($f = RASPI_MOBILEDATA_CONFIG)) ? parse_ini_file($f) : false;
if ($arrMD==false) { $arrMD=[]; $arrMD["pin"]=$arrMD["apn"]=$arrMD["apn_user"]=$arrMD["apn_pw"]=$arrMD["router_user"]=$arrMD["router_pw"]=""; }
?>
<div role="tabpanel" class="tab-pane fade in" id="netdevices">
<h4 class="mt-3"><?php echo _("Properties of network devices") ?></h4>
<div class="row">
<div class="col-sm-12">
<div class="card ">
<div class="card-body">
<form id="frm-netdevices">
<?php echo CSRFTokenFieldTag() ?>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th><?php echo _("Device"); ?></th>
<th><?php echo _("Interface"); ?></th>
<th></th>
<th><?php echo _("MAC"); ?></th>
<th><?php echo _("USB vid/pid"); ?></th>
<th><?php echo _("Device type"); ?></th>
<th style="min-width:6em"><?php echo _("Fixed name"); ?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
if(!empty($clients)) {
$ncl=$clients["clients"];
if($ncl > 0) {
foreach($clients["device"] as $id => $dev) {
echo "<tr>";
echo "<td>".$dev["vendor"]." ".$dev["model"]."</td>\n";
echo "<td>".$dev["name"]."</td>\n";
$ty="Client";
if(isset($dev["isAP"]) && $dev["isAP"]) $ty="Access Point";
echo "<td>".$ty."</td>\n";
echo "<td>".$dev["mac"]."</td>\n";
if(isset($dev["vid"]) && !empty($dev["vid"])) echo "<td>".$dev["vid"]."/".$dev["pid"]."</td>\n";
else echo "<td> - </td>\n";
$udevfile=$_SESSION["udevrules"]["udev_rules_file"];
$isStatic=array();
exec('find /etc/udev/rules.d/ -type f \( -iname "*.rules" ! -iname "'.basename($udevfile).'" \) -exec grep -i '.$dev["mac"].' {} \; ',$isStatic);
if(empty($isStatic))
exec('find /etc/udev/rules.d/ -type f \( -iname "*.rules" ! -iname "'.basename($udevfile).'" \) -exec grep -i '.$dev["vid"].' {} \; | grep -i '.$dev["pid"].' ',$isStatic);
$isStatic = empty($isStatic) ? false : true;
$devname=array();
exec('grep -i '.$dev["vid"].' '.$udevfile.' | grep -i '.$dev["pid"].' | sed -rn \'s/.*name=\"(\w*)\".*/\1/ip\' ',$devname);
if(!empty($devname)) $devname=$devname[0];
else {
exec('grep -i '.$dev["mac"].' '.$udevfile.' | sed -rn \'s/.*name=\"(\w*)\".*/\1/ip\' ',$devname);
if(!empty($devname)) $devname=$devname[0];
}
if(empty($devname)) $devname="";
$isStatic = $isStatic || in_array($dev["type"],array("ppp","tun"));
$txtdisabled=$isStatic ? "disabled":"";
echo '<td><select '.$txtdisabled.' class="selectpicker form-control" id="int-new-type-'.$dev["name"].'">';
foreach($_SESSION["net-device-types"] as $i => $type) {
$txt=$_SESSION["net-device-types-info"][$i];
$txtdisabled = in_array($type,array("ppp","tun")) ? "disabled":"";
if(preg_match("/^".$_SESSION["net-device-name-prefix"][$i].".*$/",$dev["type"])===1) echo '<option '.$txtdisabled.' selected value="'.$type.'">'.$txt.'</option>';
else echo '<option '.$txtdisabled.' value="'.$type.'">'.$txt.'</option>';
}
echo "</select></td>";
echo '<td>';
if (! $isStatic ) echo '<input type="text" class="form-control" id="int-name-'.$dev["name"].'" value="'.$devname.'" >'."\n";
else echo $dev["name"];
echo '<input type="hidden" class="form-control" id="int-vid-'.$dev["name"].'" value="'.$dev["vid"].'" >'."\n";
echo '<input type="hidden" class="form-control" id="int-pid-'.$dev["name"].'" value="'.$dev["pid"].'" >'."\n";
echo '<input type="hidden" class="form-control" id="int-mac-'.$dev["name"].'" value="'.$dev["mac"].'" >'."\n";
echo '<input type="hidden" class="form-control" id="int-type-'.$dev["name"].'" value="'.$dev["type"].'" >'."\n";
echo '</td>'."\n";
echo '<td>';
if (! $isStatic) echo '<a href="#" class="btn btn-secondary intsave" data-opts="'.$dev["name"].'" data-int="netdevices">' ._("Change").'</a>';
echo "</td>\n";
echo "</tr>\n";
}
}
} else echo "<tr><td colspan=4>No network devices found</td></tr>";
?>
</tbody>
</table>
</div>
</form>
</div>
</div>
</div>
</div>
</div><!-- /.tab-panel -->
<div role="tabpanel" class="tab-pane fade in" id="mobiledata">
<div class="row">
<div class="col-lg-6">
<h4 class="mt-3"><?php echo _("Settings for Mobile Data Devices") ?></h4>
<hr />
<form id="frm-mobiledata">
<?php echo CSRFTokenFieldTag() ?>
<div class="form-group">
<label for="pin-mobile"><?php echo _("PIN of SIM card") ?></label>
<input type="number" class="form-control" id="pin-mobile" placeholder="1234" value="<?php echo $arrMD["pin"]?>" >
</div>
<h4 class="mt-3"><?php echo _("APN Settings (Modem device ppp0)") ?></h4>
<div class="form-group">
<label for="apn-mobile"><?php echo _("Access Point Name (APN)") ?></label>
<input type="text" class="form-control" id="apn-mobile" placeholder="web.myprovider.com" value="<?php echo $arrMD["apn"]?>" >
<label for="apn-user-mobile"><?php echo _("Username") ?></label>
<input type="text" class="form-control" id="apn-user-mobile" value="<?php echo $arrMD["apn_user"]?>" >
<label for="apn-pw-mobile"><?php echo _("Password") ?></label>
<input type="text" class="form-control" id="apn-pw-mobile" value="<?php echo $arrMD["apn_pw"]?>" >
</div>
<a href="#" class="btn btn-outline btn-primary intsave" data-int="mobiledata"><?php echo _("Save settings") ?></a>
</form>
</div>
</div>
</div><!-- /.tab-panel -->
</div>
</div><!-- /.card-body -->