require_once('../prepare.php');
//require_once('lib/ranking_function.php');
//- メンバーチェック
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 . "?p[contents]=" . substr(strrchr(dirname( __FILE__ ) , '/'), 1));
exit;
}
function ranking_list( $p )
{
$this->db = cs4_open();
//- ランキングデータ配列取得(週間)
switch($p['id']){
case "m":
$ranking_list = get_RankingData($this->db, '0', RANK_PERIOD_MONTHLY , RANKING_MEAT , 10 );
$start_date = $ranking_list[1]['period_start'];
$tmp_start_arr = explode(" ",$start_date);
$start_ymd_arr = explode("-",$tmp_start_arr[0]);
$str_period = sprintf("%d月",$start_ymd_arr[1]);
// $str_period = sprintf("%d月",date("m",mktime(0,0,0,date("m") - 1,1,date("Y"))));
break;
case "f":
$ranking_list = get_RankingData($this->db, '0', RANK_PERIOD_MONTHLY , RANKING_FISH , 10 );
$start_date = $ranking_list[1]['period_start'];
$tmp_start_arr = explode(" ",$start_date);
$start_ymd_arr = explode("-",$tmp_start_arr[0]);
$str_period = sprintf("%d月",$start_ymd_arr[1]);
// $str_period = sprintf("%d月",date("m",mktime(0,0,0,date("m") - 1,1,date("Y"))));
break;
case "v":
$ranking_list = get_RankingData($this->db, '0', RANK_PERIOD_MONTHLY , RANKING_VEGETABLE , 10 );
$start_date = $ranking_list[1]['period_start'];
$tmp_start_arr = explode(" ",$start_date);
$start_ymd_arr = explode("-",$tmp_start_arr[0]);
$str_period = sprintf("%d月",$start_ymd_arr[1]);
// $str_period = sprintf("%d月",date("m",mktime(0,0,0,date("m") - 1,1,date("Y"))));
break;
default:
$ranking_list = get_RankingData($this->db, '0', RANK_PERIOD_WEEKLY ,'', 10 );
$start_date = $ranking_list[1]['period_start'];
$tmp_start_arr = explode(" ",$start_date);
$start_ymd_arr = explode("-",$tmp_start_arr[0]);
$start_period = sprintf("%d月%d日〜",$start_ymd_arr[1],$start_ymd_arr[2]);
$end_period = date("n月j日",mktime(0,0,0,$start_ymd_arr[1],$start_ymd_arr[2] + 6,$start_ymd_arr[0]));
$str_period = sprintf("%s%s",$start_period,$end_period);
//print "
start_date => ".$start_date."
";
break;
}
//var_dump($ranking_list);
cs4_close($this->db);
// テンプレート読み込み
$template =& loadTemplate( $p );
//- ranking
if(!empty($ranking_list)){
$template->setCurrentBlock('__RankingPeriod__');
$template->setVariable('split_date',$str_period);
$template->parseCurrentBlock();
for($i=1;$i< (count($ranking_list) + 1);$i++){
if(('i' == $p['carrier'] && '2' == $p['version']) || ('v' == $p['carrier'] && '3' == $p['version']) || ('e' == $p['carrier'] && '3' == $p['version']) || ('w' == $p['carrier']) || ('g' == $p['carrier'])){
$thumbnail_path = sprintf("%s/%s_n-thm.jpg",IMG_DIR_RECIPE,$ranking_list[$i]['rcp_no']);
if(file_exists($thumbnail_path) && (3 >= $ranking_list[$i]['rank'])){
$template->setCurrentBlock('__ImageLink__');
$template->setVariable('image_id',$ranking_list[$i]['rcp_no']);
$template->parseCurrentBlock();
}
}
$template->setCurrentBlock('__List__');
$template->setVariable('rank',$ranking_list[$i]['rank']);
$template->setVariable('phrase',$ranking_list[$i]['rcp_exp']);
if(!empty($ranking_list[$i]['rcp_kind'])){
$template->setVariable('rcp_kind',sprintf("・%s",$ranking_list[$i]['rcp_kind']));
}
$template->setVariable('rcp_no',$ranking_list[$i]['rcp_no']);
$template->setVariable('title',$ranking_list[$i]['rcp_nm']);
$template->parseCurrentBlock();
}
}
switch($p['id']){
case "m":
$template->TouchBlock('__TitleMeat__');
$template->TouchBlock('__HeaderLinkMeat__');
$template->TouchBlock('__FooterLinkMeat__');
break;
case "f":
$template->TouchBlock('__TitleFish__');
$template->TouchBlock('__HeaderLinkFish__');
$template->TouchBlock('__FooterLinkFish__');
break;
case "v":
$template->TouchBlock('__TitleVeg__');
$template->TouchBlock('__HeaderLinkVeg__');
$template->TouchBlock('__FooterLinkVeg__');
break;
default:
$template->TouchBlock('__Title__');
$template->TouchBlock('__HeaderLink__');
$template->TouchBlock('__FooterLink__');
break;
}
$template->show();
}
ranking_list( $p );
?>