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