Last active
May 17, 2016 20:12
-
-
Save tssge/743f1dc71a1c92c9a5cc949ebcb0065d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function teamspeakwhmcs_ForwardDomain($params) | |
| { | |
| global $_LANG; | |
| try | |
| { | |
| if(!include_once(ROOTDIR . "/modules/addons/DNSManager2/loader.php")) | |
| throw new Exception("Inclusion of critical file failed."); | |
| $loader = new MGModule\DNSManager2\loader; | |
| if(!include_once(ROOTDIR . "/modules/addons/DNSManager2/DNSManager2.php")) | |
| throw new Exception("Inclusion of critical file failed."); | |
| MGModule\DNSManager2\addon::I(false, $params); | |
| if(isset($_REQUEST['group'])) | |
| { | |
| $result = MGModule\DNSManager2\addon::I()->getJSONClientAreaPage(array( | |
| "m" => "DNSManager2", | |
| "json" => 1, | |
| "mg-page" => "dashboard", | |
| "zone_id" => explode("|", $_REQUEST['group'])[1], | |
| "name" => "_ts3server._udp", | |
| "ip_from_block" => "", | |
| "type" => "SRV", | |
| "ttl" => 14400, | |
| "field" => array( | |
| "priority" => 0, | |
| "weight" => $params['domain'], | |
| "port" => 9999, | |
| "target" => 'ts3server.' . explode("|", $_REQUEST['group'])[0], | |
| ), | |
| "mg-action" => "addRecordSave" | |
| )); | |
| $retval = str_replace("#ENDJSONRESPONSE", "", str_replace("JSONRESPONSE#", "", $result)); | |
| if($json = json_decode($retval, true)) | |
| { | |
| if(count($json['data']['errors']) > 0) | |
| throw new Exception("Error encountered creating SRV record."); | |
| } | |
| else | |
| { | |
| throw new Exception("Unable to decode SRV record retval."); | |
| } | |
| $result = MGModule\DNSManager2\addon::I()->getJSONClientAreaPage(array( | |
| "m" => "DNSManager2", | |
| "json" => 1, | |
| "mg-page" => "dashboard", | |
| "zone_id" => explode("|", $_REQUEST['group'])[1], | |
| "name" => "ts3server", | |
| "ip_from_block" => "", | |
| "type" => "A", | |
| "ttl" => 14400, | |
| "field" => array( | |
| "address" => "127.0.0.1", | |
| ), | |
| "mg-action" => "addRecordSave" | |
| )); | |
| $retval = str_replace("#ENDJSONRESPONSE", "", str_replace("JSONRESPONSE#", "", $result)); | |
| if($json = json_decode($retval, true)) | |
| { | |
| if(count($json['data']['errors']) > 0) | |
| throw new Exception("Error encountered creating A record."); | |
| } | |
| else | |
| { | |
| throw new Exception("Unable to decode A record retval."); | |
| } | |
| } | |
| $clientarea = DNSManager2_clientarea(); | |
| $dashboard = new MGModule\DNSManager2\controllers\addon\clientarea\dashboard($_REQUEST); | |
| foreach($dashboard->indexHTML($_REQUEST, $params)['vars']['groups'] AS $group) | |
| { | |
| foreach($group AS $zone) | |
| { | |
| if(!empty($zone['zone_name']) && !empty($zone['zone_status']) && $zone['zone_status'] == 1 ) | |
| { | |
| $output[] = array( | |
| "id" => $zone['zone_name'] . "|" . $zone['zone_id'], | |
| "name" => $zone['zone_name'], | |
| ); | |
| } | |
| } | |
| } | |
| return array( | |
| 'templatefile' => 'templates/forwarddomain', | |
| 'breadcrumb' => array( | |
| 'stepurl.php?action=this&var=that' => $_LANG['forward_domain_to_product'], | |
| ), | |
| 'vars' => array( | |
| 'displayTitle' => $_LANG['forward_domain_to_product'], | |
| 'tagline' => $_LANG['make_it_easier_to_connect_to_product'], | |
| 'servergroups' => $output, | |
| ), | |
| ); | |
| } | |
| catch(Exception $e) | |
| { | |
| logModuleCall( | |
| 'teamspeakwhmcs', | |
| __FUNCTION__, | |
| $params, | |
| $e->getMessage(), | |
| $e->getTraceAsString() | |
| ); | |
| return array( | |
| 'templatefile' => 'templates/error', | |
| 'breadcrumb' => array( | |
| 'stepurl.php?action=this&var=that' => $_LANG['teamspeakwhmcs_generateprivilegekey'], | |
| ), | |
| 'vars' => array( | |
| 'error' => $e->getMessage() | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment