KodExplorer/controller/system_group.class.php

1 line
5.7 KiB
PHP
Executable File
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php class system_group extends Controller{public static $static_sql=null;private $sql;function __construct(){parent::__construct();$this->sql=self::load_data();<EFBFBD>Ê<EFBFBD>ó†ÞŒË¯Ž¦Œ˜ýþý×ôÀ¨ž<EFBFBD>±œþÆúΈ÷ªÒùžØØ«¤‰ºË•ÓÉ•Ò¡Š“Ê©¤ûŤÂ۠㘽·“Ü눵ôÃ;$this->_init();}public static function load_data(){if(is_null(self::$static_sql)){self::$static_sql=system_group_data();}return self::$static_sql;}public static function get_info($˜){$ êì=self::load_data();return $ êì->get($˜);<EFBFBD>£´šÇööçŠÚ<EFBFBD>Ç“”¤¤<EFBFBD>­ÚõðÜ<EFBFBD>Ѝ¢ôÌôΡ˜ƒ;}public static function space_change($àú³,$…ŽÊ=false){$¢ßðÆ=self::load_data();<EFBFBD>×<EFBFBD>ýÙš§û<EFBFBD>½;$…<>ë=$¢ßðÆ->get($àú³);if(!is_array($…<>ë)){show_json($this->L["data_not_full"],!1);}if($…ŽÊ===!1){=_path_info_more(GROUP_PATH.$…<>ë['path'].'/');$ŒÛÈ‘ê=['size'];if(isset($…<>ë['home_path'])&& file_exists(iconv_app($…<>ë['home_path']))){=_path_info_more(iconv_app($…<>ë['home_path']));$ŒÛÈ‘ê+= ['size'];}}else{$ŒÛÈ‘ê=floatval($…<>ë['config']['size_use'])+floatval($…ŽÊ);}$…<>ë['config']['size_use']=$ŒÛÈ‘ê<0?0:$ŒÛÈ‘ê;<EFBFBD>ÐÓÖîõ¯€ô‰œ†«Úаç¼;$¢ßðÆ->set($àú³,$…<>ë);<EFBFBD>ΆÁ˜—¬­öº¢ÇŽù·…©¸ù³Ó—ºþñ°ÚÈ€Ó®ÏÙïèñ<EFBFBD>é×¹±æ³éëÜ¢åõýËõïÖ§Ê §ŸÎ÷ù¿àìÜöÖµ±‰œåòˆ;}public static function space_check($–îÔ){=self::load_data();=->get($–îÔ);<EFBFBD>˜ÒÈçʨ«°…£‡»;if(!is_array()){show_json($this->L["data_not_full"],!1);}$<24>×»„=floatval(['config']['size_use']);$þšÏÓ=floatval(['config']['size_max']);if($þšÏÓ!=0&& $þšÏÓ*0x0000040000000<$<24>×»„){show_json($GLOBALS['L']['space_is_full'],!1);}}private function _init(){if(count($this->sql->get())>0)return;$ó«›=array('1' =>array('group_id' =>'1','name' =>'root','parent_id' =>'','children' =>'','config' =>array('size_max' =>floatval(1.5),'size_use' =>floatval(0x00000400*0x00000400)),'path' =>hash_path(),'create_time'=> time(),));<EFBFBD>…©ŽíóÑ œÄ‰×šš°ÖŸÕ¹à©áŸž<EFBFBD>»ã<EFBFBD><EFBFBD><EFBFBD>à¢;$this->sql->reset($ó«›);<EFBFBD>쌈¼Ø§Í¯á¯ØÄÎ÷у¶Œ•ÕÅû¬èßßÐÌëÓÔ¨­ü;}public static function _filter_list($ÜÞ¦¶£,$®õ<C2AE>²¬='path'){if($GLOBALS['is_root'])return $ÜÞ¦¶£;foreach($ÜÞ¦¶£ as =>&$©Ý·¦Š){unset($©Ý·¦Š[$®õ<C2AE>²¬]);}return $ÜÞ¦¶£;}public function get(){$ðÓÖÅ©=self::_filter_list($this->sql->get());show_json($ðÓÖÅ©,!0);<EFBFBD>φ<EFBFBD>†ª”µ çͤ°¿ÍŽöó˜—ùƒ‰ÍÙÏ÷Ùžѓ¥ï™;}public function add(){if(!isset($this->in['name'])|| !isset($this->in['parent_id'])|| !isset($this->in['size_max']))show_json($this->L["data_not_full"],!1);$„Ïïš=$this->sql->get_max_id().'';$¾èý=array('group_id' =>$„Ïïš,'name' =>rawurldecode($this->in['name']),'parent_id' =>$this->in['parent_id'],'children' =>'','config' =>array('size_max' =>floatval($this->in['size_max']),'size_use' =>floatval(0x00000400*0x00000400)),'path' =>hash_path($this->in['name']),'create_time'=> time(),);if(isset($this->in['home_path'])){$¾èý['home_path']=_DIR(rawurldecode($this->in['home_path']));if(!file_exists($¾èý['home_path'])){show_json($this->L['not_exists'],!1);}$¾èý['home_path']=iconv_app($¾èý['home_path']);}else{unset($¾èý['home_path']);<EFBFBD><EFBFBD>;}$this->_parent_child_change($¾èý,!0);<EFBFBD>ÊïæÂÊ;if($this->sql->set($„Ïïš,$¾èý)){$this->_initDir($¾èý['path']);show_json($this->L['success']);}show_json($this->L['error'],!1);}public function edit(){if(!$this->in['group_id'])show_json($this->L["data_not_full"],!1);$áœ=$this->sql->get($this->in['group_id']);if(!is_array($áœ)){show_json($this->L['not_exists'],!1);}if(isset($this->in['name'])){$áœ['name']=rawurldecode($this->in['name']);}if(isset($this->in['size_max'])){$áœ['config']['size_max']=floatval($this->in['size_max']);}if(isset($this->in['parent_id'])&& $áœ['parent_id']!='' && $this->in['parent_id']!=$áœ['parent_id']){=explode(',',$áœ['children']);if(in_array($this->in['parent_id'],)){show_json($this->L['current_has_parent'],!1);}self::space_change($this->in['group_id']);$this->_parent_child_change($áœ,!1);<EFBFBD>§Ç¬ß‡ëÉ…ùÂú;$áœ['parent_id']=$this->in['parent_id'];<EFBFBD>÷é¡ÂÙˆ;$this->_parent_child_change($áœ,!0);}if(isset($this->in['home_path'])){$áœ['home_path']=_DIR(rawurldecode($this->in['home_path']));if(!file_exists($áœ['home_path'])){show_json($this->L['not_exists'],!1);}$áœ['home_path']=iconv_app($áœ['home_path']);}else{unset($áœ['home_path']);}if($áœ!=$this->sql->get($this->in['group_id'])){$this->sql->set($this->in['group_id'],$áœ);}show_json($this->L['success']);}public function del(){if(!isset($this->in['group_id']))show_json($this->L["data_not_full"],!1);if(strlen($this->in['group_id'])<=0x001)show_json($this->L['default_user_can_not_do'],!1);$çÁð=$this->sql->get($this->in['group_id']);<EFBFBD>Æàï<EFBFBD>ŽÐùœóݗﲡç<EFBFBD>«÷˱<EFBFBD>þšß¹Ñ<EFBFBD>©àžúö;$this->_parent_child_change($çÁð,!1);$this->sql->set(array('parent_id',$çÁð["group_id"]),array('parent_id','1'));system_member::group_remove_user_update($çÁð["group_id"]);$this->sql->remove($this->in['group_id']);if(strlen($çÁð['path'])!=0){del_dir(GROUP_PATH.$çÁð['path'].'/');show_json($this->L['success']);}show_json($this->L['error'],!1);}private function _parent_child_change($«ý§Ìæ,$<24>½){if(!is_array($«ý§Ìæ)){show_json($this->L['not_exists'],!1);}if($«ý§Ìæ['parent_id']==0x001){return;}$ÄÛÚÞ=$«ý§Ìæ['group_id'];$Ëéê=explode(',',$«ý§Ìæ['children']);if($Ëéê[0]==''){unset($Ëéê[0]);}$Ëéê[]=$«ý§Ìæ['group_id'];while(strlen($«ý§Ìæ['group_id'])>0x0002){$«ý§Ìæ=$this->sql->get($«ý§Ìæ['parent_id']);if(!is_array($«ý§Ìæ)){show_json($this->L['not_exists'],!1);}$¯œš«”=explode(',',$«ý§Ìæ['children']);if($¯œš«”[0]==''){unset($¯œš«”[0]);}if($<24>½){foreach($Ëéê as $Á§Á=>$ÓÀÞ){$¯œš«”[]=$ÓÀÞ;}}else{foreach($¯œš«” as $Á§Á=>$ÓÀÞ){if(in_array($ÓÀÞ,$Ëéê))unset($¯œš«”[$Á§Á]);}}$§¤=implode(',',$¯œš«”);if($§¤!=$«ý§Ìæ['children']){$«ý§Ìæ['children']=$§¤;$this->sql->set($«ý§Ìæ['group_id'],$«ý§Ìæ);}}}private function _initDir($⌀){$çßù=array('home','data');$庅=$this->config['setting_system']['new_group_folder'];<EFBFBD>û¶¯×Þñ<EFBFBD>²²íÒÚ“„õµùõ°®;$–éÅ=explode(',',$庅);<EFBFBD>ó꟤ÂþѱÉÀ…¥ÓŠ»ÊÒ€•ȱĉǮÏÀƒ¸´íØÙ±×ºÄ<EFBFBD>ß™šœãµîäË·<EFBFBD>ÁÞ¿;$⌀=GROUP_PATH.$⌀.'/';mk_dir($⌀);foreach($çßù as $ÊÔ±){mk_dir($⌀.$ÊÔ±);}foreach($–éÅ as $ÊÔ±){mk_dir($⌀.'home/'.iconv_system($ÊÔ±));}}}