forked from LightsOnHudson/FPP-Plugin-Matrix-Message
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcommonFunctions.inc.php
executable file
·69 lines (45 loc) · 1.61 KB
/
commonFunctions.inc.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
<?php
//get the string between two characters
function get_string_between ($str,$from,$to) {
$string = substr($str,strpos($str,$from)+strlen($from));
if (strstr ($string,$to,TRUE) != FALSE) {
$string = strstr ($string,$to,TRUE);
}
return $string;
}
//update plugin
function updatePluginFromGitHub($gitURL, $branch="master", $pluginName) {
global $settings;
logEntry ("updating plugin: ".$pluginName);
logEntry("settings: ".$settings['pluginDirectory']);
//create update script
//$gitUpdateCMD = "sudo cd ".$settings['pluginDirectory']."/".$pluginName."/; sudo /usr/bin/git git pull ".$gitURL." ".$branch;
$pluginUpdateCMD = "/opt/fpp/scripts/update_plugin ".$pluginName;
logEntry("update command: ".$pluginUpdateCMD);
exec($pluginUpdateCMD, $updateResult);
//logEntry("update result: ".print_r($updateResult));
//loop through result
return;// ($updateResult);
}
function directoryToArray($directory, $recursive) {
$array_items = array();
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
if (is_dir($directory. "/" . $file)) {
if($recursive) {
$array_items = array_merge($array_items, directoryToArray($directory. "/" . $file, $recursive));
}
$file = $directory . "/" . $file;
$array_items[] = preg_replace("/\/\//si", "/", $file);
} else {
$file = $directory . "/" . $file;
$array_items[] = preg_replace("/\/\//si", "/", $file);
}
}
}
closedir($handle);
}
return $array_items;
}
?>