/** * store the default index-file in a given destination folder * * @param string $loginname customers loginname * @param string $destination path where to create the file * @param object $logger FroxlorLogger object * @param boolean $force force creation whatever the settings say (needed for task #2, create new user) * * @return null */ function storeDefaultIndex($loginname = null, $destination = null, $logger = null, $force = false) { if ($force || (int) Settings::Get('system.store_index_file_subs') == 1) { $result_stmt = Database::prepare("\n\t\t\tSELECT `t`.`value`, `c`.`email` AS `customer_email`, `a`.`email` AS `admin_email`, `c`.`loginname` AS `customer_login`, `a`.`loginname` AS `admin_login`\n\t\t\tFROM `" . TABLE_PANEL_CUSTOMERS . "` AS `c` INNER JOIN `" . TABLE_PANEL_ADMINS . "` AS `a`\n\t\t\tON `c`.`adminid` = `a`.`adminid`\n\t\t\tINNER JOIN `" . TABLE_PANEL_TEMPLATES . "` AS `t`\n\t\t\tON `a`.`adminid` = `t`.`adminid`\n\t\t\tWHERE `varname` = 'index_html' AND `c`.`loginname` = :loginname"); Database::pexecute($result_stmt, array('loginname' => $loginname)); if (Database::num_rows() > 0) { $template = $result_stmt->fetch(PDO::FETCH_ASSOC); $replace_arr = array('SERVERNAME' => Settings::Get('system.hostname'), 'CUSTOMER' => $template['customer_login'], 'ADMIN' => $template['admin_login'], 'CUSTOMER_EMAIL' => $template['customer_email'], 'ADMIN_EMAIL' => $template['admin_email']); $htmlcontent = replace_variables($template['value'], $replace_arr); $indexhtmlpath = makeCorrectFile($destination . '/index.' . Settings::Get('system.index_file_extension')); $index_html_handler = fopen($indexhtmlpath, 'w'); fwrite($index_html_handler, $htmlcontent); fclose($index_html_handler); if ($logger !== null) { $logger->logAction(CRON_ACTION, LOG_NOTICE, 'Creating \'index.' . Settings::Get('system.index_file_extension') . '\' for Customer \'' . $template['customer_login'] . '\' based on template in directory ' . escapeshellarg($indexhtmlpath)); } } else { $destination = makeCorrectDir($destination); if ($logger !== null) { $logger->logAction(CRON_ACTION, LOG_NOTICE, 'Running: cp -a ' . FROXLOR_INSTALL_DIR . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination)); } safe_exec('cp -a ' . FROXLOR_INSTALL_DIR . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination)); } } return; }
/** * store the default index-file in a given destination folder * * @param string $loginname customers loginname * @param string $destination path where to create the file * @param object $logger FroxlorLogger object * @param boolean $force force creation whatever the settings say (needed for task #2, create new user) * * @return null */ function storeDefaultIndex($loginname = null, $destination = null, $logger = null, $force = false) { global $db, $settings, $pathtophpfiles; if ($force || (int) $settings['system']['store_index_file_subs'] == 1) { $result = $db->query("SELECT `t`.`value`, `c`.`email` AS `customer_email`, `a`.`email` AS `admin_email`, `c`.`loginname` AS `customer_login`, `a`.`loginname` AS `admin_login` FROM `" . TABLE_PANEL_CUSTOMERS . "` AS `c` INNER JOIN `" . TABLE_PANEL_ADMINS . "` AS `a` ON `c`.`adminid` = `a`.`adminid` INNER JOIN `" . TABLE_PANEL_TEMPLATES . "` AS `t` ON `a`.`adminid` = `t`.`adminid` WHERE `varname` = 'index_html' AND `c`.`loginname` = '" . $db->escape($loginname) . "'"); if ($db->num_rows($result) > 0) { $template = $db->fetch_array($result); $replace_arr = array('SERVERNAME' => $settings['system']['hostname'], 'CUSTOMER' => $template['customer_login'], 'ADMIN' => $template['admin_login'], 'CUSTOMER_EMAIL' => $template['customer_email'], 'ADMIN_EMAIL' => $template['admin_email']); $htmlcontent = replace_variables($template['value'], $replace_arr); $indexhtmlpath = makeCorrectFile($destination . '/index.' . $settings['system']['index_file_extension']); $index_html_handler = fopen($indexhtmlpath, 'w'); fwrite($index_html_handler, $htmlcontent); fclose($index_html_handler); if ($logger !== null) { $logger->logAction(CRON_ACTION, LOG_NOTICE, 'Creating \'index.' . $settings['system']['index_file_extension'] . '\' for Customer \'' . $template['customer_login'] . '\' based on template in directory ' . escapeshellarg($indexhtmlpath)); } } else { $destination = makeCorrectDir($destination); if ($logger !== null) { $logger->logAction(CRON_ACTION, LOG_NOTICE, 'Running: cp -a ' . $pathtophpfiles . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination)); } safe_exec('cp -a ' . $pathtophpfiles . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination)); } } return; }
/** * this functions validates a given value as ErrorDocument * refs #267 * * @param string error-document-string * * @return string error-document-string * */ function correctErrorDocument($errdoc = null) { global $idna_convert; if ($errdoc !== null && $errdoc != '') { // not a URL if (strtoupper(substr($errdoc, 0, 5)) != 'HTTP:' && strtoupper(substr($errdoc, 0, 6)) != 'HTTPS:' || !validateUrl($errdoc)) { // a file if (substr($errdoc, 0, 1) != '"') { $errdoc = makeCorrectFile($errdoc); // apache needs a starting-slash (starting at the domains-docroot) if (!substr($errdoc, 0, 1) == '/') { $errdoc = '/' . $errdoc; } } else { // string won't work for lighty if (Settings::Get('system.webserver') == 'lighttpd') { standard_error('stringerrordocumentnotvalidforlighty'); } elseif (substr($errdoc, -1) != '"') { $errdoc .= '"'; } } } else { if (Settings::Get('system.webserver') == 'lighttpd') { standard_error('urlerrordocumentnotvalidforlighty'); } } } return $errdoc; }
/** * read domain-related (or if empty, parentdomain-related) ssl-certificates from the database * and (if not empty) set the corresponding array-indices (ssl_cert_file, ssl_key_file, * ssl_ca_file and ssl_cert_chainfile). Hence the parameter as reference. * * @param array $domain domain-array as reference so we can set the corresponding array-indices * * @return null */ public function setDomainSSLFilesArray(array &$domain = null) { // check if the domain itself has a certificate defined $dom_certs_stmt = Database::prepare("\n\t\t\tSELECT * FROM `" . TABLE_PANEL_DOMAIN_SSL_SETTINGS . "` WHERE `domainid` = :domid\n\t\t"); $dom_certs = Database::pexecute_first($dom_certs_stmt, array('domid' => $domain['id'])); if (!is_array($dom_certs) || !isset($dom_certs['ssl_cert_file']) || $dom_certs['ssl_cert_file'] == '') { // maybe its parent? if ($domain['parentdomainid'] != null) { $dom_certs = Database::pexecute_first($dom_certs_stmt, array('domid' => $domain['parentdomainid'])); } } // check if it's an array and if the most important field is set if (is_array($dom_certs) && isset($dom_certs['ssl_cert_file']) && $dom_certs['ssl_cert_file'] != '') { // get destination path $sslcertpath = makeCorrectDir(Settings::Get('system.customer_ssl_path')); // create path if it does not exist if (!file_exists($sslcertpath)) { safe_exec('mkdir -p ' . escapeshellarg($sslcertpath)); } // make correct files for the certificates $ssl_files = array('ssl_cert_file' => makeCorrectFile($sslcertpath . '/' . $domain['domain'] . '.crt'), 'ssl_key_file' => makeCorrectFile($sslcertpath . '/' . $domain['domain'] . '.key')); if (Settings::Get('system.webserver') == 'lighttpd') { // put my.crt and my.key together for lighty. $dom_certs['ssl_cert_file'] = trim($dom_certs['ssl_cert_file']) . "\n" . trim($dom_certs['ssl_key_file']) . "\n"; $ssl_files['ssl_key_file'] = ''; } // initialize optional files $ssl_files['ssl_ca_file'] = ''; $ssl_files['ssl_cert_chainfile'] = ''; // set them if they are != empty if ($dom_certs['ssl_ca_file'] != '') { $ssl_files['ssl_ca_file'] = makeCorrectFile($sslcertpath . '/' . $domain['domain'] . '_CA.pem'); } if ($dom_certs['ssl_cert_chainfile'] != '') { if (Settings::Get('system.webserver') == 'nginx') { // put ca.crt in my.crt, as nginx does not support a separate chain file. $dom_certs['ssl_cert_file'] = trim($dom_certs['ssl_cert_file']) . "\n" . trim($dom_certs['ssl_cert_chainfile']) . "\n"; } else { $ssl_files['ssl_cert_chainfile'] = makeCorrectFile($sslcertpath . '/' . $domain['domain'] . '_chain.pem'); } } // create them on the filesystem foreach ($ssl_files as $type => $filename) { if ($filename != '') { touch($filename); $_fh = fopen($filename, 'w'); fwrite($_fh, $dom_certs[$type]); fclose($_fh); chmod($filename, 0600); } } // override corresponding array values $domain['ssl_cert_file'] = $ssl_files['ssl_cert_file']; $domain['ssl_key_file'] = $ssl_files['ssl_key_file']; $domain['ssl_ca_file'] = $ssl_files['ssl_ca_file']; $domain['ssl_cert_chainfile'] = $ssl_files['ssl_cert_chainfile']; } return; }
/** * Create or modify the AWStats configuration file for the given domain. * Modified by Berend Dekens to allow custom configurations. * * @param logFile * @param siteDomain * @param hostAliases * @return null */ function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot, $awstats_params = array()) { global $pathtophpfiles, $settings; // Generation header $header = "## GENERATED BY FROXLOR\n"; $header2 = "## Do not remove the line above! This tells Froxlor to update this configuration\n## If you wish to manually change this configuration file, remove the first line to make sure Froxlor won't rebuild this file\n## Generated for domain {SITE_DOMAIN} on " . date('l dS \\of F Y h:i:s A') . "\n"; $awstats_dir = makeCorrectDir($customerDocroot . '/awstats/' . $siteDomain . '/'); if (!is_dir($awstats_dir)) { safe_exec('mkdir -p ' . escapeshellarg($awstats_dir)); } // chown created folder, #258 makeChownWithNewStats($awstats_params); // weird but could happen... if (!is_dir($settings['system']['awstats_conf'])) { safe_exec('mkdir -p ' . escapeshellarg($settings['system']['awstats_conf'])); } // These are the variables we will replace $regex = array('/\\{LOG_FILE\\}/', '/\\{SITE_DOMAIN\\}/', '/\\{HOST_ALIASES\\}/', '/\\{CUSTOMER_DOCROOT\\}/', '/\\{AWSTATS_CONF\\}/'); $replace = array(makeCorrectFile($logFile), $siteDomain, $hostAliases, $awstats_dir, makeCorrectDir($settings['system']['awstats_conf'])); // File names $domain_file = makeCorrectFile($settings['system']['awstats_conf'] . '/awstats.' . $siteDomain . '.conf'); $model_file = dirname(dirname(dirname(dirname(__FILE__)))); $model_file .= '/templates/misc/awstatsmodel/'; if ($settings['system']['mod_log_sql'] == '1') { $model_file .= 'awstats.froxlor.model_log_sql.conf'; } else { $model_file .= 'awstats.froxlor.model.conf'; } $model_file = makeCorrectFile($model_file); // Test if the file exists if (file_exists($domain_file)) { // Check for the generated header - if this is a manual modification we won't update $awstats_domain_conf = fopen($domain_file, 'r'); if (fgets($awstats_domain_conf, strlen($header)) != $header) { fclose($awstats_domain_conf); return; } // Close the file fclose($awstats_domain_conf); } $awstats_domain_conf = fopen($domain_file, 'w'); $awstats_model_conf = fopen($model_file, 'r'); // Write the header fwrite($awstats_domain_conf, $header); fwrite($awstats_domain_conf, preg_replace($regex, $replace, $header2)); // Write the configuration file while (($line = fgets($awstats_model_conf, 4096)) !== false) { if (!preg_match('/^#/', $line) && trim($line) != '') { fwrite($awstats_domain_conf, preg_replace($regex, $replace, $line)); } } fclose($awstats_domain_conf); fclose($awstats_model_conf); }
function includeCronjobs($debugHandler, $pathtophpfiles) { global $settings; $cronjobs = getNextCronjobs(); $jobs_to_run = array(); $cron_path = makeCorrectDir($pathtophpfiles . '/scripts/jobs/'); if ($cronjobs !== false && is_array($cronjobs) && isset($cronjobs[0])) { foreach ($cronjobs as $cronjob) { $cron_file = makeCorrectFile($cron_path . $cronjob); $jobs_to_run[] = $cron_file; } } return $jobs_to_run; }
/** * This file is part of the SysCP project. * Copyright (c) 2003-2009 the SysCP Team (see authors). * * For the full copyright and license information, please view the COPYING * file that was distributed with this source code. You can also view the * COPYING file online at http://files.syscp.org/misc/COPYING.txt * * @copyright (c) the authors * @author Florian Lippert <*****@*****.**> * @license GPLv2 http://files.syscp.org/misc/COPYING.txt * @package Functions * @version $Id$ */ function validateFormFieldString($fieldname, $fielddata, $newfieldvalue) { if (isset($fielddata['string_delimiter']) && $fielddata['string_delimiter'] != '') { $newfieldvalues = explode($fielddata['string_delimiter'], $newfieldvalue); unset($fielddata['string_delimiter']); $returnvalue = true; foreach ($newfieldvalues as $single_newfieldvalue) { $single_returnvalue = validateFormFieldString($fieldname, $fielddata, $single_newfieldvalue); if ($single_returnvalue !== true) { $returnvalue = $single_returnvalue; break; } } } else { $returnvalue = false; if (isset($fielddata['string_type']) && $fielddata['string_type'] == 'mail') { $returnvalue = filter_var($newfieldvalue, FILTER_VALIDATE_EMAIL) == $newfieldvalue; } elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'url') { $returnvalue = validateUrl($newfieldvalue); } elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'dir') { $returnvalue = $newfieldvalue == makeCorrectDir($newfieldvalue); } elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'file') { $returnvalue = $newfieldvalue == makeCorrectFile($newfieldvalue); } elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'filedir') { $returnvalue = $newfieldvalue == makeCorrectDir($newfieldvalue) || $newfieldvalue == makeCorrectFile($newfieldvalue); } elseif (preg_match('/^[^\\r\\n\\t\\f\\0]*$/D', $newfieldvalue)) { $returnvalue = true; } if (isset($fielddata['string_regexp']) && $fielddata['string_regexp'] != '') { if (preg_match($fielddata['string_regexp'], $newfieldvalue)) { $returnvalue = true; } else { $returnvalue = false; } } if (isset($fielddata['string_emptyallowed']) && $fielddata['string_emptyallowed'] === true && $newfieldvalue === '') { $returnvalue = true; } elseif (isset($fielddata['string_emptyallowed']) && $fielddata['string_emptyallowed'] === false && $newfieldvalue === '') { $returnvalue = 'stringmustntbeempty'; } } if ($returnvalue === true) { return true; } elseif ($returnvalue === false) { return 'stringformaterror'; } else { return $returnvalue; } }
/** * Function getPreConfig * * outputs various content before the update process * can be continued (askes for agreement whatever is being asked) * * @param string version * * @return string */ function getPreConfig($current_version) { $has_preconfig = false; $return = '<div class="preconfig"><h3 style="color:#ff0000;">PLEASE NOTE - Important update notifications</h3>'; include_once makeCorrectFile(dirname(__FILE__) . '/preconfig/0.9/preconfig_0.9.inc.php'); parseAndOutputPreconfig($has_preconfig, $return, $current_version); $return .= '<br /><br />' . makecheckbox('update_changesagreed', '<strong>I have read the update notifications above and I am aware of the changes made to my system.</strong>', '1', true, '0', true); $return .= '</div>'; $return .= '<input type="hidden" name="update_preconfig" value="1" />'; if ($has_preconfig) { return $return; } else { return ''; } }
private function wipeOutOldConfigs() { fwrite($this->debugHandler, ' apache::wipeOutOldConfigs: cleaning ' . $this->settings['system']['apacheconf_vhost'] . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, "cleaning " . $this->settings['system']['apacheconf_vhost']); if (isConfigDir($this->settings['system']['apacheconf_vhost']) && file_exists($this->settings['system']['apacheconf_vhost']) && is_dir($this->settings['system']['apacheconf_vhost'])) { $vhost_file_dirhandle = opendir($this->settings['system']['apacheconf_vhost']); while (false !== ($vhost_filename = readdir($vhost_file_dirhandle))) { if ($vhost_filename != '.' && $vhost_filename != '..' && !in_array($vhost_filename, $this->known_filenames) && preg_match('/^(10|20|30)_syscp_ipandport_(.+)\\.conf$/', $vhost_filename) && file_exists(makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/' . $vhost_filename))) { fwrite($this->debugHandler, ' apache::wipeOutOldConfigs: unlinking ' . $vhost_filename . "\n"); $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'unlinking ' . $vhost_filename); unlink(makeCorrectFile($this->settings['system']['apacheconf_vhost'] . '/' . $vhost_filename)); } } } }
private function _connectToPdnsDb() { // get froxlor pdns config $cf = Settings::Get('system.bindconf_directory') . '/froxlor/pdns_froxlor.conf'; $config = makeCorrectFile($cf); if (!file_exists($config)) { $this->_logger->logAction(CRON_ACTION, LOG_ERROR, 'PowerDNS configuration file (' . $config . ') not found. Did you go through the configuration templates?'); die('PowerDNS configuration file (' . $config . ') not found. Did you go through the configuration templates?' . PHP_EOL); } $lines = file($config); $mysql_data = array(); foreach ($lines as $line) { $line = trim($line); if (strtolower(substr($line, 0, 6)) == 'gmysql') { $namevalue = explode("=", $line); $mysql_data[$namevalue[0]] = $namevalue[1]; } } // build up connection string $driver = 'mysql'; $dsn = $driver . ":"; $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'set names utf8'); $attributes = array('ATTR_ERRMODE' => 'ERRMODE_EXCEPTION'); $dbconf = array(); $dbconf["dsn"] = array('dbname' => $mysql_data["gmysql-dbname"], 'charset' => 'utf8'); if (isset($mysql_data['gmysql-socket']) && !empty($mysql_data['gmysql-socket'])) { $dbconf["dsn"]['unix_socket'] = makeCorrectFile($mysql_data['gmysql-socket']); } else { $dbconf["dsn"]['host'] = $mysql_data['gmysql-host']; $dbconf["dsn"]['port'] = $mysql_data['gmysql-port']; } // add options to dsn-string foreach ($dbconf["dsn"] as $k => $v) { $dsn .= $k . "=" . $v . ";"; } // clean up unset($dbconf); // try to connect try { $this->pdns_db = new PDO($dsn, $mysql_data['gmysql-user'], $mysql_data['gmysql-password'], $options); } catch (PDOException $e) { die($e->getMessage()); } // set attributes foreach ($attributes as $k => $v) { $this->pdns_db->setAttribute(constant("PDO::" . $k), constant("PDO::" . $v)); } }
Database::pexecute($result_stmt, $result_data); while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { if (isset($row['traffic']) && $row['traffic'] > 0 && $row['traffic_used_total'] * 100 / $row['traffic'] >= (int) Settings::Get('system.report_trafficmax')) { $replace_arr = array('NAME' => $row['name'], 'TRAFFIC' => round($row['traffic'] / 1024, 2), 'TRAFFICUSED' => round($row['traffic_used_total'] / 1024, 2), 'USAGE_PERCENT' => round($row['traffic_used_total'] * 100 / $row['traffic'], 2), 'MAX_PERCENT' => Settings::Get('system.report_trafficmax')); $lngfile_stmt = Database::prepare("\n\t\t\tSELECT `file` FROM `" . TABLE_PANEL_LANGUAGE . "`\n\t\t\tWHERE `language` = :deflang\n\t\t"); $lngfile = Database::pexecute_first($lngfile_stmt, array('deflang' => $row['def_language'])); if ($lngfile !== null) { $langfile = $lngfile['file']; } else { $lngfile = Database::pexecute_first($lngfile_stmt, array('deflang' => Settings::Get('panel.standardlanguage'))); $langfile = $lngfile['file']; } // include english language file (fallback) include_once makeCorrectFile(FROXLOR_INSTALL_DIR . '/lng/english.lng.php'); // include admin/customer language file include_once makeCorrectFile(FROXLOR_INSTALL_DIR . '/' . $langfile); // Get mail templates from database; the ones from 'admin' are fetched for fallback $result2_stmt = Database::prepare("\n\t\t\tSELECT `value` FROM `" . TABLE_PANEL_TEMPLATES . "`\n\t\t\tWHERE `adminid` = :adminid\n\t\t\tAND `language` = :lang\n\t\t\tAND `templategroup` = 'mails' AND `varname` = :varname\n\t\t"); $resul2_data = array('adminid' => $row['adminid'], 'lang' => $row['def_language'], 'varname' => 'trafficmaxpercent_subject'); $result2 = Database::pexecute_first($result2_stmt, $result2_data); $mail_subject = html_entity_decode(replace_variables($result2['value'] != '' ? $result2['value'] : $lng['mails']['trafficmaxpercent']['subject'], $replace_arr)); $resul2_data['varname'] = 'trafficmaxpercent_mailbody'; $result2 = Database::pexecute_first($result2_stmt, $result2_data); $mail_body = html_entity_decode(replace_variables($result2['value'] != '' ? $result2['value'] : $lng['mails']['trafficmaxpercent']['mailbody'], $replace_arr)); $_mailerror = false; try { $mail->SetFrom($row['email'], $row['name']); $mail->Subject = $mail_subject; $mail->AltBody = $mail_body; $mail->MsgHTML(nl2br($mail_body)); $mail->AddAddress($row['email'], $row['name']);
if (isset($argv[$x])) { // --force if (strtolower($argv[$x]) == '--force') { $crontasks = makeCorrectFile(FROXLOR_INSTALL_DIR . '/scripts/jobs/cron_tasks.php'); // really force re-generating of config-files by // inserting task 1 inserttask('1'); // bind (if enabled, inserttask() checks this) inserttask('4'); // also regenerate cron.d-file inserttask('99'); addToQueue($jobs_to_run, $crontasks); $lastrun_update['tasks'] = $crontasks; } elseif (substr(strtolower($argv[$x]), 0, 2) == '--') { if (strlen($argv[$x]) > 3) { $cronfile = makeCorrectFile(FROXLOR_INSTALL_DIR . '/scripts/jobs/cron_' . substr(strtolower($argv[$x]), 2) . '.php'); addToQueue($jobs_to_run, $cronfile); $lastrun_update[substr(strtolower($argv[$x]), 2)] = $cronfile; } } } } // do we have anything to include? if (count($jobs_to_run) > 0) { // include all jobs we want to execute foreach ($jobs_to_run as $cron) { updateLastRunOfCron($lastrun_update, $cron); require_once $cron; } } fwrite($debugHandler, 'Cronfiles have been included' . "\n");
/** * return path of fpm-socket file * * @param boolean $createifnotexists create the directory if it does not exist * * @return string the full path to the socket */ public function getSocketFile($createifnotexists = true) { $socketdir = makeCorrectDir(Settings::Get('phpfpm.fastcgi_ipcdir')); $socket = makeCorrectFile($socketdir . '/' . $this->_domain['loginname'] . '-' . $this->_domain['domain'] . '-php-fpm.socket'); if (!is_dir($socketdir) && $createifnotexists) { safe_exec('mkdir -p ' . escapeshellarg($socketdir)); safe_exec('chown -R ' . Settings::Get('system.httpuser') . ':' . Settings::Get('system.httpgroup') . ' ' . escapeshellarg($socketdir)); } return $socket; }
* This file is part of the Froxlor project. * Copyright (c) 2010 the Froxlor Team (see authors). * * For the full copyright and license information, please view the COPYING * file that was distributed with this source code. You can also view the * COPYING file online at http://files.froxlor.org/misc/COPYING.txt * * @copyright (c) the authors * @author Froxlor team <*****@*****.**> (2010-) * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @package Configfiles * */ // Try to guess user/group from settings' email UID/GID $vmail_user = posix_getpwuid(Settings::Get('system.vmail_uid')); $vmail_group = posix_getgrgid(Settings::Get('system.vmail_gid')); /* If one of them are not set, call it 'vmail' and suggest creating user/group * in scripts. */ if ($vmail_user === false) { $vmail_username = "******"; } else { $vmail_username = $vmail_user['name']; } if ($vmail_group === false) { $vmail_groupname = "vmail"; } else { $vmail_groupname = $vmail_group['name']; } return array('freebsd' => array('label' => 'FreeBSD', 'services' => array('http' => array('label' => $lng['admin']['configfiles']['http'], 'daemons' => array('nginx' => array('label' => 'Nginx Webserver', 'commands_1' => array('cd /usr/ports/www/nginx', 'make config', 'set [x] IPv6 protocol (default)', 'set [x] Enable HTTP module (default)', 'set [x] Enable http_cache module (default)', 'set [x] Enable http_gzip_static module', 'set [x] Enable http_rewrite module (default)', 'set [x] Enable http_ssl module (default)', 'set [x] Enable http_stub_status module (default)', 'make install clean; rehash'), 'commands_2' => array($configcommand['vhost'], $configcommand['diroptions'], Settings::Get('system.deactivateddocroot') != '' ? 'mkdir -p ' . Settings::Get('system.deactivateddocroot') : '', 'mkdir -p ' . Settings::Get('system.documentroot_prefix'), 'mkdir -p ' . Settings::Get('system.mod_fcgid_tmpdir'), 'mkdir -p ' . Settings::Get('system.logfiles_directory'), 'echo "nginx_enable=\\"YES\\"" >> /etc/rc.conf'), 'files' => array('usr_local_etc_nginx_nginx.conf' => '/usr/local/etc/nginx/nginx.conf'), 'restart' => array('/usr/local/etc/rc.d/nginx restart')), 'apache2' => array('label' => 'Apache2 Webserver', 'commands' => array('cd /usr/ports/www/apache22', 'make config', 'make install', $configcommand['vhost'], 'chown root:0 ' . Settings::Get('system.apacheconf_vhost'), 'chmod 0600 ' . Settings::Get('system.apacheconf_vhost'), $configcommand['diroptions'], 'chown root:0 ' . Settings::Get('system.apacheconf_diroptions'), 'chmod 0600 ' . Settings::Get('system.apacheconf_diroptions'), 'mkdir -p ' . Settings::Get('system.documentroot_prefix'), 'mkdir -p ' . Settings::Get('system.logfiles_directory'), Settings::Get('system.deactivateddocroot') != '' ? 'mkdir -p ' . Settings::Get('system.deactivateddocroot') : '', 'mkdir -p ' . Settings::Get('system.mod_fcgid_tmpdir'), 'chmod 1777 ' . Settings::Get('system.mod_fcgid_tmpdir'), 'echo "accf_http_load=\\"YES\\"" >> /boot/loader.conf', 'echo "accf_data_load=\\"YES\\"" >> /boot/loader.conf', 'echo "apache22_enable=\\"YES\\"" >> /etc/rc.conf'), 'restart' => array('sh /usr/local/etc/rc.d/apache22 restart')))), 'dns' => array('label' => $lng['admin']['configfiles']['dns'], 'daemons' => array('bind9' => array('label' => 'Bind9 Nameserver', 'commands_1' => array('cd /usr/ports/dns/bind99', 'make config', 'set [x] International Domain Names', 'set [x] IPv6 protocol (default)', 'set [x] 64-bit file support', 'set [x] Replace base BIND with this version', 'set [x] Enable RPZ NSDNAME policy records', 'set [x] Enable RPZ NSIP trigger rules', 'set [x] dig/host/nslookup will do DNSSEC validation', 'set [x] Build with OpenSSL (Required for DNSSEC) (default)', 'set [x] Threading support (default)', 'make install clean; rehash'), 'commands_2' => array('echo "named_enable=\\"YES\\"" >> /etc/rc.conf', PHP_EOL, strpos(Settings::Get('system.bindconf_directory'), '/etc/namedb') === false ? '(TIP: Be sure the path below is "/etc/namedb", if not you have configured the bind-directory in a false way in PANEL->SETTINGS->NAMESERVER SETTINGS!)' : null, 'echo "include \\"' . Settings::Get('system.bindconf_directory') . 'froxlor_bind.conf\\";" >> ' . Settings::Get('system.bindconf_directory') . 'named.conf', 'echo "include \\"' . Settings::Get('system.bindconf_directory') . 'default-zone\\";" >> ' . Settings::Get('system.bindconf_directory') . 'named.conf'), 'files' => array('etc_namedb_named.conf' => Settings::Get('system.bindconf_directory') . 'named.conf', 'etc_namedb_master_default.zone' => Settings::Get('system.bindconf_directory') . 'master/default.zone', 'etc_namedb_default-zone' => Settings::Get('system.bindconf_directory') . 'default-zone'), 'restart' => array('/etc/rc.d/named restart')), 'powerdns' => array('label' => 'PowerDNS', 'commands_1' => array('cd /usr/ports/dns/powerdns', 'make config', 'set MySQL backend', 'make install', 'echo "pdns_enable=\\"YES\\"" >> /etc/rc.conf'), 'files' => array('usr_local_etc_pdns_pdns.conf' => '/usr/local/etc/pdns/pdns.conf'), 'commands' => array('touch ' . Settings::Get('system.bindconf_directory') . 'froxlor_bind.conf', 'chown root:0 ' . Settings::Get('system.bindconf_directory') . 'froxlor_bind.conf', 'chmod 0600 ' . Settings::Get('system.bindconf_directory') . 'froxlor_bind.conf'), 'restart' => array('sh /usr/local/etc/rc.d/pdns restart')))), 'smtp' => array('label' => $lng['admin']['configfiles']['smtp'], 'daemons' => array('postfix' => array('label' => 'Postfix', 'commands_1' => array('cd /usr/ports/mail/postfix', 'make config', 'set Dovecot SASL authentication method', 'set Enable SSL and TLS support', 'set MySQL maps (choose version with WITH_MYSQL_VER)', 'make install'), 'commands_2' => array($vmail_group === false ? 'pw groupadd ' . $vmail_groupname . ' -g ' . Settings::Get('system.vmail_gid') : '', $vmail_user === false ? 'pw useradd ' . $vmail_username . ' -u ' . Settings::Get('system.vmail_uid') . ' -g ' . Settings::Get('system.vmail_gid') . ' -s/sbin/nologin -d/dev/null' : '', 'mkdir -p ' . Settings::Get('system.vmail_homedir'), 'chown -R ' . $vmail_username . ':' . $vmail_groupname . ' ' . Settings::Get('system.vmail_homedir'), 'chmod 0750 ' . Settings::Get('system.vmail_homedir')), 'commands_3' => array('echo "sendmail_enable=\\"NO\\"" >> /etc/rc.conf', 'echo "sendmail_submit_enable=\\"NO\\"" >> /etc/rc.conf', 'echo "sendmail_outbound_enable=\\"NO\\"" >> /etc/rc.conf', 'echo "sendmail_msp_queue_enable=\\"NO\\"" >> /etc/rc.conf', 'echo "postfix_enable=\\"YES\\"" >> /etc/rc.conf'), 'files' => array('etc_periodic.conf' => '/etc/periodic.conf', 'usr_local_etc_postfix_main.cf' => '/usr/local/etc/postfix/main.cf', 'usr_local_etc_postfix_mysql-virtual_alias_maps.cf' => '/usr/local/etc/postfix/mysql-virtual_alias_maps.cf', 'usr_local_etc_postfix_mysql-virtual_mailbox_domains.cf' => '/usr/local/etc/postfix/mysql-virtual_mailbox_domains.cf', 'usr_local_etc_postfix_mysql-virtual_mailbox_maps.cf' => '/usr/local/etc/postfix/mysql-virtual_mailbox_maps.cf', 'usr_local_etc_postfix_mysql-virtual_sender_permissions.cf' => '/usr/local/etc/postfix/mysql-virtual_sender_permissions.cf'), 'restart' => array('newaliases', 'mkdir /var/spool/postfix/etc', 'cp /etc/resolv.conf /var/spool/postfix/etc', 'sh /usr/local/etc/rc.d/postfix restart')), 'postgrey' => array('label' => 'Postgrey', 'commands_1' => array('cd /usr/ports/mail/postgrey', 'make install clean'), 'commands_2' => array('sed -i.bak \'s/# *check_policy_service *inet:127\\.0\\.0\\.1:10023/ check_policy_service inet:127\\.0\\.0\\.1:10023/\' /usr/local/etc/postfix/main.cf', 'echo "postgrey_enable=\\"YES\\"" >> /etc/rc.conf'), 'restart' => array('/usr/local/etc/rc.d/postgrey restart', '/usr/local/etc/rc.d/postfix restart')), 'postfix_mxaccess' => array('label' => 'Postfix MX-Access (anti spam)', 'files' => array('etc_postfix_mx_access' => '/usr/local/etc/postfix/mx_access', 'etc_postfix_main.cf' => '/usr/local/etc/postfix/main.cf'), 'commands_1' => array('postmap /usr/local/etc/postfix/mx_access'), 'restart' => array('/usr/local/etc/rc.d/postfix restart')), 'dkim' => array('label' => 'DomainKey filter', 'commands' => array('cd /usr/ports/mail/dkim-milter/', 'make install clean', 'touch /usr/local/etc/mail/dkim-filter.conf'), 'files' => array('dkim-filter.conf' => '/usr/local/etc/mail/dkim-filter.conf', 'postfix_dkim_addition.cf' => '/usr/local/etc/postfix/main.cf'), 'restart' => array('/usr/local/etc/rc.d/milter-dkim restart ')))), 'mail' => array('label' => $lng['admin']['configfiles']['mail'], 'daemons' => array('dovecot' => array('label' => 'Dovecot', 'commands_1' => array('cd /usr/ports/mail/dovecot', 'make config', 'set kqueue(2) support ', 'set SSL support ', 'set ManageSieve support (optional)', 'set MySQL support ', 'make install', 'echo "dovecot_enable=\\"YES\\"" >> /etc/rc.conf'), 'files' => array('usr_local_etc_dovecot.conf' => '/usr/local/etc/dovecot.conf', 'usr_local_etc_dovecot-sql.conf' => '/usr/local/etc/dovecot-sql.conf'), 'commands_2' => array('echo "dovecot unix - n n - - pipe flags=DRhu user='******':' . $vmail_groupname . ' argv=/usr/local/libexec/dovecot/deliver -f ${sender} -d ${recipient}" >> /usr/local/etc/postfix/master.cf', 'chmod 0640 /usr/local/etc/dovecot-sql.conf'), 'restart' => array('sh /usr/local/etc/rc.d/dovecot restart')), 'dovecot2' => array('label' => 'Dovecot 2.x', 'commands_1' => array('cd /usr/ports/mail/dovecot2', 'make config', 'set [x] kqueue(2) support (default)', 'set [x] MySQL database', 'set [x] SSL protocol (default)', 'make install clean; rehash'), 'commands_2' => array('echo "dovecot_enable=\\"YES\\"" >> /etc/rc.conf', PHP_EOL, 'pw adduser ' . $vmail_username . ' -g ' . $vmail_groupname . ' -u ' . Settings::Get('system.vmail_gid') . ' -d /nonexistent -s /usr/sbin/nologin -c "User for virtual mailtransport used by Postfix and Dovecot"', PHP_EOL, 'chmod 0640 /usr/local/etc/dovecot-sql.conf'), 'files' => array('usr_local_etc_dovecot_dovecot.conf' => '/usr/local/etc/dovecot/dovecot.conf', 'usr_local_etc_dovecot_dovecot-sql.conf' => '/usr/local/etc/dovecot/dovecot-sql.conf'), 'commands_3' => array('echo "dovecot unix - n n - - pipe' . PHP_EOL . 'flags=DRhu user='******':' . $vmail_groupname . ' argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient} -a ${recipient}" >> /usr/local/etc/postfix/master.cf'), 'restart' => array('/usr/local/etc/rc.d/dovecot restart')))), 'ftp' => array('label' => $lng['admin']['configfiles']['ftp'], 'daemons' => array('proftpd' => array('label' => 'ProFTPd', 'commands_1' => array('cd /usr/ports/ftp/proftpd', 'make config', 'set MySQL auth', 'set Include mod_quota', 'make install clean'), 'commands_2' => array('touch /usr/local/etc/proftpd.conf', 'chown root:0 /usr/local/etc/proftpd.conf', 'chmod 0600 /usr/local/etc/proftpd.conf', 'echo "proftpd_enable=\\"YES\\"" >> /etc/rc.conf'), 'files' => array('etc_proftpd_proftpd.conf' => '/usr/local/etc/proftpd.conf'), 'restart' => array('/usr/local/etc/rc.d/proftpd restart')), 'pure-ftpd' => array('label' => 'Pure-FTPd', 'commands_1' => array('cd /usr/ports/ftp/pure-ftpd', 'make config', '# select LARGEFILE,MYSQL,PAM,PRIVSEP,SENDFILE,THROTTLING,TLS,UTF8,VIRTUALCHROOT', 'make install clean'), 'commands_2' => array('touch /usr/local/etc/pure-ftpd.conf', 'touch /usr/local/etc/pureftpd-mysql.conf', 'chown root:0 /usr/local/etc/pure-ftpd.conf', 'chown root:0 /usr/local/etc/pureftpd-mysql.conf', 'chmod 0600 /usr/local/etc/pure-ftpd.conf', 'chmod 0600 /usr/local/etc/pureftpd-mysql.conf', 'echo "pure-ftpd_enable="YES" >> /etc/rc.conf'), 'files' => array('usr_local_etc_pure-ftpd.conf' => '/usr/local/etc/pure-ftpd.conf', 'usr_local_etc_pureftpd-mysql.conf' => '/usr/local/etc/pureftpd-mysql.conf'), 'restart' => array('service pure-ftpd restart')))), 'etc' => array('label' => $lng['admin']['configfiles']['etc'], 'daemons' => array('cron' => array('label' => 'Crond (cronscript)', 'commands' => array('echo "*/5 * * * * root nice -n 5 /usr/local/bin/php -q ' . makeCorrectDir(dirname(dirname(dirname(__FILE__)))) . 'scripts/froxlor_master_cronjob.php" >> /etc/crontab'), 'restart' => array(Settings::Get('system.crondreload'))), 'awstats' => array('label' => 'Awstats', 'commands' => array('cd /usr/ports/www/awstats/', 'make install clean', 'cp /usr/local/www/awstats/cgi-bin/awstats.model.conf ' . makeCorrectDir(Settings::Get('system.awstats_conf')), 'sed -i.bak \'s/^LogFile/# LogFile/\' ' . makeCorrectFile(Settings::Get('system.awstats_conf') . '/awstats.model.conf'), 'sed -i.bak \'s/^LogType/# LogType/\' ' . makeCorrectFile(Settings::Get('system.awstats_conf') . '/awstats.model.conf'), 'sed -i.bak \'s/^LogFormat/# LogFormat/\' ' . makeCorrectFile(Settings::Get('system.awstats_conf') . '/awstats.model.conf'), 'sed -i.bak \'s/^LogSeparator/# LogSeparator/\' ' . makeCorrectFile(Settings::Get('system.awstats_conf') . '/awstats.model.conf'), 'sed -i.bak \'s/^SiteDomain/# SiteDomain/\' ' . makeCorrectFile(Settings::Get('system.awstats_conf') . '/awstats.model.conf'), 'sed -i.bak \'s/^DirData/# DirData/\' ' . makeCorrectFile(Settings::Get('system.awstats_conf') . '/awstats.model.conf'), 'sed -i.bak \'s|^\\(DirIcons=\\).*$|\\1\\"/awstats-icon\\"|\' ' . makeCorrectFile(Settings::Get('system.awstats_conf') . '/awstats.model.conf'), '# Please make sure you deactivate awstats own cronjob as Froxlor handles that itself')), 'libnss' => array('label' => 'libnss (system login with mysql)', 'commands_1' => array('cd /usr/ports/net/libnss-mysql', 'make install clean', 'echo "nscd_enable=\\"YES\\"" >> /etc/rc.conf'), 'files' => array('usr_local_etc_libnss-mysql.cfg' => '/usr/local/etc/libnss-mysql.cfg', 'usr_local_etc_libnss-mysql-root.cfg' => '/usr/local/etc/libnss-mysql-root.cfg', 'etc_nsswitch.conf' => '/etc/nsswitch.conf'), 'commands_2' => array('chmod 600 /usr/local/etc/libnss-mysql.cfg /usr/local/etc/libnss-mysql-root.cfg'), 'restart' => array('sh /etc/rc.d/nscd restart')), 'logrotate' => array('label' => 'Logrotate', 'commands_1' => array('cd /usr/ports/sysutils/logrotate/', 'make install clean clean-depends', 'touch /etc/logrotate.d/froxlor', 'chmod 644 /etc/logrotate.d/froxlor'), 'files' => array('etc_logrotated_froxlor' => '/etc/logrotate.d/froxlor'), 'commands_2' => array('# create cronjob-entry (daily-recommended)', '0 2 * * * /usr/local/sbin/logrotate -f /etc/logrotate.d/froxlor')))))));
* Copyright (c) 2011- the Froxlor Team (see authors). * * For the full copyright and license information, please view the COPYING * file that was distributed with this source code. You can also view the * COPYING file online at http://files.froxlor.org/misc/COPYING.txt * * @copyright (c) the authors * @author Andrej S***n <*****@*****.**> (2010-2011) * @author Wolfgang Rosenauer <*****@*****.**> (2011) * @author Froxlor team <*****@*****.**> (2011-) * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @package Configfiles * */ // Try to guess user/group from settings' email UID/GID $vmail_user = posix_getpwuid(Settings::Get('system.vmail_uid')); $vmail_group = posix_getgrgid(Settings::Get('system.vmail_gid')); /* If one of them are not set, call it 'vmail' and suggest creating user/group * in scripts. */ if ($vmail_user === false) { $vmail_username = "******"; } else { $vmail_username = $vmail_user['name']; } if ($vmail_group === false) { $vmail_groupname = "vmail"; } else { $vmail_groupname = $vmail_group['name']; } return array('sle_11' => array('label' => 'SUSE Linux Enterprise 11', 'services' => array('http' => array('label' => $lng['admin']['configfiles']['http'], 'daemons' => array('apache' => array('label' => 'Apache', 'commands' => array('mkdir -p ' . Settings::Get('system.documentroot_prefix'), 'mkdir -p ' . Settings::Get('system.logfiles_directory'), 'Maybe add to /etc/apache2/httpd.conf', 'Alias /mail /srv/www/htdocs/roundcubemail', 'Alias /webmail /srv/www/htdocs/squirrelmail', Settings::Get('system.deactivateddocroot') != '' ? 'mkdir -p ' . Settings::Get('system.deactivateddocroot') : ''), 'restart' => array(' ' . '/etc/init.d/apache2 restart')))), 'dns' => array('label' => $lng['admin']['configfiles']['dns'], 'daemons' => array('bind' => array('label' => 'Bind9', 'commands' => array('Add froxlor_bind.conf to the NAMED_CONF_INCLUDE_FILES in /etc/sysconfig/named'), 'restart' => array('/etc/init.d/named restart')))), 'smtp' => array('label' => $lng['admin']['configfiles']['smtp'], 'daemons' => array('postfix' => array('label' => 'Postfix', 'files' => array('etc_postfix_main.cf' => '/etc/postfix/main.cf', 'etc_postfix_mysql-virtual_alias_maps.cf' => '/etc/postfix/mysql_virtual_alias_maps.cf', 'etc_postfix_mysql-virtual_mailbox_domains.cf' => '/etc/postfix/mysql_virtual_mailbox_domains.cf', 'etc_postfix_mysql-virtual_mailbox_maps.cf' => '/etc/postfix/mysql_virtual_mailbox_maps.cf', 'etc_sasl2_smtpd.conf' => '/etc/sasl2/smtpd.conf'), 'commands' => array($vmail_group === false ? 'groupadd -g ' . Settings::Get('system.vmail_gid') . ' ' . $vmail_groupname : '', $vmail_user === false ? 'useradd -u ' . Settings::Get('system.vmail_uid') . ' -g ' . $vmail_groupname . ' ' . $vmail_username : '', 'mkdir -p ' . Settings::Get('system.vmail_homedir'), 'chown -R ' . $vmail_username . ':' . $vmail_groupname . ' ' . Settings::Get('system.vmail_homedir'), 'mkdir -p /var/spool/postfix/etc/pam.d', 'touch /etc/postfix/mysql-virtual_alias_maps.cf', 'touch /etc/postfix/mysql-virtual_mailbox_domains.cf', 'touch /etc/postfix/mysql-virtual_mailbox_maps.cf', 'touch /etc/sasl2/smtpd.conf', 'chmod 660 /etc/postfix/mysql_virtual_alias_maps.cf', 'chmod 660 /etc/postfix/mysql_virtual_mailbox_domains.cf', 'chmod 660 /etc/postfix/mysql_virtual_mailbox_maps.cf', 'chmod 660 /etc/sasl2/smtpd.conf', 'chgrp postfix /etc/postfix/mysql_virtual_alias_maps.cf', 'chgrp postfix /etc/postfix/mysql_virtual_mailbox_domains.cf', 'chgrp postfix /etc/postfix/mysql_virtual_mailbox_maps.cf', 'chgrp postfix /etc/sasl2/smtpd.conf'), 'restart' => array('/etc/init.d/postfix restart')), 'postfix_mxaccess' => array('label' => 'Postfix MX-Access (anti spam)', 'files' => array('etc_postfix_mx_access' => '/etc/postfix/mx_access', 'etc_postfix_main.cf' => '/etc/postfix/main.cf'), 'commands_1' => array('postmap /etc/postfix/mx_access'), 'restart' => array('/etc/init.d/postfix restart')), 'postfix_dovecot' => array('label' => 'Postfix/Dovecot', 'commands' => array($vmail_group === false ? 'groupadd -g ' . Settings::Get('system.vmail_gid') . ' ' . $vmail_groupname : '', $vmail_user === false ? 'useradd -u ' . Settings::Get('system.vmail_uid') . ' -g ' . $vmail_groupname . ' ' . $vmail_username : '', 'zypper install postfix postfix-mysql', 'mkdir -p /var/spool/postfix/etc/pam.d', 'mkdir -p /var/spool/postfix/var/run/mysqld', 'mkdir -p ' . Settings::Get('system.vmail_homedir'), 'chown -R ' . $vmail_username . ':' . $vmail_groupname . ' ' . Settings::Get('system.vmail_homedir'), 'touch /etc/postfix/mysql-virtual_alias_maps.cf', 'touch /etc/postfix/mysql-virtual_mailbox_domains.cf', 'touch /etc/postfix/mysql-virtual_mailbox_maps.cf', 'touch /etc/postfix/mysql-virtual_sender_permissions.cf', 'chown root:postfix /etc/postfix/mysql-virtual_alias_maps.cf', 'chown root:postfix /etc/postfix/mysql-virtual_mailbox_domains.cf', 'chown root:postfix /etc/postfix/mysql-virtual_mailbox_maps.cf', 'chown root:postfix /etc/postfix/mysql-virtual_sender_permissions.cf', 'chmod 0640 /etc/postfix/mysql-virtual_alias_maps.cf', 'chmod 0640 /etc/postfix/mysql-virtual_mailbox_domains.cf', 'chmod 0640 /etc/postfix/mysql-virtual_mailbox_maps.cf', 'chmod 0640 /etc/postfix/mysql-virtual_sender_permissions.cf'), 'files' => array('etc_postfix_main.cf' => '/etc/postfix/main.cf', 'etc_postfix_master.cf' => '/etc/postfix/master.cf', 'etc_postfix_mysql-virtual_alias_maps.cf' => '/etc/postfix/mysql-virtual_alias_maps.cf', 'etc_postfix_mysql-virtual_mailbox_domains.cf' => '/etc/postfix/mysql-virtual_mailbox_domains.cf', 'etc_postfix_mysql-virtual_mailbox_maps.cf' => '/etc/postfix/mysql-virtual_mailbox_maps.cf', 'etc_postfix_mysql-virtual_sender_permissions.cf' => '/etc/postfix/mysql-virtual_sender_permissions.cf'), 'restart' => array('/etc/init.d/postfix restart', 'newaliases')), 'exim4' => array('label' => 'Exim4', 'commands_1' => array('zypper install exim'), 'files' => array('etc_exim4_conf.d_acl_30_exim4-config_check_rcpt.rul' => '/etc/exim4/conf.d/acl/30_exim4-config_check_rcpt.rul', 'etc_exim4_conf.d_auth_30_froxlor-config' => '/etc/exim4/conf.d/auth/30_froxlor-config', 'etc_exim4_conf.d_main_10_froxlor-config_options' => '/etc/exim4/conf.d/main/10_froxlor-config_options', 'etc_exim4_conf.d_router_180_froxlor-config' => '/etc/exim4/conf.d/router/180_froxlor-config', 'etc_exim4_conf.d_transport_30_froxlor-config' => '/etc/exim4/conf.d/transport/30_froxlor-config'), 'commands_2' => array('chmod o-rx /var/lib/exim4', 'chmod o-rx /etc/exim4/conf.d/main/10_froxlor-config_options'), 'restart' => array('/etc/init.d/exim4 restart')))), 'mail' => array('label' => $lng['admin']['configfiles']['mail'], 'daemons' => array('courier' => array('label' => 'Courier', 'commands' => array('zypper install courier-imap courier-authlib-mysql'), 'files' => array('etc_authlib_authdaemonrc' => '/etc/authlib/authdaemonrc', 'etc_authlib_authmysqlrc' => '/etc/authlib/authmysqlrc'), 'restart' => array('/etc/init.d/courier-authdaemon restart', '/etc/init.d/courier-pop restart')), 'dovecot' => array('label' => 'Dovecot 1.1', 'commands_1' => array('zypper install dovecot11'), 'files' => array('etc_dovecot_dovecot.conf' => '/etc/dovecot/dovecot.conf', 'etc_dovecot_dovecot-sql.conf' => '/etc/dovecot/dovecot-sql.conf'), 'commands_2' => array('chmod 0640 /etc/dovecot/dovecot-sql.conf'), 'restart' => array('/etc/init.d/dovecot restart')))), 'ftp' => array('label' => $lng['admin']['configfiles']['ftp'], 'daemons' => array('proftpd' => array('label' => 'ProFTPd', 'files' => array('etc_proftpd_modules.conf' => '/etc/proftpd/modules.conf', 'etc_proftpd_proftpd.conf' => '/etc/proftpd/proftpd.conf'), 'restart' => array('/etc/init.d/proftpd restart')), 'pure-ftpd' => array('label' => 'Pure-FTPd', 'files' => array('etc_pure-ftpd.conf' => '/etc/pure-ftpd/pure-ftpd.conf', 'etc_pure-ftpd_mysql.conf' => '/etc/pure-ftpd/pure-ftpd-mysql.conf'), 'restart' => array('/etc/init.d/pure-ftpd restart')))), 'etc' => array('label' => $lng['admin']['configfiles']['etc'], 'daemons' => array('cron' => array('label' => 'Crond (cronscript)', 'files' => array('etc_cron.d_froxlor' => '/etc/cron.d/froxlor'), 'restart' => array(Settings::Get('system.crondreload'))), 'awstats' => array('label' => 'Awstats', 'commands' => array('cp /usr/share/doc/packages/awstats/awstats.model.conf /etc/awstats/', 'sed -i.bak \'s/^DirData/# DirData/\'' . makeCorrectFile(Settings::Get('system.awstats_conf') . '/awstats.model.conf'), 'sed -i.bak \'s|^\\(DirIcons=\\).*$|\\1\\"/awstats-icon\\"|\' ' . makeCorrectFile(Settings::Get('system.awstats_conf') . '/awstats.model.conf'), '# Please make sure you deactivate awstats own cronjob as Froxlor handles that itself')))))));
function getCronFile($cronname) { return makeCorrectFile(FROXLOR_INSTALL_DIR . '/scripts/jobs/cron_' . $cronname . '.php'); }
} } // now get rid of old stuff //(but append /* so we don't delete the directory) $configdir .= '/*'; safe_exec('rm -rf ' . escapeshellarg(makeCorrectFile($configdir))); } } // clear php-fpm-configurations prior to re-creation to keep it clean if ($settings['phpfpm']['enabled'] == '1') { $configdir = makeCorrectDir($settings['phpfpm']['configdir']); if (is_dir($configdir)) { // now get rid of old stuff //(but append /* so we don't delete the directory) $configdir .= '/*'; safe_exec('rm -rf ' . escapeshellarg(makeCorrectFile($configdir))); } } if (!isset($webserver)) { if ($settings['system']['webserver'] == "apache2") { if ($settings['system']['mod_fcgid'] == 1 || $settings['phpfpm']['enabled'] == 1) { $webserver = new apache_fcgid($db, $cronlog, $debugHandler, $idna_convert, $settings); } else { $webserver = new apache($db, $cronlog, $debugHandler, $idna_convert, $settings); } } elseif ($settings['system']['webserver'] == "lighttpd") { if ($settings['system']['mod_fcgid'] == 1 || $settings['phpfpm']['enabled'] == 1) { $webserver = new lighttpd_fcgid($db, $cronlog, $debugHandler, $idna_convert, $settings); } else { $webserver = new lighttpd($db, $cronlog, $debugHandler, $idna_convert, $settings); }
$filelog->logAction(ADM_ACTION, LOG_WARNING, '-------------- START LOG --------------'); } catch (Exception $e) { standard_error('exception', $e->getMessage()); } /* * since froxlor, we have to check if there's still someone * out there using syscp and needs to upgrade */ if (!isFroxlor()) { /** * Upgrading SysCP to Froxlor-0.9 */ include_once makeCorrectFile(dirname(__FILE__) . '/updates/froxlor/upgrade_syscp.inc.php'); } if (isFroxlor()) { include_once makeCorrectFile(dirname(__FILE__) . '/updates/froxlor/0.9/update_0.9.inc.php'); // Check Froxlor - database integrity (only happens after all updates are done, so we know the db-layout is okay) showUpdateStep("Checking database integrity"); $integrity = new IntegrityCheck(); if (!$integrity->checkAll()) { lastStepStatus(2, 'Monkeys ate the integrity'); showUpdateStep("Trying to remove monkeys, feeding bananas"); if (!$integrity->fixAll()) { lastStepStatus(2, 'Some monkeys just would not move'); } else { lastStepStatus(0); } } else { lastStepStatus(0); } $filelog->logAction(ADM_ACTION, LOG_WARNING, '--------------- END LOG ---------------');
<?php /** * This file is part of the Froxlor project. * Copyright (c) 2003-2009 the SysCP Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors). * * For the full copyright and license information, please view the COPYING * file that was distributed with this source code. You can also view the * 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 Configfiles * */ return array('debian_squeeze' => array('label' => 'Debian 6.0 (Squeeze)', 'services' => array('http' => array('label' => $lng['admin']['configfiles']['http'], 'daemons' => array('apache2' => array('label' => 'Apache 2', 'commands' => array('mkdir -p ' . $settings['system']['documentroot_prefix'], 'mkdir -p ' . $settings['system']['logfiles_directory'], $settings['system']['deactivateddocroot'] != '' ? 'mkdir -p ' . $settings['system']['deactivateddocroot'] : '', 'mkdir -p ' . $settings['system']['mod_fcgid_tmpdir'], 'chmod 1777 ' . $settings['system']['mod_fcgid_tmpdir'], 'a2dismod userdir'), 'files' => (int) $settings['phpfpm']['enabled'] == 1 ? array('etc_apache2_mods-enabled_fastcgi.conf' => '/etc/apache2/mods-enabled/fastcgi.conf') : null, 'restart' => array('/etc/init.d/apache2 restart')), 'lighttpd' => array('label' => 'Lighttpd Webserver', 'commands_1' => array('apt-get install lighttpd'), 'files' => array('etc_lighttpd.conf' => '/etc/lighttpd/lighttpd.conf'), 'commands_2' => array($configcommand['vhost'], $configcommand['diroptions'], $configcommand['v_inclighty'], $configcommand['d_inclighty'], 'lighty-disable-mod cgi', 'lighty-disable-mod fastcgi', 'mkdir -p ' . $settings['system']['documentroot_prefix'], 'mkdir -p ' . $settings['system']['logfiles_directory'], $settings['system']['deactivateddocroot'] != '' ? 'mkdir -p ' . $settings['system']['deactivateddocroot'] : '', 'mkdir -p ' . $settings['system']['mod_fcgid_tmpdir'], 'chmod 1777 ' . $settings['system']['mod_fcgid_tmpdir']), 'restart' => array('/etc/init.d/lighttpd restart')), 'nginx' => array('label' => 'Nginx Webserver', 'commands_1' => array('apt-get install nginx php5-cgi'), 'files' => array('etc_nginx_nginx.conf' => '/etc/nginx/nginx.conf', 'etc_init.d_php-fcgi' => '/etc/init.d/php-fcgi'), 'commands_2' => array('rm /etc/nginx/sites-enabled/default', 'mkdir -p ' . $settings['system']['documentroot_prefix'], 'mkdir -p ' . $settings['system']['logfiles_directory'], 'mkdir -p ' . $settings['system']['mod_fcgid_tmpdir'], 'chmod 1777 ' . $settings['system']['mod_fcgid_tmpdir'], 'chmod u+x /etc/init.d/php-fcgi'), 'restart' => array('/etc/init.d/php-fcgi start', '/etc/init.d/nginx restart')))), 'dns' => array('label' => $lng['admin']['configfiles']['dns'], 'daemons' => array('bind' => array('label' => 'Bind9', 'commands' => array('apt-get install bind9', 'echo "include \\"' . $settings['system']['bindconf_directory'] . 'froxlor_bind.conf\\";" >> /etc/bind/named.conf', 'touch ' . $settings['system']['bindconf_directory'] . 'froxlor_bind.conf', 'chown root:bind ' . $settings['system']['bindconf_directory'] . 'froxlor_bind.conf', 'chmod 0644 ' . $settings['system']['bindconf_directory'] . 'froxlor_bind.conf'), 'restart' => array('/etc/init.d/bind9 restart')), 'powerdns' => array('label' => 'PowerDNS', 'files' => array('etc_powerdns_pdns.conf' => '/etc/powerdns/pdns.conf', 'etc_powerdns_pdns-froxlor.conf' => '/etc/powerdns/pdns_froxlor.conf'), 'restart' => array('/etc/init.d/pdns restart')))), 'smtp' => array('label' => $lng['admin']['configfiles']['smtp'], 'daemons' => array('postfix_courier' => array('label' => 'Postfix/Courier', 'commands' => array('apt-get install postfix postfix-mysql libsasl2-2 libsasl2-modules libsasl2-modules-sql', 'mkdir -p /var/spool/postfix/etc/pam.d', 'mkdir -p /var/spool/postfix/var/run/mysqld', 'groupadd -g ' . $settings['system']['vmail_gid'] . ' vmail', 'useradd -u ' . $settings['system']['vmail_uid'] . ' -g vmail vmail', 'mkdir -p ' . $settings['system']['vmail_homedir'], 'chown -R vmail:vmail ' . $settings['system']['vmail_homedir'], 'touch /etc/postfix/mysql-virtual_alias_maps.cf', 'touch /etc/postfix/mysql-virtual_mailbox_domains.cf', 'touch /etc/postfix/mysql-virtual_mailbox_maps.cf', 'touch /etc/postfix/mysql-virtual_sender_permissions.cf', 'touch /etc/postfix/sasl/smtpd.conf', 'chown root:root /etc/postfix/main.cf', 'chown root:postfix /etc/postfix/mysql-virtual_alias_maps.cf', 'chown root:postfix /etc/postfix/mysql-virtual_mailbox_domains.cf', 'chown root:postfix /etc/postfix/mysql-virtual_mailbox_maps.cf', 'chown root:postfix /etc/postfix/mysql-virtual_sender_permissions.cf', 'chown root:root /etc/postfix/sasl/smtpd.conf', 'chmod 0644 /etc/postfix/main.cf', 'chmod 0640 /etc/postfix/mysql-virtual_alias_maps.cf', 'chmod 0640 /etc/postfix/mysql-virtual_mailbox_domains.cf', 'chmod 0640 /etc/postfix/mysql-virtual_mailbox_maps.cf', 'chmod 0640 /etc/postfix/mysql-virtual_sender_permissions.cf', 'chmod 0600 /etc/postfix/sasl/smtpd.conf'), 'files' => array('etc_postfix_main.cf' => '/etc/postfix/main.cf', 'etc_postfix_mysql-virtual_alias_maps.cf' => '/etc/postfix/mysql-virtual_alias_maps.cf', 'etc_postfix_mysql-virtual_mailbox_domains.cf' => '/etc/postfix/mysql-virtual_mailbox_domains.cf', 'etc_postfix_mysql-virtual_mailbox_maps.cf' => '/etc/postfix/mysql-virtual_mailbox_maps.cf', 'etc_postfix_mysql-virtual_sender_permissions.cf' => '/etc/postfix/mysql-virtual_sender_permissions.cf', 'etc_postfix_sasl_smtpd.conf' => '/etc/postfix/sasl/smtpd.conf'), 'restart' => array('newaliases', '/etc/init.d/postfix restart')), 'dkim' => array('label' => 'DomainKey filter', 'commands_1' => array('apt-get install dkim-filter', 'mkdir -p /etc/postfix/dkim'), 'files' => array('dkim-filter.conf' => '/etc/dkim-filter.conf'), 'commands_2' => array('echo "milter_default_action = accept" >> /etc/postfix/main.cf', 'echo "milter_protocol = 2" >> /etc/postfix/main.cf', 'echo "smtpd_milters = inet:localhost:8891" >> /etc/postfix/main.cf', 'echo "non_smtpd_milters = inet:localhost:8891" >> /etc/postfix/main.cf'), 'restart' => array('/etc/init.d/dkim-filter restart', '/etc/init.d/postfix restart')), 'postfix_dovecot' => array('label' => 'Postfix/Dovecot', 'commands' => array('apt-get install postfix postfix-mysql', 'mkdir -p /var/spool/postfix/etc/pam.d', 'mkdir -p /var/spool/postfix/var/run/mysqld', 'groupadd -g ' . $settings['system']['vmail_gid'] . ' vmail', 'useradd -u ' . $settings['system']['vmail_uid'] . ' -g vmail vmail', 'mkdir -p ' . $settings['system']['vmail_homedir'], 'chown -R vmail:vmail ' . $settings['system']['vmail_homedir'], 'touch /etc/postfix/mysql-virtual_alias_maps.cf', 'touch /etc/postfix/mysql-virtual_mailbox_domains.cf', 'touch /etc/postfix/mysql-virtual_mailbox_maps.cf', 'touch /etc/postfix/mysql-virtual_sender_permissions.cf', 'chown root:root /etc/postfix/main.cf', 'chown root:root /etc/postfix/master.cf', 'chown root:postfix /etc/postfix/mysql-virtual_alias_maps.cf', 'chown root:postfix /etc/postfix/mysql-virtual_mailbox_domains.cf', 'chown root:postfix /etc/postfix/mysql-virtual_mailbox_maps.cf', 'chown root:postfix /etc/postfix/mysql-virtual_sender_permissions.cf', 'chmod 0644 /etc/postfix/main.cf', 'chmod 0644 /etc/postfix/master.cf', 'chmod 0640 /etc/postfix/mysql-virtual_alias_maps.cf', 'chmod 0640 /etc/postfix/mysql-virtual_mailbox_domains.cf', 'chmod 0640 /etc/postfix/mysql-virtual_mailbox_maps.cf', 'chmod 0640 /etc/postfix/mysql-virtual_sender_permissions.cf'), 'files' => array('etc_postfix_main.cf' => '/etc/postfix/main.cf', 'etc_postfix_master.cf' => '/etc/postfix/master.cf', 'etc_postfix_mysql-virtual_alias_maps.cf' => '/etc/postfix/mysql-virtual_alias_maps.cf', 'etc_postfix_mysql-virtual_mailbox_domains.cf' => '/etc/postfix/mysql-virtual_mailbox_domains.cf', 'etc_postfix_mysql-virtual_mailbox_maps.cf' => '/etc/postfix/mysql-virtual_mailbox_maps.cf', 'etc_postfix_mysql-virtual_sender_permissions.cf' => '/etc/postfix/mysql-virtual_sender_permissions.cf'), 'restart' => array('/etc/init.d/postfix restart', 'newaliases')), 'postfix_mxaccess' => array('label' => 'Postfix MX-Access (anti spam)', 'files' => array('etc_postfix_mx_access' => '/etc/postfix/mx_access', 'etc_postfix_main.cf' => '/etc/postfix/main.cf'), 'commands_1' => array('postmap /etc/postfix/mx_access'), 'restart' => array('/etc/init.d/postfix restart')), 'exim4' => array('label' => 'Exim4', 'commands_1' => array('dpkg-reconfigure exim4-config', '# choose "no configuration at this time" and "splitted configuration files" in the dialog'), 'files' => array('etc_exim4_conf.d_acl_30_exim4-config_check_rcpt.rul' => '/etc/exim4/conf.d/acl/30_exim4-config_check_rcpt.rul', 'etc_exim4_conf.d_auth_30_froxlor-config' => '/etc/exim4/conf.d/auth/30_froxlor-config', 'etc_exim4_conf.d_main_10_froxlor-config_options' => '/etc/exim4/conf.d/main/10_froxlor-config_options', 'etc_exim4_conf.d_router_180_froxlor-config' => '/etc/exim4/conf.d/router/180_froxlor-config', 'etc_exim4_conf.d_transport_30_froxlor-config' => '/etc/exim4/conf.d/transport/30_froxlor-config'), 'commands_2' => array('chmod o-rx /var/lib/exim4', 'chmod o-rx /etc/exim4/conf.d/main/10_froxlor-config_options'), 'restart' => array('/etc/init.d/exim4 restart')))), 'mail' => array('label' => $lng['admin']['configfiles']['mail'], 'daemons' => array('courier' => array('label' => 'Courier', 'commands' => array('apt-get install courier-pop courier-imap courier-authlib-mysql'), 'files' => array('etc_courier_authdaemonrc' => '/etc/courier/authdaemonrc', 'etc_courier_authmysqlrc' => '/etc/courier/authmysqlrc'), 'restart' => array('/etc/init.d/courier-authdaemon restart', '/etc/init.d/courier-pop restart')), 'dovecot' => array('label' => 'Dovecot', 'commands_1' => array('apt-get install dovecot-imapd dovecot-pop3d'), 'files' => array('etc_dovecot_dovecot.conf' => '/etc/dovecot/dovecot.conf', 'etc_dovecot_dovecot-sql.conf' => '/etc/dovecot/dovecot-sql.conf'), 'commands_2' => array('chmod 0640 /etc/dovecot/dovecot-sql.conf'), 'restart' => array('/etc/init.d/dovecot restart')))), 'ftp' => array('label' => $lng['admin']['configfiles']['ftp'], 'daemons' => array('proftpd' => array('label' => 'ProFTPd', 'commands' => array('apt-get install proftpd-basic proftpd-mod-mysql'), 'files' => array('etc_proftpd_sql.conf' => '/etc/proftpd/sql.conf', 'etc_proftpd_modules.conf' => '/etc/proftpd/modules.conf', 'etc_proftpd_proftpd.conf' => '/etc/proftpd/proftpd.conf'), 'restart' => array('/etc/init.d/proftpd restart')), 'pure-ftpd' => array('label' => 'Pure FTPd', 'commands_1' => array('apt-get install pure-ftpd-common pure-ftpd-mysql'), 'files' => array('etc_pure-ftpd_conf_MinUID' => '/etc/pure-ftpd/conf/MinUID', 'etc_pure-ftpd_conf_MySQLConfigFile' => '/etc/pure-ftpd/conf/MySQLConfigFile', 'etc_pure-ftpd_conf_NoAnonymous' => '/etc/pure-ftpd/conf/NoAnonymous', 'etc_pure-ftpd_conf_MaxIdleTime' => '/etc/pure-ftpd/conf/MaxIdleTime', 'etc_pure-ftpd_conf_ChrootEveryone' => '/etc/pure-ftpd/conf/ChrootEveryone', 'etc_pure-ftpd_conf_PAMAuthentication' => '/etc/pure-ftpd/conf/PAMAuthentication', 'etc_pure-ftpd_db_mysql.conf' => '/etc/pure-ftpd/db/mysql.conf', 'etc_pure-ftpd_conf_CustomerProof' => '/etc/pure-ftpd/conf/CustomerProof', 'etc_pure-ftpd_conf_Bind' => '/etc/pure-ftpd/conf/Bind', 'etc_default_pure-ftpd-common' => '/etc/default/pure-ftpd-common'), 'commands_2' => array('chmod 0640 /etc/pure-ftpd/db/mysql.conf'), 'restart' => array('/etc/init.d/pure-ftpd-mysql restart')))), 'etc' => array('label' => $lng['admin']['configfiles']['etc'], 'daemons' => array('cron' => array('label' => 'Crond (cronscript)', 'files' => array('etc_cron.d_froxlor' => '/etc/cron.d/froxlor'), 'restart' => array('/etc/init.d/cron restart')), 'awstats' => array('label' => 'Awstats', 'commands' => array('apt-get install awstats', 'cp /usr/share/awstats/tools/awstats_buildstaticpages.pl ' . makeCorrectDir($settings['system']['awstats_path']), 'mv ' . makeCorrectFile($settings['system']['awstats_conf'] . '/awstats.conf') . ' ' . makeCorrectFile($settings['system']['awstats_conf'] . '/awstats.model.conf'), 'sed -i.bak \'s/^DirData/# DirData/\' ' . makeCorrectFile($settings['system']['awstats_conf'] . '/awstats.model.conf'))), 'libnss' => array('label' => 'libnss (system login with mysql)', 'commands' => array('apt-get install libnss-mysql nscd', 'chmod 600 /etc/nss-mysql.conf /etc/nss-mysql-root.conf'), 'files' => array('etc_nss-mysql.conf' => '/etc/nss-mysql.conf', 'etc_nss-mysql-root.conf' => '/etc/nss-mysql-root.conf', 'etc_nsswitch.conf' => '/etc/nsswitch.conf'), 'restart' => array('/etc/init.d/nscd restart')))))));
fclose($debugHandler); $debugHandler = fopen("/tmp/froxlor_traffic.log", "w"); // re-create db Database::needRoot(false); } else { return 1; } } else { if (extension_loaded('pcntl')) { $msg = "PHP compiled with pcntl but pcntl_fork function is not available."; } else { $msg = "PHP compiled without pcntl."; } fwrite($debugHandler, $msg . " Not forking traffic-cron, this may take a long time!"); } require_once makeCorrectFile(dirname(__FILE__) . '/cron_traffic.inc.functions.php'); /** * TRAFFIC AND DISKUSAGE MESSURE */ fwrite($debugHandler, 'Traffic run started...' . "\n"); $admin_traffic = array(); $domainlist = array(); $speciallogfile_domainlist = array(); $result_domainlist_stmt = Database::query("\n\tSELECT `id`, `domain`, `customerid`, `parentdomainid`, `speciallogfile`\n\tFROM `" . TABLE_PANEL_DOMAINS . "` WHERE `aliasdomain` IS NULL AND `email_only` <> '1';\n"); while ($row_domainlist = $result_domainlist_stmt->fetch(PDO::FETCH_ASSOC)) { if (!isset($domainlist[$row_domainlist['customerid']])) { $domainlist[$row_domainlist['customerid']] = array(); } $domainlist[$row_domainlist['customerid']][$row_domainlist['id']] = $row_domainlist['domain']; if ($row_domainlist['parentdomainid'] == '0' && $row_domainlist['speciallogfile'] == '1') { if (!isset($speciallogfile_domainlist[$row_domainlist['customerid']])) {
$vhostcontainer_servername_statement = '0'; } if ($ssl != '1') { $ssl = '0'; } if ($ssl_cert_file != '') { $ssl_cert_file = makeCorrectFile($ssl_cert_file); } if ($ssl_key_file != '') { $ssl_key_file = makeCorrectFile($ssl_key_file); } if ($ssl_ca_file != '') { $ssl_ca_file = makeCorrectFile($ssl_ca_file); } if ($ssl_cert_chainfile != '') { $ssl_cert_chainfile = makeCorrectFile($ssl_cert_chainfile); } if (strlen(trim($docroot)) > 0) { $docroot = makeCorrectDir($docroot); } else { $docroot = ''; } if ($result['ip'] != $ip && $result['ip'] == Settings::Get('system.ipaddress') && $result_sameipotherport['id'] == '') { standard_error('cantchangesystemip'); } elseif ($result_checkfordouble['id'] != '' && $result_checkfordouble['id'] != $id) { standard_error('myipnotdouble'); } else { $upd_stmt = Database::prepare("\n\t\t\t\t\t\tUPDATE `" . TABLE_PANEL_IPSANDPORTS . "`\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\t`ip` = :ip, `port` = :port, `listen_statement` = :ls,\n\t\t\t\t\t\t\t`namevirtualhost_statement` = :nvhs, `vhostcontainer` = :vhc,\n\t\t\t\t\t\t\t`vhostcontainer_servername_statement` = :vhcss,\n\t\t\t\t\t\t\t`specialsettings` = :ss, `ssl` = :ssl,\n\t\t\t\t\t\t\t`ssl_cert_file` = :ssl_cert, `ssl_key_file` = :ssl_key,\n\t\t\t\t\t\t\t`ssl_ca_file` = :ssl_ca, `ssl_cert_chainfile` = :ssl_chain,\n\t\t\t\t\t\t\t`default_vhostconf_domain` = :dvhd, `docroot` = :docroot\n\t\t\t\t\t\tWHERE `id` = :id;\n\t\t\t\t\t"); $upd_data = array('ip' => $ip, 'port' => $port, 'ls' => $listen_statement, 'nvhs' => $namevirtualhost_statement, 'vhc' => $vhostcontainer, 'vhcss' => $vhostcontainer_servername_statement, 'ss' => $specialsettings, 'ssl' => $ssl, 'ssl_cert' => $ssl_cert_file, 'ssl_key' => $ssl_key_file, 'ssl_ca' => $ssl_ca_file, 'ssl_chain' => $ssl_cert_chainfile, 'dvhd' => $default_vhostconf_domain, 'docroot' => $docroot, 'id' => $id); Database::pexecute($upd_stmt, $upd_data); $log->logAction(ADM_ACTION, LOG_WARNING, "changed IP/port from '" . $result['ip'] . ":" . $result['port'] . "' to '" . $ip . ":" . $port . "'");
protected function getLogFiles($domain) { $logfiles_text = ''; $speciallogfile = ''; if ($domain['speciallogfile'] == '1') { if ($domain['parentdomainid'] == '0') { $speciallogfile = '-' . $domain['domain']; } else { $speciallogfile = '-' . $domain['parentdomain']; } } // The normal access/error - logging is enabled $error_log = makeCorrectFile(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-error.log'); // Create the logfile if it does not exist (fixes #46) touch($error_log); chown($error_log, Settings::Get('system.httpuser')); chgrp($error_log, Settings::Get('system.httpgroup')); $access_log = makeCorrectFile(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-access.log'); // Create the logfile if it does not exist (fixes #46) touch($access_log); chown($access_log, Settings::Get('system.httpuser')); chgrp($access_log, Settings::Get('system.httpgroup')); $logfiles_text .= "\t" . 'access_log ' . $access_log . ' combined;' . "\n"; $logfiles_text .= "\t" . 'error_log ' . $error_log . ' error;' . "\n"; if (Settings::Get('system.awstats_enabled') == '1') { if ((int) $domain['parentdomainid'] == 0) { // prepare the aliases and subdomains for stats config files $server_alias = ''; $alias_domains_stmt = Database::prepare("\n\t\t\t\t\tSELECT `domain`, `iswildcarddomain`, `wwwserveralias`\n\t\t\t\t\tFROM `" . TABLE_PANEL_DOMAINS . "`\n\t\t\t\t\tWHERE `aliasdomain` = :domainid OR `parentdomainid` = :domainid\n\t\t\t\t"); Database::pexecute($alias_domains_stmt, array('domainid' => $domain['id'])); while (($alias_domain = $alias_domains_stmt->fetch(PDO::FETCH_ASSOC)) !== false) { $server_alias .= ' ' . $alias_domain['domain'] . ' '; if ($alias_domain['iswildcarddomain'] == '1') { $server_alias .= '*.' . $domain['domain']; } else { if ($alias_domain['wwwserveralias'] == '1') { $server_alias .= 'www.' . $alias_domain['domain']; } else { $server_alias .= ''; } } } $alias = ''; if ($domain['iswildcarddomain'] == '1') { $alias = '*.' . $domain['domain']; } elseif ($domain['wwwserveralias'] == '1') { $alias = 'www.' . $domain['domain']; } // After inserting the AWStats information, // be sure to build the awstats conf file as well // and chown it using $awstats_params, #258 // Bug 960 + Bug 970 : Use full $domain instead of custom $awstats_params as following classes depend on the informations createAWStatsConf(Settings::Get('system.logfiles_directory') . $domain['loginname'] . $speciallogfile . '-access.log', $domain['domain'], $alias . $server_alias, $domain['customerroot'], $domain); } } return $logfiles_text; }
lastStepStatus(0); showUpdateStep("Adding new FTP-description field"); Database::query("ALTER TABLE `" . TABLE_FTP_USERS . "` ADD `description` varchar(255) NOT NULL DEFAULT '' AFTER `customerid`;"); lastStepStatus(0); updateToVersion('0.9.32-dev4'); } if (isFroxlorVersion('0.9.32-dev4')) { showUpdateStep("Updating from 0.9.32-dev4 to 0.9.32-dev5"); lastStepStatus(0); showUpdateStep("Updating cronjob table"); Database::query("UPDATE `" . TABLE_PANEL_CRONRUNS . "` SET `cronfile` = REPLACE( REPLACE(`cronfile`, 'cron_', ''), '.php', '')"); lastStepStatus(0); showUpdateStep("Adding new settings for cron"); // get user-chosen value $crondfile = isset($_POST['crondfile']) ? $_POST['crondfile'] : "/etc/cron.d/froxlor"; $crondfile = makeCorrectFile($crondfile); Settings::AddNew("system.cronconfig", $crondfile); // add task to generate cron.d-file inserttask('99'); lastStepStatus(0); updateToVersion('0.9.32-dev5'); } if (isFroxlorVersion('0.9.32-dev5')) { showUpdateStep("Updating from 0.9.32-dev5 to 0.9.32-dev6", false); showUpdateStep("Adding new settings for cron-daemon reload command"); // get user-chosen value $crondreload = isset($_POST['crondreload']) ? $_POST['crondreload'] : "/etc/init.d/cron reload"; Settings::AddNew("system.crondreload", $crondreload); // add task to generate cron.d-file inserttask('99'); lastStepStatus(0);
} else { ask_yesno('phpsetting_reallydelete', $filename, array('id' => $id, 'page' => $page, 'action' => $action), $result['description']); } } else { standard_error('nopermissionsorinvalidid'); } } if ($action == 'edit') { $result_stmt = Database::prepare("\n\t\t\tSELECT * FROM `" . TABLE_PANEL_PHPCONFIGS . "` WHERE `id` = :id"); $result = Database::pexecute_first($result_stmt, array('id' => $id)); if ($result['id'] != 0 && $result['id'] == $id && (int) $userinfo['change_serversettings'] == 1) { if (isset($_POST['send']) && $_POST['send'] == 'send') { $description = validate($_POST['description'], 'description'); $phpsettings = validate(str_replace("\r\n", "\n", $_POST['phpsettings']), 'phpsettings', '/^[^\\0]*$/'); if (Settings::Get('system.mod_fcgid') == 1) { $binary = makeCorrectFile(validate($_POST['binary'], 'binary')); $file_extensions = validate($_POST['file_extensions'], 'file_extensions', '/^[a-zA-Z0-9\\s]*$/'); $mod_fcgid_starter = validate($_POST['mod_fcgid_starter'], 'mod_fcgid_starter', '/^[0-9]*$/', '', array('-1', '')); $mod_fcgid_maxrequests = validate($_POST['mod_fcgid_maxrequests'], 'mod_fcgid_maxrequests', '/^[0-9]*$/', '', array('-1', '')); $mod_fcgid_umask = validate($_POST['mod_fcgid_umask'], 'mod_fcgid_umask', '/^[0-9]*$/'); // disable fpm stuff $fpm_enableslowlog = 0; $fpm_reqtermtimeout = 0; $fpm_reqslowtimeout = 0; } elseif (Settings::Get('phpfpm.enabled') == 1) { $fpm_enableslowlog = isset($_POST['phpfpm_enable_slowlog']) ? (int) $_POST['phpfpm_enable_slowlog'] : 0; $fpm_reqtermtimeout = validate($_POST['phpfpm_reqtermtimeout'], 'phpfpm_reqtermtimeout', '/^([0-9]+)(|s|m|h|d)$/'); $fpm_reqslowtimeout = validate($_POST['phpfpm_reqslowtimeout'], 'phpfpm_reqslowtimeout', '/^([0-9]+)(|s|m|h|d)$/'); // disable fcgid stuff $binary = '/usr/bin/php-cgi'; $file_extensions = 'php';
/** * We compose the diroption entries for the paths */ public function createFileDirOptions() { $result_stmt = Database::query("\n\t\t\tSELECT `htac`.*, `c`.`guid`, `c`.`documentroot` AS `customerroot`\n\t\t\tFROM `" . TABLE_PANEL_HTACCESS . "` `htac`\n\t\t\tLEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING (`customerid`)\n\t\t\tORDER BY `htac`.`path`\n\t\t"); $diroptions = array(); while ($row_diroptions = $result_stmt->fetch(PDO::FETCH_ASSOC)) { if ($row_diroptions['customerid'] != 0 && isset($row_diroptions['customerroot']) && $row_diroptions['customerroot'] != '') { $diroptions[$row_diroptions['path']] = $row_diroptions; $diroptions[$row_diroptions['path']]['htpasswds'] = array(); } } $result_stmt = Database::query("\n\t\t\tSELECT `htpw`.*, `c`.`guid`, `c`.`documentroot` AS `customerroot`\n\t\t\tFROM `" . TABLE_PANEL_HTPASSWDS . "` `htpw`\n\t\t\tLEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING (`customerid`)\n\t\t\tORDER BY `htpw`.`path`, `htpw`.`username`\n\t\t"); while ($row_htpasswds = $result_stmt->fetch(PDO::FETCH_ASSOC)) { if ($row_htpasswds['customerid'] != 0 && isset($row_htpasswds['customerroot']) && $row_htpasswds['customerroot'] != '') { if (!isset($diroptions[$row_htpasswds['path']]) || !is_array($diroptions[$row_htpasswds['path']])) { $diroptions[$row_htpasswds['path']] = array(); } $diroptions[$row_htpasswds['path']]['path'] = $row_htpasswds['path']; $diroptions[$row_htpasswds['path']]['guid'] = $row_htpasswds['guid']; $diroptions[$row_htpasswds['path']]['customerroot'] = $row_htpasswds['customerroot']; $diroptions[$row_htpasswds['path']]['customerid'] = $row_htpasswds['customerid']; $diroptions[$row_htpasswds['path']]['htpasswds'][] = $row_htpasswds; } } foreach ($diroptions as $row_diroptions) { $row_diroptions['path'] = makeCorrectDir($row_diroptions['path']); mkDirWithCorrectOwnership($row_diroptions['customerroot'], $row_diroptions['path'], $row_diroptions['guid'], $row_diroptions['guid']); $diroptions_filename = makeCorrectFile(Settings::Get('system.apacheconf_diroptions') . '/40_froxlor_diroption_' . md5($row_diroptions['path']) . '.conf'); if (!isset($this->diroptions_data[$diroptions_filename])) { $this->diroptions_data[$diroptions_filename] = ''; } if (is_dir($row_diroptions['path'])) { $cperlenabled = customerHasPerlEnabled($row_diroptions['customerid']); $this->diroptions_data[$diroptions_filename] .= '<Directory "' . $row_diroptions['path'] . '">' . "\n"; if (isset($row_diroptions['options_indexes']) && $row_diroptions['options_indexes'] == '1') { $this->diroptions_data[$diroptions_filename] .= ' Options +Indexes'; // add perl options if enabled if ($cperlenabled && isset($row_diroptions['options_cgi']) && $row_diroptions['options_cgi'] == '1') { $this->diroptions_data[$diroptions_filename] .= ' +ExecCGI -MultiViews +SymLinksIfOwnerMatch +FollowSymLinks' . "\n"; } else { $this->diroptions_data[$diroptions_filename] .= "\n"; } fwrite($this->debugHandler, ' cron_tasks: Task3 - Setting Options +Indexes' . "\n"); } if (isset($row_diroptions['options_indexes']) && $row_diroptions['options_indexes'] == '0') { $this->diroptions_data[$diroptions_filename] .= ' Options -Indexes'; // add perl options if enabled if ($cperlenabled && isset($row_diroptions['options_cgi']) && $row_diroptions['options_cgi'] == '1') { $this->diroptions_data[$diroptions_filename] .= ' +ExecCGI -MultiViews +SymLinksIfOwnerMatch +FollowSymLinks' . "\n"; } else { $this->diroptions_data[$diroptions_filename] .= "\n"; } fwrite($this->debugHandler, ' cron_tasks: Task3 - Setting Options -Indexes' . "\n"); } $statusCodes = array('404', '403', '500'); foreach ($statusCodes as $statusCode) { if (isset($row_diroptions['error' . $statusCode . 'path']) && $row_diroptions['error' . $statusCode . 'path'] != '') { $defhandler = $row_diroptions['error' . $statusCode . 'path']; if (!validateUrl($defhandler)) { if (substr($defhandler, 0, 1) != '"' && substr($defhandler, -1, 1) != '"') { $defhandler = '"' . makeCorrectFile($defhandler) . '"'; } } $this->diroptions_data[$diroptions_filename] .= ' ErrorDocument ' . $statusCode . ' ' . $defhandler . "\n"; } } if ($cperlenabled && isset($row_diroptions['options_cgi']) && $row_diroptions['options_cgi'] == '1') { $this->diroptions_data[$diroptions_filename] .= ' AllowOverride None' . "\n"; $this->diroptions_data[$diroptions_filename] .= ' AddHandler cgi-script .cgi .pl' . "\n"; // >=apache-2.4 enabled? if (Settings::Get('system.apache24') == '1') { $mypath_dir = new frxDirectory($row_diroptions['path']); // only create the require all granted if there is not active directory-protection // for this path, as this would be the first require and therefore grant all access if ($mypath_dir->isUserProtected() == false) { $this->diroptions_data[$diroptions_filename] .= ' Require all granted' . "\n"; } } else { $this->diroptions_data[$diroptions_filename] .= ' Order allow,deny' . "\n"; $this->diroptions_data[$diroptions_filename] .= ' Allow from all' . "\n"; } fwrite($this->debugHandler, ' cron_tasks: Task3 - Enabling perl execution' . "\n"); // check for suexec-workaround, #319 if ((int) Settings::Get('perl.suexecworkaround') == 1) { // symlink this directory to suexec-safe-path $loginname = getCustomerDetail($row_diroptions['customerid'], 'loginname'); $suexecpath = makeCorrectDir(Settings::Get('perl.suexecpath') . '/' . $loginname . '/' . md5($row_diroptions['path']) . '/'); if (!file_exists($suexecpath)) { safe_exec('mkdir -p ' . escapeshellarg($suexecpath)); safe_exec('chown -R ' . escapeshellarg($row_diroptions['guid']) . ':' . escapeshellarg($row_diroptions['guid']) . ' ' . escapeshellarg($suexecpath)); } // symlink to {$givenpath}/cgi-bin // NOTE: symlinks are FILES, so do not append a / here $perlsymlink = makeCorrectFile($row_diroptions['path'] . '/cgi-bin'); if (!file_exists($perlsymlink)) { safe_exec('ln -s ' . escapeshellarg($suexecpath) . ' ' . escapeshellarg($perlsymlink)); } safe_exec('chown ' . escapeshellarg($row_diroptions['guid']) . ':' . escapeshellarg($row_diroptions['guid']) . ' ' . escapeshellarg($perlsymlink)); } } else { // if no perl-execution is enabled but the workaround is, // we have to remove the symlink and folder in suexecpath if ((int) Settings::Get('perl.suexecworkaround') == 1) { $loginname = getCustomerDetail($row_diroptions['customerid'], 'loginname'); $suexecpath = makeCorrectDir(Settings::Get('perl.suexecpath') . '/' . $loginname . '/' . md5($row_diroptions['path']) . '/'); $perlsymlink = makeCorrectFile($row_diroptions['path'] . '/cgi-bin'); // remove symlink if (file_exists($perlsymlink)) { safe_exec('rm -f ' . escapeshellarg($perlsymlink)); } // remove folder in suexec-path if (file_exists($suexecpath)) { safe_exec('rm -rf ' . escapeshellarg($suexecpath)); } } } if (count($row_diroptions['htpasswds']) > 0) { $htpasswd_filename = makeCorrectFile(Settings::Get('system.apacheconf_htpasswddir') . '/' . $row_diroptions['customerid'] . '-' . md5($row_diroptions['path']) . '.htpasswd'); if (!isset($this->htpasswds_data[$htpasswd_filename])) { $this->htpasswds_data[$htpasswd_filename] = ''; } foreach ($row_diroptions['htpasswds'] as $row_htpasswd) { $this->htpasswds_data[$htpasswd_filename] .= $row_htpasswd['username'] . ':' . $row_htpasswd['password'] . "\n"; } $this->diroptions_data[$diroptions_filename] .= ' AuthType Basic' . "\n"; $this->diroptions_data[$diroptions_filename] .= ' AuthName "' . $row_htpasswd['authname'] . '"' . "\n"; $this->diroptions_data[$diroptions_filename] .= ' AuthUserFile ' . $htpasswd_filename . "\n"; $this->diroptions_data[$diroptions_filename] .= ' require valid-user' . "\n"; } $this->diroptions_data[$diroptions_filename] .= '</Directory>' . "\n"; } } }
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); } } }
/** * This file is part of the Froxlor project. * Copyright (c) 2003-2009 the SysCP Team (see authors). * Copyright (c) 2010 the Froxlor Team (see authors). * * For the full copyright and license information, please view the COPYING * file that was distributed with this source code. You can also view the * 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 Functions * */ function validateFormFieldString($fieldname, $fielddata, $newfieldvalue) { if (isset($fielddata['string_delimiter']) && $fielddata['string_delimiter'] != '') { $newfieldvalues = array_map('trim', explode($fielddata['string_delimiter'], $newfieldvalue)); unset($fielddata['string_delimiter']); $returnvalue = true; foreach ($newfieldvalues as $single_newfieldvalue) { /** * don't use tabs in value-fields, #81 */ $single_newfieldvalue = str_replace("\t", " ", $single_newfieldvalue); $single_returnvalue = validateFormFieldString($fieldname, $fielddata, $single_newfieldvalue); if ($single_returnvalue !== true) { $returnvalue = $single_returnvalue; break; } } } else { $returnvalue = false; /** * don't use tabs in value-fields, #81 */ $newfieldvalue = str_replace("\t", " ", $newfieldvalue); if (isset($fielddata['string_type']) && $fielddata['string_type'] == 'mail') { $returnvalue = filter_var($newfieldvalue, FILTER_VALIDATE_EMAIL) == $newfieldvalue; } elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'url') { $returnvalue = validateUrl($newfieldvalue); } elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'dir') { // check for empty value (it might be allowed) if (trim($newfieldvalue) == '') { $newfieldvalue = ''; $returnvalue = 'stringmustntbeempty'; } else { // add trailing slash to validate path if needed // refs #331 if (substr($newfieldvalue, -1) != '/') { $newfieldvalue .= '/'; } $returnvalue = $newfieldvalue == makeCorrectDir($newfieldvalue); } } elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'confdir') { // check for empty value (it might be allowed) if (trim($newfieldvalue) == '') { $newfieldvalue = ''; $returnvalue = 'stringmustntbeempty'; } else { // add trailing slash to validate path if needed // refs #331 if (substr($newfieldvalue, -1) != '/') { $newfieldvalue .= '/'; } // if this is a configuration directory, check for stupidity of admins :p if (checkDisallowedPaths($newfieldvalue) !== true) { $newfieldvalue = ''; $returnvalue = 'givendirnotallowed'; } else { $returnvalue = $newfieldvalue == makeCorrectDir($newfieldvalue); } } } elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'file') { // check for empty value (it might be allowed) if (trim($newfieldvalue) == '') { $newfieldvalue = ''; $returnvalue = 'stringmustntbeempty'; } else { $returnvalue = $newfieldvalue == makeCorrectFile($newfieldvalue); } } elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'filedir') { // check for empty value (it might be allowed) if (trim($newfieldvalue) == '') { $newfieldvalue = ''; $returnvalue = 'stringmustntbeempty'; } else { $returnvalue = $newfieldvalue == makeCorrectDir($newfieldvalue) || $newfieldvalue == makeCorrectFile($newfieldvalue); } } elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'validate_ip') { $newfieldvalue = validate_ip2($newfieldvalue); $returnvalue = $newfieldvalue !== false ? true : 'invalidip'; } elseif (preg_match('/^[^\\r\\n\\t\\f\\0]*$/D', $newfieldvalue)) { $returnvalue = true; } if (isset($fielddata['string_regexp']) && $fielddata['string_regexp'] != '') { if (preg_match($fielddata['string_regexp'], $newfieldvalue)) { $returnvalue = true; } else { $returnvalue = false; } } if (isset($fielddata['string_emptyallowed']) && $fielddata['string_emptyallowed'] === true && $newfieldvalue === '') { $returnvalue = true; } elseif (isset($fielddata['string_emptyallowed']) && $fielddata['string_emptyallowed'] === false && $newfieldvalue === '') { $returnvalue = 'stringmustntbeempty'; } } if ($returnvalue === true) { return true; } elseif ($returnvalue === false) { return 'stringformaterror'; } else { return $returnvalue; } }
public function writeDKIMconfigs() { if (Settings::Get('dkim.use_dkim') == '1') { if (!file_exists(makeCorrectDir(Settings::Get('dkim.dkim_prefix')))) { $this->logger->logAction(CRON_ACTION, LOG_NOTICE, 'mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('dkim.dkim_prefix')))); safe_exec('mkdir -p ' . escapeshellarg(makeCorrectDir(Settings::Get('dkim.dkim_prefix')))); } $dkimdomains = ''; $dkimkeys = ''; $result_domains_stmt = Database::query("\n\t\t\t\tSELECT `id`, `domain`, `dkim`, `dkim_id`, `dkim_pubkey`, `dkim_privkey`\n\t\t\t\tFROM `" . TABLE_PANEL_DOMAINS . "` WHERE `dkim` = '1' ORDER BY `id` ASC\n\t\t\t"); while ($domain = $result_domains_stmt->fetch(PDO::FETCH_ASSOC)) { $privkey_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id']); $pubkey_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id'] . '.public'); if ($domain['dkim_privkey'] == '' || $domain['dkim_pubkey'] == '') { $max_dkim_id_stmt = Database::query("SELECT MAX(`dkim_id`) as `max_dkim_id` FROM `" . TABLE_PANEL_DOMAINS . "`"); $max_dkim_id = $max_dkim_id_stmt->fetch(PDO::FETCH_ASSOC); $domain['dkim_id'] = (int) $max_dkim_id['max_dkim_id'] + 1; $privkey_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id']); safe_exec('openssl genrsa -out ' . escapeshellarg($privkey_filename) . ' ' . Settings::Get('dkim.dkim_keylength')); $domain['dkim_privkey'] = file_get_contents($privkey_filename); safe_exec("chmod 0640 " . escapeshellarg($privkey_filename)); $pubkey_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/dkim_' . $domain['dkim_id'] . '.public'); safe_exec('openssl rsa -in ' . escapeshellarg($privkey_filename) . ' -pubout -outform pem -out ' . escapeshellarg($pubkey_filename)); $domain['dkim_pubkey'] = file_get_contents($pubkey_filename); safe_exec("chmod 0664 " . escapeshellarg($pubkey_filename)); $upd_stmt = Database::prepare("\n\t\t\t\t\t\tUPDATE `" . TABLE_PANEL_DOMAINS . "` SET\n\t\t\t\t\t\t`dkim_id` = :dkimid,\n\t\t\t\t\t\t`dkim_privkey` = :privkey,\n\t\t\t\t\t\t`dkim_pubkey` = :pubkey\n\t\t\t\t\t\tWHERE `id` = :id\n\t\t\t\t\t"); $upd_data = array('dkimid' => $domain['dkim_id'], 'privkey' => $domain['dkim_privkey'], 'pubkey' => $domain['dkim_pubkey'], 'id' => $domain['id']); Database::pexecute($upd_stmt, $upd_data); } if (!file_exists($privkey_filename) && $domain['dkim_privkey'] != '') { $privkey_file_handler = fopen($privkey_filename, "w"); fwrite($privkey_file_handler, $domain['dkim_privkey']); fclose($privkey_file_handler); safe_exec("chmod 0640 " . escapeshellarg($privkey_filename)); } if (!file_exists($pubkey_filename) && $domain['dkim_pubkey'] != '') { $pubkey_file_handler = fopen($pubkey_filename, "w"); fwrite($pubkey_file_handler, $domain['dkim_pubkey']); fclose($pubkey_file_handler); safe_exec("chmod 0664 " . escapeshellarg($pubkey_filename)); } $dkimdomains .= $domain['domain'] . "\n"; $dkimkeys .= "*@" . $domain['domain'] . ":" . $domain['domain'] . ":" . $privkey_filename . "\n"; } $dkimdomains_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/' . Settings::Get('dkim.dkim_domains')); $dkimdomains_file_handler = fopen($dkimdomains_filename, "w"); fwrite($dkimdomains_file_handler, $dkimdomains); fclose($dkimdomains_file_handler); $dkimkeys_filename = makeCorrectFile(Settings::Get('dkim.dkim_prefix') . '/' . Settings::Get('dkim.dkim_dkimkeys')); $dkimkeys_file_handler = fopen($dkimkeys_filename, "w"); fwrite($dkimkeys_file_handler, $dkimkeys); fclose($dkimkeys_file_handler); safe_exec(escapeshellcmd(Settings::Get('dkim.dkimrestart_command'))); fwrite($this->debugHandler, ' cron_tasks: Task4 - Dkim-milter reloaded' . "\n"); $this->logger->logAction(CRON_ACTION, LOG_INFO, 'Dkim-milter reloaded'); } }
/** * Function which make webalizer statistics and returns used traffic since last run * * @param string Name of logfile * @param string Place where stats should be build * @param string Caption for webalizer output * @return int Used traffic * @author Florian Lippert <*****@*****.**> */ function callWebalizerGetTraffic($logfile, $outputdir, $caption, $usersdomainlist) { global $cronlog; $returnval = 0; $logfile = makeCorrectFile(Settings::Get('system.logfiles_directory') . $logfile . '-access.log'); if (file_exists($logfile)) { $domainargs = ''; foreach ($usersdomainlist as $domainid => $domain) { // hide referer $domainargs .= ' -r ' . escapeshellarg($domain); } $outputdir = makeCorrectDir($outputdir); if (!file_exists($outputdir)) { safe_exec('mkdir -p ' . escapeshellarg($outputdir)); } if (file_exists($outputdir . 'webalizer.hist.1')) { @unlink($outputdir . 'webalizer.hist.1'); } if (file_exists($outputdir . 'webalizer.hist') && !file_exists($outputdir . 'webalizer.hist.1')) { safe_exec('cp ' . escapeshellarg($outputdir . 'webalizer.hist') . ' ' . escapeshellarg($outputdir . 'webalizer.hist.1')); } $verbosity = ''; if (Settings::Get('system.webalizer_quiet') == '1') { $verbosity = '-q'; } elseif (Settings::Get('system.webalizer_quiet') == '2') { $verbosity = '-Q'; } $we = '/usr/bin/webalizer'; // FreeBSD uses other paths, #140 if (!file_exists($we)) { $we = '/usr/local/bin/webalizer'; } $cronlog->logAction(CRON_ACTION, LOG_INFO, "Running webalizer for domain '" . $caption . "'"); safe_exec($we . ' ' . $verbosity . ' -p -o ' . escapeshellarg($outputdir) . ' -n ' . escapeshellarg($caption) . $domainargs . ' ' . escapeshellarg($logfile)); /** * Format of webalizer.hist-files: * Month: $webalizer_hist_row['0'] * Year: $webalizer_hist_row['1'] * KB: $webalizer_hist_row['5'] */ $httptraffic = array(); $webalizer_hist = @file_get_contents($outputdir . 'webalizer.hist'); $cronlog->logAction(CRON_ACTION, LOG_INFO, "Gathering traffic information from '" . $webalizer_hist . "'"); $webalizer_hist_rows = explode("\n", $webalizer_hist); foreach ($webalizer_hist_rows as $webalizer_hist_row) { if ($webalizer_hist_row != '') { $webalizer_hist_row = explode(' ', $webalizer_hist_row); if (isset($webalizer_hist_row['0']) && isset($webalizer_hist_row['1']) && isset($webalizer_hist_row['5'])) { $month = intval($webalizer_hist_row['0']); $year = intval($webalizer_hist_row['1']); $traffic = floatval($webalizer_hist_row['5']); if (!isset($httptraffic[$year])) { $httptraffic[$year] = array(); } $httptraffic[$year][$month] = $traffic; } } } reset($httptraffic); $httptrafficlast = array(); $webalizer_lasthist = @file_get_contents($outputdir . 'webalizer.hist.1'); $cronlog->logAction(CRON_ACTION, LOG_INFO, "Gathering traffic information from '" . $webalizer_lasthist . "'"); $webalizer_lasthist_rows = explode("\n", $webalizer_lasthist); foreach ($webalizer_lasthist_rows as $webalizer_lasthist_row) { if ($webalizer_lasthist_row != '') { $webalizer_lasthist_row = explode(' ', $webalizer_lasthist_row); if (isset($webalizer_lasthist_row['0']) && isset($webalizer_lasthist_row['1']) && isset($webalizer_lasthist_row['5'])) { $month = intval($webalizer_lasthist_row['0']); $year = intval($webalizer_lasthist_row['1']); $traffic = floatval($webalizer_lasthist_row['5']); if (!isset($httptrafficlast[$year])) { $httptrafficlast[$year] = array(); } $httptrafficlast[$year][$month] = $traffic; } } } reset($httptrafficlast); foreach ($httptraffic as $year => $months) { foreach ($months as $month => $traffic) { if (!isset($httptrafficlast[$year][$month])) { $returnval += $traffic; } elseif ($httptrafficlast[$year][$month] < $httptraffic[$year][$month]) { $returnval += $httptraffic[$year][$month] - $httptrafficlast[$year][$month]; } } } } return floatval($returnval); }
// remove maildir $maildir = makeCorrectDir(Settings::Get('system.vmail_homedir') . '/' . $row['data']['loginname']); if (file_exists($maildir) && $maildir != '/' && $maildir != Settings::Get('system.vmail_homedir') && substr($maildir, 0, strlen(Settings::Get('system.vmail_homedir'))) == Settings::Get('system.vmail_homedir') && is_dir($maildir) && fileowner($maildir) == Settings::Get('system.vmail_uid') && filegroup($maildir) == Settings::Get('system.vmail_gid')) { $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($maildir)); // mail-address allows many special characters, see http://en.wikipedia.org/wiki/Email_address#Local_part $return = false; safe_exec('rm -rf ' . escapeshellarg($maildir), $return, array('|', '&', '`', '$', '~', '?')); } // remove tmpdir if it exists $tmpdir = makeCorrectDir(Settings::Get('system.mod_fcgid_tmpdir') . '/' . $row['data']['loginname'] . '/'); if (file_exists($tmpdir) && is_dir($tmpdir) && $tmpdir != "/" && $tmpdir != Settings::Get('system.mod_fcgid_tmpdir') && substr($tmpdir, 0, strlen(Settings::Get('system.mod_fcgid_tmpdir'))) == Settings::Get('system.mod_fcgid_tmpdir')) { $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($tmpdir)); safe_exec('rm -rf ' . escapeshellarg($tmpdir)); } // webserver logs $logsdir = makeCorrectFile(Settings::Get('system.logfiles_directory') . '/' . $row['data']['loginname']); if (file_exists($logsdir) && $logsdir != '/' && $logsdir != makeCorrectDir(Settings::Get('system.logfiles_directory')) && substr($logsdir, 0, strlen(Settings::Get('system.logfiles_directory'))) == Settings::Get('system.logfiles_directory')) { // build up wildcard for webX-{access,error}.log{*} $logfiles .= '-*'; safe_exec('rm -f ' . escapeshellarg($logfiles)); } } } } elseif ($row['type'] == '7') { fwrite($debugHandler, ' cron_tasks: Task7 started - deleting customer e-mail data' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task7 started - deleting customer e-mail data'); if (is_array($row['data'])) { if (isset($row['data']['loginname']) && isset($row['data']['email'])) { // remove specific maildir $email_full = $row['data']['email']; if (empty($email_full)) {