Skip to content

Commit

Permalink
Merge pull request #2112 from OnlineDynamic/accessibilityandsecurityd…
Browse files Browse the repository at this point in the history
…ec24

JS Settings framework and filemanager fixes
  • Loading branch information
OnlineDynamic authored Jan 9, 2025
2 parents ec01a74 + 0a8f610 commit c534575
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 30 deletions.
2 changes: 1 addition & 1 deletion etc/apache2.site
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ AddDefaultCharset utf-8
<IfModule mod_headers.c>
Header always set X-Content-Type-Options "nosniff"
header always set X-XSS-Protection "1; mode=block"
Header always set Content-Security-Policy "img-src 'self' data: blob:"
Header always set Content-Security-Policy "img-src 'self' https://www.paypal.com https://www.paypalobjects.com data: blob:"
Header unset Expires
Header unset Host
Header unset P3P
Expand Down
53 changes: 39 additions & 14 deletions www/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ function ApprovedCape($v)
$settings['outputProcessorsFile'] = $outputProcessorsFile;

/*
* Load default values from settings.json
* Load setting info and default values from settings.json
*/
LoadSettingInfos();

Expand Down Expand Up @@ -733,20 +733,9 @@ function GetDirSetting($dir)
?>
<!-- Falcon Player - FPP -->
<script type="text/javascript">
// Standard Common JS Variables
MINYEAR = <? echo MINYEAR; ?>;
MAXYEAR = <? echo MAXYEAR; ?>;
var settings = new Array();
<?
foreach ($settings as $key => $value) {
if (!is_array($value)) {
printf(" settings['%s'] = \"%s\";\n", $key, $value);
} else {
$js_array = json_encode($value);
printf(" settings['%s'] = %s;\n", $key, $js_array);
}
}
?>

var FPP_FULL_VERSION = '<? echo getFPPVersion(); ?>';
var FPP_VERSION = '<? echo getFPPVersionFloatStr(); ?>';
var FPP_MAJOR_VERSION = <? echo getFPPMajorVersion(); ?>;
Expand All @@ -757,7 +746,8 @@ function GetDirSetting($dir)
var FPP_PATCH_VERSION = <? echo getFPPPatchVersion(); ?>;
<? } ?>

var pageName = "<? echo str_ireplace('.php', '', basename($_SERVER['PHP_SELF'])) ?>";
<? $pageName = str_ireplace('.php', '', basename($_SERVER['PHP_SELF'])); ?>
var pageName = "<? echo $pageName; ?>";

var helpPage = "<? echo basename($_SERVER['PHP_SELF']) ?>";
if (pageName == "plugin") {
Expand All @@ -769,6 +759,41 @@ function GetDirSetting($dir)
helpPage = "help/" + helpPage;
}


// Dynamic JS Settings Array with settings which need to be exposed on a page by page basis to browser
var settings = new Array();
<?

foreach ($settings as $key => $value) {

//Print Out settings which haven't been defined at all in www/settings.json
if (!isset($settingInfos[$key])) {
//Print out settings that need to be exposed to the browser in JS settings array - this is temporary until all settings properly define in json file
if (!is_array($value)) {
printf(" settings['%s'] = \"%s\"; // Needs proper defintion in JSON\n", $key, $value);
} else {
$js_array = json_encode($value);
printf(" settings['%s'] = %s; // Needs proper defintion in JSON\n", $key, $js_array);
}
// printf(" console.log(\"%s\");\n", $key); //Debugging
}

//Print out settings that are marked to be exposed to the browser via the config flag in www/settings.json
if (isset($settingInfos[$key]["exposedAsJSToPages"])) {
if (in_array($pageName, $settingInfos[$key]["exposedAsJSToPages"]) || in_array("all", $settingInfos[$key]["exposedAsJSToPages"])) {
//Print out settings to browser
if (!is_array($value)) {
printf(" settings['%s'] = \"%s\";\n", $key, $value);
} else {
$js_array = json_encode($value);
printf(" settings['%s'] = %s;\n", $key, $js_array);
}
}
}
}
?>


</script>
<?
}
Expand Down
6 changes: 3 additions & 3 deletions www/filemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
<div class="tab-pane fade show active" id="tab-sequence" role="tabpanel"
aria-labelledby="tab-sequence-tab">

<div id="divSeq">
<div id="divSequences">
<div class="backdrop">
<div class="row justify-content-between fileDetailsHeader">
<div class="col-auto">
Expand Down Expand Up @@ -318,7 +318,7 @@ class="disableButtons singleMusicButton multiMusicButton" type="button"
</div>

<div class="tab-pane fade" id="tab-video" role="tabpanel" aria-labelledby="tab-video-tab">
<div id="divVideo">
<div id="divVideos">

