Example #1
0
 * @license GNU GPL v3.0
 * @package aetolos
 * @subpackage emailmanager
 */
// No direct access - loadable only
if (!defined('AET_IN')) {
    die("No Access");
}
// Check for parameter
if (!isset($cmdParameters['modify-virtualhost'])) {
    Log::error('Missing parameter');
    exit(9);
}
$vhost = new VirtualHost($db);
$vhost->domainName = $cmdParameters['modify-virtualhost'];
$rc = $vhost->get();
if ($rc === false) {
    Log::error('Unknown virtual host');
    exit(9);
}
$emailManager = new EmailManager($vhost);
if (isset($cmdParameters['add-email'])) {
    if (!isset($cmdParameters['password'])) {
        if (isset($cmdParameters['password-file'])) {
            if (!is_file($cmdParameters['password-file'])) {
                Log::error('Error while opening the password file');
                exit(9);
            }
            $cmdParameters['password'] = file_get_contents($cmdParameters['password-file']);
            if ($cmdParameters['password'] === false) {
                Log::error('Error while reading the password file');
Example #2
0
 /**
  * Remove a parked domain from the current virtual host
  * @param string $domainName Parked domain name to remove
  * @return boolean
  */
 public function removeParkedDomain($domainName)
 {
     // Load parked domain object
     $vhost = new VirtualHost($this->db);
     $vhost->domainName = $domainName;
     $rc = $vhost->get();
     if ($rc === false) {
         Log::error('Unknown parked domain');
         return false;
     }
     // Make sure this is a parked domain and not a virtual host
     if ($vhost->parkedUnder == '') {
         Log::error('The domain \'' . $vhost->domainName . '\' is not a parked domain, but a virtual host');
         return false;
     }
     Log::debug('Delete parked domain: ' . $domainName);
     // Full home directory path
     $home = $this->home . '/' . $this->unixName;
     // Delete etc
     $etcDir = $home . '/etc/' . $domainName;
     if (is_dir($etcDir)) {
         exec('/usr/bin/rm -rf ' . escapeshellarg($etcDir) . ' 2>/dev/null');
     }
     // Delete mail
     $mailDir = $home . '/mail/' . $domainName;
     if (is_dir($mailDir)) {
         exec('/usr/bin/rm -rf ' . escapeshellarg($mailDir) . ' 2>/dev/null');
     }
     // Delete NSD configuration and zone files
     if (is_file(Config::read('nsd|directoryConfD') . '/' . $domainName . '.conf')) {
         unlink(Config::read('nsd|directoryConfD') . '/' . $domainName . '.conf');
     }
     if (is_file(Config::read('nsd|directoryConfD') . '/' . $domainName . '.zone')) {
         unlink(Config::read('nsd|directoryConfD') . '/' . $domainName . '.zone');
     }
     // Delete vhost directory
     if (is_link('/etc/dovecot/vhost/' . $domainName)) {
         unlink('/etc/dovecot/vhost/' . $domainName);
     }
     // Delete Apache virtual host file
     if (is_file(Config::read('apache|directoryConfD') . '/' . $domainName . '.conf')) {
         unlink(Config::read('apache|directoryConfD') . '/' . $domainName . '.conf');
     }
     // Delete Apache log files
     if (is_file('/var/log/httpd/' . $domainName)) {
         unlink('/var/log/httpd/' . $domainName);
     }
     if (is_file('/var/log/httpd/' . $domainName . '-bytes_log')) {
         unlink('/var/log/httpd/' . $domainName . '-bytes_log');
     }
     if (is_file('/var/log/httpd/' . $domainName . '-ssl_log')) {
         unlink('/var/log/httpd/' . $domainName . '-ssl_log');
     }
     // Remove from database
     // Prepare statement
     $preped = $this->db->conn->prepare("DELETE FROM `virtualHostMx` WHERE VirtualHost_ID=:id");
     // Bind parameter
     $preped->bindParam(':id', $vhost->id);
     // Execute prepared statement
     $rc = $preped->execute();
     if ($rc === false) {
         Log::error('Error while deleting mail exchange server from the database table: virtualHostMx');
         return false;
     }
     // Prepare statement
     $preped = $this->db->conn->prepare("DELETE FROM `virtualHostNs` WHERE VirtualHost_ID=:id");
     // Bind parameter
     $preped->bindParam(':id', $vhost->id);
     // Execute prepared statement
     $rc = $preped->execute();
     if ($rc === false) {
         Log::error('Error while deleting name server from the database table: virtualHostNs');
         return false;
     }
     // Prepare statement
     $preped = $this->db->conn->prepare("DELETE FROM `virtualHost` WHERE Id=:id");
     // Bind parameter
     $preped->bindParam(':id', $vhost->id);
     // Execute prepared statement
     $rc = $preped->execute();
     if ($rc === false) {
         Log::error('Error while deleting parked domain from the database table: virtualHost');
         return false;
     }
     return true;
 }