#!/usr/local/bin/perl require './jcode.pl'; require './cgi-lib.pl'; $ImgUrl = "http://www.aso.ne.jp/~sizen/event/img/"; ###"http://www.aso.ne.jp/~sizen/event/img/";に変更 ###"http://127.0.0.1/sizen/event/img/";に変更 $script = "./event.cgi"; $logfile = "./event.log"; $lockfile = "./event.lock"; $ImgDir = "./imgs/"; $pass = '3333'; $cgi_lib'maxdata = '30720'; # → 例 : 102400 = 100KB &decode; if ($mode eq 'top') {⊤ } elsif ($mode eq "hyoji") { &hyoji; } elsif ($mode eq 'hensyu') { &hensyu; } elsif ($mode eq "mente") { &mente; } elsif ($mode eq "kanri") { &kanri; } elsif ($mode eq "sakujyo") { &sakujyo; } &unlock; ⊤ ###------ TOP画面 ------### sub top { &header; print <<"EOM";

イベント情報

イベントをご覧になりたい月を、クリックして下さい!

EOM &open; foreach $line (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/, $line); if ("$no" eq "2") { last; } } if("$flag" eq "0"){ print "$name CLOSE!"; }else{ print "$name OPEN!"; } print <<"EOM"; EOM &open; foreach $line (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/, $line); if ("$no" eq "3") { last; } } if("$flag" eq "0"){ print "$name CLOSE!"; }else{ print "$name OPEN!"; } print <<"EOM"; EOM &open; foreach $line (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/, $line); if ("$no" eq "4") { last; } } if("$flag" eq "0"){ print "$name CLOSE!"; }else{ print "$name OPEN!"; } print <<"EOM";
EOM &open; foreach $line (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/, $line); if ("$no" eq "5") { last; } } if("$flag" eq "0"){ print "$name CLOSE!"; }else{ print "$name OPEN!"; } print <<"EOM"; EOM &open; foreach $line (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/, $line); if ("$no" eq "6") { last; } } if("$flag" eq "0"){ print "$name CLOSE!"; }else{ print "$name OPEN!"; } print <<"EOM"; EOM &open; foreach $line (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/, $line); if ("$no" eq "7") { last; } } if("$flag" eq "0"){ print "$name CLOSE!"; }else{ print "$name OPEN!"; } print <<"EOM";
EOM &open; foreach $line (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/, $line); if ("$no" eq "8") { last; } } if("$flag" eq "0"){ print "$name CLOSE!"; }else{ print "$name OPEN!"; } print <<"EOM"; EOM &open; foreach $line (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/, $line); if ("$no" eq "9") { last; } } if("$flag" eq "0"){ print "$name CLOSE!"; }else{ print "$name OPEN!"; } print <<"EOM"; EOM &open; foreach $line (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/, $line); if ("$no" eq "10") { last; } } if("$flag" eq "0"){ print "$name CLOSE!"; }else{ print "$name OPEN!"; } print <<"EOM";
EOM &open; foreach $line (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/, $line); if ("$no" eq "11") { last; } } if("$flag" eq "0"){ print "$name CLOSE!"; }else{ print "$name OPEN!"; } print <<"EOM"; EOM &open; foreach $line (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/, $line); if ("$no" eq "12") { last; } } if("$flag" eq "0"){ print "$name CLOSE!"; }else{ print "$name OPEN!"; } print <<"EOM"; EOM &open; foreach $line (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/, $line); if ("$no" eq "13") { last; } } if("$flag" eq "0"){ print "$name CLOSE!"; }else{ print "$name OPEN!"; } print <<"EOM";

EOM &footer; } ###------ 管理画面 ------### sub kanri { if ($pass ne "$in{'pas'}") { &error("パスワードが違います"); } &header; print "イベントページに戻る
\n"; print "
\n"; print "\n"; print "内容の編集は項目をクリック
\n"; print "\n"; &open; @lines = map {$_->[0]} sort {$a->[1] <=> $b->[1]} map {[$_, split /,/]} @lines; foreach $line (@lines) { local($no,$times,$name,$flag,$comment) = split(/,/, $line); print ""; } print "
$name
\n"; &footer; exit; } ###------ 表示画面 ------### sub hyoji { &open; foreach $line (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/, $line); if ($in{'no'} eq "$no") { last; } } &header; print <<"EOM";

イベント情報
EOM if (-e "$ImgDir$no.jpg") { print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; print <<"EOM";
$nameのイベントのご案内♪
$comment
イベント情報のTOPへ戻る

EOM &footer; exit; } ###----- 編集画面 -----### sub hensyu { &open; foreach $line (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/, $line); if ($in{'no'} eq "$no") { last; } } if ($in{'pas'} != $pas) { &error("パスワードが違います"); } $comment =~ s/
/\n/g; $comment =~ s/(.*)<\/a>/$1/g; &header; print "\n"; print "\n"; print "\n"; print "戻る\n"; print "

