#! /usr/bin/perl # # attlist4.cgi # # 6.017 : 8/1/08 : ID機能により複数設置可に変更 # 6.016 : 4/24/08 : IEで全角スペースのみのコメントリンクが表示されないのを修正 # 6.015 : 4/23/08 : コメントの半角スペースの処理を修正 # 6.014 : 10/14/07 : 管理人オンリーモードを追加 # 6.013 : 10/10/07 : ヘッダを繰り返し表示するオプションを追加 # 6.012 : 9/28/07 : 更新時刻表示に曜日表示のオプションを追加 # 6.011 : 8/2/07 : 携帯用の「ページ上部、下部」を追加 # 6.010 : 5/5/07 : 管理人一括更新での日付の更新を修正 # 6.009 : 4/23/07 : 管理人一括更新機能を追加。スパム投稿防止機能を追加。 # 6.008 : 2/3/07 : テーブル表示幅とコメント欄表示幅オプションを追加 # 6.007 : 1/30/07 : 参加者ファイルを使用しないように修正。 # 6.006 : 1/24/07 : コメントの半角カンマのバグを修正 # 6.005 : 1/12/07 : ファイルロックを修正 # 6.004 : 11/5/06 : 携帯モードからのコメント修正のバグを修正 # 6.003 : 10/28/06 : 定員達成時に出席以外は変更できるように修正 # 6.002 : 10/26/06 : 定員達成時に出席以外の参加人数受付オプションを追加 # 6.001 : 10/22/06 : 携帯モードを追加 # 6.0 : 10/21/06 : attlist3にコメント機能を追加 # # http://www.hidekik.com # # $Id: attlist4.cgi,v 1.22 2008/08/01 03:54:25 Hideki Kanayama Exp $ # Copyright(c) 1997-2008, 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 = "6.017"; my $lastupdatedyear = "2008"; my $admindat = "adminpwd.dat"; my $setupfile = "attlist4_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_width = 50; #表示テーブルのカラム数 our $table_colms = 1; #参加者設定の初期登録可能人数 our $default_max = 15; #管理用リンク表示 1:有効 0:無効 our $setup_en = 1; #変更日表示 1:有効 0:無効 our $update_en = 1; our $update_type = 0; our $weekday_en = ''; #コメント機能 1:有効 0:無効 our $comment_en = 1; our $comment_box = 20; our $comment_width = 30; #削除チェック 1:有効 0:無効 our $delcheck_en = 1; #携帯モード編集 1:有効 0:無効 our $medit_en = 1; #定員設定 1:有効 0:無効 our $att_limit_en = 0; our $att_limit_num = 10; #定員に達した後出席以外の登録を有効にする 1:有効 0:無効 our $allow_absent_beyond_limit = 0; #締め切り 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 $adminonly_en = 0; our $newreg_adminpwd = 0; #カウント 1:有効 0:無効 our $count_en = 0; our $count_name = '参加人数'; #管理人一括更新ボタン 1:有効 0:無効 our $adminbutton_en = 0; #オプション オプション名,背景色 our $options = '出席,red 欠席,blue 未定,green '; #ヘッダ表示 our $header_repeat = 20; # NG word our $ngword = 'http url'; # body_head our $body_head = '

出欠表

'; # body_tail our $body_tail = ' '; # body_head for cell phone our $body_head_for_cell = ' 出欠表

