<?php
/**
 * [LJCMS] (C)2012-2099 LJdev,Inc.
 * <E-Mail：aspcms@qq.com>
 * Url http://www.liangjing.org
 *     http://www.8CMS.com
 * Update 2013.11.19
*/

class indexAModel extends X {
    
    
    public function isFunc($funname) {
        if (!empty($funname)) {
            if (function_exists($funname)) {
                return '<font color="green">√</font>';
            }
            else {
                return '<font color="red">×</font>';
            }
        }
        else {
            return '<font color="red">函数错误</font>';
        }
    }
    
    
    public function getVar($varName) {
        switch ($result = get_cfg_var($varName)){
            case 0:
                return '<font color="red">×</font>';
                break;
            case 1:
                return '<font color="green">√</font>';
                break;
            default:
                return $result;
                break;
        }
    }

    
    public function getServerIP() {
        return $_SERVER['SERVER_ADDR'];
    }
    
    
    public function getClientIP() {
        return XRequest::getip();
    }
    
    
    public function getWebEngine() {
        return $_SERVER['SERVER_SOFTWARE'];
    }
    
    
    public function getOs() {
		if (function_exists('php_uname')) {
			$os = explode(' ', php_uname());
			return $os[0];
		}
		else {
			return '';
		}
    }
    
    
    public function getPhpVersion() {
        return PHP_VERSION;
    }
    
    
    public function getGD() {
        if (function_exists('gd_info')) {
            $gd_info = @gd_info();
	        return $gd_info['GD Version'];
        }
        else {
            return "<font color='red'>×</font>";
        }
    }
    
    
    public function doGetSysData() {
       
        $data = array(
            'serverip'=>$this->getServerIP(),
            'clientip'=>$this->getClientIP(),
            'os'=>$this->getOs(),
            'webengine'=>$this->getWebEngine(),
            'time'=>time(),
            'phpversion'=>$this->getPhpVersion(),
            'curl'=>$this->isFunc('curl_init'),
            'gd'=>$this->getGD(),
            'iconv'=>$this->isFunc('iconv'),
            'urlopen'=>$this->getVar('allow_url_fopen'),
            'edition'=>$this->getedition()
        );
        return $data;
    }

    public function getedition(){
        $model  = parent::model('member', 'im');
        $system_edition = $model->getsetup('system_edition');
        $value = $system_edition['setvalue'];
        return $value;
    }
}
?>
