| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567 |
- <?php
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * SWITCH EPP REGISTRAR WHMCS Module By whmcsglobalservices.com
- * Copyright whmcsglobalservices, All Rights Reserved
- *
- * Release: 21 January, 2015
- * Version: 3.1.0
- * WHMCS Version: v6,v7,V8
- * Update Date: 17 April, 2025
- *
- * By WHMCSGLOBALSERVICES https://whmcsglobalservices.com
- * Contact info@whmcsglobalservices.com
- *
- * This module is made under license issued by whmcsglobalservices.com
- * and used under all terms and conditions of license. Ownership of
- * module can not be changed. Title and copy of module is not
- * available to any other person.
- *
- * @owner <whmcsglobalservices.com>
- * @author <WHMCSGLOBALSERVICES>
- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
- use Illuminate\Database\Capsule\Manager as Capsule;
- use WGSSWITCHEPP\IDNA\idna_convert as idna_convert;
- if (!defined("WHMCS"))
- die("This file cannot be accessed directly");
- if (!class_exists('Net_EPP_Protocol')) {
- if (file_exists(__DIR__ . "/Net/EPP/Client.php"))
- require_once __DIR__ . "/Net/EPP/Client.php";
- }
- // require_once(__DIR__ . '/idna_convert.class.php');
- #*********************Registrar config options***************************#
- function switchepp_getConfigArray()
- {
- $configarray = array(
- "FriendlyName" => array(
- "Type" => "System",
- "Value" => "Switch Epp"
- ),
- "registrar_id" => array(
- "FriendlyName" => "Registrar Id",
- "Type" => "text",
- "Size" => "50",
- 'Description' => 'Enter production SwitchEPP User ID (Client Identifier clIDs)',
- ),
- "registrar_password" => array(
- "FriendlyName" => "Password",
- "Type" => "password",
- "Size" => "50",
- 'Description' => 'Enter production SwitchEPP EPP Login password',
- ),
- "eppurl" => array(
- "FriendlyName" => "EPP URL",
- "Type" => "text",
- "Size" => "50",
- 'Description' => 'Enter production SwitchEPP URL epp.nic.ch',
- ),
- "eppport" => array(
- "FriendlyName" => "Port Number",
- "Type" => "text",
- "Size" => "50",
- 'Description' => 'Enter SwitchEPP port 700',
- ),
- 'testMode' => [
- 'FriendlyName' => 'Test Mode',
- 'Type' => 'yesno',
- 'Description' => 'Tick to enable the test mode (OTE)',
- ],
- "ote_registrar_id" => array(
- "FriendlyName" => "OTE Registrar Id",
- "Type" => "text",
- "Size" => "50",
- 'Description' => 'Enter OTE/Test SwitchEPP User ID (Client Identifier clIDs)',
- ),
- "ote_registrar_password" => array(
- "FriendlyName" => "OTE Password",
- "Type" => "password",
- "Size" => "50",
- 'Description' => 'Enter OTE/Test SwitchEPP EPP Login password',
- ),
- "ote_eppurl" => array(
- "FriendlyName" => "OTE EPP URL",
- "Type" => "text",
- "Size" => "50",
- 'Description' => 'Enter OTE SwitchEPP URL epp-test.switch.ch',
- ),
- "ote_eppport" => array(
- "FriendlyName" => "OTE Port Number",
- "Type" => "text",
- "Size" => "50",
- 'Description' => 'Enter OTE port 7001',
- ),
- "licensenum" => array(
- "FriendlyName" => "License Key",
- "Type" => "text",
- "Size" => "50",
- ),
- "dnssec" => array(
- "FriendlyName" => "DNSSEC",
- "Type" => "yesno",
- ),
- "algorithm" => array(
- "FriendlyName" => "Algorithm",
- 'Type' => 'dropdown',
- 'Options' => "5,7,8,10,13,14,15,16",
- 'Default' => '5',
- ),
- "digest_type" => array(
- "FriendlyName" => "Digest Type",
- 'Type' => 'dropdown',
- 'Options' => "1,2,3,4",
- 'Default' => '1',
- ),
- "passphrase" => array(
- "FriendlyName" => "Pass Phrase",
- "Type" => "password",
- "Size" => "30",
- "Description" => "It's optional"
- ),
- "svcExtension" => array(
- "FriendlyName" => "Enable svcExtension",
- "Type" => "yesno",
- "Description" => "Tick if svcExtension supported."
- ),
- "switchepp_version" => array(
- 'Type' => 'system',
- "FriendlyName" => "Version",
- "Description" => "3.1.0",
- ),
- "switchepp_update" => array(
- 'Type' => 'system',
- "FriendlyName" => "Updated Date",
- "Description" => "17 April, 2025",
- )
- );
- return $configarray;
- }
- #*******************Get Nameserver***********************#
- function switchepp_GetNameservers($params)
- {
- try {
- // $check_license = switchepp_license_status($params); #Check License
- $client = switchepp_clientloginepp($params); #Epp Connection
-
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- #get domain info
- $xml = switchepp_domain_info($params);
- $info_domain = switchepp_write_xml($client, $xml, __FUNCTION__ . '(domain info)');
- $ns = $info_domain->response->resData->children("domain", true)->infData->ns->hostObj;
- $i = 1;
- $values = array();
- foreach ($ns as $nn) {
- $values["ns{$i}"] = $nn;
- $i++;
- }
- } catch (Exception $ex) {
- $values['error'] = $ex->getMessage();
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $values;
- }
- #*********************Save mameserver**************************#
- function switchepp_SaveNameservers($params)
- {
- try {
- // $check_license = switchepp_license_status($params); #Check License
- $client = switchepp_clientloginepp($params); #Epp Connection
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- #get domain info
- $xml = switchepp_domain_info($params);
- $info_domain = switchepp_write_xml($client, $xml, __FUNCTION__ . '(domain info)');
- $ns = $info_domain->response->resData->children("domain", true)->infData->ns->hostObj;
- $newarray = [$params["ns1"], $params["ns2"], $params["ns3"], $params["ns4"], $params["ns5"]];
- $exist = false;
- foreach ($ns as $nn) {
- if (in_array($nn, $newarray)) {
- $exist = true;
- } else {
- $exist = false;
- break;
- }
- }
- $rem_hosts = '';
- foreach ($ns as $nn) {
- $rem_hosts .= ' <domain:hostObj>' . $nn . '</domain:hostObj> ';
- }
- # Generate XML for nameservers
- if ($nameserver1 = $params["ns1"]) {
- $add_hosts = ' <domain:hostObj>' . $nameserver1 . '</domain:hostObj> ';
- }
- if ($nameserver2 = $params["ns2"]) {
- $add_hosts .= ' <domain:hostObj>' . $nameserver2 . '</domain:hostObj> ';
- }
- if ($nameserver3 = $params["ns3"]) {
- $add_hosts .= ' <domain:hostObj>' . $nameserver3 . '</domain:hostObj> ';
- }
- if ($nameserver4 = $params["ns4"]) {
- $add_hosts .= ' <domain:hostObj>' . $nameserver4 . '</domain:hostObj> ';
- }
- if ($nameserver5 = $params["ns5"]) {
- $add_hosts .= ' <domain:hostObj>' . $nameserver5 . '</domain:hostObj> ';
- }
- $domainname = $params['domain_punycode'];
- if ($params['dnssec'] == "on") {
- $digestType = $params['digest_type'];
- if (empty($digestType))
- $digestType = 1;
- if ($digestType == 1) {
- $string = switchepp_generateDigestRandomString(40);
- $digest = strtoupper(bin2hex($string));
- $digest = substr($digest, 0, 40);
- } elseif ($digestType == 2) {
- $string = switchepp_generateDigestRandomString(64);
- $digest = strtoupper(bin2hex($string));
- $digest = substr($digest, 0, 64);
- } elseif ($digestType == 3 || $digestType == 4) {
- $string = switchepp_generateDigestRandomString(96);
- $digest = strtoupper(bin2hex($string));
- $digest = substr($digest, 0, 96);
- }
- $params['algorithm'] = (!empty($params['algorithm'])) ? $params['algorithm'] : '5';
- $dnssec = '<extension>
- <secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
- <secDNS:add>
- <secDNS:dsData>
- <secDNS:keyTag>' . substr(time(), 0, 5) . '</secDNS:keyTag>
- <secDNS:alg>' . $params['algorithm'] . '</secDNS:alg>
- <secDNS:digestType>' . $digestType . '</secDNS:digestType>
- <secDNS:digest>' . $digest . '</secDNS:digest>
- </secDNS:dsData>
- </secDNS:add>
- </secDNS:update>
- </extension>';
- }
- $xmlUpdate = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <update>
- <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
- <domain:name>' . $domainname . '</domain:name>
- <domain:add>
- <domain:ns>
- ' . $add_hosts . '
- </domain:ns>
- </domain:add>
- <domain:rem>
- <domain:ns>
- ' . $rem_hosts . '
- </domain:ns>
- </domain:rem>
- </domain:update>
- </update>
- ' . $dnssec . '
- <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
- </command>
- </epp>';
- if ($exist)
- return "success";
- else
- $update_domain = switchepp_write_xml($client, $xmlUpdate, __FUNCTION__);
- } catch (Exception $ex) {
- $values['error'] = $ex->getMessage();
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $values;
- }
- #*************************Domain Register****************************#
- function switchepp_RegisterDomain($params)
- {
- try {
- // $check_license = switchepp_license_status($params); #Check License
- $client = switchepp_clientloginepp($params); #Epp Connection
-
-
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- #get domain info
- $xmlcheck = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <check>
- <domain:check xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
- <domain:name>' . switcheppGetDomainName($params['domainid']) . '</domain:name>
- </domain:check>
- </check>
- <clTRID>' . rand(9999999, 100000) . '</clTRID>
- </command>
- </epp>';
- $domain_check = switchepp_write_xml($client, $xmlcheck, __FUNCTION__ . '( check domain)');
- if (0 == (int) $domain_check->response->resData->children("domain", true)->chkData->cd[0]->name->attributes()->avail)
- throw new exception($domain_check->response->resData->children("domain", true)->chkData->cd[0]->name . ' ' . $domain_check->response->resData->children("domain", true)->chkData->cd[0]->reason);
- $regContactId = strtoupper(switchepp_generateContactID(8) . $params['domainid']);
- $contactCheckXml = switchepp_checkContact($regContactId);
- $contact_check = switchepp_write_xml($client, $contactCheckXml, __FUNCTION__ . ' (check contact)');
- if (1 == (int) $contact_check->response->resData->children("contact", true)->chkData->cd[0]->id->attributes()->avail) {
- $xmlclient = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <create>
- <contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
- <contact:id>REG' . $regContactId . '</contact:id>
- <contact:postalInfo type="loc">
- <contact:name>' . $params['fullname'] . '</contact:name>
- <contact:org>' . $params['companyname'] . '</contact:org>
- <contact:addr>
- <contact:street>' . $params['address1'] . '</contact:street>
- <contact:street>' . $params['address2'] . '</contact:street>
- <contact:city>' . $params['city'] . '</contact:city>
- <contact:pc>' . $params['postcode'] . '</contact:pc>
- <contact:cc>' . $params['country'] . '</contact:cc>
- </contact:addr>
- </contact:postalInfo>
- <contact:voice>' . $params['phonenumberformatted'] . '</contact:voice>
- <contact:email>' . $params['email'] . '</contact:email>
- <contact:authInfo>
- <contact:pw>Con-' . time() . '</contact:pw>
- </contact:authInfo>
- </contact:create>
- </create>
- <clTRID>Regcon-' . rand(1000, 9999) . '</clTRID>
- </command>
- </epp>';
- $create_reg_contact = switchepp_write_xml($client, $xmlclient, __FUNCTION__ . '( create reg contact)');
- $reg_contact_id = $create_reg_contact->response->resData->children('contact', true)->creData->id;
- } else {
- $reg_contact_id = $regContactId;
- }
- #*************tech create*****************#
- $techContactId = strtoupper(switchepp_generateContactID(6) . $params['domainid']);
- $contactCheckXml = switchepp_checkContact($techContactId);
- $contact_check = switchepp_write_xml($client, $contactCheckXml, __FUNCTION__ . ' (check contact)');
- if (1 == (int) $contact_check->response->resData->children("contact", true)->chkData->cd[0]->id->attributes()->avail) {
- $xmlTech = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <create>
- <contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
- <contact:id>TE' . $techContactId . '</contact:id>
- <contact:postalInfo type="loc">
- <contact:name>' . $params['adminfirstname'] . ' ' . $params['adminlastname'] . '</contact:name>
- <contact:org>' . $params['admincompanyname'] . '</contact:org>
- <contact:addr>
- <contact:street>' . $params['adminaddress1'] . '</contact:street>
- <contact:street>' . $params['adminaddress2'] . '</contact:street>
- <contact:city>' . $params['admincity'] . '</contact:city>
- <contact:pc>' . $params['adminpostcode'] . '</contact:pc>
- <contact:cc>' . $params['admincountry'] . '</contact:cc>
- </contact:addr>
- </contact:postalInfo>
- <contact:voice>' . $params['adminfullphonenumber'] . '</contact:voice>
- <contact:email>' . $params['adminemail'] . '</contact:email>
- <contact:authInfo>
- <contact:pw>Tec-' . time() . '</contact:pw>
- </contact:authInfo>
- </contact:create>
- </create>
- <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
- </command>
- </epp>';
- $create_tech_contact = switchepp_write_xml($client, $xmlTech, __FUNCTION__ . '( create tech contact)');
- $tech_contact_id = $create_tech_contact->response->resData->children('contact', true)->creData->id;
- } else {
- $tech_contact_id = $techContactId;
- }
- #*******************NameServer*************#
- if ($params['ns1']) {
- $ns .= '<domain:hostObj>' . $params['ns1'] . '</domain:hostObj>';
- }
- if ($params['ns2']) {
- $ns .= '<domain:hostObj>' . $params['ns2'] . '</domain:hostObj>';
- }
- if ($params['ns3']) {
- $ns .= '<domain:hostObj>' . $params['ns3'] . '</domain:hostObj>';
- }
- if ($params['ns4']) {
- $ns .= '<domain:hostObj>' . $params['ns4'] . '</domain:hostObj>';
- }
- if ($ns) {
- $nsnameserver = ' <domain:ns>
- ' . $ns . '
- </domain:ns>';
- }
- $domainname = $params['domain_punycode'];
- if ($params['dnssec'] == "on") {
- $digestType = $params['digest_type'];
- if (empty($digestType))
- $digestType = 1;
- if ($digestType == 1) {
- $string = switchepp_generateDigestRandomString(40);
- $digest = strtoupper(bin2hex($string));
- $digest = substr($digest, 0, 40);
- } elseif ($digestType == 2) {
- $string = switchepp_generateDigestRandomString(64);
- $digest = strtoupper(bin2hex($string));
- $digest = substr($digest, 0, 64);
- } elseif ($digestType == 3 || $digestType == 4) {
- $string = switchepp_generateDigestRandomString(96);
- $digest = strtoupper(bin2hex($string));
- $digest = substr($digest, 0, 96);
- }
- $params['algorithm'] = (!empty($params['algorithm'])) ? $params['algorithm'] : '5';
- $dnssec = '<extension>
- <secDNS:create xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
- <secDNS:dsData>
- <secDNS:keyTag>' . substr(time(), 0, 5) . '</secDNS:keyTag>
- <secDNS:alg>' . $params['algorithm'] . '</secDNS:alg>
- <secDNS:digestType>' . $digestType . '</secDNS:digestType>
- <secDNS:digest>' . $digest . '</secDNS:digest>
- </secDNS:dsData>
- </secDNS:create>
- </extension>';
- }
- $domainPw = switchepp_generateRandomString(15);
- #domian create command
- $xmldomain = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <create>
- <domain:create xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
- <domain:name>' . $domainname . '</domain:name>
- ' . $nsnameserver . '
- <domain:registrant>' . $reg_contact_id . '</domain:registrant>
- <domain:contact type="tech">' . $tech_contact_id . '</domain:contact>
- <domain:authInfo>
- <domain:pw>' . $domainPw . '</domain:pw>
- </domain:authInfo>
- </domain:create>
- </create>
- ' . $dnssec . '
- <clTRID>' . rand(9999999, 100000) . '</clTRID>
- </command>
- </epp>';
- $domain_create = switchepp_write_xml($client, $xmldomain, __FUNCTION__);
- } catch (Exception $ex) {
- $values['error'] = $ex->getMessage();
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $values;
- }
- #**********************************Get Contact Detail*******************************#
- function switchepp_GetContactDetails($params)
- {
- try {
- // $check_license = switchepp_license_status($params); #Check License
- $client = switchepp_clientloginepp($params); #Epp Connection
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- #get domain info
- $xml = switchepp_domain_info($params);
- $info_domain = switchepp_write_xml($client, $xml, __FUNCTION__ . '(domain info)');
- $registrant_id = $info_domain->response->resData->children("domain", true)->infData->registrant; #registrant id
- $Tech_id = $info_domain->response->resData->children("domain", true)->infData->contact; #Tech id
- $xml2 = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <info>
- <contact:info xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
- <contact:id>' . $registrant_id . '</contact:id>
- </contact:info>
- </info>
- <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
- </command>
- </epp>';
- $info_contact = switchepp_write_xml($client, $xml2, __FUNCTION__ . '(registrant contact info)');
- $contactdataArr = $info_contact->response->resData->children("contact", true)->infData;
- $results["Registrant"]["Contact Name"] = $contactdataArr->postalInfo->name;
- $results["Registrant"]["Company Name"] = $contactdataArr->postalInfo->org;
- $results["Registrant"]["Address line 1"] = $contactdataArr->postalInfo->addr->street[0];
- $results["Registrant"]["Address 2"] = $contactdataArr->postalInfo->addr->street[1];
- $results["Registrant"]["City"] = $contactdataArr->postalInfo->addr->city;
- $results["Registrant"]["Postcode"] = $contactdataArr->postalInfo->addr->pc;
- $results["Registrant"]["Country"] = $contactdataArr->postalInfo->addr->cc;
- $results["Registrant"]["Phone Number"] = $contactdataArr->voice;
- $results["Registrant"]["Email"] = $contactdataArr->email;
- if (!empty($Tech_id)) {
- #get tech detail
- $xml3 = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <info>
- <contact:info xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
- <contact:id>' . $Tech_id . '</contact:id>
- </contact:info>
- </info>
- <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
- </command>
- </epp>';
- $tect_info_contact = switchepp_write_xml($client, $xml3, __FUNCTION__ . '(tech contact info)');
- #*************************Show tech information in field****************************#
- $techdataArr = $tect_info_contact->response->resData->children("contact", true)->infData;
- $results["Technical"]["Contact Name"] = $techdataArr->postalInfo->name;
- $results["Technical"]["Company Name"] = $techdataArr->postalInfo->org;
- $results["Technical"]["Address line 1"] = $techdataArr->postalInfo->addr->street[0];
- $results["Technical"]["Address 2"] = $techdataArr->postalInfo->addr->street[1];
- $results["Technical"]["City"] = $techdataArr->postalInfo->addr->city;
- $results["Technical"]["Postcode"] = $techdataArr->postalInfo->addr->pc;
- $results["Technical"]["Country"] = $techdataArr->postalInfo->addr->cc;
- $results["Technical"]["Phone Number"] = $techdataArr->voice;
- $results["Technical"]["Email"] = $techdataArr->email;
- }
- } catch (Exception $ex) {
- $results['error'] = $ex->getMessage();
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $results;
- }
- #******************Save Contact/Tech Detail*********************#
- function switchepp_SaveContactDetails($params)
- {
- try {
- // $check_license = switchepp_license_status($params); #Check License
- $client = switchepp_clientloginepp($params); #Epp Connection
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- #get domain info
- $xml = switchepp_domain_info($params);
- $info_domain = switchepp_write_xml($client, $xml, __FUNCTION__ . '(domain info)');
- $registrant_id = $info_domain->response->resData->children("domain", true)->infData->registrant; #registrant id
- $Tech_id = $info_domain->response->resData->children("domain", true)->infData->contact; #Tech id
- $contactArr = ['Registrant' => $registrant_id, 'Technical' => $Tech_id];
- $updateContactArr = $getContactArr = [];
- foreach ($contactArr as $type => $contactId) {
- if (!empty($contactArr[$type])) {
- $contact = [];
- $contact = $params['contactdetails'][$type];
- $updateName = ($contact['Full Name']) ? $contact['Full Name'] : $contact['Full Name'];
- $updateOrg = ($contact['Company Name']) ? $contact['Company Name'] : $contact['Company Name'];
- $updateAdd1 = ($contact['Address 1']) ? $contact['Address 1'] : $contact['Address 1'];
- $updateAdd2 = ($contact['Address 2']) ? $contact['Address 2'] : $contact['Address 2'];
- $updateCity = ($contact['City']) ? $contact['City'] : $contact['City'];
- $updateZip = ($contact['Postcode']) ? $contact['Postcode'] : $contact['Postcode'];
- $updateCc = ($contact['Country']) ? $contact['Country'] : $contact['Country'];
- $updateEmail = $contact['Email'];
- $updatePhn = ($contact['Phone Number']) ? $contact['Phone Number'] : $contact['Phone Number'];
- $updateContactArr['Full Name'] = htmlspecialchars(trim($updateName));
- $updateContactArr['Company Name'] = htmlspecialchars(trim($updateOrg));
- $updateContactArr['Address 1'] = htmlspecialchars(trim($updateAdd1));
- $updateContactArr['Address 2'] = htmlspecialchars(trim($updateAdd2));
- $updateContactArr['City'] = htmlspecialchars(trim($updateCity));
- $updateContactArr['Postcode'] = htmlspecialchars(trim($updateZip));
- $updateContactArr['Country'] = htmlspecialchars(trim($updateCc));
- $updateContactArr['Phone Number'] = htmlspecialchars(trim($updatePhn));
- $updateContactArr['Email'] = htmlspecialchars(trim($updateEmail));
- $contactInfo = switchepp_contact_info($client, $contactId, 'Get ' . $type);
- $contact_detail = simplexml_load_string($contactInfo);
- $contactdataArr = $contact_detail->response->resData->children("contact", true)->infData;
- foreach ($contactdataArr->postalInfo as $contactFromSwitch) {
- $getName = htmlspecialchars($contactFromSwitch->name);
- $getOrg = htmlspecialchars($contactFromSwitch->org);
- $getAdd1 = htmlspecialchars($contactFromSwitch->addr->street[0]);
- $getAdd2 = htmlspecialchars($contactFromSwitch->addr->street[1]);
- $getCity = htmlspecialchars($contactFromSwitch->addr->city);
- $getZip = htmlspecialchars($contactFromSwitch->addr->pc);
- $getCc = htmlspecialchars($contactFromSwitch->addr->cc);
- $getContactArr['Full Name'] = trim($getName);
- $getContactArr['Company Name'] = trim($getOrg);
- $getContactArr['Address 1'] = trim($getAdd1);
- $getContactArr['Address 2'] = trim($getAdd2);
- $getContactArr['City'] = trim($getCity);
- $getContactArr['Postcode'] = trim($getZip);
- $getContactArr['Country'] = trim($getCc);
- }
- $getEmail = htmlspecialchars($contactdataArr->email);
- $getPhn = htmlspecialchars($contactdataArr->voice);
- $getContactArr['Phone Number'] = trim($getPhn);
- $getContactArr['Email'] = trim($getEmail);
- if ($getContactArr == $updateContactArr)
- continue;
- $updateXml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <update>
- <contact:update xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
- <contact:id>' . $contactId . '</contact:id>
- <contact:chg>
- <contact:postalInfo type="loc">
- <contact:name>' . $updateContactArr['Full Name'] . '</contact:name>
- <contact:org>' . $updateContactArr['Company Name'] . '</contact:org>
- <contact:addr>
- <contact:street>' . $updateContactArr['Address 1'] . '</contact:street>
- <contact:street>' . $updateContactArr['Address 2'] . '</contact:street>
- <contact:city>' . $updateContactArr['City'] . '</contact:city>
- <contact:sp>' . $updateContactArr['City'] . '</contact:sp>
- <contact:pc>' . $updateContactArr['Postcode'] . '</contact:pc>
- <contact:cc>' . $updateContactArr['Country'] . '</contact:cc>
- </contact:addr>
- </contact:postalInfo>
- <contact:voice>' . $updateContactArr['Phone Number'] . '</contact:voice>
- <contact:fax/>
- <contact:email>' . $updateContactArr['Email'] . '</contact:email>
- <contact:authInfo>
- <contact:pw>con-' . time() . '</contact:pw>
- </contact:authInfo>
- </contact:chg>
- </contact:update>
- </update>
- <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
- </command>
- </epp>';
- switchepp_write_xml($client, $updateXml, 'Save ' . $type);
- }
- }
- } catch (Exception $ex) {
- $values['error'] = $ex->getMessage();
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $values;
- }
- #************************Domain Delete*************************#
- function switchepp_RequestDelete($params)
- {
- try {
- // $check_license = switchepp_license_status($params); #Check License
- $client = switchepp_clientloginepp($params); #Epp Connection
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- #get domain info
- $xml = switchepp_domain_info($params);
- $info_domain = switchepp_write_xml($client, $xml, __FUNCTION__ . '(domain info)');
- $domainname = $params['domain_punycode'];
- $deletxml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <delete>
- <domain:delete xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
- <domain:name>' . $domainname . '</domain:name>
- </domain:delete>
- </delete>
- <clTRID>delete-domain-' . rand(1000, 9999) . '</clTRID>
- </command>
- </epp>';
- $delete_domain = switchepp_write_xml($client, $deletxml, __FUNCTION__);
- } catch (Exception $ex) {
- $values['error'] = $ex->getMessage();
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $values;
- }
- #******************************Domain transfer********************************#
- function switchepp_TransferDomain($params)
- {
- try {
- // $check_license = switchepp_license_status($params); #Check License
- $client = switchepp_clientloginepp($params); #Epp Connection
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- #get domain info
- $xml = switchepp_domain_info($params);
- $domainname = $params['domain_punycode'];
- #domain transfer
- $xmlTransfer = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <transfer op="request">
- <domain:transfer xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
- <domain:name>' . $domainname . '</domain:name>
- <domain:authInfo>
- <domain:pw>' . htmlentities($params['transfersecret']) . '</domain:pw>
- </domain:authInfo>
- </domain:transfer>
- </transfer>
- <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
- </command>
- </epp>';
- $Transfer_domain = switchepp_write_xml($client, $xmlTransfer, __FUNCTION__);
- $regContactId = strtoupper(switchepp_generateContactID(8) . $params['domainid']);
- $contactCheckXml = switchepp_checkContact($regContactId);
- $contact_check = switchepp_write_xml($client, $contactCheckXml, __FUNCTION__ . ' (check contact)');
- if (1 == (int) $contact_check->response->resData->children("contact", true)->chkData->cd[0]->id->attributes()->avail) {
- $xmlclient = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <create>
- <contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
- <contact:id>RE' . $regContactId . '</contact:id>
- <contact:postalInfo type="loc">
- <contact:name>' . $params['fullname'] . '</contact:name>
- <contact:org>' . $params['companyname'] . '</contact:org>
- <contact:addr>
- <contact:street>' . $params['address1'] . '</contact:street>
- <contact:street>' . $params['address2'] . '</contact:street>
- <contact:city>' . $params['city'] . '</contact:city>
- <contact:pc>' . $params['postcode'] . '</contact:pc>
- <contact:cc>' . $params['country'] . '</contact:cc>
- </contact:addr>
- </contact:postalInfo>
- <contact:voice>' . $params['phonenumberformatted'] . '</contact:voice>
- <contact:email>' . $params['email'] . '</contact:email>
- <contact:authInfo>
- <contact:pw>Con-' . time() . '</contact:pw>
- </contact:authInfo>
- </contact:create>
- </create>
- <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
- </command>
- </epp>';
- $create_reg_contact = switchepp_write_xml($client, $xmlclient, __FUNCTION__ . ' (create reg contact)');
- $reg_contact_id = $create_reg_contact->response->resData->children('contact', true)->creData->id;
- } else
- $reg_contact_id = $regContactId;
- #*************tech create*****************#
- $techContactId = strtoupper(switchepp_generateContactID(6) . $params['domainid']);
- $contactCheckXml = switchepp_checkContact($techContactId);
- $contact_check = switchepp_write_xml($client, $contactCheckXml, __FUNCTION__ . ' (check contact)');
- if (1 == (int) $contact_check->response->resData->children("contact", true)->chkData->cd[0]->id->attributes()->avail) {
- $xmlTech = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <create>
- <contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
- <contact:id>TE' . $techContactId . '</contact:id>
- <contact:postalInfo type="loc">
- <contact:name>' . $params['adminfirstname'] . ' ' . $params['adminlastname'] . '</contact:name>
- <contact:org>' . $params['admincompanyname'] . '</contact:org>
- <contact:addr>
- <contact:street>' . $params['adminaddress1'] . '</contact:street>
- <contact:street>' . $params['adminaddress2'] . '</contact:street>
- <contact:city>' . $params['admincity'] . '</contact:city>
- <contact:pc>' . $params['adminpostcode'] . '</contact:pc>
- <contact:cc>' . $params['admincountry'] . '</contact:cc>
- </contact:addr>
- </contact:postalInfo>
- <contact:voice>' . $params['adminfullphonenumber'] . '</contact:voice>
- <contact:email>' . $params['adminemail'] . '</contact:email>
- <contact:authInfo>
- <contact:pw>Tec-' . time() . '</contact:pw>
- </contact:authInfo>
- </contact:create>
- </create>
- <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
- </command>
- </epp>';
- $create_tech_contact = switchepp_write_xml($client, $xmlTech, __FUNCTION__ . ' (create tech contact)');
- $tech_contact_id = $create_tech_contact->response->resData->children('contact', true)->creData->id;
- } else
- $tech_contact_id = $techContactId;
- if ($params['dnssec'] == "on") {
- $digestType = $params['digest_type'];
- if (empty($digestType))
- $digestType = 1;
- if ($digestType == 1) {
- $string = switchepp_generateDigestRandomString(40);
- $digest = strtoupper(bin2hex($string));
- $digest = substr($digest, 0, 40);
- } elseif ($digestType == 2) {
- $string = switchepp_generateDigestRandomString(64);
- $digest = strtoupper(bin2hex($string));
- $digest = substr($digest, 0, 64);
- } elseif ($digestType == 3 || $digestType == 4) {
- $string = switchepp_generateDigestRandomString(96);
- $digest = strtoupper(bin2hex($string));
- $digest = substr($digest, 0, 96);
- }
- $params['algorithm'] = (!empty($params['algorithm'])) ? $params['algorithm'] : '5';
- $dnssec = '<extension>
- <secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
- <secDNS:add>
- <secDNS:dsData>
- <secDNS:keyTag>' . substr(time(), 0, 5) . '</secDNS:keyTag>
- <secDNS:alg>' . $params['algorithm'] . '</secDNS:alg>
- <secDNS:digestType>' . $digestType . '</secDNS:digestType>
- <secDNS:digest>' . $digest . '</secDNS:digest>
- </secDNS:dsData>
- </secDNS:add>
- </secDNS:update>
- </extension>';
- }
- $xmlUpdate = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <update>
- <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
- <domain:name>' . $domainname . '</domain:name>
- <domain:add>
- <domain:contact type="tech">' . $tech_contact_id . '</domain:contact>
- </domain:add>
- <domain:chg>
- <domain:registrant>' . $reg_contact_id . '</domain:registrant>
- </domain:chg>
- </domain:update>
- </update>
- ' . $dnssec . '
- <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
- </command>
- </epp>';
- $update_domain = switchepp_write_xml($client, $xmlUpdate, __FUNCTION__ . ' (Domain update)');
- } catch (Exception $ex) {
- $values['error'] = $ex->getMessage();
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $values;
- }
- #***************************Get Epp Code******************************#
- function switchepp_GetEPPCode($params)
- {
- try {
- // $check_license = switchepp_license_status($params); #Check License
- $client = switchepp_clientloginepp($params); #Epp Connection
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- #get domain info
- $xml = switchepp_domain_info($params);
- $domainPw = switchepp_generateRandomString(15);
- $xml = switchepp_update_domain_auth($params, $domainPw);
- $domainUpdate = switchepp_write_xml($client, $xml, __FUNCTION__);
- $values['eppcode'] = $domainPw;
- } catch (Exception $ex) {
- $values['error'] = $ex->getMessage();
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $values;
- }
- #***************************Custom button function******************************#
- function switchepp_AdminCustomButtonArray()
- {
- $buttonarray = array(
- "Restore Domain" => "Restore",
- "Disable DNSSEC" => "Disable_DNSSEC",
- "Enable DNSSEC" => "Enable_DNSSEC",
- );
- return $buttonarray;
- }
- //registrarmodule_ClientAreaCustomButtonArray
- function switchepp_ClientAreaCustomButtonArray()
- {
- return array(
- "Enable DNSSEC" => "Enable_DNSSEC",
- "Disable DNSSEC" => "Disable_DNSSEC",
- );
- }
- #***************************Restore Domain******************************#
- function switchepp_Restore($params)
- {
- try {
- // $check_license = switchepp_license_status($params); #Check License
- $client = switchepp_clientloginepp($params); #Epp Connection
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- #Domain Restore XML
- $xml = switchepp_domain_restore($params);
- $domainRestore = switchepp_write_xml($client, $xml, __FUNCTION__);
- } catch (Exception $ex) {
- $values['error'] = $ex->getMessage();
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $values;
- }
- #***************************Disable DNSSEC******************************#
- function switchepp_Disable_DNSSEC($params)
- {
- try {
- // $check_license = switchepp_license_status($params); #Check License
- $client = switchepp_clientloginepp($params); #Epp Connection
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- #Domain Restore XML
- $xml = switcheppDisableDnssec($params);
- $domainRestore = switchepp_write_xml($client, $xml, __FUNCTION__);
- $values['success'] = 'success';
- } catch (Exception $ex) {
- $values['error'] = $ex->getMessage();
- return $values;
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $values;
- }
- #***************************Enable DNSSEC******************************#
- function switchepp_Enable_DNSSEC($params)
- {
- try {
- // $check_license = switchepp_license_status($params); #Check License
- //if ($check_license['status'] == "Active") {
- $client = switchepp_clientloginepp($params); #Epp Connection
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- //}
- #Domain Restore XML
- $xml = switcheppEnableDnssec($params);
- $domainRestore = switchepp_write_xml($client, $xml, __FUNCTION__);
- $values['success'] = 'success';
- } catch (Exception $ex) {
- $values['error'] = $ex->getMessage();
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $values;
- }
- #***************************Admin Fields******************************#
- function switchepp_AdminDomainsTabFields($params)
- {
- try {
- $settingArr = getSwitchEPP_setting($params['domainid']); #get registrar config settings
- $params = array_merge($params, $settingArr);
- // $check_license = switchepp_license_status($params); #Check License
- $client = switchepp_clientloginepp($params); #Epp Connection
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- $params['domain_punycode'] = $params['sld_punycode'] . '.' . $params['tld'];
- #get domain info
- $xml = switchepp_domain_info($params);
- $info_domain = switchepp_write_xml($client, $xml, __FUNCTION__ . '(domain info)');
- $expDate = $info_domain->response->resData->children("domain", true)->infData->exDate ? date('m-d-Y', strtotime($info_domain->response->resData->children("domain", true)->infData->exDate)) : '';
- $status = $info_domain->response->resData->children("domain", true)->infData->status->attributes()->s;
- $upDate = $info_domain->response->resData->children("domain", true)->infData->upDate ? date('m-d-Y', strtotime($info_domain->response->resData->children("domain", true)->infData->upDate)) : '';
- $transferDate = $info_domain->response->resData->children("domain", true)->infData->trDate ? date('m-d-Y', strtotime($info_domain->response->resData->children("domain", true)->infData->trDate)) : '';
- $createDate = $info_domain->response->resData->children("domain", true)->infData->crDate ? date('m-d-Y', strtotime($info_domain->response->resData->children("domain", true)->infData->crDate)) : '';
- $DNSSecStatus = $info_domain->response->extension->children("secDNS", true)->infData->dsData->keyTag ? "Yes" : "No";
- $html = '';
- $html .= '<table width="100%" style="margin-bottom:0;" class="datatable">';
- $html .= '<tbody>';
- $html .= '<tr align="left">';
- $html .= '<th style="text-align: left;">Item</th>';
- $html .= '<th style="text-align: left;">Content</th>';
- $html .= '</tr>';
- $html .= '<tr align="left">';
- $html .= '<td>Status</td>';
- $html .= '<td>' . $status . '</td>';
- $html .= '</tr>';
- $html .= '<tr align="left">';
- $html .= '<td>Creation Date</td>';
- $html .= '<td>' . $createDate . '</td>';
- $html .= '</tr>';
- $html .= '<tr align="left">';
- $html .= '<td>Expiration Date</td>';
- $html .= '<td>' . $expDate . '</td>';
- $html .= '</tr>';
- $html .= '<tr align="left">';
- $html .= '<td>Last Update</td>';
- $html .= '<td>' . $upDate . '</td>';
- $html .= '</tr>';
- $html .= '<tr align="left">';
- $html .= '<td>Last Transfer</td>';
- $html .= '<td>' . $transferDate . '</td>';
- $html .= '</tr>';
- $html .= '<tr align="left">';
- $html .= '<td>DNSSec Status</td>';
- $html .= '<td>' . $DNSSecStatus . '</td>';
- $html .= '</tr>';
- $html .= '</tbody>';
- $html .= '</table>';
- $values['Domain Detail'] = $html;
- } catch (Exception $ex) {
- $values['error'] = $ex->getMessage();
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $values;
- }
- #*******************Module Syncronize********************#
- function switchepp_Sync($params)
- {
- /***
- * [error] => Command failed; server closing connection. Too many requests per second! Timeout ms.: 47107
- * using usleep to slow down request frequency
- */
- usleep(500000);
- try {
- $client = switchepp_clientloginepp($params); #Epp Connection
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- #get domain info
- $xml = switchepp_domain_info($params);
- $info_domain = switchepp_write_xml($client, $xml, __FUNCTION__ . '(domain info)');
- $expDate = substr($info_domain->response->resData->children("domain", true)->infData->exDate, 0, 10);
- $statusres = $info_domain->response->resData->children("domain", true)->infData->status->attributes()->s;
- $timestamp = strtotime($info_domain->response->resData->children("domain", true)->infData->exDate);
- if ($timestamp === false) {
- return array(
- 'error' => 'Renewal date empty for domain: ' . $params['domain']
- );
- }
- Capsule::table('tbldomains')->where('id', $params['domainid'])->update(['expirydate' => $expDate]);
- $domain = Capsule::table('tbldomains')
- ->where('id', '=', $params['domainid'])
- ->where('donotrenew', '=', '1')
- ->where('registrar', '=', 'switchepp')
- ->whereRaw('`expirydate` >= CURRENT_DATE() AND `expirydate` < ADDDATE(CURRENT_DATE(), INTERVAL 1 DAY)')
- ->first();
- if (isset($domain->expirydate)) {
- $domainname = $params['domain_punycode'];
- $deletxml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <delete>
- <domain:delete xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
- <domain:name>' . $domainname . '</domain:name>
- </domain:delete>
- </delete>
- <clTRID>delete-domain-' . rand(1000, 9999) . '</clTRID>
- </command>
- </epp>';
- $delete_domain = switchepp_write_xml($client, $deletxml, __FUNCTION__ . ' (delete domain)');
- }
- if ($timestamp < time()) {
- $values['expirydate'] = $expDate;
- $values['expired'] = true;
- } else {
- $values['expirydate'] = $expDate;
- $values['active'] = true;
- }
- } catch (Exception $ex) {
- $values['error'] = $ex->getMessage();
- logModuleCall(
- 'switchEPP',
- __FUNCTION__,
- $params,
- 'debug sync err',
- $values
- );
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $values;
- }
- #*******************Transfer Syncronize********************#
- function switchepp_TransferSync($params)
- {
- try {
- $client = switchepp_clientloginepp($params); #Epp Connection
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- #get domain info
- $xml = switchepp_domain_info($params);
- $info_domain = switchepp_write_xml($client, $xml, __FUNCTION__ . '(domain info)');
- $expDate = substr($info_domain->response->resData->children("domain", true)->infData->exDate, 0, 10);
- $statusres = $info_domain->response->resData->children("domain", true)->infData->status->attributes()->s;
- if (!$statusres) {
- Capsule::table('tbldomains')->where('id', $params['domainid'])->update(["status" => "Cancelled"]);
- $values['error'] = "TransferSync/domain-info: Domain not found";
- }
- Capsule::table('tbldomains')->where('id', $params['domainid'])->update(['expirydate' => $expDate]);
- if ($statusres == "ok" || $statusres == "serverTransferProhibited") {
- $values['completed'] = true;
- } else {
- $values['error'] = "Sync/domain-info: Unknown status code '$statusres' ";
- }
- $values['expirydate'] = $expDate;
- } catch (Exception $ex) {
- $values['error'] = $ex->getMessage();
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $values;
- }
- #***********************Register Nameserver**************************#
- function switchepp_RegisterNameserver($params)
- {
- try {
- // $check_license = switchepp_license_status($params); #Check License
- $client = switchepp_clientloginepp($params); #Epp Connection
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- #get domain info
- $xml = switchepp_domain_info($params);
- $xml_Hostcreate = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <create>
- <host:create xmlns:host="urn:ietf:params:xml:ns:host-1.0">
- <host:name>' . $params['nameserver'] . '</host:name>
- <host:addr ip="v4">' . $params['ipaddress'] . '</host:addr>
- </host:create>
- </create>
- <clTRID>' . rand(9999999, 100000) . '</clTRID>
- </command>
- </epp>';
- $host_create = switchepp_write_xml($client, $xml_Hostcreate, __FUNCTION__);
- } catch (Exception $ex) {
- $values['error'] = $ex->getMessage();
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $values;
- }
- #**************************Update Nameserver************************#
- function switchepp_ModifyNameserver($params)
- {
- try {
- // $check_license = switchepp_license_status($params); #Check License
- $client = switchepp_clientloginepp($params); #Epp Connection
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- #get domain info
- $xml = switchepp_domain_info($params);
- $update_req = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <update>
- <host:update xmlns:host="urn:ietf:params:xml:ns:host-1.0">
- <host:name>' . $params['nameserver'] . '</host:name>
- <host:add>
- <host:addr ip="v4">' . $params['newipaddress'] . '</host:addr>
- </host:add>
- <host:rem>
- <host:addr ip="v4">' . $params['currentipaddress'] . '</host:addr>
- </host:rem>
- </host:update>
- </update>
- <clTRID>' . rand(9999999, 100000) . '</clTRID>
- </command>
- </epp>';
- $update = switchepp_write_xml($client, $update_req, __FUNCTION__);
- } catch (Exception $ex) {
- $values['error'] = $ex->getMessage();
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $values;
- }
- #**********************Delete Nameserver****************************#
- function switchepp_DeleteNameserver($params)
- {
- try {
- // $check_license = switchepp_license_status($params); #Check License
- $client = switchepp_clientloginepp($params); #Epp Connection
- $login = switchepp_loggedinepp($client, $params); #Epp Client login
- #get domain info
- $xml = switchepp_domain_info($params);
- $delete_xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <delete>
- <host:delete
- xmlns:host="urn:ietf:params:xml:ns:host-1.0">
- <host:name>' . $params['nameserver'] . '</host:name>
- </host:delete>
- </delete>
- <clTRID>' . rand(9999999, 100000) . '</clTRID>
- </command>
- </epp>';
- $delete = switchepp_write_xml($client, $delete_xml, __FUNCTION__);
- } catch (Exception $ex) {
- $values['error'] = $ex->getMessage();
- }
- if (!empty($client))
- switchepp_logoutepp($client, $params);
- return $values;
- }
- #*********************Create Epp Connection**************************#
- function switchepp_clientloginepp($params)
- {
- try {
- $certFile = __DIR__ . '/cert/cert.pem';
- $client = new Net_EPP_Client();
- $use_ssl = true;
- $eppurl = $params['eppurl'];
- $port = $params['eppport'];
- if ($params['testMode'] == "on") {
- $eppurl = trim($params['ote_eppurl']);
- $port = $params['ote_eppport'];
- }
-
- if (file_exists($certFile)) {
-
- $context = stream_context_create();
- stream_context_set_option($context, 'ssl', 'verify_peer', false);
- stream_context_set_option($context, 'ssl', 'allow_self_signed', true);
- stream_context_set_option($context, 'ssl', 'local_cert', $certFile);
- stream_context_set_option($context, 'ssl', 'passphrase', $params['passphrase']);
- $client->connect($eppurl, $port, 300, $use_ssl, $context) or die("Not connected with epp server");
- } else {
- $context = false;
- $client->connect($eppurl, $port, 300, $use_ssl, $context) or die("Not connected with epp server");
- }
- } catch (Exception $e) {
- $port = $params['eppport'];
- throw new exception("Connection Error: " . $e->getMessage());
- }
- return $client;
- }
- #*********************Epp client login**************************#
- function switchepp_loggedinepp($client, $params)
- {
- if($params['testMode'] == "on"){
- $params['registrar_id'] = $params['ote_registrar_id'];
- $params['registrar_password'] = $params['ote_registrar_password'];
- }
- $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <login>
- <clID>' . $params['registrar_id'] . '</clID>
- <pw>' . $params['registrar_password'] . '</pw>
- <options>
- <version>1.0</version>
- <lang>en</lang>
- </options>
- <svcs>
- <objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>
- <objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>
- <objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
- <svcExtension>
- <extURI>urn:ietf:params:xml:ns:secDNS-1.1</extURI>
- <extURI>urn:ietf:params:xml:ns:rgp-1.0</extURI>
- <extURI>urn:ietf:params:xml:ns:changePoll-1.0</extURI>
- <extURI>https://www.nic.ch/epp/balance-1.0</extURI>
- <extURI>urn:ietf:params:xml:ns:epp:unhandled-namespaces-1.0</extURI>
- </svcExtension>
- </svcs>
- </login>
- <clTRID>' . rand(9999999, 100000) . '</clTRID>
- </command>
- </epp>';
- $response = $client->request($xml);
- logModuleCall('SWITCH EPP', 'login', $xml, $response);
- $result = new SimpleXMLElement($response);
- if ($result->response->result->attributes()->code >= 2000) {
- throw new exception($result->response->result->msg . '. ' . $result->response->result->extValue->reason);
- }
- return $result;
- }
- function switchepp_logoutepp($client, $params)
- {
- if($params['testMode'] == "on"){
- $params['registrar_id'] = $params['ote_registrar_id'];
- }
- $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <epp:command xmlns:epp="urn:ietf:params:xml:ns:epp-1.0">
- <epp:logout />
- <epp:clTRID>' . $params['registrar_id'] . '</epp:clTRID>
- </epp:command>
- </epp>';
- $response = $client->request($xml);
- logModuleCall('SWITCH EPP', 'logout', $xml, $response);
- }
- #******************** Get Contact info*****************#
- function switchepp_contact_info($client, $contactId, $contactType)
- {
- #get contact detail
- $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <info>
- <contact:info xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
- <contact:id>' . $contactId . '</contact:id>
- </contact:info>
- </info>
- <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
- </command>
- </epp>';
- $response = $client->request($xml);
- logModuleCall('SWITCH EPP', $contactType, $xml, $response);
- return $response;
- }
- #***********************Get domain info*************************#
- function switchepp_domain_info($params)
- {
- $domainname = $params['domain_punycode'];
- $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <info>
- <domain:info xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
- <domain:name hosts="all">' . $domainname . '</domain:name>
- </domain:info>
- </info>
- <clTRID>clientref-' . rand(100, 999) . '</clTRID>
- </command>
- </epp>';
- return $xml;
- }
- function switchepp_domain_restore($params)
- {
- $domainname = $params['domain_punycode'];
- $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <update>
- <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
- <domain:name>' . $domainname . '</domain:name>
- <domain:chg />
- </domain:update>
- </update>
- <extension>
- <rgp:update xmlns:rgp="urn:ietf:params:xml:ns:rgp-1.0">
- <rgp:restore op="request" />
- </rgp:update>
- </extension>
- </command>
- </epp>';
- return $xml;
- }
- function switcheppDisableDnssec($params)
- {
- $domainname = $params['domain_punycode'];
- ;
- $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <update>
- <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
- <domain:name>' . $domainname . '</domain:name>
- </domain:update>
- </update>
- <extension>
- <secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
- <secDNS:rem>
- <secDNS:all>true</secDNS:all>
- </secDNS:rem>
- </secDNS:update>
- </extension>
- <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
- </command>
- </epp>';
- return $xml;
- }
- function switcheppEnableDnssec($params)
- {
- $domainname = $params['domain_punycode'];
- $digestType = $params['digest_type'];
- if (empty($digestType))
- $digestType = 1;
- if ($digestType == 1) {
- $string = switchepp_generateDigestRandomString(40);
- $digest = strtoupper(bin2hex($string));
- $digest = substr($digest, 0, 40);
- } elseif ($digestType == 2) {
- $string = switchepp_generateDigestRandomString(64);
- $digest = strtoupper(bin2hex($string));
- $digest = substr($digest, 0, 64);
- } elseif ($digestType == 3 || $digestType == 4) {
- $string = switchepp_generateDigestRandomString(96);
- $digest = strtoupper(bin2hex($string));
- $digest = substr($digest, 0, 96);
- }
- $params['algorithm'] = (!empty($params['algorithm'])) ? $params['algorithm'] : '5';
- $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <update>
- <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
- <domain:name>' . $domainname . '</domain:name>
- </domain:update>
- </update>
- <extension>
- <secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
- <secDNS:add>
- <secDNS:dsData>
- <secDNS:keyTag>' . substr(time(), 0, 5) . '</secDNS:keyTag>
- <secDNS:alg>' . $params['algorithm'] . '</secDNS:alg>
- <secDNS:digestType>' . $digestType . '</secDNS:digestType>
- <secDNS:digest>' . $digest . '</secDNS:digest>
- </secDNS:dsData>
- </secDNS:add>
- </secDNS:update>
- </extension>
- <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
- </command>
- </epp>';
- return $xml;
- }
- function switchepp_update_domain_auth($params, $domainPw)
- {
- $domainname = $params['domain_punycode'];
- $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <update>
- <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
- <domain:name>' . $domainname . '</domain:name>
- <domain:chg>
- <domain:authInfo>
- <domain:pw>' . $domainPw . '</domain:pw>
- </domain:authInfo>
- </domain:chg>
- </domain:update>
- </update>
- <clTRID>domainupdate-' . rand(1000, 9999) . '</clTRID>
- </command>
- </epp>';
- return $xml;
- }
- function switchepp_checkContact($id)
- {
- $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
- <command>
- <check>
- <contact:check xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
- <contact:id>' . $id . '</contact:id>
- </contact:check>
- </check>
- <clTRID>ABC-12345</clTRID>
- </command>
- </epp>';
- return $xml;
- }
- function switchepp_generateRandomString($length = 15)
- {
- $characters = 'abcdefghijklmnopqrstuvwxyz123456789!@$*%#ABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $charactersLength = strlen($characters);
- $randomString = '';
- for ($i = 0; $i < $length; $i++) {
- $randomString .= $characters[rand(0, $charactersLength - 1)];
- }
- return $randomString;
- }
- function switchepp_generateDigestRandomString($length = 15)
- {
- $characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $charactersLength = strlen($characters);
- $randomString = '';
- for ($i = 0; $i < $length; $i++) {
- $randomString .= $characters[rand(0, $charactersLength - 1)];
- }
- return $randomString;
- }
- function switchepp_generateContactID($length = 15)
- {
- $characters = 'abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $charactersLength = strlen($characters);
- $randomString = '';
- for ($i = 0; $i < $length; $i++) {
- $randomString .= $characters[rand(0, $charactersLength - 1)];
- }
- return $randomString;
- }
- function switcheppGetDomainName($id)
- {
- $data = Capsule::table('tbldomains')->where('id', $id)->first();
- return $data->domain;
- }
- function switchepp_write_xml($client, $xml, $action, $extra = NULL)
- {
- $response = $client->request($xml);
- if (empty($extra)) {
- logModuleCall('SWITCH EPP', $action, $xml, $response);
- $result = new SimpleXMLElement($response);
- if ($result->response->result->attributes()->code >= 2000) {
- throw new exception($result->response->result->msg . '. ' . $result->response->result->extValue->reason);
- }
- return $result;
- }
- }
- function getSwitchEPP_setting($id)
- {
- #select table domain data
- $domain_select_data = Capsule::table('tbldomains')->where('id', $id)->first();
- #select registrar data
- foreach (Capsule::table('tblregistrars')->where('registrar', $domain_select_data->registrar)->get() as $registrar_data) {
- $data[$registrar_data->setting] = decrypt($registrar_data->value);
- }
- return $data;
- }
- function switchepp_license_status($params)
- {
- $license_check = SwitchEpp_license_checklicense($params['licensenum']);
- if ($license_check['status'] != 'Active') {
- throw new exception('license is ' . $license_check['status']);
- }
- return $license_check;
- }
- #License function
- function SwitchEpp_license_checklicense($licensekey, $localkey = "")
- {
- $results['status'] = "Active";
- return $results;
- }
|