#!/usr/bin/perl # # IPFire CGIs # # This code is distributed under the terms of the GPL # # (c) The IPFire Team use strict; # enable only the following on debugging purpose use warnings; use CGI::Carp 'fatalsToBrowser'; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; my %color = (); my %mainsettings = (); my %mpfiresettings = (); my %checked = (); my $message = ""; my $errormessage = ""; open(DATEI, "<${General::swroot}/mpfire/db/songs.db") || die "No Database found"; my @songdb = ; close(DATEI); @songdb = sort(@songdb); &General::readhash("${General::swroot}/main/settings", \%mainsettings); &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); &Header::showhttpheaders(); &Header::getcgihash(\%mpfiresettings); &Header::openpage($Lang::tr{'mpfire'}, 1, ""); &Header::openbigbox('100%', 'left', '', $errormessage); ############################################################################################################################ ######################################## Scanne Verzeichnisse nach Mp3 Dateien ############################################# if ( $mpfiresettings{'ACTION'} eq "scan" ) { delete $mpfiresettings{'__CGI__'};delete $mpfiresettings{'x'};delete $mpfiresettings{'y'}; &General::writehash("${General::swroot}/mpfire/settings", \%mpfiresettings); system("/usr/local/bin/mpfirectrl scan $mpfiresettings{'SCANDIR'} $mpfiresettings{'SCANDIRDEPS'}"); } if ( $mpfiresettings{'ACTION'} eq ">" ){system("/usr/local/bin/mpfirectrl","play","\"$mpfiresettings{'FILE'}\"");} if ( $mpfiresettings{'ACTION'} eq "x" ){system("/usr/local/bin/mpfirectrl stop");} if ( $mpfiresettings{'ACTION'} eq "||" ){system("/usr/local/bin/mpfirectrl pause");} if ( $mpfiresettings{'ACTION'} eq "|>" ){system("/usr/local/bin/mpfirectrl resume");} if ( $mpfiresettings{'ACTION'} eq ">>" ){system("/usr/local/bin/mpfirectrl next");} if ( $mpfiresettings{'ACTION'} eq "stopweb" ){system("/usr/local/bin/mpfirectrl stopweb");} if ( $mpfiresettings{'ACTION'} eq "playweb" ){system("/usr/local/bin/mpfirectrl","playweb","\"$mpfiresettings{'FILE'}\"");} if ( $mpfiresettings{'ACTION'} eq "+" ){system("/usr/local/bin/mpfirectrl volup 5");} if ( $mpfiresettings{'ACTION'} eq "-" ){system("/usr/local/bin/mpfirectrl voldown 5");} if ( $mpfiresettings{'ACTION'} eq "++" ){system("/usr/local/bin/mpfirectrl volup 10");} if ( $mpfiresettings{'ACTION'} eq "--" ){system("/usr/local/bin/mpfirectrl voldown 10");} if ( $mpfiresettings{'ACTION'} eq "playlist" ){system("/usr/local/bin/mpfirectrl playall");} if ( $mpfiresettings{'ACTION'} eq "playalbum" ) { my @temp = ""; my @album = split(/\|/,$mpfiresettings{'album'}); my %hash = map{ $_, 1 }@album; foreach (@songdb){ my @song = split(/\|/,$_); chomp($song[0]); push(@temp,$song[0]."\n") if exists $hash{$song[4]}; } open(DATEI, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist"; print DATEI @temp; close(DATEI); system("/usr/local/bin/mpfirectrl playall"); } if ( $mpfiresettings{'ACTION'} eq "playartist" ) { my @temp = ""; my @artist = split(/\|/,$mpfiresettings{'artist'}); my %hash = map{ $_, 1 }@artist; foreach (@songdb){ my @song = split(/\|/,$_); chomp($song[0]); push(@temp,$song[0]."\n") if exists $hash{$song[1]}; } open(DATEI, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist"; print DATEI @temp; close(DATEI); system("/usr/local/bin/mpfirectrl playall"); } if ( $mpfiresettings{'ACTION'} eq "playall" ) { my @temp = ""; foreach (@songdb){ my @song = split(/\|/,$_); chomp($song[0]); push(@temp,$song[0]."\n"); } open(DATEI, ">${General::swroot}/mpfire/playlist") || die "Could not add playlist"; print DATEI @temp; close(DATEI); system("/usr/local/bin/mpfirectrl playall"); } if ( $mpfiresettings{'SHOWLIST'} ){delete $mpfiresettings{'__CGI__'};delete $mpfiresettings{'x'};delete $mpfiresettings{'y'};&General::writehash("${General::swroot}/mpfire/settings", \%mpfiresettings);} ############################################################################################################################ ################################### Aufbau der HTML Seite fr globale Sambaeinstellungen #################################### $mpfiresettings{'SCANDIR'} = "/"; $mpfiresettings{'SHOWLIST'} = "off"; &General::readhash("${General::swroot}/mpfire/settings", \%mpfiresettings); ############################################################################################################################ ########################################### rekursiv nach neuen Mp3s Scannen ##############################################รค if ( $message ne "" ) { print "$message"; } &Header::openbox('100%', 'center', $Lang::tr{'mpfire scanning'}); print <
$Lang::tr{'Scan for Files'}
$Lang::tr{'Scan from Directory'}
$Lang::tr{'deep scan directories'}on / off
END ; &Header::closebox(); my $song = qx(/usr/local/bin/mpfirectrl song); if ( $song eq "" ){$song = "None";} &Header::openbox('100%', 'center', $Lang::tr{'mpfire controls'}); print ""; print <
END ; if ( $mpfiresettings{'SHOWLIST'} eq "on" ){print"";} else { print"";} print <
-= $song =-

