D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
usr
/
src
/
rmw
/
cpanel
/
RemoteMxWizard
/
Filename :
index.live.php
back
Copy
<?php ################################################## # # # GK~root - Creating a better web # # Copyright (c) GK~root. All Rights Reserved. # # Software: Remote Mx Wizard # # Version: 1.0.3 # # Create Date: Jan 07 2015 # # Website: http://www.gk-root.com # # # ################################################## # # # This software is released under a license. # # You cannot transfer it to any other person, # # resell it or claim any code as your own. # # By using the software you agree to this terms. # # # ################################################## require_once("/usr/local/cpanel/php/cpanel.php"); $LiveCpApi = new CPANEL(); require_once("php/cpanel.func.php"); require_once("php/shared.func.php"); include(SetLangFile()); $usertheme = UserTheme(); $cpBase = cpBase($usertheme); if (isset($_GET['step'])) {$gawstep=trim($_GET['step']);} else {$gawstep='';} if ($usertheme === 'paper_lantern' || $usertheme === 'jupiter') { print($LiveCpApi->header('Google Mx Wizard')); print('<link rel="stylesheet" href="css/style.css" media="all" />'); print('<script type="text/javascript" src="js/jquery.min.js"></script>'); // Fix paper_lantern User btn href print('<script type="text/javascript"> $("#lnkHeaderHome").prop("href", "'.$cpBase.'index.html"); $("#lnkQuickHome").prop("href", "'.$cpBase.'index.html"); $("#lnkQuickDomains").prop("href", "'.$cpBase.'addon/index.html"); $("#lnkQuickFilemgr").prop("href", "'.$cpBase.'filemanager/index.html?showhidden=1&dir=/public_html"); $("#lnkQuickEmail").prop("href", "'.$cpBase.'mail/pops.html"); $("#lnkUserPrefChangePwd").prop("href", "'.$cpBase.'passwd/index.html"); $("#lnkUserPrefChangeLang").prop("href", "'.$cpBase.'setlang/index.html"); $("#lnkUserPrefChangeStyle").prop("href", "'.$cpBase.'styleswitcher/index.html"); $("#lnkUserPrefUpdateContactInfo").prop("href", "'.$cpBase.'contact/index.html"); $("#lnkFooterHome").prop("href", "'.$cpBase.'index.html"); $("#lnkFooterTrademark").prop("href", "'.$cpBase.'trademarks.html"); $("#lnkFooterContact").prop("href", "'.$cpBase.'contact/contactinfo.html"); // Tmp fix for header function icon $("#icon-").html(\'<img style="vertical-align: middle;" alt="RMW" src="img/remotemx48.png" /> \'); </script>'); } else { // Fix paper_lantern User btn href print(SetStdHeader()); print('<script type="text/javascript" src="js/jquery.min.js"></script>'); print('<link rel="stylesheet" href="css/style.css" media="all" />'); print('<link rel="stylesheet" href="css/x3_btn.css" media="all" />'); print('<script type="text/javascript">$("#heading-home_off a:first").prop("href", "'.$cpBase.'index.html");</script>'); print('<script type="text/javascript">$("#heading-help_off a:first").prop("href", "'.$cpBase.'help.html?url=/frontend/x3/branding/stdheader.html");</script>'); print('<h1 style="margin:15px" class="plug-title"><img src="img/remotemx-32.png" alt="Google MX Wizard" /> <span>Google MX Wizard<span></h1>'); } $GoBackBtn = '<div class="return-link"><a class="btn btn-default" href="index.live.php">❰ '.$LANG['gobackfirst'].'</a></div>'; print('<div class="body-content">'); if (!empty($_ENV['cp_security_token'])) { //////////////////////// Step 1 //////////////////////// if (empty($gawstep)) { $basedomains = $LiveCpApi->api2('DomainLookup','getbasedomains'); ?> <script type="text/javascript"> function RMWSubmitForm(dropdown){ var domain = dropdown.options[dropdown.selectedIndex].value; if (domain != '_select_') { document.getElementById("RMWSubmitForm").submit(); } } </script> <p class="description" id="descMx"> <?php print($LANG['h2step1']); ?> </p> <div class="section"> <h2 id="hdrDomain"><?php print($LANG['h1step1']); ?></h2> <div class="form-group"> <div class="row"> <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6"> <form method="POST" id="RMWSubmitForm" action="index.live.php?step=step2"> <select name="domain" id="domain" onchange="RMWSubmitForm(this);" class="form-control"> <option value="_select_"><?php print($LANG['selectdomain']); ?>.</option> <?php foreach ($basedomains['cpanelresult']['data'] as $val) { print('<option value="'.$val['domain'].'">'.$val['domain'].'</option>'); } ?> </select> </form> </div> </div> </div> </div> <?php //////////////////////// Step 2 //////////////////////// } elseif ($gawstep == 'step2') { $domain = trim($_POST['domain']); $MxAccept = GetAlwaysAccept($domain); $SetupMxForm = $MxAccept['mxconf']; if ($MxAccept['alwaysaccept'] == "1") { $pagedes = $LANG['step2des1']; $firstnote = ' '.$LANG['step2domnote'].' <b>'.$domain.'</b> '.$LANG['step2domnote1']; } else { $pagedes = $LANG['step2des2']; $firstnote = ' '.$LANG['step2domnote'].' <b>'.$domain.'</b> '.$LANG['step2domnote2']; } if (!$MxAccept['mxconf']) { if (GawMatchConfig($domain)) { $tabs = false; } else { $tabs = true; } } else { $tabs = false; } $MailProviders = GetMailProviders(); ?> <script lang="javascript"> function check1(provider) {return confirm('<?php print($LANG['popup1']); ?>'+provider+'?')} function check2(provider2) {return confirm('<?php print($LANG['popup2']); ?>'+provider2+'?')} $(document).ready(function(){ $("ul#tabs li").click(function(e){ if (!$(this).hasClass("active")) { var tabNum = $(this).index(); var nthChild = tabNum+1; $("ul#tabs li.active").removeClass("active"); $(this).addClass("active"); $("ul#tab li.active").removeClass("active"); $("ul#tab li:nth-child("+nthChild+")").addClass("active"); } }); }); </script> <p class="description" id="descMx"> <?php print($pagedes); ?> </p> <div class="section"> <h2 id="hdrDomain"><?php print($LANG['h1step2']); ?></h2> <div class="alert alert-warning" id="resetSuccess"> <span class="glyphicon glyphicon-exclamation-sign" id="resetSuccessImg"></span> <div class="alert-message" id="resetSuccessMsg"><?php print($firstnote); ?></div> </div> <div class="main-cont"> <?php if ($tabs) { print('<ul id="tabs">'); if (count($MailProviders) > 1) { $i=0; foreach ($MailProviders as $ProviderConf) { if ($ProviderConf['STATUS']) { if ($i==0) {$aClasss = 'class="active"';} else {$aClasss = '';} print('<li '.$aClasss.'>'.$ProviderConf['NAME'].'</li>'); $i++; } } } print('</ul><ul id="tab">'); if (count($MailProviders) > 0) { $i=0; foreach ($MailProviders as $ProviderConfig) { if ($ProviderConfig['STATUS']) { if ($i==0) {$aClass = 'class="active"';} else {$aClass = '';} print('<li '.$aClass.'><h2>'.$ProviderConfig['NAME'].'</h2>'); print('<p>'.$ProviderConfig['DESCRIPTION'].'</p><hr>'); print('<h4 style="color:red;">'.$LANG['note'].'</h4><p>'.$LANG['submitgN0'].'</p><p>'.$LANG['submitgP1'].' '.$ProviderConfig['NAME'].' '.$LANG['submitgP2'].' '.$ProviderConfig['NAME'].' '.$LANG['submitgP3'].'</p><hr>'); print('<form method="POST" action="index.live.php?step=step3">'); print('<input name="token" value="'.cpToken().'" type="hidden">'); print('<input name="domain" value="'.$domain.'" type="hidden">'); print('<input name="provider" value="'.$ProviderConfig['CONFFILENAME'].'" type="hidden">'); if (isset($ProviderConfig['SERVICERS']) && count($ProviderConfig['SERVICERS']) > 0) { $forminputs = ''; foreach ($ProviderConfig['SERVICERS'] as $service) { if ($service[3] == 1) { $forminputs .='<input name="services['.$service[1].']" id="'.$service[1].'" value="'.$service[1].'" type="checkbox"><label style="cursor:default" for="'.$service[1].'"><span></span> - '.$service[1].'.'.$domain.'</label><br>'; } } if (!empty($forminputs)) { print('<h4>'.$LANG['services2h'].'</h4><p>'.$LANG['services2p'].' '.$ProviderConfig['NAME'].':</p>'); print($forminputs); } } print('<br><br><input class="btn btn-primary" value="'.$LANG['submitForm2'].' '.$ProviderConfig['NAME'].'" onclick="return check2(\''.$ProviderConfig['NAME'].'\')" type="submit">'); print('</form>'); print('</li>'); $i++; } } } print('</ul>'); } else { $ProviderConfig = GetMailProviderConf(false,true); print('<h4 style="color:red;">'.$LANG['note'].'</h4><p><p>'.$LANG['submitgN0'].'</p><b>'.$LANG['submitgN1'].' '.$ProviderConfig['NAME'].'.<b></p><hr>'); print('<form method="POST" action="index.live.php?step=remove">'); print('<input name="token" value="'.cpToken().'" type="hidden">'); print('<input name="domain" value="'.$domain.'" type="hidden">'); print('<input name="provider" value="old" type="hidden">'); print('<br><br><input class="btn btn-primary" value="'.$LANG['submitForm1'].' '.$ProviderConfig['NAME'].'" onclick="return check1(\'remote\')" type="submit">'); print('</form>'); } print('</div></div>'.$GoBackBtn); //////////////////////// Step 3 //////////////////////// } elseif ($gawstep == 'step3') { ?> <p class="description" id="descMx"> <?php print($LANG['h2step3']); ?> </p> <div class="section"> <h2 id="hdrDomain"><?php print($LANG['h1step3']); ?></h2> <div class="main-cont"> <?php $token = trim($_POST['token']); if ($token == cpToken()) { $domain = trim($_POST['domain']); $provider = trim($_POST['provider']); $ProviderConf = GetMailProviderConf($provider); if (isset($ProviderConf['BACKUPMX'])) {$BackupMX = $ProviderConf['BACKUPMX'];} else {$BackupMX = '';} $DomainZone = FetchLocalDomainZone($domain); if (SaveProviderConfig($provider)) { print('<p>'.$LANG['spfstep3'].'</p>'); } else { print('<p>'.$LANG['rspfstep3'].'</p>'); } if (isset($ProviderConf['SERVICERS']) && is_array($ProviderConf['SERVICERS'])) { foreach ($ProviderConf['SERVICERS'] as $Service) { $rType = trim($Service[0]); $rName = trim($Service[1]); $rDest = trim($Service[2]); $rOptional = trim($Service[3]); if ($rName == 'mail' && $rOptional == 0 && !empty($DomainZone['mailLine'])) { EditMailLine($domain,$rDest,$DomainZone['mailLine'],$DomainZone['GlobalTTL'],$rName); } elseif ($rName == 'mail' && $rOptional == 1 && !empty($DomainZone['mailLine']) && in_array('mail',$_POST['services'])) { EditMailLine($domain,$rDest,$DomainZone['mailLine'],$DomainZone['GlobalTTL'],$rName); } elseif ($rName == 'webmail' && $rOptional == 0 && !empty($DomainZone['webmailLine'])) { EditMailLine($domain,$rDest,$DomainZone['webmailLine'],$DomainZone['GlobalTTL'],$rName); } elseif ($rName == 'webmail' && $rOptional == 1 && !empty($DomainZone['webmailLine']) && in_array('webmail',$_POST['services'])) { EditMailLine($domain,$rDest,$DomainZone['webmailLine'],$DomainZone['GlobalTTL'],$rName); } elseif ($rName == 'webmail' && $rOptional == 0 && empty($DomainZone['webmailLine'])) { SetProviderServices($domain,$rName,$rDest,$rType,$DomainZone['GlobalTTL']); } if ($rName != 'mail' && $rName != 'webmail' && $rOptional == 1 && in_array($rName,$_POST['services']) || $rName != 'mail' && $rName != 'webmail' && $rOptional == 0) { SetProviderServices($domain,$rName,$rDest,$rType,$DomainZone['GlobalTTL']); } } } if (isset($DomainZone['RspfLine']) && isset($DomainZone['spfOld'])) {RemoveZoneRecord($ProviderConf['NAME'],$domain,'',$DomainZone['RspfLine'],$DomainZone['spfOld']);} SetProviderMXs($ProviderConf['NAME'],$domain,$ProviderConf['MXs'],$DomainZone['oldMxPri'],$ProviderConf['BACKUPMX'],$ProviderConf['SPFR'],$DomainZone['GlobalTTL']); } else { die('Invalid Token!'); } print('</div></div>'.$GoBackBtn); //////////////////////// Remove //////////////////////// } elseif ($gawstep == 'remove') { ?> <p class="description" id="descMx"> <?php print($LANG['h2remove']); ?> </p> <div class="section"> <h2 id="hdrDomain"><?php print($LANG['h1remove']); ?></h2> <div class="main-cont"> <?php $token = trim($_POST['token']); if ($token == cpToken()) { $domain = trim($_POST['domain']); $ProviderConf = GetMailProviderConf(false,true); $DomainZone = FetchLocalDomainZone($domain); if (isset($DomainZone['RspfLine']) && isset($DomainZone['spfOld'])) {RemoveZoneRecord($ProviderConf['NAME'],$domain,'',$DomainZone['RspfLine']);} if (isset($ProviderConf['SERVICERS']) && is_array($ProviderConf['SERVICERS'])) { $DomainZone = FetchLocalDomainZone($domain,$ProviderConf['SERVICERS']); foreach ($DomainZone['services'] as $Service=>$ServiceLine) { if ($Service == 'mail' && !empty($DomainZone['mailLine'])) { EditMailLine($domain,$domain,$DomainZone['mailLine'],$DomainZone['GlobalTTL'],$Service); } elseif ($Service == 'webmail' && !empty($DomainZone['webmailLine'])) { EditMailLine($domain,$DomainZone['serverip'],$DomainZone['webmailLine'],$DomainZone['GlobalTTL'],$Service); } else { RemoveZoneRecord($ProviderConf['NAME'],$domain,$Service,$ServiceLine); } } } RemoveProviderMXs($domain,$DomainZone['GlobalTTL'],$ProviderConf); } else { die('Invalid Token!'); } print('</div></div>'.$GoBackBtn); } } else { print('<h3 class="error_details">'.$LANG['cptokens'].'</h3>'); } print('</div>'); if ($usertheme == 'paper_lantern' || $usertheme == 'jupiter') { print($LiveCpApi->footer()); // Fix paper_lantern footer btn href print('<script type="text/javascript"> $("#lnkFooterHome").prop("href", "'.$cpBase.'index.html"); $("#lnkFooterTrademark").prop("href", "'.$cpBase.'trademarks.html"); $("#lnkFooterContact").prop("href", "'.$cpBase.'contact/contactinfo.html"); </script>'); } else { print(SetStdFooter()); // Fix x3 footer btn href print('<script type="text/javascript"> $( "ul.footer_ul" ).html(\'<li class="footer_li"><a class="footer_li_a bottomlink" href="'.$cpBase.'index.html">Home</a></li><li class="footer_li"><span class="footer" style="font-size:18px;">▪</span></li><li class="footer_li"><a class="footer_li_a" href="'.$cpBase.'trademarks.html" target="_blank">Trademarks</a></li><li class="footer_li"><span class="footer" style="font-size:18px;">▪</span></li><li class="footer_li"><a onclick="show_help(); return false;" target="_blank" href="'.$cpBase.'help.html?url=/frontend/x3/branding/stdfooter.html" class="bottomlink footer_li_a">Help</a></li><li class="footer_li"><span style="font-size:18px;">▪</span></li><li class="footer_li"><a href="http://go.cpanel.net/documentationcpanel?build=11.46.0.9&basetheme=x3&theme=x3" target="_blank" class="bottomlink footer_li_a">Documentation</a></li><li class="footer_li"><span style="font-size:18px;">▪</span></li><li class="footer_li"><a href="'.$cpBase.'contact/contactinfo.html" class="bottomlink footer_li_a" target="_blank">Contact</a></li><li class="footer_li"><span style="font-size:18px;">▪</span></li><li class="footer_li"><a href="/logout/?locale=en" class="bottomlink footer_li_a">Log Out</a></li>\'); </script>'); } ?>