/** * 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 Functions * */ function checkHostname($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) { if (0 == strlen(trim($newfieldvalue)) || validateDomain($newfieldvalue) === false) { return array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'invalidhostname'); } else { return array(FORMFIELDS_PLAUSIBILITY_CHECK_OK); } }
/** * 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 * * @version $Id$ */ function checkMysqlAccessHost($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) { $mysql_access_host_array = array_map('trim', explode(',', $newfieldvalue)); foreach ($mysql_access_host_array as $host_entry) { if (validate_ip($host_entry, true) == false && validateDomain($host_entry) == false && $host_entry != '%') { return array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'invalidmysqlhost', $host_entry); } } return array(FORMFIELDS_PLAUSIBILITY_CHECK_OK); }
/** * 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 checkMysqlAccessHost($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues) { $mysql_access_host_array = array_map('trim', explode(',', $newfieldvalue)); foreach ($mysql_access_host_array as $host_entry) { // in mysql access host, using wildcard ('%') is allowed, but // the filters won't accept that. By replacing the first wildcard // with a '0', we can create "valid" entries: // 192.168.1.% becomes 192.168.1.0, which is valid // %.somehost.com becomes 0.somehost.com, which is also valid $host_entry_test = preg_replace('/%/', '0', $host_entry, 1); if (validate_ip2($host_entry_test, true, 'invalidip', true, true) == false && validateDomain($host_entry_test) == false && validateLocalHostname($host_entry) == false && $host_entry != '%') { return array(FORMFIELDS_PLAUSIBILITY_CHECK_ERROR, 'invalidmysqlhost', $host_entry); } } return array(FORMFIELDS_PLAUSIBILITY_CHECK_OK); }
} if ($dkim != '1') { $dkim = '0'; } if ($serveraliasoption != '1' && $serveraliasoption != '2') { $serveraliasoption = '0'; } if ($caneditdomain != '1') { $caneditdomain = '0'; } if ($issubof <= '0') { $issubof = '0'; } if ($domain == '') { standard_error(array('stringisempty', 'mydomain')); } elseif (Settings::Get('system.validate_domain') && !validateDomain($domain)) { standard_error(array('stringiswrong', 'mydomain')); } elseif ($documentroot == '') { standard_error(array('stringisempty', 'mydocumentroot')); } elseif ($customerid == 0) { standard_error('adduserfirst'); } elseif (strtolower($domain_check['domain']) == strtolower($domain)) { standard_error('domainalreadyexists', $idna_convert->decode($domain)); } elseif ($aliasdomain_check['id'] != $aliasdomain) { standard_error('domainisaliasorothercustomer'); } else { $params = array('page' => $page, 'action' => $action, 'domain' => $domain, 'customerid' => $customerid, 'adminid' => $adminid, 'documentroot' => $documentroot, 'alias' => $aliasdomain, 'isbinddomain' => $isbinddomain, 'isemaildomain' => $isemaildomain, 'email_only' => $email_only, 'subcanemaildomain' => $subcanemaildomain, 'caneditdomain' => $caneditdomain, 'zonefile' => $zonefile, 'dkim' => $dkim, 'speciallogfile' => $speciallogfile, 'selectserveralias' => $serveraliasoption, 'ipandport' => serialize($ipandports), 'ssl_redirect' => $ssl_redirect, 'ssl_ipandport' => serialize($ssl_ipandports), 'openbasedir' => $openbasedir, 'phpsettingid' => $phpsettingid, 'mod_fcgid_starter' => $mod_fcgid_starter, 'mod_fcgid_maxrequests' => $mod_fcgid_maxrequests, 'specialsettings' => $specialsettings, 'registration_date' => $registration_date, 'issubof' => $issubof); $security_questions = array('reallydisablesecuritysetting' => $openbasedir == '0' && $userinfo['change_serversettings'] == '1', 'reallydocrootoutofcustomerroot' => substr($documentroot, 0, strlen($customer['documentroot'])) != $customer['documentroot'] && !preg_match('/^https?\\:\\/\\//', $documentroot)); $question_nr = 1; foreach ($security_questions as $question_name => $question_launch) { if ($question_launch !== false) {
} } else { standard_error('domains_cantdeletemaindomain'); } } elseif ($action == 'add') { if ($userinfo['subdomains_used'] < $userinfo['subdomains'] || $userinfo['subdomains'] == '-1') { if (isset($_POST['send']) && $_POST['send'] == 'send') { if (strpos($_POST['subdomain'], '--') !== false) { standard_error('domain_nopunycode'); } $subdomain = $idna_convert->encode(preg_replace(array('/\\:(\\d)+$/', '/^https?\\:\\/\\//'), '', validate($_POST['subdomain'], 'subdomain', '', 'subdomainiswrong'))); $domain = $_POST['domain']; $domain_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAINS . "`\n\t\t\t\t\tWHERE `domain` = :domain\n\t\t\t\t\tAND `customerid` = :customerid\n\t\t\t\t\tAND `parentdomainid` = '0'\n\t\t\t\t\tAND `email_only` = '0'\n\t\t\t\t\tAND `caneditdomain` = '1'"); $domain_check = Database::pexecute_first($domain_stmt, array("domain" => $domain, "customerid" => $userinfo['customerid'])); $completedomain = $subdomain . '.' . $domain; if (Settings::Get('system.validate_domain') && !validateDomain($completedomain)) { standard_error(array('stringiswrong', 'mydomain')); } if ($completedomain == Settings::Get('system.hostname')) { standard_error('admin_domain_emailsystemhostname'); } $completedomain_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAINS . "`\n\t\t\t\t\tWHERE `domain` = :domain\n\t\t\t\t\tAND `customerid` = :customerid\n\t\t\t\t\tAND `email_only` = '0'\n\t\t\t\t\tAND `caneditdomain` = '1'"); $completedomain_check = Database::pexecute_first($completedomain_stmt, array("domain" => $completedomain, "customerid" => $userinfo['customerid'])); $aliasdomain = intval($_POST['alias']); $aliasdomain_check = array('id' => 0); $_doredirect = false; if ($aliasdomain != 0) { // also check ip/port combination to be the same, #176 $aliasdomain_stmt = Database::prepare("SELECT `d`.`id` FROM `" . TABLE_PANEL_DOMAINS . "` `d` , `" . TABLE_PANEL_CUSTOMERS . "` `c` , `" . TABLE_DOMAINTOIP . "` `dip`\n\t\t\t\t\t\tWHERE `d`.`aliasdomain` IS NULL\n\t\t\t\t\t\tAND `d`.`id` = :id\n\t\t\t\t\t\tAND `c`.`standardsubdomain` <> `d`.`id`\n\t\t\t\t\t\tAND `d`.`customerid` = :customerid\n\t\t\t\t\t\tAND `c`.`customerid` = `d`.`customerid`\n\t\t\t\t\t\tAND `d`.`id` = `dip`.`id_domain`\n\t\t\t\t\t\tAND `dip`.`id_ipandports`\n\t\t\t\t\t\tIN (SELECT `id_ipandports` FROM `" . TABLE_DOMAINTOIP . "`\n\t\t\t\t\t\t\tWHERE `id_domain` = :id )\n\t\t\t\t\t\tGROUP BY `d`.`domain`\n\t\t\t\t\t\tORDER BY `d`.`domain` ASC;"); $aliasdomain_check = Database::pexecute_first($aliasdomain_stmt, array("id" => $aliasdomain, "customerid" => $userinfo['customerid'])); triggerLetsEncryptCSRForAliasDestinationDomain($aliasdomain, $log);
public function test_Success_Eurideu() { $domainname = 'eurid.eu'; $this->assertTrue(validateDomain($domainname)); }
/** * adds a single domain to the database using the given array * * @param array $domain_data * * @return int last-inserted id or false on error */ private function _addSingleDomainToDatabase($domain_data = array()) { // format domain $idna_convert = new idna_convert_wrapper(); $domain_data['domain'] = $idna_convert->encode(preg_replace(array('/\\:(\\d)+$/', '/^https?\\:\\/\\//'), '', $domain_data['domain'])); // check if it is a valid domain if (!validateDomain($domain_data['domain'])) { return false; } // no system-hostname can be added if ($domain_data['domain'] == Settings::Get('system.hostname')) { return false; } // no existing domains can be imported if (in_array($domain_data['domain'], $this->_knownDomains)) { return false; } // check for alias-domain if (!empty($domain_data['aliasdomain'])) { // format $domain_data['aliasdomain'] = $idna_convert->encode(preg_replace(array('/\\:(\\d)+$/', '/^https?\\:\\/\\//'), '', $domain_data['aliasdomain'])); // validate alias-domain if (!validateDomain($domain_data['aliasdomain'])) { // invalid-domain lol - skip to be sure we dont add anything weird return false; } // does the domain we want to be an alias of exists? if (!in_array($domain_data['aliasdomain'], $this->_knownDomains)) { // it does not - User should respect the order of import so if the domain // he wants to alias is also part of the import is ABOVE this one // - we'd better skip return false; } } // check for use_ssl and ssl_redirect if (!isset($domain_data['use_ssl']) || $domain_data['use_ssl'] == 1) { // if not set: default is whatever the system says // if set to 1: set to 0 if system has no ssl enabled $domain_data['use_ssl'] = Settings::get('system.use_ssl') == 1 ? 1 : 0; } // use_ssl flag if ($domain_data['use_ssl'] != 1) { $domain_data['use_ssl'] = 0; } // ssl_redirect flag if ($domain_data['ssl_redirect'] != 1) { $domain_data['ssl_redirect'] = 0; } // if use_ssl is 0 ssl_redirect must be too (no ssl-ip => no ssl-redirect) if ($domain_data['use_ssl'] == 0 && $domain_data['ssl_redirect'] == 1) { $domain_data['ssl_redirect'] = 0; } // add to known domains $this->_knownDomains[] = $domain_data['domain']; // docroot (URL allowed, will lead to redirect) if (!preg_match('/^https?\\:\\/\\//', $domain_data['documentroot'])) { $domain_data['documentroot'] = makeCorrectDir($this->_custData['documentroot'] . "/" . $domain_data['documentroot']); } // is bind domain? if (!isset($domain_data['isbinddomain'])) { $domain_data['isbinddomain'] = Settings::Get('system.bind_enable') == '1' ? 1 : 0; } elseif ($domain_data['isbinddomain'] != 1) { $domain_data['isbinddomain'] = 0; } // zonefile if (!isset($domain_data['zonefile'])) { $domain_data['zonefile'] = ""; } else { if (!empty($domain_data['zonefile']) && Settings::Get('system.bind_enable') == '1') { $domain_data['zonefile'] = makeCorrectFile($domain_data['zonefile']); } else { $domain_data['zonefile'] = ""; } } // openbasedir flag if (!isset($domain_data['openbasedir'])) { $domain_data['openbasedir'] = 1; } elseif ($domain_data['openbasedir'] != 1) { $domain_data['openbasedir'] = 0; } // speciallogfile flag if (!isset($domain_data['speciallogfile'])) { $domain_data['speciallogfile'] = 0; } elseif ($domain_data['speciallogfile'] != 1) { $domain_data['speciallogfile'] = 0; } /* * automatically set values (not from the file) */ // add date $domain_data['add_date'] = time(); // set adminid $domain_data['adminid'] = (int) $this->_custData['adminid']; // set customerid $domain_data['customerid'] = (int) $this->_custId; // check for required fields foreach ($this->_required_fields as $rfld) { if (!isset($domain_data[$rfld])) { return false; } } // clean all fields that do not belong to the required fields $domain_data_tmp = $domain_data; foreach ($domain_data_tmp as $fld => $val) { if (!in_array($fld, $this->_required_fields)) { unset($domain_data[$fld]); } } // save iplist $iplist = $domain_data['ips']; $iplist_arr = array_unique(explode(",", $iplist)); $knownIPsCheck = array_unique($this->_knownIpPortChk); // check whether we actually have at least one of the used IP's in our system $result_iplist = array_intersect($iplist_arr, $knownIPsCheck); // write back iplist $iplist = implode(",", $result_iplist); // dont need that for the domain-insert-statement unset($domain_data['ips']); // remember use_ssl value $use_ssl = (bool) $domain_data['use_ssl']; // dont need that for the domain-insert-statement unset($domain_data['use_ssl']); // finally ADD the domain to panel_domains Database::pexecute($this->_ins_stmt, $domain_data); // get the newly inserted domain-id $domain_id = Database::lastInsertId(); // insert domain <-> ip/port reference if (empty($iplist)) { $iplist = Settings::Get('system.ipaddress'); } // split ip-list and remove duplicates $iplist_arr = array_unique(explode(",", $iplist)); foreach ($iplist_arr as $ip) { // if we know the ip, at all variants (different ports, ssl and non-ssl) of it! if (isset($this->_knownIpPort[$ip])) { foreach ($this->_knownIpPort[$ip] as $ipdata) { // no ssl ip/ports should be used for this domain if ($use_ssl == false && $ipdata['ssl'] == 1) { continue; } // add domain->ip reference Database::pexecute($this->_ipp_ins_stmt, array('domid' => $domain_id, 'ipid' => $ipdata['id'])); } } } return $domain_id; }
} if ($service_active == 1) { $service_active = '1'; if (!isset($servicestart_date) || $servicestart_date == '0000-00-00') { $servicestart_date = date('Y-m-d'); } } else { $service_active = '0'; $servicestart_date = '0000-00-00'; } if ($interval_payment != '1') { $interval_payment = '0'; } if ($domain == '') { standard_error(array('stringisempty', 'mydomain')); } elseif (!validateDomain($domain)) { standard_error(array('stringiswrong', 'mydomain')); } elseif ($documentroot == '') { standard_error(array('stringisempty', 'mydocumentroot')); } elseif ($customerid == 0) { standard_error('adduserfirst'); } elseif (strtolower($domain_check['domain']) == strtolower($domain)) { standard_error('domainalreadyexists', $idna_convert->decode($domain)); } elseif ($aliasdomain_check['id'] != $aliasdomain) { standard_error('domainisaliasorothercustomer'); } else { $params = array('page' => $page, 'action' => $action, 'domain' => $domain, 'customerid' => $customerid, 'adminid' => $adminid, 'documentroot' => $documentroot, 'alias' => $aliasdomain, 'isbinddomain' => $isbinddomain, 'isemaildomain' => $isemaildomain, 'email_only' => $email_only, 'subcanemaildomain' => $subcanemaildomain, 'caneditdomain' => $caneditdomain, 'zonefile' => $zonefile, 'dkim' => $dkim, 'speciallogfile' => $speciallogfile, 'wwwserveralias' => $wwwserveralias, 'ipandport' => $ipandport, 'ssl' => $ssl, 'ssl_redirect' => $ssl_redirect, 'ssl_ipandport' => $ssl_ipandport, 'openbasedir' => $openbasedir, 'safemode' => $safemode, 'phpsettingid' => $phpsettingid, 'mod_fcgid_starter' => $mod_fcgid_starter, 'mod_fcgid_maxrequests' => $mod_fcgid_maxrequests, 'specialsettings' => $specialsettings, 'registration_date' => $registration_date, 'interval_fee' => $interval_fee, 'interval_length' => $interval_length, 'interval_type' => $interval_type, 'interval_payment' => $interval_payment, 'setup_fee' => $setup_fee, 'servicestart_date' => $servicestart_date, 'service_active' => $service_active); $security_questions = array('reallydisablesecuritysetting' => ($openbasedir == '0' || $safemode == '0') && $userinfo['change_serversettings'] == '1', 'reallydocrootoutofcustomerroot' => substr($documentroot, 0, strlen($customer['documentroot'])) != $customer['documentroot'] && !preg_match('/^https?\\:\\/\\//', $documentroot)); foreach ($security_questions as $question_name => $question_launch) { if ($question_launch !== false) { $params[$question_name] = $question_name;
// check only last part of content, as it can look like: // _service._proto.name. TTL class SRV priority weight port target. $_split_content = explode(" ", $content); // SRV content must be [weight] [port] [target] if (count($_split_content) != 3) { $errors[] = $lng['error']['dns_srv_invalidcontent']; } $target = trim($_split_content[count($_split_content) - 1]); if ($target != '.') { // check for trailing dot if (substr($target, -1) == '.') { // remove it for checks $target = substr($target, 0, -1); } } if ($target != '.' && !validateDomain($target)) { $errors[] = $lng['error']['dns_srv_needdom']; } else { // check whether there is a CNAME-record for the same resource foreach ($dom_entries as $existing_entries) { $fqdn = $existing_entries['record'] . '.' . $domain; if ($existing_entries['type'] == 'CNAME' && $fqdn == $target) { $errors[] = $lng['error']['dns_srv_noalias']; break; } } } // append trailing dot (again) if ($target != '.') { $content .= '.'; }
} if ($dkim != '1') { $dkim = '0'; } if ($wwwserveralias != '1') { $wwwserveralias = '0'; } if ($caneditdomain != '1') { $caneditdomain = '0'; } if ($issubof <= '0') { $issubof = '0'; } if ($domain == '') { standard_error(array('stringisempty', 'mydomain')); } elseif ($settings['system']['validate_domain'] && !validateDomain($domain)) { standard_error(array('stringiswrong', 'mydomain')); } elseif ($documentroot == '') { standard_error(array('stringisempty', 'mydocumentroot')); } elseif ($customerid == 0) { standard_error('adduserfirst'); } elseif (strtolower($domain_check['domain']) == strtolower($domain)) { standard_error('domainalreadyexists', $idna_convert->decode($domain)); } elseif ($aliasdomain_check['id'] != $aliasdomain) { standard_error('domainisaliasorothercustomer'); } else { $params = array('page' => $page, 'action' => $action, 'domain' => $domain, 'customerid' => $customerid, 'adminid' => $adminid, 'documentroot' => $documentroot, 'alias' => $aliasdomain, 'isbinddomain' => $isbinddomain, 'isemaildomain' => $isemaildomain, 'email_only' => $email_only, 'subcanemaildomain' => $subcanemaildomain, 'caneditdomain' => $caneditdomain, 'zonefile' => $zonefile, 'dkim' => $dkim, 'speciallogfile' => $speciallogfile, 'wwwserveralias' => $wwwserveralias, 'ipandport' => $ipandport, 'ssl' => $ssl, 'ssl_redirect' => $ssl_redirect, 'ssl_ipandport' => $ssl_ipandport, 'openbasedir' => $openbasedir, 'safemode' => $safemode, 'phpsettingid' => $phpsettingid, 'mod_fcgid_starter' => $mod_fcgid_starter, 'mod_fcgid_maxrequests' => $mod_fcgid_maxrequests, 'specialsettings' => $specialsettings, 'registration_date' => $registration_date, 'issubof' => $issubof); $security_questions = array('reallydisablesecuritysetting' => $openbasedir == '0' && $userinfo['change_serversettings'] == '1', 'reallydocrootoutofcustomerroot' => substr($documentroot, 0, strlen($customer['documentroot'])) != $customer['documentroot'] && !preg_match('/^https?\\:\\/\\//', $documentroot)); $question_nr = 1; foreach ($security_questions as $question_name => $question_launch) { if ($question_launch !== false) {
public function test_Success_Sidnnl() { $domainname = 'sidn.nl'; $this->assertTrue(validateDomain($domainname)); }