KodExplorer/controller/system_member.class.php

1 line
10 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>Ø<EFBFBD>ßÄ¢¶ßáãÏ;$this->tpl=TEMPLATE.'member/';<EFBFBD>åéó‰Á”ʦò“Ò<EFBFBD>««ö;$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>Éü¨¾†éÒÐõùÄŠÌ;return $Âœ¿¦->get();<EFBFBD>酪çߤ¤½æÁüŽ®”Ì÷ô¶—ߊèÕ…­ßÒþÙ¿îýØ×Þýûœå½šôì¯ÁåÀ·<EFBFBD>Ø—¨Áì­îÍ€í§Àݦšµ…˜²¢þð½óÞìµÄ®ìáˆ;}public static function space_change(,$¸¹À¸¨=false){$ø‡Ž”½=self::load_data();$ð¶=$ø‡Ž”½->get();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:$†’Ãè;<EFBFBD>»¬ŸûåÈãßÏò󎇡þ½Ìá²ì£Ãª¨‡”ÂЉ¨Œ¶Çˆœ<EFBFBD>ìûàßðîæí¥ßÐØÌô˜´Ú轃õóËþÜë<EFBFBD>½Ìý;$ø‡Ž”½->set(,$ð¶);}public static function space_check($‘›Ø){$ë±¾à =self::load_data();<EFBFBD>趓Òó;=$ë±¾à ->get($‘›Ø);<EFBFBD>ù¿´‡ý<EFBFBD>†«µ˜ÇŽ‰´ÀǕᘗšÍ®ÔÂÆž«©ç¥éœ­èž´”ÓÌÜâÖ¤;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($<24>Ï—®){$Á–¡¬³=self::load_data();<EFBFBD>„ª§Ñ‡Š¨˜¯Ç¿µ€þ×»<EFBFBD>;$ËÜ=$Á–¡¬³->get();<EFBFBD>û¯ÅËĘÐï¿¢öÊË<EFBFBD>ù”а•Ï‰Ðܲœºò—•õ©¦îÜꇮÛÇÑÓ<EFBFBD>ã<EFBFBD>²µ¾È…Ç™âù¶žíͳä÷Äæ¢ö;foreach($ËÜ as $ÐÒ¶¢¦=>$À‹×){if(in_array($<24>Ï—®,array_keys($À‹×['group_info']))){unset($À‹×['group_info'][$<24>Ï—®]);$Á–¡¬³->set($À‹×['user_id'],$À‹×);}}}public static function role_remove_user_update($À–¼ÆÝ){$ªØ<C2AA>È=self::load_data();<EFBFBD>¬Ó·ºä®©¶<EFBFBD>àÙ¨«³„<EFBFBD>ó˺ù¢äÒ¯®š¬ÆÞîý™Ô­ÃŒ®¥åÖÑ<EFBFBD>Öþñܺëþ ¿®ÏÚ¹û¡˜ë ²ÀÎõÌüœ³;$íµàÄ=$ªØ<C2AA>È->get();<EFBFBD>¤œ¤¤¼ãÒ<EFBFBD>¾<EFBFBD>Šà¦õضÐ΄Î븤Úî… ¶æ×Úƒû€;foreach($íµàÄ as $àÒÍ=>$à×){if($à×['role']==$À–¼ÆÝ){$à×['role']='';$ªØ<C2AA>È->set($à×['user_id'],$à×);}}}public static function user_auth_group($‡){$„ß…Ô=self::load_data();=$„ß…Ô->get($_SESSION['kod_user']['user_id']);$Èõ²=['group_info'];<EFBFBD>µîŹëÅùÌ™Çìù í<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($<24>DZ,$¼øó¼='path'){if($GLOBALS['is_root'])return $<24>DZ;foreach($<24>DZ as $ <>œÄ=>&$¡þÙÜ©){unset($¡þÙÜ©[$¼øó¼]);unset($¡þÙÜ©['password']);<EFBFBD>Á¢óùñóÒ±õšâØ×ÛÍ•ÂîÞ³<EFBFBD><EFBFBD>²èÞÜ걜Øó¿Íí²ÂÁã¸ÜÆ´£àÊæ;}return $<24>DZ;<EFBFBD>ƒðƶڦ“Å×°ŸËï캣¯û‡èØÎûŽñÜØجºŸ°¬ææ‡<EFBFBD>úÍå¬í±<EFBFBD>;}public static function get_user_at_group($ìÀ‹è){$ôÁ—=self::load_data();<EFBFBD>Ωâûãƒ;$<24>ê=self::_filter_list($ôÁ—->get());if($ìÀ‹è=='0'){return $<24>ê;}=array();foreach($<24>ê as ){if(isset(['group_info'][$ìÀ‹è])){[]=;}}return ;<EFBFBD><EFBFBD>Ú¯ü»åã°¨û£ø†ò¢éî‡ì<EFBFBD>ײ°Ðï<EFBFBD>ê¿Ü½;}public static function user_share_sql($֤܈Ì){static $«Æßž;<EFBFBD>𷫉<EFBFBD>ݹß;if(!is_array($«Æßž)){$«Æßž=array();}if(!isset($«Æßž[$֤܈Ì])){<>=system_member::get_info($֤܈Ì);if(!isset(<>['path'])){return;}$»Ï=new fileCache(USER_PATH.<>['path'].'/data/share.php');$«Æßž[$֤܈Ì]=$»Ï;}return $«Æßž[$֤܈Ì];<EFBFBD>®±Ö·þ°âůڠ¼©¢;}public static function user_share_list($ƒ½³“){$ïââÇ=self::user_share_sql($ƒ½³“);<EFBFBD>¢³®¢äçõ”˜Ñ¥¹ãâã‡þÇŠ½ú<EFBFBD>Ÿë<EFBFBD>´ñÞ«•Ú·öì í¸¿¨ò¤ŒÖ«žµÈšÒè†Ôë»ÆÊçÛÝ”հ´Ã;$íƒÜ=$ïââÇ->get();<EFBFBD>·ÒôÕ‰¾ðܨ÷±”³÷ÞÔ½Ýè“<EFBFBD>žÖŒڟ색¥;if($ƒ½³“==$_SESSION['kod_user']['user_id']){return $íƒÜ;}foreach($íƒÜ as $ýûà½=>&$½åäîù){unset($½åäîù['share_password']);}return $íƒÜ;}public static function user_share_get(,$´½—“){$ª¢=self::user_share_sql();<EFBFBD>ÑÝ…¿á<EFBFBD>å¸<EFBFBD>;return $ª¢->get('name',$´½—“);<EFBFBD>Ï×±µÇ«Î°…ƒí<EFBFBD>—•Ç¹Û;}public function get($ ­©='0'){$í‹=self::get_user_at_group($ ­©);show_json($í‹);<EFBFBD>·ÝŽ‡¶¿½ý댮ñ<EFBFBD>œ<EFBFBD>§²×Ꭲ¼Ë¨«×Ý€œ¡;}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']);<EFBFBD>Ý®µ¥½×¨ù¤Ð¥û¯¦˜ÐÞ”<EFBFBD>žÅðœõͦԜ;$Ðù„=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);}$<24>=array();if(isset($this->in['isImport'])){=explode("\n",$ú¯¿);foreach( as ){if(trim()!=''){$<24>[]=trim();}}}else{$<24>[]=$ú¯¿;<EFBFBD>¸;}$Œ¸«¶õ=array();foreach($<24> 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($<24>)-count($Œ¸«¶õ);<EFBFBD>íŽÍ;$Ó¯þ¬ö=" success:";<EFBFBD>Ã膶<EFBFBD>÷ßÈŸ¢¨ïˆ¾Î<EFBFBD>¥ÑﳟևÏÖ´Æ´¢‡øŒŽ¯©‡<EFBFBD>ñ¦¡”Ï<EFBFBD>;if(==count($<24>)){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($óÆòìÒ);$üˆ=array('name','role','password','group_info','home_path','status','size_max');foreach($üˆ as $¯Ï…€â){if(!isset($this->in[$¯Ï…€â]))continue;$Óæ[$¯Ï…€â]=rawurldecode($this->in[$¯Ï…€â]);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);<EFBFBD>Üí†ÐÛØÒøÖÛ§Ç÷ÌÚޘå¦ؼ嶫뇇ÅÙ<EFBFBD>œµ¨ãÁ ±Íû;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':$ ù=intval($this->in['param']);<EFBFBD>ªˆÌ±<EFBFBD>“Œ¯Áº”„ÚÆÑ×è»ò¾„¨œ×ýҸ³â¤<EFBFBD>´”¡ÅÄã<EFBFBD>ÙçÜ º´‰õ§ÈùÐåÒ”£;$this->sql->set(array('user_id',$è›),array('status',$ ù));break;<EFBFBD>°ãÛŘïçÞ´Ìß<EFBFBD>µ¼¯ïð¹æ™ƒàéé´þŽÚË͵ü±ÂÉ<EFBFBD>«©;case 'role_set':$÷‰Å=$this->in['param'];if(!$GLOBALS['is_root']&& $÷‰Å=='1'){show_json($this->L['group_role_error'],!1);}$this->sql->set(array('user_id',$è›),array('role',$÷‰Å));break;<EFBFBD>·°…ѳ滞»¬öˆú¬…¬½Èö¿ó ;case 'group_reset':$멽šï=json_decode($this->in['param'],!0);if(!is_array($멽šï)){show_json($this->L['error'],!1);}$this->sql->set(array('user_id',$è›),array('group_info',$멽šï));break;case 'group_remove_from':$ä½=$this->in['param'];<EFBFBD>¶·Àñä·úßã;$È´ÜÓ=$this->sql->get($è›);unset($È´ÜÓ['group_info'][$ä½]);$this->sql->set($è›,$È´ÜÓ);break;<EFBFBD>¼¤Ù©Î—ÿËûç;case 'group_add':$멽šï=json_decode($this->in['param'],!0);if(!is_array($멽šï)){show_json($this->L['error'],!1);}$È´ÜÓ=$this->sql->get($è›);foreach($멽šï as $âÉß=>$‚¡){$È´ÜÓ['group_info'][$âÉß]=$‚¡;}$this->sql->set($è›,$È´ÜÓ);<EFBFBD>ǾˆÔà;default:break;<EFBFBD>Žýž·Ì¶û<EFBFBD>øô³³Øý”ò€¶€ç<EFBFBD>ˆ¯Î„°âÜôðÚ”©¨Ê¥µÌ;}}show_json($this->L['success']);}public function init_install(){$<24>Ò=system_member::load_data();$ç÷€žø=$<24>Ò->get();<EFBFBD>;foreach($ç÷€žø as $“›¯õø=>&$çÔ){$‘ý„=hash_path();$this->_initDir($‘ý„);$çÔ['path']=$‘ý„;<EFBFBD>Ò©äÒÝү׺ÞÙÒÝíî<EFBFBD>ãè³Ì½ìÝ»ñïÄëϘµê§“¾×êù·ÅÌ•³¼£˜¥ÖäãÄ;$çÔ['create_time']=time();<EFBFBD>Ù<EFBFBD>ûÆà”Üþ„ª½Ü;}$<24>Ò->reset($ç÷€žø);=explode(',',$this->config['setting_system']['new_group_folder']);$<24>Ò=system_group::load_data();$ç÷€žø=$<24>Ò->get();foreach($ç÷€žø as $“›¯õø=>&$çÔ){$‘ý„=hash_path();<EFBFBD>æ¥<EFBFBD>ËêÑ뢫ûžòܲÏó²ÔŸï±;$¨Æ‘=GROUP_PATH.$‘ý„.'/';foreach( as $¡ï¿É×){mk_dir($¨Æ‘.'home/'.iconv_system($¡ï¿É×));<EFBFBD>Щ<EFBFBD>òÕŒÈéÄ™Þöíýç ³<EFBFBD>æÅ;}$çÔ['path']=$‘ý„;$çÔ['create_time']=time();<EFBFBD>˜°ˆýˆ¬Î²¼ÂˆÉÓÑ´˜ê“<EFBFBD>ÙöùňáÇ»ñøÓ;}$<24>Ò->reset($ç÷€žø);}private function _initDir(){$®¡=array('home','recycle','data');<EFBFBD>涸¸êÑ£ýáü<EFBFBD>Ù÷ÕâÚá«Ó¤êö¦½£Õß<EFBFBD>ÂÄèøý¡äÏÄã²Âó<EFBFBD>»Ê﬜­<EFBFBD>À˜÷çÖœ½¶<EFBFBD><EFBFBD>ú‡ùø¨ßÉí;$ü°¸=explode(',',$this->config['setting_system']['new_user_folder']);$„úƒ±—=USER_PATH..'/';foreach($®¡ as $×É){mk_dir($„úƒ±—.$×É);}foreach($ü°¸ as $×É){mk_dir($„úƒ±—.'home/'.iconv_system($×É));<EFBFBD>ýÖåþÒìùÌ•Ùƒž”´×ž¡Û;}fileCache::save($„úƒ±—.'data/config.php',$this->config['setting_default']);}}