KodExplorer/controller/system_group.class.php

1 line
6.0 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>€¿µ¸ñ®ôÐöé̳اÅî„Ù猹…ÕÅÄ„áÜ€¹Å€ùú¹ëª®¼¡™ŠÕò±œá¶õÊïϚõ•ž×ñž;}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>¦¯¡éÏ;}}}