#!/usr/mesh/bin/perl5
#
# うぇぶ会議室拡張機能
# 会議室の底上げを行う
#
# Ver.01.00 Mon 23th Mar. 1988
# first release
$common_path='/home3/t_shige/public_html';
$CGIPATH='.';
require ("$CGIPATH/forum.pl");
%http_args = &http'http_args;
$room = $http_args{'room'};
$passwd = $http_args{'passwd'};
$min = $http_args{'min'};
$title = &forum'get_title($room);
&WarningMsg('Bad Forum') if ($title eq '');
if ($http_args{'jackup'})
{
local(@buf)=();
local($tempfile) = 'jackup';
local($result);
&open_contents($passwd,$room,$min,*buf);
&UpdateCotents($tempfile,*buf);
}
else
{
&OutForm;
}
###########################################
# Out Form for minimum article no input
sub OutForm
{
print "Content-Type: text/html\n\n";
print <<__FORM__;
Jackup forum ($title)
$titleの底上げ
$help
__FORM__
}
###########################################
# Load current contents
sub open_contents
{
local($passwd,$room,$min,*buf) = @_;
local($mesno, $ref_mes);
local($linebuf);
open(CONTENTS, "+<$FORUMPATH/$room/contents") || &ErrorMsg('missing', "$room/contents");
&forum'filelock(CONTENTS, 1) || &ErrorMsg('lock', "$room/contents");
$_=;
chop;
($mesno, $ref_mes, $syspass) = /^(\d{5}) (\d{5}) (\S{3,})$/;
&ErrorMsg('','Bad Adminislator Code') unless (crypt($passwd, $syspass) eq $syspass);
&ErrorMsg('', "$room/contents") unless (($mesno) && ($min) && ($min <= $ref_mes));
push(@buf,sprintf("%05d %05d %s\n", $min, $ref_mes,$syspass));
while()
{
($mesno, $ref_mes,$record) = /^(\d{5}) (\d{5}) (.*)/;
if( $mesno >= $min )
{
push(@buf,"$mesno $ref_mes $record\n");
last;
}
elsif( $http_args{'delete'} eq 'on' )
{
unlink("$FORUMPATH/$room/$mesno.html");
}
}
while()
{
push(@buf,$_);
}
}
###########################################
# Update contents
sub UpdateCotents
{
local($temp,*buf)=@_;
open(TEMP, ">$FORUMPATH/$room/$temp") || &ErrorMsg('write', "$room/$temp");
foreach(@buf)
{
print TEMP $_;
}
close(TEMP);
&forum'filelock(CONTENTS, 0);
close(CONTENTS);
if(rename("$FORUMPATH/$room/$temp","$FORUMPATH/$room/contents"))
{
&CompleetMSG;
}
else
{
&ErrorMsg('rename', "$!");
}
}
sub CompleetMSG
{
print "Content-Type: text/html\n\n";
print <<_COMPLEET_;
Jack up forum article
Jack up compleet !
_COMPLEET_
}