]>
Commit | Line | Data |
---|---|---|
a28fdc01 CS |
1 | #!/usr/bin/perl |
2 | # | |
3 | # IPFire CGIs | |
4 | # | |
5 | # This code is distributed under the terms of the GPL | |
6 | # | |
7 | # (c) The IPFire Team | |
8 | ||
9 | use strict; | |
10 | # enable only the following on debugging purpose | |
11 | use warnings; | |
12 | use CGI::Carp 'fatalsToBrowser'; | |
13 | ||
14 | require '/var/ipfire/general-functions.pl'; | |
15 | require "${General::swroot}/lang.pl"; | |
16 | require "${General::swroot}/header.pl"; | |
17 | ||
18 | my %color = (); | |
19 | my %mainsettings = (); | |
20 | my %mpfiresettings = (); | |
21 | my %checked = (); | |
22 | my $message = ""; | |
23 | my $errormessage = ""; | |
24 | ||
25 | open(DATEI, "<${General::swroot}/mpfire/db/songs.db") || die "No Database found"; | |
26 | my @songdb = <DATEI>; | |
27 | close(DATEI); | |
28 | @songdb = sort(@songdb); | |
29 | ||
30 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
31 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
32 | ||
33 | &Header::showhttpheaders(); | |
34 | &Header::getcgihash(\%mpfiresettings); | |
35 | ||
a2d5130f | 36 | &Header::openpage($Lang::tr{'mpfire'}, 1, "<meta http-equiv='refresh' content='120'>"); |
a28fdc01 CS |
37 | &Header::openbigbox('100%', 'left', '', $errormessage); |
38 | ||
a28fdc01 CS |
39 | ############################################################################################################################ |
40 | ######################################## Scanne Verzeichnisse nach Mp3 Dateien ############################################# | |
41 | ||
42 | if ( $mpfiresettings{'ACTION'} eq "scan" ) | |
43 | { | |
44 | delete $mpfiresettings{'__CGI__'};delete $mpfiresettings{'x'};delete $mpfiresettings{'y'}; | |
45 | &General::writehash("${General::swroot}/mpfire/settings", \%mpfiresettings); | |
46 | system("/usr/local/bin/mpfirectrl scan $mpfiresettings{'SCANDIR'} $mpfiresettings{'SCANDIRDEPS'}"); | |
47 | } | |
48 | ||
a2d5130f | 49 | if ( $mpfiresettings{'ACTION'} eq ">" ){system("/usr/local/bin/mpfirectrl","play","\"$mpfiresettings{'FILE'}\"");} |
a28fdc01 CS |
50 | if ( $mpfiresettings{'ACTION'} eq "x" ){system("/usr/local/bin/mpfirectrl stop");} |
51 | if ( $mpfiresettings{'ACTION'} eq "||" ){system("/usr/local/bin/mpfirectrl pause");} | |
52 | if ( $mpfiresettings{'ACTION'} eq "|>" ){system("/usr/local/bin/mpfirectrl resume");} | |
53 | if ( $mpfiresettings{'ACTION'} eq ">>" ){system("/usr/local/bin/mpfirectrl next");} | |
a2d5130f CS |
54 | if ( $mpfiresettings{'ACTION'} eq "stopweb" ){system("/usr/local/bin/mpfirectrl stopweb");} |
55 | if ( $mpfiresettings{'ACTION'} eq "playweb" ){system("/usr/local/bin/mpfirectrl","playweb","\"$mpfiresettings{'FILE'}\"");} | |
a28fdc01 CS |
56 | if ( $mpfiresettings{'ACTION'} eq "+" ){system("/usr/local/bin/mpfirectrl volup 5");} |
57 | if ( $mpfiresettings{'ACTION'} eq "-" ){system("/usr/local/bin/mpfirectrl voldown 5");} | |
58 | if ( $mpfiresettings{'ACTION'} eq "++" ){system("/usr/local/bin/mpfirectrl volup 10");} | |
59 | if ( $mpfiresettings{'ACTION'} eq "--" ){system("/usr/local/bin/mpfirectrl voldown 10");} | |
32ab16de CS |
60 | if ( $mpfiresettings{'ACTION'} eq "playlist" ){system("/usr/local/bin/mpfirectrl playall");} |
61 | if ( $mpfiresettings{'ACTION'} eq "playalbum" ) | |
62 | { | |
63 | my @temp = ""; | |
64 | my @album = split(/\|/,$mpfiresettings{'album'}); | |
65 | my %hash = map{ $_, 1 }@album; | |
66 | ||
67 | foreach (@songdb){ | |
68 | my @song = split(/\|/,$_); | |
69 | chomp($song[0]); | |
70 | push(@temp,$song[0]."\n") if exists $hash{$song[4]}; | |
71 | } | |
72 | open(DATEI, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist"; | |
73 | print DATEI @temp; | |
74 | close(DATEI); | |
75 | system("/usr/local/bin/mpfirectrl playall"); | |
76 | } | |
77 | if ( $mpfiresettings{'ACTION'} eq "playartist" ) | |
78 | { | |
79 | my @temp = ""; | |
80 | my @artist = split(/\|/,$mpfiresettings{'artist'}); | |
81 | my %hash = map{ $_, 1 }@artist; | |
82 | ||
83 | foreach (@songdb){ | |
84 | my @song = split(/\|/,$_); | |
85 | chomp($song[0]); | |
86 | push(@temp,$song[0]."\n") if exists $hash{$song[1]}; | |
87 | } | |
88 | open(DATEI, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist"; | |
89 | print DATEI @temp; | |
90 | close(DATEI); | |
91 | system("/usr/local/bin/mpfirectrl playall"); | |
92 | } | |
a28fdc01 CS |
93 | if ( $mpfiresettings{'ACTION'} eq "playall" ) |
94 | { | |
95 | my @temp = ""; | |
96 | foreach (@songdb){ | |
97 | my @song = split(/\|/,$_); | |
98 | chomp($song[0]); | |
99 | push(@temp,$song[0]."\n"); | |
100 | } | |
101 | open(DATEI, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist"; | |
102 | print DATEI @temp; | |
103 | close(DATEI); | |
104 | system("/usr/local/bin/mpfirectrl playall"); | |
105 | } | |
106 | if ( $mpfiresettings{'SHOWLIST'} ){delete $mpfiresettings{'__CGI__'};delete $mpfiresettings{'x'};delete $mpfiresettings{'y'};&General::writehash("${General::swroot}/mpfire/settings", \%mpfiresettings);} | |
107 | ||
108 | ############################################################################################################################ | |
109 | ################################### Aufbau der HTML Seite fr globale Sambaeinstellungen #################################### | |
110 | ||
111 | $mpfiresettings{'SCANDIR'} = "/"; | |
112 | $mpfiresettings{'SHOWLIST'} = "off"; | |
113 | ||
114 | &General::readhash("${General::swroot}/mpfire/settings", \%mpfiresettings); | |
115 | ||
116 | ############################################################################################################################ | |
117 | ########################################### rekursiv nach neuen Mp3s Scannen ##############################################รค | |
118 | ||
119 | if ( $message ne "" ) { print "<font color='red'>$message</font>"; } | |
120 | ||
121 | &Header::openbox('100%', 'center', $Lang::tr{'mpfire scanning'}); | |
a2d5130f | 122 | |
a28fdc01 CS |
123 | print <<END |
124 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
125 | <table width='95%' cellspacing='0'> | |
126 | <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'Scan for Files'}</b></td></tr> | |
127 | <tr><td align='left' width='40%'>$Lang::tr{'Scan from Directory'}</td><td align='left'><input type='text' name='SCANDIR' value='$mpfiresettings{'SCANDIR'}' size="30" /></td></tr> | |
128 | <tr><td align='left' width='40%'>$Lang::tr{'deep scan directories'}</td><td align='left'>on <input type='radio' name='SCANDIRDEPS' value='on' checked='checked'/>/ | |
129 | <input type='radio' name='SCANDIRDEPS' value='off'/> off</td></tr> | |
130 | <tr><td align='center' colspan='2'><input type='hidden' name='ACTION' value='scan' /> | |
131 | <input type='image' alt='$Lang::tr{'Scan for Files'}' title='$Lang::tr{'Scan for Files'}' src='/images/edit-find.png' /></td></tr> | |
132 | </table> | |
133 | </form> | |
134 | END | |
135 | ; | |
136 | &Header::closebox(); | |
137 | ||
a2d5130f CS |
138 | my $song = qx(/usr/local/bin/mpfirectrl song); |
139 | if ( $song eq "" ){$song = "None";} | |
140 | ||
a28fdc01 | 141 | &Header::openbox('100%', 'center', $Lang::tr{'mpfire controls'}); |
a2d5130f | 142 | print "<table width='95%' cellspacing='0'><tr bgcolor='$color{'color20'}'><td colspan='5' align='center'><marquee behavior='alternate' scrollamount='1' scrolldelay='5'><font color=red>-= $song =-</font></marquee></td></tr><tr><td colspan='5'><br/></td></tr><tr>"; |
a28fdc01 CS |
143 | print <<END |
144 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='x' /><input type='image' alt='$Lang::tr{'stop'}' title='$Lang::tr{'stop'}' src='/images/media-playback-stop.png' /></form></td> | |
145 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='||' /><input type='image' alt='$Lang::tr{'pause'}' title='$Lang::tr{'pause'}' src='/images/media-playback-pause.png' /></form></td> | |
146 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='|>' /><input type='image' alt='$Lang::tr{'resume'}' title='$Lang::tr{'resume'}' src='/images/media-resume.png' /></form></td> | |
147 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='playall' /><input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /></form></td> | |
148 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='>>' /><input type='image' alt='$Lang::tr{'next'}' title='$Lang::tr{'next'}' src='/images/media-skip-forward.png' /></form></td> | |
149 | </tr> | |
150 | END | |
151 | ; | |
152 | if ( $mpfiresettings{'SHOWLIST'} eq "on" ){print"<tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='SHOWLIST' value='off' /><input type='image' alt='$Lang::tr{'off'}' title='$Lang::tr{'off'}' src='/images/audio-x-generic.png' /></form></td>";} | |
153 | else { print"<tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='SHOWLIST' value='on' /><input type='image' alt='$Lang::tr{'on'}' title='$Lang::tr{'on'}' src='/images/audio-x-generic-red.png' /></form></td>";} | |
154 | print <<END | |
155 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='--' /><input type='image' alt='$Lang::tr{'voldown10'}' title='$Lang::tr{'voldown10'}' src='/images/audio-volume-low-red.png' /></form></td> | |
156 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='-' /><input type='image' alt='$Lang::tr{'voldown5'}' title='$Lang::tr{'voldown5'}' src='/images/audio-volume-low.png' /></form></td> | |
157 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='+' /><input type='image' alt='$Lang::tr{'volup5'}' title='$Lang::tr{'volup5'}' src='/images/audio-volume-high.png' /></form></td> | |
158 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='++' /><input type='image' alt='$Lang::tr{'volup10'}' title='$Lang::tr{'volup10'}' src='/images/audio-volume-high-red.png' /></form></td> | |
159 | </tr> | |
160 | </table> | |
161 | END | |
162 | ; | |
163 | &Header::closebox(); | |
164 | ||
32ab16de CS |
165 | &Header::openbox('100%', 'center', $Lang::tr{'quick playlist'}); |
166 | ||
167 | my @artist; | |
168 | my @album; | |
169 | foreach (@songdb){ | |
170 | my @song = split(/\|/,$_); | |
171 | push(@artist,$song[1]);push(@album,$song[4]);} | |
172 | my %hash = map{ $_, 1 }@artist; | |
173 | @artist = sort keys %hash; | |
174 | my %hash = map{ $_, 1 }@album; | |
175 | @album = sort keys %hash; | |
176 | print <<END | |
177 | <table width='95%' cellspacing='0'> | |
178 | <tr><td align='center'> | |
179 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
180 | <select name='artist' size='8' multiple='multiple'> | |
181 | END | |
182 | ; | |
183 | foreach (@artist){print "<option>$_</option>";} | |
184 | print <<END | |
185 | </select><br/> | |
186 | <input type='hidden' name='ACTION' value='playartist' /> | |
187 | <input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /> | |
188 | </form></td> | |
189 | <td align='center'> | |
190 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
191 | <select name='album' size='8' multiple='multiple'> | |
192 | END | |
193 | ; | |
194 | foreach (@album){print "<option>$_</option>";} | |
195 | print <<END | |
196 | </select><br/> | |
197 | <input type='hidden' name='ACTION' value='playalbum' /> | |
198 | <input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /> | |
199 | </form></td> | |
200 | </tr></table> | |
201 | END | |
202 | ; | |
203 | &Header::closebox(); | |
204 | ||
a28fdc01 CS |
205 | if ( $mpfiresettings{'SHOWLIST'} eq "on" ){ |
206 | ||
207 | &Header::openbox('100%', 'center', $Lang::tr{'mpfire songs'}); | |
208 | print <<END | |
209 | ||
32ab16de | 210 | <table width='95%' cellspacing='5'> |
a28fdc01 CS |
211 | <tr bgcolor='$color{'color20'}'><td colspan='9' align='left'><b>$Lang::tr{'Existing Files'}</b></td></tr> |
212 | <tr><td align='center'></td> | |
213 | <td align='center'><b>$Lang::tr{'artist'}<br/>$Lang::tr{'title'}</b></td> | |
214 | <td align='center'><b>$Lang::tr{'number'}</b></td> | |
215 | <td align='center'><b>$Lang::tr{'album'}</b></td> | |
216 | <td align='center'><b>$Lang::tr{'year'}</b></td> | |
217 | <td align='center'><b>$Lang::tr{'genre'}</b></td> | |
218 | <td align='center'><b>$Lang::tr{'length'}<br/>$Lang::tr{'bitrate'} - $Lang::tr{'frequency'}</b></td> | |
219 | <td align='center'><b>$Lang::tr{'mode'}</b></td></tr> | |
220 | END | |
221 | ; | |
222 | my $lines = 0; | |
223 | foreach (@songdb){ | |
224 | my @song = split(/\|/,$_); | |
225 | ||
226 | if ($lines % 2) {print "<tr bgcolor='$color{'color20'}'>";} else {print "<tr bgcolor='$color{'color22'}'>";} | |
227 | $song[0]=~s/\/\//\//g; | |
228 | print <<END | |
32ab16de | 229 | <td align='center' style="white-space:nowrap;"><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='>' /><input type='hidden' name='FILE' value="$song[0]" /><input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /></form></td> |
a28fdc01 CS |
230 | <td align='center'>$song[1]<br/>$song[2]</td> |
231 | <td align='center'>$song[3]</td> | |
232 | <td align='center'>$song[4]</td> | |
233 | <td align='center'>$song[5]</td> | |
234 | <td align='center'>$song[6]</td> | |
235 | <td align='center'>$song[7]:$song[8]<br/>$song[9] - $song[10]</td> | |
236 | END | |
237 | ; | |
238 | if ( $song[11] eq "0\n" ) {print "<td align='center'>Stereo</td></tr>"; } | |
239 | elsif ( $song[11] eq "1\n" ) {print "<td align='center'>Joint<br/>Stereo</td></tr>"; } | |
240 | elsif ( $song[11] eq "2\n" ) {print "<td align='center'>Dual<br/>Channel</td></tr>"; } | |
241 | elsif ( $song[11] eq "3\n" ) {print "<td align='center'>Single<br/>Channel</td></tr>"; } | |
242 | else {print "<td align='center'></td></tr>"; } | |
243 | $lines++ | |
244 | } | |
245 | print "</table></form>"; | |
246 | &Header::closebox(); | |
247 | } | |
248 | ||
32ab16de CS |
249 | &Header::openbox('100%', 'center', $Lang::tr{'mpfire playlist'}); |
250 | ||
32ab16de CS |
251 | open(DATEI, "<${General::swroot}/mpfire/playlist") || die "Could not open playlist"; |
252 | my @playlist = <DATEI>; | |
253 | close(DATEI); | |
254 | ||
255 | print <<END | |
256 | <table width='95%' cellspacing='0'> | |
257 | <tr bgcolor='$color{'color20'}'><td colspan='9' align='left'><b>$Lang::tr{'current playlist'}</b></td></tr> | |
258 | <tr><td align='center'><textarea cols='120' rows='10' name='playlist' style='font-size:10px' readonly='readonly' >@playlist</textarea><br/> | |
259 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
260 | <input type='hidden' name='ACTION' value='playlist' /> | |
261 | <input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /> | |
262 | </form></td></tr> | |
263 | </table> | |
264 | END | |
265 | ; | |
266 | &Header::closebox(); | |
267 | ||
a2d5130f CS |
268 | &Header::openbox('100%', 'center', $Lang::tr{'mpfire webradio'}); |
269 | ||
270 | open(DATEI, "<${General::swroot}/mpfire/webradio") || die "Could not open playlist"; | |
271 | my @webradio = <DATEI>; | |
272 | close(DATEI); | |
273 | ||
274 | print <<END | |
275 | <table width='95%' cellspacing='0'> | |
276 | <tr bgcolor='$color{'color20'}'><td colspan='9' align='left'><b>$Lang::tr{'webradio playlist'}</b></td></tr> | |
277 | <tr><td>Stream</td><td colspan='2'></td></tr> | |
278 | END | |
279 | ; | |
280 | foreach (@webradio){ | |
281 | my @stream = split(/\|/,$_); | |
282 | print <<END | |
283 | <tr><td>$stream[1]</td> | |
284 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='stopweb' /><input type='image' alt='$Lang::tr{'stop'}' title='$Lang::tr{'stop'}' src='/images/media-playback-stop.png' /></form></td> | |
285 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='FILE' value='$stream[0]' /><input type='hidden' name='ACTION' value='playweb' /><input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /></form></td> | |
286 | </tr> | |
287 | END | |
288 | ; | |
289 | } | |
290 | print "</table>"; | |
291 | &Header::closebox(); | |
292 | ||
a28fdc01 CS |
293 | &Header::closebigbox(); |
294 | &Header::closepage(); |