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/proc/self/root/scripts.20110531.215904.25158/cpanpingtest
#!/usr/bin/perl
# cpanel - cpanpingtest                           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

BEGIN { unshift @INC, '/usr/local/cpanel'; }

use strict;
use Cpanel::PingTest           ();
use Cpanel::Config::LoadConfig ();

my ( $system, $release, $machine ) = ( Cpanel::OSSys::uname() )[ 0, 2, 4 ];
my $basedir = $> == 0 ? '/home' : ( getpwuid($>) )[7];
my $cpcpandir = "$basedir/.cpcpan/";
my $my_mtime = (stat('/scripts/cpanpingtest'))[9];

$| = 1;

if ( !-e $cpcpandir . 'pingtimes' ) {
    mkdir $cpcpandir, 0700;
    mkdir $cpcpandir . 'pingtimes', 0700;
}

my %URLS;
Cpanel::Config::LoadConfig::loadConfig( $cpcpandir . 'mirrorurls', \%URLS );

my $now           = time();
my $ping_file_ttl = ( 86400 * 20 );
my @HOST_LIST;

foreach my $host ( keys %URLS ) {
    my $ping_file_mtime = ( stat( $cpcpandir . 'pingtimes/' . $host ) )[9];
    if ( $ping_file_mtime && $ping_file_mtime > $my_mtime && ( $ping_file_mtime + $ping_file_ttl ) > $now ) {
        next;
    }
    push @HOST_LIST, $host;

}
if (@HOST_LIST) {
    my $rPINGTIMES = Cpanel::PingTest::pinghosts( \@HOST_LIST, 1 );

    foreach my $host ( keys %URLS ) {
        if ( !exists $rPINGTIMES->{$host} ) { next; }

        if ( open my $pingtime_fh, '>', $cpcpandir . 'pingtimes/' . $host ) {
            print {$pingtime_fh} $rPINGTIMES->{$host};
            close $pingtime_fh;
        }
        else {
            warn "Unable to write ${cpcpandir}pingtimes/$host: $!";
        }
    }
}