]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/perl | |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
5 | # Copyright (C) 2007 Michael Tremer & Christian Schmidt # | |
6 | # # | |
7 | # This program is free software: you can redistribute it and/or modify # | |
8 | # it under the terms of the GNU General Public License as published by # | |
9 | # the Free Software Foundation, either version 3 of the License, or # | |
10 | # (at your option) any later version. # | |
11 | # # | |
12 | # This program is distributed in the hope that it will be useful, # | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
15 | # GNU General Public License for more details. # | |
16 | # # | |
17 | # You should have received a copy of the GNU General Public License # | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
19 | # # | |
20 | ############################################################################### | |
21 | ||
22 | use strict; | |
23 | # enable only the following on debugging purpose | |
24 | #use warnings; | |
25 | #use CGI::Carp 'fatalsToBrowser'; | |
26 | ||
27 | require '/var/ipfire/general-functions.pl'; | |
28 | require "${General::swroot}/lang.pl"; | |
29 | require "${General::swroot}/header.pl"; | |
30 | ||
31 | my %color = (); | |
32 | my %mainsettings = (); | |
33 | my %mpfiresettings = (); | |
34 | my %checked = (); | |
35 | my $message = '0'; | |
36 | my $errormessage = ""; | |
37 | ||
38 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
39 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
40 | ||
41 | if ( $ENV{'QUERY_STRING'} =~ /title/){ | |
42 | my $song = `/usr/local/bin/mpfirectrl song 2>/dev/null`; | |
43 | if ( $song eq "" ){$song = "None";} | |
44 | &Header::showhttpheaders(); | |
45 | print"<meta http-equiv='refresh' content='5'>"; | |
46 | print <<END | |
47 | <table width='95%' cellspacing='0'> | |
48 | <tr bgcolor='$color{'color20'}'><td align='center' valign='center'><font color='red' face='Verdana' size='2'>-= $song =-</font></td></tr> | |
49 | </table></div> | |
50 | END | |
51 | ; | |
52 | } | |
53 | else{ | |
54 | &Header::showhttpheaders(); | |
55 | ||
56 | sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;' />" );print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>$Lang::tr{'pagerefresh'}</font></center>";&Header::closebox();} | |
57 | ||
58 | $mpfiresettings{'PAGE'} = "1"; | |
59 | ||
60 | open(DATEI, "<${General::swroot}/mpfire/db/mpd.db") || die "No Database found"; | |
61 | my @songdb = <DATEI>; | |
62 | close(DATEI); | |
63 | ||
64 | my @artist; my @album; my @genre; my @year; my $linecount = 0; my %songs; | |
65 | my $key;my $file;my $Time;my $Artist;my $Title;my $Album;my $Track;my $Date;my $Genre; | |
66 | foreach (@songdb){ | |
67 | ||
68 | if ( $_ =~ /mtime: / ){ | |
69 | $songs{$key}="$file|$Time|$Artist|$Title|$Album|$Track|$Date|$Genre"; | |
70 | push(@artist,$Artist);push(@album,$Album);push(@year,$Date);push(@genre,$Genre); | |
71 | $key="";$file="";$Time="";$Artist="";$Title="";$Album="";$Track="";$Date="";$Genre=""; | |
72 | } | |
73 | elsif ( $_ =~ /key: / ){my @temp = split(/: /,$_);$key=$temp[1];} | |
74 | elsif ( $_ =~ /file: / ){my @temp = split(/: /,$_);$file=$temp[1];} | |
75 | elsif ( $_ =~ /Time: / ){my @temp = split(/: /,$_);$Time=$temp[1];} | |
76 | elsif ( $_ =~ /Artist: / ){my @temp = split(/: /,$_);$Artist=$temp[1];} | |
77 | elsif ( $_ =~ /Title: / ){my @temp = split(/: /,$_);$Title=$temp[1];} | |
78 | elsif ( $_ =~ /Album: / ){my @temp = split(/: /,$_);$Album=$temp[1];} | |
79 | elsif ( $_ =~ /Track: / ){my @temp = split(/: /,$_);$Track=$temp[1];} | |
80 | elsif ( $_ =~ /Date: / ){my @temp = split(/: /,$_);$Date=$temp[1];} | |
81 | elsif ( $_ =~ /Genre: / ){my @temp = split(/: /,$_);$Genre=$temp[1];} | |
82 | else {next;} | |
83 | } | |
84 | ||
85 | my %hash = map{ $_, 1 }@artist; | |
86 | @artist = sort keys %hash; | |
87 | my %hash = map{ $_, 1 }@album; | |
88 | @album = sort keys %hash; | |
89 | my %hash = map{ $_, 1 }@year; | |
90 | @year = sort keys %hash; | |
91 | my %hash = map{ $_, 1 }@genre; | |
92 | @genre = sort keys %hash; | |
93 | ||
94 | my $artistcount = $#artist+1; | |
95 | my $albumcount = $#album+1; | |
96 | my $yearcount = $#year+1; | |
97 | my $genrecount = $#genre+1; | |
98 | ||
99 | &Header::getcgihash(\%mpfiresettings); | |
100 | &Header::openpage($Lang::tr{'mpfire'}, 1,); | |
101 | &Header::openbigbox('100%', 'left', '', $errormessage); | |
102 | ||
103 | ############################################################################################################################ | |
104 | ######################################## Scanne Verzeichnisse nach Mp3 Dateien ############################################# | |
105 | ||
106 | if ( $mpfiresettings{'ACTION'} eq "scan" ) | |
107 | { | |
108 | delete $mpfiresettings{'__CGI__'};delete $mpfiresettings{'x'};delete $mpfiresettings{'y'};delete $mpfiresettings{'PAGE'}; | |
109 | &General::writehash("${General::swroot}/mpfire/settings", \%mpfiresettings); | |
110 | open(DATEI, "<${General::swroot}/mpfire/mpd.conf") || die "Datei nicht gefunden"; | |
111 | my @Zeilen = <DATEI>; | |
112 | close(DATEI); | |
113 | open(DATEI, ">${General::swroot}/mpfire/mpd.conf") || die "Datei nicht gefunden"; | |
114 | foreach (@Zeilen){ | |
115 | if ( $_ =~ /music_directory/){print DATEI "music_directory \"".$mpfiresettings{'MUSICDIR'}."\"\n";} | |
116 | else {print DATEI $_;} | |
117 | } | |
118 | close(DATEI); | |
119 | ||
120 | $message=system("/usr/local/bin/mpfirectrl scan 2>/dev/null"); | |
121 | refreshpage(); | |
122 | } | |
123 | elsif ( $mpfiresettings{'ACTION'} eq ">" ){$message=system("/usr/local/bin/mpfirectrl","play","\"$mpfiresettings{'FILE'}\"","2>/dev/null");} | |
124 | elsif ( $mpfiresettings{'ACTION'} eq "x" ){$message=system("/usr/local/bin/mpfirectrl stop 2>/dev/null");} | |
125 | elsif ( $mpfiresettings{'ACTION'} eq "|>" ){$message=system("/usr/local/bin/mpfirectrl toggle 2>/dev/null");} | |
126 | elsif ( $mpfiresettings{'ACTION'} eq "<<" ){$message=system("/usr/local/bin/mpfirectrl prev 2>/dev/null");} | |
127 | elsif ( $mpfiresettings{'ACTION'} eq ">>" ){$message=system("/usr/local/bin/mpfirectrl next 2>/dev/null");} | |
128 | elsif ( $mpfiresettings{'ACTION'} eq "+" ){$message=system("/usr/local/bin/mpfirectrl volup 5 2>/dev/null");} | |
129 | elsif ( $mpfiresettings{'ACTION'} eq "-" ){$message=system("/usr/local/bin/mpfirectrl voldown 5 2>/dev/null");} | |
130 | elsif ( $mpfiresettings{'ACTION'} eq "++" ){$message=system("/usr/local/bin/mpfirectrl volup 10 2>/dev/null");} | |
131 | elsif ( $mpfiresettings{'ACTION'} eq "--" ){$message=system("/usr/local/bin/mpfirectrl voldown 10 2>/dev/null");} | |
132 | elsif ( $mpfiresettings{'ACTION'} eq "playweb" ){$message=system("/usr/local/bin/mpfirectrl","playweb","\"$mpfiresettings{'FILE'}\"","2>/dev/null");} | |
133 | elsif ( $mpfiresettings{'ACTION'} eq "playlist" ){$message=system("/usr/local/bin/mpfirectrl playlist 2>/dev/null");} | |
134 | elsif ( $mpfiresettings{'ACTION'} eq "emptyplaylist" ){$message=system("/usr/local/bin/mpfirectrl clearplaylist 2>/dev/null");} | |
135 | elsif ( $mpfiresettings{'ACTION'} eq "addtoplaylist" ){$message=system("/usr/local/bin/mpfirectrl","playadd","\"$mpfiresettings{'FILE'}\"","2>/dev/null");} | |
136 | elsif ( $mpfiresettings{'ACTION'} eq "playall" ){ | |
137 | my @temp = ""; my @song = ""; | |
138 | ||
139 | foreach (keys(%songs)){ | |
140 | @song = split(/\|/,$songs{$_});push(@temp,$song[0]) | |
141 | } | |
142 | open(DATEI, ">${General::swroot}/mpfire/playlist.m3u") || die "Could not add playlist"; | |
143 | print DATEI @temp; | |
144 | close(DATEI); | |
145 | ||
146 | $message=system("/usr/local/bin/mpfirectrl playlist 2>/dev/null"); | |
147 | } | |
148 | elsif ( $mpfiresettings{'ACTION'} eq "playalbum" ) | |
149 | { | |
150 | my @temp = ""; my @song = ""; my @select = split(/\|/,$mpfiresettings{'album'}); | |
151 | ||
152 | foreach (keys(%songs)){ | |
153 | @song = split(/\|/,$songs{$_});$song[4] =~ s/\W/ /g; | |
154 | ||
155 | foreach (@select){ | |
156 | $_ =~ s/\W/ /g; | |
157 | if ( $song[4] =~ /$_/ ){push(@temp,$song[0]);} | |
158 | } | |
159 | } | |
160 | ||
161 | open(DATEI, ">${General::swroot}/mpfire/playlist.m3u") || die "Could not add playlist"; | |
162 | print DATEI @temp; | |
163 | close(DATEI); | |
164 | $message=system("/usr/local/bin/mpfirectrl playlist 2>/dev/null"); | |
165 | } | |
166 | elsif ( $mpfiresettings{'ACTION'} eq "playartist" ) | |
167 | { | |
168 | my @temp = ""; my @song = ""; my @select = split(/\|/,$mpfiresettings{'artist'}); | |
169 | ||
170 | foreach (keys(%songs)){ | |
171 | @song = split(/\|/,$songs{$_});$song[2] =~ s/\W/ /g; | |
172 | ||
173 | foreach (@select){ | |
174 | $_ =~ s/\W/ /g; | |
175 | if ( $song[2] =~ /$_/ ){push(@temp,$song[0]);} | |
176 | } | |
177 | } | |
178 | ||
179 | open(DATEI, ">${General::swroot}/mpfire/playlist.m3u") || die "Could not add playlist"; | |
180 | print DATEI @temp; | |
181 | close(DATEI); | |
182 | $message=system("/usr/local/bin/mpfirectrl playlist 2>/dev/null"); | |
183 | } | |
184 | elsif ( $mpfiresettings{'ACTION'} eq "playyear" ) | |
185 | { | |
186 | my @temp = ""; my @song = ""; my @select = split(/\|/,$mpfiresettings{'year'}); | |
187 | ||
188 | foreach (keys(%songs)){ | |
189 | @song = split(/\|/,$songs{$_});$song[6] =~ s/\W/ /g; | |
190 | ||
191 | foreach (@select){ | |
192 | $_ =~ s/\W/ /g; | |
193 | if ( $song[6] =~ /$_/ ){push(@temp,$song[0]);} | |
194 | } | |
195 | } | |
196 | ||
197 | open(DATEI, ">${General::swroot}/mpfire/playlist.m3u") || die "Could not add playlist"; | |
198 | print DATEI @temp; | |
199 | close(DATEI); | |
200 | $message=system("/usr/local/bin/mpfirectrl playlist 2>/dev/null"); | |
201 | } | |
202 | elsif ( $mpfiresettings{'ACTION'} eq "playgenre" ) | |
203 | { | |
204 | my @temp = ""; my @song = ""; my @select = split(/\|/,$mpfiresettings{'genre'}); | |
205 | ||
206 | foreach (keys(%songs)){ | |
207 | @song = split(/\|/,$songs{$_});$song[7] =~ s/\W/ /g; | |
208 | ||
209 | foreach (@select){ | |
210 | $_ =~ s/\W/ /g; | |
211 | if ( $song[7] =~ /$_/ ){push(@temp,$song[0]);} | |
212 | } | |
213 | } | |
214 | ||
215 | open(DATEI, ">${General::swroot}/mpfire/playlist.m3u") || die "Could not add playlist"; | |
216 | print DATEI @temp; | |
217 | close(DATEI); | |
218 | $message=system("/usr/local/bin/mpfirectrl playlist 2>/dev/null"); | |
219 | } | |
220 | elsif ( $mpfiresettings{'SHOWLIST'} ){delete $mpfiresettings{'__CGI__'};delete $mpfiresettings{'x'};delete $mpfiresettings{'y'};delete $mpfiresettings{'PAGE'};&General::writehash("${General::swroot}/mpfire/settings", \%mpfiresettings);refreshpage();} | |
221 | ||
222 | ############################################################################################################################ | |
223 | ################################### Aufbau der HTML Seite fr globale Sambaeinstellungen #################################### | |
224 | ||
225 | $mpfiresettings{'MUSICDIR'} = "/"; | |
226 | ||
227 | &General::readhash("${General::swroot}/mpfire/settings", \%mpfiresettings); | |
228 | ||
229 | ############################################################################################################################ | |
230 | ########################################### rekursiv nach neuen Mp3s Scannen ##############################################รค | |
231 | ||
232 | if ( $message ne '0' ) { print "<font color='red'>An Error occured while launching the command</font>"; } | |
233 | elsif ( $message ne "" && $message ne '0' ) { print "<font color='red'>$message</font>"; } | |
234 | ||
235 | &Header::openbox('100%', 'center', $Lang::tr{'mpfire scanning'}); | |
236 | ||
237 | print <<END | |
238 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
239 | <table width='95%' cellspacing='0'> | |
240 | <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'Scan for Files'}</b></td></tr> | |
241 | <tr><td align='left' width='40%'>$Lang::tr{'Scan from Directory'}</td><td align='left'><input type='text' name='MUSICDIR' value='$mpfiresettings{'MUSICDIR'}' size="50" /></td></tr> | |
242 | <tr><td align='center' colspan='2'><input type='hidden' name='ACTION' value='scan' /> | |
243 | <input type='image' alt='$Lang::tr{'Scan for Files'}' title='$Lang::tr{'Scan for Files'}' src='/images/edit-find.png' /></td></tr> | |
244 | </table> | |
245 | </form> | |
246 | END | |
247 | ; | |
248 | &Header::closebox(); | |
249 | ||
250 | my $Volume = `/usr/local/bin/mpfirectrl volume 2>/dev/null`; | |
251 | $Volume=~s/<break>/<br \/>/g; | |
252 | my $stats = `mpc stats | tail -4 2>/dev/null`; | |
253 | $stats=~s/\\/<br \/>/g | |
254 | ||
255 | &Header::openbox('100%', 'center', $Lang::tr{'mpfire controls'}); | |
256 | print <<END | |
257 | ||
258 | <table width='95%' cellspacing='0'> | |
259 | <iframe height='35' width='100%' src='/cgi-bin/mpfire.cgi?title' scrolling='no' frameborder='no' align='top' marginheight='0'></iframe> | |
260 | END | |
261 | ; | |
262 | my $countsongs=`/usr/local/bin/mpfirectrl stats 2>/dev/null`; | |
263 | print "<tr><td colspan='5' align='center'><br/><b>".$countsongs."</b><br/><br/></td></tr>"; | |
264 | print <<END | |
265 | <tr> | |
266 | <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> | |
267 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='<<' /><input type='image' alt='$Lang::tr{'prev'}' title='$Lang::tr{'prev'}' src='/images/media-skip-backward.png' /></form></td> | |
268 | <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='|>' /><input type='image' alt='$Lang::tr{'toggle'}' title='$Lang::tr{'toggle'}' src='/images/media-resume.png' /></form></td> | |
269 | <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> | |
270 | <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> | |
271 | </tr> | |
272 | END | |
273 | ; | |
274 | 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>";} | |
275 | 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>";} | |
276 | print <<END | |
277 | <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> | |
278 | <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> | |
279 | <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> | |
280 | <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> | |
281 | </tr> | |
282 | <tr><td colspan='5' align='center'>$Volume</td></tr> | |
283 | <tr><td colspan='5' align='center'><br />$stats</td></tr> | |
284 | </table> | |
285 | END | |
286 | ; | |
287 | &Header::closebox(); | |
288 | ||
289 | &Header::openbox('100%', 'center', $Lang::tr{'quick playlist'}); | |
290 | ||
291 | print "<table width='95%' cellspacing='0'>"; | |
292 | if ( $#songdb eq '-1' ) {print "<tr><td align='center' bgcolor='$color{'color20'}'><b>$Lang::tr{'artist'}</b></td><td align='center' bgcolor='$color{'color20'}'><b>$Lang::tr{'album'}</b></td></tr>";} | |
293 | else {print "<tr><td align='center' bgcolor='$color{'color20'}'><b>$Lang::tr{'artist'} - ".$artistcount."</b></td><td align='center' bgcolor='$color{'color20'}'><b>$Lang::tr{'album'} - ".$albumcount."</b></td></tr>";} | |
294 | print <<END | |
295 | <tr><td align='center'> | |
296 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
297 | <select name='artist' size='8' multiple='multiple' style='width:300px;'> | |
298 | END | |
299 | ; | |
300 | foreach (@artist){if ( $_ ne '' ){print "<option>$_</option>";}} | |
301 | print <<END | |
302 | </select><br/> | |
303 | <input type='hidden' name='ACTION' value='playartist' /> | |
304 | <input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /> | |
305 | </form></td> | |
306 | <td align='center'> | |
307 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
308 | <select name='album' size='8' multiple='multiple' style='width:300px;'> | |
309 | END | |
310 | ; | |
311 | foreach (@album){if ( $_ ne '' ){print "<option>$_</option>";}} | |
312 | print <<END | |
313 | </select><br/> | |
314 | <input type='hidden' name='ACTION' value='playalbum' /> | |
315 | <input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /> | |
316 | </form></td> | |
317 | </tr> | |
318 | END | |
319 | ; | |
320 | if ( $#songdb eq '-1' ) {print "<tr><td align='center' bgcolor='$color{'color20'}'><b>$Lang::tr{'year'}</b></td><td align='center' bgcolor='$color{'color20'}'><b>$Lang::tr{'genre'}</b></td></tr>";} | |
321 | else {print "<tr><td align='center' bgcolor='$color{'color20'}'><b>$Lang::tr{'year'} - ".$yearcount."</b></td><td align='center' bgcolor='$color{'color20'}'><b>$Lang::tr{'genre'} - ".$genrecount."</b></td></tr>";} | |
322 | print <<END | |
323 | <tr><td align='center'> | |
324 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
325 | <select name='year' size='8' multiple='multiple' style='width:300px;'> | |
326 | END | |
327 | ; | |
328 | foreach (@year){if ( $_ ne '' ){print "<option>$_</option>";}} | |
329 | print <<END | |
330 | </select><br/> | |
331 | <input type='hidden' name='ACTION' value='playyear' /> | |
332 | <input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /> | |
333 | </form></td> | |
334 | <td align='center'> | |
335 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
336 | <select name='genre' size='8' multiple='multiple' style='width:300px;'> | |
337 | END | |
338 | ; | |
339 | foreach (@genre){if ( $_ ne '' ){print "<option>$_</option>";}} | |
340 | print <<END | |
341 | </select><br/> | |
342 | <input type='hidden' name='ACTION' value='playgenre' /> | |
343 | <input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /> | |
344 | </form></td> | |
345 | </tr></table> | |
346 | END | |
347 | ; | |
348 | &Header::closebox(); | |
349 | ||
350 | if ( $mpfiresettings{'SHOWLIST'} eq "on" ){ | |
351 | ||
352 | &Header::openbox('100%', 'center', $Lang::tr{'mpfire songs'}); | |
353 | print <<END | |
354 | <a name="$Lang::tr{'mpfire songs'}"</a> | |
355 | <table width='95%' cellspacing='5'> | |
356 | <tr bgcolor='$color{'color20'}'><td colspan='9' align='left'><b>$Lang::tr{'Existing Files'}</b></td></tr> | |
357 | <tr><td align='center' colspan='9'><br/>$Lang::tr{'Pages'}<br/><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='submit' name='PAGE' value='all' /><br/> | |
358 | END | |
359 | ; | |
360 | my $pages =(int(keys(%songs)/100)+1); | |
361 | for(my $i = 1; $i <= $pages; $i++) { | |
362 | print "<input type='submit' name='PAGE' value='$i' />"; | |
363 | if (!($i % 205)){print"<br/>";} | |
364 | } | |
365 | print <<END | |
366 | </form></td></tr> | |
367 | <tr><td align='center'></td> | |
368 | <td align='center'><b>$Lang::tr{'artist'}<br/>$Lang::tr{'title'}</b></td> | |
369 | <td align='center'><b>$Lang::tr{'number'}</b></td> | |
370 | <td align='center'><b>$Lang::tr{'album'}</b></td> | |
371 | <td align='center'><b>$Lang::tr{'year'}</b></td> | |
372 | <td align='center'><b>$Lang::tr{'genre'}</b></td> | |
373 | <td align='center'><b>$Lang::tr{'length'}</b></td></tr> | |
374 | END | |
375 | ; | |
376 | my $lines=0;my $i=0;my $begin;my $end; | |
377 | if ( $mpfiresettings{'PAGE'} eq 'all' ){ | |
378 | $begin=0; | |
379 | $end=keys(%songs); | |
380 | } | |
381 | else{ | |
382 | $begin=(($mpfiresettings{'PAGE'}-1) * 100); | |
383 | $end=(($mpfiresettings{'PAGE'} * 100)-1); | |
384 | } | |
385 | foreach (keys(%songs)){ | |
386 | if (!($i >= $begin && $i <= $end)){ | |
387 | # print $begin."->".$i."<-".$end."\n"; | |
388 | $i++;next;} | |
389 | my @song = split(/\|/,$songs{$_}); | |
390 | my $minutes = sprintf ("%.0f", $song[1] / 60 ); | |
391 | my $seconds = $song[1] % 60; | |
392 | ||
393 | if ($lines % 2) {print "<tr bgcolor='$color{'color20'}'>";} else {print "<tr bgcolor='$color{'color22'}'>";} | |
394 | print <<END | |
395 | <td align='center' style="white-space:nowrap;"><form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'mpfire songs'}'><input type='hidden' name='ACTION' value='addtoplaylist' /><input type='hidden' name='FILE' value="$song[0]" /><input type='image' alt='$Lang::tr{'add'}' title='$Lang::tr{'add'}' src='/images/list-add.png' /></form><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> | |
396 | <td align='center'>$song[2]<br/>$song[3]</td> | |
397 | <td align='center'>$song[5]</td> | |
398 | <td align='center'>$song[4]</td> | |
399 | <td align='center'>$song[6]</td> | |
400 | <td align='center'>$song[7]</td> | |
401 | <td align='center'>$minutes:$seconds</td></tr> | |
402 | END | |
403 | ; | |
404 | $lines++; | |
405 | $i++; | |
406 | } | |
407 | print "</table>"; | |
408 | &Header::closebox(); | |
409 | } | |
410 | ||
411 | &Header::openbox('100%', 'center', $Lang::tr{'mpfire playlist'}); | |
412 | ||
413 | my @playlist = `mpc playlist 2>/dev/null`; | |
414 | ||
415 | print <<END | |
416 | <table width='95%' cellspacing='0'> | |
417 | <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'current playlist'}</b></td></tr> | |
418 | <tr><td align='center' colspan='2' ><textarea cols='100' rows='10' name='playlist' style='font-size:11px;width:650px;' readonly='readonly'> | |
419 | END | |
420 | ; | |
421 | foreach (@playlist){print $_;} | |
422 | print <<END | |
423 | </textarea></td></tr><tr> | |
424 | <td align='right'> | |
425 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
426 | <input type='hidden' name='ACTION' value='emptyplaylist' /> | |
427 | <input type='image' alt='$Lang::tr{'clear playlist'}' title='$Lang::tr{'clear playlist'}' src='/images/user-trash.png' /> | |
428 | </form> | |
429 | </td> | |
430 | <td align='left'> | |
431 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
432 | <input type='hidden' name='ACTION' value='playlist' /> | |
433 | <input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /> | |
434 | </form> | |
435 | </td></tr> | |
436 | </table> | |
437 | END | |
438 | ; | |
439 | &Header::closebox(); | |
440 | ||
441 | &Header::openbox('100%', 'center', $Lang::tr{'mpfire webradio'}); | |
442 | ||
443 | open(DATEI, "<${General::swroot}/mpfire/webradio") || die "Could not open playlist"; | |
444 | my @webradio = <DATEI>; | |
445 | close(DATEI); | |
446 | ||
447 | print <<END | |
448 | <table width='95%' cellspacing='0'> | |
449 | <tr bgcolor='$color{'color20'}'><td colspan='9' align='left'><b>$Lang::tr{'webradio playlist'}</b></td></tr> | |
450 | <tr><td align='left'>Stream</td><td colspan='2'></td></tr> | |
451 | END | |
452 | ; | |
453 | my $lines=0; | |
454 | foreach (@webradio){ | |
455 | my @stream = split(/\|/,$_); | |
456 | $lines++; | |
457 | if ($lines % 2) {print "<tr bgcolor='$color{'color22'}'>";} else {print "<tr>";} | |
458 | print <<END | |
459 | <td align='left'><a href="$stream[2]" target="_blank">$stream[1]</a></td> | |
460 | <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> | |
461 | </tr> | |
462 | END | |
463 | ; | |
464 | } | |
465 | $lines++; | |
466 | if ($lines % 2) {print "<tr bgcolor='$color{'color22'}'>";} else {print "<tr>";} | |
467 | print <<END | |
468 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
469 | <td align='left'>http://<input type=text name='FILE' value='www.meineradiourl:1234' size='75' /></td> | |
470 | <td align='center'><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> | |
471 | </tr> | |
472 | END | |
473 | ; | |
474 | print "</table>"; | |
475 | &Header::closebox(); | |
476 | ||
477 | &Header::closebigbox(); | |
478 | &Header::closepage(); | |
479 | } |