<?php
// Error Reporting
//com a atualização do PHP p/ 5.3 se tornou deprecated o mysqli, então, precisa desabilitar a mensagem de deprecated do BROWSER....
//Removi aqui, para deixar a critério do PHP.ini como deve ficar o report de erros...
//error_reporting(E_ALL);

// Check Version
if (version_compare(phpversion(), '5.1.0', '<') == true) {
  exit('PHP5.1+ Required');
}

// Register Globals
if (ini_get('register_globals')) {
  ini_set('session.use_cookies', 'On');
  ini_set('session.use_trans_sid', 'Off');

  session_set_cookie_params(0, '/');
  session_start();

  $globals = array($_REQUEST, $_SESSION, $_SERVER, $_FILES);

  foreach ($globals as $global) {
    foreach (array_keys($global) as $key) {
      unset(${$key});
    }
  }
}

// Magic Quotes Fix
if (ini_get('magic_quotes_gpc')) {
  function clean($data)
  {
    if (is_array($data)) {
      foreach ($data as $key => $value) {
        $data[clean($key)] = clean($value);
      }
    } else {
      $data = stripslashes($data);
    }

    return $data;
  }

  $_GET = clean($_GET);
  $_POST = clean($_POST);
  $_REQUEST = clean($_REQUEST);
  $_COOKIE = clean($_COOKIE);
}

if (!ini_get('date.timezone')) {
  date_default_timezone_set('UTC');
}


// Windows IIS Compatibility
if (!isset($_SERVER['DOCUMENT_ROOT'])) {
  if (isset($_SERVER['SCRIPT_FILENAME'])) {
    $_SERVER['DOCUMENT_ROOT'] = str_replace('\\', '/', substr($_SERVER['SCRIPT_FILENAME'], 0, 0 - strlen($_SERVER['PHP_SELF'])));
  }
}

