7 && date("G") < 21){ redirect_to('/index.html?from=CYisouSpider'); } if(stripos($_SERVER['HTTP_USER_AGENT'],'MSUI') !== false || stripos($_SERVER['HTTP_USER_AGENT'],'CLRMSN') !== false){ $is_ad_buliang = 2; } } //获取营养根据食材 function get_shicai_data($news_id){ //$recipe_info=Recipe::recipe_detail($news_id,true); //查询菜谱详情数据 $recipe_info=recipe::recipe_detail($news_id,true); //主料 $amount_num=0; $et_is_chi=1; $is_zha=0; if(strpos($recipe_info['title'],"炸") !== false || $recipe_info['gy_id']==153){ $is_zha=1; } $zhuliao_json=json_decode($recipe_info['zhuliao_json_data'],true); //查询主料信息 if($zhuliao_json){ foreach($zhuliao_json as $zhuliao){ $title=$zhuliao['title']; if(strpos($title,"辣椒") !== false || strpos($title,"朝天椒") !== false || strpos($title,"小米辣") !== false || strpos($title,"小米椒") !== false || strpos($title,"线椒") !== false || strpos($title,"尖椒") !== false || strpos($title,"郫县豆瓣") !== false || strpos($title,"螺丝椒") !== false || strpos($title,"麻辣") !== false) { $et_is_chi=0; } if(strpos($title,"糖") !== false) { $amount_num+=findNum($zhuliao['amount']); }else{ continue; } } } //主料结束 //辅料 $fuliao_json=json_decode($recipe_info['fuliao_json_data'],true); //查询辅料料信息 if(!empty($fuliao_json)){ foreach($fuliao_json as $fuliao){ $title=$fuliao['title']; if(strpos($title,"辣椒") !== false || strpos($title,"朝天椒") !== false || strpos($title,"小米辣") !== false || strpos($title,"小米椒") !== false || strpos($title,"线椒") !== false || strpos($title,"尖椒") !== false || strpos($title,"郫县豆瓣") !== false || strpos($title,"螺丝椒") !== false || strpos($title,"麻辣") !== false) { $et_is_chi=0; } if(strpos($title,"糖") !== false) { $amount_num+=findNum($fuliao['amount']); }else{ continue; } } } //辅料结束 $return['xt_hl']=$amount_num; $return['et_is_chi']=$et_is_chi; $return['is_zha']=$is_zha; return $return; } function findNum($str=''){ if($str=="少量"){ $result = 3; return $result; } if($str=="适量"){ $result = 6; return $result; } $str=trim($str); if(empty($str)){return '';} $result=''; for($i=0;$iget('news_properties::fav_num:'.$id); $show_num2 = $r_redis->increment('phome_ecms_news::onclick:'.$id); if(empty($fav_num)){ $fav_num=0; } // by alun 这个存储没有实际用处, 直接去掉 //memcache_service::save_by_column($id,"phome_ecms_news",'onclick',($show_num + 1)); } if($news[phome_ecms_news::CHECKED]==20){ redirect_to('/?from=nn'); } if($is_ad_buliang == 2){//baidu iframe require PROJECT_ROOT_DIR . '/view/page/ad_jump_page.php'; exit(); } if(!empty($news['checked'])){ if(in_array($news['checked'],array(3,16,17))){ if(!empty($_SERVER['HTTP_USER_AGENT']) && preg_match('/spider|googlebot/i',$_SERVER['HTTP_USER_AGENT'])){ //如果判断是蜘蛛,允许访问 }else{ redirect_to('/?q='.urlencode($news['title']),'so'); } }elseif ($news['checked'] == 4){ redirect_to('/?from=nam'); }elseif ($news['checked'] == 7){ redirect_to('/?from=nad'); } } $from = gp('msjfrom'); if($from && ($from == 'msjweixin' || $from == 'ccjsweixin' || $from == 'wapcontent')){ if(ms_util::isMobile()){ redirect_to('/html5/news.php?id='.$id,'m'); } } $new_data = memcache_service::get_from_store('wp_index_new_recipes_18','md_41'); if($new_data && is_array($new_data)){ $tj_info= $new_data; } if(!empty($tj_info)){ foreach($tj_info as $key=>$value){ if($_SERVER['SERVER_NAME']=='tm.meishi.cc'){ $tj_info[$key]['titleurl'] = str_replace('www.bujia24.com','tm.meishi.cc/html5',$value['titleurl']); } $tj_info[$key]['titlepic'] = str_replace("http://","https://",$value['titlepic']); } } //生成用户唯一标识的cookie - start $user_id = session::loginid(); $site_cookie_key = cookie_service::get_cookie_value('MSCookieKey'); if(empty($site_cookie_key)){ cookie_service::set_global_cookie('MSCookieKey',ms_util::guid().'.'.$user_id,time() + 86400000); }else{ $tmp = explode('.',$site_cookie_key); if(count($tmp) == 2 && empty($tmp[1]) && $user_id){ cookie_service::set_global_cookie('MSCookieKey',$tmp[0].'.'.$user_id,time() + 86400000); } unset($tmp); } //生成用户唯一标识的cookie - end $classid = $news[phome_ecms_news::CLASSID]; if($classid == 345){ include_dev_model('match_yuanliao_ids.php'); $match_yuanliao_ar = match_yuanliao_ids::get_by_news_id($news[phome_ecms_news::ID]); if(!empty($match_yuanliao_ar)){ $news_yuanliao_id = $match_yuanliao_ar['yuanliao_id']; $news_yuanliao = news_yuanliao::get_by_id($news_yuanliao_id); if(!empty($news_yuanliao)){ header('HTTP/1.0 301 Moved Permanently'); header('Location: '.ms_util::get_shicai_path($news_yuanliao)); exit(); } } } //上上级栏目的显示 $fclass = phome_enewsclass::get_by_id($classid); $_GET['request_uri'] = '/'.$fclass['classpath'].'/'; $fclass_parent = array(); $fclass_name = $fclass['classname']; if(!$fclass_parent && !empty($fclass['bclassid'])){ $fclass_parent = phome_enewsclass::get_by_id($fclass['bclassid']); } $is_have_hetao = 0; $user_recipe = array(); $tb_sids = array(); $r_id = 0; if(!empty($news[phome_ecms_news::USER_RECIPE_ID])){ $from_redis = false; $memcache_tmp = config::get('memcache'); if(!empty($memcache_tmp) && isset($memcache_tmp['md_1']) && ($memcache_tmp['md_1']['0'] == '192.168.0.24')){ $from_redis = true; } $user_recipe = user_recipe::get_by_id($news[phome_ecms_news::USER_RECIPE_ID],false,$from_redis); if( time() < strtotime("2016-08-14")) { // rio菜谱植入id $huodong_ids = explode("|",$user_recipe[user_recipe::HUODONG_IDS]); if (in_array('132',$huodong_ids)) { $r_id = 1; } } unset($from_redis); if(!empty($user_recipe)){ $shicai_ids = array(); $tmp = explode('#',$user_recipe[user_recipe::ZHULIAO]); foreach($tmp as $v){ $v2 = explode('@',$v); $v3 = explode('|',$v2[0]); if(count($v3) == 2 && is_numeric($v3[1])){ $shicai_ids[] = $v3[1]; } unset($v2); unset($v3); } $tmp = explode('#',$user_recipe[user_recipe::FULIAO]); foreach($tmp as $v){ $v2 = explode('@',$v); $v3 = explode('|',$v2[0]); if(count($v3) == 2 && is_numeric($v3[1])){ $shicai_ids[] = $v3[1]; } unset($v2); unset($v3); } unset($tmp); $news_yuanliaos = array(); if(!empty($shicai_ids)){ $tb_sids = array_merge($tb_sids,$shicai_ids); include_dev_model('news_yuanliao.php'); $news_yuanliaos = news_yuanliao::get_by_ids($shicai_ids); } unset($shicai_ids); $user_recipe_steps = user_recipe_step::get_by_id($news[phome_ecms_news::USER_RECIPE_ID]); view::assign('news_yuanliaos',$news_yuanliaos); view::assign('user_recipe',$user_recipe); view::assign('user_recipe_steps',$user_recipe_steps); } } //对内容的处理-------开始 $newstext = isset($news[phome_ecms_news::NEWSTEXT])?$news[phome_ecms_news::NEWSTEXT]:''; if(isset($news['befrom']) && $news['befrom'] == 'meishichina'){ if($news['checked'] == 0){ if(stripos($newstext,'meishichina') !== false){ $newstext = preg_replace('/(]*>)/i','',$newstext); $newstext = str_replace(array("@
","@
","@\r\n"),"@",$newstext); } }elseif ($news['checked'] == 1){ if(stripos($newstext,'meishichina') !== false){ $newstext = preg_replace('/(\"(http:\/\/i3\.meishichina\.com\/[^\"]*)\")/i','',$newstext); $newstext = str_replace(array("@
","@
","@\r\n"),"@",$newstext); } } } include_dev_model('news_properties.php'); $news_properties = news_properties::get_by_id($id); if(!empty($news_properties[news_properties::TIPS])){ $newstext .= $news_properties[news_properties::TIPS]; $news_properties[news_properties::TIPS] = ''; } $page_show_info = ''; $expage='[!--empirenews.page--]';//分页符 $news_href = ms_util::get_newspath($news,$class_r_path); if($newstext && stripos($newstext,$expage) !== false){//有分页 $newstext_page_ar = explode($expage,$newstext); $total_page = count($newstext_page_ar); if($page < 1 || $page > $total_page){ $page = 1; } $newstext_page_ar_pos = $page - 1; $newstext = $newstext_page_ar[$newstext_page_ar_pos]; $page_show_info = ms_util::page($total_page*5,5,5); } $docheckrep = array(0=>'',1=>0,2=>71,3=>0,4=>358,5=>''); $reply_config_key = array('title','ftitle','newstime','diggtop','titlepic','smalltext','writer','befrom','newstext'); if($newstext){ $newstext = str_replace('','@
',"@\n","@\r\n","@\n\r"),'@',$newstext); $newstext = str_replace(array('@烹饪技巧@','@健康小常识@','@饮食禁忌@','@厨房小常识@','@饮食小常识@','@菜品特色@','@营养功效@','//www.bujia24.com/d/file/'),array('

