/**
  * We write the configs
  */
 public function writeConfigs()
 {
     // Write diroptions
     fwrite($this->debugHandler, '  apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_diroptions') . "\n");
     $this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_diroptions'));
     if (count($this->diroptions_data) > 0) {
         $optsDir = new frxDirectory(Settings::Get('system.apacheconf_diroptions'));
         if (!$optsDir->isConfigDir()) {
             // Save one big file
             $diroptions_file = '';
             foreach ($this->diroptions_data as $diroptions_filename => $diroptions_content) {
                 $diroptions_file .= $diroptions_content . "\n\n";
             }
             $diroptions_filename = Settings::Get('system.apacheconf_diroptions');
             // Apply header
             $diroptions_file = '# ' . basename($diroptions_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $diroptions_file;
             $diroptions_file_handler = fopen($diroptions_filename, 'w');
             fwrite($diroptions_file_handler, $diroptions_file);
             fclose($diroptions_file_handler);
         } else {
             if (!file_exists(Settings::Get('system.apacheconf_diroptions'))) {
                 fwrite($this->debugHandler, '  apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))) . "\n");
                 $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))));
                 safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_diroptions'))));
             }
             // Write a single file for every diroption
             foreach ($this->diroptions_data as $diroptions_filename => $diroptions_file) {
                 $this->known_diroptionsfilenames[] = basename($diroptions_filename);
                 // Apply header
                 $diroptions_file = '# ' . basename($diroptions_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $diroptions_file;
                 $diroptions_file_handler = fopen($diroptions_filename, 'w');
                 fwrite($diroptions_file_handler, $diroptions_file);
                 fclose($diroptions_file_handler);
             }
         }
     }
     // Write htpasswds
     fwrite($this->debugHandler, '  apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_htpasswddir') . "\n");
     $this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_htpasswddir'));
     if (count($this->htpasswds_data) > 0) {
         if (!file_exists(Settings::Get('system.apacheconf_htpasswddir'))) {
             $umask = umask();
             umask(00);
             mkdir(Settings::Get('system.apacheconf_htpasswddir'), 0751);
             umask($umask);
         }
         $htpasswdDir = new frxDirectory(Settings::Get('system.apacheconf_htpasswddir'));
         if ($htpasswdDir->isConfigDir(true)) {
             foreach ($this->htpasswds_data as $htpasswd_filename => $htpasswd_file) {
                 $this->known_htpasswdsfilenames[] = basename($htpasswd_filename);
                 $htpasswd_file_handler = fopen($htpasswd_filename, 'w');
                 fwrite($htpasswd_file_handler, $htpasswd_file);
                 fclose($htpasswd_file_handler);
             }
         } else {
             fwrite($this->debugHandler, '  cron_tasks: WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!' . "\n");
             echo 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!';
             $this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!');
         }
     }
     // Write virtualhosts
     fwrite($this->debugHandler, '  apache::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n");
     $this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost'));
     if (count($this->virtualhosts_data) > 0) {
         $vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost'));
         if (!$vhostDir->isConfigDir()) {
             // Save one big file
             $vhosts_file = '';
             // sort by filename so the order is:
             // 1. subdomains                  x-29
             // 2. subdomains as main-domains  30
             // 3. main-domains                35
             // #437
             ksort($this->virtualhosts_data);
             foreach ($this->virtualhosts_data as $vhosts_filename => $vhost_content) {
                 $vhosts_file .= $vhost_content . "\n\n";
             }
             // Include diroptions file in case it exists
             if (file_exists(Settings::Get('system.apacheconf_diroptions'))) {
                 $vhosts_file .= "\n" . 'Include ' . Settings::Get('system.apacheconf_diroptions') . "\n\n";
             }
             $vhosts_filename = Settings::Get('system.apacheconf_vhost');
             // Apply header
             $vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $vhosts_file;
             $vhosts_file_handler = fopen($vhosts_filename, 'w');
             fwrite($vhosts_file_handler, $vhosts_file);
             fclose($vhosts_file_handler);
         } else {
             if (!file_exists(Settings::Get('system.apacheconf_vhost'))) {
                 fwrite($this->debugHandler, '  apache::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))) . "\n");
                 $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
                 safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
             }
             // Write a single file for every vhost
             foreach ($this->virtualhosts_data as $vhosts_filename => $vhosts_file) {
                 $this->known_vhostfilenames[] = basename($vhosts_filename);
                 // Apply header
                 $vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $vhosts_file;
                 $vhosts_file_handler = fopen($vhosts_filename, 'w');
                 fwrite($vhosts_file_handler, $vhosts_file);
                 fclose($vhosts_file_handler);
             }
         }
     }
 }
 public function writeConfigs()
 {
     fwrite($this->debugHandler, '  nginx::writeConfigs: rebuilding ' . Settings::Get('system.apacheconf_vhost') . "\n");
     $this->logger->logAction(CRON_ACTION, LOG_INFO, "rebuilding " . Settings::Get('system.apacheconf_vhost'));
     $vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost'));
     if (!$vhostDir->isConfigDir()) {
         // Save one big file
         $vhosts_file = '';
         // sort by filename so the order is:
         // 1. subdomains
         // 2. subdomains as main-domains
         // 3. main-domains
         ksort($this->nginx_data);
         foreach ($this->nginx_data as $vhosts_filename => $vhost_content) {
             $vhosts_file .= $vhost_content . "\n\n";
         }
         $vhosts_filename = Settings::Get('system.apacheconf_vhost');
         // Apply header
         $vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $vhosts_file;
         $vhosts_file_handler = fopen($vhosts_filename, 'w');
         fwrite($vhosts_file_handler, $vhosts_file);
         fclose($vhosts_file_handler);
     } else {
         if (!file_exists(Settings::Get('system.apacheconf_vhost'))) {
             fwrite($this->debugHandler, '  nginx::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))) . "\n");
             $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
             safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
         }
         // Write a single file for every vhost
         foreach ($this->nginx_data as $vhosts_filename => $vhosts_file) {
             $this->known_filenames[] = basename($vhosts_filename);
             // Apply header
             $vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $vhosts_file;
             if (!empty($vhosts_filename)) {
                 $vhosts_file_handler = fopen($vhosts_filename, 'w');
                 fwrite($vhosts_file_handler, $vhosts_file);
                 fclose($vhosts_file_handler);
             }
         }
     }
     // htaccess stuff
     if (count($this->htpasswds_data) > 0) {
         if (!file_exists(Settings::Get('system.apacheconf_htpasswddir'))) {
             $umask = umask();
             umask(00);
             mkdir(Settings::Get('system.apacheconf_htpasswddir'), 0751);
             umask($umask);
         } elseif (!is_dir(Settings::Get('system.apacheconf_htpasswddir'))) {
             fwrite($this->debugHandler, '  cron_tasks: WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!' . "\n");
             echo 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!';
             $this->logger->logAction(CRON_ACTION, LOG_WARNING, 'WARNING!!! ' . Settings::Get('system.apacheconf_htpasswddir') . ' is not a directory. htpasswd directory protection is disabled!!!');
         }
         if (is_dir(Settings::Get('system.apacheconf_htpasswddir'))) {
             foreach ($this->htpasswds_data as $htpasswd_filename => $htpasswd_file) {
                 $this->known_htpasswdsfilenames[] = basename($htpasswd_filename);
                 $htpasswd_file_handler = fopen($htpasswd_filename, 'w');
                 // Filter duplicate pairs of username and password
                 $htpasswd_file = implode("\n", array_unique(explode("\n", $htpasswd_file)));
                 fwrite($htpasswd_file_handler, $htpasswd_file);
                 fclose($htpasswd_file_handler);
             }
         }
     }
 }
 public function writeConfigs()
 {
     $this->logger->logAction(CRON_ACTION, LOG_INFO, "lighttpd::writeConfigs: rebuilding " . Settings::Get('system.apacheconf_vhost'));
     $vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost'));
     if (!$vhostDir->isConfigDir()) {
         // Save one big file
         $vhosts_file = '';
         // sort by filename so the order is:
         // 1. main-domains
         // 2. subdomains as main-domains
         // 3. subdomains
         // (former #437) - #833 (the numbering is done in createLighttpdHosts())
         ksort($this->lighttpd_data);
         foreach ($this->lighttpd_data as $vhosts_filename => $vhost_content) {
             $vhosts_file .= $vhost_content . "\n\n";
         }
         $vhosts_filename = Settings::Get('system.apacheconf_vhost');
         // Apply header
         $vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $vhosts_file;
         $vhosts_file_handler = fopen($vhosts_filename, 'w');
         fwrite($vhosts_file_handler, $vhosts_file);
         fclose($vhosts_file_handler);
     } else {
         if (!file_exists(Settings::Get('system.apacheconf_vhost'))) {
             $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'lighttpd::writeConfigs: mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
             safe_exec('mkdir ' . escapeshellarg(makeCorrectDir(Settings::Get('system.apacheconf_vhost'))));
         }
         // Write a single file for every vhost
         foreach ($this->lighttpd_data as $vhosts_filename => $vhosts_file) {
             $this->known_filenames[] = basename($vhosts_filename);
             // Apply header
             $vhosts_file = '# ' . basename($vhosts_filename) . "\n" . '# Created ' . date('d.m.Y H:i') . "\n" . '# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.' . "\n" . "\n" . $vhosts_file;
             if (!empty($vhosts_filename)) {
                 $vhosts_file_handler = fopen($vhosts_filename, 'w');
                 fwrite($vhosts_file_handler, $vhosts_file);
                 fclose($vhosts_file_handler);
             }
         }
     }
     // Write the diroptions
     $htpasswdDir = new frxDirectory(Settings::Get('system.apacheconf_htpasswddir'));
     if ($htpasswdDir->isConfigDir()) {
         foreach ($this->needed_htpasswds as $key => $data) {
             if (!is_dir(Settings::Get('system.apacheconf_htpasswddir'))) {
                 mkdir(makeCorrectDir(Settings::Get('system.apacheconf_htpasswddir')));
             }
             $filename = makeCorrectFile(Settings::Get('system.apacheconf_htpasswddir') . '/' . $key);
             $htpasswd_handler = fopen($filename, 'w');
             fwrite($htpasswd_handler, $data);
             fclose($htpasswd_handler);
         }
     }
 }
 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
 *
 * @copyright  (c) the authors
 * @author     Florian Lippert <*****@*****.**> (2003-2009)
 * @author     Froxlor team <*****@*****.**> (2010-)
 * @license    GPLv2 http://files.froxlor.org/misc/COPYING.txt
 * @package    Lib
 *
 */
$configcommand = array();
$vhostDir = new frxDirectory(Settings::Get('system.apacheconf_vhost'));
$optsDir = new frxDirectory(Settings::Get('system.apacheconf_diroptions'));
if ($vhostDir->isConfigDir()) {
    $configcommand['vhost'] = 'mkdir -p ' . Settings::Get('system.apacheconf_vhost');
    $configcommand['include'] = 'echo -e "\\nInclude ' . makeCorrectDir(Settings::Get('system.apacheconf_vhost')) . '*.conf" >> ' . makeCorrectFile(makeCorrectDir('/etc/apache2/httpd.conf'));
    $configcommand['v_inclighty'] = 'echo -e \'\\ninclude_shell "cat ' . makeCorrectDir(Settings::Get('system.apacheconf_vhost')) . '*.conf"\' >> /etc/lighttpd/lighttpd.conf';
} else {
    $configcommand['vhost'] = 'touch ' . Settings::Get('system.apacheconf_vhost');
    $configcommand['include'] = 'echo -e "\\nInclude ' . Settings::Get('system.apacheconf_vhost') . '" >> ' . makeCorrectFile('/etc/apache2/httpd.conf');
    $configcommand['v_inclighty'] = 'echo -e \'\\ninclude "' . Settings::Get('system.apacheconf_vhost') . '"\' >> /etc/lighttpd/lighttpd.conf';
}
if ($optsDir->isConfigDir()) {
    $configcommand['diroptions'] = 'mkdir -p ' . Settings::Get('system.apacheconf_diroptions');
    $configcommand['d_inclighty'] = 'echo -e \'\\ninclude_shell "cat ' . makeCorrectDir(Settings::Get('system.apacheconf_diroptions')) . '*.conf"\' >> /etc/lighttpd/lighttpd.conf';
} else {
    $configcommand['diroptions'] = 'touch ' . Settings::Get('system.apacheconf_diroptions');
    $configcommand['d_inclighty'] = 'echo -e \'\\ninclude "' . Settings::Get('system.apacheconf_diroptions') . '"\' >> /etc/lighttpd/lighttpd.conf';
}
$cfgPath = 'lib/configfiles/';
$configfiles = array();
$configfiles = array_merge(include $cfgPath . 'wheezy.inc.php', include $cfgPath . 'squeeze.inc.php', include $cfgPath . 'precise.inc.php', include $cfgPath . 'lucid.inc.php', include $cfgPath . 'gentoo.inc.php', include $cfgPath . 'sle11.inc.php', include $cfgPath . 'sle10.inc.php', include $cfgPath . 'freebsd.inc.php');