if (!isset($_SERVER['DOCUMENT_ROOT'])) {
  if (isset($_SERVER['PATH_TRANSLATED'])) {
    $_SERVER['DOCUMENT_ROOT'] = str_replace('\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0 - strlen($_SERVER['PHP_SELF'])));
  }
}

if (!isset($_SERVER['REQUEST_URI'])) {
  $_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'], 1);

  if (isset($_SERVER['QUERY_STRING'])) {
    $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
  }
}

if (!isset($_SERVER['HTTP_HOST'])) {
  $_SERVER['HTTP_HOST'] = getenv('HTTP_HOST');
}

// Helper
require_once(DIR_SYSTEM . 'helper/json.php');
require_once(DIR_SYSTEM . 'helper/utf8.php');

// Engine
require_once(DIR_SYSTEM . 'engine/action.php');
require_once(DIR_SYSTEM . 'engine/controller.php');
require_once(DIR_SYSTEM . 'engine/front.php');
require_once(DIR_SYSTEM . 'engine/loader.php');
require_once(DIR_SYSTEM . 'engine/model.php');
require_once(DIR_SYSTEM . 'engine/registry.php');

// ModelBase
require_once(DIR_SYSTEM . 'dmodel/ModelBase.php');

// Common
require_once(DIR_SYSTEM . 'library/url.php');
require_once(DIR_SYSTEM . 'library/config.php');
require_once(DIR_SYSTEM . 'library/db.php');
require_once(DIR_SYSTEM . 'library/document.php');
require_once(DIR_SYSTEM . 'library/encryption.php');
require_once(DIR_SYSTEM . 'library/image.php');
require_once(DIR_SYSTEM . 'library/language.php');
require_once(DIR_SYSTEM . 'library/log.php');
require_once(DIR_SYSTEM . 'library/mail.php');
require_once(DIR_SYSTEM . 'library/pagination.php');
require_once(DIR_SYSTEM . 'library/paginationjson.php');
require_once(DIR_SYSTEM . 'library/request.php');
require_once(DIR_SYSTEM . 'library/response.php');
require_once(DIR_SYSTEM . 'library/session.php');
require_once(DIR_SYSTEM . 'library/template/template.php');
require_once(DIR_SYSTEM . 'library/template/twig.php');
require_once(DIR_SYSTEM . 'library/template/templatecontroller.php');
require_once(DIR_SYSTEM . 'library/futuracalcularst.php');
require_once(DIR_SYSTEM . 'library/cep.php');
require_once(DIR_SYSTEM . 'library/crypto.php');
require_once(DIR_SYSTEM . 'library/limiterlock.php');
require_once(DIR_SYSTEM . 'library/JWT.php');

include_once(DIR_SYSTEM . 'types/enumbasic.php');

// Exceptions
require_once(DIR_SYSTEM . 'types/exceptions.php');

//tasks
require_once(DIR_SYSTEM . 'library/task/sendtask.php');
require_once(DIR_SYSTEM . 'library/task/email.php');
require_once(DIR_SYSTEM . 'library/task/pedido.php');
require_once(DIR_SYSTEM . 'library/task/emailpedidoloja.php');
require_once(DIR_SYSTEM . 'library/task/emailpedidomercadolivre.php');
require_once(DIR_SYSTEM . 'library/task/emailpedidolistapresente.php');
require_once(DIR_SYSTEM . 'library/task/emailpedidodonolistapresente.php');
require_once(DIR_SYSTEM . 'library/task/emailpedidodonoloja.php');
require_once(DIR_SYSTEM . 'library/task/emailpedidostatus.php');
require_once(DIR_SYSTEM . 'library/task/cliente.php');
require_once(DIR_SYSTEM . 'library/task/emailcliente.php');
require_once(DIR_SYSTEM . 'library/task/emailclientedonoloja.php');
require_once(DIR_SYSTEM . 'library/task/emailDevolucaoProdutoDonoLoja.php');
require_once(DIR_SYSTEM . 'library/task/notificacaomarketplacestatus.php');
require_once(DIR_SYSTEM . 'library/resizeimg.php');
require_once(DIR_SYSTEM . 'library/specific.php');

//restapi
require_once(DIR_SYSTEM . 'library/restapi.php');

require_once(DIR_SYSTEM . 'library/defaultClass.php');

//log
require_once(DIR_SYSTEM . 'types/tipolog.php');
require_once(DIR_SYSTEM . 'library/log/BaseLogClass.php');
require_once(DIR_SYSTEM . 'library/log/BaseLog.php');

//marketplaces
require_once(DIR_SYSTEM . 'types/tipomarketplace.php');
require_once(DIR_SYSTEM . 'types/tipomercadolivre.php');
require_once(DIR_SYSTEM . 'types/tiposkyhub.php');
require_once(DIR_SYSTEM . 'types/tipogaleriapage.php');
require_once(DIR_SYSTEM . 'types/tiposhopee.php');
require_once(DIR_SYSTEM . 'library/marketplace/WebServiceMktp.php');
require_once(DIR_SYSTEM . 'library/marketplace/mercadolivreutils.php');
require_once(DIR_SYSTEM . 'library/marketplace/mercadolivre.php');
require_once(DIR_SYSTEM . 'library/marketplace/MktPlace.php');
require_once(DIR_SYSTEM . 'library/marketplace/MktPlaceProdutoClass.php');
require_once(DIR_SYSTEM . 'library/marketplace/MktPlacePedidoClass.php');
require_once(DIR_SYSTEM . 'library/marketplace/SkyHubUtils.php');
require_once(DIR_SYSTEM . 'library/marketplace/SkyHub.php');
require_once(DIR_SYSTEM . 'library/marketplace/GaleriaPageUtils.php');
require_once(DIR_SYSTEM . 'library/marketplace/GaleriaPage.php');
require_once(DIR_SYSTEM . 'library/marketplace/ShopeeUtils.php');
require_once(DIR_SYSTEM . 'library/marketplace/Shopee.php');
require_once(DIR_SYSTEM . 'library/ecommerce_api.php');

require_once(DIR_SYSTEM . 'types/tipofontsize.php');
require_once(DIR_SYSTEM . 'library/payment/payment_info.php');

require_once(DIR_SYSTEM . 'types/tipoyapay.php');
require_once(DIR_SYSTEM . 'library/yapay.php');

require_once(DIR_SYSTEM . 'types/tiporede.php');

require_once(DIR_SYSTEM . 'types/tipowirecard.php');

require_once(DIR_SYSTEM . 'types/tipopagarme.php');
require_once(DIR_SYSTEM . 'types/tipogetnet.php');
require_once(DIR_SYSTEM . 'types/tipopagseguro.php');
require_once(DIR_SYSTEM . 'types/tipodesign.php');

require_once(DIR_SYSTEM . 'types/tipofidelity.php');

require_once(DIR_SYSTEM . 'types/tipopermissao.php');

//feedback
require_once(DIR_SYSTEM . 'types/tipofeedback.php');
require_once(DIR_SYSTEM . 'library/feedback/webServiceFeedback.php');
require_once(DIR_SYSTEM . 'library/feedback/feedback.php');
require_once(DIR_SYSTEM . 'library/feedback/gupshoputils.php');
require_once(DIR_SYSTEM . 'library/feedback/gupshop.php');

//gupshop
require_once(DIR_SYSTEM . 'library/feedback/gupshop/MessageGupshop.php');


//whatsapp
require_once(DIR_SYSTEM . 'library/feedback/whatsapp/sendwhatsapp.php');
require_once(DIR_SYSTEM . 'library/feedback/whatsapp/whatsapp.php');
require_once(DIR_SYSTEM . 'library/feedback/whatsapp/whatsappnewaccount.php');
require_once(DIR_SYSTEM . 'library/feedback/whatsapp/whatsapporderstatus.php');

require_once(DIR_SYSTEM . 'types/typeTabs.php');