SecureFilter($_POST,$_GET); //session $myses = new session("DBNAME"); $myses->start(); $ret = $myses->affirm("kb_news"); //Smarty $sm = new Smarty(); $sm->assign("mnu",$mnu); $sm->template_dir = "./templates/"; $sm->compile_dir="./templates_c/"; //display mode if (isset($_GET['nmode'] )){ $nmode = $_GET['nmode']; setcookie("nmode",$_GET['nmode'],time()+60*60*24*365*10); } else if(isset($_COOKIE['nmode'])) $nmode = $_COOKIE['nmode']; else $nmode = 'both'; $atrb1 = $atrb2 = $atrb3 = 'gry'; switch($nmode){ case 'both' : $atrb1 = 'yel'; break; case 'corp' : $atrb2 = 'yel'; break; case 'recruite' : $atrb3 = 'yel'; break; } $sm->assign('atrb1',$atrb1); $sm->assign('atrb2',$atrb2); $sm->assign('atrb3',$atrb3); list($ret,$ar_obj) = get_news_list($nmode); if($ret) $sm->assign("ar_obj",$ar_obj); $sm->assign("fmtxt",$fmtxt); $sm->assign("def",$def); $sm->assign("subtitle","お知らせ"); $sm->display("myhead.html"); $sm->display("kb_news.html"); $sm->display("mytail.html"); //-------------------------------------------------------------------------------------------------- function get_news_list($nmode){ $tm = getdate(); $yy = $tm[year]; $mm = $tm[mon]; $dd = $tm[mday]; $tt = $tm[hours]; $xtoday = sprintf("%04d%02d%02d",$yy,$mm,$dd); $ns = new dbop("news"); $ns->db_open(); switch($nmode){ case 'both' : $cond = "(kubun = '10' or kubun = '01' or kubun ='11')"; break; case 'corp' : $cond = "(kubun = '01' or kubun = '11')"; break; case 'recruite' : $cond = "(kubun = '10' or kubun = '11')"; break; } $sql = "select * from $ns->tbl_name where $cond and flg=1 and valid_from <= '$xtoday' and '$xtoday' <= valid_to order by id desc"; $rec = $ns->execute($sql); $ar_obj = array(); if(!$rec){ $msg = "DBアクセスエラー"; return array(false,$msg); }else{ $cnt = $ns->rcnt(); if($cnt > 0){ for($i=0;$i<$cnt;$i++){ $obj = $ns->fetch($i); //print_r($obj); //print "
"; $myurl = $obj[url]; if(strlen($myurl) > 0 && !preg_match("/http:\/\//",$myurl))$myurl = "http://".$myurl; $obj[url] = $myurl; $yy = substr($obj[valid_from],0,4); $mm = substr($obj[valid_from],5,2); $dd = substr($obj[valid_from],8,2); $obj[valid_from] = sprintf("%04d/%02d/%02d",$yy,$mm,$dd); $yy = substr($obj[valid_to],0,4); $mm = substr($obj[valid_to],5,2); $dd = substr($obj[valid_to],8,2); $obj[valid_to] = sprintf("%04d/%02d/%02d",$yy,$mm,$dd); $ar_obj[$i] = $obj; } }else{ $msg = "DBアクセスエラー"; return array(false,$msg); } } $ns->db_close(); return array(true,$ar_obj); } ?>