1 line
10 KiB
PHP
Executable File
1 line
10 KiB
PHP
Executable File
<?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>Üí†ÐÛØÒøÖۧNj÷Ì‹Ú³Þ˜‡‹å¦ؼ嶫뇇ÅÙ<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']);}} |