-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathother.php
More file actions
78 lines (62 loc) · 1.61 KB
/
other.php
File metadata and controls
78 lines (62 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
include_once "/opt/fpp/www/common.php";
include_once 'jukebox-common.php';
$command_array = array(
'save_song_count' => 'SaveSongCount',
'clear_stats' => 'ClearStats',
);
$command = "";
$args = array();
if (isset($_GET['command']) && !empty($_GET['command'])) {
$command = $_GET['command'];
$args = $_GET;
} elseif (isset($_POST['command']) && !empty($_POST['command'])) {
$command = $_POST['command'];
$args = $_POST;
}
if (array_key_exists($command, $command_array)) {
global $debug;
if ($debug) {
error_log("Calling " . $command);
}
call_user_func($command_array[$command]);
}
return;
function setPluginJSON($plugin, $js)
{
global $settings;
$cfgFile = $settings['configDirectory'] . "/plugin." . $plugin . ".json";
file_put_contents($cfgFile, json_encode($js, JSON_PRETTY_PRINT));
// echo json_encode($js, JSON_PRETTY_PRINT);
}
function SaveSongCount()
{
$counts = convertAndGetSettings('jukebox-counts');
$item = str_replace('.fseq', '', $_POST['item']);
if (array_search($item, array_column($counts, 'name')) !== FALSE) {
foreach ($counts as $key => $value) {
if ($value['name'] == $item) {
$current_count = (int) $value['count'];
$counts[$key]['count'] = $current_count + 1;
}
}
} else {
$counts[] = [
'name' => $item,
'count' => 1
];
}
// echo print_r($counts, true);
writeToJsonFile('counts', $counts);
echo json_encode([
'error' => false,
'message' => 'Saved: ' . $_POST['item'],
]);
}
function ClearStats()
{
setPluginJSON('fpp-jukebox-counts', []);
echo json_encode([
'error' => false
]);
}