L = new Log(__CLASS__); # inizializza variabili $this->dbp = $dbp; $this->connect(); } # Stabilisce una connessione al DB function connect($force = false) { $this->L->setMethod(__METHOD__); try { if($force) { $this->connectionIndex = (int)$force; } else { $this->L->w("test connessione..."); for($i = $this->connectionIndex; $i < sizeof($this->dbp); $i++ ) { $dbc = $this->dbp[ $this->connectionIndex ]; $this->connectionIndex = $i; $this->L->w("connesione $i - ip " . $dbc[0]); try { $this->pdo = new PDO( 'mysql:host='.$dbc[0].';dbname='.$dbc[3], $dbc[1], $dbc[2], array( PDO::ATTR_TIMEOUT => 1, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ) ); break; } catch(Exception $e) { error_log("connessione a db $i fallita"); } } } } catch(Exception $e) { $this->L->w("ATTENZIONE: --> Impossibile connettersi al database"); echo "piattaforma in manutenzione. Ci scusiamo per il disagio
"; die; } } function query($query) { try { $this->pdo->query("SET NAMES 'utf8'"); if($this->prepared) $res = $this->stmntPrep; else { $res = $this->pdo->prepare($query); $res->execute(); } $this->lid = $this->pdo->lastInsertId(); $this->prepared = false; return $res; } catch(Exception $e) { $this->error(); } } # restituisce l'ultimo messaggio del db function error($out = 0) { $this->error = $this->pdo->errorInfo(); error_log("Query KO..."); error_log("errore n. ".mysql_errno()); error_log(mysql_error()); error_log($query); if($out >1) error_log($this->error); } # metodo query # esegue una query e restituisce un resultset function queryVerbose($query, $msg = "Operazione completata con successo") { if($this->res = $this->pdo->query($query)) { error_log("uqery ok"); } else { $msg = "Errore database: ".mysql_error(); } return $msg; } function select($tab, $fields, $where = array(), $order = "", $dir = "asc", $start = 0, $limit = 0, $groupby = "") { $this->L->setMethod(__METHOD__); $wh = ""; $ff = ""; foreach($fields as $i => $f) $ff .= ", ".$f; foreach($where as $k => $v) $wh .= "and $k = '$v' "; $ff = substr($ff, 1); $wh = substr($wh, 3); if($groupby != "") $groupby = "group by ".$groupby; if($order != "") $oo = "order by $order $dir"; if($limit > 0 ) $ll = "limit $start, $limit"; $q = " select $ff from $tab where $wh $groupby $oo $ll "; return $q; } function insert($tab, $params) { $fields = ""; $values = ""; $places = ""; $items = array(); foreach($params as $f => $v) { $fields .= ", ".$f; $values .= ", '".$v."'"; $places .= ", ':".$f."'"; $items[$f] = $v; } $fields = substr($fields, 1); $values = substr($values, 1); $places = substr($values, 1); $q = " insert into $tab (".$fields.") values (".$values."); "; // pdo specifico $qP = " insert into $tab (".$fields.") values (".$places."); "; $this->prepared = true; $this->stmntPrep = $this->pdo->prepare($qP); $this->stmntPrep->execute($items); return $q; } function mod($tab, $params, $where) { $p = $w = ""; $places = ""; $items = array(); foreach($params as $f => $v) { $p .= ", $f = '$v' "; } foreach($where as $f => $v) { $w .= "and $f = '$v' "; } $p = substr($p, 1); $w = substr($w, 3); $q = " update $tab set ".$p." where ".$w; return $q; } function del($tab, $params) { $w = ""; foreach($params as $f => $v) $w .= "and $f = '$v' "; $w = substr($w, 3); $q = " delete from $tab where ". $w; return $q; } function doArray($q) { $elenco = array(); if($this->prepared) $res = $this->stmntPrep; else $res = $this->query($q); $elenco = $res->fetchAll(PDO::FETCH_ASSOC); $this->prepared = false; return $elenco; } # metodo fetch_row function fetch_row($res) { if($this->prepared) $res = $this->stmntPrep; else $this->res = $res; $this->prepared = false; return $res->fetch(PDO::FETCH_COLUMN); } # metodo fetch_array() function fetch_array($res) { if($this->prepared) $res = $this->stmntPrep; else $this->res = $res; $this->prepared = false; return $res->fetch(PDO::FETCH_ASSOC); } # metodo rows # restituisce il numero di righe nel recordset function rows($res) { $this->res = $res; return $res->rowCount(); } # metodo result # restituisce il risultato di riga e campo # se riga e campo non sono specificati vengono impostati per default a 0 (prima riga primo campo) function result($res, $riga = 0, $campo = 0) { # return @mysql_result($res, $riga, $campo); return $res->fetchColumn(0); } # metodo last_id() # restituisce l'ultimo id generato dalla insert function last_id() { return $this->lid; } function lid() { return $this->lid; } function getEnumField($tabella, $campo, $valore = "") { $q = "show columns from ".$tabella." where field = '".$campo."'"; $r = $this->fetch_array($this->query($q)); $r = $r['Type']; $r = substr($r, 5, strlen($r) - 7); $r = str_replace("'", "", $r); $r = explode(",", $r); $out = array(); foreach($r as $k) { $sel = ""; if($k == $valore) $sel = "selected"; $out[$k] = $sel; } return $out; } } function mysql_real_escape_string($v) { return $v; }
( ! ) Warning: session_start(): Session cannot be started after headers have already been sent in /var/www/html/creaArchitettura.it/conf/configuration.php on line 8
Call Stack
#TimeMemoryFunctionLocation
10.0004370368{main}( ).../sitemap.xml.php:0
20.0009386728require( '/var/www/html/creaArchitettura.it/conf/configuration.php ).../sitemap.xml.php:4
30.0010387056session_start( ).../configuration.php:8

( ! ) Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/creaArchitettura.it/classes/DB.class.php:1) in /var/www/html/creaArchitettura.it/conf/configuration.php on line 10
Call Stack
#TimeMemoryFunctionLocation
10.0004370368{main}( ).../sitemap.xml.php:0
20.0009386728require( '/var/www/html/creaArchitettura.it/conf/configuration.php ).../sitemap.xml.php:4
30.0010387056header( $header = 'Access-Control-Allow-Origin:*' ).../configuration.php:10

( ! ) Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/creaArchitettura.it/classes/DB.class.php:1) in /var/www/html/creaArchitettura.it/conf/configuration.php on line 11
Call Stack
#TimeMemoryFunctionLocation
10.0004370368{main}( ).../sitemap.xml.php:0
20.0009386728require( '/var/www/html/creaArchitettura.it/conf/configuration.php ).../sitemap.xml.php:4
30.0011387104header( $header = 'x-content-type-options:nosniff' ).../configuration.php:11

( ! ) Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/creaArchitettura.it/classes/DB.class.php:1) in /var/www/html/creaArchitettura.it/conf/configuration.php on line 12
Call Stack
#TimeMemoryFunctionLocation
10.0004370368{main}( ).../sitemap.xml.php:0
20.0009386728require( '/var/www/html/creaArchitettura.it/conf/configuration.php ).../sitemap.xml.php:4
30.0012387104header( $header = 'x-dns-prefetch-control:off' ).../configuration.php:12

( ! ) Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/creaArchitettura.it/classes/DB.class.php:1) in /var/www/html/creaArchitettura.it/conf/configuration.php on line 13
Call Stack
#TimeMemoryFunctionLocation
10.0004370368{main}( ).../sitemap.xml.php:0
20.0009386728require( '/var/www/html/creaArchitettura.it/conf/configuration.php ).../sitemap.xml.php:4
30.0012387104header( $header = 'x-frame-options:SAMEORIGIN' ).../configuration.php:13

( ! ) Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/creaArchitettura.it/classes/DB.class.php:1) in /var/www/html/creaArchitettura.it/conf/configuration.php on line 14
Call Stack
#TimeMemoryFunctionLocation
10.0004370368{main}( ).../sitemap.xml.php:0
20.0009386728require( '/var/www/html/creaArchitettura.it/conf/configuration.php ).../sitemap.xml.php:4
30.0012387104header( $header = 'x-xss-protection:1; mode=block' ).../configuration.php:14

( ! ) Fatal error: Uncaught Error: Class "DB" not found in /var/www/html/creaArchitettura.it/sitemap.xml.php on line 5
( ! ) Error: Class "DB" not found in /var/www/html/creaArchitettura.it/sitemap.xml.php on line 5
Call Stack
#TimeMemoryFunctionLocation
10.0004370368{main}( ).../sitemap.xml.php:0