Jump to content


Photo

PHP: Add Domain with target-server and port


  • Please log in to reply
No replies to this topic

#1 Harald Reindl

Harald Reindl
  • Members
  • 15 posts

Posted 21 November 2010 - 12:32 PM

HiI need some php-functions to add a domain with explicit target-server / port, remove domain and get a full ost of all configured domainsAbove my current functions for add/remove domain, but they are using old API-class and there is no way to set the target-server defined in the php-class and afaik "add_domain.gci" will be removed in future firmware-versionsThis should be intergated in our self developed backend for http://www.dbmail.org/ and is useable standalone tooThe option to get all confugured domains as php-array would be nice to get the data in our billing-system
class dbmail_barracuda {  public $enabled   = false;  public $url       = '';  public $password  = '';  public $mta       = '';  public $mta_port  = '';  /**   * @param  string $domain   * @access public   * @return boolean  */  public function domain_add($domain)  {   if(!$this->enabled)   {    return false;   }   else   {    $call = $this->url . 'cgi-mod/add_domain.cgi?password=' . $this->password . '&domain=' . urlencode($domain);    $rw = file_get_contents($call);    $xml = simplexml_load_string($rw);    $status_code = $xml->Result->Code;    if($status_code == 200)    {     return true;    }    else    {     return false;    }   }  }  /**   * @param  string $domain   * @access public   * @return boolean  */  public function domain_remove($domain)  {   if(!$this->enabled)   {    return false;   }   else   {    $call = $this->url . 'cgi-mod/delete_domain.cgi?password=' . $this->password . '&domain=' . urlencode($domain);    $rw = file_get_contents($call);    $xml = simplexml_load_string($rw);    $status_code = $xml->Result->Code;    if($status_code == 200)    {     return true;    }    else    {     return false;    }   }  } }?>
[/code]