]>
git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/mpfire.cgi
5 # This code is distributed under the terms of the GPL
10 # enable only the following on debugging purpose
12 use CGI
::Carp
'fatalsToBrowser';
14 require '/var/ipfire/general-functions.pl';
15 require "${General::swroot}/lang.pl";
16 require "${General::swroot}/header.pl";
19 my %mainsettings = ();
20 my %mpfiresettings = ();
23 my $errormessage = "";
25 open(DATEI
, "<${General::swroot}/mpfire/db/songs.db") || die "No Database found";
28 @songdb = sort(@songdb);
30 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
31 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
33 &Header
::showhttpheaders
();
34 &Header
::getcgihash
(\
%mpfiresettings);
36 &Header
::openpage
($Lang::tr
{'mpfire'}, 1, "<meta http-equiv='refresh' content='120'>");
37 &Header
::openbigbox
('100%', 'left', '', $errormessage);
39 ############################################################################################################################
40 ######################################## Scanne Verzeichnisse nach Mp3 Dateien #############################################
42 if ( $mpfiresettings{'ACTION'} eq "scan" )
44 delete $mpfiresettings{'__CGI__'};delete $mpfiresettings{'x'};delete $mpfiresettings{'y'};
45 &General
::writehash
("${General::swroot}/mpfire/settings", \
%mpfiresettings);
46 system("/usr/local/bin/mpfirectrl scan $mpfiresettings{'SCANDIR'} $mpfiresettings{'SCANDIRDEPS'}");
49 if ( $mpfiresettings{'ACTION'} eq ">" ){system("/usr/local/bin/mpfirectrl","play","\"$mpfiresettings{'FILE'}\"");}
50 if ( $mpfiresettings{'ACTION'} eq "x" ){system("/usr/local/bin/mpfirectrl stop");}
51 if ( $mpfiresettings{'ACTION'} eq "||" ){system("/usr/local/bin/mpfirectrl pause");}
52 if ( $mpfiresettings{'ACTION'} eq "|>" ){system("/usr/local/bin/mpfirectrl resume");}
53 if ( $mpfiresettings{'ACTION'} eq ">>" ){system("/usr/local/bin/mpfirectrl next");}
54 if ( $mpfiresettings{'ACTION'} eq "stopweb" ){system("/usr/local/bin/mpfirectrl stopweb");}
55 if ( $mpfiresettings{'ACTION'} eq "playweb" ){system("/usr/local/bin/mpfirectrl","playweb","\"$mpfiresettings{'FILE'}\"");}
56 if ( $mpfiresettings{'ACTION'} eq "+" ){system("/usr/local/bin/mpfirectrl volup 5");}
57 if ( $mpfiresettings{'ACTION'} eq "-" ){system("/usr/local/bin/mpfirectrl voldown 5");}
58 if ( $mpfiresettings{'ACTION'} eq "++" ){system("/usr/local/bin/mpfirectrl volup 10");}
59 if ( $mpfiresettings{'ACTION'} eq "--" ){system("/usr/local/bin/mpfirectrl voldown 10");}
60 if ( $mpfiresettings{'ACTION'} eq "playlist" ){system("/usr/local/bin/mpfirectrl playall");}
61 if ( $mpfiresettings{'ACTION'} eq "playalbum" )
64 my @album = split(/\|/,$mpfiresettings{'album'});
65 my %hash = map{ $_, 1 }@album;
68 my @song = split(/\|/,$_);
70 push(@temp,$song[0]."\n") if exists $hash{$song[4]};
72 open(DATEI
, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist";
75 system("/usr/local/bin/mpfirectrl playall");
77 if ( $mpfiresettings{'ACTION'} eq "playartist" )
80 my @artist = split(/\|/,$mpfiresettings{'artist'});
81 my %hash = map{ $_, 1 }@artist;
84 my @song = split(/\|/,$_);
86 push(@temp,$song[0]."\n") if exists $hash{$song[1]};
88 open(DATEI
, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist";
91 system("/usr/local/bin/mpfirectrl playall");
93 if ( $mpfiresettings{'ACTION'} eq "playall" )
97 my @song = split(/\|/,$_);
99 push(@temp,$song[0]."\n");
101 open(DATEI
, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist";
104 system("/usr/local/bin/mpfirectrl playall");
106 if ( $mpfiresettings{'SHOWLIST'} ){delete $mpfiresettings{'__CGI__'};delete $mpfiresettings{'x'};delete $mpfiresettings{'y'};&General
::writehash
("${General::swroot}/mpfire/settings", \
%mpfiresettings);}
108 ############################################################################################################################
109 ################################### Aufbau der HTML Seite fr globale Sambaeinstellungen ####################################
111 $mpfiresettings{'SCANDIR'} = "/";
112 $mpfiresettings{'SHOWLIST'} = "off";
114 &General
::readhash
("${General::swroot}/mpfire/settings", \
%mpfiresettings);
116 ############################################################################################################################
117 ########################################### rekursiv nach neuen Mp3s Scannen ##############################################รค
119 if ( $message ne "" ) { print "<font color='red'>$message</font>"; }
121 &Header
::openbox
('100%', 'center', $Lang::tr
{'mpfire scanning'});
124 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
125 <table width='95%' cellspacing='0'>
126 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'Scan for Files'}</b></td></tr>
127 <tr><td align='left' width='40%'>$Lang::tr{'Scan from Directory'}</td><td align='left'><input type='text' name='SCANDIR' value='$mpfiresettings{'SCANDIR'}' size="30" /></td></tr>
128 <tr><td align='left' width='40%'>$Lang::tr{'deep scan directories'}</td><td align='left'>on <input type='radio' name='SCANDIRDEPS' value='on' checked='checked'/>/
129 <input type='radio' name='SCANDIRDEPS' value='off'/> off</td></tr>
130 <tr><td align='center' colspan='2'><input type='hidden' name='ACTION' value='scan' />
131 <input type='image' alt='$Lang::tr{'Scan for Files'}' title='$Lang::tr{'Scan for Files'}' src='/images/edit-find.png' /></td></tr>
138 my $song = qx(/usr/local/bin/mpfirectrl song
);
139 if ( $song eq "" ){$song = "None";}
141 &Header
::openbox
('100%', 'center', $Lang::tr
{'mpfire controls'});
142 print "<table width='95%' cellspacing='0'><tr bgcolor='$color{'color20'}'><td colspan='5' align='center'><marquee behavior='alternate' scrollamount='1' scrolldelay='5'><font color=red>-= $song =-</font></marquee></td></tr><tr><td colspan='5'><br/></td></tr><tr>";
144 <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>
145 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='||' /><input type='image' alt='$Lang::tr{'pause'}' title='$Lang::tr{'pause'}' src='/images/media-playback-pause.png' /></form></td>
146 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='|>' /><input type='image' alt='$Lang::tr{'resume'}' title='$Lang::tr{'resume'}' src='/images/media-resume.png' /></form></td>
147 <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>
148 <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>
152 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>";}
153 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>";}
155 <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>
156 <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>
157 <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>
158 <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>
165 &Header
::openbox
('100%', 'center', $Lang::tr
{'quick playlist'});
170 my @song = split(/\|/,$_);
171 push(@artist,$song[1]);push(@album,$song[4]);}
172 my %hash = map{ $_, 1 }@artist;
173 @artist = sort keys %hash;
174 my %hash = map{ $_, 1 }@album;
175 @album = sort keys %hash;
177 <table width='95%' cellspacing='0'>
178 <tr><td align='center'>
179 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
180 <select name='artist' size='8' multiple='multiple'>
183 foreach (@artist){print "<option>$_</option>";}
186 <input type='hidden' name='ACTION' value='playartist' />
187 <input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' />
190 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
191 <select name='album' size='8' multiple='multiple'>
194 foreach (@album){print "<option>$_</option>";}
197 <input type='hidden' name='ACTION' value='playalbum' />
198 <input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' />
205 if ( $mpfiresettings{'SHOWLIST'} eq "on" ){
207 &Header
::openbox
('100%', 'center', $Lang::tr
{'mpfire songs'});
210 <table width='95%' cellspacing='5'>
211 <tr bgcolor='$color{'color20'}'><td colspan='9' align='left'><b>$Lang::tr{'Existing Files'}</b></td></tr>
212 <tr><td align='center'></td>
213 <td align='center'><b>$Lang::tr{'artist'}<br/>$Lang::tr{'title'}</b></td>
214 <td align='center'><b>$Lang::tr{'number'}</b></td>
215 <td align='center'><b>$Lang::tr{'album'}</b></td>
216 <td align='center'><b>$Lang::tr{'year'}</b></td>
217 <td align='center'><b>$Lang::tr{'genre'}</b></td>
218 <td align='center'><b>$Lang::tr{'length'}<br/>$Lang::tr{'bitrate'} - $Lang::tr{'frequency'}</b></td>
219 <td align='center'><b>$Lang::tr{'mode'}</b></td></tr>
224 my @song = split(/\|/,$_);
226 if ($lines % 2) {print "<tr bgcolor='$color{'color20'}'>";} else {print "<tr bgcolor='$color{'color22'}'>";}
227 $song[0]=~s/\/\//\//g
;
229 <td align='center' style="white-space:nowrap;"><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>
230 <td align='center'>$song[1]<br/>$song[2]</td>
231 <td align='center'>$song[3]</td>
232 <td align='center'>$song[4]</td>
233 <td align='center'>$song[5]</td>
234 <td align='center'>$song[6]</td>
235 <td align='center'>$song[7]:$song[8]<br/>$song[9] - $song[10]</td>
238 if ( $song[11] eq "0\n" ) {print "<td align='center'>Stereo</td></tr>"; }
239 elsif ( $song[11] eq "1\n" ) {print "<td align='center'>Joint<br/>Stereo</td></tr>"; }
240 elsif ( $song[11] eq "2\n" ) {print "<td align='center'>Dual<br/>Channel</td></tr>"; }
241 elsif ( $song[11] eq "3\n" ) {print "<td align='center'>Single<br/>Channel</td></tr>"; }
242 else {print "<td align='center'></td></tr>"; }
245 print "</table></form>";
249 &Header
::openbox
('100%', 'center', $Lang::tr
{'mpfire playlist'});
251 open(DATEI
, "<${General::swroot}/mpfire/playlist") || die "Could not open playlist";
252 my @playlist = <DATEI
>;
256 <table width='95%' cellspacing='0'>
257 <tr bgcolor='$color{'color20'}'><td colspan='9' align='left'><b>$Lang::tr{'current playlist'}</b></td></tr>
258 <tr><td align='center'><textarea cols='120' rows='10' name='playlist' style='font-size:10px' readonly='readonly' >@playlist</textarea><br/>
259 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
260 <input type='hidden' name='ACTION' value='playlist' />
261 <input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' />
268 &Header
::openbox
('100%', 'center', $Lang::tr
{'mpfire webradio'});
270 open(DATEI
, "<${General::swroot}/mpfire/webradio") || die "Could not open playlist";
271 my @webradio = <DATEI
>;
275 <table width='95%' cellspacing='0'>
276 <tr bgcolor='$color{'color20'}'><td colspan='9' align='left'><b>$Lang::tr{'webradio playlist'}</b></td></tr>
277 <tr><td>Stream</td><td colspan='2'></td></tr>
281 my @stream = split(/\|/,$_);
283 <tr><td>$stream[1]</td>
284 <td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'><input type='hidden' name='ACTION' value='stopweb' /><input type='image' alt='$Lang::tr{'stop'}' title='$Lang::tr{'stop'}' src='/images/media-playback-stop.png' /></form></td>
285 <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>
293 &Header
::closebigbox
();
294 &Header
::closepage
();