CHips L MINI SHELL

CHips L pro

Current Path : /proc/self/root/proc/2/root/usr/local/rvglobalsoft/rvglobalsoft/lib/RVL/
Upload File :
Current File : //proc/self/root/proc/2/root/usr/local/rvglobalsoft/rvglobalsoft/lib/RVL/CpHandle.pm

package RVL::CpHandle;
##LICENSE##
use strict;
use warnings;

use Class::Std::Utils;
{
    sub new {
        my ($class) = @_;
        my (%hash);
        my ($this) = bless( \%hash, $class);
        RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
        return $this;
    }
    
    sub factory {
        my ($this, $mode, $opt) = @_;

        my ($cpMode) = (defined $mode) ? $mode : RVL::CpHandle::_getCpMode();
        RVL::logMessage('CALL CPMODE: ' . $cpMode, __CONSTANT__::RVL_LOG_DEBUG);
        
        my ($newClass, $callClass);
        
        require "RVL/CpHandle/$cpMode.pm";
        my ($req) = RVL::Request::singleton();
        my ($moduleName) = $req->getModuleName();
        my ($customHandle) = __CONSTANT__::RVL_MOD_DIR . "/$moduleName/classes/CpHandle/$cpMode.pm";
        if (-f $customHandle) {
        	RVL::logMessage("Usage: $customHandle", __CONSTANT__::RVL_LOG_DEBUG);
            require $customHandle;
            $callClass = "Custom::CpHandle::" . $cpMode . "::factory";
        } else {
        	RVL::logMessage("Usage: RVL::CpHandle::" . $cpMode . "::factory", __CONSTANT__::RVL_LOG_DEBUG);
           $callClass = "RVL::CpHandle::" . $cpMode . "::factory";
        }

        eval("\$newClass = $callClass();");
        if ($@) {
        	RVL::logMessage("Eval has error!!" . $@, __CONSTANT__::RVL_LOG_DEBUG);
        	RVL::print_r($@); exit;
        }
        # $newClass = $callClass->new();
        
        $newClass->setCpMode($cpMode);
        return $newClass;
    }
    
    sub singleton {
        my ($class) = __PACKAGE__;

        if (!defined $RVL::INSTANCE{$class}) {
            $RVL::INSTANCE{$class} = $class->factory();
        }
        return $RVL::INSTANCE{$class}
    }
    
    sub _getCpMode {
        my ($this) = @_;

        if ((defined $ENV{'CPANEL'} && $ENV{'CPANEL'} eq 'active') || (-e "/usr/local/cpanel/cpkeyclt")) {
            return 'cPanel';
        }elsif ((defined $ENV{'SERVER_SOFTWARE'} && $ENV{'SERVER_SOFTWARE'} eq 'sw-cp-server') || (-e '/etc/sw/keys/registry.xml')) {
            return 'Plesk';
        } else {
            return 'NoCp';   
        }
        
    }
    
    sub getVersion {
    	
    }
    
    sub getHostname
    {
        my ($this) = @_;
        my ($hostname);
        $hostname = $this->callBackticks('hostname');
        return $hostname;
    }
    
    sub setCpMode
    {
        my ($this, $mode) = @_;

        $this->{CPMODE} = $mode;
    }
    
    sub getCpMode
    {
        my ($this) = @_;

        return $this->{CPMODE};
    }
    
    sub setCpPrivilege
    {
        my ($this, $privilege) = @_;

        $this->{CPPRIVILEGE} = $privilege;
    }
    
    sub getCpPrivilege
    {
        my ($this) = @_;
        return $this->{CPPRIVILEGE};
    }
    
    
    sub isRoot {
    	my ($this) = @_;

        if (lc($this->{CPPRIVILEGE}) eq 'root') {
        	return 1;
        } else {
        	return 0;
        }
        
    }
    
    sub isReseller {
    	my ($this) = @_;

        if (lc($this->{CPPRIVILEGE}) eq 'reseller') {
        	return 1;
        } else {
        	return 0;
        }
        
    }
    
    sub isUser {
    	my ($this) = @_;

        if (lc($this->{CPPRIVILEGE}) eq 'user') {
        	return 1;
        } else {
        	return 0;
        }
        
    }
    
    sub getRVGOwner {
        my ($this) = @_;
        my ($ownerDir) = $this->getOwnerDir();
        my ($ownername);
        if (-f $ownerDir . '/.rvglobalsoft/authorizeid.pub') {
            open(FD, '<', $ownerDir . '/.rvglobalsoft/authorizeid.pub');
            $ownername = join('', <FD>);
            close(FD);
            chomp $ownername;
        }
        return $ownername;
    }
    
   sub callBackticks{
   	    my ($this) = shift;
        my $cmd = join(' ', @_);
        if (-f '/tmp/.rvsBackticks') {
            system('rm -f /tmp/.rvsBackticks');
        }

        my ($TestBackticks) = `echo 'RV Test Backticks'`;

        my ($skipBackticks) = 0;
        if ($TestBackticks !~/RV Test Backticks/) {
            $skipBackticks = 1;
        }

        my ($resuft);
        if (-f '/tmp/.rvsBackticks' || $skipBackticks eq 1) {
            system("$cmd > /tmp/.rvsBackticks 2>&1");
            open(my $fd, '<', '/tmp/.rvsBackticks');
            $resuft = join('',<$fd>);
            close($fd);
            system('rm -f /tmp/.rvsBackticks');
        } else {
            $resuft = `$cmd 2>&1`;
        }
        RVL::logMessage('Resuft Command "' . $cmd . '": ' . $resuft, __CONSTANT__::RVL_LOG_DEBUG);
        return $resuft;
    }
}
1;

__END__;

Copyright 2K16 - 2K18 Indonesian Hacker Rulez