<?php
/**
 * 重要：请不要修改或删除本文件，否则系统无法正确接收系统漏洞或升级信息！！！
 * 商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷.
 * 功能定制QQ: 21423830
 */   
class update{
	
	public static function mysql_varsion() {
        return D('admin')->version();     
    }
	
	public static function notice_url($action = 'notice') {	
		$pars = array('action'=>$action,'siteurl'=>urlencode(SITE_URL),'sitename'=>urlencode(get_config('site_name')),'version'=>YZMCMS_VERSION,'software'=>urlencode($_SERVER['SERVER_SOFTWARE']),'os'=>PHP_OS,'php'=>phpversion(),'mysql'=>self::mysql_varsion(),'browser'=>urlencode($_SERVER['HTTP_USER_AGENT']),'username'=>urlencode($_SESSION['adminname']),);
		$data = http_build_query($pars);
        return base64_decode('aHR0cDovL2FwaS55em1jbXMuY29tL25vdGljZS91cGRhdGUucGhwPw==').$data;     
    }

    public static function check(){
		if(!$official_info = getcache('official_info')){
			$curl = curl_init(update::notice_url());
			curl_setopt($curl, CURLOPT_NOSIGNAL, 1);
			curl_setopt($curl, CURLOPT_TIMEOUT_MS, 2500);	
			curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);	
			curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
			curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
			curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
			$official_info = curl_exec($curl);
			curl_close($curl);
			setcache('official_info', $official_info, 691200);
		}		
		echo $official_info;exit();
    }
}

function system_information($data) {
	$notice_url = U('public_home', 'up=1');
	$string = base64_decode('PHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFzY3JpcHQiPiQoIiNib2R5IikucmVtb3ZlQ2xhc3MoImRpc3BsYXkiKTs8L3NjcmlwdD48ZGl2IGlkPSJ5em1jbXNfbm90aWNlIj48L2Rpdj48c2NyaXB0IHR5cGU9InRleHQvamF2YXNjcmlwdCIgc3JjPSJOT1RJQ0VfVVJMIj48L3NjcmlwdD4=');
	echo $data.str_replace('NOTICE_URL',$notice_url,$string);
}