--- orig/item.cgi Wed May 12 09:21:06 2004 +++ item.cgi Mon May 17 15:15:54 2004 @@ -3,6 +3,7 @@ ; ############################################## # HPギア +# ver1.51(2004/05/11)見かけのURLを動的なものから静的なものへ変更 # ver1.50(2002/07/10) # ver1.40(2002/05/14)商品一覧の最大5列対応 # ver1.21(2002/04/21) @@ -12,6 +13,7 @@ # ※理由の如何を問わず「ショップギア」に連動しなくなるプログラムの改変は一切認めません。 ############################################## require './jcode.pl'; #日本語コード変換ライブラリ +use File::Basename; #プロ級仕様の場合、以下の値は変更可(特にディレクトリ等) $rec0 = "./data/item.dat"; #商品マスタのファイル名 @@ -19,6 +21,7 @@ $rec2 = "./data/footer.dat"; #htmlフッタのファイル名 $rec5 = "./data/cat.dat"; #カテゴリマスタのファイル名 $rec6 = "./data/shop.dat"; #ショップ設定値のファイル名 +$rec7 = "./data/default.css"; #カスケーディングスタイルシートのファイル名 #以下はshop.datから取得 $data_shop_id = ""; #ショップギアのショップギアID @@ -40,10 +43,10 @@ #■■■ ここから ■■■ -&put_header; #■ヘッダ作成 &get_pam; #■入力値取得 &de_code; #■入力値デコード &mae; #■前処理 +&put_header; #■ヘッダ作成 &main; #■メイン処理 &put_footer; #■フッタ作成 exit; @@ -54,8 +57,57 @@ print "Content-type: text/html\n\n"; if (open(TXT, "<$rec1")) { @txt_header = ; + + if ($pam_item ne "") { + + if (open(TXT, "<$rec0")) { + @txt = ; + close(TXT); + } + + @txt_temp; + + foreach $text (sort @txt) { + ($i_item,$nichi,$cat,$img,$com,$i_name,$i_tanka,$i_price,$i_zaiko,$i_suumei,$i_suutan,$i_suukai,$i_suuowa,$i_bi1mei,$i_bi1[0],$i_bi1[1],$i_bi1[2],$i_bi1[3],$i_bi1[4],$i_bi1[5],$i_bi1[6],$i_bi1[7],$i_bi1[8],$i_bi1[9],$i_bi1[10],$i_bi1[11],$i_bi1[12],$i_bi1[13],$i_bi1[14],$i_bi1[15],$i_bi1[16],$i_bi1[17],$i_bi1[18],$i_bi1[19],$i_bi2mei,$i_bi2[0],$i_bi2[1],$i_bi2[2],$i_bi2[3],$i_bi2[4],$i_bi2[5],$i_bi2[6],$i_bi2[7],$i_bi2[8],$i_bi2[9],$i_bi2[10],$i_bi2[11],$i_bi2[12],$i_bi2[13],$i_bi2[14],$i_bi2[15],$i_bi2[16],$i_bi2[17],$i_bi2[18],$i_bi2[19],$i_bi3mei,$i_bi3[0],$i_bi3[1],$i_bi3[2],$i_bi3[3],$i_bi3[4],$i_bi3[5],$i_bi3[6],$i_bi3[7],$i_bi3[8],$i_bi3[9],$i_bi3[10],$i_bi3[11],$i_bi3[12],$i_bi3[13],$i_bi3[14],$i_bi3[15],$i_bi3[16],$i_bi3[17],$i_bi3[18],$i_bi3[19],$i_keyword,$hide) = split(/,/, $text); + if ($i_item eq $pam_item) { + last; + } + } + + foreach (@txt_header) { + if (/__DESCRIPTION__/i) { + s|__DESCRIPTION__|$com|io; + } + if (/__CSS__/i) { + s|__CSS__|$script_dir/$rec7|io; + } + if (/__KEYWORDS__/i) { + s|__KEYWORDS__|$i_name|io; + } + if (/__TITLE__/i) { + s|__TITLE__|$i_name|io; + } + print; + } + + } else { + foreach (@txt_header) { + if (/__DESCRIPTION__/i) { + s|__DESCRIPTION__|$data_shop_name|io; + } + if (/__CSS__/i) { + s|__CSS__|$script_dir/$rec7|io; + } + if (/__KEYWORDS__/i) { + s|__KEYWORDS__,||io; + } + if (/__TITLE__/i) { + s|__TITLE__|$data_shop_name|io; + } + print; + } + } close(TXT); - print "@txt_header"; } } @@ -67,19 +119,46 @@ #■入力値デコード sub de_code { - @pairs = split(/&/,$buf2); - foreach $pair (@pairs) { - ($name,$value) = split(/=/,$pair); - $value =~ tr/+/ /; - $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; - $name =~ tr/+/ /; - $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; - &jcode'convert(*name,'sjis'); &jcode'convert(*value,'sjis'); - if ($value =~ /\r\n/) { $value =~ s/\r//g; } - elsif ($value =~ /\r/) { $value =~ s/\r/\n/g; } - if ($name eq "pam_i_page") { $pam_i_page = $value; } #商品ページ番号 - if ($name eq "pam_cat") { $pam_cat = $value; } #カテゴリ番号 - if ($name eq "pam_item") { $pam_item = $value; } #商品番号 + $script_name = $ENV{'SCRIPT_NAME'}; + $request_uri = $ENV{'REQUEST_URI'}; + $script_dir = dirname($script_name); + + if ($ENV{'QUERY_STRING'} =~ /=/) { + @pairs = split(/&/,$buf2); + foreach $pair (@pairs) { + ($name,$value) = split(/=/,$pair); + $value =~ tr/+/ /; + $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; + $name =~ tr/+/ /; + $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; + &jcode'convert(*name,'sjis'); &jcode'convert(*value,'sjis'); + if ($value =~ /\r\n/) { $value =~ s/\r//g; } + elsif ($value =~ /\r/) { $value =~ s/\r/\n/g; } + if ($name eq "pam_i_page") { $pam_i_page = $value; } #商品ページ番号 + if ($name eq "pam_cat") { $pam_cat = $value; } #カテゴリ番号 + if ($name eq "pam_item") { $pam_item = $value; } #商品番号 + } + } else { + $query_string = $ENV{'REQUEST_URI'}; + $query_string =~ s|$script_name/||; + + if ($query_string eq $script_name) { + $pam_i_page = 1; + } else { + (@param) = split(/\//, $query_string); + foreach (@param) { + if (/cat/) { + ($key_cat, $pam_cat) = split(/_/); + } + if (/page/) { + ($key_page, $pam_i_page) = split(/_/); + } + if (/item/) { + ($key_item, $pam_item) = split(/_/); + } + } + $pam_i_page = 1 if ($pam_i_page !~ /^[0-9]+$/); + } } } @@ -104,6 +183,7 @@ chop($data_my_cat = $txt[11]); #オリジナルのカテゴリ用HPを利用したい場合 chop($data_buy_img = $txt[12]); #購入ボタンを画像にしたい場合 chop($data_img_div = $txt[13]); #商品画像のセンタリング + chop($data_shop_name = $txt[14]); #ショップ名 } #■メイン処理 @@ -125,30 +205,30 @@ $temp = "(「$c_name」$data_cat内)"; } #ガイダンス出力 - print "
\n"; - print "|home\n"; + print "\n"; - print "
\n"; + print "|home\n"; if ($data_my_cat eq "") { - print "|$data_cat一覧\n"; #通常どおり自動作成catへのリンク + print "|$data_cat一覧\n"; #通常どおり自動作成catへのリンク } else { - print "|$data_cat一覧\n"; + print "|$data_cat一覧\n"; } if ($pam_cat eq "" && $pam_item eq "") { - print "|$data_item一覧\n"; + print "|$data_item一覧\n"; } else { - print "|$data_item一覧\n"; + print "|$data_item一覧\n"; } - print "|\n"; - print "
"; + print "| \n"; + print "\n"; + print "
"; print ""; print ""; - print "\n"; - print "
\n"; + print "|\n"; + print "
\n"; #商品一覧に文言を表示する(商品詳細HPの時は表示しない) if ($data_txt_i ne "" && $pam_item eq "") { print "
\n"; - print "
\n"; + print "
\n"; print "$data_txt_i
\n"; print "

