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