getFacebookMeta($restaurant['subject'], '', $restaurant['image']) ); setPlusHit($restaurant['no']); $tagRestaurants = findRestaurantByTags($restaurant['no'], $restaurant['tag'], $restaurant['section']); require_once dirname(__FILE__)."/../include/top.php"; $banner = noblesseBanner('banner_home', 'p', '301', 1); } else { notFoundError(); exit; } function findRestaurant($no) { global $db, $homeRootDir, $h_scrap_hit_table, $r_contents_section; $table = $h_scrap_hit_table['restaurant']; $restaurant = array(); $query = " SELECT no, subject, contents, new_file, section, area, address, mapUrl, businessHours, tel, homepage, tag, DATE_FORMAT(R.showDate, '%Y-%m-%d') AS showDate, (SELECT IFNULL(SUM(hit), 0) FROM gd_bd_magazine_hit WHERE contents_table = '".$table."' AND magazine_no = R.no) AS hit, '".$table."' AS tableName FROM ".$table." AS R WHERE (UNIX_TIMESTAMP(R.openDate) = 0 OR (CASE WHEN openTime = 'am' THEN DATE_ADD(R.openDate, INTERVAL 9 HOUR) WHEN openTime = 'pm' THEN DATE_ADD(R.openDate, INTERVAL 21 HOUR) ELSE now() END) <= NOW() ) AND R.no = ".$no.""; $restaurant = $db->fetch($query); if ($restaurant['new_file']) { $images = explodeString('|', $restaurant['new_file']); $restaurant['image'] = getImagePath('board/restaurant', $image); $restaurant['slideImage'] = $images; } else { $restaurant['image'] = getContentsByImage($data['contents']); } if ($restaurant) { $restaurant['snsUrl'] = getSnsUrl('restaurant', $restaurant['no']); $restaurant['categoryUrl'] = $homeRootDir.'/restaurant/list.php?section='.array_search($restaurant['section'], $r_contents_section['r'], true); } return $restaurant; } function setPlusHit($no) { global $db, $h_scrap_hit_table; $table = $h_scrap_hit_table['restaurant']; $query = "SELECT COUNT(1) AS cnt FROM gd_bd_magazine_hit WHERE contents_table = '".$table."' AND hitDate = curdate() AND magazine_no = ".trim($no).""; $res = $db->fetch($query); if ($res['cnt'] > 0) { $query = "UPDATE gd_bd_magazine_hit SET hit = (hit + 1) WHERE contents_table = '".$table."' AND hitDate = curdate() AND magazine_no = ".trim($no).""; } else { $query = "INSERT INTO gd_bd_magazine_hit (contents_table, magazine_no, hitDate, hit, regdt) VALUES('".$table."', ".trim($no).", curdate(), 1, NOW())"; } $res = $db->query($query); } function findRestaurantByTags($no, $tag, $section) { global $db, $h_scrap_hit_table; $table = $h_scrap_hit_table['restaurant']; $restaurants = array(); $tags = array_values(array_filter(array_map('trim',explodeString(',', $tag)))); if (empty($tags)) { return $restaurants; } $field = array ( 'no', 'subject', 'contents', 'new_file', 'section', 'area' ); $caseQuery = ''; $caseSumQuery = ''; for ($i = 0, $a = 'a'; $i < count($tags); $i++, $a++) { $value = $tags[$i]; $caseSumQuery .= ($i == 0 ? "(".$a : $a ); $caseQuery .= "CASE WHEN replace(tag,' ','') REGEXP '^".$value."$|^,".$value."$|^".$value.",$|^,".$value.",$|,".$value.",|,".$value."$' THEN 1 ELSE 0 END AS ".$a.""; if (($i + 1) < count($tags)) { $caseSumQuery .= " + "; $caseQuery .= ","; } else { $caseSumQuery .= ")"; } $caseQuery .= PHP_EOL; } $query = " SELECT ".implode(",", $field).", DATE_FORMAT(showDate, '%Y-%m-%d') AS showDate, '".$table."' AS tableName, ".$caseSumQuery." as tagCount FROM ( SELECT ".implode(",", $field).", showDate, ".$caseQuery." FROM ".$table." AS R WHERE (UNIX_TIMESTAMP(R.openDate) = 0 OR ( CASE WHEN R.openTime = 'am' THEN DATE_ADD(R.openDate, INTERVAL 9 HOUR) WHEN R.openTime = 'pm' THEN DATE_ADD(R.openDate, INTERVAL 21 HOUR) ELSE NOW() END) <= NOW() ) AND R.section = '".$section."' AND R.no <> ".$no." ) AS Sub WHERE ".$caseSumQuery." > 0 ORDER BY tagCount DESC, Sub.showDate DESC, no DESC LIMIT 12"; $res = $db->query($query); while ($data = $db->fetch($res, 1)) { if ($data['new_file']) { $image = explodeString('|', $data['new_file']); $data['image'] = getImagePath('board/restaurant', $image[0]); } else { $data['image'] = getContentsByImage($data['contents']); } $data['snsUrl'] = getSnsUrl('restaurant', $data['no']); $restaurants[] = $data; } return $restaurants; } function changeSectionName($value) { switch ($value) { case 'Cafe' : return 'Café'; break; case 'etc' : return 'Etc.'; break; default : return $value; break; } } ?>

Restaurant

    $data) { ?>
    $data) { ?>
  • >

Infomation

  • Address
  • Business Hours
  • Call
  • Homepage
0){ ?>