#!/use/bin/perl
package RVL::CpHandle::NoCp;
# 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);
use Class::Std::Utils;
{
sub new {
my ($class) = @_;
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
my ($this) = $class->SUPER::new();
$this->{'_NOCPDATA'} = {};
my ($nocpConfig) = __CONSTANT__::RVL_VAR_DIR . '/NoCpData.yaml';
if (-f $nocpConfig) {
my ($oConf) = RVL::Config->new({file => $nocpConfig});
my ($config) = $oConf->getAll();
$this->{'_NOCPDATA'} = $config;
}
return $this;
}
sub factory {
my ($class, $opt) = @_;
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
my ($cpPrivilege) = ucfirst(lc(RVL::CpHandle::NoCp::_getPrivilege()));
my ($callClass, $newClass);
require "RVL/CpHandle/NoCp/$cpPrivilege.pm";
my ($req) = RVL::Request::singleton();
my ($moduleName) = $req->getModuleName();
my ($customFile) = __CONSTANT__::RVL_MOD_DIR . "/$moduleName/classes/CpHandle/NoCp/$cpPrivilege.pm";
if (-f $customFile) {
require $customFile;
$callClass = "Custom::CpHandle::NoCp::$cpPrivilege";
} else {
$callClass = "RVL::CpHandle::NoCp::$cpPrivilege";
}
$newClass = $callClass->new();
$newClass->setCpPrivilege($cpPrivilege);
return $newClass;
}
sub _getPrivilege {
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
my ($nocpConfig) = __CONSTANT__::RVL_VAR_DIR . '/NoCpData.yaml';
if (-f $nocpConfig) {
my ($oConf) = RVL::Config->new({file => $nocpConfig});
my ($config) = $oConf->getAll();
if (defined $config->{'UserName'}
&& defined $config->{'UserConf'}->{ $config->{'UserName'} }) {
return $config->{'UserConf'}->{ $config->{'UserName'} }->{'rold'};
}
}
return 'root';
}
sub getVersion{
my ($this) = @_;
return return (defined $this->{'_NOCPDATA'}->{'CPVERSION'})
? $this->{'_NOCPDATA'}->{'CPVERSION'}
: '-' ;
}
sub getHostname{
return RVL::Config::getRealHostname();
}
=head3 getRootDir
Get root dir
return <string> home dir
=cut
sub getRootDir {
my ($this) = shift;
return (defined $this->{'_NOCPDATA'}->{'UserConf'}->{'root'}->{'homedir'})
? $this->{'_NOCPDATA'}->{'UserConf'}->{'root'}->{'homedir'}
: '/home';
}
sub getFrontScriptName{
my ($this) = @_;
RVL::logMessage('', __CONSTANT__::RVL_LOG_DEBUG);
return '';
}
sub redirectUrl{
my ($this) = @_;
my ($this) = @_;
my ($error) = '';
foreach (@{$RVL::GLOBALS{'_RVL'}{'ERRORS'}}) {
$error .= $error . "Error: Package: $_->{'code'} - $_->{'message'}<br />";
}
RVL::Session::remove('message');
RVL::Session::remove('messageType');
if ($error ne '') {
RVL::fatalErrors("Error!! <hr />$error");
}
exit;
}
sub getApiUrl {
my ($this) = @_;
# apiservice.url
my ($confUrl) = RVL::Config::get('apiservice.url');
my ($usageUrl) = (defined $this->{'_NOCPDATA'}->{'SiteConf'}->{'api'}->{'url'})
? $this->{'_NOCPDATA'}->{'SiteConf'}->{'api'}->{'url'}
: $confUrl;
if ($this->isUser()) {
return $usageUrl .'/usercp';
} else {
return $usageUrl .'/admincp';
}
}
} use implements "RVL::CpHandle::CPModeInterface";
1;
__END__;
Copyright 2K16 - 2K18 Indonesian Hacker Rulez