| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328 |
- <?php
- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
- * SWITCH EPP REGISTRAR WHMCS Module By whmcsglobalservices.com
- * Copyright whmcsglobalservices, All Rights Reserved
- *
- * Release: 21 January, 2015
- * Version: 3.0.6
- * WHMCS Version: v6,v7
- * Update Date: 04 Sep, 2019
- *
- * 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",
- ),
- "registrar_password" => array(
- "FriendlyName" => "Password",
- "Type" => "password",
- "Size" => "50",
- ),
- "eppurl" => array(
- "FriendlyName" => "EPP URL",
- "Type" => "text",
- "Size" => "50",
- ),
- "eppport" => array(
- "FriendlyName" => "Port Number",
- "Type" => "text",
- "Size" => "50",
- ),
- "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(
- "FriendlyName" => "Version",
- "Description" => "3.0.6",
- ),
- "switchepp_update" => array(
- "FriendlyName" => "Updated Date",
- "Description" => "04 Sep, 2019",
- )
- );
- return $configarray;
- }
- #*******************Get Nameserver***********************#
- function switchepp_GetNameservers($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)');
- $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 {
- $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;
- $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> ';
- }
- $IDN = new idna_convert();
- $input = switcheppGetDomainName($params['domainid']);
- $domainname = $IDN->encode($input);
- 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>';
- $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>';
- }
- $IDN = new idna_convert();
- $input = switcheppGetDomainName($params['domainid']);
- $domainname = $IDN->encode($input);
- 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"]["Organisation"] = $contactdataArr->postalInfo->org;
- $results["Registrant"]["Address line 1"] = $contactdataArr->postalInfo->addr->street[0];
- $results["Registrant"]["Address line 2"] = $contactdataArr->postalInfo->addr->street[1];
- $results["Registrant"]["TownCity"] = $contactdataArr->postalInfo->addr->city;
- $results["Registrant"]["Zip code"] = $contactdataArr->postalInfo->addr->pc;
- $results["Registrant"]["Country Code"] = $contactdataArr->postalInfo->addr->cc;
- $results["Registrant"]["Phone"] = $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"]["Organisation"] = $techdataArr->postalInfo->org;
- $results["Technical"]["Address line 1"] = $techdataArr->postalInfo->addr->street[0];
- $results["Technical"]["Address line 2"] = $techdataArr->postalInfo->addr->street[1];
- $results["Technical"]["TownCity"] = $techdataArr->postalInfo->addr->city;
- $results["Technical"]["Zip code"] = $techdataArr->postalInfo->addr->pc;
- $results["Technical"]["Country Code"] = $techdataArr->postalInfo->addr->cc;
- $results["Technical"]["Phone"] = $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['Contact Name'];
- $updateOrg = ($contact['Organisation Name']) ? $contact['Organisation Name'] : $contact['Organisation'];
- $updateAdd1 = ($contact['Address 1']) ? $contact['Address 1'] : $contact['Address line 1'];
- $updateAdd2 = ($contact['Address 2']) ? $contact['Address 2'] : $contact['Address line 2'];
- $updateCity = ($contact['City']) ? $contact['City'] : $contact['TownCity'];
- $updateZip = ($contact['Postcode']) ? $contact['Postcode'] : $contact['Zip code'];
- $updateCc = ($contact['Country']) ? $contact['Country'] : $contact['Country Code'];
- $updateEmail = $contact['Email'];
- $updatePhn = ($contact['Phone Number']) ? $contact['Phone Number'] : $contact['Phone'];
- $updateContactArr['Contact Name'] = htmlspecialchars(trim($updateName));
- $updateContactArr['Organisation'] = htmlspecialchars(trim($updateOrg));
- $updateContactArr['Address line 1'] = htmlspecialchars(trim($updateAdd1));
- $updateContactArr['Address line 2'] = htmlspecialchars(trim($updateAdd2));
- $updateContactArr['TownCity'] = htmlspecialchars(trim($updateCity));
- $updateContactArr['Zip code'] = htmlspecialchars(trim($updateZip));
- $updateContactArr['Country Code'] = htmlspecialchars(trim($updateCc));
- $updateContactArr['Phone'] = 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['Contact Name'] = trim($getName);
- $getContactArr['Organisation'] = trim($getOrg);
- $getContactArr['Address line 1'] = trim($getAdd1);
- $getContactArr['Address line 2'] = trim($getAdd2);
- $getContactArr['TownCity'] = trim($getCity);
- $getContactArr['Zip code'] = trim($getZip);
- $getContactArr['Country Code'] = trim($getCc);
- }
- $getEmail = htmlspecialchars($contactdataArr->email);
- $getPhn = htmlspecialchars($contactdataArr->voice);
- $getContactArr['Phone'] = 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['Contact Name'] . '</contact:name>
- <contact:org>' . $updateContactArr['Organisation'] . '</contact:org>
- <contact:addr>
- <contact:street>' . $updateContactArr['Address line 1'] . '</contact:street>
- <contact:street>' . $updateContactArr['Address line 2'] . '</contact:street>
- <contact:city>' . $updateContactArr['TownCity'] . '</contact:city>
- <contact:sp>' . $updateContactArr['TownCity'] . '</contact:sp>
- <contact:pc>' . $updateContactArr['Zip code'] . '</contact:pc>
- <contact:cc>' . $updateContactArr['Country Code'] . '</contact:cc>
- </contact:addr>
- </contact:postalInfo>
- <contact:voice>' . $updateContactArr['Phone'] . '</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)');
- $IDN = new idna_convert();
- $input = switcheppGetDomainName($params['domainid']);
- $domainname = $IDN->encode($input);
- $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);
- $IDN = new idna_convert();
- $input = switcheppGetDomainName($params['domainid']);
- $domainname = $IDN->encode($input);
- #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",
- );
- return $buttonarray;
- }
- #***************************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;
- }
- #***************************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
- #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)) : '';
- $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 .= '</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) {
- 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)) {
- $IDN = new idna_convert();
- $input = switcheppGetDomainName($params['domainid']);
- $domainname = $IDN->encode($input);
- $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();
- }
- 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 {
- $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['currentipaddress'] . '</host:addr>
- </host:add>
- <host:rem>
- <host:addr ip="v6">' . $params['newipaddress'] . '</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 {
- $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;
- 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($params['eppurl'], $params['eppport'], 300, $use_ssl, $context) or die("Not connected with epp server");
- } else {
- $context = false;
- $client->connect($params['eppurl'], $params['eppport'], 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) {
- error_log("switchepp_loggedinepp " . $client . " | " . $params);
-
- if ($params['svcExtension'] == "on") {
- $dnssec = '<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>
- </svcExtension>';
- } else {
- $dnssec = '<svcExtension>
- <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>
- </svcExtension>';
- }
- $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>
- ' . $dnssec . '
- </svcs>
- </login>
- <clTRID>' . rand(9999999, 100000) . '</clTRID>
- </command>
- </epp>';
- error_log("EPP LOGIN: " . $xml);
- $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) {
- $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) {
- $IDN = new idna_convert();
- $input = switcheppGetDomainName($params['domainid']);
- $domainname = $IDN->encode($input);
- $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) {
- $IDN = new idna_convert();
- $input = switcheppGetDomainName($params['domainid']);
- $domainname = $IDN->encode($input);
- $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 switchepp_update_domain_auth($params, $domainPw) {
- $IDN = new idna_convert();
- $input = switcheppGetDomainName($params['domainid']);
- $domainname = $IDN->encode($input);
- $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) {
- if ($license_check['status'] != 'Active') {
- throw new exception('license is ' . $license_check['status']);
- }
- return $license_check;
- }
- #License function
- ?>
|