where('id', $_SESSION['uid'])->where('language', '<>', '')->value('language'); if ($litem) { $clang = $litem; } } if (isset($_SESSION['Language'])) { $clang = $_SESSION['Language']; } if (file_exists(ROOTDIR . "/modules/addons/ExistingDomains/lang/" . $clang . ".php")) { include(ROOTDIR . "/modules/addons/ExistingDomains/lang/" . $clang . ".php"); } elseif (file_exists(ROOTDIR . "/modules/addons/ExistingDomains/lang/" . $CONFIG['Language'] . ".php")) { include(ROOTDIR . "/modules/addons/ExistingDomains/lang/" . $CONFIG['Language'] . ".php"); } elseif (file_exists(ROOTDIR . "/modules/addons/ExistingDomains/lang/english.php")) { include(ROOTDIR . "/modules/addons/ExistingDomains/lang/english.php"); } if ($vars['productinfo']['pid'] && $_SESSION['uid']) { $EDMODULE = array(); $results = Capsule::table('tbladdonmodules')->where('module', 'ExistingDomains')->get(); foreach ($results as $data) { $setting = $data->setting; $value = $data->value; $EDMODULE[$setting] = $value; } if ($EDMODULE['doption'] != '') { $edresult = Capsule::table('tbldomains')->where('userid', $_SESSION['uid'])->where('status', 'Active')->get(); } foreach ($edresult as $eddata) { $returns['existingdomains'][] = $eddata->domain; } $returns['EDLANG'] = $_ADDONLANG; $returns['WSEXISTING'] = $EDMODULE; return $returns; } }); add_hook("ClientAreaFooterOutput", 1, function($vars) { global $CONFIG; if ("flowcart7" == $CONFIG['OrderFormTemplate']) { return ''; } if ("lagom" == $CONFIG['OrderFormTemplate']) { return ''; } if (!isset($_SESSION['uid'])) { return ''; } $wscurrentfile = App::getCurrentFilename(); if ($wscurrentfile != 'cart') { return ''; } $clang = $CONFIG['Language']; $litem = Capsule::table('tblclients')->where('id', $_SESSION['uid'])->where('language', '<>', '')->value('language'); if ($litem) { $clang = $litem; } if (isset($_SESSION['Language'])) { $clang = $_SESSION['Language']; } if (file_exists(ROOTDIR . "/modules/addons/ExistingDomains/lang/" . $clang . ".php")) { include(ROOTDIR . "/modules/addons/ExistingDomains/lang/" . $clang . ".php"); } elseif (file_exists(ROOTDIR . "/modules/addons/ExistingDomains/lang/" . $CONFIG['Language'] . ".php")) { include(ROOTDIR . "/modules/addons/ExistingDomains/lang/" . $CONFIG['Language'] . ".php"); } elseif (file_exists(ROOTDIR . "/modules/addons/ExistingDomains/lang/english.php")) { include(ROOTDIR . "/modules/addons/ExistingDomains/lang/english.php"); } return << jQuery('#frmProductDomain').submit(function (e) { e.preventDefault(); $(".errordomainnamepws").remove(); var btnSearchObj = jQuery(this).find('button[type="submit"]'), domainSearchResults = jQuery("#DomainSearchResults"), spotlightTlds = jQuery('#spotlightTlds'), suggestions = jQuery('#domainSuggestions'), btnDomainContinue = jQuery('#btnDomainContinue'), domainoption = jQuery(".domain-selection-options input:checked").val(), sldInput = jQuery("#" + domainoption + "sld"), sld = sldInput.val(), tld = '', pid = jQuery('#frmProductDomainPid').val(), tldInput = ''; if (domainoption == 'existing_domain') { sldInput = jQuery("#existing_domainsld option:selected"); sld = sldInput.text(); var splitDomain = sld.split('.'); sld = splitDomain[0]; splitDomain.splice(0, 1); tld = '.' + splitDomain.join("."); jQuery('.domain-lookup-other-loader').show(); jQuery('.domain-lookup-loader').show(); btnDomainContinue.addClass('hidden').attr('disabled', 'disabled'); var otherDomain = jQuery.post( 'cart.php', { token: csrfToken, a: 'checkDomain', type: "owndomain",//domainoption, pid: pid, wscheck: 1, domain: sld + tld }, 'json' ); otherDomain.done(function(data) { if (typeof data != 'object' || data.result.length == 0) { jQuery('.domain-lookup-subdomain-loader').hide(); return; } if(typeof data.result.wsres !== 'undefined' && data.result.wsres.length > 0){ $(".errordomainnamepws").remove(); $('#frmProductDomainSelections').prepend('
'+data.result.wsdomain+' {$_ADDONLANG['errordomain']}
'); } jQuery.each(data.result, function(index, result) { if (result.status === true) { window.location = 'cart.php?a=confproduct&i=' + result.num; } else { jQuery('.domain-lookup-primary-loader').hide(); jQuery('#primaryLookupResult').removeClass('hidden').show().find('.domain-invalid').show(); } }); }).always(function(){ hasProductDomainLookupEnded(1, btnSearchObj); }); }else if(domainoption == 'subexisting_domain'){ if($("#subdomainexisting_domaindomains").val() === ''){ $('#subdomainexisting_domaindomains').tooltip('show'); return 0; } jQuery('.domain-lookup-other-loader').show(); jQuery('.domain-lookup-loader').show(); btnDomainContinue.addClass('hidden').attr('disabled', 'disabled'); var ddsubdomain = $("#subexisting_domaindomainid").val(); var otherDomain = jQuery.post( 'cart.php', { token: csrfToken, a: 'checkDomain', type: "owndomain",//domainoption, pid: pid, wscheck: 1, issubdomain: 1, domain: ddsubdomain }, 'json' ); otherDomain.done(function(data) { if (typeof data != 'object' || data.result.length == 0) { jQuery('.domain-lookup-subdomain-loader').hide(); return; } if(typeof data.result.wsres !== 'undefined' && data.result.wsres.length > 0){ $(".errordomainnamepws").remove(); $('#frmProductDomainSelections').prepend('
'+data.result.wsdomain+' {$_ADDONLANG['errordomain']}.
'); } jQuery.each(data.result, function(index, result) { if (result.status === true) { window.location = 'cart.php?a=confproduct&i=' + result.num; } else { jQuery('.domain-lookup-primary-loader').hide(); jQuery('#primaryLookupResult').removeClass('hidden').show().find('.domain-invalid').show(); } }); }).always(function(){ hasProductDomainLookupEnded(1, btnSearchObj); }); } btnDomainContinue.removeClass('hidden'); }); EOL; }); $wscurrentfile = App::getCurrentFilename(); function ExistingDomains_checkdomainvalid() { $EDMODULE = array(); $results = Capsule::table('tbladdonmodules')->where('module', 'ExistingDomains')->get(); foreach ($results as $data) { $setting = $data->setting; $value = $data->value; $EDMODULE[$setting] = $value; } $wcddomain = (string) strip_tags(trim($_REQUEST['domain'])); if ($EDMODULE['doption'] != 'Allow Duplicate') { $wsdvccheck = false; $wcduseri = (int) $_SESSION['uid']; $wcdpid = (int) $_REQUEST['pid']; if ($EDMODULE['doption'] == 'Same product domain') { $wcditem = Capsule::table('tblhosting')->where('userid', $wcduseri)->where('packageid', $wcdpid)->where('domain', $wcddomain)->where('domainstatus', 'Active')->count(); if ($wcditem) { $wsdvccheck = TRUE; } } if ($EDMODULE['doption'] == 'All product domain') { $wcditem = Capsule::table('tblhosting')->where('userid', $wcduseri)->where('domain', $wcddomain)->where('domainstatus', 'Active')->count(); if ($wcditem) { $wsdvccheck = TRUE; } } if ($wsdvccheck) { $result = array( 'status' => FALSE, 'result' => '', 'wsres' => 'notallowed', 'wsdomain' => $wcddomain, ); $response = new \WHMCS\Http\JsonResponse(array("result" => $result), 200, array("Content-Type" => "application/json")); $response->send(); \WHMCS\Terminus::getInstance()->doExit(); } if (isset($_REQUEST['issubdomain']) && $_REQUEST['issubdomain'] != '') { $resss = wscheckIncart($wcddomain); $response = new \WHMCS\Http\JsonResponse(array("result" => array("result" => $resss)), 200, array("Content-Type" => "application/json")); $response->send(); \WHMCS\Terminus::getInstance()->doExit(); } } } function wscartPreventDuplicateProduct($domain) { if ($domain) { $domains = array(); foreach ($_SESSION["cart"]["products"] as $k => $values) { $domains[$k] = $values["domain"]; } if (in_array($domain, $domains)) { $i = array_search($domain, $domains); if ($i !== false) { unset($_SESSION["cart"]["products"][$i]); $_SESSION["cart"]["products"] = array_values($_SESSION["cart"]["products"]); } } } } function wscheckIncart($domain) { $orderForm = new \WHMCS\OrderForm(); $productId = (int) $_REQUEST["pid"]; $productInfo = $orderForm->setPid($productId); $passedVariables = $_SESSION["cart"]["passedvariables"]; unset($_SESSION["cart"]["passedvariables"]); wscartPreventDuplicateProduct($domain); $productArray = array("pid" => $productId, "domain" => $domain, "billingcycle" => $passedVariables["billingcycle"] ?: $orderForm->validateBillingCycle(""), "configoptions" => $passedVariables["configoption"], "customfields" => $passedVariables["customfield"], "addons" => $passedVariables["addons"], "server" => "", "noconfig" => true, "skipConfig" => isset($passedVariables["skipconfig"]) && $passedVariables["skipconfig"]); if (isset($passedVariables["bnum"])) { $productArray["bnum"] = $passedVariables["bnum"]; } if (isset($passedVariables["bitem"])) { $productArray["bitem"] = $passedVariables["bitem"]; } $_SESSION["cart"]["newproduct"] = true; $updatedExistingQuantity = false; if ($productInfo["allowqty"]) { foreach ($_SESSION["cart"]["products"] as &$cart_prod) { if ($productId == $cart_prod["pid"]) { if (empty($cart_prod["qty"])) { $cart_prod["qty"] = 1; } $cart_prod["qty"] ++; if ($productInfo["stockcontrol"] && $productInfo["qty"] < $cart_prod["qty"]) { $cart_prod["qty"] = $productInfo["qty"]; } $updatedExistingQuantity = true; break; } } } if (!$updatedExistingQuantity) { $_SESSION["cart"]["products"][] = $productArray; } $newProductIValue = count($_SESSION["cart"]["products"]) - 1; if (isset($passedVariables["skipconfig"]) && $passedVariables["skipconfig"]) { unset($_SESSION["cart"]["products"][$newProductIValue]["noconfig"]); $_SESSION["cart"]["lastconfigured"] = array("type" => "product", "i" => $newProductIValue); } $searchResult = array("status" => true, "num" => $newProductIValue); return $searchResult; } if ($wscurrentfile == 'cart' && isset($_SESSION['uid']) && isset($_REQUEST['a']) && $_REQUEST['a'] == "checkDomain" && isset($_REQUEST['wscheck'])) { ExistingDomains_checkdomainvalid(); }