]>
Commit | Line | Data |
---|---|---|
a28fdc01 CS |
1 | #!/usr/bin/perl |
2 | # | |
3 | # IPFire CGIs | |
4 | # | |
5 | # This code is distributed under the terms of the GPL | |
6 | # | |
7 | # (c) The IPFire Team | |
8 | ||
9 | use strict; | |
10 | # enable only the following on debugging purpose | |
11 | use warnings; | |
12 | use CGI::Carp 'fatalsToBrowser'; | |
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 = (); | |
22 | my $message = ""; | |
23 | my $errormessage = ""; | |
24 | ||
25 | open(DATEI, "<${General::swroot}/mpfire/db/songs.db") || die "No Database found"; | |
26 | my @songdb = <DATEI>; | |
27 | close(DATEI); | |
28 | @songdb = sort(@songdb); | |
29 | ||
30 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
31 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
32 | ||
33 | &Header::showhttpheaders(); | |
34 | &Header::getcgihash(\%mpfiresettings); | |
35 | ||
36 | &Header::openpage($Lang::tr{'mpfire'}, 1, ''); | |
37 | &Header::openbigbox('100%', 'left', '', $errormessage); | |
38 | ||
39 | sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;'>" );} | |
40 | ||
41 | ############################################################################################################################ | |
42 | ######################################## Scanne Verzeichnisse nach Mp3 Dateien ############################################# | |
43 | ||
44 | if ( $mpfiresettings{'ACTION'} eq "scan" ) | |
45 | { | |
46 | delete $mpfiresettings{'__CGI__'};delete $mpfiresettings{'x'};delete $mpfiresettings{'y'}; | |
47 | &General::writehash("${General::swroot}/mpfire/settings", \%mpfiresettings); | |
48 | system("/usr/local/bin/mpfirectrl scan $mpfiresettings{'SCANDIR'} $mpfiresettings{'SCANDIRDEPS'}"); | |
49 | } | |
50 | ||
32ab16de | 51 | if ( $mpfiresettings{'ACTION'} eq ">" ){system("/usr/local/bin/mpfirectrl","play","\"$mpfiresettings{'FILE'}\""); print $mpfiresettings{'FILE'};} |
a28fdc01 CS |
52 | if ( $mpfiresettings{'ACTION'} eq "x" ){system("/usr/local/bin/mpfirectrl stop");} |
53 | if ( $mpfiresettings{'ACTION'} eq "||" ){system("/usr/local/bin/mpfirectrl pause");} | |
54 | if ( $mpfiresettings{'ACTION'} eq "|>" ){system("/usr/local/bin/mpfirectrl resume");} | |
55 | if ( $mpfiresettings{'ACTION'} eq ">>" ){system("/usr/local/bin/mpfirectrl next");} | |
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");} | |
32ab16de CS |
60 | if ( $mpfiresettings{'ACTION'} eq "playlist" ){system("/usr/local/bin/mpfirectrl playall");} |
61 | if ( $mpfiresettings{'ACTION'} eq "playalbum" ) | |
62 | { | |
63 | my @temp = ""; | |
64 | my @album = split(/\|/,$mpfiresettings{'album'}); | |
65 | my %hash = map{ $_, 1 }@album; | |
66 | ||
67 | foreach (@songdb){ | |
68 | my @song = split(/\|/,$_); | |
69 | chomp($song[0]); | |
70 | push(@temp,$song[0]."\n") if exists $hash{$song[4]}; | |
71 | } | |
72 | open(DATEI, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist"; | |
73 | print DATEI @temp; | |
74 | close(DATEI); | |
75 | system("/usr/local/bin/mpfirectrl playall"); | |
76 | } | |
77 | if ( $mpfiresettings{'ACTION'} eq "playartist" ) | |
78 | { | |
79 | my @temp = ""; | |
80 | my @artist = split(/\|/,$mpfiresettings{'artist'}); | |
81 | my %hash = map{ $_, 1 }@artist; | |
82 | ||
83 | foreach (@songdb){ | |
84 | my @song = split(/\|/,$_); | |
85 | chomp($song[0]); | |
86 | push(@temp,$song[0]."\n") if exists $hash{$song[1]}; | |
87 | } | |
88 | open(DATEI, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist"; | |
89 | print DATEI @temp; | |
90 | close(DATEI); | |
91 | system("/usr/local/bin/mpfirectrl playall"); | |
92 | } | |
a28fdc01 CS |
93 | if ( $mpfiresettings{'ACTION'} eq "playall" ) |
94 | { | |
95 | my @temp = ""; | |
96 | foreach (@songdb){ | |
97 | my @song = split(/\|/,$_); | |
98 | chomp($song[0]); | |
99 | push(@temp,$song[0]."\n"); | |
100 | } | |
101 | open(DATEI, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist"; | |
102 | print DATEI @temp; | |
103 | close(DATEI); | |
104 | system("/usr/local/bin/mpfirectrl playall"); | |
105 | } | |
106 | if ( $mpfiresettings{'SHOWLIST'} ){delete $mpfiresettings{'__CGI__'};delete $mpfiresettings{'x'};delete $mpfiresettings{'y'};&General::writehash("${General::swroot}/mpfire/settings", \%mpfiresettings);} | |
107 | ||
108 | ############################################################################################################################ | |
109 | ################################### Aufbau der HTML Seite fr globale Sambaeinstellungen #################################### | |
110 | ||
111 | $mpfiresettings{'SCANDIR'} = "/"; | |
112 | $mpfiresettings{'SHOWLIST'} = "off"; | |
113 | ||
114 | &General::readhash("${General::swroot}/mpfire/settings", \%mpfiresettings); | |
115 | ||
116 | ############################################################################################################################ | |
117 | ########################################### rekursiv nach neuen Mp3s Scannen ##############################################รค | |
118 | ||
119 | if ( $message ne "" ) { print "<font color='red'>$message</font>"; } | |
120 | ||
121 | &Header::openbox('100%', 'center', $Lang::tr{'mpfire scanning'}); | |
122 | ||
123 | print <<END | |
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> | |
132 | </table> | |
133 | </form> | |
134 | END | |
135 | ; | |
136 | &Header::closebox(); | |
137 | ||
138 | &Header::openbox('100%', 'center', $Lang::tr{'mpfire controls'}); | |
32ab16de | 139 | print "<table width='95%' cellspacing='0'><tr>"; |
a28fdc01 CS |
140 | print <<END |
141 | <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> | |
142 | <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> | |
143 | <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> | |
144 | <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> | |
145 | <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> | |
146 | </tr> | |
147 | END | |
148 | ; | |
149 | 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>";} | |
150 | 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>";} | |
151 | print <<END | |
152 | <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> | |
153 | <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> | |
154 | <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> | |
155 | <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> | |
156 | </tr> | |
157 | </table> | |
158 | END | |
159 | ; | |
160 | &Header::closebox(); | |
161 | ||
32ab16de CS |
162 | &Header::openbox('100%', 'center', $Lang::tr{'quick playlist'}); |
163 | ||
164 | my @artist; | |
165 | my @album; | |
166 | foreach (@songdb){ | |
167 | my @song = split(/\|/,$_); | |
168 | push(@artist,$song[1]);push(@album,$song[4]);} | |
169 | my %hash = map{ $_, 1 }@artist; | |
170 | @artist = sort keys %hash; | |
171 | my %hash = map{ $_, 1 }@album; | |
172 | @album = sort keys %hash; | |
173 | print <<END | |
174 | <table width='95%' cellspacing='0'> | |
175 | <tr><td align='center'> | |
176 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
177 | <select name='artist' size='8' multiple='multiple'> | |
178 | END | |
179 | ; | |
180 | foreach (@artist){print "<option>$_</option>";} | |
181 | print <<END | |
182 | </select><br/> | |
183 | <input type='hidden' name='ACTION' value='playartist' /> | |
184 | <input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /> | |
185 | </form></td> | |
186 | <td align='center'> | |
187 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
188 | <select name='album' size='8' multiple='multiple'> | |
189 | END | |
190 | ; | |
191 | foreach (@album){print "<option>$_</option>";} | |
192 | print <<END | |
193 | </select><br/> | |
194 | <input type='hidden' name='ACTION' value='playalbum' /> | |
195 | <input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /> | |
196 | </form></td> | |
197 | </tr></table> | |
198 | END | |
199 | ; | |
200 | &Header::closebox(); | |
201 | ||
a28fdc01 CS |
202 | if ( $mpfiresettings{'SHOWLIST'} eq "on" ){ |
203 | ||
204 | &Header::openbox('100%', 'center', $Lang::tr{'mpfire songs'}); | |
205 | print <<END | |
206 | ||
32ab16de | 207 | <table width='95%' cellspacing='5'> |
a28fdc01 CS |
208 | <tr bgcolor='$color{'color20'}'><td colspan='9' align='left'><b>$Lang::tr{'Existing Files'}</b></td></tr> |
209 | <tr><td align='center'></td> | |
210 | <td align='center'><b>$Lang::tr{'artist'}<br/>$Lang::tr{'title'}</b></td> | |
211 | <td align='center'><b>$Lang::tr{'number'}</b></td> | |
212 | <td align='center'><b>$Lang::tr{'album'}</b></td> | |
213 | <td align='center'><b>$Lang::tr{'year'}</b></td> | |
214 | <td align='center'><b>$Lang::tr{'genre'}</b></td> | |
215 | <td align='center'><b>$Lang::tr{'length'}<br/>$Lang::tr{'bitrate'} - $Lang::tr{'frequency'}</b></td> | |
216 | <td align='center'><b>$Lang::tr{'mode'}</b></td></tr> | |
217 | END | |
218 | ; | |
219 | my $lines = 0; | |
220 | foreach (@songdb){ | |
221 | my @song = split(/\|/,$_); | |
222 | ||
223 | if ($lines % 2) {print "<tr bgcolor='$color{'color20'}'>";} else {print "<tr bgcolor='$color{'color22'}'>";} | |
224 | $song[0]=~s/\/\//\//g; | |
225 | print <<END | |
32ab16de | 226 | <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> |
a28fdc01 CS |
227 | <td align='center'>$song[1]<br/>$song[2]</td> |
228 | <td align='center'>$song[3]</td> | |
229 | <td align='center'>$song[4]</td> | |
230 | <td align='center'>$song[5]</td> | |
231 | <td align='center'>$song[6]</td> | |
232 | <td align='center'>$song[7]:$song[8]<br/>$song[9] - $song[10]</td> | |
233 | END | |
234 | ; | |
235 | if ( $song[11] eq "0\n" ) {print "<td align='center'>Stereo</td></tr>"; } | |
236 | elsif ( $song[11] eq "1\n" ) {print "<td align='center'>Joint<br/>Stereo</td></tr>"; } | |
237 | elsif ( $song[11] eq "2\n" ) {print "<td align='center'>Dual<br/>Channel</td></tr>"; } | |
238 | elsif ( $song[11] eq "3\n" ) {print "<td align='center'>Single<br/>Channel</td></tr>"; } | |
239 | else {print "<td align='center'></td></tr>"; } | |
240 | $lines++ | |
241 | } | |
242 | print "</table></form>"; | |
243 | &Header::closebox(); | |
244 | } | |
245 | ||
32ab16de CS |
246 | &Header::openbox('100%', 'center', $Lang::tr{'mpfire playlist'}); |
247 | ||
248 | ; | |
249 | ||
250 | open(DATEI, "<${General::swroot}/mpfire/playlist") || die "Could not open playlist"; | |
251 | my @playlist = <DATEI>; | |
252 | close(DATEI); | |
253 | ||
254 | print <<END | |
255 | <table width='95%' cellspacing='0'> | |
256 | <tr bgcolor='$color{'color20'}'><td colspan='9' align='left'><b>$Lang::tr{'current playlist'}</b></td></tr> | |
257 | <tr><td align='center'><textarea cols='120' rows='10' name='playlist' style='font-size:10px' readonly='readonly' >@playlist</textarea><br/> | |
258 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
259 | <input type='hidden' name='ACTION' value='playlist' /> | |
260 | <input type='image' alt='$Lang::tr{'play'}' title='$Lang::tr{'play'}' src='/images/media-playback-start.png' /> | |
261 | </form></td></tr> | |
262 | </table> | |
263 | END | |
264 | ; | |
265 | &Header::closebox(); | |
266 | ||
a28fdc01 CS |
267 | &Header::closebigbox(); |
268 | &Header::closepage(); |