#!/usr/local/bin/perl #----------------------------------------------- # Schedule2 V2.2 # Copyright (C) Sora All rights reserved # # written by Sora # script : schedule.cgi # web : http://sky-web.info/ # reference : http://www.din.or.jp/~ohzaki/perl.htm (正規表現) # http://www.tohoho-web.com/ # http://www.orange-factory.com/ # # history : 2004/12/23 Ver.1.0 release # スケジュールの書き込みは管理者のみです。 # 2005/03/15 Ver.1.11 # ・IIS対策 # ・不具合修正 # 2005/04/14 Ver.1.12 # ・不具合修正 # 2005/06/28 Ver.1.13 # ・不具合修正 # 2005/09/19 Ver.1.14 # ・不具合修正 # 2006/01/05 Ver.1.15 # ・不具合修正 # 2006/04/21 Ver.2.00 # ・月一覧表示 # ・タイトル一覧表示 # ・検索機能追加 # ・タイトル文字色変更 # 2006/05/27 Ver.2.01 # ・不具合修正 # 2006/11/18 Ver.2.1 # ・最終更新日表示 # ・新しいタイトルにマーク # ・mode=todayを付けることで、今日の予定を表示できるようにする # 2007/02/09 Ver.2.1α # ・携帯対応(DoCoMo、au、Softbank) # 2007/07/01 Ver.2.2 # ・画像アップロード # ・CGI.pm利用 # ・月曜日から始まるカレンダーに対応 # 2007/08/07 Ver.2.3 # ・Locationヘッダが使用できないサーバーに対応 # ・不具合修正 #------------------------------------------------------------------------ # ■ディレクトリ構成例 # public_html # |--- cgi-bin # |--- schedule.cgi (アクセス権:755) # |--- search.cgi (アクセス権:755) # |--- jcode.pl (アクセス権:604) # |--- update.cgi (アクセス権:666) # |--- log (作成してください。:アクセス権:777) # |--- schedule_yyyymm.cgi (自動的に作成されます。) # |--- img # | |--- c.gif (ダミーgif:旧ログのために使用) # |--- lock (作成してください。アクセス権:777) # |--- schedule.lock (自動的に作成/削除されます。) # # ■このファイルの 1行目の「#!/usr/local/bin/perl」を サーバーの環境に # あわせて書き換えてください。パス名が分らない場合は、プロバイダや # サーバー管理者に問い合わせてください。 # # ■管理画面を表示するときは・・・ # http://〜/cgi-bin/schedule.cgi?mode=admin #------------------------------------------------------------------------ #--- 初期設定 --- ### jcode.plの場所 ### require './jcode.pl'; ### cssファイル名 ### $css = './schedule.css'; ### lockファイルの名前 ### $flock = 'lock/schedule.lock'; # 自動的に作成/削除されます。なるべく変更しないでください。 ### ログファイルの格納ディレクトリ名 ### $logdir = 'log'; # ログファイルを入れるディレクトリー名を入れてください。 ### 画像をおくディレクトリー ### $imgDir = 'schedule2_img'; # ディレクトリー名 ### 画像表示の幅 ### # アップロード画像の横幅か高さがこのサイズより大きい場合、サムネイルを作成します。 # ※画像の容量が変わりません。(ImageMagickは使用しません) # 容量が大きい画像は加工してアップロードしてください。 # 携帯で見ることができない場合があります。 $w_imgsize = 120; # 表示するサムネイル画像の幅。ピクセルで指定して下さい。 $h_imgsize = 120; # 表示するサムネイル画像の高さ。ピクセルで指定して下さい。 # アップロードできるファイルサイズの上限 # サーバーの容量に注意してください。 $CGI::POST_MAX = 1024 * 100; # 1KB=1024B (1024*100=100K) ### ページのタイトル ### $ptitle = '仙台イベント情報'; # HTMLのの中に入ります。 ### ページの背景画像 ### $bg_gif = ''; # 入れない場合は''にしてください。 ### タイトル画像 ### $title_img = '0'; # 入れる場合は「1」、入れない場合は「0」にしてください。 $titleImg = ""; # 画像を入れる場合は画像のパス名 $titleAlt = ""; # 画像のalt ### 入力フォームの背景色 ### $bgcolor = '#f1fff1'; ### タイトル文字の色 ### #''で囲んで、,(カンマ)で区切ってください。色の名前でも番号でもOK。 #一番初めの色がデフォルトになります。 @titlecolor = ('#ff33cc;', '#cc6600', '#000099', '#006633', '#cc0000'); ### 入力文字の色 ### #''で囲んで、,(カンマ)で区切ってください。色の名前でも番号でもOK。 @textcolor = ('#333333', '#000099', '#006633', '#cc6600', '#cc0000'); ### 月曜日から始まるカレンダーにする ### $start_monday = 0; # 月曜日から始まる場合は1にしてください。0の場合は日曜日から。 ### カレンダーとスケジュールの線の色 ### $calcolor = '#78a0b0'; ### カレンダーの1マスの幅 ### $calWidth = 110; # ピクセルで指定してください。 ### カレンダーの1マスの高さ ### $calHeight = 80; # ピクセルで指定してください。 ### スケジュール表示テーブルの幅 ### $sTableWidth = "770"; # ピクセルでも%でも可 ### カレンダーに表示するタイトルを文字にするかアイコンにするか ### $displayTitle = 1; # タイトル=1、アイコン=0(アイコンにする場合はアイコン設定に「なし」を入れないでください) ### 1日のカラムに入れるタイトルの件数 ### $nTitle = 7; # 件数を数字で指定してください。 ### 1日のカラムに入れるタイトルの文字数 ### $tTitle = 9; # 日本語での文字数を数字で指定してください。半角は2倍入ります。 ### 新しい投稿にマークをつける ### $newmark = 1; # つける場合は「1」、つけない場合は「0」 ### $newmark=1の時マークの画像 ### $mark_img = "img/n.gif"; # ### $newmark=1の時マークを入れる日数 ### $mark_days = "3"; # 投稿した日から何日間マークを入れるか指定してください。 ### カレンダーに表示するタイトルの文字の大きさ ### $title_px = 10; # pxで指定してください。 ### 日付が入っていないカラムに画像を入れる ### $day_gif = ''; # 画像のファイル名 (大きさは60×60より小さくしてください)入れない場合は''にしてください。 ### 「先月へ」のボタンを画像にする場合 ### $last_gif = ''; # 入れない場合は''にしてください。「←」になります。 ### 「来月」のボタンを画像にする場合 ### $next_gif = ''; # 入れない場合は''にしてください。「→」になります。 ### 選択できる年 ### $min_year = 2007; # 何年から選択できるか4桁で入れて下さい。 $max_year = 1; # 何年まで選択できるか 今年から何年後かを入れて下さい。 ### 「TOP」のボタン(ページトップへ)を画像にする場合 ### $top_gif = ''; # 入れない場合は''にしてください。「↑TOP」になります。 ### 記事に対して「返信」をつけられるようにする ### $res_mode = 1; # 返信がいる場合は「1」、いらない場合は「0」 ### 「返信」のボタンを画像にする場合 ### $res_gif = ''; # 入れない場合は''にしてください。「返信」になります。 ### 編集モードへのリンク設定 ### $edit_gif = ''; # 編集モードへのリンクを画像にしたい場合。しない場合は''にしてテキストを設定してください。 $edit_text = 'edit'; # テキストにしたい場合は、↑を''にしてこれを設定してください。 ### 区切り線の色 (IEのみ)### $linecolor = '#78ffb0'; ### アイコン設定 ### # 表示されるアイコンです。追加・削除する場合、数字は必ず連番にしてください。 # ['xxxx', 'xxxx.gif'] 1項目目がセレクトボックスに表示されるテキスト、2項目目がアイコンの場所です。 # 最後の行は、行末に「,」を入れないでください。 %sche_icon = ( "01" => ['花束', 'img/news.gif'], "02" => ['クローバー', 'img/clover.gif'], "03" => ['ひまわり', 'img/himawari.gif'], "04" => ['菊', 'img/dazy.gif'], "05" => ['蝶', 'img/cyou.gif'], "06" => ['金魚', 'img/kingyo.gif'], "07" => ['子ねこ', 'img/neko.gif'], "08" => ['子ねこと花', 'img/neko_hana.gif'], "09" => ['アメショ', 'img/amesho.gif'], "10" => ['フテねこ', 'img/neko_fute.gif'], "11" => ['子ねこと毛糸', 'img/neko_keito.gif'], "12" => ['子ライオン', 'img/baby_lion.gif'], "13" => ['犬帽子', 'img/inu.gif'], "14" => ['ブルドッグ', 'img/bulldog.gif'], "15" => ['子犬', 'img/dog.gif'], "16" => ['象', 'img/zou.gif'], "17" => ['風船', 'img/fuusen.gif'], "18" => ['マスク', 'img/musk.gif'], "19" => ['龍_中国', 'img/chinies_dragon.gif'], "20" => ['ベル', 'img/bell.gif'], "21" => ['天使', 'img/tensi.gif'], "22" => ['飛行船', 'img/hikousen.gif'], "23" => ['ペガサス', 'img/pegasos.gif'], "24" => ['ヴァイオリン', 'img/violin.gif'], "25" => ['Violinとバラ', 'img/violin_rose.gif'], "26" => ['チェロ', 'img/cello.gif'], "27" => ['サックス', 'img/sax.gif'], "28" => ['サックス横', 'img/sax2.gif'], "29" => ['ホルン', 'img/horn.gif'], "30" => ['ギター', 'img/guitar.gif'], "31" => ['ピアノ', 'img/piano.gif'], "32" => ['アート', 'img/art.gif'], "33" => ['フルーツ', 'img/fruts.gif'], "34" => ['さくらんぼ', 'img/sakuranbo.gif'], "35" => ['収穫', 'img/syukaku.gif'], "36" => ['唐辛子', 'img/tougarashi.gif'], "37" => ['かぼちゃ', 'img/pumpkin.gif'], "38" => ['マスカット', 'img/muscat.gif'], "39" => ['葡萄', 'img/budou.gif'], "40" => ['ワイン', 'img/wine.gif'], "41" => ['コンパス', 'img/compus.gif'], "42" => ['ひよこ', 'img/hiyoko.gif'], "43" => ['おかめ', 'img/okame.gif'], "44" => ['鷹1', 'img/hawk.gif'], "45" => ['鷹2', 'img/hawk2.gif'], "46" => ['白鳥', 'img/swan.gif'], "47" => ['なし', 'img/c.gif'], "48" => ['桜', 'img/sakura.gif'] ); $k_icon = 'img/ktai.gif'; # 携帯からの投稿の専用アイコン(設定しないと画像なしになります) ### アイコンの画像一覧表示 ### # 画像一覧を表示させる場合は、HTMLファイルを作成してください。 # ポップアップウィンドウで見せることができます。 $iconDisp = 1; # 表示させる場合'1'、しない場合'0' $iconURL = 'icon.html'; # アイコン画像のURL $winWidth = 200; # ポップアップウィンドウの幅 $winHeight = 300; # ポップアップウィンドウの高さ ### 画像が設定されていない場合に表示する ### $noimg = 'img/c.gif'; # 旧バージョンからのログを移行する際に使用 ### タイトル一覧/検索窓の大きさ ### $winTWidth = 400; # 別窓の幅 $winTHeight = 500; # 別窓の高さ ### ログのファイル名 ### $logfilename = 'schedule2'; ### 戻り先のURL ### $return_text = '[仙台イベントTop]'; # 戻り先リンクをテキストにするときはその文字。 $return_gif = ''; # 戻り先リンクを画像にするときはファイル名。(文字が優先されます) $return_url = ''; # 戻り先のURLをhttp://から入力してください。 ### ヘルプ画面へのリンクアイコン ### $help_link = '1'; # リンクを表示させる場合は'1'、しない場合は'0' $help_gif = ''; # 上の項目が'1'のとき、画像のファイル名。画像にしない場合は''。 ### 管理者画面へのリンクアイコン ### $admin_link = '1'; # リンクを表示させる場合は'1'、しない場合は'0' $admin_gif = ''; # 上の項目が'1'のとき、画像のファイル名。画像にしない場合は''。 ### 管理者のパスワード(管理画面ログイン用) ### $admin_pass = '13488888'; # 英数字8文字以内 必ず設定してください。 ### 管理者のメール設定 ### $mailto = 'sendai@s-se.jp'; # メール送信する場合は、$mailtoにメールアドレスを入力してください。しない場合は、'' $sendmail = '/usr/sbin/sendmail'; # SENDMAILのパス 加入プロバイダに確認してください。 $subject = 'スケジュールへの投稿'; # メールの件名 ### Locationヘッダーが使用できるサーバーは1 できない場合は0 ### $location = 1; ### 祝日の設定 ### #祝日の変更があった場合は、日付を修正してください。(ハッピーマンデー制度対象の日、春分の日、秋分の日は入れないでください) #元日,建国記念日,昭和の日,憲法記念日,みどりの日,こどもの日,敬老の日,文化の日,勤労感謝の日,天皇誕生日 @holiday = ('0101','0211','0429','0503','0504','0505','0917','1008','1103','1123','1223'); #--- 設定終わり--- ############################################################# ############################################################# #--- Main --- use CGI; $pc = 1; @UA = ('DoCoMo','J-PHONE','UP\.Browser', 'SoftBank', 'Vodafone', 'DDIPOCKET', 'WILLCOM'); foreach $u(@UA) { if ($ENV{'HTTP_USER_AGENT'} =~ /$u/){ $pc = 0; } } $hostname = $ENV{'SERVER_NAME'}; $filename = $ENV{'SCRIPT_NAME'}; $updatefile = "update.cgi"; $res = 0; $oldno = 0; $help = ''; $ed = ''; $dl = 0; $list = 0; &readdata; if ($act eq 'month') { if ($pc) { &monthLog; } else { &kmonthLog; } exit; } elsif (($pc) and ($act eq 'year')) { &yearLog; exit; } &getDate; if ($action eq 'delete') { &deletelog; } elsif ($action eq 'write') { &writelog; } elsif ($action eq 'edwrite') { &edwrite; } elsif ($action eq 'res') { $res = 1; } elsif ($action eq 'mn') { $year = substr($ddate, 0, 4); $mon = substr($ddate, 4); &logname; &readlog; my @log = split(/,/, $loglist{$dno}); $lpass = $log[9]; if ($mn eq '' ) { &error("EditかDeleteを選択してください。"); } elsif ($dpass eq '' ) { &error("パスワードを入力してください。"); } elsif ((! &decipher($dpass, $lpass)) and ($mode ne 'admin')) { &error("パスワードが一致しません。"); } elsif ($lpass eq '') { &error("パスワードが一致しません。"); } if ($mn eq 'del') { &deletelog; } elsif ($mn eq 'edit') { if ($pc) { &editlog; } else { &keditlog; } } } elsif ($action eq 'list') { $list = 1; } if (($pc) and ($mode eq 'admin')) { $list = 1; &admin; exit; } elsif (($pc) and ($mode eq 'help')) { &help; exit; } elsif ($mode eq 'edit') { if ($pc) { &editform; } else { &keditform; } exit; } elsif (($pc) and ($mode eq 'today')) { $thisday = 1; } &logname; if ($pc) { &header; if (!$res) { &calendar; } if (($cdate ne "") or ($no ne "")) { &logname; &disp; } elsif ($res == 1) { &resinput; } elsif ($list == 1) { &disp; } elsif ($thisday == 1) { $cdate = sprintf("%04d%02d%02d", $orgyear, $orgmon, $orgday); &logname; &disp; } &footer; } else { if ($no ne "") { &getDate; &logname; &kheader; &kdisp; &kfooter; } elsif ($res == 1) { &kheader; &kresinput; &kfooter; } else { &kmonthLog; } } exit; #--- Get Date --- sub getDate { ($sec,$min,$hour,$mday,$month,$tyear,$wwday,$yday,$isdst) = localtime; $month = $month + 1; $tyear = $tyear + 1900; if ($year == "") { $year = $tyear; } if ($mon == "") { $mon = $month; } if ($day == "") { $day = $mday; } $date_now = sprintf("%04d年%d月%d日", $tyear, $month, $mday); $time_now = sprintf("%02d時%02d分", $hour, $min); $now2 = sprintf("%04d/%02d/%02d %02d:%02d", $tyear, $month, $mday,$hour, $min); @date = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); if(($year % 4) == 0 and ($year % 100) != 0 or ($year % 400) == 0) { $date[1] = 29; } @week = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); $tweek = @week[$wwday]; $today = $date_now."(".$tweek.") ".$time_now; $orgyear = $tyear; $orgmon = $month; $orgday = $mday; } #--- Read POST Data --- sub readdata { $q = new CGI; if (!$upfile && $q->cgi_error()) { &error("アップロードファイルのサイズが大きすぎます。"); } $buf = ""; if ($ENV{'REQUEST_METHOD'} eq "POST") { $submit = $q->param('submit'); $action = $q->param('action'); $act = $q->param('act'); $inyear = $q->param('inyear'); $inmon = $q->param('inmon'); $inday = $q->param('inday'); $tcolor = $q->param('tcolor'); $title = $q->param('title'); $name = $q->param('name'); $icon = $q->param('icon'); $email = $q->param('email'); $color = $q->param('color'); $comment = $q->param('comment'); $fname = $q->param('fname'); $width = $q->param('width'); $height = $q->param('height'); $upfile = $q->param('upfile'); $year = $q->param('year'); $mon = $q->param('mon'); $pass = $q->param('pass'); $apass = $q->param('apass'); $dpass = $q->param('dpass'); $dno = $q->param('dno'); $ddate = $q->param('ddate'); $ono = $q->param('ono'); $tmd = $q->param('tmd'); $mode = $q->param('mode'); $mn = $q->param('mn'); $mnno = $q->param('mnno'); $cookie = $q->param('cookie'); $title =~ s/,/,/g; $name =~ s/,/,/g; $comment =~ s/,/,/g; $comment =~ s/\x0D\x0A/
/g; $comment =~ s/\x0D/
/g; $comment =~ s/\x0A/
/g; if ($q->param('year') ne '') { $year = $q->param('year'); } if ($q->param('month') ne '') { $month = $q->param('month'); } } elsif ($ENV{'REQUEST_METHOD'} eq "GET") { $buf = $ENV{'QUERY_STRING'}; @pairs = split(/&/,$buf); foreach $pair (@pairs) { ($getname, $getvalue) = split(/=/, $pair); $getvalue =~ tr/+/ /; if ($getname eq 'cdate') { $year = substr($getvalue, 0, 4); $mon = substr($getvalue, 4, 2); $mon =~ s/^0+//; $day = substr($getvalue, 6, 2); $day =~ s/^0+//; } elsif ($getname eq 'no') { $year = substr($getvalue, 0, 4); $mon = substr($getvalue, 4, 2); $mon =~ s/^0+//; $day = substr($getvalue, 6, 2); $day =~ s/^0+//; $nno = substr($getvalue, 8); } $$getname = $getvalue; } $no = $q->param('no'); $cdate = $q->param('cdate'); $mode = $q->param('mode'); $apass = $q->param('apass'); $ddate = $q->param('ddate'); $page = $q->param('page'); $eno = $q->param('eno'); $act = $q->param('act'); if ($q->param('year') ne '') { $year = $q->param('year'); } if ($q->param('month') ne '') { $month = $q->param('month'); } if ($q->param('mon') ne '') { $mon = $q->param('mon'); } } if (($apass ne '') and ($action eq 'Login')) { $apass = &cipher($apass); } } #--- Header --- sub header { print "Content-type: text/html\n\n"; print "$ptitle-$mon月のイベント一覧-$mon月$day日$title$ctitle\n"; print "\n"; print "\n"; print "\n"; print "\n"; print <<"EOH";

BookMark
ブックマークに追加する
 


仙台イベント情報はリニューアルしました。→仙台イベント情報

EOH print "\n"; print "\n"; print "\n"; print ""; print "\n"; if (($mode eq 'admin') and ($apass eq '')) { $focus = ' onLoad="window.document.forms[0].apass.focus()"'; } else {$focus = '' } if ($bg_gif eq '' ) { print ""; } else { print ""; } print ""; if ($help eq '') { if ($return_text ne '') { } elsif ($return_gif ne '') { print "\"戻る\"\n"; } } else { print "[戻る]\n"; } print "
\n"; } #--- Header2 --- sub header2{ print "Content-type: text/html\n\n"; print "$ptitle\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; } sub kheader { print "Content-type: text/html\n\n"; jcode::z2h_sjis(\$ptitle); print <<"EOH"; $ptitle
$ptitle
EOH } #--- Footer --- sub footer { print "
\n"; if ($admin_link == 1) { if ($mode ne 'admin') { if ($admin_gif ne '') { print ""; } else { print ""; } print ""; } } print <
[Sponsored Link]
[Sponsored Link]

 
EOD print "\n"; } sub kfooter { print "\n"; print "\n"; } #--- Display Calendar --- sub calendar { $nyear = $year; $nmon = $mon; $thyear = $year; if ($title_img == 1) { print "\"$titleAlt\"

"; } print "\n"; print "\n"; if ($nmon == 1) { $lastmon = 12; $lastyear = $nyear - 1; } else { $lastmon = $nmon - 1; $lastyear = $nyear; } print "\n"; print "\n"; print "\n"; print "\n"; if ($nmon == 12) { $nextmon = 1; $nextyear = $nyear + 1; } else { $nextmon = $nmon + 1; $nextyear = $nyear; } print "\n"; print "\n"; if ($next_gif eq '') { print "\n"; print "
\n"; if ($last_gif eq '') { print " \n"; } else { print " \n"; } print " \n"; &ifadmin; print "\n"; print "年\n"; print "
 \n"; } else { print " \n"; } &ifadmin; print "
\n"; my $col = 0; my $row = 0; my $hol = 0; my $nexthol = 0; my ($wdd, $tmon, $x, $tday, $rows); my $twidth = $calWidth * 7; &readlog; &mhash; $wday = getwday($year, $mon, "01"); $ttday = $mday; if ((($mon == 1) or ($mon == 10)) and ($year >= 2000)) { $hday = sprintf("%02d%02d", $mon, &getHMD($year, $mon, 1, 2)); push (@holiday, $hday); } else { push (@holiday, '0115'); push (@holiday, '1010'); } if ((($mon == 7) or ($mon == 9)) and ($year >= 2003)) { $hday = sprintf("%02d%02d", $mon, &getHMD($year, $mon, 1, 3)); push (@holiday, $hday); } else { push (@holiday, '0720'); push (@holiday, '0915'); } $haru = sprintf("%02d%02d", 3, int(20.8431 + 0.242194 * ($year - 1980) - int(($year - 1980) / 4))); $aki = sprintf("%02d%02d", 9, int(23.2488 + 0.242194 * ($year - 1980) - int(($year - 1980) / 4 ))); push (@holiday, $haru); push (@holiday, $aki); if (-e $updatefile) { open(IN, "$updatefile") || &error("$updatefileをオープンできませんでした。"); $update = ; close(IN); } print ""; print "\n"; print ""; print "
"; if (($help_link == 1) and ($mode ne 'admin')) { if ($help_gif ne '') { } } if ($mode eq 'admin') { print "   "; } print "
\n"; print "
\n"; print "\n"; print "\n"; if ($start_monday == 0) { for ($w = 0; $w < 7; $w++) { print "\n" } } else { for $w(1,2,3,4,5,6,0) { print "\n" } } print "\n"; print "\n"; if ($start_monday == 0) { for ($d = 0; $d < $wday; $d++) { if ($day_gif eq '') { print "\n"; } else { print "\n"; } $col++; } } else { if ($wday != 0) { $wwday = $wday; } else { $wwday = 7; } for ($d = 1; $d < $wwday ; $d++) { if ($day_gif eq '') { print "\n"; } else { print "\n"; } $col++; } } $tmon = sprintf("%02d", $mon); @match = grep { /^$tmon/ } @holiday; @match = sort { $a <=> $b } @match; if ($start_monday == 0) { $_day = 7; $_day1 = 0; $_day2 = 6; } else { $_day = 6; $_day1 = 6; $_day2 = 5; } for ($wd = 1; $wd <= $date[$mon-1]; $wd++) { $rows = 0; $tday = sprintf("%02d", $wd); if ($#match >= 0) { for ($x = 0; $x < ($#match+1); $x++) { if ($tday eq substr($match[$x], 2, 2)) { if (($col % $_day) != 0) { $hol = 1; } else { $nexthol = 1; } shift @match; } } } $ww = sprintf("%04d%02d%02d", $year, $mon, $wd); if (($wd == $ttday) and ($mon == $month) and ($year == $tyear)) { $wdd = "$wd"; if ($hol == 1) { $hol = 0; } } elsif ((($col % 7) == $_day1) or ($hol == 1) or ($nexthol == 2)) { $wdd = "$wd"; $hol = 0; if ($nexthol == 2) { $nexthol = 0;} } elsif (($col % 7) == $_day2) { $wdd = "$wd"; } else { $wdd = "$wd"; } if ($nexthol == 1) { $nexthol++; } print "\n"; $col++; if ($col == 7) { print "\n"; $row++; $col = 0; } } if ($col != 0) { until ($col == 7) { if ($day_gif eq '') { print "\n"; } else { print "\n"; } $col++; } print "\n"; } print "
$week[$w]$week[$w]
 \"\" \"\"\n"; print ""; } else { print "d.html\">\n"; } print "$wdd\n"; @{$tmp{$ww}} = sort { $a <=> $b } @{$tmp{$ww}}; foreach $cc (@{$tmp{$ww}}) { @cdate = split(/,/, $loglist{$cc}); if ($cdate[1] == $cdate[2]) { if ($cdate[13] > @titlecolor) { $cdate[13] = 0; } if ($displayTitle) { $ctitle = "".substr($cdate[5], 0, $tTitle*2)." "; } else { $ctitle = "\"$cdate[5]\""; } print "
"; if ($newmark) { if ($mark_img){ if (&isNew($cdate[4])) { print "\"\""; } } } if ($mode eq 'admin') { print ""; } else { print ""; } print "$ctitle"; $rows++; } if ($rows == $nTitle) { last; } } print "
 \"\"
