get_exception();
}
}
/* 検索ボックスの更新(毎日6時過ぎ初回アクセス) */
if ($err_str === "") {
$condition_stamp = filemtime(LOCOMILL_SMARTY_TEMPLATES_DIR . 'search_result/condition_spot.tpl');
if (date('Y-m-d') != date('Y-m-d', $condition_stamp) && '06:00:00' <= date('H:i:s')) {
include('./condition_update.shtml');
}
}
/* 出力準備 */
$smarty = new SmartyEx();
$smarty->prepare();
/* マイプロフィール */
include('common/myprofile.inc');
/* Searchクラスインスタンス生成 */
if ($err_str === "") {
try {
$search = new Search($locomill->get_db3());
$sort_menu = $search->get_sort_array();
} catch (SearchError $e) {
$err_str = $e->get_exception();
}
}
/* Spotクラスインスタンス生成 */
if ($err_str === "") {
try {
$spot = new Spot($locomill->get_db3());
} catch (SpotError $e) {
$err_str = $e->get_exception();
}
}
/* Areaクラスインスタンス生成 */
if ($err_str === "") {
try {
$area = new Area($locomill->get_db3());
} catch (AreaError $e) {
$err_str .= $e->get_exception();
}
}
/* Categoryクラスインスタンス生成 */
if ($err_str === "") {
try {
$category = new Category($locomill->get_db3());
} catch (CategoryError $e) {
$err_str .= $e->get_exception();
}
}
/* Serviceクラスインスタンス生成 */
if ($err_str === "") {
try {
$service = new Service($locomill->get_db3());
} catch (ServiceError $e) {
$err_str .= $e->get_exception();
}
}
/* HospitalServiceクラスインスタンス生成 */
if ($err_str === "") {
try {
$hospital_service = new HospitalService($locomill->get_db3());
} catch (HospitalServiceError $e) {
$err_str .= $e->get_exception();
}
}
/* EventServiceクラスインスタンス生成 */
if ($err_str === "") {
try {
$event_service = new EventService($locomill->get_db3());
} catch (EventServiceError $e) {
$err_str .= $e->get_exception();
}
}
/* EventSceneクラスインスタンス生成 */
if ($err_str === "") {
try {
$event_scene = new EventScene($locomill->get_db3());
} catch (EventSceneError $e) {
$err_str .= $e->get_exception();
}
}
/* Barrierfreeクラスインスタンス生成 */
if ($err_str === "") {
try {
$barrier = new Barrierfree($locomill->get_db3());
} catch (BarrierfreeError $e) {
$err_str .= $e->get_exception();
}
}
/* Featureクラスインスタンス生成 */
if ($err_str === "") {
try {
$feature = new Feature($locomill->get_db3());
} catch (FeatureError $e) {
$err_str .= $e->get_exception();
}
}
/* Kuchikomiクラスインスタンス生成 */
if ($err_str === "") {
try {
$kuchikomi = new Kuchikomi($locomill->get_db3());
} catch (KuchikomiError $e) {
$err_str .= $e->get_exception();
}
}
/* KuchikomiTagクラスインスタンス生成 */
if ($err_str === "") {
try {
$kuchikomi_tag = new KuchikomiTag($locomill->get_db3());
} catch (KuchikomiTagError $e) {
$err_str .= $e->get_exception();
}
}
/* GoodTypeクラスインスタンス生成 */
if ($err_str === "") {
try {
$good_type = new GoodType($locomill->get_db3());
$good_type_array = $good_type->get_data_array(true);
} catch (GoodTypeError $e) {
$err_str .= $e->get_exception();
}
}
/* Pagerクラスインスタンス生成 */
if ($err_str === "") {
try {
$pager = new Pager();
} catch (PagerError $e) {
$err_str .= $e->get_exception();
}
}
/* Request値の検証 */
if ($err_str === "") {
if (isset($_POST) === true && empty($_POST) === false) {
$rq = $_POST;
} elseif (isset($_GET) === true && empty($_GET) === false) {
$rq = $_GET;
}
unset($rq['terminal'], $rq['cross']);
if (!empty($rq['view_C1'])) {
$rq['C1'] = $rq['view_C1'];
unset($rq['view_C1']);
}
if (!empty($rq['view_C2'])) {
$rq['C2'] = $rq['view_C2'];
unset($rq['view_C2']);
}
if (!empty($rq['view_C3'])) {
$rq['C3'] = $rq['view_C3'];
unset($rq['view_C3']);
}
if (!empty($rq['view_area'])) {
$rq['area'] = $rq['view_area'];
unset($rq['view_area']);
}
if (!empty($rq['view_word'])) {
$rq['word'] = $rq['view_word'];
unset($rq['view_word']);
}
if (!empty($rq['view_year']) && !empty($rq['view_month']) && !empty($rq['view_day']) && !empty($rq['view_term'])) {
$rq['year'] = $rq['view_year'];
$rq['month'] = $rq['view_month'];
$rq['day'] = $rq['view_day'];
$rq['term'] = $rq['view_term'];
unset($rq['view_year'], $rq['view_month'], $rq['view_day'], $rq['view_term']);
}
// 端末
$where['terminal'] = 1;
// 対象
if (!empty($rq['type'])) {
if (is_array($rq['type'])) {
if (in_array(1, $rq['type'])) {
$rq['type'] = 'spot';
} elseif (in_array(2, $rq['type'])) {
$rq['type'] = 'event';
} elseif (in_array(4, $rq['type'])) {
$rq['type'] = 'feature';
} elseif (in_array('k', $rq['type'])) {
$rq['type'] = 'kuchikomi';
} else {
unset($rq['type']);
}
} elseif (!in_array($rq['type'], array('spot', 'event', 'feature', 'kuchikomi'))) {
if ($rq['type'] == 1) {
$rq['type'] = 'spot';
} elseif ($rq['type'] == 2) {
$rq['type'] = 'event';
} elseif ($rq['type'] == 3) {
$rq['type'] = 'spot';
} elseif ($rq['type'] == 4) {
$rq['type'] = 'feature';
} elseif ($rq['type'] == 'k') {
$rq['type'] = 'kuchikomi';
} else {
unset($rq['type']);
}
}
}
if (empty($rq['type'])) {
$rq['type'] = 'spot';
}
if ($rq['type'] == 'spot') {
$where['type'] = array(1, 3);
} elseif ($rq['type'] == 'event') {
$where['type'] = array(2);
$sort = 1;
} elseif ($rq['type'] == 'feature') {
$where['type'] = array(4, 5);
$sort = 1;
unset($sort_menu[3], $sort_menu[4], $sort_menu[5]);
} elseif ($rq['type'] == 'kuchikomi') {
$where['type'] = array('k');
}
$type = $rq['type'];
// 並び順ID
$sort = (isset($rq['sort']) && !is_array($rq['sort']) && preg_match('/^[0-9]+$/', $rq['sort']))? $rq['sort']: $sort;
// ページID
$page = (isset($rq['page']) && !is_array($rq['page']) && preg_match('/^[0-9]+$/', $rq['page']))? $rq['page']: $page;
// 表示方法
$list_type = ($type == 'kuchikomi' && isset($rq['list_type']) && $rq['list_type'] == 1)? $rq['list_type']: 0;
// ワード
if (!empty($rq['keyword'])) {
$rq['word'] = $rq['keyword'];
unset($rq['keyword']);
}
if (!empty($rq['word'])) {
if (is_array($rq['word'])) {
$klist = $rq['word'];
} else {
// スペース区切り
$kwd = mb_convert_kana(trim($rq['word']), 's');
$klist = explode(' ', $kwd);
}
$klist = array_diff(array_unique($klist), array('')); // 同じ文字・空はナシ
$kwd = join(' ', $klist);
$rq['word'] = $kwd;
$where['word'] = $klist;
$search_spec_word_str[] = $kwd;
}
// 期間(イベント)
if (!empty($rq['term']) && checkdate((int)$rq['month'], (int)$rq['day'], (int)$rq['year'])) {
$temp = sprintf('%04d年%d月%d日', $rq['year'], $rq['month'], $rq['day']);
if ($rq['term'] == 1) {
$temp .= '当日';
} elseif ($rq['term'] == 2) {
$temp .= 'から一週間以内';
} elseif ($rq['term'] == 3) {
$temp .= 'から二週間以内';
} elseif ($rq['term'] == 4) {
$temp .= 'から一ヶ月以内';
} elseif ($rq['term'] == 5) {
$temp .= 'から二ヶ月以内';
} else {
unset($rq['term']);
}
}
if (!empty($rq['term'])) {
$where['term'] = $rq['term'];
$where['year'] = $rq['year'];
$where['month'] = $rq['month'];
$where['day'] = $rq['day'];
$search_spec_term_str[] = $temp;
} elseif ($type == 'event') {
$rq['year'] = date('Y');
$rq['month'] = date('n');
$rq['day'] = date('j');
}
// カテゴリ ----------------------------------------------------------------------------------------------------
// 簡易メニューからのアクセスを反映:カテゴリ
if (!empty($rq['category'])) {
$temp = explode(':', $rq['category']);
list($k, $v) = explode('_', end($temp));
$rq[$k] = $v;
unset($rq['category']);
}
if (!empty($rq['c_03'])) {
$rq['C3'] = $rq['c_03'];
} elseif (!empty($rq['c_02'])) {
$rq['C2'] = $rq['c_02'];
} elseif (!empty($rq['c_01'])) {
$rq['C1'] = $rq['c_01'];
}
if (isset($rq['c_01'])) {
unset($rq['c_01']);
}
if (isset($rq['c_02'])) {
unset($rq['c_02']);
}
if (isset($rq['c_03'])) {
unset($rq['c_03']);
}
// カテゴリ大ID
if (!empty($rq['C1'])) {
$rq['C1'] = (is_array($rq['C1']))? $rq['C1']: array($rq['C1']);
if (empty($format)) {
foreach ($rq['C1'] AS $k => $v) {
$name = '';
try {
if ($type == 'spot') {
$name = $category->get_name(1, $v);
} elseif ($type == 'event') {
$name = $category->get_name(1, $v, 3);
}
} catch (CategoryError $e) {
}
if (!empty($name)) {
$search_spec_cat_str[] = $name;
} else {
unset($rq['C1'][$k]);
}
}
}
$where['C1'] = $rq['C1'];
}
// カテゴリ中ID
if (!empty($rq['C2'])) {
$rq['C2'] = (is_array($rq['C2']))? $rq['C2']: array($rq['C2']);
if (empty($format)) {
foreach ($rq['C2'] AS $k => $v) {
$name = '';
try {
if ($type == 'spot') {
$name = $category->get_name(2, $v);
} elseif ($type == 'event') {
$name = $category->get_name(2, $v, 3);
}
} catch (CategoryError $e) {
}
if (!empty($name)) {
$search_spec_cat_str[] = $name;
} else {
unset($rq['C2'][$k]);
}
}
}
$where['C2'] = $rq['C2'];
}
// カテゴリ小ID
if (!empty($rq['C3'])) {
$rq['C3'] = (is_array($rq['C3']))? $rq['C3']: array($rq['C3']);
if (empty($format)) {
foreach ($rq['C3'] AS $k => $v) {
$name = '';
try {
if ($type == 'spot') {
$name = $category->get_name(3, $v);
}
} catch (CategoryError $e) {
}
if (!empty($name)) {
$search_spec_cat_str[] = $name;
} else {
unset($rq['C3'][$k]);
}
}
}
$where['C3'] = $rq['C3'];
}
// 病院カテゴリID
if (!empty($rq['C3_H'])) {
$rq['C3_H'] = (is_array($rq['C3_H']))? $rq['C3_H']: array($rq['C3_H']);
if (empty($format)) {
foreach ($rq['C3_H'] AS $k => $v) {
$name = '';
try {
if ($type == 'spot') {
$name = $category->get_name(3, $v);
}
} catch (CategoryError $e) {
}
if (!empty($name)) {
$search_spec_cat_str[] = $name;
} else {
unset($rq['C3_H'][$k]);
}
}
}
$where['C3_H'] = $rq['C3_H'];
}
// エリア ----------------------------------------------------------------------------------------------------
// 簡易メニューからのアクセスを反映:エリア
if (!empty($rq['area'])) {
$temp = explode(':', $rq['area']);
list($k, $v) = explode('_', end($temp));
$rq[$k] = $v;
unset($rq['area']);
}
// Flash:階層指定の適用
if (!empty($rq['t'])) {
$rq[strtoupper($rq['t'])] = $rq['id'];
unset($rq['t']);
}
// A3(市町村階層)が宇都宮フラグだった場合の処理
if (!empty($rq['A3']) && !is_array($rq['A3']) && preg_match('/^F(1|2):[0-9]+$/', $rq['A3'])) {
list($key, $code) = explode(':', $rq['A3']);
$rq[$key] = $code;
}
// A3(市町村階層)が宇都宮市だった場合の処理
if (!empty($rq['A3'])) {
if ((is_array($rq['A3']) && in_array(1, $rq['A3'])) || (!is_array($rq['A3']) && $rq['A3'] == 1)) {
$rq['A3'] = (is_array($rq['A3']))? $rq['A3']: array($rq['A3']);
foreach ($rq['A3'] AS $k => $v) {
if ($v == 1) {
if (!empty($rq['A2']) && is_array($rq['A2'])) {
$rq['A2'][] = 1;
} else {
$rq['A2'] = array(1);
}
unset($rq['A3'][$k]);
break;
}
}
}
}
// 圏域指定あり
if (!empty($rq['A2'])) {
$rq['A2'] = (is_array($rq['A2']))? $rq['A2']: array($rq['A2']);
if (empty($format)) {
foreach ($rq['A2'] AS $k => $v) {
$name = '';
try {
$name = $area->get_name('area_master_02_tbl', $v);
} catch (AreaError $e) {
}
if (!empty($name)) {
$search_spec_area_str[] = $name;
} else {
unset($rq['A2'][$k]);
}
}
}
$where['A2'] = $rq['A2'];
}
// 市町村指定あり
if (!empty($rq['A3'])) {
$rq['A3'] = (is_array($rq['A3']))? $rq['A3']: array($rq['A3']);
if (empty($format)) {
foreach ($rq['A3'] AS $k => $v) {
$name = '';
try {
$name = $area->get_name('area_master_03_tbl', $v);
} catch (AreaError $e) {
}
if (!empty($name)) {
$search_spec_area_str[] = $name;
} else {
unset($rq['A3'][$k]);
}
}
}
$where['A3'] = $rq['A3'];
}
// 宇都宮フラグ1指定あり
if (!empty($rq['F1'])) {
$rq['F1'] = (is_array($rq['F1']))? $rq['F1']: array($rq['F1']);
if (empty($format)) {
foreach ($rq['F1'] AS $k => $v) {
$name = '';
try {
$name = $area->get_name('area_master_flag_01_tbl', $v);
} catch (AreaError $e) {
}
if (!empty($name)) {
$search_spec_area_str[] = '宇都宮' . $name;
} else {
unset($rq['F1'][$k]);
}
}
}
$where['F1'] = $rq['F1'];
}
// 宇都宮フラグ2指定あり
if (!empty($rq['F2'])) {
$rq['F2'] = (is_array($rq['F2']))? $rq['F2']: array($rq['F2']);
if (empty($format)) {
foreach ($rq['F2'] AS $k => $v) {
$name = '';
try {
$name = $area->get_name('area_master_flag_02_tbl', $v);
} catch (AreaError $e) {
}
if (!empty($name)) {
$search_spec_area_str[] = '宇都宮' . $name;
} else {
unset($rq['F2'][$k]);
}
}
}
$where['F2'] = $rq['F2'];
}
// 町名指定あり
if (!empty($rq['A4'])) {
$rq['A4'] = (is_array($rq['A4']))? $rq['A4']: array($rq['A4']);
if (empty($format)) {
foreach ($rq['A4'] AS $k => $v) {
$name = '';
try {
$name = $area->get_name('area_tbl', $v);
} catch (AreaError $e) {
}
if (!empty($name)) {
$search_spec_area_str[] = $name;
} else {
unset($rq['A4'][$k]);
}
}
}
$where['A4'] = $rq['A4'];
}
// シーン ----------------------------------------------------------------------------------------------------
// クーポンあり
if (!empty($rq['coupon'])) {
$rq['coupon'] = (is_array($rq['coupon']))? $rq['coupon']: array($rq['coupon']);
$where['coupon'] = 1;
$search_spec_sce_str[] = 'クーポンあり';
}
// クチコミn件以上
if (!empty($rq['kuchikomi']) && preg_match('/^[0-9]+$/', $rq['kuchikomi'])) {
$where['kuchikomi'] = $rq['kuchikomi']; // フォームにはない
$search_spec_sce_str[] = sprintf('クチコミ%d件以上', $rq['kuchikomi']);
}
// 紙トチ!設置店
if (!empty($rq['kamitochi'])) {
$rq['kamitochi'] = (is_array($rq['kamitochi']))? $rq['kamitochi']: array($rq['kamitochi']);
$where['kamitochi'] = 1;
$search_spec_sce_str[] = '紙トチ!設置店';
}
// とちぎの地産地消推進店
if (!empty($rq['chisan'])) {
$rq['chisan'] = (is_array($rq['chisan']))? $rq['chisan']: array($rq['chisan']);
$where['chisan'] = 1;
$search_spec_sce_str[] = 'とちぎの地産地消推進店';
}
// 宇都宮愉快SHOP
if (!empty($rq['yukai'])) {
$rq['yukai'] = (is_array($rq['yukai']))? $rq['yukai']: array($rq['yukai']);
$where['yukai'] = 1;
$search_spec_sce_str[] = '宇都宮愉快SHOP';
}
// うつのみや地産地消推進店
if (!empty($rq['uchisan'])) {
$rq['uchisan'] = (is_array($rq['uchisan']))? $rq['uchisan']: array($rq['uchisan']);
$where['uchisan'] = 1;
$search_spec_sce_str[] = 'うつのみや地産地消推進店';
}
// ネット予約
if (!empty($rq['reserve'])) {
$rq['reserve'] = (is_array($rq['reserve']))? $rq['reserve']: array($rq['reserve']);
$where['reserve'] = 1;
$search_spec_sce_str[] = 'ネット予約可能店';
}
// スペースマッチング
if (!empty($rq['space'])) {
$rq['space'] = (is_array($rq['space']))? $rq['space']: array($rq['space']);
$where['space'] = 1;
$search_spec_sce_str[] = 'スペースマッチング参加店';
}
// テイクアウト
if (!empty($rq['takeout'])) {
$rq['takeout'] = (is_array($rq['takeout']))? $rq['takeout']: array($rq['takeout']);
$where['takeout'] = 1;
$search_spec_sce_str[] = 'テイクアウト予約可能店';
}
// ネットショップ
if (!empty($rq['netshop'])) {
$rq['netshop'] = (is_array($rq['netshop']))? $rq['netshop']: array($rq['netshop']);
$where['netshop'] = 1;
$search_spec_sce_str[] = 'ネットショップ登録店';
}
// コロナ対策宣言
if (!empty($rq['covid'])) {
$rq['covid'] = (is_array($rq['covid']))? $rq['covid']: array($rq['covid']);
$where['covid'] = 1;
$search_spec_sce_str[] = 'コロナ対策宣言';
}
// 現在営業中
if (!empty($rq['is_now'])) {
$rq['is_now'] = (is_array($rq['is_now']))? $rq['is_now']: array($rq['is_now']);
$where['is_now'] = 1;
$search_spec_sce_str[] = '現在営業中';
}
// キャンペーン中
if (!empty($rq['cam'])) {
$rq['campaign'] = $rq['cam'];
unset($rq['cam']);
}
if (!empty($rq['campaign'])) {
$rq['campaign'] = (is_array($rq['campaign']))? $rq['campaign']: array($rq['campaign']);
$where['campaign'] = 1;
$search_spec_sce_str[] = 'キャンペーン中';
}
// スタンプラリー開催中
if (!empty($rq['stamprally'])) {
$rq['stamprally'] = (is_array($rq['stamprally']))? $rq['stamprally']: array($rq['stamprally']);
$where['stamprally'] = 1;
$search_spec_sce_str[] = 'スタンプラリー対象店';
}
// ポイント交換賞品
if (!empty($rq['point'])) {
$rq['point'] = (is_array($rq['point']))? $rq['point']: array($rq['point']);
$where['point'] = 1;
$search_spec_sce_str[] = 'ポイント交換賞品あり';
}
// オンライン開催
if (!empty($rq['online'])) {
$rq['online'] = (is_array($rq['online']))? $rq['online']: array($rq['online']);
$where['online'] = 1;
$search_spec_sce_str[] = 'オンライン開催';
}
// サービス
if (!empty($rq['s'])) {
$rq['service'] = $rq['s'];
unset($rq['s']);
}
if (!empty($rq['service'])) {
$rq['service'] = (is_array($rq['service']))? $rq['service']: array($rq['service']);
if (empty($format)) {
foreach ($rq['service'] AS $k => $v) {
$temp = array();
try {
$temp = $service->get_data($v);
} catch (ServiceError $e) {
}
if (!empty($temp) && $temp['enable'] == 1) {
$search_spec_sce_str[] = $temp['name_01'];
} else {
unset($rq['service'][$k]);
}
}
}
$where['service'] = $rq['service'];
}
// 病院サービス
if (!empty($rq['service_h'])) {
$rq['service_h'] = (is_array($rq['service_h']))? $rq['service_h']: array($rq['service_h']);
if (empty($format)) {
foreach ($rq['service_h'] AS $k => $v) {
$temp = array();
try {
$temp = $hospital_service->get_data($v);
} catch (HospitalServiceError $e) {
}
if (!empty($temp) && $temp['enable'] == 1) {
$search_spec_sce_str[] = $temp['name_01'];
} else {
unset($rq['service_h'][$k]);
}
}
}
$where['service_h'] = $rq['service_h'];
}
// イベントサービス
if (!empty($rq['service_e'])) {
$rq['service_e'] = (is_array($rq['service_e']))? $rq['service_e']: array($rq['service_e']);
if (empty($format)) {
foreach ($rq['service_e'] AS $k => $v) {
$temp = array();
try {
$temp = $event_service->get_data($v);
} catch (EventServiceError $e) {
}
if (!empty($temp) && $temp['enable'] == 1) {
$search_spec_sce_str[] = $temp['name_01'];
} else {
unset($rq['service_e'][$k]);
}
}
}
$where['service_e'] = $rq['service_e'];
}
// バリアフリー
if (!empty($rq['barrier'])) {
$rq['barrier'] = (is_array($rq['barrier']))? $rq['barrier']: array($rq['barrier']);
if (empty($format)) {
foreach ($rq['barrier'] AS $k => $v) {
$temp = array();
try {
$temp = $barrier->get_data($v);
} catch (BarrierfreeError $e) {
}
if (!empty($temp) && $temp['enable'] == 1) {
$search_spec_sce_str[] = $temp['name_01'];
} else {
unset($rq['barrier'][$k]);
}
}
}
$where['barrier'] = $rq['barrier'];
}
// 予算
if (!empty($rq['price'])) {
$rq['price'] = (is_array($rq['price']))? $rq['price']: array($rq['price']);
if (empty($format)) {
$temp = array(1 => '1,000円以下', 2 => '1,001~2,000円', 3 => '2,001~3,000円', 4 => '3,001~4,000円', 5 => '4,001~5,000円', 6 => '5,000円以上', 7 => '無料(値段設定なし)');
foreach ($rq['price'] AS $k => $v) {
if (isset($temp[$v])) {
$search_spec_sce_str[] = $temp[$v];
} else {
unset($rq['price'][$k]);
}
}
}
$where['price'] = $rq['price'];
}
// 状況
if (!empty($rq['scene'])) {
$rq['scene'] = (is_array($rq['scene']))? $rq['scene']: array($rq['scene']);
if (empty($format)) {
foreach ($rq['scene'] AS $k => $v) {
try {
$temp = $event_scene->get_data($v);
} catch (EventSceneError $e) {
}
if (!empty($temp)) {
$search_spec_sce_str[] = $temp['name_01'];
} else {
unset($rq['scene'][$k]);
}
}
}
$where['scene'] = $rq['scene'];
}
// 終了を表示しない
if (!empty($rq['end'])) {
$rq['end'] = (is_array($rq['end']))? $rq['end']: array($rq['end']);
$where['end'] = 1;
$search_spec_sce_str[] = '終了を表示しない';
}
// 特集 ----------------------------------------------------------------------------------------------------
// 特集
if (!empty($rq['feature'])) {
$rq['feature'] = (is_array($rq['feature']))? $rq['feature']: array($rq['feature']);
if (empty($format)) {
foreach ($rq['feature'] AS $k => $v) {
$temp = array();
try {
$temp = $feature->get_data($v, 0, 1);
} catch (FeatureError $e) {
}
if (!empty($temp)) {
$search_spec_fea_str[] = $temp['title_01'];
} else {
unset($rq['feature'][$k]);
}
}
}
$where['feature'] = $rq['feature'];
}
// 属性 ----------------------------------------------------------------------------------------------------
// クチコミタグ
if (!empty($rq['tag'])) {
$rq['tag'] = (is_array($rq['tag']))? $rq['tag']: array($rq['tag']);
if (empty($format)) {
foreach ($rq['tag'] AS $k => $v) {
$name = '';
try {
$temp = $kuchikomi_tag->get_data($v);
$name = strip_tags($temp['name']);
} catch (KuchikomiTagError $e) {
}
if (!empty($name)) {
$search_spec_mem_str[] = $name;
} else {
unset($rq['tag'][$k]);
}
}
}
$where['tag_id'] = $rq['tag'];
}
// エリア
if (!empty($rq['member_A3'])) {
$rq['member_A3'] = (is_array($rq['member_A3']))? $rq['member_A3']: array($rq['member_A3']);
if (empty($format)) {
foreach ($rq['member_A3'] AS $k => $v) {
$name = '';
try {
$name = $area->get_name('area_master_03_tbl', $v);
} catch (AreaError $e) {
}
if (!empty($name)) {
$search_spec_mem_str[] = $name;
} else {
unset($rq['member_A3'][$k]);
}
}
}
$where['area'] = $rq['member_A3'];
}
// 圏域
if (!empty($rq['member_A2'])) {
if (!isset($where['area'])) {
$where['area'] = array();
}
$rq['member_A2'] = (is_array($rq['member_A2']))? $rq['member_A2']: array($rq['member_A2']);
foreach ($rq['member_A2'] AS $k => $v) {
if ($v == -1) {
$where['area'][] = -1;
$search_spec_mem_str[] = '栃木県以外';
} else {
$name = '';
try {
$name = $area->get_name('area_master_02_tbl', $v);
} catch (AreaError $e) {
}
if (!empty($name)) {
$search_spec_mem_str[] = $name;
try {
$child = $area->get_data_array('area_master_03_tbl', true, $v);
foreach ($child AS $val) {
$where['area'][] = $val['id'];
}
unset($child, $val);
} catch (AreaError $e) {
}
} else {
unset($rq['member_A2'][$k]);
}
}
}
}
// 対象
if (!empty($rq['target_type'])) {
$rq['target_type'] = (is_array($rq['target_type']))? $rq['target_type']: array($rq['target_type']);
if (empty($format)) {
$temp = array(1 => 'スポット', 2 => 'イベント', 4 => '特集', 5 => 'エリア');
foreach ($rq['target_type'] AS $k => $v) {
if (isset($temp[$v])) {
$search_spec_type_str[] = $temp[$v];
} else {
unset($rq['target_type'][$k]);
}
}
}
$where['target_type'] = $rq['target_type'];
}
if (!empty($rq['is_fkd'])) {
$where['is_fkd'] = $rq['is_fkd'] = 1;
}
}
if ($format == 'search' || $format == 'search_sp') {
/* SQL取得 */
$temp = array();
if ($err_str === "") {
if ($type == 'kuchikomi') {
try {
if ($list_type == 1) {
$where['img'] = 1;
}
$where['parent_enable'] = 2;
$where['sort'] = 1;
$sql = $kuchikomi->get_id_query(0, 0, true, $where);
} catch (KuchikomiError $e) {
$err_str = $e->get_exception();
}
} else {
try {
$sql = $search->get_query($where, $sort, $vector);
} catch (SearchError $e) {
$err_str = $e->get_exception();
}
}
}
/* データ取得 */
if ($err_str === "") {
$item_line = ($type == 'kuchikomi' && $list_type == 1)? 48: $item_line;
$result = $locomill->get_db3()->query($sql);
if ($result !== false) {
$item_num = $locomill->get_db3()->num($result);
if ($item_num > 0) {
$page = $pager->exec($item_num, $page, $item_line, $pane_num);
if ($pager->get_err_str() === "") {
if ($locomill->get_db3()->seek($result, $pager->get_start_row())) {
for ($i = $pager->get_start_row(); $i < $pager->get_end_row(); $i++) {
$row = $locomill->get_db3()->fetch_array($result);
if ($type == 'kuchikomi') {
$temp[$row['id']] = $kuchikomi->adjust($row['id'], $login_user_id, true);
} else {
$temp[$row['id']] = $search->get_data_by_id($row['id']);
}
}
} else {
$err_str = "・データの参照に失敗しました。
" . mysqli_error($locomill->get_db3()->get_db_connect());
}
} else {
$err_str = "・ページ情報の処理に失敗しました。
";
}
}
} else {
$err_str = "・データの参照に失敗しました。
" . mysqli_error($locomill->get_db3()->get_db_connect());
}
}
/* データ整形 */
if ($err_str === "") {
if ($type == 'kuchikomi') {
foreach ($temp AS $k => $v) {
$v['TARGET_TYPE'] = 'k';
$item_array[$k] = $v;
}
} else {
$item_array = $search->adjust($temp, $where['terminal']);
if ($type == 'spot') {
foreach ($item_array AS &$v) {
if (isset($v['IS_RESERVE']) && $v['IS_RESERVE'] == 1) {
try {
$v['RESERVE_CALENDAR'] = $spot->get_reserve_calendar($v['TARGET_ID']);
} catch (SpotError $e) {
$v['RESERVE_CALENDAR'] = array();
}
}
} unset($v);
}
}
}
unset($temp);
/* 変数の準備 */
$smarty->assign("LIST_TYPE", $list_type);
$smarty->assign("RQ", escapeHTML($rq));
// 検索結果数
$smarty->assign("RESULT_NUM", $item_num);
// 結果データ配列
$smarty->assign("ITEM_ARRAY", $item_array);
// ログインURL
$smarty->assign("LOGIN_URL", str_replace('&format=search', '', str_replace('&format=search_sp', '', $_SERVER['REQUEST_URI'])));
// ぐっとタイプ
$smarty->assign("GOOD_TYPE_ARRAY", escapeHTML($good_type_array));
/* 広告系 */
$adver_out = array();
if ($type == 'spot') {
$the_corner_id = 9;
$category_list_01_id = $category_list_02_id = $category_list_03_id = '';
if (!empty($rq['C3']) && count($rq['C3']) == 1) {
$category_list_03_id = $rq['C3'][0];
} elseif (!empty($rq['C2']) && count($rq['C2']) == 1) {
$category_list_02_id = $rq['C2'][0];
} elseif (!empty($rq['C1']) && count($rq['C1']) == 1) {
$category_list_01_id = $rq['C1'][0];
}
$adver_param = array('terminal_type' => 1,
'corner_id' => $the_corner_id,
'category_list_01_id' => $category_list_01_id,
'category_list_02_id' => $category_list_02_id,
'category_list_03_id' => $category_list_03_id,
'b_type' => 13);
require_once('adver.inc');
try {
$adver = new Adver($locomill->get_db());
$adver_out = $adver->get_adver_data($adver_param);
} catch (AdverError $e) {
$err_str = $e->get_exception();
}
}
$smarty->assign("PR_ARRAY", $adver_out);
// エラー文字列
$smarty->assign("ERR_STR", $err_str);
/* 出 力 */
$data = $smarty->fetch('search_result/search.tpl');
$json = array('data' => $data,
'item_num' => $item_num,
'pager' => $pager->get_page_info_public());
ob_start('ob_gzhandler');
header('Content-Type: application/json; charset=utf-8');
echo json_encode($json);
exit;
}
/* 大カテゴリ・エリア取得 */
if ($err_str === "") {
$temp = $temp2 = $temp3 = array();
if ($type == 'spot' || $type == 'event') {
try {
if (((!empty($rq['C3']) && count($rq['C3']) == 1) || (!empty($rq['C3_H']) && count($rq['C3_H']) == 1)) && $type == 'spot') {
$category_03_rq = (!empty($rq['C3']))? $rq['C3'][0]: $rq['C3_H'][0];
$temp = $category->get_data(3, -1, $category_03_rq);
$category_02_rq = $temp['parent_id'];
}
if (((!empty($rq['C2']) && count($rq['C2']) == 1) || !empty($category_02_rq)) && $type == 'spot') {
if (!empty($rq['C2'][0])) {
$category_02_rq = $rq['C2'][0];
}
$temp = $category->get_data_array(3, $category_02_rq, true, true, 1);
foreach ($temp AS $v) {
$category_03_array[$v['id']] = $v['name_01'];
}
$temp = $category->get_data(2, -1, $category_02_rq);
$category_01_rq = $temp['parent_id'];
}
if ((!empty($rq['C1']) && count($rq['C1']) == 1) || !empty($category_01_rq)) {
if (!empty($rq['C1'][0])) {
$category_01_rq = $rq['C1'][0];
}
$temp = $category->get_data_array(2, $category_01_rq, true, true, ($type == 'spot'? 1: 3));
foreach ($temp AS $v) {
$category_02_array[$v['id']] = $v['name_01'];
}
}
$temp = $category->get_data_array(1, -1, true, true, ($type == 'spot'? 1: 3));
foreach ($temp AS $v) {
$category_01_array[$v['id']] = $v['name_01'];
}
} catch (CategoryError $e) {
$err_str .= $e->get_exception();
}
}
try {
$temp = $area->get_data_array('area_master_02_tbl', true);
foreach ($temp AS $v) {
$area_array[sprintf('A2_%d', $v['id'])] = '●' . $v['name'];
if ($v['id'] == 1) {
$temp2 = $area->get_data_array('area_master_flag_01_tbl', true, $v['id']);
foreach ($temp2 AS $v2) {
$area_array[sprintf('F1_%d', $v2['id'])] = ' ' . $v2['name'];
if ($v2['id'] == 1) {
$temp3 = $area->get_data_array('area_master_flag_02_tbl', true, $v2['id']);
foreach ($temp3 AS $v3) {
$area_array[sprintf('F2_%d', $v3['id'])] = ' ' . $v3['name'];
}
}
}
} else {
$temp2 = $area->get_data_array('area_master_03_tbl', true, $v['id']);
foreach ($temp2 AS $v2) {
$area_array[sprintf('A3_%d', $v2['id'])] = ' ' . $v2['name'];
}
}
}
if (!empty($rq['F2']) && count($rq['F2']) == 1) {
$area_rq = sprintf('F2_%d', $rq['F2'][0]);
} elseif (!empty($rq['F1']) && count($rq['F1']) == 1) {
$area_rq = sprintf('F1_%d', $rq['F1'][0]);
} elseif (!empty($rq['A3']) && count($rq['A3']) == 1) {
$area_rq = sprintf('A3_%d', $rq['A3'][0]);
} elseif (!empty($rq['A2']) && count($rq['A2']) == 1) {
$area_rq = sprintf('A2_%d', $rq['A2'][0]);
}
} catch (AreaError $e) {
$err_str .= $e->get_exception();
}
unset($temp, $temp2, $temp3);
}
/* 変数の準備 */
$smarty->assign("TYPE", $type);
$smarty->assign("PAGE", $page);
$smarty->assign("SORT", $sort);
$smarty->assign("LIST_TYPE", $list_type);
$smarty->assign("RQ", escapeHTML($rq));
$values = array();
foreach ($rq AS $k => $v) {
if (!empty($v) && !in_array($k, array('page', 'sort', 'type', 'list_type'))) {
$values[$k] = $v;
}
}
$smarty->assign("VALUES", escapeHTML($values));
// カテゴリ
$smarty->assign("CATEGORY_01_ARRAY", $category_01_array);
$smarty->assign("CATEGORY_02_ARRAY", $category_02_array);
$smarty->assign("CATEGORY_03_ARRAY", $category_03_array);
$smarty->assign("CATEGORY_01_RQ", $category_01_rq);
$smarty->assign("CATEGORY_02_RQ", $category_02_rq);
$smarty->assign("CATEGORY_03_RQ", $category_03_rq);
// エリア
$smarty->assign("AREA_ARRAY", $area_array);
$smarty->assign("AREA_RQ", $area_rq);
// 年
$smarty->assign("YEAR_ARRAY", array(date('Y'), date('Y') + 1));
// ソート順
$smarty->assign("SORT_LIST", $sort_menu);
// ページタイトル情報
$page_title = array();
if (!empty($search_spec_word_str)) {
$page_title[] = implode(' ', $search_spec_word_str);
}
if (!empty($search_spec_cat_str)) {
$page_title[] = implode(' ', $search_spec_cat_str);
}
if (!empty($search_spec_area_str)) {
$page_title[] = implode(' ', $search_spec_area_str);
}
if (!empty($search_spec_sce_str)) {
$page_title[] = implode(' ', $search_spec_sce_str);
}
if (!empty($search_spec_mem_str)) {
$page_title[] = implode(' ', $search_spec_mem_str);
}
if (!empty($search_spec_type_str)) {
$page_title[] = implode(' ', $search_spec_type_str);
}
$smarty->assign("PAGE_TITLE_STR", (!empty($page_title)? htmlspecialchars(implode(' | ', $page_title)) . ' | ': ''));
// キーワード情報
$keyword = array();
if (!empty($search_spec_word_str)) {
$keyword = array_merge($keyword, $search_spec_word_str);
}
if (!empty($search_spec_cat_str)) {
$keyword = array_merge($keyword, $search_spec_cat_str);
}
if (!empty($search_spec_area_str)) {
$keyword = array_merge($keyword, $search_spec_area_str);
}
if (!empty($search_spec_sce_str)) {
$keyword = array_merge($keyword, $search_spec_sce_str);
}
if (!empty($search_spec_mem_str)) {
$keyword = array_merge($keyword, $search_spec_mem_str);
}
if (!empty($search_spec_type_str)) {
$keyword = array_merge($keyword, $search_spec_type_str);
}
$smarty->assign("KEYWORD_STR", (!empty($keyword)? htmlspecialchars(implode(',', $keyword)) . ',': ''));
// canonical情報・詳細検索フラグ
$detail_flg = $category_num = $area_num = 0;
$param = $rq;
if ($type == 'event' && empty($param['term'])) {
unset($param['year'], $param['month'], $param['day']);
}
$values = array();
$temp = array('type', 'word',
'C1', 'C2', 'C3', 'C3_H', 'A2', 'A3', 'A4', 'F1', 'F2',
'service', 'service_h', 'service_e', 'barrier',
'coupon', 'kuchikomi', 'kamitochi', 'chisan', 'covid', 'yukai', 'uchisan', 'reserve', 'space', 'takeout', 'netshop', 'is_now', 'campaign', 'stamprally', 'point', 'online', 'price', 'scene', 'end',
'term', 'year', 'month', 'day',
'feature',
'tag', 'member_A2', 'member_A3', 'target_type', 'is_fkd', 'list_type');
foreach ($temp AS $v) {
if (isset($param[$v]) && !empty($param[$v])) {
if (is_array($param[$v])) {
foreach ($param[$v] AS $v2) {
$values[] = sprintf('%s%s=%s', $v, ((count($param[$v]) == 1)? '': '[]'), urlencode($v2));
}
} else {
$values[] = sprintf('%s=%s', $v, urlencode($param[$v]));
}
if (!in_array($v, array('type', 'word', 'C1', 'C2', 'C3', 'C3_H', 'A2', 'A3', 'A4', 'F1', 'F2', 'term', 'year', 'month', 'day', 'list_type')) ||
(in_array($v, array('C1', 'C2', 'C3', 'C3_H', 'A2', 'A3', 'A4', 'F1', 'F2')) && 1 < count($param[$v]))
) {
$detail_flg = 1;
} elseif (in_array($v, array('C1', 'C2', 'C3', 'C3_H'))) {
$category_num++;
if ($type == 'event' && $v == 'C2') {
$detail_flg = 1;
}
} elseif (in_array($v, array('A2', 'A3', 'A4', 'F1', 'F2'))) {
$area_num++;
}
}
}
if (1 < $category_num || 1 < $area_num) {
$detail_flg = 1;
}
$page_url = (!empty($values))? htmlspecialchars(sprintf('?%s', implode('&', $values))): '';
$smarty->assign("PAGE_URL", $page_url);
$smarty->assign("DETAIL_FLG", $detail_flg);
unset($param, $detail_flg, $category_num, $area_num);
// イマココ用
$search_title = '';
$search_spec = array();
if (!empty($search_spec_area_str)) {
$search_spec[] = implode(',', $search_spec_area_str);
}
if (!empty($search_spec_type_str)) {
$search_spec[] = implode(',', $search_spec_type_str);
}
if (!empty($search_spec)) {
$search_title .= implode('の', $search_spec);
if ($type == 'kuchikomi') {
$search_title .= 'のクチコミ';
}
}
$search_spec = array();
if (!empty($search_spec_cat_str)) {
$search_spec[] = implode(',', $search_spec_cat_str);
}
if (!empty($search_spec_word_str)) {
$search_spec[] = implode(',', $search_spec_word_str);
}
if (!empty($search_spec_mem_str)) {
$search_spec[] = implode(',', $search_spec_mem_str);
}
if (!empty($search_spec)) {
if (!empty($search_title)) {
if ($type == 'kuchikomi') {
$search_title .= ' ';
} else {
$search_title .= 'の';
}
}
$search_title .= implode(' ', $search_spec);
}
/* Newsクラスインスタンス生成 */
if ($err_str === "") {
try {
$news = new News($locomill->get_db3());
if ($type == 'event') {
$news_type = 3;
} elseif ($type == 'spot') {
$news_type = 2;
} else {
$news_type = 0;
}
if (!empty($news_type)) {
$temp = $news->get_latest_news($news_type, 4);
$news_num = count($temp);
foreach ($temp AS $k => $v) {
$news_array[$k] = $news->adjust($v);
if (count($news_array) == 3) {
break;
}
}
}
} catch (NewsError $e) {
$err_str .= $e->get_exception();
}
}
$smarty->assign("NEWS_ID", $news_type);
$smarty->assign("NEWS_NUM", $news_num);
$smarty->assign("NEWS_ARRAY", $news_array);
// イマココ
$imakoko = getTopicsPath($type);
if ($type == 'feature') {
$imakoko[] = array('/search_result/?type=feature&sort=1', '特集を探す');
}
$c_flg = 0;
if (!empty($imakoko_data1) || !empty($imakoko_data2) || !empty($imakoko_data3) || !empty($imakoko_data3_h)) {
$c_flg = 1;
if (!empty($imakoko_data1)) {
$temp = array();
foreach ($imakoko_data1 AS $k => $v) {
$temp[] = sprintf('C1%s=%d', ((count($imakoko_data1) == 1)? '': '[]'), $k);
}
$imakoko[] = array(sprintf('/search_result/?type=%s&%s', $type, implode('&', $temp)), htmlspecialchars(mb_strimwidth(implode(' ', $imakoko_data1), 0, 50, '…')));
}
if (!empty($imakoko_data2)) {
$temp = array();
foreach ($imakoko_data2 AS $k => $v) {
$temp[] = sprintf('C2%s=%d', ((count($imakoko_data2) == 1)? '': '[]'), $k);
}
$imakoko[] = array(sprintf('/search_result/?type=%s&%s', $type, implode('&', $temp)), htmlspecialchars(mb_strimwidth(implode(' ', $imakoko_data2), 0, 50, '…')));
}
if (!empty($imakoko_data3) || !empty($imakoko_data3_h)) {
$temp = array();
foreach ($imakoko_data3 AS $k => $v) {
$temp[] = sprintf('C3%s=%d', ((count($imakoko_data3) == 1)? '': '[]'), $k);
}
foreach ($imakoko_data3_h AS $k => $v) {
$temp[] = sprintf('C3_H%s=%d', ((count($imakoko_data3_h) == 1)? '': '[]'), $k);
}
$imakoko[] = array(sprintf('/search_result/?type=%s&%s', $type, implode('&', $temp)), htmlspecialchars(mb_strimwidth(implode(' ', array_merge($imakoko_data3, $imakoko_data3_h)), 0, 50, '…')));
}
}
if (!empty($search_title) && !empty($page_url) && ($c_flg == 0 || !empty($search_spec_word_str) || !empty($search_spec_area_str))) {
$imakoko[] = array(sprintf('/search_result/%s', $page_url), htmlspecialchars(mb_strimwidth($search_title, 0, 50, '…')));
}
$smarty->assign("IMAKOKO_ARRAY", $imakoko);
// 最新情報
include('common/whatsnew.inc');
/* 広告系 */
$category_list_01_id = $category_list_02_id = $category_list_03_id = '';
$event_cat_list_01_id = $event_cat_list_02_id = $feature_id = '';
if ($type == 'spot') {
$the_corner_id = 9;
if (!empty($rq['C3']) && count($rq['C3']) == 1) {
$category_list_03_id = $rq['C3'][0];
} elseif (!empty($rq['C2']) && count($rq['C2']) == 1) {
$category_list_02_id = $rq['C2'][0];
} elseif (!empty($rq['C1']) && count($rq['C1']) == 1) {
$category_list_01_id = $rq['C1'][0];
}
} elseif ($type == 'event') {
$the_corner_id = 10;
if (!empty($rq['C2']) && count($rq['C2']) == 1) {
$event_cat_list_02_id = $rq['C2'][0];
} elseif (!empty($rq['C1']) && count($rq['C1']) == 1) {
$event_cat_list_01_id = $rq['C1'][0];
}
} elseif ($type == 'feature') {
$the_corner_id = 11;
if (!empty($rq['feature']) && count($rq['feature']) == 1) {
$feature_id = $rq['feature'][0];
}
} elseif ($type == 'kuchikomi') {
$the_corner_id = 19;
} else {
$the_corner_id = 27;
}
$adver_param = array('terminal_type' => 1,
'corner_id' => $the_corner_id,
'category_list_01_id' => $category_list_01_id,
'category_list_02_id' => $category_list_02_id,
'category_list_03_id' => $category_list_03_id,
'event_cat_list_01_id' => $event_cat_list_01_id,
'event_cat_list_02_id' => $event_cat_list_02_id,
'feature_id' => $feature_id);
if ($format == 'search') {
$adver_b_type = array();
$topics_type = 'none';
} elseif ($format == 'search_sp') {
$adver_b_type = array(1);
$topics_type = 'none';
} else {
$adver_b_type = array(1, 2, 7);
}
include('common/banners.inc');
// エラー文字列
$smarty->assign("ERR_STR", $err_str);
/* 出 力 */
$smarty->display('search_result/index.tpl');