#!/bin/sh
eval 'if [ -x /usr/local/cpanel/3rdparty/bin/perl ]; then exec /usr/local/cpanel/3rdparty/bin/perl -x -- $0 ${1+"$@"}; else exec /usr/bin/perl -x $0 ${1+"$@"}; fi;'
if 0;
package RVL::CpHandle::cPanel;
# WebSite: http://www.rvglobalsoft.com
# Unauthorized copying is strictly forbidden and may result in severe legal action.
# Copyright (c) 2013 RV Global Soft Co.,Ltd. All rights reserved.
#
# =====YOU MUST KEEP THIS COPYRIGHTS NOTICE INTACT AND CAN NOT BE REMOVE =======
# Copyright (c) 2013 RV Global Soft Co.,Ltd. All rights reserved.
# This Agreement is a legal contract, which specifies the terms of the license
# and warranty limitation between you and RV Global Soft Co.,Ltd. and RV2Factor Product for RV Global Soft.
# You should carefully read the following terms and conditions before
# installing or using this software. Unless you have a different license
# agreement obtained from RV Global Soft Co.,Ltd., installation or use of this software
# indicates your acceptance of the license and warranty limitation terms
# contained in this Agreement. If you do not agree to the terms of this
# Agreement, promptly delete and destroy all copies of the Software.
#
# ===== Grant of License =======
# The Software may only be installed and used on a single host machine.
#
# ===== Disclaimer of Warranty =======
# THIS SOFTWARE AND ACCOMPANYING DOCUMENTATION ARE PROVIDED "AS IS" AND
# WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER
# WARRANTIES WHETHER EXPRESSED OR IMPLIED. BECAUSE OF THE VARIOUS HARDWARE
# AND SOFTWARE ENVIRONMENTS INTO WHICH RV SITE BUILDER MAY BE USED, NO WARRANTY OF
# FITNESS FOR A PARTICULAR PURPOSE IS OFFERED. THE USER MUST ASSUME THE
# ENTIRE RISK OF USING THIS PROGRAM. ANY LIABILITY OF RV GLOBAL SOFT CO.,LTD. WILL BE
# LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE.
# IN NO CASE SHALL RV GLOBAL SOFT CO.,LTD. BE LIABLE FOR ANY INCIDENTAL, SPECIAL OR
# CONSEQUENTIAL DAMAGES OR LOSS, INCLUDING, WITHOUT LIMITATION, LOST PROFITS
# OR THE INABILITY TO USE EQUIPMENT OR ACCESS DATA, WHETHER SUCH DAMAGES ARE
# BASED UPON A BREACH OF EXPRESS OR IMPLIED WARRANTIES, BREACH OF CONTRACT,
# NEGLIGENCE, STRICT TORT, OR ANY OTHER LEGAL THEORY. THIS IS TRUE EVEN IF
# RV GLOBAL SOFT CO.,LTD. IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN NO CASE WILL
# RV GLOBAL SOFT CO.,LTD.'S LIABILITY EXCEED THE AMOUNT OF THE LICENSE FEE ACTUALLY PAID
# BY LICENSEE TO RV GLOBAL SOFT CO.,LTD.
# ===============================
use strict;
use warnings;
use base qw(RVL::CpHandle);
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 Class::Std::Utils;
{
sub new {
my ($class) = @_;
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
my ($this) = $class->SUPER::new();
return $this;
}
sub factory {
my ($class, $opt) = @_;
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
my ($cpPrivilege) = ucfirst(lc(RVL::CpHandle::cPanel::_getPrivilege()));
RVL::logMessage('CALL PRIVILEGE: ' . $cpPrivilege, __CONSTANT__::RVL_LOG_DEBUG);
my ($callClass, $newClass);
eval {
require "RVL/CpHandle/cPanel/$cpPrivilege.pm";
};
if ($@) {
RVL::logMessage("RVL::CpHandle::cPanel::$cpPrivilege has ERROR: " . $@, __CONSTANT__::RVL_LOG_DEBUG);
}
my ($req) = RVL::Request::singleton();
my ($moduleName) = $req->getModuleName();
my ($customFile) = __CONSTANT__::RVL_MOD_DIR . "/$moduleName/classes/CpHandle/cPanel/$cpPrivilege.pm";
if (-f $customFile) {
require $customFile;
$callClass = "Custom::CpHandle::cPanel::$cpPrivilege";
} else {
$callClass = "RVL::CpHandle::cPanel::$cpPrivilege";
}
RVL::logMessage('CALL PACKAGE: ' . $callClass, __CONSTANT__::RVL_LOG_DEBUG);
$newClass = $callClass->new();
$newClass->setCpPrivilege($cpPrivilege);
return $newClass;
}
sub _getPrivilege {
my ($this) = @_;
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
my ($priv) = 'user';
my ($oCli) = RVL::Request::singleton();
if($oCli->getRequestType() eq 'Cli'){
if(defined $ENV{'USER'} && $ENV{'USER'} ne ''){
$priv = $ENV{'USER'};
} elsif (defined $ENV{'REMOTE_USER'} && $ENV{'REMOTE_USER'} ne '') {
$priv = $ENV{'REMOTE_USER'};
} else {
my $call = new RVL::CpHandle;
$priv = $call->callBackticks('whoami');
chomp($priv);
if($priv ne 'root'){
$priv = 'reseller';
}
}
} else {
if ($ENV{'SERVER_PORT'} eq '2086' || $ENV{'SERVER_PORT'} eq '2087') {
eval {
Whostmgr::ACLS::init_acls();
#ยังไม่ได้เทสในฝั่ง 3rdparty
if (Whostmgr::ACLS::hasroot() && $ENV{'REMOTE_USER'} eq 'root') {
$priv = 'root';
} elsif (Cpanel::Reseller::isreseller($ENV{'REMOTE_USER'}) && $ENV{'REMOTE_USER'} ne 'root') {
$priv = 'reseller';
}
};
}else{
$priv = 'user';
}
}
RVL::logMessage("Privilege is: $priv", __CONSTANT__::RVL_LOG_DEBUG);
return $priv;
}
sub getRootDir {
my ($this, $user) = @_;
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
return "/var/cpanel/rvglobalsoft";
}
sub getVersion {
my ($this) = @_;
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
return Cpanel::Version::get_version_full();
}
sub getApiUrl {
my ($this) = @_;
# apiservice.url
my ($confUrl) = RVL::Config::get('apiservice.url');
my ($usageUrl) = (defined $confUrl && $confUrl ne '')
? $confUrl
: 'http://api.rvglobalsoft.com';
if ($this->isUser()) {
return $usageUrl .'/usercp';
} else {
return $usageUrl .'/admincp';
}
}
sub getFrontScriptName{
my ($this) = @_;
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
if ($this->isUser()) {
return $ENV{cp_security_token};
} else {
return $ENV{cp_security_token} . '/cgi/rvglobalsoftmanager/index.cgi?action=apimanager';
}
}
sub redirectUrl{
my ($this) = @_;
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
my $urlRedirect;
if ($this->isUser()) {
$urlRedirect = $ENV{cp_security_token} . '';
} else {
$urlRedirect = $ENV{cp_security_token} . '/cgi/rvglobalsoftmanager/index.cgi?action=apimanager';
}
my (@header) = ();
@header = (
-X_Powered_By => 'RV Framework http://www.rvglobalsoft.com',
-location => $urlRedirect,
);
my ($obj) = RVL::Output::singleton();
foreach my $listOutput ($obj->getHeader()) {
push(@header, $listOutput);
}
print RVL::Session::singleton()->header(@header);
RVL::Session::singleton()->flush();
exit;
}
} use implements "RVL::CpHandle::CPModeInterface";
1;
__END__;
Copyright 2K16 - 2K18 Indonesian Hacker Rulez