#!/usr/local/bin/perl ## cart.cgi v2.11 (2003/06/03) ## Copyright (c) KentWeb # 外部ファイル取り込み require './cartini.cgi'; require $jcode; # メイン処理 &decode; if ($mode eq "cart") { &cart; } elsif ($mode eq "note") { ¬e; } elsif ($mode eq "check") { ✓ } &menu; #----------------# # メニュー表示 # #----------------# sub menu { local($i,$n,$next,$back); # 在庫 &stock if ($stock); &header; print < EOM if ($t_image) { print "\"$title\"\n"; } else { print "
$title
\n"; } print <
$sub_msg
EOM # 検索窓 if ($find) { print "\n"; # 検索実行 if ($in{'word'} ne "") { &find; } print "
\n"; print "
\n"; print "\n"; foreach (0 .. $#key) { print "\n"; } print "\n"; print "
\n"; } # 買物受付け if ($key[0]) { &pick; } # カテゴリ表示 if ($category == 2) { &category; } if ($page eq '') { $page=0; } $gview *= $rview; print "\n"; $i=0; $n=0; open(IN,"$logfile") || &error("Open Error: $logfile"); while () { $n++; if ($n < $page + 1) { next; } if ($n > $page + $gview) { last; } if ($i >= $rview) { print ""; $i=0; } $i++; if ($category) { $span=6; } else { $span=5; } if ($stock) { $span++; } chop; ($no,$item,$price,$size,$color,$img,$memo,$w,$h,$intax,$nmb,$id,$cate,$link) = split(/<>/); if ($size) { $span++; } if ($color) { $span++; } if ($memo) { $span++; } if (!$imgview && $img) { $item = "$item"; } $price2 = &filler($price); if ($id eq "") { $id = $no; } print ""; } close(IN); print "
"; print "
\n"; print "\n"; print "\n"; # 注文オーダ蓄積 foreach (0 .. $#key) { print "\n"; } print "\n"; print ""; # 画像 if ($img && $imgview) { print "\n"; print "\n"; } else { print "\n"; } print "\n"; if ($category) { if ($cate eq "") { $cate = 0; } print ""; print "\n"; } print "\n"; if ($stock) { if (!defined($stock{$no})) { $stock{$no}=0; } print "\n"; } print ""; # 入力 $flag=0; $pnum=$psize=$pcol=''; foreach (0 .. $#key) { if ($no == $key[$_]) { $flag=1; ($pnum,$psize,$pcol) = split(/:/, $val[$_]); last; } } if (!$flag) { $pnum = 0; } if ($nmb) { @nmb = split(/\s+/, $nmb); print "\n"; } else { print "\n"; } if ($size) { @size = split(/\s+/, $size); print "\n"; } if ($color) { @color = split(/\s+/, $color); print "\n"; } if ($memo) { print "\n"; } print "
商品No$id"; if ($w && $h) { $wh = "width=$w height=$h"; } print "" if ($link); print "\"$id\""; print "" if ($link); print "
$id
商品名 $item
カテゴリ$cate[$cate]
単価 \\$price2 "; if ($intax == 1) { print "(税込み)"; } else { print "(税別)"; } print "
在庫   $stock{$no}
数量
$attr1
$attr2
備考 $memo
購入"; if ($stock && $stock{$no} <= 0) { print "在庫切れ"; } else { print ""; } print "
\n"; # ページ繰越ボタン $next = $page + $gview; $back = $page - $gview; print "

\n"; if ($back >= 0) { print "\n"; } if ($next < $n) { print "\n"; } # 著作権表示(削除改編を禁止します) print <<"EOM";
\n"; print "\n"; foreach (0 .. $#key) { print "\n"; } print "
\n"; print "\n"; foreach (0 .. $#key) { print "\n"; } print "


