Annotation of mp3/bin/addmp3playlist.pl, Revision 1.2
1.1 andrew 1: #!/usr/bin/perl -w
1.2 ! andrew 2: # $RedRiver$
1.1 andrew 3: ########################################################################
4: # addmp3playlist.pl *** Adds MP3's to the playlist
5: #
6: # 04-13-00
7: # Written by andrew fresh <andrew@mad-techies.org>
8: ########################################################################
9: use strict;
10: use diagnostics;
11:
12:
13:
14: ########################################################################
15: # *** Variables ***
16: my $DestDir = '/home/mp3/Sorted';
17: my $filename = $ENV{'QUERY_STRING'};
18: my $playlist = '/var/www/mp3/playlist/playlist.lst';
19:
20:
21:
22: ########################################################################
23: # *** MAIN ***
24: ########################################################################
25: if (! -d $DestDir) { mkdir $DestDir, 0777 }
26:
27:
28:
29: print "Content-Type: text/html\n\n";
30:
31: $filename =~ s/%(..)/pack("c",hex($1))/ge;
32:
33: if ($filename) {
34: print "<html>\n<head>\n\t<meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>";
35:
36: if ($ENV{'QUERY_STRING'}) {
37: print "<meta HTTP-EQUIV=Refresh CONTENT=\"10; URL=/blank.htm\">";
38: }
39:
40: print "<title>Added $filename</title>\n<body>\n\n";
41:
42: print "<h3>Added $filename</h3>\n";
43: open PLAYLIST, ">>$playlist" or bail("unable to open PLAYLIST: $!");
44: print PLAYLIST "$filename\n";
45: close PLAYLIST or bail("unable to close PLAYLIST: $!");
46: } else {
47: print "<h1>You need to pass a song</h1>";
48: }
49:
50: print "</body>\n</head>\n</html>\n";
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61: ########################################################################
62: # *** SUBS ***
63: ########################################################################
64:
65:
66:
67:
68:
69:
70:
71:
72: ########################################################################
73: # Bail: this subrouting dies and displays the error to the browser.
74: # gotten from the example in the O'Reilly
75: # _Learning_Perl_on_Win32_Systems_
76: sub bail {
77: my $error = "@_";
78: print "Error! $error";
79: exit;
80: }
81: ########################################################################
82:
83:
84: sub Print_Nav
85: {
86: open FILE, 'nav.inc' or die "\n\ncouldn't open FILE nav.inc: $!";
87: while (<FILE>) {
88: print;
89: }
90: close FILE;
91: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>