function guestbook($length=20,$limit=10,$ordertype='id') { $_ordertype=$ordertype; $cache_id=md5($length.$limit.$ordertype); if ($ordertype == 'rand()') $cache_id=$cache_id.time(); if (cache::get($cache_id)) $guestbooks=cache::get($cache_id); else { $ordertype=str_replace('-',' ',$ordertype); $order='1 desc'; if (preg_match('/^\w+$/',$ordertype)) $order=$ordertype.' desc'; elseif ($ordertype) $order=$ordertype; $guestbook=guestbook::getInstance(); $guestbooks=$guestbook->getrows('state=1',$limit,$order,$guestbook->getcols('list')); foreach ($guestbooks as $order=>$arc) { $guestbooks[$order]['adddate']=sdate($arc['adddate']); $guestbooks[$order]['title']=tool::cn_substr($arc['title'],$length); $guestbooks[$order]['url']=url('guestbook/view/id/'.$arc['id']); } if ($ordertype != 'rand()') cache::set($cache_id,$guestbooks); } return $guestbooks; }