| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- namespace MGModule\DNSManager2\mgLibs\custom\helpers;
- use \MGModule\DNSManager2 as main;
- class RegistrarDNSHelper
- {
- /**
- * This function is used to enable DNS Mamagement section in client area section
- * @return type
- */
- public static function prepareRegisrtrar()
- {
- //if we are not in domain details or in available actions function needs to be terminated
- if(!self::paresUrl())
- {
- return;
- }
- //when in "general option" section Domain ID needs to be taken from $_GET['id']
- $domainId = (int)$_GET['id'];
- if(empty($domainId))
- {
- //when showing DNS Records Domain ID needs to be taken from $_GET['domainid']
- $domainId = (int)$_GET['domainid'];
- }
- //when "save DNS" action is called Domain ID needs to be taken from $_POST['domainid']
- if(empty($domainId))
- {
- $domainId = (int)$_POST['domainid'];
- }
-
- if(empty($domainId))
- {
- return;
- }
- try
- {
- main\addon::I(true);
- $registrarHelper = new main\mgLibs\custom\dns\utils\CustomDnsRegistrarHelper($domainId);
- if(!$registrarHelper->isPackageActive())
- {
- return;
- }
- $file = $registrarHelper->creatreFunctionsFile(str_replace(
- DS.'mgLibs'.DS.'custom'.DS.'helpers','', realpath(dirname(__FILE__))));
- if(!file_exists($file))
- {
- throw new \Exception(
- $file.' '.
- main\mgLibs\lang::T('not found').'.'
- );
- }
- require_once($file);
- }
- catch(Exception $ex)
- {
- main\addon::dump($ex);
- logModuleCall(
- 'DNS Manager', __FUNCTION__, $ex->getMessage(), $ex->getMessage(), $ex->getTraceAsString()
- );
- }
- }
-
- /**
- * Function is used to parse URL address and detect if user is in avaialbe action section<Br />
- * What daoe it mean means it allow to run run action only when Domain ID is avaialble
- */
- public static function paresUrl()
- {
- $availableActions = array(
- 'domaindetails',
- 'domaindns'
- );
- global $CONFIG;
- $host = parse_url($CONFIG['SystemURL'])['host'];
- $url = "http" . (($_SERVER['SERVER_PORT'] == 443) ? "s://" : "://") . $host . $_SERVER['REQUEST_URI'];
- $urlDetails = parse_url($url);
- foreach ($urlDetails as $key)
- {
- foreach ($availableActions as $action)
- {
- preg_match("/$action/", $key, $match);
- if (isset($match[0]))
- {
- return true;
- }
- }
- }
- return false;
- }
- }
|