assign("main",$main); if($kari_arr[1]){ $smarty->assign("bukkentype", $kari_arr[1]); if($kari_arr[1] == "tochi"){ $pagetitle1 = "土地 "; $bcode = "1"; }else if($kari_arr[1] == "tatemono"){ $pagetitle1 = "建物 "; $bcode = "2"; }else if($kari_arr[1] == "mansion"){ $pagetitle1 = "マンション "; $bcode = "3"; } $smarty->assign("bcode",$bcode); }else{ $smarty->assign("bukkentype","tochi"); $pagetitle1 = ""; $smarty->assign("bcode","1"); } //お気に入り・閲覧履歴 include_once($_SERVER['DOCUMENT_ROOT']."/favorite.php"); include_once($_SERVER['DOCUMENT_ROOT']."/history.php"); //件数の集計 $sql = "select bdata.main_cd,count(*) as count from bdata,vt_jiscode where bdata.jiscode = vt_jiscode.jiscode and vt_jiscode.site = '".$site."' and bdata.open_flg = '1' and bdata.open_date <= '".date("Y-m-d H:i:s")."' and bdata.close_date >= '".date("Y-m-d H:i:s")."' and (bdata.done_date = '0000-00-00 00:00:00' or bdata.done_date is null) and (bdata.del_date = '0000-00-00 00:00:00' or bdata.del_date is null) group by bdata.main_cd"; $result = mysql_query($sql); if(@mysql_num_rows($result)){ while($rows = mysql_fetch_array($result)){ $torokunum[$rows["main_cd"]] = $rows["count"]; } } $smarty->assign("torokunum1",$torokunum["売買"]); $smarty->assign("torokunum2",$torokunum["賃貸"]); //人気エリアランキングの取得 if(date("H") < 6){ $day = date("Y-m-d",strtotime("-2 day")); }else{ $day = date("Y-m-d",strtotime("-1 day")); } $ninki_area=""; $sql = "select rank,area from log_ninki_area where site = '".$site."' and main_cd = '".$main."' and day = '".$day."' order by rank limit 5"; $result = mysql_query($sql); if(@mysql_num_rows($result)){ while($rows = mysql_fetch_array($result)){ $ninki_area[] = $rows; } } $smarty->assign("ninki_area",$ninki_area); //人気物件の取得 $ninki_bukken=""; $sql = "select*from log_ninki_bukken where site = '".$site."' and main_cd = '".$main."' and day = '".$day."' order by pageviews desc limit 500"; $result = mysql_query($sql); $i = 0; $j = 0; if(@mysql_num_rows($result)){ while($rows = mysql_fetch_array($result)){ $sql = "select bdata.bdata_id as bdataid,bdata.bukkendata_id as old_bukkendata_id,bdata.*,rdata.* from bdata left join rdata on bdata.bdata_id = rdata.bdata_id where bdata.open_flg = '1' and bdata.open_date <= '".date("Y-m-d H:i:s")."' and bdata.close_date >= '".date("Y-m-d H:i:s")."' and (done_date = '0000-00-00 00:00:00' or done_date is null) and (del_date = '0000-00-00 00:00:00' or del_date is null) and status_code <= '2' and bdata.bdata_id = '".mysql_real_escape_string($rows['bdata_id'])."'"; $res2 = mysql_query($sql); if(@mysql_num_rows($res2)){ $row2 = mysql_fetch_array($res2); if(strstr($row2['prefecture'],"長野県")) $row2['prefecture']=""; if($row2['address2'] && !strstr($row2['address2'],"丁目")) $row2['address2'] .= "丁目"; //画像2枚 $image = array(); $sql = "select imgfile from dt_image where bdata_id = '".$rows['bdata_id']."' and deletetime is null and imgdisp = '1' order by mag_flg desc,sort limit 2"; $res3 = mysql_query($sql); if(mysql_numrows($res3)){ while($row3 = mysql_fetch_array($res3)){ $image[] = $row3; } $row2["image1"] = $image[0]["imgfile"]; $row2["image2"] = $image[1]["imgfile"]; } if($rows['bcode']=="1"){ //土地 $ninki_bukken['tochi'][$i] = $rows; $ninki_bukken['tochi'][$i]['bukken'] = $row2; $i++; }else{ //建物 $ninki_bukken['tatemono'][$j] = $rows; $ninki_bukken['tatemono'][$j]['bukken'] = $row2; $j++; } } } } $smarty->assign("ninki_bukken",$ninki_bukken); //価格帯取得 $amt_array = ""; $i = 0; $j = 0; if($main=="売買"){ $sql = " select `day`,site,log_access_day.main_cd,log_access_day.bcode,TRUNCATE(bdata.kakaku_amt,-6) as kakakutai, COUNT(*) as count from log_access_day,bdata where bdata.bdata_id = log_access_day.bdata_id and log_access_day.day = '".$day."' and bdata.kakaku_amt != '0' and bdata.kakaku_amt is not null and log_access_day.site=\"${site}\" and log_access_day.main_cd ='売買' group by log_access_day.day,kakakutai,log_access_day.site,log_access_day.main_cd order by log_access_day.site,count desc LIMIT 0 , 500 "; $result = mysql_query($sql); if($rows = @mysql_num_rows($result)){ while($arr = mysql_fetch_array($result)){ $arr['kakakutai_max'] = $arr['kakakutai']+999999; if($arr['bcode']=="1"){ $amt_array['tochi'][$i] = $arr; $i++; }else{ $amt_array['tatemono'][$j] = $arr; $j++; } } } } $smarty->assign("amt_array", $amt_array); $smarty->assign("pagetitle1", $pagetitle1); $smarty->assign("pagetitle2", "|長野県諏訪市・岡谷市・下諏訪町・茅野市・原村・富士見町などの土地、中古住宅等の不動産物件が簡単に探せます。"); $smarty->display("_2_index.tpl"); ?>