- Shopping Cart - EOM exit; } #------------# # 買物処理 # #------------# sub pick { local($order,$all1,$all2,$tax); # データ認識 %pick=(); open(IN,"$logfile") || &error("Open Error: $logfile"); while () { ($no) = split(/<>/); $pick{$no} = $_; } close(IN); # 在庫認識 if ($stock) { &stock; } # 買い物 $order=0; foreach (0 .. $#key) { ($pnum) = split(/:/, $val[$_]); if (length($pnum) > $maxlen) { &error("注文個数は$maxlen桁までです"); } if ($pnum > 0) { $order++; } ($no,$item,$price,$size,$col,$img,$memo,$w,$h,$intax,$nmb) = split(/<>/, $pick{$key[$_]}); # 在庫数チェック if ($stock) { if ($stock{$key[$_]} < $pnum) { &error("購入個数が在庫数をオーバーしています"); } $stock{$key[$_]} -= $pnum; } $price2 = $price * $pnum; if ($intax == 1) { $in_tax += $price2; } else { $no_tax += $price2; } } # 0個の場合 if (!$order) { return; } # 小計 $all_pr2 = $in_tax + $no_tax; $tax = $no_tax * $pertax; $all_pr3 = $all_pr2 + $tax; $tax = &filler($tax); $all_pr2 = &filler($all_pr2); $all_pr3 = &filler($all_pr3); print "

\n"; # 注文オーダ蓄積 foreach (0 .. $#key) { print "\n"; } # 合計金額表示 print <<"EOM";
小 計: \\$all_pr2 消費税: \\$tax 合計金額: \\$all_pr3

EOM } #------------# # 注文処理 # #------------# sub cart { # 買い物締めチェック if ($in{'job'} == 2 && @key == 0) { &header; print <

買い物カゴの中身が空です。

注文を行うにはメニューに戻って買い物カゴに商品を入れてください。

EOM exit; # 住所入力チェック } elsif ($in{'job'} == 3) { if ($in{'name'} eq "") { &error("名前の入力がありません"); } if ($in{'addr'} eq "") { &error("住所の入力がありません"); } if ($in{'tel'} eq "") { &error("電話の入力がありません"); } if ($in{'email'} !~ /[\w\.\-]+\@[\w\.\-]+\.[a-zA-Z]{2,6}$/) { &error("E-Mailの入力が不正です"); } # 支払選択の場合 if ($payment && $in{'payment'} eq "") { &error('支払方法の選択がありません'); } # 配達月日 if ($deliver) { if (($in{'mon'} eq "" && $in{'day'} ne "") || ($in{'mon'} ne "" && $in{'day'} eq "")) { &error('配達の月日が不完全です'); } elsif ($in{'mon'} && $in{'day'}) { if ($in{'mon'} > 12 || $in{'mon'} < 1) { &error('あり得ない月です'); } if ($in{'day'} > 31 || $in{'mon'} < 1) { &error('あり得ない日です'); } } } # 郵便番号 if ($postno && $in{'yuno'} !~ /^\d{3}\-?\d{4}$/) { &error('郵便番号は7桁の数字が必要です
「3桁 - 4桁」で入力してください'); } # クッキー情報格納 } elsif ($in{'job'} == 4) { $in{'addr'} =~ s/<br>/
/g; $in{'addr2'} =~ s/<br>/
/g; $in{'note'} =~ s/<br>/
/g; &set_cookie($in{'comp'},$in{'name'},$in{'yuno'},$in{'addr'},$in{'tel'},$in{'fax'},$in{'email'},$in{'comp2'},$in{'name2'},$in{'yuno2'},$in{'addr2'},$in{'tel2'},$in{'fax2'},$in{'cook'}); } # 取消処理 if ($in{'del'} ne "") { @k=(); @v=(); foreach (0 .. $#key) { if ($_ == $in{'del'}) { next; } push(@k,$key[$_]); push(@v,$val[$_]); } @key=@k; @val=@v; } &header; print "
\n"; print "\n"; print "\n"; print "
\n"; print "
\n"; # 状況表示 &order_view($in{'job'}); # 確定処理 if ($in{'job'} == 4) { # ロック開始 &lock if ($lockkey); # 注文の受理 &sendmail; # ロック解除 &unlock if ($lockkey); # 完了メッセージ print "

ご利用ありがとうございました

