phpcms中set_config和get_sysinfo函数
Posted 大漠孤魂
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了phpcms中set_config和get_sysinfo函数相关的知识,希望对你有一定的参考价值。
/** * 设置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函数的主要内容,如果未能解决你的问题,请参考以下文章