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