KodExplorer/controller/system_group.class.php

1 line
5.9 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();$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($ ¸¶™ù));}}}