<?php
//TIMEZONE DEFAULT ################################
date_default_timezone_set("America/Sao_Paulo");

//CONFIGURAÇÃO DO SITE ############################
define('HOST', 'localhost');
define('USER', 'root');
define('PASS', '');
define('DBSA', 'adeltec');

//DEFINE SERVIDOR DE EMAIL ########################
define('MAILUSER', 'contato@tagpage.com.br');
define('MAILPASS', 'tagpage1030');
define('MAILPORT', '587');
define('MAILHOST', 'mail.tagpage.com.br');

//DEFINE IDENTIDADE DO SITE #######################
define('SITENAME', 'Adeltec Soluções');
define('SITEDESC', 'Esse site');

//DEFINE O HOME DO SITE ###########################
define('HOME', 'http://localhost/adeltec');
define('THEME', 'adeltec');
define('INCLUDE_PATH', HOME . '/themes/' . THEME);
define('REQUIRE_PATH', 'themes/' . THEME);

//DEFINE O PAGSEGURO ###########################
define('PAGSEGURO_API_URL', 'https://ws.sandbox.pagseguro.uol.com.br');
define('PAGSEGURO_EMAIL', 'thierree@hotmail.com');
define('PAGSEGURO_TOKEN', '6D60229AD3CC4D8FB73172D3D4F945DC');

//PARAMETROS DE CONFIGURAÇÃO
define('DESCONTO_BOLETO', 15);

//AUTO LOAD DE CLASSES ############################
function __autoload($class) {

    $cDir = ['Conn', 'Helpers', 'Models'];
    $iDir = null;

    foreach ($cDir as $dirName):
        if (!$iDir && file_exists(__DIR__ . DIRECTORY_SEPARATOR . $dirName . DIRECTORY_SEPARATOR . $class .".class.php") && !is_dir(__DIR__ . DIRECTORY_SEPARATOR . $dirName . DIRECTORY_SEPARATOR . $class . ".class.php")):
            include_once (__DIR__ . DIRECTORY_SEPARATOR . $dirName . DIRECTORY_SEPARATOR . $class . ".class.php");
            $iDir = true;
        endif;
    endforeach;

    if (!$iDir):
        trigger_error("Não foi possivel incluir {$class}.class.php", E_USER_ERROR);
        die;
    endif;
}

//TRATAMENTO DE ERROS #############################
// CSS constantes :: Mensagens de Erro
define('WS_ACCEPT', 'accept');
define('WS_INFOR', 'infor');
define('WS_ALERT', 'alert');
define('WS_ERROR', 'error');

//WSErro :: Exibe erros lanÃ§ados :: Front
function WSErro($ErrMsg, $ErrNo, $ErrDie = null) {
    $CssClass = ($ErrNo == E_USER_NOTICE ? WS_INFOR : ($ErrNo == E_USER_WARNING ? WS_ALERT : ($ErrNo == E_USER_ERROR ? WS_ERROR : $ErrNo)));
    echo "<p class=\"trigger trigger-{$CssClass}\">{$ErrMsg}<span class=\"ajax_close\"></span></p>";

    if ($ErrDie):
        die;
    endif;
}

// PHPErro :: personaliza o gatilho do PHP
function PHPErro($ErrNo, $ErrMsg, $ErrFile, $ErrLine) {
    $CssClass = ($ErrNo == E_USER_NOTICE ? WS_INFOR : ($ErrNo == E_USER_WARNING ? WS_ALERT : ($ErrNo == E_USER_ERROR ? WS_ERROR : $ErrNo)));
    echo "<p class=\"trigger {$CssClass}\">";
    echo "<b>Erro na linha: {$ErrLine} ::</b> {$ErrMsg}<br>";
    echo "<small>{$ErrFile}</small>";
    echo "<span class=\"ajax_close\"></span></p>";

    if ($ErrNo == E_USER_ERROR):
        die;
    endif;
}

set_error_handler('PHPErro');
