Merge branch 'master' into fix/theme-options

This commit is contained in:
Bill Zimmerman
2023-11-29 17:28:37 +01:00
committed by GitHub
13 changed files with 66 additions and 13 deletions

View File

@@ -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);
}