\n"; print "
\n"; if (($row == 4) || ($col == 0)){ print "\n"; for ($d = 0; $d < 7; $d++) { print "\n"; } print "
 
\n"; } if ($mode ne 'admin') { print "
"; print "\n"; print "\n"; print "
"; print "\n"; if (substr($mon, 0, 1) == 0) { $mon = substr($mon, 1, 1); } print "\n"; print "  \n"; print "  "; print "  
\n"; } print "\n"; } sub getwday { my($year, $mon, $mday) = @_; if ($mon == 1 or $mon == 2) { $year--; $mon += 12; } int($year + int($year / 4) - int($year / 100) + int($year / 400) + int((13 * $mon + 8) / 5) + $mday) % 7; } sub getHMD($$$$) { local ($year, $mon, $wday, $n) = @_; $wday1 = getwday($year, $mon, 1); $mday = 1 + ($wday - $wday1) % 7 + 7 * ($n - 1); } sub isNew { my($inputday) = @_; if ($inputday =~ /^([0-9][0-9][0-9][0-9])年([0-9]?[0-9])月([0-9]?[0-9])日.*分$/) { my $year = $1; my $mon = sprintf("%02d", $2); my $day = sprintf("%02d", $3); my $iday = $year.$mon.$day; my $ptime = 60 * 60 * 24 * $mark_days; my($ss, $mm, $hh, $d, $m, $y, $w, $yd, $is) = localtime(time - $ptime); my $fday = sprintf("%04d%02d%02d", $y + 1900, $m +1, $d); if ($iday >= $fday) { return 1; } else { return 0; } } } #--- Display Data --- sub disp { @tdata = (); if ($no ne '') { &mhash2; foreach $ll (@{$tmp2{$nno}}) { push (@tdata, $loglist{$ll}); } @tmp = map {(split /,/)[2]} @tdata; @tdata = @tdata[sort {$tmp[$a] <=> $tmp[$b]} 0 .. $#tmp]; } elsif ($cdate ne '') { foreach $ll (@{$tmp{$cdate}}) { push (@tdata, $loglist{$ll}); } @tmp = map {(split /,/)[1]} @tdata; @tdata = @tdata[sort {$tmp[$a] <=> $tmp[$b]} 0 .. $#tmp]; } elsif ($res) { &readlog; &mhash2; foreach $l (@{$tmp2{$ono}}) { push (@tdata, $loglist{$l}); } @tmp = map {(split /,/)[2]} @tdata; @tdata = @tdata[sort {$tmp[$a] <=> $tmp[$b]} 0 .. $#tmp]; } elsif ($list) { @tmp1 = @tmp2 = (); foreach (@log) { my ($one, $two, $three, $four) = split /,/; push(@tmp1, $one); push(@tmp2, $two); push(@tmp3, $three); } @tdata = @log[sort {$tmp1[$a] cmp $tmp1[$b] or $tmp2[$a] <=> $tmp2[$b] or $tmp3[$a] <=> $tmp3[$b]} 0 .. $#tmp1]; } if ($nolog == 0) { if ($#tdata < 0 ) { print $day."日の\予\定はありません。

