#!/usr/local/bin/perl # for ibbs.cgi v1.03 #-------------------------------------------------------------------------------------------------- # 初期設定 ここから #-------------------------------------------------------------------------------------------------- #●タイトル設定 $title = 'iMODE絵文字'; #●絵文字データファイル(PATH) $image_data = "./emoji.dat"; #●画面設定 $body_web = ''; # Web画面用 $body1 = ''; # iモード対応HTML Version1.0用 $body2 = ''; # iモード対応HTML Version2.0用 (カラー対応) #●絵文字画像用ディレクトリ(URL) $images = "./images/"; #-------------------------------------------------------------------------------------------------- # ここまで #-------------------------------------------------------------------------------------------------- $| = 1; $page = 20; # 変更しないこと if ($ENV{'HTTP_USER_AGENT'} =~ /DoCoMo/) { $iMODE = 1; if ($ENV{'HTTP_USER_AGENT'} =~ /502/) { $body = $body2; } else { $body = $body1; } } else { $body = $body_web; } if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'}); } else { $buffer = $ENV{'QUERY_STRING'}; } @pairs = split(/&/,$buffer); foreach $pair (@pairs) { ($key,$val) = split(/=/,$pair); $key =~ tr/+/ /; $key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $val =~ tr/+/ /; $val =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; $in{$key} = $val; } if (!open(IN,$image_data)) { &error("●エラー","File Not Found"); } @BASE = ; close(IN); if ($in{'FF'} eq '') { $FF = 0; } else { $FF = $in{'FF'}; } $TO = $FF + $page - 1; if ($TO > $#BASE) { $TO = $#BASE; } $hit = 0; foreach $num ($FF .. $#BASE) { $BASE[$num] =~ s/\n//g; $data = $BASE[$num]; if ($in{'FF'} ne '') { $allhits = $in{'allhits'}; if ($hit == $page) { last; } else { push(@NEW,$data); $hit++; } } else { if ($allhits % $page == 0) { push(@Index,$num); } if ($hit < $page) { $hit++; push(@NEW,$data); } $allhits++; } } if ($in{'allhits'} eq '') { push(@Buf,"allhits=$allhits"); $in{'allhits'} = $allhits; } if ($in{'FF'} ne '') { @Index = split(/\s/,$in{'IDX'}); } if (!@NEW) { &error('データなし'); } $count_new = @NEW; print "Content-type: text/html\n\n"; print <<"EOF"; $title $body EOF if ($iMODE) { print <<"EOF";
略$title

牢絵文字の書き方
&#番号\;
と文中に記します
キー驪〜憐で改頁
EOF } else { print "

\"\" $title

\n"; print <<"EOF"; ○絵文字の書き方 &#番号\; と文中に記します.


EOF } $buf = join('&',@Buf); $idx = join('+',@Index); $FROM = $page_now * $page - ($page - 1); $LAST = $FROM + $count_new - 1; if (!$iMODE) { print <<"EOF"; EOF } foreach $data (0 .. $#NEW) { ($num,$F16,$S10,$name) = &DecodeCSV($NEW[$data]); $S10 =~ s/^63(\d\d\d)/$1/g; if ($iMODE) { print "$S10 ?$S10; $name
\n"; } else { print <<"EOF"; EOF } } if (!$iMODE) { print <<"EOF";
番号 絵文字 説明
$S10 $name $name

EOF } if ($iMODE) { print "


Page:"; } else { print " [ "; } foreach (0 .. $#Index) { $view_page = $_ + 1; if ($FF == $Index[$_] || ($in{'FF'} eq '' && $_ == 0)) { print "↑"; $page_now = $view_page; } else { if (!$iMODE) { print " "; } print "$view_page"; } } if (!$iMODE) { print " ]\n"; } $copyr = "$images" . "108.gif"; if ($iMODE) { print <<"EOF";
掲示板(*)投稿(#)
掠iBBS
EOF } else { print <<"EOF";
iBBS

EOF } print <<"EOF"; EOF exit; sub DecodeCSV { local($text) = @_; local(@fields) = (); local($a); $text =~ s/\n//; if ($text eq '') { return (); } while ($text =~ m/"([^\\]*(\\.[^\\]*)*)",?|([^,]+),?|,/g) { $a = defined($1) ? $1 : $3; $a =~ s/""/"/g; $a =~ s/&/&/g; $a =~ s/"/"/g; $a =~ s//>/g; push(@fields,$a); } push(@fields, undef) if $text =~ m/,$/; @fields; } sub error { local (@msg) = @_; local ($i); print "Content-type: text/html\n\n"; print <<"EOF"; $title $body EOF if ($iMODE) { print "

略$title
\n"; } else { print "

\"\" $title

\n"; } foreach $i (0 .. $#msg) { print "$msg[$i]
\n"; } print "\n"; exit; }