clear_all_cache(); //$smarty->compile_check = false; $page = (isset($_GET['type']))?$_GET['type']:'index'; switch($page){ case 'inc.hidamari': $format = (isset($_GET['format']))?$_GET['format']:'php'; switch ($format){ case 'xml': $file = "hidamari/data/list.xml"; $xml = simplexml_load_file($file); $item = $xml->entry[0]; header("Content-Type: text/xml"); echo $item->asXML(); break; case 'json': $file = "hidamari/data/list.xml"; $xml = simplexml_load_file($file); $item = (array)$xml->entry[0]; $item['body'] = (string)($item['body']); header("Content-Type: application/json; charset=utf-8"); echo json_encode($item); break; case 'jsonp': $callback = (isset($_GET['callback']))?$_GET['callback']:'callback'; $file = "hidamari/data/list.xml"; $xml = simplexml_load_file($file); $item = (array)$xml->entry[0]; $item['body'] = (string)($item['body']); header("Content-Type: text/javascript; charset=utf-8"); $json = json_encode($item); echo "{$callback}({$json})"; break; default: //if(!$smarty->is_cached('lib/inc.hidamari.stpl.php')) { $file = "hidamari/data/list.xml"; $xml = simplexml_load_file($file); $smarty->assign("hidamari",$xml->entry[0]); //} $ret = $smarty->fetch('lib/inc.hidamari.stpl.php'); echo $ret; break; } break; case 'inc.groupinfo': $rssItems = array(); $rssItems['kaihatsu'] = array('name'=>'辰巳開発','url'=>'http://kaihatsu.tatsumi.com/info/atom.xml','category'=>'kaihatsu'); $rssItems['jutaku'] = array('name'=>'辰巳住宅','url'=>'http://jutaku.tatsumi.com/info/atom.xml','category'=>'jutaku'); $rssItems['juken'] = array('name'=>'辰巳住研','url'=>'https://juken.tatsumi.com/news/index.xml','category'=>'juken'); $rssItems['inakagurashi'] = array('name'=>'田舎暮し','url'=>'https://inakagurashi.tatsumi.com/promotion/feed','category'=>'inakagurashi'); $rssItems['amenity'] = array('name'=>'アメニティ辰巳','url'=>'http://ame.tatsumi.com/info/atom.xml','category'=>'amenity'); $outData = array(); foreach ($rssItems as $rssItem){ $xml = @simplexml_load_file($rssItem['url']); if (is_object($xml)): $entries = $xml->entry; if (count($entries)==0){$entries = $xml->channel->item;} $i=0; foreach ($entries as $entry){ $tmp = array(); $keyTime = strtotime($entry->published); if ($keyTime==""){ $keyTime = strtotime($entry->pubDate);} $tmp['title'] = (string)$entry->title; $tmp['link'] = (string)xml_attribute($entry->link, "href"); if ($tmp['link']==""){$tmp['link'] = (string)$entry->link;} $tmp['name'] = $rssItem['name']; $tmp['category'] = $rssItem['category']; $tmp['date'] = $keyTime; $outData[$keyTime] = $tmp; if (++$i>2) break; } endif; } krsort($outData); $smarty->assign("info",array_slice($outData,0,5)); $out = $smarty->fetch("inc.groupinfo.stpl.php"); header('Content-Type: text/html; charset=UTF-8'); echo $out; break; default: // pickup $file = "manage/pickup/list.xml"; $xml = simplexml_load_file($file); $smarty->assign("pickup",$xml); $smarty->assign("info",array()); //ひだまり $file = "hidamari/data/list.xml"; $xml = simplexml_load_file($file); $smarty->assign("hidamari",$xml->entry[0]); // display $tpl = (empty($_GET["tpl"]))?"index.stpl.php":$_GET["tpl"]; $date = (empty($_GET['date']))?date("Ymd"):$_GET["date"]; $smarty->assign('date',$date); $smarty->display($tpl); break; } // // // function block // // function xml_attribute($object, $attribute){ if(isset($object[$attribute])) return (string) $object[$attribute]; } function mkInfoDate($str){ return date('Y/m/d',$str); } function mtrim($str,$width=80){ return mb_strimwidth(preg_replace("/(\s)/","",mb_convert_kana($str,"KVas","UTF-8")),0,$width,"…","UTF-8"); } // function function datetimePeriod( $start, $end){ $datetime = (empty( $_GET['datetime'] ))?date( 'YmdHi'):$_GET['datetime']; if ( $datetime >= $start and $datetime < $end ){ return true; } else { return false; } }