\n"; } else { foreach $xx (@tdata) { ($tmd,$tcno,$tno,$tday,$ttoday,$ttitle,$tname,$temail,$tcomment,$tpass,$taddr,$thost,$ticon,$ttcolor,$tfname,$twidth,$theight,$tdum) = split(/,/, $xx); $tcom = &linkUrl($tcomment); if (($oldno != 0) and ($oldno != $tcno)) { print "
\n"; print "\n"; if (!$res) { print "
\n"; if ($top_gif eq '') { print "\n"; } else { print "\"TOPへ\"

\n"; } print "
\n"; } $oldno = 0; } if ($tno == $tcno) { print "\n"; print "\n"; print "
\n"; print "\n"; print "
\n"; print "\n"; } else { print "\n"; } $oldno = $tcno; } print "
\n"; print "\n"; } else { print "$tname\n"; } if ((!$res) and ($tcno == $tno) and ($action ne 'dl')) { if ($mode eq 'admin') { print "\n"; print "
\n"; print "$tday  $ttitle   \n"; if ($temail ne "") { print "$tname
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; &ifadmin; } if (($res_mode) and ($mode ne 'admin')) { print "
\n"; print "\n"; print "\n"; print "\n"; if ($res_gif ne '') { print "\n"; print "\n"; } else { print "\n"; print "\n"; } } } print "

\n"; print "\n"; print "
"; if ($ticon) { print ""; } else { print ""; } print ""; chomp($tfname); if ((-e $tfname) and ($tfname ne '')) { if (($twidth > $w_imgsize) and ($theight < $h_imgsize)) { $ww = $w_imgsize; $hh = $theight * ($w_imgsize / $twidth); } elsif(($twidth < $w_imgsize) and ($theight > $h_imgsize)) { $ww = $twidth * ($h_imgsize / $theight); $hh = $h_imgsize; } elsif(($twidth > $w_imgsize) and ($theight > $h_imgsize)) { $ww = $w_imgsize; $hh = $theight * ($w_imgsize / $twidth); } else { $ww = $twidth; $hh = $theight; } if (($tfname > $w_imgsize) or ($twidth > $h_imgsize)) { print ""; } print "\"\""; if (($twidth > $w_imgsize) or ($theight > $h_imgsize)) { print "\n"; } } print "$tcom\n"; print "

