package CPHandle;
##LICENSE##
use strict;
use Carp;
use warnings;
use Cwd;
use Cwd 'realpath';
use File::Basename qw(&basename &dirname);
use Data::Dumper;
use File::Basename;
use lib dirname(realpath(__FILE__));
use lib dirname(realpath(__FILE__)).'/lib';
use lib dirname(realpath(__FILE__)).'/modules';
use lib dirname(realpath(__FILE__)).'/modules/CPHandle';
use vars qw(@ISA @EXPORT_OK $CONF);
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(
$OUTPUT $ERROR $CONF $VERSIONCACHE
);
{
sub new {
my ($class, $opt) = @_;
my $CPMODE = getControlPanelMode();
my $fileCPHandle = dirname(realpath(__FILE__)) . '/CPHandle/';
my $PACKAGE = '';
if ($CPMODE eq "Cpanel") {
$fileCPHandle .= "Cpanel.pm";
$PACKAGE = "CPHandle::Cpanel";
} elsif ($CPMODE eq "Plesk") {
$fileCPHandle .= "Plesk.pm";
$PACKAGE = "CPHandle::Plesk";
} elsif ($CPMODE eq "Directadmin") {
$fileCPHandle .= "Directadmin.pm";
$PACKAGE = "CPHandle::Directadmin";
} elsif ($CPMODE eq "Nocp") {
$fileCPHandle .= "Nocp.pm";
$PACKAGE = "CPHandle::Nocp";
}
if (-f $fileCPHandle) {
}
my ($code) = 'require \'' .$fileCPHandle . '\'; $CONF->{\'CPHandle\'} = CPHandle::' . $CPMODE . '->new({conf => $CONF});';
eval $code;
return $PACKAGE;
}
sub getControlPanelMode {
my ($self) = shift;
my $controlPanelName = '';
if ((defined $ENV{'CPANEL'} && $ENV{'CPANEL'} eq 'active') || (-e "/usr/local/cpanel/cpkeyclt")) {
$controlPanelName = 'Cpanel';
}elsif ((defined $ENV{'SERVER_SOFTWARE'} && $ENV{'SERVER_SOFTWARE'} eq 'sw-cp-server') || (-e '/etc/sw/keys/registry.xml')) {
$controlPanelName = 'Plesk';
} else {
$controlPanelName = 'NoCp';
}
return $controlPanelName;
}
sub getControlPanelName {
my ($self) = shift;
my $controlPanelMode = getControlPanelMode();
my $controlPanelName = '';
if ($controlPanelMode eq 'Cpanel') {
$controlPanelName = 'Cpanel';
}elsif ($controlPanelMode eq 'Plesk') {
$controlPanelName = 'Plesk';
}elsif ($controlPanelMode eq 'DirectAdmin') {
$controlPanelName = 'DirectAdmin';
}elsif ($controlPanelMode eq 'NoCp') {
$controlPanelName = 'NoCp';
}
return $controlPanelName;
}
}
1;
Copyright 2K16 - 2K18 Indonesian Hacker Rulez