-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallbacks.php
75 lines (63 loc) · 2.02 KB
/
callbacks.php
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
#!/usr/bin/php
<?php
error_reporting(0);
//Include our required php files
include_once('/opt/fpp/www/common.php');
include_once("functions.inc.php");
include_once("commonFunctions.inc.php");
//Debug mode
//$DEBUG=true;
$skipJSsettings = 1;
//Plugin name
$pluginName = "FPP-VotingAPI-Integration";
//Logfile
$logFile = $settings['logDirectory'] . "/" . $pluginName . ".log";
//config file
$pluginConfigFile = $settings['configDirectory'] . "/plugin." . $pluginName;
//Callback register
$callbackRegisters = "sequence,media\n";
//Get php process id
$myPid = getmypid();
//var_dump($argv);
//Grab the fpp command from supplied args
//arg0 is the program
//arg1 is the first argument in the registration this will be --list
$FPPD_COMMAND = $argv[1];
//defaults
$ENABLED = '';
//Read the config, work out if plugin is enabled
if (file_exists($pluginConfigFile)) {
$pluginSettings = parse_ini_file($pluginConfigFile);
$ENABLED = $pluginSettings['ENABLED'];
}
//plugin not enabled, then just quit. so we won't get to the registration callback
if (strtolower($ENABLED) != "on" && $ENABLED != "1") {
logEntry("WARNING :: Plugin Status: DISABLED Please enable in Plugin Setup to use & Restart FPPD Daemon");
//quit script
exit(0);
}
//echo "FPPD Command: ".$FPPD_COMMAND."<br/> \n";
//React to the FPPD list command to find out what callbacks we support
if ($FPPD_COMMAND == "--list") {
echo $callbackRegisters;
logEntry("FPPD List Registration request: responded:" . $callbackRegisters);
exit(0);
}
//Act upon the FPPD callback with the --type command
if ($FPPD_COMMAND == "--type") {
if ($DEBUG) {
logEntry("DEBUG :: type callback requested");
}
//we got a register request message from the daemon
$forkResult = fork($argv);
if ($DEBUG) {
logEntry("DEBUG :: Fork Result: " . $forkResult);
}
//exit here, work will be carried out via the forked process
exit(0);
// processCallback($argv);
} else {
logEntry("ERROR :: " . $argv[0] . " called with no parameters");
exit(0);
}
?>