Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
feat(aftermarket domains): brought back after having a non-transfer b…
Browse files Browse the repository at this point in the history
…locking solution identified
  • Loading branch information
KaiSchwarz-cnic committed Jul 8, 2022
1 parent c5bfda1 commit 478911f
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 32 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

52 changes: 31 additions & 21 deletions modules/addons/ispapidomaincheck/lib/Client/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,37 @@ public function checkdomains($vars, $smarty)
&& isset($rs["PRICE"], $rs["CURRENCY"])
&& !empty($rs["PRICE"][$idx])
) {
$row["status"] = "AFTERMARKET";//STATUS_REGISTERED
$row["statusText"] = SearchResult::STATUS_NOT_REGISTERED;
$row["status"] = "AVAILABLE";
$row["REASON"] = "AFTERMARKET";
// $row["status"] = "AFTERMARKET";
$price = $rs["PRICE"][$idx];
$currency = $rs["CURRENCY"][$idx];
$currencies = DCHelper::getCurrencies();
$currencysettings = $currencies[$currency];
$active_settings = $currencies[$_SESSION["currency"]];
if ($currencysettings === null) {
//unsupported currency in WHMCS
//TODO: we could improve here by just converting currency
//$row["status"] = "TAKEN";
//$row["statusText"] = SearchResult::STATUS_REGISTERED;
unset($rs["PRICE"][$idx], $rs["PRICERENEW"][$idx], $rs["CURRENCY"][$idx]);
} else {
$premiumchannel = $rs["PREMIUMCHANNEL"][$idx];
$class = $rs["CLASS"][$idx];
$register_price_raw = DCHelper::getPremiumRegistrationPrice(
$price,
$currencysettings
);
$renew_price_raw = DCHelper::getPremiumRenewPrice(
$data["registrars"][$idx],
$class,
DCHelper::getDomainExtension($idn),
$currencysettings
);
$rs["PRICE"][$idx] = $register_price_raw;
$rs["PRICERENEW"][$idx] = $renew_price_raw;
}
} elseif (
!empty($rs["PREMIUMCHANNEL"][$idx]) //exclude already registered ones
&& preg_match("/^PREMIUM_/", $rs["CLASS"][$idx])
Expand Down Expand Up @@ -206,26 +236,6 @@ public function checkdomains($vars, $smarty)
}
$res["errormsg"] = $msg;
}
/*if (!empty($invalids)) {
$file = "/var/www/html/invalid.json";
if (file_exists($file)) {
$current = json_decode(file_get_contents($file), true);
$current = array_merge($current, $invalids);
} else {
$current = $invalids;
}
file_put_contents($file, json_encode($current, JSON_PRETTY_PRINT));
}
if (!empty($takens)) {
$file = "/var/www/html/taken.json";
if (file_exists($file)) {
$current = json_decode(file_get_contents($file), true);
$current = array_merge($current, $takens);
} else {
$current = $takens;
}
file_put_contents($file, json_encode($current, JSON_PRETTY_PRINT));
}*/
ksort($res["results"]);
$perf["controller"]["end"] = microtime(true);
$perf["controller"]["rt"] = $perf["controller"]["end"] - $perf["controller"]["start"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ ShoppingCart.prototype.addOrderPremium = function (sr, successmsg, errmsg) {
// WHMCS adds premium domain data to session in their standard domain availability check
const row = sr.data;
$.ajax(
`cart.php?a=checkDomain&token=${csrfToken}&domain=${row.IDN}&source&cartAddDomain&type=domain`,
`cart.php?a=checkDomain&token=${csrfToken}&domain=${row.IDN}&source&cartAddDomain&type=domain&ispapichecker=true`,
{
type: 'GET',
dataType: 'json',
Expand Down Expand Up @@ -2191,6 +2191,12 @@ DomainSearch.prototype.processResults = function (grp, d) {
} else {
row.premiumtype = 'PREMIUM';
}
} else if (
row.PREMIUMCHANNEL &&
row.REASON &&
row.REASON === 'AFTERMARKET'
) {
row.premiumtype = row.REASON;
}
// override by returned registrar prices and cleanup row data
if (Object.prototype.hasOwnProperty.call(row, 'PRICE')) {
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,12 @@ DomainSearch.prototype.processResults = function (grp, d) {
} else {
row.premiumtype = 'PREMIUM';
}
} else if (
row.PREMIUMCHANNEL &&
row.REASON &&
row.REASON === 'AFTERMARKET'
) {
row.premiumtype = row.REASON;
}
// override by returned registrar prices and cleanup row data
if (Object.prototype.hasOwnProperty.call(row, 'PRICE')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ShoppingCart.prototype.addOrderPremium = function (sr, successmsg, errmsg) {
// WHMCS adds premium domain data to session in their standard domain availability check
const row = sr.data;
$.ajax(
`cart.php?a=checkDomain&token=${csrfToken}&domain=${row.IDN}&source&cartAddDomain&type=domain`,
`cart.php?a=checkDomain&token=${csrfToken}&domain=${row.IDN}&source&cartAddDomain&type=domain&ispapichecker=true`,
{
type: 'GET',
dataType: 'json',
Expand Down

0 comments on commit 478911f

Please sign in to comment.