|
|
ɳ

楼主 |
发表于 2017-11-5 23:17:21
|
只看该作者
已完成设置管理。新增sysconfig.php 文件存放配置文件- function set_config($config, $filename="sysconfig") {
- $configfile = APP_PATH.DIRECTORY_SEPARATOR.MODULE_NAME.DIRECTORY_SEPARATOR.'Conf'.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 C('lock_ex') ? file_put_contents($configfile, $str, LOCK_EX) : file_put_contents($configfile, $str);
- }
复制代码 |
|