本文以WordPress环境为例
首先,请参照全部中国大陆IP段获取中国大陆IP信息
然后,安装好Exec-PHP插件
查看你的FaceBook代码,以我的为例:
1 | <!-- Facebook Badge START --><a href="http://zh-tw.facebook.com/ksj32750" target="_TOP" style="font-family: "lucida grande",tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="Peter Chang">Peter Chang</a><br/><a href="http://zh-tw.facebook.com/ksj32750" target="_TOP" title="Peter Chang"><img src="http://badge.facebook.com/badge/100001562501152.221.1559676673.png" width="120" height="252" style="border: 0px;" /></a><br/><a href="http://zh-tw.facebook.com/badges/" target="_TOP" style="font-family: "lucida grande",tahoma,verdana,arial,sans-serif; font-size: 11px; font-variant: normal; font-style: normal; font-weight: normal; color: #3B5998; text-decoration: none;" title="建立你的名片貼!">建立你的名片貼</a><!-- Facebook Badge END --> |
我把它砍得只剩下:
1 | <a href="http://zh-tw.facebook.com/ksj32750" target="_TOP" title="Peter Chang"><img src="http://badge.facebook.com/badge/100001562501152.221.1559676673.png" width="120" height="252" style="border: 0px;" /></a> |
也就是去掉了上面的名字和下面的无用链接。
然后在img标签的src后面添加php代码,结果如下:
1 2 3 4 5 6 7 8 9 10 11 | <!-- Facebook Badge START --><a href="http://zh-cn.facebook.com/ksj32750" target="_TOP" title="Peter Chang"><img src=<?php if ($cn) { clearstatcache(); if (!file_exists("$RootDir/wp-includes/images/cache/facebook.1559676673.png") || time() - filemtime("$RootDir/wp-includes/images/cache/facebook.1559676673.png") > 86400) copy("http://badge.facebook.com/badge/100001562501152.221.1559676673.png", "$RootDir/wp-includes/images/cache/facebook.1559676673.png"); echo "http://zi-jin.com/wp-includes/images/cache/facebook.1559676673.png"; } else echo "http://badge.facebook.com/badge/100001562501152.221.1559676673.png"; ?> width="120" height="252" style="border: 0px;" /></a><!-- Facebook Badge END --> |
直接复制是无用的,那会显示我的出来…… ![[#38]](http://zi-jin.com/wp-includes/images/smilies/face (29).gif)
请参照以上稍作修改即可。
如果不会判断用户的ip段,请参考PHP判断IP段-以大陆ip段为例
(这就没有进度条的意义了)