#!/use/bin/perl
package RVL::CpHandle::NoCp;
##LICENSE##
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