home *** CD-ROM | disk | FTP | other *** search
/ Bila Vrana / BILA_VRANA.iso / 018A / NO2F16XL.ZIP / NO2F16XL.EXE / t2.z / resetBBS.cgi < prev    next >
Text File  |  1997-01-20  |  3KB  |  150 lines

  1.  
  2. print "Content-type: text/html\n\n";
  3. #
  4. # This reads in the information sent when the user pressed Submit
  5. #
  6. if ($ENV{'REQUEST_METHOD'} eq "GET") { $buffer = $ENV{'QUERY_STRING'}; }
  7. else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); }
  8.  
  9. #
  10. # Now, using a little loop, we'll split up the data into name/value
  11. # pairs, which makes them easier to work with. 
  12. #
  13. @pairs = split(/&/, $buffer);
  14. foreach $pair (@pairs)
  15. {
  16.     ($name, $value) = split(/=/, $pair);
  17.  
  18.     $value =~ tr/+/ /;
  19.     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  20.  
  21.     $FORM{$name} = $value;
  22. }
  23.  
  24.  
  25. &processFile;
  26. &success;
  27.  
  28. exit;
  29.  
  30.  
  31. #######################################################################
  32. ############################  Add to data file  #######################
  33. #######################################################################
  34.  
  35.  
  36. sub processFile {
  37.  
  38.     unlink <../message/*.html>;
  39.  
  40.     open(original,"../message/bbs-data.original") || die "can't open bbs-data.original\n";
  41.     open(ind,">> ../message/bbs-data.html") || die "can't open bbs-data.original\n";
  42.     &lock(ind);
  43.     select(ind);
  44.     while(<original>){
  45.     print;
  46.     }
  47.     &unlock(ind);
  48.     close(original);
  49.     close(ind);
  50.     chmod 0606, <../message/bbs-data.html>;
  51.  
  52.     open(original,"../message/zero.counter") || die "can't open zero.counter\n";
  53.     open(ind, "> ../message/thread_counter") || die "can't open thread_counter\n";
  54.     &lock(ind);
  55.     select(ind);
  56.     while(<original>){
  57.     print;
  58.     }
  59.     &unlock(ind);
  60.     close(original);
  61.     close(ind);
  62.  
  63.     open(original,"../message/zero.counter") || die "can't open zero.counter\n";
  64.     open(ind, "> ../message/counter") || die "can't open thread_counter\n";
  65.     &lock(ind);
  66.     select(ind);
  67.     while(<original>){
  68.     print;
  69.     }
  70.     &unlock(ind);
  71.     close(original);
  72.     close(ind);
  73.  
  74. }
  75.  
  76.  
  77.  
  78. sub lock{
  79. if ($flock_exists == 1){
  80.     local ($file_handle);
  81.     foreach $file_handle (@_){
  82.         flock($file_handle, 2);
  83.         }
  84.     }
  85. }
  86.  
  87.  
  88. sub unlock{
  89. if ($flock_exists == 1){
  90.     local ($file_handle);
  91.     foreach $file_handle (@_){
  92.         flock($file_handle, 8);
  93.         }
  94.     }
  95. }
  96.  
  97.  
  98.  
  99.  
  100.  
  101. ###############################################################################
  102. ############################  Complete/Success  ###############################
  103. ###############################################################################
  104. sub success{
  105.     select(STDOUT);
  106.     open(EP,"$SUCCESS");
  107.     print "<html><head>Web Forum have been reseted</head><h3>The message area of the Web Forum have been completely reseted.</h3>";
  108.  
  109.     close(EP);
  110.     exit;
  111.  
  112. ##### chmod 
  113.  
  114.  
  115.  
  116. }
  117.  
  118.  
  119. ###############################################################################
  120. ############################  Incomplete Error  ###############################
  121. ###############################################################################
  122. sub notcomplete {
  123.     select(STDOUT);
  124.     open(EP,"$ERROR");
  125.     while(<EP>){
  126.     print "$_";
  127.     }
  128.     close(EP);
  129.     exit;
  130.  
  131. ###############################################################################
  132. ############################  Invalid char  ###############################
  133. ###############################################################################
  134. sub invalidchar {
  135.     select(STDOUT);
  136.     open(EP,"$ERROR_CHAR");
  137.     while(<EP>){
  138.     print "$_";
  139.     }
  140.     close(EP);
  141.     exit;
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.