mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-21 23:20:22 +00:00
Merge branch 'master' into fix/theme-options
This commit is contained in:
commit
194ca3a295
13 changed files with 66 additions and 13 deletions
|
@ -8,6 +8,7 @@ define('RASPI_ADMIN_DETAILS', RASPI_CONFIG.'/raspap.auth');
|
|||
define('RASPI_WIFI_AP_INTERFACE', 'wlan0');
|
||||
define('RASPI_CACHE_PATH', sys_get_temp_dir() . '/raspap');
|
||||
define('RASPI_DEBUG_LOG', 'raspap_debug.log');
|
||||
define('RASPI_LOG_SIZE_LIMIT', 64);
|
||||
|
||||
// Constants for configuration file paths.
|
||||
// These are typical for default RPi installs. Modify if needed.
|
||||
|
@ -18,6 +19,7 @@ define('RASPI_ADBLOCK_CONFIG', RASPI_DNSMASQ_PREFIX.'adblock.conf');
|
|||
define('RASPI_HOSTAPD_CONFIG', '/etc/hostapd/hostapd.conf');
|
||||
define('RASPI_DHCPCD_CONFIG', '/etc/dhcpcd.conf');
|
||||
define('RASPI_DHCPCD_LOG', '/var/log/dnsmasq.log');
|
||||
define('RASPI_HOSTAPD_LOG', '/tmp/hostapd.log');
|
||||
define('RASPI_WPA_SUPPLICANT_CONFIG', '/etc/wpa_supplicant/wpa_supplicant.conf');
|
||||
define('RASPI_HOSTAPD_CTRL_INTERFACE', '/var/run/hostapd');
|
||||
define('RASPI_WPA_CTRL_INTERFACE', '/var/run/wpa_supplicant');
|
||||
|
|
|
@ -92,6 +92,7 @@ function DisplayAdBlockConfig()
|
|||
} else {
|
||||
$adblock_log = "Unable to open log file";
|
||||
}
|
||||
$logdata = getLogLimited(RASPI_DHCPCD_LOG, $adblock_log);
|
||||
|
||||
echo renderTemplate(
|
||||
"adblock", compact(
|
||||
|
@ -101,7 +102,7 @@ function DisplayAdBlockConfig()
|
|||
"enabled",
|
||||
"custom_enabled",
|
||||
"adblock_custom_content",
|
||||
"adblock_log"
|
||||
"logdata"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ $defaults = [
|
|||
'RASPI_WIFI_AP_INTERFACE' => 'wlan0',
|
||||
'RASPI_CACHE_PATH' => sys_get_temp_dir() . '/raspap',
|
||||
'RASPI_DEBUG_LOG' => 'raspap_debug.log',
|
||||
'RASPI_LOG_SIZE_LIMIT' => 64,
|
||||
|
||||
// Constants for configuration file paths.
|
||||
// These are typical for default RPi installs. Modify if needed.
|
||||
|
@ -23,6 +24,7 @@ $defaults = [
|
|||
'RASPI_HOSTAPD_CONFIG' => '/etc/hostapd/hostapd.conf',
|
||||
'RASPI_DHCPCD_CONFIG' => '/etc/dhcpcd.conf',
|
||||
'RASPI_DHCPCD_LOG' => '/var/log/dnsmasq.log',
|
||||
'RASPI_HOSTAPD_LOG' => '/tmp/hostapd.log',
|
||||
'RASPI_WPA_SUPPLICANT_CONFIG' => '/etc/wpa_supplicant/wpa_supplicant.conf',
|
||||
'RASPI_HOSTAPD_CTRL_INTERFACE' => '/var/run/hostapd',
|
||||
'RASPI_WPA_CTRL_INTERFACE' => '/var/run/wpa_supplicant',
|
||||
|
|
|
@ -60,6 +60,9 @@ function DisplayDHCPConfig()
|
|||
count($log_dhcp) > 0 ? $conf['log-dhcp'] = true : false ;
|
||||
count($log_queries) > 0 ? $conf['log-queries'] = true : false ;
|
||||
|
||||
exec('sudo /bin/chmod o+r '.RASPI_DHCPCD_LOG);
|
||||
$logdata = getLogLimited(RASPI_DHCPCD_LOG);
|
||||
|
||||
echo renderTemplate(
|
||||
"dhcp", compact(
|
||||
"status",
|
||||
|
@ -70,7 +73,8 @@ function DisplayDHCPConfig()
|
|||
"hosts",
|
||||
"upstreamServers",
|
||||
"interfaces",
|
||||
"leases"
|
||||
"leases",
|
||||
"logdata"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -924,6 +924,29 @@ function checkReleaseVersion($installed, $latest) {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns logfile contents up to a maximum defined limit, in kilobytes
|
||||
*
|
||||
* @param string $file_path
|
||||
* @param string $file_data optional
|
||||
* @return string $log_limited
|
||||
*/
|
||||
function getLogLimited($file_path, $file_data = null) {
|
||||
$limit_in_kb = isset($_SESSION['log_limit']) ? $_SESSION['log_limit'] : RASPI_LOG_SIZE_LIMIT;
|
||||
$limit = $limit_in_kb * 1024; // convert KB to bytes
|
||||
|
||||
if ($file_data === null) {
|
||||
$file_size = filesize($file_path);
|
||||
$start_position = max(0, $file_size - $limit);
|
||||
$log_limited = file_get_contents($file_path, false, null, $start_position);
|
||||
} else {
|
||||
$file_size = strlen($file_data);
|
||||
$start_position = max(0, $file_size - $limit);
|
||||
$log_limited = substr($file_data, $start_position);
|
||||
}
|
||||
return $log_limited;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to darken a color by a percentage
|
||||
* From @marek-guran's material-dark theme for RaspAP
|
||||
|
@ -961,4 +984,3 @@ function lightenColor($color, $percent)
|
|||
|
||||
return sprintf("#%02x%02x%02x", $r, $g, $b);
|
||||
}
|
||||
|
||||
|
|
|
@ -135,6 +135,8 @@ function DisplayHostAPDConfig()
|
|||
$selectedHwMode = 'w';
|
||||
}
|
||||
}
|
||||
exec('sudo /bin/chmod o+r '.RASPI_HOSTAPD_LOG);
|
||||
$logdata = getLogLimited(RASPI_HOSTAPD_LOG);
|
||||
|
||||
echo renderTemplate(
|
||||
"hostapd", compact(
|
||||
|
@ -153,7 +155,8 @@ function DisplayHostAPDConfig()
|
|||
"arrHostapdConf",
|
||||
"operatingSystem",
|
||||
"selectedHwMode",
|
||||
"countryCodes"
|
||||
"countryCodes",
|
||||
"logdata"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,16 @@ function DisplaySystem(&$extraFooterScripts)
|
|||
$serverBind = escapeshellarg($_POST['serverBind']);
|
||||
}
|
||||
}
|
||||
// Validate log limit
|
||||
if (isset($_POST['logLimit'])) {
|
||||
if ( strlen($_POST['logLimit']) > 4 || !is_numeric($_POST['logLimit']) ) {
|
||||
$status->addMessage('Invalid value for log size limit', 'danger');
|
||||
$good_input = false;
|
||||
} else {
|
||||
$_SESSION['log_limit'] = intval($_POST['logLimit']);
|
||||
$status->addMessage(sprintf(_('Changing log limit size to %s KB'), $_SESSION['log_limit']), 'info');
|
||||
}
|
||||
}
|
||||
// Save settings
|
||||
if ($good_input) {
|
||||
exec("sudo /etc/raspap/lighttpd/configport.sh $serverPort $serverBind " .RASPI_LIGHTTPD_CONFIG. " ".$_SERVER['SERVER_NAME'], $return);
|
||||
|
@ -141,6 +151,7 @@ function DisplaySystem(&$extraFooterScripts)
|
|||
|
||||
$extraFooterScripts[] = array('src'=>'dist/huebee/huebee.pkgd.min.js', 'defer'=>false);
|
||||
$extraFooterScripts[] = array('src'=>'app/js/huebee.js', 'defer'=>false);
|
||||
$logLimit = isset($_SESSION['log_limit']) ? $_SESSION['log_limit'] : RASPI_LOG_SIZE_LIMIT;
|
||||
|
||||
echo renderTemplate("system", compact(
|
||||
"arrLocales",
|
||||
|
@ -166,6 +177,7 @@ function DisplaySystem(&$extraFooterScripts)
|
|||
"hostapd_status",
|
||||
"hostapd_led",
|
||||
"themes",
|
||||
"selectedTheme"
|
||||
"selectedTheme",
|
||||
"logLimit"
|
||||
));
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -911,6 +911,12 @@ msgstr "Generate debug log"
|
|||
msgid "Debug log generation in progress..."
|
||||
msgstr "Debug log generation in progress..."
|
||||
|
||||
msgid "Diagnostic log size limit (KB)"
|
||||
msgstr "Diagnostic log size limit (KB)"
|
||||
|
||||
msgid "Changing log limit size to %s KB"
|
||||
msgstr "Changing log limit size to %s KB"
|
||||
|
||||
#: includes/data_usage.php
|
||||
msgid "Data usage"
|
||||
msgstr "Data usage"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<h4 class="mt-3"><?php echo _("Logging"); ?></h4>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-8">
|
||||
<?php echo '<textarea class="logoutput">'.htmlspecialchars($adblock_log, ENT_QUOTES).'</textarea>'; ?>
|
||||
<?php echo '<textarea class="logoutput">'.htmlspecialchars($logdata, ENT_QUOTES).'</textarea>'; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.tab-pane -->
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
<div class="form-group col-md-8 mt-2">
|
||||
<?php
|
||||
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" id="dnsmasq-log">'.htmlspecialchars($log, ENT_QUOTES).'</textarea>';
|
||||
echo '<textarea class="logoutput" id="dnsmasq-log">'.htmlspecialchars($logdata, ENT_QUOTES).'</textarea>';
|
||||
} else {
|
||||
echo '<textarea class="logoutput my-3"></textarea>';
|
||||
}
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
<div class="form-group col-md-8 mt-2">
|
||||
<?php
|
||||
if ($arrHostapdConf['LogEnable'] == 1) {
|
||||
exec('sudo /bin/chmod o+r /tmp/hostapd.log');
|
||||
$log = file_get_contents('/tmp/hostapd.log');
|
||||
echo '<textarea class="logoutput" id="hostapd-log">'.htmlspecialchars($log, ENT_QUOTES).'</textarea>';
|
||||
echo '<textarea class="logoutput" id="hostapd-log">'.htmlspecialchars($logdata, ENT_QUOTES).'</textarea>';
|
||||
} else {
|
||||
echo '<textarea class="logoutput my-3"></textarea>';
|
||||
}
|
||||
|
|
|
@ -16,10 +16,15 @@
|
|||
<input type="text" class="form-control" name="serverBind" value="<?php echo htmlspecialchars($serverBind, ENT_QUOTES); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="code"><?php echo _("Diagnostic log size limit (KB)") ;?></label>
|
||||
<input type="text" class="form-control" name="logLimit" value="<?php echo htmlspecialchars($logLimit, ENT_QUOTES); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" class="btn btn-outline btn-primary" name="SaveServerSettings" value="<?php echo _("Save settings"); ?>" />
|
||||
<input type="submit" class="btn btn-warning" name="RestartLighttpd" value="<?php echo _("Restart lighttpd"); ?>" />
|
||||
</form>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue