1 line
5.9 KiB
PHP
Executable File
1 line
5.9 KiB
PHP
Executable File
<?php class system_group extends Controller{public static $static_sql=null;private $sql;function __construct(){parent::__construct();$this->sql=self::load_data();$this->_init();<EFBFBD>ÒÞà“÷õÎ<EFBFBD>¸ö§žÁ⪜ÕÎëœÊ´¡‚€Â…½½èµ‘Ç—¤¿<EFBFBD>óÁÆêéåÌ<EFBFBD>ɣߵÀªêá¬ê¥²¨â›Þôãõš¤„ŽåËùб§<EFBFBD>Â;}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();<EFBFBD>§íȆâ¬üý;return $ä->get($Á¢§‚Í);<EFBFBD>·Î;}public static function space_change($‰,$¯=false){$á=self::load_data();<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:$²;$á->set($‰,$ïÍŒ);}public static function space_check($ÊÅ){$·×è„=self::load_data();<EFBFBD><EFBFBD>ÏÀ·†°éõþö§µßÈúæú¹ô‰Û¿Î³÷§œû–áô¥±µÜ¸æÇ¯æ¿Ö<EFBFBD>ŸŸ™†›Òú¥®»óá´;$þ°=$·×è„->get($ÊÅ);if(!is_array($þ°)){show_json($this->L["data_not_full"],!1);}$¥Ø“Û=floatval($þ°['config']['size_use']);$ËÃý=floatval($þ°['config']['size_max']);<EFBFBD>ÒÈÜòáâ<EFBFBD>´Þ´ã›©ÅÏÆÄ<EFBFBD>ù¦;if($ËÃý!=0&& $ËÃý*0x0000040000000<$¥Ø“Û){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(),));$this->sql->reset($Ò¹);}public static function _filter_list($È,$ƒ='path'){if($GLOBALS['is_root'])return $È;foreach($È as $ÅÕ¼¢É=>&$†Ù){unset($†Ù[$ƒ]);<EFBFBD>¸‚¹ýÒ€ÃÓùê;}return $È;<EFBFBD><EFBFBD>Ö¬ÉÞ¯½¤†úÇϚͪ§¶;}public function get(){$¦‰óêÝ=self::_filter_list($this->sql->get());<EFBFBD>¼úÛ”¨¦ó×ä™Ýßà®ù¯Øéä“‘›‡·¥û£„êøÞ¨ô»½<EFBFBD>á±ôÇÊÓ§¬‚¢ÜÛŒÁî;show_json($¦‰óêÝ,!0);}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().'';<EFBFBD>óç‡è¤Ä‡‡öüÎÂ;$õîÓ™=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(),);<EFBFBD>ŽŸÃì—›ðŠ•ùè‰áð;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>úެ÷ÜîÉ;}$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']);<EFBFBD>¼žã«Ê²¿…¢˜¨ŒÆº•Ù¶¨Î¢®ËŰ֕«¿Ô;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);$¢<>‹Ïù['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']);<EFBFBD>œìˤÕ<EFBFBD>;}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']);$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"]);<EFBFBD>³ÝÌâŒ÷éÏϰç˜ôô´âÀظѧ<EFBFBD>ÕÉó“ùúãï̘͚ûÙ’å©â–’úŒˆ¯îɉ§›±¸ñú¬…ô§é;$this->sql->remove($this->in['group_id']);<EFBFBD>³<EFBFBD>þ;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($¢,$·…üÊ){if(!is_array($¢)){show_json($this->L['not_exists'],!1);}if($¢['parent_id']==0x001){return;}$±÷œº=$¢['group_id'];$¸ì=explode(',',$¢['children']);<EFBFBD>†°ÝšÃ¢žö²ž…Ô„½Ú<EFBFBD>ˆÛ‹Û<EFBFBD>ƒøÈ¤²µýÝž„Ž;if($¸ì[0]==''){unset($¸ì[0]);}$¸ì[]=$¢['group_id'];while(strlen($¢['group_id'])>0x0002){$¢=$this->sql->get($¢['parent_id']);<EFBFBD>¿ÔÇ·‡å¼Üêù·ìƒ”÷;if(!is_array($¢)){show_json($this->L['not_exists'],!1);}$¡ûÙê=explode(',',$¢['children']);if($¡ûÙê[0]==''){unset($¡ûÙê[0]);}if($·…üÊ){foreach($¸ì as $Œ¡=>$é¿){$¡ûÙê[]=$é¿;}}else{foreach($¡ûÙê as $Œ¡=>$é¿){if(in_array($é¿,$¸ì))unset($¡ûÙê[$Œ¡]);}}$ø¼=implode(',',$¡ûÙê);<EFBFBD>«ê³²Ñð<EFBFBD>¼ëÇ©ïÛ¢Ïýžªé¿¶‹Þ¡Ë‚š‰×½…ƒ©¹;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.$ú«Æ.'/';<EFBFBD>ÀêÇêÜêÖé‰;mk_dir($ú«Æ);<EFBFBD>…扅<EFBFBD>‘¹™¤šÃàÜÅçÞ•‘ùÖüÂÁÚ®™Ä·÷Àþý¨‰ƒµš¼Ï¿Ö“¡³ØŠ’î›<EFBFBD>řЇó;foreach($—<>â as $ ¸¶™ù){mk_dir($ú«Æ.$ ¸¶™ù);}foreach($¨à as $ ¸¶™ù){mk_dir($ú«Æ.'home/'.iconv_system($ ¸¶™ù));}}} |