<?php
// $mensagem = <<<HTML
//     <!DOCTYPE html>
//      <html>
//      <head>
//          <meta charset="utf-8">
//          <meta http-equiv="X-UA-Compatible" content="IE=edge">
//          <title>CRM Delvale</title>
//          <link rel="stylesheet" href="">
//      </head>
//      <body style="background: #efefef;">
//          <img src="http://crm.delvale.com.br/logoDelvale.png" style="width:450px">
//          <h1>Atualizando para CRM Release 3.1.1!</h1>
//      </body>
//      </html>
// HTML;
// die($mensagem);

function pr($data) {
	echo '<pre>';
	print_r($data);
	echo '</pre>';
}
function debug($data) {
	echo '<pre>';
	var_dump($data);
	echo '</pre>';
}
function prSql($criteria) {
	$test = $criteria->condition;
	$criteria->params = array_reverse($criteria->params);
	foreach ($criteria->params as $key => $param) {
		$test = str_replace($key, $param, $test);
	}
	pr($test);
}
function debugStack($options = array()) {

	$opt = [
		'args' => false,
		'object' => false,
		'type' => false,
		'class' => false,
		'file' => true,
		'function' => true,
		'line' => true,
		];
	$options = array_merge($options, $opt);
	echo '<span style="color:red!important;">';
	pr('<b>----------------------------- Pilha de chamadas -----------------------------</b>');
	$trace = debug_backtrace();
    $text = "Pilha de chamadas:" . PHP_EOL;
	foreach($trace as $caller) {
		foreach($options as $option => $show) {
			if($show != 1) {
				if(isset($caller[$option]))
					unset($caller[$option]);
			}
		}
		pr($caller);

	}
	pr('<b>----------------------------- Fim da Pilha de chamadas -----------------------------</b>');
	echo '</span>';
    die;
}
function urlAtual() {
  return sprintf(
    "%s://%s%s",
    isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
    $_SERVER['SERVER_NAME'],
    $_SERVER['REQUEST_URI']
  );
}
set_time_limit(0);
ini_set('memory_limit', '7000M');
ini_set('default_socket_timeout', '6000');
ini_set('default_charset', 'ISO-8859-1');
date_default_timezone_set('America/Sao_paulo');

if(extension_loaded('redis')) {
	ini_set('session.save_handler', 'redis');
	ini_set('session.save_path',    'tcp://127.0.0.1:6379');
}

// change the following paths if necessary
$base    = dirname(__FILE__);
defined('YII_BASE') or define('YII_BASE', $base);
$autoload    = dirname(__FILE__).'/protected/extensions/vendor/autoload.php';
$yii    = dirname(__FILE__).'/framework/yiilite.php';
$config = dirname(__FILE__).'/protected/config/main.php';
$php_dir = dirname(__FILE__) . '/../php';
if(is_dir($php_dir)) {
	ini_set("include_path", $php_dir . ':' . ini_get("include_path"));
}

defined('BASE_TESTES') or define('BASE_TESTES', false);

if(BASE_TESTES) {
	defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
	defined('YII_DEBUG') or define('YII_DEBUG', BASE_TESTES);
	error_reporting(E_ALL|E_WARNING|E_NOTICE);
	ini_set('display_errors', true);
	ini_set('log_errors', true);
} else {
	defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 0);
	defined('YII_DEBUG') or define('YII_DEBUG', false);
	error_reporting(E_ALL);
	ini_set('display_errors', false);
}
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
defined('VERSAO') or define('VERSAO', '3.1.3');

defined('URL_AREA_CLIENTES') or define('URL_AREA_CLIENTES', "https://clientes.windel.com.br/");

require ($autoload);
require_once ($yii);
Yii::createWebApplication($config)->run();
