Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: create .ram file on the web server using asp


Message #1 by "Ram Sharan Khakurel" <rkhakurel@h...> on Mon, 24 Jun 2002 15:40:43
hi i would like to know if we could create .ram file on the web server 
ushing asp.
i got the same code in perl,but i just want to translate into asp.below is 
the code in perl;

jukebox.cgi#!/usr/bin/perl

##########################################################


print "Content-type:text/html\n\n";


$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/fruit.rm";
$Songs{'e5'} = "http://members.xoom.com/lewisl818/get_it_tonight.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 

   $FORM{$name} = $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(/,/, $FORM{'text1'});


$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);



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;
}



this code will create a .ram file on the web server which contains the 
following links to real media files as given in the code.

http://members.xoom.com/lewisl818/adam05.rm
http://members.xoom.com/lewisl818/adam09.rm
http://members.xoom.com/lewisl818/adam13.rm
http://members.xoom.com/lewisl818/fruit.rm
http://members.xoom.com/lewisl818/get_it_tonight.rm

i would appreciate if anyone could help me.
thanks

ram



  Return to Index