CustomDnsRegistrarHelper.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. <?php
  2. /* * ********************************************************************
  3. * Rrgistrar Helper
  4. *
  5. *
  6. * CREATED BY MODULESGARDEN -> http://modulesgarden.com
  7. * CONTACT -> contact@modulesgarden.com
  8. * AUTHOR -> MODULESGARDEN
  9. * contact@modulesgarden.com
  10. *
  11. *
  12. *
  13. * This software is furnished under a license and may be used and copied
  14. * only in accordance with the terms of such license and with the
  15. * inclusion of the above copyright notice. This software or any other
  16. * copies thereof may not be provided or otherwise made available to any
  17. * other person. No title to and ownership of the software is hereby
  18. * transferred.
  19. *
  20. *
  21. * ******************************************************************** */
  22. namespace MGModule\DNSManager2\mgLibs\custom\dns\utils;
  23. use MGModule\DNSManager2\models\custom\reverse\Repository;
  24. use MGModule\DNSManager2\mgLibs\custom\dns\record\Record;
  25. use MGModule\DNSManager2\mgLibs\custom\dns\utils\ReverseDNSHelper;
  26. use MGModule\DNSManager2\mgLibs\exceptions\RegistrarDNSException;
  27. use MGModule\DNSManager2\mgLibs\MySQL as mysql;
  28. use MGModule\DNSManager2\mgLibs\MySQL\query;
  29. use MGModule\DNSManager2\addon;
  30. use MGModule\DNSManager2\mgLibs\custom\manager\ClientHelper;
  31. use MGModule\DNSManager2\models\custom\zone\Zone;
  32. use MGModule\DNSManager2\models\custom\zone\ZoneTypeEnum;
  33. use MGModule\DNSManager2 as main;
  34. /**
  35. * registrar helper for DNS Management
  36. * Please make sure that "mocks" folder is readable<br/>
  37. * Please also make sure that "function" folder is writable. It is necessairy to create dynamic files with specific DNS Functions
  38. */
  39. class CustomDnsRegistrarHelper
  40. {
  41. public $domainId = null;
  42. public $moduleName = null;
  43. private $package = null;
  44. /**
  45. * Current Module Parametrers for given domain
  46. * @var Array
  47. */
  48. protected $moduleParams = array();
  49. protected $availableTypes = array(
  50. 'A' => array(
  51. 'name' => 'A',
  52. 'ttl' => 14400
  53. ),
  54. 'AAAA' => array(
  55. 'name' => 'AAAA',
  56. 'ttl' => 14400
  57. ),
  58. 'MX' => array(
  59. 'name' => 'MX',
  60. 'ttl' => 14400
  61. ),
  62. 'CNAME' => array(
  63. 'name' => 'CNAME',
  64. 'ttl' => 14400
  65. ),
  66. 'TXT' => array(
  67. 'name' => 'SPF',
  68. 'ttl' => 14400,
  69. 'alias' => 'SPF'
  70. ),
  71. 'TXT' => array(
  72. 'name' => 'TXT',
  73. 'ttl' => 14400,
  74. 'alias' => 'SPF'
  75. )
  76. );
  77. const REGISTRAR_DOMAIN_ID_NOT_EXISTS = 100;
  78. const REGISTRAR_ZONE_NOT_FOUND = 101;
  79. const REGISTRAR_DOMAIN_DETAILS_NOT_FOUND = 102;
  80. const REGISTRAR_DOMAIN_NAME_NOT_FOUND = 103;
  81. const REGISTRAR_MODULE_NAME_NOT_FOUND = 104;
  82. const REGISTRAR_USER_ID_NOT_EXISTS = 105;
  83. static public $MSGS_LIST = array(
  84. 100 => "Domain ID cannot be empty. Please provide correct Domain ID in %s",
  85. 101 => "Unable to find zone for provided domain. Create a new zone first or contact your administrator",
  86. 102 => "Unable to get Domain Details Information in %s",
  87. 103 => "No Domain name has been provided for %s",
  88. 104 => "No Module Name has been found for %s",
  89. 105 => "Unable to get User ID in %s. Probably session has expired",
  90. );
  91. public final function __construct($domainId = null)
  92. {
  93. $this->domainId = $domainId;
  94. $this->getPackage();
  95. }
  96. public function setDomainId($domainId)
  97. {
  98. $this->domainId = $domainId;
  99. }
  100. public function getDNSRecords($domainId)
  101. {
  102. $params = $this->getModuleParams();
  103. addon::I(FALSE, $params);
  104. $helper = new ClientHelper($_SESSION['uid']);
  105. $zone = new Zone($this->getZoneIdForDomain($domainId));
  106. $dns = array();
  107. if(!$helper->isZoneOwnedByClient($zone))
  108. {
  109. return array(
  110. 'error' => main\mgLibs\lang::T('you_cannot_edit_this_zone_because_it_is_not_belongs_to_you')
  111. );
  112. }
  113. $module = $zone->getModule();
  114. $vars['records'] = $module->getRecords();
  115. $vars['records'] = array_merge($vars['records'], $this->getPTRRecords($zone));
  116. foreach($vars['records'] as &$record)
  117. {
  118. $record->encode();
  119. if(!isset($this->availableTypes[$record['type']]))
  120. {
  121. continue;
  122. }
  123. $priority = null;
  124. switch($record['type'])
  125. {
  126. case 'MX':
  127. $address = $record['rdata']->exchange;
  128. $priority = $record['rdata']->preference;
  129. break;
  130. case 'CNAME':
  131. $address = $record['rdata']['cname'];
  132. break;
  133. case 'A':
  134. $address = $record['rdata']['address'];
  135. break;
  136. case 'AAAA':
  137. $address = $record['rdata']['address'];
  138. break;
  139. case 'TXT':
  140. $address = $record['rdata']['txtdata'];
  141. break;
  142. default:
  143. }
  144. $dns[] = array(
  145. "hostname" => $record['name'],
  146. "line" => $record['line'],
  147. "type" => $record['type'],
  148. "address" => $address,
  149. "priority" => $priority,
  150. "name" => $record['name'],
  151. "class" => $record['class'],
  152. "ttl" => $record['ttl'],
  153. "rdlength" => $record['rdlength'],
  154. "rdata" => $record["rdata"]
  155. );
  156. }
  157. return $dns;
  158. }
  159. /**
  160. *
  161. * @param type $record
  162. * @return type
  163. */
  164. private function convertRecord($record)
  165. {
  166. //applying additional parameters to match DNS Manager spec
  167. $record['ttl'] = $this->availableTypes[trim(strtoupper($record['type']))]['ttl'];
  168. $record['name'] = $record['hostname'];
  169. if($record['type'] == "MX")
  170. {
  171. $record['exchange'] = $record['address'];
  172. $record['preference'] = (int) $record['priority'];
  173. $record['rdata']['exchange'] = $record['address'];
  174. $record['rdata']['preference'] = (int) $record['priority'];
  175. }
  176. if($record['type'] == "CNAME")
  177. {
  178. $record['rdata']['cname'] = $record['address'];
  179. }
  180. if($record['type'] == "TXT")
  181. {
  182. $record['rdata']['txtdata'] = $record['address'];
  183. }
  184. return $record;
  185. }
  186. private function transformRecords()
  187. {
  188. $records = $_POST['dnsrecordhost'];
  189. $recordsType = $_POST['dnsrecordtype'];
  190. $recordsAddress = $_POST['dnsrecordaddress'];
  191. $recordsPriority = $_POST['dnsrecordpriority'];
  192. $results = array();
  193. foreach($records as $key => $value)
  194. {
  195. $results[] = array(
  196. 'hostname' => $value,
  197. 'name' => $value,
  198. 'type' => $recordsType[$key],
  199. 'address' => $recordsAddress[$key],
  200. 'priority' => $recordsPriority[$key],
  201. 'ttl' => $this->availableTypes[trim(strtoupper($recordsType[$key]))]['ttl'],
  202. 'rdata' => array(
  203. 'hostname' => $value,
  204. 'name' => $value,
  205. 'type' => $recordsType[$key],
  206. 'address' => $recordsAddress[$key],
  207. 'priority' => $recordsPriority[$key],
  208. 'ttl' => $this->availableTypes[trim(strtoupper($recordsType[$key]))]['ttl'],
  209. ),
  210. );
  211. }
  212. return $results;
  213. }
  214. /**
  215. * This function is used to check if record type which is going to be created is allowed and available
  216. * @param String $type Name of the DNS record Type to check if is allowed to create
  217. * @see Registrar::availableTypes for available types
  218. * @return boolean True is returned is allowed - false otherwise
  219. */
  220. private function checkTypeIfAvailable($type = null)
  221. {
  222. if(empty($type))
  223. {
  224. return false;
  225. }
  226. foreach ($this->availableTypes as $key)
  227. {
  228. if ($key['name'] == trim(strtoupper($type)))
  229. {
  230. return true;
  231. }
  232. }
  233. return false;
  234. }
  235. /**
  236. * Function used to save or delete DNS record with provided details
  237. * @param type $domainId Id of the domain for whitch records would be deleted or created
  238. * @return Array . Void otherwise
  239. * @throws \Exception Array with error key is returend in case of failure. in that case an exception is thrown
  240. */
  241. public function saveDNSRecords($domainId = null)
  242. {
  243. if (empty($domainId))
  244. {
  245. $domainId = $this->domainId;
  246. }
  247. $zoneLoggerManager = new main\mgLibs\custom\helpers\ZoneLogger\Manager($_SESSION['uid']);
  248. $error = array();
  249. $params = $this->getModuleParams();
  250. addon::I(FALSE, $params);
  251. $helper = new ClientHelper($_SESSION['uid']);
  252. $zone = new Zone($this->getZoneIdForDomain($domainId));
  253. //getting den for
  254. $newDNSCollection = $this->transformRecords();
  255. $oldDNSCollection = $this->getDNSRecords($domainId);
  256. $limits = $this->checkPackageLimits($newDNSCollection);
  257. if($limits)
  258. {
  259. throw new \Exception($limits, 0);
  260. }
  261. if (!$helper->isZoneOwnedByClient($zone))
  262. {
  263. throw new \Exception(main\mgLibs\lang::T('you_cannot_edit_this_zone_because_it_is_not_belongs_to_you'), 0);
  264. }
  265. $module = $zone->getModule();
  266. foreach ($newDNSCollection as $newKey => $newValue)
  267. {
  268. $newValue = $this->convertRecord($newValue);
  269. //if such a key does not exists it could be a new one
  270. if (!array_key_exists($newKey, $oldDNSCollection))
  271. {
  272. if (empty($newValue['hostname']) && empty($newValue['address']))
  273. {
  274. continue;
  275. }
  276. //if type is not allowd - return error
  277. if (!$this->checkTypeIfAvailable($newValue['type']))
  278. {
  279. $error[] = $newValue['type'] . ' is not supported. Available types: A, AAAA, MX, CNAME, SPF(txt).';
  280. continue;
  281. }
  282. try
  283. {
  284. $record = $this->createRecordFromData($newValue);
  285. $module->addRecord($record);
  286. $zoneLoggerManager->logAddRecordToZone($zone, $record);
  287. }
  288. catch(\Exception $ex)
  289. {
  290. $error[] = $ex->getMessage();
  291. }
  292. continue;
  293. }
  294. //if there are no difference - do nothing
  295. if($newValue['hostname'] == $oldDNSCollection[$newKey]['hostname']
  296. && $newValue['address'] == $oldDNSCollection[$newKey]['address']
  297. && ($newValue['priority'] == $oldDNSCollection[$newKey]['priority'] || !is_numeric($newValue['priority'])))
  298. {
  299. continue;
  300. }
  301. //if there are discrepencies in a host name or IP address remove old record and add new one
  302. //or remove only those in which both hostname and address are empty
  303. try
  304. {
  305. $module->deleteRecord($record = $this->createRecordFromData($oldDNSCollection[$newKey]));
  306. $zoneLoggerManager->logRemoveRecordFromZone($record);
  307. //remove record and if values was empty - do nothing else
  308. if (empty($newValue['hostname']) && empty($newValue['address']))
  309. {
  310. continue;
  311. }
  312. }
  313. catch(\Exception $ex)
  314. {
  315. $error[] = $ex->getMessage();
  316. continue;
  317. }
  318. try
  319. {
  320. $module->addRecord($record = $this->createRecordFromData($newValue));
  321. }
  322. catch(\Exception $ex)
  323. {
  324. $error[] = $ex->getMessage();
  325. //rollbacking
  326. $module->addRecord($record = $this->createRecordFromData($oldDNSCollection[$newKey]));
  327. }
  328. $zoneLoggerManager->logAddRecordToZone($zone, $record);
  329. }
  330. if(!empty($error))
  331. {
  332. throw new \Exception(implode(". <br />\n", $error), 1);
  333. }
  334. }
  335. /**
  336. * Function used to create record from form data
  337. * @param Array $input Collection of form parameters sent by WHMCS while new DNS record creation
  338. * @return MGModule\DNSManager2\mgLibs\custom\dns\record\Record
  339. */
  340. private function createRecordFromData($input)
  341. {
  342. $record = Record::tryToCreateFromArray($input);
  343. $record->rdata->setDataFromArray($input['rdata']);
  344. return $record;
  345. }
  346. /**
  347. * Function used to get Current Domain ID
  348. * @return integer ID of the domain is used
  349. */
  350. protected function getDomainId()
  351. {
  352. return (int)$this->domainId;
  353. }
  354. private function getPTRRecords($zone)
  355. {
  356. $out = array();
  357. foreach(Repository::factory()->from($zone->getServer()->id, $zone->name)->get() as $data)
  358. {
  359. $ptr = new Record();
  360. $ptr->name = ReverseDNSHelper::getLastOctetFromIPv4($data->ip) . '.' . $data->name;
  361. $ptr->type = 'PTR';
  362. $ptr->ttl = $data->ttl;
  363. $ptr->ip = $data->ip;
  364. $ptr->createRDATAObject('PTR');
  365. $ptr->rdata->setFirstProperty(empty($data->sub) ? $data->from : $data->sub . '.' . $data->from);
  366. $out[] = $ptr;
  367. }
  368. return $out;
  369. }
  370. private function getZoneIdForDomain($domainId = null)
  371. {
  372. if (empty($domainId))
  373. {
  374. throw new RegistrarDNSException(sprintf(self::$MSGS_LIST[self::REGISTRAR_DOMAIN_ID_NOT_EXISTS], __FUNCTION__), self::REGISTRAR_DOMAIN_ID_NOT_EXISTS);
  375. }
  376. $clientid = $_SESSION['uid'];
  377. $details = query::query("
  378. SELECT CONCAT('#', tbldomains.id, ' ', tbldomains.domain) AS group_name,
  379. :type `type`,
  380. tbldomains.id AS relid,
  381. dns_manager2_zone.id AS zone_id,
  382. dns_manager2_zone.name AS zone_name,
  383. dns_manager2_zone.status AS zone_status
  384. FROM tbldomains
  385. LEFT JOIN dns_manager2_zone ON dns_manager2_zone.type = :type2
  386. AND dns_manager2_zone.relid = tbldomains.id
  387. AND dns_manager2_zone.clientid = :clientid
  388. WHERE tbldomains.status IN ('Active')
  389. AND tbldomains.id = :domainid
  390. AND tbldomains.userid = :clientid2", array(
  391. 'type' => ZoneTypeEnum::DOMAIN,
  392. 'type2' => ZoneTypeEnum::DOMAIN,
  393. 'clientid' => $clientid,
  394. 'clientid2' => $clientid,
  395. 'domainid' => $domainId
  396. ))->fetch();
  397. if(empty($details))
  398. {
  399. throw new RegistrarDNSException(sprintf(self::$MSGS_LIST[self::REGISTRAR_DOMAIN_DETAILS_NOT_FOUND], __FUNCTION__), self::REGISTRAR_DOMAIN_DETAILS_NOT_FOUND);
  400. }
  401. if(empty($details['zone_id']))
  402. {
  403. throw new RegistrarDNSException(sprintf(self::$MSGS_LIST[self::REGISTRAR_ZONE_NOT_FOUND], __FUNCTION__), self::REGISTRAR_ZONE_NOT_FOUND);
  404. }
  405. return $details['zone_id'];
  406. }
  407. /**
  408. * This function is used to get Current Module Name from DB
  409. * @return String Module Name is returned
  410. * @throws RegistrarDNSException An exception is thrown if no domainId has been set or nothign has been found in DB
  411. */
  412. public function getModuleName()
  413. {
  414. if(empty($this->domainId))
  415. {
  416. throw new RegistrarDNSException(sprintf(self::$MSGS_LIST[self::REGISTRAR_DOMAIN_ID_NOT_EXISTS], __FUNCTION__), self::REGISTRAR_DOMAIN_ID_NOT_EXISTS);
  417. }
  418. if(!isset($_SESSION['uid']))
  419. {
  420. throw new RegistrarDNSException(sprintf(self::$MSGS_LIST[self::REGISTRAR_USER_ID_NOT_EXISTS], __FUNCTION__), self::REGISTRAR_USER_ID_NOT_EXISTS);
  421. }
  422. $clientId = $_SESSION['uid'];
  423. $details = query::query("
  424. SELECT tbldomains.id AS domainId,
  425. tbldomains.registrar AS registrar
  426. FROM tbldomains
  427. WHERE tbldomains.status IN ('Active')
  428. AND tbldomains.id = :domainId
  429. AND tbldomains.userid = :clientId", array(
  430. 'domainId' => $this->domainId,
  431. 'clientId' => $clientId,
  432. ))->fetch();
  433. if(empty($details))
  434. {
  435. throw new RegistrarDNSException(sprintf(self::$MSGS_LIST[self::REGISTRAR_DOMAIN_DETAILS_NOT_FOUND], __FUNCTION__), self::REGISTRAR_DOMAIN_DETAILS_NOT_FOUND);
  436. }
  437. $this->moduleName = $details['registrar'];
  438. return $details['registrar'];
  439. }
  440. /**
  441. * This function is used to create dynamic file with DNS mamagement functions in it<br />
  442. * Generasted file is later included so the registrar could recognize a set of function so DNS Management section could be activated
  443. * @param String $currentPath Current path location of the DNS Manager hook file
  444. * @return String Name of the file to be included is returned. void in case of errors
  445. */
  446. public function creatreFunctionsFile($currentPath)
  447. {
  448. $sourceLocation = $currentPath.DS.'storage'.DS.'registrar'.DS.'mocks'.DS.'DNSMockFunction.txt';
  449. $moduleName = $this->getModuleName();
  450. $locaction = $currentPath.DS.'storage'.DS.'registrar'.DS.'functions'.DS;
  451. $file = $locaction . $moduleName . "_DNSFunctions.php";
  452. if(!file_exists($file))
  453. {
  454. if(!is_readable($currentPath.DS.'storage'.DS.'registrar'.DS.'mocks'.DS))
  455. {
  456. throw new \Exception(
  457. main\mgLibs\lang::T('Directory').': '.
  458. $currentPath . '/storage/registrar/mocks '.
  459. main\mgLibs\lang::T('is_not_readable')
  460. );
  461. }
  462. $fileContent = str_replace("%module_name%", $moduleName, file_get_contents($sourceLocation));
  463. if(!is_writable($locaction))
  464. {
  465. throw new \Exception(
  466. main\mgLibs\lang::T('Directory').': '.
  467. $locaction.
  468. main\mgLibs\lang::T('is_not_writable')
  469. );
  470. }
  471. file_put_contents($file, $fileContent);
  472. }
  473. return $file;
  474. }
  475. /**
  476. * This function is used to get Parameters saved for currently used module
  477. * @param String $module Name of the module we want to find parameters for
  478. * @return Array Collection of parameted is returned
  479. * @throws RegistrarDNSException An Exception is thrown in case of Errors
  480. */
  481. public function getModuleParams($module = null)
  482. {
  483. if (empty($module))
  484. {
  485. $module = $this->getModuleName();
  486. }
  487. if (empty($module))
  488. {
  489. throw new RegistrarDNSException();
  490. }
  491. $q = query::query(
  492. "SELECT * FROM `tblregistrars` WHERE `registrar`= :registrar ", array(
  493. 'registrar' => $module
  494. ))->fetchAll();
  495. $params = array();
  496. foreach ($q as $row)
  497. {
  498. $params[$row['setting']] = decrypt($row['value']);
  499. }
  500. return $params;
  501. }
  502. public function getTld()
  503. {
  504. $tld = false;
  505. $domain = \MGModule\DNSManager2\models\whmcs\domains\domain::factory($this->domainId);
  506. if($domain)
  507. {
  508. $name = $domain->domain;
  509. $pos = mb_stripos($name, '.');
  510. $tld = mb_substr($name, $pos);
  511. }
  512. return $tld;
  513. }
  514. public function getPackage()
  515. {
  516. $tldExtension = $this->getTld();
  517. $tld = main\models\whmcs\domains\pricing\domainpricing::getExtensionId($tldExtension); // id
  518. if($tld)
  519. {
  520. $dnsRegistrar = main\models\custom\package\registrar\Repository::factory()
  521. ->byTld($tld)->one();
  522. if($dnsRegistrar)
  523. {
  524. $this->package = new main\models\custom\package\Package($dnsRegistrar->packageid);
  525. }
  526. }
  527. }
  528. public function isPackageActive()
  529. {
  530. if($this->package)
  531. {
  532. if($this->package->status == "1" && $this->checkRegistrar())
  533. {
  534. return true;
  535. }
  536. }
  537. return false;
  538. }
  539. public function checkPackageLimits($newDNSCollection)
  540. {
  541. //if(!$this->isPackageActive())
  542. //{
  543. // main\mgLibs\lang::T('');
  544. //}
  545. $counts = $this->countRecords($newDNSCollection);
  546. $totalLimit = $this->getPackageTotalRecordsLimit();
  547. if((int)$totalLimit < $counts['all'])
  548. {
  549. return main\mgLibs\lang::T('recordLimitExceded');
  550. }
  551. $recordsLimits = $this->getPackageRecordsLimits();
  552. foreach($counts as $rName => $rCount)
  553. {
  554. if($rName == 'all')
  555. {
  556. continue;
  557. }
  558. if((int)$recordsLimits[$rName] < $rCount)
  559. {
  560. return main\mgLibs\lang::T('youCannotAddSpecificRecords')
  561. .' '.$rName.' '.main\mgLibs\lang::T('limitExceded');
  562. }
  563. }
  564. }
  565. public function countRecords($newDNSCollection)
  566. {
  567. $counts = array('all' => 0);
  568. foreach($newDNSCollection as $record)
  569. {
  570. if($record['hostname'] !== '')
  571. {
  572. $counts['all']++;
  573. if($counts[$record['type']])
  574. {
  575. $counts[$record['type']]++;
  576. }
  577. else
  578. {
  579. $counts[$record['type']] = 1;
  580. }
  581. }
  582. }
  583. return $counts;
  584. }
  585. private function getPackageRecordsLimits()
  586. {
  587. $allowedRecords = main\models\custom\package\setting\Repository::factory()
  588. ->byPackageID($this->package->id)
  589. ->byKey(main\models\custom\package\setting\PackageSettingEnum::ALLOWED_RECORD_TYPES)
  590. ->one();
  591. $result = $allowedRecords ? unserialize($allowedRecords->value) : false;
  592. return $result;
  593. }
  594. private function getPackageTotalRecordsLimit()
  595. {
  596. $limit = main\models\custom\package\item\Repository::factory()
  597. ->byPackageID($this->package->id)
  598. ->byType(main\models\custom\package\item\PackageItemTypeEnum::DOMAIN)
  599. ->byRelID($this->domainId)
  600. ->one();
  601. return $limit->limit;
  602. }
  603. public function checkRegistrar()
  604. {
  605. $reg = mysql\query::query("SELECT registrar FROM tbldomains WHERE id = :domainID ",
  606. array('domainID' => $this->domainId))->fetchColumn("registrar");
  607. $path = str_replace( DS.'addons'.DS.'DNSManager2'.DS.'mgLibs'.DS.'custom'.DS.'dns'.DS.'utils',
  608. DS.'registrars'.DS.$reg.DS.$reg.'.php', __DIR__ );
  609. if(file_exists($path))
  610. {
  611. if (!function_exists("getRegistrarConfigOptions")) {
  612. require ROOTDIR . "/includes/registrarfunctions.php";
  613. }
  614. require_once $path;
  615. if(!function_exists($reg.'_GetDNS') && !function_exists($reg.'_SaveDNS'))
  616. {
  617. return true;
  618. }
  619. }
  620. return false;
  621. }
  622. }