CHips L MINI SHELL

CHips L pro

Current Path : /proc/2/root/usr/local/rvglobalsoft/rvglobalsoft/auto/rvsitebuilderinstaller/
Upload File :
Current File : //proc/2/root/usr/local/rvglobalsoft/rvglobalsoft/auto/rvsitebuilderinstaller/fixpearpackage.pl

#!/usr/bin/perl
#################################################
# Detect PHP version to install PEAR MDB2
# PHP >= 5.3.0 pear install --force MDB2-2.5.0b5
# PHP <= 5.2.0 pear install --force MDB2-2.4.1
# PEAR Package Information: MDB2 http://pear.php.net/package/MDB2/download
#################################################
my $cmdphp = whichCmd('php');
$cmdphp =~s/\r|\n//gi;
my $cmdpear = whichCmd('pear');
$cmdpear =~s/\r|\n//gi;

my $phpoption = '-d disable_functions="" -d register_globals="Off"';
my $cmdversion = "$cmdphp -r 'if(version_compare(phpversion(), \"5.3.0\", \">=\")) { echo \"1\"; } else { echo \"0\"; }' $phpoption";
# PHP >= 5.3.0 output = 1
# PHP <= 5.2.0 output = 0
#print $cmdversion . "\n";
$cmdversion = trim($cmdversion);
$isPHP53 = callBackticks($cmdversion);
if ($isPHP53 == 1) {
    my $cmdinstallMDB = "$cmdpear install --force MDB2-2.5.0b5";
    callBackticks($cmdinstallMDB);
    print $cmdinstallMDB . " complete.\n";

} else {
    my $cmdinstallMDB = "$cmdpear install --force MDB2-2.4.1";
    callBackticks($cmdinstallMDB);
    print $cmdinstallMDB . " complete.\n";
}

sub whichCmd{
    my ($cmd) = $_[0];
    return if ($cmd eq '');
    return if ($cmd =~/\//);

    my $whichCmd = '';
    my $binpath = '';
    my @binpathList = (
        '/bin',
        '/usr/bin',
        '/usr/local/bin',
        '/sbin',
        '/usr/sbin',
        '/usr/local/sbin'
    );

        foreach my $path(@binpathList) {
        if ( -x $path . '/' . 'which') {
            $whichCmd = $path . '/' . 'which';
            last;
        }
    }
    if ($whichCmd eq '') {
        print 'which command is not support.';
        return $binpath;
    }

    $binpath = callBackticks("$whichCmd $cmd");
    chomp ($binpath);
    $binpath =~s/\n|\r//gi;

    if ($binpath eq '' || $binpath=~/null/) {
        foreach my $path(@binpathList) {
            if ( -x $path . '/' . $cmd) {
                $binpath = $path . '/' . $cmd;
                last;
            }
        }
    }

    if ($binpath eq '') {
        print $cmd . ' is not support.';

    } elsif (!-x $binpath) {
        print $cmd . ' is not executeable.';
    }

    return $binpath;
}

sub callBackticks{
    my $cmd = join(' ', @_);

    if (-f '.rvsBackticks') {
        system('rm -f .rvsBackticks');
    }

    my ($TestBackticks) = `echo 'RV Test Backticks'`;
    my ($skipBackticks) = 0;
    if ($TestBackticks !~/RV Test Backticks/) {
        $skipBackticks = 1;
    }
    if (-f '.skipBackticks' || $skipBackticks eq 1) {
        system("$cmd > .rvsBackticks 2>&1");
    }
    my ($resuft);
    if (-f '.rvsBackticks') {
        my ($fd);
        open($fd, '<', '.rvsBackticks');
        $resuft = join('',<$fd>);
        close($fd);
        system('rm -f .rvsBackticks');
    } else {
        $resuft = `$cmd 2>&1`;
    }
 
    return $resuft;
}

sub trim {
    my ($value) = shift;
    $value =~ s/^\s+//;
    $value =~ s/\s+$//;
    return $value;
}    

Copyright 2K16 - 2K18 Indonesian Hacker Rulez