'; # body_tail for cell phone our $body_tail_for_cell = ' '; # 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 ($script eq 'atmobile.cgi'){ $script = 'attlist4.cgi'; $in{mode} = 'mobile'; } if ($in{id} ne ''){ $datafile = "$in{id}-$datafile"; } 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, $comment) = &get_data; my (@name, @status, @count, @eachpwd, @eachmod, @comment); @name = @{$name}; @status = @{$status}; @count = @{$count}; @eachpwd = @{$eachpwd}; @eachmod = @{$eachmod}; @comment = @{$comment}; my @valid_list = grep /^0$/, @status; my $attnum = $#valid_list + 1; my $hit_limit = 0; my $update_button = 1; my @option_list = grep !/^\s*$/, split /[\r\n]/, $options; my @newoption_list; foreach (@option_list){ chomp; my ($a,$b) = split /,/; push(@newoption_list,$a); } my @ngword = split /\s/, $ngword; if ($in{mode} eq 'atwrite'){ &atwrite; } elsif ($in{mode} eq 'setup'){ &setup; } elsif ($in{mode} eq 'setup_update'){ &setup_update; } elsif ($in{mode} eq 'mobile'){ &mobile; } elsif ($in{mode} eq 'medit'){ &medit; } else { &display; } ###################### 書き込み ############################ sub atwrite { if ($adminonly_en and $in{add} ne '' and !&checkadmin($in{newpwd})){ &error('管理人オンリーモードなので管理人のみ追加できます。'); } unless (&check_adminbutton or $in{adminbutton} eq ''){ &error('管理用パスワードが違います。'); } if ($deadline_en and $now > $deadline_time){ &error('締め切り日時を過ぎているので追加、変更できません。'); } if ($in{add} ne ''){ &newregister; } else { &update; } &extraupdate; print "Location: $script"; print "?id=$in{id}" if ($in{id} ne ''); if ($in{'next'} eq 'mobile') { print $in{id} ? '&' : '?'; print "mode=mobile"; } print "\n\n"; } sub newregister { &error('名前は必ず入れてください')if ($in{newname} =~ /^\s*$/); &error('パスワードは必ず入れてください')if ($in{newpwd} eq "" and $password_en); my $invalid = 0; foreach (@ngword){ foreach my $in ($in{newname},$in{newcomment}){ $invalid = 1 if ($in =~ /$_/i); } } if ($invalid) { &error('不適当な言葉が含まれています。'); } if (($att_limit_en and $attnum >= $att_limit_num and !($allow_absent_beyond_limit and $in{newoption} != 0))){ &error('締め切り人数に達しているので追加できません。。'); } &lockfile; my ($maxnum, @dummy) = &get_data; open (TMPFILE, "> tmp.$$") or &error("tempfileを作成できません。"); print TMPFILE "0,$in{newname},$update\n"; if (open(DAT,"< $datafile")) { flock DAT, 1; my $i = 0; while (){ print TMPFILE "$_" if ($i != 0); $i++; } close(DAT); } $maxnum++; $in{newoption} = 0 if ($in{newoption} eq ''); my $encpwd = ($password_en and ($adminonly_en == 0 or ($adminonly_en and $newreg_adminpwd))) ? &makecrypt($in{newpwd}) : ''; print TMPFILE "$maxnum,$in{newname},$in{newoption},$in{newcount},$update,$encpwd,$in{newcomment}\n"; close(TMPFILE); rename "tmp.$$", $datafile; &unlockfile; } sub update { &lockfile; my $tmpfile = "tmp.$$"; open(WRDAT,">$tmpfile") or &error("$tmpfileが開けません。"); my $endatt = $#items + 1; my $i; for ($i=1;$i<=$endatt;$i=$i+1){ my $btni = "btn_$i"; if ($in{$btni} ne ''){ $lastname = $name[$i]; last; } } if ($in{adminbutton} ne ''){ $lastname = '管理人'; } print WRDAT "0,$lastname,$update,\n"; my $newstatus; my $newcount; my $newcomment; my $modified = 0; for ($i=1;$i<=$endatt;$i=$i+1){ my $pwdi = "pwd_$i"; my $btni = "btn_$i"; $newstatus = $status[$i]; $newcount = $count[$i]; $newcomment = $comment[$i]; chomp($items[$i-1]); if (($in{$btni} ne '' and ($password_en == 1 && &checkcrypt("$in{$pwdi}","$eachpwd[$i]"))) or (&check_adminbutton and $in{adminbutton} ne '')) { $modified = 1; } if ((($in{$i} ne $status[$i] or ($in{"count_$i"} != $count[$i] and $count_en) or ($in{"comment_$i"} ne $comment[$i] and $comment_en)) and $in{$btni} ne '') or ((&check_adminbutton and $in{adminbutton} ne '') and ($in{$i} ne $status[$i] or $in{delallcom} eq 'on')) ) { $eachmod[$i] = "$update"; $modified = 1; if (($password_en == 1 && "$eachpwd[$i]" ne '' && !&checkcrypt("$in{$pwdi}","$eachpwd[$i]")) and !&check_adminbutton) { close(WRDAT); unlink("$tmpfile"); &error("$name[$i]を変更しようとしましたが、そのパスワードが違います。"); } $newstatus = $in{$i} unless ($newstatus eq 'deleted'); $newcount = $in{"count_$i"}; $newcomment = $in{"comment_$i"} if ($in{edit} == $i); $newcomment = '' if ($in{delallcom} eq 'on' and $in{adminbutton} ne ''); my $invalid = 0; foreach (@ngword){ $invalid = 1 if ($newcomment =~ /$_/i); } if ($invalid){ close(WRDAT); unlink("$tmpfile"); &error('不適当な言葉が含まれています。'); } if ($att_limit_en and $attnum >= $att_limit_num and $newstatus eq '0'){ close(WRDAT); unlink("$tmpfile"); &error('締め切り人数に達しているので追加、変更できません。'); } } if ($password_en == 1 && ("$in{$pwdi}" ne '' && "$eachpwd[$i]" eq '')){ $eachpwd[$i] = &makecrypt("$in{$pwdi}"); } print WRDAT "$i,$items[$i-1],$newstatus,$newcount,$eachmod[$i],$eachpwd[$i],$newcomment\n"; } close(WRDAT); if ($modified){ rename("$tmpfile","$datafile"); } else { unlink "$tmpfile"; } chmod(0666,"$datafile"); &unlockfile; } sub check_adminbutton { return ($adminbutton_en and &checkadmin($in{adminpwd})); } ###################### 表示 ############################ sub display { &htmlhead($title); if ($att_limit_en and $attnum >= $att_limit_num){ $hit_limit = 1; } if ($deadline_en and $now >= $deadline_time){ $delcheck_en = 0; $password_en = 0; $update_button = 0; } print "$body_head"; print "

