MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //proc/self/root/scripts.20110531.215904.25158/cPpkgversions.pm
package cPpkgversions;

# cpanel - cPpkgversions.pm                       Copyright(c) 2010 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

use strict;
use Cpanel::HttpRequest ();
use Cpanel::Config      ();

my $cPhttpClient = Cpanel::HttpRequest->new( 'hideOutput' => 0 );

sub getpkgversioninfo {
    my ($pv) = @_;
    my $tree = gettree();

    my $vif;
    print "Fetching version information from http://httpupdate.cpanel.net/${pv}install/version ($tree)....";
    eval {
        local $SIG{'ALRM'} = sub { die 'Timeout while fetching version information'; };
        alarm 45;
        $vif = $cPhttpClient->request(
            'host'     => 'httpupdate.cpanel.net',
            'url'      => '/' . $pv . 'install/version',
            'protocol' => 0,
        );
    };
    alarm 0;
    if ( $@ && $@ =~ m{ Timeout }xms ) {    # Retry
        sleep 2;
        eval {
            local $SIG{'ALRM'} = sub { die 'Timeout while fetching version information'; };
            alarm 45;
            $vif = $cPhttpClient->request(
                'host'     => 'httpupdate.cpanel.net',
                'url'      => '/' . $pv . 'install/version',
                'protocol' => 0,
            );
        };
        alarm 0;
    }

    if ( !$vif ) {
        die "Unable to retrieve version info: $!";
    }

    my @VERINFO = split( /\n/, $vif );

    my %VINFO;
    foreach my $vinfo (@VERINFO) {
        next if !$vinfo;
        chomp $vinfo;
        my ( $trees, $pkg, $version, $release, $flags, $pkgs ) = split( /:/, $vinfo );
        my @TREES = split( /\,/, $trees );
        foreach my $testtree (@TREES) {
            if ( $testtree eq $tree ) {
                $VINFO{$pkg}{'version'} = $version;
                $VINFO{$pkg}{'release'} = $release;
                $VINFO{$pkg}{'flags'}   = $flags;
                $VINFO{$pkg}{'pkgs'}    = $pkgs;
            }
        }
    }
    print "Done\n";

    return wantarray ? %VINFO : \%VINFO;
}

sub gettree {
    if ( -e '/var/cpanel/dnsonly' ) {
        return 'DNSONLY';
    }
    if ( !-e '/etc/cpupdate.conf' ) {
        return 'RELEASE';
    }

    my $upconf_ref = Cpanel::Config::loadConfig('/etc/cpupdate.conf');

    if ( !defined $upconf_ref || !exists $upconf_ref->{'CPANEL'} ) {
        return 'RELEASE';
    }
    else {
        if (   $upconf_ref->{'CPANEL'} eq 'stable'
            || $upconf_ref->{'CPANEL'} eq 'manual' ) {
            return 'STABLE';
        }
        elsif ($upconf_ref->{'CPANEL'} eq 'manual-edge'
            || $upconf_ref->{'CPANEL'} =~ /demo/i
            || $upconf_ref->{'CPANEL'} eq 'edge' ) {
            return 'EDGE';
        }
        elsif ($upconf_ref->{'CPANEL'} eq 'manual-current'
            || $upconf_ref->{'CPANEL'} eq 'current' ) {
            return 'CURRENT';
        }
        elsif ($upconf_ref->{'CPANEL'} eq 'manual-dnsonly'
            || $upconf_ref->{'CPANEL'} eq 'dnsonly' ) {
            return 'DNSONLY';
        }
        elsif ($upconf_ref->{'CPANEL'} =~ /^\d+$/
            || $upconf_ref->{'CPANEL'} =~ /nightly/i
            || $upconf_ref->{'CPANEL'} eq 'manual-beta'
            || $upconf_ref->{'CPANEL'} eq 'beta' ) {
            return 'BETA';
        }
        else {
            return 'RELEASE';
        }
    }
    return 'RELEASE';
}

1;