<?php
//decode by http://www.yunlu99.com/
 class outputAModel extends X { private $key = "50XYWGKYYP0TP38G6666"; private $token = NULL; private $domain = NULL; public function __construct() { if (file_exists(BASE_ROOT.'./source/conf/cert.inc.php')) { require_once(BASE_ROOT.'/source/conf/cert.inc.php'); } $v_siteurl = strtolower($_SERVER['HTTP_HOST']); $v_siteurl = empty($v_siteurl) ? strtolower($_SERVER['SERVER_NAME']) : $v_siteurl; $v_siteurl = trim($v_siteurl); $v_ascode = defined('LJCMSSERIAL_KEY') ? LJCMSSERIAL_KEY : ''; $libdm = parent::import('domain', 'util'); $this->domain = $libdm->getDomain(); unset($libdm); $v_type = defined('LJCMS_TYPE') ? LJCMS_TYPE : ''; $v_version = defined('LJCMS_VERSION') ? LJCMS_VERSION : ''; $v_release = defined('LJCMS_RELEASE') ? LJCMS_RELEASE : ''; $v_serverip = $this->_getServIp(); $v_clientip = XRequest::getip(); $token_content = $v_siteurl.'|'.$v_ascode.'|'.$this->domain.'|'. $v_type.'|'.$v_version.'|'.$v_release.'|'. $v_serverip.'|'.$v_clientip; $code = parent::import('code', 'util'); $this->token = $code->authCode($token_content, 'ENCODE', $this->key); unset($code); } private function _readCache() { $time = 0; if (file_exists(BASE_ROOT.'./data/cache/s.cache')) { $cache = parent::import('cache', 'lib'); $data = $cache->readDcache('s'); if (!empty($data)) { $time = intval($data['time']); } unset($cache); } return $time; } private function _writeCache() { $time = time(); $cache = parent::import('cache', 'lib'); $data = array( 'time'=>$time ); $cache->writeDcache(serialize($data), 's'); unset($cache); } private function _validTime() { $time = $this->_readCache(); if ((time()-$time)<60) { return true; } else { return false; } } public function tjReqs() { $result = ''; if (false === $this->_validTime()) { if (true === $this->_checkDomain($this->domain)) { $curl = parent::import('curl', 'util'); $url = "http://www.8cms.com/index.php?c=version&a=tj". "&name=LJCMS&key=".urlencode($this->key). "&token=".urlencode($this->token); if (intval(LJCMS_STYPE) == 1) { $result = @$curl->fileGet($url); } else { $result = @$curl->get($url); } unset($curl); $this->_writeCache(); } } return $result; } public function doGetSerial() { $res = 0; $msg = ''; $response_content = NULL; if (true === $this->_checkDomain($this->domain)) { $curl = parent::import('curl', 'util'); $url = "http://www.8cms.com/index.php?c=version&a=getserial". "&name=LJCMS&key=".urlencode($this->key). "&token=".urlencode($this->token); if (intval(LJCMS_STYPE) == 1) { $response_content = @$curl->fileGet($url); } else { $response_content = @$curl->get($url); } unset($curl); if (!empty($response_content)) { $response_content = json_decode($response_content, true); $result = $response_content['result']; $code = parent::import('code', 'util'); $de_token = $code->authCode($result, 'DECODE', $this->key); unset($code); if (!empty($de_token)) { $token_item = explode('|', $de_token); $res = @intval($token_item[0]); $msg = @$token_item[1]; } } else { $res = 4; $msg = "请求无响应"; } } else { $res = 3; $msg = "请使用授权域名进行查询"; } return array($res, $msg); } private function _checkDomain($dm) { $result = true; if (empty($dm)) { $result = false; } else { $dm = strtolower($dm); if (strpos($dm, 'localhost') || strpos($dm, '127.0.0.') || strpos($dm, '192.168.')) { $result = false; } } return $result; } private function _getServIp() { if (isset($_SERVER)) { if($_SERVER['SERVER_ADDR']) { $server_ip = $_SERVER['SERVER_ADDR']; } else { $server_ip = $_SERVER['LOCAL_ADDR']; } } else { $server_ip = getenv('SERVER_ADDR'); } $one = '([0-9]|[0-9]{2}|1\d\d|2[0-4]\d|25[0-5])'; if(!@preg_match('/'.$one.'\.'.$one.'\.'.$one.'\.'.$one.'$/', $server_ip)){$server_ip='0.0.0.0';}; return $server_ip; } }