\n"; print "\n"; &hiddenid; if ($date =~ /(\d+)_(\d+)_(\d+)_(\d+)_(\d+)/) { $date = sprintf("%s年%s月%s日%s時%s分",$1,$2,$3,$4,$5); } else { $date = " "; } print "$backlink_name

\n" if ($backlink_en); if ($deadline_en == 1){ printf("更新締め切り:%4d年%02d月%02d日%02d時%02d分
\n",$deadline_year,$deadline_month,$deadline_day,$deadline_hour,$deadline_min); } if ($att_limit_en){ print "参加者上限:$att_limit_num人
\n"; } print "最終更新日:"; print "$date
"; print "最終更新者:"; print "$lastname

\n"; my $select_items = $#option_list + 2 + $delcheck_en + $comment_en + $update_en + $count_en + $password_en + $update_button; my $cols = $table_colms * $select_items; if ($adminbutton_en){ print "管理用パスワード"; print ""; print "コメント一括削除"; print "
\n"; } print "\n"; &header_disp(@option_list); my $i = 1; my $line = 1; my $totalattlist4; my @total; while ($#items >= 0){ if ($status[$i] eq 'deleted'){ shift @items; $i++; next; } if ($line != 1 and ($line-1) % $header_repeat == 0) {&header_disp(@option_list);} print "\n"; my $j; my @checked; for ($j=1;$j<=$table_colms;$j=$j+1){ if ($#items < 0) { my $h; for ($h=0;$h<$select_items;$h=$h+1){ print "\n"; } last; } print "\n"; $checked[$status[$i]] = 'checked'; my $k; for ($k=0;$k<=$#option_list;$k++) { my ($item,$color) = split /,/, $option_list[$k]; if ($checked[$k] eq 'checked') { print "\n"; } if ($delcheck_en == 1){ print "\n"; } if ($count_en == 1){ $count[$i] = 0 if (!$count[$i]); print "\n"; } if ($comment_en == 1){ print "\n"; } if ($update_en == 1){ print "\n"; } if ($password_en == 1){ print "\n"; } else { print "\n"; } if ($update_button){ print "\n"; } $totalattlist4 = $totalattlist4 + $count[$i]; shift(@items); $i = $i + 1; } print "\n"; $line++; } print ""; print "\n"; my $rightcolspan = $delcheck_en + $comment_en + $update_en + $count_en + $password_en + $update_button; my $leftcol = $cols - $rightcolspan - 2; for ($i=0;$i<=$leftcol;$i++){ if ($total[$i] ne '') { print "\n"; } else { print "\n"; } } if ($count_en == 1){ print "\n"; } else { for ($i=1;$i<=$rightcolspan;$i++){ print "\n"; } } print "\n"; # Display when # time limit is not reached or # $udpate_button = 0 when time limit is reached # attend limit is not reached # $hit_limit = 1 when attend limit is reached # or # attend limit is reached and $allow_absent_beyond_limit == 1 if (($update_button == 1 and $deadline_en) or ($hit_limit == 0 and $att_limit_en) or ($hit_limit and $att_limit_en and $allow_absent_beyond_limit) or (($att_limit_en == 0) and ($deadline_en == 0))){ print "\n"; print ""; my $k; for ($k=0;$k<=$#option_list;$k++) { my ($item,$color) = split /,/, $option_list[$k]; print "\n"; } if ($delcheck_en == 1){ print "\n"; } if ($count_en == 1){ print "\n"; } if ($comment_en == 1){ print "\n"; } if ($update_en == 1){ print "\n"; } if ($password_en == 1){ print "\n"; } else { print "\n"; } print "\n"; print "\n"; } print "
 "; chomp($items[0]); print "$items[0]"; print ""; $total[$k]++; print ""; } else { print ""; if ($k == 0 and $hit_limit){ print " "; } else { print ""; } } print ""; print ""; print ""; print "\n"; print ""; if ($in{edit} == $i){ print "\n"; print "\n"; } else { $comment[$i] = ' ' if ($comment[$i] =~ /^[\s ]*$/); if ($update_button){ print "$comment[$i]"; } else { print "$comment[$i]"; } } print ""; if ($eachmod[$i] =~ /(\d+)_(\d+)_(\d+)_(\d+)_(\d+)/) { &update_disp; } else { print " "; } print ""; print ""; print ""; print ""; print "
