// if($_GET['testemail']) die(mail("carlo@tnx.it", "testemail", "testemail")?'ok':'KO'); if($_GET['phpinfo']){ phpinfo(); die; } if(@$_GET['phpversion']){ die("
". "intervallo ".$intervalloTempoKey."" ; if($erroriIntervallo['globale'] < $max_errori_globale && $erroriIntervallo['errori'][$err_key] < $max_errori_identici && $erroriIntervallo['siti'][$sito_key] < $max_errori_sito){ $oggetto = ""; if($msg['gruppo']) $oggetto .= $msg['gruppo']." "; if($msg['nome']) $oggetto .= $msg['nome']." "; if($GLOBALS['DATI']['utente']) $oggetto .= $GLOBALS['DATI']['utente']." "; if($oggetto) $oggetto .= " - "; $oggetto .= $msg['errore']; $testo = $body.$erroriStats; if($gestioneAttiva == 2){ $erroriIntervallo['globale'] = xcache_inc("errG_globale".$intervalloTempoKey, 1, $intervallo_tempo); $erroriIntervallo['errori'][$err_key] = xcache_inc("errE".$intervalloTempoKey."_".$err_key, 1, $intervallo_tempo); $erroriIntervallo['siti'][$sito_key] = xcache_inc("errS".$intervalloTempoKey."_".$sito_key, 1, $intervallo_tempo); } else{ $erroriIntervallo['globale']++; $erroriIntervallo['errori'][$err_key]++; $erroriIntervallo['siti'][$sito_key]++; } if($erroriIntervallo['globale'] == $max_errori_globale){ //raggiunto limite errori globali $oggetto = "Raggiunto limite $max_errori_globale segnalazioni globali in $intervallo_tempo\" (intervallo $intervalloTempoKey)"; $testo = $erroriStats; } else if($erroriIntervallo['errori'][$err_key] == $max_errori_identici){ //raggiunto limite errori dello stesso tipo $oggetto = "Raggiunto limite $max_errori_identici segnalazioni \"$msg[errore]\" in \"$sito_key\" in $intervallo_tempo\" (intervallo $intervalloTempoKey)"; $testo = $erroriStats; } else if($erroriIntervallo['siti'][$sito_key] == $max_errori_sito){ //raggiunto limite errori dallo stesso sito $oggetto = "Raggiunto limite $max_errori_sito segnalazioni per sito \"$sito_key\" in $intervallo_tempo\" (intervallo $intervalloTempoKey)"; $testo = $erroriStats; } } if($gestioneAttiva == 4){ $serialized = serialize(array($intervalloTempoKey => $erroriIntervallo));//ripulisco da vecchi intervalli ftruncate($pointer, 0 /*mb_strlen($serialized)*/); rewind($pointer); fwrite($pointer, $serialized); fflush($pointer); flock($pointer, LOCK_UN); fclose($pointer); } else if($gestioneAttiva == 1){ indiCacheSet($xCacheKey, array($intervalloTempoKey => $erroriIntervallo), $intervallo_tempo); //ripulisco da vecchi intervalli } // else if($gestioneAttiva == 2){ //non c'è da fare niente // } else if($gestioneAttiva == 3){ if($esisteSize){ shmop_delete($shres);//la cancello per ricrearla della dimensione esatta shmop_close($shres); } //salvo gestione 3 $serialized = serialize(array($intervalloTempoKey => $erroriIntervallo));//ripulisco da vecchi intervalli $shres = shmop_open($shmid, "c", 0644, strlen($serialized)); if($shres){ shmop_write($shres, $serialized, 0); shmop_close($shres); } else{ //successo durante un carico alto di mysql //shmop_open triggera comunque un warning che va su error.log //faccio return, perchè sicuramente è un momento di sovraccarico che invierebbe parecchie mail (verificato 19/9/2018 dopo aver aggiunto shmop_close()) return; } } if($oggetto){ if($_GET['testErrori']){ // $GLOBALS['_dev_email'] = "c@localhost"; // $GLOBALS['_dev_email'] = "test@tnx.it"; $oggetto = "[".$intervalloTempoKey."] ".$oggetto; } // return [$oggetto, $testo]; return ['=?UTF-8?B?'.base64_encode($oggetto).'?=', $testo];//fix temporaneo } } //PHP > 5.6 if(!isPhp5_2()){ //funzione da richiamare negli script che danno per scontato che che le magic_quotes siano on, ovvero non chiamano mai get_magic_quotes_gpc() //per compatibilita php 5.2 / 5.6 usare con: //if(function_exists("simulaMagicQuotesTnx")) simulaMagicQuotesTnx(); function simulaMagicQuotesTnx(){ if($GLOBALS['simulaMagicQuotesTnxEseguito']) return; $GLOBALS['simulaMagicQuotesTnxEseguito'] = 1; $_POST = aSMQ($_POST); $_GET = aSMQ($_GET); $_COOKIE = aSMQ($_COOKIE); $_REQUEST = aSMQ($_REQUEST); } //importante non far passare tutti gli errori dal gestore perchè anche un operazione semplice tipo is_array($CONF) prima di controllare e ignorare alcuni tipi di errore consuma oltre 1 secondo per via dei molti notice //E_ALL da php 5.4 comprende anche E_STRICT //E_DEPRECATED esiste da 5.3 //non posso usare lo stesso valore sul php 5.2, succede che ignora gli warning define("ERROR_LEVEL_HANDLER_TNX", E_ALL &~ E_NOTICE &~ E_STRICT &~ E_DEPRECATED); } if(PHP_MAJOR_VERSION >= 7){ if($_GET['apcutnx']){ function apcuFormatSize($size,$unit="") { if( (!$unit && $size >= 1<<30) || $unit == "GB") return number_format($size/(1<<30),2)."GB"; if( (!$unit && $size >= 1<<20) || $unit == "MB") return number_format($size/(1<<20),2)."MB"; if( (!$unit && $size >= 1<<10) || $unit == "KB") return number_format($size/(1<<10),2)."KB"; return number_format($size)." bytes"; } function apcuTimeFix($time){ //apcu usa un conteggio dei secondi a partire dal boot della macchina (macchina contenitore in caso di virtualizzazione!) //attenzione: per quanto riguarda "start_time" all'avvio c'è un timestamp normale, al primo reset inizia a usare il suo formato if($time < 999999999){ if(!$GLOBALS['apcutimeServerBoot']) $GLOBALS['apcutimeServerBoot'] = exec('cat /proc/stat | grep btime | awk \'{ print $2 }\''); return $time + $GLOBALS['apcutimeServerBoot']; } else return $time; } if($_GET['del'] || $_GET['delLike'] || $_GET['delAll']){ if($_GET['del']) apcu_delete($_GET['del']); if($_GET['delLike'] || $_GET['delAll']){ $apcu_cache_info = apcu_cache_info(); foreach($apcu_cache_info['cache_list'] as $c) if($_GET['delAll'] || strpos($c['info'], $_GET['delLike']) !== false) apcu_delete($c['info']); } header("Location: ".$_SERVER['HTTP_REFERER']); } $apcu_sma_info = apcu_sma_info(); $apcu_cache_info = apcu_cache_info(); echo '
". "durata richiesta ".(time()-$_SERVER['REQUEST_TIME'])."
". // "cacheFree ".(round($cacheStat['avail'] / $cacheStat['size'] * 10000)/100)."%
". // "shmid:
".$shmid."\n\n". // "errori counter:
".(print_r($erroriCounterArray, true))."\n\n". "errori intervallo:
".(print_r($erroriIntervallo, true))."\n\n". "
per cancellare in blocco: &delLike={parteDiId} oppure &delAll=1
| $title | "; } echo "
|---|
| $value | "; } echo "
';
// foreach($apcu_cache_info['cache_list'] as $c){
// echo $c['info']." hits:".$c['num_hits']." size:".str_repeat("|", round($c['mem_size']/1000))."\n";
// }
// echo '';
}
/* https://web.archive.org/web/20190204180013/http://xcache.lighttpd.net/wiki/XcacheApi */
function xcache_set($var, $value, $ttl = 0) {
return apcu_store($var, $value, $ttl);
}
function xcache_isset($var) {
return apcu_exists($var);
}
function xcache_unset($var) {
return apcu_delete($var);
}
function xcache_get($var) {
return apcu_fetch($var);
}
function set_magic_quotes_runtime($bool) {
mail(
"c@localhost",
"Uno script sta cercando di ".($bool?'attivare':'disattivare')." le magic_quotes (funzione rimossa in php 5.4, ma simulata nei nostri script con simulaMagicQuotesTnx())",
__FILE__.":".__LINE__."\n".print_r(array($_REQUEST, $_SERVER), true)
);
}
function mysql_ping($a = null){
if(!function_exists("mysql_tnx_ping")) mysql_tnx_debug_backtrace();
return mysql_tnx_ping($a);
}
function mysql_tnx_debug_backtrace(){
$debugBacktrace = debug_backtrace();
die("Aggiornare a mysqli (chiamata a ".$debugBacktrace[1]['function']."() in ".$debugBacktrace[1]['file'].":".$debugBacktrace[1]['line'].")");
}
function mysql_query($a, $b = null){
if(!function_exists("mysql_tnx_query")) mysql_tnx_debug_backtrace();
return mysql_tnx_query($a, $b);
}
function mysql_fetch_assoc($a){
if(!function_exists("mysql_tnx_fetch_assoc")) mysql_tnx_debug_backtrace();
return mysql_tnx_fetch_assoc($a);
}
function mysql_fetch_array($a){
if(!function_exists("mysql_tnx_fetch_array")) mysql_tnx_debug_backtrace();
return mysql_tnx_fetch_array($a);
}
function mysql_fetch_row($a){
if(!function_exists("mysql_tnx_fetch_row")) mysql_tnx_debug_backtrace();
return mysql_tnx_fetch_row($a);
}
function mysql_connect($a, $b, $c){
if(!function_exists("mysql_tnx_connect")) mysql_tnx_debug_backtrace();
return mysql_tnx_connect($a, $b, $c);
}
function mysql_close($a = null){
if(!function_exists("mysql_tnx_close")) mysql_tnx_debug_backtrace();
return mysql_tnx_close($a = null);
}
function mysql_select_db($a, $b = null){
if(!function_exists("mysql_tnx_select_db")) mysql_tnx_debug_backtrace();
return mysql_tnx_select_db($a, $b = null);
}
function mysql_free_result($a){
if(!function_exists("mysql_tnx_free_result")) mysql_tnx_debug_backtrace();
return mysql_tnx_free_result($a);
}
function mysql_num_fields($a){
if(!function_exists("mysql_tnx_num_fields")) mysql_tnx_debug_backtrace();
return mysql_tnx_num_fields($a);
}
function mysql_num_rows($a) {
if(!function_exists("mysql_tnx_num_rows")) mysql_tnx_debug_backtrace();
return mysql_tnx_num_rows($a) ;
}
function mysql_field_name($a, $i){
if(!function_exists("mysql_tnx_field_name")) mysql_tnx_debug_backtrace();
return mysql_tnx_field_name($a, $i);
}
function mysql_errno($a = null){
if(!function_exists("mysql_tnx_errno")) mysql_tnx_debug_backtrace();
return mysql_tnx_errno($a = null);
}
function mysql_error($a = null){
if(!function_exists("mysql_tnx_error")) mysql_tnx_debug_backtrace();
return mysql_tnx_error($a = null);
}
function mysql_insert_id($a = null) {
if(!function_exists("mysql_tnx_insert_id")) mysql_tnx_debug_backtrace();
return mysql_tnx_insert_id($a = null) ;
}
function mysql_affected_rows($a = null) {
if(!function_exists("mysql_tnx_affected_rows")) mysql_tnx_debug_backtrace();
return mysql_tnx_affected_rows($a = null) ;
}
function mysql_escape_string($a){
if(!function_exists("mysql_tnx_escape_string")) mysql_tnx_debug_backtrace();
return mysql_tnx_escape_string($a);
}
function mysql_real_escape_string($a){
if(!function_exists("mysql_tnx_real_escape_string")) mysql_tnx_debug_backtrace();
return mysql_tnx_real_escape_string($a);
}
function mssql_connect($servername, $username = null, $password = null, $new_link = FALSE) {
$connectionInfo = array("UID"=> $username, "PWD"=> $password);
$conn = sqlsrv_connect($servername, $connectionInfo);
if(!$conn) {
echo "Connection could not be established.