forked from LightsOnHudson/FPP-Plugin-MessageQueue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugin_setup.php
executable file
·181 lines (117 loc) · 4.09 KB
/
plugin_setup.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
//$DEBUG=true;
//3.0 - Dec 27 2016 - Convert to SQLLITE3, write version to config file
//2.5 - Dec 3 2016 - Fix update button form
//2.4 - Dec 2 2016 - touch the message queue file
//2.3 - Dec 2 2016 - ability to delete message queue file
//2.2 - Dec 2 - Blacklist functions!
//2.1 - Dec 2 - added dyanimic profnaity file for message queue.
include_once "/opt/fpp/www/common.php";
include_once "functions.inc.php";
include_once 'commonFunctions.inc.php';
//$pluginName = "MessageQueue";
$pluginName = basename(dirname(__FILE__)); //pjd 7-14-2019 added per dkulp
$pluginVersion ="2.7";
//$DEBUG=true;
$myPid = getmypid();
$gitURL = "https://github.com/LightsOnHudson/FPP-Plugin-MessageQueue.git";
$pluginUpdateFile = $settings['pluginDirectory']."/".$pluginName."/"."pluginUpdate.inc";
//write version number!
WriteSettingToFile("VERSION",urlencode($pluginVersion),$pluginName);
$logFile = $settings['logDirectory']."/".$pluginName.".log";
logEntry("plugin update file: ".$pluginUpdateFile);
if(isset($_POST['updatePlugin']))
{
$updateResult = updatePluginFromGitHub($gitURL, $branch="master", $pluginName);
echo $updateResult."<br/> \n";
}
if(isset($_POST['submit']))
{
WriteSettingToFile("MESSAGE_FILE",urlencode($_POST["MESSAGE_FILE"]),$pluginName);
}
sleep(1);
$pluginConfigFile = $settings['configDirectory'] . "/plugin." .$pluginName;
if (file_exists($pluginConfigFile))
$pluginSettings = parse_ini_file($pluginConfigFile);
$ENABLED = urldecode($pluginSettings['ENABLED']);
$MESSAGE_FILE = urldecode($pluginSettings['MESSAGE_FILE']);
//set a default message queue file
if(trim($MESSAGE_FILE) == "") {
$MESSAGE_FILE = "/home/fpp/media/config/FPP.".$pluginName.".db";
WriteSettingToFile("MESSAGE_FILE",urlencode($_POST["MESSAGE_FILE"]),$pluginName);
}
$db = new SQLite3($MESSAGE_FILE) or die('Unable to open database');
//logEntry("DB: ".$db);
if($db != null) {
createTables();
}
if(isset($_POST['delMessageQueue'])) {
//delete message queue database
logEntry("Deleting message queue db file");
$DELETE_CMD = "/bin/rm ".$MESSAGE_FILE;
exec($DELETE_CMD);
//touch a new file
// $TOUCH_CMD = "/bin/touch ".$MESSAGE_FILE;
// exec($TOUCH_CMD);
//create new DB
$createNewDB_CMD = "/usr/bin/sqlite3 ".$MESSAGE_FILE;
exec($createNewDB_CMD);
}
?>
<html>
<head>
</head>
<div id="MessageQueue" class="settings">
<fieldset>
<legend><?php echo $pluginName." Version: ".$pluginVersion;?> Support Instructions</legend>
<p>Known Issues:
<ul>
<li>NONE</li>
</ul>
<p>Configuration:
<ul>
<li>There is no configuration necessary. This plugin supports/allows plugins to communicate and share messages</li>
<li>Current Plugins utilizing MessageQueue:</li>
<li> SMS Control</li>
<li> Matrix </li>
<li> SportsTicker</li>
<li> Weather</li>
<li> Election</li>
<li> Stock Ticker</li>
<li> RDS To Matrix</li>
<li> Event Date</li>
</ul>
<p>
<p>To report a bug, please file it against the MessageQueue plugin project on Git: https://github.com/LightsOnHudson/FPP-Plugin-MessageQueue
<form method="post" action="http://<? echo $_SERVER['SERVER_ADDR']?>/plugin.php?plugin=<?echo $pluginName;?>&page=plugin_setup.php">
<?
if($DEBUG)
print_r($settings);
$restart=0;
$reboot=0;
echo "ENABLE PLUGIN: ";
PrintSettingCheckbox("Message Queue", "ENABLED", $restart = 0, $reboot = 0, "ON", "OFF", $pluginName = $pluginName, $callbackName = "");
echo "<p/> \n";
echo "Message File Path and Name (/home/fpp/media/config/FPP.FPP-Plugin-MessageQueue.db) : \n";
echo "<input type=\"text\" name=\"MESSAGE_FILE\" size=\"64\" value=\"".$MESSAGE_FILE."\"> \n";
echo "<p/> \n";
echo "<hr/> \n";
echo "Message file database \n";
echo "<form name=\"messageManagement\" method=\"post\" action=\"".$_SERVER['PHP_SELF']."?plugin=".$pluginName."&page=plugin_setup.php\"> \n";
echo "<input type=\"submit\" name=\"delMessageQueue\" value=\"Delete Message Queue DB\"> \n";
?>
<p/>
<input id="submit_button" name="submit" type="submit" class="buttons" value="Save Config">
<?
if(file_exists($pluginUpdateFile))
{
//echo "updating plugin included";
include $pluginUpdateFile;
}
echo "</form> \n";
?>
</form>
</fieldset>
</div>
<br />
</html>