home *** CD-ROM | disk | FTP | other *** search
/ Web Designer 98 (Professional) / WebDesigner 1.0.iso / tutorials / tutorial / free.txt < prev    next >
Encoding:
Text File  |  1997-06-15  |  3.2 KB  |  100 lines

  1. #!/usr/bin/perl
  2.  
  3. $freelocation = "http://cavalcade-whimsey.com/addlinks.html";
  4. $freepath = "/usr/home/shpank/public_html/addlinks.html";
  5. $cgilocation = "http://cavalcade-whimsey.com/shpank/free.pl";
  6.  
  7. # DO NOT EDIT BELOW THIS LINE!!!!
  8. #####################################################################
  9.  
  10. # Receive Info From Free Link
  11. read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  12.  
  13. # Process Info From Free Link
  14. @pairs = split(/&/, $buffer);
  15.    foreach $pair (@pairs) {
  16.    ($name, $value) = split(/=/, $pair);
  17.    $value =~ tr/+/ /;
  18.    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  19.    $value =~ s/<!--(.|\n)*-->//g;
  20.    $value =~ s/<([^>]|\n)*>//g;
  21.    $FORM{$name} = $value;}
  22.  
  23. # Give Error Messages
  24. &no_url unless $FORM{'url'};
  25. &no_title unless $FORM{'title'};
  26.  
  27. # Set Up Free Link Page
  28. open (FILE, "$freepath");
  29. @LINES=<FILE>;
  30. close(FILE);
  31. $SIZE=@LINES;
  32.  
  33. # Write To Free Link Page
  34. open (FREE,">$freepath");
  35.  
  36. for ($i=0;$i<=$SIZE;$i++) {
  37.    $_=$LINES[$i];
  38.    if (/<!--links-->/) { 
  39.  
  40. print FREE "<!--links-->\n";
  41. print FREE "<a href=\"$FORM{'url'}\">$FORM{'title'}</a> - 
  42. $FORM{'description'}<br>\n"; } else {
  43.         print FREE $_;
  44. }
  45. close (FREE);
  46.  
  47. &follow;
  48.  
  49. # Error Pages
  50.  
  51. sub no_url {
  52.    print "Content-type: text/html\n\n";
  53.    print "<html><head><title>No URL</title></head>\n";
  54.    print "<body><h1>URL appears to be blank</h1>\n";
  55.    print "You didn't add your URL so your entry to the Free Link Page was not added.\n";
  56.    print "Please add your url below.<br>\n";
  57.    print "<form method=POST action=\"$cgilocation\">\n";
  58.    print "Page URL: <INPUT TYPE=\"text\" NAME=\"url\" VALUE=\"http://\" SIZE=\"40\">\n";
  59.    print "<INPUT TYPE=\"hidden\" NAME=\"title\" VALUE=\"$FORM{'title'}\"><br><br>\n";
  60.    print "<INPUT TYPE=\"hidden\" NAME=\"category\"\n";
  61.    print "VALUE=\"$FORM{'category'}\"><br><br>\n";
  62.    print "<input type=submit VALUE=\"Submit Link\"><hr>\n";
  63.    print "</body></html>\n";
  64.  
  65.    exit;
  66. }
  67.  
  68. sub no_title {
  69.    print "Content-type: text/html\n\n";
  70.    print "<html><head><title>No Title</title></head>\n";
  71.    print "<body><h1>Title appears to be blank</h1>\n";
  72.    print "You didn't add your Title so your entry to the Free Link Page was not added.\n";
  73.    print "Please add your url below.<br>\n";
  74.    print "<form method=POST action=\"$cgilocation\">\n";
  75.    print "Page Title: <INPUT TYPE=\"text\" NAME=\"title\" SIZE=\"40\">\n";
  76.    print "<INPUT TYPE=\"hidden\" NAME=\"url\" VALUE=\"$FORM{'url'}\"><br><br>\n";
  77.    print "<INPUT TYPE=\"hidden\" NAME=\"category\"\n";
  78.    print "VALUE=\"$FORM{'category'}\"><br><br>\n";
  79.    print "<input type=submit VALUE=\"Submit Link\"><hr>\n";
  80.    print "</body></html>\n";
  81.  
  82.    exit;
  83. }
  84.  
  85. sub follow {
  86.    print "Content-type: text/html\n\n";
  87.    print "<html><head><title>Thank You</title></head>\n";
  88.    print "<body bgcolor=#000000 text=#ff8000 link=#ffffff vlink=#ffffff><h1>Thank You For Adding a 
  89. Link</h1>\n";
  90.    print "Here's what you added:<br><br>\n";
  91.    print "<b>Page URL:</b> $FORM{'url'}<br>\n";
  92.    print "<b>Page Title:</b> $FORM{'title'}<br>\n";
  93.    print "I really appreciate you adding your URL.<br>\n";
  94.    print "Click here to go back to <a href=\"$freelocation\">The Free Links Page</a>.<br>\n ";
  95.    print "If you do not see your entry, hit RELOAD<br>\n";
  96.    print "</body></html>\n";
  97. }
  98. exit;
  99.