<?php define('KOD_GROUP_PATH','{group_path}');define('KOD_GROUP_SHARE','{group_share}');define('KOD_USER_SHARE','{user_share}');define('KOD_USER_RECYCLE','{user_recycle}');define('KOD_USER_FAV','{user_fav}');define('KOD_GROUP_ROOT_SELF','{tree_group_self}');define('KOD_GROUP_ROOT_ALL','{tree_group_all}');function _DIR_CLEAR($){if(isset($GLOBALS['is_root'])&& $GLOBALS['is_root']){return $;}$=str_replace('\\','/',trim($));if(strstr($,'../')){$=preg_replace('/\.+\/+/','/',$);}$=preg_replace('/\/+/','/',$);return $;οۉ毽лⶂɕ;}function _DIR($̽Ǟ){$с=_DIR_CLEAR($̽Ǟ);Ƴ̭̓ڄכք;$с=iconv_system($с);$=array(KOD_GROUP_PATH,KOD_GROUP_SHARE,KOD_GROUP_ROOT_SELF,KOD_GROUP_ROOT_ALL,KOD_USER_SHARE,KOD_USER_RECYCLE,KOD_USER_FAV,);;ƁܒӣӹֽϚÏ;$GLOBALS['path_type']='';͟ˢ݁;$GLOBALS['path_pre']=HOME;ܮݨ;;$GLOBALS['path_id']='';趿뵖;unset($GLOBALS['path_id_user_share']);ӂ̭怍Ц;֖;foreach($ as $ܓ){if(substr($с,0,strlen($ܓ))==$ܓ){$GLOBALS['path_type']=$ܓ;$=explode('/',$с);$Ț=$[0];unset($[0]);$=implode('/',$);$̒=explode(':',$Ț);if(count($̒)>0x001){$GLOBALS['path_id']=trim($̒[0x001]);}else{$GLOBALS['path_id']='';}break;}}switch($GLOBALS['path_type']){case '':$с=iconv_system(HOME).$с;򑲹;̴灏ҡЪڑ详ʊ鉟;뽔ǋѳչݞ䅳ɺ;break;͙;ڍȑӹÝޑٴԘߍ܋;٦źیÿ͑򓱹;case KOD_USER_RECYCLE:$GLOBALS['path_pre']=trim(USER_RECYCLE,'/');禉ɟ;$GLOBALS['path_id']='';ԝĩ涧䟂蒵;return iconv_system(USER_RECYCLE).'/'.str_replace(KOD_USER_RECYCLE,'',$с);ؓ܌ޝÂčޛ;case KOD_USER_FAV:$GLOBALS['path_pre']=trim(KOD_USER_FAV,'/');;렱ٻض;⧎򴡖퍈Ⱆ棴;$GLOBALS['path_id']='';return KOD_USER_FAV;ˬϾ˫ܴƻՒ׮ס׫ژ;case KOD_GROUP_ROOT_SELF:$GLOBALS['path_pre']=trim(KOD_GROUP_ROOT_SELF,'/');㤯;ןە;$GLOBALS['path_id']='';return KOD_GROUP_ROOT_SELF;case KOD_GROUP_ROOT_ALL:$GLOBALS['path_pre']=trim(KOD_GROUP_ROOT_ALL,'/');$GLOBALS['path_id']='';return KOD_GROUP_ROOT_ALL;ӣЭͨن;case KOD_GROUP_PATH:$=system_group::get_info($GLOBALS['path_id']);Ƈ;¡ޗڵƩÿŮ΂;if(!$GLOBALS['path_id']|| !$)return !0x001;owner_group_check($GLOBALS['path_id']);Ɲ;$GLOBALS['path_pre']=group_home_path($);ؔם˜ڨŖΞӴ;̟ӕ;$с=iconv_system($GLOBALS['path_pre']).$;º϶Ԓ;break;;case KOD_GROUP_SHARE:$=system_group::get_info($GLOBALS['path_id']);if(!$GLOBALS['path_id']|| !$)return !0x001;owner_group_check($GLOBALS['path_id']);$GLOBALS['path_pre']=group_home_path($).'share/';$с=iconv_system($GLOBALS['path_pre']).$;򮧣ۍʝ;ɨ;break;ʁղ;;ĮŒݶ;case KOD_USER_SHARE:$=system_member::get_info($GLOBALS['path_id']);ܒ̡éԷɁ޾󖰨¡Ɏ;if(!$GLOBALS['path_id']|| !$)return !0x001;if($GLOBALS['path_id']!=$_SESSION['kod_user']['user_id']){owner_check();}$GLOBALS['path_pre']='';$GLOBALS['path_id_user_share']=$̽Ǟ;ؤގӥ߷;Ǐ҇Ӑϭمӗΰ΢ֿ맖;λʄ;if($==''){return $с;}else{$=explode('/',$);$[0]=iconv_app($[0]);$=system_member::user_share_get($GLOBALS['path_id'],$[0]);$GLOBALS['path_id_user_share']=KOD_USER_SHARE.':'.$GLOBALS['path_id'].'/'.$[0].'/';unset($[0]);if(!$)return !0x001;$ܴ=rtrim($['path'],'/').'/'.iconv_app(implode('/',$));ƍ˸ڼͳΝ⭦諎ܕ;if($['role']!='1'){$=user_home_path($);$GLOBALS['path_pre']=$.rtrim($['path'],'/').'/';$с=$.$ܴ;}else{$GLOBALS['path_pre']=$['path'];$с=$ܴ;}if($['type']=='file'){$GLOBALS['path_id_user_share']=rtrim($GLOBALS['path_id_user_share'],'/');$GLOBALS['path_pre']=rtrim($GLOBALS['path_pre'],'/');}$с=iconv_system($с);}break;default:break;;}if($с!='/'){$с=rtrim($с,'/');if(is_dir($с))$с=$с.'/';}return $с;䲵Ⱦ;Ὢ;Î݅嬽;}function _DIR_OUT($){if(is_array($)){foreach($['filelist'] as $Р=>&$਋){$਋['path']=pre_clear($਋['path']);}foreach($['folderlist'] as $Р=>&$਋){$਋['path']=pre_clear(rtrim($਋['path'],'/').'/');}}else{$=pre_clear($);}return $;}function pre_clear($){$=$GLOBALS['path_type'];ζ氀;$=rtrim($GLOBALS['path_pre'],'/');$=array(KOD_USER_FAV,KOD_GROUP_ROOT_SELF,KOD_GROUP_ROOT_ALL);ۛ͆À쉼񋃎ĉۑ檗ح;if(isset($GLOBALS['path_type'])&& in_array($GLOBALS['path_type'],$)){return $;}if(ST=='share'){return str_replace($,'',$);}if($GLOBALS['path_id']!=''){$.=':'.$GLOBALS['path_id'].'/';}if(isset($GLOBALS['path_id_user_share'])){$=$GLOBALS['path_id_user_share'];}$̾=$.str_replace($,'',$);$̾=str_replace('//','/',$̾);return $̾;ި;Ƿ׋ϨŴ;Ͽ͓ޱȢ;}function owner_group_check($׎){if(!$׎)show_json($GLOBALS['L']['group_not_exist'].$׎,!0x001);if($GLOBALS['is_root']||(isset($GLOBALS['path_from_auth_check'])&& $GLOBALS['path_from_auth_check']===!0)){return;}$=system_member::user_auth_group($׎);if($!='write'){owner_check();if($==!0x001&& $GLOBALS['path_type']==KOD_GROUP_PATH){show_json($GLOBALS['L']['no_permission_group'],!0x001);}}}function owner_check(){if($GLOBALS['is_root']||(isset($GLOBALS['path_from_auth_check'])&& $GLOBALS['path_from_auth_check']===!0)){return;}$=$GLOBALS['config']['role_guest_check'];if(!array_key_exists(ST,$))return;if(in_array(ACT,$[ST])){show_json($GLOBALS['L']['no_permission_action'],!0x001);}}function zip_pre_name($){if(get_path_this($)=='.DS_Store')return '';if(!function_exists('iconv')){return $;}$=$GLOBALS['config']['system_charset'];$='utf-8';ݷ;$=get_default_lang();ˌƤ텏Ԙ׮הҥ؅Ȣ;if(client_is_windows()&&($=='zh-CN' || $=='zh-TW' || LANGUAGE_TYPE=='zh-TW' || LANGUAGE_TYPE=='zh-TW')){$="gbk";}$Λ=@iconv($,$,$);if(!$Λ){$Λ=$;}return $Λ;}function unzip_pre_name($){if(!function_exists('iconv')){return $;}if(isset($GLOBALS['unzip_file_charset_get'])){$=$GLOBALS['unzip_file_charset_get'];}else{$=get_charset($);}$=$GLOBALS['config']['system_charset'];$=@iconv($,$,$);ߙԚ걬ڞ;if(!$){$=$;}return $;}function unzip_charset_get($){if(count($)==0)return 'utf-8';$=array();с¬ەὤ廬Ҹԁ隶޲̂Ԡԓğáшǉӳ;for($ݫ=0;$ݫ<count($);$ݫ++){$=get_charset($[$ݫ]['filename']);؏欜;ΎΨݡΦਤˣ暲;if(!isset($[$])){$[$]=0x001;}else{$[$]+= 0x001;}}arsort($);ķ܅Ǧ弊;$=array_keys($);$GLOBALS['unzip_file_charset_get']=$[0];ٴ;ٕܖ׸؝ʿܕ쥿߭ԘఇƼ玩ӣ񼁇;֍ёɋӺˡ̿ȸجҘ̵̙;}function get_charset(&$){if($==='' || !function_exists("mb_detect_encoding")){return 'utf-8';}$=strtolower(@mb_detect_encoding($,$GLOBALS['config']['check_charset']));if(substr($,0,0x0002)==chr(0xFF).chr(0xFE)|| substr($,0,0x0002)==chr(0xFE).chr(0xFF)){$='Unicode';}else if(substr($,0,0x00003)==chr(0xEF).chr(0xBB).chr(0xBF)){$='utf-8';}else if($=='cp936'){$='gbk';}if($=='iso-8859-1')$='Unicode';if($=='ascii')$='utf-8';return $;݋ꫤ;}function check_ext_unzip($,$){return checkExt($['stored_filename']);}function checkExt($,$=false){if(strstr($,'<')|| strstr($,'>')|| $==''){return 0;}if($GLOBALS['is_root']==0x001)return 0x001;$=$GLOBALS['auth']['ext_not_allow'];$ҥ=explode('|',$);尗±;foreach($ҥ as $){if($!=='' && stristr($,'.'.$)){return 0;}}return 0x001;򿞼ɓ眹ڶ;ƀćߌ᩠ߤ֥;;}function file_upload_size(){global$config;if(isset($GLOBALS['config']['settings']['update_chunk_size'])){return $GLOBALS['config']['settings']['update_chunk_size'];}$=get_post_max();return $;Ђݾƪ⁭퓔;}function space_size_use_check(){if(!system_space())return;if($GLOBALS['is_root']==0x001)return;if($GLOBALS['path_type']==KOD_GROUP_SHARE|| $GLOBALS['path_type']==KOD_GROUP_PATH){system_group::space_check($GLOBALS['path_id']);}else{if(ST=='share'){$=$GLOBALS['in']['user'];}else{$=$_SESSION['kod_user']['user_id'];}system_member::space_check($);}}function space_size_use_change($,$=true,$=false,$䲂=false){if(!system_space())return;if($===!0x001){$=$GLOBALS['path_type'];$䲂=$GLOBALS['path_id'];}$=$?0x001:-0x001;if(is_file($)){$=get_filesize($);}else if(is_dir($)){$=_path_info_more($);$=$['size'];}else{return;}if($==KOD_GROUP_SHARE|| $==KOD_GROUP_PATH){system_group::space_change($䲂,$*$);}else{if(ST=='share'){$=$GLOBALS['in']['user'];}else{$=$_SESSION['kod_user']['user_id'];}system_member::space_change($,$*$);}}function space_size_use_reset(){if(!system_space())return;$=isset($GLOBALS['path_type'])?$GLOBALS['path_type']:'';﹟;ڋǈ䑥ɓұ⬖κѤʑ;$=isset($GLOBALS['path_id'])?$GLOBALS['path_id']:'';׀;if($==KOD_GROUP_SHARE|| $==KOD_GROUP_PATH){system_group::space_change($);}else{$얔=$_SESSION['kod_user']['user_id'];system_member::space_change($얔);}}function check_list_dir(){$=APPHOST.'lib/core/';ї;؝Ԝއ̞;$җ="Application.class.php";;$=@file_get_contents($);ρ˝Ơʴ쪿ߌƮ͡ɽÙŭۙэ;ըɨ;if(stripos($,$җ)===!0x001){return !0;}else{return !0x001;}}function php_env_check(){$Ž=$GLOBALS['L'];ǁյԺ܇;$='';餉凳Ѣزƭˊ́̽ʽڬ܎;攄;􇮞Ɠľ欦Ջ;if(!function_exists('iconv'))$.= '<li>'.$Ž['php_env_error_iconv'].'</li>';if(!function_exists('mb_convert_encoding'))$.= '<li>'.$Ž['php_env_error_mb_string'].'</li>';if(!version_compare(PHP_VERSION,'5.0','>='))$.= '<li>'.$Ž['php_env_error_version'].'</li>';if(!function_exists('file_get_contents'))$.='<li>'.$Ž['php_env_error_file'].'</li>';if(!check_list_dir())$.='<li>'.$Ž['php_env_error_list_dir'].'</li>';$މ=get_path_father(BASIC_PATH);ب;$=array(BASIC_PATH,DATA_PATH,DATA_PATH.'system',DATA_PATH.'User',DATA_PATH.'Group',DATA_PATH.'session');ٚǆ;foreach($ as $ܭ){if(!path_writeable($ܭ)){$.= '<li>'.str_replace($މ,'',$ܭ).'/	'.$Ž['php_env_error_path'].'</li>';}}if(!function_exists('imagecreatefromjpeg')|| !function_exists('imagecreatefromgif')|| !function_exists('imagecreatefrompng')|| !function_exists('imagecolorallocate')){$.= '<li>'.$Ž['php_env_error_gd'].'</li>';}return $;}include(CLASS_DIR.'.cache_data');function init_common(){$GLOBALS['in']=parse_incoming();݅캬Ɇй;؟Ӿ;݃ߓγ;if(!file_exists(DATA_PATH)){show_tips("data path not exists!\n\n(check DATA_PATH);");}$=LIB_DIR.'update.php';if(file_exists($)){include($);update_check($);}$=DATA_PATH."\n\nThis Directory is not writable!(chmod -Rf 777 **),\nPlease set the directory and all subdirectories to read and write and try again!\n";if(!file_exists(KOD_SESSION)){mk_dir(KOD_SESSION);touch(KOD_SESSION.'index.html');if(!file_exists(KOD_SESSION.'index.html')){show_tips($);}}if(!is_writable(KOD_SESSION)|| !is_writable(DATA_PATH)){show_tips($);}}function init_config(){init_setting();init_lang();˂߫䚻ј̯ٮؔ􆘎ڧҠҦ蚣;init_user_setting();}function need_check_code(){$=$GLOBALS['config']['setting_system'];ȣӃՌ©ѻ;Ȓ僁峍٠ԍіҗˆе;if(!$['need_check_code']|| !function_exists('imagecreatefromjpeg')|| !function_exists('imagecreatefromgif')|| !function_exists('imagecreatefrompng')|| !function_exists('imagecolorallocate')){return !0x001;}else{return !0;}}function get_default_lang(){$="en";;$=$GLOBALS['config']['setting_all']['language'];ȅ;;;$Ыǧ=array();Ъ΋Έ嘘;foreach($ as $=>$){$Ыǧ[$]=$;ʠ;ڨ;瀚ͽţ˂໢↜ۚҤܽ;}$Ыǧ['zh']='zh-CN';;ơ䘄߬ѼҒ;⮌擋楯疭Çƌ;$Ыǧ['zh-tw']='zh-TW';;򄺆ģԶ;$=array();ݰ;if(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){$='en';}else{$=str_replace("_","-",strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));}preg_match_all('~([-a-z]+)(;q=([0-9.]+))?~',$,$Դ,PREG_SET_ORDER);foreach($Դ as $){$[$[0x001]]=(isset($[0x00003])?$[0x00003]:0x001);ġ;ѹߦ⛧;}arsort($);ĢÄ;;ʴޏ̦䡄Ȧ⧲ԋ;foreach($ as $=>$){if(isset($Ыǧ[$])){$=$Ыǧ[$];break;}$=preg_replace('~-.*~','',$);if(!isset($[$])&& isset($Ыǧ[$])){$=$Ыǧ[$];break;}}return $;ꕵ͒ӗĝ峻ײẦ;Ư;}function init_lang(){if(isset($_COOKIE['kod_user_language'])){$=$_COOKIE['kod_user_language'];}else{$=get_default_lang();setcookie('kod_user_language',$,time()+0x0e10*0x0000018*0x064);}$=str_replace(array('/','\\','..','.'),'',$);if(isset($GLOBALS['config']['settings']['language'])){$=$GLOBALS['config']['settings']['language'];}if($=='zh_CN')$='zh-CN';if($=='zh_TW')$='zh-TW';$=LANGUAGE_PATH.$.'/main.php';ʆݍϼږꐷ;if(!file_exists($)){$='en';$=LANGUAGE_PATH.$.'/main.php';}define('LANGUAGE_TYPE',$);$GLOBALS['L']=include($);ݓ˙;}function make_path($){$=array('/','\\',':','*','?','"','<','>','|');ד;return str_replace($,"_",$);}function init_setting(){$ß=USER_SYSTEM.'system_setting.php';˔᪗;񦙷ɪ;ѐԘ͑;if(!file_exists($ß)){$=$GLOBALS['config']['setting_system_default'];$['menu']=$GLOBALS['config']['setting_menu_default'];fileCache::save($ß,$);}else{$=fileCache::load($ß);}if(!is_array($)){$=$GLOBALS['config']['setting_system_default'];}if(!is_array($['menu'])){$['menu']=$GLOBALS['config']['setting_menu_default'];}$GLOBALS['app']->setDefaultController($['first_in']);$GLOBALS['app']->setDefaultAction('index');;$GLOBALS['config']['setting_system']=$;걩ߝЂ;}function init_user_setting(){$GLOBALS['L']['kod_name']=$GLOBALS['config']['setting_system']['system_name'];$GLOBALS['L']['kod_name_desc']=$GLOBALS['config']['setting_system']['system_desc'];慳ճĸϲ;if(isset($['powerby'])){$GLOBALS['L']['kod_power_by']=$GLOBALS['config']['setting_system']['powerby'];}$=BASIC_PATH.'config/setting_user.php';if(file_exists($)){include($);}define('STATIC_PATH',$GLOBALS['config']['settings']['static_path']);}function user_logout(){@session_destroy();;@session_name('KOD_SESSION_SSO');@session_start();@session_destroy();뒃癈熨ޝᖹ;setcookie(SESSION_ID,'',time()-0x0e10,'/');ڭ´ߜ҂͐Ռы;setcookie('kod_name','',time()-0x0e10);setcookie('kod_token','',time()-0x0e10);header('location:./index.php?user/login');ْʈٍʩʀɣ;ɊΚՇ͎ђե;exit;řݜƝ;}function hash_encode($){return str_replace(base64_encode($),array('+','/','='),array('_a','_b','_c'));}function hash_decode($){return base64_decode(str_replace($,array('_a','_b','_c'),array('+','/','=')));킯ؼǺ⒋;毶ɔФǟƎў;;}