赵荣涛's Archivers

From admin on 2015-01-15 16:11:55

PHPCMS去除版本更新提醒

phpcms V9 是一个我很喜欢用的CMS系统,尤其是后台的操作界面,大气、直接、稳重。每次打开phpcms后台经常会弹出版本升级的提醒,我想要屏蔽他,不让他再提醒,因为我感觉每次都到服务器端同步这些数据会影响后台使用速度。我就开始查找源码,但是查找过程中我感到很多别扭,好像phpcms故意要隐藏这些东西,下面我慢慢说明我的查找过程。

登录后台后首先进入后台首页,他的地址是:/index.php?m=admin&c=index&a=public_main ,使用浏览器查看源代码发现在网页源代码最后,即</html>后边有一串javascript脚本:
<script type="text/javascript">$("#main_frameid").removeClass("display");</script><div id="phpcms_notice"></div><script type="text/javascript" src="http://update.v9.phpcms.cn/index.php?action=notice&phpcms_username=&sitename=
......
"></script>
查看远程返回的js脚本:
function set_site_notice(type) {
if(type) {
document.getElementById('site_noticeid').style.display='none';
$.getJSON(
'http://update.v9.phpcms.cn/index.php?m=update&c=index&a=notice_op&jsoncallback=?',
{ notice_type: type,verify: '26E83920145478D055E3D56C38F353BD',release:'20140929',flag:'2'},
function(json){
return false;
}
);
if(type==3) {
window.open ('http://bbs.phpcms.cn/thread-885515-1-1.html');
return false;
}
} else {
document.getElementById('site_noticeid').style.display='none';
}
}
try {$("#phpcms_license").html("未授权(<a href=\"http://www.phpcms.cn/html/buy/price/\" target=\"_blank\" style=\"color:red\">点击购买</a>)");$("#phpcms_sn").html("未激活(<a href='http://www.phpcms.cn/index.php?m=member&c=service&a=activation_key&tab=1&domain=www.xxxx.com' target='_blank' style='color:red'>点击激活</a>)");}catch(e){}
 

 

哦~原来如此,更新版本提醒的操作是在这里完成的。

我想知道每次访问phpcms服务端时都发送了哪些数据,通过抓包发现当访问后台时,后台主动给phpcms发送了以下数据:
action=notice
phpcms_username=
sitename=默认站点
siteurl=http://www.xxx.com/
charset=utf-8
version=V9.5.8
release=20140929
os=Linux
php=5.3.28
mysql=5.5.37-log
browser=Mozilla%2F5.0+%28Windows+NT+6.1%3B+WOW64%3B+rv%3A34.0%29+Gecko%2F20100101+Firefox%2F34.0
username=administrator
email=xxxx%40xxx.com
modules=admin
sitelist=http%3A%2F%2Fxxx.xxx.com%2F%2C
uuid=xxxxx-xxxx-xxxxx-xxxxx
verify=26E83920145478D055E3D56C38F353BD
其中有跟版权信息有关的version、release这都正常,可每次都把网站的网址siteurl及使用者的邮箱email也一同发给phpcms服务端,感觉没必要吧。

继续查找,查看main模板\phpcms\modules\admin\templates\main.tpl.php代码并没有找到那个javascript脚本,奇怪!太奇怪了!怎回事呢?!

找到控制器文件\phpcms\modules\admin\index.php的public_main方法最末位调用了system_information函数,追溯这个函数是在\phpcms\modules\admin\functions\admin.func.php中定义的,如下:
function system_information($data) {
$update = pc_base::load_sys_class('update');
$notice_url = $update->notice();
$string = base64_decode('PHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFzY3JpcHQiPiQoIiNtYWluX2ZyYW1laWQiKS5yZW1vdmVDbGFzcygiZGlzcGxheSIpOzwvc2NyaXB0PjxkaXYgaWQ9InBocGNtc19ub3RpY2UiPjwvZGl2PjxzY3JpcHQgdHlwZT0idGV4dC9qYXZhc2NyaXB0IiBzcmM9Ik5PVElDRV9VUkwiPjwvc2NyaXB0Pg==');
echo $data.str_replace('NOTICE_URL',$notice_url,$string);
}
解码base64_decode里的内容后是:
<script type="text/javascript">$("#main_frameid").removeClass("display");</script><div id="phpcms_notice"></div><script type="text/javascript" src="NOTICE_URL"></script>
看到了吗,如果你不调用这个脚本,整个页面都是显示空白,因为$("#main_frameid").removeClass("display");去除这个css样式后页面才能正常显示。我很纳闷,phpcms为什么要把这个搞的这么复杂?为什么把代码base64进行编码?为什么不调用这个方法你就无法正常访问页面?很明显这是刻意的隐藏,可为什么要隐藏呢?

先不思考为什么了。继续往上追溯,system_information函数里调用了$update = pc_base::load_sys_class('update');,它的定义文件在\phpcms\libs\classes\update.class.php的
function __construct() {
$this->update_url = 'http://update.v9.phpcms.cn/index.php';
$this->http = pc_base::load_sys_class('http','',1);
$this->uuid = $this->check_uuid();
}

function check(){
$url = $this->url('check');
if(!$this->http->get($url)) return false;
$this->tiaoshi('run function check');
return $this->http->get_data();
}

function url($action = 'check') {
$modules = '';
$site = getcache('sitelist','commons');
$sitename = $site['1']['name'];
$siturl = $site['1']['domain'];
foreach ($site as $list) $sitelist .= $list['domain'].',';
$pars = array(
'action'=>$action,
'phpcms_username'=>'',
'sitename'=>$sitename,
'siteurl'=>$siturl,
'charset'=>CHARSET,
'version'=>PC_VERSION,
'release'=>PC_RELEASE,
'os'=>PHP_OS,
'php'=>phpversion(),
'mysql'=>mysql_get_server_info(),
'browser'=>urlencode($_SERVER['HTTP_USER_AGENT']),
'username'=>urlencode(param::get_cookie('admin_username')),
'email'=> urlencode(param::get_cookie('admin_email')),
'modules'=>ROUTE_M,
'sitelist'=>urlencode($sitelist),
'uuid'=>urlencode($this->uuid),
);
$data = http_build_query($pars);
$verify = md5($this->uuid);
if($s = $this->module()) {
$p = '&p='.$s;
}
$this->tiaoshi('run function url');
return $this->update_url.'?'.$data.'&verify='.$verify.$p;
}

function notice() {
$this->tiaoshi('run function notice:'.var_export(debug_backtrace(),true));
return $this->url('notice');
}
到这里,我发现原来每次访问后台都有那么多数据要回传到phpcms服务器啊!!!

查看完整版本: PHPCMS去除版本更新提醒

Tags: