]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/mpfire.cgi
Ended core 5 and started core 6
[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";}
8a5898e7 44&Header::showhttpheaders();
8a5898e7 45print <<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
54END
55;
fcd5cb6f 56}
8a5898e7 57else{
a28fdc01 58&Header::showhttpheaders();
a28fdc01 59
bac7231b 60sub 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
64open(DATEI, "<${General::swroot}/mpfire/db/mpd.db") || die "No Database found";
65my @songdb = <DATEI>;
66close(DATEI);
67
9a6214e0
CS
68my @artist; my @album; my @genre; my @year; my $linecount = 0; my %songs;
69my $key;my $file;my $Time;my $Artist;my $Title;my $Album;my $Track;my $Date;my $Genre;
70ccd4a7 70foreach (@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
109if ( $mpfiresettings{'ACTION'} eq "scan" )
110{
fcd5cb6f
MT
111&General::readhash("${General::swroot}/mpfire/settings", \%mpfiresettings);
112&Header::getcgihash(\%mpfiresettings);
8871b9f2 113delete $mpfiresettings{'__CGI__'};delete $mpfiresettings{'x'};delete $mpfiresettings{'y'};delete $mpfiresettings{'PAGE'};
a28fdc01 114&General::writehash("${General::swroot}/mpfire/settings", \%mpfiresettings);
70ccd4a7
CS
115open(DATEI, "<${General::swroot}/mpfire/mpd.conf") || die "Datei nicht gefunden";
116my @Zeilen = <DATEI>;
117close(DATEI);
118open(DATEI, ">${General::swroot}/mpfire/mpd.conf") || die "Datei nicht gefunden";
119foreach (@Zeilen){
120if ( $_ =~ /music_directory/){print DATEI "music_directory \"".$mpfiresettings{'MUSICDIR'}."\"\n";}
121else {print DATEI $_;}
122}
123close(DATEI);
124
8c384f97 125$message=system("/usr/local/bin/mpfirectrl scan 2>/dev/null");
69addbb8 126refreshpage();
a28fdc01 127}
8c384f97
CS
128elsif ( $mpfiresettings{'ACTION'} eq ">" ){$message=system("/usr/local/bin/mpfirectrl","play","\"$mpfiresettings{'FILE'}\"","2>/dev/null");}
129elsif ( $mpfiresettings{'ACTION'} eq "x" ){$message=system("/usr/local/bin/mpfirectrl stop 2>/dev/null");}
130elsif ( $mpfiresettings{'ACTION'} eq "|>" ){$message=system("/usr/local/bin/mpfirectrl toggle 2>/dev/null");}
131elsif ( $mpfiresettings{'ACTION'} eq "<<" ){$message=system("/usr/local/bin/mpfirectrl prev 2>/dev/null");}
132elsif ( $mpfiresettings{'ACTION'} eq ">>" ){$message=system("/usr/local/bin/mpfirectrl next 2>/dev/null");}
133elsif ( $mpfiresettings{'ACTION'} eq "+" ){$message=system("/usr/local/bin/mpfirectrl volup 5 2>/dev/null");}
134elsif ( $mpfiresettings{'ACTION'} eq "-" ){$message=system("/usr/local/bin/mpfirectrl voldown 5 2>/dev/null");}
135elsif ( $mpfiresettings{'ACTION'} eq "++" ){$message=system("/usr/local/bin/mpfirectrl volup 10 2>/dev/null");}
136elsif ( $mpfiresettings{'ACTION'} eq "--" ){$message=system("/usr/local/bin/mpfirectrl voldown 10 2>/dev/null");}
137elsif ( $mpfiresettings{'ACTION'} eq "playweb" ){$message=system("/usr/local/bin/mpfirectrl","playweb","\"$mpfiresettings{'FILE'}\"","2>/dev/null");}
138elsif ( $mpfiresettings{'ACTION'} eq "playlist" ){$message=system("/usr/local/bin/mpfirectrl playlist 2>/dev/null");}
139elsif ( $mpfiresettings{'ACTION'} eq "emptyplaylist" ){$message=system("/usr/local/bin/mpfirectrl clearplaylist 2>/dev/null");}
140elsif ( $mpfiresettings{'ACTION'} eq "addtoplaylist" ){$message=system("/usr/local/bin/mpfirectrl","playadd","\"$mpfiresettings{'FILE'}\"","2>/dev/null");}
85cedd09
CS
141elsif ( $mpfiresettings{'ACTION'} eq "playall" ){
142my @temp = ""; my @song = "";
143
144foreach (keys(%songs)){
a609bfb0
CS
145 @song = split(/\|/,$songs{$_});push(@temp,$song[0])
146 }
85cedd09
CS
147open(DATEI, ">${General::swroot}/mpfire/playlist.m3u") || die "Could not add playlist";
148print DATEI @temp;
fcd5cb6f 149close(DATEI);
85cedd09 150
8c384f97 151$message=system("/usr/local/bin/mpfirectrl playlist 2>/dev/null");
85cedd09 152}
bac7231b 153elsif ( $mpfiresettings{'ACTION'} eq "playalbum" )
32ab16de 154{
70ccd4a7
CS
155my @temp = ""; my @song = ""; my @select = split(/\|/,$mpfiresettings{'album'});
156
157foreach (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 166open(DATEI, ">${General::swroot}/mpfire/playlist.m3u") || die "Could not add playlist";
32ab16de
CS
167print DATEI @temp;
168close(DATEI);
8c384f97 169$message=system("/usr/local/bin/mpfirectrl playlist 2>/dev/null");
32ab16de 170}
bac7231b 171elsif ( $mpfiresettings{'ACTION'} eq "playartist" )
32ab16de 172{
70ccd4a7
CS
173my @temp = ""; my @song = ""; my @select = split(/\|/,$mpfiresettings{'artist'});
174
175foreach (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
184open(DATEI, ">${General::swroot}/mpfire/playlist.m3u") || die "Could not add playlist";
32ab16de
CS
185print DATEI @temp;
186close(DATEI);
8c384f97 187$message=system("/usr/local/bin/mpfirectrl playlist 2>/dev/null");
32ab16de 188}
8050f37b
CS
189elsif ( $mpfiresettings{'ACTION'} eq "playyear" )
190{
70ccd4a7
CS
191my @temp = ""; my @song = ""; my @select = split(/\|/,$mpfiresettings{'year'});
192
193foreach (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 202open(DATEI, ">${General::swroot}/mpfire/playlist.m3u") || die "Could not add playlist";
8050f37b
CS
203print DATEI @temp;
204close(DATEI);
8c384f97 205$message=system("/usr/local/bin/mpfirectrl playlist 2>/dev/null");
8050f37b 206}
70ccd4a7 207elsif ( $mpfiresettings{'ACTION'} eq "playgenre" )
a28fdc01 208{
70ccd4a7
CS
209my @temp = ""; my @song = ""; my @select = split(/\|/,$mpfiresettings{'genre'});
210
211foreach (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
220open(DATEI, ">${General::swroot}/mpfire/playlist.m3u") || die "Could not add playlist";
a28fdc01
CS
221print DATEI @temp;
222close(DATEI);
8c384f97 223$message=system("/usr/local/bin/mpfirectrl playlist 2>/dev/null");
a28fdc01 224}
fcd5cb6f
MT
225elsif ( $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
244if ( $message ne '0' ) { print "<font color='red'>An Error occured while launching the command</font>"; }
245elsif ( $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
249print <<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>
258END
259;
260&Header::closebox();
261
8c384f97 262my $Volume = `/usr/local/bin/mpfirectrl volume 2>/dev/null`;
8050f37b 263$Volume=~s/<break>/<br \/>/g;
8c384f97 264my $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 268print <<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
271END
272;
8c384f97 273my $countsongs=`/usr/local/bin/mpfirectrl stats 2>/dev/null`;
901a50cf 274print "<tr><td colspan='5' align='center'><b>".$countsongs."</b></td></tr>";
05882fff 275print <<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
283END
284;
285if ( $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
286else { 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>";}
287print <<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>
296END
297;
298&Header::closebox();
299
32ab16de
CS
300&Header::openbox('100%', 'center', $Lang::tr{'quick playlist'});
301
cb5e9c6c
CS
302print "<table width='95%' cellspacing='0'>";
303if ( $#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 304else {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 305print <<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
309END
310;
cb5e9c6c 311foreach (@artist){if ( $_ ne '' ){print "<option>$_</option>";}}
32ab16de 312print <<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
320END
321;
8050f37b 322 foreach (@album){if ( $_ ne '' ){print "<option>$_</option>";}}
32ab16de 323print <<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
329END
330;
cb5e9c6c 331if ( $#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 332else {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 333print <<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;'>
337END
338;
339 foreach (@year){if ( $_ ne '' ){print "<option>$_</option>";}}
340print <<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
348END
349;
350 foreach (@genre){if ( $_ ne '' ){print "<option>$_</option>";}}
351print <<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
357END
358;
359&Header::closebox();
360
a28fdc01
CS
361if ( $mpfiresettings{'SHOWLIST'} eq "on" ){
362
363&Header::openbox('100%', 'center', $Lang::tr{'mpfire songs'});
364print <<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/>
369END
370;
70ccd4a7 371my $pages =(int(keys(%songs)/100)+1);
8871b9f2
CS
372for(my $i = 1; $i <= $pages; $i++) {
373print "<input type='submit' name='PAGE' value='$i' />";
374if (!($i % 205)){print"<br/>";}
375}
376print <<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
385END
386;
8871b9f2
CS
387my $lines=0;my $i=0;my $begin;my $end;
388if ( $mpfiresettings{'PAGE'} eq 'all' ){
a609bfb0
CS
389 $begin=0;
390 $end=keys(%songs);
8871b9f2
CS
391}
392else{
a609bfb0
CS
393 $begin=(($mpfiresettings{'PAGE'}-1) * 100);
394 $end=(($mpfiresettings{'PAGE'} * 100)-1);
8871b9f2 395}
fcd5cb6f 396foreach (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
413END
414;
a609bfb0
CS
415 $lines++;
416 $i++;
417 }
8871b9f2 418print "</table>";
a28fdc01
CS
419&Header::closebox();
420}
421
32ab16de
CS
422&Header::openbox('100%', 'center', $Lang::tr{'mpfire playlist'});
423
8c384f97 424my @playlist = `mpc playlist 2>/dev/null`;
bac7231b 425
32ab16de
CS
426print <<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
430END
431;
901a50cf 432foreach (@playlist){$_=~s/&/&amp\;/g;;print $_;}
bac7231b 433print <<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>
448END
449;
450&Header::closebox();
451
a2d5130f
CS
452&Header::openbox('100%', 'center', $Lang::tr{'mpfire webradio'});
453
454open(DATEI, "<${General::swroot}/mpfire/webradio") || die "Could not open playlist";
455my @webradio = <DATEI>;
456close(DATEI);
457
458print <<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
462END
463;
d089ce65 464my $lines=0;
a2d5130f 465foreach (@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 470print <<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>
474END
475;
a609bfb0
CS
476 }
477 $lines++;
478 if ($lines % 2) {print "<tr bgcolor='$color{'color22'}'>";} else {print "<tr>";}
d089ce65 479print <<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>
483END
484;
a2d5130f
CS
485print "</table>";
486&Header::closebox();
487
a28fdc01
CS
488&Header::closebigbox();
489&Header::closepage();
8a5898e7 490}