Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. /**
  2. * @access Public
  3. * @method removeUserFromZnc
  4. * @return (bool) True if user was removed from ZNC successfully
  5. * Remove user from ZNC
  6. */
  7. public function removeUserFromZnc()
  8. {
  9. /*** Global Vars ***/
  10. global $bshell_cfg, $profile, $LightJet;
  11.  
  12. $znc_file = '/home/znc/.znc/configs/znc.conf';
  13. $znc_config = $LightJet->openFile( $znc_file );
  14.  
  15. /* Check for already configured ZNC user */
  16. $regex = "`^<User {$profile->currentProfile[ 'bs_userid' ]}>$`m";
  17. if ( !preg_match( $regex , $znc_config ) ) {
  18. return false;
  19. }
  20.  
  21. $regex = "`^<User {$profile->currentProfile[ 'bs_userid' ]}>(.*)</User>`m";
  22. $znc_config = preg_replace( $regex , '' , $znc_config );
  23.  
  24. $LightJet->writeFile( $znc_config, $znc_file , 'a' , null , $filename , true );
  25. /* rehash ZNC */
  26. /* Find ZNC PID */
  27. $procs = $this->getUserProcs( 'znc' );
  28. foreach( $procs as $proc ) {
  29. if ( $proc[ 'program' ] == 'znc' ) {
  30. exec( "kill -s 1 {$proc[ 'pid' ]}" );
  31. }
  32. }
  33. $this->printf( 'Removed user from ZNC' );
  34. return true;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement