ISPcfg3 WHMCS module enhancement

Discussion in 'Tips/Tricks/Mods' started by webguyz, Jun 1, 2015.

  1. webguyz

    webguyz Active Member HowtoForge Supporter

    I changed some code in the ISPcfg3 module because I have multiserver setup with multiple mail servers and I wanted to add mail server for a new user to the server with the least amount of mailboxes in the hope of load balancing my mail servers like I do now with the web servers. I simply lifted the code from cwispy's latest addon and modified it to count mailboxes on each mailserver instead of websites.

    PHP:
     if (count$server['mail_server'] ) == ) {
               
                
    $defaultmailserver $server['mail_server'][0]['server_id'];
               
            } else {
               
               
    /*
             $rnd = rand(0, ( count( $server['mail_server'] ) - 1 ) );
                $defaultmailserver = $server['mail_server'][$rnd]['server_id'];
            */

              /* Andy added this to choose mail server with least amount of mail accounts    */

                
    $a 1;
                
    $b 0;
                       
                while ( 
    $a <= count($server['mail_server']) ) {
               
                    
    $result = array();
                    
    $result $client->mail_user_get$session_id,
                        array( 
    'server_id' => $server['mail_server'][$b]['server_id'],
                                
    'homedir' => '/var/vmail') );
                   
                    if (!isset(
    $mailboxcnt)) {
                        
    $mailboxcnt countarray_keys($result) );
                       
                    }
                   
                    if ( 
    $mailboxcnt countarray_keys($result) ) OR
                        ( !isset(
    $defaultmailserver) ) ) {
                           
                        
    $mailboxcnt countarray_keys($result) );
                        
    $defaultmailserver $server['mail_server'][$b]['server_id'];
                   
                 }
                 
    $a++;
                 
    $b++;
               
                }
               
                unset(
    $a);
                unset(
    $b);

              
            }
     
    Last edited: Jun 1, 2015
    cwispy likes this.

Share This Page