<div class="backdrop">
<div class="row justify-content-between fileDetailsHeader">
Expand Down Expand Up @@ -793,4 +793,4 @@ class="disableButtons singleBackupsButton multiBackupsButton" type="button"

</body>

</html>
</html>
2 changes: 1 addition & 1 deletion www/js/fpp-filemanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function UpdateFileCount ($dir) {
.not('.filtered').length;
if ($('#tbl' + $dir + ' tbody tr.filtered').length > 0) {
//is filtered
$('#div' + $dir + ' .fileCountlabelHeading')[0].innerHTML = innerHtml =
$('#div' + $dir + ' .fileCountlabelHeading')[0].innerHTML =
'<span class="filtered">Filtered items:<span>';
$('#fileCount_' + $dir)
.removeClass('text-bg-secondary')
Expand Down
55 changes: 44 additions & 11 deletions www/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,10 @@
"default": "0",
"type": "checkbox",
"checkedValue": "1",
"uncheckedValue": "0"
"uncheckedValue": "0",
"exposedAsJSToPages": [
"all"
]
},
"DisableScheduler": {
"name": "DisableScheduler",
Expand All @@ -935,7 +938,10 @@
"tip": "The Disable Scheduler setting allows disabling all scheduling rather than having to go to each schedule entry and deactivate.",
"type": "checkbox",
"level": 1,
"restart": 1
"restart": 1,
"exposedAsJSToPages": [
"all"
]
},
"E131BridgingInterval": {
"name": "E131BridgingInterval",
Expand Down Expand Up @@ -1056,7 +1062,10 @@
"150 pixels": 150,
"175 pixels": 175,
"200 pixels": 200
}
},
"exposedAsJSToPages": [
"filemanager"
]
},
"fileManagerTableFilter": {
"name": "fileManagerTableFilter",
Expand All @@ -1065,7 +1074,10 @@
"default": "1",
"type": "checkbox",
"checkedValue": "1",
"uncheckedValue": "0"
"uncheckedValue": "0",
"exposedAsJSToPages": [
"filemanager"
]
},
"FPP_UUID": {
"name": "FPP_UUID",
Expand All @@ -1088,7 +1100,10 @@
"options": {
"Player": "player",
"Remote": "remote"
}
},
"exposedAsJSToPages": [
"all"
]
},
"FPDEnabled": {
"name": "FPDEnabled",
Expand Down Expand Up @@ -1298,7 +1313,10 @@
"restart": 2,
"default": "Global",
"type": "select",
"optionsURL": "api/settings/Locale/options"
"optionsURL": "api/settings/Locale/options",
"exposedAsJSToPages": [
"all"
]
},
"LogLevel_General": {
"name": "LogLevel_General",
Expand Down Expand Up @@ -1985,7 +2003,10 @@
"gatherStats": true,
"restart": 0,
"default": 0,
"type": "checkbox"
"type": "checkbox",
"exposedAsJSToPages": [
"index"
]
},
"piRTC": {
"name": "piRTC",
Expand Down Expand Up @@ -2048,7 +2069,10 @@
"tip": "Allow scheduling down to the second instead of scheduling on minute boundaries. Enabling this setting will show the seconds value in the Scheduler UI for the Start and End times on schedule entries.",
"type": "checkbox",
"level": 1,
"restart": 1
"restart": 1,
"exposedAsJSToPages": [
"scheduler"
]
},
"screensaver": {
"name": "screensaver",
Expand Down Expand Up @@ -2230,7 +2254,10 @@
"Enabled": "Enabled",
"Disabled": "Disabled",
"Banner": "Banner"
}
},
"exposedAsJSToPages": [
"all"
]
},
"tableColorPair1A": {
"name": "tableColorPair1A",
Expand Down Expand Up @@ -2314,7 +2341,10 @@
"options": {
"Celsius": 0,
"Fahrenheit": 1
}
},
"exposedAsJSToPages": [
"all"
]
},
"TetherInterface": {
"name": "TetherInterface",
Expand Down Expand Up @@ -2356,7 +2386,10 @@
"HH:MM (23:40)": "%H:%M",
"HH:MM AM/PM (11:40 PM)": "%I:%M %p"
},
"note": "Any addition of a new format in the options array here will need corresponding additions in js/fpp.js to the Convert24H*UIFormat functions"
"note": "Any addition of a new format in the options array here will need corresponding additions in js/fpp.js to the Convert24H*UIFormat functions",
"exposedAsJSToPages": [
"all"
]
},
"uiLevel": {
"name": "uiLevel",
Expand Down

0 comments on commit c534575

Please sign in to comment.