vin16
December 5th, 2001, 19:52
Hi Guys,
Help me out.......
This is a jukebox script that I downloaded from a perl archive, the only problem is that the songs selected is sent to the cgi script through a textbox and I want it to be sent via variables instead.
Am attaching the cgi script, hoping for a solution. Please help me out, I tired almost everything with little perl knowledge and so far haven't gotten anyway as mentioned your my last hope.
1.Here's the html file
<html>
<head>
<title>Demo page</title>
</head>
<SCRIPT language=JavaScript>
function LOADJUKEBOX() {
songid = new Array;
count = 0;
for (var i=0;i<document.jukebox.elements.length;i++) {
if (document.jukebox.elements[i].name == 'ID') {
if (document.jukebox.elements[i].checked) {
songid[count] =document.jukebox.elements[i].value;
count ++;
}
}
}
parameters = songid[0];
for (var j=1;j<count;j++) {
parameters += "," +songid[j];
}
url="mytry.cgi?parameter="+parameters;
window.open(url,'PLAYER','toolbar=no,location=no,directories =no,status=yes,menubar=no,resizable=yes,copyhistory=no,scrol lbars=no,width=540,height=230');
}
</SCRIPT>
<SCRIPT language=JavaScript>
function CheckAll()
{
for (var i=0;i<document.jukebox.elements.length;i++)
{
var box = document.jukebox.elements[i];
if (box.name != 'all')
box.checked = 1;
}
javascript:LOADJUKEBOX(this)
}
</SCRIPT>
<SCRIPT language=JavaScript>
function ClearAll()
{
for (var i=0;i<document.jukebox.elements.length;i++)
{
var box = document.jukebox.elements[i];
box.checked = 0;
}
document.jukebox.text1.value = ""
}
</SCRIPT>
<body>
<form action="mytry.cgi" method="POST" name="jukebox">
<table border="0" width="90%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" bgcolor="#0080FF"><font size="2"><input type="checkbox" name=ID
onclick=javascript:LOADJUKEBOX(this) value="e1">e1 - Star -- Bryan Adams</font></td>
</tr>
<tr>
<td width="100%" bgcolor="#85C47B"><font size="2"><input type="checkbox" name=ID
onclick=javascript:LOADJUKEBOX(this) value="e2">e2 - I will always be right there -- Bryan Adams
</font></td>
</tr>
<tr>
<td width="100%" bgcolor="#0080FF"><font size="2"><input type="checkbox" name=ID
onclick=javascript:LOADJUKEBOX(this) value="e3">e3 - Have you ever loved a woman -- Bryan Adams</font></td>
</tr>
<tr>
<td width="100%" bgcolor="#85C47B"><font size="2"><input type="checkbox" name=ID
onclick=javascript:LOADJUKEBOX(this) value="e4">e4 - Da di da -- Fruit</font></td>
</tr>
<tr>
<td width="100%" bgcolor="#0080FF"><font size="2"><input type="checkbox" name=ID
onclick=javascript:LOADJUKEBOX(this) value="e5">e5 - Get it tonight -- Montell Jordon</font></td>
</tr>
</table>
<p><input type="submit" value="Play your customised list"></p>
<p><input onclick=javascript:ClearAll(this) type="button" value="Clear"></p>
<p><input onclick=javascript:CheckAll(this) type="button" value="Check"></p>
<p><input type="textbox" name="text1" size="-1"></p>
</form>
</body>
</html>
2.Here's the cgi script
#!/usr/bin/perl
print "Content-type:text/html\n\n";
$Parameter = $in{'Parameter'};
$Songs{'e1'}= "http://members.xoom.com/lewisl818/adam05.rm";
$Songs{'e2'} = "http://members.xoom.com/lewisl818/adam09.rm";
$Songs{'e3'} = "http://members.xoom.com/lewisl818/adam13.rm";
$Songs{'e4'} = "http://members.xoom.com/lewisl818/adam13.rm";
$Songs{'e5'} = "http://members.xoom.com/lewisl818/adam13.rm";
use Time::localtime;
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/\n/ /g;# added to strip line breaks
$Parameter = $value;
}
$EXT = ".ram";
$tm = localtime;
($DAY, $MONTH, $YEAR, $HR, $MIN, $SEC) = ($tm->mday, $tm->mon, $tm->year, $tm->hour, $tm->min, $tm->sec);
if($YEAR < 100)
{ $YEAR = $YEAR + 100;
}
# This remove the old .ram files on server
sub song_expire
{
local(@items, $item);
opendir(RAMHANDLE, "./");
@items = grep(/[0-9]$EXT/,readdir(RAMHANDLE));
closedir(RAMHANDLE);
foreach $item (@items)
{
($YMD, $HMS) = split(/_/, $item);
if($YMD != $YEAR.$MONTH.$DAY)
{
unlink("./$item");
}
}
}
&song_expire;
print <<EndHTML1;
<html><head><title>Here comes~</title></head>
<body><center>
EndHTML1
@Lists = split(/,/, $Parameter = $in{'Parameter'})
$FILE_NAME = $YEAR.$MONTH.$DAY. "_" .$HR.$MIN.$SEC.".ram";
$FILE_NAME2 = ">".$FILE_NAME;
open(OUTF,$FILE_NAME2) or &dienice("Couldn't open survey.out for
writing. Please notify webmaster.");
foreach $list (@Lists) {
print OUTF "$Songs{$list}\n";
}
close(OUTF);
# Modify this yourself if you want a different look.. or add a pop up
# windows for the .ram file. If you don't know how to do it. I suggest
# you leave it as it is. =)
print <<EndHTML;
Here is your list<p>
<img src="http://images.real.com/pics/general/freeplayer_g2.gif"><p>
<a href="$FILE_NAME">Click Here to listen!</a><p>
Thanks for visiting my site. =)
<p>
<br>
EndHTML
print "</body></html>";
sub dienice {
($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}
Help me out.......
This is a jukebox script that I downloaded from a perl archive, the only problem is that the songs selected is sent to the cgi script through a textbox and I want it to be sent via variables instead.
Am attaching the cgi script, hoping for a solution. Please help me out, I tired almost everything with little perl knowledge and so far haven't gotten anyway as mentioned your my last hope.
1.Here's the html file
<html>
<head>
<title>Demo page</title>
</head>
<SCRIPT language=JavaScript>
function LOADJUKEBOX() {
songid = new Array;
count = 0;
for (var i=0;i<document.jukebox.elements.length;i++) {
if (document.jukebox.elements[i].name == 'ID') {
if (document.jukebox.elements[i].checked) {
songid[count] =document.jukebox.elements[i].value;
count ++;
}
}
}
parameters = songid[0];
for (var j=1;j<count;j++) {
parameters += "," +songid[j];
}
url="mytry.cgi?parameter="+parameters;
window.open(url,'PLAYER','toolbar=no,location=no,directories =no,status=yes,menubar=no,resizable=yes,copyhistory=no,scrol lbars=no,width=540,height=230');
}
</SCRIPT>
<SCRIPT language=JavaScript>
function CheckAll()
{
for (var i=0;i<document.jukebox.elements.length;i++)
{
var box = document.jukebox.elements[i];
if (box.name != 'all')
box.checked = 1;
}
javascript:LOADJUKEBOX(this)
}
</SCRIPT>
<SCRIPT language=JavaScript>
function ClearAll()
{
for (var i=0;i<document.jukebox.elements.length;i++)
{
var box = document.jukebox.elements[i];
box.checked = 0;
}
document.jukebox.text1.value = ""
}
</SCRIPT>
<body>
<form action="mytry.cgi" method="POST" name="jukebox">
<table border="0" width="90%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" bgcolor="#0080FF"><font size="2"><input type="checkbox" name=ID
onclick=javascript:LOADJUKEBOX(this) value="e1">e1 - Star -- Bryan Adams</font></td>
</tr>
<tr>
<td width="100%" bgcolor="#85C47B"><font size="2"><input type="checkbox" name=ID
onclick=javascript:LOADJUKEBOX(this) value="e2">e2 - I will always be right there -- Bryan Adams
</font></td>
</tr>
<tr>
<td width="100%" bgcolor="#0080FF"><font size="2"><input type="checkbox" name=ID
onclick=javascript:LOADJUKEBOX(this) value="e3">e3 - Have you ever loved a woman -- Bryan Adams</font></td>
</tr>
<tr>
<td width="100%" bgcolor="#85C47B"><font size="2"><input type="checkbox" name=ID
onclick=javascript:LOADJUKEBOX(this) value="e4">e4 - Da di da -- Fruit</font></td>
</tr>
<tr>
<td width="100%" bgcolor="#0080FF"><font size="2"><input type="checkbox" name=ID
onclick=javascript:LOADJUKEBOX(this) value="e5">e5 - Get it tonight -- Montell Jordon</font></td>
</tr>
</table>
<p><input type="submit" value="Play your customised list"></p>
<p><input onclick=javascript:ClearAll(this) type="button" value="Clear"></p>
<p><input onclick=javascript:CheckAll(this) type="button" value="Check"></p>
<p><input type="textbox" name="text1" size="-1"></p>
</form>
</body>
</html>
2.Here's the cgi script
#!/usr/bin/perl
print "Content-type:text/html\n\n";
$Parameter = $in{'Parameter'};
$Songs{'e1'}= "http://members.xoom.com/lewisl818/adam05.rm";
$Songs{'e2'} = "http://members.xoom.com/lewisl818/adam09.rm";
$Songs{'e3'} = "http://members.xoom.com/lewisl818/adam13.rm";
$Songs{'e4'} = "http://members.xoom.com/lewisl818/adam13.rm";
$Songs{'e5'} = "http://members.xoom.com/lewisl818/adam13.rm";
use Time::localtime;
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/\n/ /g;# added to strip line breaks
$Parameter = $value;
}
$EXT = ".ram";
$tm = localtime;
($DAY, $MONTH, $YEAR, $HR, $MIN, $SEC) = ($tm->mday, $tm->mon, $tm->year, $tm->hour, $tm->min, $tm->sec);
if($YEAR < 100)
{ $YEAR = $YEAR + 100;
}
# This remove the old .ram files on server
sub song_expire
{
local(@items, $item);
opendir(RAMHANDLE, "./");
@items = grep(/[0-9]$EXT/,readdir(RAMHANDLE));
closedir(RAMHANDLE);
foreach $item (@items)
{
($YMD, $HMS) = split(/_/, $item);
if($YMD != $YEAR.$MONTH.$DAY)
{
unlink("./$item");
}
}
}
&song_expire;
print <<EndHTML1;
<html><head><title>Here comes~</title></head>
<body><center>
EndHTML1
@Lists = split(/,/, $Parameter = $in{'Parameter'})
$FILE_NAME = $YEAR.$MONTH.$DAY. "_" .$HR.$MIN.$SEC.".ram";
$FILE_NAME2 = ">".$FILE_NAME;
open(OUTF,$FILE_NAME2) or &dienice("Couldn't open survey.out for
writing. Please notify webmaster.");
foreach $list (@Lists) {
print OUTF "$Songs{$list}\n";
}
close(OUTF);
# Modify this yourself if you want a different look.. or add a pop up
# windows for the .ram file. If you don't know how to do it. I suggest
# you leave it as it is. =)
print <<EndHTML;
Here is your list<p>
<img src="http://images.real.com/pics/general/freeplayer_g2.gif"><p>
<a href="$FILE_NAME">Click Here to listen!</a><p>
Thanks for visiting my site. =)
<p>
<br>
EndHTML
print "</body></html>";
sub dienice {
($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
}