合計$total[$i]0合計 $totalattlist4 
"; print qq(\n); print ""; if ($k == 0 and $hit_limit and $att_limit_en and $allow_absent_beyond_limit) { print " "; } else { print ""; } print ""; print " "; print ""; print ""; print ""; print ""; print ""; print " "; print ""; print ""; print ""; print ""; print "
\n"; ©right; if ($setup_en == 1){ print "
管理用
\n"; } print "

"; print "$body_tail"; &htmltail; } ###################### セットアップ ############################ sub setup { &setadminpwd if ($in{pwd} eq ''); &error('管理用パスワードが違います。') unless &checkadmin($in{pwd}); &htmlhead('管理用セットアップ'); print "
\n"; &hiddenid; print "\n"; print "\n"; print "\n"; my @setup_check; my @update_check; my @update_type_check; my @comment_check; my @password_check; my @adminonly_check; my @newreg_adminpwd_check; my @adminbutton_check; my @count_check; my @update1_file_check; my @update2_file_check; my @localtime_check; my @att_limit_check; my @allow_absent_beyond_limit_check; my @deadline_check; my @medit_check; $setup_check[$setup_en] = "checked"; $update_check[$update_en] = "checked"; $update_type_check[$update_type] = "checked"; $comment_check[$comment_en] = "checked"; $password_check[$password_en] = "checked"; $adminonly_check[$adminonly_en] = "checked"; $newreg_adminpwd_check[$newreg_adminpwd] = "checked"; $adminbutton_check[$adminbutton_en] = "checked"; $count_check[$count_en] = "checked"; $update1_file_check[$update1_file_en] = "checked"; $update2_file_check[$update2_file_en] = "checked"; $localtime_check[$localtime_en] = "checked"; $att_limit_check[$att_limit_en] = "checked"; $allow_absent_beyond_limit_check[$allow_absent_beyond_limit] = "checked"; $deadline_check[$deadline_en] = "checked"; $medit_check[$medit_en] = "checked"; my %check; $check{bgimage}[$bgimage_en] = "checked"; $check{backlink}[$backlink_en] = "checked"; $check{style_sheet}[$style_sheet_en] = "checked"; $check{head_insert}[$head_insert_en] = "checked"; my %chkbox = (on => 'checked'); $count_name =~ s//>/g; print <
  • 管理人パスワードを変更するには、$admindatを削除して、$scriptを実行しなおしてパスワードを再入力してください。
  • これらの設定は$setupfileに保存されます。また、$setupfileをエディタ等で変更してもこの設定ページに反映されます。
  • $scriptがバージョンアップされた場合、単純に$scriptだけを置き換えるだけで設定はそのまま使えます。
  • $admindatと$setupfileのファイル名はこの設定ページでは変更できません。変更したい場合は$scriptの中で変更してください。
  • 管理用リンクを非表\示にしている場合にこのページにアクセスするには、$script?mode=setupを実行するとアクセスできます。
  • 数字やカラー指定は必ず半角で指定してください。全角やブランクだとCGIが起動しなくなります。万一間違って全角で書いてしまった場合は、$setupfileをエディタで開きその場所を半角に正しく修正してください。それで直ります。
