]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - html/cgi-bin/mpfire.cgi
Don't provide ssh keys in the update to 2.3.
[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;
e5a63a6f 23
a28fdc01 24# enable only the following on debugging purpose
19f5a6cc
CS
25#use warnings;
26#use CGI::Carp 'fatalsToBrowser';
a28fdc01 27
e5a63a6f
CS
28# use the special mpd POD and the encode POD to handle the utf8 scalars
29use Audio::MPD;
30use Encode;
31
32# initiate the connector for the mpd POD, mpd must be running on locahost
33# port 6600 without authentication
34my $mpd = Audio::MPD->new('localhost',6600,'','$REUSE');
35my $work = $mpd->status()->updating_db();
36
a28fdc01
CS
37require '/var/ipfire/general-functions.pl';
38require "${General::swroot}/lang.pl";
39require "${General::swroot}/header.pl";
40
41my %color = ();
42my %mainsettings = ();
43my %mpfiresettings = ();
44my %checked = ();
8871b9f2 45my $message = '0';
a28fdc01 46my $errormessage = "";
e5a63a6f 47my @songs;
a28fdc01 48
a28fdc01
CS
49&General::readhash("${General::swroot}/main/settings", \%mainsettings);
50&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
51
8a5898e7 52&Header::showhttpheaders();
e5a63a6f
CS
53
54if ( $ENV{'QUERY_STRING'} =~ /title/){
55
56################################################################################
57# $ENV{'QUERY_STRING'} =~ /title/ is used to handle the inline iframe used to
58# display the current song playing ( artist - title - album aso )
59# the cgi call´s itself with a parameter and the iframe refreshes itself without
60# reloading the whole page
61################################################################################
62
63 my $number = $mpd->status()->song()+1;
64 my $volume = $mpd->status()->volume();
65 my $random = $mpd->status()->random();
66
67 if ($random eq "0" ){
68 $random="off";
69 }else{
70 $random="on";
71 }
72
73 my $repeat = $mpd->status()->repeat();
74 if ($repeat eq "0" ){
75 $repeat="off";
76 }else{
77 $repeat="on";
78 }
79
80 my $song = "";
81 if ( $mpd->current() )
82 {
3fcb086e 83 $song = substr("-= ".$mpd->current()->Artist()." | ".$mpd->current()->Title(),0,85)." =-<br /> ";
e5a63a6f
CS
84 if ( $song eq "-= | =-<br /> " ){
85 $song = "None<br />"
86 };
87 $song .= $mpd->current()->Track()."# ".substr($mpd->current()->Album(),0,90)."<br />";
88 }else{
89 $song = "None<br /><br />";
90 }
91
92 if ( $song eq "None<br /># <br />" ){
93 $song = "None<br />".substr($mpd->current()->file(),0,90)."<br />"
94 };
95 $song .= "Playlist: ".$number."-".$mpd->status()->playlistlength()." Time: ".$mpd->status()->time()->sofar."/";
96 $song .= $mpd->status()->time()->total." (".$mpd->status()->time()->percent()."%) Status: ";
97 $song .= $mpd->status()->state()." Volume: ".$volume." % Repeat: ".$repeat." Random: ".$random;
98
99 print <<END
a609bfb0 100<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
901a50cf 101<meta http-equiv='refresh' content='5'>
e5a63a6f 102<title></title>
901a50cf 103<body>
6cd3f682 104<table width='100%' cellspacing='0' align='center' style="background-image:url(/images/mpfire/box.png);background-repeat:no-repeat">
8a5898e7
CS
105END
106;
e5a63a6f
CS
107 print"<tr ><td align='center'><font color='red' face='Verdana' size='2'><br />".encode('utf-8', $song)."<br /><br /></font></td></tr></table></body>";
108 exit;
109}elsif ( $ENV{'QUERY_STRING'} =~ /control/){
a28fdc01 110
e5a63a6f
CS
111################################################################################
112# $ENV{'QUERY_STRING'} =~ /control/ is used to handle the inline iframe used to
113# display the control button ( prev play skip stop toggle aso )
114# the cgi call´s itself with a parameter and only the iframe is reloaded on click
115################################################################################
69addbb8 116
e5a63a6f
CS
117 &Header::getcgihash(\%mpfiresettings);
118 if ( $mpfiresettings{'ACTION'} eq "playall" ){
119 $mpd->playlist->clear();
120 foreach ($mpd->collection->all_pathes){
121 $mpd->playlist->add($_);
a609bfb0 122 }
e5a63a6f
CS
123 $mpd->play();
124 }elsif ($mpfiresettings{'ACTION'} eq "x" ){
125 $mpd->stop();
126 }elsif ( $mpfiresettings{'ACTION'} eq "|>" ){
127 $mpd->pause();
128 }elsif ( $mpfiresettings{'ACTION'} eq "<<" ){
129 $mpd->prev();
130 }elsif ( $mpfiresettings{'ACTION'} eq ">>" ){
131 $mpd->next();
132 }elsif ( $mpfiresettings{'ACTION'} eq "+" ){
133 $mpd->volume('+5');
134 }elsif ( $mpfiresettings{'ACTION'} eq "-" ){
135 $mpd->volume('-5');
136 }elsif ( $mpfiresettings{'ACTION'} eq "++" ){
137 $mpd->volume('+10');
138 }elsif ( $mpfiresettings{'ACTION'} eq "--" ){
139 $mpd->volume('-10');
140 }elsif ( $mpfiresettings{'ACTION'} eq ">" ){
141 $mpd->play();
142 }elsif ( $mpfiresettings{'ACTION'} eq "repeat" ){
143 $mpd->repeat();
144 }elsif ( $mpfiresettings{'ACTION'} eq "shuffle" ){
145 $mpd->random();
a609bfb0 146 }
e5a63a6f
CS
147 print <<END
148<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
149<title></title>
150<body>
151<table width='95%' cellspacing='0'>
152<tr>
153<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}?control'><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>
154<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}?control'><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>
155<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}?control'><input type='hidden' name='ACTION' value='|>' /><input type='image' alt='$Lang::tr{'toggle'}' title='$Lang::tr{'toggle'}' src='/images/media-resume.png' /></form></td>
156<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}?control'><input type='hidden' name='ACTION' value='>' /><input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /></form></td>
157<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}?control'><input type='hidden' name='ACTION' value='playall' /><input type='image' alt='$Lang::tr{'play'} all' title='$Lang::tr{'play'} all' src='/images/media-playback-start-all.png' /></form></td>
158<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}?control'><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>
159</tr>
160END
161;
162 print <<END
163<tr>
164<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}?control'><input type='hidden' name='ACTION' value='repeat' /><input type='image' alt='$Lang::tr{'repeat'}' title='$Lang::tr{'repeat'}' src='/images/media-repeat.png' /></form></td>
165<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}?control'><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>
166<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}?control'><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>
167<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}?control'><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>
168<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}?control'><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>
169<td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}?control'><input type='hidden' name='ACTION' value='shuffle' /><input type='image' alt='$Lang::tr{'shuffle'}' title='$Lang::tr{'shuffle'}' src='/images/media-shuffle.png' /></form></td>
170</tr>
171</table>
172</body>
173END
174;
175 exit;
176}
a609bfb0 177
e5a63a6f
CS
178# just a little subpage to handle automatic page refresh on demand ( 1 sec )
179sub refreshpage{
180 &Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;' />" );
181 print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>$Lang::tr{'pagerefresh'}</font></center>";
182 &Header::closebox();
183}
184
185# if the mpd is updating his database because of user interaction then the cgi
186# should display that the mpd is unavailable, and refresh the status every 5 seconds
187if ($work ne ""){
188 &Header::openpage($Lang::tr{'mpfire'}, 1,);
189 &Header::openbigbox('100%', 'left', '', $errormessage);
190 &Header::openbox( 'Waiting', 5, "<meta http-equiv='refresh' content='5;' />" );
191 print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>Database is updating, please be patient.</font></center>";
192 &Header::closebox();
193 &Header::closebigbox();
194 &Header::closepage();
195 exit;
196}
a609bfb0 197
e5a63a6f 198if ( $mpfiresettings{'PAGE'} eq "" ){$mpfiresettings{'PAGE'} = "1";}
70ccd4a7 199
69addbb8 200&Header::getcgihash(\%mpfiresettings);
8a5898e7 201&Header::openpage($Lang::tr{'mpfire'}, 1,);
a28fdc01
CS
202&Header::openbigbox('100%', 'left', '', $errormessage);
203
a28fdc01
CS
204############################################################################################################################
205######################################## Scanne Verzeichnisse nach Mp3 Dateien #############################################
206
e5a63a6f 207if ( $mpfiresettings{'ACTION'} eq "scan" ){
70ccd4a7 208
e5a63a6f
CS
209# on keypress scan the given directory and store the path to the mpd config
210 &General::readhash("${General::swroot}/mpfire/settings", \%mpfiresettings);
211 &Header::getcgihash(\%mpfiresettings);
212 delete $mpfiresettings{'__CGI__'};delete $mpfiresettings{'x'};delete $mpfiresettings{'y'};
213 &General::writehash("${General::swroot}/mpfire/settings", \%mpfiresettings);
214
215 open(DATEI, "<${General::swroot}/mpfire/mpd.conf") || die "Datei nicht gefunden";
216 my @Zeilen = <DATEI>;
217 close(DATEI);
218
219 open(DATEI, ">${General::swroot}/mpfire/mpd.conf") || die "Datei nicht gefunden";
220 foreach (@Zeilen){
221 if ( $_ =~ /music_directory/){
222 print DATEI "music_directory \"".$mpfiresettings{'MUSICDIR'}."\"\n";
223 }else {
224 print DATEI $_;
225 }
a609bfb0 226 }
e5a63a6f
CS
227 close(DATEI);
228
229 $mpd->updatedb();
230 refreshpage();
231}elsif ( $mpfiresettings{'ACTION'} eq "playweb" ){
232 $message=system("/usr/local/bin/mpfirectrl","playweb","\"$mpfiresettings{'FILE'}\"","2>/dev/null");
233}elsif ( $mpfiresettings{'ACTION'} eq "playlist" ){
234# on keypress play the playlist
235 $message=system("/usr/local/bin/mpfirectrl playlist 2>/dev/null");
236}elsif ( $mpfiresettings{'ACTION'} eq "emptyplaylist" ){
237# on keypress clear the playlist
238 $mpd->playlist->clear();
239}elsif ( $mpfiresettings{'ACTION'} eq "addtoplaylist" ){
240 $mpd->playlist->add($mpfiresettings{'FILE'});
241}elsif ( $mpfiresettings{'ACTION'} eq "playalbum" ){
242# on keypress play the selected albums
243 my @select = split(/\|/,$mpfiresettings{'album'});
244 $mpd->playlist->clear();
a609bfb0 245 foreach (@select){
e5a63a6f
CS
246 foreach ($mpd->collection->filenames_by_album($_)){
247 if ( $_ ne "" ){
248 $mpd->playlist->add($_);
249 }
250 }
a609bfb0 251 }
e5a63a6f
CS
252 $mpd->play();
253}elsif ( $mpfiresettings{'ACTION'} eq "playartist" ){
254# on keypress play the selected artist
255 my @select = split(/\|/,$mpfiresettings{'artist'});
256 $mpd->playlist->clear();
a609bfb0 257 foreach (@select){
e5a63a6f
CS
258 foreach ($mpd->collection->filenames_by_artist($_)){
259 if ( $_ ne "" ){
260 $mpd->playlist->add($_);
261 }
262 }
a609bfb0 263 }
e5a63a6f
CS
264 $mpd->play();
265}elsif ( $mpfiresettings{'ACTION'} eq "playyear" ){
266# on keypress play the selected year
267 my @select = split(/\|/,$mpfiresettings{'year'});
268 $mpd->playlist->clear();
a609bfb0 269 foreach (@select){
e5a63a6f
CS
270 foreach ($mpd->collection->filenames_by_year($_)){
271 if ( $_ ne "" ){
272 $mpd->playlist->add($_);
273 }
274 }
a609bfb0 275 }
e5a63a6f
CS
276 $mpd->play();
277}elsif ( $mpfiresettings{'ACTION'} eq "playgenre" ){
278# on keypress play the selected genre
279 my @select = split(/\|/,$mpfiresettings{'genre'});
280 $mpd->playlist->clear();
281 foreach (@select){
282 foreach ($mpd->collection->filenames_by_genre($_)){
283 if ( $_ ne "" ){
284 $mpd->playlist->add($_);
285 }
286 }
287 }
288 $mpd->play();
289}elsif ( $mpfiresettings{'ACTION'} eq ">" ){
290 $mpd->playlist->clear();
291 $mpd->playlist->add($mpfiresettings{'FILE'});
292 $mpd->play();
8050f37b 293}
8050f37b 294
e5a63a6f
CS
295 if ( $mpfiresettings{'SEARCH'} eq "artist" && $mpfiresettings{'SEARCHITEM'} ne "" ){
296 foreach ($mpd->collection->songs_with_artist_partial_filename($mpfiresettings{'SEARCHITEM'})){
297 if ( $_ ne "" ){
298 push(@songs,$_);
299 }
300 }
301 }elsif ( $mpfiresettings{'SEARCH'} eq "title" && $mpfiresettings{'SEARCHITEM'} ne "" ){
302 foreach ($mpd->collection->songs_with_title_partial_filename($mpfiresettings{'SEARCHITEM'})){
303 if ( $_ ne "" ){
304 push(@songs,$_);
305 }
306 }
307 }elsif ( $mpfiresettings{'SEARCH'} eq "album" && $mpfiresettings{'SEARCHITEM'} ne "" ){
308 foreach ($mpd->collection->songs_with_album_partial_filename($mpfiresettings{'SEARCHITEM'})){
309 if ( $_ ne "" ){
310 push(@songs,$_);
311 }
312 }
313 }else{
314 @songs = $mpd->collection->all_items_simple();
315 shift(@songs);
316 }
a28fdc01
CS
317
318############################################################################################################################
319################################### Aufbau der HTML Seite fr globale Sambaeinstellungen ####################################
320
70ccd4a7 321$mpfiresettings{'MUSICDIR'} = "/";
a28fdc01
CS
322&General::readhash("${General::swroot}/mpfire/settings", \%mpfiresettings);
323
324############################################################################################################################
325########################################### rekursiv nach neuen Mp3s Scannen ##############################################ä
326
e5a63a6f
CS
327if ( $message ne '0' ){
328 print "<font color='red'>An Error occured while launching the command</font>";
329}elsif ( $message ne "" && $message ne '0' ){
330 print "<font color='red'>$message</font>";
331}
a28fdc01
CS
332
333&Header::openbox('100%', 'center', $Lang::tr{'mpfire scanning'});
e5a63a6f 334# box to enter the music directory and initiate the scan process
a28fdc01
CS
335print <<END
336<form method='post' action='$ENV{'SCRIPT_NAME'}'>
337<table width='95%' cellspacing='0'>
338<tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'Scan for Files'}</b></td></tr>
19f5a6cc 339<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>
e5a63a6f 340<tr><td align='center' colspan='2'><input type='hidden' name='ACTION' value='scan' /><input type='image' alt='$Lang::tr{'Scan for Files'}' title='$Lang::tr{'Scan for Files'}' src='/images/edit-find.png' /></td></tr>
a28fdc01
CS
341</table>
342</form>
343END
344;
345&Header::closebox();
346
347&Header::openbox('100%', 'center', $Lang::tr{'mpfire controls'});
e5a63a6f 348# box for the two iframes showing the current playbar and the control buttons
a28fdc01 349print <<END
e5a63a6f
CS
350<iframe height='85' width='685' src='/cgi-bin/mpfire.cgi?title' scrolling='no' frameborder='no' marginheight='0'></iframe>
351<iframe height='50' width='685' src='/cgi-bin/mpfire.cgi?control' scrolling='no' frameborder='no' marginheight='0'></iframe>
a28fdc01
CS
352END
353;
e5a63a6f
CS
354print "<b>Songs:".$mpd->stats()->songs()."</b><br />";
355
a28fdc01
CS
356&Header::closebox();
357
32ab16de 358&Header::openbox('100%', 'center', $Lang::tr{'quick playlist'});
e5a63a6f 359# box to quickly select artist, album, year or genre and play the selection
cb5e9c6c 360print "<table width='95%' cellspacing='0'>";
e5a63a6f
CS
361print "<tr><td align='center' bgcolor='$color{'color20'}'><b>$Lang::tr{'artist'} - ".$mpd->stats()->artists()."</b></td><td align='center' bgcolor='$color{'color20'}'><b>$Lang::tr{'album'} - ".$mpd->stats()->albums()."</b></td></tr>";
362
05882fff 363print <<END
e5a63a6f
CS
364<tr><td align='center'>
365<form method='post' action='$ENV{'SCRIPT_NAME'}'>
366<select name='artist' size='8' multiple='multiple' style='width:300px;'>
32ab16de
CS
367END
368;
e5a63a6f
CS
369
370foreach ($mpd->collection->all_artists()){
371 if ( $_ ne '' ){
372 print "<option>".encode('utf-8', $_)."</option>\n";
373 }
374}
375
32ab16de 376print <<END
e5a63a6f
CS
377</select><br/>
378<input type='hidden' name='ACTION' value='playartist' />
379<input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' />
380</form></td>
381<td align='center'>
382<form method='post' action='$ENV{'SCRIPT_NAME'}'>
383<select name='album' size='8' multiple='multiple' style='width:300px;'>
32ab16de
CS
384END
385;
e5a63a6f
CS
386
387foreach ($mpd->collection->all_albums()){
388 if ( $_ ne '' ){
389 print "<option>".encode('utf-8', $_)."</option>\n";
390 }
391}
392
32ab16de 393print <<END
e5a63a6f
CS
394</select><br/>
395<input type='hidden' name='ACTION' value='playalbum' />
396<input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' />
397</form></td>
398</tr>
399<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>
400<tr><td align='center'>
401<form method='post' action='$ENV{'SCRIPT_NAME'}'>
402<select name='year' size='8' multiple='multiple' style='width:300px;'>
05882fff
CS
403END
404;
e5a63a6f
CS
405
406foreach ($mpd->collection->all_years()){
407 if ( $_ ne '' ){
408 print "<option>$_</option>\n";
409 }
410}
411
05882fff 412print <<END
e5a63a6f
CS
413</select><br/>
414<input type='hidden' name='ACTION' value='playyear' />
415<input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' />
416</form></td>
417<td align='center'>
418<form method='post' action='$ENV{'SCRIPT_NAME'}'>
419<select name='genre' size='8' multiple='multiple' style='width:300px;'>
8050f37b
CS
420END
421;
e5a63a6f
CS
422
423foreach ($mpd->collection->all_genre()){
424 if ( $_ ne '' ){
425 print "<option>$_</option>\n";
426 }
427}
428
8050f37b 429print <<END
e5a63a6f
CS
430</select><br/>
431<input type='hidden' name='ACTION' value='playgenre' />
432<input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' />
433</form></td>
434</tr></table>
8050f37b
CS
435END
436;
e5a63a6f
CS
437
438&Header::closebox();
439
440&Header::openbox('100%', 'center', $Lang::tr{'mpfire search'});
441# box to quickly search artist, album or title
8050f37b 442print <<END
6cd3f682 443<form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'mpfire songs'}'>
e5a63a6f
CS
444<table width='95%' cellspacing='0'>
445<tr>
446<td align='right' width='33%'>$Lang::tr{'artist'}</td>
447<td align='center' width='33%'>$Lang::tr{'title'}</td>
448<td align='left' width='33%'>$Lang::tr{'album'}</td>
449</tr>
450<tr>
451<td align='right' width='33%'><input type='radio' name='SEARCH' value='artist' /></td>
452<td align='center' width='33%'><input type='radio' name='SEARCH' value='title' checked='checked' /></td>
453<td align='left' width='33%'><input type='radio' name='SEARCH' value='album' /></td>
454</tr>
455<tr>
456<td align='center' colspan='3'><input type='text' name='SEARCHITEM' value='$mpfiresettings{'SEARCHITEM'}' size="50" /></td>
457</tr>
458<tr>
459<td align='center' colspan='3'><input type='hidden' name='ACTION' value='search' /><input type='image' alt='$Lang::tr{'Scan for Songs'}' title='$Lang::tr{'Scan for Songs'}' src='/images/edit-find.png' /></td>
460</tr>
461</table>
462</form>
32ab16de
CS
463END
464;
465&Header::closebox();
466
a28fdc01
CS
467&Header::openbox('100%', 'center', $Lang::tr{'mpfire songs'});
468print <<END
e5a63a6f
CS
469<a id='$Lang::tr{'mpfire songs'}' name='$Lang::tr{'mpfire songs'}'></a>
470<table width='95%' cellspacing='3'>
471<tr bgcolor='$color{'color20'}'><td colspan='4' align='left'><b>$Lang::tr{'Existing Files'}</b></td></tr>
8871b9f2
CS
472END
473;
e5a63a6f
CS
474if ( $#songs > 100 ){
475 print "<tr><td align='center' colspan='4'><br/>$Lang::tr{'Pages'}<br/><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='submit' name='PAGE' value='all' /><br/>";
476 my $pages =(int($#songs/100)+1);
477 for(my $i = 1; $i <= $pages; $i++){
478 print "<input type='submit' name='PAGE' value='$i' />";
479 if (!($i % 205)){
480 print"<br/>";
481 }
482 }
483
484 print "</form></td></tr>";
8871b9f2
CS
485}
486print <<END
a28fdc01 487<tr><td align='center'></td>
e5a63a6f
CS
488<td align='center'><b>$Lang::tr{'artist'}<br/>$Lang::tr{'title'}</b></td>
489<td align='center'><b>$Lang::tr{'number'}</b></td>
490<td align='center'><b>$Lang::tr{'album'}</b></td>
a28fdc01
CS
491END
492;
e5a63a6f 493
8871b9f2
CS
494my $lines=0;my $i=0;my $begin;my $end;
495if ( $mpfiresettings{'PAGE'} eq 'all' ){
a609bfb0 496 $begin=0;
e5a63a6f
CS
497 $end=$#songs;
498}else{
a609bfb0
CS
499 $begin=(($mpfiresettings{'PAGE'}-1) * 100);
500 $end=(($mpfiresettings{'PAGE'} * 100)-1);
8871b9f2 501}
e5a63a6f 502 foreach (@songs){
a609bfb0 503 if (!($i >= $begin && $i <= $end)){
e5a63a6f
CS
504 #print $begin."->".$i."<-".$end."\n";
505 $i++;next;
506 }
507 my @song = split(/\=/,$mpd->collection->song($_));
508 @song = reverse @song;
a609bfb0 509
e5a63a6f
CS
510 if ($lines % 2) {
511 print "<tr bgcolor='$color{'color20'}'>";
512 }else{
513 print "<tr bgcolor='$color{'color22'}'>";
514 }
a609bfb0 515 print <<END
e5a63a6f
CS
516<td align='center' style="white-space:nowrap;">
517<form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'mpfire songs'}'>
518<input type='hidden' name='ACTION' value='addtoplaylist' />
519<input type='hidden' name='FILE' value="$_" />
520<input type='hidden' name='PAGE' value='$mpfiresettings{'PAGE'}' />
521<input type='hidden' name='SEARCH' value='$mpfiresettings{'SEARCH'}' />
522<input type='hidden' name='SEARCHITEM' value='$mpfiresettings{'SEARCHITEM'}' />
523<input type='image' alt='$Lang::tr{'add'}' title='$Lang::tr{'add'}' src='/images/list-add.png' />
524</form>
525<form method='post' action='$ENV{'SCRIPT_NAME'}#$Lang::tr{'mpfire songs'}'>
526<input type='hidden' name='ACTION' value='>' />
527<input type='hidden' name='FILE' value="$_" />
528<input type='hidden' name='PAGE' value='$mpfiresettings{'PAGE'}' />
529<input type='hidden' name='SEARCH' value='$mpfiresettings{'SEARCH'}' />
530<input type='hidden' name='SEARCHITEM' value='$mpfiresettings{'SEARCHITEM'}' />
531<input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' />
532</form>
533</td>
a28fdc01
CS
534END
535;
e5a63a6f
CS
536 print "<td align='center'>".encode('utf-8', $song[0])."<br/>".encode('utf-8', $song[1])."</td>";
537 print "<td align='center'>".encode('utf-8', $song[2])."</td>";
538 print "<td align='center'>".encode('utf-8', $song[3])."</td>";
a609bfb0
CS
539 $lines++;
540 $i++;
e5a63a6f
CS
541}
542
8871b9f2 543print "</table>";
a28fdc01 544&Header::closebox();
a28fdc01 545
32ab16de 546&Header::openbox('100%', 'center', $Lang::tr{'mpfire playlist'});
e5a63a6f 547# box to show the current playlist given from mpc system command
8c384f97 548my @playlist = `mpc playlist 2>/dev/null`;
bac7231b 549
32ab16de
CS
550print <<END
551<table width='95%' cellspacing='0'>
8871b9f2
CS
552<tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'current playlist'}</b></td></tr>
553<tr><td align='center' colspan='2' ><textarea cols='100' rows='10' name='playlist' style='font-size:11px;width:650px;' readonly='readonly'>
bac7231b
CS
554END
555;
e5a63a6f
CS
556
557foreach (@playlist){
558 $_=~s/&/&amp\;/g;;print $_;
559}
560
bac7231b 561print <<END
8871b9f2
CS
562</textarea></td></tr><tr>
563<td align='right'>
e5a63a6f
CS
564<form method='post' action='$ENV{'SCRIPT_NAME'}'>
565<input type='hidden' name='ACTION' value='emptyplaylist' />
566<input type='image' alt='$Lang::tr{'clear playlist'}' title='$Lang::tr{'clear playlist'}' src='/images/user-trash.png' />
567</form>
8871b9f2
CS
568</td>
569<td align='left'>
e5a63a6f
CS
570<form method='post' action='$ENV{'SCRIPT_NAME'}'>
571<input type='hidden' name='ACTION' value='playlist' />
572<input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' />
573</form>
a609bfb0 574</td></tr>
32ab16de
CS
575</table>
576END
577;
e5a63a6f 578
32ab16de
CS
579&Header::closebox();
580
a2d5130f 581&Header::openbox('100%', 'center', $Lang::tr{'mpfire webradio'});
e5a63a6f 582# box to select some webradio´s to be played by one click
a2d5130f
CS
583open(DATEI, "<${General::swroot}/mpfire/webradio") || die "Could not open playlist";
584my @webradio = <DATEI>;
585close(DATEI);
586
587print <<END
588<table width='95%' cellspacing='0'>
589<tr bgcolor='$color{'color20'}'><td colspan='9' align='left'><b>$Lang::tr{'webradio playlist'}</b></td></tr>
efb2af14 590<tr><td align='left'>Stream</td><td colspan='2'></td></tr>
a2d5130f
CS
591END
592;
e5a63a6f 593
d089ce65 594my $lines=0;
a2d5130f 595foreach (@webradio){
a609bfb0
CS
596 my @stream = split(/\|/,$_);
597 $lines++;
598 chomp($stream[2]);
e5a63a6f
CS
599 if ($lines % 2) {
600 print "<tr bgcolor='$color{'color22'}'>";
601 }else{
602 print "<tr>";
603 }
3fcb086e 604 chomp $stream[1];chomp $stream[2];
e5a63a6f
CS
605 print <<END
606<td align='left'><a href='$stream[2]' target='_blank'>$stream[1]</a></td>
607<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
608</tr>
609END
610;
e5a63a6f
CS
611}
612
613$lines++;
614if ($lines % 2){
615 print "<tr bgcolor='$color{'color22'}'>";
616}else{
617 print "<tr>";
618}
619
d089ce65 620print <<END
e5a63a6f
CS
621<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' />
622<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
623</tr>
624END
625;
a2d5130f
CS
626print "</table>";
627&Header::closebox();
a28fdc01
CS
628&Header::closebigbox();
629&Header::closepage();