手机号码是一组敏感的数字,它将涉及到个人的隐私。如果在网站上发布了手机号码,很有可能被收录然后被一些不法分子采集利用,那么如何屏蔽这个现象呢,最好的办法就是让号码不显示。当然这并不是解决办法,最好的办法就是让帝国cms仿站中的手机号码自动显示为图片,此功能同之前的58同城的手机号码显示方式相类似,我们需要开发一个php文件,代码如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<?php $get = $_GET ; $phone = $get [ 'phone' ]; $im = @imagecreatetruecolor(130, 30); $bgcolor = imagecolorallocate( $im , 255, 255, 255); imagefilledrectangle( $im ,0,0,130,30, $bgcolor ); $fontcolor = imagecolorallocate( $im ,255,0,0); $fonttype = 'lsansi.ttf' ; $text = $phone ; imagefttext( $im ,13,0,3,19, $fontcolor , $fonttype , $text ); header( "Content-type: image/png" ); imagepng( $im ); imagedestroy( $im ); ?> |
我们将这段代码保存为tele.php,把这个文件放在帝国cms仿站的根目录,使用方法也非常简单,下面这句代码就可以实现
1
|
< img src = "/phone.php?phone=[!---tel--]" width = "160" height = "25" /> |
不同页面使用方法,列表页面:
1
2
3
|
$listtemp=' < img src = "/phone.php?phone='.$r[tel].'" width = "160" height = "25" /> '; |
文章页面使用方法:
1
|
< img src = "/phone.php?phone='.$navinfor[tel].'" width = "160" height = "25" /> |
解释一下上面的代码,PHP中的代码$fonttype='lsansi.ttf';其中后面的lsansi.ttf是字体文件,根据需要你可以替换成自己的想要的字体文件,但要记得和这个telee.php一样放在帝国cms仿站的根目录。