$value) { $arr['filelist'][$key]['path'] = pre_clear($value['path']); } foreach ($arr['folderlist'] as $key => $value) { $arr['folderlist'][$key]['path'] = pre_clear($value['path']); } }else{ $arr = pre_clear($arr); } } //前缀处理 非root用户目录/从HOME开始 function pre_clear($path){ if (ST=='share') { return str_replace(HOME,'',$path); } if (substr($path,0,strlen(PUBLIC_PATH)) == PUBLIC_PATH) { return '*public*/'.str_replace(PUBLIC_PATH,'',$path); } return str_replace(HOME,'',$path); } function xxsClear(&$list){ if (is_array($list)) { foreach ($list['filelist'] as $key => $value) { $list['filelist'][$key]['ext'] = htmlspecial($value['ext']); $list['filelist'][$key]['path'] = htmlspecial($value['path']); $list['filelist'][$key]['name'] = htmlspecial($value['name']); } foreach ($list['folderlist'] as $key => $value) { $list['folderlist'][$key]['path'] = htmlspecial($value['path']); $list['folderlist'][$key]['name'] = htmlspecial($value['name']); } }else{ $list = htmlspecial($list); } } function htmlspecial($str){ return str_replace( array('<','>','"',"'"), array('<','>','"',''','&'), $str ); } function htmlspecial_decode($str){ return str_replace( array('<','>','"','''), array('<','>','"',"'"), $str ); } //扩展名权限判断 function checkExtUnzip($s,$info){ return checkExt($info['stored_filename']); } //扩展名权限判断 有权限则返回1 不是true function checkExt($file,$changExt=false){ if (strstr($file,'<') || strstr($file,'>') || $file=='') { return 0; } if ($GLOBALS['is_root'] == 1) return 1; $not_allow = $GLOBALS['auth']['ext_not_allow']; $ext_arr = explode('|',$not_allow); foreach ($ext_arr as $current) { $current = trim($current); if ($current !== '' && stristr($file,'.'.$current)){//含有扩展名 return 0; } } return 1; } function php_env_check(){ $L = $GLOBALS['L']; $error = ''; $base_path = get_path_this(BASIC_PATH).'/'; if(!function_exists('iconv')) $error.= '
  • '.$L['php_env_error_iconv'].'
  • '; if(!function_exists('mb_convert_encoding')) $error.= '
  • '.$L['php_env_error_mb_string'].'
  • '; if(!version_compare(PHP_VERSION,'5.0','>=')) $error.= '
  • '.$L['php_env_error_version'].'
  • '; if(!function_exists('file_get_contents')) $error.='
  • '.$L['php_env_error_file'].'
  • '; if(!path_writable(BASIC_PATH)) $error.= '
  • '.$base_path.' '.$L['php_env_error_path'].'
  • '; if(!path_writable(BASIC_PATH.'data')) $error.= '
  • '.$base_path.'data '.$L['php_env_error_path'].'
  • '; if(!path_writable(BASIC_PATH.'data/system')) $error.= '
  • '.$base_path.'data/system '.$L['php_env_error_path'].'
  • '; if(!path_writable(BASIC_PATH.'data/User')) $error.= '
  • '.$base_path.'data/User '.$L['php_env_error_path'].'
  • '; if(!path_writable(BASIC_PATH.'data/thumb')) $error.= '
  • '.$base_path.'data/thumb '.$L['php_env_error_path'].'
  • '; if( !function_exists('imagecreatefromjpeg')|| !function_exists('imagecreatefromgif')|| !function_exists('imagecreatefrompng')|| !function_exists('imagecolorallocate')){ $error.= '
  • '.$L['php_env_error_gd'].'
  • '; } return $error; } //语言包加载:优先级:cookie获取>自动识别 //首次没有cookie则自动识别——存入cookie,过期时间无限 function init_lang(){ if (isset($_COOKIE['kod_user_language'])) { $lang = $_COOKIE['kod_user_language']; }else{//没有cookie preg_match('/^([a-z\-]+)/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches); $lang = $matches[1]; switch (substr($lang,0,2)) { case 'zh': if ($lang != 'zn-TW'){ $lang = 'zh-CN'; } break; case 'en':$lang = 'en';break; default:$lang = 'en';break; } $lang = str_replace('-', '_',$lang); setcookie('kod_user_language',$lang, time()+3600*24*365); } if ($lang == '') $lang = 'en'; $lang = str_replace(array('/','\\','..','.'),'',$lang); define('LANGUAGE_TYPE', $lang); include(LANGUAGE_PATH.$lang.'/main.php'); $GLOBALS['L'] = $L; } function init_setting(){ $setting_file = USER_SYSTEM.'system_setting.php'; if (!file_exists($setting_file)){//不存在则建立 $setting = $GLOBALS['config']['setting_system_default']; $setting['menu'] = $GLOBALS['config']['setting_menu_default']; fileCache::save($setting_file,$setting); }else{ $setting = fileCache::load($setting_file); } if (!is_array($setting)) { $setting = $GLOBALS['config']['setting_system_default']; } if (!is_array($setting['menu'])) { $setting['menu'] = $GLOBALS['config']['setting_menu_default']; } $GLOBALS['app']->setDefaultController($setting['first_in']);//设置默认控制器 $GLOBALS['app']->setDefaultAction('index'); //设置默认控制器函数 $GLOBALS['config']['setting_system'] = $setting;//全局 $GLOBALS['L']['kod_name'] = $setting['system_name']; $GLOBALS['L']['kod_name_desc'] = $setting['system_desc']; if (isset($setting['powerby'])) { $GLOBALS['L']['kod_power_by'] = $setting['powerby']; } }