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