CHips L MINI SHELL

CHips L pro

Current Path : /proc/3/task/3/cwd/usr/local/ssl/local/rvglobalsoft/rvglobalsoftmanager/modules/CPHandle/
Upload File :
Current File : //proc/3/task/3/cwd/usr/local/ssl/local/rvglobalsoft/rvglobalsoftmanager/modules/CPHandle/Cpanel.pm

package CPHandle::Cpanel;
#@LICENSE@#
use strict;
use Carp;
#use Data::Dumper;
use File::Basename qw(&basename &dirname);
BEGIN {
    unshift @INC, '/usr/local/cpanel';
}

use Cpanel::Version;
use Cpanel::AcctUtils;
use Cpanel::ContactInfo;
use Cpanel::Reseller;
eval{ use Whostmgr::ACLS; };

use vars qw(@ISA @EXPORT @EXPORT_OK $CONF $OUTPUT $ERROR);
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(
  $OUTPUT $ERROR $CONF 
);
@EXPORT = qw(getPanelVersion getCpToken isRoot isReseller getIPList getMainIPList getAllIPList getPerlVersion getPhpVersion
 getBaseUrl
);
{
	sub new {
        my ($class, $opt) = @_;
        my $self = {};
        bless $self, $class;
        $CONF = $opt->{conf} if (defined $opt->{conf});
        return $self;
    }
    
    *callBackticks = \&RvglobalsoftManager::Rvlibary::callBackticks;
	
	sub getPanelVersion{
		my ($self) = shift;
		my $fileVersion = '/usr/local/cpanel/version';
		my $versionNo = '';
		if(-r $fileVersion){
			$versionNo = join('',RvglobalsoftManager::Rvlibary::parseTextFile($fileVersion));
		}
		chomp($versionNo);
		return $versionNo;
	}
	
	sub getCpToken {
		my ($self) = shift;
		if(defined $ENV{cp_security_token} && $ENV{cp_security_token} ne ''){
			return $ENV{cp_security_token};
		}
		return '';
	}
	
	sub isRoot {
		if(defined $ENV{'REMOTE_USER'} && $ENV{'REMOTE_USER'} eq 'root'){
			return 1;
		}
		return 0;
	}
	
	sub isReseller {
		if(defined $ENV{'REMOTE_USER'} && $ENV{'REMOTE_USER'} ne 'root'){
			return 1;
		}
		return 0;
	}
	
	sub getIPList {
	    my ($self) = shift;
	    return $self->getMainIPList();
#		my ($opt) = $_[0];
#		#TODO หา ip list
#		if (!defined $opt || $opt eq '') {
#			return $self->getMainIPList();
#		} elsif ($opt eq 1) {
#		    #TODO หา all list
#			return $self->getAllIPList();;
#		}
	}
	
	sub getMainIPList {
		my($system, $ethdev,$ips, @IPS);
		$ethdev = '';
		chomp($system = callBackticks("uname -s"));
		if ( -f "/etc/wwwacct.conf") {
			open(CONF,"/etc/wwwacct.conf");
			while(<CONF>) {
				s/\n//g;
				if ($_ !~ /^;/) {
					if ($_ =~ /ETHDEV/) {
						(undef,$ethdev) = split(/ /, $_);
					}
				}   
			}
			close(CONF);
		}
		
		if ($system =~ /freebsd/i || $ethdev eq "") {
			$ips = callBackticks("/sbin/ifconfig -a");
		} else {
			$ips = callBackticks("/sbin/ifconfig $ethdev");
		}
		@IPS = split(/\n/, $ips);
		foreach my $ip (@IPS) {
			if ($ip =~ /(\d*)\.(\d*)\.(\d*).(\d*)/) {
				if ($1 ne "127") {
					return "$1.$2.$3.$4";
				}
			}
		}
		return "0.0.0.0";
	}
	
	sub getAllIPList {
	    my $ifconfigs = callBackticks("/sbin/ifconfig -a");
	    my @IPS = split(/\n/, $ifconfigs);
	    my @allIP = ();
	    foreach my $ip (@IPS) {
	        if ($ip =~ /(\d*)\.(\d*)\.(\d*).(\d*)/) {
	            if ($1 ne "127") {
	                push(@allIP, "$1.$2.$3.$4");
	            }
	        }
	    }
	    
	    return @allIP;
	}
	
	sub getPerlVersion{
        my $perlv = callBackticks("perl -v");
        if ( $perlv =~ /v(\d+\.\d+\.\d+)/ ) {
            return $1;
        } else {
    	   return 'unknown';
        }
    }
    
	sub getPhpVersion{
        my $perlv = callBackticks("php -v");
        if ( $perlv =~ /PHP (\d+\.\d+\.\d+)/ ) {
            return $1;
        } else {
    	   return 'unknown';
        }
    }
    
    sub getBaseUrl {
    	my ($self) = shift;
    	return  getCpToken();
#    	my $serverProtocal = (defined $ENV{HTTPS} && $ENV{HTTPS} eq 'on')?'https':'http';
#    	my $serverName = (defined $ENV{SERVER_NAME} && $ENV{SERVER_NAME} ne '')?$ENV{SERVER_NAME}:$ENV{HTTP_HOST};
#    	my $serverPort = (defined $ENV{SERVER_PORT} && $ENV{SERVER_PORT} ne '80')? ':' . $ENV{SERVER_PORT}:''; 
#    	my $cpToken = getCpToken();
#    	#return $serverProtocal .'://'. $serverName . $serverPort . $cpToken;
    };
    
    sub getHomeDir {
    	if(isRoot()){
    		return getRootDir();
    	}else{
    		return getHomeDirByUser();
    	}
    	return '/var/cpanel/rvglobalsoft';
    }
    
    sub getRootDir {
    	return '/var/cpanel/rvglobalsoft';
    }
    
	sub getAllowReseller {
        if (-f getRootDir() . '/.rvglobalsoft/.allowreseller') {
            return 1;
        } else {
            return 0;   
        }
    }
    
	sub getUsername {
        if (defined $ENV{REMOTE_USER}) {
	    	return $ENV{REMOTE_USER};	
		} elsif (defined $ENV{USERNAME}) {
			return $ENV{USERNAME}
		} else {
			my $username = callBackticks('whoami');
			chomp($username);
			return $username;
		}   
    }
    
	sub getHomeDirByUser {
    	return Cpanel::AcctUtils::gethomedir(getUsername());
    }
}
1;

Copyright 2K16 - 2K18 Indonesian Hacker Rulez