Housekeeping on domain and application registration

This commit is contained in:
Pinga 2025-02-17 15:25:00 +02:00
parent 3171adc1b2
commit 52f4eab87d
2 changed files with 38 additions and 43 deletions

View file

@ -1064,15 +1064,12 @@ class ApplicationsController extends Controller
$parts = extractDomainAndTLD($domainName); $parts = extractDomainAndTLD($domainName);
$label = $parts['domain']; $label = $parts['domain'];
$domain_extension = $parts['tld']; $domain_extension = '.' . strtoupper($parts['tld']);
$result = $db->select('SELECT id, tld FROM domain_tld'); $tld_id = $db->selectValue(
foreach ($result as $row) { "SELECT id FROM domain_tld WHERE UPPER(tld) = ?",
if ('.' . strtoupper($domain_extension) === strtoupper($row['tld'])) { [$domain_extension]
$tld_id = $row['id']; );
break;
}
}
$result = $db->selectRow('SELECT registrar_id FROM registrar_users WHERE user_id = ?', [$_SESSION['auth_user_id']]); $result = $db->selectRow('SELECT registrar_id FROM registrar_users WHERE user_id = ?', [$_SESSION['auth_user_id']]);
@ -1081,18 +1078,18 @@ class ApplicationsController extends Controller
} else { } else {
$clid = $registrar_id_domain; $clid = $registrar_id_domain;
} }
$result = $db->selectRow('SELECT accountBalance, creditLimit, currency FROM registrar WHERE id = ?', [$clid]); $result = $db->selectRow('SELECT accountBalance, creditLimit, currency FROM registrar WHERE id = ?', [$clid]);
$registrar_balance = $result['accountBalance']; $registrar_balance = $result['accountBalance'];
$creditLimit = $result['creditLimit']; $creditLimit = $result['creditLimit'];
$currency = $result['currency']; $currency = $result['currency'];
$date_add = 12; $date_add = 12;
$returnValue = getDomainPrice($db, $domainName, $tld_id, $date_add, 'create', $clid, $currency); $returnValue = getDomainPrice($db, $domainName, $tld_id, $date_add, 'create', $clid, $currency);
$price = $returnValue['price']; $price = $returnValue['price'];
try { try {
$db->beginTransaction(); $db->beginTransaction();

View file

@ -181,20 +181,14 @@ class DomainsController extends Controller
return $response->withHeader('Location', '/domain/create')->withStatus(302); return $response->withHeader('Location', '/domain/create')->withStatus(302);
} }
$label = $parts['domain']; $label = $parts['domain'];
$domain_extension = $parts['tld']; $domain_extension = '.' . strtoupper($parts['tld']);
$valid_tld = false;
$result = $db->select('SELECT id, tld FROM domain_tld');
foreach ($result as $row) { $tld_id = $db->selectValue(
if ('.' . strtoupper($domain_extension) === strtoupper($row['tld'])) { "SELECT id FROM domain_tld WHERE UPPER(tld) = ?",
$valid_tld = true; [$domain_extension]
$tld_id = $row['id']; );
break;
}
}
if (!$valid_tld) { if (!$tld_id) {
$this->container->get('flash')->addMessage('error', 'Error creating domain: Invalid domain extension'); $this->container->get('flash')->addMessage('error', 'Error creating domain: Invalid domain extension');
return $response->withHeader('Location', '/domain/create')->withStatus(302); return $response->withHeader('Location', '/domain/create')->withStatus(302);
} }
@ -216,13 +210,18 @@ class DomainsController extends Controller
"SELECT phase_category "SELECT phase_category
FROM launch_phases FROM launch_phases
WHERE tld_id = ? WHERE tld_id = ?
AND phase_type = ?
AND start_date <= ? AND start_date <= ?
AND (end_date >= ? OR end_date IS NULL OR end_date = '') AND (end_date >= ? OR end_date IS NULL OR end_date = '')
", ",
[$tld_id, $phaseType, $currentDate, $currentDate] [$tld_id, $currentDate, $currentDate]
); );
// Check if the phase requires application submission
if ($phase_details && $phase_details === 'Application') {
$this->container->get('flash')->addMessage('error', 'Domain registration is not allowed for this TLD. You must submit a new application instead.');
return $response->withHeader('Location', '/domain/create')->withStatus(302);
}
if ($phase_details !== 'First-Come-First-Serve') { if ($phase_details !== 'First-Come-First-Serve') {
if ($phaseType !== 'none') { if ($phaseType !== 'none') {
if ($phaseType == null && $phaseType == '') { if ($phaseType == null && $phaseType == '') {
@ -1765,16 +1764,18 @@ class DomainsController extends Controller
$parts = extractDomainAndTLD($domainName); $parts = extractDomainAndTLD($domainName);
$label = $parts['domain']; $label = $parts['domain'];
$domain_extension = $parts['tld']; $domain_extension = '.' . strtoupper($parts['tld']);
$result = $db->select('SELECT id, tld FROM domain_tld'); $tld_id = $db->selectValue(
foreach ($result as $row) { "SELECT id FROM domain_tld WHERE UPPER(tld) = ?",
if ('.' . strtoupper($domain_extension) === strtoupper($row['tld'])) { [$domain_extension]
$tld_id = $row['id']; );
break;
} if (!$tld_id) {
$this->container->get('flash')->addMessage('error', 'Error creating domain: Invalid domain extension');
return $response->withHeader('Location', '/domains')->withStatus(302);
} }
$result = $db->selectRow('SELECT registrar_id FROM registrar_users WHERE user_id = ?', [$_SESSION['auth_user_id']]); $result = $db->selectRow('SELECT registrar_id FROM registrar_users WHERE user_id = ?', [$_SESSION['auth_user_id']]);
if ($_SESSION["auth_roles"] != 0) { if ($_SESSION["auth_roles"] != 0) {
@ -2051,7 +2052,12 @@ class DomainsController extends Controller
$parts = extractDomainAndTLD($domainName); $parts = extractDomainAndTLD($domainName);
$label = $parts['domain']; $label = $parts['domain'];
$domain_extension = $parts['tld']; $domain_extension = '.' . strtoupper($parts['tld']);
$tld_id = $db->selectValue(
"SELECT id FROM domain_tld WHERE UPPER(tld) = ?",
[$domain_extension]
);
if ($_SESSION["auth_roles"] != 0) { if ($_SESSION["auth_roles"] != 0) {
$clid = $db->selectValue('SELECT registrar_id FROM registrar_users WHERE user_id = ?', [$_SESSION['auth_user_id']]); $clid = $db->selectValue('SELECT registrar_id FROM registrar_users WHERE user_id = ?', [$_SESSION['auth_user_id']]);
@ -2062,14 +2068,6 @@ class DomainsController extends Controller
$clid = $registrar_id_domain; $clid = $registrar_id_domain;
} }
$result = $db->select('SELECT id, tld FROM domain_tld');
foreach ($result as $row) {
if ('.' . strtoupper($domain_extension) === strtoupper($row['tld'])) {
$tld_id = $row['id'];
break;
}
}
$results = $db->select( $results = $db->select(
'SELECT status FROM domain_status WHERE domain_id = ?', 'SELECT status FROM domain_status WHERE domain_id = ?',
[ $domain_id ] [ $domain_id ]