码迷,mamicode.com
首页 > Web开发 > 详细

phpcms中set_config和get_sysinfo函数

时间:2018-10-11 23:53:01      阅读:400      评论:0      收藏:0      [点我收藏+]

标签:inf   upload   函数   version   directory   function   foreach   zip   bool   

    /**
     * 设置config文件
     * @param $config 配属信息
     * @param $filename 要配置的文件名称
     */
    function set_config($config, $filename="system") {
        $configfile = CACHE_PATH.‘configs‘.DIRECTORY_SEPARATOR.$filename.‘.php‘;
        if(!is_writable($configfile)) showmessage(‘Please chmod ‘.$configfile.‘ to 0777 !‘);
        $pattern = $replacement = array();
        foreach($config as $k=>$v) {
            if(in_array($k,array(‘js_path‘,‘css_path‘,‘img_path‘,‘attachment_stat‘,‘admin_log‘,‘gzip‘,‘errorlog‘,‘phpsso‘,‘phpsso_appid‘,‘phpsso_api_url‘,‘phpsso_auth_key‘,‘phpsso_version‘,‘connect_enable‘, ‘upload_url‘,‘sina_akey‘, ‘sina_skey‘, ‘snda_enable‘, ‘snda_status‘, ‘snda_akey‘, ‘snda_skey‘, ‘qq_akey‘, ‘qq_skey‘,‘qq_appid‘,‘qq_appkey‘,‘qq_callback‘,‘admin_url‘))) {
                $v = trim($v);
                $configs[$k] = $v;
                $pattern[$k] = "/‘".$k."‘\s*=>\s*([‘]?)[^‘]*([‘]?)(\s*),/is";
                $replacement[$k] = "‘".$k."‘ => \${1}".$v."\${2}\${3},";                    
            }
        }
        $str = file_get_contents($configfile);
        $str = preg_replace($pattern, $replacement, $str);
        return pc_base::load_config(‘system‘,‘lock_ex‘) ? file_put_contents($configfile, $str, LOCK_EX) : file_put_contents($configfile, $str);        
    }
    
    /**
     * 获取系统信息
     */
    function get_sysinfo() {
        $sys_info[‘os‘]             = PHP_OS;
        $sys_info[‘zlib‘]           = function_exists(‘gzclose‘);//zlib
        $sys_info[‘safe_mode‘]      = (boolean) ini_get(‘safe_mode‘);//safe_mode = Off
        $sys_info[‘safe_mode_gid‘]  = (boolean) ini_get(‘safe_mode_gid‘);//safe_mode_gid = Off
        $sys_info[‘timezone‘]       = function_exists("date_default_timezone_get") ? date_default_timezone_get() : L(‘no_setting‘);
        $sys_info[‘socket‘]         = function_exists(‘fsockopen‘) ;
        $sys_info[‘web_server‘]     = strpos($_SERVER[‘SERVER_SOFTWARE‘], ‘PHP‘)===false ? $_SERVER[‘SERVER_SOFTWARE‘].‘PHP/‘.phpversion() : $_SERVER[‘SERVER_SOFTWARE‘];
        $sys_info[‘phpv‘]           = phpversion();    
        $sys_info[‘fileupload‘]     = @ini_get(‘file_uploads‘) ? ini_get(‘upload_max_filesize‘) :‘unknown‘;
        return $sys_info;
    }

 

phpcms中set_config和get_sysinfo函数

标签:inf   upload   函数   version   directory   function   foreach   zip   bool   

原文地址:https://www.cnblogs.com/cblx/p/9775518.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!