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/findphpversion
#!/usr/bin/perl
# cpanel - findphpversion                         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::HttpUtils::Version ();
use Cpanel::SafeRun::Simple    ();
use Cpanel::SafeFile           ();
use Cpanel::Logger             ();

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

my $usebin = 0;
my $phpso;
my $sl = Cpanel::SafeFile::safeopen( \*APC, '/usr/local/apache/conf/httpd.conf' );
if ( !$sl ) {
    $logger->die("Could not read from /usr/local/apache/conf/httpd.conf");
}
while (<APC>) {
    next if (/^#/);
    if (/(libphp\S+)/) {
        $phpso = $1;
        last();
    }
}

my $binphp = '/usr/local/bin/php';    # if it ever becomes so it could be other places use a find function

Cpanel::SafeFile::safeclose( \*APC, $sl );
if ( $phpso !~ /libphp\d+\.so/ && -e $binphp ) {
    $usebin = 1;
}

my $so_dir = Cpanel::HttpUtils::Version::get_current_apache_version_key() eq '1' ? 'libexec' : 'modules';

my ( $phpsosize, $phpsomtime ) = ( stat("/usr/local/apache/$so_dir/$phpso") )[ 7, 9 ];
my ( $phpbinsize, $phpbinmtime ) = ( stat $binphp )[ 7, 9 ];
my ( $phpverfilesize, $phpverfilemtime ) = ( stat('/usr/local/apache/conf/php.version') )[ 7, 9 ];
my $now = time();

if (   $phpverfilesize > 0
    && $phpverfilemtime > ( $phpbinmtime + 86400 )
    && $phpverfilemtime > ( $phpsomtime + 86400 )
    && $phpverfilemtime <= $now ) {
    print "PHP version file is up to date\n";
    exit;
}

my $phpv;
if ($usebin) {
    $phpv = Cpanel::SafeRun::Simple::saferun( $binphp, '-v' );
    $phpv =~ /^PHP[\s\t]+(\S+)/;
    $phpv = $1;
}
else {
    open( my $so_bin_fh, "/usr/local/apache/$so_dir/$phpso" );
    while ( readline($so_bin_fh) ) {
        if (/X-Powered-By:\s*[HP\/]*([\d+\.]*)/) {
            $phpv = $1;
            last;
        }
    }
    close($so_bin_fh);
}
open( my $phpv_fh, '>', '/usr/local/apache/conf/php.version' );
print {$phpv_fh} $phpv;
close($phpv_fh);

print "PHP version file has been updated to $phpv\n";

exec '/usr/local/cpanel/bin/build_global_cache';