/**
*-----------------------------------------------------------------
* Copyright (c) ${year} T-Immagine All Rights Reserved.
*
* This software is the confidential and proprietary information
* of T-Immagine ("Confidential Information").
* You shall not disclose such Confidential Information and shall
* use it only in accordance with the terms of the license
* agreement you entered into with T-Immagine
*-----------------------------------------------------------------
*/
/**
* -- Pagina CONNESSIONE
*
* -- Settaggio connessione al DB
* -- Settaggio inclusioni principali (Funzioni, Smarty, ecc..)
* -- Settaggio livello di errore
* -- Settaggio time limit script
* -- Altri settaggi
* -- Start SESSION
* -- redirect in index.php con riproposizione LOGIN se manca session
* -- assegnazione a varibili PHP e SMARTY valori di SESSION
*
*
* @package
* @author Andrea Manessi
* @version $$Id$$
*/
$durataCookie = 259200; //CARRELLO VALIDO PER 3gg
$NOW = date("Ymdhis");
$IVA = 0;
$host = $_SERVER['HTTP_HOST'];
error_reporting(E_ERROR);
switch ($host) {
/*****************/
//SOLO PER LAB
case "lab":
case "172.16.1.223":
case "178.19.151.107":
case "lab2.timmagine.it":
case "lab2-timmagine.advantia.it":
case "lab2-priv.advantia.it":
$URLASSOLUTO = "http://" . $host . "/Web/gardafrigor.it/http/";
$pass = trim(file_get_contents("http://172.16.1.223/Web/.config/config.json"));
$PATHASSOLUTO=(dirname($_SERVER["SCRIPT_FILENAME"]).""); //php5
mysql_connect("localhost","root",$pass) or die("ERRORE CONNESSIONE".mysql_error());
mysql_select_db("lab_gardafrigor") or die("ERRORE DATABASE".mysql_error());
error_reporting(E_ERROR);
$NOMESITO = "GardaFrigor";
$Codifica = "utf8";
mysql_query("SET NAMES utf8");
$destinatarioSendMail="andrea.timmagine@gmail.com";
$_DEBUG=1;
break;
//DEMO
case "demo":
case "demo.timmagine.com":
case "demo.timmagine.com/gardafrigor.it/":
$URLASSOLUTO = "http://demo.timmagine.com/gardafrigor.it/";
$PATHASSOLUTO=(dirname($_SERVER["SCRIPT_FILENAME"]).""); //php5
//die($PATHASSOLUTO);
mysql_connect("localhost","gardafrigor","ganti7711") or die("ERRORE CONNESSIONE".mysql_error());
mysql_select_db("gardafrigor") or die("ERRORE DATABASE".mysql_error());
error_reporting(0);
$NOMESITO = "GardaFrigor";
$Codifica = "utf8";
mysql_query("SET NAMES utf8");
$destinatarioSendMail="andrea.timmagine@gmail.com";
$_DEBUG=1;
break;
//ON LINE
case "www.gardafrigor.it":
case "gardafrigor.it":
default:
$URLASSOLUTO = "https://www.gardafrigor.it/";
$PATHASSOLUTO=(dirname($_SERVER["SCRIPT_FILENAME"]).""); //php5
//die($PATHASSOLUTO);
mysql_connect("localhost","gardafrigor","ganti7711") or die("ERRORE CONNESSIONE".mysql_error());
mysql_select_db("gardafrigor") or die("ERRORE DATABASE".mysql_error());
error_reporting(0);
$NOMESITO = "GardaFrigor";
mysql_query("SET NAMES utf8");
$destinatarioSendMail="andrea.timmagine@gmail.com";
$_DEBUG=0;
break;
}
?>
/**
*-----------------------------------------------------------------
* Copyright (c) ${year} T-Immagine All Rights Reserved.
*
* This software is the confidential and proprietary information
* of T-Immagine ("Confidential Information").
* You shall not disclose such Confidential Information and shall
* use it only in accordance with the terms of the license
* agreement you entered into with T-Immagine
*-----------------------------------------------------------------
*/
/**
* -- Pagina Funzioni
*
* -- Definizione Funzioni comuni da utilizzare nel Software
*
*
*
* @package
* @author Andrea Manessi
* @version $$Id$$
*/
//SELEZIONE DINAMICA RUOLI
function SelezioneRuoli(){
$qR="Select IDRuolo, Descrizione from ruolo order by IDRuolo";
$resR = mysql_query($qR);
while($rowR =mysql_fetch_array($resR)){
$DescrizioneA = str_replace(" ", "_", $rowR[Descrizione]);
$i[$rowR[IDRuolo]] = $DescrizioneA;
}
return $i;
}
function TagliaStringa($stringa, $max_char){
if(strlen($stringa)>$max_char){
$stringa_tagliata=substr($stringa, 0,$max_char);
$last_space=strrpos($stringa_tagliata," ");
$stringa_ok=substr($stringa_tagliata, 0,$last_space);
return $stringa_ok."...";
}else{
return $stringa;
}
}
function nomeMese($mese){
//die($mese);
if ($mese==1 || $mese=="01") {$mese='Gennaio';}
if ($mese=="2" || $mese=="02") {$mese='Febbraio';}
if ($mese=="3" || $mese=="03") {$mese='Marzo';}
if ($mese=="4" || $mese=="04") {$mese='Aprile';}
if ($mese=="5" || $mese=="05") {$mese='Maggio';}
if ($mese=="6" || $mese=="06") {$mese='Giugno';}
if ($mese=="7" || $mese=="07") {$mese='Luglio';}
if ($mese=="8" || $mese=="08") {$mese='Agosto';}
if ($mese=="9" || $mese=="09") {$mese='Settembre';}
if ($mese=="10") {$mese='Ottobre';}
if ($mese=="11") {$mese='Novembre';}
if ($mese=="12") {$mese='Dicembre';}
return $mese;
}
//FUNZIONI SU DATA
function data_view($data){
$data_dt=explode(" ",$data);
$data_ar=explode("-",$data_dt[0]);
$data="$data_ar[2]/$data_ar[1]/$data_ar[0]";
return $data;
}
//VISUALIZZAZIONE ARRAY PER DEBUG
function pre($array){
print "
";
print_r($array);
print "
";
}
function printy($var){
foreach($var as $vary){
print($vary."
");
}
}
//RIMOZIONE SPAZI
function removeWhitespace($string){
$string = ereg_replace(chr(10), ' ', $string);
$string = ereg_replace(chr(13), ' ', $string);
$string = ereg_replace( "".chr(9)." +", ' ', $string);
$string = ereg_replace( ' +', ' ', $string);
return($string);
}
function decodificaFlag($Valore, $Tabella){
$query = "SELECT Descrizione from catalogo_decodificastato WHERE Tabella = '$Tabella' AND Stato = '$Valore'";
$res = mysql_query($query);
if($row = mysql_fetch_assoc($res)){
return @$row[Descrizione];
}else{
return "ERRORE GENERICO (...)";
}
}
function file_exists_incpath($file){
$paths = explode(PATH_SEPARATOR, get_include_path());
foreach ($paths as $path) {
// Formulate the absolute path
$fullpath = $path . DIRECTORY_SEPARATOR . $file;
// Check it
if (file_exists($fullpath)) {
return $fullpath;
}
}
return false;
}
function aggiusta_url($indirizzo){
$indirizzo = str_replace ( ' ', '-', $indirizzo);
$indirizzo = str_replace ( 'à', 'a', $indirizzo);
$indirizzo = str_replace ( 'è', 'e', $indirizzo);
$indirizzo = str_replace ( 'é', 'e', $indirizzo);
$indirizzo = str_replace ( 'ù', 'u', $indirizzo);
$indirizzo = str_replace ( 'ò', 'o', $indirizzo);
$indirizzo = str_replace ( 'ì', 'i', $indirizzo);
$indirizzo = str_replace ( '\'', '-', $indirizzo);
$indirizzo = str_replace ( '/', '-', $indirizzo);
$indirizzo = str_replace ( '?', '', $indirizzo);
$indirizzo = str_replace ( '!', '', $indirizzo);
$indirizzo = str_replace ( '"', '', $indirizzo);
$indirizzo = str_replace ( '\"', '', $indirizzo);
$indirizzo = str_replace ( '&', 'e', $indirizzo);
$indirizzo = str_replace ( ',', '', $indirizzo);
$indirizzo = str_replace ( '.', '', $indirizzo);
$indirizzo = str_replace ( '(', '', $indirizzo);
$indirizzo = str_replace ( ')', '', $indirizzo);
$indirizzo = str_replace ( '[', '', $indirizzo);
$indirizzo = str_replace ( ']', '', $indirizzo);
$indirizzo = str_replace ( '/', '', $indirizzo);
$indirizzo = str_replace ( '\'', '-', $indirizzo);
$indirizzo = str_replace ( '---', '-', $indirizzo);
$indirizzo = str_replace ( '--', '-', $indirizzo);
$indirizzo = str_replace ( '%', '', $indirizzo);
$indirizzo = str_replace ( ':', '', $indirizzo);
$indirizzo = str_replace("+", "", $indirizzo);
$indirizzo = str_replace("--", "-", $indirizzo);
$indirizzo = str_replace(";", "", $indirizzo);
$indirizzo = str_replace("@", "", $indirizzo);
$indirizzo = str_replace("°", "", $indirizzo);
$indirizzo = str_replace("#", "", $indirizzo);
$indirizzo = str_replace("=", "", $indirizzo);
$indirizzo = str_replace("€", "", $indirizzo);
$indirizzo = str_replace("£", "", $indirizzo);
$indirizzo = str_replace("$", "", $indirizzo);
$indirizzo = strtolower($indirizzo);
return $indirizzo;
}
function mastrolindo($NomeUrlencoded){
$NomeUrlencoded = str_replace("/", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("(", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace(")", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("Ø", "diam", $NomeUrlencoded);
$NomeUrlencoded = str_replace("x", "x", $NomeUrlencoded);
$NomeUrlencoded = str_replace(".", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace(":", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace(",", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace(";", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("à", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("è", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("é", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("ì", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("ò", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("ù", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("°", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("+", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("-", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("=", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("*", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("?", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("^", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("&", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("%", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("\"", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("!", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("\\", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("[", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("]", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("{", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("}", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace(">", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("<", "", $NomeUrlencoded);
$NomeUrlencoded = str_replace("---", "-", $NomeUrlencoded);
return $NomeUrlencoded;
}
function codifica_stringa_xml($stringa) {
$stringa = str_replace('&','&', $stringa);
$stringa = str_replace('<','<', $stringa);
$stringa = str_replace('>','>', $stringa);
$stringa = str_replace('"','"', $stringa);
$stringa = str_replace("'",''', $stringa);
//$stringa = utf8_encode($stringa);
return $stringa;
}
function dividi_testo($stringa, $lenght, $separatore="\n"){
//se la stringa non è vuota ed è più lunga di $lenght, la divido
if($stringa!="" and strlen($stringa)>$lenght){
$stringa2="";
//la divido in base agli accapo (separatori) già presenti, poi prendo ogni frammento e, se più lungo di $lenght, li divido in pezzi contenenti $lenght caratteri
$array=explode($separatore, $stringa);
//prendo ogni pezzo e lo divido in base al totale di caratteri per riga
foreach($array as $value){
if(strlen($value)>$lenght){
$inizio=0;
while($iniziostrlen($value)-$lenght){
$stringa2.=$parte1.$separatore;
break;
}
//torno al carattere prima dello spazio
$parte1=substr($parte1, 0, strrpos($parte1, ' '));
//aggiorno il puntatore per ripartire dalla stringa (il +1 serve per eliminare lo spazio quando va a capo)
$inizio+=strlen($parte1)+1;
//salvo la parte tagliata
$stringa2.=$parte1.$separatore;
}
}else
$stringa2.=$value.$separatore;
}
return trim($stringa2, $separatore);
}else
return $stringa;
}
?>