'; $max_pages = ceil($total_items / $items_per_page ); //上一页 if($current_page>1){ $page=$current_page-1; if($page == 1){ $pages_str.='
  • «
  • '; }else{ $pages_str.='
  • «
  • '; } } //第一页 if($current_page>1){ $page_str='
  • 1
  • '; $pages_str.=$page_str; }else{ $pages_str.='
  • 1
  • '; } //显示当前两页的前两页到后两页 if($max_pages-$current_page<3){ $prev_2_page=$max_pages-5; }else{ $prev_2_page=$current_page-2; } if($prev_2_page<2){ $prev_2_page=2; } $next_2_page=$prev_2_page+5; if($next_2_page>$max_pages) $next_2_page=$max_pages; for($i=$prev_2_page; $i<=$next_2_page; $i++){ if($i==$current_page){ $pages_str.='
  • '.$i.'
  • '; }else{ $pages_str.='
  • '.$i.'
  • '; } } //下一页 if($current_page<$max_pages){ $page=$current_page+1; $pages_str.='
  • »
  • '; } $pages_str.''; return $pages_str; } //手机版的分页 public static function pager_mobile($total_items, $items_per_page=20,$current_page=1, $url){ if ($total_items <= $items_per_page) { return ''; } if($items_per_page==0){ return ''; } $pages_str=''; return $pages_str; } //判断终端类型 //返回设备类型 public static function checkmobile() { $mobile = array(); static $touchbrowser_list =array('iphone', 'android', 'phone', 'mobile', 'wap', 'netfront', 'java', 'opera mobi', 'opera mini', 'ucweb', 'windows ce', 'symbian', 'series', 'webos', 'sony', 'blackberry', 'dopod', 'nokia', 'samsung', 'palmsource', 'xda', 'pieplus', 'meizu', 'midp', 'cldc', 'motorola', 'foma', 'docomo', 'up.browser', 'up.link', 'blazer', 'helio', 'hosin', 'huawei', 'novarra', 'coolpad', 'webos', 'techfaith', 'palmsource', 'alcatel', 'amoi', 'ktouch', 'nexian', 'ericsson', 'philips', 'sagem', 'wellcom', 'bunjalloo', 'maui', 'smartphone', 'iemobile', 'spice', 'bird', 'zte-', 'longcos', 'pantech', 'gionee', 'portalmmm', 'jig browser', 'hiptop', 'benq', 'haier', '^lct', '320x320', '240x320', '176x220', 'windows phone'); static $wmlbrowser_list = array('cect', 'compal', 'ctl', 'lg', 'nec', 'tcl', 'alcatel', 'ericsson', 'bird', 'daxian', 'dbtel', 'eastcom', 'pantech', 'dopod', 'philips', 'haier', 'konka', 'kejian', 'lenovo', 'benq', 'mot', 'soutec', 'nokia', 'sagem', 'sgh', 'sed', 'capitel', 'panasonic', 'sonyericsson', 'sharp', 'amoi', 'panda', 'zte'); static $pad_list = array('ipad'); if(isset($_SERVER['HTTP_USER_AGENT'])){ $useragent = strtolower($_SERVER['HTTP_USER_AGENT']); }else{ $useragent = ''; } if(CommonFn::dstrpos($useragent, array('windows'))) { return 'pc'; } if(CommonFn::dstrpos($useragent, $pad_list)) { return 'pad'; } if(($v = CommonFn::dstrpos($useragent, $touchbrowser_list, true))){ if(strpos($useragent, 'iphone') || strpos($useragent, 'ipod')){ return 'ios'; }else{ return 'android'; } } if(($v = CommonFn::dstrpos($useragent, $wmlbrowser_list))) { return 'android'; } return 'pc'; } public static function header_redirect($url, $code=301){ header('Location: '.$url, true, $code); return false; } }