home *** CD-ROM | disk | FTP | other *** search
/ ftp.sunet.sepub/pictures / 2014.11.ftp.sunet.se-pictures.tar / ftp.sunet.se / pub / pictures / ACiD-artpacks / www / mirrors / acheron / cgi-bin / remove_Links.cgi < prev    next >
Text File  |  1999-02-08  |  3KB  |  105 lines

  1. #!/usr/bin/perl
  2.  
  3. require ("cgi-lib.pl") or die "Could not open or find cgi-lib.pl\n";
  4.  
  5. # declare variables
  6. $current_ip = "nothing";
  7.  
  8. $filename = "links.txt";
  9. $temp = "";
  10.  
  11. # call initial functions
  12. &Get_request_types;
  13. &Analyse_file;
  14.  
  15. #########################################################################
  16.  
  17. sub Get_request_types {
  18.         
  19. &ReadParse(*input);
  20. $name_in = ($input{'name'});
  21.  
  22. }
  23.  
  24. #########################################################################
  25.  
  26. sub Analyse_file {
  27.  
  28. print &Header;
  29. print &Top("test");
  30. $output = "STDOUT";
  31.  
  32.  
  33. ## wipe temp links file for new order of entries
  34. open (LNKFILE, ">links2.txt") || die "Could not open or find $filename\n";
  35. print LNKFILE "";
  36. close (LNKFILE);
  37.  
  38. ## open links file for reading and determine whether current entries match 
  39. ## the given one - if yes then it is not printed to the temp links file.
  40. open (LOGFILE, "<links.txt") || die "Could not open or find $filename\n";
  41. open (LNKFILE, ">>links2.txt") || die "Could not open or find $filename\n";
  42.  
  43.     foreach $line (<LOGFILE>) {
  44.     ($category, $name, $url, $desc) = split(' : ', $line);
  45.          if ($name_in ne $name) {print LNKFILE "$category : $name : $url : $desc";}
  46.  
  47.     }
  48. close (LNKFILE);
  49. close (LOGFILE);
  50.  
  51. ## write a blank char to the links file.
  52. open (LOGFILE, ">links.txt") || die "Could not open or find $filename\n";
  53. print LOGFILE "";
  54. close (LOGFILE);
  55.  
  56. ## open temp links file and transfer to the existing (blank) links file.
  57. open (LNKFILE, "<links2.txt") || die "Could not open or find $filename\n";
  58. open (LOGFILE, ">>links.txt") || die "Could not open or find $filename\n";
  59.  
  60.     foreach $line (<LNKFILE>) {
  61.     ($category, $name, $url, $desc) = split(' : ', $line);
  62.          print LOGFILE "$category : $name : $url : $desc";
  63.  
  64.     }
  65.  
  66. close(LOGFILE);
  67. close(LNKFILE);
  68. print $output "Link removed";
  69. print &Bottom;
  70.  
  71. }
  72.  
  73. #########################################################################
  74.  
  75. #_____Module Returns the Output Document Type______#
  76. sub Header
  77. {
  78.         return "Content-type: text/html\n\n";
  79. }   
  80.  
  81. #_____Module Returns the Output Document Head_______#
  82. sub Top
  83. {
  84.         my ($title) = @_;
  85.         return <<"ENDPRINT";
  86. <HTML>
  87. <HEAD>
  88. <TITLE>acheron.org // admin / banner statistics</TITLE>
  89. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  90. </HEAD>
  91.  
  92. <BODY link="#FFCC00" vlink="#FF9900" alink="#FFFFFF" text="#cccccc" BGCOLOR="#000000">
  93. <div align="center">
  94.               <table border="0" width="640" align="center" cellspacing="0" cellpadding="0">
  95.                 <tr> 
  96.                   <td width="640"> 
  97.                     <p><font size="2" face="Arial, Helvetica, sans-serif">
  98. ENDPRINT
  99. }
  100.  
  101. #_____Module Returns the Output Document Bottom______#
  102. sub Bottom
  103. {
  104.         return "</td></tr></table></div></BODY></HTML>\n";
  105. }