-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.php
executable file
·109 lines (95 loc) · 3.47 KB
/
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
<?php
new setup();
class setup {
private $globs;
function __construct() {
$this->globs = new globals(false);
if($this->globs->isNew()) {
$this->createConfig();
header('location: /roku/configuration.php?new=true');
}
}
private function createConfig() {
//Linux machine
if (strtoupper(substr(PHP_OS, 0, 3)) === 'LIN') {
$videoPath = "~/movies/";
$serverConf = "/etc/apache2/apache2.conf";
//Modify permissions for linux systems
exec("chmod 777 /var/www/xml/all.xml");
exec("chmod 777 /var/www/xml/configTemplate.xml");
exec("chmod 777 /var/www/xml/playlist.xml");
exec("chmod 777 /var/www/xml/rokuConfig.xml");
exec("chmod 777 /var/www/movies.conf");
exec("chmod 777 $serverConf");
}
//Mac Machine
if (strtoupper(substr(PHP_OS, 0, 3)) === 'DAR') {
exec("chmod 777 '/Applications/MAMP/htdocs/roku/mediainfo'");
$videoPath = exec("cd ~ && pwd")."/Movies/";
$serverConf = "/Applications/MAMP/conf/apache/httpd.conf";
}
//Windows Machine
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$videoPath = "C:/Users/Public/Videos/";
$serverConf = "C:/wamp/bin/apache/Apache2.2.17/conf/httpd.conf";
}
$this->globs->setup($serverConf, $videoPath, $this->getServerIp());
}
function getServerIp() {
$matches = array();
//Linux machine
if (strtoupper(substr(PHP_OS, 0, 3)) === 'LIN') {
$interface = false;
exec("ifconfig", $output, $return);
foreach ($output as $line) {
if (strpos($line, "th0"))
$interface = true;
if ($interface) {
if (strpos($line, "inet ")) {
if(preg_match_all('/([0-9]{1,3}\.){3}[0-9]{1,3}/', $line, $matches) !== false)
break;
}
}
}
if(count($matches) > 0) {
return $matches[0][0];
} else
return "0.0.0.0";
}
//Mac Machine
if (strtoupper(substr(PHP_OS, 0, 3)) === 'DAR') {
$interface = false;
exec("ifconfig", $output, $return);
foreach ($output as $line) {
if (strpos($line, "n0"))
$interface = true;
if ($interface) {
if (strpos($line, "net ")) {
if(preg_match_all('/([0-9]{1,3}\.){3}[0-9]{1,3}/', $line, $matches) !== false)
break;
}
}
}
if(count($matches) > 0) {
return $matches[0][0].":8888";
} else
return "0.0.0.0";
}
//Windows Machine
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$interface = false;
exec("ipconfig /all", $output, $return);
foreach ($output as $line) {
if (strpos($line, "IPv4") || strpos($line, "IP Address")) {
if(preg_match_all('/([0-9]{1,3}\.){3}[0-9]{1,3}/', $line, $matches) !== false)
break;
}
}
if(count($matches) > 0) {
return $matches[0][0];
} else
return "0.0.0.0";
}
}
}
?>