页面代码:获取终端类型,手机或者pc
<input type="hidden" id="getdevice" name="getdevice" value="" /><script type="text/javascript"> function getdevice() { var get_device = document.getElementById("getdevice"); if ((navigator.userAgent.match( /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i ))) { get_device.value = "mobile" } else { get_device.value = "PC" } } getdevice();</script>1.在数据库的“前缀名_enewsgbook”例如(phome_enewsgbook)表中添加您要显示的字段,比如我要加终端"getdevice"字段,可以用工具添加,也可以执行sql添加:
ALTER TABLE phome_enewsgbook ADD getdevice VARCHAR(30);2.打开e\enews\gbookfun.php
在13行左右的地方插入下面代码:
$getdevice=dgdb_tosave($add[getdevice]);
在60行左右找到 $empire->query("insert into 的语句中的相应的位置加入相应的字段代码例如:getdevice,注意有两处需要修改
$sql=$empire->query("insert into {$dbtbpre}enewsgbook(name,email,`mycall`,lytime,lytext,retext,bid,ip,checked,userid,username,eipport,geturl,getcity,getdevice) values('$name','$email','$mycall','$lytime','$lytext','','$bid','$ip','$br[checked]','$userid','$username','$eipport','$geturl','$getcity','$getdevice');");3.打开e\tool\gbook\index.php,若不需要前端显示,可以删除该文件或者修改为index.php.bak
在51行左右找到“$query="select …”查询语句中适当位置加入字段,如:getdevice
4.打开e/data/template/gbooktemp.txt文件
约51行找到“$query="select…”查询语句,在适当位置加入字段,如:getdevice
5.打开e/class/functions.php文件,约2940行找到:“$listtemp_center=str_replace("[!--retext--]","<?=\$r[retext]?>",$listtemp_center);”行下面插入相应写法的代码,如:
$listtemp_center=str_replace("[!--getdevice--]","<?=\$r[getdevice]?>",$listtemp_center);6.打开e/admin/tool/gbook.php大约117行找到$query="select lyid,name,email加上字段getdevice,然后在<table width="100%" border="0" cellspacing="1" cellpadding="3">在适当位置调用字段,例如:终端:<?=$r[getdevice]?>
|
|
|
|
|
|
精彩评论 (0)