;################################################### ;## このファイルは共通設定用ファイルです。 ;## 必要に応じて設定を変更して下さい。 ;################################################### ;# メインスクリプト $script = "./i.cgi"; ;# 編集スクリプト $e_script = "./e.cgi"; ;# コメント用スクリプト $m_script = "./m.cgi"; ;# メインスクリプトを置くURL(必ずhttp://から記述) $script_url = "http://www.xxx.com/i.cgi"; ;# sendmail のパス $sendmail = '/usr/lib/sendmail'; ;# 日本語変換ライブラリ $jcode = "./jcode.pl"; ;# 絵文字変換ライブラリ $mobile_pl = "./mobile.pl"; # 絵文字用画像が収納されているディレクトリ $emo_dir = "./emoji/"; # アップロードできる画像サイズの制限(KB) : 100KB以下を推奨 $img_limit = "200000"; # アップロードできる画像数(1記事ごと : 1-9 で指定) $img_upload = "5"; ;###################################### ;# --- 設定が必要なのははここまで --- # ;###################################### ;# --- バージョン情報 $version = "My Moblog v1.0"; ;# ---タイトル表示 sub title { if ($_[1]) { $t_color = $_[1]; } if ($furiwake eq "pc") { print "<< $_[0] >>\n"; print "

\n"; } else { print "$hr
$_[0]
$hr"; } } sub form_hidden { foreach (@_) { if ($FORM{$_} ne "") { print "$para"; } } } sub write_form { &get_cookie; print "
\n"; print "\n"; print "\n"; if ($id ne "") { print "\n"; } if ($error) { print "
"; print "$error"; print "
$br\n"; } if ($regkey_mode) { if ($regkey_limit) { $rkl = $regkey_limit; } else { $rkl = 60; } local ($ti) = int(time/$rkl); local ($tl) = length($ti); foreach (0 .. ($tl-1)) { local ($num) = substr($ti,$_,1); push (@fig,"$num"); } @seed = (d .. z); $rk = ""; $k=0; while ($k < 7 || $f < ($tl+1)) { $rand = int(rand(2)); if ($rand == 1) { $rk .= "$fig[$f]"; $f++; } else { $kt = int(rand($#seed)); $rk .= "$seed[$kt]"; $k++; } } print "\n"; } print "\n"; &text_form("名 前","n","$c_name"); &text_form("E-MAIL","e","$c_email"); &text_form("URL","u","http://$c_url"); &text_form("タイトル","s","$FORM{'s'}"); &textarea_form("コメント","c","$FORM{'c'}","$emoji_mode"); if ($color_mode==1) { print "\n"; } if ($regkey_mode) { print " \n"; print " \n"; print " \n"; print " \n"; } print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
文字色"; foreach (0 .. $#color) { if ($c_color eq "$_") { print "\n"; } else { print "\n"; } } print "
投稿キー \"投稿キー\" と入力して下さい)
削除キー (記事編集時に必要となります)
\n"; print "
\n"; print " \n"; print " クッキー保存\n"; print "
\n"; print "

