#!/usr/bin/perl
package RVL;
# 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.
# ===============================
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