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

205 lines
12 KiB
PHP
Raw Normal View History

2019-08-19 01:38:41 +02:00
<div class="row">
2019-08-19 01:51:26 +02:00
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<div class="row">
<div class="col">
<i class="fas fa-network-wired mr-2"></i><?php echo _("Networking"); ?>
</div>
</div><!-- ./row -->
</div><!-- ./card-header -->
2019-10-13 00:04:27 +02:00
<div class="card-body">
2019-08-19 01:38:41 +02:00
<div id="msgNetworking"></div>
2019-08-19 01:51:26 +02:00
<ul class="nav nav-tabs">
2019-10-14 22:57:29 +02:00
<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 ?>
2021-04-15 10:05:01 +02:00
<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 ?>
2019-08-19 01:51:26 +02:00
</ul>
<div class="tab-content">
2020-06-25 16:56:53 +02:00
<div role="tabpanel" class="tab-pane active" id="summary">
2020-06-25 16:00:41 +02:00
<h4 class="mt-3"><?php echo _("Internet connection"); ?></h4>
<div class="row">
<div class="col-sm-12">
2020-06-25 16:00:41 +02:00
<div class="card ">
<div class="card-body">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th><?php echo _("Interface"); ?></th>
<th><?php echo _("IP Address"); ?></th>
<th><?php echo _("Gateway"); ?></th>
<th colspan="2"><?php echo _("Internet Access"); ?></th>
</tr>
</thead>
<tbody>
<?php
if (isset($routeInfo["error"]) || empty($routeInfo)) {
2020-06-25 16:00:41 +02:00
echo "<tr><td colspan=5>No route to the internet found</td></tr>";
2020-06-28 18:12:42 +02:00
} else {
foreach($routeInfo as $route) {
2020-06-28 18:12:42 +02:00
echo "<tr>";
echo "<td>".$route["interface"]."</td>";
echo "<td>".$route["ip-address"]."</td>";
echo "<td>".$route["gateway"]."<br>".$route["gw-name"]."</td>";
2020-06-29 15:13:06 +02:00
$status = $route["access-ip"] ? "fa-check" : "fa-times";
echo '<td><i class="fas '.$status.'"></i><br>'.RASPI_ACCESS_CHECK_IP.'</td>';
$status = $route["access-dns"] ? "fa-check" : "fa-times";
echo '<td><i class="fas '.$status.'"></i><br>'.RASPI_ACCESS_CHECK_DNS.'</td>';
2020-06-28 18:12:42 +02:00
echo "</tr>";
}
}
2020-06-25 16:00:41 +02:00
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
2019-10-14 22:57:29 +02:00
<h4 class="mt-3"><?php echo _("Current settings") ?></h4>
2019-08-19 01:51:26 +02:00
<div class="row">
<?php if (!$bridgedEnabled) : // No interface details when bridged ?>
2019-08-19 01:51:26 +02:00
<?php foreach ($interfaces as $if): ?>
2020-06-28 18:12:42 +02:00
<?php $if_quoted = htmlspecialchars($if, ENT_QUOTES) ?>
2019-10-14 22:57:29 +02:00
<div class="col-md-6 mb-3">
2019-10-13 00:04:27 +02:00
<div class="card">
<div class="card-header"><?php echo $if_quoted ?></div>
<div class="card-body">
2019-08-19 01:51:26 +02:00
<pre class="unstyled" id="<?php echo $if_quoted ?>-summary"></pre>
</div>
</div>
</div>
<?php endforeach ?>
<?php endif ?>
2019-08-19 01:51:26 +02:00
</div><!-- /.row -->
<div class="col-lg-12">
<div class="row">
<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>
</div>
</div>
2021-05-21 14:57:14 +02:00
<?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";
2021-03-20 10:24:19 +01:00
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":"";
2021-03-27 20:34:35 +01:00
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>
2019-10-13 00:04:27 +02:00
</div><!-- /.card-body -->
<div class="card-footer"><?php echo _("Information provided by /sys/class/net"); ?></div>
</div><!-- /.card -->
2019-08-19 01:38:41 +02:00
</div><!-- /.col-lg-12 -->
</div><!-- /.row -->