$ttoday No.$tno\n"; if ($mode eq 'admin') { print "$taddr  $thost\n"; } print "
\n"; print "\n"; print "
 \n"; print "\n"; } if (($mode eq 'admin') and ($action ne 'dl')) { print "\n"; } print "
\n"; print "
$ttitle   \n"; if ($temail ne "") { print "$tname\n"; } else { print "$tname
\n"; print "\n"; print "\n"; print "\n"; print "\n"; &ifadmin; print "

\n"; print "
\n"; print "
"; if ($ticon) { print ""; } else { print ""; } print "\n"; print "$tcom\n"; print "

$ttoday No.$tno\n"; if ($mode eq 'admin') { print "
$taddr  $thost\n"; } if ($mode ne 'admin') { if ($edit_gif ne '') { print " "; } elsif ($edit_text ne '') { print " $edit_text"; } else { print " edit"; } } print "
\n"; print "
\n"; print "
\n"; if (!$res) { print "
\n"; if ($top_gif eq '') { print "\n"; } else { print "\"TOPへ\"

\n"; } print "
\n"; } } } else { if ($list) { print $year."年".$mon."月の\予\定はありません。

\n"; } else { print $day."日の\予\定はありません。

\n"; } } } sub kdisp { &readlog; if ($no ne '') { &mhash2; foreach $ll (@{$tmp2{$nno}}) { push (@tdata, $loglist{$ll}); } @tmp = map {(split /,/)[2]} @tdata; @tdata = @tdata[sort {$tmp[$a] <=> $tmp[$b]} 0 .. $#tmp]; } if ($nolog == 0) { if ($#tdata < 0 ) { print $day."日の予\定はありません。

\n"; } else { foreach $xx (@tdata) { ($tmd,$tcno,$tno,$tday,$ttoday,$ttitle,$tname,$temail,$tcomment,$tpass,$taddr,$thost,$ticon,$ttcolor,$tfname,$twidth,$theight,$tdum) = split(/,/, $xx); $tcom = &linkUrl($tcomment); if (($oldno != 0) and ($oldno != $tcno)) { print "
\n"; if (!$res) { print "
\n"; } $oldno = 0; } jcode::z2h_sjis(\$ttitle); jcode::z2h_sjis(\$tname); jcode::z2h_sjis(\$tcom); if ($tno == $tcno) { print "$year年$tday
Title:$ttitle
\n"; if ($temail ne "") { print "$tname
\n"; } else { print "Name:$tname
\n"; } print "$tcom\n"; if (-e $tfname) { my $size = int ((-s $tfname) / 1000); print "
画像(".$size."KB)\n"; } print "

$ttoday No.$tno\n"; if ($res_mode) { print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
\n"; } } else { print "

Title:$ttitle
\n"; if ($temail ne "") { print "$tname\n"; } else { print "Name:$tname\n"; } print "
\n"; print "$tcom\n"; print "

$ttoday No.$tno\n"; print " edit\n"; } $oldno = $tcno; } print "
\n"; if (!$res) { print "
$year年$mon月に戻る
\n"; } } } else { if ($list) { print $year."年".$mon."月の予\定はありません。