\n"; exit; } # 注文表 print < EOM if ($in{'job'} eq "") { print "\n"; $colspan=7; } else { print "\n"; $colspan=6; } # データ認識 %pick=(); open(IN,"$logfile") || &error("Open Error: $logfile"); while () { ($no) = split(/<>/); $pick{$no} = $_; } close(IN); # 在庫認識 if ($stock) { &stock; } # 購入処理 foreach (0 .. $#key) { ($pnum,$psize,$pcol) = split(/:/, $val[$_]); ($no,$item,$price,$size,$color,$img,$memo,$w,$h,$intax,$nmb,$id,$cate,$link) = split(/<>/, $pick{$key[$_]}); # 在庫数チェック if ($stock) { if ($stock{$key[$_]} < $pnum) { &error("商品購入個数が在庫数をオーバーしています"); } $stock{$key[$_]} -= $pnum; } # 合価 $price2 = $price * $pnum; # 税 if ($intax == 1) { $in_tax += $price2; $zei = "込み"; } else { $no_tax += $price2; $zei = "別"; } $ten += $pnum; # 桁区切り $price = &filler($price); $price2 = &filler($price2); if ($psize eq "") { $psize="
"; } if ($pcol eq "") { $pcol="
"; } if ($memo eq "") { $memo="
"; } if ($id eq "") { $id = $no; } print "
"; if ($in{'job'} eq "") { print "\n"; } print "\n"; } # 桁区切り $all_pr2 = $in_tax + $no_tax; if ($all_pr2 eq "") { $all_pr2 = 0; } if ($all_tax eq "") { $all_tax = 0; } $all_pr2 = &filler($all_pr2); print < \n"; if ($in{'job'} == 3) { $tax = int $no_tax * $pertax; $all = $in_tax + $no_tax + $tax; $tax = &filler($tax); $all = &filler($all); print "\n"; } print <

