/************************************/
/* ソフトトップ画面表示用スクリプト */
/************************************/
//
include("/home/htdocs/data/admin/def/dol_def.inc");
$tmpl = TEMPLATE_DIR."soft_top.tmpl";
/**************************/
/* 検索対象季節取得用関数 */
/**************************/
//
function getSearchSeason($month){
$season = "";
if($month >= 3 && $month <= 5){
$season = 13;
}
elseif($month >= 6 && $month <= 8){
$season = 14;
}
elseif($month >= 9 && $month <= 11){
$season = 15;
}
elseif($month >= 1 && $month <= 2 || $month == 12){
$season = 16;
}
return $season;
}
/************************/
/* 発売年月日取得用関数 */
/************************/
//
function GetSoftTopSaleDate($month, $day){
$sale_date = $month."月";
if($day == 32){
$sale_date .= "上旬";
}
elseif($day == 33){
$sale_date .= "中旬";
}
elseif($day == 34){
$sale_date .= "下旬";
}
return $sale_date;
}
/* GETデータ取得 */
//
$target = $_GET["target"];
$t_year = substr($target, 0, 4);
$t_month = number_format(substr($target, 4));
if($target == ''){
$t_year = date("Y");
$t_month = date("n");
}
$t_season = getSearchSeason($t_month);
/* 日付関連 */
//
// 先月の値
$p_year = $t_year;
$p_month = $t_month - 1;
if(!checkdate($p_month, 1, $p_year)){
$p_year--;
$p_month = 12;
}
// データ存在有無チェック
if(CheckSoftDataCount($p_year, $p_month)){
$p_target = $p_year.substr("0".$p_month, -2, 2);
}
// 来月の値
$n_year = $t_year;
$n_month = $t_month + 1;
if(!checkdate($n_month, 1, $n_year)){
$n_year++;
$n_month = 1;
}
// データ存在有無チェック
if(CheckSoftDataCount($n_year, $n_month)){
$n_target = $n_year.substr("0".$n_month, -2, 2);
}
/* テンプレートの読み込み(データ繰り返し部分) */
//
$roop_data = array();
$roop_body = array();
$roop_f_data = 0;
$roop_f_body = 0;
$fp = fopen($tmpl,"r");
while($line = @fgets($fp, 1024)){
if(ereg("<\? SOFT_DATA \?>", $line, $match)){
if($roop_f_data){
$roop_f_data = 0;
} else {
$roop_f_data = 1;
}
} else {
if($roop_f_data){
if(ereg("<\? SOFT_BODY \?>", $line, $match)){
if($roop_f_body){
$roop_f_body = 0;
$roop_data[] = $line;
} else {
$roop_f_body = 1;
}
} else {
if($roop_f_body){
$roop_body[] = $line;
} else {
$roop_data[] = $line;
}
}
}
}
}
fclose($fp);
$fname_saleyear = mb_convert_encoding('発売日(年)', "EUC", "SJIS");
$fname_salemonth = mb_convert_encoding('発売日(月)', "EUC", "SJIS");
$fname_saleday = mb_convert_encoding('発売日(日)', "EUC", "SJIS");
$fname_machine = mb_convert_encoding('対応機種', "EUC", "SJIS");
$fname_titleyomi = mb_convert_encoding('タイトル読み', "EUC", "SJIS");
$f_saleyear = "f".GetMasterInfo($fname_saleyear, 0, 'soft', $db);
$f_salemonth = "f".GetMasterInfo($fname_salemonth, 0, 'soft', $db);
$f_saleday = "f".GetMasterInfo($fname_saleday, 0, 'soft', $db);
$f_machine = "f".GetMasterInfo($fname_machine, 0, 'soft', $db);
$f_titleyomi = "f".GetMasterInfo($fname_titleyomi, 0, 'soft', $db);
$machinelist = GetMachineList();
$sql = "select ".$f_salemonth.",".$f_saleday." from soft_data where ";
$sql .= $f_saleyear." = ".$t_year." ";
$sql .= "and (".$f_salemonth." = ".$t_month." or ".$f_salemonth." = ".$t_season.") ";
$sql .= "and open_date <= '".date("YmdHis")."' ";
$sql .= "order by ".$f_salemonth." asc, ".$f_saleday." asc";
$res = $db->query($sql);
if(DB::isError($res)){
echo $t_year."年".$t_month."月分ソフトデータ取得失敗:".DB::errorMessage($res)."
\n";
exit;
}
$cnt = $res->numRows();
if($cnt > 0){
$searchdate_flg = array();
$searchdate = array();
while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)){
if(!$searchdate_flg[$row[$f_salemonth]][$row[$f_saleday]]){
$searchdate_flg[$row[$f_salemonth]][$row[$f_saleday]] = 1;
$searchmonth[] = $row[$f_salemonth];
$searchday[] = $row[$f_saleday];
}
}
}
$res->free();
if(count($searchmonth) > 0){
$val = "";
foreach($searchmonth as $search_id => $search_value) {
$t_month = $searchmonth[$search_id];
$t_day = $searchday[$search_id];
foreach($roop_data as $value){
if(ereg("<\? SOFT_BODY \?>", $value, $match)){
foreach($machinelist as $value2){
$sql2 = "select * from soft_data where ";
$sql2 .= $f_saleyear." = ".$t_year." and ";
$sql2 .= "(".$f_salemonth." = ".$t_month." and ".$f_saleday." = ".$t_day.")";
$sql2 .= " and ";
$sql2 .= $f_machine." like '%".$value2."|%' and ";
$sql2 .= "open_date <= '".date("YmdHis")."' ";
$sql2 .= "order by ".$f_titleyomi." asc";
$res2 = $db->query($sql2);
if(DB::isError($res2)){
echo $t_year."年".$t_month."月".$t_day."日[".$value2."]分ソフトデータ取得失敗:".DB::errorMessage($res2)."
\n";
exit;
}
if($res2->numRows() > 0){
$i = 1;
$val3 = "";
$value2 = mb_convert_encoding($value2, "SJIS", "EUC");
while($row2 = $res2->fetchRow(DB_FETCHMODE_ASSOC)){
$s_data = GetSoftTopData($row2["id"], $row2);
foreach($roop_body as $value3){
if(ereg("<\?(.+)\?>", $value3, $match3)){
$rep_name3 = trim($match3[1]);
$rep_data3 = "";
$value_icon = "";
if($rep_name3 == 'SOFT_MACHINE'){
if($i == 1){
if($value2 == "ネオジオ"){
$value_icon = "ng";
} else {
$value_icon = strtolower($value2);
}
$rep_data3 = '';
}
} elseif($rep_name3 == 'BGCOLOR'){
switch($value2){
case "PS":
$rep_data3 = "#F0FFFF";
break;
case "PS2":
$rep_data3 = "#EEF7FF";
break;
case "PSP":
$rep_data3 = "#E8F0FB";
break;
case "DC":
$rep_data3 = "#FFF4DD";
break;
case "GC":
$rep_data3 = "#F3E6FF";
break;
case "GBA":
$rep_data3 = "#ECECFF";
break;
case "DS":
$rep_data3 = "#E7FAEA";
break;
case "Xbox":
$rep_data3 = "#EEFFDF";
break;
case "WS":
$rep_data3 = "#FFF0F9";
break;
case "GB":
$rep_data3 = "#FFE9E6";
break;
case "ネオジオ":
$rep_data3 = "#DDDDDD";
break;
case "NGP":
$rep_data3 = "#DDDDDD";
break;
case "N64":
$rep_data3 = "#CCCCCC";
break;
case "Xbox360":
$rep_data3 = "#EEFFDF";
break;
default:
break;
}
} else {
$rep_data3 = $s_data[$rep_name3];
}
$val3 .= ereg_replace("<\?.+\?>", $rep_data3, $value3);
} else {
$val3 .= $value3;
}
}
$i++;
}
$val .= ereg_replace("<\?.+\?>", $val3, $value);
}
$res2->free();
}
} else {
if(ereg("<\?(.+)\?>", $value, $match)){
$rep_name = trim($match[1]);
$rep_data = "";
if($rep_name == 'SOFT_SALEDATE'){
$saledate = $t_year.substr("0".$t_month, -2, 2).substr("0".$t_day, -2, 2);
$jwday = mb_convert_encoding(GetJWday($saledate), "SJIS", "EUC");
switch($t_month){
case "13":
$rep_data .= "春";
break;
case "14":
$rep_data .= "夏";
break;
case "15":
$rep_data .= "秋";
break;
case "16":
$rep_data .= "冬";
break;
default:
$rep_data .= $t_month."月";
break;
}
if($t_day == "" || is_null($t_day) || $t_day == 0){
$rep_data .= "予定";
}
else {
switch($t_day){
case "32":
$rep_data .= "上旬";
break;
case "33":
$rep_data .= "中旬";
break;
case "34":
$rep_data .= "下旬";
break;
case "35":
$rep_data .= "予定";
break;
default:
$rep_data .= $t_day."日".$jwday;
}
}
}
$val .= ereg_replace("<\?.+\?>", $rep_data, $value);
} else {
$val .= $value;
}
}
}
}
}
$res->free();
/* 日付検索用フォーム生成 */
//
$arr["OPTION_SY"] = "";
for($i=DB_STARTYEAR; $i<=(date("Y") + 1); $i++){
$arr["OPTION_SY"] .= ''."\n";
}
$arr["OPTION_SD"] = "";
for($i=1; $i<=31; $i++){
$arr["OPTION_SD"] .= ''."\n";
}
$arr["OPTION_EY"] = "";
for($i=DB_STARTYEAR; $i<=(date("Y") + 1); $i++){
$arr["OPTION_EY"] .= '