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