#! c:/perl/bin/perl # # nerimb4.cgi # # Revision history # 4.011 : 4/24/06 : メールアドレスチェックを追加 # 4.010 : 2/18/06 : Message#の自動リンクを修正 # 4.009 : 1/23/06 : SSIモードでの添付アイコンのパスを修正 # 4.008 : 1/22/06 : サポート外のファイルがアップされた場合に添付ファイルと # して表示するよう修正 # 4.007 : 1/20/06 : 変更画面での名前とメールを修正 # 4.006 : 1/11/06 : 変更時に記事が消えてしまうバグを修正 # 4.005 : 12/11/05 : rejectlink.datにあるMessage#のリンクは自動リンクしない # ように修正 # 4.004 : 11/26/05 : 時間計算のバグを修正 # 4.003 : 11/26/05 : 古いアーカイブファイルの自動削除機能追加 # アーカイブファイルのファイル名を選択不可に修正 # 4.002 : 11/19/05 : サポートしていない画像も表示するように修正 # 4.001 : 11/13/05 : アーカイブで画像もzipに含むように修正 # 4.0 : 11/6/05 : Modified from nerimb3.cgi # Clean up all code to be efficient # Added English mode(incompleted) # Incorportated mbutil.pl # Deleted 1.0 compatible mode # Choise of Local time and time offset (incompleted) # # 直接実行可能なMode Options: # mode=read # mode=title # mode=wrform # mode=res # mode=delete # mode=edit # mode=link # mode=sumform # mode=sumpsnl # mode=schform # mode=archform # mode=past # mode=iread # mode=iwrform # mode=iresform # mode=unlock # mode=setup # mode=namedef # mode=print # mode=ssi(SSIで呼び出すときのみ有効) # # セットアップを非表示にした場合、mode=delete(削除)、mode=setup(セットアップ)のみ # URL直接指定で実行できます。その他の機能は直接指定しても動きません。 # # パスワードファイルを削除することにより新パスワードを設定し直す事ができます。 # # - mode=ssi # 次のようにSSIとして埋め込むのことによって最新メッセージの最初のline行を # を表示することができます。 # # # 次のようになどで直接リンクすることで特定のメッセージを表示させることが # できます。 # - nerimb4.cgi?mode=print&message= # でMessage# を表示します。 # は、ハイフン、カンマで複数指定することが出来ます。 # ハイフンは範囲、カンマは区切りを表します。 # 例:nerimb4.cgi?mode=print&message=12,15,24,20-22,8-5 # Message#5,6,7,8,12,15,20,21,22,24を表示します。 # - nerimb4.cgi?mode=print&message=&title=on # でMessage# のタイトルを表示します。 # は、ハイフン、カンマで複数指定することが出来ます。 # ハイフンは範囲、カンマは区切りを表します。 # 例:nerimb4.cgi?mode=print&message=12,15,24,20-22,8-5 # Message#5,6,7,8,12,15,20,21,22,24のタイトルを表示します。 # # - nerimb4.cgi?mode=past&number= # でMessage# を表示します。 # - nerimb4.cgi?mode=past&number=&lin= # でから分前までを表示します。 # 例:nerimb4.cgi?mode=past&number=1232&lin=6 # Message#1226から#1232まで計7件表示します。 # - nerimb4.cgi?mode=read&number=d # で今日から過去日分のメッセージを表示します。 # 例:nerimb4.cgi?mode=read&number=d16 # 今日から過去16日分表示(最新200件分以内のみ有効) # - nerimb4.cgi?mode=read&number= # で最新メッセージから過去分のメッセージを表示します。 # 例:nerimb4.cgi?mode=read&number=120 # 最新メッセージから過去120件分表示(最新200件分以内のみ有効) # # 自動リンク: # - 書き込み記事内のhttp://から半角文字の最後まで自動リンクされます。 # - 書き込み記事内の(#1234)などの表記でそのメッセージナンバーへリンクされます。 # - 書き込み記事内のMessage#1234の表記でもそのメッセージナンバーへリンクされます。 # # rejectlink.datとnamedef.datはファイル名が決まっています。 # rejectlink.datは、link modeで、namedef.datは、summary modeで # 使用されますが、無くても問題ありません。 # どちらもnerimb4.cgiと同じディレクトリに置いてください。 # 通常どちらもcgi-binに置いてください。 # # rejectlink.dat : # メッセージ中のリンクの中でデッドリンク等でリンク表示のリストから # 除外したいメッセージナンバーをrejectlink.datに1行つづ記述してください。 # 例:以下はrejectlink.datの内容の例です。 #   ---------------------------------------- #   1 #   120 #   123 #   523 #   ---------------------------------------- # # namedef.dat : # 統計の個人名方式で「人物」を選んだ場合に違う名前を同一人物と # 判断させることができます。 # namedef.datにそれらの名前を人物ごとに1行に登録されていると # 一番左の名前が代表として表示されます。 # 例:以下はnamedef.datの内容の例です。 #   ---------------------------------------- #   管理人,作成者,かんりにん #   ホークス,hawks #   ---------------------------------------- # この例では、「作成者」「かんりにん」共に「管理人」と同一人物として # まとめて集計されます。 # 「ホークス」は改行されているので管理人と別人として判断されますが、 # 「hawks」とは同一人物となります。 # namedef.datがない場合は、書き込みの名前そのままで集計されます。 # # $Id: nerimb4.cgi,v 1.24 2006/04/23 20:47:42 Hideki Kanayama Exp $ use CGI::Carp qw(fatalsToBrowser); use Time::Local; use CGI qw(:cgi-lib); use strict; use LWP::UserAgent; use Archive::Zip; use GD; use File::Basename; use File::Copy; my $mbsetupfile = "mb4setup.pl"; my $admindat = "adminpwd.dat"; my $namedef = "namedef.dat"; my $rejectlink = "rejectlink.dat"; my $version = "4.011"; my $reservedyear = "1997-2006"; my $script = basename($0); my $lang = 1; my $charset = ('Shift_JIS','ISO-8859-1')[$lang]; #### File definitions ###################### our $mbdir = "."; our $mbdata = "$mbdir/logdata.dat"; our $mbdellog="$mbdir/mbdel.log"; our $cookiename = "mb_cookie"; our $cookiename2 = "read_cookie"; our $lockfile = "$mbdir/lockfile.lock"; our $mbtitle = ("メッセージボード","Message Board")[$lang]; our $mblogo = "$mbdir/mboard.gif"; our $logo_style = ''; our $logo_color = 'black'; our $logo_size = '+1'; our $logo_face = ''; our $logo_sel = 0; # 0:デフォルト、1:テキスト、2:ロゴ、3:スタイルシート our $logo_loc=1; # 0:左、1:中、2:右 our $mbwrtitle = ("メッセージボード書き込み","Post Message")[$lang]; our $mbwr_logo = ""; our $mbwr_style = ''; our $mbwr_color = 'black'; our $mbwr_size = '+1'; our $mbwr_face = ''; our $mbwr_sel = 0; # 0:デフォルト、1:テキスト、2:ロゴ、3:スタイルシート our $mbwr_loc=0; # 0:左、1:中、2:右 our $mbrestitle = ("メッセージボード返事","Reply Message")[$lang]; our $mbres_logo = ""; our $mbres_style = ''; our $mbres_color = 'black'; our $mbres_size = '+1'; our $mbres_face = ''; our $mbres_sel = 0; # 0:デフォルト、1:テキスト、2:ロゴ、3:スタイルシート our $mbres_loc=0; # 0:左、1:中、2:右 our $mbsumtitle = ("メッセージボード 書き込み統計","Statistics")[$lang]; our $mbsum_logo = ""; our $mbsum_style = ''; our $mbsum_color = 'black'; our $mbsum_size = '+1'; our $mbsum_face = ''; our $mbsum_sel = 0; # 0:デフォルト、1:テキスト、2:ロゴ、3:スタイルシート our $mbsum_loc=1; # 0:左、1:中、2:右 our $mbarctitle = ("メッセージボード アーカイブ作成","Archive")[$lang]; our $mbarc_logo = ""; our $mbarc_style = ''; our $mbarc_color = 'black'; our $mbarc_size = '+1'; our $mbarc_face = ''; our $mbarc_sel = 0; # 0:デフォルト、1:テキスト、2:ロゴ、3:スタイルシート our $mbarc_loc=1; # 0:左、1:中、2:右 our $mblinktitle = ("リンク抜粋","Link")[$lang]; our $mblink_logo = ""; our $mblink_style = ''; our $mblink_color = 'black'; our $mblink_size = '+1'; our $mblink_face = ''; our $mblink_sel = 0; # 0:デフォルト、1:テキスト、2:ロゴ、3:スタイルシート our $mblink_loc=1; # 0:左、1:中、2:右 our $mbsrctitle = ("メッセージボード サーチ","Search")[$lang]; our $mbsrc_logo = ""; our $mbsrc_style = ''; our $mbsrc_color = 'black'; our $mbsrc_size = '+1'; our $mbsrc_face = ''; our $mbsrc_sel = 0; # 0:デフォルト、1:テキスト、2:ロゴ、3:スタイルシート our $mbsrc_loc=1; # 0:左、1:中、2:右 our $mbdeltitle = ("メッセージボード削除","Delete Message")[$lang]; our $mbdel_logo = ""; our $mbdel_style = ''; our $mbdel_color = 'black'; our $mbdel_size = '+1'; our $mbdel_face = ''; our $mbdel_sel = 0; # 0:デフォルト、1:テキスト、2:ロゴ、3:スタイルシート our $mbdel_loc=1; # 0:左、1:中、2:右 our $mbedititle = ("メッセージボード変更","Delete Message")[$lang]; our $mbedit_logo = ""; our $mbedit_style = ''; our $mbedit_color = 'black'; our $mbedit_size = '+1'; our $mbedit_face = ''; our $mbedit_sel = 0; # 0:デフォルト、1:テキスト、2:ロゴ、3:スタイルシート our $mbedit_loc=1; # 0:左、1:中、2:右 # Background設定 # 1:画像を使う 0:カラー番号を使う our $bgimage_en = 0; our $bgimagefile = "$mbdir/sample.jpg"; our $bgcolor="#ffffff"; # 統計の「ピッタリ賞」でキリ番として扱われるメッセージナンバーの設定。 our @period=(1,100,111,200,222,300,333,400,444,500,555,600,666,700,777,800,888,900,999,1000,1111,1234,2000,2222,2345,3000,3333,3456,4000,4321,4444,4567,5000,5555,5678,6000,6666,6789,7000,7777,8000,8888,9000,9999,10000,11111,20000,22222,30000,33333); # 統計 1:有効 0:無効 our $summary_en = 1; # アーカイブ 1:有効 0:無効 our $archive_en = 1; # リンク 1:有効 0:無効 our $link_en = 1; # タイトル 1:有効 0:無効 our $title_en = 1; # 画像リスト 1:有効 0:無効 our $imlist_en = 1; # サーチ 1:有効 0:無効 our $search_en = 1; # 携帯モード 1:有効 0:無効 our $imode_en = 1; # 削除機能 1:有効 0:無効 our $delete_en = 1; # 変更機能 1:有効 0:無効 our $modify_en = 1; #タグ使用 1:可 0:不可 our $tag_use = 0; #削除変更元記事保存 1:有効 0:無効 our $dellog_save = 1; #200件以前の過去記事保存 1:有効 0:無効 our $pastlog_save = 1; #携帯モードでの画像表示 1:有効 0:無効 our $imode_image = 0; #携帯モーででの画像表示サイズ our $imode_image_x = 100; our $imode_image_y = 100; #タグ使用可の時にhttp://からのオートリンク 1:on 0:off our $autolink_when_tag_is_on = 0; #http://の適用 1:行頭のみ 0:どこでも our $autolink_head_only = 0; # セットアップ表示 1:表示 0:非表示 our $setup_en = 1; # 自動リンククリック時 1:同じウィンドウ 0:別ウィンドウ our $link_samewin_en = 1; # トップへのリンク 1:表示 0:非表示 our $top_link_en = 1; our $top_link_title = ('トップへ','Top')[$lang]; our $top_link = '../index.html'; # 書き込みタイトルのサイズ、色、フォント our $post_title_color = '#00aa00'; our $post_title_size = '+2'; our $post_title_face = ''; # 名前の色 our $post_name_color = '#0000ee'; # 返信引用記事の色 our $quate_color = '#804040'; # 記事本文の色 our $text_color = 'black'; # 投稿者個人色設定 1:on 0:off our $user_name_color_en = 0; our $user_title_color_en = 0; our $user_text_color_en = 0; # 記事本文の表示幅 ブラウザ全体の% our $body_width = 100; # 名前欄のメールアドレス表示 1:on 0:off our $maildisp_en = 1; # 名前欄の敬称 1:on 0:off our $namesan_en = 0; our $namesan = ('さん','-san')[$lang]; # 返信コメントでの敬称 1:on 0:off our $ressan_en = 0; our $ressan = ('さん','-san')[$lang]; # SSIモード設定 # SSIモードを使用するHTMLファイルから見たこのスクリプトへの相対パス、 # 又はhttp://からのフルパス our $httpcgibin = "http://localhost/cgi-bin"; # 続き表示リンクの文字列 our $gotomb = ('続きはこちら.....','See more')[$lang]; # SSIモードの表示ライン数のデフォルト our $ssiline = 7; # SSIモードの表示件数 # $ssikenが2以上の場合は$ssilineは無効 our $ssiken = 1; # SSIモードで画像表示 0:off 1:on our $ssiimage_en = 0; #画像サイズ our $ssiimage_w = 100; our $ssiimage_h = 100; # サポートされていない画像やファイルの場合のアイコン使用 1:有効 0:無効 our $attach_icon_en = 0; our $attach_icon = ''; # Use localtime? our $localtime_en = 0; # If not using localtime, 時間設定 GMTからのオフセット 日本:+9 our $offset = 9; # Summary で使われる棒グラフの棒 our $gif="$mbdir/bar.gif"; # 画像機能 0:無し 1:有り our $image_en = 1; # 画像格納ディレクトリ our $imagedir = "$mbdir"; # 画像クリック時のウィンドウ 0:別ウィンドウ 1:同じウィンドウ our $image_samewin_en = 1; # 縮小表示時のサイズ our $max_width = 150; our $max_height = 150; #最大画像アップサイズ(kB) our $maxmb = 100; #会員専用書き込み 1:on 0:off our $member_only = 0; our $member_pwd = '12345'; #スタイルシート 1:on 0:off our $style_sheet_en = 0; our $style_sheet = ' A:link {text-decoration: none} A:visited {text-decoration: none} A:active {text-decoration: none} '; #〜内に挿入できる構文 1:on, 0:off our $head_insert_en = 0; our $head_insert = ''; #メッセージボード上部に表示させる文 1:on, 0:off our $body_insert1_en = 0; our $body_insert1 = ''; our $body_insert2_en = 0; our $body_insert2 = ''; our $body_insert3_en = 0; our $body_insert3 = ''; our $body_insert4_en = 0; our $body_insert4 = ''; our $body_insert5_en = 0; our $body_insert5 = ''; #トップからのSSI表示による更新時間のための予備のアップデートファイル # 1: on, 0: off our $update1_file_en = 0; our $update2_file_en = 0; our $update1_file = "$mbdir/update1.log"; our $update2_file = "$mbdir/update2.log"; ######################################################################### if (-e "$mbsetupfile"){ require "$mbsetupfile"; } my $url_pattern = 'https?:\/\/[\w\.\~\/\?\&\+\=\:\@\%\;\#\$\%\-]*'; my $tag_pattern = '[\w\s\"\'\\\+\=\/\;\:\%\(\)#\?\.\~\-]*'; my $mail_pattern = '\w\@\.\-'; my $color_pattern = '\w\#'; if ($maxmb < 100) {$maxmb = 100;} my $maxmb2 = $maxmb + 20; # Margin for text up size $CGI::POST_MAX = $maxmb2 * 1024; my $q = new CGI; my $cgierror = $q->cgi_error; &error($cgierror) if ($cgierror); my %in = $q->Vars; %in = &postprocess(%in); if ($script eq 'mbssi.cgi'){ $script = 'nerimb4.cgi'; $in{mode} = 'ssi'; } elsif ($script eq 'mbiread.cgi'){ $script = 'nerimb4.cgi'; $in{mode} = 'iread'; } if (defined $in{mode} and $in{mode} eq 'ssi' && $in{line} eq ''){ $in{line} = $ssiline; } my $mbread = "$script?mode=read"; my $mbreadt = "$script?mode=title"; my $mbwrite = "$script?mode=write"; my $mbres = "$script?mode=res"; my $mbpast = "$script?mode=past"; my $mbwrform = "$script?mode=wrform"; my $mblink = "$script?mode=link"; my $mbdel1 = "$script?mode=delete"; my $mbdel2 = "$script?mode=del2"; my $mbdel3 = "$script?mode=del3"; my $mbsum = "$script?mode=summary"; my $mbsearch = "$script?mode=search"; my $mbschform = "$script?mode=schform"; my $mbarchform = "$script?mode=archform"; my $mbarch = "$script?mode=archive"; my $mbsumfm = "$script?mode=sumform"; my $mbsumpsfm = "$script?mode=sumpsnl"; my $mbiread = "$script?mode=iread"; my $mbiwrite = "$script?mode=iwrite"; my $mbiwrform = "$script?mode=iwrform"; my $mbires = "$script?mode=iresform"; my $mbsetup = "$script?mode=setup"; my $mbedit = "$script?mode=edit"; my $mbnamedef = "$script?mode=namedef"; my $mbnamedefwr = "$script?mode=namedefwr"; my $mbprint = "$script?mode=print"; my $mbssi = "$script?mode=ssi"; if (! -e "$admindat"){ if ($in{mode} eq 'adminpwd'){ &wradminpwd; } else { &setadminpwd; } } my $link_target = $link_samewin_en ? '_top' : '_blank'; my @reject = &reject_list; if (! defined $in{mode}) { &mbread; } elsif ($in{mode} eq 'read' || ($in{mode} eq 'title' && $title_en == 1) || $in{mode} eq ''){ &mbread; } elsif ($in{mode} eq 'wrform'){ &mbwrform; } elsif ($in{mode} eq 'write'){ &mbwrite; } elsif ($in{mode} eq 'res'){ &mbres; } elsif ($in{mode} eq 'delete'){ &mbdel1; } elsif ($in{mode} eq 'del2'){ &mbdel2; } elsif ($in{mode} eq 'del3'){ &mbwrite; } elsif ($in{mode} eq 'edit'){ &mbedit; } elsif ($in{mode} eq 'edit2'){ &mbwrite; } elsif ($in{mode} eq 'link' && $link_en == 1){ &mblink; } elsif ($in{mode} eq 'sumform' && $summary_en == 1){ &mbsumform; } elsif ($in{mode} eq 'sumpsnl' && $summary_en == 1){ &mbsumpsnl; } elsif ($in{mode} eq 'summary' && $summary_en == 1){ &mbsum; } elsif ($in{mode} eq 'namedef' && $summary_en == 1){ &mbnamedef; } elsif ($in{mode} eq 'namedefwr' && $summary_en == 1){ &mbnamedefwr; } elsif ($in{mode} eq 'schform' && $search_en == 1){ &mbschform; } elsif ($in{mode} eq 'search' && $search_en == 1){ &mbsearch; } elsif ($in{mode} eq 'archform' && $archive_en == 1){ &mbarchform; } elsif ($in{mode} eq 'archive' && $archive_en == 1){ &mbarch; } elsif ($in{mode} eq 'past' || $in{mode} eq 'print'){ &mbpast; } elsif ($in{mode} eq 'iread' && $imode_en == 1){ &mbiread; } elsif ($in{mode} eq 'iwrite' && $imode_en == 1){ &mbiwrite; } elsif ($in{mode} eq 'iwrform' && $imode_en == 1){ &mbiwrform; } elsif ($in{mode} eq 'iresform' && $imode_en == 1){ &mbiresform; } elsif ($in{mode} eq 'setup'){ &setup; } elsif ($in{mode} eq 'setup2'){ &makesetup; } elsif ($in{mode} eq 'ssi'){ &mbssi; } elsif ($in{mode} eq 'cleanlink'){ &mbcleanlink; } elsif ($in{mode} eq 'cleanlink2'){ &cleanlink; } elsif ($in{mode} eq 'makebar'){ &mbmakebargif; } elsif ($in{mode} eq 'makebar2'){ &makebar; } elsif ($in{mode} eq 'dispbar'){ &dispbar; } else { &mbread; } exit; ############################################################################# # Read mode ################################################################# ############################################################################# sub mbread { my @alldata = reverse &getmbdata; my @findata = split(/,/,$alldata[0]); my ($name, $done) = split /:/, $q->cookie($cookiename2); my $cook="done:$findata[0]"; my $cookie = $q->cookie(-name => "$cookiename2", -value => "$cook", -expires => "+1y"); $cookie = &cookie_decode($cookie); print "Set-Cookie: $cookie\n"; my $fdone=$findata[0] - $done; my $fnext=$findata[0] - 20; my $startpoint = 0; my @day_before = &get_before_data(@alldata); my $line; my $t = $in{mode}; my $ago = $in{number}; if($ago eq 'done'){ $line=$fdone; } elsif ($ago =~ /&/) { ($ago,$t)=split(/&/,$ago); $line = $ago; } elsif ($ago =~ /^d/) { $ago =~ s/d(\d+)/$1/; my $i; foreach $i (0 .. $ago){ $line = $line + $day_before[$i]; } } elsif ($ago =~ /^n/) { $ago =~ s/n(\d+)/$1/; $startpoint=$findata[0] - $ago; $fnext=$ago - 20; $line=$startpoint+20; } elsif ($ago =~ /^\d/) { $line=$ago; } else { $line=20; } my $finline; if ($#alldata < $line){ $finline=$#alldata; } else { $finline=$line-1; } &htmlhead($mbtitle); &disphead($fdone,@day_before); if (($fnext > $findata[0] - 200) && (($ago eq '')||($startpoint != 0))) { if ($fnext > 0) { print ""; print (('更に前の20件を見る','Older massage')[$lang]); print ""; } } print "
\n"; if ($t eq 'title' or $t eq 'imlist') {print "
\n";}; if (($fnext > $findata[0] - 200) && (($ago eq '')||($startpoint != 0))) { if ($fnext > 0) { print ""; print (('更に前の20件を見る','Older messages')[$lang]); print " \n"; } } &disptail; print "

