#! /usr/bin/perl # # attlist3.cgi # # 5.007 : 2/2/07 : 参加者ファイルを使わないように修正 # 5.006 : 1/24/07 : 名前欄の半角カンマのバグを修正 # 5.005 : 8/5/06 : パスワード無効モードを追加 # 5.004 : 4/23/06 : パスワードがマッチすると更新日を更新するように修正 # 5.003 : 4/16/06 : 変更なしでも更新者、更新日が更新されるのを修正 # 5.002 : 3/19/06 : 参加人数制限、更新締め切り機能を追加 # 5.001 : 3/6/06 : 追加時に更新情報が正しく表示されるように修正 # 5.0 : 3/5/06 : Upgread from attlist2.cgi # # http://www.hidekik.com/ # # $Id: attlist3.cgi,v 1.9 2007/02/02 02:07:49 Hideki Kanayama Exp $ # Copyright(c) 1997-2006, Hideki Kanayama, All rights reserved. use CGI qw(:cgi-lib); use strict; use CGI::Carp qw(fatalsToBrowser); use File::Basename; use Time::Local; my $version = "5.007"; my $lastupdatedyear = "2007"; my $admindat = "adminpwd.dat"; my $setupfile = "attlist3_setup.pl"; my $script = basename($0); my $lang = 0; my $charset = ("Shift_JIS","ISO-8859-1")[$lang]; ########## 環境設定 ここから ########################### our $datafile = "attend.dat"; # lockfile our $lockfile = "lockfile.dat"; # Title our $title = '出欠表 '; # Background our $bgimage_en = 0; our $bgimage_file = ''; our $bgcolor = "#ffffff"; # Back link our $backlink_en = 1; our $backlink = '..'; our $backlink_name = '戻る'; # Body width our $body_width = '100'; # option cell back ground color our $option_bg_color = "#ffcc33"; # option cell font color our $option_font_color = "black"; # item cell back ground color our $item_bg_color = "#66ff99"; # item cell font color our $item_font_color = "black"; #表示テーブルのカラム数 our $table_colms = 1; #参加者設定の初期登録可能人数 our $default_max = 15; #管理用リンク表示 1:有効 0:無効 our $setup_en = 1; #変更日表示 1:有効 0:無効 our $update_en = 1; #削除チェック 1:有効 0:無効 our $delcheck_en = 1; #定員設定 1:有効 0:無効 our $att_limit_en = 0; our $att_limit_num = 10; #締め切り 1:有効 0:無効 our $deadline_en = 0; our $deadline_year = 2006; our $deadline_month = 3; our $deadline_day = 25; our $deadline_hour = 0; our $deadline_min = 0; #パスワード保護 1:有効 0:無効 our $password_en = 1; #カウント 1:有効 0:無効 our $count_en = 0; #管理人オンリーモード 1:有効 0:無効 our $adminonly_en = 0; #オプション オプション名,背景色 our $options = '出席,red 欠席,blue 未定,green '; # body_head our $body_head = '
';
# body_tail
our $body_tail = '
';
# Style Sheet
our $style_sheet_en = 0;
our $style_sheet = '
';
# Head insert
our $head_insert_en = 0;
our $head_insert = '
';
#時間設定 1:localtime, 0:offset from GMT
our $localtime_en = 1;
our $offset_from_gmt = 9;
#予備のアップデートファイル
# 1: on, 0: off
our $update1_file_en = 0;
our $update2_file_en = 0;
our $update1_file = "update1.log";
our $update2_file = "update2.log";
########## 環境設定 ここまで ###########################
require "$setupfile" if (-e "$setupfile");
my $q = CGI->new;
my $cgierror = $q->cgi_error;
&error($cgierror) if ($cgierror);
my %in = &postprocess($q->Vars);
if (! -e "$admindat"){
if ($in{mode} ne 'wradminpwd'){
&setadminpwd;
} else {
&wradminpwd($in{pwd});
}
}
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=
$localtime_en ? localtime(time) : gmtime(time + 3600 * $offset_from_gmt);
my $update = sprintf("%s_%s_%s_%02s_%02s",$year+1900,$mon+1,$mday,$hour,$min);
my $deadline_time = timelocal(0,$deadline_min,$deadline_hour,$deadline_day,$deadline_month-1,$deadline_year);
my $now = timelocal(localtime);
my @items = &get_items;
my ($maxnum, $date, $lastname, $name, $status, $count, $eachpwd, $eachmod) = &get_data;
my (@name, @status, @count, @eachpwd, @eachmod);
@name = @{$name};
@status = @{$status};
@count = @{$count};
@eachpwd = @{$eachpwd};
@eachmod = @{$eachmod};
my @valid_list = grep /^0$/, @status;
my $attnum = $#valid_list + 1;
my $hit_limit = 0;
my $update_button = 1;
if ($in{mode} eq 'atwrite'){
&atwrite;
} elsif ($in{mode} eq 'setup'){
&setup;
} elsif ($in{mode} eq 'setup_update'){
&setup_update;
} else {
&display;
}
###################### 書き込み ############################
sub atwrite {
&error('管理用パスワードが違います。') if (!&checkadmin($in{pwd}) and $adminonly_en == 1);
if ($deadline_en and $now > $deadline_time){
&error('締め切り日時を過ぎているので追加、変更できません。');
}
if ($in{add} ne ''){
&newregister;
} else {
&update;
}
&extraupdate;
print "Location: $script\n\n";
}
sub newregister {
&error('名前は必ず入れてください')if ($in{newname} eq "");
&error('パスワードは必ず入れてください')if ($in{newpwd} eq "" and $password_en);
if ($att_limit_en and $attnum >= $att_limit_num){
&error('締め切り人数に達しているので追加できません。。');
}
&lockfile;
my ($maxnum, @dummy) = &get_data;
open (TMPFILE, "> tmp.$$") or &error("tempfileを作成できません。");
print TMPFILE "0,$in{newname},$update\n";
if (open(DAT,"< $datafile")) {
my $i = 0;
while (
CGIを置いてあるディレクトリが書き込み可能\か確認してください。');
foreach (keys(%in)){
$in{$_} =~ s/
/\n/g if (!/body_head/ and !/body_tail/);
$in{$_} =~ s/,/,/g;
$in{$_} =~ s/<//g;
$in{$_} =~ s/\s*$//;
}
print SETUP <
\n";
exit;
}
sub error {
my ($msg) = shift;
&unlockfile;
&htmlhead($msg);
print "\n";
}
sub copyright {
my $mysite = ('http://www.hidekik.com/','http://www.hidekik.com/en/')[$lang];
print "$script Ver. $version\n";
print "Copyright(C) 1997-$lastupdatedyear, hidekik.com\n";
}
sub htmltail {
print "