1 line
6.0 KiB
PHP
Executable File
1 line
6.0 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>€¿µ¸ñ®ôÐöé̳اÅî„Ù猹…ÕÅÄ„áÜ€¹Å€ùú¹ëª®¼¡™ŠÕò±œá¶õÊïϚõ•ž×ñž;}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($·){$<24>³=self::load_data();<EFBFBD>ˆ¶€¡ÀÕ”òñö©çÂ옓‡<EFBFBD>¨¦çšÅùÒ䇇¾<EFBFBD>åÆ·åè÷»ýëô––¸„¯ËŒ¾ó²¦<EFBFBD>÷¡áݨé<EFBFBD>ªÏäáµÍÚñËÇŸ;return $<24>³->get($·);<EFBFBD>ùáåÆí¤»¡ÊÊšë÷•—–Àçú£<EFBFBD>Èþ<EFBFBD>•Æ¯×¤åÒ‡;}public static function space_change($™ôð,$–¼ °=false){$Ω=self::load_data();$¿€Î»¤=$Ω->get($™ôð);<EFBFBD>ûšê¬;if(!is_array($¿€Î»¤)){show_json($this->L["data_not_full"],!1);}if($–¼ °===!1){$<24>’Å—Þ=_path_info_more(GROUP_PATH.$¿€Î»¤['path'].'/');$ŒÐµ£=$<24>’Å—Þ['size'];if(isset($¿€Î»¤['home_path'])&& file_exists(iconv_app($¿€Î»¤['home_path']))){$<24>’Å—Þ=_path_info_more(iconv_app($¿€Î»¤['home_path']));$ŒÐµ£+= $<24>’Å—Þ['size'];}}else{$ŒÐµ£=floatval($¿€Î»¤['config']['size_use'])+floatval($–¼ °);}$¿€Î»¤['config']['size_use']=$ŒÐµ£<0?0:$ŒÐµ£;<EFBFBD>¦þ÷<EFBFBD>¿÷Üú<EFBFBD>É€ÀÅ›«ñŽ»…ÔÒä´ß¶ê„ÄÂÙü;$Ω->set($™ôð,$¿€Î»¤);<EFBFBD>ö˜íÓ“‹<EFBFBD>”Ëã¯÷Ö½³Ü“‡ÂÇçø³ë¾õŻߟ°Ö¸žªÌ©Èàõ<EFBFBD>í„Ρàᩤª‘<EFBFBD>ÝýÛÔ×´ãÈ‹œæ¶è;}public static function space_check($þ){$‡¬Û=self::load_data();<EFBFBD>—“<EFBFBD>Á·¸ÒԖбê•ÉŸø;$«=$‡¬Û->get($þ);if(!is_array($«)){show_json($this->L["data_not_full"],!1);}$ဋáÊ=floatval($«['config']['size_use']);$Ž=floatval($«['config']['size_max']);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(),));<EFBFBD>Þá‹—´à®†’š›Üº•îå«èÈ«ôª;$this->sql->reset($À);<EFBFBD><EFBFBD>‘ùî±ÍΔ;}public static function _filter_list($æɺ•,$Ì°ë©='path'){if($GLOBALS['is_root'])return $æɺ•;foreach($æɺ• as $<24>™Ñƒ=>&$Ø÷){unset($Ø÷[$Ì°ë©]);<EFBFBD>þ;}return $æɺ•;<EFBFBD>ÜÅÇ«Ù¡’¤Û¨ó©ØàÒÄáì—<EFBFBD>ï²;}public function get(){$èø¹ê÷=self::_filter_list($this->sql->get());show_json($èø¹ê÷,!0);<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().'';<EFBFBD>¶à×´‰ù¢ Š’ÓóûÌæÄÓä·×©ñ‡ÇÎÈŠ†³ÁçöÙ<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(),);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);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>¹¥‹<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);<EFBFBD>ïŒàß<EFBFBD>œ†œ¬ÇæêÎãÞâàÑ<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']);<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'));<EFBFBD>³²ý<EFBFBD>ÖÇ––¦ÒÕø‡¢§‘‰<EFBFBD>îúéÅ©Ôȯ匊ÉÀ½ÇÁ”<EFBFBD>׫¶ª‚°²¤×à¶àí¥ÜØꆴ¶;system_member::group_remove_user_update($ÜÖéƒ["group_id"]);$this->sql->remove($this->in['group_id']);<EFBFBD>‚ý¥Ã“µœ¿ìÆÁ<EFBFBD>ùåõÚ<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']);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);}$¿ðÛ…<C39B>=explode(',',$¨Ê¬['children']);if($¿ðÛ…<C39B>[0]==''){unset($¿ðÛ…<C39B>[0]);}if($¦É){foreach($â ÙÇÅ as $Šš¶Ð=>$‚ýâ){$¿ðÛ…<C39B>[]=$‚ýâ;}}else{foreach($¿ðÛ…<C39B> as $Šš¶Ð=>$‚ýâ){if(in_array($‚ýâ,$â ÙÇÅ))unset($¿ðÛ…<C39B>[$Šš¶Ð]);}}$ÇÙ=implode(',',$¿ðÛ…<C39B>);if($ÇÙ!=$¨Ê¬['children']){$¨Ê¬['children']=$ÇÙ;$this->sql->set($¨Ê¬['group_id'],$¨Ê¬);}}}private function _initDir($†«’í){$²=array('home','data');<EFBFBD>Öàç–ÒÜᩦüàöÀâô¤Œ½ý¥“…ѦóàÙ¼¸Ó”š»ªì€ÆϪíÌ‹äŽíÙ²ù˜± ¬·ñÒ«ÓçŒ<EFBFBD>û§½§•½î;$èܲó=$this->config['setting_system']['new_group_folder'];<EFBFBD>œóݵ¦ýáÝ﵉ÃâñÐãîø¡—Žß†óÈ㧽¦è ÃÝþø„üÚáí<EFBFBD>ë²ó;$„×Ìü=explode(',',$èܲó);<EFBFBD>ØꀢΨßõ;$†«’í=GROUP_PATH.$†«’í.'/';mk_dir($†«’í);foreach($² as $){mk_dir($†«’í.$);<EFBFBD>ÖìŸÃŸ”¡£ëî¡å;}foreach($„×Ìü as $){mk_dir($†«’í.'home/'.iconv_system($));<EFBFBD>¿®á<EFBFBD>×Á…éþÙÄñÎÂ<EFBFBD>¦¯¡éÏ;}}} |