\n"; } @@ -225,22 +305,22 @@ #◆サブ処理(ページリンクを出力) sub sub_link { - print "
\n"; + print "
\n"; print "Page "; #$iはページ数 #「前へ」を表示 for ($i = 1; $i * 10 * $retsu - 10 * $retsu < $ctr_num; $i++) { if ($i eq $pam_i_page && $i ne 1) { $i_temp = $i - 1; - print "前へ "; + print "前へ "; } } #12345を表示 for ($i = 1; $i * 10 * $retsu - 10 * $retsu < $ctr_num; $i++) { if ($i eq $pam_i_page) { - print "$i "; + print "$i "; } else { - print "$i "; + print "$i "; } } #「次へ」を表示 @@ -248,13 +328,13 @@ for ($i = 1; $i * 10 * $retsu - 10 * $retsu < $ctr_num; $i++) { if ($i eq $pam_i_page && $i ne $i_last) { $i_temp = $i + 1; - print "次へ "; + print "次へ "; } } if ($pam_cat eq "") { - print " $ctr_num$data_item
\n"; + print " $ctr_num$data_item
\n"; } else { - print " $ctr_num$data_item($c_name$data_cat内)
\n"; + print " $ctr_num$data_item($c_name$data_cat内)
\n"; } print "

\n"; } @@ -270,32 +350,32 @@ #◆サブ処理(formタグの出力1) sub sub_form1 { - print "$data_tbl"; #テーブルの形状 + print '
'; $_ = $i_price; s/\G((?:^-)?\d{1,3})(?=(?:\d\d\d)+(?!\d))/$1,/g; $i_price_format = $_; #金額桁数の整形 - print "$i_name"; - if ($i_tanka ne "") { print "($i_tanka)"; } - print " \\$i_price_format [$cat-$i_item]
"; + print "

$i_name

"; + if ($i_tanka ne "") { print "($i_tanka)"; } + print " \\$i_price_format [$cat-$i_item]
"; #画像(複数可) if ($img ne "") { @imgs = split(/::/,$img); foreach $imgs (@imgs) { if ($data_img_div eq "") { - print "

"; + print "
\"$i_name\"

"; } else { - print "

"; + print "
\"$i_name\"

"; } } } - print "$com
"; + print "$com
"; #↓ここからformタグ - print "
"; + print ""; print ""; print ""; print ""; #ここから下は右寄せ - print "
"; + print "
"; #在庫管理番号がある場合のみ数量表示 - if ($i_zaiko ne "") { print "在庫数
"; } + if ($i_zaiko ne "") { print "在庫数 \"在庫数\"
"; } print "$i_suumei"; #名称(例:購入数) #数量タグ if ($i_suukai eq $i_suuowa || $i_suuowa eq "") { @@ -353,36 +433,36 @@ if ($data_buy_img eq "") { print ""; } else { - print ""; + print ""; } #ここまで右寄せ - print "
"; - print "

\n"; + print ""; + print "

\n"; } #◆サブ処理(formタグの出力2) sub sub_form2 { #例えば、5列あった場合、1列目の時のみtableタグを出力 + $temp_w = int(100 / $retsu); if ($ctr_retsu eq 1) { - print "$data_tbl"; #テーブルの形状
+ print "
"; } else { - $temp_w = 100 / $retsu; - print ""; + print ""; } - print ""; + print ""; $_ = $i_price; s/\G((?:^-)?\d{1,3})(?=(?:\d\d\d)+(?!\d))/$1,/g; $i_price_format = $_; #金額桁数の整形 - print "$i_name"; - if ($i_tanka ne "") { print "($i_tanka)"; } - print " \\$i_price_format [$cat-$i_item]
"; + print "$i_name" . ""; + if ($i_tanka ne "") { print "($i_tanka)"; } + print " \\$i_price_format [$cat-$i_item]
"; #画像(複数可) if ($img ne "" && substr($data_detail,5,5) eq "image") { @imgs = split(/::/,$img); foreach $imgs (@imgs) { if ($data_img_div eq "") { - print "

\n"; + print "
\"$i_name\"

\n"; } else { - print "

\n"; + print "
\"$i_name\"

\n"; } } } @@ -415,7 +495,9 @@ if (open(TXT, "<$rec2")) { @txt_footer = ; close(TXT); - print "@txt_footer"; + foreach (@txt_footer) { + print; + } } } @@ -423,7 +505,7 @@ sub error { print "*** ERROR *** \n"; print "$_[0]\n"; - print "

\n"; + print "

\n"; print "ブラウザの「戻る」ボタンで前の画面に移動して下さい。
\n"; &put_footer; #フッタ作成 exit;