-
Notifications
You must be signed in to change notification settings - Fork 6
/
function.inc.php
152 lines (125 loc) · 3.7 KB
/
function.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
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
<?php
class trans
{
var $host;
var $port;
var $adminpass;
var $adminuser;
function getInfoTrans($option)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://'.$this->adminuser.':'.$this->adminpass.'@'.$this->host.':'.$this->port.'/api');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $option);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$xml = curl_exec($ch);
return($xml);
curl_close ($ch);
}
}
class strings {
function between($von,$bis,$string)
{
##$von (<teil>)
##$bis (</teil>)
##$string = datei
$a = explode($von,$string);
$b = explode($bis,$a[1]);
return($b[0]);
}
function file_list($dir) {
global $sort;
global $file_file_count;
if (is_dir($dir)):
$fd = @opendir($dir);
while (($part = @readdir($fd)) == true):
clearstatcache();
if ($part != '.' && $part != '..'):
$file_array[] = $part;
endif;
endwhile;
if($fd == true):
closedir($fd);
endif;
if (is_array($file_array)):
$sort($file_array);
$file_file_count = count($file_array);
return $file_array;
else:
return false;
endif;
else:
return false;
endif;
}
function generate_file_list($path) {
global $download_path;
$final_path = str_replace("//","/",str_replace("..","",urldecode($path)));
$file_array = $this->file_list("$download_path/$final_path/");
echo '<strong>'.$final_path.'/</strong>';
echo '<br />';
if ($file_array == false):
echo 'Verzeichnis ist leer.';
else:
echo '<div style="overflow: auto; height: 200px;">';
echo '<table border="1" cellpadding="2" cellspacing="3" class="display"><thead>
<tr>
<th>Dateiname</th>
<th>Pfad</th>
<th>Select</th>
</tr></thead><tbody>';
foreach ($file_array as $file_name):
$is_file = "$download_path/$final_path/$file_name";
$final_dir_name = urlencode($final_path);
$final_file_name = urlencode($file_name);
if (is_file($is_file)):
echo '<tr class="odd">';
echo '<td>'.$file_name.'</td>';
echo '<td>'.$_SERVER['DOCUMENT_ROOT'].'/files'.$final_path.'</td>';
echo '<td> <input type="checkbox" name="mp3[]"></td>';
echo "</tr>\n";
elseif (is_dir($is_file)):
echo '<tr class="even">';
echo '<td><a href="?page=modi&mode=play&go=list&path='.$final_dir_name.'/'.$final_file_name.'">'.$file_name.'/</a></td>';
echo '<td>Verzeichnis</td>';
echo '<td> </td>';
echo "</tr>\n";
endif;
endforeach;
echo '</tbody></table></div>';
endif;
}
function generate_file_list_type2($path) {
global $download_path;
$final_path = str_replace("//","/",str_replace("..","",urldecode($path)));
$file_array = $this->file_list("$download_path/$final_path/");
if ($file_array == false):
echo '<li>Verzeichnis ist leer.</li>';
else:
foreach ($file_array as $file_name):
$is_file = "$download_path/$final_path/$file_name";
$final_dir_name = urlencode($final_path);
$final_file_name = urlencode($file_name);
if (is_file($is_file)):
echo '<li>'.$file_name.' | ';
echo '<input type="checkbox" name="mp3[]"></li>';
elseif (is_dir($is_file)):
echo '<li><a href="?page=modi&mode=play&go=list&path='.$final_dir_name.'/'.$final_file_name.'">'.$file_name.'/</a> | ';
echo 'Verzeichnis</li>';
endif;
endforeach;
endif;
}
function load_xml($action, $file = 'serverinfo.xml', $dir = 'xml/')
{
$handle = fopen ($dir.$file, w);
fwrite ($handle, $action);
fclose ($handle);
$xml = simplexml_load_file($dir.$file);
$array = json_decode(json_encode((array) $xml), 1);
$array = array($xml->getName() => $array);
return $array;
//unlink($dir.$file);
}
}
?>