#!/usr/local/bin/perl
#///////////////////////////////////////////////////////////////////////////////
# Multi Shop Great Ver6.05
# ----- 2002(C) WEB INVENTOR(Solve) -----
# solve@wb-i.net
# http://wb-i.net/
#
# 【Ver4.00】csv形式のデータをメールに添付。注文ログの作成。
# 【Ver4.04】csv形式貴のデータのバグを修正すると共に、データ構成の変更。
# 販売管理(sale.csv)
# 注文番号,日付,商品番号,商品名,オプション1,オプション2,商品記号,単価,注文数,合計,送料,代引き料
# 【Ver4.05】注文の取消し、注文確定後にかごの中が完全に空にならないバグを修正。
# 【Ver5.00】外税、内税、税なしを設定できるようにしました。また、支払方法としてe-コレクトを設定できるようにしました。顧客管理(user.csv)及び注文ログに連絡事項を含めました。「次の戻る」の不具合を修正。
# 【Ver5.01】確認画面で「銀行振込」「郵便振替」が表示されないバグを修正。ロック及びCSVファイル書き込みの際にエラーが起きる場合がったバグを修正
# 【Great版】CSVファイルから商品一括登録機能付。画像のURL指定。詳細説明を拡大画像と共に表示。
# 【Ver5.02】CSVファイル及びログファイルに氏名2,郵便番号2,住所2,電話2を追加。
# 【Ver5.03】詳細画面にオプションを追加しました。携帯の詳細画面で説明を表示するようにしました。
# 【Ver5.04】商品画面でページ数を表示、非表示に設定できるようにしました。
# 【Ver5.06】CSVファイルを添付しない設定にしたときに連絡事項が設定されないバグを修正。
# 【Ver6.00】大分類、小分類を設定できるようにしました。
# 【Ver6.01】小分類をメニュー及び一覧表上部に表示または非表示に設定することできる。
# 【Ver6.02】一覧表上部に表示された小分類のバグを修正。
# 【Ver6.03】一覧の説明、詳細説明、携帯用説明を設定可能。配達時間指定が設定可能。
# 【Ver6.04】商品管理Goods Manager(画像ファイルUPロード機能付き)を標準装備。
# 【Ver6.05】sendmailの使用法を検討し、RFC基準に準拠するように努力しました。
#///////////////////////////////////////////////////////////////////////////////
#================================ [注意事項] ===================================
# このスクリプトはシェアウエアです。このスクリプトを使用したいかなる損害に対して
# も作者は一切の責任を負いません。
#====================================使用法=====================================
# 次のようにして呼び出してください。
# 1.商品画面
# http://・・/mu-shop.cgi PC用
# http://・・/k-shop.cgi i-mode、j-sky用(自動的に機種を判別する)
# 2.検索窓の設置
#
# 3.キーワード及び分類表からの呼び出しかた
# 当店お勧め
# 分類A
# $class_all
# 4.管理者用
# http://・・/mu_shop.cgi?mode=adm1
#
#===============================================================================
# ▼設定▼
#===============================================================================
# jcode.plへのパス
require './jcode.pl';
# cgi-lib.plへのパス
require './cgi-lib.pl';
# MIMEコード変換ライブラリ
require './mimew.pl';
# ===============================================================================
# ▲設定終了▲
# ===============================================================================
&ReadParse;
while (($key,$val) = each %in) {
&jcode'convert($val, "sjis");
$form{$key} = $val;
$val =~ s/<>//g;
if($form{'mode'} eq 'adm4' || $form{'mode'} eq 'order_form' || $form{'mode'} eq 'order_mail'){
$val =~ s/"/\"/g;
if ($key eq "MESS" || $key eq "setumei") {
$val =~ s/<//g;
$val =~ s/
/\n/g;
$val =~ s/\.\n/\. \n/g;
}else{
$val =~ s/</g;
$val =~ s/>/>/g;
$val =~ s/\r\n//g;
$val =~ s/\r//g;
$val =~ s/\n//g;
$val =~ s/\s//g;
}
}else{
$val =~ s/\"/"/g;
$val =~ s/\0/ /g;
if ($key eq "MESS" || $key eq "setumei" || $key eq "setumei2" || $key eq "setumei3") {
$val =~ s/\r\n/
/g;
$val =~ s/\r/
/g;
$val =~ s/\n/
/g;
if ($val =~ /
$/) {
while ($val =~ /
$/) { $val =~ s/
$//g; }
}
# $val =~ s/\s//g;
} else {
$val =~ s/</g;
$val =~ s/>/>/g;
$val =~ s/\r\n//g;
$val =~ s/\r//g;
$val =~ s/\n//g;
$val =~ s/\s//g;
}
}
$in{$key} = $val;
}
#=================注文加算============================================
if($in{'order'} eq ""){
# Cookieの値を得る
&getCookie();
$in{'order'} = $COOKIE{'ORDER'};
}
$order=$in{'order'};
$order_new =$in{'g_no'}.",".$in{'op1'}.",".$in{'op2'};
if($in{'amount'} ne "" and $in{'amount'} ne "0"){
if($order eq ""){
$order =$in{'g_no'}.",".$in{'op1'}.",".$in{'op2'}.":".$in{'amount'};
}else{
@order_1 = split(/!/,$order);
foreach (@order_1) {
($i,$j) = split(/:/,$_);
if($i eq $order_new){
$j = $j + $in{"amount"};
if($order_2 eq ""){
$order_2 =$order_new.":".$j;
}else{
$order_2 .="!".$order_new.":".$j;
}
$k =1;
}else{
if($order_2 eq ""){
$order_2 =$_;
}else{
$order_2 .="!".$_;
}
}
}
if($k ne 1){
$order .="!".$in{'g_no'}.",".$in{'op1'}.",".$in{'op2'}.":".$in{'amount'};
}else{
$order =$order_2;
}
}
$in{'order'}=$order;
}
#=================注文減算============================================
if($in{'del_no'} ne ""){
$order ="";
@order_1 = split(/!/,$in{'order'});
foreach (@order_1) {
($s,$t) = split(/:/,$_);
if($s eq $in{'del_no'}){next;}
if($order eq ""){
$order = $s.":".$t;
}else{
$order .="!".$s.":".$t;
}
}
$in{'order'}=$order;
}
#クッキーの設定
print &setCookie_0("ORDER", $order);
# 設定ファイル====================================================================
if ( $in{'mode'} eq 'order_mail' ) {
$in{'order'} ='';
require './mu_set.pl';
$in{'order'}=$order;
}else{
require './mu_set.pl';
}
#===== 戻り先========================================================
$save_data="$script?&keyword=$in{'keyword'}&FF=$in{'FF'}&class=$in{'class'}";
$modoru_adding = "$save_data&mode=adm2&pass=$adm_pass";
$modoru_dell = "$save_data&mode=adm3&pass=$adm_pass";
$modoru_renew = "$save_data&mode=adm4&pass=$adm_pass";
$modoru_goods ="$script?order=$in{'order'}&class=$in{'class'}&keyword=$in{'keyword'}&FF=$in{'FF'}&price_sort=$in{'price_sort'}";
$modoru_goods_2 ="$script?class=$in{'class'}&keyword=$in{'keyword'}&FF=$in{'FF'}&price_sort=$in{'price_sort'}";
$modoru_goods_end ="$script?class=$in{'class'}&keyword=$in{'keyword'}&FF=$in{'FF'}&price_sort=$in{'price_sort'}";
#====================================================================
if (!open(IN,"$data_file")) { &error('データベース読取エラー','復旧をお待ちください.'); }
@BASE = ;
close(IN);
if($in{'price_sort'} ne 1){
@BASE = reverse @BASE;
}else{
@BASE = sort { (split(/\<\>/,$a))[8] <=> (split(/\<\>/,$b))[8] } @BASE;
}
$hit = 0;
$next_num = '';
$over_no = 0;
if($in{'mode'} eq 'adm3' or $in{'mode'} eq 'addell'){
$page =$page_dell;
}
#=========消費税のの扱い====================
if($tax_flag eq '' or $tax_flag == 0){
$tax_set ='(税別)';
$br_tax_set ='
(税別)';
}elsif($tax_flag == 1){
$tax_set ='(税込)';
$br_tax_set ='
(税込)';
$syouhi_tax =0;
}else{
$syouhi_tax =0;
}
#====================================================================
if ( $in{'mode'} eq 'adding' ) { &adding; exit;}
if ( $in{'mode'} eq 'renew' ) { &renew; exit;}
if ( $in{'mode'} eq 'dell' ) { &dell; exit;}
if ( $in{'mode'} eq 'look' ) { &look; exit;}
if ( $in{'mode'} eq 'order_form' ) { &order_form; exit;}
if ( $in{'mode'} eq 'sure' ) { &sure; exit;}
if ( $in{'mode'} eq 'order_mail' ) { &order_mail; exit;}
if ( $in{'mode'} eq 'adm5' ) { &csv_adm; exit;}
if ( $in{'mode'} eq 'adm6' ) { &csv_adm_ok; exit;}
if ( $in{'mode'} eq 'adm7' ) { &csv_new; exit;}
#====================================================================
# Cookieの値を得る
&getCookie();
$classmei = $COOKIE{'BUNRUIMEI'};
$ff_no = $COOKIE{'FF'};
if($ff_no eq ''){$ff_no =0;}
$pas_word = $COOKIE{'WORD'};
if($in{'class'} ne ""){
$classmei = $in{'class'};
print &setCookie("BUNRUIMEI", $classmei);
}
if($in{'FF'} ne ""){
$ff_no = $in{'FF'};
print &setCookie('FF', $ff_no);
}
if($in{'keyword'} ne "" or $in{'superkey'} eq "1"){
$pas_word = $in{'keyword'};
print &setCookie('WORD', $pas_word);
}
$in{'keyword'} = $pas_word;
$in{'class'}=$classmei;
#===================================================================
$data_su= 0;
$data_ff =0;
foreach $num (0 .. $#BASE) {
$data = $data2 = $BASE[$num];
&jcode'convert(*data,'sjis');
($goods_no,$name,$kigou,$option,$option2,$class,$setumei,$fcolor,$price,$tani,$zaiko,$limit,$picture,$bikou) = split(/\<\>/,$data);
if($pas_word ne "") {
# 入力内容を整理
$word = $pas_word;
$word =~ s/ / /g;
$word =~ s/\t/ /g;
@pairs = split(/ /,$word);
($a,$b) =split(/\//,$class);
&class_name_get();
# 検索処理
$flag_k = 0;
foreach $pair (@pairs){
if (index($kigou,$pair) >= 0) {
next;
}elsif (index($name,$pair) >= 0) {
next;
}elsif (index($goods_no,$pair) >= 0) {
next;
}elsif (index($class_B,$pair) >= 0) {
next;
}elsif (index($class_S,$pair) >= 0) {
next;
}elsif (index($option,$pair) >= 0) {
next;
}elsif (index($setumei,$pair) >= 0) {
next;
}elsif (index($bikou,$pair) >= 0) {
next;
}elsif (index($price,$pair) >= 0) {
next;
}elsif (index($class,$pair) >= 0) {
next;
}
$flag_k = 1;
last;
}
if ($flag_k == 1) { next; }
}
if ($classmei ne "all" && $classmei ne "") {
($a1,$a2) =split(/\//,$class);
($b1,$b2) =split(/\//,$classmei);
if ($a1 ne $b1) { next; }
if ($b2 ne ''){
if($a2 ne $b2){ next;}
}
}
if ($in{'id'} ne '' && ($in{'mode'} eq 'adm4' or $in{'mode'} eq 'p_wide')) {
if ($goods_no eq $in{'id'}) {
push(@NEW,$data2);
last;
} else { next; }
}
$data_su++;
# 検索終了処理
if ($hit == $page) { $next_num = $data_ff; $over_no ++; $hit++; next; }
elsif($hit < $page && $data_ff >= $ff_no){
push(@NEW,$data2); $hit++;
}elsif($hit > $page && $data_ff >= $ff_no){
$over_no ++;
}
$data_ff ++;
}
if($over_no > $page){
$over_no = $page;
}
#=========================================================================================
if ( $in{'mode'} eq 'adm1' ) { &adm1; exit;}
elsif ( $in{'mode'} eq 'adm2' ) { &adm_add; exit;}
elsif ( $in{'mode'} eq 'adm3' ) { &adm_dell; exit;}
elsif ( $in{'mode'} eq 'adm4' ) { &adm_renew; exit;}
elsif ( $in{'mode'} eq 'p_wide' ) { &p_wide; exit;}
else { &shop_form; exit;}
#=============================画像の拡大(詳細)===========================================
sub p_wide {
&html_header();
if($zaiko eq ""){
$zaiko = 100000;
}
if($limit eq ""){
$limit =100000;
}
$kosuu_setting = "";
foreach ( @kosuu_set ) {
if($_ >$limit or $_ >$zaiko){
last;
}else{
$kosuu_setting .= "";
}
}
if($kosuu_setting eq ""){
$kosuu_setting = "$tani_set";
}else{
$kosuu_setting = "$tani_set";
}
$folder="$dir_p/order.gif";
if($zaiko ne 0){
$get_setting = "";
}else{
$get_setting = "在庫切れ";
}
($pic1,$pic2,$pic3,$pici,$picj) =split(/\|/,$picture);
if($pic1 eq ""){
$pic1 ="$dir_p/space.gif";
}
if($pic2 eq ""){
$pic2 ="$dir_p/space.gif";
}
if($pic3 eq ""){
$pic3 ="$dir_p/space.gif";
}
($setumei,$setumei2) =split(/\|\|/,$setumei);
@option = split(/\:/,$option);
$i = 0;
$option_set = "";
while($i < $option_no) {
($op_k[$i],$op_m[$i]) =split(/\,/,$option[$i]);
if($op_k[$i] eq ""){ $i++; next;}
$option_set = $option_set."\n";
$i++;
}
if($option_set ne ""){
$option_set = "";
}else{
$option_set ="\ ";
}
@option2 = split(/\:/,$option2);
$i = 0;
$option2_set = "";
while($i < $option2_no) {
($op2_k[$i],$op2_m[$i]) =split(/\,/,$option2[$i]);
if($op2_k[$i] eq ""){ $i++; next;}
$option2_set = $option2_set."\n";
$i++;
}
if($option2_set ne ""){
$option2_set = "";
}else{
$option2_set ="\ ";
}
print <<"EOF";
EOF
print <<"EOF";
EOF
#====================================
1 while $price =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理
print <<"EOF";
EOF
print <<"EOF";
EOF
print <<"EOF";
EOF
print "$foot