diff --git a/automation/helpers.php b/automation/helpers.php index f19b570..0c785a1 100644 --- a/automation/helpers.php +++ b/automation/helpers.php @@ -104,7 +104,7 @@ function checkUrlhaus($domain, Map $urlhausData) { return $urlhausData->get($domain, false); } -function getDomainPrice($pdo, $domain_name, $tld_id, $date_add = 12, $command = 'create') { +function getDomainPrice($pdo, $domain_name, $tld_id, $date_add = 12, $command = 'create', $registrar_id = null) { // Check if the domain is a premium domain $stmt = $pdo->prepare(" SELECT c.category_price @@ -145,8 +145,17 @@ function getDomainPrice($pdo, $domain_name, $tld_id, $date_add = 12, $command = // Get regular price for the specified period $priceColumn = "m" . $date_add; - $stmt = $pdo->prepare("SELECT $priceColumn FROM domain_price WHERE tldid = ? AND command = '$command' LIMIT 1"); - $stmt->execute([$tld_id]); + $sql = " + SELECT $priceColumn + FROM domain_price + WHERE tldid = ? + AND command = ? + AND (registrar_id = ? OR registrar_id IS NULL) + ORDER BY registrar_id DESC + LIMIT 1 + "; + $stmt = $pdo->prepare($sql); + $stmt->execute([$tld_id, $command, $registrar_id]); if ($stmt->rowCount() > 0) { $regularPrice = $stmt->fetch()[$priceColumn]; diff --git a/cp/bootstrap/helper.php b/cp/bootstrap/helper.php index 2b518fd..afa84d3 100644 --- a/cp/bootstrap/helper.php +++ b/cp/bootstrap/helper.php @@ -338,7 +338,7 @@ function extractDomainAndTLD($urlString) { return ['domain' => $sld, 'tld' => $tld]; } -function getDomainPrice($db, $domain_name, $tld_id, $date_add = 12, $command = 'create') { +function getDomainPrice($db, $domain_name, $tld_id, $date_add = 12, $command = 'create', $registrar_id = null) { // Check if the domain is a premium domain $premiumDomain = $db->selectRow( 'SELECT c.category_price @@ -377,8 +377,8 @@ function getDomainPrice($db, $domain_name, $tld_id, $date_add = 12, $command = ' // Get regular price for the specified period $priceColumn = "m" . $date_add; $regularPrice = $db->selectValue( - "SELECT $priceColumn FROM domain_price WHERE tldid = ? AND command = ? LIMIT 1", - [$tld_id, $command] + "SELECT $priceColumn FROM domain_price WHERE tldid = ? AND command = ? AND (registrar_id = ? OR registrar_id IS NULL) ORDER BY registrar_id DESC LIMIT 1", + [$tld_id, $command, $registrar_id] ); if ($regularPrice !== false) { diff --git a/epp/src/helpers.php b/epp/src/helpers.php index 77dda8a..20da880 100644 --- a/epp/src/helpers.php +++ b/epp/src/helpers.php @@ -515,7 +515,7 @@ function updatePermittedIPs($pool, $permittedIPsTable) { } } -function getDomainPrice($pdo, $domain_name, $tld_id, $date_add = 12, $command = 'create') { +function getDomainPrice($pdo, $domain_name, $tld_id, $date_add = 12, $command = 'create', $registrar_id = null) { // Check if the domain is a premium domain $stmt = $pdo->prepare(" SELECT c.category_price @@ -556,8 +556,17 @@ function getDomainPrice($pdo, $domain_name, $tld_id, $date_add = 12, $command = // Get regular price for the specified period $priceColumn = "m" . $date_add; - $stmt = $pdo->prepare("SELECT $priceColumn FROM domain_price WHERE tldid = ? AND command = '$command' LIMIT 1"); - $stmt->execute([$tld_id]); + $sql = " + SELECT $priceColumn + FROM domain_price + WHERE tldid = ? + AND command = ? + AND (registrar_id = ? OR registrar_id IS NULL) + ORDER BY registrar_id DESC + LIMIT 1 + "; + $stmt = $pdo->prepare($sql); + $stmt->execute([$tld_id, $command, $registrar_id]); if ($stmt->rowCount() > 0) { $regularPrice = $stmt->fetch()[$priceColumn];