-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathplugin_setup.php
executable file
·291 lines (198 loc) · 9.47 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<?php
//$DEBUG=true;
include_once "/opt/fpp/www/common.php";
include_once 'functions.inc.php';
include_once 'commonFunctions.inc.php';
//$pluginName = "Weather";
$pluginName = basename(dirname(__FILE__)); //pjd 7-14-2019 added per dkulp
$gitURL = "https://github.com/LightsOnHudson/FPP-Plugin-Weather.git";
$pluginUpdateFile = $settings['pluginDirectory']."/".$pluginName."/"."pluginUpdate.inc";
$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']))
{
// echo "Writring config fie <br/> \n";
//WriteSettingToFile("ENABLED",urlencode($_POST["ENABLED"]),$pluginName);
WriteSettingToFile("SEPARATOR",urlencode($_POST["SEPARATOR"]),$pluginName);
WriteSettingToFile("CITY",urlencode($_POST["CITY"]),$pluginName);
WriteSettingToFile("STATE",urlencode($_POST["STATE"]),$pluginName);
WriteSettingToFile("LAST_READ",urlencode($_POST["LAST_READ"]),$pluginName);
WriteSettingToFile("API_KEY",urlencode($_POST["API_KEY"]),$pluginName);
WriteSettingToFile("INCLUDE_TEMP",urlencode($_POST["INCLUDE_TEMP"]),$pluginName);
WriteSettingToFile("INCLUDE_WIND",urlencode($_POST["INCLUDE_WIND"]),$pluginName);
WriteSettingToFile("INCLUDE_HUMIDITY",urlencode($_POST["INCLUDE_HUMIDITY"]),$pluginName);
WriteSettingToFile("INCLUDE_LOCALE",urlencode($_POST["INCLUDE_LOCALE"]),$pluginName);
WriteSettingToFile("PRE_TEXT",urlencode($_POST["PRE_TEXT"]),$pluginName);
WriteSettingToFile("POST_TEXT",urlencode($_POST["POST_TEXT"]),$pluginName);
WriteSettingToFile("TEMP_TYPE",urlencode($_POST["TEMP_TYPE"]),$pluginName);
WriteSettingToFile("INCLUDE_DEGREE_SYMBOL",urlencode($_POST["INCLUDE_DEGREE_SYMBOL"]),$pluginName);
}
$ENABLED = urldecode($pluginSettings['ENABLED']);
$SEPARATOR = urldecode($pluginSettings['SEPARATOR']);
$CITY= urldecode($pluginSettings['CITY']);
$STATE= urldecode($pluginSettings['STATE']);
$API_KEY = urldecode($pluginSettings['API_KEY']);
$INCLUDE_WIND = urldecode($pluginSettings['INCLUDE_WIND']);
$INCLUDE_TEMP = urldecode($pluginSettings['INCLUDE_TEMP']);
$INCLUDE_HUMIDITY = urldecode($pluginSettings['INCLUDE_HUMIDITY']);
$INCLUDE_LOCALE = urldecode($pluginSettings['INCLUDE_LOCALE']);
$PRE_TEXT = urldecode($pluginSettings['PRE_TEXT']);
$POST_TEXT = urldecode($pluginSettings['POST_TEXT']);
$TEMP_TYPE = urldecode($pluginSettings['TEMP_TYPE']);
$INCLUDE_DEGREE_SYMBOL = urldecode($pluginSettings['INCLUDE_DEGREE_SYMBOL']);
$LAST_READ = urldecode($pluginSettings['LAST_READ']);//("LAST_READ",$pluginName));
if($SEPARATOR == "" || strlen($SEPARATOR)>1) {
$SEPARATOR="|";
}
//echo "sports read: ".$SPORTS."<br/> \n";
if((int)$LAST_READ == 0 || $LAST_READ == "") {
$LAST_READ=0;
}
?>
<html>
<head>
</head>
<div id="<?echo $pluginName;?>" class="settings">
<fieldset>
<legend><?php echo $pluginName;?> Support Instructions</legend>
<p>Known Issues:
<ul>
<li>NONE</li>
</ul>
<p>Configuration:
<ul>
<li>Configure your City & 2 Character State & Separator Character to display</li>
<li>Visit http://home.openweathermap.org/ to sign up for an API KEY</li>
</ul>
<ul>
</ul>
<form method="post" action="http://<? echo $_SERVER['SERVER_ADDR']?>/plugin.php?plugin=<?echo $pluginName;?>&page=plugin_setup.php">
<?
echo "<input type=\"hidden\" name=\"LAST_READ\" value=\"".$LAST_READ."\"> \n";
echo "<p/>\n";
$restart=0;
$reboot=0;
echo "ENABLE PLUGIN: ";
//if($ENABLED== 1 || $ENABLED == "on") {
// echo "<input type=\"checkbox\" checked name=\"ENABLED\"> \n";
//just use the name of the plugin. Because it will pop up with 'enabled / disabled ' suffix
PrintSettingCheckbox($pluginName." Plugin", "ENABLED", $restart = 0, $reboot = 0, "ON", "OFF", $pluginName = $pluginName, $callbackName = "");
//} else {
//echo "<input type=\"checkbox\" name=\"ENABLED\"> \n";
//}
echo "<p/> \n";
if($DEBUG) {
echo "RESET LAST READ INDEX: ";
echo "<br/> \n";
echo "Last read: ".$LAST_READ. ": ";
echo "<input type=\"checkbox\" name=\"RESET_LAST_READ\"> \n";
//PrintSettingCheckbox("Radio Station", "ENABLED", $restart = 0, $reboot = 0, "ON", "OFF", $pluginName = $pluginName, $callbackName = "");
echo "<p/> \n";
}
echo "<p/> \n";
echo "Pre Text (Text to display ahead of Weather data): \n";
echo "<input type=\"text\" name=\"PRE_TEXT\" size=\"16\" value=\"".$PRE_TEXT."\"> \n";
//PrintSettingText("CITY", $restart = 0, $reboot = 0, $maxlength = 32, $size = 32, $pluginName);
//PrintSettingSave("CITY", "CITY", $restart = 1, $reboot = 0, $pluginName, $callbackName = "");
//PrintSettingSave($title, $setting, $restart = 1, $reboot = 0, $pluginName = "", $callbackName = "");
echo "<p/> \n";
echo "Post Text (Text to display after weather data): \n";
echo "<input type=\"text\" name=\"POST_TEXT\" size=\"16\" value=\"".$POST_TEXT."\"> \n";
//PrintSettingText("CITY", $restart = 0, $reboot = 0, $maxlength = 32, $size = 32, $pluginName);
//PrintSettingSave("CITY", "CITY", $restart = 1, $reboot = 0, $pluginName, $callbackName = "");
//PrintSettingSave($title, $setting, $restart = 1, $reboot = 0, $pluginName = "", $callbackName = "");
echo "<p/> \n";
echo "City: \n";
echo "<input type=\"text\" name=\"CITY\" size=\"16\" value=\"".$CITY."\"> \n";
//PrintSettingText("CITY", $restart = 0, $reboot = 0, $maxlength = 32, $size = 32, $pluginName);
//PrintSettingSave("CITY", "CITY", $restart = 1, $reboot = 0, $pluginName, $callbackName = "");
//PrintSettingSave($title, $setting, $restart = 1, $reboot = 0, $pluginName = "", $callbackName = "");
echo "<p/> \n";
echo "State: \n";
echo "<input type=\"text\" name=\"STATE\" size=\"2\" value=\"".$STATE."\"> \n";
//PrintSettingText("STATE", $restart = 0, $reboot = 0, $maxlength = 5, $size = 5, $pluginName);
echo "<p/>\n";
echo "Temperature type: \n";
echo "<select name=\"TEMP_TYPE\"> \n";
switch ($TEMP_TYPE)
{
case "F":
echo "<option selected value=\"".$TEMP_TYPE."\">Farenheit</option> \n";
echo "<option value=\"C\">Celcius</option> \n";
break;
case "C":
echo "<option selected value=\"".$TEMP_TYPE."\">Celcius</option> \n";
echo "<option value=\"F\">Farenheit</option> \n";
break;
default:
echo "<option value=\"C\">Celcius</option> \n";
echo "<option value=\"F\">Farenheit</option> \n";
break;
}
echo "</select> \n";
echo "<p/> \n";
echo "Include Locale in output: \n";
PrintSettingCheckbox("Include Locale", "INCLUDE_LOCALE", $restart = 0, $reboot = 0, "1", "0", $pluginName = $pluginName, $callbackName = "");
// PrintSettingText("SEPARATOR", $restart = 0, $reboot = 0, $maxlength = 3, $size = 3, $pluginName);
echo "<p/> \n";
echo "Separator: \n";
echo "<input type=\"text\" name=\"SEPARATOR\" size=\"2\" value=\"".$SEPARATOR."\"> \n";
// PrintSettingText("SEPARATOR", $restart = 0, $reboot = 0, $maxlength = 3, $size = 3, $pluginName);
echo "<p/> \n";
echo "Include Temp: ";
//if($INCLUDE_TEMP== 1 || $INCLUDE_TEMP == "on") {
//echo "<input type=\"checkbox\" checked name=\"INCLUDE_TEMP\"> \n";
PrintSettingCheckbox("Include Temp", "INCLUDE_TEMP", $restart = 0, $reboot = 0, "1", "0", $pluginName = $pluginName, $callbackName = "");
//} else {
//echo "<input type=\"checkbox\" name=\"INCLUDE_TEMP\"> \n";
//}
echo "<p/> \n";
echo "Include Wind: ";
// if($INCLUDE_WIND == 1 || $INCLUDE_WIND == "on") {
// echo "<input type=\"checkbox\" checked name=\"INCLUDE_WIND\"> \n";
PrintSettingCheckbox("Include Wind", "INCLUDE_WIND", $restart = 0, $reboot = 0, "1", "0", $pluginName = $pluginName, $callbackName = "");
//} else {
// echo "<input type=\"checkbox\" name=\"INCLUDE_WIND\"> \n";
//}
echo "<p/> \n";
echo "Include Humidity: ";
// if($INCLUDE_HUMIDITY == 1 || $INCLUDE_HUMIDITY == "on") {
// echo "<input type=\"checkbox\" checked name=\"INCLUDE_HUMIDITY\"> \n";
PrintSettingCheckbox("Include Humidity", "INCLUDE_HUMIDITY", $restart = 0, $reboot = 0, "1", "0", $pluginName = $pluginName, $callbackName = "");
//} else {
//echo "<input type=\"checkbox\" name=\"INCLUDE_HUMIDITY\"> \n";
//}
echo "<p/> \n";
echo "Include Degree Symbol (°): ";
// if($INCLUDE_HUMIDITY == 1 || $INCLUDE_HUMIDITY == "on") {
// echo "<input type=\"checkbox\" checked name=\"INCLUDE_HUMIDITY\"> \n";
PrintSettingCheckbox("Include Degree Symbol", "INCLUDE_DEGREE_SYMBOL", $restart = 0, $reboot = 0, "1", "0", $pluginName = $pluginName, $callbackName = "");
//} else {
//echo "<input type=\"checkbox\" name=\"INCLUDE_HUMIDITY\"> \n";
//}
echo "<p/> \n";
echo "API KEY: \n";
echo "<input type=\"text\" name=\"API_KEY\" size=\"64\" value=\"".$API_KEY."\"> \n";
// PrintSettingText("API_KEY", $restart = 1, $reboot = 0, $maxlength = 64, $size = 64, $pluginName);
echo "<p/> \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;
}
?>
</form>
<p>To report a bug, please file it against the project on Git: https://github.com/LightsOnHudson/FPP-Plugin-Weather
</fieldset>
</div>
<br />
</html>