This repository has been archived by the owner on Aug 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathsetup.php
234 lines (209 loc) · 7.4 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
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
<?php
/*
* @author: Scottish Borders Design
* @script: SBD SHOUTcast Manager
* @function: Settings Page
* @website: http://scottishbordersdesign.co.uk/
*/
////////////////////////////////////////////////////////////////////////
require('header.php');
// Process changes if we are called by form
if (isset($_POST['configsub'])) {
unset($_POST['configsub']);
updatesettings($_POST);
docheck(1);
header("Location: setup.php?group=$_POST[category]&return=3");
exit;
}
// Use first settings group as default
if (!isset($_REQUEST['group'])) { $_REQUEST['group'] = 1; }
// Build menu of setting groups
$menu = "<div class=\"nav-tabs-custom\"><ul class=\"nav nav-tabs\">";
foreach (confgroups() as $group) {
if ($group['id'] == $_REQUEST['group']) {
$activegroup = $group;
$menu .= "<li class=\"active\"><a href='#'>".$group['name']."</a></li>";
} else {
$menu .= "<li><a class=\"headbarlink\" href=\"".$_SERVER['PHP_SELF']."?group=".$group['id']."\">".$group['name']."</a></li>";
}
}
$menu .= "</ul>";
?>
<h1>
Administration
<small><?php echo $activegroup['title']; ?></small>
</h1>
<ol class="breadcrumb">
<li><a href="home.php"><i class="fa fa-dashboard"></i> SHOUTcast Panel</a></li>
<li class="active"><i class="glyphicon glyphicon-gear"></i> Administration - <?php echo $activegroup['title']; ?></li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-xs-12">
<?php
if(useraccess($_SESSION['username']) < "5") {
// do nothing
} else {
if (isset($_GET['return']) && $_GET['return']=='3') {
?>
<div class="alert alert-success alert-dismissable">
<i class="fa fa-check"></i>
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<b>Success!</b> Your settings have been saved.
</div>
<?php
}
echo $menu;
} ?>
<div class="tab-content">
<div class="tab-pane active" id="tab_1">
<?php // Store fields from submit
?>
<form action="" method="post" enctype="multipart/form-data">
<section id="portfolio" class="two">
<div class="container">
<table border = "0">
<?php
if(useraccess($_SESSION['username']) < "5") {
echo "<div class=\"alert alert-danger alert-dismissable\"><i class=\"fa fa-ban\"></i><button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">×</button><b>ERROR!</b> ACCESS DENIED - YOU DO NOT HAVE ACCESS TO SERVER SETTINGS</div>";
} else {
/*
Preprocess dynamic update of multiple choices
*/
$db = dbConnect();
$config = settings();
$dnas = array();
fetchAndUpdateLang();
fetchAndUpdateTheme();
$db->where('setting', 'media_url');
$db->update('config', array('value' => $config['web_addr'].'/autodj/mp3s/'));
$db->where('setting', 'media_path');
$db->update('config', array('value' => $config['sbd_path'].'/autodj/mp3s/'));
// Find available SHOUTcast DNAS binaries
$path = $config['sbd_path']."/shoutcast";
if ($mainhandle = opendir($path)) {
// Read contents of 'shoutcast/' directory
while ($dir=readdir($mainhandle)) {
// Do not read directories '.', '..', '.svn', etc.
if (is_dir($path.'/'.$dir) && substr($dir, 0, 1) != ".") {
// Open the directories we found under 'shoutcast/'
if ($localhandle = opendir($path.'/'.$dir)) {
// Check the names of contents that are files, add sc_serv
while ($file=readdir($localhandle)) {
if (is_file($path.'/'.$dir.'/'.$file)
&& (strtoupper($file) == "SC_SERV" || strtoupper($file) == "SC_SERV.EXE")) {
// If it's an sc_serv binary, add it to the list of DNAS'es
$dnas[$dir] = $path."/".$dir."/".$file;
}
}
}
}
}
}
// Find the record id for the 'sc_serv' setting
$db->orderBy("id", "ASC");
$db->where("setting", "sc_serv");
$row = $db->getOne("config");
$row = index_array($row);
$configid = $row[0];
// Replace any existing entries with the DNAS binary paths found
$db->where('configid', $configid);
$db->delete('config_sets');
foreach ($dnas as $key => $value) {
$db->insert('config_sets', array( 'configid' => $configid,
'value' => $value,
'caption' => $key )
);
}
// Find available SHOUTcast DNAS binaries
$path = $config['sbd_path']."/shoutcast";
if ($mainhandle = opendir($path)) {
// Read contents of 'shoutcast/' directory
while ($dir=readdir($mainhandle)) {
// Do not read directories '.', '..', '.svn', etc.
if (is_dir($path.'/'.$dir) && substr($dir, 0, 1) != ".") {
// Open the directories we found under 'shoutcast/'
if ($localhandle = opendir($path.'/'.$dir)) {
// Check the names of contents that are files, add SC_TRANS
while ($file=readdir($localhandle)) {
if (is_file($path.'/'.$dir.'/'.$file)
&& (strtoupper($file) == "SC_TRANS" || strtoupper($file) == "SC_TRANS.EXE")) {
// If it's an SC_TRANS binary, add it to the list of DNAS'es
$dnas[$dir] = $path."/".$dir."/".$file;
}
}
}
}
}
}
// Find the record id for the 'SC_TRANS' setting
$db = dbConnect();
$db->orderBy("id", "ASC");
$db->where("setting", "SC_TRANS");
$row = $db->getOne("config");
$row = index_array($row);
$configid = $row[0];
// Replace any existing entries with the DNAS binary paths found
$db->where('configid', $configid);
$db->delete('config_sets');
foreach ($dnas as $key => $value) {
$db->insert('config_sets', array( 'configid' => $configid,
'value' => $value,
'caption' => $key )
);
}
/*
Proceed to build settings form
*/
// Fetch settings for selected group (if any)
$settings = groupsettings($_REQUEST['group']);
if (isset($settings)) {
foreach ($settings as $setting) {
echo "<div class=\"form-group\"><label>".$setting['title']."</label>";
// Check to see if this is a multiple choice setting
$options = settingoptions($setting['id']);
if (isset($options) && !empty($options)) {
echo "<select class=\"form-control\" name=\"".$setting['setting']."\">";
foreach ($options as $option) {
echo "<option value=\"".$option['value']."\"";
if ($option['value'] == $setting['value']) {
echo " selected>";
} else {
echo ">";
}
echo $option['caption']."</option>
";
}
echo "</select>
";
} else {
if (strlen($setting['value']) < 8) {
$fieldsize = "10";
} else {
$fieldsize = "50";
}
echo "<input type=\"text\" class=\"form-control\" name=\"".$setting['setting']."\" value=\"".$setting['value']."\" placeholder=\"".$setting['value']."\" size=\"".$fieldsize."\"></div>";
}
}
echo "<input type=\"hidden\" name=\"category\" value=\"".$_REQUEST['group']."\">";
$lastline = "<div class=\"box-footer\"><button type=\"submit\" name=\"configsub\" class=\"btn btn-primary\">Save Changes</button></div>";
} else {
$lastline = "<div class=\"box-footer\">".$activegroup['title']." category is empty.</div>";
}
}
?>
<tr>
<td><br> </td><td> </td>
<td><?php echo $lastline; ?></td>
</tr>
</table><br />
</div>
</section>
</form>
</div><!-- /.tab-pane -->
</div><!-- /.tab-content -->
</div>
<?php require('footer.php');
?>