CHips L MINI SHELL

CHips L pro

Current Path : /proc/self/root/proc/2/root/usr/local/rvglobalsoft/rvglobalsoft/lib/
Upload File :
Current File : //proc/self/root/proc/2/root/usr/local/rvglobalsoft/rvglobalsoft/lib/RVL.pm

#!/usr/bin/perl
package RVL;
##LICENSE##
BEGIN {
	my (@INC_OLD) = reverse @INC;
}

use strict;
use warnings;
use RVL::Constants;
use RVL::Logger;
use RVL::FrontController;
use RVL::Config;
use RVL::String;
use RVL::Manager;
use RVL::Error;
use RVL::Request;
use RVL::Session;
use RVL::Translation;
use RVL::System;
use RVL::LicenseCycle;
use File::Basename qw(&basename &dirname);
use Data::Dumper qw(Dumper);
#use Smart::Comments '###', '####';
# $instance
use vars qw ($INSTANCE %CONSTANTS %GLOBALS $NoLog);

=head1 NAME
    RVL - RV Library Modules
=head1 SYNOPSIS

=head DESCRIPTION

=cut
use Class::Std::Utils;
{
    
=item RV::print_r( LIST )
    Prints human-readable information about a variable
=cut
    sub print_r {
        my ($oCli) = RVL::Request::singleton();
        if ($oCli->getRequestType() eq 'Browser') {
            my (@header) = (
                -type => 'text/html; charset=' . getCurrentCharset(),
                -X_Powered_By => 'RV Framework http://www.rvglobalsoft.com',
            );
            print RVL::Session::singleton()->header(@header);
        }
        print '<pre>';
        print Dumper(@_);
        print '</pre>';
    }

=item RV::debug( LIST )
    Develop debug usage Smart::Comments for debug
=cut
    sub debug {
        my (@message) = @_;
        my ($devDebugLevel) = 1;
        return if ($devDebugLevel);

        foreach my $debug (@message) {
            ### $debug;
        }
    }

=item RV::logMessage( LIST )
    Log a message to the global RVFramework log backend.
=cut 
    sub logMessage {
        my ($message, $priority) = @_;
        if ($NoLog) {
        	return 0;
        }
        my ($tmp1, $filename, $line) = caller;
        my ($package, $tmp3, $tmp4, $subroutine) = caller(1);
        my ($callInfo) = "$filename on line $line";

        my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
        my @monthText = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
        my ($runtime) = "[$mday-$monthText[$mon]-$year $hour:$min:$sec]";
        my ($logMessage);
        $priority = 0 if (!$priority || $priority eq '');

        if ("$priority" eq __CONSTANT__::RVL_LOG_DEBUG) {
            $logMessage = $runtime . ' : [DEBUG] '. $subroutine . ' ' . $message . ' ' . $callInfo;
        } else {
            $logMessage = $subroutine . ' ' . $message;                  
        }
        ### $logMessage;
    }

    sub raiseMsg {
        my ($message, $getTranslation, $messageType) = @_;
        $getTranslation = 0 if ( $getTranslation eq '');
        $messageType = __CONSTANT__::RVL_MESSAGE_ERROR if ($messageType eq '');
        if ($message ne '') {
            RVL::Session::set('message', $message);
            RVL::Session::set('messageType', $messageType);
        }
    }

    sub raiseError {
        my ($message, $priority) = @_;
        my ($package, $filename, $line) = caller;
        RVL::logMessage($message, $priority);
        
        my ($error);
        $error->{message} = $message;
        $error->{type} = $priority;
        $error->{code} = "Package: $package, Line: $line";
        RVL::Error::singleton()->push($error);

        if ($priority > 0) {
        #    require Carp;
        #    Carp::croak($message);
        }
        return RVL::Error::singleton();
    }
    
    sub moduleIsEnabled{
        my ($module) = shift;
        if (!-e __CONSTANT__::RVL_MOD_DIR . '/' . $module) {
            return 0;
        }
        return 1;   
    }
    
    sub runningFromCLI {
        my ($oCli) = RVL::Request::singleton();
        if ($oCli->getRequestType() eq 'Cli') {
            return 1;
        } else {
            return 0;   
        }
    }
    
    sub getCurrentLang {
        return 'en';   
    }
    
    sub getCurrentCharset {
        return 'utf-8';   
    }
    
    sub DumpEnv {
        print RVL::Session::singleton()->header(-type  =>  'text/html');
        print '<pre>';
        RVL::print_r(%ENV);
        print '</pre>';
    }
    
    sub is_timeout_call ($$) {
        my ($timeout, $code) = @_;
        my $isTimeout = 0;
        eval {
            local $SIG{ALRM} = sub {die "died in SIG ALRM";};
            alarm($timeout);
            &$code;
            alarm(0);
        };
   
        if ($@) {
        	if ($@ =~ /died in SIG ALRM/) {
                $isTimeout = 1;
        	}
        }
   
        return $isTimeout;
    }
    
    sub fatalErrors {
    	my ($errors) = @_;
    	if (!RVL::runningFromCLI()) {
            my (@header) = ();
            @header = (
                -type => 'text/html; charset=UTF-8' ,
                -X_Powered_By => 'RV Framework http://www.rvglobalsoft.com',
            );
            print RVL::Session::singleton()->header(@header);
        }
        
        my $html = <<EOF;
        <h1>Connect failed!!</h1>
        <p>
    		Please contact to your host provider.
        </p>
        
        <p>
        $errors
        </p>
EOF
        
        RVL::Output::singleton()->fatalErrorsDisplay($html);
        exit;
    }
    
    sub exit {
    	if(!defined $ENV{'PERL5OPT'}){	
	    	exit();
    	}
    }
}
1;

=pod

=head1 RVL

RVL Lib.

=head1 HOW IT WORKS

=head2 is_timeout_call($timeout, callback)
@param Integer $timeout - Set timeout
@param Callback - Sub callback function
@return Boolean
simple: 
            my $start = time();
            my $res = RVL::is_timeout_call(2 ,sub { 
                                for (my $i;$i<99999999999;$i++) {} 
                            });
            if ($res == 1) {
                RVL::print_r("TIME OUT");
                RVL::print_r("Finished after " . (time() - $start). " millisec \n");
            }
            
=cut

Copyright 2K16 - 2K18 Indonesian Hacker Rulez