\n"; } else { print $day."日の予\定はありません。

\n"; } } } #--- Input Area --- sub input { &getCookie; print "
\n"; print "\n"; print "
\n"; print "\n"; if (!$res) { print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if (!$res) { print "\n"; print "\n"; } if ($mode ne 'admin') { print "\n"; } print "\n"; print "
Date:\n"; print "年\n"; print "月\n"; print "日\n"; print "
Title Color:\n"; for ($ttc = 0; $ttc < @titlecolor; $ttc++) { print " \n"; } print "
Title:
Name:
Email:
Icon:\n"; print ""; if ($iconDisp == 1) { print "    アイコン\n"; } print "
Text Color:\n"; for ($tc = 0; $tc < @textcolor; $tc++) { print " \n"; } print "
Comment:
(タグは不可)
Image:
Key:\n"; print "(英数字8文字以内)
Cookie:
\n"; print "    \n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; &ifadmin; if ($res) { $inmon = substr($tmd,4,2); print "\n"; print "\n"; print "\n"; &ifadmin; } print "
\n"; } sub ifadmin { if ($mode eq 'admin') { print "\n"; print "\n"; } } sub kinput { $max_year = $orgyear + $max_year + 1; print "
\n"; if (!$res) { print "Date:
"; print "年\n"; print "月\n"; print "
\n"; } print "Title Color:
\n"; for ($ttc = 0; $ttc < @titlecolor; $ttc++) { print " \n"; } print "
\n"; print "Title:
\n"; print "Name:
\n"; print "Email:
\n"; print "Text Color:
\n"; for ($tc = 0; $tc < @textcolor; $tc++) { print " \n"; } print "
\n"; print "Comment:"; print "
\n"; print "Key:
\n"; print "    \n"; print "\n"; print "\n"; print "\n"; if ($res) { $inmon = substr($tmd,4,2); print "\n"; print "\n"; print "\n"; &ifadmin; } print "

\n"; print "今月に戻る
\n"; } #--- Res Input --- sub resinput { print "$title「$title」への返信

\n"; print "
"; if ($write_gif eq'' ) { print "書き込み"; } else { print "\"書き込みフォームへ\""; } print "
\n"; $year = substr($tmd, 0, 4); $mon = substr($tmd, 4, 2); $mon =~ s/^0+//; &logname; &disp; &input; } sub kresinput { print "「$title」への返信

\n"; $year = substr($tmd, 0, 4); $mon = substr($tmd, 4, 2); $mon =~ s/^0+//; &kinput; } #--- Check Data --- sub checkData { if ($title eq "") { &error('タイトルを記入してください。'); } else { jcode::h2z_sjis(\$title); } if ($name eq "") { &error('名前を記入してください。'); } else { jcode::h2z_sjis(\$name); } if ($comment eq "") { &error('コメントを記入してください。'); } else { jcode::h2z_sjis(\$comment); } if ($email ne "") { $email = &zen2han($email); } if ($pass ne "") { $pass = &zen2han($pass); } } #--- Logfile name --- sub logname { $mmm = $mon; if ($mon < 10 ) { $mmm = sprintf("%02d", $mon); } $logfile = $logdir."/schedule_".$year.$mmm.".cgi"; } #--- Read Logfile --- sub readlog { my $hh; $nolog = 0; %loglist = (); %loglist2 = (); %loglist3 = (); if (-e $logfile) { open(IN, "$logfile") || &error("ログファイル:$logfileをオープンできませんでした。"); @log = ; close(IN); foreach $hh (@log) { ($hmd,$hcno,$hno,$hday,$htoday,$htitle,$hname,$hemail,$hcomment,$hpass,$haddr,$hhos,$hicon,$htcolor,$hfname,$hwidth,$hheight,$hdumt) = split(/,/, $hh); $loglist{$hno} = $hh; $loglist2{$hno} = $hmd; $loglist3{$hno} = $hcno; } } else { $nolog = 1; } } #--- Make Hash --- sub mhash { while (($lno, $lday) = each(%loglist2)) { push (@{$tmp{$lday}}, $lno); } } sub mhash2 { while (($lno, $lcno) = each(%loglist3)) { push (@{$tmp2{$lcno}}, $lno); } } #--- Write Logfile --- sub writelog { ### イメージ読み込み if ($upfile ne '') { if (!$upfile && $q->cgi_error()) { &error('ファイルサイズが大きすぎます。'); } $mime = $q->uploadInfo($q->param('upfile'))->{'Content-Type'}; if (($mime ne 'image/gif') and ($mime ne 'image/jpeg') and ($mime ne 'image/pjpeg')) { &error('このファイルはアップロードできません。
(jpgまたはgif以外は不可)'); } while($bytesread = read($upfile, $buffer, $ENV{'CONTENT_LENGTH'})){ $file .= $buffer; } if ($upfile =~ /(.*)\.(.*)$/) { $ext = $2; } $timestamp = time(); $fname = $imgDir."/".$timestamp.".".$ext; open(OUT,"> $fname"); binmode(OUT); binmode(STDOUT); print OUT $file; close(OUT); chmod (0666,$fname); ($width, $height) = &get_imagesize($fname); } if ($tmd eq '') { $day = $inday; $mon = $inmon; $year = $inyear; } &logname; &checkData; $comment = "$comment"; $addr = $ENV{'REMOTE_ADDR'}; $host = $ENV{'REMOTE_HOST'}; if ($host eq "" || $host eq $addr) { $host = gethostbyaddr(pack("C4", split(/\./, $addr)), 2) || $addr; } $SIG{'PIPE'} = $SIG{'INT'} = $SIG{'HUP'} = $SIG{'QUIT'} = $SIG{'TERM'} = "sigexit"; &filelock; &readlog; $lastno = @log; if ($lastno < 1) { $no = 1; } else { ($llmd,$llcno,$llno,$tmp) = split(/,/, $log[0]); $no = $llno; $no++; } if ($pass ne "") { $pass = &cipher($pass); } if ($ono > 0) { $cno = $ono; ($rmd,$rcno,$rno,$rday,$rtoday,$rtitle,$rname,$remail,$rcomment,$rpass,$raddr,$rhost,$ricon,$rtcolor,$rfname,$rwidth,$rheight,$rdum) = split(/,/, $loglist{$ono}); $inputday = $rday; $yyyymmdd = $tmd; $inday = substr($tmd, 6, 2); $inday =~ s/^0+//; } else { $cno = $no; $inputday = sprintf("%d月%d日", $inmon, $inday); $yyyymmdd = sprintf("%04d%02d%02d", $inyear, $inmon, $inday); } if (!$pc) { $icon = $k_icon; } $height =~ s/\s*$//; $height =~ s/<<>>.*$//; $sdata = "$yyyymmdd,$cno,$no,$inputday,$today,$title,$name,$email,$comment,$pass,$addr,$host,$icon,$tcolor,$fname,$width,$height,$dum\n"; unshift (@log, $sdata); open(LOG, "> $logfile") || &error("ログファイル:$logfileをオープンできませんでした。"); print LOG @log; close(LOG); open(UP, "> $updatefile") || &error("ログファイル:$updatefileをオープンできませんでした。"); print UP $now2; close(UP); rmdir($flock); $mailfrom = $email; if ($mailto ne '') { &sendMail($mailfrom, $mailto, $subject); } if ($pc) { if ($cookie eq 'on') { &setCookie; } else { &clearCookie; } $cd = sprintf("%04d%02d%02d", $year, $mon, $inday); if ($mode ne 'admin') { jump("http://$hostname$filename?no=$cd$ono#disp"); } else { jump("http://$hostname$filename?cdate=$cd&mode=admin&apass=$apass"); } } else { jump("http://$hostname$filename?no=$yyyymmdd$cno"); } } #--- Editform --- sub editform { &getCookie; &header; print "

記事の編集・削除

\n"; print "
\n"; print "No:$eno
\n"; print "  \n"; print "
\n"; print "Key:\n"; print "

\n"; print "

\n"; print "
\n"; &footer; } sub keditform { &kheader; print "

記事の編集・削除

\n"; print "
\n"; print "No:$eno
\n"; print "Edit  \n"; print "Delete
\n"; print "Key:\n"; print "

\n"; print "

\n"; print "
\n"; &kfooter; } #--- Edit Log --- sub editlog { $dpass = &zen2han($dpass); $dno = &zen2han($dno); $year = substr($ddate, 0, 4); $mon = substr($ddate, 4); &logname; &readlog; my @log = split(/,/, $loglist{$dno}); $lpass = $log[9]; if ($dno eq '' ) { &error("記事番号を入力してください。"); } if ((! &decipher($dpass, $lpass)) and ($mode ne 'admin')) { &error("パスワードが一致しません。"); } else { &header; print "

