コード例 #1
0
ファイル: Domain.php プロジェクト: omines/directadmin
 /**
  * Creates a new domain under the specified user.
  *
  * @param User $user Owner of the domain
  * @param string $domainName Domain name to create
  * @param float|null $bandwidthLimit Bandwidth limit in MB, or NULL to share with account
  * @param float|null $diskLimit Disk limit in MB, or NULL to share with account
  * @param bool|null $ssl Whether SSL is to be enabled, or NULL to fallback to account default
  * @param bool|null $php Whether PHP is to be enabled, or NULL to fallback to account default
  * @param bool|null $cgi Whether CGI is to be enabled, or NULL to fallback to account default
  * @return Domain The newly created domain
  */
 public static function create(User $user, $domainName, $bandwidthLimit = null, $diskLimit = null, $ssl = null, $php = null, $cgi = null)
 {
     $options = ['action' => 'create', 'domain' => $domainName, isset($bandwidthLimit) ? 'bandwidth' : 'ubandwidth' => $bandwidthLimit, isset($diskLimit) ? 'quota' : 'uquota' => $diskLimit, 'ssl' => Conversion::onOff($ssl, $user->hasSSL()), 'php' => Conversion::onOff($php, $user->hasPHP()), 'cgi' => Conversion::onOff($cgi, $user->hasCGI())];
     $user->getContext()->invokePost('DOMAIN', $options);
     $config = $user->getContext()->invokeGet('ADDITIONAL_DOMAINS');
     return new self($domainName, $user->getContext(), $config[$domainName]);
 }
コード例 #2
0
ファイル: User.php プロジェクト: omines/directadmin
 /**
  * @param bool $newValue Whether catch-all email is enabled for this user
  */
 public function setAllowCatchall($newValue)
 {
     $this->modifyConfig(['catchall' => Conversion::onOff($newValue)]);
 }
コード例 #3
0
ファイル: DirectAdmin.php プロジェクト: omines/directadmin
 /**
  * Sends a raw request to DirectAdmin.
  *
  * @param string $method
  * @param string $uri
  * @param array $options
  * @return array
  */
 private function rawRequest($method, $uri, $options)
 {
     try {
         $response = $this->connection->request($method, $uri, $options);
         if ($response->getHeader('Content-Type')[0] == 'text/html') {
             throw new DirectAdminException(sprintf('DirectAdmin API returned text/html to %s %s containing "%s"', $method, $uri, strip_tags($response->getBody()->getContents())));
         }
         $body = $response->getBody()->getContents();
         return Conversion::responseToArray($body);
     } catch (TransferException $exception) {
         // Rethrow anything that causes a network issue
         throw new DirectAdminException(sprintf('%s request to %s failed', $method, $uri), 0, $exception);
     }
 }