= 1 && $month <= 2){ $ret = 16; } if($month >= 3 && $month <= 5){ $ret = 13; } if($month >= 6 && $month <= 8){ $ret = 14; } if($month >= 9 && $month <= 11){ $ret = 15; } if($month == 12){ $ret = 16; } return $ret; } /* データタイプの取得 */ // $type = $_GET["type"]; define("DATA_TYPE", $type); /* テンプレートの読み込み(データ繰り返し部分) */ // $roop = array(); $roopflg = 0; $tmpl = TEMPLATE_DIR."search_".DATA_TYPE.".tmpl"; $fp = fopen($tmpl,"r"); while($line = @fgets($fp, 1024)){ if(ereg("<\? RESULT \?>", $line, $match)){ if($roopflg){ $roopflg = 0; } else { $roopflg = 1; } } else { if($roopflg){ $roop[] = $line; } } } fclose($fp); /* キーワードの取得 */ // $keyword = urldecode($_GET["keyword"]); $keyword = htmlspecialchars($keyword); $s_key = mb_convert_encoding($keyword, "EUC", "SJIS"); if(preg_match("/ /i", $s_key)){ $key = explode(" ", $s_key); } else { $key[] = $s_key; } /* ニュースデータ検索 */ // if(DATA_TYPE == 'news'){ /* キーワードが存在する場合のみ検索実施 */ // if($s_key != ''){ /* 検索用フィールド番号の取得 */ // $n_genre = mb_convert_encoding("ジャンル", "EUC", "SJIS"); $n_title = mb_convert_encoding("見出し", "EUC", "SJIS"); $n_text = mb_convert_encoding("本文", "EUC", "SJIS"); $n_text2 = mb_convert_encoding("本文2", "EUC", "SJIS"); $n_softtitle = mb_convert_encoding("ソフトタイトル", "EUC", "SJIS"); $n_webname = mb_convert_encoding("関連サイト", "EUC", "SJIS"); $n_press = mb_convert_encoding("関連記事", "EUC", "SJIS"); $n_copyright = mb_convert_encoding("コピーライト", "EUC", "SJIS"); $n_photo = mb_convert_encoding("写真", "EUC", "SJIS"); $n_soft = mb_convert_encoding("タイトル", "EUC", "SJIS"); $f_genre = "f".GetMasterInfo($n_genre, 0, DATA_TYPE, $db); $f_title = "f".GetMasterInfo($n_title, 0, DATA_TYPE, $db); $f_text = "f".GetMasterInfo($n_text, 0, DATA_TYPE, $db); $f_text2 = "f".GetMasterInfo($n_text2, 0, DATA_TYPE, $db); $f_softtitle = "f".GetMasterInfo($n_softtitle, 0, DATA_TYPE, $db); $f_webname = "f".GetMasterInfo($n_webname, 0, DATA_TYPE, $db); $f_press = "f".GetMasterInfo($n_press, 0, DATA_TYPE, $db); $f_copyright = "f".GetMasterInfo($n_copyright, 0, DATA_TYPE, $db); $f_photo = "f".GetMasterInfo($n_photo, 0, DATA_TYPE, $db); // ソフトタイトル検索用 $f_soft = "f".GetMasterInfo($n_soft, 0, 'soft', $db); /* 検索期間の取得 */ // if($_GET["s_date"]){ $sy = $_GET["sy"]; if($sy == ''){ $sy = DB_STARTYEAR; } $sm = $_GET["sm"]; if($sm == ''){ $sm = 1; } $sd = $_GET["sd"]; if($sd == ''){ $sd = 1; } $ey = $_GET["ey"]; if($ey == ''){ $ey = date("Y"); } $em = $_GET["em"]; if($em == ''){ $em = date("n"); } $ed = $_GET["ed"]; if($ed == ''){ $ed = 31; } $start = $sy.substr("0".$sm, -2, 2).substr("0".$sd, -2, 2)."000000"; $end = $ey.substr("0".$em, -2, 2).substr("0".$ed, -2, 2)."235959"; } /* SQLの生成 */ // $sql = "select * from ".DATA_TYPE."_data where "; $sql .= "open_date <= '".date("YmdHis")."' and "; $sql .= $f_text." != '' and "; if($_GET["s_date"]){ $sql .= "(open_date between '".$start."' and '".$end."') and "; } for($i=0; $iquery($soft_sql); if(DB::isError($res)){ echo "ソフトタイトル検索失敗:".DB::errorMessage($res)."
\n"; exit; } if($res->numRows() > 0){ while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)){ $sql .= $f_softtitle." = '".$row["id"]."' or "; } } $res->free(); $sql .= $f_webname." like '%".$key[$i]."%' or "; $sql .= $f_press." like '%".$key[$i]."%' or "; $sql .= $f_copyright." like '%".$key[$i]."%' or "; $sql .= $f_photo." like '%".$key[$i]."%'"; $sql .= ")"; if($i < count($key) - 1){ $sql .= " and "; } } $sql .= " order by open_date desc"; //$sql .= " limit ".SEARCH_RESULT; $res = $db->query($sql); if(DB::isError($res)){ echo "ニュースデータ検索失敗:".DB::errorMessage($res)."
\n"; exit; } $cnt = $res->numRows(); /********************* * * 検索結果のスクリーニング(2004.03.11 修正) * 検索結果データセットよりタグ表記を削除した状態で、Keywordが該当するかを確認 * */ if($cnt > 0){ $i=1; while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)){ if($i <= SEARCH_RESULT){ // GENRE $chk_genre = $row[$f_genre]; // TITLE $chk_title = strip_tags($row[$f_title]); // TEXT $chk_text = strip_tags($row[$f_text]); // TEXT2 $chk_text2 = strip_tags($row[$f_text2]); // WEBNAME $chk_webname = strip_tags($row[$f_webname]); // PRESS $chk_press = strip_tags($row[$f_press]); // COPYRIGHT $chk_copyright = strip_tags($row[$f_copyright]); // PHOTO $chk_photo = strip_tags($row[$f_photo]); // MATCH_FLG $match_flg = 0; reset($key); // KEY_CHECK --- START for($chk=0; $chk'.$title.''; $text = strip_tags($row[$f_text]); $text = mb_strimwidth($text, 0, 200, "..."); $text = ereg_replace("<\?(.+)\?>", "", $text); $text = mb_convert_encoding($text, "SJIS", "EUC"); $text = str_replace("\r\n", "", $text); $text = str_replace(" ", "", $text); $open_date = $sd_year."年"; $open_date .= number_format($sd_mon)."月"; $open_date .= number_format($sd_day)."日"; $arr["NUMBER"] = sprintf($i, d); $arr["TITLE"] = $title; $arr["TEXT"] = $text; $arr["DATE"] = $open_date; /* テンプレートへの当てはめ */ // $result[$i] = ""; foreach($roop as $value){ if(ereg("<\?(.+)\?>", $value, $match)){ $rep_name = trim($match[1]); $rep_data = $arr[$rep_name]; $result[$i] .= ereg_replace("<\?.+\?>", $rep_data, $value); } else { $result[$i] .= $value; } } $i++; } // SET TEMPLATE --- END } } } $res->free(); } } /* ソフトデータ検索 */ // if(DATA_TYPE == 'soft'){ /* SQLの生成 */ // /* 検索用フィールド番号の取得 */ // $n_title = mb_convert_encoding("タイトル", "EUC", "SJIS"); $n_maker = mb_convert_encoding("メーカー", "EUC", "SJIS"); $n_machine = mb_convert_encoding("対応機種", "EUC", "SJIS"); $n_genre = mb_convert_encoding("ジャンル", "EUC", "SJIS"); $n_genre2 = mb_convert_encoding("ジャンル2", "EUC", "SJIS"); $n_price = mb_convert_encoding("価格", "EUC", "SJIS"); $n_option = mb_convert_encoding("周辺機器", "EUC", "SJIS"); $n_webname = mb_convert_encoding("関連サイト名称", "EUC", "SJIS"); $n_copyright = mb_convert_encoding("コピーライト", "EUC", "SJIS"); $n_intro = mb_convert_encoding("商品紹介", "EUC", "SJIS"); $n_point = mb_convert_encoding("ポイント紹介", "EUC", "SJIS"); $n_memo = mb_convert_encoding("備考", "EUC", "SJIS"); $n_year = mb_convert_encoding("発売日(年)", "EUC", "SJIS"); $n_month = mb_convert_encoding("発売日(月)", "EUC", "SJIS"); $n_day = mb_convert_encoding("発売日(日)", "EUC", "SJIS"); $f_title = "f".GetMasterInfo($n_title, 0, DATA_TYPE, $db); $f_maker = "f".GetMasterInfo($n_maker, 0, DATA_TYPE, $db); $f_machine = "f".GetMasterInfo($n_machine, 0, DATA_TYPE, $db); $f_genre = "f".GetMasterInfo($n_genre, 0, DATA_TYPE, $db); $f_genre2 = "f".GetMasterInfo($n_genre2, 0, DATA_TYPE, $db); $f_price = "f".GetMasterInfo($n_price, 0, DATA_TYPE, $db); $f_option = "f".GetMasterInfo($n_option, 0, DATA_TYPE, $db); $f_webname = "f".GetMasterInfo($n_webname, 0, DATA_TYPE, $db); $f_copyright = "f".GetMasterInfo($n_copyright, 0, DATA_TYPE, $db); $f_intro = "f".GetMasterInfo($n_intro, 0, DATA_TYPE, $db); $f_point = "f".GetMasterInfo($n_point, 0, DATA_TYPE, $db); $f_memo = "f".GetMasterInfo($n_memo, 0, DATA_TYPE, $db); $f_year = "f".GetMasterInfo($n_year, 0, DATA_TYPE, $db); $f_month = "f".GetMasterInfo($n_month, 0, DATA_TYPE, $db); $f_day = "f".GetMasterInfo($n_day, 0, DATA_TYPE, $db); $sql = "select * from ".DATA_TYPE."_data where "; $sql .= "open_date <= '".date("YmdHis")."' and "; //$sql .= $f_intro." != '' and "; // 紹介がなくても検索対象とするよう変更(2004.01.14) if($s_key != ''){ for($i=0; $i%') or "; $sql .= "(".$f_point." like '%".$key[$i]."%' and ".$f_point." not like '%<%".$key[$i]."%>%') or "; $sql .= "(".$f_memo." like '%".$key[$i]."%' and ".$f_memo." not like '%<%".$key[$i]."%>%')"; $sql .= ")"; if($i < count($key) - 1){ $sql .= " and "; } } } if(!$_GET["s_date"]){ /* 日付GETデータの取得 */ // $sy = $_GET["sy"]; $sm = $_GET["sm"]; $sd = $_GET["sd"]; $ey = $_GET["ey"]; $em = $_GET["em"]; $ed = $_GET["ed"]; if( ($sy > $ey) || (($sy == $ey) && ($sm > $em)) || (($sy == $ey) && ($sm == $em) && ($sd > $ed)) ){ $err = 1; } if(!$err){ if($s_key != ''){ $sql .= " and ("; } /* 発売日検索(2004.01.14 修正) */ $sql .= "("; if($sy == $ey){ // Start と End が同じ場合 if($sm == $em){ $sql .= "(".$f_year." = ".$sy." and ".$f_month." = ".$sm.")"; } else { $sql .= "(".$f_year." = ".$sy." and (".$f_month." between ".$sm." and ".$em."))"; } } else { for($x=$sy; $x<=$ey; $x++){ if($x==$sy){ $sql .= "(".$f_year." = ".$x." and ".$f_month." >= ".$sm.") or "; } elseif($x==$ey){ $sql .= "(".$f_year." = ".$x." and ".$f_month." <= ".$em.")"; } else { $sql .= "(".$f_year." = ".$x.") or "; } } } $sql .= ")"; /* 期間データ抽出 */ // $sql .= " or "; if($sy == $ey){ if($sm == $em){ $sql .= "(".$f_year." = ".$sy." and ".$f_month." = ".GetSaleSeason($sm).")"; } else { $sql .= "(".$f_year." = ".$sy." and ".$f_month." in ("; for($i=$sm; $i<=$em; $i++){ $sql .= GetSaleSeason($i); if($i < $em){ $sql .= ","; } } $sql .= "))"; } } else { $sql .= "("; for($i=$sy; $i<=$ey; $i++){ if($i==$sy){ $sql .= "(".$f_year." = ".$i." and ".$f_month." in ("; for($j=$sm; $j<=12; $j++){ $sql .= GetSaleSeason($j); if($j < 12){ $sql .= ","; } } $sql .= "))"; } if($i>$sy && $i<$ey){ $sql .= "(".$f_year." = ".$i." and ".$f_month." in (13,14,15,16))"; } if($i==$ey){ $sql .= "(".$f_year." = '".$i."' and ".$f_month." in ("; for($k=1; $k<=$em; $k++){ $sql .= GetSaleSeason($k); if($k < $em){ $sql .= ","; } } $sql .= "))"; } if($i < $ey){ $sql .= " or "; } } $sql .= ")"; } if($s_key != ''){ $sql .= ")"; } } } else { if($s_key != ''){ $sql .= " and "; } $sql .= $f_year." = 9999"; } $sql .= " order by ".$f_year." desc, ".$f_month." desc, ".$f_day." desc limit ".SEARCH_RESULT; $res = $db->query($sql); if(DB::isError($res)){ echo "ソフトデータ検索失敗:".DB::errorMessage($res)."
\n"; exit; } $cnt = $res->numRows(); if($cnt > 0){ $i=1; while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)){ $arr = array(); $id = $row["id"]; $title = mb_convert_encoding($row[$f_title], "SJIS", "EUC"); $title = ''.$title.''; $sell_date = GetSaleDate($row[$f_year], $row[$f_month], $row[$f_day], $db); $maker = mb_convert_encoding($row[$f_maker], "SJIS", "EUC"); $machine = str_replace("|", " ", $row[$f_machine]); if($row[$f_genre2] != ''){ $genre = mb_convert_encoding($row[$f_genre2], "SJIS", "EUC"); } else { $genre = $row[$f_genre]; } if(preg_match("/\{\+\}/i", $row[$f_price])){ $hope = mb_convert_encoding("希望小売価格", "EUC", "SJIS"); $prc = mb_ereg_replace($hope."\{\+\}", "", $row[$f_price]); $price = number_format($prc)." 円"; } else { $price = mb_convert_encoding($row[$f_price], "SJIS", "EUC"); } $memo = ereg_replace("<\?(.+)\?>", "", $row[$f_memo]); $memo = mb_convert_encoding($memo, "SJIS", "EUC"); $arr["NUMBER"] = sprintf($i, d); $arr["TITLE"] = $title; $arr["DATE"] = mb_convert_encoding($sell_date, "SJIS", "EUC"); $arr["MAKER"] = $maker; $arr["MACHINE"] = $machine; $arr["GENRE"] = $genre; $arr["PRICE"] = $price; $arr["MEMO"] = ""; if($memo != ''){ $arr["MEMO"] = '●'.$memo."\n"; } /* テンプレートへの当てはめ */ // $result[$i] = ""; foreach($roop as $value){ if(ereg("<\?(.+)\?>", $value, $match)){ $rep_name = trim($match[1]); $rep_data = $arr[$rep_name]; $result[$i] .= ereg_replace("<\?.+\?>", $rep_data, $value); } else { $result[$i] .= $value; } } $i++; } } $res->free(); } /* 検索結果の表示 */ // if(count($result) > 0){ $p = $_GET["p"]; if($p == ''){ $p = 1; } $page = count($result) / SEARCH_RESULT_PAGES; if(count($result) % SEARCH_RESULT_PAGES){ $page++; } $arr["PAGELINK"] = ""; for($i=1; $i<=$page; $i++){ if($i == $p){ $arr["PAGELINK"] .= ''.$i.''; } else { $nextlink = ""; if(DATA_TYPE == 'news'){ if($_GET["s_date"]){ $nextlink = "&s_date=1&sy=".$sy."&sm=".$sm."&sd=".$sd."&ey=".$ey."&em=".$em."&ed=".$ed; } } elseif(DATA_TYPE == 'soft'){ if($_GET["s_date"]){ $nextlink = "&s_date=1"; } else { $nextlink = "&sy=".$sy."&sm=".$sm."&sd=".$sd."&ey=".$ey."&em=".$em."&ed=".$ed; } } $arr["PAGELINK"] .= ''.$i.''; } if($i <= $page - 1){ $arr["PAGELINK"] .= ' | '; } } $page_start = (($p - 1) * SEARCH_RESULT_PAGES) + 1; $page_end = $p * SEARCH_RESULT_PAGES; if($page_end > count($result)){ $page_end = count($result); } $arr["TOTAL"] = sprintf(count($result), d); $arr["VIEWPAGE"] = $page_start." 〜 ".$page_end; /* データ表示用テンプレートの読み込み */ // $val = ""; $roopflg = 0; $tmpl = TEMPLATE_DIR."search_".DATA_TYPE.".tmpl"; $fp = fopen($tmpl,"r"); while($line = @fgets($fp, 1024)){ $data = ""; if(ereg("<\? RESULT \?>", $line, $match)){ if($roopflg){ $roopflg = 0; foreach($result as $key=>$value){ if($page_start <= $key && $key <= $page_end){ $data .= $value; } } } else { $roopflg = 1; } } else { if(!$roopflg){ if(ereg("<\?(.+)\?>", $line, $match)){ $rep_name = trim($match[1]); $rep_data = $arr[$rep_name]; $data = ereg_replace("<\?.+\?>", $rep_data, $line); } else { $data = $line; } } } if($data != ''){ $val .= $data; } } fclose($fp); } else { /* 該当データがない場合 */ // $val = ""; $tmpl = TEMPLATE_DIR."search_zero.tmpl"; $fp = fopen($tmpl,"r"); while($line = @fgets($fp, 1024)){ $val .= $line; } fclose($fp); } $db->disconnect(); /* 画面表示用テンプレートの読み込み */ // $ret = ""; // ヘッダー $tmpl = TEMPLATE_DIR."header.tmpl"; $fp = fopen($tmpl,"r"); while($line = @fgets($fp, 1024)){ $ret .= $line; } fclose($fp); // メニュー // 2006.03.03 バナー表示対応 $tmpl = TEMPLATE_DIR."menu3.tmpl"; $fp = fopen($tmpl,"r"); while($line = @fgets($fp, 1024)){ $data = ""; if(ereg("<\?(.+)\?>", $line, $match)){ $rep_name = trim($match[1]); $bnno = str_replace("BANNER", "", $rep_name); $bntag = exec("/home/htdocs/data/banner/bn.php $bnno"); $data = ereg_replace("<\?.+\?>", $bntag, $line); } else { $data = $line; } $ret .= $data; } fclose($fp); // ボディー $ret .= $val; // フッター $tmpl = TEMPLATE_DIR."footer.tmpl"; $fp = fopen($tmpl,"r"); while($line = @fgets($fp, 1024)){ $ret .= $line; } fclose($fp); echo $ret; ?>