// if($_SERVER['REMOTE_ADDR'] == '192.168.0.177' || $_GET['debugtnx']){
// echo '
';
// $debugBacktrace = debug_backtrace(); array_unshift($debugBacktrace, array('file'=>__FILE__, 'line'=>__LINE__, 'function'=>'debugTnx')); foreach($debugBacktrace as $debugLine) echo "".str_replace("/tnx/www/html/www/", "", $debugLine['file']).""." ".$debugLine['function']."()
";
// $printMe = $_SERVER; ob_start(); if(is_object($printMe)||is_array($printMe)) print_r($printMe); else var_dump($printMe); echo htmlentities(ob_get_clean(), ENT_COMPAT|ENT_HTML401|ENT_SUBSTITUTE, 'UTF-8');
// $printMe = $_GET; ob_start(); if(is_object($printMe)||is_array($printMe)) print_r($printMe); else var_dump($printMe); echo htmlentities(ob_get_clean(), ENT_COMPAT|ENT_HTML401|ENT_SUBSTITUTE, 'UTF-8');
// echo '';
// die;
// }
if(COTTO_BOOT_INDI === true){
if(!$GLOBALS['tnxBoot']) $GLOBALS['tnxBoot'] = "admin_tnx";
}
$GLOBALS['timebench'] = array();
function timebench($id, $isChiusura = 0, $printId = null, $email = false, $emailIfIdMaggiore = 0, $emailIfId = 'totaleraw'){
if($id){
$diff = count($GLOBALS['timebench'][$id][0]) - count($GLOBALS['timebench'][$id][1]);
$ricorsiveAperte = $GLOBALS['timebench'][$id][2];
if(!$ricorsiveAperte && (($isChiusura&&$diff==1)||(!$isChiusura&&$diff==0))){
$GLOBALS['timebench'][$id][$isChiusura][] = microtime(true);
}
else{
if($isChiusura) $GLOBALS['timebench'][$id][2]--;
else{
$GLOBALS['timebench'][$id][2]++;
$GLOBALS['timebench'][$id][3]++;
}
}
$GLOBALS['timebench'][$id][4]= $diff." ".$ricorsiveAperte;
if($printId === true) $printId = $id;//stampo quello benchmarkato
}
if($printId){
if($printId === true){
$printId = array_keys($GLOBALS['timebench']);
}
else if(!is_array($printId)) $printId = array($printId);
$out = '';
$stampa = ['TOTALE' => microtime(true)-$_SERVER['REQUEST_TIME_FLOAT']];
foreach($printId as $id){
if(count($GLOBALS['timebench'][$id][0]) != count($GLOBALS['timebench'][$id][1])){
$out .= "$id ERRORE aperture/chiusure non corrispondenti
";
}
else{
/* ha qualche tipo di bug in caso di chiamate annidate
for($i=0; $i<(count($GLOBALS['timebench'][$id])/2); $i++){
echo "$id: ";
echo number_format($GLOBALS['timebench'][$id][$i+1] - $GLOBALS['timebench'][$id][$i], 2);
echo "
";
}
*/
$stampa[$id] = 0;
foreach($GLOBALS['timebench'][$id] as $iisChiusura=>$valori){
foreach($valori as $v){
$stampa[$id] += $v * (!$iisChiusura ? -1 : 1);
}
}
}
}
asort($stampa);
$stampa = array_reverse($stampa);
ob_start();
foreach($stampa as $id=>$tot){
$decimali = 2;
if(round($tot*pow(10, $decimali))){
$count = count($GLOBALS['timebench'][$id][0]);
$countRic = $GLOBALS['timebench'][$id][3];
echo "$id ".($count>1?" ".$count."x":"").($countRic>1?" ".$countRic."ric":"").": ";
echo number_format($tot, $decimali);
echo "
";
}
}
$out .= ob_get_clean();
if($email){
//inserire
//ConnectionManager::getDataSource('default')->fullDebug = true / false;
//prima/dopo le query da loggare
$out .= print_r(ConnectionManager::getDataSource('default')->getLog(), true);
if(!$emailIfIdMaggiore || $stampa[$id] > $emailIfIdMaggiore) mail($email, "timebench $emailIfId > $emailIfIdMaggiore", $out, 'MIME-Version: 1.0'."\r\n".'Content-type: text/html; charset=utf-8');
}
else echo "$out
";
}
}
timebench("preboot", 0);
//getcwd() => /tnx/www/html/www/indi/SITI/base/admin_tnx/webroot
//importante che sia "once" perchè questo file viene incluso anche dalle pagine di indi e reincludere questi file vorrebbe dire sovrascrivere delle variabili
function isInvoicexWebApp() {
if (substr($_SERVER["REQUEST_URI"],0,15) == "/invoicex_2021/") return true;
}
if(!function_exists("is_local")){
//duplicata in I:\cotto2\vendors\funzioni.php
function is_local(){
return
stristr($_SERVER['SERVER_NAME'],'demo.tnx.it')
|| stristr($_SERVER['SERVER_NAME'],'demo2.tnx.it')
|| stristr($_SERVER['SERVER_NAME'],'demo3.tnx.it')
|| stristr($_SERVER['SERVER_NAME'],'demo8.tnx.it')
|| stristr($_SERVER['SERVER_ADDR'],'192.168.0.105')
;
}
}
if($GLOBALS['tnxBoot'] != "admin_tnx"){
$old_cwd = getcwd();
chdir(dirname(dirname($old_cwd)));
$new_cwd = getcwd();
$CONTROLLA_SESSIONE = !rand(0,20);
if($CONTROLLA_SESSIONE) $vecchia_sessione = serialize($_SESSION);
// if(!function_exists('isPhpNew'))//temporaneo per test doppia versione indi
require_once(INDI_PATH."base.inc.php");
$CONF['dove_sono'] = is_local() ? "loc" : "rem";
if(canUseDbPrivato()) include_once(INDI_PATH."../INDI_privato/db_config/".(is_local()?"demo.tnx.it.php":"web.tnx.it.php"));
if($_SERVER['SERVER_NAME'] == 'onlinedb.tnx.it'){
$DB = $DB_REMOTE;
}
// @include_once(dirname(dirname(getcwd()))."/INDI_privato/db_config/".(is_local()?"demo.tnx.it.php":"web.tnx.it.php"));
$file = '';
if(defined("CUSTOM_INDI_INC")) $file = CUSTOM_INDI_INC;
else if(is_file($new_cwd."/"."indi.php")) $file = $new_cwd."/"."indi.php";
else if(is_file($new_cwd."/"."indi.inc.php")) $file = $new_cwd."/"."indi.inc.php";
if($file) require_once($file);
if($CONTROLLA_SESSIONE && $vecchia_sessione != serialize($_SESSION)){
$messaggio = "Sembra venga inizializzata la sessione in uno dei file inclusi da cakeBoot, quindi salterà un if in I:\cotto2\cake\libs\session.php:445 e di conseguenza il cookie di sessione non dovrebbe avere il path corretto e probabilmente sarà comune a tutte le admin(problema login unico su demo).";
if(strpos($_SERVER["REMOTE_ADDR"], "192.168.") === 0) die($messaggio);
else mail("carlo@tnx.it", "Possibile problema sessione cake", $messaggio);
}
chdir($old_cwd);
if(!function_exists("is_indi")){
function is_indi(){//funzione per controllare se sto usando cake dentro indi o standalone
return @constant('INDI');
}
}
// if(!is_indi()){//a cosa servono?? aggiungo segnalazione
// function genera_link(){trigger_error("Chiamata pseudo funzione ".__FUNCTION__, E_USER_ERROR);}
// function gall(){trigger_error("Chiamata pseudo funzione ".__FUNCTION__, E_USER_ERROR);}
// function mtp_foto_dir(){trigger_error("Chiamata pseudo funzione ".__FUNCTION__, E_USER_ERROR);}
// function encode(){trigger_error("Chiamata pseudo funzione ".__FUNCTION__, E_USER_ERROR);}
// }
}
timebench("preboot", 1);
if(!is_indi()) timebench("totaleraw", 0);
if($GLOBALS['tnxBoot'] == "admin_tnx"){
timebench("indiBoot", 0);
$old_cwd = getcwd();
chdir(dirname(dirname($old_cwd)));
// require(VENDORS."funzioni.php");//non ho ancora la costante qui, ma tra le due attuali versioni di cotto usano la stessa cartella VENDORS
require("../../cotto2/vendors/funzioni.php");
require(getcwd()."/index.php");//includo tutto indi
chdir($old_cwd);
timebench("indiBoot", 1);
// print_r(db_qa("select * from labels limit 1"));
}
define('WINDOW_COTTOSUBMIT', 'window.cottosubmit');
define('WINDOW_COTTOSUBMIT_ANNULLATO', 'window.cottosubmitAnnullato');
define('WINDOW_COTTOSUBMIT_DATI_NON_SALVATI', 'window.cottosubmitDatiNonSalvati');
/* SVN FILE: $Id: index.php 5811 2007-10-20 06:39:14Z phpnut $ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework
* Copyright 2005-2007, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
* @package cake
* @subpackage cake.app.webroot
* @since CakePHP(tm) v 0.2.9
* @version $Revision: 5811 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2007-10-20 01:39:14 -0500(Sat, 20 Oct 2007) $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Do not change
*/
if(!defined('DS')){
define('DS', DIRECTORY_SEPARATOR);
}
/**
* These defines should only be edited if you have cake installed in
* a directory layout other than the way it is distributed.
* Each define has a commented line of code that explains what you would change.
*/
if(!defined('ROOT')){
//define('ROOT', 'FULL PATH TO DIRECTORY WHERE APP DIRECTORY IS LOCATED. DO NOT ADD A TRAILING DIRECTORY SEPARATOR');
//You should also use the DS define to separate your directories
define('ROOT', dirname(dirname(getcwd())));
}
if(!defined('APP_DIR')){
//define('APP_DIR', 'DIRECTORY NAME OF APPLICATION');
define('APP_DIR', basename(dirname(getcwd())));
}
/**
* This only needs to be changed if the cake installed libs are located
* outside of the distributed directory structure.
*/
if(!defined('CAKE_CORE_INCLUDE_PATH')){
//define('CAKE_CORE_INCLUDE_PATH', 'FULL PATH TO DIRECTORY WHERE CAKE CORE IS INSTALLED. DO NOT ADD A TRAILING DIRECTORY SEPARATOR');
//You should also use the DS define to separate your directories
// define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(ROOT)));
//define('CAKE_CORE_INCLUDE_PATH', ROOT);
if(PHP_MAJOR_VERSION >= 7){
$cakedir = "cotto3";
}
else if(is_indi()){
$cakedir = $GLOBALS['DATI']["CAKE"] ? $GLOBALS['DATI']["CAKE"] : $GLOBALS['CONF']["CAKE"];
}
else{
$cakedir = $CONF["CAKE"];
}
// if($cakedir != "cotto3" && !in_array($GLOBALS['CONF']['nome_sito'], array("Legalgest SRL", "Tuscan Chef", "VesuvioTour", "MTP", "Villa il Santo", "Associazione Socioculturale Circolo Semifonte", "TNX srl"))){
// mail("carlo@tnx.it", "Sito che usa ".$cakedir.": ".$GLOBALS['CONF']['nome_sito'], "http".(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 's' : '')."://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
// }
define('CAKE_VER',substr($cakedir, 5, 1));//occhio a cotto2_cicos
define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(dirname(getcwd())))).DS.$cakedir);
}
///////////////////////////////
//DO NOT EDIT BELOW THIS LINE//
///////////////////////////////
if(!defined('WEBROOT_DIR')){
define('WEBROOT_DIR', basename(getcwd()));
}
if(!defined('WWW_ROOT')){
define('WWW_ROOT', getcwd() . DS);
}
if(!defined('CORE_PATH')){
if(function_exists('ini_set')){
ini_set('include_path', CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . ROOT . DS . APP_DIR . DS . PATH_SEPARATOR . ini_get('include_path'));
define('APP_PATH', null);
define('CORE_PATH', null);
} else{
define('APP_PATH', ROOT . DS . APP_DIR . DS);
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
}
}
timebench("cake_bootstrap", 0);
if(!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')){
trigger_error("Can't find CakePHP core. Check the value of CAKE_CORE_INCLUDE_PATH in app/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
}
Cache::config('default', array(
'probability'=> 0, //disabilito garbage collector
));
timebench("cake_bootstrap", 1);
if(in_array($_GET['url'], array('favicon.ico', 'favicon.gif')) ||($GLOBALS['tnxBoot'] != "admin_tnx" && is_indi())){
return;
} else{
if(strpos($_SERVER['REQUEST_URI'], "%0A") !== false){
$prima = $_GET['url'];
$_GET['url'] = substr($_SERVER['REQUEST_URI'], 1+strlen(dirname(dirname($_SERVER['SCRIPT_NAME']))));
mail(
"c@localhost",
"c'è un newline nell'url, provo a fixare manualmente",
"il . nelle espressioni regolari non matcha i newline e non ho trovato un modo diverso\n".print_r(array('$_GET[url] prima' => $prima, '$_GET[url] dopo' => $_GET['url'], '$_REQUEST' => $_REQUEST, '$_SERVER' => $_SERVER), true)
);
//due volte dirname perchè sono in webroot e nell'url non c'è
}
timebench("new_dispatch", 0);
$Dispatcher = new Dispatcher();
timebench("new_dispatch", 1);
timebench("dispatch", 0);
$Dispatcher->dispatch();
timebench("dispatch", 1);
}
if(Configure::read() > 1){
echo "";
}
require("vendors/history3k.php");
timebench("totaleraw", 1);
if($_GET['bench']){
timebench(null,null,true);
}
?>