function set() { global $_CONFIG; $func_num_args=func_num_args(); $func_args=func_get_args(); $value=array_pop($func_args); $value = dstripslashes($value); $type=array_shift($func_args); $remark = '/'.'********************************************* *[tttuangou] (C)2005 - 2010 Cenwor Inc. * * tttuangou '.$type.'配置 * * @author www.tttuangou.net * * @time '.date('Y-m-d H:i').' *********************************************'.'/ '; $file=ConfigHandler::file($type); if($type===null) { $data="<?php \r\n {$remark} \r\n \$config=".var_export($value,true)."; \r\n ?>"; } else { if(($config=$_CONFIG[$type])===null) { $config=array(); @include($file); $config=$config[$type]; } foreach($func_args as $arg) { $path_str.="['$arg']"; } eval($value===null?'unset($config'.$path_str.');':'$config'.$path_str.'=$value;'); $data="<?php \r\n {$remark} \r\n\$config['$type']=".var_export($config,true).";\r\n?>"; } @$fp=fopen($file,'wb'); if(!$fp) { zlog('error')->found('denied.io', $file); die($file."文件无法写入,请检查是否有可写权限。"); } $len=fwrite($fp, $data); fclose($fp); if($len)$_CONFIG[$type]=$config; return $len; }
static function set() { $func_args = func_get_args(); $value = array_pop($func_args); $type = array_shift($func_args); ConfigHandler::backup($type); $file = ConfigHandler::file($type); $data = ''; if ($type === null) { if ($value && $value['auth_key']) { ksort($value); $keeps = array('acceleration_mode' => 1, 'charset' => 1, 'db_host' => 1, 'db_port' => 1, 'db_name' => 1, 'db_user' => 1, 'db_pass' => 1, 'db_table_prefix' => 1, 'db_slave' => 1, 'jishigou_founder' => 1, 'setting_from_db' => 1); foreach ($keeps as $k => $v) { if ($v && isset($value[$k]) && $value[$k] != $GLOBALS['_J']['config'][$k]) { $value[$k] = $GLOBALS['_J']['config'][$k]; } } ConfigHandler::db(null, $value); $data = "<?php \r\n \r\n\t\t\t\t\r\n \$config = " . var_export(ConfigHandler::core_settings($value, array(), 'local'), true) . "; \r\n?>"; } } else { global $_J; $config = ConfigHandler::get($type); $path_str = ''; foreach ($func_args as $arg) { $arg = str_replace(array(';', '"', "'"), '', $arg); $path_str .= "['{$arg}']"; } eval($value === null ? 'unset($config' . $path_str . ');' : '$config' . $path_str . '=$value;'); if (!is_null($config) && $_J['config'][$type] != $config) { $_J['config'][$type] = $config; ConfigHandler::db($type, $config); $data = "<?php \r\n \r\n\t\t\t\t\r\n \$config['{$type}'] = " . var_export($config, true) . "; \r\n?>"; } } if ($data) { $len = jio()->WriteFile($file, $data); if (false === $len) { die($file . " 文件无法写入,请检查是否有可写权限。"); } } return $len; }