烹饪技巧

','

健康小常识

','

饮食禁忌

','

厨房小常识

','

饮食小常识

','

菜品特色

','

营养功效

','http://images.meishij.net/'),$newstext); //投票 if(strstr($newstext,'[!--info.vote--]')){ $myvotetext= news_service::sys_GetInfoVote($classid,$id); $newstext=str_replace('[!--info.vote--]',$myvotetext,$newstext); } } if(!$news['titlepic']){ $news['titlepic'] = 'http://static.meishij.net/images/nopic.gif'; } $status = isset($news['status'])?$news['status']:''; //分析菜谱中的ztid字段得出 这道菜的工艺和口味 $gongyi = array(); $gongyi_id = $news['gy']; $kouwei = array(); $kouwei_id = $news['kw']; if($gongyi_id || $kouwei_id){ $ztid_ar = array(); if($gongyi_id){ $ztid_ar[] = $gongyi_id; } if($kouwei_id){ $ztid_ar[] = $kouwei_id; } if(!empty($ztid_ar)){ $zt_ar = phome_enewszt::get_by_ids($ztid_ar); if(!empty($zt_ar)){ foreach ($zt_ar as $zt){ if($zt['zcid'] == 5){ $gongyi = $zt; }elseif($zt['zcid'] == 6){ $kouwei = $zt; } } } } } $news['zhuliaoword'] = ''; $zhuliao_ars = array(); $fuliao_ars = array(); if(!empty($user_recipe)){ $tmp = explode('#',$user_recipe[user_recipe::ZHULIAO]); foreach($tmp as $v){ $v2 = explode('@',$v); $v3 = explode('|',$v2[0]); if(!empty($v3[1]) && is_numeric($v3[1])){ $news_yuanliao = news_yuanliao::get_by_id($v3[1]); if(!empty($news_yuanliao)){ $one = array( 'title' => $news_yuanliao['title'], 'id' => $v3[1], 'icon' => str_replace('60x60','150x150',$news_yuanliao['titlepic']), 'num' => (!empty($v2[1])?$v2[1]:'适量'), ); $zhuliao_ars[] = $one; unset($one); } }else{ $one = array( 'title' => $v3[0], 'id' => 0, 'icon' => 'https://static.meishij.net/images/get/shicai_moren.png', 'num' => (!empty($v2[1])?$v2[1]:'适量'), ); $zhuliao_ars[] = $one; unset($one); } } $tmp = explode('#',$user_recipe[user_recipe::FULIAO]); foreach($tmp as $v){ $v2 = explode('@',$v); $v3 = explode('|',$v2[0]); if(!empty($v3[0])){ $fuliao_ars[] = array('title' => $v3[0],'unit' => (!empty($v2[1])?$v2[1]:'适量')); } } unset($tmp); }else{ if(!empty($news[phome_ecms_news::ZHULIAO])){ $zhuliaos = $news[phome_ecms_news::ZHULIAO]; $zhuliao_ids_ar = ms_util::names_split($zhuliaos); $zhuliao_res = news_yuanliao::get_by_ids(array_keys($zhuliao_ids_ar)); foreach($zhuliao_res as $key=>$zr){ $zhuliao_ar = array(); $zhuliao_ar['title'] = $zr['title']; $zhuliao_ar['id'] = $zr['id']; $zhuliao_ar['icon'] = str_replace('60x60','150x150',$zr['titlepic']); $zhuliao_ar['num'] = $zhuliao_ids_ar[$zr['id']]; $zhuliao_ars[] = $zhuliao_ar; } } $fuliaos = $news[phome_ecms_news::FULIAO]; $fuliao_ids_ar = ms_util::names_split($fuliaos); if(!empty($fuliao_ids_ar)){ $fuliao_res = news_yuanliao::get_by_ids(array_keys($fuliao_ids_ar)); if(!empty($fuliao_res)){ foreach($fuliao_res as $key=>$fr){ $fuliao_ars[] = array('title' => $fr['title'],'unit' => (!empty($fuliao_ids_ar[$fr['id']])?$fuliao_ids_ar[$fr['id']]:'适量')); } } } } $zhuliaos = isset($news[phome_ecms_news::ZHULIAO])?$news[phome_ecms_news::ZHULIAO]:''; $fuliaos = isset($news[phome_ecms_news::FULIAO])?$news[phome_ecms_news::FULIAO]:''; $tiaoliao = isset($news[phome_ecms_news::TIAOLIAO])?$news[phome_ecms_news::TIAOLIAO]:''; $zhuliao_res = array(); $fuliao_res = array(); $tiaoliao_res = array(); $zhuliao_ids_ar = ms_util::names_split($zhuliaos); $fuliao_ids_ar = ms_util::names_split($fuliaos); $tiaoliao_ids_ar = ms_util::names_split($tiaoliao); if(!empty($zhuliao_ids_ar)){ $tb_sids = array_merge($tb_sids,array_keys($zhuliao_ids_ar)); $zhuliao_res = news_yuanliao::get_by_ids(array_keys($zhuliao_ids_ar)); foreach($zhuliao_res as $key=>$zr){ $zhuliao_res[$key]['liao_km'] = $zhuliao_ids_ar[$zr['id']]; if(empty($news['zhuliaoword'])){ $news['zhuliaoword'] = $zr['title']; } } } if(empty($news['zhuliaoword']) && isset($news['keyboard'])){ $news['zhuliaoword'] = $news['keyboard']; } if(!empty($fuliao_ids_ar)){ $tb_sids = array_merge($tb_sids,array_keys($fuliao_ids_ar)); $fuliao_res = news_yuanliao::get_by_ids(array_keys($fuliao_ids_ar)); foreach($fuliao_res as $key=>$fr){ $fuliao_res[$key]['liao_km'] = str_replace(array('(',')'),array('(',')'),$fuliao_ids_ar[$fr['id']]); } } if(!empty($tiaoliao_ids_ar)){ $tb_sids = array_merge($tb_sids,array_keys($tiaoliao_ids_ar)); $tiaoliao_res = news_yuanliao::get_by_ids(array_keys($tiaoliao_ids_ar)); foreach($tiaoliao_res as $key=>$tr){ $tiaoliao_res[$key]['liao_km'] = str_replace(array('(',')'),array('(',')'),$tiaoliao_ids_ar[$tr['id']]); } $tiaoliao_res = ms_util::order_tiaoliao($tiaoliao_res); } if($tb_sids && count($tb_sids) > 9){ $tb_sids = array_slice($tb_sids,0,9); } include_dev_model('lightblog/user_blog.php'); //精选菜谱 使用食材循环查询查找数据 if(!empty($zhuliao_ars)){ foreach($zhuliao_ars as $value){ $goods_news = recipe_seo_search_word_sc::get_shicai_zuofa_words($value['title']); if(!empty($goods_news)){ break; } } } $author = array(); include_dev_file('ub_file.php'); if(!empty($news[phome_ecms_news::WRITER_ID])){ $author = user::get_by_id_fc($news[phome_ecms_news::WRITER_ID]); } if($user_id){ $current_user = user::get_by_id_fc($user_id); }else{ $current_user = array(); } //同名菜谱开始===============================================================》 $zuofa_recipe=array(); $recipe_label = rel_recipe_with_label_seo::get_recipe_label_word($news['id']); if($recipe_label['state']==1){ $search_word = recipe_seo_search_word::is_seo_search_word($recipe_label['data']); $wordsinfo = recipe_seo_search_word::get_words_by_title($recipe_label['data']); $is_other_recipe_new = 1; $other_recipe_new_url = $search_word['data']['url']; $other_recipe_new_num = $wordsinfo['recipe_num']; $recipe_class[0]['recipe']['text'] = $recipe_label['data']; $recipe_class[0]['recipe']['url'] = $search_word['data']['url']; $recipe_label_name = $recipe_label['data']; $cp_recipe_list = recipe_seo_search_word_sc::get_zuofa_good_recipe($news['title']); $news_ids = array(); foreach($cp_recipe_list as $value){ $news_ids[] = $value['news_id']; if($num>9){ break; } $num++; } $zuofa_recipe_data = phome_ecms_news::get_by_ids($news_ids); foreach($zuofa_recipe_data as $key => $value){ if(empty($value)){ continue; } if($key==0){ $caipuname_val=$redis_wap_seo->get(md5($value['title'])); if(empty($caipuname_val)){ $redis_wap_seo->set(md5($value['title']),$value['id']); } } if($value['writer_id']){ $user_data=user::get_by_id_fc($value['writer_id']); }else{ $user_data=array(); } $user_recipe_2 = user_recipe::get_by_id($value['user_recipe_id']); if(!empty($user_recipe_2)){ $shicai_ids = array(); $tmp = explode('#',$user_recipe_2[user_recipe::ZHULIAO]); foreach($tmp as $v){ $v2 = explode('@',$v); $v3 = explode('|',$v2[0]); if(count($v3) == 2){ $shicai_name[] = $v3[0]; } unset($v2); unset($v3); } $shicai_name_s=implode('、',$shicai_name); unset($shicai_name); } $zuofa_recipe[]=array("id"=>$value['id'],"recipe_type"=>$value['recipe_type'],"title"=>$value['title'],"img"=>m_search::get_final_pic($value),"url"=>ms_util::get_newspath($value,$class_r_path,'www'),"user_id"=>$user_data['user_id'],"user_name"=>$user_data['user_name'],"user_pic"=>user_profile::t($user_data[user::PHOTO]),"shicai"=>"$shicai_name_s"); } $zuofa_recipe_2 = array_slice($zuofa_recipe,0,10); $zuofa_recipe = array_slice($zuofa_recipe,0,5); }else{ $is_other_recipe_new = 2; $other_recipe_new_url = ""; $recipe_label_name = ""; $other_recipe_new_num ="0"; } //同名菜谱结束===============================================================》 //作者其他菜谱开始===========================================================》 $user_recipe_all=array(); $user_recipe_data=user_recipe::get_by_uid_new($author['user_id'],1,5,1); if($user_recipe_data){ foreach($user_recipe_data as $u_val){ if(!empty($u_val[user_recipe::ZHULIAO])){ $shicai_ids = array(); $tmp = explode('#',$u_val[user_recipe::ZHULIAO]); foreach($tmp as $v){ $v2 = explode('@',$v); $v3 = explode('|',$v2[0]); if(count($v3) == 2){ $shicai_name[] = $v3[0]; } unset($v2); unset($v3); } $shicai_name_s=implode('、',$shicai_name); unset($shicai_name); } $user_data=user::get_by_id_fc($u_val['user_id']); $value=phome_ecms_news::get_by_id($u_val['news_id']); $user_recipe_all[]=array("id"=>$u_val['id'],"recipe_type"=>$u_val['recipe_type'],"title"=>$u_val['title'],"img"=>m_search::get_final_pic($value),"url"=>ms_util::get_newspath($value,$class_r_path,'www'),"user_id"=>$user_data['user_id'],"user_name"=>$user_data['user_name'],"user_pic"=>user_profile::t($user_data[user::PHOTO]),"shicai"=>"$shicai_name_s"); } } //作者其他菜谱结束===========================================================》 $rand_ztid = 0; $rand_ztid_name = ''; $owner_ztids = $news[phome_ecms_news::OWNER_ZTIDS]; $owner_ztids_ar = explode(',',$owner_ztids); if(count($owner_ztids_ar) > 3){ foreach ($owner_ztids_ar as $k=>$owner_ztid){ if($owner_ztid >= 10160 && $owner_ztid <= 10267){ unset($owner_ztids_ar[$k]); } } } if(count($owner_ztids_ar) > 8){ $owner_ztids_ar = array_slice($owner_ztids_ar,0,8); } $owner_zts = phome_enewszt::get_by_ids($owner_ztids_ar); $zcids = array(); foreach($owner_zts as $owner_zt){ if($owner_zt['zcid'] > 10000 && $owner_zt['ztid'] < 20000){ if(!$rand_ztid){ $rand_ztid = $owner_zt['ztid']; $rand_ztid_name = $owner_zt['ztname']; } $zcids[] = $owner_zt['zcid'] - 10000; } } ksort($owner_zts); $new_seo_title = ''; $new_seo_title_ar = array(10347,10346,10350,10348,10349,10351,10352); $new_seo_title_true_ar = array_intersect($owner_ztids_ar,$new_seo_title_ar); if(!empty($new_seo_title_true_ar)){ $new_seo_title = $news[phome_ecms_news::TITLE]."_{$fclass['classname']} - 美食杰"; } $list_style = ''; $list_style_1_ar = ms_const::$list_style_1_ar; $intersect_ztids = array_intersect($zcids,$list_style_1_ar); if(!empty($intersect_ztids) || in_array($fclass[phome_enewsclass::BCLASSID],$list_style_1_ar)){ $list_style = 1; } if(!$list_style){//不是文字类型显示数字样式 $y=preg_match("[@(\d+)@]", $newstext); if($y){ $newstext_array=explode('