$log[3] $log[5]の編集
\n"; print "
\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; $log[8] =~ s/<(f|F)(o|O)(n|N)(t|T) *([^>]*)>//; $log[8] =~ s|||; $log[8] =~ s/<(a|A) *([^>]*)>//g; $log[8] =~ s|||g; $log[8] =~ s/
/\n/ig; $log[14] =~ s/\n//g; print "\n"; if ($log[1] == $log[2]) { print "\n"; print "\n"; print "\n"; } print "
Title Color:\n"; for ($ttc = 0; $ttc < @titlecolor; $ttc++) { print " \n"; } print "
Title:
Name:
Email:
Icon:\n"; print ""; print "
Color:\n"; $st = substr($log[8], 13, 7); for ($tc = 0; $tc < @textcolor; $tc++) { print " \n"; } print "
Comment:
(タグは不可)
Image:
 ※画像をアップロードすると現在の画像と置き換わります。
(追加ではありません)
\n"; print "    \n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; &ifadmin; print "
\n"; &footer; exit; } } sub keditlog { $dno = &zen2han($dno); $year = substr($ddate, 0, 4); $mon = substr($ddate, 4); &logname; &readlog; my @log = split(/,/, $loglist{$dno}); &kheader; print "

$log[3] $log[5]の編集
\n"; print "\n"; print "Title Color:
\n"; for ($ttc = 0; $ttc < @titlecolor; $ttc++) { print "\n"; } print "
Title:

\n"; print "Name:

\n"; print "Email:

\n"; print "Color:
\n"; $st = substr($log[8], 13, 7); for ($tc = 0; $tc < @textcolor; $tc++) { print "\n"; } print "
Comment:(タグは不可)
\n"; $log[8] =~ s/<(f|F)(o|O)(n|N)(t|T) *([^>]*)>//; $log[8] =~ s|||; $log[8] =~ s/<(a|A) *([^>]*)>//g; $log[8] =~ s|||g; $log[8] =~ s/
/\n/ig; print "
\n"; print "
\n"; print "    \n"; print "\n"; print "\n"; print "\n"; print "\n"; &kfooter; exit; } #---Edit --- sub edwrite { ### イメージ読み込み if ($upfile ne '') { if (!$upfile && $q->cgi_error()) { &error('ファイルサイズが大きすぎます。'); } $mime = $q->uploadInfo($upfile)->{'Content-Type'}; if (($mime ne 'image/gif') and ($mime ne 'image/jpeg') and ($mime ne 'image/pjpeg')) { &error('このファイルはアップロードできません。
(jpgまたはgif以外は不可)'); } while($bytesread = read($upfile, $buffer, $ENV{'CONTENT_LENGTH'})){ $file .= $buffer; } if ($upfile =~ /(.*)\.(.*)$/) { $ext = $2; } $timestamp = time(); $fname = $imgDir."/".$timestamp.".".$ext; open(OUT,"> $fname"); binmode(OUT); binmode(STDOUT); print OUT $file; close(OUT); chmod (0666,$fname); ($width, $height) = &get_imagesize($fname); } &checkData; $addr = $ENV{'REMOTE_ADDR'}; $host = $ENV{'REMOTE_HOST'}; if ($host eq "" || $host eq $addr) { $host = gethostbyaddr(pack("C4", split(/\./, $addr)), 2) || $addr; } $comment = &linkUrl($comment); $comment = "$comment"; &logname; &readlog; my @log = split(/,/, $loglist{$dno}); &getDate; if (!$pc) { $icon = $k_icon; } my $sdata = "$log[0],$log[1],$log[2],$log[3],$today,$title,$name,$email,$comment,$log[9],$addr,$host,$icon,$tcolor,$fname,$width,$height,$dum\n"; $SIG{'PIPE'} = $SIG{'INT'} = $SIG{'HUP'} = $SIG{'QUIT'} = $SIG{'TERM'} = "sigexit"; &filelock; $loglist{$dno} = $sdata; open(LOG, "> $logfile") || &error("ログファイル:$logfileをオープンできませんでした。"); foreach $lk (reverse sort { $a <=> $b } keys %loglist) { print LOG $loglist{$lk}; } close(LOG); open(UP, "> $updatefile") || &error("ログファイル:$updatefileをオープンできませんでした。"); print UP $now2; close(UP); rmdir($flock); $mailfrom = $email; $ed = 'on'; if ($mailto ne '') { &sendMail($mailfrom, $mailto, $subject, $log[3]); } if ($pc) { if ($mode ne 'admin') { jump("http://$hostname$filename?cdate=$log[0]"); } else { jump("http://$hostname$filename?cdate=$log[0]&mode=admin&apass=$apass"); } } else { jump("http://$hostname$filename?no=$log[0]$log[1]"); } } #--- Delete Logfile --- sub deletelog { $dpass = &zen2han($dpass); $dno = &zen2han($dno); $year = substr($ddate, 0, 4); $mon = substr($ddate, 4); &logname; &readlog; $SIG{'PIPE'} = $SIG{'INT'} = $SIG{'HUP'} = $SIG{'QUIT'} = $SIG{'TERM'} = "sigexit"; &filelock; my @ddata = split(/,/, $loglist{$dno}); $lpass = $ddata[9]; if ($dno eq '' ) { &error("記事番号を入力してください。"); } if ((! &decipher($dpass, $lpass)) and ($mode ne 'admin')) { &error("パスワードが一致しません。"); } else { if ($ddata[1] != $ddata[2]) { delete $loglist{$dno}; } else { &mhash2; foreach $dd (@{$tmp2{$dno}}) { delete $loglist{$dd}; } } if (-e $ddata[14]) { unlink($ddata[14]); } $nno = keys(%loglist); open(LOG, "> $logfile") || &error("ログファイル:$logfileをオープンできませんでした。"); foreach $lk (reverse sort { $a <=> $b } keys %loglist) { print LOG $loglist{$lk}; } close(LOG); rmdir($flock); } if (($pc) and ($mode ne 'admin')) { jump("http://$hostname$filename?cdate=$ddata[0]"); } } #--- Month log --- sub monthLog { my $mlog; &header2; if ($month eq '') { &getDate; } print "|| $year年$month月 ||

\n"; print "タイトルをクリックしてください。
親ウィンドウに表\示されます

\n"; $mon = $month; &logname; &readlog; print "\n"; if ($#log < 0) { print "\n"; } else { @log = sort(@log); foreach $mlog (@log) { if ($mlog =~ /^\n$/) { next; } ($mmd,$mcno,$mno,$mday,$mtoday,$mtitle,$mname,$memail,$mcomment,$mpass,$maddr,$mhos,$micon,$mcolor,$mfname,$mwidth,$mheight,$mdumt) = split(/,/, $mlog); if ($mcno != $mno) { next; } $mdate = $mmd; print "\n"; } } print "\n"; print "
$month月はありません。

\n"; print "$mday  $mtitle
\n"; print "


\n"; $nextm = $month + 1; $nexty = $year; if ($nextm == 13) { $nextm = 1; $nexty++;} $backm = $month - 1; $backy = $year; if ($backm == 0) { $backm = 12; $backy--; } print "  \n"; print "\n"; print "
\n"; print "
\n"; print "  \n"; print "


\n"; print "\n"; #↓消さないでね。 print "
\n"; print "Copyright (C) HELLO!
\n"; print "\n"; } sub kmonthLog { my $mlog; &kheader; if ($month eq '') { &getDate; } my ($ttsec,$ttmin,$tthour,$ttmday,$ttmonth,$ttyear,$ttwwday,$ttyday,$ttisdst) = localtime; my $orgyear = $ttyear + 1900; my $ttmonth = $ttmonth + 1; print "今月に戻る

"; print "\n"; $max_year = $orgyear + $max_year + 1; print "年\n"; print "月\n"; print ""; print "\n"; print "

\n"; $mon = $month; &logname; &readlog; if ($#log < 0) { print "$month月の予\定はありません。

\n"; } else { @log = sort(@log); foreach $mlog (@log) { if ($mlog =~ /^\n$/) { next; } ($mmd,$mcno,$mno,$mday,$mtoday,$mtitle,$mname,$memail,$mcomment,$mpass,$maddr,$mhos,$micon,$mcolor,$mfname,$mwidth,$mheight,$mdumt) = split(/,/, $mlog); if ($mcno != $mno) { next; } $mdate = $mmd; jcode::z2h_sjis(\$mtitle); print "$mday  $mtitle
\n"; } } print "

\n"; &kfooter; } #--- year log --- sub yearLog { &header2; @files = (); opendir(DIR, "./".$logdir); while ($file = readdir(DIR)) { if (($file =~ /schedule_\d{4}/) and (!-z "./".$logdir."/".$file)) { push(@files, $file); } } closedir(DIR); @files = sort(@files); if ($month == '') { print "|| 年別一覧 ||

