Transfer template logic to includes, see #749 thx @mp035

This commit is contained in:
billz
2021-02-02 12:26:14 +00:00
parent 3d2d608477
commit b21ea0d28d
19 changed files with 216 additions and 193 deletions

View File

@@ -2,11 +2,7 @@
<div class="tab-pane fade" id="aboutsponsors">
<div class="row">
<div class="col-lg-12 mt-3">
<?php
$Parsedown = new Parsedown();
$strContent = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/BACKERS.md');
echo $Parsedown->text($strContent);
?>
<?php echo $sponsorsHtml; ?>
</div>
</div><!-- /.row -->
</div><!-- /.tab-pane | sponsors tab -->

View File

@@ -21,13 +21,7 @@
</div>
<div class="row">
<div class="form-group col-md-8">
<?php
$adblock_custom = file_get_contents(RASPI_ADBLOCK_LISTPATH .'custom.txt');
if (strlen($adblock_custom) == 0) {
$adblock_custom = _("Custom blocklist not defined");
}
echo '<textarea class="logoutput" name="adblock-custom-hosts">'.htmlspecialchars($adblock_custom, ENT_QUOTES).'</textarea>';
?>
<?php echo '<textarea class="logoutput" name="adblock-custom-hosts">'.htmlspecialchars($adblock_custom_content, ENT_QUOTES).'</textarea>'; ?>
</div>
</div>
</div><!-- /.tab-pane -->

View File

@@ -3,22 +3,7 @@
<h4 class="mt-3"><?php echo _("Logging"); ?></h4>
<div class="row">
<div class="form-group col-md-8">
<?php
$log = '';
exec('sudo chmod o+r /tmp/dnsmasq.log');
$handle = fopen("/tmp/dnsmasq.log", "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
if (preg_match('/(0.0.0.0)/', $line)){
$log.=$line;
}
}
} else {
$log = "Unable to open log file";
}
fclose($handle);
echo '<textarea class="logoutput">'.htmlspecialchars($log, ENT_QUOTES).'</textarea>';
?>
<?php echo '<textarea class="logoutput">'.htmlspecialchars($adblock_log, ENT_QUOTES).'</textarea>'; ?>
</div>
</div>
</div><!-- /.tab-pane -->

View File

@@ -1,13 +1,3 @@
<?php
$client_interface = $_SESSION['wifi_client_interface'];
exec('ip a show '.$client_interface, $stdoutIp);
$stdoutIpAllLinesGlued = implode(" ", $stdoutIp);
$stdoutIpWRepeatedSpaces = preg_replace('/\s\s+/', ' ', $stdoutIpAllLinesGlued);
preg_match('/state (UP|DOWN)/i', $stdoutIpWRepeatedSpaces, $matchesState) || $matchesState[1] = 'unknown';
$ifaceStatus = strtolower($matchesState[1]) ? "up" : "down";
?>
<div class="row">
<div class="col-lg-12">
<div class="card">
@@ -19,7 +9,7 @@ $ifaceStatus = strtolower($matchesState[1]) ? "up" : "down";
<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 strtolower($client_interface) .' '. _($ifaceStatus) ?></span>
<span class="text service-status"><?php echo strtolower($clientInterface) .' '. _($ifaceStatus) ?></span>
</button>
</div>
</div><!-- /.row -->

View File

@@ -1,19 +1,3 @@
<?php
$arrHostapdConf = parse_ini_file(RASPI_CONFIG.'/hostapd.ini');
$client_interface = $_SESSION['wifi_client_interface'];
$ap_iface = $_SESSION['ap_interface'];
$MACPattern = '"([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}"';
if ($arrHostapdConf['BridgedEnable'] == 1) {
$moreLink = "hostapd_conf";
exec('iw dev '.$ap_iface.' station dump | grep -oE '.$MACPattern, $clients);
} else {
$moreLink = "dhcpd_conf";
exec('cat '.RASPI_DNSMASQ_LEASES.'| grep -E $(iw dev '.$ap_iface.' station dump | grep -oE '.$MACPattern.' | paste -sd "|")', $clients);
}
$ifaceStatus = $wlan0up ? "up" : "down";
?>
<div class="row">
<div class="col-lg-12">
<div class="card">
@@ -25,7 +9,7 @@ $ifaceStatus = $wlan0up ? "up" : "down";
<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 strtolower($ap_iface) .' '. _($ifaceStatus) ?></span>
<span class="text service-status"><?php echo strtolower($apInterface) .' '. _($ifaceStatus) ?></span>
</button>
</div>
</div><!-- /.row -->
@@ -38,7 +22,7 @@ $ifaceStatus = $wlan0up ? "up" : "down";
<div class="card mb-3">
<div class="card-body">
<h4><?php echo _("Hourly traffic amount"); ?></h4>
<div id="divInterface" class="d-none"><?php echo $_SESSION['ap_interface']; ?></div>
<div id="divInterface" class="d-none"><?php echo $apInterface; ?></div>
<div class="col-md-12">
<canvas id="divDBChartBandwidthhourly"></canvas>
</div>
@@ -53,7 +37,7 @@ $ifaceStatus = $wlan0up ? "up" : "down";
<div class="row justify-content-md-center">
<div class="col-md">
<div class="info-item"><?php echo _("Connected To"); ?></div><div><?php echo htmlspecialchars($connectedSSID, ENT_QUOTES); ?></div>
<div class="info-item"><?php echo _("Interface"); ?></div><div><?php echo htmlspecialchars($_SESSION['wifi_client_interface']); ?></div>
<div class="info-item"><?php echo _("Interface"); ?></div><div><?php echo htmlspecialchars($clientInterface); ?></div>
<div class="info-item"><?php echo _("AP Mac Address"); ?></div><div><?php echo htmlspecialchars($connectedBSSID, ENT_QUOTES); ?></div>
<div class="info-item"><?php echo _("Bitrate"); ?></div><div><?php echo htmlspecialchars($bitrate, ENT_QUOTES); ?></div>
<div class="info-item"><?php echo _("Signal Level"); ?></div><div><?php echo htmlspecialchars($signalLevel, ENT_QUOTES); ?></div>
@@ -78,7 +62,7 @@ $ifaceStatus = $wlan0up ? "up" : "down";
<table class="table table-hover">
<thead>
<tr>
<?php if ($arrHostapdConf['BridgedEnable'] == 1) : ?>
<?php if ($bridgedEnable == 1) : ?>
<th><?php echo _("MAC Address"); ?></th>
<?php else : ?>
<th><?php echo _("Host name"); ?></th>
@@ -88,7 +72,7 @@ $ifaceStatus = $wlan0up ? "up" : "down";
</tr>
</thead>
<tbody>
<?php if ($arrHostapdConf['BridgedEnable'] == 1) : ?>
<?php if ($bridgedEnable == 1) : ?>
<tr>
<td><small class="text-muted"><?php echo _("Bridged AP mode is enabled. For Hostname and IP, see your router's admin page.");?></small></td>
</tr>
@@ -126,12 +110,12 @@ $ifaceStatus = $wlan0up ? "up" : "down";
<?php echo CSRFTokenFieldTag() ?>
<?php if (!RASPI_MONITOR_ENABLED) : ?>
<?php if (!$wlan0up) : ?>
<input type="submit" class="btn btn-success" value="<?php echo _("Start").' '.$client_interface ?>" name="ifup_wlan0" />
<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").' '.$client_interface ?>" name="ifdown_wlan0" />
<input type="submit" class="btn btn-warning" value="<?php echo _("Stop").' '.$clientInterface ?>" name="ifdown_wlan0" />
<?php endif ?>
<?php endif ?>
<a href="<?php echo $_GET['page'] ?>" class="btn btn-outline btn-primary"><i class="fas fa-sync-alt"></i> <?php echo _("Refresh") ?></a>
<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>

View File

