| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554 |
- <?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)
- {
- 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();
- }
- 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;
- }
|