db = cs4_open();
//- レシピ詳細情報取得
$db_r = DB::connect(constant('KTY_DSN_R'));
if(DB::isError($db_r)){
echo "DB接続エラー:".DB::errorMessage($db_r)."\n";
exit;
}
$detail = get_rcpDetail_new($db_r,$p['id']);
//- 2007.07.06 J.Nikaido Add 有料レシピの場合には無料会員はマイメニュー登録ページへ遷移
if($detail[0][toll_flg] >= 1){
//- メンバーチェック
if("e" == $p['carrier']){
chdir(dirname(__FILE__) . "/authcheck");
require_once("../authcheck/authcheck.php");
chdir(dirname(__FILE__));
}
$db = u4user_open();
if(!get_UserDetail_uid($db, $p['uid'], '0', '1') && MEMBER_CHECK){
/*$p['template'] = preg_replace('/.php$/','_free.html', basename( $_SERVER['SCRIPT_NAME'] ) );
$p['template_x'] = preg_replace('/.php$/','_free.xhtml', basename( $_SERVER['SCRIPT_NAME'] ) );
$free_flg = true;*/
//header("Location: " . MEMBER_REGIST_URL . "?p[contents]=" . substr(strrchr(dirname( __FILE__ ) , '/'), 1));
header("Location: " . NEW_MEMBER_REGIST_URL . "?p[contents]=" . substr(strrchr(dirname( __FILE__ ) , '/')."_".$p['id'], 1));
exit;
}
u4user_close($db);
}
//- レシピ写真サイズ判定
//$photo_size = (empty($p['p_size'])) ? '0' : '1' ;
if("1" == $p['version']){
$photo_size = 1;
}else{
$photo_size = 0;
}
//- au Ver.2 対応
if("e" == $p['carrier'] && $p['version'] == "2"){
$photo_size = 1;
}
$dir_name = substr(strrchr(dirname( __FILE__ ) , '/'), 1);
// テンプレート読み込み
$template =& loadTemplate( $p );
/*if($free_flg){
if($p['carrier'] == 'i'){
$template->setVariable('regist_url', MEMBER_REGIST_URL . "?uid=NULLGWDOCOMO&p[contents]=" . $dir_name."_".$p['id']);
}else{
$template->setVariable('regist_url', MEMBER_REGIST_URL . "?p[contents]=" . $dir_name."_".$p['id']);
}
}*/
$template->setVariable('recipe_name',$detail[0]['rcp_nm']);
$img_filename = array(sprintf("%s_n.jpg",$detail[0]['uniq_id']),sprintf("%s_n-s.jpg",$detail[0]['uniq_id']));
switch($photo_size){
case "0":
$img_path = sprintf("%s/%s",constant('IMG_DIR_RECIPE'),$img_filename[0]);
$another_url = sprintf("%s/%s",constant('IMG_DIR_RECIPE'),$img_filename[1]);
if(file_exists($img_path)){
$template->setVariable('recipe_image',sprintf("",str_replace(KTY_SERVER_ROOT,"",$img_path)));
}
clearstatcache();
break;
case "1":
$img_path = sprintf("%s/%s",constant('IMG_DIR_RECIPE'),$img_filename[1]);
$another_url = sprintf("%s/%s",constant('IMG_DIR_RECIPE'),$img_filename[0]);
if(file_exists($img_path)){
$template->setVariable('recipe_image',sprintf("",str_replace(KTY_SERVER_ROOT,"",$img_path)));
}
clearstatcache();
break;
default:
break;
}
//- 塩分量表示追加
if(!empty($detail[0]['rcp_salt']) && "1" == $detail[0]['rcp_salt_flg']){
$template->setCurrentBlock('__Salt__');
$template->setVariable('salt',sprintf("%sg
",$detail[0]['rcp_salt']));
$template->parseCurrentBlock();
}
if(!empty($detail[0]['rcp_menu'])){
$template->setCurrentBlock('__Genre__');
$template->setVariable('genre',sprintf("%s
",$detail[0]['rcp_menu']));
$template->parseCurrentBlock();
}
if(!empty($detail[0]['rcp_time'])){
$template->setCurrentBlock('__Time__');
$template->setVariable('time',sprintf("%s分
",$detail[0]['rcp_time']));
$template->parseCurrentBlock();
}
if(!empty($detail[0]['rcp_crl'])){
$template->setCurrentBlock('__Calorie__');
$template->setVariable('calorie',sprintf("%skcal
",$detail[0]['rcp_crl']));
$template->parseCurrentBlock();
}
if(!empty($detail[0]['rcp_style'])){
$template->setCurrentBlock('__Style__');
$template->setVariable('style',sprintf("%s
",$detail[0]['rcp_style']));
$template->parseCurrentBlock();
}
if(!empty($detail[0]['rcp_num'])){
$template->setVariable('number_of_persons',sprintf("(%s人分)",$detail[0]['rcp_num']));
}
else
{
$template->touchBlock("__Easy__");
}
//- 材料セット
$ing = array();
$detail[0]['rcp_cook_mtr'] = str_replace("、",",",$detail[0]['rcp_cook_mtr']);
$ing = explode(",",$detail[0]['rcp_cook_mtr']);
for($i=0;$isetCurrentBlock('__Ingedients__');
$ing_name = get_filter($ing_name);
$template->setVariable('Ingredients',$ing_name);
if(!empty($ing_amount)){
$template->setVariable('amount',sprintf(":%s",$ing_amount));
}
$template->parseCurrentBlock();
}
//if(!$free_flg){
//- 作り方セット
$howto = array();
$howto = explode(",",$detail[0]['mtr_cook_exp']);
$exist_show = get_bsc_img_show($p['uid']);
if(!$p['flg']){
if($exist_show){
$p['flg'] = $exist_show;
} else {
$p['flg'] = 2;
}
}
$exist_flg = 0;
for($i=0;$itouchBlock('__HowtoCook__');
$image_id = "process_".($i+1)."_image";
if($detail[0][$image_id] && $p['flg'] == 1){
$template->setVariable('image_id',$detail[0][$image_id]);
}
if($detail[0][$image_id]) {
$exist_flg++;
}
$template->setVariable('process',sprintf("%s.%s",$i + 1,$howto[$i]));
$template->setVariable('_process_num_',$i+1);
$template->setVariable('_process_howto_',get_filter($howto[$i]));
$template->parse('__HowtoCook__');
}
if($exist_flg == 0){
$template->hideBlock("__show__");
}else{
if(!$p['flg']) {
$template->touchBlock("__a1__");
$template->touchBlock("__t2__");
$template->hideBlock("__t1__");
$template->hideBlock("__a2__");
} else {
$image_show = get_ImageShow($p['uid'], $p['flg']);
if($p['flg'] == 1) {
$template->touchBlock("__t1__");
$template->touchBlock("__a2__");
$template->hideBlock("__a1__");
$template->hideBlock("__t2__");
}else{
$template->touchBlock("__t2__");
$template->touchBlock("__a1__");
$template->hideBlock("__a2__");
$template->hideBlock("__t1__");
}
}
}
//- Memoセット
$template->setCurrentBlock('__Memo__');
$detail[0]['rcp_comment'] = str_replace("", '', $detail[0]['rcp_comment']);
$detail[0]['rcp_comment'] = str_replace('', '', $detail[0]['rcp_comment']);
$detail[0]['rcp_comment'] = str_replace('', '', $detail[0]['rcp_comment']);
$detail[0]['rcp_comment'] = get_filter($detail[0]['rcp_comment']);
$template->setVariable('memo',"".$detail[0]['rcp_comment']."");
$template->parseCurrentBlock();
$template->setVariable('rcp_no',$detail[0]['uniq_id']);
//- お気に入り セット
if( is_favorite($this->db,$detail[0]['uniq_id'],$p['uid']) ){
$template->setCurrentBlock('__FavoriteOff__');
$template->setVariable('rcp_no',$detail[0]['uniq_id']);
$template->setVariable('contents','okazu_new');
$template->parseCurrentBlock();
$template->hideBlock('__FavoriteOn__');
}else{
$template->setCurrentBlock('__FavoriteOn__');
$template->setVariable('rcp_no',$detail[0]['uniq_id']);
$template->setVariable('contents','okazu_new');
$template->parseCurrentBlock();
$template->hideBlock('__FavoriteOff__');
}
//- 検索条件
$p['pre_terms'] = serialize($p);
//}
//- access_log 記録
//$ret = bsc_insert_acslog($this->db,$detail[0],"r",$p['uid']);
$ktkm = get_ktkm($p['id']);
$review = get_review($p['id']);
if($review)
{
$template->setVariable('review_count', $review['review_count']);
if($review['rating']){
$template->setVariable('prating', get_star($review['rating']));
}
if($review['value']){
$template->setVariable('value', $review['value'], 'hq');
}
$template->setVariable('r_user_name', $review['handle']);
$template->setVariable('ruurl', $review['user_url']);
$template->setVariable('r_create_datetime', $review['create_datetime']);
$template->setVariable('view_url', $review['review_url']);
$template->setVariable('vote_url', $review['vote_url']);
}
if($ktkm)
{
$template->setVariable('star', $ktkm['star']);
$template->setVariable('rstar', $ktkm['star']);
if($ktkm['ranking']){
foreach($ktkm['ranking'] as $k=> $v){
$template->touchBlock('__Rdata__');
$template->setVariable('url', $v['url']);
$v['theme_name'] = mb_ereg_replace( "\{_#i\w{4}_\}", "", $v['theme_name'] );
$template->setVariable('theme_name', $v['theme_name']);
$template->setVariable('rating_name', $v['rating_name']);
$template->setVariable('rating', get_star($v['rating']));
$template->setVariable('rank', $v['rank']);
$template->parse('__Rdata__');
}
}
if($ktkm['photo']){
foreach($ktkm['photo'] as $k=> $v){
$template->touchBlock('__Pdata__');
$template->setVariable('photo', $v['picture_url']);
$template->setVariable('ptitle', $v['photo_title']);
$template->setVariable('user_name', $v['user_name']);
$template->setVariable('create_datetime', $v['create_datetime']);
$template->setVariable('uurl', $v['url']);
$template->setVariable('purl', $v['purl']);
$template->setVariable('p_view_url', $v['view_url']);
$template->setVariable('ph_rcnt', $v['ph_rcnt']);
$template->setVariable('ph_vote_url', $v['vote_url']);
$template->parse('__Pdata__');
}
}else{
$template->setVariable('ph_vote_url', $v['view_url']);
}
}
if($p['carrier'] == 'i'){
header( "Content-Type: application/xhtml+xml;charset=EUC-JP" );
}
$template->show();
cs4_close($this->db);
cs4_close($db_r);
}
function get_filter($data){
$data = str_replace('/search/','/search_new/',$data);
$data = str_replace('/jouzu/','/jouzu_new/',$data);
$data = str_replace('/kotu/','/kotu_new/',$data);
return $data;
}
function get_star($rating){
if($rating < 1){
return "☆☆☆☆☆";
} else if($rating >= 1 && $rating < 2){
return "★☆☆☆☆".$rating;
} else if($rating >= 2 && $rating < 3){
return "★★☆☆☆".$rating;
} else if($rating >= 3 && $rating < 4){
return "★★★☆☆".$rating;
} else if($rating >= 4 && $rating < 5){
return "★★★★☆".$rating;
} else if($rating >=5){
return "★★★★★".$rating;
}
}
special_detail( $p );
?>