主站www.123.com 手機站 wap.123.com
1.安裝手機wap浏覽 模塊
2.根目錄創建 wap文件夾 ,將 templets\wap 文件移入 根目錄下的 wap, 如圖:
<?php
if(isset($_SERVER['HTTP_USER_AGENT']))
{
$clientkeywords = array('nokia','sony','ericsson','mot','samsung','htc','sgh','lg','sharp','sie-','philips','panasonic','alcatel','lenovo','iphone','ipod','blackberry','meizu','android','netfront',
'symbian','ucweb','windowsce','palm','operamini','operamobi','openwave','nexusone','cldc','midp','wap','mobile');
// 從HTTP_USER_AGENT中查找手機浏覽器的關鍵字if (preg_match("/(".implode('|',$clientkeywords).")/i",strtolower($_SERVER['HTTP_USER_AGENT']))){
?>
window.location.href='http://wap.123.com';
<?PHP
}
}
?>
8.wap站添加 搜索
修改 wap.php
*else if($action=='search')
{
$needCode = 'UTF-8';
if(empty($keyword)) exit('Error!');
require_once(dirname(__FILE__)."/../include/datalistcp.class.php");
$varlist = "cfg_webname,cfg_templeturl";
ConvertCharset($varlist);
$dlist = new DataListCP();
$dlist->SetTemplet($cfg_templets_dir."/wap/search.wml");
$dlist->pageSize = 10;
$dlist->SetParameter("action","search");
$dlist->SetParameter("keyword",$keyword);
$dlist->SetSource("Select id,title,pubdate,click From `dede_archives` where title like '%". iconv("UTF-8", "GB2312",$keyword)."%' And arcrank=0 order by id desc");
$dlist->Display();
exit();
}