mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-22 07:30:23 +00:00
Merge pull request #1235 from RaspAP/feature/clear-log
Adds a 'clear log' button to service logging UIs
This commit is contained in:
commit
4c23b45375
8 changed files with 50 additions and 10 deletions
12
ajax/logging/clearlog.php
Normal file
12
ajax/logging/clearlog.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
require_once '../../includes/config.php';
|
||||
require_once '../../includes/functions.php';
|
||||
|
||||
if (isset($_POST['logfile'])) {
|
||||
$logfile = $_POST['logfile'];
|
||||
|
||||
// truncate requested log file
|
||||
exec("sudo truncate -s 0 $logfile", $return);
|
||||
echo json_encode($return);
|
||||
}
|
|
@ -122,6 +122,28 @@ $(document).on("click", "#gen_wpa_passphrase", function(e) {
|
|||
$('#txtwpapassphrase').val(genPassword(63));
|
||||
});
|
||||
|
||||
$(document).on("click", "#js-clearhostapd-log", function(e) {
|
||||
$.post('ajax/logging/clearlog.php?',{'logfile':'/tmp/hostapd.log'},function(data){
|
||||
jsonData = JSON.parse(data);
|
||||
$("#hostapd-log").val("");
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", "#js-cleardnsmasq-log", function(e) {
|
||||
$.post('ajax/logging/clearlog.php?',{'logfile':'/var/log/dnsmasq.log'},function(data){
|
||||
jsonData = JSON.parse(data);
|
||||
$("#dnsmasq-log").val("");
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", "#js-clearopenvpn-log", function(e) {
|
||||
$.post('ajax/logging/clearlog.php?',{'logfile':'/tmp/openvpn.log'},function(data){
|
||||
jsonData = JSON.parse(data);
|
||||
$("#openvpn-log").val("");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Enable Bootstrap tooltips
|
||||
$(function () {
|
||||
$('[data-toggle="tooltip"]').tooltip()
|
||||
|
|
|
@ -63,4 +63,4 @@ 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:/usr/sbin/netplan
|
||||
|
||||
www-data ALL=(ALL) NOPASSWD:/bin/truncate -s 0 /tmp/*.log,/bin/truncate -s 0 /var/log/dnsmasq.log
|
||||
|
|
Binary file not shown.
|
@ -434,8 +434,8 @@ msgstr "Format"
|
|||
msgid "Choose a hosted server"
|
||||
msgstr "Choose a hosted server"
|
||||
|
||||
msgid "Enable these options to log DHCP server activity."
|
||||
msgstr "Enable these options to log DHCP server activity."
|
||||
msgid "Enable these options to log <code>dhcpcd</code> and <code>dnsmasq</code> activity."
|
||||
msgstr "Enable these options to log <code>dhcpcd</code> and <code>dnsmasq</code> activity."
|
||||
|
||||
msgid "Log DHCP requests"
|
||||
msgstr "Log DHCP requests"
|
||||
|
@ -971,6 +971,9 @@ msgstr "up"
|
|||
msgid "down"
|
||||
msgstr "down"
|
||||
|
||||
msgid "Clear log"
|
||||
msgstr "Clear log"
|
||||
|
||||
#: includes/adblock.php
|
||||
|
||||
msgid "adblock"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!-- logfile output tab -->
|
||||
<div class="tab-pane fade" id="logging">
|
||||
<h4><?php echo _("Logging") ?></h4>
|
||||
<p><?php echo _("Enable these options to log DHCP server activity.") ?></p>
|
||||
<p><?php echo _("Enable these options to log <code>dhcpcd</code> and <code>dnsmasq</code> activity.") ?></p>
|
||||
|
||||
<div class="custom-control custom-switch">
|
||||
<input class="custom-control-input" id="log-dhcp" type="checkbox" name="log-dhcp" value="1" <?php echo $conf['log-dhcp'] ? ' checked="checked"' : "" ?> aria-describedby="log-dhcp-requests">
|
||||
|
@ -9,7 +9,8 @@
|
|||
</div>
|
||||
<div class="custom-control custom-switch">
|
||||
<input class="custom-control-input" id="log-queries" type="checkbox" name="log-queries" value="1" <?php echo $conf['log-queries'] ? ' checked="checked"' : "" ?> aria-describedby="log-dhcp-queries">
|
||||
<label class="custom-control-label" for="log-queries"><?php echo _("Log DNS queries") ?></label>
|
||||
<label class="custom-control-label align-middle" for="log-queries"><?php echo _("Log DNS queries") ?></label>
|
||||
<input type="button" class="btn btn-outline btn-warning btn-sm align-top ml-4" id="js-cleardnsmasq-log" value="<?php echo _("Clear log"); ?>" />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
@ -18,7 +19,7 @@
|
|||
if ($conf['log-dhcp'] == 1 || $conf['log-queries'] == 1) {
|
||||
exec('sudo /bin/chmod o+r '.RASPI_DHCPCD_LOG);
|
||||
$log = file_get_contents(RASPI_DHCPCD_LOG);
|
||||
echo '<textarea class="logoutput">'.htmlspecialchars($log, ENT_QUOTES).'</textarea>';
|
||||
echo '<textarea class="logoutput" id="dnsmasq-log">'.htmlspecialchars($log, ENT_QUOTES).'</textarea>';
|
||||
} else {
|
||||
echo '<textarea class="logoutput my-3"></textarea>';
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
<div class="custom-control custom-switch">
|
||||
<?php $checked = $arrHostapdConf['LogEnable'] == 1 ? 'checked="checked"' : '' ?>
|
||||
<input class="custom-control-input" id="chxlogenable" name="logEnable" type="checkbox" value="1" <?php echo $checked ?> />
|
||||
<label class="custom-control-label" for="chxlogenable"><?php echo _("Logfile output"); ?></label>
|
||||
<label class="custom-control-label align-middle" for="chxlogenable"><?php echo _("Logfile output"); ?></label>
|
||||
<input type="button" class="btn btn-outline btn-warning btn-sm align-top ml-2" id="js-clearhostapd-log" value="<?php echo _("Clear log"); ?>" />
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
@ -15,7 +16,7 @@
|
|||
if ($arrHostapdConf['LogEnable'] == 1) {
|
||||
exec('sudo /bin/chmod o+r /tmp/hostapd.log');
|
||||
$log = file_get_contents('/tmp/hostapd.log');
|
||||
echo '<textarea class="logoutput">'.htmlspecialchars($log, ENT_QUOTES).'</textarea>';
|
||||
echo '<textarea class="logoutput" id="hostapd-log">'.htmlspecialchars($log, ENT_QUOTES).'</textarea>';
|
||||
} else {
|
||||
echo '<textarea class="logoutput my-3"></textarea>';
|
||||
}
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
|
||||
<div class="custom-control custom-switch">
|
||||
<input class="custom-control-input" id="log-openvpn" type="checkbox" name="log-openvpn" value="1" <?php echo $logEnable ? ' checked="checked"' : "" ?> aria-describedby="log-openvpn">
|
||||
<label class="custom-control-label" for="log-openvpn"><?php echo _("Enable logging") ?></label>
|
||||
<label class="custom-control-label align-middle" for="log-openvpn"><?php echo _("Enable logging") ?></label>
|
||||
<input type="button" class="btn btn-outline btn-warning btn-sm align-top ml-2" id="js-clearopenvpn-log" value="<?php echo _("Clear log"); ?>" />
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-8 mt-2">
|
||||
<textarea class="logoutput"><?php echo htmlspecialchars($logOutput, ENT_QUOTES); ?></textarea>
|
||||
<textarea class="logoutput" id="openvpn-log"><?php echo htmlspecialchars($logOutput, ENT_QUOTES); ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.tab-pane -->
|
||||
|
|
Loading…
Reference in a new issue