#! c:/perl/bin/perl # # attlist.cgi # # 4.001 : 3/6/06 : 参加者ファイル作成のバグを修正 # 4.0 : 10/12/05 : Created as a Non-SSI versoin # # $Id: attlist2.cgi,v 1.9 2006/03/05 08:29:49 Hideki Kanayama Exp $ use CGI qw(:cgi-lib); use strict; use CGI::Carp qw(fatalsToBrowser); use File::Basename; my $version = "4.001"; my $lastupdatedyear = "2006"; my $admindat = "adminpwd.dat"; my $setupfile = "attend_setup.pl"; my $script = basename($0); my $charset = "Shift_JIS"; my $lang = 0; ########## 環境設定 ここから ########################### our $datafile = "attend.dat"; our $attendees = "attendees.lst"; # 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'; #表示テーブルのカラム数 our $table_colms = 2; #参加者設定の初期登録可能人数 our $default_max = 30; #管理用リンク表示 1:有効 0:無効 our $setup_en = 1; #変更日表示 1:有効 0:無効 our $update_en = 0; #パスワード保護 1:有効 0:無効 our $password_en = 0; #参加人数 1:有効 0:無効 our $family_en = 0; #初期状態 1:あり 0:なし our $init_state_en = 0; # 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 = ' '; #時間設定 our $offset = 9; #トップからのSSI表示による更新時間のための予備のアップデートファイル # 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 = $q->Vars; &postprocess; if (! -e "$admindat"){ if ($in{mode} ne 'wradminpwd'){ &setadminpwd; } else { &wradminpwd($in{pwd}); } } 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 ($in{name} eq ""); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=gmtime(time + 3600 * $offset); my $update = sprintf("%s_%s_%s_%02s_%02s",$year+1900,$mon+1,$mday,$hour,$min); my @attendees = &get_attendees; my ($date, $lastname, $name, $status, $family, $eachpwd, $eachmod) = &get_data; my (@name, @status, @family, @eachpwd, @eachmod); @name = @{$name}; @status = @{$status}; @family = @{$family}; @eachpwd = @{$eachpwd}; @eachmod = @{$eachmod}; &lockfile; my $tmpfile = "tmp.$$"; open(WRDAT,">$tmpfile"); print WRDAT "0,$in{name},$update,\n"; my $endatt = $#attendees + 1; my $i; for ($i=1;$i<=$endatt;$i=$i+1){ my $pwdi = "pwd_$i"; chomp($attendees[$i-1]); if ($in{$i} ne $status[$i]) { $eachmod[$i] = "$update"; if ($password_en == 1 && "$eachpwd[$i]" ne '' && !&checkcrypt("$in{$pwdi}","$eachpwd[$i]")) { close(WRDAT); unlink("$tmpfile"); &error("$name[$i]のパスワードが違います。"); } } if ($password_en == 1 && ("$in{$pwdi}" ne '' && "$eachpwd[$i]" eq '')){ $eachpwd[$i] = &makecrypt("$in{$pwdi}"); } print WRDAT "$i,$attendees[$i-1],$in{$i},$in{\"family_$i\"},$eachmod[$i],$eachpwd[$i]\n"; } close(WRDAT); rename("$tmpfile","$datafile"); chmod(0666,"$datafile"); &unlockfile; &extraupdate; print "Location: $script\n\n"; } ###################### 表示 ############################ sub display { &htmlhead($title); my ($date, $lastname, $name, $status, $family, $eachpwd, $eachmod) = &get_data; my (@name, @status, @family, @eachpwd, @eachmod); @name = @{$name}; @status = @{$status}; @family = @{$family}; @eachpwd = @{$eachpwd}; @eachmod = @{$eachmod}; my @attendees_list = &get_attendees; print "$body_head"; print "
"; print "$body_tail"; &htmltail; } ###################### セットアップ ############################ sub setup { &setadminpwd if ($in{pwd} eq ''); &error('管理用パスワードが違います。') unless &checkadmin($in{pwd}); &htmlhead('管理用セットアップ'); print "\n"; 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 " |