データファイル
ロックファイル
タイトル
ブラウザのタイトルバーに表\示されるタイトルです。ページのタイトルは「ページ上部」で自由にタイトル表\示させることができます。
バックグランド 画像を使う カラー設定にする
画像を使う場合の画像ファイル
カラー設定の場合のカラー番号(白:\#ffffff 又は white)
トップへのリンク 表\示 非表\示
リンク名
URL
表\示幅 ブラウザ全体の
ページ内の表\示全てに適用されます。
テーブル表\示幅 表\示幅からの
テーブルのみに適用されます。
ヘッダーセルの色 オプションセルの背景色
オプションセルのフォント色
項目セルの背景色
項目セルのフォント色
オプション設定 選択可能\なオプションを「オプション名,背景色」で並べてください。
例)
参加,red
不参加,#ff0000
未定,green
ヘッダ表\示 テー\ブルのヘッダを行毎に表\示
管理用リンク表\示 表\示 非表\示
更新日表\示 表\示 非表\示
曜日表\示
2006年10月21日12時00分
2006年10月21日
10月21日
10月21日12時00分
12時00分
コメント入力 有効 無効
コメントのテキストボックスのサイズ:
コメント列のサイズ:テーブル全体の%
携帯モード編集 有効 無効
数量 有効 無効
数量名
参加人数設定 有効 無効
参加人数上限
参加人数上限に達した時に出席以外の新規登録 有効 無効
締め切り時間 有効にすると締め切り日時以降に更新できなくなります。
有効 無効
締め切り
パスワード保護 有効 無効
管理人オンリーモード 有効 無効
管理人オンリーモードで新規登録の際、 管理人パスワードで登録 パスワード無しで登録
「管理人パスワードで登録」で参加者を新規追加すると、以降も管理人にしか選択の変更ができなくなります。
「パスワード無し」で参加者を新規追加すると、パスワードが設定されずに追加されます。一度その参加者の選択をパスワードを入力して変更することでその参加者に対してパスワードが設定され、保護されるようになります。
管理用一括更新ボタン 有効 無効
NGワード 名前とコメントに登録禁止する単語を半角スペースで区切って指定してください。シングルクォーテーションとダブルクォーテーションは指定できません。

