switchepp.php 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567
  1. <?php
  2. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  3. * SWITCH EPP REGISTRAR WHMCS Module By whmcsglobalservices.com
  4. * Copyright whmcsglobalservices, All Rights Reserved
  5. *
  6. * Release: 21 January, 2015
  7. * Version: 3.1.0
  8. * WHMCS Version: v6,v7,V8
  9. * Update Date: 17 April, 2025
  10. *
  11. * By WHMCSGLOBALSERVICES https://whmcsglobalservices.com
  12. * Contact info@whmcsglobalservices.com
  13. *
  14. * This module is made under license issued by whmcsglobalservices.com
  15. * and used under all terms and conditions of license. Ownership of
  16. * module can not be changed. Title and copy of module is not
  17. * available to any other person.
  18. *
  19. * @owner <whmcsglobalservices.com>
  20. * @author <WHMCSGLOBALSERVICES>
  21. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  22. use Illuminate\Database\Capsule\Manager as Capsule;
  23. use WGSSWITCHEPP\IDNA\idna_convert as idna_convert;
  24. if (!defined("WHMCS"))
  25. die("This file cannot be accessed directly");
  26. if (!class_exists('Net_EPP_Protocol')) {
  27. if (file_exists(__DIR__ . "/Net/EPP/Client.php"))
  28. require_once __DIR__ . "/Net/EPP/Client.php";
  29. }
  30. // require_once(__DIR__ . '/idna_convert.class.php');
  31. #*********************Registrar config options***************************#
  32. function switchepp_getConfigArray()
  33. {
  34. $configarray = array(
  35. "FriendlyName" => array(
  36. "Type" => "System",
  37. "Value" => "Switch Epp"
  38. ),
  39. "registrar_id" => array(
  40. "FriendlyName" => "Registrar Id",
  41. "Type" => "text",
  42. "Size" => "50",
  43. 'Description' => 'Enter production SwitchEPP User ID (Client Identifier clIDs)',
  44. ),
  45. "registrar_password" => array(
  46. "FriendlyName" => "Password",
  47. "Type" => "password",
  48. "Size" => "50",
  49. 'Description' => 'Enter production SwitchEPP EPP Login password',
  50. ),
  51. "eppurl" => array(
  52. "FriendlyName" => "EPP URL",
  53. "Type" => "text",
  54. "Size" => "50",
  55. 'Description' => 'Enter production SwitchEPP URL epp.nic.ch',
  56. ),
  57. "eppport" => array(
  58. "FriendlyName" => "Port Number",
  59. "Type" => "text",
  60. "Size" => "50",
  61. 'Description' => 'Enter SwitchEPP port 700',
  62. ),
  63. 'testMode' => [
  64. 'FriendlyName' => 'Test Mode',
  65. 'Type' => 'yesno',
  66. 'Description' => 'Tick to enable the test mode (OTE)',
  67. ],
  68. "ote_registrar_id" => array(
  69. "FriendlyName" => "OTE Registrar Id",
  70. "Type" => "text",
  71. "Size" => "50",
  72. 'Description' => 'Enter OTE/Test SwitchEPP User ID (Client Identifier clIDs)',
  73. ),
  74. "ote_registrar_password" => array(
  75. "FriendlyName" => "OTE Password",
  76. "Type" => "password",
  77. "Size" => "50",
  78. 'Description' => 'Enter OTE/Test SwitchEPP EPP Login password',
  79. ),
  80. "ote_eppurl" => array(
  81. "FriendlyName" => "OTE EPP URL",
  82. "Type" => "text",
  83. "Size" => "50",
  84. 'Description' => 'Enter OTE SwitchEPP URL epp-test.switch.ch',
  85. ),
  86. "ote_eppport" => array(
  87. "FriendlyName" => "OTE Port Number",
  88. "Type" => "text",
  89. "Size" => "50",
  90. 'Description' => 'Enter OTE port 7001',
  91. ),
  92. "licensenum" => array(
  93. "FriendlyName" => "License Key",
  94. "Type" => "text",
  95. "Size" => "50",
  96. ),
  97. "dnssec" => array(
  98. "FriendlyName" => "DNSSEC",
  99. "Type" => "yesno",
  100. ),
  101. "algorithm" => array(
  102. "FriendlyName" => "Algorithm",
  103. 'Type' => 'dropdown',
  104. 'Options' => "5,7,8,10,13,14,15,16",
  105. 'Default' => '5',
  106. ),
  107. "digest_type" => array(
  108. "FriendlyName" => "Digest Type",
  109. 'Type' => 'dropdown',
  110. 'Options' => "1,2,3,4",
  111. 'Default' => '1',
  112. ),
  113. "passphrase" => array(
  114. "FriendlyName" => "Pass Phrase",
  115. "Type" => "password",
  116. "Size" => "30",
  117. "Description" => "It's optional"
  118. ),
  119. "svcExtension" => array(
  120. "FriendlyName" => "Enable svcExtension",
  121. "Type" => "yesno",
  122. "Description" => "Tick if svcExtension supported."
  123. ),
  124. "switchepp_version" => array(
  125. 'Type' => 'system',
  126. "FriendlyName" => "Version",
  127. "Description" => "3.1.0",
  128. ),
  129. "switchepp_update" => array(
  130. 'Type' => 'system',
  131. "FriendlyName" => "Updated Date",
  132. "Description" => "17 April, 2025",
  133. )
  134. );
  135. return $configarray;
  136. }
  137. #*******************Get Nameserver***********************#
  138. function switchepp_GetNameservers($params)
  139. {
  140. try {
  141. // $check_license = switchepp_license_status($params); #Check License
  142. $client = switchepp_clientloginepp($params); #Epp Connection
  143. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  144. #get domain info
  145. $xml = switchepp_domain_info($params);
  146. $info_domain = switchepp_write_xml($client, $xml, __FUNCTION__ . '(domain info)');
  147. $ns = $info_domain->response->resData->children("domain", true)->infData->ns->hostObj;
  148. $i = 1;
  149. $values = array();
  150. foreach ($ns as $nn) {
  151. $values["ns{$i}"] = $nn;
  152. $i++;
  153. }
  154. } catch (Exception $ex) {
  155. $values['error'] = $ex->getMessage();
  156. }
  157. if (!empty($client))
  158. switchepp_logoutepp($client, $params);
  159. return $values;
  160. }
  161. #*********************Save mameserver**************************#
  162. function switchepp_SaveNameservers($params)
  163. {
  164. try {
  165. // $check_license = switchepp_license_status($params); #Check License
  166. $client = switchepp_clientloginepp($params); #Epp Connection
  167. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  168. #get domain info
  169. $xml = switchepp_domain_info($params);
  170. $info_domain = switchepp_write_xml($client, $xml, __FUNCTION__ . '(domain info)');
  171. $ns = $info_domain->response->resData->children("domain", true)->infData->ns->hostObj;
  172. $newarray = [$params["ns1"], $params["ns2"], $params["ns3"], $params["ns4"], $params["ns5"]];
  173. $exist = false;
  174. foreach ($ns as $nn) {
  175. if (in_array($nn, $newarray)) {
  176. $exist = true;
  177. } else {
  178. $exist = false;
  179. break;
  180. }
  181. }
  182. $rem_hosts = '';
  183. foreach ($ns as $nn) {
  184. $rem_hosts .= ' <domain:hostObj>' . $nn . '</domain:hostObj> ';
  185. }
  186. # Generate XML for nameservers
  187. if ($nameserver1 = $params["ns1"]) {
  188. $add_hosts = ' <domain:hostObj>' . $nameserver1 . '</domain:hostObj> ';
  189. }
  190. if ($nameserver2 = $params["ns2"]) {
  191. $add_hosts .= ' <domain:hostObj>' . $nameserver2 . '</domain:hostObj> ';
  192. }
  193. if ($nameserver3 = $params["ns3"]) {
  194. $add_hosts .= ' <domain:hostObj>' . $nameserver3 . '</domain:hostObj> ';
  195. }
  196. if ($nameserver4 = $params["ns4"]) {
  197. $add_hosts .= ' <domain:hostObj>' . $nameserver4 . '</domain:hostObj> ';
  198. }
  199. if ($nameserver5 = $params["ns5"]) {
  200. $add_hosts .= ' <domain:hostObj>' . $nameserver5 . '</domain:hostObj> ';
  201. }
  202. $domainname = $params['domain_punycode'];
  203. if ($params['dnssec'] == "on") {
  204. $digestType = $params['digest_type'];
  205. if (empty($digestType))
  206. $digestType = 1;
  207. if ($digestType == 1) {
  208. $string = switchepp_generateDigestRandomString(40);
  209. $digest = strtoupper(bin2hex($string));
  210. $digest = substr($digest, 0, 40);
  211. } elseif ($digestType == 2) {
  212. $string = switchepp_generateDigestRandomString(64);
  213. $digest = strtoupper(bin2hex($string));
  214. $digest = substr($digest, 0, 64);
  215. } elseif ($digestType == 3 || $digestType == 4) {
  216. $string = switchepp_generateDigestRandomString(96);
  217. $digest = strtoupper(bin2hex($string));
  218. $digest = substr($digest, 0, 96);
  219. }
  220. $params['algorithm'] = (!empty($params['algorithm'])) ? $params['algorithm'] : '5';
  221. $dnssec = '<extension>
  222. <secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
  223. <secDNS:add>
  224. <secDNS:dsData>
  225. <secDNS:keyTag>' . substr(time(), 0, 5) . '</secDNS:keyTag>
  226. <secDNS:alg>' . $params['algorithm'] . '</secDNS:alg>
  227. <secDNS:digestType>' . $digestType . '</secDNS:digestType>
  228. <secDNS:digest>' . $digest . '</secDNS:digest>
  229. </secDNS:dsData>
  230. </secDNS:add>
  231. </secDNS:update>
  232. </extension>';
  233. }
  234. $xmlUpdate = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  235. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  236. <command>
  237. <update>
  238. <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
  239. <domain:name>' . $domainname . '</domain:name>
  240. <domain:add>
  241. <domain:ns>
  242. ' . $add_hosts . '
  243. </domain:ns>
  244. </domain:add>
  245. <domain:rem>
  246. <domain:ns>
  247. ' . $rem_hosts . '
  248. </domain:ns>
  249. </domain:rem>
  250. </domain:update>
  251. </update>
  252. ' . $dnssec . '
  253. <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
  254. </command>
  255. </epp>';
  256. if ($exist)
  257. return "success";
  258. else
  259. $update_domain = switchepp_write_xml($client, $xmlUpdate, __FUNCTION__);
  260. } catch (Exception $ex) {
  261. $values['error'] = $ex->getMessage();
  262. }
  263. if (!empty($client))
  264. switchepp_logoutepp($client, $params);
  265. return $values;
  266. }
  267. #*************************Domain Register****************************#
  268. function switchepp_RegisterDomain($params)
  269. {
  270. try {
  271. // $check_license = switchepp_license_status($params); #Check License
  272. $client = switchepp_clientloginepp($params); #Epp Connection
  273. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  274. #get domain info
  275. $xmlcheck = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  276. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  277. <command>
  278. <check>
  279. <domain:check xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
  280. <domain:name>' . switcheppGetDomainName($params['domainid']) . '</domain:name>
  281. </domain:check>
  282. </check>
  283. <clTRID>' . rand(9999999, 100000) . '</clTRID>
  284. </command>
  285. </epp>';
  286. $domain_check = switchepp_write_xml($client, $xmlcheck, __FUNCTION__ . '( check domain)');
  287. if (0 == (int) $domain_check->response->resData->children("domain", true)->chkData->cd[0]->name->attributes()->avail)
  288. 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);
  289. $regContactId = strtoupper(switchepp_generateContactID(8) . $params['domainid']);
  290. $contactCheckXml = switchepp_checkContact($regContactId);
  291. $contact_check = switchepp_write_xml($client, $contactCheckXml, __FUNCTION__ . ' (check contact)');
  292. if (1 == (int) $contact_check->response->resData->children("contact", true)->chkData->cd[0]->id->attributes()->avail) {
  293. $xmlclient = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  294. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  295. <command>
  296. <create>
  297. <contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
  298. <contact:id>REG' . $regContactId . '</contact:id>
  299. <contact:postalInfo type="loc">
  300. <contact:name>' . $params['fullname'] . '</contact:name>
  301. <contact:org>' . $params['companyname'] . '</contact:org>
  302. <contact:addr>
  303. <contact:street>' . $params['address1'] . '</contact:street>
  304. <contact:street>' . $params['address2'] . '</contact:street>
  305. <contact:city>' . $params['city'] . '</contact:city>
  306. <contact:pc>' . $params['postcode'] . '</contact:pc>
  307. <contact:cc>' . $params['country'] . '</contact:cc>
  308. </contact:addr>
  309. </contact:postalInfo>
  310. <contact:voice>' . $params['phonenumberformatted'] . '</contact:voice>
  311. <contact:email>' . $params['email'] . '</contact:email>
  312. <contact:authInfo>
  313. <contact:pw>Con-' . time() . '</contact:pw>
  314. </contact:authInfo>
  315. </contact:create>
  316. </create>
  317. <clTRID>Regcon-' . rand(1000, 9999) . '</clTRID>
  318. </command>
  319. </epp>';
  320. $create_reg_contact = switchepp_write_xml($client, $xmlclient, __FUNCTION__ . '( create reg contact)');
  321. $reg_contact_id = $create_reg_contact->response->resData->children('contact', true)->creData->id;
  322. } else {
  323. $reg_contact_id = $regContactId;
  324. }
  325. #*************tech create*****************#
  326. $techContactId = strtoupper(switchepp_generateContactID(6) . $params['domainid']);
  327. $contactCheckXml = switchepp_checkContact($techContactId);
  328. $contact_check = switchepp_write_xml($client, $contactCheckXml, __FUNCTION__ . ' (check contact)');
  329. if (1 == (int) $contact_check->response->resData->children("contact", true)->chkData->cd[0]->id->attributes()->avail) {
  330. $xmlTech = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  331. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  332. <command>
  333. <create>
  334. <contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
  335. <contact:id>TE' . $techContactId . '</contact:id>
  336. <contact:postalInfo type="loc">
  337. <contact:name>' . $params['adminfirstname'] . ' ' . $params['adminlastname'] . '</contact:name>
  338. <contact:org>' . $params['admincompanyname'] . '</contact:org>
  339. <contact:addr>
  340. <contact:street>' . $params['adminaddress1'] . '</contact:street>
  341. <contact:street>' . $params['adminaddress2'] . '</contact:street>
  342. <contact:city>' . $params['admincity'] . '</contact:city>
  343. <contact:pc>' . $params['adminpostcode'] . '</contact:pc>
  344. <contact:cc>' . $params['admincountry'] . '</contact:cc>
  345. </contact:addr>
  346. </contact:postalInfo>
  347. <contact:voice>' . $params['adminfullphonenumber'] . '</contact:voice>
  348. <contact:email>' . $params['adminemail'] . '</contact:email>
  349. <contact:authInfo>
  350. <contact:pw>Tec-' . time() . '</contact:pw>
  351. </contact:authInfo>
  352. </contact:create>
  353. </create>
  354. <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
  355. </command>
  356. </epp>';
  357. $create_tech_contact = switchepp_write_xml($client, $xmlTech, __FUNCTION__ . '( create tech contact)');
  358. $tech_contact_id = $create_tech_contact->response->resData->children('contact', true)->creData->id;
  359. } else {
  360. $tech_contact_id = $techContactId;
  361. }
  362. #*******************NameServer*************#
  363. if ($params['ns1']) {
  364. $ns .= '<domain:hostObj>' . $params['ns1'] . '</domain:hostObj>';
  365. }
  366. if ($params['ns2']) {
  367. $ns .= '<domain:hostObj>' . $params['ns2'] . '</domain:hostObj>';
  368. }
  369. if ($params['ns3']) {
  370. $ns .= '<domain:hostObj>' . $params['ns3'] . '</domain:hostObj>';
  371. }
  372. if ($params['ns4']) {
  373. $ns .= '<domain:hostObj>' . $params['ns4'] . '</domain:hostObj>';
  374. }
  375. if ($ns) {
  376. $nsnameserver = ' <domain:ns>
  377. ' . $ns . '
  378. </domain:ns>';
  379. }
  380. $domainname = $params['domain_punycode'];
  381. if ($params['dnssec'] == "on") {
  382. $digestType = $params['digest_type'];
  383. if (empty($digestType))
  384. $digestType = 1;
  385. if ($digestType == 1) {
  386. $string = switchepp_generateDigestRandomString(40);
  387. $digest = strtoupper(bin2hex($string));
  388. $digest = substr($digest, 0, 40);
  389. } elseif ($digestType == 2) {
  390. $string = switchepp_generateDigestRandomString(64);
  391. $digest = strtoupper(bin2hex($string));
  392. $digest = substr($digest, 0, 64);
  393. } elseif ($digestType == 3 || $digestType == 4) {
  394. $string = switchepp_generateDigestRandomString(96);
  395. $digest = strtoupper(bin2hex($string));
  396. $digest = substr($digest, 0, 96);
  397. }
  398. $params['algorithm'] = (!empty($params['algorithm'])) ? $params['algorithm'] : '5';
  399. $dnssec = '<extension>
  400. <secDNS:create xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
  401. <secDNS:dsData>
  402. <secDNS:keyTag>' . substr(time(), 0, 5) . '</secDNS:keyTag>
  403. <secDNS:alg>' . $params['algorithm'] . '</secDNS:alg>
  404. <secDNS:digestType>' . $digestType . '</secDNS:digestType>
  405. <secDNS:digest>' . $digest . '</secDNS:digest>
  406. </secDNS:dsData>
  407. </secDNS:create>
  408. </extension>';
  409. }
  410. $domainPw = switchepp_generateRandomString(15);
  411. #domian create command
  412. $xmldomain = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  413. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  414. <command>
  415. <create>
  416. <domain:create xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
  417. <domain:name>' . $domainname . '</domain:name>
  418. ' . $nsnameserver . '
  419. <domain:registrant>' . $reg_contact_id . '</domain:registrant>
  420. <domain:contact type="tech">' . $tech_contact_id . '</domain:contact>
  421. <domain:authInfo>
  422. <domain:pw>' . $domainPw . '</domain:pw>
  423. </domain:authInfo>
  424. </domain:create>
  425. </create>
  426. ' . $dnssec . '
  427. <clTRID>' . rand(9999999, 100000) . '</clTRID>
  428. </command>
  429. </epp>';
  430. $domain_create = switchepp_write_xml($client, $xmldomain, __FUNCTION__);
  431. } catch (Exception $ex) {
  432. $values['error'] = $ex->getMessage();
  433. }
  434. if (!empty($client))
  435. switchepp_logoutepp($client, $params);
  436. return $values;
  437. }
  438. #**********************************Get Contact Detail*******************************#
  439. function switchepp_GetContactDetails($params)
  440. {
  441. try {
  442. // $check_license = switchepp_license_status($params); #Check License
  443. $client = switchepp_clientloginepp($params); #Epp Connection
  444. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  445. #get domain info
  446. $xml = switchepp_domain_info($params);
  447. $info_domain = switchepp_write_xml($client, $xml, __FUNCTION__ . '(domain info)');
  448. $registrant_id = $info_domain->response->resData->children("domain", true)->infData->registrant; #registrant id
  449. $Tech_id = $info_domain->response->resData->children("domain", true)->infData->contact; #Tech id
  450. $xml2 = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  451. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  452. <command>
  453. <info>
  454. <contact:info xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
  455. <contact:id>' . $registrant_id . '</contact:id>
  456. </contact:info>
  457. </info>
  458. <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
  459. </command>
  460. </epp>';
  461. $info_contact = switchepp_write_xml($client, $xml2, __FUNCTION__ . '(registrant contact info)');
  462. $contactdataArr = $info_contact->response->resData->children("contact", true)->infData;
  463. $results["Registrant"]["Contact Name"] = $contactdataArr->postalInfo->name;
  464. $results["Registrant"]["Company Name"] = $contactdataArr->postalInfo->org;
  465. $results["Registrant"]["Address line 1"] = $contactdataArr->postalInfo->addr->street[0];
  466. $results["Registrant"]["Address 2"] = $contactdataArr->postalInfo->addr->street[1];
  467. $results["Registrant"]["City"] = $contactdataArr->postalInfo->addr->city;
  468. $results["Registrant"]["Postcode"] = $contactdataArr->postalInfo->addr->pc;
  469. $results["Registrant"]["Country"] = $contactdataArr->postalInfo->addr->cc;
  470. $results["Registrant"]["Phone Number"] = $contactdataArr->voice;
  471. $results["Registrant"]["Email"] = $contactdataArr->email;
  472. if (!empty($Tech_id)) {
  473. #get tech detail
  474. $xml3 = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  475. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  476. <command>
  477. <info>
  478. <contact:info xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
  479. <contact:id>' . $Tech_id . '</contact:id>
  480. </contact:info>
  481. </info>
  482. <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
  483. </command>
  484. </epp>';
  485. $tect_info_contact = switchepp_write_xml($client, $xml3, __FUNCTION__ . '(tech contact info)');
  486. #*************************Show tech information in field****************************#
  487. $techdataArr = $tect_info_contact->response->resData->children("contact", true)->infData;
  488. $results["Technical"]["Contact Name"] = $techdataArr->postalInfo->name;
  489. $results["Technical"]["Company Name"] = $techdataArr->postalInfo->org;
  490. $results["Technical"]["Address line 1"] = $techdataArr->postalInfo->addr->street[0];
  491. $results["Technical"]["Address 2"] = $techdataArr->postalInfo->addr->street[1];
  492. $results["Technical"]["City"] = $techdataArr->postalInfo->addr->city;
  493. $results["Technical"]["Postcode"] = $techdataArr->postalInfo->addr->pc;
  494. $results["Technical"]["Country"] = $techdataArr->postalInfo->addr->cc;
  495. $results["Technical"]["Phone Number"] = $techdataArr->voice;
  496. $results["Technical"]["Email"] = $techdataArr->email;
  497. }
  498. } catch (Exception $ex) {
  499. $results['error'] = $ex->getMessage();
  500. }
  501. if (!empty($client))
  502. switchepp_logoutepp($client, $params);
  503. return $results;
  504. }
  505. #******************Save Contact/Tech Detail*********************#
  506. function switchepp_SaveContactDetails($params)
  507. {
  508. try {
  509. // $check_license = switchepp_license_status($params); #Check License
  510. $client = switchepp_clientloginepp($params); #Epp Connection
  511. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  512. #get domain info
  513. $xml = switchepp_domain_info($params);
  514. $info_domain = switchepp_write_xml($client, $xml, __FUNCTION__ . '(domain info)');
  515. $registrant_id = $info_domain->response->resData->children("domain", true)->infData->registrant; #registrant id
  516. $Tech_id = $info_domain->response->resData->children("domain", true)->infData->contact; #Tech id
  517. $contactArr = ['Registrant' => $registrant_id, 'Technical' => $Tech_id];
  518. $updateContactArr = $getContactArr = [];
  519. foreach ($contactArr as $type => $contactId) {
  520. if (!empty($contactArr[$type])) {
  521. $contact = [];
  522. $contact = $params['contactdetails'][$type];
  523. $updateName = ($contact['Full Name']) ? $contact['Full Name'] : $contact['Full Name'];
  524. $updateOrg = ($contact['Company Name']) ? $contact['Company Name'] : $contact['Company Name'];
  525. $updateAdd1 = ($contact['Address 1']) ? $contact['Address 1'] : $contact['Address 1'];
  526. $updateAdd2 = ($contact['Address 2']) ? $contact['Address 2'] : $contact['Address 2'];
  527. $updateCity = ($contact['City']) ? $contact['City'] : $contact['City'];
  528. $updateZip = ($contact['Postcode']) ? $contact['Postcode'] : $contact['Postcode'];
  529. $updateCc = ($contact['Country']) ? $contact['Country'] : $contact['Country'];
  530. $updateEmail = $contact['Email'];
  531. $updatePhn = ($contact['Phone Number']) ? $contact['Phone Number'] : $contact['Phone Number'];
  532. $updateContactArr['Full Name'] = htmlspecialchars(trim($updateName));
  533. $updateContactArr['Company Name'] = htmlspecialchars(trim($updateOrg));
  534. $updateContactArr['Address 1'] = htmlspecialchars(trim($updateAdd1));
  535. $updateContactArr['Address 2'] = htmlspecialchars(trim($updateAdd2));
  536. $updateContactArr['City'] = htmlspecialchars(trim($updateCity));
  537. $updateContactArr['Postcode'] = htmlspecialchars(trim($updateZip));
  538. $updateContactArr['Country'] = htmlspecialchars(trim($updateCc));
  539. $updateContactArr['Phone Number'] = htmlspecialchars(trim($updatePhn));
  540. $updateContactArr['Email'] = htmlspecialchars(trim($updateEmail));
  541. $contactInfo = switchepp_contact_info($client, $contactId, 'Get ' . $type);
  542. $contact_detail = simplexml_load_string($contactInfo);
  543. $contactdataArr = $contact_detail->response->resData->children("contact", true)->infData;
  544. foreach ($contactdataArr->postalInfo as $contactFromSwitch) {
  545. $getName = htmlspecialchars($contactFromSwitch->name);
  546. $getOrg = htmlspecialchars($contactFromSwitch->org);
  547. $getAdd1 = htmlspecialchars($contactFromSwitch->addr->street[0]);
  548. $getAdd2 = htmlspecialchars($contactFromSwitch->addr->street[1]);
  549. $getCity = htmlspecialchars($contactFromSwitch->addr->city);
  550. $getZip = htmlspecialchars($contactFromSwitch->addr->pc);
  551. $getCc = htmlspecialchars($contactFromSwitch->addr->cc);
  552. $getContactArr['Full Name'] = trim($getName);
  553. $getContactArr['Company Name'] = trim($getOrg);
  554. $getContactArr['Address 1'] = trim($getAdd1);
  555. $getContactArr['Address 2'] = trim($getAdd2);
  556. $getContactArr['City'] = trim($getCity);
  557. $getContactArr['Postcode'] = trim($getZip);
  558. $getContactArr['Country'] = trim($getCc);
  559. }
  560. $getEmail = htmlspecialchars($contactdataArr->email);
  561. $getPhn = htmlspecialchars($contactdataArr->voice);
  562. $getContactArr['Phone Number'] = trim($getPhn);
  563. $getContactArr['Email'] = trim($getEmail);
  564. if ($getContactArr == $updateContactArr)
  565. continue;
  566. $updateXml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  567. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  568. <command>
  569. <update>
  570. <contact:update xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
  571. <contact:id>' . $contactId . '</contact:id>
  572. <contact:chg>
  573. <contact:postalInfo type="loc">
  574. <contact:name>' . $updateContactArr['Full Name'] . '</contact:name>
  575. <contact:org>' . $updateContactArr['Company Name'] . '</contact:org>
  576. <contact:addr>
  577. <contact:street>' . $updateContactArr['Address 1'] . '</contact:street>
  578. <contact:street>' . $updateContactArr['Address 2'] . '</contact:street>
  579. <contact:city>' . $updateContactArr['City'] . '</contact:city>
  580. <contact:sp>' . $updateContactArr['City'] . '</contact:sp>
  581. <contact:pc>' . $updateContactArr['Postcode'] . '</contact:pc>
  582. <contact:cc>' . $updateContactArr['Country'] . '</contact:cc>
  583. </contact:addr>
  584. </contact:postalInfo>
  585. <contact:voice>' . $updateContactArr['Phone Number'] . '</contact:voice>
  586. <contact:fax/>
  587. <contact:email>' . $updateContactArr['Email'] . '</contact:email>
  588. <contact:authInfo>
  589. <contact:pw>con-' . time() . '</contact:pw>
  590. </contact:authInfo>
  591. </contact:chg>
  592. </contact:update>
  593. </update>
  594. <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
  595. </command>
  596. </epp>';
  597. switchepp_write_xml($client, $updateXml, 'Save ' . $type);
  598. }
  599. }
  600. } catch (Exception $ex) {
  601. $values['error'] = $ex->getMessage();
  602. }
  603. if (!empty($client))
  604. switchepp_logoutepp($client, $params);
  605. return $values;
  606. }
  607. #************************Domain Delete*************************#
  608. function switchepp_RequestDelete($params)
  609. {
  610. try {
  611. // $check_license = switchepp_license_status($params); #Check License
  612. $client = switchepp_clientloginepp($params); #Epp Connection
  613. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  614. #get domain info
  615. $xml = switchepp_domain_info($params);
  616. $info_domain = switchepp_write_xml($client, $xml, __FUNCTION__ . '(domain info)');
  617. $domainname = $params['domain_punycode'];
  618. $deletxml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  619. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  620. <command>
  621. <delete>
  622. <domain:delete xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
  623. <domain:name>' . $domainname . '</domain:name>
  624. </domain:delete>
  625. </delete>
  626. <clTRID>delete-domain-' . rand(1000, 9999) . '</clTRID>
  627. </command>
  628. </epp>';
  629. $delete_domain = switchepp_write_xml($client, $deletxml, __FUNCTION__);
  630. } catch (Exception $ex) {
  631. $values['error'] = $ex->getMessage();
  632. }
  633. if (!empty($client))
  634. switchepp_logoutepp($client, $params);
  635. return $values;
  636. }
  637. #******************************Domain transfer********************************#
  638. function switchepp_TransferDomain($params)
  639. {
  640. try {
  641. // $check_license = switchepp_license_status($params); #Check License
  642. $client = switchepp_clientloginepp($params); #Epp Connection
  643. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  644. #get domain info
  645. $xml = switchepp_domain_info($params);
  646. $domainname = $params['domain_punycode'];
  647. #domain transfer
  648. $xmlTransfer = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  649. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  650. <command>
  651. <transfer op="request">
  652. <domain:transfer xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
  653. <domain:name>' . $domainname . '</domain:name>
  654. <domain:authInfo>
  655. <domain:pw>' . htmlentities($params['transfersecret']) . '</domain:pw>
  656. </domain:authInfo>
  657. </domain:transfer>
  658. </transfer>
  659. <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
  660. </command>
  661. </epp>';
  662. $Transfer_domain = switchepp_write_xml($client, $xmlTransfer, __FUNCTION__);
  663. $regContactId = strtoupper(switchepp_generateContactID(8) . $params['domainid']);
  664. $contactCheckXml = switchepp_checkContact($regContactId);
  665. $contact_check = switchepp_write_xml($client, $contactCheckXml, __FUNCTION__ . ' (check contact)');
  666. if (1 == (int) $contact_check->response->resData->children("contact", true)->chkData->cd[0]->id->attributes()->avail) {
  667. $xmlclient = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  668. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  669. <command>
  670. <create>
  671. <contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
  672. <contact:id>RE' . $regContactId . '</contact:id>
  673. <contact:postalInfo type="loc">
  674. <contact:name>' . $params['fullname'] . '</contact:name>
  675. <contact:org>' . $params['companyname'] . '</contact:org>
  676. <contact:addr>
  677. <contact:street>' . $params['address1'] . '</contact:street>
  678. <contact:street>' . $params['address2'] . '</contact:street>
  679. <contact:city>' . $params['city'] . '</contact:city>
  680. <contact:pc>' . $params['postcode'] . '</contact:pc>
  681. <contact:cc>' . $params['country'] . '</contact:cc>
  682. </contact:addr>
  683. </contact:postalInfo>
  684. <contact:voice>' . $params['phonenumberformatted'] . '</contact:voice>
  685. <contact:email>' . $params['email'] . '</contact:email>
  686. <contact:authInfo>
  687. <contact:pw>Con-' . time() . '</contact:pw>
  688. </contact:authInfo>
  689. </contact:create>
  690. </create>
  691. <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
  692. </command>
  693. </epp>';
  694. $create_reg_contact = switchepp_write_xml($client, $xmlclient, __FUNCTION__ . ' (create reg contact)');
  695. $reg_contact_id = $create_reg_contact->response->resData->children('contact', true)->creData->id;
  696. } else
  697. $reg_contact_id = $regContactId;
  698. #*************tech create*****************#
  699. $techContactId = strtoupper(switchepp_generateContactID(6) . $params['domainid']);
  700. $contactCheckXml = switchepp_checkContact($techContactId);
  701. $contact_check = switchepp_write_xml($client, $contactCheckXml, __FUNCTION__ . ' (check contact)');
  702. if (1 == (int) $contact_check->response->resData->children("contact", true)->chkData->cd[0]->id->attributes()->avail) {
  703. $xmlTech = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  704. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  705. <command>
  706. <create>
  707. <contact:create xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
  708. <contact:id>TE' . $techContactId . '</contact:id>
  709. <contact:postalInfo type="loc">
  710. <contact:name>' . $params['adminfirstname'] . ' ' . $params['adminlastname'] . '</contact:name>
  711. <contact:org>' . $params['admincompanyname'] . '</contact:org>
  712. <contact:addr>
  713. <contact:street>' . $params['adminaddress1'] . '</contact:street>
  714. <contact:street>' . $params['adminaddress2'] . '</contact:street>
  715. <contact:city>' . $params['admincity'] . '</contact:city>
  716. <contact:pc>' . $params['adminpostcode'] . '</contact:pc>
  717. <contact:cc>' . $params['admincountry'] . '</contact:cc>
  718. </contact:addr>
  719. </contact:postalInfo>
  720. <contact:voice>' . $params['adminfullphonenumber'] . '</contact:voice>
  721. <contact:email>' . $params['adminemail'] . '</contact:email>
  722. <contact:authInfo>
  723. <contact:pw>Tec-' . time() . '</contact:pw>
  724. </contact:authInfo>
  725. </contact:create>
  726. </create>
  727. <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
  728. </command>
  729. </epp>';
  730. $create_tech_contact = switchepp_write_xml($client, $xmlTech, __FUNCTION__ . ' (create tech contact)');
  731. $tech_contact_id = $create_tech_contact->response->resData->children('contact', true)->creData->id;
  732. } else
  733. $tech_contact_id = $techContactId;
  734. if ($params['dnssec'] == "on") {
  735. $digestType = $params['digest_type'];
  736. if (empty($digestType))
  737. $digestType = 1;
  738. if ($digestType == 1) {
  739. $string = switchepp_generateDigestRandomString(40);
  740. $digest = strtoupper(bin2hex($string));
  741. $digest = substr($digest, 0, 40);
  742. } elseif ($digestType == 2) {
  743. $string = switchepp_generateDigestRandomString(64);
  744. $digest = strtoupper(bin2hex($string));
  745. $digest = substr($digest, 0, 64);
  746. } elseif ($digestType == 3 || $digestType == 4) {
  747. $string = switchepp_generateDigestRandomString(96);
  748. $digest = strtoupper(bin2hex($string));
  749. $digest = substr($digest, 0, 96);
  750. }
  751. $params['algorithm'] = (!empty($params['algorithm'])) ? $params['algorithm'] : '5';
  752. $dnssec = '<extension>
  753. <secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
  754. <secDNS:add>
  755. <secDNS:dsData>
  756. <secDNS:keyTag>' . substr(time(), 0, 5) . '</secDNS:keyTag>
  757. <secDNS:alg>' . $params['algorithm'] . '</secDNS:alg>
  758. <secDNS:digestType>' . $digestType . '</secDNS:digestType>
  759. <secDNS:digest>' . $digest . '</secDNS:digest>
  760. </secDNS:dsData>
  761. </secDNS:add>
  762. </secDNS:update>
  763. </extension>';
  764. }
  765. $xmlUpdate = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  766. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  767. <command>
  768. <update>
  769. <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
  770. <domain:name>' . $domainname . '</domain:name>
  771. <domain:add>
  772. <domain:contact type="tech">' . $tech_contact_id . '</domain:contact>
  773. </domain:add>
  774. <domain:chg>
  775. <domain:registrant>' . $reg_contact_id . '</domain:registrant>
  776. </domain:chg>
  777. </domain:update>
  778. </update>
  779. ' . $dnssec . '
  780. <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
  781. </command>
  782. </epp>';
  783. $update_domain = switchepp_write_xml($client, $xmlUpdate, __FUNCTION__ . ' (Domain update)');
  784. } catch (Exception $ex) {
  785. $values['error'] = $ex->getMessage();
  786. }
  787. if (!empty($client))
  788. switchepp_logoutepp($client, $params);
  789. return $values;
  790. }
  791. #***************************Get Epp Code******************************#
  792. function switchepp_GetEPPCode($params)
  793. {
  794. try {
  795. // $check_license = switchepp_license_status($params); #Check License
  796. $client = switchepp_clientloginepp($params); #Epp Connection
  797. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  798. #get domain info
  799. $xml = switchepp_domain_info($params);
  800. $domainPw = switchepp_generateRandomString(15);
  801. $xml = switchepp_update_domain_auth($params, $domainPw);
  802. $domainUpdate = switchepp_write_xml($client, $xml, __FUNCTION__);
  803. $values['eppcode'] = $domainPw;
  804. } catch (Exception $ex) {
  805. $values['error'] = $ex->getMessage();
  806. }
  807. if (!empty($client))
  808. switchepp_logoutepp($client, $params);
  809. return $values;
  810. }
  811. #***************************Custom button function******************************#
  812. function switchepp_AdminCustomButtonArray()
  813. {
  814. $buttonarray = array(
  815. "Restore Domain" => "Restore",
  816. "Disable DNSSEC" => "Disable_DNSSEC",
  817. "Enable DNSSEC" => "Enable_DNSSEC",
  818. );
  819. return $buttonarray;
  820. }
  821. //registrarmodule_ClientAreaCustomButtonArray
  822. function switchepp_ClientAreaCustomButtonArray()
  823. {
  824. return array(
  825. "Enable DNSSEC" => "Enable_DNSSEC",
  826. "Disable DNSSEC" => "Disable_DNSSEC",
  827. );
  828. }
  829. #***************************Restore Domain******************************#
  830. function switchepp_Restore($params)
  831. {
  832. try {
  833. // $check_license = switchepp_license_status($params); #Check License
  834. $client = switchepp_clientloginepp($params); #Epp Connection
  835. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  836. #Domain Restore XML
  837. $xml = switchepp_domain_restore($params);
  838. $domainRestore = switchepp_write_xml($client, $xml, __FUNCTION__);
  839. } catch (Exception $ex) {
  840. $values['error'] = $ex->getMessage();
  841. }
  842. if (!empty($client))
  843. switchepp_logoutepp($client, $params);
  844. return $values;
  845. }
  846. #***************************Disable DNSSEC******************************#
  847. function switchepp_Disable_DNSSEC($params)
  848. {
  849. try {
  850. // $check_license = switchepp_license_status($params); #Check License
  851. $client = switchepp_clientloginepp($params); #Epp Connection
  852. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  853. #Domain Restore XML
  854. $xml = switcheppDisableDnssec($params);
  855. $domainRestore = switchepp_write_xml($client, $xml, __FUNCTION__);
  856. $values['success'] = 'success';
  857. } catch (Exception $ex) {
  858. $values['error'] = $ex->getMessage();
  859. return $values;
  860. }
  861. if (!empty($client))
  862. switchepp_logoutepp($client, $params);
  863. return $values;
  864. }
  865. #***************************Enable DNSSEC******************************#
  866. function switchepp_Enable_DNSSEC($params)
  867. {
  868. try {
  869. // $check_license = switchepp_license_status($params); #Check License
  870. //if ($check_license['status'] == "Active") {
  871. $client = switchepp_clientloginepp($params); #Epp Connection
  872. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  873. //}
  874. #Domain Restore XML
  875. $xml = switcheppEnableDnssec($params);
  876. $domainRestore = switchepp_write_xml($client, $xml, __FUNCTION__);
  877. $values['success'] = 'success';
  878. } catch (Exception $ex) {
  879. $values['error'] = $ex->getMessage();
  880. }
  881. if (!empty($client))
  882. switchepp_logoutepp($client, $params);
  883. return $values;
  884. }
  885. #***************************Admin Fields******************************#
  886. function switchepp_AdminDomainsTabFields($params)
  887. {
  888. try {
  889. $settingArr = getSwitchEPP_setting($params['domainid']); #get registrar config settings
  890. $params = array_merge($params, $settingArr);
  891. // $check_license = switchepp_license_status($params); #Check License
  892. $client = switchepp_clientloginepp($params); #Epp Connection
  893. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  894. $params['domain_punycode'] = $params['sld_punycode'] . '.' . $params['tld'];
  895. #get domain info
  896. $xml = switchepp_domain_info($params);
  897. $info_domain = switchepp_write_xml($client, $xml, __FUNCTION__ . '(domain info)');
  898. $expDate = $info_domain->response->resData->children("domain", true)->infData->exDate ? date('m-d-Y', strtotime($info_domain->response->resData->children("domain", true)->infData->exDate)) : '';
  899. $status = $info_domain->response->resData->children("domain", true)->infData->status->attributes()->s;
  900. $upDate = $info_domain->response->resData->children("domain", true)->infData->upDate ? date('m-d-Y', strtotime($info_domain->response->resData->children("domain", true)->infData->upDate)) : '';
  901. $transferDate = $info_domain->response->resData->children("domain", true)->infData->trDate ? date('m-d-Y', strtotime($info_domain->response->resData->children("domain", true)->infData->trDate)) : '';
  902. $createDate = $info_domain->response->resData->children("domain", true)->infData->crDate ? date('m-d-Y', strtotime($info_domain->response->resData->children("domain", true)->infData->crDate)) : '';
  903. $DNSSecStatus = $info_domain->response->extension->children("secDNS", true)->infData->dsData->keyTag ? "Yes" : "No";
  904. $html = '';
  905. $html .= '<table width="100%" style="margin-bottom:0;" class="datatable">';
  906. $html .= '<tbody>';
  907. $html .= '<tr align="left">';
  908. $html .= '<th style="text-align: left;">Item</th>';
  909. $html .= '<th style="text-align: left;">Content</th>';
  910. $html .= '</tr>';
  911. $html .= '<tr align="left">';
  912. $html .= '<td>Status</td>';
  913. $html .= '<td>' . $status . '</td>';
  914. $html .= '</tr>';
  915. $html .= '<tr align="left">';
  916. $html .= '<td>Creation Date</td>';
  917. $html .= '<td>' . $createDate . '</td>';
  918. $html .= '</tr>';
  919. $html .= '<tr align="left">';
  920. $html .= '<td>Expiration Date</td>';
  921. $html .= '<td>' . $expDate . '</td>';
  922. $html .= '</tr>';
  923. $html .= '<tr align="left">';
  924. $html .= '<td>Last Update</td>';
  925. $html .= '<td>' . $upDate . '</td>';
  926. $html .= '</tr>';
  927. $html .= '<tr align="left">';
  928. $html .= '<td>Last Transfer</td>';
  929. $html .= '<td>' . $transferDate . '</td>';
  930. $html .= '</tr>';
  931. $html .= '<tr align="left">';
  932. $html .= '<td>DNSSec Status</td>';
  933. $html .= '<td>' . $DNSSecStatus . '</td>';
  934. $html .= '</tr>';
  935. $html .= '</tbody>';
  936. $html .= '</table>';
  937. $values['Domain Detail'] = $html;
  938. } catch (Exception $ex) {
  939. $values['error'] = $ex->getMessage();
  940. }
  941. if (!empty($client))
  942. switchepp_logoutepp($client, $params);
  943. return $values;
  944. }
  945. #*******************Module Syncronize********************#
  946. function switchepp_Sync($params)
  947. {
  948. /***
  949. * [error] => Command failed; server closing connection. Too many requests per second! Timeout ms.: 47107
  950. * using usleep to slow down request frequency
  951. */
  952. usleep(500000);
  953. try {
  954. $client = switchepp_clientloginepp($params); #Epp Connection
  955. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  956. #get domain info
  957. $xml = switchepp_domain_info($params);
  958. $info_domain = switchepp_write_xml($client, $xml, __FUNCTION__ . '(domain info)');
  959. $expDate = substr($info_domain->response->resData->children("domain", true)->infData->exDate, 0, 10);
  960. $statusres = $info_domain->response->resData->children("domain", true)->infData->status->attributes()->s;
  961. $timestamp = strtotime($info_domain->response->resData->children("domain", true)->infData->exDate);
  962. if ($timestamp === false) {
  963. return array(
  964. 'error' => 'Renewal date empty for domain: ' . $params['domain']
  965. );
  966. }
  967. Capsule::table('tbldomains')->where('id', $params['domainid'])->update(['expirydate' => $expDate]);
  968. $domain = Capsule::table('tbldomains')
  969. ->where('id', '=', $params['domainid'])
  970. ->where('donotrenew', '=', '1')
  971. ->where('registrar', '=', 'switchepp')
  972. ->whereRaw('`expirydate` >= CURRENT_DATE() AND `expirydate` < ADDDATE(CURRENT_DATE(), INTERVAL 1 DAY)')
  973. ->first();
  974. if (isset($domain->expirydate)) {
  975. $domainname = $params['domain_punycode'];
  976. $deletxml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  977. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  978. <command>
  979. <delete>
  980. <domain:delete xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
  981. <domain:name>' . $domainname . '</domain:name>
  982. </domain:delete>
  983. </delete>
  984. <clTRID>delete-domain-' . rand(1000, 9999) . '</clTRID>
  985. </command>
  986. </epp>';
  987. $delete_domain = switchepp_write_xml($client, $deletxml, __FUNCTION__ . ' (delete domain)');
  988. }
  989. if ($timestamp < time()) {
  990. $values['expirydate'] = $expDate;
  991. $values['expired'] = true;
  992. } else {
  993. $values['expirydate'] = $expDate;
  994. $values['active'] = true;
  995. }
  996. } catch (Exception $ex) {
  997. $values['error'] = $ex->getMessage();
  998. logModuleCall(
  999. 'switchEPP',
  1000. __FUNCTION__,
  1001. $params,
  1002. 'debug sync err',
  1003. $values
  1004. );
  1005. }
  1006. if (!empty($client))
  1007. switchepp_logoutepp($client, $params);
  1008. return $values;
  1009. }
  1010. #*******************Transfer Syncronize********************#
  1011. function switchepp_TransferSync($params)
  1012. {
  1013. try {
  1014. $client = switchepp_clientloginepp($params); #Epp Connection
  1015. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  1016. #get domain info
  1017. $xml = switchepp_domain_info($params);
  1018. $info_domain = switchepp_write_xml($client, $xml, __FUNCTION__ . '(domain info)');
  1019. $expDate = substr($info_domain->response->resData->children("domain", true)->infData->exDate, 0, 10);
  1020. $statusres = $info_domain->response->resData->children("domain", true)->infData->status->attributes()->s;
  1021. if (!$statusres) {
  1022. Capsule::table('tbldomains')->where('id', $params['domainid'])->update(["status" => "Cancelled"]);
  1023. $values['error'] = "TransferSync/domain-info: Domain not found";
  1024. }
  1025. Capsule::table('tbldomains')->where('id', $params['domainid'])->update(['expirydate' => $expDate]);
  1026. if ($statusres == "ok" || $statusres == "serverTransferProhibited") {
  1027. $values['completed'] = true;
  1028. } else {
  1029. $values['error'] = "Sync/domain-info: Unknown status code '$statusres' ";
  1030. }
  1031. $values['expirydate'] = $expDate;
  1032. } catch (Exception $ex) {
  1033. $values['error'] = $ex->getMessage();
  1034. }
  1035. if (!empty($client))
  1036. switchepp_logoutepp($client, $params);
  1037. return $values;
  1038. }
  1039. #***********************Register Nameserver**************************#
  1040. function switchepp_RegisterNameserver($params)
  1041. {
  1042. try {
  1043. // $check_license = switchepp_license_status($params); #Check License
  1044. $client = switchepp_clientloginepp($params); #Epp Connection
  1045. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  1046. #get domain info
  1047. $xml = switchepp_domain_info($params);
  1048. $xml_Hostcreate = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  1049. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  1050. <command>
  1051. <create>
  1052. <host:create xmlns:host="urn:ietf:params:xml:ns:host-1.0">
  1053. <host:name>' . $params['nameserver'] . '</host:name>
  1054. <host:addr ip="v4">' . $params['ipaddress'] . '</host:addr>
  1055. </host:create>
  1056. </create>
  1057. <clTRID>' . rand(9999999, 100000) . '</clTRID>
  1058. </command>
  1059. </epp>';
  1060. $host_create = switchepp_write_xml($client, $xml_Hostcreate, __FUNCTION__);
  1061. } catch (Exception $ex) {
  1062. $values['error'] = $ex->getMessage();
  1063. }
  1064. if (!empty($client))
  1065. switchepp_logoutepp($client, $params);
  1066. return $values;
  1067. }
  1068. #**************************Update Nameserver************************#
  1069. function switchepp_ModifyNameserver($params)
  1070. {
  1071. try {
  1072. // $check_license = switchepp_license_status($params); #Check License
  1073. $client = switchepp_clientloginepp($params); #Epp Connection
  1074. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  1075. #get domain info
  1076. $xml = switchepp_domain_info($params);
  1077. $update_req = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  1078. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  1079. <command>
  1080. <update>
  1081. <host:update xmlns:host="urn:ietf:params:xml:ns:host-1.0">
  1082. <host:name>' . $params['nameserver'] . '</host:name>
  1083. <host:add>
  1084. <host:addr ip="v4">' . $params['newipaddress'] . '</host:addr>
  1085. </host:add>
  1086. <host:rem>
  1087. <host:addr ip="v4">' . $params['currentipaddress'] . '</host:addr>
  1088. </host:rem>
  1089. </host:update>
  1090. </update>
  1091. <clTRID>' . rand(9999999, 100000) . '</clTRID>
  1092. </command>
  1093. </epp>';
  1094. $update = switchepp_write_xml($client, $update_req, __FUNCTION__);
  1095. } catch (Exception $ex) {
  1096. $values['error'] = $ex->getMessage();
  1097. }
  1098. if (!empty($client))
  1099. switchepp_logoutepp($client, $params);
  1100. return $values;
  1101. }
  1102. #**********************Delete Nameserver****************************#
  1103. function switchepp_DeleteNameserver($params)
  1104. {
  1105. try {
  1106. // $check_license = switchepp_license_status($params); #Check License
  1107. $client = switchepp_clientloginepp($params); #Epp Connection
  1108. $login = switchepp_loggedinepp($client, $params); #Epp Client login
  1109. #get domain info
  1110. $xml = switchepp_domain_info($params);
  1111. $delete_xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  1112. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  1113. <command>
  1114. <delete>
  1115. <host:delete
  1116. xmlns:host="urn:ietf:params:xml:ns:host-1.0">
  1117. <host:name>' . $params['nameserver'] . '</host:name>
  1118. </host:delete>
  1119. </delete>
  1120. <clTRID>' . rand(9999999, 100000) . '</clTRID>
  1121. </command>
  1122. </epp>';
  1123. $delete = switchepp_write_xml($client, $delete_xml, __FUNCTION__);
  1124. } catch (Exception $ex) {
  1125. $values['error'] = $ex->getMessage();
  1126. }
  1127. if (!empty($client))
  1128. switchepp_logoutepp($client, $params);
  1129. return $values;
  1130. }
  1131. #*********************Create Epp Connection**************************#
  1132. function switchepp_clientloginepp($params)
  1133. {
  1134. try {
  1135. $certFile = __DIR__ . '/cert/cert.pem';
  1136. $client = new Net_EPP_Client();
  1137. $use_ssl = true;
  1138. $eppurl = $params['eppurl'];
  1139. $port = $params['eppport'];
  1140. if ($params['testMode'] == "on") {
  1141. $eppurl = trim($params['ote_eppurl']);
  1142. $port = $params['ote_eppport'];
  1143. }
  1144. if (file_exists($certFile)) {
  1145. $context = stream_context_create();
  1146. stream_context_set_option($context, 'ssl', 'verify_peer', false);
  1147. stream_context_set_option($context, 'ssl', 'allow_self_signed', true);
  1148. stream_context_set_option($context, 'ssl', 'local_cert', $certFile);
  1149. stream_context_set_option($context, 'ssl', 'passphrase', $params['passphrase']);
  1150. $client->connect($eppurl, $port, 300, $use_ssl, $context) or die("Not connected with epp server");
  1151. } else {
  1152. $context = false;
  1153. $client->connect($eppurl, $port, 300, $use_ssl, $context) or die("Not connected with epp server");
  1154. }
  1155. } catch (Exception $e) {
  1156. $port = $params['eppport'];
  1157. throw new exception("Connection Error: " . $e->getMessage());
  1158. }
  1159. return $client;
  1160. }
  1161. #*********************Epp client login**************************#
  1162. function switchepp_loggedinepp($client, $params)
  1163. {
  1164. if($params['testMode'] == "on"){
  1165. $params['registrar_id'] = $params['ote_registrar_id'];
  1166. $params['registrar_password'] = $params['ote_registrar_password'];
  1167. }
  1168. $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  1169. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  1170. <command>
  1171. <login>
  1172. <clID>' . $params['registrar_id'] . '</clID>
  1173. <pw>' . $params['registrar_password'] . '</pw>
  1174. <options>
  1175. <version>1.0</version>
  1176. <lang>en</lang>
  1177. </options>
  1178. <svcs>
  1179. <objURI>urn:ietf:params:xml:ns:domain-1.0</objURI>
  1180. <objURI>urn:ietf:params:xml:ns:contact-1.0</objURI>
  1181. <objURI>urn:ietf:params:xml:ns:host-1.0</objURI>
  1182. <svcExtension>
  1183. <extURI>urn:ietf:params:xml:ns:secDNS-1.1</extURI>
  1184. <extURI>urn:ietf:params:xml:ns:rgp-1.0</extURI>
  1185. <extURI>urn:ietf:params:xml:ns:changePoll-1.0</extURI>
  1186. <extURI>https://www.nic.ch/epp/balance-1.0</extURI>
  1187. <extURI>urn:ietf:params:xml:ns:epp:unhandled-namespaces-1.0</extURI>
  1188. </svcExtension>
  1189. </svcs>
  1190. </login>
  1191. <clTRID>' . rand(9999999, 100000) . '</clTRID>
  1192. </command>
  1193. </epp>';
  1194. $response = $client->request($xml);
  1195. logModuleCall('SWITCH EPP', 'login', $xml, $response);
  1196. $result = new SimpleXMLElement($response);
  1197. if ($result->response->result->attributes()->code >= 2000) {
  1198. throw new exception($result->response->result->msg . '. ' . $result->response->result->extValue->reason);
  1199. }
  1200. return $result;
  1201. }
  1202. function switchepp_logoutepp($client, $params)
  1203. {
  1204. if($params['testMode'] == "on"){
  1205. $params['registrar_id'] = $params['ote_registrar_id'];
  1206. }
  1207. $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  1208. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  1209. <epp:command xmlns:epp="urn:ietf:params:xml:ns:epp-1.0">
  1210. <epp:logout />
  1211. <epp:clTRID>' . $params['registrar_id'] . '</epp:clTRID>
  1212. </epp:command>
  1213. </epp>';
  1214. $response = $client->request($xml);
  1215. logModuleCall('SWITCH EPP', 'logout', $xml, $response);
  1216. }
  1217. #******************** Get Contact info*****************#
  1218. function switchepp_contact_info($client, $contactId, $contactType)
  1219. {
  1220. #get contact detail
  1221. $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  1222. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  1223. <command>
  1224. <info>
  1225. <contact:info xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
  1226. <contact:id>' . $contactId . '</contact:id>
  1227. </contact:info>
  1228. </info>
  1229. <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
  1230. </command>
  1231. </epp>';
  1232. $response = $client->request($xml);
  1233. logModuleCall('SWITCH EPP', $contactType, $xml, $response);
  1234. return $response;
  1235. }
  1236. #***********************Get domain info*************************#
  1237. function switchepp_domain_info($params)
  1238. {
  1239. $domainname = $params['domain_punycode'];
  1240. $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  1241. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  1242. <command>
  1243. <info>
  1244. <domain:info xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
  1245. <domain:name hosts="all">' . $domainname . '</domain:name>
  1246. </domain:info>
  1247. </info>
  1248. <clTRID>clientref-' . rand(100, 999) . '</clTRID>
  1249. </command>
  1250. </epp>';
  1251. return $xml;
  1252. }
  1253. function switchepp_domain_restore($params)
  1254. {
  1255. $domainname = $params['domain_punycode'];
  1256. $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  1257. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  1258. <command>
  1259. <update>
  1260. <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
  1261. <domain:name>' . $domainname . '</domain:name>
  1262. <domain:chg />
  1263. </domain:update>
  1264. </update>
  1265. <extension>
  1266. <rgp:update xmlns:rgp="urn:ietf:params:xml:ns:rgp-1.0">
  1267. <rgp:restore op="request" />
  1268. </rgp:update>
  1269. </extension>
  1270. </command>
  1271. </epp>';
  1272. return $xml;
  1273. }
  1274. function switcheppDisableDnssec($params)
  1275. {
  1276. $domainname = $params['domain_punycode'];
  1277. ;
  1278. $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  1279. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  1280. <command>
  1281. <update>
  1282. <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
  1283. <domain:name>' . $domainname . '</domain:name>
  1284. </domain:update>
  1285. </update>
  1286. <extension>
  1287. <secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
  1288. <secDNS:rem>
  1289. <secDNS:all>true</secDNS:all>
  1290. </secDNS:rem>
  1291. </secDNS:update>
  1292. </extension>
  1293. <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
  1294. </command>
  1295. </epp>';
  1296. return $xml;
  1297. }
  1298. function switcheppEnableDnssec($params)
  1299. {
  1300. $domainname = $params['domain_punycode'];
  1301. $digestType = $params['digest_type'];
  1302. if (empty($digestType))
  1303. $digestType = 1;
  1304. if ($digestType == 1) {
  1305. $string = switchepp_generateDigestRandomString(40);
  1306. $digest = strtoupper(bin2hex($string));
  1307. $digest = substr($digest, 0, 40);
  1308. } elseif ($digestType == 2) {
  1309. $string = switchepp_generateDigestRandomString(64);
  1310. $digest = strtoupper(bin2hex($string));
  1311. $digest = substr($digest, 0, 64);
  1312. } elseif ($digestType == 3 || $digestType == 4) {
  1313. $string = switchepp_generateDigestRandomString(96);
  1314. $digest = strtoupper(bin2hex($string));
  1315. $digest = substr($digest, 0, 96);
  1316. }
  1317. $params['algorithm'] = (!empty($params['algorithm'])) ? $params['algorithm'] : '5';
  1318. $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  1319. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  1320. <command>
  1321. <update>
  1322. <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
  1323. <domain:name>' . $domainname . '</domain:name>
  1324. </domain:update>
  1325. </update>
  1326. <extension>
  1327. <secDNS:update xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1">
  1328. <secDNS:add>
  1329. <secDNS:dsData>
  1330. <secDNS:keyTag>' . substr(time(), 0, 5) . '</secDNS:keyTag>
  1331. <secDNS:alg>' . $params['algorithm'] . '</secDNS:alg>
  1332. <secDNS:digestType>' . $digestType . '</secDNS:digestType>
  1333. <secDNS:digest>' . $digest . '</secDNS:digest>
  1334. </secDNS:dsData>
  1335. </secDNS:add>
  1336. </secDNS:update>
  1337. </extension>
  1338. <clTRID>clientref-' . rand(1000, 9999) . '</clTRID>
  1339. </command>
  1340. </epp>';
  1341. return $xml;
  1342. }
  1343. function switchepp_update_domain_auth($params, $domainPw)
  1344. {
  1345. $domainname = $params['domain_punycode'];
  1346. $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  1347. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  1348. <command>
  1349. <update>
  1350. <domain:update xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
  1351. <domain:name>' . $domainname . '</domain:name>
  1352. <domain:chg>
  1353. <domain:authInfo>
  1354. <domain:pw>' . $domainPw . '</domain:pw>
  1355. </domain:authInfo>
  1356. </domain:chg>
  1357. </domain:update>
  1358. </update>
  1359. <clTRID>domainupdate-' . rand(1000, 9999) . '</clTRID>
  1360. </command>
  1361. </epp>';
  1362. return $xml;
  1363. }
  1364. function switchepp_checkContact($id)
  1365. {
  1366. $xml = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>
  1367. <epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
  1368. <command>
  1369. <check>
  1370. <contact:check xmlns:contact="urn:ietf:params:xml:ns:contact-1.0">
  1371. <contact:id>' . $id . '</contact:id>
  1372. </contact:check>
  1373. </check>
  1374. <clTRID>ABC-12345</clTRID>
  1375. </command>
  1376. </epp>';
  1377. return $xml;
  1378. }
  1379. function switchepp_generateRandomString($length = 15)
  1380. {
  1381. $characters = 'abcdefghijklmnopqrstuvwxyz123456789!@$*%#ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  1382. $charactersLength = strlen($characters);
  1383. $randomString = '';
  1384. for ($i = 0; $i < $length; $i++) {
  1385. $randomString .= $characters[rand(0, $charactersLength - 1)];
  1386. }
  1387. return $randomString;
  1388. }
  1389. function switchepp_generateDigestRandomString($length = 15)
  1390. {
  1391. $characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  1392. $charactersLength = strlen($characters);
  1393. $randomString = '';
  1394. for ($i = 0; $i < $length; $i++) {
  1395. $randomString .= $characters[rand(0, $charactersLength - 1)];
  1396. }
  1397. return $randomString;
  1398. }
  1399. function switchepp_generateContactID($length = 15)
  1400. {
  1401. $characters = 'abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  1402. $charactersLength = strlen($characters);
  1403. $randomString = '';
  1404. for ($i = 0; $i < $length; $i++) {
  1405. $randomString .= $characters[rand(0, $charactersLength - 1)];
  1406. }
  1407. return $randomString;
  1408. }
  1409. function switcheppGetDomainName($id)
  1410. {
  1411. $data = Capsule::table('tbldomains')->where('id', $id)->first();
  1412. return $data->domain;
  1413. }
  1414. function switchepp_write_xml($client, $xml, $action, $extra = NULL)
  1415. {
  1416. $response = $client->request($xml);
  1417. if (empty($extra)) {
  1418. logModuleCall('SWITCH EPP', $action, $xml, $response);
  1419. $result = new SimpleXMLElement($response);
  1420. if ($result->response->result->attributes()->code >= 2000) {
  1421. throw new exception($result->response->result->msg . '. ' . $result->response->result->extValue->reason);
  1422. }
  1423. return $result;
  1424. }
  1425. }
  1426. function getSwitchEPP_setting($id)
  1427. {
  1428. #select table domain data
  1429. $domain_select_data = Capsule::table('tbldomains')->where('id', $id)->first();
  1430. #select registrar data
  1431. foreach (Capsule::table('tblregistrars')->where('registrar', $domain_select_data->registrar)->get() as $registrar_data) {
  1432. $data[$registrar_data->setting] = decrypt($registrar_data->value);
  1433. }
  1434. return $data;
  1435. }
  1436. function switchepp_license_status($params)
  1437. {
  1438. $license_check = SwitchEpp_license_checklicense($params['licensenum']);
  1439. if ($license_check['status'] != 'Active') {
  1440. throw new exception('license is ' . $license_check['status']);
  1441. }
  1442. return $license_check;
  1443. }
  1444. #License function
  1445. function SwitchEpp_license_checklicense($licensekey, $localkey = "")
  1446. {
  1447. $results['status'] = "Active";
  1448. return $results;
  1449. }