EOM $submit = '住所入力画面へ移動'; if ($in{'job'}) { $job = $in{'job'}+1; } else { $job=2; } print "\n"; foreach (0 .. $#key) { print "\n"; } ## 住所入力 if ($in{'job'} == 2) { # ボタン名を定義 $submit = '注文確認画面へ移動'; # 支払方法 if ($payment) { print "

商品No商品名 数量単価 合価消費税 $attr1$attr2 備考取消
$id $item $pnum $price $price2 $zei $psize $pcol $memo
\n"; foreach (0 .. $#key) { print "\n"; } print "
小計 \\$all_pr2 EOM if ($in{'job'} != 3 && $no_tax > 0) { print "(消費税は計算されていません)"; } else { print "
"; } print "
消費税 \\$tax
合計 \\$all
支払方法(選択必須)
\n"; foreach (0 .. $#payment) { if ($_ == $paycheck-1) { print "$payment[$_]  \n"; } else { print "$payment[$_]  \n"; } } print "
\n"; } # 送料 if ($postage) { print "

送料 (上記金額とは別途にかかります)
$postage2
\n"; } # 配達日時 if ($deliver) { print "

希望配達日時 (ご希望がある場合に記入してください)
希望日 日    時間帯
\n"; } # クッキー取得 local($ccom,$cnam,$cyu,$cadr,$ctel,$cfax,$ceml,$ccom2,$cnam2,$cyu2,$cadr2,$ctel2,$cfax2,$cck) = &get_cookie; $cadr =~ s/
/\r/g; $cadr2 =~ s/
/\r/g; print < EOM # CCメール if ($ccmail) { print "\n"; } if ($cck eq "on") { $chk=" checked"; } else { $chk=""; } print <

注文者 ( 入力必須 )
会社名
名前
郵便番号 EOM print " " if ($postno); print <   (例 : 103-0225)
住所
電話
FAX
E-Mail
注文控え (チェックを入れると注文内容の写しを送信します)
配送先(注文者の住所と異なる場合に記入)
会社名
名前
郵便番号   (例 : 103-0225)
住所
電話
FAX

クッキー情報(注文者と配達先情報を次回以降に自動表\示します)
保存する

備考(ご要望、ご質問などをどうぞ・・)
EOM ## 確認画面 } elsif ($in{'job'} == 3) { $submit = '上記内容で確定処理をする'; print "

\n"; print "
\n"; if ($payment) { print "\n"; print "
支払い方法
$payment[$in{'payment'}]

\n"; } if ($postage) { print "
送料(上記金額とは別にかかります)\n"; print "
$postage2

\n"; } if ($deliver) { print "
希望配達日時
"; if ($in{'mon'} ne "" && $in{'day'} ne "") { print "$in{'mon'}月 $in{'day'}日 "; } else { print "月日指定なし "; } if ($in{'hour'} ne "") { print "$deli[$in{'hour'}]"; } else { print "時間帯指定なし"; } print "

\n"; } # 改行処理 $in{'addr'} =~ s/\r\n/
/g; $in{'addr'} =~ s/\r/
/g; $in{'addr'} =~ s/\n/
/g; $in{'addr2'} =~ s/\r\n/
/g; $in{'addr2'} =~ s/\r/
/g; $in{'addr2'} =~ s/\n/
/g; $in{'note'} =~ s/\r\n/
/g; $in{'note'} =~ s/\r/
/g; $in{'note'} =~ s/\n/
/g; 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 "\n"; print "\n"; print "\n"; print "\n"; print "
注文者情報\n"; print "
[会社名]
$in{'comp'}\n" if ($in{'comp'}); print "
[名前]
$in{'name'}\n"; print "
[郵便番号]
$in{'yuno'}\n" if ($in{'yuno'}); print "
[住所]
$in{'addr'}\n"; print "
[電話]
$in{'tel'}\n"; print "
[FAX]
$in{'fax'}\n" if ($in{'fax'}); print "
[E-Mail]
$in{'email'}\n"; if ($ccmail) { print "
[注文控え]"; if ($in{'cc'}) { print "
必要\n"; } else { print "
不要\n"; } } print "

\n"; print "
送付先情報\n"; print "
[会社名]
$in{'comp2'}\n" if ($in{'comp2'}); print "
[名前]
$in{'name2'}\n" if ($in{'name2'}); print "
[郵便番号]
$in{'yuno2'}\n" if ($in{'yuno2'}); print "
[住所]
$in{'addr2'}\n" if ($in{'addr2'}); print "
[電話]
$in{'tel2'}\n" if ($in{'tel2'}); print "
[FAX]
$in{'fax2'}\n" if ($in{'fax2'}); if (!$in{'comp2'} && !$in{'name2'} && !$in{'yuno2'} && !$in{'addr2'} && !$in{'tel2'} && !$in{'fax2'}) { print "
特になし\n"; } if ($in{'cook'} eq "on") { $ck = '保存する'; } else { $ck = '保存しない'; } print "

クッキー情報
$ck\n"; print "

備考
$in{'note'}\n" if ($in{'note'}); print "
\n"; } print <
EOM if (!$in{'job'}) { print "
\n"; print "\n"; foreach (0 .. $#key) { print "\n"; } print "\n"; } else { print " "; } print <
EOM exit; } #------------# # 検索実行 # #------------# sub find { # 戻りボタン print < EOM foreach (0 .. $#key) { print "\n"; } print < EOM # 買物受付け if ($key[0]) { &pick; } # 入力内容を整理 $in{'word'} =~ s/ / /g; @wd = split(/\s+/, $in{'word'}); # リスト print < EOM if ($stock) { print ""; } print <情報 EOM # 検索 $i=0; open(IN,"$logfile") || &error("Open Error: $logfile"); while () { chop; ($no,$item,$price,$size,$col,$img,$memo,$w,$h,$intax,$nmb,$id,$cate,$link) = split(/<>/); $flag=0; foreach $wd (@wd) { if (index("$item$memo",$wd) >= 0) { $i++; if ($i % 2) { $line=$lin1; } else { $line=$lin2; } if ($img) { $item = "$item"; } $price = &filler($price); print ""; print "\n"; print "\n"; print "\n"; foreach (0 .. $#key) { print "\n"; } if ($intax == 1) { $zei="税込み"; } else { $zei="税別"; } if ($id eq "") { $id = $no; } print ""; if ($stock) { if (!defined($stock{$no})) { $stock{$no}=0; } print ""; } print "\n"; } } } close(IN); print < EOM exit; } #------------# # 状況表示 # #------------# sub order_view { local($job) = @_; local($col1,$col2,$col3,$col4,$col5,$col6,$col7,$col8,$msg); if ($job == 2) { $col1 = $col3 = $col4 = $col5 = $col7 = $col8 = "#808080"; $col2 = "white"; $col6 = "yellow"; $msg = "必要事項を入力してください。\n"; } elsif ($job == 3) { $col1 = $col2 = $col4 = $col5 = $col6 = $col8 = "#808080"; $col3 = "white"; $col7 = "yellow"; $msg = "これでよろしければ送信ボタンを押してください。\n"; } elsif ($job == 4) { $col1 = $col2 = $col3 = $col5 = $col6 = $col7 = "#808080"; $col4 = "white"; $col8 = "yellow"; $msg = "ありがとうございます。注文を受け付けました。\n"; } else { $col1 = "white"; $col2 = $col3 = $col4 = $col6 = $col7 = $col8 = "#808080"; $col5 = "yellow"; $msg = "ご注文ありがとうございます。内容をご確認ください。\n"; } print <<"EOM";
商品No 商品名 単価在庫数量 購入
$id $item \\$price ($zei)$stock{$no}"; if ($size) { @size = split(/\s+/, $size); print "($attr1)

\n"; } if ($col) { @col = split(/\s+/, $col); print "($attr2)

\n"; } print "(備考)
$memo
"; if ($nmb) { @nmb = split(/\s+/, $nmb); print "\n"; } else { print ""; } print ""; if ($stock && $stock{$no} <= 0) { print "在庫切れ"; } else { print ""; } print "
内容確認 住所入力 注文確認 確定

$msg EOM } #----------------# # カテゴリ表示 # #----------------# sub category { local($next, $back); # カテゴリメニュー if ($in{'view'} eq "") { print < ▼最初にカテゴリーをお選びください。

EOM $i=0; $f=0; $j=0; open(IN,"$logfile") || &error("Open Error: $logfile"); while () { ($no,$item,$price,$size,$col,$img,$memo,$w,$h,$intax,$nmb,$id,$cate,$link) = split(/<>/); if ($cate2 ne $cate) { if ($f) { $f=0; print "\n"; $i=0; } $f=1; print ""; print ""; $j++; } $cate2 = $cate; $i++; } close(IN); if ($f) { print "\n"; } # 著作権表示(削除改編禁止) print <

- Shopping Cart - EOM exit; # カテゴリの中身を表示 } else { # 在庫 &stock if ($stock); print <
内容閲覧 カテゴリー 商品数
$i
\n"; foreach (0 .. $#key) { print "\n"; } print "
"; if (@cateImg > 0) { print ""; } print "$cate[$cate]
$i
$cate[$in{'view'}]
EOM foreach (0 .. $#key) { print "\n"; } print <
EOM if ($stock) { print ""; } print <情報 EOM $k=0; open(IN,"$logfile") || &error("Open Error: $logfile"); while () { ($no,$item,$price,$size,$col,$img,$memo,$w,$h,$intax,$nmb,$id,$cate,$link) = split(/<>/); next if ($in{'view'} != $cate); $k++; if ($k < $page + 1) { next; } if ($k > $page + $pageView) { next; } $i++; if ($intax == 1) { $zei="税込み"; } else { $zei="税別"; } if ($id eq "") { $id = $no; } $price = &filler($price); print "
\n"; print "\n"; print "\n"; foreach (0 .. $#key) { print "\n"; } print "
"; if ($stock) { if (!defined($stock{$no})) { $stock{$no}=0; } print ""; } print "\n"; } close(IN); print "
商品No 商品 単価在庫数量 購入
$id$item"; # 画像 if ($img) { if ($w && $h) { $wh="width=$w height=$h"; } print "

" if ($link); print "\"$item\""; print "" if ($link); } print "

"; print "\\$price ($zei)$stock{$no}"; if ($size) { @size = split(/\s+/, $size); print "($attr1)


\n"; } else { print " "; } if ($col) { @col = split(/\s+/, $col); print "($attr2)


\n"; } else { print " "; } if ($memo eq "" && $link eq "") { $memo="
"; } else { print "(備考)
"; } print "$memo
"; if ($nmb) { @nmb = split(/\s+/, $nmb); print "\n"; } else { print ""; } print ""; if ($stock && $stock{$no} <= 0) { print "在庫切れ"; } else { print ""; } print "
\n"; } ## $next = $page + $pageView; $back = $page - $pageView; print "

\n"; if ($back >= 0) { print "\n"; } if ($next < $k) { print "\n"; } print < EOM exit; } #--------------# # メール送信 # #--------------# sub sendmail { local($msub, $mbody, $ordlog, $in_tax, $no_tax); # データ認識 %pick=(); open(IN,"$logfile") || &error("Open Error: $logfile"); while () { ($no) = split(/<>/); $pick{$no} = $_; } close(IN); # 在庫認識 if ($stock) { &stock; } # ホスト名・日付 local($date,$datm) = &get_time; local($host) = &get_host; # メール本文 $mbody = </, $pick{$key[$_]}); # 在庫数チェック if ($stock) { if ($stock{$key[$_]} < $pnum) { &error("商品購入個数が在庫数をオーバーしています"); } $stock{$key[$_]} -= $pnum; } $price2 = $price * $pnum; if ($intax == 1) { $in_tax += $price2; $zei = "税込み"; } else { $no_tax += $price2; $zei = "税別"; } $ten += $pnum; # 桁区切り $price = &filler($price); $price2 = &filler($price2); $i++; if ($id eq "") { $id = $no; } $mbody .= "($i) $item ($id)"; $mbody .= " $attr1($psize)" if ($psize ne ""); $mbody .= " $attr2($pcol)" if ($pcol ne ""); $mbody .= "\n $price × $pnum = \\$price2 [$zei]\n"; # $mbody .= "消費税 \\$tax 小計 \\$price3\n"; $mbody .= "-" x 74 . "\n"; } # 総計 $all_pr2 = $in_tax + $no_tax; $tax = int $no_tax * $pertax; $all_pr3 = $all_pr2 + $tax; $tax = &filler($tax); $all_pr2 = &filler($all_pr2); $all_pr3 = &filler($all_pr3); $mbody .= "小 計 : \\$all_pr2\n"; $mbody .= "消費税 : \\$tax\n"; $mbody .= "合 計 : \\$all_pr3\n"; $mbody .= "-" x 74 . "\n"; # 改行等復元 $in{'addr'} =~ s/
/\n /g; $in{'addr2'} =~ s/
/\n /g; $in{'note'} =~ s/
/\n/g; $mbody .= "\n▼支払方法:\n$payment[$in{'payment'}]\n" if ($payment); if ($deliver) { $mbody .= "\n▼配達日時:\n"; if ($in{'mon'} ne "" && $in{'day'} ne "") { $mbody .= "$in{'mon'}月 $in{'day'}日 "; } else { $mbody .= "月日指定なし "; } if ($in{'hour'} ne "") { $mbody .= "$deli[$in{'hour'}]\n"; } else { $mbody .= "時間帯指定なし\n"; } } $mbody .= "\n▼注文者:\n"; $mbody .= "e-mail = $in{'email'}\n"; $mbody .= "会社名 = $in{'comp'}\n" if ($in{'comp'}); $mbody .= "名前 = $in{'name'}\n"; $mbody .= "郵便番号 = $in{'yuno'}\n" if ($in{'yuno'}); $mbody .= "住所 = $in{'addr'}\n"; $mbody .= "電話 = $in{'tel'}\n"; $mbody .= "FAX = $in{'fax'}\n" if ($in{'fax'}); if ($ccmail) { if ($in{'cc'}) { $cc='必要'; } else { $cc='不要'; } $mbody .= "注文控 = $cc\n"; } $mbody .= "\n▼配送先:\n" if ($in{'comp2'} || $in{'name2'} || $in{'yuno2'} || $in{'addr2'} || $in{'tel2'} || $in{'fax2'}); $mbody .= "会社名 = $in{'comp2'}\n" if ($in{'comp2'}); $mbody .= "名前 = $in{'name2'}\n" if ($in{'name2'}); $mbody .= "郵便番号 = $in{'yuno2'}\n" if ($in{'yuno2'}); $mbody .= "住所 = $in{'addr2'}\n" if ($in{'addr2'}); $mbody .= "電話 = $in{'tel2'}\n" if ($in{'tel2'}); $mbody .= "FAX = $in{'fax2'}\n" if ($in{'fax2'}); $mbody .= "\n▼備考:\n$in{'note'}\n" if ($in{'note'}); # タグ等復元 $ordlog = $mbody; $mbody =~ s/"/"/g; $mbody =~ s/<//g; # メール送信 if ($ordertype == 1) { # メール件名を定義 $msub = "注文メール ($in{'name'} 様)"; $msub = &base64($msub); # sendmail起動 open(MAIL,"| $sendmail -t"); print MAIL "To: $mailto\n"; print MAIL "From: $in{'email'}\n"; print MAIL "Cc: $in{'email'}\n" if ($in{'cc'}); print MAIL "Subject: $msub\n"; print MAIL "Date: $datm\n"; print MAIL "MIME-Version: 1.0\n"; print MAIL "Content-type: text/plain; charset=ISO-2022-JP\n"; print MAIL "Content-Transfer-Encoding: 7bit\n"; print MAIL "X-Mailer: $ver\n\n"; foreach ( split(/\n/, $mbody) ) { &jcode'convert(*_, "jis", "sjis"); print MAIL $_, "\n"; } close(MAIL); } # 在庫更新 if ($stock) { local($k,$v); open(OUT,">$stkfile") || &error("Write Error: $stkfile"); while (($k,$v) = each %stock) { print OUT "$k<>$v<>\n"; } close(OUT); } # 新規注文ログ定義 $ordlog =~ s/\n/
/g; @new=("$ordlog\n"); # 既存ログ読み出し $i=0; open(IN,"$ordfile") || &error("Open Error: $ordfile"); while () { $i++; push(@new,$_); last if ($i >= $max-1); } close(IN); # 更新 open(OUT,">$ordfile") || &error("Write Error: $ordfile"); print OUT @new; close(OUT); } #------------# # 留意事項 # #------------# sub note { &header; print <

特定商取引に関する法律の表\示

\n"; print "\n"; foreach (0 .. $#key) { print "\n"; } print "\n"; print "
\n"; print "\n"; foreach (0 .. $#key) { print "\n"; } print "\n"; print "
EOM
	open(IN,"$rawfile") || &error("Open Error: $rawfile");
	print ;
	close(IN);

	print <

EOM if ($in{'job'} eq "blank") { print ""; } else { print ""; } print < EOM exit; } #------------# # 時間取得 # #------------# sub get_time { $ENV{'TZ'} = "JST-9"; local($sec,$min,$hour,$mday,$mon,$year,$wday) = localtime(time); local(@w) = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); local(@m) = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); # 日時のフォーマット local($d1) = sprintf("%04d/%02d/%02d(%s) %02d:%02d", $year+1900,$mon+1,$mday,$w[$wday],$hour,$min); local($d2) = sprintf("%s, %02d %s %04d %02d:%02d:%02d", $w[$wday],$mday,$m[$mon],$year+1900,$hour,$min,$sec) . " +0900"; return ($d1,$d2); } #--------------# # ホスト取得 # #--------------# sub get_host { local($host, $addr); $host = $ENV{'REMOTE_HOST'}; $addr = $ENV{'REMOTE_ADDR'}; if ($host eq "" || $host eq $addr) { $host = gethostbyaddr(pack("C4", split(/\./, $addr)), 2) || $addr; } $host; } #----------------# # クッキー発行 # #----------------# sub set_cookie { local(@cook) = @_; local($gmt, $cook, @t, @m, @w); @t = gmtime(time + 60*24*60*60); @m = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); @w = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat'); # 国際標準時を定義 $gmt = sprintf("%s, %02d-%s-%04d %02d:%02d:%02d GMT", $w[$t[6]], $t[3], $m[$t[4]], $t[5]+1900, $t[2], $t[1], $t[0]); # 保存データをURLエンコード $cook=''; foreach (@cook) { s/(\W)/sprintf("%%%02X", unpack("C", $1))/eg; $cook .= "$_<>"; } # 格納 if ($in{'cook'} eq "on") { print "Set-Cookie: SHOP_CART=$cook; expires=$gmt\n"; } else { print "Set-Cookie: SHOP_CART=; expires=$gmt\n"; } } #----------------# # クッキー取得 # #----------------# sub get_cookie { local($key, $val, *cook); # クッキーを取得 $cook = $ENV{'HTTP_COOKIE'}; # 該当IDを取り出す foreach ( split(/;/, $cook) ) { ($key, $val) = split(/=/); $key =~ s/\s//g; $cook{$key} = $val; } # データをURLデコードして復元 @cook=(); foreach ( split(/<>/, $cook{'SHOP_CART'}) ) { s/%([0-9A-Fa-f][0-9A-Fa-f])/pack("C", hex($1))/eg; push(@cook,$_); } return (@cook); } #------------------# # チェックモード # #------------------# sub check { &header; print <Check Mode
    EOM foreach ($logfile, $ordfile, $stkfile) { if (-e $_) { print "
  • $_のパスOK\n"; } else { print "
  • $_のパスNG\n"; } if (-r $_ && -w $_) { print "
  • $_のパーミッションOK\n"; } else { print "
  • $_のパーミッションNG\n"; } } # ロックディレクトリ print "
  • ロック形式:"; if ($lockkey == 0) { print "ロック設定なし\n"; } else { if ($lockkey == 1) { print "symlink\n"; } else { print "mkdir\n"; } ($lockdir) = $lockfile =~ /(.*)[\\\/].*$/; print "
  • ロックディレクトリ:$lockdir\n"; if (-d $lockdir) { print "
  • ロックディレクトリのパス:OK\n"; if (-r $lockdir && -w $lockdir && -x $lockdir) { print "
  • ロックディレクトリのパーミッション:OK\n"; } else { print "
  • ロックディレクトリのパーミッション:NG → $lockdir\n"; } } else { print "
  • ロックディレクトリのパス:NG → $lockdir\n"; } } # 送信方式 if ($ordertype == 1) { print "
  • 注文方式:メール送信\n"; # sendmailチェック if (-e $sendmail) { print "
  • sendmailパス:OK!\n"; } else { print "
  • sendmailパス:NG → $sendmail\n"; } } else { print "
  • 注文方式:ログ蓄積\n"; } # jcode.pl バージョンチェック print "
  • jcode.plバージョンチェック:"; open(IN, $jcode); while () { if (/jcode\.pl\,v (\d)\.(\d+)/) { $v1=$1; $v2=$2; $flag=1; last; } } close(IN); if ($v1 < 2 || $v2 < 13) { print "バージョンが低いようです。→ $v1.$v2\n"; } else { print "バージョンOK (v $v1.$v2)\n"; } print <

    $ver EOM exit; } #--------------# # BASE64変換 # とほほのWWW入門で公開されているルーチンを #--------------# 参考にしました。( http://tohoho.wakusei.ne.jp/ ) sub base64 { local($sub) = $_[0]; &jcode'convert(*sub, 'jis', 'sjis'); $sub =~ s/\x1b\x28\x42/\x1b\x28\x4a/g; $sub = "=?iso-2022-jp?B?" . &b64enc($sub) . "?="; $sub; } sub b64enc { local($ch)="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; local($x, $y, $z, $i); $x = unpack("B*", $_[0]); for ($i=0; $y=substr($x,$i,6); $i+=6) { $z .= substr($ch, ord(pack("B*", "00" . $y)), 1); if (length($y) == 2) { $z .= "=="; } elsif (length($y) == 4) { $z .= "="; } } $z; } __END__