"; print (('新規書き込み','New post')[$lang]); print "

\n"; &htmltail; } sub cookie_decode { my $a = shift; $a =~ s/%([A-Fa-f0-9][A-Fa-f0-9])/pack("C", hex($1))/eg; $a =~ s/path\s*=\s*[^;]*;//i; return $a; } sub display_one_title { my $line = shift; my ($number,$datecode,$name,$mail,$host,$date,$subject,$main,$encpwd,$imagefile,$user_name_color,$user_title_color,$user_text_color)=split(/,/,$line); my ($each_name_color,$each_title_color,$each_text_color) = &replace_color($user_name_color,$user_title_color,$user_text_color); if ($in{mode} ne 'imlist' or ($in{mode} eq 'imlist' and $imagefile ne '' and -e "$imagedir/$imagefile")) { print "

  • #${number}、"; my $disp_subject = &subject_text($subject); print "$disp_subject"; if ($lang == 0){ my @darray = split(/[^\d]/,$date); if ($darray[0] < 1900){ my $dy = $darray[0]+1900; $date =~ s/^\d?\d\d([^\d]..*)$/$dy$1/; } } print " ........ $date"; } if ($in{mode} eq 'imlist' and $imagefile ne '' and -e "$imagedir/$imagefile") { my ($imagefile,$w,$h)=&get_image_size($imagefile,$ssiimage_w,$ssiimage_h); print "
    "; print &image_tag($imagefile,$w,$h); print ""; } print "
  • \n"; } sub image_tag { my ($image,$w,$h) = @_; if ($w == 0 or $h == 0) { if ($attach_icon_en) { if ($in{mode} eq 'ssi'){ return ""; } else { return ""; } } else { return "<Attachment>"; } } else { return ""; } } sub subject_text { my $subject = shift; my @sub2=split(/Re:/,$subject); my $disp_subject; if ($#sub2 > 1){ $disp_subject = "Re" . $#sub2 . ":" . $sub2[$#sub2]; } else { $disp_subject = "$subject"; } } sub display_one_message { my $one_line = shift; my ($number,$datecode,$name,$mail,$host,$date,$subject,$main,$encpwd,$imagefile,$user_name_color,$user_title_color,$user_text_color)=split(/,/,$one_line); my ($each_name_color,$each_title_color,$each_text_color) = &replace_color($user_name_color,$user_title_color,$user_text_color); my $one_message; $one_message = ""; my @darray = split(/[^\d]/,$date); $one_message .= ""; $one_message .= "
    Message#${number} "; if ($lang == 0){ if ($darray[0] < 1900){ my $dy; $dy = $darray[0]+1900; $date =~ s/^\d?\d\d([^\d]..*)$/$dy$1/; } } $one_message .= "$date
    "; $one_message .= "From: "; if ($mail){ $one_message .= "$name" } else { $one_message .= "$name"; } if ($namesan_en){ $one_message .= "$namesan"; } if ($mail && $maildisp_en){ $one_message .= " ($mail)" } $one_message .= "
    "; if ($in{mode} ne 'past' and $in{mode} ne 'del2'){ if ($in{mode} ne 'delete'){ $one_message .= ""; $one_message .= (('返事','reply')[$lang]); $one_message .= " \n"; } if ($delete_en or $in{mode} eq 'delete') { $one_message .= " "; $one_message .= (('削除','delete')[$lang]); $one_message .= " \n"; } if ($modify_en or $in{mode} ne 'delete') { $one_message .= ""; $one_message .= (('変更','edit')[$lang]); $one_message .= " \n"; } } $one_message .= "
    "; $one_message .= "
    "; my $disp_subject = &subject_text($subject); $one_message .= "$disp_subject"; $one_message .= "
    "; my $link_target; if ($link_samewin_en){ $link_target = '_top'; } else { $link_target = '_blank'; } $main =~ s/\(\#(\d+)\)/\(\#$1<\/a>\)/g; $main =~ s/(message)\#(\d+)/$1\#$2<\/a>/gi; my @mainarry=split /
    /i, $main; $one_message .= ""; $one_message .= ""; $one_message .= ""; $one_message .= "
    "; chomp($imagefile); if ($image_en && $imagefile ne '' && -e "$imagedir/$imagefile"){ my ($actual_width, $actual_height); ($imagefile,$actual_width,$actual_height) = &get_image_size("$imagefile",$max_width,$max_height); my $newwin; if ($image_samewin_en){ $newwin = ''; } else { $newwin = 'target="_blank"'; } $imagefile = basename($imagefile) if ($in{mode} eq 'archive'); $one_message .= ""; $one_message .= &image_tag($imagefile,$actual_width,$actual_height); $one_message .= ""; } $one_message .= ""; $one_message .= ""; foreach (@mainarry){ $_ = &replace_link($_,$number); $_ = &replace_tag($_); if(/^\>.*$/){ $one_message .= "$_"; } else { $one_message .= "$_"; } $one_message .= "
    "; } $one_message .= "
    "; $one_message .= "

    \n"; if ($in{mode} eq 'archive'){ return($one_message); } else { print $one_message; } } sub get_before_data { my @alldata = @_; my $today; if ($localtime_en) { $today = time; } else { $today = time + $offset*3600; } my $ago = $in{number}; my @day_before; my $i; my $yesterday; my ($ysec,$ymin,$yhour,$ymday,$ymon,$yyear,$ywday,$yyday,$yisdst); my $yrmon; my @yesterdata; foreach $i (0 .. 5){ $yesterday=$today-86400*$i; if ($localtime_en){ ($ysec,$ymin,$yhour,$ymday,$ymon,$yyear,$ywday,$yyday,$yisdst)=localtime($yesterday); } else { ($ysec,$ymin,$yhour,$ymday,$ymon,$yyear,$ywday,$yyday,$yisdst)=gmtime($yesterday); } $yrmon=$ymon+1; @yesterdata=grep(/^\d\d*,${yyear}_${yrmon}_${ymday},/,@alldata); $day_before[$i] = $#yesterdata + 1; } return @day_before; } sub htmlhead { my $mbtitle = shift; my $firstyear = shift; my $head_message; $head_message = $q->header(-charset=>"$charset") if ($in{mode} ne 'archive'); $head_message .= "\n"; $head_message .= "\n"; $head_message .= "\n"; $head_message .= "\n"; $head_message .= "$mbtitle\n"; if ($in{mode} eq 'sumform' or $in{mode} eq 'sumpsnl'){ $head_message .= ' '; } if ($in{mode} eq 'schform'){ $head_message .= " "; } if ($head_insert_en == 1){ $head_message .= "$head_insert\n"; } if ($style_sheet_en == 1){ $head_message .= "\n"; } $head_message .= "\n"; my $onload; if ($in{mode} eq 'sumform' or $in{mode} eq 'sumpsnl' or $in{mode} eq 'schform') { $onload = 'onLoad="setopt();"'; } else { $onload = ''; } my $bgimage; if ($bgimage_en == 1){ $bgimage = "background=\"$bgimagefile\""; } else { $bgimage = "bgcolor=\"$bgcolor\""; } $head_message .= "\n"; $head_message .= "
    \n"; if ($in{mode} eq 'archive'){ return($head_message); } else { print $head_message; } } sub lockfile { open(LOCKFILE,"> $lockfile"); flock LOCKFILE, 2; } sub unlockfile { no strict; close (LOCKFILE) if (defined LOCKFILE); close (TMPFILE) if (defined TMPFILE); unlink $lockfile if (-e $lockfile); unlink "tmp.$$" if (-e "tmp.$$"); } sub htmltail { print ©right; print "
    \n"; print "\n"; print "\n"; exit; } sub copyright { my $mysite = ('http://www.hidekik.com/','http://www.hidekik.com/en/')[$lang]; my $copyright; $copyright = "
    $script Ver. $version
    \n"; $copyright .= "
    Copyright(C) $reservedyear, hidekik.com
    \n"; return $copyright; } sub get_image_size { my ($image,$max_width,$max_height) = @_; my $imagefile = "$imagedir/$image"; my $im; $image =~ /\.jpe?g$/i and $im = GD::Image->newFromJpeg($imagefile); $image =~ /\.gif$/i and $im = GD::Image->newFromGif($imagefile); $image =~ /\.png$/i and $im = GD::Image->newFromPng($imagefile); $image =~ /\.xbm$/i and $im = GD::Image->newFromxbm($imagefile); $image =~ /\.gd$/i and $im = GD::Image->newFromgd($imagefile); $image =~ /\.gd2$/i and $im = GD::Image->newFromgd2($imagefile); $image =~ /\.xpm$/i and $im = GD::Image->newFromxpm($imagefile); my ($width, $height) = $im->getBounds() if ($im); my $actual_width; my $actual_height; if ($width > $max_width or $height > $max_height){ my $width_shrink = $max_width / $width; my $height_shrink = $max_height / $height; my $shrink_ratio; if ($width_shrink < $height_shrink){ $shrink_ratio = $width_shrink; } else { $shrink_ratio = $height_shrink; } $actual_width = int($width * $shrink_ratio); $actual_height = int($height * $shrink_ratio); } else { $actual_width = $width; $actual_height = $height; } return($imagefile,$actual_width,$actual_height); } sub disphead { my ($fdone,@line) = @_; my $i; my $mb0=$line[0]; my $mb1=$mb0+$line[1]; my $mb2=$mb1+$line[2]; my $mb3=$mb2+$line[3]; my $mb4=$mb3+$line[4]; my $mb5=$mb4+$line[5]; my $titleprint=&titleprint("$mbtitle","$mblogo","$logo_style","$logo_color","$logo_size","$logo_face","$logo_sel","$logo_loc"); print "$body_insert1" if ($body_insert1_en == 1 and $in{mode} ne 'past' and $in{mode} ne 'link'); if ($in{mode} ne 'past' and $in{mode} ne 'link' and $in{mode} ne 'print'){ if ($logo_sel != 4){ print "$titleprint\n"; } print "$body_insert2" if ($body_insert2_en == 1); if ($lang) { print "
    Recent post: Today :$mb0, Yesterday:$line[1]
    \n"; } else { print "
    最近の書き込み件数: 今日 $mb0件、昨日 $line[1]件
    \n"; } if ($fdone > 0) {print "";} if ($lang){ print "Unread : $fdone"; } else { print "未読分:$fdone件"; } if ($fdone > 0) {print "\n";} print "
    \n"; print "
    " if ($body_insert3_en == 0); print "$body_insert3" if ($body_insert3_en == 1); print "
    "; if ($top_link_en == 1){ print "$top_link_title "; } print ""; print (('新規書き込み','New post')[$lang]); print "
    \n"; print "

    " if ($body_insert4_en == 0); print "$body_insert4" if ($body_insert4_en == 1); } print "

    "; print (('最新20件','latest 20')[$lang]); print " \n"; print ""; print (('最新50件','latest 50')[$lang]); print " \n"; print ""; print (('最新100件','latest 100')[$lang]); print " \n"; print ""; print (('最新200件','latest 200')[$lang]); print " \n"; print "", ('200件以前','Before 200')[$lang], "" if ($pastlog_save); print "
    \n"; print ""; print (('昨日以降','since yesterday')[$lang]); print "($mb1) \n"; print ""; print (('2日前以降','since two days ago')[$lang]); print "($mb2) \n"; print ""; print (('3日前以降','since three days ago')[$lang]); print "($mb3) \n"; print ""; print (('4日前以降','since four days ago')[$lang]); print "($mb4) \n"; print ""; print (('5日前以降','since five days ago')[$lang]); print "($mb5)
    \n"; if ($summary_en){ print ""; print (('統計','stat')[$lang]); print " \n"; } if ($archive_en){ print ""; print (('アーカイブ','archive')[$lang]); print " \n"; } if ($link_en){ print ""; print (('リンク','link')[$lang]); print " \n"; } if ($title_en){ print ""; print (('タイトル','title')[$lang]); print " \n"; } if ($imlist_en == 1 and $image_en == 1){ print ""; print (('画像','image')[$lang]); print " \n"; } if ($search_en){ print ""; print (('サーチ','search')[$lang]); print " \n"; } if ($imode_en){ print ""; print (('携帯モード','mobile')[$lang]); print " \n"; } if ($setup_en){ print ""; print (('セットアップ','setup')[$lang]); print " \n"; } print "
    "; print "\n"; print "

    " if ($body_insert5_en == 0); print "$body_insert5" if ($body_insert5_en == 1); } sub disptail { print "

    "; print (('最新20件','latest 20')[$lang]); print " \n"; print ""; print (('最新50件','latest 50')[$lang]); print " \n"; print ""; print (('最新100件','latest 100')[$lang]); print " \n"; print ""; print (('最新200件','latest 200')[$lang]); print " \n"; print "", ('200件以前','Before 200')[$lang], "" if ($pastlog_save); print "
    \n"; print ""; print (('昨日以降','since yesterday')[$lang]); print " \n"; print ""; print (('2日前以降','since two days ago')[$lang]); print " \n"; print ""; print (('3日前以降','since three days ago')[$lang]); print " \n"; print ""; print (('4日前以降','since four days ago')[$lang]); print " \n"; print ""; print (('5日前以降','since five days ago')[$lang]); print "
    \n"; } sub getmbdata { my @alldata; open(GETFILE,"< $mbdata"); while(){ chomp; push(@alldata,$_); if ($#alldata >= 200){ shift(@alldata); } }; close(GETFILE); return (@alldata); } ############################################################################# # Write Form mode ########################################################### ############################################################################# sub mbwrform { my $titleprint = &titleprint("$mbwrtitle","$mbwr_logo","$mbwr_style","$mbwr_color","$mbwr_size","$mbwr_face","$mbwr_sel","$mbwr_loc"); &htmlhead($mbwrtitle); my %cookie = &input_forms($titleprint); print "\n"; print "

    \n"; &input_forms2(%cookie); &display_after_write; &write_comment; print "\n"; print "\n"; &htmltail; } sub input_forms { my %COOKIE; my @pairs = split /,/, $q->cookie($cookiename); foreach my $pair (@pairs) { my ($name, $value) = split(/:/, $pair); $COOKIE{$name} = $value; } my ($titleprint,$name_color_input,$title_color_input,$contents_color_input,$name, $mail,$subject) = @_; if ($in{mode} eq 'wrform' or $in{mode} eq 'res'){ ($name, $mail) = ($COOKIE{name},$COOKIE{email}); ($name_color_input,$title_color_input,$contents_color_input) = &user_color_input("$COOKIE{user_name_color}","$COOKIE{user_title_color}","$COOKIE{user_text_color}"); } if ($in{mode} eq 'res'){ $subject = "Re:" . $subject; } print "

    \n"; print "$titleprint"; print (('お名前(必須)','Name')[$lang]); print "\n
    $name_color_input\n"; print "
    "; print (('メールアドレス','Mailaddress')[$lang]); print "\n
    \n"; print "
    "; print (('タイトル(必須)','Subject')[$lang]); print "\n
    $title_color_input\n"; print "
    \n"; print "

    "; print (('内容','Contents')[$lang]); print "$contents_color_input\n"; print "

    "; &input_forms2(%cookie); &display_after_write; &write_comment; print "\n"; print "

    \n"; &htmltail; } ############################################################################# # Message edit Form mode #################################################### ############################################################################# sub mbedit { my @alldata = &getmbdata; my @resdata = grep(/^$in{resnum},/,@alldata); my ($resnumber,$rescode,$resname,$resmail,$reshost,$resdate,$ressubject,$resmain,$resencpwd,$resimagefile,$user_name_color,$user_title_color,$user_text_color)=split(/,/,$resdata[0]); &htmlhead($mbedititle); my $titleprint=&titleprint("$mbedititle","$mbedit_logo","$mbedit_style","$mbedit_color","$mbedit_size","$mbedit_face","$mbedit_sel","$mbedit_loc"); my ($name_color_input, $title_color_input, $contents_color_input) = &user_color_input("$user_name_color","$user_title_color","$user_text_color"); my %cookie = &input_forms($titleprint, $name_color_input, $title_color_input, $contents_color_input,$resname,$resmail,$ressubject); @resdata=split(/<[bB][rR]>/,$resmain); foreach (@resdata){ print "$_\n"; } print "

    "; if ($image_en == 1){ if ($resimagefile ne ''){ print qq//; print (('画像はそのまま','No image change')[$lang]); print "
    \n"; print qq//; print (('画像を削除','Delete image')[$lang]); print "
    \n"; print qq//; print (('画像を差し替え','Replace image')[$lang]); print "
    \n"; print (('差し替え画像ファイル(ファイル名は半角英数、アンダースコア、ドット、ハイフンのみ)','New image file')[$lang]); print "\n"; } else { print qq//; print (('アップ画像ファイル(ファイル名は半角英数、アンダースコア、ドット、ハイフンのみ)','Uploading file')[$lang]); print "\n"; } print "

    \n"; } if ($delete_en == 1 || $modify_en == 1){ print (('削除修正用個人パスワード(半角英数で)','Your password')[$lang]); print "
    \n"; print "

    \n"; } &display_after_write; &write_comment; print "\n"; print "\n"; print "\n"; &htmltail; } ############################################################################# # Delete display mode ####################################################### # $delete_en = 0 の場合は直接$mbdel1をタイプして実行してください。 # 管理人のみ削除できることになります。 ############################################################################# sub mbdel1 { my @alldata = &getmbdata; @alldata = reverse(@alldata); my @findata = split(/,/,$alldata[0]); my $line = 200; my $finline; if ($#alldata < $line){ $finline=$#alldata; } else { $finline=$line-1; } my $titleprint=&titleprint("$mbdeltitle","$mbdel_logo","$mbdel_style","$mbdel_color","$mbdel_size","$mbdel_face","$mbdel_sel","$mbdel_loc"); &htmlhead($mbdeltitle); print "$titleprint\n"; my @day_before = &get_before_data(@alldata); &disphead(0,@day_before); print "


    \n"; foreach my $count (0 .. $finline){ &display_one_message($alldata[$count]); } &disptail; } ############################################################################# # Delete confirm mode ####################################################### ############################################################################# sub mbdel2 { my @alldata = &getmbdata; my @resdata = grep(/^$in{resnum},/,@alldata); my ($resnumber,$rescode,$resname,$resmail,$reshost,$resdate,$ressubject,$resmain,$resencpwd,$imagefile,$name_text_color,$title_text_color,$contents_text_color)=split(/,/,$resdata[0]); my ($each_name_color,$each_title_color,$each_text_color) = &replace_color($name_text_color,$title_text_color,$contents_text_color); my $titleprint=&titleprint("$mbdeltitle","$mbdel_logo","$mbdel_style","$mbdel_color","$mbdel_size","$mbdel_face","$mbdel_sel","$mbdel_loc"); &htmlhead($mbdeltitle); print $titleprint; print "
    \n"; &display_one_message($resdata[0]); my $withimage; if ($image_en == 1 && $imagefile ne ''){ $withimage = ('と画像','and the image')[$lang]; } else { $withimage = ''; } print (("上のメッセージ$withimageを削除します。
    よければパスワードを入力し、削除ボタンをクリックしてください。

    ","Delete the above message $withimage.
    If OK, click the Delete button")[$lang]); print "

    \n"; print (("パスワード:","Password")[$lang]); print "\n"; print "\n"; print "\n"; my $delbutton = ("削除","Delete")[$lang]; print "

    \n"; print "

    \n"; &htmltail; } ############################################################################# # Link display mode ######################################################### # メッセージ中のリンクの中でデッドリンク等でリンク表示のリストから # 除外したいメッセージナンバーをrejectlink.datに1行つづ記述してください。 ############################################################################# sub mblink { my @alldata = &getmbdata; &htmlhead($mblinktitle); my $titleprint=&titleprint("$mblinktitle","$mblink_logo","$mblink_style","$mblink_color","$mblink_size","$mblink_face","$mblink_sel","$mblink_loc"); my @numarray; my @datearray; my @titlearray; my @linkarray; my @user_title_color; open(FILE,"< $mbdata"); while (){ chomp; my ($number,$b,$c,$d,$e,$date,$title,$main,$encpwd,$imagefile,$user_name_color,$user_title_color,$user_text_color)=split(/,/); my $linkarray2; if (/$url_pattern/){ foreach (split(/
    /i,$main)){ if (/($url_pattern)/ && !/^\>/){ $linkarray2 .= "$1
    "; } } if($linkarray2 ne ""){ if (! grep(/^$number$/,@reject)){ push(@numarray,$number); push(@datearray,$date); push(@titlearray,$title); push(@linkarray,$linkarray2); push(@user_title_color,$user_title_color); } } $linkarray2=""; } } close(FILE); print "$body_insert1" if ($body_insert1_en == 1); print $titleprint; print "$body_insert4" if ($body_insert4_en == 1); my @day_before = &get_before_data(@alldata); &disphead(0,@day_before); print "
    \n"; print "
      \n"; my $i; for($i=$#linkarray;$i>=0;$i=$i-1){ my ($each_name_color,$each_title_color,$each_text_color) = &replace_color('',$user_title_color[$i],''); print "
    • #$numarray[$i],"; my $subject = &subject_text($titlearray[$i]); print "$subject
      \n"; foreach my $url (split(/
      /i,$linkarray[$i])){ print "$url
      "; } print "

    • \n"; } print "
    \n"; print "
    ", ("$rejectlinkを更新する","Update $rejectlink")[$lang], "
    \n"; print "
    \n"; &disptail; &htmltail; } sub reject_list { my @reject; if (open(REJECT,"< $rejectlink")){ @reject = ; close(REJECT); } else { @reject = (); } map {chomp} @reject; return (@reject); } ############################################################################# # Summary Form mode ######################################################### ############################################################################# sub mbsumform { my ($firstyear,$finyear) = &get_firstyear; my $titleprint=&titleprint("$mbsumtitle","$mbsum_logo","$mbsum_style","$mbsum_color","$mbsum_size","$mbsum_face","$mbsum_sel","$mbsum_loc"); &htmlhead($mbsumtitle,$firstyear); print qq!
    \n!; print qq!\n!; print qq!$titleprint\n!; print qq!\n!; print qq!\n!; print qq!\n!; print qq!\n!; print qq!
    !; print (('参照対象','Range')[$lang]); print qq! \n!; print qq!\n!; print qq!\n!; print qq!
    \n!; print qq!!; print (('全部','all')[$lang]); print "\n"; print qq!Message#\n!; print "from" if ($lang == 1); print qq!!; print "から" if ($lang == 0); print "to" if ($lang == 0); print qq!!; print "まで\n" if ($lang == 0); print qq!
    \n!; print qq!!; print (('日付が','date')[$lang]); print qq!\n!; print "Year" if ($lang == 1); print qq!"; print '年' if ($lang == 0); print "Month" if ($lang == 1); print <
    個人名方式   名前  人物 (印のみ有効) 同一人物設定
    日毎の集計
    トップ100 書き込み量の上位100
    件数対日数 日数を件数でソ\ート
    時間帯集計 時間帯毎の書き込みの量
    曜日毎集計 曜日毎の書き込みの量
    月毎の集計 毎月の書き込みの量
    年毎の集計 毎年の書き込みの量
    ぴったり賞 Message#100, 777, 等に当たった人
    個人別集計 名前別書き込みの量
    月間個人別集計
    年間個人別集計
    月間トップ3 歴代の月間トップ3
    個人最終書き込み 特定の名前で最後に書き込んだ日
         

    メッセージボードへ  個人データ詳細

    END5 print "bar.gif作成\n"; &htmltail; } sub optyear { my ($firstyear,$finyear) = @_; foreach ($firstyear .. $finyear){ my $dispy = $_+1900; my $selected = ''; $selected = 'selected' if ($_ == $finyear); print "