\n"; } ## --- フォーム表示 sub text_form { print " \n"; print " $_[0]\n"; print " \n"; print " \n"; } sub textarea_form { print " \n"; print " $_[0]\n"; print " \n"; if ($_[3]) { print " \"DoCoMo絵文字\"絵文字 :\n"; print " \"Softbank絵文字\"絵文字 :\n"; print " \"EzWeb絵文字\"絵文字
\n"; } print " \n"; print " \n"; print "\n"; } ## --- クッキー取得 sub get_cookie { $cookies = $ENV{'HTTP_COOKIE'}; @pairs = split(/;/,$cookies); foreach (@pairs) { ($name, $value) = split(/=/, $_); $name =~ s/ //g; $DUMMY{$name} = $value; } @pairs = split(/,/,$DUMMY{'MyMoblog'}); foreach (@pairs) { ($name, $value) = split(/:/, $_); $COOKIE{$name} = $value; } $c_name = $COOKIE{'name'}; $c_email = $COOKIE{'email'}; $c_url = $COOKIE{'url'}; $c_pswd = $COOKIE{'pswd'}; $c_color = $COOKIE{'color'}; if ($FORM{'n'}) { $c_name = $FORM{'n'}; } if ($FORM{'e'}) { $c_email = $FORM{'e'}; } if ($FORM{'u'}) { $c_url = $url; } if ($FORM{'p'}) { $c_pswd = $FORM{'p'}; } if ($FORM{'r'}) { $c_color = $FORM{'r'}; } } ;## --- 複数設置対応 sub id_set { $id = $FORM{'id'}; if ($id ne "") { unless(-e "$id/cond.cgi") { unless (-e "cond.cgi") { &no_id; } else { require "cond.cgi"; &id_error; } } else { require "$id/cond.cgi"; $file = "$id/data.cgi"; $import_file = "$id/data.csv"; $bbs_file = "./$id/bbs.cgi"; $count_file = "$id/count.txt"; $lockfile = "$id/diary.lock"; $bbslock = "$id/bbs.lock"; $rss_file = "./$id/rss.xml"; $img_dir = "./$id/img"; $id_link = "&id=$id"; unless (-e "./$id/mail.gif") { $mail_gif = "./mail.gif"; } else { $mail_gif = "./$id/mail.gif"; } unless (-e "./$id/home.gif") { $home_gif = "./home.gif"; } else { $home_gif = "./$id/home.gif"; } } } elsif (-e "./cond.cgi") { require "./cond.cgi"; $file = "./data.cgi"; $import_file = "./data.csv"; $bbs_file = "./bbs.cgi"; $count_file = "./count.txt"; $lockfile = "./diary.lock"; $bbslock = "./bbs.lock"; $rss_file = "./rss.xml"; $mail_gif = "./mail.gif"; $home_gif = "./home.gif"; $img_dir = "./img"; } else { &no_id; } } sub no_id { $bgcolor = "#FFFFFF"; $text = "#666699"; $link = "#3333FF"; $vlink = "#6666FF"; $alink = "#FF0000"; $ts_size = "20pt"; $t_color = "#0000FF"; $t_face = "MS P明朝"; &id_error; } sub id_error { &furiwake; $ider = "1"; &error("アクセスエラー","指定されたIDは存在しません。"); } ;## --- 日時の取得 sub date_set { $ENV{'TZ'} = "JST-9"; if ($_[0]) { $times = $_[0]; } else { $times = time; } ($sec,$min,$hour,$mday,$mon,$year,$wday,$dmy,$dmy) = localtime($times); $year = 1900 + $year; $mon++; if ($mon < 10) { $mon = "0$mon"; } if ($mday < 10) { $mday = "0$mday"; } if ($hour < 10) { $hour = "0$hour"; } if ($min < 10) { $min = "0$min"; } if ($sec < 10) { $sec = "0$sec"; } ## --- 日時のフォーマット $now_date = "$year\/$mon\/$mday"; } ;## --- 曜日の取得 sub week_set { my($year,$mon,$day) = @_; if ($mon < 3) { $mon += 12; $year--; } my($week) = int($year + int($year/4) - int($year/100) + int($year/400) + int((13*$mon+8)/5) + $day) % 7; $week; } ;## --- ブラウザによって処理分け sub furiwake { $ackey = "accesskey"; $type = $FORM{'type'}; $hr = "
"; $br="
"; $key_long = "10"; $how_long = "10"; $base_size=0; @weeks_i = ('日','月','火','水','木','金','土'); @weeks = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); @month_day = (31,31,28,31,30,31,30,31,31,30,31,30,31); $agent = $ENV{"HTTP_USER_AGENT"}; if ($agent =~ /DoCoMo/i){ @emoji = ("","","","","","","","","","","}","~",""); $furiwake = "mobile"; $mobile = "imode"; $input_abc = " istyle=\"3\""; $input_123 = " istyle=\"4\""; if ($home_i) { $home = $home_i; } $base_size=500; } elsif ($ENV{HTTP_X_JPHONE_COLOR} || $ENV{HTTP_X_JPHONE_DISPLAY} || $ENV{HTTP_X_JPHONE_MSNAME} || $ENV{HTTP_X_JPHONE_SOUND} || $agent =~ /J-PHONE|Vodafone|SoftBank/i) { @emoji = ("","","","","","","","","","","認証","→","\$E4"); @emokey = ('E','<','=','>','?','@','A','B','C','D'); $method = "GET"; $how_long = "20"; $key_long = "8"; $hr = "
"; $furiwake = "mobile"; $mobile = "jsky"; $input_abc = " mode=alphabet"; $input_123 = " mode=numeric"; $ackey = "directkey"; if ($home_i) { $home = $home_i; } } elsif ($agent =~ /UP\.Browser/i) { @emoji = ("0.","1.","2.","3.","4.","5.","6.","7.","8.","9.","認証","→","検索"); @emokey = ("325","180","181","182","183","184","185","186","187","188"); $furiwake = "mobile"; $ackey = "accesskey"; $mobile = "ezweb"; $input_abc = " format=\"*x\""; $input_123 = " format=\"*N\""; if ($home_i) { $home = $home_i; } } elsif ($agent =~ /DDIPOCKET|WILLCOM/i) { @emoji = ("0.","1.","2.","3.","4.","5.","6.","7.","8.","9.","認証","→","検索"); $furiwake = "mobile"; $ackey = "accesskey"; if ($home_i) { $home = $home_i; } } else { @emoji = ("[0]","[1]","[2]","[3]","[4]","[5]","[6]","[7]","[8]","[9]","認証","→","検索"); $key_long = "14"; $mobile = "pc"; if ($type eq "mobile") { $furiwake = "mobile"; $pc = "yes"; $t_type = "&type=mobile"; if ($home_i) { $home = $home_i; } } else { $furiwake = "pc"; $para="\n"; } } } ;## --- 各ページのヘッダ設定 sub header { if ($furiwake eq "mobile" && $pc ne "yes") { print "Content-type: text/html; charset=Shift_JIS\n\n"; print ""; print ""; if ($_[0]) { print "$_[0]"; } else { print "$title"; } print ""; print ""; } else { print "Content-type: text/html; charset=Shift_JIS\n\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if (-e "$rss_file") { print "\n"; } if (-e "./lightbox.js") { print "\n"; } if ($emoji_mode) { print "\n"; } print "\n"; if ($_[0]) { print "$title - $_[0]\n"; } else { print "$title\n"; } print "\n"; print "\n"; } } ;## --- 各ページのフッタ設定(著作権表示の削除・改変は禁止!) sub footer { if ($furiwake eq "mobile" && $pc ne "yes") { print "
-My Moblog-
"; } else { print "
\n"; print " - $version -\n"; print "
\n"; print "\n"; } } # --- 仮アップロードしたものを削除 sub tmp_del { foreach $n (1 .. $img_upload) { foreach $tl ('upl','jpg','gif') { if (-e "$img_dir/temp$n\.$tl") { unlink("$img_dir/temp$n.$tl"); } } } } ;## --- エラー発生時 sub error { if ($furiwake eq "") { &furiwake; } &tmp_del; if ($_[2] ne "non") { &header; } if ($_[3]) { $t_color=$_[3]; } else { $t_color="#FF0000"; } if($furiwake eq "pc") { if ($home) { print "ホーム\n"; } if (!$ider) { print " > $title\n"; } print " > $_[0]

\n\n"; print "
\n"; &title("$_[0]","$t_color"); print "$_[1]\n"; print "
\n"; print "


\n"; } else { &title("$_[0]","$t_color"); print "$_[1]"; print "$hr"; if (!($ider)) { print "$emoji[0]トップに戻る"; } elsif ($home) { print "$emoji[0]ホームに戻る"; } print "

"; } &footer; exit; } ;## --- ファイルロック sub lock { if ($_[0] ne "") { $lockfile = $_[0]; } if ($lockfile ne "") { local($flag) = 0; foreach (1 .. 5) { if (-e $lockfile) { sleep(1); } else { open(LOCK,">$lockfile"); close(LOCK); $flag = 1; last; } } if ($flag == 0) { $past_lock = -M "$lockfile"; if ($past_lock * 24 * 60 < 3) { &error("システムエラー","アクセスが集中しているため、タイムアウトとなりました。(ロックファイルが存在しています)"); } } } } ;## --- ファイルロック解除 sub unlock { if ($_[0] ne "") { $lockfile = $_[0]; } if (-e $lockfile) { unlink($lockfile); } } if ($img_upload > 9) { $img_upload = 9; } elsif ($img_upload < 1) { $img_upload = 1; } 1;