Пример #1
0
 /**
  * Creates a new database under the specified user.
  *
  * @param User $user Owner of the database
  * @param string $name Database name, without <user>_ prefix
  * @param string $username Username to access the database with, without <user>_ prefix
  * @param string|null $password Password, or null if database user already exists
  * @return Database Newly created database
  */
 public static function create(User $user, $name, $username, $password)
 {
     $options = ['action' => 'create', 'name' => $name];
     if (!empty($password)) {
         $options += ['user' => $username, 'passwd' => $password, 'passwd2' => $password];
     } else {
         $options += ['userlist' => $username];
     }
     $user->getContext()->invokePost('DATABASES', $options);
     return new self($name, $user, $user->getContext());
 }
Пример #2
0
 /**
  * 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]);
 }