#! c:/perl/bin/perl # # smail.cgi # SSIモードフォームメール CAPTCHA付き # # 1.001 : 2/11/07 : デフォルトでCAPTCHAをオフに修正 # 1.0 : 2/9/07 : Initial revision # # http://www.hidekik.com # # Copyright(c) 2007, Hideki Kanayama All rights reserved use strict; use CGI qw(:cgi-lib); use CGI::Carp qw(fatalsToBrowser); use File::Basename; use Jcode; use GD::SecurityImage::AC; my $lastupdatedyear = 2007; my $version = "1.001"; my $script = basename($0); my $setupfile = "smail_setup.pl"; my $charset = "Shift_JIS"; my $lang = 0; ########################################### # Enable mail our $enable_mail = 0; # SSIを設置するshtmlからみたこのCGIへのパス our $path_from_shtml = "smail"; # Back link our $backlink = '../toppage.shtml'; # CGIからみた戻りページへのパスとファイル our $backlink_name = '戻る'; # return page after sending a mail # 0: $backlinkのページへ 1:送信完了ページへ our $return_page = 0; # mail command # sendmailの場合、-tは必ず必用です。 our $mail_cmd = '/usr/sbin/sendmail -t'; # メール受信者 our $to_mail = 'yourname@yourdomain.com'; # Name on From: # 1: display, 0:no display our $mail_name = 1; # 名前のtextboxのサイズ our $name_textsize = 10; # メールのtextboxのサイズ our $mail_textsize = 15; # タイトルのtextboxのサイズ our $title_textsize = 15; # 本文のtextareaのサイズ our $textarea_rows = 5; our $textarea_cols = 30; #セキュリティイメージ 1:有効 0:無効 our $captcha_en = 0; #セキュリティイメージ画像サイズ our $capimage_width = 230; our $capimage_height = 80; #セキュリティイメージオプション our $scramble_en = 1; our $cap_text_num = 4; #文字数 our $cap_expire = 60; #有効期限(分) # セキュリティイメージデータディレクトリ our $capdatadir = 'capdata'; # ttffontファイルを絶対パスで。 "Document and Setting"のようなパス内のspace禁止 our $ttffont = "c:/windows/fonts/cour.ttf"; # ttfrontのポイントサイズ our $ttffont_ptsize = 30; ####################################### require "$setupfile" if (-e "$setupfile"); my $mail_pattern = '(^[\w\.\-]+\@[\w\.\-]+\.[a-zA-Z]{2,4}$|^$)'; my $q = CGI->new; my $cgierror = $q->cgi_error; &error($cgierror) if ($cgierror); my %in = $q->Vars; my $captcha; if ($captcha_en){ $captcha = GD::SecurityImage::AC->new; $captcha->gdsi( new => { width => $capimage_width, height => $capimage_height, lines => 10, scramble => $scramble_en, font => "$ttffont", ptsize => $ttffont_ptsize, }, create => ['ttf', 'rect', '#000000', '#555555'], particle => [500], ); if (! -d "$capdatadir") {mkdir $capdatadir;} $captcha->data_folder($capdatadir); $captcha->output_folder($capdatadir); $captcha->expire($cap_expire * 60); } if ($in{mode} eq 'send'){ &send; } else { &mainpage; } sub mainpage { print $q->header; print qq(