\n"; print "年を選択して下さい

\n"; } else { print "|| $year年一覧 ||

\n"; } print "\n"; if ($#files < 0) { print "\n"; } else { if ($month != '') { foreach $yfile (@files) { $yfile =~ s/schedule_//; $yfile =~ s/\.cgi//; $fyear = substr($yfile, 0, 4); $month = substr($yfile, 4, 2); $month = sprintf("%d", $month); if ($fyear == $year) { print "\n"; } } } else { foreach $yfile (@files) { $yfile =~ s/schedule_//; $yfile =~ s/\.cgi//; $year = substr($yfile, 0, 4); push(@logyear, $year); } %tmp; @logyear = grep(!$tmp{$_}++, @logyear); foreach $yy (@logyear) { print "\n"; } } } print "\n"; print "
データがありません。

\n"; print "$year年$month月    "; print "タイトル一覧
\n"; print "
\n"; print "$yy年  "; print "
\n"; print "
\n"; print "  \n"; print "


\n"; print "\n"; #↓消さないでね。 print "
\n"; print "Copyright (C) HELLO!
\n"; print "\n"; } #--- Admin Mode --- sub admin { if ($apass eq '') { &header; print "
"; print "



管理者画面です。

パスワードを入力してください。"; print "
\n"; print "

\n"; print "\n"; print "\n"; print "\n"; print "
\n"; } else { if (! &decipher($admin_pass, $apass)) { &error("

パスワードが違います。"); } else { if ($action eq 'delete') { &deletelog; } elsif ($mn eq 'edit') { &editlog; } elsif ($action eq 'dl') { $dl = 1; &logname; if (! -e $logfile) { &error("$year年$mon月のログはありません。"); } &readlog; foreach (@log) { my ($one, $two, $three, $four) = split /,/; push(@tmp1, $one); push(@tmp2, $two); push(@tmp3, $three); } @tdata = @log[sort {$tmp1[$a] cmp $tmp1[$b] or $tmp2[$a] <=> $tmp2[$b] or $tmp3[$a] <=> $tmp3[$b]} 0 .. $#tmp1]; if ($#tdata >= 0 ) { $dlfilename = $logfile; $dlfilename =~ s/.cgi/.html/; print "Content-Disposition: attachment;filename=\"$dlfilename\"\n"; print "Content-type: application/x-html\n\n"; print "$ptitle\n"; print "\n"; print "\n"; print "\n"; print "\n"; if ($bg_gif eq '' ) { print ""; } else { print ""; } print "
\n"; print "$year年$mon月

\n"; &disp; &footer; exit; } else { &error("$year年$mon月のログはありません。"); } } elsif ($action eq 'creIcon') { if ($iconURL eq '') { $iconURL = 'icon.html' } $iconfile = "アイコン"; $iconfile .= "\n"; $iconfile .= "
\n"; $iconfile .= "\n"; for $ic (sort keys %sche_icon){ $iconfile .= "\n"; } $iconfile .= "
${$sche_icon{$ic}}[0]\"${$sche_icon{$ic}}[0]\"
\n"; $iconfile .= ""; open(ICON, "> $iconURL") || &error("ファイル:$iconURLをオープンできませんでした。"); print ICON $iconfile; close(ICON); } &header; &zen2han($pass); &getDate; &logname; &readlog; print "\n"; print "\n"; print "
管理画面の終了
\n"; print "管理者画面

\n"; &calendar; @tmp1 = @tmp2 = (); foreach (@log) { my ($one, $two, $three, $four) = split /,/; push(@tmp1, $one); push(@tmp2, $two); push(@tmp3, $three); } @tdata = @log[sort {$tmp1[$a] cmp $tmp1[$b] or $tmp2[$a] <=> $tmp2[$b] or $tmp3[$a] <=> $tmp3[$b]} 0 .. $#tmp1]; if ($#tdata < 0 ) { print "$year年$mon月の\予\定はありません。

\n"; } else { print "
記事を削除するときは、該当する記事の ボタンを押してください。
\n"; if ($res_mode) { print "親記事を削除するとそれに対する返信もすべて削除されます。\n"; } print "


\n"; print "
\n"; &disp; } &input; print "

\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\表\示中の年月のログファイルをダウンロードします。\n"; print "
"; print "(アイコン・画像はダウンロードされません。)

\n"; print "
\n"; print "アイコンHTMLを作成
\n"; print "すでにファイルが存在する場合には、置き換えられます。\n"; print "\n"; print "\n"; print "\n"; print "
\n"; } } &footer; exit; } #--- Help Screen --- sub help { $help = 'on'; &header; print "使い方

\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
スケジュールを見る
 ◆ 日付をクリックすると、その日のスケジュールの一覧が\表\示されます。
 ◆ タイトルをクリックすると、そのスケジュールだけが\表\示されます。
 ◆ セレクトボックスで見たい年月を選ぶと、その年月のカレンダーを表示します。
 ◆ "; if ($last_gif eq '') { print "\n"; } else { print "\n"; } print " 1ヶ月前に戻ります。
 ◆ "; if ($this_gif eq '') { print "\n"; } else { print "\n"; } print " 今月に戻ります。
 ◆ "; if ($next_gif eq '') { print "\n"; } else { print "\n"; } print " 1ヶ月先に進みます。
 ◆ "; if ($top_gif eq '') { print "↑TOP\n"; } else { print "\n"; } print " ページトップへジャンプします。
  表\示月のスケジュール一覧が表\示されます。
  別ウィンドウにタイトル一覧が表\示されます。
  検索ウィンドウが開きます。
   名前・タイトル・コメントから検索されます。
  今月に戻ります。
 ◆ カレンダー部分のスケジュールは1日につき最大$nTitle件まで\表\示されます。


\n"; if ($res_mode) { print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
返信を書き込む
 ◆ "; if ($res_gif ne '') { print "\n"; } else { print "\n"; } print " をクリックすると、その記事に対する返信を書き込むことができます。
 ◆ タイトル、名前、コメントを入力しないと書き込みできません。
 ◆ Keyをセットすれば、自分の投稿記事を削除したり編集することができます。
 ◆ Cookieをチェックすると、名前とメールアドレスとアイコンと文字色を記憶することができます。


\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "
自分の書いた記事を削除/編集する
 ◆ 記事の右下にある "; if ($edit_gif ne '') { print "\n"; } else { print "「edit」"; } print " を押してください。
   次の画面で編集か削除を選びキーを入力して下さい。
 ◆ キーが一致すると、削除/編集することができます。
   もし削除できない場合は、管理者に削除依頼を出してください。
 ◆ キーがわからない場合は、削除/編集できません。