END ; &Header::closebox(); &Header::openbox('100%', 'center', $Lang::tr{'quick playlist'}); my @artist; my @album; foreach (@songdb){ my @song = split(/\|/,$_); push(@artist,$song[1]);push(@album,$song[4]);} my %hash = map{ $_, 1 }@artist; @artist = sort keys %hash; my %hash = map{ $_, 1 }@album; @album = sort keys %hash; print <
END ; &Header::closebox(); if ( $mpfiresettings{'SHOWLIST'} eq "on" ){ &Header::openbox('100%', 'center', $Lang::tr{'mpfire songs'}); print < $Lang::tr{'Existing Files'} $Lang::tr{'artist'}
$Lang::tr{'title'}
$Lang::tr{'number'} $Lang::tr{'album'} $Lang::tr{'year'} $Lang::tr{'genre'} $Lang::tr{'length'}
$Lang::tr{'bitrate'} - $Lang::tr{'frequency'}
$Lang::tr{'mode'} END ; my $lines = 0; foreach (@songdb){ my @song = split(/\|/,$_); if ($lines % 2) {print "";} else {print "";} $song[0]=~s/\/\//\//g; print <
$song[1]
$song[2] $song[3] $song[4] $song[5] $song[6] $song[7]:$song[8]
$song[9] - $song[10] END ; if ( $song[11] eq "0\n" ) {print "Stereo"; } elsif ( $song[11] eq "1\n" ) {print "Joint
Stereo"; } elsif ( $song[11] eq "2\n" ) {print "Dual
Channel"; } elsif ( $song[11] eq "3\n" ) {print "Single
Channel"; } else {print ""; } $lines++ } print ""; &Header::closebox(); } &Header::openbox('100%', 'center', $Lang::tr{'mpfire playlist'}); open(DATEI, "<${General::swroot}/mpfire/playlist") || die "Could not open playlist"; my @playlist = ; close(DATEI); print < $Lang::tr{'current playlist'}
END ; &Header::closebox(); &Header::openbox('100%', 'center', $Lang::tr{'mpfire webradio'}); open(DATEI, "<${General::swroot}/mpfire/webradio") || die "Could not open playlist"; my @webradio = ; close(DATEI); print < $Lang::tr{'webradio playlist'} Stream END ; foreach (@webradio){ my @stream = split(/\|/,$_); print <$stream[1]
END ; } print ""; &Header::closebox(); &Header::closebigbox(); &Header::closepage();