KodExplorer/controller/system_member.class.php

1 line
9.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_member extends Controller{public static $static_sql=null;private $sql;function __construct(){parent::__construct();<EFBFBD>¨Óµ—;$this->tpl=TEMPLATE.'member/';$this->sql=self::load_data();}public static function load_data(){if(is_null(self::$static_sql)){self::$static_sql=system_member_data();}return self::$static_sql;}public static function get_info($®ˆ¾þ){=self::load_data();<EFBFBD>ÍÈÚ¾³†¾ÇâëˆÐð«øÄáàñß<EFBFBD>ùŸ<EFBFBD>ýÎæŒÐøÔ«·‰²öÐ;return ->get($®ˆ¾þ);<EFBFBD>Ô†àšçòúÙÒÔñšÓÀ<EFBFBD>ºÍí´¢™ë«ËâüáÆ×ÉÝ«µÆž±¡ñ¼õä×É¥ô…óâ¹û¦ÂȉÀ«Ð˜;}public static function space_change($ìö¢¢½,$ÔÞ³=false){=self::load_data();$ ¾Ý¥²=->get($ìö¢¢½);<EFBFBD>½†<EFBFBD><EFBFBD>Í²àæ©ÎÝËñœŽÆûÁ×ÑÚÀòšŸ˜Íàø—ž€¥¥<EFBFBD>òØñÙÀ¸Í²Ô;if(!is_array($ ¾Ý¥²)){show_json($this->L["data_not_full"],!1);}if($ÔÞ³===!1){$øÐžÑ=_path_info_more(USER_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();$×¹=$ù²->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);}}public static function group_remove_user_update($ûÝ){$Íü=self::load_data();<EFBFBD>€‰Œ²¸îÆáéøŒŠÐÅžò<EFBFBD>µà´±•œ€‰ñЉû—¼µ†ƒ˜ðü¤ûÎêšÐݧ†¾Ü½ÁŽÒÞŽåç<EFBFBD>ïñüˆ¯³Ž³Ë€°ïûþÚи¾Ö÷•º©;$™¸Î‚º=$Íü->get();<EFBFBD>ǤëÖ×·Ö‰§ÒˆƒéÙ»¨°´ÄÆî¨þŠâ¾þ‡¤‡Þû¿µ†æ‰Ž;foreach($™¸Î‚º as $óç¦<C3A7>=>$áàÊÐ){if(in_array($ûÝ,array_keys($áàÊÐ['group_info']))){unset($áàÊÐ['group_info'][$ûÝ]);$Íü->set($áàÊÐ['user_id'],$áàÊÐ);}}}public static function role_remove_user_update(){$<24>ÞÜÎÞ=self::load_data();<EFBFBD>€µ€;$놧=$<24>ÞÜÎÞ->get();<EFBFBD>éý¸;foreach($놧 as $”=>$øßºŠ´){if($øßºŠ´['role']==){$øßºŠ´['role']='';$<24>ÞÜÎÞ->set($øßºŠ´['user_id'],$øßºŠ´);}}}public static function user_auth_group($š”‘){$òŠÀö‹=self::load_data();<EFBFBD>âýòØ“…½ɪҳ£³î­ç¤Èü¶²ïÀòçÌéߘÍݦñ<EFBFBD>é„δ®¢èÒÕ×<EFBFBD>¾üÉ»³û¬ôî;=$òŠÀö‹->get($_SESSION['kod_user']['user_id']);<EFBFBD>§ÒåÎÄö¹ÈÆîöè×ɾ°Ëý­•¹áåÖ<EFBFBD>ù™ÚîóƒÁÙÒ‡Ñ<EFBFBD>ϘûÇ<EFBFBD>ÔÀ†Ý¾´òø…Þì†Ù†áÉùäÔ¸;=['group_info'];<EFBFBD>«Á˜½žœÁÒ<EFBFBD>ºè”šÖóÝü½ØâÉ­œÜÔâ¿•¥ëÖ½©ÙÜÅ;if(!is_array()){return !1;}if(isset([$š”‘])){return [$š”‘];}foreach( as $ÕÖ=>){$ï†äÍ„=system_group::get_info($ÕÖ);$¦æ=explode(',',$ï†äÍ„['children']);if(in_array($š”‘,$¦æ)){return [$ÕÖ];}}return !1;<EFBFBD>É©æ;}public static function _filter_list(,='path'){if($GLOBALS['is_root'])return ;foreach( as =>&$ï¨){unset($ï¨[]);<EFBFBD>¼áð¨Ó௸¯³ÛÕ;unset($ï¨['password']);<EFBFBD>”Ô‡ž””•ªßµ;}return ;}public static function get_user_at_group($¦à){$‰ÒƒÝ=self::load_data();$–âæ=self::_filter_list($‰ÒƒÝ->get());<EFBFBD>½ä;if($¦à=='0'){return $–âæ;}$ѹ=array();foreach($–âæ as $ïÎ){if(isset($ïÎ['group_info'][$¦à])){$ѹ[]=$ïÎ;}}return $ѹ;}public static function user_share_sql(){static $¼•;if(!is_array($¼•)){$¼•=array();}if(!isset($¼•[])){$¼‰³Æ=system_member::get_info();if(!isset($¼‰³Æ['path'])){return;}$·¤<C2B7>é=new fileCache(USER_PATH.$¼‰³Æ['path'].'/data/share.php');$¼•[]=$·¤<C2B7>é;}return $¼•[];<EFBFBD>­Õë“ø¾Ì£®œâµñ¬©Ëè³þ°<EFBFBD>·Ô ;}public static function user_share_list($<24>){$¿ÂÉ«Õ=self::user_share_sql($<24>);<EFBFBD>æ™ÀÉÏ×ÌÁ„õ<EFBFBD>í©<EFBFBD>ž¹ÄòÙæ„îÛÃ;$¦ï=$¿ÂÉ«Õ->get();if($<24>==$_SESSION['kod_user']['user_id']){return $¦ï;}foreach($¦ï as $Ú¬Ñôì=>&$ÄÄ){unset($ÄÄ['share_password']);}return $¦ï;}public static function user_share_get($†ÉÞ”·,){$ÃæÊž=self::user_share_sql($†ÉÞ”·);<EFBFBD>ª¿ÐȺÜ;return $ÃæÊž->get('name',);<EFBFBD>⨨<EFBFBD>ñð±ªúÓ;}public function get($»ÌÜ='0'){$=self::get_user_at_group($»ÌÜ);<EFBFBD>«†°óÁ<EFBFBD>éÎßÌ÷öô‰”çúÆ;show_json($);}public function add(){if(!isset($this->in['name'])|| !isset($this->in['password'])|| !isset($this->in['role'])|| !isset($this->in['group_info'])|| !isset($this->in['size_max']))show_json($this->L["data_not_full"],!1);$›”µÖá=trim(rawurldecode($this->in['name']));$üþ—«=rawurldecode($this->in['password']);$ÜŸ=json_decode(rawurldecode($this->in['group_info']),!0);<EFBFBD>¯ÊÕ§Á˱;if(!is_array($ÜŸ)){show_json($this->L["system_member_group_error"],!1);}if($this->sql->get(array('name',$›”µÖá))){show_json($this->L['error_repeat'],!1);}if(!$GLOBALS['is_root']&& $this->in['role']=='1'){show_json($this->L['group_role_error'],!1);}$³¬<C2B3>Æ=array();if(isset($this->in['isImport'])){$¸Û=explode("\n",$›”µÖá);foreach($¸Û as $<24>½íò){if(trim($<24>½íò)!=''){$³¬<C2B3>Æ[]=trim($<24>½íò);}}}else{$³¬<C2B3>Æ[]=$›”µÖá;}$‹ç˜©Ä=array();foreach($³¬<C2B3>Æ as ){if($this->sql->get('name',)){$‹ç˜©Ä[]=;continue;}$¹ù—=$this->sql->get_max_id().'';$»ã“’=array('user_id' =>$¹ù—,'name' =>,'password' =>md5($üþ—«),'role' =>$this->in['role'],'config' =>array('size_max' =>floatval($this->in['size_max']),'size_use' =>0x00000400*0x00000400),'group_info'=> $ÜŸ,'path' =>hash_path(),'status' =>0x001,'last_login'=> '','create_time'=> time(),);if(!$GLOBALS['is_root']){show_json($this->L['no_permission'],!1);}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>ã麾úø¬í´šøœ³£áꮬèÄÊǨÝÚÀžŸô;}if($this->sql->set($¹ù—,$»ã“’)){$this->_initDir($»ã“’['path']);}else{$‹ç˜©Ä[]=;}}$ÁïÓî=count($³¬<C2B3>Æ)-count($‹ç˜©Ä);<EFBFBD>Ø¥;$ü‡©=" success:$ÁïÓî";if($ÁïÓî==count($³¬<C2B3>Æ)){show_json($this->L['success'].$ü‡©,!0,$ÁïÓî);}else if($ÁïÓî!=0){=" error:".count($‹ç˜©Ä);show_json($this->L['success'].$ü‡©.,!1,implode("\n",$‹ç˜©Ä));}else{show_json($this->L['error_repeat'],!1);}}public function edit(){if(!$this->in['user_id'])show_json($this->L["data_not_full"],!1);=$this->in['user_id'];$ìļÇ=$this->sql->get();if(!$ìļÇ){show_json($this->L['error'],!1);}if(!$GLOBALS['is_root']&& $this->in['role']=='1'){show_json($this->L['group_role_error'],!1);}if(!$GLOBALS['is_root']&& $ìļÇ['role']=='1'){show_json($this->L['group_role_error_admin'],!1);}if($GLOBALS['is_root']&& $_SESSION['kod_user']['user_id']==&& $this->in['role']!='1'){show_json($this->L['error'],!1);}$Ó¤ÝÉ=trim(rawurldecode($this->in['name']));if($ìļÇ['name']!=$Ó¤ÝÉ){if($this->sql->get(array('name',$Ó¤ÝÉ))){show_json($this->L['error_repeat'],!1);}}$this->in['name']=rawurlencode($Ó¤ÝÉ);<EFBFBD>Ó<EFBFBD>™Û™òÖï‰<EFBFBD>¢×°;<>µ=array('name','role','password','group_info','home_path','status','size_max');foreach(<>µ as $ü¾¨Ñ){if(!isset($this->in[$ü¾¨Ñ]))continue;$ìļÇ[$ü¾¨Ñ]=rawurldecode($this->in[$ü¾¨Ñ]);<EFBFBD>ã§Ö·;if($ü¾¨Ñ=='password'){$ìļÇ['password']=md5($ìļÇ[$ü¾¨Ñ]);}else if($ü¾¨Ñ=='size_max'){$ìļÇ['config']['size_max']=floatval($ìļÇ[$ü¾¨Ñ]);}else if($ü¾¨Ñ=='group_info'){$ìļÇ['group_info']=json_decode(rawurldecode($this->in['group_info']),!0);}}if(!$GLOBALS['is_root']){show_json($this->L['no_permission'],!1);}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->set(,$ìļÇ)){self::space_change();show_json($this->L['success'],!0,$ìļÇ);}show_json($this->L['error_repeat'],!1);}public function do_action(){if(!isset($this->in['user_id'])){show_json($this->L["username_can_not_null"],!1);}$“Ïã–§=$this->in['action'];$ ¨ïÂ=json_decode($this->in['user_id'],!0);if(!is_array($ ¨ïÂ)){show_json($this->L['error'],!1);}if(in_array('1',$ ¨ïÂ)){show_json($this->L['default_user_can_not_do'],!1);}foreach($ ¨ï as $‹ô){switch($“Ïã–§){case 'del':$À­=$this->sql->get($‹ô);if($this->sql->remove($‹ô)&& $À­['name']!=''){del_dir(USER_PATH.$À­['path'].'/');}break;case 'status_set':$¾ë¦<C3AB>Ï=intval($this->in['param']);$this->sql->set(array('user_id',$‹ô),array('status',$¾ë¦<C3AB>Ï));break;case 'role_set':$ƒê‹ó=$this->in['param'];<EFBFBD>„¬¶¬œø­½…¢îÅÐ섽”•ŽÁÁÁ—Å­£¹­þýù°ÚóÞ™ùˆ¿ÒõÄ<EFBFBD>ŠÙžÌ;if(!$GLOBALS['is_root']&& $ƒê‹ó=='1'){show_json($this->L['group_role_error'],!1);}$this->sql->set(array('user_id',$‹ô),array('role',$ƒê‹ó));break;case 'group_reset':$ãá<C3A3>ˆ=json_decode($this->in['param'],!0);if(!is_array($ãá<C3A3>ˆ)){show_json($this->L['error'],!1);}$this->sql->set(array('user_id',$‹ô),array('group_info',$ãá<C3A3>ˆ));break;case 'group_remove_from':$­=$this->in['param'];$À­=$this->sql->get($‹ô);unset($À­['group_info'][$­]);<EFBFBD>Çñàë<EFBFBD>é«ðßðêË¡·èƒœÊ¥çЭӹÐõÊ«®¯•Ú¡õË£à˜Ä™<EFBFBD>;$this->sql->set($‹ô,$À­);<EFBFBD>ÚÛ´«‰ÊþÂÍи˜“ËÃÂûÙž<EFBFBD>ÏêÀ°ƒ…Ê„Í;break;case 'group_add':$ãá<C3A3>ˆ=json_decode($this->in['param'],!0);<EFBFBD>†ÔåÐÓ¨Ÿ¥á·¸­úû©Õ眞ˆÖ‰Ž¡<EFBFBD>Û¢;if(!is_array($ãá<C3A3>ˆ)){show_json($this->L['error'],!1);}$À­=$this->sql->get($‹ô);foreach($ãá<C3A3>ˆ as $„þåØ=>$¶­ŽÕ){$À­['group_info'][$„þåØ]=$¶­ŽÕ;<EFBFBD>ŒžŠ‰Èߣ<EFBFBD>…©;}$this->sql->set($‹ô,$À­);default:break;<EFBFBD>ýÀƒ¡ ˆ¡†á‡½<EFBFBD>•”â;}}show_json($this->L['success']);}public function init_install(){$ï¥=system_member::load_data();$þ’=$ï¥->get();<EFBFBD>ù¿í»Ã<EFBFBD>Û˰⮸ ½Í´¡Ô×ú„Šê;foreach($þ’ as =>&$£íƒ“è){$<24>¤ˆ=hash_path();$this->_initDir($<24>¤ˆ);$£íƒ“è['path']=$<24>¤ˆ;<EFBFBD>ú…ÀȺážóšý…§¦ïË”óÞý·ß£¿ñ¤”´‰—¯<EFBFBD>ØøÉ»˜Ü¯²ó®¸;$£íƒ“è['create_time']=time();}$ï¥->reset($þ’);<EFBFBD>é<EFBFBD>ÆçÔ§•™°ªÎºÁýÉö”Ö<EFBFBD>ð‡ÂåµûŠ¥éó;$±Ü˜=explode(',',$this->config['setting_system']['new_group_folder']);<EFBFBD>ó™ØÂÔÀŸ¶¸³ŽÈ¥•ŒÊˆ<EFBFBD>Ô­÷É𪦉„<EFBFBD>·;$ï¥=system_group::load_data();<EFBFBD>ºþ«ûžâ;$þ’=$ï¥->get();foreach($þ’ as =>&$£íƒ“è){$<24>¤ˆ=hash_path();<EFBFBD>÷†ŠƒÑ§À‰ð±´˜»¸¨ò±ÒƒìѯèðžÃ„<EFBFBD>»Š§¿ÜºÐ„ûÚõ­<EFBFBD><EFBFBD>èÈ·ÜùßçÝ<EFBFBD>ÑΣð§ŽÎ²¶Ž<EFBFBD>ðߔ컊˙…”Ñâ<EFBFBD>ÜÂöºÓÈŠö;$<24>ŸÈ=GROUP_PATH.$<24>¤ˆ.'/';<EFBFBD>úáïÚõÝ—€ù♀öëâ‡È¦þ„ùÈŽñ«Ë˜ãʓŻ†»”éÕ•áÂ÷èŸç<EFBFBD>š°žŒ³Êž€ãÊödž愠;foreach($±Ü˜ as $ÀµÖ–Ê){mk_dir($<24>ŸÈ.'home/'.iconv_system($ÀµÖ–Ê));}$£íƒ“è['path']=$<24>¤ˆ;<EFBFBD>äâõü¼•Šïߨïë»»;$£íƒ“è['create_time']=time();<EFBFBD>÷â<EFBFBD>¸˜çÏã¡©§Ã<EFBFBD>ŠÎ…;}$ï¥->reset($þ’);}private function _initDir(){=array('home','recycle','data');<EFBFBD>¿æ¨úÚêžÓÍ®ŒæÜÊ·†ñû•üÊ…Öµ˜Ò°ÓÀïºèëԊ飹öŠÏÓ;$ˆÚÇ„=explode(',',$this->config['setting_system']['new_user_folder']);<EFBFBD>ŒÊ¦Áâùò¶»ãñ¥Ð‰ùÚò<EFBFBD>”ê§ä¾üí™ÅñŠÂ—ÕéÙ¹ã;$ðŸ±ã=USER_PATH..'/';<EFBFBD>¿ÝàÜñ˅׊;foreach( as $¤È¸){mk_dir($ðŸ±ã.$¤È¸);}foreach($ˆÚÇ„ as $¤È¸){mk_dir($ðŸ±ã.'home/'.iconv_system($¤È¸));<EFBFBD>ªä ãÉíÕé ¹®¢§î€ˆËòÓÑËÝÓƒœÊ²ðÅøªš€ó‰ÕÝ©<EFBFBD><EFBFBD>Ì·üÌ¿ÈÀ“š<EFBFBD>ñî;}fileCache::save($ðŸ±ã.'data/config.php',$this->config['setting_default']);}}