Skip to content

Commit 3dbdf83

Browse files
committed
Add $key to chkValue() and chkValueEx() for debug
1 parent 4b682bf commit 3dbdf83

File tree

10 files changed

+21
-21
lines changed

10 files changed

+21
-21
lines changed

www/apl-config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
if (isset($_POST['save']) && $_POST['save'] == '1') {
1515
foreach ($_POST['config'] as $key => $value) {
16-
chkValue($value);
16+
chkValue($key, $value);
1717
sqlUpdate('cfg_airplay', $dbh, $key, $value);
1818

1919
if ($value != 'deprecated') {

www/command/cfg-table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
chkVariables($_GET);
1414
chkVariables($_POST, array('library_flatlist_filter_str'));
15-
chkValueEx($_POST['library_flatlist_filter_str']);
15+
chkValueEx('library_flatlist_filter_str', $_POST['library_flatlist_filter_str']);
1616

1717
switch ($_GET['cmd']) {
1818
case 'get_cfg_tables':

www/command/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
exit(1);
1818
}
1919

20-
chkValue($_GET['cmd']);
20+
chkValue('cmd', $_GET['cmd']);
2121

2222
// DEBUG:
2323
//workerLog('index.php: cmd=' . $_GET['cmd']);
@@ -124,7 +124,7 @@ function getArgs($cmd) {
124124
$argCount = count($cmd);
125125
if ($argCount > 1) {
126126
for ($i = 0; $i < $argCount; $i++) {
127-
chkValue($cmd[$i + 1]);
127+
chkValue('cmd', $cmd[$i + 1]);
128128
$args .= ' ' . $cmd[$i + 1];
129129
}
130130
} else {

www/dez-config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
if (isset($_POST['save']) && $_POST['save'] == '1') {
1515
foreach ($_POST['config'] as $key => $value) {
1616
if ($key != 'password') {
17-
chkValue($value);
17+
chkValue($key, $value);
1818
}
1919
sqlUpdate('cfg_deezer', $dbh, $key, $value);
2020
}

www/inc/common.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,21 @@ function chkVariables($variables, $excludedKeys = array()) {
8383
if (is_array($value2)) {
8484
foreach($value2 as $key3 => $value3) {
8585
if (!in_array($key3, $excludedKeys)) {
86-
chkValue($value3);
86+
chkValue($key3, $value3);
8787
} else {
8888
debugLog('chkVariables(): Excluded key: ' . $key3);
8989
}
9090
}
9191
} else {
9292
if (!in_array($key2, $excludedKeys)) {
93-
chkValue($value2);
93+
chkValue($key2, $value2);
9494
} else {
9595
debugLog('chkVariables(): Excluded key: ' . $key2);
9696
}
9797
}
9898
}
9999
} else {
100-
chkValue($value);
100+
chkValue($key, $value);
101101
}
102102
} else {
103103
debugLog('chkVariables(): Excluded key: ' . $key);
@@ -106,7 +106,7 @@ function chkVariables($variables, $excludedKeys = array()) {
106106
}
107107

108108
// Check for unwanted characters and shell commands
109-
function chkValue($value) {
109+
function chkValue($key = 'nokey', $value) {
110110
$valid = true;
111111
$msg = '';
112112

@@ -133,18 +133,18 @@ function chkValue($value) {
133133
if ($valid === false) {
134134
// Write log entry
135135
workerLog('SECCHK: ' . $msg);
136-
workerLog('SECCHK: ' . $value);
136+
workerLog('SECCHK: ' . $key . '|' . $value);
137137
// Redirect to '400 Bad request' page and then exit
138138
http_response_code(400);
139139
header('Location: /response400.html');
140140
exit(1);
141141
} else {
142-
//debugLog('chkValue(): ' . (empty($value) ? 'Value is blank' : $value));
142+
//debugLog('chkValue(): ' . $key . '|' . (empty($value) ? 'Value is blank' : $value));
143143
}
144144
}
145145
// Same as chkValue() except pipe | is excluded
146146
// For: library_flatlist_filter_str, ashuffle_filter
147-
function chkValueEx($value) {
147+
function chkValueEx($key = 'nokey', $value) {
148148
$valid = true;
149149
$msg = '';
150150

@@ -171,13 +171,13 @@ function chkValueEx($value) {
171171
if ($valid === false) {
172172
// Write log entry
173173
workerLog('SECCHK: ' . $msg);
174-
workerLog('SECCHK: ' . $value);
174+
workerLog('SECCHK: ' . $key . '|' . $value);
175175
// Redirect to '400 Bad request' page and then exit
176176
http_response_code(400);
177177
header('Location: /response400.html');
178178
exit(1);
179179
} else {
180-
//debugLog('chkValueEx(): ' . (empty($value) ? 'Value is blank' : $value));
180+
//debugLog('chkValueEx(): ' . $key . '|' . (empty($value) ? 'Value is blank' : $value));
181181
}
182182
}
183183

@@ -656,7 +656,7 @@ function updBootConfigTxt($action, $value) {
656656
if ($result == '0') {
657657
sysCmd('sed -i s/^dtparam=fan_temp0.*/dtparam=' . $value . '/ ' . BOOT_CONFIG_TXT);
658658
} else {
659-
sysCmd('sed -i s/^#dtparam=fan_temp0.*/dtparam=' . $value . '/ ' . BOOT_CONFIG_TXT);
659+
sysCmd('sed -i s/^#dtparam=fan_temp0.*/dtparam=' . $value . '/ ' . BOOT_CONFIG_TXT);
660660
}
661661
}
662662
break;

www/players.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
require_once __DIR__ . '/inc/sql.php';
1111

1212
if (isset($_GET['cmd']) && !empty($_GET['cmd'])) {
13-
chkValue($_GET['cmd']);
13+
chkValue('cmd', $_GET['cmd']);
1414
if (!isset($_POST['ipaddr'])) {
1515
workerLog('players.php: No destination IP addresses for command ' . $_GET['cmd']);
1616
} else {

www/snd-config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
$deviceNames = getAlsaDeviceNames();
2020

2121
chkVariables($_POST, array('ashuffle_filter', 'ashuffle_exclude'));
22-
chkValueEx($_POST['ashuffle_filter']);
23-
chkValueEx($_POST['ashuffle_exclude']);
22+
chkValueEx('ashuffle_filter', $_POST['ashuffle_filter']);
23+
chkValueEx('ashuffle_exclude', $_POST['ashuffle_exclude']);
2424

2525
// AUDIO OUTPUT
2626

www/spo-config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
if (isset($_POST['save']) && $_POST['save'] == '1') {
1515
foreach ($_POST['config'] as $key => $value) {
16-
chkValue($value);
16+
chkValue($key, $value);
1717
sqlUpdate('cfg_spotify', $dbh, $key, $value);
1818
}
1919
$notify = $_SESSION['spotifysvc'] == '1' ?

www/sqe-config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
if (isset($_POST['save']) && $_POST['save'] == '1') {
1616
foreach ($_POST['config'] as $key => $value) {
17-
chkValue($value);
17+
chkValue($key, $value);
1818
sqlUpdate('cfg_sl', $dbh, $key, SQLite3::escapeString($value));
1919
}
2020
$notify = $_SESSION['slsvc'] == '1' ?

www/upp-config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
foreach ($_POST['config'] as $key => $value) {
1919
if ($key != 'qobuzpass') {
20-
chkValue($value);
20+
chkValue($key, $value);
2121
}
2222
sqlUpdate('cfg_upnp', $dbh, $key, $value);
2323
if ($value != '') {

0 commit comments

Comments
 (0)