\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
赤色の項目は必須です
紹介文
画像 画像サイズは30kb未満で
OPEN or CLOSECLOSE=0 OPEN=1(なんでもよい)
\n"; $MaxData = int ($cgi_lib'maxdata / 1024); print "
\n"; &footer; exit; } ###----- 編集処理 -----### sub mente { $data = "$in{'name'}$in{flag}$in{'comment'}\n"; if (index($data,",") >= 0) { &error("どこかに小文字のカンマが含まれていますので、消去してください"); } &lock; &open; @new=(); ## 画像ファイルがあれば更新する if ($in{'upfile'}) { &open; foreach $line (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/, $line); if ($in{'no'} eq "$no") { last; } } $ImgFile = "$ImgDir$no.jpg";&UpFile; } ##ここまで $itimes = time; &auto_link($in{'comment'}); foreach (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/,); if ($in{'no'} eq "$no") { $_ = "$no,$itimes,$in{'name'},$in{'flag'},$in{'comment'},\n"; } push(@new,$_); } open(OUT,">$logfile") || &error("Write Error : $logfile"); print OUT @new; close(OUT); &unlock; &header; print "

下の「イベントへ」をクリックし、イベント情報のページに戻ってください。

\n"; print "

イベントへ\n"; print "


\n"; &footer; exit; } ###-------- 画像のアップロード ------------### sub UpFile { $upfile = $in{'upfile'}; open(OUT,"> $ImgFile") || &error("画像のアップロードに失敗しました","lock"); binmode(OUT); binmode(STDOUT); print OUT $upfile; close(OUT); chmod (0666,$ImgFile); } ###------ 削除処理 --------### sub sakujyo { &open; if ($in{'action'} eq 'sakujyo') { if ($in{'no'} eq ''){ &error("削除Noが入力されていません"); } &lock; &open; $flag=0; @new=(); foreach (@lines) { ($no,$times,$name,$flag,$comment) = split(/,/); if ($in{'no'} eq "$no") { $flag=1;if (-e "$ImgDir$no.jpg"){ unlink("$ImgDir$no.jpg"); }} else { push(@new,$_); } } if ($flag == 0) { &error("該当記事が見当たりません","lock"); } open(OUT,">$logfile") || &error("Write Error : $logfile"); print OUT @new; close(OUT); &unlock; &header; print "

削除処理、完了しました

\n"; print "

イベントへ\n"; &footer; exit; } &header; $count = @lines; print "戻る\n"; print "


削除処理 登録は $count
\n"; print "

\n"; print "\n"; print "\n"; print "\n"; print "NO(削除後は復元できません

"; print "\n"; print "\n"; foreach $line (@lines) { local($no,$times,$name,$flag,$comment) = split(/,/, $line); &get_date($times); # 日付表示を変換 print ""; print ""; } print "
NO名前・名称
$no
$name

\n"; &footer; exit; } ###----- デコード処理 -----### sub decode { &ReadParse; while (($key,$val) = each %in) { if ($key ne "upfile") { # シフトJISコードに変換 &jcode'convert(*val, "sjis", "", "z"); # タグ処理 if ($tagkey) { $val =~ s/,/<>/g; } else { $val =~ s//>/g; } # 改行処理 if ($key eq "comment") { $val =~ s/\r\n/
/g; $val =~ s/\r/
/g; $val =~ s/\n/
/g; } else { $val =~ s/\r//g; $val =~ s/\n//g; } } $in{$key} = $val; } $mode = $in{'mode'}; $part =$in{'part'}; $page = $in{'page'}; } ###------- 時間の取得 -------### sub get_date { $ENV{'TZ'} = "JST-9"; # タイムゾーンを日本時間へ ($sec,$min,$hour,$mday,$mon,$year,$wday,$dmy,$dmy) = localtime($_[0]); @week = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); # 日時のフォーマット $date = sprintf("\%02d\/%02d",$mon+1,$mday); } ###------- HTMLのヘッダー -------### sub header { print "Content-type: text/html\n\n"; print <<"EOM"; イベント情報
株式会社はくすいロゴ
会社 ご案内 お買い物
サイト案内 ホームページ
白水温泉「瑠璃」 物産館「自然庵」 水加工場「はくすい」 観光案内 イベント情報 リンク集
EOM } ###------- HTMLのフッター -------### sub footer { print <<"EOM";
Copyright(C) 2002 HAKUSUI Co.,Ltd ALL Rights Reserved.
EOM } ###------- エラー処理 -------### sub error { &header; print "





$_[0]\n"; print "


前のページに戻る

\n"; print "
\n"; &footer; exit; } ###------ファイルロック処理-------### sub lock { local($flag) = 0; foreach (1 .. 5) { if (-e $lockfile) { sleep(1); } else { open(LOCK,">$lockfile"); close(LOCK); $flag = 1; last; } } if ($flag == 0) { &error("Lock Error"); } } ###------ファイルロック解除-------### sub unlock { if (-e $lockfile) { unlink($lockfile); } } ###------ファイルオープン-------### sub open { open(IN,"$logfile") || &error("Open Error : $logfile"); @lines = ; close(IN); } #------- AUTOリンク-------# sub auto_link { $_[0] =~ s/([^=^\"]|^)(http\:[\w\.\~\-\/\?\&\=\@\;\#\:\%]+)/$1$2<\/a>/g; }