This repository has been archived by the owner on Jun 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
backend.php
519 lines (413 loc) · 16.6 KB
/
backend.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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
<?php
if ($_GET['action'] == 'stop') {
$outputtext = "player stopped";
system("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/testscreenoff.py &");
}
if ($_GET['action'] == 'startmaster') {
exec("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/testscreenoff.py &");
exec("sudo /var/www/sync/startmaster.py");
$outputtext = "start player as master";
}
if ($_GET['action'] == 'startmaster01') {
exec("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/testscreenoff.py &");
exec("sudo /var/www/sync/startmaster01.py");
$outputtext = "start video 01 loop";
}
if ($_GET['action'] == 'startmaster02') {
exec("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/testscreenoff.py &");
exec("sudo /var/www/sync/startmaster02.py");
$outputtext = "start video 02 loop";
}
if ($_GET['action'] == 'startmaster03') {
exec("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/testscreenoff.py &");
exec("sudo /var/www/sync/startmaster03.py");
$outputtext = "start video 03 loop";
}
if ($_GET['action'] == 'startmaster04') {
exec("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/testscreenoff.py &");
exec("sudo /var/www/sync/startmaster04.py");
$outputtext = "start video 04 loop";
}
if ($_GET['action'] == 'startmaster05') {
exec("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/testscreenoff.py &");
exec("sudo /var/www/sync/startmaster05.py");
$outputtext = "start video 05 loop";
}
if ($_GET['action'] == 'startmaster06') {
exec("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/testscreenoff.py &");
exec("sudo /var/www/sync/startmaster06.py");
$outputtext = "start video 06 loop";
}
if ($_GET['action'] == 'startmasteronce') {
exec("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/testscreenoff.py &");
exec("sudo /var/www/sync/startmasterone.py");
$outputtext = "start player as master once";
}
if ($_GET['action'] == 'startmasteronce01') {
exec("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/testscreenoff.py &");
exec("sudo /var/www/sync/startmasterone01.py");
$outputtext = "start video 01 once";
}
if ($_GET['action'] == 'startmasteronce02') {
exec("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/testscreenoff.py &");
exec("sudo /var/www/sync/startmasterone02.py");
$outputtext = "start video 02 once";
}
if ($_GET['action'] == 'startmasteronce03') {
exec("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/testscreenoff.py &");
exec("sudo /var/www/sync/startmasterone03.py");
$outputtext = "start video 03 once";
}
if ($_GET['action'] == 'startmasteronce04') {
exec("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/testscreenoff.py &");
exec("sudo /var/www/sync/startmasterone04.py");
$outputtext = "start video 04 once";
}
if ($_GET['action'] == 'startslave') {
exec("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/testscreenoff.py &");
exec("sudo /var/www/sync/startslave.py");
$outputtext = "start player as slave";
}
if ($_GET['action'] == 'startusb') {
exec("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/testscreenoff.py &");
exec("sudo /var/www/sync/startmasterusb.py");
$outputtext = "start player in usb mode";
}
if ($_GET['action'] == 'stopimage') {
$outputtext = "image player stopped";
system("sudo killall fbi");
}
if ($_GET['action'] == 'image') {
$outputtext = "start image player";
system("sudo killall fbi");
system("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/startimage.py > /dev/null 2>&1 & echo $!");
}
if ($_GET['action'] == 'imageusb') {
$outputtext = "start image player from usb";
system("sudo killall fbi");
system("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/startimageusb.py > /dev/null 2>&1 & echo $!");
}
//# Testscreen
if ($_GET['action'] == 'testscreen') {
exec("sudo /var/www/sync/omxkill.py");
system("sudo killall fbi");
system("sudo /var/www/sync/testscreen.py &");
$outputtext = "testscreen activated (needs 2 clicks to activate)";
}
if ($_GET['action'] == 'testscreenoff') {
system("sudo /var/www/sync/testscreenoff.py &");
$outputtext = "testscreen deactivated";
}
if ($_GET['action'] == 'audio') {
exec("sudo /var/www/sync/omxkill.py");
exec("sudo omxplayer-sync -mu /media/internal/*.mp3 > /dev/null 2>&1 & echo $!");
$outputtext = "start audio player";
}
if ($_GET['action'] == 'audiousb') {
$outputtext = "start audio player in usb mode";
exec("sudo /var/www/sync/omxkill.py");
exec("sudo omxplayer-sync -mu /media/usb/*.mp3 > /dev/null 2>&1 & echo $!");
}
if ($_GET['action'] == 'reboot') {
$outputtext = "rebooting now!";
system("sudo reboot");
}
if ($_GET['action'] == 'eject') {
$outputtext = "usb stick unmounted";
system("sudo umount /dev/sda1");
}
if ($_GET['action'] == 'mount') {
$outputtext = "usb stick mounted";
system("sudo mount /dev/sda1 /media/usb/");
}
if ($_GET['action'] == 'master') {
$outputtext = "master set";
system("sudo cp /var/www/sync/rc.local.master /etc/rc.local");
}
if ($_GET['action'] == 'slave') {
$outputtext = "slave set";
system("sudo cp /var/www/sync/rc.local.slave /etc/rc.local");
}
if ($_GET['action'] == 'extension1') {
$outputtext = "extension1 set";
system("sudo cp /var/www/sync/rc.local.ext1 /etc/rc.local");
}
if ($_GET['action'] == 'usb') {
$outputtext = "usb mode set";
system("sudo cp /var/www/sync/rc.local.usb /etc/rc.local");
}
if ($_GET['action'] == 'setimage') {
$outputtext = "set to image player";
system("sudo cp /var/www/sync/rc.local.image /etc/rc.local");
}
if ($_GET['action'] == 'setimageusb') {
$outputtext = "image player usb mode set";
system("sudo cp /var/www/sync/rc.local.imageusb /etc/rc.local");
}
if ($_GET['action'] == 'setaudio') {
$outputtext = "autostart audio set";
system("sudo cp /var/www/sync/rc.local.audio /etc/rc.local");
}
if ($_GET['action'] == 'setaudiousb') {
$outputtext = "autostart audio usb set";
system("sudo cp /var/www/sync/rc.local.audiousb /etc/rc.local");
}
if ($_GET['action'] == 'bootconf') {
$outputtext = "custom boot conf to boot";
system("sudo cp /media/internal/config.txt /boot/config.txt");
}
if ($_GET['action'] == 'bootconfusb') {
$outputtext = "custom boot conf from usb to boot";
system("sudo cp /media/usb/config.txt /boot/config.txt");
}
if ($_GET['action'] == 'hdmireset') {
$output = "reset resolution settings";
system("sudo cp /var/www/sync/defaulthdmi /boot/config.txt");
}
if ($_GET['action'] == 'hdmi1') {
$output = "forced to use hdmi VGA";
system("sudo cp /var/www/sync/forcehdmi1 /boot/config.txt");
}
if ($_GET['action'] == 'hdmi4') {
$outputtext = "forced to use hdmi 720p";
system("sudo cp /var/www/sync/forcehdmi4 /boot/config.txt");
}
if ($_GET['action'] == 'hdmi5') {
$outputtext = "forced to fullHD 1080";
system("sudo cp /var/www/sync/forcehdmi5 /boot/config.txt");
}
if ($_GET['action'] == 'hdmivga') {
$outputtext = "hdmi to vga 800x600";
system("sudo cp /var/www/sync/forcevga /boot/config.txt");
}
if ($_GET['action'] == 'force1200') {
$outputtext = "force 1920x1200 rb";
system("sudo cp /var/www/sync/force1200 /boot/config.txt");
}
if ($_GET['action'] == 'clean') {
$outputtext = "clean hidden files";
system("sudo rm -R /media/internal/.[DTf_]*");
system("sudo rm -R /media/internal/__MACOSX");
}
if ($_GET['action'] == 'screenon') {
$outputtext = shell_exec('sudo /opt/vc/bin/tvservice -p');
}
if ($_GET['action'] == 'screenoff') {
$outputtext = shell_exec('sudo /opt/vc/bin/tvservice -o');
}
//# Display Info
if ($_GET['action'] == 'getresolution') {
$output = shell_exec('sudo tvservice -s');
$preoutputtext = "<pre>$output</pre>";
$outputtext = wordwrap($preoutputtext, 51, "<br />\n");
}
if ($_GET['action'] == 'parser') {
$output = shell_exec('sudo tvservice -d edid.dat');
$output = shell_exec('sudo edidparser edid.dat');
$preoutputtext = "<pre>$output</pre>";
$outputtext = wordwrap($preoutputtext, 51, "<br />\n");
}
if ($_GET['action'] == 'codecinfo') {
$output = shell_exec('mediainfo --Inform="General;%CompleteName% Format: %Format% Codec: %CodecID% Bitrate: %OverallBitRate% " /media/internal/*');
$preoutputtext = "<pre>$output</pre>";
$outputtext = wordwrap($preoutputtext, 33, "<br />\n");
}
if ($_GET['action'] == 'movieinfo') {
$output = shell_exec('mediainfo --Inform="Video;Videosize: %Width%x%Height% pixel " /media/internal/*');
$preoutputtext2 = "<pre>$output</pre>";
$newtext = wordwrap($preoutputtext2, 30, "<br />\n");
$outputtext = "$newtext\n";
}
if ($_GET['action'] == 'diskspace') {
$output = shell_exec('df -h /media');
$preoutputtext = "<pre>$output</pre>";
$outputtext = wordwrap($preoutputtext, 51, "<br />\n");
}
//# Firmmware Stuff
if ($_GET['action'] == 'firmware') {
$outputtext = "upgrade player and sync";
system("sudo cp /media/usb/omxplayer /usr/bin/omxplayer");
system("sudo cp /media/usb/omxplayer.bin /usr/bin/omxplayer.bin");
system("sudo cp /media/usb/omxplayer-sync /usr/bin/omxplayer-sync");
}
if ($_GET['action'] == 'controlpanel') {
$outputtext = "update ControlPanel USB";
system("sudo cp -r /media/usb/www/* /var/www");
system("sudo chmod 755 -R /var/www");
}
if ($_GET['action'] == 'controlpanelintern') {
$outputtext = "update ControlPanel internal";
system("sudo cp -r /media/internal/www/* /var/www");
system("sudo chmod 755 -R /var/www");
system("sudo rm -r /media/internal/www");
}
if ($_GET['action'] == 'depencies1') {
$outputtext = "update depencies";
system("sudo /var/www/sync/omxkill.py");
system("sudo /var/www/sync/testscreenoff.py &");
system("sudo /var/www/sync/depencies1.py &");
}
if ($_GET['action'] == 'factoryreset') {
$outputtext = "factory reset system";
system("sudo cp /var/www/sync/omxplayer-sync /usr/bin/omxplayer-sync");
system("sudo cp /var/www/sync/defaulthdmi /boot/config.txt");
system("sudo cp /var/www/sync/rc.local.master /etc/rc.local");
system("sudo chmod 755 -R /var/www");
}
if ($_GET['action'] == 'removeold') {
$outputtext = "old cp removed";
system("sudo rm /var/www/index.php");
}
//# Audio Volume
if ($_GET['action'] == 'volume_up') {
system("sudo su - pi -c 'amixer set Master 10%+'");
$outputtext = "<pre>$output</pre>";
}
if ($_GET['action'] == 'volume_down') {
system("sudo su - pi -c 'amixer set Master 10%-'");
$outputtext = "<pre>$output</pre>";
}
//# Audio Output
if ($_GET['action'] == 'hdmi_out') {
system("sudo sed -ri 's/-o [a-z]+/-o hdmi/' /etc/rc.local");
system("sudo sed -ri 's/-o [a-z]+/-o hdmi/' /var/www/sync/startmaster.py");
system("sudo sed -ri 's/-o [a-z]+/-o hdmi/' /var/www/sync/startmasterusb.py");
system("sudo sed -ri 's/-o [a-z]+/-o hdmi/' /var/www/sync/startmasterone.py");
system("sudo sed -ri 's/-o [a-z]+/-o hdmi/' /var/www/sync/startslave.py");
system("sudo sed -ri 's/-o [a-z]+/-o hdmi/' /var/www/sync/startmaster01.py");
system("sudo sed -ri 's/-o [a-z]+/-o hdmi/' /var/www/sync/startmaster02.py");
system("sudo sed -ri 's/-o [a-z]+/-o hdmi/' /var/www/sync/startmaster03.py");
system("sudo sed -ri 's/-o [a-z]+/-o hdmi/' /var/www/sync/startmaster04.py");
system("sudo sed -ri 's/-o [a-z]+/-o hdmi/' /var/www/sync/startmaster05.py");
system("sudo sed -ri 's/-o [a-z]+/-o hdmi/' /var/www/sync/startmaster06.py");
system("sudo sed -ri 's/-o [a-z]+/-o hdmi/' /var/www/sync/startmasterone01.py");
system("sudo sed -ri 's/-o [a-z]+/-o hdmi/' /var/www/sync/startmasterone02.py");
system("sudo sed -ri 's/-o [a-z]+/-o hdmi/' /var/www/sync/startmasterone03.py");
$outputtext = "Audio set to HDMI";
}
if ($_GET['action'] == 'jack_out') {
system("sudo sed -ri 's/-o [a-z]+/-o local/' /etc/rc.local");
system("sudo sed -ri 's/-o [a-z]+/-o local/' /var/www/sync/startmaster.py");
system("sudo sed -ri 's/-o [a-z]+/-o local/' /var/www/sync/startmasterusb.py");
system("sudo sed -ri 's/-o [a-z]+/-o local/' /var/www/sync/startmasterone.py");
system("sudo sed -ri 's/-o [a-z]+/-o local/' /var/www/sync/startslave.py");
system("sudo sed -ri 's/-o [a-z]+/-o local/' /var/www/sync/startmaster01.py");
system("sudo sed -ri 's/-o [a-z]+/-o local/' /var/www/sync/startmaster02.py");
system("sudo sed -ri 's/-o [a-z]+/-o local/' /var/www/sync/startmaster03.py");
system("sudo sed -ri 's/-o [a-z]+/-o local/' /var/www/sync/startmaster04.py");
system("sudo sed -ri 's/-o [a-z]+/-o local/' /var/www/sync/startmaster05.py");
system("sudo sed -ri 's/-o [a-z]+/-o local/' /var/www/sync/startmaster06.py");
system("sudo sed -ri 's/-o [a-z]+/-o local/' /var/www/sync/startmasterone01.py");
system("sudo sed -ri 's/-o [a-z]+/-o local/' /var/www/sync/startmasterone02.py");
system("sudo sed -ri 's/-o [a-z]+/-o local/' /var/www/sync/startmasterone03.py");
$outputtext = "Audio set to Jack";
}
if ($_GET['action'] == 'both_out') {
system("sudo sed -ri 's/-o [a-z]+/-o both/' /etc/rc.local");
system("sudo sed -ri 's/-o [a-z]+/-o both/' /var/www/sync/startmaster.py");
system("sudo sed -ri 's/-o [a-z]+/-o both/' /var/www/sync/startmasterusb.py");
system("sudo sed -ri 's/-o [a-z]+/-o both/' /var/www/sync/startmasterone.py");
system("sudo sed -ri 's/-o [a-z]+/-o both/' /var/www/sync/startslave.py");
system("sudo sed -ri 's/-o [a-z]+/-o both/' /var/www/sync/startmaster01.py");
system("sudo sed -ri 's/-o [a-z]+/-o both/' /var/www/sync/startmaster02.py");
system("sudo sed -ri 's/-o [a-z]+/-o both/' /var/www/sync/startmaster03.py");
system("sudo sed -ri 's/-o [a-z]+/-o both/' /var/www/sync/startmaster04.py");
system("sudo sed -ri 's/-o [a-z]+/-o both/' /var/www/sync/startmaster05.py");
system("sudo sed -ri 's/-o [a-z]+/-o both/' /var/www/sync/startmaster06.py");
system("sudo sed -ri 's/-o [a-z]+/-o both/' /var/www/sync/startmasterone01.py");
system("sudo sed -ri 's/-o [a-z]+/-o both/' /var/www/sync/startmasterone02.py");
system("sudo sed -ri 's/-o [a-z]+/-o both/' /var/www/sync/startmasterone03.py");
$outputtext = "Audio set to both";
}
if ($_GET['action'] == 'screenshare') {
$outputtext = "set to screenshare mode";
system("sudo cp /var/www/sync/rc.local.screenshare /etc/rc.local");
}
if ($_GET['action'] == 'imageconform') {
system("sudo mogrify -format jpg /media/internal/*.png");
system("sudo mogrify -format jpg /media/internal/*.tiff");
system("sudo mogrify -format jpg /media/internal/*.tif");
system("sudo mogrify -format jpg /media/internal/*.jpeg");
system("sudo mogrify -format jpg /media/internal/*.bmp");
system("sudo mogrify -format jpg /media/internal/*.gif");
system("sudo rm /media/internal/*.png");
system("sudo rm /media/internal/*.tiff");
system("sudo rm /media/internal/*.tif");
system("sudo rm /media/internal/*.jpeg");
system("sudo rm /media/internal/*.bmp");
system("sudo rm /media/internal/*.gif");
system("sudo mogrify -resize 1920x1080\> /media/internal/*.jpg");
$outputtext = "FINISHED! all images converted to jpg and resized to HD";
}
//# Slideshow Time
if ($_GET['action'] == 'slidetime5') {
system("sudo sed -ri 's/-t [0-9]+/-t 5/' /var/www/sync/startimage.py");
system("sudo sed -ri 's/-t [0-9]+/-t 5/' /var/www/sync/startimageusb.py");
$outputtext = "set slideshowtime to 5s";
}
if ($_GET['action'] == 'slidetime10') {
system("sudo sed -ri 's/-t [0-9]+/-t 10/' /var/www/sync/startimage.py");
system("sudo sed -ri 's/-t [0-9]+/-t 10/' /var/www/sync/startimageusb.py");
$outputtext = "set slideshowtime to 10s";
}
if ($_GET['action'] == 'slidetime15') {
system("sudo sed -ri 's/-t [0-9]+/-t 15/' /var/www/sync/startimage.py");
system("sudo sed -ri 's/-t [0-9]+/-t 15/' /var/www/sync/startimageusb.py");
$outputtext = "set slideshowtime to 15s";
}
//# Extension
if ($_GET['action'] == 'temperature') {
$output = shell_exec('sudo /var/www/sync/temperature.py 11 4');
$preoutputtext = "<pre>$output</pre>";
$outputtext = wordwrap($preoutputtext, 51, "<br />\n");
}
if ($_GET['action'] == 'heateron') {
$outputtext = "Heater ON !!!";
system("sudo /var/www/sync/relais1_on.py &");
}
if ($_GET['action'] == 'heateroff') {
$outputtext = "Heater OFF !!!";
system("sudo /var/www/sync/relais1_off.py &");
}
//# Sheduler
if ($_GET['action'] == 'setscheduler') {
$outputtext = "autostart into scheduler mode";
system("sudo cp /var/www/sync/rc.local.scheduler /etc/rc.local");
}
if ($_GET['action'] == 'gettime') {
$output = shell_exec('date');
$preoutputtext = "<pre>$output</pre>";
$outputtext = wordwrap($preoutputtext, 51, "<br />\n");
}
if ($_GET['action'] == 'timeron') {
$outputtext = "enable scheduler, TIMER ON";
system("sudo crontab /media/timer.txt");
}
if ($_GET['action'] == 'timeroff') {
$outputtext = "disable scheduler, NO TIMER";
system("sudo crontab /var/www/sync/notimer");
}
if ($_GET['action'] == 'timer') {
$output = shell_exec('sudo crontab -l | grep -v "^$\|^\s*\#"');
$preoutputtext = "<pre>$output</pre>";
$outputtext = wordwrap($preoutputtext, 102, "<br />\n");
}
echo $outputtext;
?>