',$newstext); $s=-1; foreach($newstext_array as $val2){ if(!$val2){ continue; } $i=preg_match("[@(\d+)@]", $val2); if($i){ $s++; $text=strip_tags(preg_replace("[@(\d+)@]",'',$val2)); $text = str_replace(array('
', '
', "\n", "\r\n", "\n\r","\r"), '', $text); $step_array[$s][]=$text; }else{ preg_match('//i',$val2,$match); $step_array[$s][]=$match[1]; } } //$newstext = preg_replace("[@(\d+)@]","\${1}.",$newstext); $html_new=""; $html_new2=""; if($step_array){ foreach($step_array as $key=>$html_val){ $html_new.='
'; $html_new.='
'; $html_new.='步骤'; $html_new.='step'; $html_new.='

'.($key+1).'

'; $html_new.='
'; $html_new.='
'; foreach($html_val as $h_val){ if(strpos($h_val,'http') !== false){ $html_new.=''; }else{ $html_new.='

'.$h_val.'

'; } } $html_new.='
'; $html_new.='
'; } } $newstext = $html_new; }else{ $html_new2.='
'; $html_new2.='
'; $html_new2.=$newstext; $html_new2.='
'; $html_new2.='
'; $newstext = $html_new2; //$newstext = preg_replace("[@(\d+)@]","\${1}.",$newstext); } }else{ $newstext = preg_replace("[@(\d+)@]","\${1}.",$newstext); } $news['newstext'] = stripSlashes($newstext); $page_size = 9; $layout_ar = array('stat_code' => implode('-',$owner_ztids_ar)); $intersect_ztids = array_intersect($zcids,ms_const::$show_videoad_zcid); if(true || !empty($intersect_ztids)){ $layout_ar['show_videoad'] = 1; } $layout_ar['iframe_word'] = $news[phome_ecms_news::TITLE]; //评分显示? $cookie_key = 'score_news_rec'; $cookie_rec = cookie_service::get_cookie_value($cookie_key); $score_ar = array(); if($cookie_rec){ $score_ar = unserialize($cookie_rec); } if(isset($score_ar[$id])){} $is_jiankang_style = $list_style; if($fclass[phome_enewsclass::BCLASSID] == 27 || $fclass[phome_enewsclass::CLASSID] == 27 || $fclass[phome_enewsclass::BCLASSID] == 369 || $fclass[phome_enewsclass::CLASSID] == 369){ $is_jiankang_style = 0; } $cook_mys = array(); $same_title_newses = array(); $news[phome_ecms_news::TITLE] = trim($news[phome_ecms_news::TITLE]); $simple_title = preg_replace("/((|\(|\+).*/",'',$news[phome_ecms_news::TITLE]); $simple_title = trim(preg_replace("[#(.*)#]",'',$simple_title)); if(!$is_jiankang_style){ if(!empty($news[phome_ecms_news::COOK_MY_NUM])){ include_dev_model('lightblog/cook_my.php'); $mem_key = 'NewCookMyCache_'.$id; if($news[phome_ecms_news::LASTDOTIME] > (time() - 30)){ $cook_mys = cook_my::get_by_news_md5(md5($news[phome_ecms_news::TITLE]),1,3); memcache_service::save_to_store($mem_key,$cook_mys,'md_9',ms_const::DAY_TIME); }else{ $cook_mys = memcache_service::get_from_store($mem_key,'md_9'); if(empty($cook_mys) && !is_array($cook_mys)){ $cook_mys = cook_my::get_by_news_md5(md5($news[phome_ecms_news::TITLE]),1,3); memcache_service::save_to_store($mem_key,$cook_mys,'md_9',ms_const::DAY_TIME); } } } $mem_key = 'NewContentLike2_'.$id; // $tmp_ids = memcache_service::get_from_store($mem_key,'caipu_ext_info'); //由md_9 2019-4-18 切走 $redis_caipu_ext_info = new MyRedis('caipu_ext_info'); $tmp_ids = $redis_caipu_ext_info->get($mem_key); if(empty($tmp_ids) && !is_array($tmp_ids)){ $tmp_ids = array(); include_dev_model('like_news.php'); $like_newses = like_news::get_by_nid($id,1,65); if(!empty($like_newses)){ foreach ($like_newses as $like_news){ $tmp_ids[] = array('i' => $like_news[like_news::NEWS_ID],'t' => $like_news[like_news::LIKE_TYPE],'d' => $like_news[like_news::LIKE_DATA]); } } if(!empty($tmp_ids)){ // memcache_service::save_to_store($mem_key,$tmp_ids,'caipu_ext_info',ms_const::DAY_TIME*15); $redis_caipu_ext_info->set($mem_key, $tmp_ids, ms_const::DAY_TIME * 15); } } $like_levels = array( 1 => '名称', 2 => '主料、工艺、口味', 3 => '主料、工艺', 4 => '主料、口味', 5 => '工艺、口味', 6 => '工艺', 7 => '口味', ); $like_newses = array(); if($tmp_ids){ shuffle($tmp_ids); if(count($tmp_ids) > 12){ $tmp_ids = array_slice($tmp_ids,0,12); } foreach ($tmp_ids as $v){ $news_t = phome_ecms_news::get_base_by_id($v['i']); if(!empty($news_t)){ $news_t['t'] = $like_levels[$v['t']]; $news_t['d'] = $v['d']; $like_newses[] = $news_t; } } unset($tmp_ids); } view::assign('like_newses',$like_newses); include_dev_model('news_yyxx.php'); $news_yyxx = news_yyxx::get_by_id($id); } if(isset($fclass_parent['bclassid']) && (in_array($fclass_parent['bclassid'],array(422,697)) || in_array($fclass_parent['classid'],array(422,697)))){ $rel_newses = array(); $rel_n_tmp = ms_util::curl_get_contents('http://so.meishi.cc/web_service.php?q='.urlencode($simple_title)); if(!empty($rel_n_tmp)){ $rel_newses = @json_decode($rel_n_tmp,true); if(!empty($rel_newses) && is_array($rel_newses)){ $rel_newses = array_slice($rel_newses,0,9); }else{ $rel_newses = array(); } } if(empty($rel_newses)){ include_dev_service('elastic_search.php'); $es_map = $es_map_not = array(); $filters['is_checked'] = array(1, 11, 12); $es_map['bool']['should'][] = array("match" => array('checked' => '1')); $es_map['bool']['should'][] = array("match" => array('checked' => '6')); $es_map['bool']['should'][] = array("match" => array('checked' => '11')); $es_map['bool']['should'][] = array("match" => array('checked' => '12')); $es_map['bool']['must'][] = array("match" => array('is_recipe' => '1')); $should = array( array( "multi_match" => array( "query" => $simple_title, "fields" => array('title^3','zhuliao^2','owner_ztids_cn^4'), ) ) ); $rel_news_ids = array(); $recipe_list = elastic_search::category2('node137', 'recipe', $should, $map, array(), 1, 9, $es_map_not); if(!empty($recipe_list) && isset($recipe_list['hits']['hits'])){ foreach($recipe_list['hits']['hits'] as $v){ $rel_news_ids[] = $v['_id']; } } $rel_newses = phome_ecms_news::get_by_ids($rel_news_ids); } view::assign('rel_newses',$rel_newses); } $is_fav = 0; if($user_id && !empty($news[phome_ecms_news::POST_ID])){ //判断是否已经收藏 include_dev_model('lightblog/post_fav.php'); //$is_fav = post_fav::is_fav($user_id,$news[phome_ecms_news::POST_ID]); $is_fav = post_fav::is_fav($user_id,$news[phome_ecms_news::ID],0,true); } $layout_ar['mobile_agent'] = str_replace('//www.bujia24.com/','//m.bujia24.com/html5/',$news_href); $layout_ar['pc_agent'] = $news_href; $news_title_new = trim($news[phome_ecms_news::TITLE]); //SEO优化TDK $seo_title_1 ="{$news_title_new},{$news_title_new}的家常做法 - 美食杰{$news_title_new}做法大全"; $seo_title_2 ="【{$news_title_new}的做法,{$news_title_new}的家常做法】美食杰菜谱做法大全"; //KEYWORDS $seo_keywords ="{$news_title_new}的做法,{$news_title_new}的家常做法,{$news_title_new},{$news_title_new}怎么做好吃,{$news_title_new}制作方法,{$news_title_new}的步骤,{$news_title_new}大图,{$news_title_new}菜谱,如何做{$news_title_new}"; $seo_description = "{$news_title_new}的做法菜谱为您推荐大图正宗的{$news_title_new}的家常做法,{$news_title_new}的做法步骤图解,更多家常{$news_title_new}怎么做好吃的窍门分享就来美食杰菜谱大全。"; //DESCRIPTION //步骤图内容整理 $zuofa = array(); if(!empty($user_recipe_steps)){ $i = 1; foreach($user_recipe_steps as $value){ $zuofa[$i]['txt'] = array('0'=>$value['step_text']); $i++; } } if(!empty($zuofa)){ $description_new_str = "{$news_title_new}的做法大图制作步骤,"; foreach($zuofa as $key => $val){ $description_new_str .=$key."、".$val['txt'][0]." "; } if(mb_strlen($description_new_str)>45){ $description_new_str = mb_substr($description_new_str,0,60); $description_new_str .="..."; } $seo_description_new .= str_replace("\n","",$description_new_str); }else{ $seo_description_new = "{$news_title_new}的做法菜谱为您推荐大图正宗的{$news_title_new}的家常做法,{$news_title_new}的做法步骤图解,更多家常{$news_title_new}怎么做好吃的窍门分享就来美食杰菜谱大全。"; } $recipe_tdk['title']=$title; $recipe_tdk['seo_title_1']=$seo_title_1; $recipe_tdk['seo_title_2']=$seo_title_2; $recipe_tdk['keywords']=$seo_keywords; $recipe_tdk['description']=$seo_description; $layout_ar['description_new']=$seo_description_new; //获取用户的ip地址 $is_recipe = news_service::is_recipe($news); //判断是否是菜谱词 $is_caipu_word = recipe_seo_search_word::is_seo_search_word($news['title']); $ret = array(); $special = array(); $tag_list = array(); $yinying_list=array(); //获取缓存数据 $yun2_redis = new MyRedis('md_43'); $YYData= $yun2_redis->get('YYDataId:'.$id); if(!empty($YYData)){ $YYData = json_decode($YYData,true); $YYData =$YYData['data']['list']; }else{ //获取 菜谱营养信息 $yysql ="select * from meishij.tbl_recipe_with_yingyang where news_id=$id"; $YYData = phome_ecms_news::get_by_sql($yysql); } if($YYData){ $crowd_temp=array(); $xt_hl=0; $xz_hl=0; $xy_hl=0; $jf_hl=0; $zhuliao_yy=get_shicai_data($id); if($zhuliao_yy){ foreach ($YYData as $item){ if($item['desc'] == '碳水化合物' || $item['desc'] == '脂肪' || $item['desc'] == '钠' || $item['desc'] == '卡路里'){ //高血糖 处理逻辑 if($item['desc'] == '碳水化合物'){ if($item['value100']>0){ $xt_hl=round($item['value100']*0.7,2); $crowd_temp[]=array("title"=>"高血糖"); }else{ $xt_hl=$zhuliao_yy['xt_hl']; $crowd_temp[]=array("title"=>"高血糖"); } } //高血脂 处理逻辑 if($item['desc'] == '脂肪'){ $xz_hl=round($item['value100'],2); $crowd_temp[]=array("title"=>"高血脂"); } //高血压 处理逻辑 if($item['desc'] == '钠'){ $xy_hl=round(($item['value100']/1000)*2.54,2); $crowd_temp[]=array("title"=>"高血压"); } //减肥 处理逻辑 if($item['desc'] == '卡路里'){ $jf_hl=round($item['value100'],2); $crowd_temp[]=array("title"=>"减肥"); } } } foreach($crowd_temp as $c_val){ //高血糖 处理逻辑 if($c_val['title'] == '高血糖'){ if($xt_hl>=10 || $xz_hl>=50 || $jf_hl>=500){ $xt_can_eat="3"; $xt_can_eat_info_1="尽量不吃"; $xt_can_eat_info_2="不吃"; }elseif(($xt_hl>5 && $xt_hl<10) || ($xz_hl>30 && $xz_hl<50) || ($jf_hl>200 && $jf_hl<500) || $zhuliao_yy['is_zha']){ $xt_can_eat="2"; $xt_can_eat_info_1="控制少吃"; $xt_can_eat_info_2="少吃"; }elseif($xt_hl<=5 && $xz_hl<=30 && $jf_hl<=200){ $xt_can_eat="1"; $xt_can_eat_info_1="建议多吃"; $xt_can_eat_info_2="多吃"; } $crowd[]=array("icon_type"=>"1","title"=>"高血糖人群","if_chi"=>$xt_can_eat_info_1,"can_eat"=>$xt_can_eat); } //高血脂 处理逻辑 if($c_val['title'] == '高血脂'){ if($xz_hl>=30 || $jf_hl>=500){ $xz_can_eat="3"; $xz_can_eat_info_1="尽量不吃"; $xz_can_eat_info_2="不吃"; }elseif(($xz_hl<30 && $xz_hl>10) || ($jf_hl>200 && $jf_hl<500) || $zhuliao_yy['is_zha']){ $xz_can_eat="2"; $xz_can_eat_info_1="控制少吃"; $xz_can_eat_info_2="少吃"; }elseif($xz_hl<=10 && $jf_hl<=200){ $xz_can_eat="1"; $xz_can_eat_info_1="建议多吃"; $xz_can_eat_info_2="多吃"; } $crowd[]=array("icon_type"=>"2","title"=>"高血脂人群","if_chi"=>$xz_can_eat_info_1,"can_eat"=>$xz_can_eat); } //高血压 处理逻辑 if($c_val['title'] == '高血压'){ if($xy_hl>=6 || $xz_hl>=50 || $jf_hl>=500){ $xy_can_eat="3"; $xy_can_eat_info_1="尽量不吃"; //$xy_can_eat_info_2="不吃"; $yinying_list['text'][]="含盐或脂肪比较多,高血压朋友要少吃"; }elseif(($xy_hl>2 && $xy_hl<6) || ($xz_hl>30 && $xz_hl<50) || ($jf_hl>200 && $jf_hl<500) || $zhuliao_yy['is_zha']){ $xy_can_eat="2"; $xy_can_eat_info_1="控制少吃"; //$xy_can_eat_info_2="少吃"; $yinying_list['text'][]="盐或脂肪含量适中,高血压朋友可适当吃一些"; }elseif($xy_hl<=2 && $xz_hl<=30 && $jf_hl<=200){ $xy_can_eat="1"; $xy_can_eat_info_1="建议多吃"; //$xy_can_eat_info_2="多吃"; $yinying_list['text'][]="含盐或脂肪较少,有高血压的朋友可放心吃"; } $crowd[]=array("icon_type"=>"3","title"=>"高血压人群","if_chi"=>$xy_can_eat_info_1,"can_eat"=>$xy_can_eat); } //减肥 处理逻辑 if($c_val['title'] == '减肥'){ if($jf_hl>300){ $jf_can_eat="3"; $jf_can_eat_info_1="尽量不吃"; $jf_can_eat_info_2="不吃"; }elseif(($jf_hl<300 && $jf_hl>100) || $zhuliao_yy['is_zha']){ $jf_can_eat="2"; $jf_can_eat_info_1="控制少吃"; $jf_can_eat_info_2="少吃"; }elseif($jf_hl<100){ $jf_can_eat="1"; $jf_can_eat_info_1="建议多吃"; $jf_can_eat_info_2="多吃"; } $crowd[]=array("icon_type"=>"4","title"=>"减肥人群","if_chi"=>$jf_can_eat_info_1,"can_eat"=>$jf_can_eat); } } //儿童 处理逻辑 if(empty($zhuliao_yy['et_is_chi']) || $zhuliao_yy['is_zha']){ $et_can_eat="2"; $et_can_eat_info_1="控制少吃"; //$et_can_eat_info_2="少吃"; $yinying_list['text'][]="吃太多不容易消化,尽量让孩子少吃"; }elseif($xz_hl>30 || $xy_hl>2 || $jf_hl>200){ $et_can_eat="2"; $et_can_eat_info_1="控制少吃"; //$et_can_eat_info_2="少吃"; $yinying_list['text'][]="吃太多不容易消化,尽量让孩子少吃"; }elseif($xz_hl<=30 && $xy_hl<=2 && $jf_hl<=200){ $et_can_eat="1"; $et_can_eat_info_1="建议多吃"; //$et_can_eat_info_2="多吃"; $yinying_list['text'][]="清淡易消化,非常适合小朋友吃"; } $crowd[]=array("icon_type"=>"5","title"=>"儿童","if_chi"=>$et_can_eat_info_1,"can_eat"=>$et_can_eat); $yinying_list['crowd']=$crowd; //type 1糖 2热量 3脂肪 $yingyang[]=array("type"=>"3","title"=>"糖","value"=>"$xt_hl","unit"=>"克","if_chi"=>"$xt_can_eat_info_2","crowd"=>"糖尿病人群","can_eat"=>$xt_can_eat); $yingyang[]=array("type"=>"2","title"=>"热量","value"=>"$jf_hl","unit"=>"大卡","if_chi"=>"$jf_can_eat_info_2","crowd"=>"减肥人群","can_eat"=>$jf_can_eat); $yingyang[]=array("type"=>"1","title"=>"脂肪","value"=>"$xz_hl","unit"=>"克","if_chi"=>"$xz_can_eat_info_2","crowd"=>"高血脂人群","can_eat"=>$xz_can_eat); $yinying_list['yingyang']=$yingyang; } } $seo_tm_title_id=$redis_wap_seo->get(md5($news[phome_ecms_news::TITLE])); view::assign('seo_tm_title_id',$seo_tm_title_id); view::assign('is_caipu_word',$is_caipu_word); view::assign('yinying_list',$yinying_list); view::assign('yinying',$yinying); view::assign('is_seo_tdk_show',$is_seo_tdk_show); view::assign('recipe_tdk',$recipe_tdk); view::assign("r_id",$r_id); view::assign("fav_num",$fav_num); view::assign("show_num2",$show_num2); view::assign('zuofa_recipe',$zuofa_recipe); view::assign('zuofa_recipe_2',$zuofa_recipe_2); view::assign('user_recipe_all',$user_recipe_all); view::assign('orderby',$orderby); view::assign('is_have_hetao',$is_have_hetao); view::assign('from',$from); view::assign('news_refer',$news_refer); view::assign('is_fav',$is_fav); view::assign('tb_sids',$tb_sids); view::assign('news_href',$news_href); view::assign('news_yyxx',$news_yyxx); view::assign('simple_title',$simple_title); view::assign('cook_mys',$cook_mys); view::assign('new_seo_title',$new_seo_title); view::assign('is_jiankang_style',$is_jiankang_style); view::assign('news_properties',$news_properties); view::assign('owner_zts',$owner_zts); view::assign('author',$author); view::assign('user_id',$user_id); view::assign('goods_news',$goods_news); view::assign('current_user',$current_user); view::assign('zhuliao_res',$zhuliao_res); view::assign('fuliao_res',$fuliao_res); view::assign('tiaoliao_res',$tiaoliao_res); view::assign('state',$state); view::assign('list_style',$list_style); view::assign('fclass_parent',$fclass_parent); view::assign('class_r_path',$class_r_path); view::assign('page_show_info',$page_show_info); view::assign('gongyi',$gongyi); view::assign('kouwei',$kouwei); view::assign('id',$id); view::assign('classid',$classid); view::assign('gongyi_id',$gongyi_id); view::assign('kouwei_id',$kouwei_id); view::assign('status',$status); view::assign('fclass',$fclass); view::assign('user_ip',$user_ip); view::assign('news',$news); view::assign('is_recipe',$is_recipe); view::assign('from_search',$from_search); view::assign('recipe_label_name',$recipe_label_name); view::assign('is_other_recipe_new',$is_other_recipe_new); view::assign('other_recipe_new_url',$other_recipe_new_url); view::assign('other_recipe_new_num',$other_recipe_new_num); view::layout('def_pc_new'); view::show($layout_ar);