PC用ページ上部 ページ上部に表\示させるものをHTML表\記

PC用ページ下部 ページ下部に表\示させるものをHTML表\記

携帯用ページ上部 携帯モードでのページ上部に表\示させるものをHTML表\記

携帯用ページ下部 携帯モードでのページ下部に表\示させるものをHTML表\記

スタイルシート 有効 無効

<head>内挿入文 有効 無効
HTML書式
ポップアップ広告やJavascript、<META>を挿入したい場合にここに記述する。
以下の記述が<head>〜</head>内に挿入される。

時間設定 GMTからのオフセット ローカルタイム
GMTからのオフセットに設定した場合、GMTより時間(日本:+9時間)
予\備のアップデートファイル 使用 非使用 ファイル名
使用 非使用 ファイル名
END_SETUP print "

"; print "

\n"; print "

"; ©right; print "
"; &htmltail; } ###################### セットアップ作成 ############################ sub wrsetup { &error('パスワードが違います。') unless (&checkadmin($in{pwd})); open(SETUP,"> $setupfile") || &error('セットアップファイルが作成できません。
CGIを置いてあるディレクトリが書き込み可能\か確認してください。'); foreach (keys(%in)){ $in{$_} =~ s/
/\n/ig if (!/body_head/ and !/body_tail/ and !/count_name/ and !/options/); $in{$_} =~ s/,/,/g; $in{$_} =~ s/<//g; $in{$_} =~ s/\s*$//; } print SETUP <header(-charset=>$charset); print "\n"; print "\n"; print "\n"; print "$title\n"; if ($head_insert_en == 1){ print "$head_insert\n"; } if ($style_sheet_en == 1){ print "\n"; } print "\n"; 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 "
\n"; exit; } sub error { my ($msg) = shift; &unlockfile; &htmlhead($msg); print "
$msg
\n"; print "
"; ©right; print "
"; &htmltail; exit; } sub makecrypt { my $plain = shift; my $salt = join "", ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]; my $result = crypt($plain,$salt) or crypt($plain,'$1$'.$salt.'$'); return $result; } sub setadminpwd { my $subname = 'setadminpwd'; &htmlhead('管理者用パスワードを入力してください'); print "
\n"; &hiddenid; if ($in{mode} eq 'setup'){ print "
管理者用パスワードを入力してください。
\n"; print "\n"; print "\n"; print "\n"; } else { print "
管理者用パスワードを設定してください。
\n"; print "\n"; print "\n"; print "\n"; } print "