@@ -12,12 +12,6 @@
<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
// Get Bridged AP mode status
$arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini');
// defaults to false
$bridgedEnabled = $arrHostapdConf['BridgedEnable'];
?>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="summary">
@@ -38,12 +32,10 @@
</thead>
<tbody>
<?php
$checkAccess=true;
require "includes/internetRoute.php";
if (isset($rInfo["error"]) || empty($rInfo)) {
if (isset($routeInfo["error"]) || empty($routeInfo)) {
echo "<tr><td colspan=5>No route to the internet found</td></tr>";
} else {
foreach($rInfo as $route) {
foreach($routeInfo as $route) {
echo "<tr>";
echo "<td>".$route["interface"]."</td>";
echo "<td>".$route["ip-address"]."</td>";
@@ -65,6 +57,7 @@
</div>
<h4 class="mt-3"><?php echo _("Current settings") ?></h4>
<div class="row">
<?php if (!$bridgedEnabled) : // No interface details when bridged ?>
<?php foreach ($interfaces as $if): ?>
<?php $if_quoted = htmlspecialchars($if, ENT_QUOTES) ?>
<div class="col-md-6 mb-3">
@@ -76,84 +69,18 @@
</div>
</div>
<?php endforeach ?>
<?php endif ?>
</div><!-- /.row -->
<div class="col-lg-12">
<div class="row">
<a href="#" class="btn btn-outline btn-primary" id="btnSummaryRefresh"><i class="fas fa-sync-alt"></i> <?php echo _("Refresh"); ?></a>
</div><!-- /.row -->
</div><!-- /.col-lg-12 -->
</div><!-- /.tab-pane -->
<?php foreach ($interfaces as $if): ?>
<?php $if_quoted = htmlspecialchars($if, ENT_QUOTES) ?>
<div role="tabpanel" class="tab-pane fade in" id="<?php echo $if_quoted ?>">
<div class="row">
<div class="col-lg-6">
<form id="frm-<?php echo $if_quoted ?>">
<?php echo CSRFTokenFieldTag() ?>
<div class="form-group">
<h4 class="mt-3"><?php echo _("Adapter IP Address Settings") ?></h4>
<div class="btn-group" role="group" data-toggle="buttons">
<label class="btn btn-primary">
<input class="mr-2" type="radio" name="<?php echo $if_quoted ?>-addresstype" id="<?php echo $if_quoted ?>-dhcp" autocomplete="off"><?php echo _("DHCP") ?>
</label>
<label class="btn btn-primary">
<input class="mr-2" type="radio" name="<?php echo $if_quoted ?>-addresstype" id="<?php echo $if_quoted ?>-static" autocomplete="off"><?php echo _("Static IP") ?>
</label>
</div><!-- /.btn-group -->
<h4 class="mt-3"><?php echo _("Enable Fallback to Static Option") ?></h4>
<div class="btn-group" role="group" data-toggle="buttons">
<label class="btn btn-primary">
<input class="mr-2" type="radio" name="<?php echo $if_quoted ?>-dhcpfailover" id="<?php echo $if_quoted ?>-failover" autocomplete="off"><?php echo _("Enabled") ?>
</label>
<label class="btn btn-warning">
<input class="mr-2" type="radio" name="<?php echo $if_quoted ?>-dhcpfailover" id="<?php echo $if_quoted ?>-nofailover" autocomplete="off"><?php echo _("Disabled") ?>
</label>
</div><!-- /.btn-group -->
</div><!-- /.form-group -->
<hr />
<h4><?php echo _("Static IP Options") ?></h4>
<div class="form-group">
<label for="<?php echo $if_quoted ?>-ipaddress"><?php echo _("IP Address") ?></label>
<input type="text" class="form-control" id="<?php echo $if_quoted ?>-ipaddress" placeholder="0.0.0.0">
</div>
<div class="form-group">
<label for="<?php echo $if_quoted ?>-netmask"><?php echo _("Subnet Mask") ?></label>
<input type="text" class="form-control" id="<?php echo $if_quoted ?>-netmask" placeholder="255.255.255.0">
</div>
<div class="form-group">
<label for="<?php echo $if_quoted ?>-gateway"><?php echo _("Default Gateway") ?></label>
<input type="text" class="form-control" id="<?php echo $if_quoted ?>-gateway" placeholder="0.0.0.0">
</div>
<div class="form-group">
<label for="<?php echo $if_quoted ?>-dnssvr"><?php echo _("DNS Server") ?></label>
<input type="text" class="form-control" id="<?php echo $if_quoted ?>-dnssvr" placeholder="0.0.0.0">
</div>
<div class="form-group">
<label for="<?php echo $if_quoted ?>-dnssvralt"><?php echo _("Alternate DNS Server") ?></label>
<input type="text" class="form-control" id="<?php echo $if_quoted ?>-dnssvralt" placeholder="0.0.0.0">
</div>
<div class="form-group">
<label for="<?php echo $if_quoted ?>-metric"><?php echo _("Metric") ?></label>
<input type="text" class="form-control" id="<?php echo $if_quoted ?>-metric" placeholder="0">
</div>
<?php if (!RASPI_MONITOR_ENABLED) : ?>
<a href="#" class="btn btn-outline btn-primary intsave" data-int="<?php echo $if_quoted ?>"><?php echo _("Save settings") ?></a>
<a href="#" class="btn btn-warning intapply" data-int="<?php echo $if_quoted ?>"><?php echo _("Apply settings") ?></a>
<?php endif ?>
</form>
<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><!-- /.tab-panel -->
</div>
</div>
<?php endforeach ?>
</div><!-- /.tab-content -->
</div>
</div><!-- /.card-body -->
<div class="card-footer"><?php echo _("Information provided by /sys/class/net"); ?></div>
</div><!-- /.card -->
</div><!-- /.col-lg-12 -->
</div>
</div><!-- /.row -->

View File

@@ -35,12 +35,11 @@ include('includes/sysstats.php');
<form action="system_info" method="POST">
<?php echo CSRFTokenFieldTag() ?>
<a href="<?php echo $_GET['page'] ?>" class="btn btn-outline btn-primary"><i class="fas fa-sync-alt"></i> <?php echo _("Refresh") ?></a>
<?php if (!RASPI_MONITOR_ENABLED) : ?>
<input type="submit" class="btn btn-warning" name="system_reboot" value="<?php echo _("Reboot"); ?>" />
<input type="submit" class="btn btn-warning" name="system_shutdown" value="<?php echo _("Shutdown"); ?>" />
<?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") ?></a>
</form>
</div>
</div>

View File

@@ -8,6 +8,6 @@
</div>
</div>
<input type="submit" class="btn btn-outline btn-primary" name="SaveLanguage" value="<?php echo _("Save settings"); ?>" />
<a href="<?php echo $_GET['page'] ?>" class="btn btn-outline btn-primary"><i class="fas fa-sync-alt"></i> <?php echo _("Refresh") ?></a>
<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>

View File

@@ -21,8 +21,8 @@
</div>
</div>
<form action="system_info" method="POST">
<?php echo CSRFTokenFieldTag() ?>
<a href="<?php echo $_GET['page'] ?>" class="btn btn-outline btn-primary"><i class="fas fa-sync-alt"></i> <?php echo _("Refresh"); ?></a>
<?php echo CSRFTokenFieldTag() ?>
<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><!-- /.card-body -->
<div class="card-footer"></div>