require_once('../prepare.php');
require_once('lib/diary_function.php');
$free_flg = false;
//- 表示対象日記リスト情報取得
if(!empty($p['id'])){
$diary_detail = get_DiaryDetail_id($p['id']);
if(
date("Ymd",mktime(0,0,0,substr($diary_detail[0]['open_date'],5,2),substr($diary_detail[0]['open_date'],8,2),substr($diary_detail[0]['open_date'],0,4)))
==
date("Ymd",mktime(0,0,0,date("m"),date("d"),date("Y")))
){
$free_flg = true;
}
}else{
$diary_detail = get_DiaryDetail();
$free_flg = true;
}
//- メンバーチェック
if(!$free_flg){
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){
header("Location: ".MEMBER_REGIST_URL."?contents=".substr(strrchr(dirname( __FILE__ ) , '/'), 1));
exit;
}
u4user_close($db);
}
function diary_detail( $p , $diary_detail)
{
$this->db = cs4_open();
//- レシピ写真サイズ判定
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 );
$template->setVariable('recipe_name',$diary_detail[0]['rcp_nm']);
$img_filename = array(sprintf("%s_n.jpg",$diary_detail[0]['uniq_id']),sprintf("%s_n-s.jpg",$diary_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;
}
//- 画像セット
switch($photo_size){
case "0":
if(!empty($diary_detail[0]['test_kty_image'])){
$template->setCurrentBlock('__ShowImage__');
$template->setVariable('image_id',$diary_detail[0]['test_kty_image']);
$template->parseCurrentBlock();
}else{
$template->hideBlock('__ShowImage__');
}
break;
case "1":
if(!empty($diary_detail[0]['test_kty_image_mini'])){
$template->setCurrentBlock('__ShowImage__');
$template->setVariable('image_id',$diary_detail[0]['test_kty_image_mini']);
$template->parseCurrentBlock();
}else{
$template->hideBlock('__ShowImage__');
}
break;
}
//- 公開日セット
$tmp = substr($diary_detail[0]['open_date'],0,12);
$date_arr = explode("-",$tmp);
$day = get_Day(date("w",mktime(0,0,0,$date_arr[1],$date_arr[2],$date_arr[0])));
$date_str = sprintf("%d/%d (%s)",$date_arr[1],$date_arr[2],$day);
$template->setVariable('open_date',$date_str);
//- タイトルセット
$template->setVariable('title',$diary_detail[0]['title']);
//- ライターセット
$writer = get_DiaryWriter($diary_detail[0]['test_writer']);
$template->setVariable('writer',$writer);
//- 本文セット
$template->setVariable('body',$diary_detail[0]['test_kty_body']);
//- 前日リンク
if(!empty($diary_detail[1])){
$writer = "";
$writer = get_DiaryWriter($diary_detail[1]['test_writer']);
$template->setCurrentBlock('__Yesterday__');
$template->setVariable('diary_id',$diary_detail[1]['uniq_id']);
$template->setVariable('writer',$writer);
$template->parseCurrentBlock();
}
//- 前々日リンク
if(!empty($diary_detail[2])){
$writer = "";
$writer = get_DiaryWriter($diary_detail[2]['test_writer']);
$template->setCurrentBlock('__2Days_before__');
$template->setVariable('diary_id',$diary_detail[2]['uniq_id']);
$template->setVariable('writer',$writer);
$template->parseCurrentBlock();
}
//- コンテンツトップ戻りリンク
if(strstr(date("Y-m-d"),$diary_detail['open_date'])){
$template->hideBlock('__ReturnContentsTop__');
}else{
$template->setCurrentBlock('__ReturnContentsTop__');
$template->setVariable('contents_top_url','diary_detail.php');
$template->setVariable('contents_top',"キッチンスタジオ通信");
$template->parseCurrentBlock();
}
//- access_log 記録
//$ret = bsc_insert_acslog($this->db,$detail[0],"r",$p['uid']);
$template->show();
cs4_close($this->db);
}
diary_detail( $p , $diary_detail);
?>