"; ©right; print "
"; &htmltail; exit; } sub wradminpwd { my $plain = shift; my $passwd = &makecrypt($plain); if (open(FILE,"> $admindat")){ print FILE "$passwd"; close(FILE); } else { &error('パスワードファイル作成に失敗しました'); } print "Location: $script\n\n"; } sub checkadmin { my $pwd = shift; if (open(ADMINFILE,"< $admindat")){ my $filepwd = ; close(ADMINFILE); my $inpwd = crypt($pwd,$filepwd); return ("$inpwd" eq "$filepwd"); } else { &error('パスワードファイルが存在しません'); } } sub lockfile { open(LOCK,"> $lockfile"); flock LOCK, 2; } sub unlockfile { close(LOCK); unlink("tmp.$$") if (-e "tmp.$$"); # unlink("$lockfile") if (-e $lockfile); } sub get_items { my @items_list; if (open(ITEM,"< $datafile")){ flock ITEM, 1; while (){ push @items_list, (split /,/)[1]; } close(ITEM); shift @items_list; } return (@items_list); } sub get_data { my ($date, $lastname); my (@name, @status, @count, @eachpwd, @eachmod, @comment); my ($key,$name,$value,$count,$moddate,$pwd); if (open(ATTLIST4,"< $datafile")) { flock ATTLIST4, 1; foreach (){ chomp; ($key,$name,$value,$count,$moddate,$pwd,$comment)=split(/,/); if ($key == 0){ $date = $value;; $lastname = $name; } else { $name[$key] = "$name"; if ($value eq '') { $status[$key] = "0"; } else { $status[$key] = "$value"; } $count[$key] = "$count"; $eachpwd[$key] = "$pwd"; $eachmod[$key] = "$moddate"; $comment[$key] = "$comment"; } } close(ATTLIST4); } return ($key, $date, $lastname, \@name, \@status, \@count, \@eachpwd, \@eachmod, \@comment); } sub extraupdate { if ($update1_file_en == 1){ open(UPDATE,">$update1_file"); print UPDATE "dummy file1\n"; close(UPDATE); chmod(0666,"$update1_file"); } if ($update2_file_en == 1){ open(UPDATE,">$update2_file"); print UPDATE "dummy file2\n"; close(UPDATE); chmod(0666,"$update2_file"); } } sub mobile { if ($att_limit_en and $attnum >= $att_limit_num){ $hit_limit = 1; } if ($deadline_en and $now >= $deadline_time){ $update_button = 0; } print $q->header(-charset=>$charset); my @items_list = &get_items; print "$body_head_for_cell\n"; print "$backlink_name
\n" if ($backlink_en); # Display when # time limit is not reached or # $udpate_button = 0 when time limit is reached # attend limit is not reached # $hit_limit = 1 when attend limit is reached # or # attend limit is reached and $allow_absent_beyond_limit == 1 if (($update_button == 1 and $deadline_en) or ($hit_limit == 0 and $att_limit_en) or ($hit_limit and $att_limit_en and $allow_absent_beyond_limit) or (($att_limit_en == 0) and ($deadline_en == 0)) and $medit_en){ print "新規追加\n"; } print "

\n"; if ($date =~ /(\d+)_(\d+)_(\d+)_(\d+)_(\d+)/) { $date = sprintf("%s年%s月%s日%s時%s分",$1,$2,$3,$4,$5); } else { $date = " "; } if ($deadline_en == 1){ printf("更新締め切り:%4d年%02d月%02d日%02d時%02d分
\n",$deadline_year,$deadline_month,$deadline_day,$deadline_hour,$deadline_min); } if ($att_limit_en){ print "参加者上限:$att_limit_num人
\n"; } print "最終更新日:"; print "$date
"; print "最終更新者:"; print "$lastname

"; my $select_items = $#option_list + 2 + $delcheck_en + $comment_en + $update_en + $count_en + $password_en + $update_button; my $cols = $table_colms * $select_items; my $i = 1; my $totalattlist4; my @total; while ($#items_list >= 0){ if ($status[$i] eq 'deleted'){ shift @items_list; $i++; next; } my $j; for ($j=1;$j<=$table_colms;$j=$j+1){ if ($#items_list < 0) { last; } chomp($items_list[0]); print "$items_list[0]"; $newoption_list[$status[$i]] =~ s/<.*>//g; print " : $newoption_list[$status[$i]]"; $total[$status[$i]]++; if ($count_en == 1){ $count[$i] = 0 if (!$count[$i]); print " : $count[$i]\n"; } if ($comment_en == 1){ $comment[$i] =~ s/<.*>//g; print " : $comment[$i]\n"; } if ($update_en == 1){ if ($eachmod[$i] =~ /(\d+)_(\d+)_(\d+)_(\d+)_(\d+)/) { print " : "; &update_disp; } } if ($update_button and $medit_en){ # if ($hit_limit and $status[$i] eq '0' or $hit_limit == 0) { print " (更新)"; # } } $totalattlist4 = $totalattlist4 + $count[$i]; shift(@items_list); $i = $i + 1; } print "
\n"; } print "
\n"; for ($i=0;$i<=$#option_list;$i++){ $newoption_list[$i] =~ s/<.*>//g; print "$newoption_list[$i] 合計 : "; if ($total[$i] ne '') { print "$total[$i]
\n"; } else { print "0
\n"; } } if ($count_en == 1){ $count_name =~ s/<.*>//g; print "$count_name合計 : $totalattlist4
\n"; } print "$body_tail_for_cell\n"; &htmltail; } sub medit { if ($att_limit_en and $attnum >= $att_limit_num){ $hit_limit = 1; } if ($deadline_en and $now >= $deadline_time){ $delcheck_en = 0; $password_en = 0; $update_button = 0; } print $q->header(-charset=>$charset); print "\n"; &hiddenid; my $i = $in{edit}; my @checked; $checked[$status[$i]] = 'checked'; my $optionname; my $countname; my $commentname; my $pwdname; my $buttonname; my $buttonvalue; if ($in{edit} eq ''){ $optionname = 'newoption'; $countname = 'newcount'; $commentname = 'newcomment'; $pwdname = 'newpwd'; $buttonname = 'add'; $buttonvalue = '追加'; print qq(名前:

\n); } else { $optionname = $i; $countname = "count_$i"; $commentname = "comment_$i"; $pwdname = "pwd_$i"; $buttonname = "btn_$i"; $buttonvalue = '更新'; print qq(名前: $name[$i]

\n); } for (my $k=0;$k<=$#option_list;$k++) { my ($item,$color) = split /,/, $option_list[$k]; $item =~ s/<.*>//g; unless ($k == 0 and $hit_limit and $att_limit_en and $allow_absent_beyond_limit) { print "$item
\n"; } } if ($delcheck_en == 1 and $in{edit} ne ''){ print "削除
"; } print "
\n"; if ($count_en == 1){ $count[$i] = 0 if (!$count[$i]); $count_name =~ s/<.*>//g; print "$count_name:
\n"; } if ($comment_en == 1){ print "コメント:
\n"; print "
\n"; } if ($password_en == 1){ # if ($hit_limit and $status[$i] eq '0' or $hit_limit == 0) { print "パスワード:
"; # } } else { print "
\n"; } print "\n"; print "\n"; print "\n"; print "

\n"; &htmltail; } sub update_disp { my $weekday_num = 7; my @weekday = qw((日) (月) (火) (水) (木) (金) (土)); if ($weekday_en eq 'on'){ my $epic=timelocal(0,0,0,$3,$2-1,$1); $weekday_num = (localtime($epic))[6]; } if ($update_type == 0) { print "$1年$2月$3日$weekday[$weekday_num]$4時$5分"; } elsif ($update_type == 1) { print "$1年$2月$3日$weekday[$weekday_num]"; } elsif ($update_type == 2) { print "$2月$3日$weekday[$weekday_num]"; } elsif ($update_type == 3) { print "$2月$3日$weekday[$weekday_num]$4時$5分"; } elsif ($update_type == 4) { print "$4時$5分"; } else { print "$1年$2月$3日$4時$5分"; } } sub postprocess { my (%in) = @_; my ($key, $value); while (($key,$value)=each %in){ $value =~ s//>/g; $value =~ s/,/&\#44;/g; $in{"$key"}=$value; } return(%in); } sub header_disp { my @option_list = @_; print "\n"; my $i; for ($i=1;$i<=$table_colms;$i=$i+1){ print "名前\n"; my $j; for ($j=0;$j<=$#option_list;$j++) { my ($option,$color) = split /,/, $option_list[$j]; print "$option\n"; } print "削除\n" if ($delcheck_en == 1); print "$count_name\n" if ($count_en == 1); print "コメント\n" if ($comment_en == 1); print "更新日\n" if ($update_en == 1); print "パスワード\n" if ($password_en == 1); print " \n" if ($update_button); } print "\n"; } sub hiddenid { if ($in{id} ne ''){ print "\n"; } }