\n"; } &footer; exit; } #--- File Lock --- sub filelock { foreach $i ( 1, 2, 3, 4, 5, 6 ) { if (mkdir("$flock", 0755)) { last; } elsif ($i == 1) { ($mtime) = (stat($flock))[9]; if ($mtime < time() - 600) { rmdir($flock); } } elsif ($i < 6) { sleep(1); } else { &error("他の人が書き込み中です。もう一度やり直してください。"); } } } sub sigexit { rmdir($flock); exit(0); } #--- send mail --- sub sendMail($$$$) { local ($mailfrom, $mailto, $subject, $edate) = @_; jcode::convert(\$subject, 'jis'); $comment =~ s/<(f|F)(o|O)(n|N)(t|T) *([^>]*)>//g; $comment =~ s|||g; $comment =~ s|
|\n|g; $comment =~ s/&/&/g; $comment =~ s/<//g; $comment =~ s/>/>/g; $comment =~ s/"/"/g; #" $body = ""; if ($ed eq 'on') { $body .= $ptitle."が編集されました。\n\n"; } else { $body .= $ptitle."に投稿がありました。\n\n"; } $body .= "[投稿日]   ".$today."\n"; if ($ed eq 'on') { $body .= "[Date]    ".$year."年".$edate."\n"; } else { $body .= "[Date]    ".$year."年".$inmon."月".$inday."日\n"; } $body .= "[タイトル]  ".$title."\n"; $body .= "[名前]    ".$name."\n"; $body .= "[E-Mail]   ".$email."\n"; $body .= "[コメント]  \n".$comment."\n"; $body .= "[IPアドレス] ".$addr."\n"; $body .= "[ホスト名]  ".$host."\n"; jcode::convert(\$body, 'jis'); open(SENDMAIL, "|$sendmail -t -oi") || &error("メール送信に失敗しました。"); print SENDMAIL "To: $mailto\n"; print SENDMAIL "From: $mailfrom\n"; print SENDMAIL "Subject: $subject\n\n"; print SENDMAIL "$body\n"; close(SENDMAIL); } #--- URL LINK --- sub linkUrl() { local ($str) = @_; my $http_URL_regex = qq{s?https?://[-_.!~*'()a-zA-Z0-9;/?:@&=+$,%#]+}; my $tag_regex_ = q{[^"'<>]*(?:"[^"]*"[^"'<>]*|'[^']*'[^"'<>]*)*(?:>|(?=<)|$(?!\n))}; #'}}}} my $comment_tag_regex = '-]*(?:-[^>-]+)*?)??)*(?:>|$(?!\n)|--.*$)'; my $tag_regex = qq{$comment_tag_regex|<$tag_regex_}; my $text_regex = q{[^<]*}; $ftp_URL_regex = q{\bftp://(?:(?:[-_.!~*'()a-zA-Z0-9;&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*} . q{(?::(?:[-_.!~*'()a-zA-Z0-9;&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)?@)?(?} . q{:(?:[a-zA-Z0-9](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?\.)*[a-zA-Z](?:[-a-zA-} . q{Z0-9]*[a-zA-Z0-9])?\.?|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)(?::[0-9]*)?} . q{(?:/(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*(?:/(?} . q{:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])*)*(?:;type=[} . q{AIDaid])?)?(?:\?(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9} . q{A-Fa-f])*)?(?:#(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9A} . q{-Fa-f])*)?}; $mail_regex = q{(?:[^(\040)<>@,;:".\\\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\\} . q{\[\]\000-\037\x80-\xff])|"[^\\\\\x80-\xff\n\015"]*(?:\\\\[^\x80-\xff][} . q{^\\\\\x80-\xff\n\015"]*)*")(?:\.(?:[^(\040)<>@,;:".\\\\\[\]\000-\037\x} . q{80-\xff]+(?![^(\040)<>@,;:".\\\\\[\]\000-\037\x80-\xff])|"[^\\\\\x80-} . q{\xff\n\015"]*(?:\\\\[^\x80-\xff][^\\\\\x80-\xff\n\015"]*)*"))*@(?:[^(} . q{\040)<>@,;:".\\\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\\\[\]\0} . q{00-\037\x80-\xff])|\[(?:[^\\\\\x80-\xff\n\015\[\]]|\\\\[^\x80-\xff])*} . q{\])(?:\.(?:[^(\040)<>@,;:".\\\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,} . q{;:".\\\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\\\x80-\xff\n\015\[\]]|\\\\[} . q{^\x80-\xff])*\]))*}; &jcode'convert(*str,'euc'); $result = ''; $skip = 0; while ($str =~ /($text_regex)($tag_regex)?/gso) { last if $1 eq '' and $2 eq ''; $text_tmp = $1; $tag_tmp = $2; if ($skip) { $result .= $text_tmp . $tag_tmp; $skip = 0 if $tag_tmp =~ /^<\/[aA](?![0-9A-Za-z])/; } else { $text_tmp =~ s{($http_URL_regex|$ftp_URL_regex|($mail_regex))} {my($org, $mail) = ($1, $2); (my $tmp = $org) =~ s/"/"/g; '$org"}ego; $result .= $text_tmp . $tag_tmp; $skip = 1 if $tag_tmp =~ /^<[aA](?![0-9A-Za-z])/; if ($tag_tmp =~ /^<(XMP|PLAINTEXT|SCRIPT)(?![0-9A-Za-z])/i) { $str =~ /(.*?(?:<\/$1(?![0-9A-Za-z])$tag_regex_|$))/gsi; $result .= $1; } } } jcode::convert(\$result, 'sjis'); return $result; } #--- Zenkaku to Hankaku --- sub zen2han{ my $str = $_[0]; jcode::convert(\$str, 'euc'); jcode::tr(\$str,"0123456789","0123456789"); jcode::tr(\$str,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","ABCDEFGHIJKLMNOPQRSTUVWXYZ"); jcode::tr(\$str, '/_@−.', '/_@-.'); jcode::convert(\$str, 'sjis'); return($str); } #--- Cryptographic Password --- sub cipher { my ($val) = @_; my (@seed) = ('0'..'9', 'A'..'Z', 'a'..'z'); srand(); $salt = $seed[int(rand(64))] . $seed[int(rand(64))]; $pass = crypt($val, $salt); return $pass; } #--- Check Password --- sub decipher{ my ($pass1, $pass2) = @_; if (crypt($pass1, $pass2) eq $pass2) { return 1; } else { return 0; } } #--- Get cookie --- sub getCookie { local($xx, $key, $val); foreach $xx (split(/; */, $ENV{'HTTP_COOKIE'})) { ($name, $value) = split(/=/, $xx); $value =~ s/%([0-9A-Fa-f][0-9A-Fa-f])/pack("C", hex($1))/eg; $cookiedata{$name} = $value; } foreach $xx (split(/,/, $cookiedata{'skysora'})) { ($key,$val) = split(/:/, $xx); $COOK{$key} = $val; } $cname = $COOK{'cname'}; $cmail = $COOK{'cmail'}; $cicon = $COOK{'cicon'}; $ccolor = $COOK{'ccolor'}; $ctcolor = $COOK{'ctcolor'}; $ccook = $COOK{'ccook'}; } #--- Set cookie --- sub setCookie { &getDate; $temp = ""; local($sec, $min, $hour, $mday, $mon, $year, $wday) = gmtime(time + 60*24*60*60); @cmonth=('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); $temp = "cname:$name,cmail:$email,ccolor:$color,ctcolor:$tcolor,cicon:$icon,ccook:$cookie,rdum:sky"; $temp =~ s/(\W)/sprintf("%%%02X", unpack("C", $1))/eg; $cdate = sprintf("%s, %02d-%s-%04d %02d:%02d:%02d GMT", $week[$wday], $mday, $cmonth[$mon], $year+1900, $hour, min, $sec); print "Set-Cookie: skysora=$temp; expires=$cdate;\n"; } #--- Delete cookie --- sub clearCookie { $cdate = "Thu, 1-Jan-1980 00:00:00 GMT"; print "Set-Cookie: skysora=\"\"; expires=$cdate;\n"; } #--- Error Message --- sub error{ rmdir($flock); if ($pc) { &header; } else { &kheader; } local($msg) = @_; print "

$msg

\n"; print 'ブラウザーの「戻る」ボタンで前の画面に戻ってください。'; print "


"; if ($pc) { &footer; } else { &kfooter; } exit(0); } #--- jump --- sub jump { my ($url) = @_; if ($location) { print "Location: $url\n\n"; } else { print "Content-Type: text/html\n\n"; print "\n"; print "\n"; print "\n"; exit(0); } } #--- Get Image Size --- # 画像の縦横ピクセル数取得 # by kishi@orange-factory.com sub get_imagesize { my $filename = shift; # 画像ファイル名 my $rise_error = shift; # エラー処理 my ( $width, $height ); # 戻り値 # ファイルが存在しないとき if ( ! -e $filename ) { if ( $rise_error ) { croak("Cannot find file [$filename]."); } else { return (0,0); } } # オープンできないとき unless ( open( IMG, $filename ) ) { if ( $rise_error ) { &error("Cannot open file [$filename]."); } else { return (0,0); } } binmode(IMG); my $buf; # GIF if( $filename =~ /\.gif$/i ){ read( IMG, $buf, 6 ); if ( $buf =~ /^GIF/ ) { read( IMG, $buf, 2 ); $width = unpack("v*", $buf); read( IMG, $buf, 2); $height = unpack("v*", $buf); } else { &error("GIF Format error") if ( $rise_error ); } } elsif ( $filename =~ /\.jpe?g?$/i ) { seek( IMG, 0, 0 ); read( IMG, $buf, 2 ); # FFD8 = JPEGファイルの先頭 if ( $buf =~ /^\xFF\xD8$/ ) { my $skip_size; # マーカーごとに読む while ( read( IMG, $buf, 2 ) ) { # 画像サイズはFFC0マーカーで記述 if ( $buf =~ /^\xFF\xC0$/ ) { seek( IMG, 3, 1 ); read( IMG, $height, 2 ); $height = unpack("n*", $height); read( IMG, $width, 2 ); $width = unpack("n*", $width); last; } # FFD9 = ファイル終端 # FFDA = イメージデータそのもの elsif ( $buf =~ /\xFF(?:\xD9|\xDA)/ ) { last; } # FFC0にたどり着くまでは読み飛ばす elsif ( $buf =~ /\xFF(?:[\xE0-\xED]|\xFE|\xDB|\xDD|\xC4)/ ) { read( IMG, $buf, 2 ); $skip_size = unpack("n*", $buf) - 2; seek( IMG, $skip_size, 1 ); } } } else { &error("JPEG Format error") if ( $rise_error ); } } # その他 else { &error("Bad filename [$filename]") if ( $rise_error ); } close( IMG ); return( $width, $height ); }