From 435808a90a696c06940d199d1ca8e1485a36e20f Mon Sep 17 00:00:00 2001 From: GIService Date: Tue, 24 Jan 2023 12:41:50 +0100 Subject: [PATCH] upload --- bckmap.php | 1369 +++++++++++++++++++++++++++++ cataistanze.php | 1471 +++++++++++++++++++++++++++++++ catamap.php | 1490 ++++++++++++++++++++++++++++++++ catasearch.php | 200 +++++ catavincoli.php | 769 +++++++++++++++++ cdu_level.php | 657 ++++++++++++++ cfg.php | 42 + cfg_srv.php | 25 + decrypt.php | 7 + detail.php | 1387 ++++++++++++++++++++++++++++++ draw.php | 166 ++++ encrypt.php | 68 ++ error.php | 56 ++ favicon.ico | Bin 0 -> 1150 bytes index.php | 413 +++++++++ intro.php | 29 + legenda.php | 236 +++++ load.php | 65 ++ load2.php | 50 ++ map_info.php | 458 ++++++++++ marker-icon-2x.png | Bin 0 -> 2464 bytes marker-icon.png | Bin 0 -> 1466 bytes mc_footer2.php | 27 + mc_header2.php | 28 + mobile_detect.php | 1341 +++++++++++++++++++++++++++++ routine.php | 54 ++ routine_feature.php | 359 ++++++++ routine_map.php | 80 ++ routine_map_bckoffice.php | 109 +++ routine_map_interventi.php | 90 ++ routine_map_ricercageo.php | 42 + routine_rec.php | 1671 ++++++++++++++++++++++++++++++++++++ 32 files changed, 12759 insertions(+) create mode 100755 bckmap.php create mode 100755 cataistanze.php create mode 100755 catamap.php create mode 100755 catasearch.php create mode 100755 catavincoli.php create mode 100755 cdu_level.php create mode 100755 cfg.php create mode 100755 cfg_srv.php create mode 100755 decrypt.php create mode 100755 detail.php create mode 100755 draw.php create mode 100755 encrypt.php create mode 100755 error.php create mode 100755 favicon.ico create mode 100755 index.php create mode 100755 intro.php create mode 100755 legenda.php create mode 100755 load.php create mode 100755 load2.php create mode 100755 map_info.php create mode 100755 marker-icon-2x.png create mode 100755 marker-icon.png create mode 100755 mc_footer2.php create mode 100755 mc_header2.php create mode 100755 mobile_detect.php create mode 100755 routine.php create mode 100755 routine_feature.php create mode 100755 routine_map.php create mode 100755 routine_map_bckoffice.php create mode 100644 routine_map_interventi.php create mode 100755 routine_map_ricercageo.php create mode 100755 routine_rec.php diff --git a/bckmap.php b/bckmap.php new file mode 100755 index 0000000..1463b52 --- /dev/null +++ b/bckmap.php @@ -0,0 +1,1369 @@ + + + + + + + + + + +Paesaggistica Sicilia + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Skip to main content +
+
+ + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+
+ + + + +
+

Questo sito utilizza cookie tecnici, analytics e di terze parti.
Proseguendo nella navigazione accetti l’utilizzo dei cookie.

+
+ +
+
+ + + + + + + + + + + + + diff --git a/cataistanze.php b/cataistanze.php new file mode 100755 index 0000000..9a47dc9 --- /dev/null +++ b/cataistanze.php @@ -0,0 +1,1471 @@ + + + + + + + + + + + + + + + +mapcloud - mapping services + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Skip to main content +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+
+ + + + + + + + + + + + + diff --git a/catamap.php b/catamap.php new file mode 100755 index 0000000..69c5e93 --- /dev/null +++ b/catamap.php @@ -0,0 +1,1490 @@ + + + + + + + + + + + + + + +Paesaggistica Sicilia + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Skip to main content +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+
+ + + + + + + + + + + + + diff --git a/catasearch.php b/catasearch.php new file mode 100755 index 0000000..2f735dd --- /dev/null +++ b/catasearch.php @@ -0,0 +1,200 @@ + + + + +CDU + + + + + + + + + + + + + + + + +
+ +"; +//echo "QUERY=".$_SESSION['QUERY_CDU']."
"; +//echo "PROV=".strtolower($_SESSION['COMUNE_PROV'])."
"; + +if ($_GET['mode'] == "new") { + $_SESSION['QUERY_CDU'] = ""; + $_SESSION['PARTICELLE'] = ""; + $_SESSION['CATA_TABLE'] = ""; + $_SESSION['cataparticella'] = ""; + } + +if (!empty($_SESSION['cataparticella'])) { + //$arraycata[] = $_SESSION['cataparticella']; + $arraycata = explode(";", $_SESSION['cataparticella']); +} + +if (!empty($_POST['mappale'])) { + $arraycata = $_POST['mappale']; +} + + $valorecata = count($arraycata); + +// INIZIO PROCEDURA DI RICERCA PROVENIENTE DA FORM QUESTA PAGINA +//if($_POST['mappale']) { +if($valorecata > 0) { + + echo "Dati catastali inseriti:

"; + + foreach( $arraycata as $index => $mappale ) { + + if(strlen($valorecata) > 0) { //CALCOLA LA LUNGHEZZA DELLA STRINGA ARRAY + + $arr = explode("-", $mappale); + echo '» Foglio: '.$arr[0].'   Particella: '.$arr[1].''; + + $query = "SELECT id FROM ".strtolower($_SESSION['COMUNE_PROV']).".particelle WHERE comune = '".$_SESSION['COMUNE_BELF']."' AND mappale ='".trim($mappale)."'"; + $result_query = pg_query($conn, $query) or die('ERROR query_mappale: '); + $numrec = pg_numrows($result_query); + //echo "REC = ". $numrec ."
"; + if ($numrec > 0) { + + while($rowparticelle = pg_fetch_assoc($result_query)) { $gidquery[] = $rowparticelle['id']; } + echo "
"; + $_SESSION['CATA_TABLE'] = strtolower($_SESSION['COMUNE_PROV']).".particelle"; + + } elseif ($numrec == 0) { + + $query = "SELECT id FROM public.particelle_modificate WHERE comune = '".$_SESSION['COMUNE_BELF']."' AND mappale ='".$mappale."'"; + $result_query = pg_query($conn, $query) or die('ERROR query_mappale_modificato: '); + + while($rowparticelle = pg_fetch_assoc($result_query)) { $gidquery[] = $rowparticelle['id']; } + echo "
"; + $_SESSION['CATA_TABLE'] = "public.particelle_modificate"; + + } else { echo "
".$foglioparticella."   » particella non trovata
";} + } + } + + $valorearray = count($gidquery); + $stringa = implode(' OR id=', $gidquery); + $_SESSION['QUERY_CDU'] = $stringa; + //echo '
STRINGA: '.$_SESSION['QUERY_CDU']; + + if ($stringa != "") { + + // INIZIO CALCOLO GEOMETRIE E ZOOM + if(!$strcoordinate = @pg_query("SELECT ST_X(ST_Transform(ST_Centroid(ST_Union(geom)),4326)) as long, ST_Y(ST_Transform(ST_Centroid(ST_union(geom)),4326)) as lat FROM ".$_SESSION['CATA_TABLE']." WHERE comune = '".$_SESSION['COMUNE_BELF']."' AND id=".$_SESSION['QUERY_CDU'].";")) + die("Errore CENTRO PARTICELLA: " . pg_last_error($conn)); + while($rowcoord = pg_fetch_assoc($strcoordinate)) { + $_SESSION['CENTER'] = $rowcoord['lat'] .", ".$rowcoord['long']; + } + + function escapeJsonString($value) { # list from www.json.org: (\b backspace, \f formfeed) + $escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c"); + $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b"); + $result = str_replace($escapers, $replacements, $value); + return $result; + } + + // CALCOLA GEOMETRIA PARTICELLA + //$sql_catasto = "SELECT ST_AsGeoJSON(ST_Transform(geom,4326)) AS cata_geojson, round(ST_Area(geom)::numeric,2) as area + $sql_catasto = "SELECT ST_AsGeoJSON(ST_Transform(geom,4326)) AS cata_geojson FROM ".$_SESSION['CATA_TABLE']." WHERE comune = '".$_SESSION['COMUNE_BELF']."' AND id=".$_SESSION['QUERY_CDU'].""; + + $rs = pg_query($conn, $sql_catasto); + if (!$rs) { + echo "ERROR GEOM PARTICELLE.\n"; + } else { + // echo "QUERY OKKEY

"; + } + + $output = ''; $rowOutput = ''; + + while ($row = pg_fetch_assoc($rs)) { + $rowOutput = (strlen($rowOutput) > 0 ? ',' : '') . '{"type": "Feature", "properties": {'; + $props = ''; + $id = ''; + foreach ($row as $key => $val) { + if ($key != "cata_geojson") { + $props .= (strlen($props) > 0 ? ',' : '') . '"' . $key . '":"' . escapeJsonString($val) . '"'; + } + if ($key == "id") { + $id .= ',"id":"' . escapeJsonString($val) . '"'; + } + } + $rowOutput .= $props . '}, "geometry": ' . $row['cata_geojson'] . ''; + $rowOutput .= $id; + $rowOutput .= '}'; + $output .= $rowOutput; + } + + $_SESSION['SELECT_PARTICELLA'] = '{ "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4326" } }, "features": [ ' . $output . ' ] }'; + $_SESSION['ZOOM'] = 16; + // FINE CALCOLO GEOMETRIE E ZOOM + + echo ""; + ?> + +
+ +
   Visualizza mappa
+ +
   Completa la geolocalizzazione
+ +
   Localizza intervento
+ +
   Nuova interrogazione
+ +
Verificare con esattezza i dati catastali.
è possibile che sia presente un frazionamento recente o un'area riservata;
contattare il supporto."; + } +} +?> + + +
Verifica regime vincolistico:
+Foglio-Particella, es: 15-234

+
+

    

+ +

+ +
+

+ + +

+ + \ No newline at end of file diff --git a/catavincoli.php b/catavincoli.php new file mode 100755 index 0000000..99e78ee --- /dev/null +++ b/catavincoli.php @@ -0,0 +1,769 @@ + + + + + + + + + + + + + + +"; +$text = preg_replace($tags, $replacement, $text); +$text = preg_replace("/=\"\"/", "=", $text); +return $text; +} +$mode = $_GET['mode']; +$idwg = $_GET['id']; + + + +if ($mode == "wg") { + if (strlen($idwg) > 9) { + $cata = explode(".", $idwg); //VARIABILE PER LA RICERCA DEI CATASTALI + $cataid = $cata[1]; //VARIABILE PER LA RICERCA DEI CATASTALI + } else { + $cataid = $idwg; //VARIABILE PER LA RICERCA DEI CATASTALI + } +} else { + $cataid = $_SESSION['QUERY_CDU']; //VARIABILE PER LA RICERCA DEI CATASTALI +} + $comu_cata = strtolower($_SESSION['COMUNE_PROV']).".particelle"; // COMPOSIZIONE TABELLA PARTICELLE-COMUNE + $comu_prg = strtolower($_SESSION['COMUNE_PROV']).".zoning"; // COMPOSIZIONE TABELLA ZONING-COMUNE + $comu = $_SESSION['COMUNE_BELF']; // COMPOSIZIONE TABELLA ZONING-COMUNE + $comu_vincoprg = strtolower($_SESSION['COMUNE_PROV']).".vincoli"; // COMPOSIZIONE TABELLA ZONING-COMUNE + +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + count($daticata_view)) { ?> + + + + count($daticata_view)) { ?> + + + + count($daticata_view)) { ?> + + + + + + + + + + + + + + + + + + +
logo
Regione Siciliana
Dipartimento dei Beni Culturali e dell'Identità Siciliana
- - - - - - - - - - - - - - -
ANTEPRIMA REGIME VINCOLISTICO
+
Particelle individuate:

+ 0 ) { + while($lista = pg_fetch_assoc($rs_dati)) { + //$daticata = explode("-", substr($lista['mappale'],5,20)); + $daticata = explode("-", $lista['mappale']); + echo "   » Foglio: ". $daticata[0]."     Particella: ".$daticata[1]."    (area ".round($lista['area'],3)." m2)
"; + + $formcata = $lista['mappale']; + if ($row_dati_list == 1) { + $daticata_view[] = $formcata; + } + if ($row_dati_list > 1) { + $daticata_view[] = $formcata."; "; + } + } + } +//############# END CADASTRAL LIST + +//############# BEGIN LAT & LONG + if(!$strcoordinate = @pg_query("SELECT ST_X(ST_Transform(ST_Centroid(ST_Union(geom)),4326)) as long, + ST_Y(ST_Transform(ST_Centroid(ST_union(geom)),4326)) as lat + FROM ".$_SESSION['CATA_TABLE']." WHERE comune = '".$_SESSION['COMUNE_BELF']."' AND id = ".$_SESSION['QUERY_CDU']."")) + die("Errore CENTRO COMUNE: " . pg_last_error($conn)); + while($rowcoord = pg_fetch_assoc($strcoordinate)) { + $coord_lat[] = $rowcoord['lat']; + $coord_long[] = $rowcoord['long']; + } +//############# END LAT & LONG +?> + + + +
+
+ + + + + + + + + + +"; + $foglio = $row3['foglio']; + $area_sezione = $row3['area']; + $particella = $row3['numero']; + $idparticella = $row3['id']; + +// PARTICELLE INTERESSATE +echo "\n\t\n\t\t\n\t"; + +//####### BEGIN RECORD ######## +$record_paesaggio[] = "Foglio ".$foglio." - Particella ".$particella."\n"; +$record_tutela[] = "Foglio ".$foglio." - Particella ".$particella."\n"; +$record_vincoli[] = "Foglio ".$foglio." - Particella ".$particella."\n"; +//####### END RECORD ######## + +// INIZIO DEFINIZIONE DELLA COPERTURA DELLA ZONAZIONE + $query_zoning = "SELECT a.descdest, ST_AREA(ST_intersection(a.geom, b.geom)) AS areazto FROM (SELECT descdest, geom FROM public.zoning_stir) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_zoning = pg_query($conn, $query_zoning) or die('Query query_zoning failied'); + + if (pg_num_rows($result_query_zoning) > 0) { + while($row4 = pg_fetch_assoc($result_query_zoning)) { + $areazto_percent = round(($row4['areazto']/$area_sezione)*100,2); + + //$zto_array[] = $row4['zon_sigla']." - ".row4['zon_descr']; + + //####### BEGIN RECORD ######## + //$record_form[] = row4['zon_descr']."\n"; + //####### END RECORD ######## + + if ($areazto_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + //$ntart[] = $row4['zon_art']; + + }}} +// FINE DEFINIZIONE DELLA COPERTURA DELLA ZONAZIONE + + +// INIZIO DEFINIZIONE DELLA COPERTURA DEI VINCOLI DI PRG + $query_prgvincoli = "SELECT a.zon_descr, ST_AREA(ST_intersection(a.geom, b.geom)) AS areavinc FROM (SELECT zon_descr, geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".vincoli) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_prgvincoli = pg_query($conn, $query_prgvincoli) or die('Query query_prgvincoli failied'); + + if (pg_num_rows($result_query_prgvincoli) > 0) { + while($row5 = pg_fetch_assoc($result_query_prgvincoli)) { + $areavinc_percent = round(($row5['areavinc']/$area_sezione)*100,2); + + if ($areavinc_percent > 10) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + } + } + } +// FINE DEFINIZIONE DELLA COPERTURA DEI VINCOLI DI PRG + +// INIZIO DEFINIZIONE DELLA COPERTURA DEI VINCOLI BBCCAA + $query_regimi = "SELECT a.pl, a.liv_tutela, a.contesto, ST_AREA(ST_intersection(a.geom, b.geom)) AS areabbccaa FROM (SELECT pl, liv_tutela, contesto, geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".regimi_normativi) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_regimi = pg_query($conn, $query_regimi) or die('Query query_regimi failied'); + + if (pg_num_rows($result_query_regimi) > 0) { + while($row6 = pg_fetch_assoc($result_query_regimi)) { + $area_bbccaa_percent = round(($row6['areabbccaa']/$area_sezione)*100,2); + + switch ($row6['liv_tutela']) { + case 1: + $bbccaa = "Livello di tutela 1"; + break; + case 2: + $bbccaa = "Livello di tutela 2"; + break; + case 3: + $bbccaa = "Livello di tutela 3"; + break; + case 4: + $bbccaa = "Livello di tutela 4"; + break; + default: + $bbccaa = ""; + } + + if ($area_bbccaa_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_paesaggio[] = "Paesaggio Locale: ".$row6['pl']."     Contesto: ".$row6['contesto']."\n"; + $record_tutela[] = $bbccaa."\n"; + //####### END RECORD ######## + }}} +// FINE DEFINIZIONE DELLA COPERTURA DEI VINCOLI BBCCAA + + + +if ($_SESSION['COMUNE_PROV'] == 'TP') { + + // INIZIO DEFINIZIONE DELLA COPERTURA REGIMI NORMATIVI TP1 + $query_regimi_tp1 = "SELECT a.regime_nor, a.denominazi, a.codice, ST_AREA(ST_intersection(a.geom, b.geom)) AS areatp1 FROM (SELECT regime_nor, denominazi, codice, geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".regimi_normativi_tp1) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_regimi_tp1 = pg_query($conn, $query_regimi_tp1) or die('Query query_regimi_tp1 failied'); + + if (pg_num_rows($result_query_regimi_tp1) > 0) { + while($row6 = pg_fetch_assoc($result_query_regimi_tp1)) { + $area_bbccaa_percent = round(($row6['areatp1']/$area_sezione)*100,2); + + if ($area_bbccaa_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_paesaggio[] = "Denominazione: ".$row6['denominazi']."     Codice: ".$row6['codice']."\n"; + //####### END RECORD ######## + }}} + // FINE DEFINIZIONE DELLA COPERTURA REGIMI NORMATIVI TP1 + + // INIZIO DEFINIZIONE DELLA COPERTURA FASCIA COSTA + $query_costa = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_costa FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".fascia_rispetto_costa) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_costa = pg_query($conn, $query_costa) or die('Query query_costa failied'); + + if (pg_num_rows($result_query_costa) > 0) { + while($row6bb = pg_fetch_assoc($result_query_costa)) { + $area_v_percent = round(($row6bb['area_costa']/$area_sezione)*100,2); + + if ($area_v_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Fascia di rispetto della costa - art. 54 NdA\n"; + //####### BEGIN RECORD ######## + }}} + // FINE DEFINIZIONE DELLA COPERTURA FASCIA COSTA + + // INIZIO DEFINIZIONE DELLA COPERTURA AREA RECUPERO + $query_recupero = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_recupero FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".area_recupero) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_recupero = pg_query($conn, $query_recupero) or die('Query query_recupero failied'); + + if (pg_num_rows($result_query_recupero) > 0) { + while($row6cc = pg_fetch_assoc($result_query_recupero)) { + $area_v_percent = round(($row6cc['area_recupero']/$area_sezione)*100,2); + + if ($area_v_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Area di recupero - art. 51 NdA\n"; + //####### BEGIN RECORD ######## + }}} + // FINE DEFINIZIONE DELLA COPERTURA AREA RECUPERO + +} + + +// INIZIO DEFINIZIONE DELLA COPERTURA V_1497 + $query_v_1497 = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_1497 FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_1497) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_1497 = pg_query($conn, $query_v_1497) or die('Query query_v_1497 failied'); + + if (pg_num_rows($result_query_v_1497) > 0) { + while($row6a = pg_fetch_assoc($result_query_v_1497)) { + $area_v_percent = round(($row6a['area_v_1497']/$area_sezione)*100,2); + + if ($area_v_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Area tutelata (art.136, D.lgs.42/04)\n"; + //####### BEGIN RECORD ######## + }}} +// FINE DEFINIZIONE DELLA COPERTURA V_1497 + +// INIZIO DEFINIZIONE DELLA COPERTURA V_ARCHEO + $query_v_archeo = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_archeo FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_archeo) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_archeo = pg_query($conn, $query_v_archeo) or die('Query query_v_archeo failied'); + + if (pg_num_rows($result_query_v_archeo) > 0) { + while($row6b = pg_fetch_assoc($result_query_v_archeo)) { + $area_v_archeo_percent = round(($row6b['area_v_archeo']/$area_sezione)*100,2); + + if ($area_v_archeo_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Vincolo Archeologico (art.10, D.lgs.42/04)\n"; + //####### BEGIN RECORD ######## + + }}} +// FINE DEFINIZIONE DELLA COPERTURA V_ARCHEO + + +// INIZIO DEFINIZIONE DELLA COPERTURA V_BOSCHI + /* */ + $query_v_boschi = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_boschi FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_boschi) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_boschi = pg_query($conn, $query_v_boschi) or die('Query query_v_boschi failied'); + + if (pg_num_rows($result_query_v_boschi) > 0) { + while($row6c = pg_fetch_assoc($result_query_v_boschi)) { + $area_v_boschi_percent = round(($row6c['area_v_boschi']/$area_sezione)*100,2); + + if ($area_v_boschi_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Aree boscate (art.142, lett. g, D.lgs.42/04)\n"; + //####### BEGIN RECORD ######## + + }}} + +// FINE DEFINIZIONE DELLA COPERTURA V_BOSCHI + + +// INIZIO DEFINIZIONE DELLA COPERTURA V_COSTA + $query_v_costa = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_costa FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_costa) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + //echo $query_v_costa."
"; + $result_query_v_costa = pg_query($conn, $query_v_costa) or die('Query query_v_costa failied'); + + if (pg_num_rows($result_query_v_costa) > 0) { + while($row6d = pg_fetch_assoc($result_query_v_costa)) { + $area_v_percent = round(($row6d['area_v_costa']/$area_sezione)*100,2); + + if ($area_v_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Aree costa 300m (art.142, lett.a, D.lgs. 42/04)\n"; + //####### BEGIN RECORD ######## + + }}} +// FINE DEFINIZIONE DELLA COPERTURA V_COSTA + + +// INIZIO DEFINIZIONE DELLA COPERTURA V_FIUMI + $query_v_fiumi = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_fiumi FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_fiumi) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_fiumi = pg_query($conn, $query_v_fiumi) or die('Query query_v_fiumi failied'); + + if (pg_num_rows($result_query_v_fiumi) > 0) { + while($row6e = pg_fetch_assoc($result_query_v_fiumi)) { + $area_v_percent = round(($row6e['area_v_fiumi']/$area_sezione)*100,2); + + if ($area_v_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Aree fiumi 150m (art.142, lett. c, D.lgs.42/04)\n"; + //####### BEGIN RECORD ######## + + }}} +// FINE DEFINIZIONE DELLA COPERTURA V_FIUMI + + +// INIZIO DEFINIZIONE DELLA COPERTURA V_INTERESSE_ARCHEO + $query_v_interesse_archeo = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_interesse_archeo FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_interesse_archeo) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_interesse_archeo = pg_query($conn, $query_v_interesse_archeo) or die('Query query_v_interesse_archeo failied'); + + if (pg_num_rows($result_query_v_interesse_archeo) > 0) { + while($row6f = pg_fetch_assoc($result_query_v_interesse_archeo)) { + $area_v_percent = round(($row6f['area_v_interesse_archeo']/$area_sezione)*100,2); + + if ($area_v_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Aree di interesse archeologico (art.142, lett. m, D.lgs.42/04)\n"; + //####### BEGIN RECORD ######## + + }}} +// FINE DEFINIZIONE DELLA COPERTURA V_INTERESSE_ARCHEO + + +// INIZIO DEFINIZIONE DELLA COPERTURA V_LAGHI + $query_v_laghi = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_laghi FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_laghi) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_laghi = pg_query($conn, $query_v_laghi) or die('Query query_v_laghi failied'); + + if (pg_num_rows($result_query_v_laghi) > 0) { + while($row6g = pg_fetch_assoc($result_query_v_laghi)) { + $area_v_percent = round(($row6g['area_v_laghi']/$area_sezione)*100,2); + + if ($area_v_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Aree laghi 300m (art.142, lett. b, D.lgs. 42/04)\n"; + //####### BEGIN RECORD ######## + }}} +// FINE DEFINIZIONE DELLA COPERTURA V_LAGHI + + +// INIZIO DEFINIZIONE DELLA COPERTURA V_LETTERA_C + $query_v_lettera_c = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_lettera_c FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_lettera_c) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_lettera_c = pg_query($conn, $query_v_lettera_c) or die('Query query_v_lettera_c failied'); + + if (pg_num_rows($result_query_v_lettera_c) > 0) { + while($row6h = pg_fetch_assoc($result_query_v_lettera_c)) { + $area_v = $row6h['area_v_lettera_c']; + $area_v_percent = round(($area_v/$area_sezione)*100,2); + + if ($area_v_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Aree tutelate (art.134, lett. c, D.lgs. 42/04)\n"; + //####### BEGIN RECORD ######## + }}} +// FINE DEFINIZIONE DELLA COPERTURA V_LETTERA_C + + +// INIZIO DEFINIZIONE DELLA COPERTURA V_RISERVE + $query_v_riserve = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_riserve FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_riserve) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_riserve = pg_query($conn, $query_v_riserve) or die('Query query_v_riserve failied'); + + if (pg_num_rows($result_query_v_riserve) > 0) { + while($row6i = pg_fetch_assoc($result_query_v_riserve)) { + $area_v = $row6i['area_v_riserve']; + $area_v_percent = round(($area_v/$area_sezione)*100,2); + + if ($area_v_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Aree riserve regionali (art.142, lett. f, D.lgs.42/04)\n"; + //####### BEGIN RECORD ######## + }}} +// FINE DEFINIZIONE DELLA COPERTURA V_RISERVE + +// INIZIO DEFINIZIONE DELLA COPERTURA V_PARCHI + $query_v_parchi = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_parchi FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_parchi) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_parchi = pg_query($conn, $query_v_parchi) or die('Query query_v_parchi failied'); + + if (pg_num_rows($result_query_v_parchi) > 0) { + while($row6l = pg_fetch_assoc($result_query_v_parchi)) { + $area_v_percent = round(($row6l['area_v_parchi']/$area_sezione)*100,2); + + if ($area_v_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Parchi regionali (art.142, lett. f, D.lgs.42/04)\n"; + //####### BEGIN RECORD ######## + }}} +// FINE DEFINIZIONE DELLA COPERTURA V_PARCHI + + +// INIZIO DEFINIZIONE DELLA COPERTURA V_1200 + $query_v_1200 = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_1200 FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_1200) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_1200 = pg_query($conn, $query_v_1200) or die('Query query_v_1200 failied'); + + if (pg_num_rows($result_query_v_1200) > 0) { + while($row6m = pg_fetch_assoc($result_query_v_1200)) { + $area_v_percent = round(($row6m['area_v_1200']/$area_sezione)*100,2); + + if ($area_v_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Aree al di sopra di 1200 (art.142, lett. d, D.lgs.42/04)\n"; + //####### BEGIN RECORD ######## + }}} +// FINE DEFINIZIONE DELLA COPERTURA V_1200 + +// INIZIO DEFINIZIONE DELLA COPERTURA V_VULCANO + $query_v_vulcano = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_vulcano FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_vulcano) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_vulcano = pg_query($conn, $query_v_vulcano) or die('Query query_v_vulcano failied'); + + if (pg_num_rows($result_query_v_vulcano) > 0) { + while($row6m = pg_fetch_assoc($result_query_v_vulcano)) { + $area_v_percent = round(($row6m['area_vulcano']/$area_sezione)*100,2); + + if ($area_v_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Vincolo area vulcano\n"; + //####### BEGIN RECORD ######## + }}} +// FINE DEFINIZIONE DELLA COPERTURA V_VULCANO + + +// INIZIO DEFINIZIONE DELLA COPERTURA DEL VINCOLO IDROGEOLOGICO + $query_v_idrogeol = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS areaidro FROM (SELECT geom FROM rscarto.sif_vincolo_idrogeo_sicilia) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_idrogeol = pg_query($conn, $query_v_idrogeol) or die('Query query_v_idrogeol failied'); + + if (pg_num_rows($result_query_v_idrogeol) > 0) { + while($row7 = pg_fetch_assoc($result_query_v_idrogeol)) { + $area_idro_percent = round(($row7['areaidro']/$area_sezione)*100,2); + + if ($area_idro_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Vincolo Idrogeologico (R.D.L. n° 3267 del 30/12/1923)\n"; + //####### BEGIN RECORD ######## + + }}} +// FINE DEFINIZIONE DELLA COPERTURA VINCOLO IDROGEOLOGICO + + +// INIZIO DEFINIZIONE DELLA COPERTURA DEL VINCOLO BOSCHI DL227 + /* */ + $query_dl227 = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS areadl227 FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".sif_dl227) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_dl227 = pg_query($conn, $query_dl227) or die('Query query_dl227 failied'); + + if (pg_num_rows($result_query_dl227) > 0) { + while($row72 = pg_fetch_assoc($result_query_dl227)) { + $area_dl227_percent = round(($row72['areadl227']/$area_sezione)*100,2); + + if ($area_dl227_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Vincolo Boschi (Art.2 D.L. 18 maggio 2001, n. 227)\n"; + //####### END RECORD ######## + }}} + +// FINE DEFINIZIONE DELLA COPERTURA DEL VINCOLO BOSCHI DL227 + + +// INIZIO DEFINIZIONE DELLA COPERTURA DEL VINCOLO BOSCHI LR16 + /* */ + $query_lr16 = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS arealr16 FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".sif_lr16) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_lr16 = pg_query($conn, $query_lr16) or die('Query query_lr16 failied'); + + if (pg_num_rows($result_query_lr16) > 0) { + while($row8 = pg_fetch_assoc($result_query_lr16)) { + $area_lr16_percent = round(($row8['arealr16']/$area_sezione)*100,2); + + if ($area_lr16_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "Vincolo Boschi (L.R. 16/96 art. 4)\n"; + //####### END RECORD ######## + }}} + +// FINE DEFINIZIONE DELLA COPERTURA DEL VINCOLO BOSCHI LR16 + + +// INIZIO DEFINIZIONE DELLA COPERTURA SIC-ZPS + $query_siczps = "SELECT a.denom, ST_AREA(ST_intersection(a.geom, b.geom)) AS areasiczps FROM (SELECT denom, geom FROM rscarto.sic_zps) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_siczps = pg_query($conn, $query_siczps) or die('Query query_siczps failied'); + + if (pg_num_rows($result_query_siczps) > 0) { + while($row81 = pg_fetch_assoc($result_query_siczps)) { + $area_siczps_percent = round(($row81['areasiczps']/$area_sezione)*100,2); + + if ($area_siczps_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "SIC-ZPS (".$row81['codice']."-".$row81['denom'].")\n"; + //####### END RECORD ######## + }}} +// FINE DEFINIZIONE DELLA COPERTURA SIC-ZPS + + +// INIZIO DEFINIZIONE DELLA COPERTURA RISERVE + $query_riserve = "SELECT a.denom, ST_AREA(ST_intersection(a.geom, b.geom)) AS areariserve FROM (SELECT denom, geom FROM rscarto.riserve_sicilia) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_riserve = pg_query($conn, $query_riserve) or die('Query query_riserve failied'); + + if (pg_num_rows($result_query_riserve) > 0) { + while($row82 = pg_fetch_assoc($result_query_riserve)) { + $area_riserva_percent = round(($row82['areariserve']/$area_sezione)*100,2); + + if ($area_riserva_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "RISERVE (".$row82['codice']."-".$row82['denom'].")\n"; + //####### END RECORD ######## + }}} +// FINE DEFINIZIONE DELLA COPERTURA RISERVE + + +// INIZIO DEFINIZIONE DELLA COPERTURA PAI IDRO RISCHIO + $query_idro_rischio = "SELECT a.rischio, ST_AREA(ST_intersection(a.geom, b.geom)) AS area_idro_rischio FROM (SELECT rischio, geom FROM rscarto.pai_idr_r) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_idro_rischio = pg_query($conn, $query_idro_rischio) or die('Query query_idro_rischio failied'); + + if (pg_num_rows($result_query_idro_rischio) > 0) { + while($row9 = pg_fetch_assoc($result_query_idro_rischio)) { + $area_idro_r_percent = round(($row9['area_idro_rischio']/$area_sezione)*100,2); + + if ($area_idro_r_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "P.A.I. (Rischio Idraulico - ".$row9['rischio'].")\n"; + //####### END RECORD ######## + }}} +// FINE DEFINIZIONE DELLA COPERTURA PAI IDRO RISCHIO + + +// INIZIO DEFINIZIONE DELLA COPERTURA PAI IDRO PERICOLOSITA' + $query_idro_pericolo = "SELECT a.pericolo, ST_AREA(ST_intersection(a.geom, b.geom)) AS area_idro_pericolo FROM (SELECT pericolo, geom FROM rscarto.pai_idr_p_sa) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_idro_pericolo = pg_query($conn, $query_idro_pericolo) or die('Query query_idro_pericolo failied'); + + if (pg_num_rows($result_query_idro_pericolo) > 0) { + while($row10 = pg_fetch_assoc($result_query_idro_pericolo)) { + $area_idro_p_percent = round(($row10['area_idro_pericolo']/$area_sezione)*100,2); + + if ($area_idro_r_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "P.A.I. (Pericolosità Idraulica - ".$row10['pericolo'].")\n"; + //####### END RECORD ######## + }}} +// FINE DEFINIZIONE DELLA COPERTURA PAI IDRO RISCHIO + + +// INIZIO DEFINIZIONE DELLA COPERTURA PAI GEOMORF RISCHIO + $query_geo_rischio = "SELECT a.rischio, ST_AREA(ST_intersection(a.geom, b.geom)) AS area_geo_rischio FROM (SELECT rischio, geom FROM rscarto.pai_geo_rischio) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_geo_rischio = pg_query($conn, $query_geo_rischio) or die('Query query_geo_rischio failied'); + + if (pg_num_rows($result_query_geo_rischio) > 0) { + while($row11 = pg_fetch_assoc($result_query_geo_rischio)) { + $area_geo_r_percent = round(($row11['area_geo_rischio']/$area_sezione)*100,2); + + if ($area_geo_r_percent > 10) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "P.A.I. (Rischio Geomorfologico - ".$row11['rischio'].")\n"; + //####### END RECORD ######## + }}} +// FINE DEFINIZIONE DELLA COPERTURA PAI GEOMORF RISCHIO + +// INIZIO DEFINIZIONE DELLA COPERTURA PAI GEOMORF PERICOLOSITA + $query_geo_pericolo = "SELECT a.pericolo, ST_AREA(ST_intersection(a.geom, b.geom)) AS area_geo_pericolo FROM (SELECT pericolo, geom FROM rscarto.pai_geo_peric) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_geo_pericolo = pg_query($conn, $query_geo_pericolo) or die('Query query_geo_pericolo failied'); + + if (pg_num_rows($result_query_geo_pericolo) > 0) { + while($row12 = pg_fetch_assoc($result_query_geo_pericolo)) { + $area_geo_p_percent = round(($row12['area_geo_pericolo']/$area_sezione)*100,2); + + if ($area_geo_p_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "P.A.I. (Pericolosità Geomorfologica - ".$row12['pericolo'].")\n"; + //####### END RECORD ######## + + }}} +// FINE DEFINIZIONE DELLA COPERTURA PAI GEOMORF PERICOLOSITA + +// INIZIO DEFINIZIONE DELLA COPERTURA SIN + $query_sin = "SELECT a.denominaz, ST_AREA(ST_intersection(a.geom, b.geom)) AS area_sin FROM (SELECT denominaz, geom FROM rscarto.sin) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_sin = pg_query($conn, $query_sin) or die('Query query_sin failied'); + + if (pg_num_rows($result_query_sin) > 0) { + while($rowsin = pg_fetch_assoc($result_query_sin)) { + $area_sin_percent = round(($rowsin['area_sin']/$area_sezione)*100,2); + + if ($area_sin_percent > 1) { + echo "\n\t\n\t\t\n\t\t\n\t\t\n\t"; + + //####### BEGIN RECORD ######## + $record_vincoli[] = "SIN (Sito di Interesse Nazionale)\n"; + //####### END RECORD ######## + + }}} + +// FINE DEFINIZIONE DELLA COPERTURA SIN + +} + +//pg_close($conn); +?> + + + +
TIPO
DESTINAZIONE
COPERTURA
   Foglio {$foglio}  e  Particella {$particella}
Zona di PRG{$row4['descdest']}  ({$areazto_percent}%)
Vincolo di PRG{$row5['zon_descr']}  ({$areavinc_percent}%)
Piano Paesaggistico Regionale
Regimi Normativi
Paesaggio locale {$row6['pl']}
{$bbccaa} - Contesto {$row6['contesto']}
+ {$row6['contesto']}
   ({$area_bbccaa_percent}%)
Piano Paesaggistico Regionale
Regimi Normativi (Ambito 1)
Denominazione {$row6['denominazi']}
Codice {$row6['codice']} - Reg. Norm. {$row6['regime_nor']}
+ {$row6['contesto']}
   ({$area_bbccaa_percent}%)
Piano Paesaggistico Regionale
Regimi Normativi (Ambito 1)
Fascia di rispetto della costa - art. 54 NdA  ({$area_v_percent}%)
Piano Paesaggistico Regionale
Regimi Normativi (Ambito 1)
Area di recupero - art. 51 NdA  ({$area_v_percent}%)
BENI PAESAGGISTICIArea tutelata (art.136, D.lgs.42/04)  ({$area_v_percent}%)
BENI PAESAGGISTICIVincolo Archeologico (art.10, D.lgs.42/04)  ({$area_v_archeo_percent}%)
BENI PAESAGGISTICIAree boscate (art.142, lett. g, D.lgs.42/04)  ({$area_v_boschi_percent}%)
BENI PAESAGGISTICIAree costa 300m (art.142, lett.a, D.lgs. 42/04)  ({$area_v_percent}%)
BENI PAESAGGISTICIAree fiumi 150m (art.142, lett. c, D.lgs.42/04)  ({$area_v_percent}%)
BENI PAESAGGISTICIAree di interesse archeologico (art.142, lett. m, D.lgs.42/04)  ({$area_v_percent}%)
BENI PAESAGGISTICIAree laghi 300m (art.142, lett. b, D.lgs. 42/04)  ({$area_v_percent}%)
BENI PAESAGGISTICIAree tutelate (art.134, lett. c, D.lgs. 42/04)  ({$area_v_percent}%)
BENI PAESAGGISTICIAree riserve regionali (art.142, lett. f, D.lgs.42/04)  ({$area_v_percent}%)
BENI PAESAGGISTICIParchi regionali (art.142, lett. f, D.lgs.42/04)
{$row6l['denom']}
  ({$area_v_percent}%)
BENI PAESAGGISTICIAree al di sopra di 1200 (art.142, lett. d, D.lgs.42/04)  ({$area_v_percent}%)
BENI PAESAGGISTICIVincolo area vulcano  ({$area_v_percent}%)
Vincolo IdrogeologicoR.D.L. n° 3267 del 30/12/1923   ({$area_idro_percent}%)
Vincolo Boschi  Art.2 D.L. 18 maggio 2001, n. 227   ({$area_dl227_percent}%)
Vincolo Boschi  L.R. 16/96 art. 4   {$copertura_lr16} ({$area_lr16_percent}%)
SIC - ZPS{$row81['codice']} - {$row81['denom']}   ({$area_siczps_percent}%)
RISERVE{$row82['codice']} - {$row82['denom']}   ({$area_riserva_percent}%)
P.A.I.Rischio Idraulico - {$row9['rischio']}   ({$area_idro_r_percent}%)
P.A.I.Pericolosità Idraulica - {$row10['pericolo']}   ({$area_idro_p_percent}%)
P.A.I.Rischio Geomorfologico - {$row11['rischio']}   ({$area_geo_r_percent}%)
P.A.I.Pericolosità Geomorfologica - {$row12['pericolo']}   ({$area_geo_p_percent}%)
SINSito di Interesse Nazionale   ({$area_sin_percent}%)
+
 
I dati rappresentati non hanno validità legale e devono essere rilasciati ufficialmente dall'ufficio competente.


  
+ + diff --git a/cdu_level.php b/cdu_level.php new file mode 100755 index 0000000..5f352e7 --- /dev/null +++ b/cdu_level.php @@ -0,0 +1,657 @@ + + +\n\t\t   Foglio {$foglio}  e  Particella {$particella}\n\t"; + +//####### BEGIN RECORD ######## +$record_paesaggio[] = "Foglio ".$foglio." - Particella".$particella."\n"; +$record_tutela[] = "Foglio ".$foglio." - Particella".$particella."\n"; +$record_vincoli[] = "Foglio ".$foglio." - Particella".$particella."\n"; +//####### END RECORD ######## + +// INIZIO DEFINIZIONE DELLA COPERTURA DELLA ZONAZIONE + if(!$query4 = @pg_query("SELECT zon_sigla, zon_descr, ST_Area(the_geom) as areazto, zon_art FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.zon_sigla, e.zon_descr, e.zon_art FROM ". + " (SELECT a.the_geom, a.zon_sigla, a.zon_descr, a.zon_art FROM $comu_prg a inner join ". + " (SELECT the_geom FROM $comu_cata where gid = $idparticella) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT * FROM $comu_cata where gid = $idparticella) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("ERROR STR3: " . pg_last_error($conn)); + + while($row4 = pg_fetch_assoc($query4)) { + $areazto = $row4['areazto']; + $areazto_percent = round(($areazto/$area_sezione)*100,2); + $areazto_percentuale[] = round(($areazto/$area_sezione)*100,2); + +// PARAMETRI DELLA COPERTURA DI PRG + if ($areazto_percent > 80) { + $copertura_zonprg = "Completamente"; + } + if ($areazto_percent > 60 AND $areazto_percent < 80) { + $copertura_zonprg = "Per la maggior parte"; + } + if ($areazto_percent > 40 AND $areazto_percent < 59) { + $copertura_zonprg = "In parte"; + } + if ($areazto_percent > 10 AND $areazto_percent < 39) { + $copertura_zonprg = "In minima parte"; + } + + $zto_array[] = $row4['zon_sigla']." - ".row4['zon_descr']; + +//####### BEGIN RECORD ######## +//$record_form[] = row4['zon_descr']."\n"; +//####### END RECORD ######## + + if ($areazto_percent > 10) { //SOGLIA DI VISUALIZZAZIONE SOVRAPPOSIZIONE (20%) + echo "\n\t\n\t\tZona di PRG\n\t\t{$row4['zon_sigla']} - {$row4['zon_descr']}\n\t\t   {$copertura_zonprg} ({$areazto_percent}%)\n\t"; + $ntart[] = $row4['zon_art']; + } +} +// FINE DEFINIZIONE DELLA COPERTURA DELLA ZONAZIONE + + +// INIZIO DEFINIZIONE DELLA COPERTURA DEI VINCOLI DI PRG + if(!$query5 = @pg_query("SELECT zon_descr, ST_Area(the_geom) as areavinc from ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.zon_descr FROM ". + " (SELECT a.the_geom, a.zon_descr from ".$comu_vincoprg." a inner join ". + " (SELECT the_geom FROM ".$comu_cata." where gid=$idparticella) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT * FROM ".$comu_cata." where gid=$idparticella) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("Error STR4: " . pg_last_error($conn)); + + $row_query5 = pg_num_rows($query5); + if ($row_query5 > 0) { + + while($row5 = pg_fetch_assoc($query5)) { + $area_vinc = $row5['areavinc']; + $areavinc_percent = round(($area_vinc/$area_sezione)*100,2); + +// PARAMETRI DELLA COPERTURA DEI VINCOLI + if ($areavinc_percent > 80) { + $copertura_vincprg = "Completamente"; + } + if ($areavinc_percent > 60 AND $areavinc_percent < 80) { + $copertura_vincprg = "Per la maggior parte"; + } + if ($areavinc_percent > 40 AND $areavinc_percent < 59) { + $copertura_vincprg = "In parte"; + } + if ($areavinc_percent > 10 AND $areavinc_percent < 39) { + $copertura_vincprg = "In minima parte"; + } + + if ($areavinc_percent > 10) { //SOGLIA DI VISUALIZZAZIONE SOVRAPPOSIZIONE (20%) + echo "\n\t\n\t\tVincolo di PRG\n\t\t{$row5['zon_descr']}\n\t\t   {$copertura_vincprg} ({$areavinc_percent}%)\n\t"; + } + } + } +// FINE DEFINIZIONE DELLA COPERTURA DEI VINCOLI DI PRG + +// INIZIO DEFINIZIONE DELLA COPERTURA DEI VINCOLI BBCCAA +//DEFINIZIONE conndbESSIONE + + if(!$query6 = @pg_query("SELECT art142_a, art142_b, art142_c, art142_f, art142_g, art142_m, art10_arch, art134_a, art134_c, liv_tutela, contesto, nome_conte, ST_Area(the_geom) as areabbccaa FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.art142_a, e.art142_b, e.art142_c, e.art142_f, e.art142_g, e.art142_m, e.art10_arch, e.art134_a, e.art134_c, e.liv_tutela, e.contesto, e.nome_conte FROM ". + " (SELECT a.the_geom, a.art142_a, a.art142_b, a.art142_c, a.art142_f, a.art142_g, a.art142_m, a.art10_arch, a.art134_a, a.art134_c, a.liv_tutela, a.contesto, a.nome_conte FROM dbcarto.regimi_normativi_".strtolower($_SESSION['COMUNE_PROV'])." a inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("ERROR STR5: " . pg_last_error($conn)); + + $row_query6 = pg_num_rows($query6); + if ($row_query6 > 0) { + //echo "####".$row_query6. "####"; + while($row6 = pg_fetch_assoc($query6)) { + $area_bbccaa = $row6['areabbccaa']; + $area_bbccaa_percent = round(($area_bbccaa/$area_sezione)*100,2); + +// PARAMETRI DELLA COPERTURA DEI VINCOLI + if ($area_bbccaa_percent > 80) { + $copertura_bbccaa = "Completamente"; + } + if ($area_bbccaa_percent > 60 AND $area_bbccaa_percent < 80) { + $copertura_bbccaa = "Per la maggior parte"; + } + if ($area_bbccaa_percent > 40 AND $area_bbccaa_percent < 59) { + $copertura_bbccaa = "In parte"; + } + if ($area_bbccaa_percent > 10 AND $area_bbccaa_percent < 39) { + $copertura_bbccaa = "In minima parte"; + } + + if ($row6['art142_a'] <> "") { + $art142_a = "Art.142a - Aree tutelate per legge:
territori costieri compresi in una fascia di 300m dalla linea di battigia
"; + } + if ($row6['art142_b'] <> "") { + $art142_b = "Art.142b - Aree tutelate per legge:
territori contermini ai laghi in una fascia di 300m dalla linea di battigia
"; + } + if ($row6['art142_c'] <> "") { + $art142_c = "Art.142c - Aree tutelate per legge:
fascia di 150m da fiumi, torrenti e corsi d'acqua
"; + } + if ($row6['art142_f'] <> "") { + $art142_f = "Art.142f - Aree tutelate per legge:
parchi e riserve nazionali o regionali
"; + } + if ($row6['art142_g'] <> "") { + $art142_g = "Art.142g - Aree tutelate per legge:
territori coperti da foreste e da boschi anche percorsi o danneggiati dal fuoco
"; + } + if ($row6['art142_m'] <> "") { + $art142_m = "Art.142m - Aree tutelate per legge:
zone di interesse archeologico
"; + } + if ($row6['art10_arch'] <> "") { + $art10_arch = "Art.10 - comma 11 L.R. 6 aprile 1996:
zona di rispetto dei boschi e delle fasce forestali
"; + } + if ($row6['art134_a'] <> "") { + $art134_a = "Art.134a - Vincoli Paesaggistici ex L. 1497/39
"; + } + if ($row6['art134_c'] <> "") { + $art134_c = "Art.134c - Codice dei Beni Culturali e del Paesaggio
"; + } + + + switch ($row6['liv_tutela']) { + case 1: + $bbccaa = "Livello di tutela 1"; + break; + case 2: + $bbccaa = "Livello di tutela 2"; + break; + case 3: + $bbccaa = "Livello di tutela 3"; + break; + case 4: + $bbccaa = "Livello di tutela 4"; + break; + default: + $bbccaa = ""; + } + + if ($area_bbccaa_percent > 1) { //SOGLIA DI VISUALIZZAZIONE SOVRAPPOSIZIONE (20%) + echo "\n\t\n\t\tPiano Paesaggistico Regionale\n\t\t{$bbccaa} - Contesto {$row6['contesto']}
+ {$row6['nome_conte']}
+ {$art142_a}{$art142_b}{$art142_c}{$art142_f}{$art142_g}{$art142_m}{$art142_m}{$art134_a}{$art134_c} + \n\t\t   {$copertura_bbccaa} ({$area_bbccaa_percent}%)\n\t"; + +//####### BEGIN RECORD ######## +$record_paesaggio[] = $row6['nome_conte']."\n"; +$record_tutela[] = $bbccaa."\n"; +//####### END RECORD ######## + + } + } +// FINE DEFINIZIONE DELLA COPERTURA DEI VINCOLI BBCCAA + + } + +// INIZIO DEFINIZIONE DELLA COPERTURA DEL VINCOLO IDROGEOLOGICO + if(!$query7 = @pg_query("SELECT ST_Area(the_geom) as areaidro from ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom FROM ". + " (SELECT a.the_geom FROM dbcarto.sif_vincolo_idrogeo_sicilia a inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("ERROR STR6: " . pg_last_error($conn)); + + $row_query7 = pg_num_rows($query7); + if ($row_query7 > 0) { + //echo "#### - 7 ".$row_query7. "####"; + while($row7 = pg_fetch_assoc($query7)) { + $area_idro = $row7['areaidro']; + $area_idro_percent = round(($area_idro/$area_sezione)*100,2); + +// PARAMETRI DELLA COPERTURA DEI VINCOLI + if ($area_idro_percent > 80) { + $copertura_idro = "Completamente"; + } + if ($area_idro_percent > 60 AND $area_idro_percent < 80) { + $copertura_idro = "Per la maggior parte"; + } + if ($area_idro_percent > 40 AND $area_idro_percent < 59) { + $copertura_idro = "In parte"; + } + if ($area_idro_percent > 10 AND $area_idro_percent < 39) { + $copertura_idro = "In minima parte"; + } + + if ($area_idro_percent > 10) { //SOGLIA DI VISUALIZZAZIONE SOVRAPPOSIZIONE (20%) + echo "\n\t\n\t\tVincolo Idrogeologico\n\t\tR.D.L. n° 3267 del 30/12/1923\n\t\t   {$copertura_idro} ({$area_idro_percent}%)\n\t"; + } + } + } +// FINE DEFINIZIONE DELLA COPERTURA VINCOLO IDROGEOLOGICO + + +// INIZIO DEFINIZIONE DELLA COPERTURA DEL VINCOLO BOSCHI DL227 + if(!$query8 = @pg_query("SELECT ST_Area(the_geom) as areadl227 from ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom FROM ". + " (SELECT a.the_geom FROM dbcarto.cfrs_dl227 a inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("ERROR STR7: " . pg_last_error($conn)); + + $row_query8 = pg_num_rows($query8); + if ($row_query8 > 0) { + //echo "#### - 7 ".$row_query7. "####"; + while($row8 = pg_fetch_assoc($query8)) { + $area_dl227 = $row8['areadl227']; + $area_dl227_percent = round(($area_dl227/$area_sezione)*100,2); + +// PARAMETRI DELLA COPERTURA DEI VINCOLI + if ($area_dl227_percent > 80) { + $copertura_dl227 = "Completamente"; + } + if ($area_dl227_percent > 60 AND $area_dl227_percent < 80) { + $copertura_dl227 = "Per la maggior parte"; + } + if ($area_dl227_percent > 40 AND $area_dl227_percent < 59) { + $copertura_dl227 = "In parte"; + } + if ($area_dl227_percent > 10 AND $area_dl227_percent < 39) { + $copertura_dl227 = "In minima parte"; + } + + if ($area_dl227_percent > 10) { //SOGLIA DI VISUALIZZAZIONE SOVRAPPOSIZIONE (20%) + echo "\n\t\n\t\tVincolo Boschi\n\t\t  Art.2 D.L. 18 maggio 2001, n. 227\n\t\t   {$copertura_dl227} ({$area_dl227_percent}%)\n\t"; + +//####### BEGIN RECORD ######## +$record_vincoli[] = "Vincolo Boschi (Art.2 D.L. 18 maggio 2001, n. 227)\n"; +//####### END RECORD ######## + + } + } + } +// FINE DEFINIZIONE DELLA COPERTURA DEL VINCOLO BOSCHI DL227 + + +// INIZIO DEFINIZIONE DELLA COPERTURA DEL VINCOLO BOSCHI LR16 + if(!$query8 = @pg_query("SELECT ST_Area(the_geom) as arealr16 from ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom FROM ". + " (SELECT a.the_geom FROM dbcarto.cfrs_lr16 a inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("ERROR STR8c: " . pg_last_error($conn)); + + $row_query8 = pg_num_rows($query8); + if ($row_query8 > 0) { + //echo "#### - 7 ".$row_query7. "####"; + while($row8 = pg_fetch_assoc($query8)) { + $area_lr16 = $row8['arealr16']; + $area_lr16_percent = round(($area_lr16/$area_sezione)*100,2); + +// PARAMETRI DELLA COPERTURA DEI VINCOLI + if ($area_lr16_percent > 80) { + $copertura_lr16 = "Completamente"; + } + if ($area_lr16_percent > 60 AND $area_lr16_percent < 80) { + $copertura_lr16 = "Per la maggior parte"; + } + if ($area_lr16_percent > 40 AND $area_lr16_percent < 59) { + $copertura_lr16 = "In parte"; + } + if ($area_lr16_percent > 10 AND $area_lr16_percent < 39) { + $copertura_lr16 = "In minima parte"; + } + + if ($area_lr16_percent > 10) { //SOGLIA DI VISUALIZZAZIONE SOVRAPPOSIZIONE (20%) + echo "\n\t\n\t\tVincolo Boschi\n\t\t  L.R. 16/96 art. 4\n\t\t   {$copertura_lr16} ({$area_lr16_percent}%)\n\t"; + +//####### BEGIN RECORD ######## +$record_vincoli[] = "Vincolo Boschi (L.R. 16/96 art. 4)\n"; +//####### END RECORD ######## + + } + } + } +// FINE DEFINIZIONE DELLA COPERTURA DEL VINCOLO BOSCHI LR16 + + +// INIZIO DEFINIZIONE DELLA COPERTURA SIC-ZPS + if(!$query81 = @pg_query("SELECT codice, denomi, ST_Area(the_geom) as areasiczps from ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.codice, e.denomi FROM ". + " (SELECT a.codice, a.denomi, a.the_geom FROM dbcarto.sic_zps_sicilia a inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("ERROR STR8a: " . pg_last_error($conndb)); + + $row_query81 = pg_num_rows($query81); + if ($row_query81 > 0) { + //echo "#### - 7 ".$row_query7. "####"; + while($row81 = pg_fetch_assoc($query81)) { + $area_siczps = $row81['areasiczps']; + $area_siczps_percent = round(($area_siczps/$area_sezione)*100,2); + +// PARAMETRI DELLA COPERTURA DEI VINCOLI + if ($$area_siczps_percent > 80) { + $copertura_siczps = "Completamente"; + } + if ($area_siczps_percent > 60 AND $area_siczps_percent < 80) { + $copertura_siczps = "Per la maggior parte"; + } + if ($area_siczps_percent > 40 AND $area_siczps_percent < 59) { + $copertura_siczps = "In parte"; + } + if ($$area_siczps_percent > 10 AND $area_siczps_percent < 39) { + $copertura_siczps = "In minima parte"; + } + + if ($area_siczps_percent > 10) { //SOGLIA DI VISUALIZZAZIONE SOVRAPPOSIZIONE (20%) + echo "\n\t\n\t\tSIC - ZPS\n\t\t{$row81['codice']} - {$row81['denominazi']}\n\t\t   {$copertura_siczps} ({$area_siczps_percent}%)\n\t"; + +//####### BEGIN RECORD ######## +$record_vincoli[] = "SIC-ZPS (".$row81['codice']."-".$row81['denominazi'].")\n"; +//####### END RECORD ######## + + } + } + } +// FINE DEFINIZIONE DELLA COPERTURA SIC-ZPS + + +// INIZIO DEFINIZIONE DELLA COPERTURA RISERVE + if(!$query82 = @pg_query("SELECT codice, denom, ST_Area(the_geom) as areariserve from ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.codice, e.denom FROM ". + " (SELECT a.codice, a.denom, a.the_geom FROM dbcarto.riserve_sicilia a inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("ERROR STR8b: " . pg_last_error($conndb)); + + $row_query82 = pg_num_rows($query82); + if ($row_query82 > 0) { + //echo "#### - 7 ".$row_query7. "####"; + while($row82 = pg_fetch_assoc($query82)) { + $area_riserva = $row82['areariserve']; + $area_riserva_percent = round(($area_riserva/$area_sezione)*100,2); + +// PARAMETRI DELLA COPERTURA DEI VINCOLI + if ($area_riserva_percent > 80) { + $copertura_riserva = "Completamente"; + } + if ($area_riserva_percent > 60 AND $area_riserva_percent < 80) { + $copertura_riserva = "Per la maggior parte"; + } + if ($area_riserva_percent > 40 AND $area_riserva_percent < 59) { + $copertura_riserva = "In parte"; + } + if ($area_riserva_percent > 10 AND $area_riserva_percent < 39) { + $copertura_riserva = "In minima parte"; + } + + if ($area_riserva_percent > 10) { //SOGLIA DI VISUALIZZAZIONE SOVRAPPOSIZIONE (20%) + echo "\n\t\n\t\tRISERVE\n\t\t{$row82['codice']} - {$row82['denom']}\n\t\t   {$copertura_riserva} ({$area_riserva_percent}%)\n\t"; + +//####### BEGIN RECORD ######## +$record_vincoli[] = "RISERVE (".$row82['codice']."-".$row82['denom'].")\n"; +//####### END RECORD ######## + + } + } + } +// FINE DEFINIZIONE DELLA COPERTURA RISERVE + + + +// INIZIO DEFINIZIONE DELLA COPERTURA PAI IDRO RISCHIO + if(!$query9 = @pg_query("SELECT rischio, ST_Area(the_geom) as area_idro_rischio FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.rischio FROM ". + " (SELECT a.the_geom, a.rischio FROM dbcarto.idro_r a inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("ERROR STR9: " . pg_last_error($conndb)); + + $row_query9 = pg_num_rows($query9); + if ($row_query9 > 0) { + //echo "#### - 7 ".$row_query7. "####"; + while($row9 = pg_fetch_assoc($query9)) { + $area_idro_r = $row9['area_idro_rischio']; + $area_idro_r_percent = round(($area_idro_r/$area_sezione)*100,2); + +// PARAMETRI DELLA COPERTURA DEI VINCOLI + if ($area_idro_r_percent > 80) { + $copertura_pai_idro_r = "Completamente"; + } + if ($area_idro_r_percent > 60 AND $area_idro_r_percent < 80) { + $copertura_pai_idro_r = "Per la maggior parte"; + } + if ($area_idro_r_percent > 40 AND $area_idro_r_percent < 59) { + $copertura_pai_idro_r = "In parte"; + } + if ($area_idro_r_percent > 10 AND $area_idro_r_percent < 39) { + $copertura_pai_idro_r = "In minima parte"; + } + + if ($area_idro_r_percent > 10) { //SOGLIA DI VISUALIZZAZIONE SOVRAPPOSIZIONE (20%) + echo "\n\t\n\t\tP.A.I.\n\t\tRischio Idraulico - {$row9['rischio']}\n\t\t   {$copertura_pai_idro_r} ({$area_idro_r_percent}%)\n\t"; + +//####### BEGIN RECORD ######## +$record_vincoli[] = "P.A.I. (Rischio Idraulico - ".$row9['rischio'].")\n"; +//####### END RECORD ######## + + } + } + } +// FINE DEFINIZIONE DELLA COPERTURA PAI IDRO RISCHIO + + +// INIZIO DEFINIZIONE DELLA COPERTURA PAI IDRO PERICOLOSITA' + if(!$query10 = @pg_query("SELECT pericolo, ST_Area(the_geom) as area_idro_pericolo FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.pericolo FROM ". + " (SELECT a.the_geom, a.pericolo FROM dbcarto.idro_p_sa a inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("ERROR STR10: " . pg_last_error($conndb)); + + $row_query10 = pg_num_rows($query10); + if ($row_query10 > 0) { + //echo "#### - 7 ".$row_query7. "####"; + while($row10 = pg_fetch_assoc($query10)) { + $area_idro_p = $row10['area_idro_pericolo']; + $area_idro_p_percent = round(($area_idro_p/$area_sezione)*100,2); + +// PARAMETRI DELLA COPERTURA DEI VINCOLI + if ($area_idro_p_percent > 80) { + $copertura_pai_idro_p = "Completamente"; + } + if ($area_idro_p_percent > 60 AND $area_idro_p_percent < 80) { + $copertura_pai_idro_p = "Per la maggior parte"; + } + if ($area_idro_p_percent > 40 AND $area_idro_p_percent < 59) { + $copertura_pai_idro_p = "In parte"; + } + if ($area_idro_p_percent > 10 AND $area_idro_p_percent < 39) { + $copertura_pai_idro_p = "In minima parte"; + } + + if ($area_idro_r_percent > 10) { //SOGLIA DI VISUALIZZAZIONE SOVRAPPOSIZIONE (20%) + echo "\n\t\n\t\tP.A.I.\n\t\tPericolosità Idraulica - {$row10['pericolo']}\n\t\t   {$copertura_pai_idro_p} ({$area_idro_p_percent}%)\n\t"; + +//####### BEGIN RECORD ######## +$record_vincoli[] = "P.A.I. (Pericolosità Idraulica - ".$row10['pericolo'].")\n"; +//####### END RECORD ######## + + } + } + } +// FINE DEFINIZIONE DELLA COPERTURA PAI IDRO RISCHIO + + +// INIZIO DEFINIZIONE DELLA COPERTURA PAI GEOMORF RISCHIO + if(!$query11 = @pg_query("SELECT rischio, ST_Area(the_geom) as area_geo_rischio FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.rischio FROM ". + " (SELECT a.the_geom, a.rischio FROM dbcarto.geo_rischio a inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("ERROR STR10: " . pg_last_error($conndb)); + + $row_query11 = pg_num_rows($query11); + if ($row_query11 > 0) { + //echo "#### - 7 ".$row_query7. "####"; + while($row11 = pg_fetch_assoc($query11)) { + $area_geo_r = $row11['area_geo_rischio']; + $area_geo_r_percent = round(($area_geo_r/$area_sezione)*100,2); + +// PARAMETRI DELLA COPERTURA DEI VINCOLI + if ($area_geo_r_percent > 80) { + $copertura_pai_geo_r = "Completamente"; + } + if ($area_geo_r_percent > 60 AND $area_geo_r_percent < 80) { + $copertura_pai_geo_r = "Per la maggior parte"; + } + if ($area_geo_r_percent > 40 AND $area_geo_r_percent < 59) { + $copertura_pai_geo_r = "In parte"; + } + if ($area_geo_r_percent > 10 AND $area_geo_r_percent < 39) { + $copertura_pai_geo_r = "In minima parte"; + } + + if ($area_geo_r_percent > 10) { //SOGLIA DI VISUALIZZAZIONE SOVRAPPOSIZIONE (20%) + echo "\n\t\n\t\tP.A.I.\n\t\tRischio Geomorfologico - {$row11['rischio']}\n\t\t   {$copertura_pai_geo_r} ({$area_geo_r_percent}%)\n\t"; + +//####### BEGIN RECORD ######## +$record_vincoli[] = "P.A.I. (Rischio Geomorfologico - ".$row11['rischio'].")\n"; +//####### END RECORD ######## + + } + } + } +// FINE DEFINIZIONE DELLA COPERTURA PAI GEOMORF RISCHIO + +// INIZIO DEFINIZIONE DELLA COPERTURA PAI GEOMORF PERICOLOSITA + if(!$query12 = @pg_query("SELECT pericolo, ST_Area(the_geom) as area_geo_pericolo FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.pericolo FROM ". + " (SELECT a.the_geom, a.pericolo FROM dbcarto.geo_p_crolli a inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("ERROR STR10: " . pg_last_error($conndb)); + + $row_query12 = pg_num_rows($query12); + if ($row_query12 > 0) { + //echo "#### - 7 ".$row_query7. "####"; + while($row12 = pg_fetch_assoc($query12)) { + $area_geo_p = $row12['area_geo_pericolo']; + $area_geo_p_percent = round(($area_geo_p/$area_sezione)*100,2); + +// PARAMETRI DELLA COPERTURA DEI VINCOLI + if ($area_geo_p_percent > 80) { + $copertura_pai_geo_p = "Completamente"; + } + if ($area_geo_p_percent > 60 AND $area_geo_p_percent < 80) { + $copertura_pai_geo_r = "Per la maggior parte"; + } + if ($area_geo_p_percent > 40 AND $area_geo_p_percent < 59) { + $copertura_pai_geo_p = "In parte"; + } + if ($area_geo_p_percent > 10 AND $area_geo_p_percent < 39) { + $copertura_pai_geo_p = "In minima parte"; + } + + if ($area_geo_p_percent > 10) { //SOGLIA DI VISUALIZZAZIONE SOVRAPPOSIZIONE (20%) + echo "\n\t\n\t\tP.A.I.\n\t\tPericolosità Geomorfologica - {$row12['pericolo']}\n\t\t   {$copertura_pai_geo_p} ({$area_geo_p_percent}%)\n\t"; + +//####### BEGIN RECORD ######## +$record_vincoli[] = "P.A.I. (Pericolosità Geomorfologica - ".$row12['pericolo'].")\n"; +//####### END RECORD ######## + + } + } + } +// FINE DEFINIZIONE DELLA COPERTURA PAI GEOMORF PERICOLOSITA + + + +// INIZIO DEFINIZIONE DELLA COPERTURA INCENDI + if(!$queryfire = @pg_query("SELECT dat_segn, ST_Area(the_geom) as area_fire FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.dat_segn FROM ". + " (SELECT a.the_geom, a.dat_segn FROM public.incendi a inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("ERROR STR10: " . pg_last_error($conndb)); + + $row_queryfire = pg_num_rows($queryfire); + if ($row_queryfire > 0) { + //echo "#### - 7 ".$row_query7. "####"; + while($rowfire = pg_fetch_assoc($queryfire)) { + $area_fire = $rowfire['area_fire']; + $area_fire_percent = round(($area_fire/$area_sezione)*100,2); + +// PARAMETRI DELLA COPERTURA DEI VINCOLI + if ($area_fire_percent > 80) { + $copertura_fire = "Completamente"; + } + if ($area_fire_percent > 60 AND $area_fire_percent < 80) { + $copertura_fire = "Per la maggior parte"; + } + if ($area_fire_percent > 40 AND $area_fire_percent < 59) { + $copertura_fire = "In parte"; + } + if ($area_fire_percent > 10 AND $area_fire_percent < 39) { + $copertura_fire = "In minima parte"; + } + + if ($area_fire_percent > 10) { //SOGLIA DI VISUALIZZAZIONE SOVRAPPOSIZIONE (20%) + echo "\n\t\n\t\tAREE INCENDIATE\n\t\tEvento del {$rowfire['dat_segn']}\n\t\t   {$copertura_fire} ({$area_fire_percent}%)\n\t"; + + } + } + } +// FINE DEFINIZIONE DELLA COPERTURA INCENDI + + +// INIZIO DEFINIZIONE DELLA COPERTURA SIN + if(!$querysin = @pg_query("SELECT denominaz, ST_Area(the_geom) as area_sin FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.denominaz FROM ". + " (SELECT a.the_geom, a.denominaz FROM dbcarto.sin_priolo a inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$_SESSION['THE_GEOM']."') as the_geom) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("ERROR STR10: " . pg_last_error($conndb)); + + $row_querysin = pg_num_rows($querysin); + if ($row_querysin > 0) { + //echo "#### - 7 ".$row_query7. "####"; + while($rowsin = pg_fetch_assoc($querysin)) { + $area_sin = $rowsin['area_sin']; + $area_sin_percent = round(($area_sin/$area_sezione)*100,2); + +// PARAMETRI DELLA COPERTURA DEI VINCOLI + if ($area_sin_percent > 80) { + $copertura_sin = "Completamente"; + } + if ($area_sin_percent > 60 AND $area_sin_percent < 80) { + $copertura_sin = "Per la maggior parte"; + } + if ($area_sin_percent > 40 AND $area_sin_percent < 59) { + $copertura_sin = "In parte"; + } + if ($area_sin_percent > 10 AND $area_sin_percent < 39) { + $copertura_sin = "In minima parte"; + } + + if ($area_sin_percent > 10) { //SOGLIA DI VISUALIZZAZIONE SOVRAPPOSIZIONE (20%) + echo "\n\t\n\t\tSIN\n\t\t{$rowsin['denominaz']}\n\t\t   {$copertura_sin} ({$area_sin_percent}%)\n\t"; + +//####### BEGIN RECORD ######## +$record_vincoli[] = "SIN (".$rowsin['denominaz'].")\n"; +//####### END RECORD ######## + + + } + } + } +// FINE DEFINIZIONE DELLA COPERTURA SIN + + +} + +//pg_close($conndb); +?> + + diff --git a/cfg.php b/cfg.php new file mode 100755 index 0000000..034369a --- /dev/null +++ b/cfg.php @@ -0,0 +1,42 @@ + + + $inactive) { + session_destroy(); + //header("Location: logout.php"); + echo ""; + } +} +$_SESSION["timeout"] = time(); + +if (isset($_GET['obj'])) { $obj = $_GET['obj']; } +if (isset($_GET['id'])) { $id = $_GET['id']; } +//if (!isset($_GET['risk'])) { $_SESSION['RISK'] = ""; } +if (isset($_GET['risk'])) { $_SESSION['RISK'] = $_GET['risk']; } + +//$tabella = $_GET['tab']; +//$id = $_REQUEST['id']; +//echo $risk; + +$php_blot_key = "rep2021aus"; + + +?> + diff --git a/cfg_srv.php b/cfg_srv.php new file mode 100755 index 0000000..6210f59 --- /dev/null +++ b/cfg_srv.php @@ -0,0 +1,25 @@ +'); + header("location: 500"); + } else { + // echo 'Connessione riuscita !
'; + } + + +?> \ No newline at end of file diff --git a/decrypt.php b/decrypt.php new file mode 100755 index 0000000..3ece9c0 --- /dev/null +++ b/decrypt.php @@ -0,0 +1,7 @@ + "lax"]); //none, lax, strict +session_set_cookie_params(["Secure" => "true"]); //false, true +session_set_cookie_params(["HttpOnly" => "true"]); //false, true +//session_start(); +?> + + + + + + + + + + + + + +Paesaggistica Sicilia + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Skip to main content +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+ + + + + + + + + + + + + diff --git a/draw.php b/draw.php new file mode 100755 index 0000000..624d5f9 --- /dev/null +++ b/draw.php @@ -0,0 +1,166 @@ + + + + + + + + + mapcloud.it for BBCCAA Regione Sicilia + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ × + +
+
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/encrypt.php b/encrypt.php new file mode 100755 index 0000000..23f4354 --- /dev/null +++ b/encrypt.php @@ -0,0 +1,68 @@ + $file){ + $excludes[ $key ] = $src.'/'.$file; +} + +$rec = new RecursiveIteratorIterator(new RecursiveDirectoryIterator( $src )); +$require_funcs = array('include_once', 'include', 'require', 'require_once'); + + +foreach ($rec as $file) { + + if ($file->isDir()) { + $newDir = str_replace( 'src', 'encrypted', $file->getPath() ); + if( !is_dir( $newDir ) ) mkdir( $newDir ); + continue; + }; + + $filePath = $file->getPathname(); + + if( pathinfo($filePath, PATHINFO_EXTENSION) != 'php' || + in_array( $filePath, $excludes ) ) { + $newFile = str_replace('src', 'encrypted', $filePath ); + copy( $filePath, $newFile ); + continue; + } + + $contents = file_get_contents( $filePath ); + $preppand = ' ".$contents, $php_blot_key );*/ + $cipher = bolt_encrypt( $contents, $php_blot_key ); + $newFile = str_replace('src', 'encrypted', $filePath ); + $fp = fopen( $newFile, 'w'); + fwrite($fp, $preppand.$cipher); + fclose($fp); + + unset( $cipher ); + unset( $contents ); +} + +$out_str = substr_replace($src, '', 0, 4); +$file_location = __DIR__."/encrypted/".$out_str; +echo "Successfully Encrypted... Please check in " .$file_location." folder."; + + + diff --git a/error.php b/error.php new file mode 100755 index 0000000..7ba7e28 --- /dev/null +++ b/error.php @@ -0,0 +1,56 @@ + + + + + + + + + + + + + +
+ +
XXXX
+ + +
+ +
+
+

Qualcosa non ha funzionato
prova a riperete la procedura

+
+
+ +
+
+ + + diff --git a/favicon.ico b/favicon.ico new file mode 100755 index 0000000000000000000000000000000000000000..d2e90ac9dc4927d409165fda9b1e708088e4b125 GIT binary patch literal 1150 zcmaKrYe-XJ7{_1D(#p!D(hS2&Qp}d_EKU1h^vNzCGBAmf(yZpN8qO|W8M?fZm(-*= z-L*MQ5mSdGsBI>sLe7?2HVSW#Z5jLhR_HcQ z9X=6GcG$18^NubEWEQ^`vlPaUlw|akPeyC3NAN{gJ3_3TY*v|zaOPrXM>b&1^Hj`k z-<x6% zg=>jN;Iya%r0N`_413nipfsv$_I2c}{Y=zUSrv3{RyE!Ue7;*0HrjckEtEsj~j_-v^{iBbN;%l zX|!2W37-b$buZf{}m)6kQKVdWT$p8QV literal 0 HcmV?d00001 diff --git a/index.php b/index.php new file mode 100755 index 0000000..31bbfbd --- /dev/null +++ b/index.php @@ -0,0 +1,413 @@ + + + + + + + + + + + Paesaggistica Sicilia + + + + + + + "lax"]); //none, lax, strict +session_set_cookie_params(["Secure" => "true"]); //false, true +session_set_cookie_params(["HttpOnly" => "true"]); //false, true +//session_start(); +?> + + + +"; + if (strlen($estremicata) > 8){ + $_SESSION['cataparticella'] = substr($estremicata,0,-1); + } else { + $_SESSION['cataparticella'] = $estremicata; + } + } + + if (empty($_GET['readOnly'])) { + $_SESSION['STATUS'] = ''; + } else { + $_SESSION['STATUS'] = $_GET['readOnly']; + } + + if (empty($_GET['idPratica'])) { + $_SESSION['IDPRATICA'] = 0; + } else { + $_SESSION['IDPRATICA'] = $_GET['idPratica']; + } + + if (empty($_GET['npratica'])) { + $npratica = "0"; + } else { + $npratica = $_GET['npratica']; + } + + if (empty($_GET['lat'])) { + $_SESSION['LAT'] = 0; + } else { + $_SESSION['LAT'] = $_GET['lat']; + } + + if (empty($_GET['lng'])) { + $_SESSION['LONG'] = 0; + } else { + $_SESSION['LONG'] = $_GET['lng']; + } + + + $rs_provincia = "SELECT provincia FROM public.comuni WHERE cod_belf = '" . $_SESSION['COMUNE_BELF'] . "'"; + $result_prov = pg_query($conn, $rs_provincia) or die('Query failed0'); + if (pg_num_rows($result_prov) > 0) { + while ($result_row = pg_fetch_assoc($result_prov)) { + //$_SESSION['COMUNE_PROV'] = strtolower($result_row['provincia']); + $_SESSION['COMUNE_PROV'] = $result_row['provincia']; + switch ($result_row['provincia']) { + case "SR": + $_SESSION['PROV_NOME'] = "Siracusa"; + break; + case "CT": + $_SESSION['PROV_NOME'] = "Catania"; + break; + case "EN": + $_SESSION['PROV_NOME'] = "Enna"; + break; + case "PA": + $_SESSION['PROV_NOME'] = "Palermo"; + break; + case "RG": + $_SESSION['PROV_NOME'] = "Ragusa"; + break; + case "ME": + $_SESSION['PROV_NOME'] = "Messina"; + break; + case "CL": + $_SESSION['PROV_NOME'] = "Caltanissetta"; + break; + case "TP": + $_SESSION['PROV_NOME'] = "Trapani"; + break; + case "AG": + $_SESSION['PROV_NOME'] = "Agrigento"; + break; + default: + $_SESSION['PROV_NOME'] = ""; + } + } + } + + +if ($_GET['client'] == 'BO') { + + $routine_map = 'routine_map_bckoffice'; + +} elseif ($_GET['client'] == 'RG') { //RICERCA GEOGRAFICA + + if (empty($_GET['prov'])) { + $_SESSION['COMUNE_PROV'] = ""; + + $rs_provincia = "SELECT provincia FROM public.comuni WHERE cod_belf = '" . $_SESSION['COMUNE_BELF'] . "'"; + $result_prov = pg_query($conn, $rs_provincia) or die('Query failed0'); + if (pg_num_rows($result_prov) > 0) { + while ($result_row = pg_fetch_assoc($result_prov)) { + //$_SESSION['COMUNE_PROV'] = strtolower($result_row['provincia']); + $_SESSION['COMUNE_PROV'] = $result_row['provincia']; + switch ($result_row['provincia']) { + case "SR": + $_SESSION['PROV_NOME'] = "Siracusa"; + break; + case "CT": + $_SESSION['PROV_NOME'] = "Catania"; + break; + case "EN": + $_SESSION['PROV_NOME'] = "Enna"; + break; + case "PA": + $_SESSION['PROV_NOME'] = "Palermo"; + break; + case "RG": + $_SESSION['PROV_NOME'] = "Ragusa"; + break; + case "ME": + $_SESSION['PROV_NOME'] = "Messina"; + break; + case "CL": + $_SESSION['PROV_NOME'] = "Caltanissetta"; + break; + case "TP": + $_SESSION['PROV_NOME'] = "Trapani"; + break; + case "AG": + $_SESSION['PROV_NOME'] = "Agrigento"; + break; + default: + $_SESSION['PROV_NOME'] = ""; + } + } + } + + + } else { + $_SESSION['COMUNE_PROV'] = $_GET['prov']; + $_SESSION['DATA_PROV'] = "prov"; + switch ($_GET['prov']) { + case "SR": + $_SESSION['PROV_NOME'] = "Siracusa"; + break; + case "CT": + $_SESSION['PROV_NOME'] = "Catania"; + break; + case "EN": + $_SESSION['PROV_NOME'] = "Enna"; + break; + case "PA": + $_SESSION['PROV_NOME'] = "Palermo"; + break; + case "RG": + $_SESSION['PROV_NOME'] = "Ragusa"; + break; + case "ME": + $_SESSION['PROV_NOME'] = "Messina"; + break; + case "CL": + $_SESSION['PROV_NOME'] = "Caltanissetta"; + break; + case "TP": + $_SESSION['PROV_NOME'] = "Trapani"; + break; + case "AG": + $_SESSION['PROV_NOME'] = "Agrigento"; + break; + default: + $_SESSION['PROV_NOME'] = ""; + } + } + + if (empty($_GET['idcom'])) { + $_SESSION['COMUNE_BELF'] = ""; + } else { + $_SESSION['COMUNE_BELF'] = $_GET['idcom']; + $_SESSION['DATA_PROV'] = "comu"; + } + + $routine_map = 'routine_map_ricercageo'; + + $url = $_GET['url']; + + function getCurl(string $url): ?array + { + $result = null; + $curl = curl_init($url); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_PROXY, '172.21.1.1:3128'); + $data = curl_exec($curl); + $rc = curl_getinfo($curl, CURLINFO_HTTP_CODE); + curl_close($curl); + if (200 == $rc) { + $result = json_decode($data, true); + } + return $result; + } + + $list = getCurl($url); + // Inizio Modifica TURE + $geodata = [ + 'type' => 'FeatureCollection', + 'crs' => [ + 'type' => 'name', + 'properties' => [ + 'name' => 'urn:ogc:def:crs:EPSG::4326', + ], + ], + 'features' => [], + ]; + foreach ($list as $item) { + $geodata['features'][] = [ + 'type' => 'Feature', + 'properties' => [ + 'prov' => $item['provincia'], + 'comune' => $item['nomeComune'], + 'descrizione' => $item['descrizione'], + 'estremi_catastali' => $item['estremiCatastali'], + 'lat' => $item['lat'], + 'lng' => $item['lng'], + 'numero_progetto' => $item['numeroProgetto'], + 'url' => $item['url'], + ], + 'geometry' => [ + 'type' => 'Point', + 'coordinates' => [ + $item['lng'], + $item['lat'], + ], + ], + ]; + } + $_SESSION['GEODATA'] = json_encode($geodata, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + // Fine modifica Ture +} else { + + $routine_map = 'routine_map'; + + + //INSERISCE LOG + + $instanza = "INSERT INTO public.istanze (comune,data_creaz,estremi_catastali,attivo,auth,idpratica,npratica,lat,lng) VALUES ('" . $_GET['idcom'] . "', '" . date("Y-m-d h:i:sa", time()) . "', '" . $_SESSION['cataparticella'] . "', '" . $_GET['readOnly'] . "', '" . $_GET['auth'] . "', " . $_SESSION['IDPRATICA'] . ", '" . $npratica . "', " . $_SESSION['LAT'] . ", ".$_SESSION['LONG'].")"; + //echo $instanza; + $result_instanza = pg_query($conn, $instanza) or die('Query failed3'); + + + function getSharedSecret(): string + { + return 'prosecco'; + } + + function verificaLogin($httpReferer, $date, $auth) + { + $remoteHost = parse_url($httpReferer, PHP_URL_HOST); + $hash = hash('sha256', $date . getSharedSecret() . $remoteHost); + return $hash === $auth; + } + + if (!verificaLogin($_SERVER['HTTP_REFERER'], $_GET['date'], $_GET['auth'])) { + // Il server remoto non si è autenticato correttamente. + echo 'REFERER:' . $_SERVER['HTTP_REFERER'] . "
"; + echo '

Accesso non autorizzato

'; + } + + + $rs_comune = "SELECT * FROM public.comuni WHERE cod_belf = '" . $_SESSION['COMUNE_BELF'] . "'"; + $result = pg_query($conn, $rs_comune) or die('Query failed4'); + $row_comune = pg_num_rows($result); + if ($row_comune > 0) { + while ($comunesession = pg_fetch_assoc($result)) { + $_SESSION['COMUNE_NAME'] = $comunesession['comune']; + $_SESSION['COMUNE_ISTAT'] = "0" . substr($comunesession['cod_istat'], 0, 2); + $_SESSION['COMUNE_PROV'] = $comunesession['provincia']; + $_SESSION['CENTER'] = $comunesession['lat'] .", ".$comunesession['long']; + $_SESSION['BOUND'] = $comunesession['bound']; + + } + } + + $arraymappale = explode(';', $_SESSION['cataparticella']); + + if (count($arraymappale) > 0) { + + foreach ($arraymappale as $index => $mappale) { + + if (!$query = @pg_query("SELECT id FROM ".strtolower($_SESSION['COMUNE_PROV']).".particelle WHERE comune = '" . $_SESSION['COMUNE_BELF'] . "' AND mappale ='" . $mappale . "';")) + die("Errore nella query CERCA PARTICELLA: " . pg_last_error($conn)); + + if (pg_numrows($query) > 0) { + + while ($rowparticelle = pg_fetch_assoc($query)) { + $gidquery[] = $rowparticelle['id']; + } + } + } + + //$valorearray = count($gidquery); + $stringa = implode(' OR id=', $gidquery); + $_SESSION['QUERY_CDU'] = $stringa; + $_SESSION['GET_CDU'] = 1; + } else { + unset($_SESSION['cataparticella']); + unset($_SESSION['QUERY_CDU']); + $_SESSION['GET_CDU'] = 0; + } +} +?> + + + +
+
+
+
+
+
+ +
+ + + +
+ +
+ +
+
+
+
+ + +
+ + + \ No newline at end of file diff --git a/intro.php b/intro.php new file mode 100755 index 0000000..c0cabe6 --- /dev/null +++ b/intro.php @@ -0,0 +1,29 @@ + "lax"]); //none, lax, strict +//session_set_cookie_params(["Secure" => "true"]); //false, true +//session_set_cookie_params(["HttpOnly" => "true"]); //false, true +//session_start(); +?> + + + + + +
+ +
+
+ +
+ +
+ +
+
+ +
+ + + diff --git a/legenda.php b/legenda.php new file mode 100755 index 0000000..8da330f --- /dev/null +++ b/legenda.php @@ -0,0 +1,236 @@ + + + + + + + + + + + + + + + + + + + +
LIVELLO
DESCRIZIONE
+
+ diff --git a/load.php b/load.php new file mode 100755 index 0000000..74aba71 --- /dev/null +++ b/load.php @@ -0,0 +1,65 @@ + + + + + + + + + + + + + +
+ + + +
+
+
+
+
+ +
+ + + +
+ +
+ +
+
+ +
+
+ +
+ + diff --git a/load2.php b/load2.php new file mode 100755 index 0000000..b494e3d --- /dev/null +++ b/load2.php @@ -0,0 +1,50 @@ + + + + + + +
+
+
+
+
+
+ +
+ + + +
+ +
+ +
+
+
+
+ + +
+ diff --git a/map_info.php b/map_info.php new file mode 100755 index 0000000..da32eb8 --- /dev/null +++ b/map_info.php @@ -0,0 +1,458 @@ + + + + + +
"; +} + +while ($rec_zon = pg_fetch_assoc($rs_zon)) { ?> + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
COMUNE
SIGLA
DESCRIZIONE BREVE
DESCRIZIONE
ASSOGGETTAMENTO
ART. NTA
APPROVAZIONE
AREA 10000){ + echo round (($rec_zon['area']/10000),2)." ha"; + } else { + echo round ($rec_zon['area'],2)." m2"; + } + ?> +
+ + + +
+ + FOGLIO '.$foglio.'   -   PARTICELLA '.$particella.''; + + + ?> +
+ + + + + + + + + 0) { + while($row4 = pg_fetch_assoc($result_query_zoning)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA DELLA ZONAZIONE + + + // INIZIO DEFINIZIONE DELLA COPERTURA DEI VINCOLI DI PRG + $query_prgvincoli = "SELECT a.zon_descr FROM (SELECT zon_descr, geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".vincoli) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_prgvincoli = pg_query($conn, $query_prgvincoli) or die('Query query_prgvincoli failied'); + + if (pg_num_rows($result_query_prgvincoli) > 0) { + while($row5 = pg_fetch_assoc($result_query_prgvincoli)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA DEI VINCOLI DI PRG + + // INIZIO DEFINIZIONE DELLA COPERTURA DEI VINCOLI BBCCAA + $query_regimi = "SELECT a.pl, a.liv_tutela, a.contesto, ST_AREA(ST_intersection(a.geom, b.geom)) AS areabbccaa FROM (SELECT pl, liv_tutela, contesto, geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".regimi_normativi) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_regimi = pg_query($conn, $query_regimi) or die('Query query_regimi failied'); + + if (pg_num_rows($result_query_regimi) > 0) { + //echo "####".$row_query6. "####"; + while($row6 = pg_fetch_assoc($result_query_regimi)) { + + switch ($row6['liv_tutela']) { + case 1: + $bbccaa = "Livello di tutela 1"; + break; + case 2: + $bbccaa = "Livello di tutela 2"; + break; + case 3: + $bbccaa = "Livello di tutela 3"; + break; + case 4: + $bbccaa = "Livello di tutela 4"; + break; + default: + $bbccaa = ""; + } + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA DEI VINCOLI BBCCAA + + + // INIZIO DEFINIZIONE DELLA COPERTURA V_1497 + $query_v_1497 = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_1497 FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_1497) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_1497 = pg_query($conn, $query_v_1497) or die('Query query_v_1497 failied'); + + if (pg_num_rows($result_query_v_1497) > 0) { + while($row6a = pg_fetch_assoc($result_query_v_1497)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA V_1497 + + // INIZIO DEFINIZIONE DELLA COPERTURA V_ARCHEO + $query_v_archeo = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_archeo FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_archeo) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_archeo = pg_query($conn, $query_v_archeo) or die('Query query_v_archeo failied'); + + if (pg_num_rows($result_query_v_archeo) > 0) { + while($row6b = pg_fetch_assoc($result_query_v_archeo)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA V_ARCHEO + + // INIZIO DEFINIZIONE DELLA COPERTURA V_BOSCHI + $query_v_boschi = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_boschi FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_boschi) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_boschi = pg_query($conn, $query_v_boschi) or die('Query query_v_boschi failied'); + + if (pg_num_rows($result_query_v_boschi) > 0) { + while($row6c = pg_fetch_assoc($result_query_v_boschi)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA V_BOSCHI + + // INIZIO DEFINIZIONE DELLA COPERTURA V_COSTA + $query_v_costa = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_costa FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_costa) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + //echo $query_v_costa."
"; + $result_query_v_costa = pg_query($conn, $query_v_costa) or die('Query query_v_costa failied'); + + if (pg_num_rows($result_query_v_costa) > 0) { + while($row6d = pg_fetch_assoc($result_query_v_costa)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA V_COSTA + + // INIZIO DEFINIZIONE DELLA COPERTURA V_FIUMI + $query_v_fiumi = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_fiumi FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_fiumi) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_fiumi = pg_query($conn, $query_v_fiumi) or die('Query query_v_fiumi failied'); + + if (pg_num_rows($result_query_v_fiumi) > 0) { + while($row6e = pg_fetch_assoc($result_query_v_fiumi)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA V_FIUMI + + // INIZIO DEFINIZIONE DELLA COPERTURA V_INTERESSE_ARCHEO + $query_v_interesse_archeo = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_interesse_archeo FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_interesse_archeo) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_interesse_archeo = pg_query($conn, $query_v_interesse_archeo) or die('Query query_v_interesse_archeo failied'); + + if (pg_num_rows($result_query_v_interesse_archeo) > 0) { + while($row6f = pg_fetch_assoc($result_query_v_interesse_archeo)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA V_INTERESSE_ARCHEO + + // INIZIO DEFINIZIONE DELLA COPERTURA V_LAGHI + $query_v_laghi = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_laghi FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_laghi) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_laghi = pg_query($conn, $query_v_laghi) or die('Query query_v_laghi failied'); + + if (pg_num_rows($result_query_v_laghi) > 0) { + while($row6g = pg_fetch_assoc($result_query_v_laghi)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA V_LAGHI + + // INIZIO DEFINIZIONE DELLA COPERTURA V_LETTERA_C + $query_v_lettera_c = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_lettera_c FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_lettera_c) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_lettera_c = pg_query($conn, $query_v_lettera_c) or die('Query query_v_lettera_c failied'); + + if (pg_num_rows($result_query_v_lettera_c) > 0) { + while($row6h = pg_fetch_assoc($result_query_v_lettera_c)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA V_LETTERA_C + + // INIZIO DEFINIZIONE DELLA COPERTURA V_RISERVE + $query_v_riserve = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_riserve FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_riserve) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_riserve = pg_query($conn, $query_v_riserve) or die('Query query_v_riserve failied'); + + if (pg_num_rows($result_query_v_riserve) > 0) { + while($row6i = pg_fetch_assoc($result_query_v_riserve)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA V_RISERVE + + // INIZIO DEFINIZIONE DELLA COPERTURA V_PARCHI + $query_v_parchi = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_parchi FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_parchi) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_parchi = pg_query($conn, $query_v_parchi) or die('Query query_v_parchi failied'); + + if (pg_num_rows($result_query_v_parchi) > 0) { + while($row6l = pg_fetch_assoc($result_query_v_parchi)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA V_PARCHI + + // INIZIO DEFINIZIONE DELLA COPERTURA V_1200 + $query_v_1200 = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS area_v_1200 FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".v_1200) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_1200 = pg_query($conn, $query_v_1200) or die('Query query_v_1200 failied'); + + if (pg_num_rows($result_query_v_1200) > 0) { + while($row6m = pg_fetch_assoc($result_query_v_1200)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA V_1200 + + // INIZIO DEFINIZIONE DELLA COPERTURA DEL VINCOLO IDROGEOLOGICO + $query_v_idrogeol = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS areaidro FROM (SELECT geom FROM rscarto.sif_vincolo_idrogeo_sicilia) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_v_idrogeol = pg_query($conn, $query_v_idrogeol) or die('Query query_v_idrogeol failied'); + + if (pg_num_rows($query72) > 0) { + while($row72 = pg_fetch_assoc($query72)) { + + echo "\n\t\n\t\t\n\t\t\n\t\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA VINCOLO IDROGEOLOGICO + + // INIZIO DEFINIZIONE DELLA COPERTURA DEL VINCOLO BOSCHI DL227 + $query_dl227 = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS areadl227 FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".sif_dl227) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_dl227 = pg_query($conn, $query_dl227) or die('Query query_dl227 failied'); + + if (pg_num_rows($result_query_dl227) > 0) { + while($row72 = pg_fetch_assoc($result_query_dl227)) { + + echo "\n\t\n\t\t\n\t\t\n\t\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA DEL VINCOLO BOSCHI DL227 + + // INIZIO DEFINIZIONE DELLA COPERTURA DEL VINCOLO BOSCHI LR16 + $query_lr16 = "SELECT ST_AREA(ST_intersection(a.geom, b.geom)) AS arealr16 FROM (SELECT geom FROM ".strtolower($_SESSION['COMUNE_PROV']).".sif_lr16) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_lr16 = pg_query($conn, $query_lr16) or die('Query query_lr16 failied'); + + if (pg_num_rows($result_query_lr16) > 0) { + //echo "#### - 7 ".$row_query7. "####"; + while($row8 = pg_fetch_assoc($result_query_lr16)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA DEL VINCOLO BOSCHI LR16 + + // INIZIO DEFINIZIONE DELLA COPERTURA SIC-ZPS + $query_siczps = "SELECT a.denom, ST_AREA(ST_intersection(a.geom, b.geom)) AS areasiczps FROM (SELECT denom, geom FROM rscarto.sic_zps) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_siczps = pg_query($conn, $query_siczps) or die('Query query_siczps failied'); + + if (pg_num_rows($result_query_siczps) > 0) { + //echo "#### - 7 ".$row_query7. "####"; + while($row81 = pg_fetch_assoc($result_query_siczps)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA SIC-ZPS + + // INIZIO DEFINIZIONE DELLA COPERTURA RISERVE + $query_riserve = "SELECT a.denom, ST_AREA(ST_intersection(a.geom, b.geom)) AS areariserve FROM (SELECT denom, geom FROM rscarto.riserve_sicilia) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_riserve = pg_query($conn, $query_riserve) or die('Query query_riserve failied'); + + if (pg_num_rows($query82) > 0) { + //echo "#### - 7 ".$row_query7. "####"; + while($row82 = pg_fetch_assoc($query82)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA RISERVE + + // INIZIO DEFINIZIONE DELLA COPERTURA PAI IDRO RISCHIO + $query_idro_rischio = "SELECT a.rischio, ST_AREA(ST_intersection(a.geom, b.geom)) AS area_idro_rischio FROM (SELECT rischio, geom FROM rscarto.pai_idr_r) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_idro_rischio = pg_query($conn, $query_idro_rischio) or die('Query query_idro_rischio failied'); + + if (pg_num_rows($result_query_idro_rischio) > 0) { + while($row9 = pg_fetch_assoc($result_query_idro_rischio)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA PAI IDRO RISCHIO + + // INIZIO DEFINIZIONE DELLA COPERTURA PAI IDRO PERICOLOSITA' + $query_idro_pericolo = "SELECT a.pericolo, ST_AREA(ST_intersection(a.geom, b.geom)) AS area_idro_pericolo FROM (SELECT pericolo, geom FROM rscarto.pai_idr_p_sa) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_idro_pericolo = pg_query($conn, $query_idro_pericolo) or die('Query query_idro_pericolo failied'); + + if (pg_num_rows($result_query_idro_pericolo) > 0) { + + while($row10 = pg_fetch_assoc($result_query_idro_pericolo)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA PAI IDRO RISCHIO + + // INIZIO DEFINIZIONE DELLA COPERTURA PAI GEOMORF RISCHIO + $query_geo_rischio = "SELECT a.rischio, ST_AREA(ST_intersection(a.geom, b.geom)) AS area_geo_rischio FROM (SELECT rischio, geom FROM rscarto.pai_geo_rischio) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_geo_rischio = pg_query($conn, $query_geo_rischio) or die('Query query_geo_rischio failied'); + + if (pg_num_rows($result_query_geo_rischio) > 0) { + + while($row11 = pg_fetch_assoc($result_query_geo_rischio)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA PAI GEOMORF RISCHIO + + // INIZIO DEFINIZIONE DELLA COPERTURA PAI GEOMORF PERICOLOSITA + $query_geo_pericolo = "SELECT a.pericolo, ST_AREA(ST_intersection(a.geom, b.geom)) AS area_geo_pericolo FROM (SELECT pericolo, geom FROM rscarto.pai_geo_peric) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_geo_pericolo = pg_query($conn, $query_geo_pericolo) or die('Query query_geo_pericolo failied'); + + if (pg_num_rows($result_query_geo_pericolo) > 0) { + //echo "#### - 7 ".$row_query7. "####"; + while($row12 = pg_fetch_assoc($result_query_geo_pericolo)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA PAI GEOMORF PERICOLOSITA + + + // INIZIO DEFINIZIONE DELLA COPERTURA SIN + $query_sin = "SELECT a.denominaz, ST_AREA(ST_intersection(a.geom, b.geom)) AS area_sin FROM (SELECT denominaz, geom FROM rscarto.sin) a, (SELECT ST_GeomFromEWKT('SRID=25833;".$_SESSION['geom']."') as geom) b WHERE ST_Intersects (a.geom,b.geom)"; + $result_query_sin = pg_query($conn, $query_sin) or die('Query query_sin failied'); + + if (pg_num_rows($result_query_sin) > 0) { + //echo "#### - 7 ".$row_query7. "####"; + while($rowsin = pg_fetch_assoc($result_query_sin)) { + + echo "\n\t\n\t\t\n\t\t\n\t"; + + }} + // FINE DEFINIZIONE DELLA COPERTURA SIN + + + //} + + //pg_close($conndb); + ?> + + + +
DESTINAZIONE
COPERTURA
Zona di PRG{$row4['zon_sigla']} - {$row4['zon_descr']}
Vincolo di PRG{$row5['zon_descr']}
Piano Paesaggistico Regionale
Regimi Normativi
Paesaggio locale {$row6['pl']}
{$bbccaa} - Contesto {$row6['contesto']}
+ {$row6['contesto']}
BENI PAESAGGISTICIArea tutelata (art.136, D.lgs.42/04)
BENI PAESAGGISTICIVincolo Archeologico (art.10, D.lgs.42/04)
BENI PAESAGGISTICIAree boscate (art.142, lett. g, D.lgs.42/04)
BENI PAESAGGISTICIAree costa 300m (art.142, lett.a, D.lgs. 42/04)
BENI PAESAGGISTICIAree fiumi 150m (art.142, lett. c, D.lgs.42/04)
BENI PAESAGGISTICIAree di interesse archeologico (art.142, lett. m, D.lgs.42/04)
BENI PAESAGGISTICIAree laghi 300m (art.142, lett. b, D.lgs. 42/04)
BENI PAESAGGISTICIAree tutelate (art.134, lett. c, D.lgs. 42/04)
BENI PAESAGGISTICIAree riserve regionali (art.142, lett. f, D.lgs.42/04)
BENI PAESAGGISTICIParchi regionali (art.142, lett. f, D.lgs.42/04)
{$row6l['denom']}
BENI PAESAGGISTICIAree al di sopra di 1200 (art.142, lett. d, D.lgs.42/04)
Vincolo Boschi  Art.2 D.L. 18 maggio 2001, n. 227
Vincolo Boschi  Art.2 D.L. 18 maggio 2001, n. 227
Vincolo Boschi  L.R. 16/96 art. 4
SIC - ZPS{$row81['codice']} - {$row81['denom']}
RISERVE{$row82['codice']} - {$row82['denom']}
P.A.I.Rischio Idraulico - {$row9['rischio']}
P.A.I.Pericolosità Idraulica - {$row10['pericolo']}
P.A.I.Rischio Geomorfologico - {$row11['rischio']}
P.A.I.Pericolosità Geomorfologica - {$row12['pericolo']}
SINSito di Interesse Nazionale
+ + + diff --git a/marker-icon-2x.png b/marker-icon-2x.png new file mode 100755 index 0000000000000000000000000000000000000000..88f9e501888c9c6cb29ad340d9a888627dd1b6d8 GIT binary patch literal 2464 zcmV;R319Y!P)YnU^5s62$4H-fe}gSR(=wKRaTHh!@*b)YV6mo|a4Fn6Rgc&Rpk zvn_X|3VY?v=>nJ{slE^V1GaGWk}m@aIWGIpghbfPh8m@aIWEo_%AZI>==moIFVE^L=C zZJ91?mo03UEp3-BY?wBGur6$uD{Yr9Y?m%SHF8Fk1pc(Nva%QJ+{FLkalfypz3&M|||Fn`7|g3c~4(nXHKFmRnwn$J#_$xE8i z|Ns9!kC;(oC1qQk>LMp3_a2(odYyMT@>voX=UI)k>1cJdn;gjmJ-|6v4nb1Oryh)eQMwHP(i@!36%vGJyFK(JTj?Vb{{C=jx&)@1l zlFmnw%0`&bqruifkkHKC=vbiAM3&E`#Mv>2%tw;VK8?_|&E89cs{a1}$J*!f_xd-C z&F%B|oxRgPlh0F!txkxrQjNA`m9~?&&|jw4W0<`_iNHsX$VQXVK!B}Xkh4>av|f_8 zLY2?t?ejE=%(TnfV5iqOjm?d;&qI~ZGl|SzU77a)002XDQchC<95+*MjE@82?VLm= z3xf6%Vd@99z|q|-ua5l3kJxvZwan-8K1cPiwQAtlcNX~ZqLeoMB+a;7)WA|O#HOB% zg6SX;754xD1{Fy}K~#8Ntklac&zTpadXZ& zC*_=T&g7hfbI$R?v%9?sknIb97gJOJ=`-8YyS3ndqN+Jm+x33!p&Hc@@L$w))s2@N ztv~i}Emc?DykgwFWwma($8+~b>l?tqj$dh13R^nMZnva9 zn0Vflzv2Dvp`oVQw{Guby~i`JGbyBGTEC{y>yzCkg>K&CIeQ$u;lyQ+M{O~gEJ^)Z zrF3p)^>|uT;57}WY&IRwyOQ=dq%Az}_t=_hKowP!Z79q0;@Zu(SWEJJcHY+5T6I({ zw)wj*SNi4wrd+POUfZe4gF77vW?j zoFS}|r2n&$U9Y!S4VEOyN}OpZZi|?cr1VcE_tHsDQgp-ga(SwkBrkCm{|*-yb=}ZW zvcYvLvfA90TPn|!-TuYJV<6`}+RJeRgP3EA=qQcF9k0*#*{f&I_pjam%I6Dd#YE|G zqB!R}tW-K!wV1w+4JcFA_s6~=@9F&j8`u$-ifLN3vK;`lvaA-`jRn_}(8|)!3?-}I zvFi{H;@A$gEZYh?%|Qr_y#*UkOPjwiRCsJQ>mb6h5yGIk6C5_XA=8T?IBfm_?+P0; zhhUs)-(0R*H<&Kku(1>#cGtOpk&Z&kQcw&SJv-4VY<+;=8hYnoX zfNJMCa9)^5Z0;2dCUk;x-%#yS!I~Jr3pNuI!g_tHz!$hKwt1GL~sFvx)3u4TA zv>CLGdQtoZ7Du7ctJRfTqY;FPxs1G{ZJ?73D5J@OO{6BHcPbk{_mjg&p2QFeke%QI zlAJ-kvjuwy1<5D-6>su68A+i998aSZNnQX)+Q}6(GK-C%8G-!1bOJBONU{gT%IOOE z;Yk24YC@^lFW77>r6x7eS1Omc;8=GUp#&zLQ&L{ zv8$hGC`wp~$9pR>f%-_Ps3>YhzP(+vC(E*zr1CVO8ChN^MI-VGMX7+|(r!SGZ9gd5 zzO9sQd>sm|f1|X&oh=8lOzd6+ITvo zCXInR?>RZ#>Hb*PO=7dI!dZ(wY4O}ZGv zdfQFio7+0~PN*RFCZGM6@9-o~y*@?;k00NvOsw54t1^tt{*ATMs^2j}4Wp=4t3RH* z_+8b`F-{E=0sOgM<;VHTo!Ij3u zmmI`2?K7g(GOcGA)@h?$SW&pwHdtj1n57PLI8&6RHhx4R%Q7b z^JEqR)@06V!pbS*@D_ZyRMo_LlT}r{#sXOx4kM-V<_V{!5SSuM^SIVCA37|nY7LWQ zZA#B1h4l`6asz=Lvax_#GMRX|NF>=$=p{Qn0i@ExX1jGhy@B8a*_uR+ODEbVi8ObL zezG?azy>E~S~dl43&8<$(2H}P&*tuBdESUP83KQ?8B z?K(!uS>H1wlWQz;qOfB`T#TZ=EoSp~vZ5XtCvwm1h*Ex6mzTsn_y@_=xREIslV-%- zpdWkEzMjeNOGWrSM32gpBt27*O29NdhGzuDgYxcf`Jjjqw@B;Vmdb@fxdhCRi`Kg> zmUTr$=&@#i!%F4Q6mb&4QKfR^95KJ!<6~fqx-f^66AV!|ywG{6D^Vay-3b99>XOe# e-I|>x8~*?ZhF3snGbtJX0000cOl4 literal 0 HcmV?d00001 diff --git a/marker-icon.png b/marker-icon.png new file mode 100755 index 0000000000000000000000000000000000000000..950edf24677ded147df13b26f91baa2b0fa70513 GIT binary patch literal 1466 zcmV;r1x5OaP)P001cn1^@s6z>|W`000GnNklGNuHDcIX17Zdjl&3`L?0sTjIws<{((Dh&g-s0<@jYQyl?D*X^?%13;ml^gy> ziMrY_^1WI=(g@LMizu=zCoA>C`6|QEq1eV92k*7m>G65*&@&6)aC&e}G zI)pf-Za|N`DT&Cn1J|o`19mumxW~hiKiKyc-P`S@q)rdTo84@QI@;0yXrG%9uhI>A zG5QHb6s4=<6xy{1 z@NMxEkryp{LS44%z$3lP^cX!9+2-;CTt3wM4(k*#C{aiIiLuB>jJj;KPhPzIC00bL zU3a#;aJld94lCW=`4&aAy8M7PY=HQ>O%$YEP4c4UY#CRxfgbE~(|uiI=YS8q;O9y6 zmIkXzR`}p7ti|PrM3a}WMnR=3NVnWdAAR>b9X@)DKL6=YsvmH%?I24wdq?Gh54_;# z$?_LvgjEdspdQlft#4CQ z`2Zyvy?*)N1Ftw|{_hakhG9WjS?Az@I@+IZ8JbWewR!XUK4&6346+d#~gsE0SY(LX8&JfY>Aj)RxGy96nwhs2rv zzW6pTnMpFkDSkT*a*6Dx|u@ds6ISVn0@^RmIsKZ5Y;bazbc;tTSq(kg(=481ODrPyNB6n z-$+U}(w$m6U6H$w17Bw+wDaFIe~GvNMYvnw31MpY0eQKT9l>SU``8k7w4)z!GZKMI z#_cEKq7k~i%nlK@6c-K?+R;B#5$?T#YpKD`t_4bAs^#E+@5QW$@OX3*`;(#{U^d-vY)&xEE>n5lYl&T?Am + + + + + + + + + + + + diff --git a/mc_header2.php b/mc_header2.php new file mode 100755 index 0000000..66726ed --- /dev/null +++ b/mc_header2.php @@ -0,0 +1,28 @@ + + + + + + + + + + + + +Paesaggistica Sicilia + + + + + + + + + + + + + +
+
diff --git a/mobile_detect.php b/mobile_detect.php new file mode 100755 index 0000000..3a82c29 --- /dev/null +++ b/mobile_detect.php @@ -0,0 +1,1341 @@ + + * Nick Ilyin + * + * Original author: Victor Stanciu + * + * @license Code and contributions have 'MIT License' + * More details: https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt + * + * @link Homepage: http://mobiledetect.net + * GitHub Repo: https://github.com/serbanghita/Mobile-Detect + * Google Code: http://code.google.com/p/php-mobile-detect/ + * README: https://github.com/serbanghita/Mobile-Detect/blob/master/README.md + * HOWTO: https://github.com/serbanghita/Mobile-Detect/wiki/Code-examples + * + * @version 2.8.11 + */ + +class Mobile_Detect +{ + /** + * Mobile detection type. + * + * @deprecated since version 2.6.9 + */ + const DETECTION_TYPE_MOBILE = 'mobile'; + + /** + * Extended detection type. + * + * @deprecated since version 2.6.9 + */ + const DETECTION_TYPE_EXTENDED = 'extended'; + + /** + * A frequently used regular expression to extract version #s. + * + * @deprecated since version 2.6.9 + */ + const VER = '([\w._\+]+)'; + + /** + * Top-level device. + */ + const MOBILE_GRADE_A = 'A'; + + /** + * Mid-level device. + */ + const MOBILE_GRADE_B = 'B'; + + /** + * Low-level device. + */ + const MOBILE_GRADE_C = 'C'; + + /** + * Stores the version number of the current release. + */ + const VERSION = '2.8.11'; + + /** + * A type for the version() method indicating a string return value. + */ + const VERSION_TYPE_STRING = 'text'; + + /** + * A type for the version() method indicating a float return value. + */ + const VERSION_TYPE_FLOAT = 'float'; + + /** + * The User-Agent HTTP header is stored in here. + * @var string + */ + protected $userAgent = null; + + /** + * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE. + * @var array + */ + protected $httpHeaders = array(); + + /** + * The matching Regex. + * This is good for debug. + * @var string + */ + protected $matchingRegex = null; + + /** + * The matches extracted from the regex expression. + * This is good for debug. + * @var string + */ + protected $matchesArray = null; + + /** + * The detection type, using self::DETECTION_TYPE_MOBILE or self::DETECTION_TYPE_EXTENDED. + * + * @deprecated since version 2.6.9 + * + * @var string + */ + protected $detectionType = self::DETECTION_TYPE_MOBILE; + + /** + * HTTP headers that trigger the 'isMobile' detection + * to be true. + * + * @var array + */ + protected static $mobileHeaders = array( + + 'HTTP_ACCEPT' => array('matches' => array( + // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/ + 'application/x-obml2d', + // BlackBerry devices. + 'application/vnd.rim.html', + 'text/vnd.wap.wml', + 'application/vnd.wap.xhtml+xml' + )), + 'HTTP_X_WAP_PROFILE' => null, + 'HTTP_X_WAP_CLIENTID' => null, + 'HTTP_WAP_CONNECTION' => null, + 'HTTP_PROFILE' => null, + // Reported by Opera on Nokia devices (eg. C3). + 'HTTP_X_OPERAMINI_PHONE_UA' => null, + 'HTTP_X_NOKIA_GATEWAY_ID' => null, + 'HTTP_X_ORANGE_ID' => null, + 'HTTP_X_VODAFONE_3GPDPCONTEXT' => null, + 'HTTP_X_HUAWEI_USERID' => null, + // Reported by Windows Smartphones. + 'HTTP_UA_OS' => null, + // Reported by Verizon, Vodafone proxy system. + 'HTTP_X_MOBILE_GATEWAY' => null, + // Seen this on HTC Sensation. SensationXE_Beats_Z715e. + 'HTTP_X_ATT_DEVICEID' => null, + // Seen this on a HTC. + 'HTTP_UA_CPU' => array('matches' => array('ARM')), + ); + + /** + * List of mobile devices (phones). + * + * @var array + */ + protected static $phoneDevices = array( + 'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes + 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+', + 'HTC' => 'HTC|HTC.*(Sensation|Evo|Vision|Explorer|6800|8100|8900|A7272|S510e|C110e|Legend|Desire|T8282)|APX515CKT|Qtek9090|APA9292KT|HD_mini|Sensation.*Z710e|PG86100|Z715e|Desire.*(A8181|HD)|ADR6200|ADR6400L|ADR6425|001HT|Inspire 4G|Android.*\bEVO\b|T-Mobile G1|Z520m', + 'Nexus' => 'Nexus One|Nexus S|Galaxy.*Nexus|Android.*Nexus.*Mobile|Nexus 4|Nexus 5|Nexus 6', + // @todo: Is 'Dell Streak' a tablet or a phone? ;) + 'Dell' => 'Dell.*Streak|Dell.*Aero|Dell.*Venue|DELL.*Venue Pro|Dell Flash|Dell Smoke|Dell Mini 3iX|XCD28|XCD35|\b001DL\b|\b101DL\b|\bGS01\b', + 'Motorola' => 'Motorola|DROIDX|DROID BIONIC|\bDroid\b.*Build|Android.*Xoom|HRI39|MOT-|A1260|A1680|A555|A853|A855|A953|A955|A956|Motorola.*ELECTRIFY|Motorola.*i1|i867|i940|MB200|MB300|MB501|MB502|MB508|MB511|MB520|MB525|MB526|MB611|MB612|MB632|MB810|MB855|MB860|MB861|MB865|MB870|ME501|ME502|ME511|ME525|ME600|ME632|ME722|ME811|ME860|ME863|ME865|MT620|MT710|MT716|MT720|MT810|MT870|MT917|Motorola.*TITANIUM|WX435|WX445|XT300|XT301|XT311|XT316|XT317|XT319|XT320|XT390|XT502|XT530|XT531|XT532|XT535|XT603|XT610|XT611|XT615|XT681|XT701|XT702|XT711|XT720|XT800|XT806|XT860|XT862|XT875|XT882|XT883|XT894|XT901|XT907|XT909|XT910|XT912|XT928|XT926|XT915|XT919|XT925', + 'Samsung' => 'Samsung|SGH-I337|BGT-S5230|GT-B2100|GT-B2700|GT-B2710|GT-B3210|GT-B3310|GT-B3410|GT-B3730|GT-B3740|GT-B5510|GT-B5512|GT-B5722|GT-B6520|GT-B7300|GT-B7320|GT-B7330|GT-B7350|GT-B7510|GT-B7722|GT-B7800|GT-C3010|GT-C3011|GT-C3060|GT-C3200|GT-C3212|GT-C3212I|GT-C3262|GT-C3222|GT-C3300|GT-C3300K|GT-C3303|GT-C3303K|GT-C3310|GT-C3322|GT-C3330|GT-C3350|GT-C3500|GT-C3510|GT-C3530|GT-C3630|GT-C3780|GT-C5010|GT-C5212|GT-C6620|GT-C6625|GT-C6712|GT-E1050|GT-E1070|GT-E1075|GT-E1080|GT-E1081|GT-E1085|GT-E1087|GT-E1100|GT-E1107|GT-E1110|GT-E1120|GT-E1125|GT-E1130|GT-E1160|GT-E1170|GT-E1175|GT-E1180|GT-E1182|GT-E1200|GT-E1210|GT-E1225|GT-E1230|GT-E1390|GT-E2100|GT-E2120|GT-E2121|GT-E2152|GT-E2220|GT-E2222|GT-E2230|GT-E2232|GT-E2250|GT-E2370|GT-E2550|GT-E2652|GT-E3210|GT-E3213|GT-I5500|GT-I5503|GT-I5700|GT-I5800|GT-I5801|GT-I6410|GT-I6420|GT-I7110|GT-I7410|GT-I7500|GT-I8000|GT-I8150|GT-I8160|GT-I8190|GT-I8320|GT-I8330|GT-I8350|GT-I8530|GT-I8700|GT-I8703|GT-I8910|GT-I9000|GT-I9001|GT-I9003|GT-I9010|GT-I9020|GT-I9023|GT-I9070|GT-I9082|GT-I9100|GT-I9103|GT-I9220|GT-I9250|GT-I9300|GT-I9305|GT-I9500|GT-I9505|GT-M3510|GT-M5650|GT-M7500|GT-M7600|GT-M7603|GT-M8800|GT-M8910|GT-N7000|GT-S3110|GT-S3310|GT-S3350|GT-S3353|GT-S3370|GT-S3650|GT-S3653|GT-S3770|GT-S3850|GT-S5210|GT-S5220|GT-S5229|GT-S5230|GT-S5233|GT-S5250|GT-S5253|GT-S5260|GT-S5263|GT-S5270|GT-S5300|GT-S5330|GT-S5350|GT-S5360|GT-S5363|GT-S5369|GT-S5380|GT-S5380D|GT-S5560|GT-S5570|GT-S5600|GT-S5603|GT-S5610|GT-S5620|GT-S5660|GT-S5670|GT-S5690|GT-S5750|GT-S5780|GT-S5830|GT-S5839|GT-S6102|GT-S6500|GT-S7070|GT-S7200|GT-S7220|GT-S7230|GT-S7233|GT-S7250|GT-S7500|GT-S7530|GT-S7550|GT-S7562|GT-S7710|GT-S8000|GT-S8003|GT-S8500|GT-S8530|GT-S8600|SCH-A310|SCH-A530|SCH-A570|SCH-A610|SCH-A630|SCH-A650|SCH-A790|SCH-A795|SCH-A850|SCH-A870|SCH-A890|SCH-A930|SCH-A950|SCH-A970|SCH-A990|SCH-I100|SCH-I110|SCH-I400|SCH-I405|SCH-I500|SCH-I510|SCH-I515|SCH-I600|SCH-I730|SCH-I760|SCH-I770|SCH-I830|SCH-I910|SCH-I920|SCH-I959|SCH-LC11|SCH-N150|SCH-N300|SCH-R100|SCH-R300|SCH-R351|SCH-R400|SCH-R410|SCH-T300|SCH-U310|SCH-U320|SCH-U350|SCH-U360|SCH-U365|SCH-U370|SCH-U380|SCH-U410|SCH-U430|SCH-U450|SCH-U460|SCH-U470|SCH-U490|SCH-U540|SCH-U550|SCH-U620|SCH-U640|SCH-U650|SCH-U660|SCH-U700|SCH-U740|SCH-U750|SCH-U810|SCH-U820|SCH-U900|SCH-U940|SCH-U960|SCS-26UC|SGH-A107|SGH-A117|SGH-A127|SGH-A137|SGH-A157|SGH-A167|SGH-A177|SGH-A187|SGH-A197|SGH-A227|SGH-A237|SGH-A257|SGH-A437|SGH-A517|SGH-A597|SGH-A637|SGH-A657|SGH-A667|SGH-A687|SGH-A697|SGH-A707|SGH-A717|SGH-A727|SGH-A737|SGH-A747|SGH-A767|SGH-A777|SGH-A797|SGH-A817|SGH-A827|SGH-A837|SGH-A847|SGH-A867|SGH-A877|SGH-A887|SGH-A897|SGH-A927|SGH-B100|SGH-B130|SGH-B200|SGH-B220|SGH-C100|SGH-C110|SGH-C120|SGH-C130|SGH-C140|SGH-C160|SGH-C170|SGH-C180|SGH-C200|SGH-C207|SGH-C210|SGH-C225|SGH-C230|SGH-C417|SGH-C450|SGH-D307|SGH-D347|SGH-D357|SGH-D407|SGH-D415|SGH-D780|SGH-D807|SGH-D980|SGH-E105|SGH-E200|SGH-E315|SGH-E316|SGH-E317|SGH-E335|SGH-E590|SGH-E635|SGH-E715|SGH-E890|SGH-F300|SGH-F480|SGH-I200|SGH-I300|SGH-I320|SGH-I550|SGH-I577|SGH-I600|SGH-I607|SGH-I617|SGH-I627|SGH-I637|SGH-I677|SGH-I700|SGH-I717|SGH-I727|SGH-i747M|SGH-I777|SGH-I780|SGH-I827|SGH-I847|SGH-I857|SGH-I896|SGH-I897|SGH-I900|SGH-I907|SGH-I917|SGH-I927|SGH-I937|SGH-I997|SGH-J150|SGH-J200|SGH-L170|SGH-L700|SGH-M110|SGH-M150|SGH-M200|SGH-N105|SGH-N500|SGH-N600|SGH-N620|SGH-N625|SGH-N700|SGH-N710|SGH-P107|SGH-P207|SGH-P300|SGH-P310|SGH-P520|SGH-P735|SGH-P777|SGH-Q105|SGH-R210|SGH-R220|SGH-R225|SGH-S105|SGH-S307|SGH-T109|SGH-T119|SGH-T139|SGH-T209|SGH-T219|SGH-T229|SGH-T239|SGH-T249|SGH-T259|SGH-T309|SGH-T319|SGH-T329|SGH-T339|SGH-T349|SGH-T359|SGH-T369|SGH-T379|SGH-T409|SGH-T429|SGH-T439|SGH-T459|SGH-T469|SGH-T479|SGH-T499|SGH-T509|SGH-T519|SGH-T539|SGH-T559|SGH-T589|SGH-T609|SGH-T619|SGH-T629|SGH-T639|SGH-T659|SGH-T669|SGH-T679|SGH-T709|SGH-T719|SGH-T729|SGH-T739|SGH-T746|SGH-T749|SGH-T759|SGH-T769|SGH-T809|SGH-T819|SGH-T839|SGH-T919|SGH-T929|SGH-T939|SGH-T959|SGH-T989|SGH-U100|SGH-U200|SGH-U800|SGH-V205|SGH-V206|SGH-X100|SGH-X105|SGH-X120|SGH-X140|SGH-X426|SGH-X427|SGH-X475|SGH-X495|SGH-X497|SGH-X507|SGH-X600|SGH-X610|SGH-X620|SGH-X630|SGH-X700|SGH-X820|SGH-X890|SGH-Z130|SGH-Z150|SGH-Z170|SGH-ZX10|SGH-ZX20|SHW-M110|SPH-A120|SPH-A400|SPH-A420|SPH-A460|SPH-A500|SPH-A560|SPH-A600|SPH-A620|SPH-A660|SPH-A700|SPH-A740|SPH-A760|SPH-A790|SPH-A800|SPH-A820|SPH-A840|SPH-A880|SPH-A900|SPH-A940|SPH-A960|SPH-D600|SPH-D700|SPH-D710|SPH-D720|SPH-I300|SPH-I325|SPH-I330|SPH-I350|SPH-I500|SPH-I600|SPH-I700|SPH-L700|SPH-M100|SPH-M220|SPH-M240|SPH-M300|SPH-M305|SPH-M320|SPH-M330|SPH-M350|SPH-M360|SPH-M370|SPH-M380|SPH-M510|SPH-M540|SPH-M550|SPH-M560|SPH-M570|SPH-M580|SPH-M610|SPH-M620|SPH-M630|SPH-M800|SPH-M810|SPH-M850|SPH-M900|SPH-M910|SPH-M920|SPH-M930|SPH-N100|SPH-N200|SPH-N240|SPH-N300|SPH-N400|SPH-Z400|SWC-E100|SCH-i909|GT-N7100|GT-N7105|SCH-I535|SM-N900A|SGH-I317|SGH-T999L|GT-S5360B|GT-I8262|GT-S6802|GT-S6312|GT-S6310|GT-S5312|GT-S5310|GT-I9105|GT-I8510|GT-S6790N|SM-G7105|SM-N9005|GT-S5301|GT-I9295|GT-I9195|SM-C101|GT-S7392|GT-S7560|GT-B7610|GT-I5510|GT-S7582|GT-S7530E|GT-I8750', + 'LG' => '\bLG\b;|LG[- ]?(C800|C900|E400|E610|E900|E-900|F160|F180K|F180L|F180S|730|855|L160|LS740|LS840|LS970|LU6200|MS690|MS695|MS770|MS840|MS870|MS910|P500|P700|P705|VM696|AS680|AS695|AX840|C729|E970|GS505|272|C395|E739BK|E960|L55C|L75C|LS696|LS860|P769BK|P350|P500|P509|P870|UN272|US730|VS840|VS950|LN272|LN510|LS670|LS855|LW690|MN270|MN510|P509|P769|P930|UN200|UN270|UN510|UN610|US670|US740|US760|UX265|UX840|VN271|VN530|VS660|VS700|VS740|VS750|VS910|VS920|VS930|VX9200|VX11000|AX840A|LW770|P506|P925|P999|E612|D955|D802)', + 'Sony' => 'SonyST|SonyLT|SonyEricsson|SonyEricssonLT15iv|LT18i|E10i|LT28h|LT26w|SonyEricssonMT27i|C5303|C6902|C6903|C6906|C6943|D2533', + 'Asus' => 'Asus.*Galaxy|PadFone.*Mobile', + // http://www.micromaxinfo.com/mobiles/smartphones + // Added because the codes might conflict with Acer Tablets. + 'Micromax' => 'Micromax.*\b(A210|A92|A88|A72|A111|A110Q|A115|A116|A110|A90S|A26|A51|A35|A54|A25|A27|A89|A68|A65|A57|A90)\b', + // @todo Complete the regex. + 'Palm' => 'PalmSource|Palm', // avantgo|blazer|elaine|hiptop|plucker|xiino ; + 'Vertu' => 'Vertu|Vertu.*Ltd|Vertu.*Ascent|Vertu.*Ayxta|Vertu.*Constellation(F|Quest)?|Vertu.*Monika|Vertu.*Signature', // Just for fun ;) + // http://www.pantech.co.kr/en/prod/prodList.do?gbrand=VEGA (PANTECH) + // Most of the VEGA devices are legacy. PANTECH seem to be newer devices based on Android. + 'Pantech' => 'PANTECH|IM-A850S|IM-A840S|IM-A830L|IM-A830K|IM-A830S|IM-A820L|IM-A810K|IM-A810S|IM-A800S|IM-T100K|IM-A725L|IM-A780L|IM-A775C|IM-A770K|IM-A760S|IM-A750K|IM-A740S|IM-A730S|IM-A720L|IM-A710K|IM-A690L|IM-A690S|IM-A650S|IM-A630K|IM-A600S|VEGA PTL21|PT003|P8010|ADR910L|P6030|P6020|P9070|P4100|P9060|P5000|CDM8992|TXT8045|ADR8995|IS11PT|P2030|P6010|P8000|PT002|IS06|CDM8999|P9050|PT001|TXT8040|P2020|P9020|P2000|P7040|P7000|C790', + // http://www.fly-phone.com/devices/smartphones/ ; Included only smartphones. + 'Fly' => 'IQ230|IQ444|IQ450|IQ440|IQ442|IQ441|IQ245|IQ256|IQ236|IQ255|IQ235|IQ245|IQ275|IQ240|IQ285|IQ280|IQ270|IQ260|IQ250', + 'iMobile' => 'i-mobile (IQ|i-STYLE|idea|ZAA|Hitz)', + // Added simvalley mobile just for fun. They have some interesting devices. + // http://www.simvalley.fr/telephonie---gps-_22_telephonie-mobile_telephones_.html + 'SimValley' => '\b(SP-80|XT-930|SX-340|XT-930|SX-310|SP-360|SP60|SPT-800|SP-120|SPT-800|SP-140|SPX-5|SPX-8|SP-100|SPX-8|SPX-12)\b', + // Wolfgang - a brand that is sold by Aldi supermarkets. + // http://www.wolfgangmobile.com/ + 'Wolfgang' => 'AT-B24D|AT-AS50HD|AT-AS40W|AT-AS55HD|AT-AS45q2|AT-B26D|AT-AS50Q', + 'Alcatel' => 'Alcatel', + 'Nintendo' => 'Nintendo 3DS', + // http://en.wikipedia.org/wiki/Amoi + 'Amoi' => 'Amoi', + // http://en.wikipedia.org/wiki/INQ + 'INQ' => 'INQ', + // @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039 + 'GenericPhone' => 'Tapatalk|PDA;|SAGEM|\bmmp\b|pocket|\bpsp\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\bwap\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser', + ); + + /** + * List of tablet devices. + * + * @var array + */ + protected static $tabletDevices = array( + 'iPad' => 'iPad|iPad.*Mobile', // @todo: check for mobile friendly emails topic. + 'NexusTablet' => 'Android.*Nexus[\s]+(7|9|10)|^.*Android.*Nexus(?:(?!Mobile).)*$', + 'SamsungTablet' => 'SAMSUNG.*Tablet|Galaxy.*Tab|SC-01C|GT-P1000|GT-P1003|GT-P1010|GT-P3105|GT-P6210|GT-P6800|GT-P6810|GT-P7100|GT-P7300|GT-P7310|GT-P7500|GT-P7510|SCH-I800|SCH-I815|SCH-I905|SGH-I957|SGH-I987|SGH-T849|SGH-T859|SGH-T869|SPH-P100|GT-P3100|GT-P3108|GT-P3110|GT-P5100|GT-P5110|GT-P6200|GT-P7320|GT-P7511|GT-N8000|GT-P8510|SGH-I497|SPH-P500|SGH-T779|SCH-I705|SCH-I915|GT-N8013|GT-P3113|GT-P5113|GT-P8110|GT-N8010|GT-N8005|GT-N8020|GT-P1013|GT-P6201|GT-P7501|GT-N5100|GT-N5105|GT-N5110|SHV-E140K|SHV-E140L|SHV-E140S|SHV-E150S|SHV-E230K|SHV-E230L|SHV-E230S|SHW-M180K|SHW-M180L|SHW-M180S|SHW-M180W|SHW-M300W|SHW-M305W|SHW-M380K|SHW-M380S|SHW-M380W|SHW-M430W|SHW-M480K|SHW-M480S|SHW-M480W|SHW-M485W|SHW-M486W|SHW-M500W|GT-I9228|SCH-P739|SCH-I925|GT-I9200|GT-I9205|GT-P5200|GT-P5210|GT-P5210X|SM-T311|SM-T310|SM-T310X|SM-T210|SM-T210R|SM-T211|SM-P600|SM-P601|SM-P605|SM-P900|SM-P901|SM-T217|SM-T217A|SM-T217S|SM-P6000|SM-T3100|SGH-I467|XE500|SM-T110|GT-P5220|GT-I9200X|GT-N5110X|GT-N5120|SM-P905|SM-T111|SM-T2105|SM-T315|SM-T320|SM-T320X|SM-T321|SM-T520|SM-T525|SM-T530NU|SM-T230NU|SM-T330NU|SM-T900|XE500T1C|SM-P605V|SM-P905V|SM-P600X|SM-P900X|SM-T210X|SM-T230|SM-T230X|SM-T325|GT-P7503|SM-T531|SM-T330|SM-T530|SM-T705C|SM-T535|SM-T331|SM-T800|SM-T700|SM-T537|SM-T807|SM-P907A|SM-T337A|SM-T707A|SM-T807A|SM-T237P|SM-T807P|SM-P607T|SM-T217T|SM-T337T', // SCH-P709|SCH-P729|SM-T2558 - Samsung Mega - treat them like a regular phone. + // http://docs.aws.amazon.com/silk/latest/developerguide/user-agent.html + 'Kindle' => 'Kindle|Silk.*Accelerated|Android.*\b(KFOT|KFTT|KFJWI|KFJWA|KFOTE|KFSOWI|KFTHWI|KFTHWA|KFAPWI|KFAPWA|WFJWAE|KFSAWA|KFSAWI|KFASWI)\b', + // Only the Surface tablets with Windows RT are considered mobile. + // http://msdn.microsoft.com/en-us/library/ie/hh920767(v=vs.85).aspx + 'SurfaceTablet' => 'Windows NT [0-9.]+; ARM;.*(Tablet|ARMBJS)', + // http://shopping1.hp.com/is-bin/INTERSHOP.enfinity/WFS/WW-USSMBPublicStore-Site/en_US/-/USD/ViewStandardCatalog-Browse?CatalogCategoryID=JfIQ7EN5lqMAAAEyDcJUDwMT + 'HPTablet' => 'HP Slate (7|8|10)|HP ElitePad 900|hp-tablet|EliteBook.*Touch|HP 8|Slate 21|HP SlateBook 10', + // Watch out for PadFone, see #132. + // http://www.asus.com/de/Tablets_Mobile/Memo_Pad_Products/ + 'AsusTablet' => '^.*PadFone((?!Mobile).)*$|Transformer|TF101|TF101G|TF300T|TF300TG|TF300TL|TF700T|TF700KL|TF701T|TF810C|ME171|ME301T|ME302C|ME371MG|ME370T|ME372MG|ME172V|ME173X|ME400C|Slider SL101|\bK00F\b|\bK00C\b|\bK00E\b|\bK00L\b|TX201LA|ME176C|ME102A|\bM80TA\b|ME372CL|ME560CG|ME372CG', + 'BlackBerryTablet' => 'PlayBook|RIM Tablet', + 'HTCtablet' => 'HTC_Flyer_P512|HTC Flyer|HTC Jetstream|HTC-P715a|HTC EVO View 4G|PG41200|PG09410', + 'MotorolaTablet' => 'xoom|sholest|MZ615|MZ605|MZ505|MZ601|MZ602|MZ603|MZ604|MZ606|MZ607|MZ608|MZ609|MZ615|MZ616|MZ617', + 'NookTablet' => 'Android.*Nook|NookColor|nook browser|BNRV200|BNRV200A|BNTV250|BNTV250A|BNTV400|BNTV600|LogicPD Zoom2', + // http://www.acer.ro/ac/ro/RO/content/drivers + // http://www.packardbell.co.uk/pb/en/GB/content/download (Packard Bell is part of Acer) + // http://us.acer.com/ac/en/US/content/group/tablets + // http://www.acer.de/ac/de/DE/content/models/tablets/ + // Can conflict with Micromax and Motorola phones codes. + 'AcerTablet' => 'Android.*; \b(A100|A101|A110|A200|A210|A211|A500|A501|A510|A511|A700|A701|W500|W500P|W501|W501P|W510|W511|W700|G100|G100W|B1-A71|B1-710|B1-711|A1-810|A1-811|A1-830)\b|W3-810|\bA3-A10\b', + // http://eu.computers.toshiba-europe.com/innovation/family/Tablets/1098744/banner_id/tablet_footerlink/ + // http://us.toshiba.com/tablets/tablet-finder + // http://www.toshiba.co.jp/regza/tablet/ + 'ToshibaTablet' => 'Android.*(AT100|AT105|AT200|AT205|AT270|AT275|AT300|AT305|AT1S5|AT500|AT570|AT700|AT830)|TOSHIBA.*FOLIO', + // http://www.nttdocomo.co.jp/english/service/developer/smart_phone/technical_info/spec/index.html + // http://www.lg.com/us/tablets + 'LGTablet' => '\bL-06C|LG-V909|LG-V900|LG-V700|LG-V510|LG-V500|LG-V410|LG-V400|LG-VK810\b', + 'FujitsuTablet' => 'Android.*\b(F-01D|F-02F|F-05E|F-10D|M532|Q572)\b', + // Prestigio Tablets http://www.prestigio.com/support + 'PrestigioTablet' => 'PMP3170B|PMP3270B|PMP3470B|PMP7170B|PMP3370B|PMP3570C|PMP5870C|PMP3670B|PMP5570C|PMP5770D|PMP3970B|PMP3870C|PMP5580C|PMP5880D|PMP5780D|PMP5588C|PMP7280C|PMP7280C3G|PMP7280|PMP7880D|PMP5597D|PMP5597|PMP7100D|PER3464|PER3274|PER3574|PER3884|PER5274|PER5474|PMP5097CPRO|PMP5097|PMP7380D|PMP5297C|PMP5297C_QUAD', + // http://support.lenovo.com/en_GB/downloads/default.page?# + 'LenovoTablet' => 'Idea(Tab|Pad)( A1|A10| K1|)|ThinkPad([ ]+)?Tablet|Lenovo.*(S2109|S2110|S5000|S6000|K3011|A3000|A3500|A1000|A2107|A2109|A1107|A5500|A7600|B6000|B8000|B8080)(-|)(FL|F|HV|H|)', + // http://www.dell.com/support/home/us/en/04/Products/tab_mob/tablets + 'DellTablet' => 'Venue 11|Venue 8|Venue 7|Dell Streak 10|Dell Streak 7', + // http://www.yarvik.com/en/matrix/tablets/ + 'YarvikTablet' => 'Android.*\b(TAB210|TAB211|TAB224|TAB250|TAB260|TAB264|TAB310|TAB360|TAB364|TAB410|TAB411|TAB420|TAB424|TAB450|TAB460|TAB461|TAB464|TAB465|TAB467|TAB468|TAB07-100|TAB07-101|TAB07-150|TAB07-151|TAB07-152|TAB07-200|TAB07-201-3G|TAB07-210|TAB07-211|TAB07-212|TAB07-214|TAB07-220|TAB07-400|TAB07-485|TAB08-150|TAB08-200|TAB08-201-3G|TAB08-201-30|TAB09-100|TAB09-211|TAB09-410|TAB10-150|TAB10-201|TAB10-211|TAB10-400|TAB10-410|TAB13-201|TAB274EUK|TAB275EUK|TAB374EUK|TAB462EUK|TAB474EUK|TAB9-200)\b', + 'MedionTablet' => 'Android.*\bOYO\b|LIFE.*(P9212|P9514|P9516|S9512)|LIFETAB', + 'ArnovaTablet' => 'AN10G2|AN7bG3|AN7fG3|AN8G3|AN8cG3|AN7G3|AN9G3|AN7dG3|AN7dG3ST|AN7dG3ChildPad|AN10bG3|AN10bG3DT|AN9G2', + // http://www.intenso.de/kategorie_en.php?kategorie=33 + // @todo: http://www.nbhkdz.com/read/b8e64202f92a2df129126bff.html - investigate + 'IntensoTablet' => 'INM8002KP|INM1010FP|INM805ND|Intenso Tab|TAB1004', + // IRU.ru Tablets http://www.iru.ru/catalog/soho/planetable/ + 'IRUTablet' => 'M702pro', + 'MegafonTablet' => 'MegaFon V9|\bZTE V9\b|Android.*\bMT7A\b', + // http://www.e-boda.ro/tablete-pc.html + 'EbodaTablet' => 'E-Boda (Supreme|Impresspeed|Izzycomm|Essential)', + // http://www.allview.ro/produse/droseries/lista-tablete-pc/ + 'AllViewTablet' => 'Allview.*(Viva|Alldro|City|Speed|All TV|Frenzy|Quasar|Shine|TX1|AX1|AX2)', + // http://wiki.archosfans.com/index.php?title=Main_Page + 'ArchosTablet' => '\b(101G9|80G9|A101IT)\b|Qilive 97R|Archos5|\bARCHOS (70|79|80|90|97|101|FAMILYPAD|)(b|)(G10| Cobalt| TITANIUM(HD|)| Xenon| Neon|XSK| 2| XS 2| PLATINUM| CARBON|GAMEPAD)\b', + // http://www.ainol.com/plugin.php?identifier=ainol&module=product + 'AinolTablet' => 'NOVO7|NOVO8|NOVO10|Novo7Aurora|Novo7Basic|NOVO7PALADIN|novo9-Spark', + // @todo: inspect http://esupport.sony.com/US/p/select-system.pl?DIRECTOR=DRIVER + // Readers http://www.atsuhiro-me.net/ebook/sony-reader/sony-reader-web-browser + // http://www.sony.jp/support/tablet/ + 'SonyTablet' => 'Sony.*Tablet|Xperia Tablet|Sony Tablet S|SO-03E|SGPT12|SGPT13|SGPT114|SGPT121|SGPT122|SGPT123|SGPT111|SGPT112|SGPT113|SGPT131|SGPT132|SGPT133|SGPT211|SGPT212|SGPT213|SGP311|SGP312|SGP321|EBRD1101|EBRD1102|EBRD1201|SGP351|SGP341|SGP511|SGP512|SGP521|SGP541|SGP551', + // http://www.support.philips.com/support/catalog/worldproducts.jsp?userLanguage=en&userCountry=cn&categoryid=3G_LTE_TABLET_SU_CN_CARE&title=3G%20tablets%20/%20LTE%20range&_dyncharset=UTF-8 + 'PhilipsTablet' => '\b(PI2010|PI3000|PI3100|PI3105|PI3110|PI3205|PI3210|PI3900|PI4010|PI7000|PI7100)\b', + // db + http://www.cube-tablet.com/buy-products.html + 'CubeTablet' => 'Android.*(K8GT|U9GT|U10GT|U16GT|U17GT|U18GT|U19GT|U20GT|U23GT|U30GT)|CUBE U8GT', + // http://www.cobyusa.com/?p=pcat&pcat_id=3001 + 'CobyTablet' => 'MID1042|MID1045|MID1125|MID1126|MID7012|MID7014|MID7015|MID7034|MID7035|MID7036|MID7042|MID7048|MID7127|MID8042|MID8048|MID8127|MID9042|MID9740|MID9742|MID7022|MID7010', + // http://www.match.net.cn/products.asp + 'MIDTablet' => 'M9701|M9000|M9100|M806|M1052|M806|T703|MID701|MID713|MID710|MID727|MID760|MID830|MID728|MID933|MID125|MID810|MID732|MID120|MID930|MID800|MID731|MID900|MID100|MID820|MID735|MID980|MID130|MID833|MID737|MID960|MID135|MID860|MID736|MID140|MID930|MID835|MID733', + // http://www.msi.com/support + // @todo Research the Windows Tablets. + 'MSITablet' => 'MSI \b(Primo 73K|Primo 73L|Primo 81L|Primo 77|Primo 93|Primo 75|Primo 76|Primo 73|Primo 81|Primo 91|Primo 90|Enjoy 71|Enjoy 7|Enjoy 10)\b', + // @todo http://www.kyoceramobile.com/support/drivers/ + // 'KyoceraTablet' => null, + // @todo http://intexuae.com/index.php/category/mobile-devices/tablets-products/ + // 'IntextTablet' => null, + // http://pdadb.net/index.php?m=pdalist&list=SMiT (NoName Chinese Tablets) + // http://www.imp3.net/14/show.php?itemid=20454 + 'SMiTTablet' => 'Android.*(\bMID\b|MID-560|MTV-T1200|MTV-PND531|MTV-P1101|MTV-PND530)', + // http://www.rock-chips.com/index.php?do=prod&pid=2 + 'RockChipTablet' => 'Android.*(RK2818|RK2808A|RK2918|RK3066)|RK2738|RK2808A', + // http://www.fly-phone.com/devices/tablets/ ; http://www.fly-phone.com/service/ + 'FlyTablet' => 'IQ310|Fly Vision', + // http://www.bqreaders.com/gb/tablets-prices-sale.html + 'bqTablet' => 'bq.*(Elcano|Curie|Edison|Maxwell|Kepler|Pascal|Tesla|Hypatia|Platon|Newton|Livingstone|Cervantes|Avant)|Maxwell.*Lite|Maxwell.*Plus', + // http://www.huaweidevice.com/worldwide/productFamily.do?method=index&directoryId=5011&treeId=3290 + // http://www.huaweidevice.com/worldwide/downloadCenter.do?method=index&directoryId=3372&treeId=0&tb=1&type=software (including legacy tablets) + 'HuaweiTablet' => 'MediaPad|MediaPad 7 Youth|IDEOS S7|S7-201c|S7-202u|S7-101|S7-103|S7-104|S7-105|S7-106|S7-201|S7-Slim', + // Nec or Medias Tab + 'NecTablet' => '\bN-06D|\bN-08D', + // Pantech Tablets: http://www.pantechusa.com/phones/ + 'PantechTablet' => 'Pantech.*P4100', + // Broncho Tablets: http://www.broncho.cn/ (hard to find) + 'BronchoTablet' => 'Broncho.*(N701|N708|N802|a710)', + // http://versusuk.com/support.html + 'VersusTablet' => 'TOUCHPAD.*[78910]|\bTOUCHTAB\b', + // http://www.zync.in/index.php/our-products/tablet-phablets + 'ZyncTablet' => 'z1000|Z99 2G|z99|z930|z999|z990|z909|Z919|z900', + // http://www.positivoinformatica.com.br/www/pessoal/tablet-ypy/ + 'PositivoTablet' => 'TB07STA|TB10STA|TB07FTA|TB10FTA', + // https://www.nabitablet.com/ + 'NabiTablet' => 'Android.*\bNabi', + 'KoboTablet' => 'Kobo Touch|\bK080\b|\bVox\b Build|\bArc\b Build', + // French Danew Tablets http://www.danew.com/produits-tablette.php + 'DanewTablet' => 'DSlide.*\b(700|701R|702|703R|704|802|970|971|972|973|974|1010|1012)\b', + // Texet Tablets and Readers http://www.texet.ru/tablet/ + 'TexetTablet' => 'NaviPad|TB-772A|TM-7045|TM-7055|TM-9750|TM-7016|TM-7024|TM-7026|TM-7041|TM-7043|TM-7047|TM-8041|TM-9741|TM-9747|TM-9748|TM-9751|TM-7022|TM-7021|TM-7020|TM-7011|TM-7010|TM-7023|TM-7025|TM-7037W|TM-7038W|TM-7027W|TM-9720|TM-9725|TM-9737W|TM-1020|TM-9738W|TM-9740|TM-9743W|TB-807A|TB-771A|TB-727A|TB-725A|TB-719A|TB-823A|TB-805A|TB-723A|TB-715A|TB-707A|TB-705A|TB-709A|TB-711A|TB-890HD|TB-880HD|TB-790HD|TB-780HD|TB-770HD|TB-721HD|TB-710HD|TB-434HD|TB-860HD|TB-840HD|TB-760HD|TB-750HD|TB-740HD|TB-730HD|TB-722HD|TB-720HD|TB-700HD|TB-500HD|TB-470HD|TB-431HD|TB-430HD|TB-506|TB-504|TB-446|TB-436|TB-416|TB-146SE|TB-126SE', + // Avoid detecting 'PLAYSTATION 3' as mobile. + 'PlaystationTablet' => 'Playstation.*(Portable|Vita)', + // http://www.trekstor.de/surftabs.html + 'TrekstorTablet' => 'ST10416-1|VT10416-1|ST70408-1|ST702xx-1|ST702xx-2|ST80208|ST97216|ST70104-2|VT10416-2|ST10216-2A|SurfTab', + // http://www.pyleaudio.com/Products.aspx?%2fproducts%2fPersonal-Electronics%2fTablets + 'PyleAudioTablet' => '\b(PTBL10CEU|PTBL10C|PTBL72BC|PTBL72BCEU|PTBL7CEU|PTBL7C|PTBL92BC|PTBL92BCEU|PTBL9CEU|PTBL9CUK|PTBL9C)\b', + // http://www.advandigital.com/index.php?link=content-product&jns=JP001 + // because of the short codenames we have to include whitespaces to reduce the possible conflicts. + 'AdvanTablet' => 'Android.* \b(E3A|T3X|T5C|T5B|T3E|T3C|T3B|T1J|T1F|T2A|T1H|T1i|E1C|T1-E|T5-A|T4|E1-B|T2Ci|T1-B|T1-D|O1-A|E1-A|T1-A|T3A|T4i)\b ', + // http://www.danytech.com/category/tablet-pc + 'DanyTechTablet' => 'Genius Tab G3|Genius Tab S2|Genius Tab Q3|Genius Tab G4|Genius Tab Q4|Genius Tab G-II|Genius TAB GII|Genius TAB GIII|Genius Tab S1', + // http://www.galapad.net/product.html + 'GalapadTablet' => 'Android.*\bG1\b', + // http://www.micromaxinfo.com/tablet/funbook + 'MicromaxTablet' => 'Funbook|Micromax.*\b(P250|P560|P360|P362|P600|P300|P350|P500|P275)\b', + // http://www.karbonnmobiles.com/products_tablet.php + 'KarbonnTablet' => 'Android.*\b(A39|A37|A34|ST8|ST10|ST7|Smart Tab3|Smart Tab2)\b', + // http://www.myallfine.com/Products.asp + 'AllFineTablet' => 'Fine7 Genius|Fine7 Shine|Fine7 Air|Fine8 Style|Fine9 More|Fine10 Joy|Fine11 Wide', + // http://www.proscanvideo.com/products-search.asp?itemClass=TABLET&itemnmbr= + 'PROSCANTablet' => '\b(PEM63|PLT1023G|PLT1041|PLT1044|PLT1044G|PLT1091|PLT4311|PLT4311PL|PLT4315|PLT7030|PLT7033|PLT7033D|PLT7035|PLT7035D|PLT7044K|PLT7045K|PLT7045KB|PLT7071KG|PLT7072|PLT7223G|PLT7225G|PLT7777G|PLT7810K|PLT7849G|PLT7851G|PLT7852G|PLT8015|PLT8031|PLT8034|PLT8036|PLT8080K|PLT8082|PLT8088|PLT8223G|PLT8234G|PLT8235G|PLT8816K|PLT9011|PLT9045K|PLT9233G|PLT9735|PLT9760G|PLT9770G)\b', + // http://www.yonesnav.com/products/products.php + 'YONESTablet' => 'BQ1078|BC1003|BC1077|RK9702|BC9730|BC9001|IT9001|BC7008|BC7010|BC708|BC728|BC7012|BC7030|BC7027|BC7026', + // http://www.cjshowroom.com/eproducts.aspx?classcode=004001001 + // China manufacturer makes tablets for different small brands (eg. http://www.zeepad.net/index.html) + 'ChangJiaTablet' => 'TPC7102|TPC7103|TPC7105|TPC7106|TPC7107|TPC7201|TPC7203|TPC7205|TPC7210|TPC7708|TPC7709|TPC7712|TPC7110|TPC8101|TPC8103|TPC8105|TPC8106|TPC8203|TPC8205|TPC8503|TPC9106|TPC9701|TPC97101|TPC97103|TPC97105|TPC97106|TPC97111|TPC97113|TPC97203|TPC97603|TPC97809|TPC97205|TPC10101|TPC10103|TPC10106|TPC10111|TPC10203|TPC10205|TPC10503', + // http://www.gloryunion.cn/products.asp + // http://www.allwinnertech.com/en/apply/mobile.html + // http://www.ptcl.com.pk/pd_content.php?pd_id=284 (EVOTAB) + // @todo: Softwiner tablets? + // aka. Cute or Cool tablets. Not sure yet, must research to avoid collisions. + 'GUTablet' => 'TX-A1301|TX-M9002|Q702|kf026', // A12R|D75A|D77|D79|R83|A95|A106C|R15|A75|A76|D71|D72|R71|R73|R77|D82|R85|D92|A97|D92|R91|A10F|A77F|W71F|A78F|W78F|W81F|A97F|W91F|W97F|R16G|C72|C73E|K72|K73|R96G + // http://www.pointofview-online.com/showroom.php?shop_mode=product_listing&category_id=118 + 'PointOfViewTablet' => 'TAB-P506|TAB-navi-7-3G-M|TAB-P517|TAB-P-527|TAB-P701|TAB-P703|TAB-P721|TAB-P731N|TAB-P741|TAB-P825|TAB-P905|TAB-P925|TAB-PR945|TAB-PL1015|TAB-P1025|TAB-PI1045|TAB-P1325|TAB-PROTAB[0-9]+|TAB-PROTAB25|TAB-PROTAB26|TAB-PROTAB27|TAB-PROTAB26XL|TAB-PROTAB2-IPS9|TAB-PROTAB30-IPS9|TAB-PROTAB25XXL|TAB-PROTAB26-IPS10|TAB-PROTAB30-IPS10', + // http://www.overmax.pl/pl/katalog-produktow,p8/tablety,c14/ + // @todo: add more tests. + 'OvermaxTablet' => 'OV-(SteelCore|NewBase|Basecore|Baseone|Exellen|Quattor|EduTab|Solution|ACTION|BasicTab|TeddyTab|MagicTab|Stream|TB-08|TB-09)', + // http://hclmetablet.com/India/index.php + 'HCLTablet' => 'HCL.*Tablet|Connect-3G-2.0|Connect-2G-2.0|ME Tablet U1|ME Tablet U2|ME Tablet G1|ME Tablet X1|ME Tablet Y2|ME Tablet Sync', + // http://www.edigital.hu/Tablet_es_e-book_olvaso/Tablet-c18385.html + 'DPSTablet' => 'DPS Dream 9|DPS Dual 7', + // http://www.visture.com/index.asp + 'VistureTablet' => 'V97 HD|i75 3G|Visture V4( HD)?|Visture V5( HD)?|Visture V10', + // http://www.mijncresta.nl/tablet + 'CrestaTablet' => 'CTP(-)?810|CTP(-)?818|CTP(-)?828|CTP(-)?838|CTP(-)?888|CTP(-)?978|CTP(-)?980|CTP(-)?987|CTP(-)?988|CTP(-)?989', + // MediaTek - http://www.mediatek.com/_en/01_products/02_proSys.php?cata_sn=1&cata1_sn=1&cata2_sn=309 + 'MediatekTablet' => '\bMT8125|MT8389|MT8135|MT8377\b', + // Concorde tab + 'ConcordeTablet' => 'Concorde([ ]+)?Tab|ConCorde ReadMan', + // GoClever Tablets - http://www.goclever.com/uk/products,c1/tablet,c5/ + 'GoCleverTablet' => 'GOCLEVER TAB|A7GOCLEVER|M1042|M7841|M742|R1042BK|R1041|TAB A975|TAB A7842|TAB A741|TAB A741L|TAB M723G|TAB M721|TAB A1021|TAB I921|TAB R721|TAB I720|TAB T76|TAB R70|TAB R76.2|TAB R106|TAB R83.2|TAB M813G|TAB I721|GCTA722|TAB I70|TAB I71|TAB S73|TAB R73|TAB R74|TAB R93|TAB R75|TAB R76.1|TAB A73|TAB A93|TAB A93.2|TAB T72|TAB R83|TAB R974|TAB R973|TAB A101|TAB A103|TAB A104|TAB A104.2|R105BK|M713G|A972BK|TAB A971|TAB R974.2|TAB R104|TAB R83.3|TAB A1042', + // Modecom Tablets - http://www.modecom.eu/tablets/portal/ + 'ModecomTablet' => 'FreeTAB 9000|FreeTAB 7.4|FreeTAB 7004|FreeTAB 7800|FreeTAB 2096|FreeTAB 7.5|FreeTAB 1014|FreeTAB 1001 |FreeTAB 8001|FreeTAB 9706|FreeTAB 9702|FreeTAB 7003|FreeTAB 7002|FreeTAB 1002|FreeTAB 7801|FreeTAB 1331|FreeTAB 1004|FreeTAB 8002|FreeTAB 8014|FreeTAB 9704|FreeTAB 1003', + // Vonino Tablets - http://www.vonino.eu/tablets + 'VoninoTablet' => '\b(Argus[ _]?S|Diamond[ _]?79HD|Emerald[ _]?78E|Luna[ _]?70C|Onyx[ _]?S|Onyx[ _]?Z|Orin[ _]?HD|Orin[ _]?S|Otis[ _]?S|SpeedStar[ _]?S|Magnet[ _]?M9|Primus[ _]?94[ _]?3G|Primus[ _]?94HD|Primus[ _]?QS|Android.*\bQ8\b|Sirius[ _]?EVO[ _]?QS|Sirius[ _]?QS|Spirit[ _]?S)\b', + // ECS Tablets - http://www.ecs.com.tw/ECSWebSite/Product/Product_Tablet_List.aspx?CategoryID=14&MenuID=107&childid=M_107&LanID=0 + 'ECSTablet' => 'V07OT2|TM105A|S10OT1|TR10CS1', + // Storex Tablets - http://storex.fr/espace_client/support.html + // @note: no need to add all the tablet codes since they are guided by the first regex. + 'StorexTablet' => 'eZee[_\']?(Tab|Go)[0-9]+|TabLC7|Looney Tunes Tab', + // Generic Vodafone tablets. + 'VodafoneTablet' => 'SmartTab([ ]+)?[0-9]+|SmartTabII10|SmartTabII7', + // French tablets - Essentiel B http://www.boulanger.fr/tablette_tactile_e-book/tablette_tactile_essentiel_b/cl_68908.htm?multiChoiceToDelete=brand&mc_brand=essentielb + // Aka: http://www.essentielb.fr/ + 'EssentielBTablet' => 'Smart[ \']?TAB[ ]+?[0-9]+|Family[ \']?TAB2', + // Ross & Moor - http://ross-moor.ru/ + 'RossMoorTablet' => 'RM-790|RM-997|RMD-878G|RMD-974R|RMT-705A|RMT-701|RME-601|RMT-501|RMT-711', + // i-mobile http://product.i-mobilephone.com/Mobile_Device + 'iMobileTablet' => 'i-mobile i-note', + // http://www.tolino.de/de/vergleichen/ + 'TolinoTablet' => 'tolino tab [0-9.]+|tolino shine', + // AudioSonic - a Kmart brand + // http://www.kmart.com.au/webapp/wcs/stores/servlet/Search?langId=-1&storeId=10701&catalogId=10001&categoryId=193001&pageSize=72¤tPage=1&searchCategory=193001%2b4294965664&sortBy=p_MaxPrice%7c1 + 'AudioSonicTablet' => '\bC-22Q|T7-QC|T-17B|T-17P\b', + // AMPE Tablets - http://www.ampe.com.my/product-category/tablets/ + // @todo: add them gradually to avoid conflicts. + 'AMPETablet' => 'Android.* A78 ', + // Skk Mobile - http://skkmobile.com.ph/product_tablets.php + 'SkkTablet' => 'Android.* (SKYPAD|PHOENIX|CYCLOPS)', + // Tecno Mobile (only tablet) - http://www.tecno-mobile.com/index.php/product?filterby=smart&list_order=all&page=1 + 'TecnoTablet' => 'TECNO P9', + // JXD (consoles & tablets) - http://jxd.hk/products.asp?selectclassid=009008&clsid=3 + 'JXDTablet' => 'Android.*\b(F3000|A3300|JXD5000|JXD3000|JXD2000|JXD300B|JXD300|S5800|S7800|S602b|S5110b|S7300|S5300|S602|S603|S5100|S5110|S601|S7100a|P3000F|P3000s|P101|P200s|P1000m|P200m|P9100|P1000s|S6600b|S908|P1000|P300|S18|S6600|S9100)\b', + // i-Joy tablets - http://www.i-joy.es/en/cat/products/tablets/ + 'iJoyTablet' => 'Tablet (Spirit 7|Essentia|Galatea|Fusion|Onix 7|Landa|Titan|Scooby|Deox|Stella|Themis|Argon|Unique 7|Sygnus|Hexen|Finity 7|Cream|Cream X2|Jade|Neon 7|Neron 7|Kandy|Scape|Saphyr 7|Rebel|Biox|Rebel|Rebel 8GB|Myst|Draco 7|Myst|Tab7-004|Myst|Tadeo Jones|Tablet Boing|Arrow|Draco Dual Cam|Aurix|Mint|Amity|Revolution|Finity 9|Neon 9|T9w|Amity 4GB Dual Cam|Stone 4GB|Stone 8GB|Andromeda|Silken|X2|Andromeda II|Halley|Flame|Saphyr 9,7|Touch 8|Planet|Triton|Unique 10|Hexen 10|Memphis 4GB|Memphis 8GB|Onix 10)', + // http://www.intracon.eu/tablet + 'FX2Tablet' => 'FX2 PAD7|FX2 PAD10', + // http://www.xoro.de/produkte/ + // @note: Might be the same brand with 'Simply tablets' + 'XoroTablet' => 'KidsPAD 701|PAD[ ]?712|PAD[ ]?714|PAD[ ]?716|PAD[ ]?717|PAD[ ]?718|PAD[ ]?720|PAD[ ]?721|PAD[ ]?722|PAD[ ]?790|PAD[ ]?792|PAD[ ]?900|PAD[ ]?9715D|PAD[ ]?9716DR|PAD[ ]?9718DR|PAD[ ]?9719QR|PAD[ ]?9720QR|TelePAD1030|Telepad1032|TelePAD730|TelePAD731|TelePAD732|TelePAD735Q|TelePAD830|TelePAD9730|TelePAD795|MegaPAD 1331|MegaPAD 1851|MegaPAD 2151', + // http://www1.viewsonic.com/products/computing/tablets/ + 'ViewsonicTablet' => 'ViewPad 10pi|ViewPad 10e|ViewPad 10s|ViewPad E72|ViewPad7|ViewPad E100|ViewPad 7e|ViewSonic VB733|VB100a', + // http://www.odys.de/web/internet-tablet_en.html + 'OdysTablet' => 'LOOX|XENO10|ODYS[ -](Space|EVO|Xpress|NOON)|\bXELIO\b|Xelio10Pro|XELIO7PHONETAB|XELIO10EXTREME|XELIOPT2|NEO_QUAD10', + // http://www.captiva-power.de/products.html#tablets-en + 'CaptivaTablet' => 'CAPTIVA PAD', + // IconBIT - http://www.iconbit.com/products/tablets/ + 'IconbitTablet' => 'NetTAB|NT-3702|NT-3702S|NT-3702S|NT-3603P|NT-3603P|NT-0704S|NT-0704S|NT-3805C|NT-3805C|NT-0806C|NT-0806C|NT-0909T|NT-0909T|NT-0907S|NT-0907S|NT-0902S|NT-0902S', + // http://www.teclast.com/topic.php?channelID=70&topicID=140&pid=63 + 'TeclastTablet' => 'T98 4G|\bP80\b|\bX90HD\b|X98 Air|X98 Air 3G|\bX89\b|P80 3G|\bX80h\b|P98 Air|\bX89HD\b|P98 3G|\bP90HD\b|P89 3G|X98 3G|\bP70h\b|P79HD 3G|G18d 3G|\bP79HD\b|\bP89s\b|\bA88\b|\bP10HD\b|\bP19HD\b|G18 3G|\bP78HD\b|\bA78\b|\bP75\b|G17s 3G|G17h 3G|\bP85t\b|\bP90\b|\bP11\b|\bP98t\b|\bP98HD\b|\bG18d\b|\bP85s\b|\bP11HD\b|\bP88s\b|\bA80HD\b|\bA80se\b|\bA10h\b|\bP89\b|\bP78s\b|\bG18\b|\bP85\b|\bA70h\b|\bA70\b|\bG17\b|\bP18\b|\bA80s\b|\bA11s\b|\bP88HD\b|\bA80h\b|\bP76s\b|\bP76h\b|\bP98\b|\bA10HD\b|\bP78\b|\bP88\b|\bA11\b|\bA10t\b|\bP76a\b|\bP76t\b|\bP76e\b|\bP85HD\b|\bP85a\b|\bP86\b|\bP75HD\b|\bP76v\b|\bA12\b|\bP75a\b|\bA15\b|\bP76Ti\b|\bP81HD\b|\bA10\b|\bT760VE\b|\bT720HD\b|\bP76\b|\bP73\b|\bP71\b|\bP72\b|\bT720SE\b|\bC520Ti\b|\bT760\b|\bT720VE\b|T720-3GE|T720-WiFi', + 'JaytechTablet' => 'TPC-PA762', + 'BlaupunktTablet' => 'Endeavour 800NG|Endeavour 1010', + // http://www.digma.ru/support/download/ + // @todo: Ebooks also (if requested) + 'DigmaTablet' => '\b(iDx10|iDx9|iDx8|iDx7|iDxD7|iDxD8|iDsQ8|iDsQ7|iDsQ8|iDsD10|iDnD7|3TS804H|iDsQ11|iDj7|iDs10)\b', + // http://www.evolioshop.com/ro/tablete-pc.html + // http://www.evolio.ro/support/downloads_static.html?cat=2 + // @todo: Research some more + 'EvolioTablet' => 'ARIA_Mini_wifi|Aria[ _]Mini|Evolio X10|Evolio X7|Evolio X8|\bEvotab\b|\bNeura\b', + // @todo http://www.lavamobiles.com/tablets-data-cards + 'LavaTablet' => 'QPAD E704|\bIvoryS\b|E-TAB IVORY', + // https://www.celkonmobiles.com/?_a=categoryphones&sid=2 + 'CelkonTablet' => 'CT695|CT888|CT[\s]?910|CT7 Tab|CT9 Tab|CT3 Tab|CT2 Tab|CT1 Tab|C820|C720|\bCT-1\b', + // http://www.mi.com/en + 'MiTablet' => '\bMI PAD\b|\bHM NOTE 1W\b', + // http://www.nbru.cn/index.html + 'NibiruTablet' => 'Nibiru M1|Nibiru Jupiter One', + // http://navroad.com/products/produkty/tablety/ + 'NexoTablet' => 'NEXO NOVA|NEXO 10|NEXO AVIO|NEXO FREE|NEXO GO|NEXO EVO|NEXO 3G|NEXO SMART|NEXO KIDDO|NEXO MOBI', + // http://www.datawind.com/ubislate/ + 'UbislateTablet' => 'UbiSlate[\s]?7C', + // http://www.pocketbook-int.com/ru/support + 'PocketBookTablet' => 'Pocketbook', + // http://www.tesco.com/direct/hudl/ + 'Hudl' => 'Hudl HT7S3', + // http://www.telstra.com.au/home-phone/thub-2/ + 'TelstraTablet' => 'T-Hub2', + 'GenericTablet' => 'Android.*\b97D\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|rk30sdk|\bEVOTAB\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\bM6pro\b|CT1020W|arc 10HD|\bJolla\b' + ); + + /** + * List of mobile Operating Systems. + * + * @var array + */ + protected static $operatingSystems = array( + 'AndroidOS' => 'Android', + 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os', + 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino', + 'SymbianOS' => 'Symbian|SymbOS|Series60|Series40|SYB-[0-9]+|\bS60\b', + // @reference: http://en.wikipedia.org/wiki/Windows_Mobile + 'WindowsMobileOS' => 'Windows CE.*(PPC|Smartphone|Mobile|[0-9]{3}x[0-9]{3})|Window Mobile|Windows Phone [0-9.]+|WCE;', + // @reference: http://en.wikipedia.org/wiki/Windows_Phone + // http://wifeng.cn/?r=blog&a=view&id=106 + // http://nicksnettravels.builttoroam.com/post/2011/01/10/Bogus-Windows-Phone-7-User-Agent-String.aspx + // http://msdn.microsoft.com/library/ms537503.aspx + 'WindowsPhoneOS' => 'Windows Phone 8.0|Windows Phone OS|XBLWP7|ZuneWP7|Windows NT 6.[23]; ARM;', + 'iOS' => '\biPhone.*Mobile|\biPod|\biPad', + // http://en.wikipedia.org/wiki/MeeGo + // @todo: research MeeGo in UAs + 'MeeGoOS' => 'MeeGo', + // http://en.wikipedia.org/wiki/Maemo + // @todo: research Maemo in UAs + 'MaemoOS' => 'Maemo', + 'JavaOS' => 'J2ME/|\bMIDP\b|\bCLDC\b', // '|Java/' produces bug #135 + 'webOS' => 'webOS|hpwOS', + 'badaOS' => '\bBada\b', + 'BREWOS' => 'BREW', + ); + + /** + * List of mobile User Agents. + * + * @var array + */ + protected static $browsers = array( + // @reference: https://developers.google.com/chrome/mobile/docs/user-agent + 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?', + 'Dolfin' => '\bDolfin\b', + 'Opera' => 'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+|Coast/[0-9.]+', + 'Skyfire' => 'Skyfire', + 'IE' => 'IEMobile|MSIEMobile', // |Trident/[.0-9]+ + 'Firefox' => 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile', + 'Bolt' => 'bolt', + 'TeaShark' => 'teashark', + 'Blazer' => 'Blazer', + // @reference: http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3 + 'Safari' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari', + // http://en.wikipedia.org/wiki/Midori_(web_browser) + //'Midori' => 'midori', + 'Tizen' => 'Tizen', + 'UCBrowser' => 'UC.*Browser|UCWEB', + 'baiduboxapp' => 'baiduboxapp', + 'baidubrowser' => 'baidubrowser', + // https://github.com/serbanghita/Mobile-Detect/issues/7 + 'DiigoBrowser' => 'DiigoBrowser', + // http://www.puffinbrowser.com/index.php + 'Puffin' => 'Puffin', + // http://mercury-browser.com/index.html + 'Mercury' => '\bMercury\b', + // http://en.wikipedia.org/wiki/Obigo_Browser + 'ObigoBrowser' => 'Obigo', + // http://en.wikipedia.org/wiki/NetFront + 'NetFront' => 'NF-Browser', + // @reference: http://en.wikipedia.org/wiki/Minimo + // http://en.wikipedia.org/wiki/Vision_Mobile_Browser + 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger', + ); + + /** + * Utilities. + * + * @var array + */ + protected static $utilities = array( + // Experimental. When a mobile device wants to switch to 'Desktop Mode'. + // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/ + // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011 + 'DesktopMode' => 'WPDesktop', + 'TV' => 'SonyDTV|HbbTV', // experimental + 'WebKit' => '(webkit)[ /]([\w.]+)', + 'Bot' => 'Googlebot|YandexBot|bingbot|ia_archiver|AhrefsBot|Ezooms|GSLFbot|WBSearchBot|Twitterbot|TweetmemeBot|Twikle|PaperLiBot|Wotbox|UnwindFetchor|facebookexternalhit', + 'MobileBot' => 'Googlebot-Mobile|YahooSeeker/M1A1-R2D2', + // @todo: Include JXD consoles. + 'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|PLAYSTATION|Xbox)\b', + 'Watch' => 'SM-V700', + ); + + /** + * All possible HTTP headers that represent the + * User-Agent string. + * + * @var array + */ + protected static $uaHttpHeaders = array( + // The default User-Agent string. + 'HTTP_USER_AGENT', + // Header can occur on devices using Opera Mini. + 'HTTP_X_OPERAMINI_PHONE_UA', + // Vodafone specific header: http://www.seoprinciple.com/mobile-web-community-still-angry-at-vodafone/24/ + 'HTTP_X_DEVICE_USER_AGENT', + 'HTTP_X_ORIGINAL_USER_AGENT', + 'HTTP_X_SKYFIRE_PHONE', + 'HTTP_X_BOLT_PHONE_UA', + 'HTTP_DEVICE_STOCK_UA', + 'HTTP_X_UCBROWSER_DEVICE_UA' + ); + + /** + * The individual segments that could exist in a User-Agent string. VER refers to the regular + * expression defined in the constant self::VER. + * + * @var array + */ + protected static $properties = array( + + // Build + 'Mobile' => 'Mobile/[VER]', + 'Build' => 'Build/[VER]', + 'Version' => 'Version/[VER]', + 'VendorID' => 'VendorID/[VER]', + + // Devices + 'iPad' => 'iPad.*CPU[a-z ]+[VER]', + 'iPhone' => 'iPhone.*CPU[a-z ]+[VER]', + 'iPod' => 'iPod.*CPU[a-z ]+[VER]', + //'BlackBerry' => array('BlackBerry[VER]', 'BlackBerry [VER];'), + 'Kindle' => 'Kindle/[VER]', + + // Browser + 'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'), + 'Coast' => array('Coast/[VER]'), + 'Dolfin' => 'Dolfin/[VER]', + // @reference: https://developer.mozilla.org/en-US/docs/User_Agent_Strings_Reference + 'Firefox' => 'Firefox/[VER]', + 'Fennec' => 'Fennec/[VER]', + // @reference: http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx + 'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];'), + // http://en.wikipedia.org/wiki/NetFront + 'NetFront' => 'NetFront/[VER]', + 'NokiaBrowser' => 'NokiaBrowser/[VER]', + 'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ), + 'Opera Mini' => 'Opera Mini/[VER]', + 'Opera Mobi' => 'Version/[VER]', + 'UC Browser' => 'UC Browser[VER]', + 'MQQBrowser' => 'MQQBrowser/[VER]', + 'MicroMessenger' => 'MicroMessenger/[VER]', + 'baiduboxapp' => 'baiduboxapp/[VER]', + 'baidubrowser' => 'baidubrowser/[VER]', + 'Iron' => 'Iron/[VER]', + // @note: Safari 7534.48.3 is actually Version 5.1. + // @note: On BlackBerry the Version is overwriten by the OS. + 'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ), + 'Skyfire' => 'Skyfire/[VER]', + 'Tizen' => 'Tizen/[VER]', + 'Webkit' => 'webkit[ /][VER]', + + // Engine + 'Gecko' => 'Gecko/[VER]', + 'Trident' => 'Trident/[VER]', + 'Presto' => 'Presto/[VER]', + + // OS + 'iOS' => ' \bOS\b [VER] ', + 'Android' => 'Android [VER]', + 'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'), + 'BREW' => 'BREW [VER]', + 'Java' => 'Java/[VER]', + // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx + // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases + 'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'), + 'Windows Phone' => 'Windows Phone [VER]', + 'Windows CE' => 'Windows CE/[VER]', + // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd + 'Windows NT' => 'Windows NT [VER]', + 'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'), + 'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'), + ); + + /** + * Construct an instance of this class. + * + * @param array $headers Specify the headers as injection. Should be PHP _SERVER flavored. + * If left empty, will use the global _SERVER['HTTP_*'] vars instead. + * @param string $userAgent Inject the User-Agent header. If null, will use HTTP_USER_AGENT + * from the $headers array instead. + */ + public function __construct( + array $headers = null, + $userAgent = null + ) { + $this->setHttpHeaders($headers); + $this->setUserAgent($userAgent); + } + + /** + * Get the current script version. + * This is useful for the demo.php file, + * so people can check on what version they are testing + * for mobile devices. + * + * @return string The version number in semantic version format. + */ + public static function getScriptVersion() + { + return self::VERSION; + } + + /** + * Set the HTTP Headers. Must be PHP-flavored. This method will reset existing headers. + * + * @param array $httpHeaders The headers to set. If null, then using PHP's _SERVER to extract + * the headers. The default null is left for backwards compatibilty. + */ + public function setHttpHeaders($httpHeaders = null) + { + //use global _SERVER if $httpHeaders aren't defined + if (!is_array($httpHeaders) || !count($httpHeaders)) { + $httpHeaders = $_SERVER; + } + + //clear existing headers + $this->httpHeaders = array(); + + //Only save HTTP headers. In PHP land, that means only _SERVER vars that + //start with HTTP_. + foreach ($httpHeaders as $key => $value) { + if (substr($key,0,5) == 'HTTP_') { + $this->httpHeaders[$key] = $value; + } + } + } + + /** + * Retrieves the HTTP headers. + * + * @return array + */ + public function getHttpHeaders() + { + return $this->httpHeaders; + } + + /** + * Retrieves a particular header. If it doesn't exist, no exception/error is caused. + * Simply null is returned. + * + * @param string $header The name of the header to retrieve. Can be HTTP compliant such as + * "User-Agent" or "X-Device-User-Agent" or can be php-esque with the + * all-caps, HTTP_ prefixed, underscore seperated awesomeness. + * + * @return string|null The value of the header. + */ + public function getHttpHeader($header) + { + //are we using PHP-flavored headers? + if (strpos($header, '_') === false) { + $header = str_replace('-', '_', $header); + $header = strtoupper($header); + } + + //test the alternate, too + $altHeader = 'HTTP_' . $header; + + //Test both the regular and the HTTP_ prefix + if (isset($this->httpHeaders[$header])) { + return $this->httpHeaders[$header]; + } elseif (isset($this->httpHeaders[$altHeader])) { + return $this->httpHeaders[$altHeader]; + } + + return null; + } + + public function getMobileHeaders() + { + return self::$mobileHeaders; + } + + /** + * Get all possible HTTP headers that + * can contain the User-Agent string. + * + * @return array List of HTTP headers. + */ + public function getUaHttpHeaders() + { + return self::$uaHttpHeaders; + } + + /** + * Set the User-Agent to be used. + * + * @param string $userAgent The user agent string to set. + * + * @return string|null + */ + public function setUserAgent($userAgent = null) + { + if (!empty($userAgent)) { + return $this->userAgent = $userAgent; + } else { + $this->userAgent = null; + foreach ($this->getUaHttpHeaders() as $altHeader) { + if (!empty($this->httpHeaders[$altHeader])) { // @todo: should use getHttpHeader(), but it would be slow. (Serban) + $this->userAgent .= $this->httpHeaders[$altHeader] . " "; + } + } + + return $this->userAgent = (!empty($this->userAgent) ? trim($this->userAgent) : null); + + } + } + + /** + * Retrieve the User-Agent. + * + * @return string|null The user agent if it's set. + */ + public function getUserAgent() + { + return $this->userAgent; + } + + /** + * Set the detection type. Must be one of self::DETECTION_TYPE_MOBILE or + * self::DETECTION_TYPE_EXTENDED. Otherwise, nothing is set. + * + * @deprecated since version 2.6.9 + * + * @param string $type The type. Must be a self::DETECTION_TYPE_* constant. The default + * parameter is null which will default to self::DETECTION_TYPE_MOBILE. + */ + public function setDetectionType($type = null) + { + if ($type === null) { + $type = self::DETECTION_TYPE_MOBILE; + } + + if ($type != self::DETECTION_TYPE_MOBILE && $type != self::DETECTION_TYPE_EXTENDED) { + return; + } + + $this->detectionType = $type; + } + + public function getMatchingRegex() + { + return $this->matchingRegex; + } + + public function getMatchesArray() + { + return $this->matchesArray; + } + + /** + * Retrieve the list of known phone devices. + * + * @return array List of phone devices. + */ + public static function getPhoneDevices() + { + return self::$phoneDevices; + } + + /** + * Retrieve the list of known tablet devices. + * + * @return array List of tablet devices. + */ + public static function getTabletDevices() + { + return self::$tabletDevices; + } + + /** + * Alias for getBrowsers() method. + * + * @return array List of user agents. + */ + public static function getUserAgents() + { + return self::getBrowsers(); + } + + /** + * Retrieve the list of known browsers. Specifically, the user agents. + * + * @return array List of browsers / user agents. + */ + public static function getBrowsers() + { + return self::$browsers; + } + + /** + * Retrieve the list of known utilities. + * + * @return array List of utilities. + */ + public static function getUtilities() + { + return self::$utilities; + } + + /** + * Method gets the mobile detection rules. This method is used for the magic methods $detect->is*(). + * + * @deprecated since version 2.6.9 + * + * @return array All the rules (but not extended). + */ + public static function getMobileDetectionRules() + { + static $rules; + + if (!$rules) { + $rules = array_merge( + self::$phoneDevices, + self::$tabletDevices, + self::$operatingSystems, + self::$browsers + ); + } + + return $rules; + + } + + /** + * Method gets the mobile detection rules + utilities. + * The reason this is separate is because utilities rules + * don't necessary imply mobile. This method is used inside + * the new $detect->is('stuff') method. + * + * @deprecated since version 2.6.9 + * + * @return array All the rules + extended. + */ + public function getMobileDetectionRulesExtended() + { + static $rules; + + if (!$rules) { + // Merge all rules together. + $rules = array_merge( + self::$phoneDevices, + self::$tabletDevices, + self::$operatingSystems, + self::$browsers, + self::$utilities + ); + } + + return $rules; + } + + /** + * Retrieve the current set of rules. + * + * @deprecated since version 2.6.9 + * + * @return array + */ + public function getRules() + { + if ($this->detectionType == self::DETECTION_TYPE_EXTENDED) { + return self::getMobileDetectionRulesExtended(); + } else { + return self::getMobileDetectionRules(); + } + } + + /** + * Retrieve the list of mobile operating systems. + * + * @return array The list of mobile operating systems. + */ + public static function getOperatingSystems() + { + return self::$operatingSystems; + } + + /** + * Check the HTTP headers for signs of mobile. + * This is the fastest mobile check possible; it's used + * inside isMobile() method. + * + * @return bool + */ + public function checkHttpHeadersForMobile() + { + + foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) { + if ( isset($this->httpHeaders[$mobileHeader]) ) { + if ( is_array($matchType['matches']) ) { + foreach ($matchType['matches'] as $_match) { + if ( strpos($this->httpHeaders[$mobileHeader], $_match) !== false ) { + return true; + } + } + + return false; + } else { + return true; + } + } + } + + return false; + + } + + /** + * Magic overloading method. + * + * @method boolean is[...]() + * @param string $name + * @param array $arguments + * @return mixed + * @throws BadMethodCallException when the method doesn't exist and doesn't start with 'is' + */ + public function __call($name, $arguments) + { + //make sure the name starts with 'is', otherwise + if (substr($name, 0, 2) != 'is') { + throw new BadMethodCallException("No such method exists: $name"); + } + + $this->setDetectionType(self::DETECTION_TYPE_MOBILE); + + $key = substr($name, 2); + + return $this->matchUAAgainstKey($key); + } + + /** + * Find a detection rule that matches the current User-agent. + * + * @param null $userAgent deprecated + * @return boolean + */ + protected function matchDetectionRulesAgainstUA($userAgent = null) + { + // Begin general search. + foreach ($this->getRules() as $_regex) { + if (empty($_regex)) { + continue; + } + if ($this->match($_regex, $userAgent)) { + return true; + } + } + + return false; + } + + /** + * Search for a certain key in the rules array. + * If the key is found the try to match the corresponding + * regex agains the User-Agent. + * + * @param string $key + * @param null $userAgent deprecated + * @return mixed + */ + protected function matchUAAgainstKey($key, $userAgent = null) + { + // Make the keys lowercase so we can match: isIphone(), isiPhone(), isiphone(), etc. + $key = strtolower($key); + + //change the keys to lower case + $_rules = array_change_key_case($this->getRules()); + + if (array_key_exists($key, $_rules)) { + if (empty($_rules[$key])) { + return null; + } + + return $this->match($_rules[$key], $userAgent); + } + + return false; + } + + /** + * Check if the device is mobile. + * Returns true if any type of mobile device detected, including special ones + * @param null $userAgent deprecated + * @param null $httpHeaders deprecated + * @return bool + */ + public function isMobile($userAgent = null, $httpHeaders = null) + { + + if ($httpHeaders) { + $this->setHttpHeaders($httpHeaders); + } + + if ($userAgent) { + $this->setUserAgent($userAgent); + } + + $this->setDetectionType(self::DETECTION_TYPE_MOBILE); + + if ($this->checkHttpHeadersForMobile()) { + return true; + } else { + return $this->matchDetectionRulesAgainstUA(); + } + + } + + /** + * Check if the device is a tablet. + * Return true if any type of tablet device is detected. + * + * @param string $userAgent deprecated + * @param array $httpHeaders deprecated + * @return bool + */ + public function isTablet($userAgent = null, $httpHeaders = null) + { + $this->setDetectionType(self::DETECTION_TYPE_MOBILE); + + foreach (self::$tabletDevices as $_regex) { + if ($this->match($_regex, $userAgent)) { + return true; + } + } + + return false; + } + + /** + * This method checks for a certain property in the + * userAgent. + * @todo: The httpHeaders part is not yet used. + * + * @param string $key + * @param string $userAgent deprecated + * @param string $httpHeaders deprecated + * @return bool|int|null + */ + public function is($key, $userAgent = null, $httpHeaders = null) + { + // Set the UA and HTTP headers only if needed (eg. batch mode). + if ($httpHeaders) { + $this->setHttpHeaders($httpHeaders); + } + + if ($userAgent) { + $this->setUserAgent($userAgent); + } + + $this->setDetectionType(self::DETECTION_TYPE_EXTENDED); + + return $this->matchUAAgainstKey($key); + } + + /** + * Some detection rules are relative (not standard), + * because of the diversity of devices, vendors and + * their conventions in representing the User-Agent or + * the HTTP headers. + * + * This method will be used to check custom regexes against + * the User-Agent string. + * + * @param $regex + * @param string $userAgent + * @return bool + * + * @todo: search in the HTTP headers too. + */ + public function match($regex, $userAgent = null) + { + // Escape the special character which is the delimiter. + $regex = str_replace('/', '\/', $regex); + $match = (bool) preg_match('/'.$regex.'/is', (!empty($userAgent) ? $userAgent : $this->userAgent), $matches); + // If positive match is found, store the results for debug. + if ($match) { + $this->matchingRegex = $regex; + $this->matchesArray = $matches; + } + + return $match; + } + + /** + * Get the properties array. + * + * @return array + */ + public static function getProperties() + { + return self::$properties; + } + + /** + * Prepare the version number. + * + * @todo Remove the error supression from str_replace() call. + * + * @param string $ver The string version, like "2.6.21.2152"; + * + * @return float + */ + public function prepareVersionNo($ver) + { + $ver = str_replace(array('_', ' ', '/'), '.', $ver); + $arrVer = explode('.', $ver, 2); + + if (isset($arrVer[1])) { + $arrVer[1] = @str_replace('.', '', $arrVer[1]); // @todo: treat strings versions. + } + + return (float) implode('.', $arrVer); + } + + /** + * Check the version of the given property in the User-Agent. + * Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31) + * + * @param string $propertyName The name of the property. See self::getProperties() array + * keys for all possible properties. + * @param string $type Either self::VERSION_TYPE_STRING to get a string value or + * self::VERSION_TYPE_FLOAT indicating a float value. This parameter + * is optional and defaults to self::VERSION_TYPE_STRING. Passing an + * invalid parameter will default to the this type as well. + * + * @return string|float The version of the property we are trying to extract. + */ + public function version($propertyName, $type = self::VERSION_TYPE_STRING) + { + if (empty($propertyName)) { + return false; + } + + //set the $type to the default if we don't recognize the type + if ($type != self::VERSION_TYPE_STRING && $type != self::VERSION_TYPE_FLOAT) { + $type = self::VERSION_TYPE_STRING; + } + + $properties = self::getProperties(); + + // Check if the property exists in the properties array. + if (array_key_exists($propertyName, $properties)) { + + // Prepare the pattern to be matched. + // Make sure we always deal with an array (string is converted). + $properties[$propertyName] = (array) $properties[$propertyName]; + + foreach ($properties[$propertyName] as $propertyMatchString) { + + $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString); + + // Escape the special character which is the delimiter. + $propertyPattern = str_replace('/', '\/', $propertyPattern); + + // Identify and extract the version. + preg_match('/'.$propertyPattern.'/is', $this->userAgent, $match); + + if (!empty($match[1])) { + $version = ( $type == self::VERSION_TYPE_FLOAT ? $this->prepareVersionNo($match[1]) : $match[1] ); + + return $version; + } + + } + + } + + return false; + } + + /** + * Retrieve the mobile grading, using self::MOBILE_GRADE_* constants. + * + * @return string One of the self::MOBILE_GRADE_* constants. + */ + public function mobileGrade() + { + $isMobile = $this->isMobile(); + + if ( + // Apple iOS 4-7.0 – Tested on the original iPad (4.3 / 5.0), iPad 2 (4.3 / 5.1 / 6.1), iPad 3 (5.1 / 6.0), iPad Mini (6.1), iPad Retina (7.0), iPhone 3GS (4.3), iPhone 4 (4.3 / 5.1), iPhone 4S (5.1 / 6.0), iPhone 5 (6.0), and iPhone 5S (7.0) + $this->isIOS() && $this->version('iPad', self::VERSION_TYPE_FLOAT)>=4.3 || + $this->isIOS() && $this->version('iPhone', self::VERSION_TYPE_FLOAT)>=4.3 || + $this->isIOS() && $this->version('iPod', self::VERSION_TYPE_FLOAT)>=4.3 || + + // Android 2.1-2.3 - Tested on the HTC Incredible (2.2), original Droid (2.2), HTC Aria (2.1), Google Nexus S (2.3). Functional on 1.5 & 1.6 but performance may be sluggish, tested on Google G1 (1.5) + // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM + // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices + // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7 + ( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) || + + // Windows Phone 7.5-8 - Tested on the HTC Surround (7.5), HTC Trophy (7.5), LG-E900 (7.5), Nokia 800 (7.8), HTC Mazaa (7.8), Nokia Lumia 520 (8), Nokia Lumia 920 (8), HTC 8x (8) + $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT)>=7.5 || + + // Tested on the Torch 9800 (6) and Style 9670 (6), BlackBerry® Torch 9810 (7), BlackBerry Z10 (10) + $this->is('BlackBerry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)>=6.0 || + // Blackberry Playbook (1.0-2.0) - Tested on PlayBook + $this->match('Playbook.*Tablet') || + + // Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0), HP TouchPad (3.0) + ( $this->version('webOS', self::VERSION_TYPE_FLOAT)>=1.4 && $this->match('Palm|Pre|Pixi') ) || + // Palm WebOS 3.0 - Tested on HP TouchPad + $this->match('hp.*TouchPad') || + + // Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices + ( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT)>=18 ) || + + // Chrome for Android - Tested on Android 4.0, 4.1 device + ( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT)>=4.0 ) || + + // Skyfire 4.1 - Tested on Android 2.3 device + ( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT)>=4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT)>=2.3 ) || + + // Opera Mobile 11.5-12: Tested on Android 2.3 + ( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT)>=11.5 && $this->is('AndroidOS') ) || + + // Meego 1.2 - Tested on Nokia 950 and N9 + $this->is('MeeGoOS') || + + // Tizen (pre-release) - Tested on early hardware + $this->is('Tizen') || + + // Samsung Bada 2.0 - Tested on a Samsung Wave 3, Dolphin browser + // @todo: more tests here! + $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT)>=2.0 || + + // UC Browser - Tested on Android 2.3 device + ( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT)>=2.3 ) || + + // Kindle 3 and Fire - Tested on the built-in WebKit browser for each + ( $this->match('Kindle Fire') || + $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT)>=3.0 ) || + + // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet + $this->is('AndroidOS') && $this->is('NookTablet') || + + // Chrome Desktop 16-24 - Tested on OS X 10.7 and Windows 7 + $this->version('Chrome', self::VERSION_TYPE_FLOAT)>=16 && !$isMobile || + + // Safari Desktop 5-6 - Tested on OS X 10.7 and Windows 7 + $this->version('Safari', self::VERSION_TYPE_FLOAT)>=5.0 && !$isMobile || + + // Firefox Desktop 10-18 - Tested on OS X 10.7 and Windows 7 + $this->version('Firefox', self::VERSION_TYPE_FLOAT)>=10.0 && !$isMobile || + + // Internet Explorer 7-9 - Tested on Windows XP, Vista and 7 + $this->version('IE', self::VERSION_TYPE_FLOAT)>=7.0 && !$isMobile || + + // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7 + $this->version('Opera', self::VERSION_TYPE_FLOAT)>=10 && !$isMobile + ){ + return self::MOBILE_GRADE_A; + } + + if ( + $this->isIOS() && $this->version('iPad', self::VERSION_TYPE_FLOAT)<4.3 || + $this->isIOS() && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<4.3 || + $this->isIOS() && $this->version('iPod', self::VERSION_TYPE_FLOAT)<4.3 || + + // Blackberry 5.0: Tested on the Storm 2 9550, Bold 9770 + $this->is('Blackberry') && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)>=5 && $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<6 || + + //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3 + ($this->version('Opera Mini', self::VERSION_TYPE_FLOAT)>=5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT)<=7.0 && + ($this->version('Android', self::VERSION_TYPE_FLOAT)>=2.3 || $this->is('iOS')) ) || + + // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1) + $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') || + + // @todo: report this (tested on Nokia N71) + $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT)>=11 && $this->is('SymbianOS') + ){ + return self::MOBILE_GRADE_B; + } + + if ( + // Blackberry 4.x - Tested on the Curve 8330 + $this->version('BlackBerry', self::VERSION_TYPE_FLOAT)<=5.0 || + // Windows Mobile - Tested on the HTC Leo (WinMo 5.2) + $this->match('MSIEMobile|Windows CE.*Mobile') || $this->version('Windows Mobile', self::VERSION_TYPE_FLOAT)<=5.2 || + + // Tested on original iPhone (3.1), iPhone 3 (3.2) + $this->isIOS() && $this->version('iPad', self::VERSION_TYPE_FLOAT)<=3.2 || + $this->isIOS() && $this->version('iPhone', self::VERSION_TYPE_FLOAT)<=3.2 || + $this->isIOS() && $this->version('iPod', self::VERSION_TYPE_FLOAT)<=3.2 || + + // Internet Explorer 7 and older - Tested on Windows XP + $this->version('IE', self::VERSION_TYPE_FLOAT)<=7.0 && !$isMobile + ){ + return self::MOBILE_GRADE_C; + } + + //All older smartphone platforms and featurephones - Any device that doesn't support media queries + //will receive the basic, C grade experience. + return self::MOBILE_GRADE_C; + } +} diff --git a/routine.php b/routine.php new file mode 100755 index 0000000..5e824f9 --- /dev/null +++ b/routine.php @@ -0,0 +1,54 @@ + 5 ) { +// ########## CALCOLA CENTROIDE PARTICELLA + if(!$strcoordinate = @pg_query("SELECT ST_X(ST_Transform(ST_Centroid(ST_Union(the_geom)),4326)) as long, + ST_Y(ST_Transform(ST_Centroid(ST_union(the_geom)),4326)) as lat + FROM ".$_SESSION['COMUNE_BELF'].".particelle WHERE gid=".$_SESSION['cataparticella_id'].";")) + die("Errore CENTRO COMUNE: " . pg_last_error($conn)); + while($rowcoord = pg_fetch_assoc($strcoordinate)) { +// ########## CENTRO MAPPA + $_SESSION['CENTER'] = $rowcoord['lat'] .", ".$rowcoord['long']; + } + $zoom = 16; +} else { + +// ########## CALCOLA CENTROIDE COMUNE +if ($levelid < 80) { + + if(!$strcoordinate = @pg_query("SELECT ST_X(ST_Centroid(ST_Transform(ST_Union(the_geom),4326))) as long, + ST_Y(ST_Centroid(ST_Transform(ST_Union(the_geom),4326))) as lat FROM comuni_italia_3004 WHERE cod_belf ='".$_SESSION['COMUNE_BELF']."';")) + die("Errore nella query CENTER: " . pg_last_error($conn)); + while($rowcoord = pg_fetch_assoc($strcoordinate)) { +// ########## CENTRO MAPPA + $_SESSION['CENTER'] = $rowcoord['lat'] .", ".$rowcoord['long']; + } + + + if(!$strbound = @pg_query("SELECT ST_YMax(ST_Buffer(ST_Transform(the_geom,4326),0.15)) as ymax, ST_XMax(ST_Buffer(ST_Transform(the_geom,4326),0.15)) as xmax, ST_YMin(ST_Buffer(ST_Transform(the_geom,4326),0.15)) as ymin, ST_XMin(ST_Buffer(ST_Transform(the_geom,4326),0.15)) as xmin + FROM comuni_italia_3004 WHERE cod_belf = '".$_SESSION['COMUNE_BELF']."';")) + die("ERROR BOUND: " . pg_last_error($conn)); + while($rowbound = pg_fetch_assoc($strbound)) { +// ########## CALCOLO BOUND COMUNE + $_SESSION['BOUND'] = "[".$rowbound['ymin'].", ".$rowbound['xmin']."],[".$rowbound['ymax'].", ".$rowbound['xmax']."]"; + } + //echo "### ".$_SESSION['BOUND']." ###
"; + //echo "### ".$_SESSION['CENTER']." ###"; + $zoom = 12; +} + +// ########## CALCOLA CENTROIDE GRUPPO COMUNI + if ($levelid > 80) { + $_SESSION['CENTER'] = '37.068, 14.985'; + $zoom = 8; + } +} + +?> \ No newline at end of file diff --git a/routine_feature.php b/routine_feature.php new file mode 100755 index 0000000..c5b9549 --- /dev/null +++ b/routine_feature.php @@ -0,0 +1,359 @@ + + + + +"; +echo "OBJ = ".$obj."
"; +echo "RISK ID = ".$risk."
"; + +if(!$conn) { ?> + +'; + } + +switch ($obj) { +case 'point': + $objtable = "objpoint"; + $schema = strtolower($_SESSION['COMUNE_BELF']); + $idgeom = "id_obj"; + break; +case 'gate': + $objtable = "objgate"; + $schema = strtolower($_SESSION['COMUNE_BELF']); + $idgeom = "id_obj"; + break; +case 'area': + $objtable = "objarea"; + $schema = strtolower($_SESSION['COMUNE_BELF']); + $idgeom = "id_obj"; + break; +case 'fire': + $objtable = "incendi"; + $schema = "public"; + $idgeom = "id_aib"; + break; +case 'sce': + $objtable = "objscenari"; + $schema = strtolower($_SESSION['COMUNE_BELF']); + $idgeom = "id_obj"; + break; +case 'line': + $objtable = "objline"; + $schema = strtolower($_SESSION['COMUNE_BELF']); + $idgeom = "id_obj"; + break; +case 'sog': + $objtable = "objsoggetti"; + $schema = strtolower($_SESSION['COMUNE_BELF']); + $idgeom = "id_obj"; + break; +case 'trash': + $objtable = "discarica"; + $schema = strtolower($_SESSION['COMUNE_BELF']); + $idgeom = "id"; + break; +case 'int': + $objtable = "interventi"; + $schema = strtolower($_SESSION['COMUNE_BELF']); + $idgeom = "id_inter"; + break; +case 'suolo_pub': + $objtable = "objsoggetti"; + $schema = strtolower($_SESSION['COMUNE_BELF']); + $idgeom = "suolo_id"; + break; +case 'passi': + $objtable = "objsoggetti"; + $schema = strtolower($_SESSION['COMUNE_BELF']); + $idgeom = "passi_id"; + break; +case 'pubblicita': + $objtable = "objsoggetti"; + $schema = strtolower($_SESSION['COMUNE_BELF']); + $idgeom = "pubbli_id"; + break; +case 'civici': + $objtable = "topo_civici"; + $schema = strtolower($_SESSION['COMUNE_BELF']); + $idgeom = "civico_id"; + break; +case 'sign': + $objtable = "segnalazioni"; + $schema = strtolower($_SESSION['COMUNE_BELF']); + $idgeom = "segnalazione_id"; + break; +case 'zoning_compare': + $schema = strtolower($_SESSION['COMUNE_BELF']); + $idgeom = "compare_id"; + break; +case 'zpoi': + $objtable = "zoning_poi"; + $schema = strtolower($_SESSION['COMUNE_BELF']); + $idgeom = "poi_id"; + break; +default: + $schema = "public"; +} + +/**/ + //RECUPERA L'ULTIMO ID DALLA TABELLA GEOMETRY_TEST + if(!$last_idtable = @pg_query("SELECT ".$idgeom." AS idgeometria FROM ".$schema.".".$objtable." ORDER BY ".$objtable.".".$idgeom." DESC LIMIT 1")) + die("Errore nella query RECUPERA ID: " . pg_last_error($conn)); +echo "SELECT = ".$last_idtable."
"; + while($last_idtable_result = pg_fetch_assoc($last_idtable)) { + $id_new_geometry = $last_idtable_result['idgeometria']; + } + +//echo "1 FEATURE: ".$feature."
2 MODE: ".$mode."
3 OBJ: ".$obj."
"; + +//$featuredati = explode(".", $feature); + +//echo "3 TABELLA: ".$featuredati[0]."
4 ID: ".$featuredati[1]."
5 SCHEMA: ".$schema."
6 ID: ".$idgeom."
"; + +//$id_new_geometry = $featuredati[1]; + +$tabella = $_SESSION['TAB']; +//echo "5 TABELLA: ".$tabella."
"; + + +//######################### FIRE +if ($obj == "fire") { + +//RECUPERA AREA +if(!$last_gid = @pg_query("SELECT ST_AREA(the_geom) AS area FROM public.incendi WHERE id_aib = ".$id_new_geometry."")) + die("ERROR FIRE AREA: " . pg_last_error($conn)); + while($last_result = pg_fetch_assoc($last_gid)) { + $areaincendio = round($last_result['area']/10000,2); + } +//echo "AREA INCENDIO ".$areaincendio ."
"; + +//CERCA I COMUNI INTERESSATI DALL'INCENDIO + if(!$query8 = @pg_query("SELECT comune FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.comune FROM ". + " (SELECT a.the_geom, a.comune FROM public.comuni_italia_3004 a inner join ". + " (SELECT ST_UNION(the_geom) as the_geom FROM ".$schema.".".$objtable." WHERE ".$idgeom." = ".$id_new_geometry.") b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT * FROM public.incendi WHERE id_aib = ".$id_new_geometry.") f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("ERROR STR3: " . pg_last_error($conn)); + while($row8 = pg_fetch_assoc($query8)) { + $comuni[] = $row8['comune']; +} +$lista_comuni = implode(', ', $comuni); + + +//CERCA I TOPONIMI INTERESSATI DALL'INCENDIO +if(!$query_toponimi = @pg_query("SELECT toponimo, secondo_no FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.toponimo, e.secondo_no FROM ". + " (SELECT a.the_geom, a.toponimo, a.secondo_no FROM public.toponimi a inner join ". + " (SELECT ST_UNION(the_geom) AS the_geom FROM public.incendi WHERE id_aib = ".$id_new_geometry.") b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT * FROM public.incendi WHERE id_aib = ".$id_new_geometry.") f on ST_Intersects(e.the_geom, f.the_geom)) a;")) +die("Errore nella query STR2: " . pg_last_error($conn)); + +while($row_toponimi = pg_fetch_assoc($query_toponimi)) { + $topo[] = str_replace("'", "’" ,$row_toponimi['toponimo'])." ".str_replace("'", "’" ,$row_toponimi['secondo_no']); + } +$lista_toponimi = implode(', ', $topo); +//echo "TOPONIMI ".$lista_toponimi."
"; + + +//CERCA I CATASTALI CHE INTERESSA IL PUNTO +if(!$query4 = @pg_query("SELECT mappale FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.mappale FROM ". + " (SELECT a.the_geom, a.mappale FROM ".strtolower($_SESSION['COMUNE_BELF']).".particelle a inner join ". + " (SELECT ST_UNION(the_geom) AS the_geom FROM public.incendi WHERE id_aib = $id_new_geometry) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT * FROM public.incendi WHERE id_aib = $id_new_geometry) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) +die("ERROR STR3: " . pg_last_error($conn)); +while($row4 = pg_fetch_assoc($query4)) { + $mappale[] = $row4['mappale']; +} +$cataincendio = implode(', ', $mappale); + + if(!$rs_update = @pg_query("UPDATE public.incendi SET comune_app = '".$_SESSION['COMUNE_NAME']."', localita = '".$lista_toponimi."', altri_com='".$lista_comuni."', catasto ='".$cataincendio."', totsup = ".$areaincendio.", archiviato = 0, attivo=1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg = '".date("Y-m-d h:i:sa", time())."' WHERE id_aib = ".$id_new_geometry."")) + die("ERROR 1: " . pg_last_error($conn)); + +} + +//######################### AREA +if ($obj == "area") { +//RECUPERA AREA +if(!$last_gid = @pg_query("SELECT ST_AREA(the_geom) AS area FROM ".strtolower($_SESSION['COMUNE_BELF']).".objarea WHERE id_obj = ".$id_new_geometry."")) + die("ERROR AREA PROTEZIONE CIVILE: " . pg_last_error($conn)); + while($last_result = pg_fetch_assoc($last_gid)) { + $areaincendio = round($last_result['area'],0); + } +//echo "AREA INCENDIO ".$areaincendio ."
"; + +//CERCA I TOPONIMI INTERESSATI DALL'INCENDIO +if(!$query_toponimi = @pg_query("SELECT toponimo, secondo_no FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.toponimo, e.secondo_no FROM ". + " (SELECT a.the_geom, a.toponimo, a.secondo_no FROM public.toponimi a inner join ". + " (SELECT ST_UNION(the_geom) AS the_geom FROM ".strtolower($_SESSION['COMUNE_BELF']).".objarea WHERE id_obj = ".$id_new_geometry.") b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT * FROM ".strtolower($_SESSION['COMUNE_BELF']).".objarea WHERE id_obj = ".$id_new_geometry.") f on ST_Intersects(e.the_geom, f.the_geom)) a;")) +die("Errore nella query STR2: " . pg_last_error($conn)); + +while($row_toponimi = pg_fetch_assoc($query_toponimi)) { + $topo[] = str_replace("'", "’" ,$row_toponimi['toponimo'])." ".str_replace("'", "’" ,$row_toponimi['secondo_no']); + } +$lista_toponimi = implode(', ', $topo); +//echo "TOPONIMI ".$lista_toponimi."
"; + + +//CERCA I CATASTALI CHE INTERESSA IL PUNTO +if(!$query4 = @pg_query("SELECT mappale FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.mappale FROM ". + " (SELECT a.the_geom, a.mappale FROM ".strtolower($_SESSION['COMUNE_BELF']).".particelle a inner join ". + " (SELECT ST_UNION(the_geom) AS the_geom FROM ".strtolower($_SESSION['COMUNE_BELF']).".objarea WHERE id_obj = $id_new_geometry) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT * FROM ".strtolower($_SESSION['COMUNE_BELF']).".objarea WHERE id_obj = $id_new_geometry) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) +die("ERROR STR3: " . pg_last_error($conn)); +while($row4 = pg_fetch_assoc($query4)) { + $mappale[] = $row4['mappale']; +} +$cataincendio = implode(', ', $mappale); + + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".objarea SET comune_app='".$_SESSION['COMUNE_NAME']."', localita='".$lista_toponimi."', catasto='".$cataincendio."', area_totale='".$areaincendio."', archiviato = false, attivo=1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg = '".date("Y-m-d h:i:sa", time())."' WHERE id_obj = ".$id_new_geometry."")) + die("ERROR 8: " . pg_last_error($conn)); +} + +//######################### SCE +if ($obj == "sce") { + +switch ($risk) { + case 'ind': // AREA + $tipo = "Rischio industriale"; + break; + case 'tsu': // AREA + $tipo = "Rischio tsunami"; + break; + case 'inc': // AREA + $tipo = "Rischio incendi"; + break; + case 'idr': // AREA + $tipo = "Rischio idrogeologico"; + break; + default: + $tipo = ""; +} + +// INSERISCE AREA E GEOMETRIA IN TABELLA +if(!$testpoint = @pg_query("INSERT INTO ".strtolower($_SESSION['COMUNE_BELF']).".objscenari (tipo,attivo,comune,the_geom) VALUES ('".$tipo."',3,'".$_SESSION['COMUNE_BELF']."', + (SELECT ST_MULTI(the_geom) FROM public.polygon_support3004 WHERE gid=".$featuredati[1]."))")) + die("ERROR INSER GEOM: " . pg_last_error($conn)); + +//RECUPERA L'ULTIMO ID DALLA TABELLA GEOMETRY_TEST +if(!$last_gid = @pg_query("SELECT id_obj, ST_AREA(the_geom) AS area FROM ".strtolower($_SESSION['COMUNE_BELF']).".objscenari ORDER BY id_obj DESC LIMIT 1")) + die("Errore nella query RECUPERA ID: " . pg_last_error($conn)); + while($last_result = pg_fetch_assoc($last_gid)) { + $id_new = $last_result['id_obj']; + $areascenario = round($last_result['area'],2); + } + +//CERCA I TOPONIMI INTERESSATI DALL'INCENDIO +if(!$query_toponimi = @pg_query("SELECT toponimo, secondo_no FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.toponimo, e.secondo_no FROM ". + " (SELECT a.the_geom, a.toponimo, a.secondo_no FROM public.toponimi a inner join ". + " (SELECT ST_UNION(the_geom) AS the_geom FROM ".strtolower($_SESSION['COMUNE_BELF']).".objscenari WHERE id_obj = ".$id_new.") b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT * FROM ".strtolower($_SESSION['COMUNE_BELF']).".objscenari WHERE id_obj = ".$id_new.") f on ST_Intersects(e.the_geom, f.the_geom)) a;")) +die("Errore nella query STR2: " . pg_last_error($conn)); + +while($row_toponimi = pg_fetch_assoc($query_toponimi)) { + $topo[] = str_replace("'", "’" ,$row_toponimi['toponimo'])." ".str_replace("'", "’" ,$row_toponimi['secondo_no']); + } +$lista_toponimi = implode(', ', $topo); +//echo "TOPONIMI ".$lista_toponimi."
"; + + +//CERCA I CATASTALI CHE INTERESSA IL PUNTO +if(!$query4 = @pg_query("SELECT mappale FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.mappale FROM ". + " (SELECT a.the_geom, a.mappale FROM ".strtolower($_SESSION['COMUNE_BELF']).".particelle a inner join ". + " (SELECT ST_UNION(the_geom) AS the_geom FROM ".strtolower($_SESSION['COMUNE_BELF']).".objscenari WHERE id_obj = $id_new) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT * FROM ".strtolower($_SESSION['COMUNE_BELF']).".objscenari WHERE id_obj = $id_new) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) +die("ERROR STR3: " . pg_last_error($conn)); +while($row4 = pg_fetch_assoc($query4)) { + $mappale[] = $row4['mappale']; +} +$cataincendio = implode(', ', $mappale); + + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".objscenari SET comune_app = '".$_SESSION['COMUNE_NAME']."', localita = '".$lista_toponimi."', catasto ='".$cataincendio."', area = ".$areascenario.", archiviato = 0, attivo=1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg = '".date("Y-m-d h:i:sa", time())."' WHERE id_obj = ".$id_new."")) + die("ERROR 1: " . pg_last_error($conn)); + +} + + +//######################### SCE +if ($obj == "line") { + + +//RECUPERA L'ULTIMO ID DALLA TABELLA GEOMETRY_TEST +if(!$last_gid = @pg_query("SELECT id_obj FROM ".strtolower($_SESSION['COMUNE_BELF']).".objline ORDER BY id_obj DESC LIMIT 1")) + die("Errore nella query RECUPERA ID: " . pg_last_error($conn)); + while($last_result = pg_fetch_assoc($last_gid)) { + $id_new = $last_result['id_obj']; + } + + } + +if ($obj == "point" OR $obj == "trash" OR $obj == "gate" OR $obj == "sign" OR $obj == "int" OR $obj == "sog" OR $obj == "civ" OR $obj == "pas" OR $obj == "pub" OR $obj == "zoning_compare" OR $obj == "zpoi") { + +//INIZIO ALTRI PUNTI +//------------------------------------------------------------------------------ +// CERCA LE COORDINATE DEL PUNTO +/* +if(!$query_xy = @pg_query("SELECT ST_Y(ST_Transform(the_geom,3004)) as lat, ST_X(ST_Transform(the_geom,3004)) as long FROM ".$schema.".".$featuredati[0]." WHERE ".$idgeom."=".$featuredati[1]."")) + die("Errore nella query LAT-LONG : " . pg_last_error($conn)); + $row_obj = pg_num_rows($query_xy); + echo "ROW = ".$row_obj."
"; + while($row_xy = pg_fetch_assoc($query_xy)) { + $long = $row_xy['long']; + $lat = $row_xy['lat']; + echo "LAT2: ".$lat." - LONG2: ".$long."
"; + } + +//CERCA I TOPONIMI ENTRO UN RAGGIO DI 750 M INTERESSATI DAL PUNTO + if(!$query_toponimi = @pg_query("SELECT toponimo, secondo_no FROM toponimi WHERE + ST_DWithin(Geography(the_geom)), + Geography(ST_MakePoint($long, $lat)),750);")) + die("Errore nella query STR21: " . pg_last_error($conn)); + + while($row_toponimi = pg_fetch_assoc($query_toponimi)) { + $topo[] = $row_toponimi['toponimo']." ".$row_toponimi['secondo_no']; + } + $toponimi = implode(', ', $topo); + +//CERCA I CATASTALI CHE INTERESSA IL PUNTO + if(!$query_cata = @pg_query("SELECT mappale FROM ".strtolower($_SESSION['COMUNE_BELF']).".particelle WHERE + ST_DWithin(Geography(the_geom), + Geography(ST_MakePoint($long, $lat)),0.1);")) + die("Errore nella query STR22: " . pg_last_error($conn)); + + while($row_cata = pg_fetch_assoc($query_cata)) { + //$cata = substr($row_cata['mappale'],5,10); + $cata = $row_cata['mappale']; + } +*/ +// if(!$rs_update = @pg_query("UPDATE ".$schema.".".$featuredati[0]." SET comune_app='".$_SESSION['COMUNE_NAME']."', localita='".$toponimi."', catasto='".$cata."', archiviato = 0, attivo=1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg = '".date("Y-m-d h:i:sa", time())."' WHERE ".$idgeom." = ".$id_new_geometry."")) + if(!$rs_update = @pg_query("UPDATE ".$schema.".".$objtable." SET comune_app='".$_SESSION['COMUNE_NAME']."', archiviato = 0, attivo=1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg = '".date("Y-m-d h:i:sa", time())."' WHERE ".$idgeom." = ".$id_new_geometry."")) + die("ERROR 111: " . pg_last_error($conn)); + +} + + + if ($obj == "sce") { ?> + + + + \ No newline at end of file diff --git a/routine_map.php b/routine_map.php new file mode 100755 index 0000000..15fdd32 --- /dev/null +++ b/routine_map.php @@ -0,0 +1,80 @@ + + + +"; +/**/ +if (strlen($_SESSION['cataparticella']) > 2 ) { +// ########## CALCOLA CENTROIDE PARTICELLA + if(!$strcoordinate = @pg_query("SELECT ST_X(ST_Transform(ST_Centroid(ST_Union(geom)),4326)) as long, + ST_Y(ST_Transform(ST_Centroid(ST_union(geom)),4326)) as lat + FROM ".$_SESSION['COMUNE_PROV'].".particelle WHERE comune = '".$_SESSION['COMUNE_BELF']."' AND id=".$_SESSION['QUERY_CDU'].";")) + die("Errore CENTRO COMUNE: " . pg_last_error($conn)); + while($rowcoord = pg_fetch_assoc($strcoordinate)) { $_SESSION['CENTER'] = $rowcoord['lat'] .", ".$rowcoord['long']; } + + $_SESSION['ZOOM'] = 18; + +// ########## CALCOLO BOUND PARTICELLE + + if(!$strbound = @pg_query("SELECT ST_YMax(ST_Buffer(ST_Transform(ST_Union(geom),4326),0.15)) as ymax, ST_XMax(ST_Buffer(ST_Transform(ST_Union(geom),4326),0.15)) as xmax, ST_YMin(ST_Buffer(ST_Transform(ST_Union(geom),4326),0.15)) as ymin, ST_XMin(ST_Buffer(ST_Transform(ST_Union(geom),4326),0.15)) as xmin + FROM ".$_SESSION['COMUNE_PROV'].".particelle WHERE comune = '".$_SESSION['COMUNE_BELF']."' AND id=".$_SESSION['QUERY_CDU'].";")) + die("ERROR BOUND: " . pg_last_error($conn)); + while($rowbound = pg_fetch_assoc($strbound)) { + // ---------- ESTENSIONE MAPPA + $_SESSION['BOUND'] = "[".$rowbound['ymin'].", ".$rowbound['xmin']."],[".$rowbound['ymax'].", ".$rowbound['xmax']."]"; + } + + +// CALCOLA GEOMETRIA PARTICELLA + $sql_catasto = "SELECT ST_AsGeoJSON(ST_Transform(geom,4326)) AS cata_geojson, round(ST_Area(geom)::numeric,2) as area + FROM ".strtolower($_SESSION['COMUNE_PROV']).".particelle WHERE comune = '".$_SESSION['COMUNE_BELF']."' AND id=".$_SESSION['QUERY_CDU'].";"; + + # Try query or error + $rs = pg_query($conn, $sql_catasto); + if (!$rs) { + echo "ERROR GEOM PARTICELLE.\n"; + } else { + // echo "QUERY OKKEY

"; + } + + # Build GeoJSON + $output = ''; + $rowOutput = ''; + + while ($row = pg_fetch_assoc($rs)) { + // $rowOutput = (strlen($rowOutput) > 0 ? ',' : '') . '{"type": "Feature", "geometry": ' . $row['geojson'] . ', "properties": {'; + $rowOutput = (strlen($rowOutput) > 0 ? ',' : '') . '{"type": "Feature", "properties": {'; + $props = ''; + $id = ''; + foreach ($row as $key => $val) { + if ($key != "cata_geojson") { + $props .= (strlen($props) > 0 ? ',' : '') . '"' . $key . '":"' . escapeJsonString($val) . '"'; + } + if ($key == "id") { + $id .= ',"id":"' . escapeJsonString($val) . '"'; + } + } + // $rowOutput .= $props . '}'; + $rowOutput .= $props . '}, "geometry": ' . $row['cata_geojson'] . ''; + $rowOutput .= $id; + $rowOutput .= '}'; + $output .= $rowOutput; + } + + $particella = '{ "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4326" } }, "features": [ ' . $output . ' ] }'; + $_SESSION['SELECT_PARTICELLA'] = $particella; + + +} else { + + $_SESSION['ZOOM'] = 12; +} + + ?> diff --git a/routine_map_bckoffice.php b/routine_map_bckoffice.php new file mode 100755 index 0000000..fe20e5e --- /dev/null +++ b/routine_map_bckoffice.php @@ -0,0 +1,109 @@ + + + +"; + $arraymappale = explode(';', $_SESSION['cataparticella']); + + if (count($arraymappale) > 0) { + + foreach( $arraymappale as $index => $mappale ) { + + if(!$query = @pg_query("SELECT id FROM ".$_SESSION['COMUNE_PROV'].".particelle WHERE comune = '".$_SESSION['COMUNE_BELF']."' AND mappale ='".$mappale."';")) + die("Error query CERCA PARTICELLA: " . pg_last_error($conn)); + + if (pg_numrows($query) > 0){ + + while($rowparticelle = pg_fetch_assoc($query)) { + $gidquery[] = $rowparticelle['id']; + } + } + } + + $valorearray = count($gidquery); + //echo "VALORE ARRAY = ".$valorearray."
"; + $stringa = implode(' OR id=', $gidquery); + $_SESSION['QUERY_CDU'] = $stringa; + //echo '
STRINGA: '.$_SESSION['QUERY_CDU']."
"; + $_SESSION['GET_CDU'] = 1; + + } else { + unset($_SESSION['cataparticella']); + unset($_SESSION['QUERY_CDU']); + $_SESSION['GET_CDU'] = 0; + } + + // CALCOLA GEOMETRIA PARTICELLA + $sql_catasto = "SELECT ST_AsGeoJSON(ST_Transform(geom,4326)) AS cata_geojson, round(ST_Area(geom)::numeric,2) as area + FROM ".strtolower($_SESSION['COMUNE_PROV']).".particelle WHERE comune = '".$_SESSION['COMUNE_BELF']."' AND id=".$_SESSION['QUERY_CDU'].";"; + + $rs = pg_query($conn, $sql_catasto); + if (!$rs) {echo "ERROR GEOM PARTICELLE.\n"; } else { /*echo "QUERY OKKEY

";*/ } + + $output = ''; + $rowOutput = ''; + + while ($row = pg_fetch_assoc($rs)) { + $_SESSION['CENTER'] = $row['lat'] .", ".$row['long']; + $rowOutput = (strlen($rowOutput) > 0 ? ',' : '') . '{"type": "Feature", "properties": {'; + $props = ''; + $id = ''; + foreach ($row as $key => $val) { + if ($key != "cata_geojson") { $props .= (strlen($props) > 0 ? ',' : '') . '"' . $key . '":"' . escapeJsonString($val) . '"'; } + if ($key == "id") { $id .= ',"id":"' . escapeJsonString($val) . '"'; } + } + $rowOutput .= $props . '}, "geometry": ' . $row['cata_geojson'] . ''; + $rowOutput .= $id; + $rowOutput .= '}'; + $output .= $rowOutput; + } + + $particella = '{ "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4326" } }, "features": [ ' . $output . ' ] }'; + //$var=fopen("data/comune".$comuneuser.".json","w"); + $_SESSION['SELECT_PARTICELLA'] = $particella; + + +if ($valorearray >= 1){ +// ########## CALCOLA CENTROIDE PARTICELLA + if(!$strcoordinate = @pg_query("SELECT ST_X(ST_Transform(ST_Centroid(ST_Union(geom)),4326)) as long, + ST_Y(ST_Transform(ST_Centroid(ST_union(geom)),4326)) as lat + FROM ".$_SESSION['COMUNE_PROV'].".particelle WHERE comune = '".$_SESSION['COMUNE_BELF']."' AND id=".$_SESSION['QUERY_CDU'].";")) + die("Errore CENTRO COMUNE: " . pg_last_error($conn)); + while($rowcoord = pg_fetch_assoc($strcoordinate)) { $_SESSION['CENTER'] = $rowcoord['lat'] .", ".$rowcoord['long']; } + + //$_SESSION['CENTER'] = $lat .", ".$lng; + $_SESSION['ZOOM'] = 18; + + + // ########## CALCOLO BOUND PARTICELLA + if (!$strbound = @pg_query("SELECT ST_YMax(ST_Buffer(ST_Transform(geom,4326),0.15)) as ymax, ST_XMax(ST_Buffer(ST_Transform(geom,4326),0.15)) as xmax, ST_YMin(ST_Buffer(ST_Transform(geom,4326),0.15)) as ymin, ST_XMin(ST_Buffer(ST_Transform(geom,4326),0.15)) as xmin + FROM ".$_SESSION['COMUNE_PROV'].".particelle WHERE comune = '".$_SESSION['COMUNE_BELF']."' AND id=".$_SESSION['QUERY_CDU'].";")) + die("ERROR BOUND: " . pg_last_error($conn)); + while ($rowbound = pg_fetch_assoc($strbound)) { + $_SESSION['BOUND'] = "[" . $rowbound['ymin'] . ", " . $rowbound['xmin'] . "],[" . $rowbound['ymax'] . ", " . $rowbound['xmax'] . "]"; + } + +} else { + + $rs_comune = "SELECT bound FROM public.comuni WHERE cod_belf = '" . $_SESSION['COMUNE_BELF'] . "'"; + $result = pg_query($conn, $rs_comune) or die('Query failed4'); + $row_comune = pg_num_rows($result); + if ($row_comune > 0) { + while ($comunesession = pg_fetch_assoc($result)) { + $_SESSION['BOUND'] = $comunesession['bound']; + + } + } + $_SESSION['CENTER'] = $_SESSION['LAT'] .", ".$_SESSION['LONG']; + $_SESSION['ZOOM'] = 17; } + + ?> diff --git a/routine_map_interventi.php b/routine_map_interventi.php new file mode 100644 index 0000000..30caaed --- /dev/null +++ b/routine_map_interventi.php @@ -0,0 +1,90 @@ + + + +
";*/ } + + $output = ''; $rowOutput = ''; + + while ($row = pg_fetch_assoc($rs_polygon)) { + $rowOutput = (strlen($rowOutput) > 0 ? ',' : '') . '{"type": "Feature", "properties": {'; + $props = ''; + $id = ''; + foreach ($row as $key => $val) { + if ($key != "geojson") { + $props .= (strlen($props) > 0 ? ',' : '') . '"' . $key . '":"' . escapeJsonString($val) . '"'; + } + if ($key == "id") { $id .= ',"id":"' . escapeJsonString($val) . '"'; } + } + $rowOutput .= $props . '}, "geometry": ' . $row['geojson'] . ''; + $rowOutput .= $id; + $rowOutput .= '}'; + $output .= $rowOutput; + } + + $_SESSION['INT_POLYGON'] = '{ "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4326" } }, "features": [ ' . $output . ' ] }'; + + + // ####### LINE ####### // + $sql_line = "SELECT id, notes, ST_AsGeoJSON(geom, 4326, 1) AS geojson FROM interventi_line WHERE idpratica = ".$_SESSION['IDPRATICA'].""; + $rs_line = pg_query($conn, $sql_line); + if (!$rs_line) {echo "ERROR - LINE.\n"; } else { /*echo "QUERY OKKEY

";*/ } + + $output = ''; $rowOutput = ''; + + while ($row = pg_fetch_assoc($rs_line)) { + $rowOutput = (strlen($rowOutput) > 0 ? ',' : '') . '{"type": "Feature", "properties": {'; + $props = ''; + $id = ''; + foreach ($row as $key => $val) { + if ($key != "geojson") { + $props .= (strlen($props) > 0 ? ',' : '') . '"' . $key . '":"' . escapeJsonString($val) . '"'; + } + if ($key == "id") { $id .= ',"id":"' . escapeJsonString($val) . '"'; } + } + $rowOutput .= $props . '}, "geometry": ' . $row['geojson'] . ''; + $rowOutput .= $id; + $rowOutput .= '}'; + $output .= $rowOutput; + } + + $_SESSION['INT_LINE'] = '{ "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4326" } }, "features": [ ' . $output . ' ] }'; + + + // ####### POINT ####### // + $sql_point = "SELECT id, notes, ST_AsGeoJSON(geom, 4326, 1) AS geojson FROM interventi_point WHERE idpratica = ".$_SESSION['IDPRATICA'].""; + $rs_point = pg_query($conn, $sql_point); + if (!$rs_point) {echo "ERROR - POINT.\n"; } else { /*echo "QUERY OKKEY

";*/ } + + $output = ''; $rowOutput = ''; + + while ($row = pg_fetch_assoc($rs_point)) { + $rowOutput = (strlen($rowOutput) > 0 ? ',' : '') . '{"type": "Feature", "properties": {'; + $props = ''; + $id = ''; + foreach ($row as $key => $val) { + if ($key != "geojson") { + $props .= (strlen($props) > 0 ? ',' : '') . '"' . $key . '":"' . escapeJsonString($val) . '"'; + } + if ($key == "id") { $id .= ',"id":"' . escapeJsonString($val) . '"'; } + } + $rowOutput .= $props . '}, "geometry": ' . $row['geojson'] . ''; + $rowOutput .= $id; + $rowOutput .= '}'; + $output .= $rowOutput; + } + + $_SESSION['INT_POINT'] = '{ "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4326" } }, "features": [ ' . $output . ' ] }'; + + + ?> diff --git a/routine_map_ricercageo.php b/routine_map_ricercageo.php new file mode 100755 index 0000000..5bfa3d1 --- /dev/null +++ b/routine_map_ricercageo.php @@ -0,0 +1,42 @@ + + + + 0) { + while ($provsession = pg_fetch_assoc($result)) { + $_SESSION['CENTER'] = $provsession['lat'] . ", " . $provsession['long']; + $_SESSION['BOUND'] = $provsession['bound']; + $_SESSION['LIMITE_AMMINISTRATIVO'] = $_SESSION['COMUNE_PROV']."_limite_provincia.json"; + } + } + $_SESSION['ZOOM'] = 10; + +} + +// +if ($_SESSION['DATA_PROV'] == "comu") { + + $rs_comune = "SELECT lat, long, bound FROM public.comuni WHERE cod_belf = '" . $_SESSION['COMUNE_BELF'] . "'"; + $result = pg_query($conn, $rs_comune) or die('Query failed4'); + $row_comune = pg_num_rows($result); + if ($row_comune > 0) { + while ($comunesession = pg_fetch_assoc($result)) { + $_SESSION['CENTER'] = $comunesession['lat'] .", ".$comunesession['long']; + $_SESSION['BOUND'] = $comunesession['bound']; + $_SESSION['LIMITE_AMMINISTRATIVO'] = $_SESSION['COMUNE_BELF']."_limite_comune.json"; + + } + } + + $_SESSION['ZOOM'] = 12; + +} + diff --git a/routine_rec.php b/routine_rec.php new file mode 100755 index 0000000..c77c50d --- /dev/null +++ b/routine_rec.php @@ -0,0 +1,1671 @@ + + + +"; +echo "TABLE = ".$_SESSION['TAB']."
"; +//echo "SUBTABLE = ".$_SESSION['SUBTAB']."
"; +//echo "LINK = ".$_GET['link']."
"; +//$objtable = $_GET['obj']; +$mode = $_GET['mode']; +$link = $_GET['link']; +$type = $_GET['type']; + +//############### INIZIO PROCEDURA INCENDI ############### +if ($_SESSION['TAB'] == "incendi") { +if ($mode == "edit") { +if ($_POST['data_update'] == ""){$update=date("Y-m-d",time()); }else{$update= $_POST['data_update']; } + + +if(!$rs_record = @pg_query("SELECT * FROM public.incendi WHERE id_aib =".$_SESSION['TABID']."")) + die("Errore nella query di INCENDI DETTAGLI: " . pg_last_error($conn)); + $row_edif = pg_num_rows($rs_record); + if ($row_edif > 0) { + //echo "OKKEY
"; + while($record = pg_fetch_assoc($rs_record)) { + $the_geom = $record['the_geom']; + } + } else { + echo "NESSUN RECORD TROVATO
"; + } + +//CERCA I COMUNI INTERESSATI DALL'INCENDIO + if(!$query_comuni = @pg_query("SELECT comune FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.comune FROM ". + " (SELECT a.the_geom, a.comune FROM public.comuni_italia_3004 a inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$the_geom."') as the_geom) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$the_geom."') as the_geom) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("Errore nella query CERCA COMUNI: " . pg_last_error($conn)); + + while($row_comuni = pg_fetch_assoc($query_comuni)) { + $comuni[] = $row_comuni['comune']; + } + $altricomuni = implode(', ', $comuni); + $valorearray = count($comuni); + for ($val = 0; $val <= $valorearray-1; ++$val) { + // a:4:{i:0;s:5:"false";i:1;s:17:"CANICATTINI BAGNI";i:2;s:4:"NOTO";i:3;s:7:"BUSCEMI";} + $ris[] = "i:".$val.";s:".strlen($comuni[$val]).":\"".$comuni[$val]."\";"; + } + $stringa = implode('', $ris); + $comuni_aib = "a:".$valorearray.":{".$stringa."}"; + //echo $comuni_aib; + + +//CERCA I CATASTALI CHE INTERESSA IL PUNTO + if(!$query_cata = @pg_query("SELECT mappale FROM ". + " (SELECT ST_Intersection(e.the_geom, f.the_geom) as the_geom, e.mappale FROM ". + " (SELECT a.the_geom, a.mappale FROM ".strtolower($_SESSION['COMUNE_BELF']).".particelle a inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$the_geom."') as the_geom) b on ST_Intersects(a.the_geom, b.the_geom)) e inner join ". + " (SELECT ST_GeomFromEWKT('SRID=3004;".$the_geom."') as the_geom) f on ST_Intersects(e.the_geom, f.the_geom)) a;")) + die("ERROR QUERY CATA: " . pg_last_error($conn)); + + while($row_cata = pg_fetch_assoc($query_cata)) { + //$cata[] = substr($row_cata['mappale'],5,20); + $cata[] = $row_cata['mappale']; + } + $cataincendio = implode(', ', $cata); + + +if ($_POST['comune_app'] == ""){ $_POST['comune_app'] = $_SESSION['COMUNE_NAME']; } +if ($_POST['localita'] == ""){ $_POST['localita'] = '-'; } +if ($_POST['indirizzo'] == ""){ $_POST['indirizzo'] = '-'; } +if ($_POST['altri_com'] == ""){ $_POST['altri_com'] = $comuni_aib; } + +if (empty($_POST['dat_segn'])) { + $dat_segn='1970-01-01'; +} else { + $dat_segn= date("Y-m-d", strtotime(str_replace('/', '-', $_POST['dat_segn']))); +} + +if (empty($_POST['dat_infuoc'])) { + $dat_infuoc='1970-01-01'; +} else { + $dat_infuoc= date("Y-m-d", strtotime(str_replace('/', '-', $_POST['dat_infuoc']))); +} + +if (empty($_POST['dat_iniint'])) { + $dat_iniint='1970-01-01'; +} else { + $dat_iniint= date("Y-m-d", strtotime(str_replace('/', '-', $_POST['dat_iniint']))); +} + +if (empty($_POST['dat_finint'])) { + $dat_finint='1970-01-01'; +} else { + $dat_finint= date("Y-m-d", strtotime(str_replace('/', '-', $_POST['dat_finint']))); +} + +if (empty($_POST['dat_redaz'])) { + $dat_redaz='1970-01-01'; +} else { + $dat_redaz= date("Y-m-d", strtotime(str_replace('/', '-', $_POST['dat_redaz']))); +} + +if (empty($_POST['dat_ivf'])) { + $dat_ivf='1970-01-01'; +} else { + $dat_ivf= date("Y-m-d", strtotime(str_replace('/', '-', $_POST['dat_redaz']))); +} + +if ($_POST['time_fuoco'] == ""){ $_POST['time_fuoco'] = 0; } +if ($_POST['time_interv'] == ""){ $_POST['time_interv'] = 0; } +if ($_POST['time_minint'] == ""){ $_POST['time_minint'] = 0; } +if ($_POST['time_lav'] == ""){ $_POST['time_lav'] = 0; } +if ($_POST['tot_sqaib'] == ""){ $_POST['tot_sqaib'] = 0; } +if ($_POST['totsup'] == ""){ $_POST['totsup'] = 0; } +if ($_POST['totsupbosc'] == ""){ $_POST['totsupbosc'] = 0; } +if ($_POST['totsupnnbo'] == ""){ $_POST['totsupnnbo'] = 0; } +if ($_POST['totsupfor'] == ""){ $_POST['totsupfor'] = 0; } +if ($_POST['altresup'] == ""){ $_POST['altresup'] = 0; } +if ($_POST['tipoluog'] == ""){ $_POST['tipoluog'] = '-'; } +if ($_POST['altitud'] == ""){ $_POST['altitud'] = '-'; } +if ($_POST['vento'] == ""){ $_POST['vento'] = '-'; } +if ($_POST['pendenza'] == ""){ $_POST['pendenza'] = '-'; } +if ($_POST['fuoco_prec'] == ""){ $_POST['fuoco_prec'] = '-'; } +if ($_POST['dannobeni'] == ""){ $_POST['dannobeni'] = 0; } +if ($_POST['dannospsri'] == ""){ $_POST['dannospsri'] = 0; } +if ($_POST['dannovalma'] == ""){ $_POST['dannovalma'] = 0; } +if ($_POST['costospegn'] == ""){ $_POST['costospegn'] = 0; } +if ($_POST['sub_evento'] == ""){ $_POST['sub_evento'] = '-'; } +if ($_POST['tot_ferit'] == ""){ $_POST['tot_ferit'] = 0; } +if ($_POST['tot_perit'] == ""){ $_POST['tot_perit'] = 0; } +if ($_POST['rilevatore'] == ""){ $_POST['rilevatore'] = 0; } +if ($_POST['id_forers'] == ""){ $_POST['id_forers'] = 0; } +if ($_POST['note'] == ""){ $_POST['note'] = '-'; } + if(!$rs_update = @pg_query("UPDATE public.incendi SET id_aib=".$_POST['id_aib'].", localita='".$_POST['localita']."', indirizzo='".$_POST['indirizzo']."', altri_com='".$altricomuni."', catasto='".$cataincendio."', dat_segn='".$dat_segn."', dat_infuoc='".$dat_infuoc."', dat_iniint='".$dat_iniint."', dat_finint='".$dat_finint."', dat_redaz='".$dat_redaz."', dat_ivf='".$dat_ivf."', time_fuoco=".$_POST['time_fuoco'].", time_interv=".$_POST['time_interv'].", time_minint=".$_POST['time_minint'].", time_lav=".$_POST['time_lav'].", tot_sqaib=".$_POST['tot_sqaib'].", totsup=".$_POST['totsup'].", totsupbosc=".$_POST['totsupbosc'].", totsupnnbo=".$_POST['totsupnnbo'].", totsupfor=".$_POST['totsupfor'].", altresup=".$_POST['altresup'].", tipoluog='".$_POST['tipoluog']."', altitud='".$_POST['altitud']."', vento='".$_POST['vento']."', pendenza='".$_POST['pendenza']."', fuoco_prec='".$_POST['fuoco_prec']."', dannobeni=".$_POST['dannobeni'].", dannospsri=".$_POST['dannospsri'].", dannovalma=".$_POST['dannovalma'].", costospegn=".$_POST['costospegn'].", sub_evento='".$_POST['sub_evento']."', tot_ferit=".$_POST['tot_ferit'].", tot_perit=".$_POST['tot_perit'].", rilevatore='".$_POST['rilevatore']."', id_forers=".$_POST['id_forers'].", note='".$_POST['note']."', archiviato=0, attivo=1, comune='".$_SESSION['COMUNE_BELF']."', operatore='".$_SESSION['USER_NAME']."', data_agg='".date("Y-m-d h:i:sa", time())."' WHERE id_aib = ".$_SESSION['TABID']."")) + die("ERROR 1: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 2: " . pg_last_error($conn)); + } + $link = 4; +} +//############### FINE PROCEDURA INCENDI ############### + + +//############### INIZIO PROCEDURA ZONING_POI ############### +if ($_SESSION['TAB'] == "zoning_poi") { +if ($mode == "edit") { +if ($_POST['data_update'] == ""){$update=date("Y-m-d",time()); }else{$update= $_POST['data_update']; } + echo "
".$update."
"; + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".zoning_poi SET comune_app = '".$_POST['comune_app']."', localita = '".$_POST['localita']."', catasto ='".$_POST['catasto']."', tipo ='".$_POST['tipo']."', categoria ='".$_POST['categoria']."', codice ='".$_POST['codice']."', denominazione ='".$_POST['denominazione']."', descrizione ='".$_POST['descrizione']."', responsabile ='".$_POST['responsabile']."', data_update = '".$update."', archiviato = false, attivo=1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg = '".date("Y-m-d h:i:sa", time())."' WHERE poi_id = ".$_SESSION['TABID']."")) + die("ERROR 3: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 4: " . pg_last_error($conn)); + } + $link = 4; +} +//############### FINE PROCEDURA ZONING_POI ############### + + +//############### INIZIO PROCEDURA OBJPOINT ############### +if ($_SESSION['TAB'] == "objpoint") { +if ($mode == "edit") { + +if ($_POST['id_obj'] == ""){ $_POST['id_obj'] = 0; } +if ($_POST['codice'] == ""){ $_POST['codice'] = '-'; } +if ($_POST['comune_app'] == ""){ $_POST['comune_app'] = '-'; } +if ($_POST['localita'] == ""){ $_POST['localita'] = '-'; } else { $_POST['localita'] = str_replace("'", "’" ,$_POST['localita']); } +if ($_POST['quartiere'] == ""){ $_POST['quartiere'] = '-'; } else { $_POST['quartiere'] = str_replace("'", "’" ,$_POST['quartiere']); } +if ($_POST['catasto'] == ""){ $_POST['catasto'] = '-'; } +if ($_POST['centro_abi'] == ''){ $_POST['centro_abi'] = '-'; } +if ($_POST['tipo_edi'] == ''){ $_POST['tipo_edi'] = '-'; } +if ($_POST['tipologia'] == ""){ $_POST['tipologia'] = '-'; } else { $_POST['tipologia'] = str_replace("'", "’" ,$_POST['tipologia']); } +if ($_POST['categoria'] == ""){ $_POST['categoria'] = '-'; } else { $_POST['categoria'] = str_replace("'", "’" ,$_POST['categoria']); } +if ($_POST['settore'] == ""){ $_POST['settore'] = '-'; } else { $_POST['settore'] = str_replace("'", "’" ,$_POST['settore']); } +if ($_POST['denominazi'] == ""){ $_POST['denominazi'] = '-'; } else { $_POST['denominazi'] = str_replace("'", "’" ,$_POST['denominazi']); } +if ($_POST['indirizzo'] == ""){ $_POST['indirizzo'] = '-'; } else { $_POST['indirizzo'] = str_replace("'", "’" ,$_POST['indirizzo']); } +if ($_POST['referente'] == ""){ $_POST['referente'] = '-'; } else { $_POST['referente'] = str_replace("'", "’" ,$_POST['referente']); } +if ($_POST['ref_email'] == ""){ $_POST['ref_email'] = '-'; } +if ($_POST['ref_tel'] == ""){ $_POST['ref_tel'] = '-'; } +if ($_POST['ref_mob'] == ""){ $_POST['ref_mob'] = '-'; } +if ($_POST['postilet'] == ""){ $_POST['postilet'] = 0; } +if ($_POST['popolazi'] == ""){ $_POST['popolazi'] = 0; } +if ($_POST['presid_med'] == ""){ $_POST['presid_med'] = 0; } +if ($_POST['presid_mil'] == ""){ $_POST['presid_mil'] = 0; } +if ($_POST['pres_diur'] == ""){ $_POST['pres_diur'] = 0; } +if ($_POST['pres_nott'] == ""){ $_POST['pres_nott'] = 0; } +if ($_POST['struttura'] == ""){ $_POST['struttura'] = '-'; } +if ($_POST['sostanze'] == ""){ $_POST['sostanze'] = '-'; } +if ($_POST['proprieta'] == ""){ $_POST['proprieta'] = '-'; } +if ($_POST['plesso'] == ""){ $_POST['plesso'] = '-'; } +if ($_POST['tel_scuo'] == ""){ $_POST['tel_scuo'] = '-'; } +if ($_POST['fax_scuo'] == ""){ $_POST['fax_scuo'] = '-'; } +if ($_POST['email_scuo'] == ""){ $_POST['email_scuo'] = '-'; } +if ($_POST['responsab'] == ""){ $_POST['responsab'] = '-'; } else { $_POST['responsab'] = str_replace("'", "’" ,$_POST['responsab']); } +if ($_POST['resp_email'] == ""){ $_POST['resp_email'] = '-'; } +if ($_POST['resp_tel'] == ""){ $_POST['resp_tel'] = '-'; } +if ($_POST['resp_mob'] == ""){ $_POST['resp_mob'] = '-'; } +if ($_POST['key1'] == ""){ $_POST['key1'] = '-'; } else { $_POST['key1'] = str_replace("'", "’" ,$_POST['key1']); } +if ($_POST['key1_email'] == ""){ $_POST['key1_email'] = '-'; } +if ($_POST['key1_tel'] == ""){ $_POST['key1_tel'] = '-'; } +if ($_POST['key1_mob'] == ""){ $_POST['key1_mob'] = '-'; } +if ($_POST['key2'] == ""){ $_POST['key2'] = '-'; } else { $_POST['key2'] = str_replace("'", "’" ,$_POST['key2']); } +if ($_POST['key2_email'] == ""){ $_POST['key2_email'] = '-'; } +if ($_POST['key2_tel'] == ""){ $_POST['key2_tel'] = '-'; } +if ($_POST['key2_mob'] == ""){ $_POST['key2_mob'] = '-'; } +if ($_POST['loc_aule'] == ""){ $_POST['loc_aule'] = 0; } +if ($_POST['loc_inform'] == ""){ $_POST['loc_inform'] = 0; } +if ($_POST['loc_riunio'] == ""){ $_POST['loc_riunio'] = 0; } +if ($_POST['loc_inferm'] == ""){ $_POST['loc_inferm'] = 0; } +if ($_POST['loc_palest'] == ""){ $_POST['loc_palest'] = 0; } +if ($_POST['loc_mensa'] == ""){ $_POST['loc_mensa'] = 0; } +if ($_POST['pop_docent'] == ""){ $_POST['pop_docent'] = 0; } +if ($_POST['pop_segret'] == ""){ $_POST['pop_segret'] = 0; } +if ($_POST['pop_ata'] == ""){ $_POST['pop_ata'] = 0; } +if ($_POST['pop_alunni'] == ""){ $_POST['pop_alunni'] = 0; } +if ($_POST['pop_hfisic'] == ""){ $_POST['pop_hfisic'] = 0; } +if ($_POST['pop_hpsich'] == ""){ $_POST['pop_hpsich'] = 0; } +if ($_POST['antincendi'] == ""){ $_POST['antincendi'] = '-'; } +if ($_POST['generatore'] == ""){ $_POST['generatore'] = '-'; } +if ($_POST['caldaia'] == ""){ $_POST['caldaia'] = '-'; } +if ($_POST['gas'] == ""){ $_POST['gas'] = '-'; } +if ($_POST['radio'] == ""){ $_POST['radio'] = '-'; } +if ($_POST['internet'] == ""){ $_POST['internet'] = '-'; } +if ($_POST['piano_emer'] == ""){ $_POST['piano_emer'] = '-'; } else { $_POST['piano_emer'] = str_replace("'", "’" ,$_POST['piano_emer']); } +if ($_POST['area_attes'] == ""){ $_POST['area_attes'] = '-'; } +if ($_POST['interna'] == ""){ $_POST['interna'] = '-'; } +if ($_POST['esterna'] == ""){ $_POST['esterna'] = '-'; } +if ($_POST['indir_area'] == ""){ $_POST['indir_area'] = '-'; } else { $_POST['indir_area'] = str_replace("'", "’" ,$_POST['indir_area']); } +if ($_POST['ris_indu'] == 0){ $_POST['ris_indu'] = 0; } +if ($_POST['ris_sism'] == 0){ $_POST['ris_sism'] = 0; } +if ($_POST['ris_tsun'] == 0){ $_POST['ris_tsun'] = 0; } +if ($_POST['ris_idro'] == 0){ $_POST['ris_idro'] = 0; } +if ($_POST['ris_ince'] == 0){ $_POST['ris_ince'] = 0; } +if ($_POST['ris_nucl'] == 0){ $_POST['ris_nucl'] = 0; } +if ($_POST['ris_rir'] == 0){ $_POST['ris_rir'] = 0; } +if ($_POST['note'] == ""){ $_POST['note'] = '-'; } else { $_POST['note'] = str_replace("'", "’" ,$_POST['note']); } + +/* */ + echo 'id_obj = '.$_POST['id_obj'].'
'; + echo 'codice = '.$_POST['codice'].'
'; + echo 'comune_app = '.$_POST['comune_app'].'
'; + echo 'localita = '.$_POST['localita'].'
'; + echo 'quartiere = '.$_POST['quartiere'].'
'; + echo 'catasto = '.$_POST['catasto'].'
'; + echo 'centro_abi = '.$_POST['centro_abi'].'
'; + echo 'tipo_edi = '.$_POST['tipo_edi'].'
'; + echo 'tipologia = '.$_POST['tipologia'].'
'; + echo 'categoria = '.$_POST['categoria'].'
'; + echo 'settore = '.$_POST['settore'].'
'; + echo 'denominazi = '.$_POST['denominazi'].'
'; + echo 'indirizzo = '.$_POST['indirizzo'].'
'; + echo 'referente = '.$_POST['referente'].'
'; + echo 'ref_email = '.$_POST['ref_email'].'
'; + echo 'ref_tel = '.$_POST['ref_tel'].'
'; + echo 'ref_mob = '.$_POST['ref_mob'].'
'; + echo 'postilet = '.$_POST['postilet'].'
'; + echo 'popolazi = '.$_POST['popolazi'].'
'; + echo 'presid_med = '.$_POST['presid_med'].'
'; + echo 'presid_mil = '.$_POST['presid_mil'].'
'; + echo 'pres_diur = '.$_POST['pres_diur'].'
'; + echo 'pres_nott = '.$_POST['pres_nott'].'
'; + echo 'struttura = '.$_POST['struttura'].'
'; + echo 'sostanze = '.$_POST['sostanze'].'
'; + echo 'proprieta = '.$_POST['proprieta'].'
'; + echo 'plesso = '.$_POST['plesso'].'
'; + echo 'tel_scuo = '.$_POST['tel_scuo'].'
'; + echo 'fax_scuo = '.$_POST['fax_scuo'].'
'; + echo 'email_scuo = '.$_POST['email_scuo'].'
'; + echo 'responsab = '.$_POST['responsab'].'
'; + echo 'resp_email = '.$_POST['resp_email'].'
'; + echo 'resp_tel = '.$_POST['resp_tel'].'
'; + echo 'resp_mob = '.$_POST['resp_mob'].'
'; + echo 'key1 = '.$_POST['key1'].'
'; + echo 'key1_email = '.$_POST['key1_email'].'
'; + echo 'key1_tel = '.$_POST['key1_tel'].'
'; + echo 'key1_mob = '.$_POST['key1_mob'].'
'; + echo 'key2 = '.$_POST['key2'].'
'; + echo 'key2_email = '.$_POST['key2_email'].'
'; + echo 'key2_tel = '.$_POST['key2_tel'].'
'; + echo 'key2_mob = '.$_POST['key2_mob'].'
'; + echo 'loc_aule = '.$_POST['loc_aule'].'
'; + echo 'loc_inform = '.$_POST['loc_inform'].'
'; + echo 'loc_riunio = '.$_POST['loc_riunio'].'
'; + echo 'loc_inferm = '.$_POST['loc_inferm'].'
'; + echo 'loc_palest = '.$_POST['loc_palest'].'
'; + echo 'loc_mensa = '.$_POST['loc_mensa'].'
'; + echo 'pop_docent = '.$_POST['pop_docent'].'
'; + echo 'pop_segret = '.$_POST['pop_segret'].'
'; + echo 'pop_ata = '.$_POST['pop_ata'].'
'; + echo 'pop_alunni = '.$_POST['pop_alunni'].'
'; + echo 'pop_hfisic = '.$_POST['pop_hfisic'].'
'; + echo 'pop_hpsich = '.$_POST['pop_hpsich'].'
'; + echo 'antincendi = '.$_POST['antincendi'].'
'; + echo 'generatore = '.$_POST['generatore'].'
'; + echo 'caldaia = '.$_POST['caldaia'].'
'; + echo 'gas = '.$_POST['gas'].'
'; + echo 'radio = '.$_POST['radio'].'
'; + echo 'internet = '.$_POST['internet'].'
'; + echo 'piano_emer = '.$_POST['piano_emer'].'
'; + echo 'area_attes = '.$_POST['area_attes'].'
'; + echo 'interna = '.$_POST['interna'].'
'; + echo 'esterna = '.$_POST['esterna'].'
'; + echo 'indir_area = '.$_POST['indir_area'].'
'; + echo 'ris_indu = '.$_POST['ris_indu'].'
'; + echo 'ris_sism = '.$_POST['ris_sism'].'
'; + echo 'ris_tsun = '.$_POST['ris_tsun'].'
'; + echo 'ris_idro = '.$_POST['ris_idro'].'
'; + echo 'ris_ince = '.$_POST['ris_ince'].'
'; + echo 'ris_nucl = '.$_POST['ris_nucl'].'
'; + echo 'ris_rir = '.$_POST['ris_rir'].'
'; + echo 'note = '.$_POST['note'].'
'; + + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".objpoint SET codice='".$_POST['codice']."', comune_app='".$_POST['comune_app']."', localita='".$_POST['localita']."', quartiere='".$_POST['quartiere']."', catasto='".$_POST['catasto']."', centro_abi='".$_POST['centro_abi']."', tipo_edi='".$_POST['tipo_edi']."', tipologia='".$_POST['tipologia']."', categoria='".$_POST['categoria']."', settore='".$_POST['settore']."', denominazi='".$_POST['denominazi']."', indirizzo='".$_POST['indirizzo']."', referente='".$_POST['referente']."', ref_email='".$_POST['ref_email']."', ref_tel='".$_POST['ref_tel']."', ref_mob='".$_POST['ref_mob']."', postilet=".$_POST['postilet'].", popolazi=".$_POST['popolazi'].", presid_med=".$_POST['presid_med'].", presid_mil=".$_POST['presid_mil'].", pres_diur=".$_POST['pres_diur'].", pres_nott=".$_POST['pres_nott'].", struttura='".$_POST['struttura']."', sostanze='".$_POST['sostanze']."', proprieta='".$_POST['proprieta']."', plesso='".$_POST['plesso']."', tel_scuo='".$_POST['tel_scuo']."', fax_scuo='".$_POST['fax_scuo']."', email_scuo='".$_POST['email_scuo']."', responsab='".$_POST['responsab']."', resp_email='".$_POST['resp_email']."', resp_tel='".$_POST['resp_tel']."', resp_mob='".$_POST['resp_mob']."', key1='".$_POST['key1']."', key1_email='".$_POST['key1_email']."', key1_tel='".$_POST['key1_tel']."', key1_mob='".$_POST['key1_mob']."', key2='".$_POST['key2']."', key2_email='".$_POST['key2_email']."', key2_tel='".$_POST['key2_tel']."', key2_mob='".$_POST['key2_mob']."', loc_aule=".$_POST['loc_aule'].", loc_inform=".$_POST['loc_inform'].", loc_riunio=".$_POST['loc_riunio'].", loc_inferm=".$_POST['loc_inferm'].", loc_palest=".$_POST['loc_palest'].", loc_mensa=".$_POST['loc_mensa'].", pop_docent=".$_POST['pop_docent'].", pop_segret=".$_POST['pop_segret'].", pop_ata=".$_POST['pop_ata'].", pop_alunni=".$_POST['pop_alunni'].", pop_hfisic=".$_POST['pop_hfisic'].", pop_hpsich=".$_POST['pop_hpsich'].", antincendi='".$_POST['antincendi']."', generatore='".$_POST['generatore']."', caldaia='".$_POST['caldaia']."', gas='".$_POST['gas']."', radio='".$_POST['radio']."', internet='".$_POST['internet']."', piano_emer='".$_POST['piano_emer']."', area_attes='".$_POST['area_attes']."', interna='".$_POST['interna']."', esterna='".$_POST['esterna']."', indir_area='".$_POST['indir_area']."', ris_indu=".$_POST['ris_indu'].", ris_sism=".$_POST['ris_sism'].", ris_tsun=".$_POST['ris_tsun'].", ris_idro=".$_POST['ris_idro'].", ris_ince=".$_POST['ris_ince'].", ris_nucl=".$_POST['ris_nucl'].", ris_rir=".$_POST['ris_rir'].", note='".$_POST['note']."', archiviato = 0, attivo=1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg = '".date("Y-m-d h:i:sa", time())."' WHERE id_obj = ".$_SESSION['TABID']."")) + die("ERROR OBJPOINT: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 5: " . pg_last_error($conn)); + } + $link = 4; +} +//############### FINE PROCEDURA OBJPOINT ############### + + +//############### INIZIO PROCEDURA OBJGATE ############### +if ($_SESSION['TAB'] == "objgate") { + if ($mode == "edit") { + + if ($_POST['id_obj'] == ""){ $_POST['id_obj'] = 0; } + if ($_POST['codice'] == ""){ $_POST['codice'] = '-'; } + if ($_POST['comune_app'] == ""){ $_POST['comune_app'] = '-'; } else { $_POST['comune_app'] = str_replace("'", "’" ,$_POST['comune_app']); } + if ($_POST['localita'] == ""){ $_POST['localita'] = '-'; } else { $_POST['localita'] = str_replace("'", "’" ,$_POST['localita']); } + if ($_POST['tipo'] == ""){ $_POST['tipo'] = '-'; } + if ($_POST['namegate'] == ""){ $_POST['namegate'] = '-'; } else { $_POST['namegate'] = str_replace("'", "’" ,$_POST['namegate']); } + if ($_POST['scenario'] == ""){ $_POST['scenario'] = '-'; } else { $_POST['scenario'] = str_replace("'", "’" ,$_POST['scenario']); } + if ($_POST['titolari'] == ""){ $_POST['titolari'] = '-'; } else { $_POST['titolari'] = str_replace("'", "’" ,$_POST['titolari']); } + if ($_POST['azioni'] == ""){ $_POST['azioni'] = '-'; } else { $_POST['azioni'] = str_replace("'", "’" ,$_POST['azioni']); } + if ($_POST['tipo_risch'] == ""){ $_POST['tipo_risch'] = '-'; } + if ($_POST['note'] == ""){ $_POST['note'] = '-'; } else { $_POST['note'] = str_replace("'", "’" ,$_POST['note']); } + + + /* */ + echo 'id_obj = '.$_POST['id_obj'].'
'; + echo 'the_geom = '.$_POST['the_geom'].'
'; + echo 'codice = '.$_POST['codice'].'
'; + echo 'comune_app = '.$_POST['comune_app'].'
'; + echo 'localita = '.$_POST['localita'].'
'; + echo 'tipo = '.$_POST['tipo'].'
'; + echo 'namegate = '.$_POST['namegate'].'
'; + echo 'scenario = '.$_POST['scenario'].'
'; + echo 'titolari = '.$_POST['titolari'].'
'; + echo 'azioni = '.$_POST['azioni'].'
'; + echo 'tipo_risch = '.$_POST['tipo_risch'].'
'; + echo 'note = '.$_POST['note'].'
'; + echo 'archiviato = '.$_POST['archiviato'].'
'; + echo 'attivo = '.$_POST['attivo'].'
'; + echo 'comune = '.$_POST['comune'].'
'; + echo 'operatore = '.$_POST['operatore'].'
'; + echo 'data_agg = '.$_POST['data_agg'].'
'; + + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".objgate SET codice='".$_POST['codice']."', comune_app='".$_POST['comune_app']."', localita='".$_POST['localita']."', tipo='".$_POST['tipo']."', namegate='".$_POST['namegate']."', scenario='".$_POST['scenario']."', titolari='".$_POST['titolari']."', azioni='".$_POST['azioni']."', tipo_risch='".$_POST['tipo_risch']."', note='".$_POST['note']."', archiviato = 0, attivo=1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg = '".date("Y-m-d h:i:sa", time())."' WHERE id_obj = ".$_SESSION['TABID']."")) + die("ERROR OBJPOINT: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 5: " . pg_last_error($conn)); + } + $link = 4; + } +//############### FINE PROCEDURA OBJGATE ############### + +//############### INIZIO PROCEDURA OBJLINE ############### +if ($_SESSION['TAB'] == "objline") { +if ($mode == "edit") { +if ($_POST['data_update'] == ""){$update=date("Y-m-d",time()); }else{$update= $_POST['data_update']; } + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".objline SET comune_app = '".$_POST['comune_app']."', localita = '".$_POST['localita']."', catasto ='".$_POST['catasto']."', tipo ='".$_POST['tipo']."', categoria ='".$_POST['categoria']."', codice ='".$_POST['codice']."', denominazione ='".$_POST['denominazione']."', toponimo ='".$_POST['toponimo']."', lunghezza =".$_POST['lunghezza'].", descrizione ='".$_POST['descrizione']."', responsabile ='".$_POST['responsabile']."', recapito ='".$_POST['recapito']."', data_update = '".$update."', archiviato = false, attivo=1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg = '".date("Y-m-d h:i:sa", time())."' WHERE id_obj = ".$_SESSION['TABID']."")) + die("ERROR 6: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 7: " . pg_last_error($conn)); + } + $link = 4; +} +//############### FINE PROCEDURA OBJLINE ############### + + +//############### INIZIO PROCEDURA OBJAREA ############### +if ($_SESSION['TAB'] == "objarea") { +if ($mode == "edit") { + +if ($_POST['comune_app'] == ""){ $_POST['comune_app'] = '-'; } +if ($_POST['localita'] == ""){ $_POST['localita'] = '-'; } else { $_POST['localita'] = str_replace("'", "’" ,$_POST['localita']); } +if ($_POST['quartiere'] == ""){ $_POST['quartiere'] = '-'; } else { $_POST['quartiere'] = str_replace("'", "’" ,$_POST['quartiere']); } +if ($_POST['catasto'] == ""){ $_POST['catasto'] = '-'; } +if ($_POST['codice'] == ""){ $_POST['codice'] = '-'; } +if ($_POST['tipo'] == ""){ $_POST['tipo'] = '-'; } +if ($_POST['stato_area'] == ""){ $_POST['stato_area'] = 0; } +if ($_POST['usoattuale'] == ""){ $_POST['usoattuale'] = '-'; } +if ($_POST['denominazi'] == ""){ $_POST['denominazi'] = '-'; } else { $_POST['denominazi'] = str_replace("'", "’" ,$_POST['denominazi']); } +if ($_POST['indirizzo'] == ""){ $_POST['indirizzo'] = '-'; } else { $_POST['indirizzo'] = str_replace("'", "’" ,$_POST['indirizzo']); } +if ($_POST['proprieta'] == ""){ $_POST['proprieta'] = '-'; } +if ($_POST['capienza'] == ""){ $_POST['capienza'] = 0; } +if ($_POST['referente'] == ""){ $_POST['referente'] = '-'; } else { $_POST['referente'] = str_replace("'", "’" ,$_POST['referente']); } +if ($_POST['ref_email'] == ""){ $_POST['ref_email'] = '-'; } +if ($_POST['ref_tel'] == ""){ $_POST['ref_tel'] = '-'; } +if ($_POST['reperibilita'] == ""){ $_POST['reperibilita'] = 'false'; }else{ $_POST['reperibilita'] = 'true';} +if ($_POST['area_totale'] == ""){ $_POST['area_totale'] = 0; } +if ($_POST['area_coperta'] == ""){ $_POST['area_coperta'] = 0; } +if ($_POST['area_disserbo'] == ""){ $_POST['area_disserbo'] = 0; } +if ($_POST['area_limitrofe'] == ""){ $_POST['area_limitrofe'] = 0; } +if ($_POST['pendenza'] == ""){ $_POST['pendenza'] = '-'; } +if ($_POST['dest_prg'] == ""){ $_POST['dest_prg'] = '-'; } +if ($_POST['accessi_viaria'] == ""){ $_POST['accessi_viaria'] = 0; } +if ($_POST['accesso_denom'] == ""){ $_POST['accesso_denom'] = '-'; } else { $_POST['accesso_denom'] = str_replace("'", "’" ,$_POST['accesso_denom']); } +if ($_POST['accesso_carrabile'] == ""){ $_POST['accesso_carrabile'] = 'false'; }else{ $_POST['accesso_carrabile'] = 'true';} +if ($_POST['accesso_inf4m'] == ""){ $_POST['accesso_inf4m'] = 'false'; }else{ $_POST['accesso_inf4m'] = 'true';} +if ($_POST['spazi_aperti'] == ""){ $_POST['spazi_aperti'] = 'false'; }else{ $_POST['spazi_aperti'] = 'true';} +if ($_POST['accesso_pedonale'] == ""){ $_POST['accesso_pedonale'] = 'false'; }else{ $_POST['accesso_pedonale'] = 'true';} +if ($_POST['accesso_mezzipesa'] == ""){ $_POST['accesso_mezzipesa'] = 'false'; }else{ $_POST['accesso_mezzipesa'] = 'true';} +if ($_POST['viab_idonea'] == ""){ $_POST['viab_idonea'] = 'false'; }else{ $_POST['viab_idonea'] = 'true';} +if ($_POST['accesso_elisup'] == ""){ $_POST['accesso_elisup'] = 'false'; }else{ $_POST['accesso_elisup'] = 'true';} +if ($_POST['accesso_park'] == ""){ $_POST['accesso_park'] = 'false'; }else{ $_POST['accesso_park'] = 'true';} +if ($_POST['accesso_parkn'] == ""){ $_POST['accesso_parkn'] = '-'; } +if ($_POST['rete_idr'] == ""){ $_POST['rete_idr'] = 0; } +if ($_POST['rete_ele'] == ""){ $_POST['rete_ele'] = 0; } +if ($_POST['rete_tel'] == ""){ $_POST['rete_tel'] = 0; } +if ($_POST['rete_gas'] == ""){ $_POST['rete_gas'] = 0; } +if ($_POST['rete_fogna'] == ""){ $_POST['rete_fogna'] = 0; } +if ($_POST['rete_illum'] == ""){ $_POST['rete_illum'] = 0; } +if ($_POST['fabbricati'] == ""){ $_POST['fabbricati'] = 'false'; }else{ $_POST['fabbricati'] = 'true';} +if ($_POST['servizi_igenici'] == ""){ $_POST['servizi_igenici'] = 'false'; }else{ $_POST['servizi_igenici'] = 'true';} +if ($_POST['moduli_max'] == ""){ $_POST['moduli_max'] = 0; } +if ($_POST['tende_max'] == ""){ $_POST['tende_max'] = 0; } +if ($_POST['pavimentazione'] == ""){ $_POST['pavimentazione'] = 0; } +if ($_POST['idonea_rischi'] == ""){ $_POST['idonea_rischi'] = 'false'; }else{ $_POST['idonea_rischi'] = 'true';} +if ($_POST['note'] == ""){ $_POST['note'] = '-'; } else { $_POST['note'] = str_replace("'", "’" ,$_POST['note']); } +if ($_POST['data_update'] == ""){ $_POST['data_update'] = '-'; } + + /* + echo 'id_obj = '.$_POST['id_obj'].'
'; + echo 'comune_app = '.$_POST['comune_app'].'
'; + echo 'localita = '.$_POST['localita'].'
'; + echo 'quartiere = '.$_POST['quartiere'].'
'; + echo 'catasto = '.$_POST['catasto'].'
'; + echo 'codice = '.$_POST['codice'].'
'; + echo 'tipo = '.$_POST['tipo'].'
'; + echo 'stato_area = '.$_POST['stato_area'].'
'; + echo 'usoattuale = '.$_POST['usoattuale'].'
'; + echo 'denominazi = '.$_POST['denominazi'].'
'; + echo 'indirizzo = '.$_POST['indirizzo'].'
'; + echo 'proprieta = '.$_POST['proprieta'].'
'; + echo 'capienza = '.$_POST['capienza'].'
'; + echo 'referente = '.$_POST['referente'].'
'; + echo 'ref_email = '.$_POST['ref_email'].'
'; + echo 'ref_tel = '.$_POST['ref_tel'].'
'; + echo 'reperibilita = '.$_POST['reperibilita'].'
'; + echo 'area_totale = '.$_POST['area_totale'].'
'; + echo 'area_coperta = '.$_POST['area_coperta'].'
'; + echo 'area_disserbo = '.$_POST['area_disserbo'].'
'; + echo 'area_limitrofe = '.$_POST['area_limitrofe'].'
'; + echo 'pendenza = '.$_POST['pendenza'].'
'; + echo 'dest_prg = '.$_POST['dest_prg'].'
'; + echo 'accessi_viaria = '.$_POST['accessi_viaria'].'
'; + echo 'accesso_denom = '.$_POST['accesso_denom'].'
'; + echo 'accesso_carrabile = '.$_POST['accesso_carrabile'].'
'; + echo 'accesso_inf4m = '.$_POST['accesso_inf4m'].'
'; + echo 'spazi_aperti = '.$_POST['spazi_aperti'].'
'; + echo 'accesso_pedonale = '.$_POST['accesso_pedonale'].'
'; + echo 'accesso_mezzipesa = '.$_POST['accesso_mezzipesa'].'
'; + echo 'viab_idonea = '.$_POST['viab_idonea'].'
'; + echo 'accesso_elisup = '.$_POST['accesso_elisup'].'
'; + echo 'accesso_park = '.$_POST['accesso_park'].'
'; + echo 'accesso_parkn = '.$_POST['accesso_parkn'].'
'; + echo 'rete_idr = '.$_POST['rete_idr'].'
'; + echo 'rete_ele = '.$_POST['rete_ele'].'
'; + echo 'rete_tel = '.$_POST['rete_tel'].'
'; + echo 'rete_gas = '.$_POST['rete_gas'].'
'; + echo 'rete_fogna = '.$_POST['rete_fogna'].'
'; + echo 'rete_illum = '.$_POST['rete_illum'].'
'; + echo 'fabbricati = '.$_POST['fabbricati'].'
'; + echo 'servizi_igenici = '.$_POST['servizi_igenici'].'
'; + echo 'moduli_max = '.$_POST['moduli_max'].'
'; + echo 'tende_max = '.$_POST['tende_max'].'
'; + echo 'pavimentazione = '.$_POST['pavimentazione'].'
'; + echo 'idonea_rischi = '.$_POST['idonea_rischi'].'
'; + echo 'note = '.$_POST['note'].'
'; + echo 'data_update = '.$_POST['data_update'].'
'; + echo 'archiviato = '.$_POST['archiviato'].'
'; + echo 'attivo = '.$_POST['attivo'].'
'; + echo 'comune = '.$_POST['comune'].'
'; + echo 'operatore = '.$_POST['operatore'].'
'; + echo 'data_agg = '.$_POST['data_agg'].'
'; + echo 'the_geom = '.$_POST['the_geom'].'
'; + + */ +if ($_POST['data_update'] == ""){$update=date("d-m-Y",time()); } else {$update=$_POST['data_update']; } + + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".objarea SET comune_app='".$_SESSION['COMUNE_NAME']."', localita='".$_POST['localita']."', quartiere='".$_POST['quartiere']."', catasto='".$_POST['catasto']."', codice='".$_POST['codice']."', tipo='".$_POST['tipo']."', stato_area=".$_POST['stato_area'].", usoattuale='".$_POST['usoattuale']."', denominazi='".$_POST['denominazi']."', indirizzo='".$_POST['indirizzo']."', proprieta='".$_POST['proprieta']."', capienza=".$_POST['capienza'].", referente='".$_POST['referente']."', ref_email='".$_POST['ref_email']."', ref_tel='".$_POST['ref_tel']."', reperibilita='".$_POST['reperibilita']."', area_totale=".$_POST['area_totale'].", area_coperta=".$_POST['area_coperta'].", area_disserbo=".$_POST['area_disserbo'].", area_limitrofe=".$_POST['area_limitrofe'].", pendenza='".$_POST['pendenza']."', dest_prg='".$_POST['dest_prg']."', accessi_viaria=".$_POST['accessi_viaria'].", accesso_denom='".$_POST['accesso_denom']."', accesso_carrabile='".$_POST['accesso_carrabile']."', accesso_inf4m='".$_POST['accesso_inf4m']."', spazi_aperti='".$_POST['spazi_aperti']."', accesso_pedonale='".$_POST['accesso_pedonale']."', accesso_mezzipesa='".$_POST['accesso_mezzipesa']."', viab_idonea='".$_POST['viab_idonea']."', accesso_elisup='".$_POST['accesso_elisup']."', accesso_park='".$_POST['accesso_park']."', accesso_parkn='".$_POST['accesso_parkn']."', rete_idr=".$_POST['rete_idr'].", rete_ele=".$_POST['rete_ele'].", rete_tel=".$_POST['rete_tel'].", rete_gas=".$_POST['rete_gas'].", rete_fogna=".$_POST['rete_fogna'].", rete_illum=".$_POST['rete_illum'].", fabbricati='".$_POST['fabbricati']."', servizi_igenici='".$_POST['servizi_igenici']."', moduli_max=".$_POST['moduli_max'].", tende_max=".$_POST['tende_max'].", pavimentazione=".$_POST['pavimentazione'].", idonea_rischi='".$_POST['idonea_rischi']."', note='".$_POST['note']."', data_update='".$_POST['data_update']."', archiviato = false, attivo=1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg = '".date("Y-m-d h:i:sa", time())."' WHERE id_obj = ".$_SESSION['TABID']."")) + die("ERROR 8: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 9: " . pg_last_error($conn)); + } + $link = 4; +} +//############### FINE PROCEDURA OBJAREA ############### + + +//############### INIZIO PROCEDURA OBJSOGGETTI ############### +if ($_SESSION['TAB'] == "objsoggetti") { + +if ($_POST['comune_app'] == ""){ $_POST['comune_app'] = '-'; } +if ($_POST['localita'] == ""){ $_POST['localita'] = '-'; } else { $_POST['localita'] = str_replace("'", "’" ,$_POST['localita']); } +if ($_POST['quartiere'] == ""){ $_POST['quartiere'] = '-'; } else { $_POST['quartiere'] = str_replace("'", "’" ,$_POST['quartiere']); } +if ($_POST['catasto'] == ""){ $_POST['catasto'] = '-'; } +if ($_POST['nominativo'] == ""){ $_POST['nominativo'] = '-'; } else { $_POST['nominativo'] = str_replace("'", "’" ,$_POST['nominativo']); } +if ($_POST['nascita'] == ""){ $_POST['nascita'] = '-'; } else { $_POST['nascita'] = str_replace("'", "’" ,$_POST['nascita']); } +if ($_POST['indirizzo'] == ""){ $_POST['indirizzo'] = '-'; } else { $_POST['indirizzo'] = str_replace("'", "’" ,$_POST['indirizzo']); } +if ($_POST['stato'] == ""){ $_POST['stato'] = '-'; } else { $_POST['stato'] = str_replace("'", "’" ,$_POST['stato']); } +if ($_POST['sesso'] == ""){ $_POST['sesso'] = '-'; } +if ($_POST['struttura'] == ""){ $_POST['struttura'] = '-'; } else { $_POST['struttura'] = str_replace("'", "’" ,$_POST['struttura']); } +if ($_POST['resp'] == ""){ $_POST['resp'] = '-'; } else { $_POST['resp'] = str_replace("'", "’" ,$_POST['resp']); } +if ($_POST['resp_rel'] == ""){ $_POST['resp_rel'] = '-'; } else { $_POST['resp_rel'] = str_replace("'", "’" ,$_POST['resp_rel']); } +if ($_POST['note'] == ""){ $_POST['note'] = '-'; } else { $_POST['note'] = str_replace("'", "’" ,$_POST['note']); } + +if ($mode == "edit") { + + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".objsoggetti SET comune_app='".$_POST['comune_app']."', localita='".$_POST['localita']."', quartiere='".$_POST['quartiere']."', catasto='".$_POST['catasto']."', nominativo='".$_POST['nominativo']."', nascita='".$_POST['nascita']."', indirizzo='".$_POST['indirizzo']."', stato='".$_POST['stato']."', sesso='".$_POST['sesso']."', struttura='".$_POST['struttura']."', resp='".$_POST['resp']."', resp_rel='".$_POST['resp_rel']."', note='".$_POST['note']."', archiviato = 0, attivo = 1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg = '".date("Y-m-d h:i:sa", time())."' WHERE id_obj = ".$_SESSION['TABID']."")) + die("ERROR 1: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 10: " . pg_last_error($conn)); + } + $link = 4; +} +//############### FINE PROCEDURA OBJSOGGETTI ############### + +//############### INIZIO PROCEDURA CERTIFICATI ############### +if ($_SESSION['TAB'] == "certificazioni") { +echo $mode."
"; +echo $_POST['certif_data']."
"; +//$certif_note = str_replace("'", "\'", $_POST['certif_note']); +if ($_POST['certif_tipo'] == ""){ $_POST['certif_tipo'] = 'Certificato di Destinazione Urbanistica'; } +if ($_POST['certif_numero'] == ""){ $_POST['certif_numero'] = 0; } +//if ($_POST['certif_data'] == ""){ $_POST['certif_data'] = 0; } +$date1 = str_replace('/', '-', $_POST['certif_data']); +if (!empty($_POST['certif_data'])){$certif_data=date("Y-m-d", strtotime($date1));} + +if ($_POST['certif_prot_istanza'] == ""){ $_POST['certif_prot_istanza'] = '-'; } +$date2 = str_replace('/', '-', $_POST['certif_data_istanza']); +if (!empty($_POST['certif_data_istanza'])){$certif_data_istanza=date("Y-m-d", strtotime($date2));} + +if ($_POST['certif_catasto'] == ""){ $_POST['certif_catasto'] = '-'; } +if ($_POST['certif_note'] == ""){ $_POST['certif_note'] = '-'; }else{$_POST['certif_note'] = str_replace("'", "’" ,$_POST['certif_note']);} +if ($_POST['certif_rilasciato'] == ""){ $_POST['certif_rilasciato'] = 0; } +if ($_POST['richied_id'] == ""){ $_POST['richied_id'] = 0; } +if ($_POST['richied_nome'] == ""){ $_POST['richied_nome'] = '-'; }else{$_POST['richied_nome'] = str_replace("'", "’" ,$_POST['richied_nome']);} +if ($_POST['richied_cognome'] == ""){ $_POST['richied_cognome'] = '-'; }else{$_POST['richied_cognome'] = str_replace("'", "’" ,$_POST['richied_cognome']);} +if ($_POST['richied_res_comune'] == ""){ $_POST['richied_res_comune'] = '-'; }else{$_POST['richied_res_comune'] = str_replace("'", "’" ,$_POST['richied_res_comune']);} +if ($_POST['richied_res_indirizzo'] == ""){ $_POST['richied_res_indirizzo'] = '-'; }else{$_POST['richied_res_indirizzo'] = str_replace("'", "’" ,$_POST['richied_res_indirizzo']);} +if ($_POST['richied_res_cap'] == ""){ $_POST['richied_res_cap'] = '-'; } +if ($_POST['richied_cf'] == ""){ $_POST['richied_cf'] = '-'; } +if ($_POST['richied_iva'] == ""){ $_POST['richied_iva'] = '-'; } +if ($_POST['richied_tel'] == ""){ $_POST['richied_tel'] = '-'; } +if ($_POST['richied_email'] == ""){ $_POST['richied_email'] = '-'; } +if ($_POST['richied_ruolo'] == ""){ $_POST['richied_ruolo'] = '-'; } +$date = str_replace('/', '-', $_POST['certif_data_istanza']); +echo date("Y-m-d", strtotime($date))."
"; +if ($mode == "add") { + + + if(!$rs_update = @pg_query("INSERT INTO ".strtolower($_SESSION['COMUNE_BELF']).".certificazioni (certif_tipo,certif_numero,certif_data,certif_prot_istanza,certif_data_istanza,certif_catasto,certif_note,archiviato,attivo,comune,operatore,data_agg,certif_rilasciato,certi_query,richied_nome,richied_cognome,richied_res_comune,richied_res_indirizzo,richied_cf,richied_iva,richied_tel,richied_email,richied_ruolo) ". + " VALUES('".$_POST['certif_tipo']."',".$_POST['certif_numero'].",'".$certif_data."','".$_POST['certif_prot_istanza']."', '".$certif_data_istanza."', '".$_POST['certif_catasto']."', '".$_POST['certif_note']."', false,1,'".$_SESSION['COMUNE_BELF']."','".$_SESSION['USER_NAME']."','".date("Y-m-d h:i:sa", time())."',1,".$_POST['certif_numero'].",'".$_POST['richied_nome']."','".$_POST['richied_cognome']."','".$_POST['richied_res_comune']."','".$_POST['richied_res_indirizzo']."','".$_POST['richied_cf']."','".$_POST['richied_iva']."','".$_POST['richied_tel']."','".$_POST['richied_email']."','".$_POST['richied_ruolo']."'); ")) + die("ERROR 3: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'NEW RECORD','".$_SESSION['TAB']."','".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 4: " . pg_last_error($conn)); + + //RECUPERA L'ULTIMO ID + if(!$last_id = @pg_query("SELECT certificazioni.* FROM ".strtolower($_SESSION['COMUNE_BELF']).".certificazioni ORDER BY data_agg DESC LIMIT 1")) + die("ERROR 6: " . pg_last_error($conn)); + while($last_id_result = pg_fetch_assoc($last_id)) { + $_SESSION['TABID'] = $last_id_result['id_certificazione']; + $tipocertificato = $last_id_result['certif_tipo']; + } + if ($tipocertificato == "Certificato di Destinazione Urbanistica") { + $link = 3; + } else { + $link = 4; + } + + } +if ($mode == "edit") { + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".certificazioni SET certif_tipo = '".$_POST['certif_tipo']."', certif_numero = ".$_POST['certif_numero'].", certif_data = '".$_POST['certif_data']."', certif_prot_istanza = '".$_POST['certif_prot_istanza']."', certif_data_istanza ='".$_POST['certif_data_istanza']."', certif_catasto = '".$_POST['certif_catasto']."', certif_note = '".$_POST['certif_note']."', archiviato = false, attivo=1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg='".date("Y-m-d h:i:sa", time())."', certif_rilasciato=1, richied_nome = '".$_POST['richied_nome']."', richied_cognome = '".$_POST['richied_cognome']."', richied_res_comune = '".$_POST['richied_res_comune']."', richied_res_indirizzo = '".$_POST['richied_res_indirizzo']."', richied_cf = '".$_POST['richied_cf']."', richied_iva = '".$_POST['richied_iva']."', richied_tel = '".$_POST['richied_tel']."', richied_email = '".$_POST['richied_email']."', richied_ruolo = '".$_POST['richied_ruolo']."' WHERE id_certificazione = ".$_SESSION['TABID']."")) + die("ERROR 5: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 6: " . pg_last_error($conn)); + if ($_POST['certif_tipo'] == "Certificato di Destinazione Urbanistica") { + $link = 3; + } else { + $link = 4; + } + + } +} +//############### FINE PROCEDURA CERTIFICATI ############### + +//############### INIZIO PROCEDURA UTENTI ############### +if ($_SESSION['TAB'] == "user") { + +if ($_POST['user_tipo'] == ""){ $_POST['user_tipo'] = '-'; } +if ($_POST['user_cognome'] == ""){ $_POST['user_cognome'] = '-'; } else { $_POST['user_cognome'] = str_replace("'", "’" ,$_POST['user_cognome']); } +if ($_POST['user_nome'] == ""){ $_POST['user_nome'] = '-'; } +if ($_POST['user_comune'] == ""){ $_POST['user_comune'] = '-'; } +if ($_POST['user_indirizzo'] == ""){ $_POST['user_indirizzo'] = '-'; } else { $_POST['user_indirizzo'] = str_replace("'", "’" ,$_POST['user_indirizzo']); } +if ($_POST['user_email'] == ""){ $_POST['user_email'] = '-'; } +if ($_POST['user_recapito'] == ""){ $_POST['user_recapito'] = '-'; } +if ($_POST['user_password'] == ""){ $_POST['user_password'] = '-'; } + +//$hashedPassword = crypt($_POST['user_password'], '$5$rounds=5000$usesomesillystringforsalt$'); +$crypt_password = encrypt_decrypt('encrypt', $_POST['user_password']); + +if ($_POST['user_role'] == ""){ $_POST['user_role'] = 0; } +if ($_POST['note'] == ""){ $_POST['note'] = '-'; } else { $_POST['note'] = str_replace("'", "’" ,$_POST['note']); } +if ($_POST['user_code'] == ""){ $user_code = hash('sha512', uniqid(openssl_random_pseudo_bytes(16), TRUE)); } +if ($_POST['attivo'] == ""){ $_POST['attivo'] = 0; } +if ($_POST['data_agg'] == ""){ $_POST['data_agg'] = date("Y-m-d h:i:sa", time()); } +if ($_POST['urbanistica'] == ""){ $_POST['urbanistica'] = 'false'; }else{ $_POST['urbanistica'] = 'true';} +if ($_POST['mobilita'] == ""){ $_POST['mobilita'] = 'false'; }else{ $_POST['mobilita'] = 'true';} +if ($_POST['reti'] == ""){ $_POST['reti'] = 'false'; }else{ $_POST['reti'] = 'true';} +if ($_POST['emergenze'] == ""){ $_POST['emergenze'] = 'false'; }else{ $_POST['emergenze'] = 'true';} +if ($_POST['prot_civile'] == ""){ $_POST['prot_civile'] = 'false'; }else{ $_POST['prot_civile'] = 'true';} +if ($_POST['fiscalita'] == ""){ $_POST['fiscalita'] = 'false'; }else{ $_POST['fiscalita'] = 'true';} + +if ($mode == "add") { + if(!$rs_update = @pg_query("INSERT INTO public.user (user_tipo, user_cognome, user_nome, user_comune, user_indirizzo, user_email, user_recapito, user_username, user_password, user_role, note, user_code, urbanistica, mobilita, reti, emergenze, prot_civile, fiscalita, archiviato, attivo, comune, operatore, data_agg) ". + " VALUES('".$_POST['user_tipo']."', '".$_POST['user_cognome']."', '".$_POST['user_nome']."', '".$_POST['user_comune']."', '".$_POST['user_indirizzo']."', '".$_POST['user_email']."', '".$_POST['user_recapito']."', '".$_POST['user_email']."', '".$crypt_password."', ".$_POST['user_role'].", '".$_POST['note']."', '".$user_code."', '".$_POST['urbanistica']."', '".$_POST['mobilita']."', '".$_POST['reti']."', '".$_POST['emergenze']."', '".$_POST['prot_civile']."', '".$_POST['fiscalita']."', false, ".$_POST['attivo'].", '".$_SESSION['COMUNE_BELF']."','".$_SESSION['USER_NAME']."','".date("Y-m-d h:i:sa", time())."'); ")) + + die("ERROR 11: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'NEW RECORD','".$_SESSION['TAB']."','".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 12: " . pg_last_error($conn)); + + //RECUPERA L'ULTIMO ID + if(!$last_id = @pg_query("SELECT * FROM public.user ORDER BY user_id DESC LIMIT 1")) + die("ERROR 6: " . pg_last_error($conn)); + while($last_id_result = pg_fetch_assoc($last_id)) { + $_SESSION['TABID'] = $last_id_result['user_id']; + //echo $last_id_result; + } + $link = 7; + } +if ($mode == "edit") { + if(!$rs_update = @pg_query("UPDATE public.user SET user_tipo='".$_POST['user_tipo']."', user_cognome='".$_POST['user_cognome']."', user_nome='".$_POST['user_nome']."', user_comune='".$_POST['user_comune']."', user_indirizzo='".$_POST['user_indirizzo']."', user_email='".$_POST['user_email']."', user_recapito='".$_POST['user_recapito']."', user_username='".$_POST['user_email']."', user_password='".$crypt_password."', user_role=".$_POST['user_role'].", note='".$_POST['note']."', user_code='".$user_code."', urbanistica='".$_POST['urbanistica']."', mobilita='".$_POST['mobilita']."', reti='".$_POST['reti']."', emergenze='".$_POST['emergenze']."', prot_civile='".$_POST['prot_civile']."', fiscalita='".$_POST['fiscalita']."', archiviato = false, attivo=".$_POST['attivo'].", comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg='".date("Y-m-d h:i:sa", time())."' WHERE user_id = ".$_SESSION['TABID']."")) + die("ERROR 13: " . pg_last_error($conn)); + + + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 14: " . pg_last_error($conn)); + + $iduser = $_SESSION['TABID'] ; + $link = 7; + } +} + +//############### FINE PROCEDURA UTENTI ############### + +//############### INIZIO PROCEDURA NTA ############### +if ($_SESSION['TAB'] == "zoning_nta") { + +if ($_POST['tipo'] == ""){ $_POST['tipo'] = '-'; } +if ($_POST['art_titolo'] == ""){ $_POST['art_titolo'] = '-'; }else{$_POST['art_titolo'] = str_replace("'", "’" ,$_POST['art_titolo']);} +if ($_POST['art_numero'] == ""){ $_POST['art_numero'] = '-'; }else{$_POST['art_numero'] = str_replace("'", "’" ,$_POST['art_numero']);} +if ($_POST['art_descrizione'] == ""){ $_POST['art_descrizione'] = '-'; }else{$_POST['art_descrizione'] = str_replace("'", "’" ,$_POST['art_descrizione']);} + +if ($mode == "add") { + if(!$rs_update = @pg_query("INSERT INTO ".strtolower($_SESSION['COMUNE_BELF']).".zoning_nta (tipo,art_numero,art_titolo,art_descrizione,archiviato,attivo,comune,operatore,data_agg) VALUES('".$_POST['tipo']."','".$_POST['art_numero']."','".$_POST['art_titolo']."', '".$_POST['art_descrizione']."', false, 1, '".$_SESSION['COMUNE_BELF']."', '".$_SESSION['USER_NAME']."', '".date("Y-m-d h:i:sa", time())."'); ")) + + die("ERROR 21: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'NEW RECORD','".$_SESSION['TAB']."','".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 22: " . pg_last_error($conn)); + + //RECUPERA L'ULTIMO ID + if(!$last_id = @pg_query("SELECT zoning_nta.* FROM ".strtolower($_SESSION['COMUNE_BELF']).".zoning_nta ORDER BY zoning_nta.nta_id DESC LIMIT 1")) + die("ERROR 6: " . pg_last_error($conn)); + while($last_id_result = pg_fetch_assoc($last_id)) { + $_SESSION['TABID'] = $last_id_result['nta_id']; + //echo $last_id_result; + } + $link = 4; + } +if ($mode == "edit") { + //$titolo = str_replace("'", "\"" ,$_POST['art_titolo']); + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".zoning_nta SET tipo = '".$_POST['tipo']."', art_numero = '".$_POST['art_numero']."', art_titolo = '".$_POST['art_titolo']."', art_descrizione ='".$_POST['art_descrizione']."', archiviato = false, attivo=1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg='".date("Y-m-d h:i:sa", time())."' WHERE nta_id = ".$_SESSION['TABID']."")) + die("ERROR 23: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 24: " . pg_last_error($conn)); + $link = 4; + } +} +//############### FINE PROCEDURA NTA ############### + +//############### INIZIO PROCEDURA DOC ############### +if ($_SESSION['TAB'] == "zoning_doc") { + +if ($_POST['tipo'] == ""){ $_POST['tipo'] = '-'; } +if ($_POST['titolo'] == ""){ $_POST['titolo'] = '-'; }else{$_POST['titolo'] = str_replace("'", "’" ,$_POST['titolo']);} +if ($_POST['descrizione'] == ""){ $_POST['descrizione'] = '-'; }else{$_POST['descrizione'] = str_replace("'", "’" ,$_POST['descrizione']);} +if ($_POST['numero'] == ""){ $_POST['art_numero'] = '-'; }else{$_POST['art_numero'] = str_replace("'", "’" ,$_POST['art_numero']);} + +if ($mode == "add") { + if(!$rs_update = @pg_query("INSERT INTO ".strtolower($_SESSION['COMUNE_BELF']).".zoning_doc (tipo,titolo,descrizione,attivo,comune,operatore,data_agg) VALUES('".$_POST['tipo']."','".$_POST['titolo']."', '".$_POST['descrizione']."', ".$_POST['attivo'].", '".$_SESSION['COMUNE_BELF']."', '".$_SESSION['USER_NAME']."', '".date("Y-m-d h:i:sa", time())."'); ")) + + die("ERROR 21: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'NEW RECORD','".$_SESSION['TAB']."','".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 22: " . pg_last_error($conn)); + + //RECUPERA L'ULTIMO ID + if(!$last_id = @pg_query("SELECT zoning_doc.* FROM ".strtolower($_SESSION['COMUNE_BELF']).".zoning_doc ORDER BY zoning_doc.id DESC LIMIT 1")) + while($last_id_result = pg_fetch_assoc($last_id)) { + $_SESSION['TABID'] = $last_id_result['id']; + //echo $last_id_result; + } + $link = 4; + } +if ($mode == "edit") { + //$titolo = str_replace("'", "\"" ,$_POST['art_titolo']); + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".zoning_doc SET tipo = '".$_POST['tipo']."', titolo = '".$_POST['titolo']."', descrizione ='".$_POST['descrizione']."', attivo=".$_SESSION['attivo'].", comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg='".date("Y-m-d h:i:sa", time())."' WHERE id = ".$_SESSION['TABID']."")) + die("ERROR 23: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 24: " . pg_last_error($conn)); + $link = 4; + } +} +//############### FINE PROCEDURA DOC ############### + +//############### INIZIO RISCHIO IDRO ############### +if ($_SESSION['TAB'] == "interventi") { + +if ($_POST['id'] == ""){ $_POST['id'] = 0; } +if ($_POST['localita'] == ""){$_POST['localita']='-';}else{$_POST['localita']=str_replace("'", "’" ,$_POST['localita']);} + + if (empty($_POST['data_inter'])) { + $data_inter='1970-01-01'; + } else { + $data_inter= date("Y-m-d", strtotime(str_replace('/', '-', $_POST['data_inter']))); + } + +if ($_POST['tipo'] == ""){ $_POST['tipo'] = '-'; } +if ($_POST['tipo_luogo'] == ""){ $_POST['tipo_luogo'] = '-'; } +if ($_POST['area'] == ""){ $_POST['area'] = 0; } +if ($_POST['viabilita'] == ""){ $_POST['viabilita'] = '-'; } +if ($_POST['abitazioni'] == ""){ $_POST['abitazioni'] = '-'; } +if ($_POST['reti_impianti'] == ""){ $_POST['reti_impianti'] = '-'; } +if ($_POST['industriale'] == ""){ $_POST['industriale'] = '-'; } +if ($_POST['luoghi_pubblici'] == ""){ $_POST['luoghi_pubblici'] = '-'; } +if ($_POST['note'] == ""){$_POST['note']='-';}else{$_POST['note']=str_replace("'", "’" ,$_POST['note']);} + +if ($mode == "edit") { + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".interventi SET localita = '".$_POST['localita']."', data_inter = '".$data_inter."', tipo ='".$_POST['tipo']."', tipo_luogo ='".$_POST['tipo_luogo']."', area =".$_POST['area'].", viabilita ='".$_POST['viabilita']."', abitazioni ='".$_POST['abitazioni']."', reti_impianti ='".$_POST['reti_impianti']."', industriale ='".$_POST['industriale']."', luoghi_pubblici ='".$_POST['luoghi_pubblici']."', note ='".$_POST['note']."', archiviato = false, attivo=1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg='".date("Y-m-d h:i:sa", time())."' WHERE id = ".$_SESSION['TABID']."")) + die("ERROR 25: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 26: " . pg_last_error($conn)); + } + $link = 4; +} +//############### FINE PROCEDURA RISCHIO IDRO ############### + +//############### INIZIO PROCEDURA SEGNALAZIONI ############### +if ($_SESSION['TAB'] == "segnalazioni") { +if ($_POST['id'] == ""){ $_POST['id'] = 0; } + + if (empty($_POST['data_segnal'])) { + $data_segnal='1970-01-01'; + } else { + $data_segnal= date("Y-m-d", strtotime(str_replace('/', '-', $_POST['data_segnal']))); + } + + +if ($_POST['nominativo'] == ""){$_POST['nominativo']='-';}else{$_POST['nominativo']=str_replace("'", "’" ,$_POST['nominativo']);} +if ($_POST['recapito'] == ""){$_POST['recapito']='-';}else{$_POST['recapito']=str_replace("'", "’" ,$_POST['recapito']);} +if ($_POST['localita'] == ""){$_POST['localita']='-';}else{$_POST['localita']=str_replace("'", "’" ,$_POST['localita']);} +if ($_POST['indirizzo'] == ""){$_POST['indirizzo']='-';}else{$_POST['indirizzo']=str_replace("'", "’" ,$_POST['indirizzo']);} +if ($_POST['settore'] == ""){ $_POST['settore'] = '-'; } +if ($_POST['categoria'] == ""){ $_POST['categoria'] = '-'; } +if ($_POST['descrizione'] == ""){ $_POST['descrizione'] = '-'; }else{$_POST['descrizione'] = str_replace("'", "’" ,$_POST['descrizione']);} +if ($_POST['catasto'] == ""){ $_POST['catasto'] = '-'; } + + echo 'id = '.$_POST['id'].'
'; + echo 'data = '.$_POST['data'].'
'; + echo 'nominativo = '.$_POST['nominativo'].'
'; + echo 'recapito = '.$_POST['recapito'].'
'; + echo 'comune_app = '.$_POST['comune_app'].'
'; + echo 'localita = '.$_POST['localita'].'
'; + echo 'settore = '.$_POST['settore'].'
'; + echo 'categoria = '.$_POST['categoria'].'
'; + echo 'descrizione = '.$_POST['descrizione'].'
'; + echo 'catasto = '.$_POST['catasto'].'
'; + echo 'attivo = '.$_POST['attivo'].'
'; + +if ($mode == "edit") { + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".segnalazioni SET data_segnal = '".$data_segnal."', nominativo = '".$_POST['nominativo']."', recapito = '".$_POST['recapito']."', localita ='".$_POST['localita']."', indirizzo ='".$_POST['indirizzo']."', settore ='".$_POST['settore']."', categoria ='".$_POST['categoria']."', descrizione ='".$_POST['descrizione']."', archiviato = false, attivo=".$_POST['attivo'].", comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg='".date("Y-m-d h:i:sa", time())."' WHERE id = ".$_SESSION['TABID']."")) + die("ERROR 29: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 30: " . pg_last_error($conn)); + } + $link = 4; +} +//############### FINE PROCEDURA PROCEDURA SEGNALAZIONI ############### + + +//############### INIZIO PROCEDURA ZONING NOTE AL PRG ############### +if ($_SESSION['TAB'] == "zoning_compare") { +if ($mode == "edit") { + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".zoning_compare SET comune_app ='".$_POST['comune_app']."', localita ='".$_POST['localita']."', segnalatore = '".$_POST['segnalatore']."', nota_data = '".$_POST['nota_data']."', nota ='".$_POST['nota']."', archiviato = false, attivo=1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg='".date("Y-m-d h:i:sa", time())."' WHERE compare_id = ".$_SESSION['TABID']."")) + die("ERROR 29: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 30: " . pg_last_error($conn)); + } + $link = 4; +} +//############### FINE PROCEDURA PROCEDURA ZONING NOTE AL PRG ############### + + +//############### INIZIO PROCEDURA DISCARICA ############### +if ($_SESSION['TAB'] == "discarica") { +if ($mode == "edit") { + +if ($_POST['localita'] == ""){ + $_POST['localita'] = '-'; + } else { + $_POST['localita'] = str_replace("'", "’" ,$_POST['localita']); + } + +if ($_POST['indirizzo'] == ""){ + $_POST['indirizzo'] = '-'; + } else { + $_POST['indirizzo'] = str_replace("'", "’" ,$_POST['indirizzo']); +} + +if ($_POST['segnal_preced'] == ""){$_POST['segnal_preced'] = '-';} + +if ($_POST['segnal_preced'] == ""){ + $segnal_preced_data = '2000-01-01'; + } else if ($_POST['segnal_preced'] == '2000-01-01'){ + $segnal_preced_data = '2000-01-01'; + } else { + $segnal_preced_data = date("Y-m-d", strtotime($_POST['segnal_preced_data'])); + } + +if ($_POST['catasto'] == ""){ $_POST['catasto'] = '-'; } +if ($_POST['tipo_zona'] == ""){ $_POST['tipo_zona'] = '-'; } +if ($_POST['tipo_luogo'] == ""){ $_POST['tipo_luogo'] = '-'; } +if ($_POST['area_presunta'] == ""){ $_POST['area_presunta'] = 0; } +if ($_POST['volume_presunto'] == ""){ $_POST['volume_presunto'] = 0; } +if ($_POST['tipo_rifiuto'] == ""){ $_POST['tipo_rifiuto'] = '-'; } +if ($_POST['note'] == ""){ $_POST['note'] = '-'; } else { $_POST['note'] = str_replace("'", "’" ,$_POST['note']); } + +if ($_POST['eliminata_data'] == ""){ + $eliminata_data = '2000-01-01'; + } else if ($_POST['eliminata_data'] == '2000-01-01'){ + $eliminata_data = '2000-01-01'; + } else { + $eliminata_data = date("Y-m-d", strtotime($_POST['eliminata_data'])); + } + + +if ($_POST['eliminata_chi'] == ""){ $_POST['eliminata_chi'] = '-'; } else { $_POST['eliminata_chi'] = str_replace("'", "’" ,$_POST['eliminata_chi']); } + +$rifiuti = implode(', ', $_POST['tipo_rifiuto']); + + echo 'id = '.$_POST['id'].'
'; + echo 'localita = '.$_POST['localita'].'
'; + echo 'indirizzo = '.$_POST['indirizzo'].'
'; + echo 'segnal_preced = '.$_POST['segnal_preced'].'
'; + echo 'segnal_preced_data = '.$segnal_preced_data.'
'; + echo 'catasto = '.$_POST['catasto'].'
'; + echo 'tipo_zona = '.$_POST['tipo_zona'].'
'; + echo 'tipo_luogo = '.$_POST['tipo_luogo'].'
'; + echo 'area_presunta = '.$_POST['area_presunta'].'
'; + echo 'volume_presunto = '.$_POST['volume_presunto'].'
'; + echo 'tipo_rifiuto = '.$rifiuti.'
'; + echo 'note = '.$_POST['note'].'
'; + echo 'eliminata_data = '.$eliminata_data.'
'; + echo 'eliminata_chi = '.$_POST['eliminata_chi'].'
'; + + + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".discarica SET localita='".$_POST['localita']."', indirizzo='".$_POST['indirizzo']."', segnal_preced='".$_POST['segnal_preced']."', segnal_preced_data='".$segnal_preced_data."', catasto='".$_POST['catasto']."', tipo_zona='".$_POST['tipo_zona']."', tipo_luogo='".$_POST['tipo_luogo']."', area_presunta=".$_POST['area_presunta'].", volume_presunto=".$_POST['volume_presunto'].", tipo_rifiuto='".$rifiuti."', note='".$_POST['note']."', eliminata_data='".$eliminata_data."', eliminata_chi='".$_POST['eliminata_chi']."', archiviato = false, attivo=1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg='".date("Y-m-d h:i:sa", time())."' WHERE id = ".$_SESSION['TABID']."")) + die("ERROR 31: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 32: " . pg_last_error($conn)); + } + $link = 4; +} +//############### FINE PROCEDURA DISCARICA ############### + + +//############### INIZIO PROCEDURA AVVISI ############### +if ($_SESSION['TAB'] == "avvisi") { +if ($mode == "add") { + if(!$rs_update = @pg_query("INSERT INTO public.avvisi (avviso_data,comune_app,avviso_tipo,avviso_oggetto,avviso_descrizione,archiviato,attivo,comune,operatore,data_agg) VALUES('".$_POST['avviso_data']."','".$_POST['comune_app']."','".$_POST['avviso_tipo']."','".$_POST['avviso_oggetto']."','".$_POST['avviso_descrizione']."',false,1,'".$_SESSION['COMUNE_BELF']."','".$_SESSION['USER_NAME']."','".date("Y-m-d h:i:sa", time())."'); ")) + + die("ERROR 33: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'NEW RECORD','".$_SESSION['TAB']."','".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 34: " . pg_last_error($conn)); + + //RECUPERA L'ULTIMO ID + if(!$last_id = @pg_query("SELECT avvisi.* FROM public.avvisi ORDER BY avvisi.avviso_id DESC LIMIT 1")) + die("ERROR 6: " . pg_last_error($conn)); + while($last_id_result = pg_fetch_assoc($last_id)) { + $_SESSION['TABID'] = $last_id_result['avviso_id']; + //echo $last_id_result; + } + } +if ($mode == "edit") { + if(!$rs_update = @pg_query("UPDATE public.avvisi SET avviso_data = '".$_POST['avviso_data']."', comune_app = '".$_POST['comune_app']."', avviso_tipo = '".$_POST['avviso_tipo']."', avviso_oggetto ='".$_POST['avviso_oggetto']."', avviso_descrizione ='".$_POST['avviso_descrizione']."', archiviato = false, attivo=1, comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg='".date("Y-m-d h:i:sa", time())."' WHERE avviso_id = ".$_SESSION['TABID']."")) + die("ERROR 35: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 36: " . pg_last_error($conn)); + } + $link = 4; +} +//############### FINE PROCEDURA AVVISI ############### + + +//############### INIZIO PROCEDURA LAYERS ############### +if ($_SESSION['TAB'] == "layers") { + +//$attribution = str_replace(array("'", ",", "\"", """), """, htmlspecialchars($_POST['attribution'])); + +if ($mode == "add") { +$attribution = str_replace(array("'", "\"", """), "#", htmlspecialchars($_POST['attribution'])); + + if(!$rs_update = @pg_query("INSERT INTO public.layers (type,cat,name,url,format,layers,transparent,opacity,maxzoom, minzoom,attribution,subdomains,layer_default,layer_private,archiviato,attivo,comune,operatore,data_agg,orderlay) VALUES('".$_POST['type']."','".$_POST['cat']."','".$_POST['name']."','".$_POST['url']."','".$_POST['format']."','". $_POST['layers']."','".$_POST['transparent']."','".$_POST['opacity']."',".$_POST['maxzoom'].",".$_POST['minzoom'].",'".$attribution."','".$_POST['subdomains']."',".$_POST['layer_default'].",".$_POST['layer_private'].",false,1,'".$_POST['comune']."','".$_SESSION['USER_NAME']."','".date("Y-m-d h:i:sa", time())."',".$_POST['orderlay']."); ")) + + die("ERROR 37: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'NEW RECORD','".$_SESSION['TAB']."','".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 38: " . pg_last_error($conn)); + + //RECUPERA L'ULTIMO ID + if(!$last_id = @pg_query("SELECT layers.* FROM public.layers ORDER BY layers.layer_id DESC LIMIT 1")) + die("ERROR 6: " . pg_last_error($conn)); + while($last_id_result = pg_fetch_assoc($last_id)) { + $_SESSION['TABID'] = $last_id_result['layer_id']; + //echo $last_id_result; + } ?> + + + + + + + +client_id = '.$_POST['client_id'].'
'; + echo 'client_type = '.$_POST['client_type'].'
'; + echo 'client_code = '.$_POST['client_code'].'
'; + echo 'title = '.$_POST['title'].'
'; + echo 'layers = '.implode(';', $_POST['layers']).'
'; + echo 'comu_nome = '.$_POST['comu_nome'].'
'; + echo 'archiviato = '.$_POST['archiviato'].'
'; + echo 'attivo = '.$_POST['attivo'].'
'; + echo 'comune = '.$_POST['comune'].'
'; + echo 'operatore = '.$_POST['operatore'].'
'; + echo 'data_agg = '.$_POST['data_agg'].'
'; + echo 'orderlay = '.$_POST['orderlay'].'
'; + echo 'urbanistica = '.$_POST['urbanistica'].'
'; + echo 'emergenze = '.$_POST['emergenze'].'
'; + echo 'fiscalita = '.$_POST['fiscalita'].'
'; + echo 'mobilita = '.$_POST['mobilita'].'
'; + echo 'prot_civile = '.$_POST['prot_civile'].'
'; + echo 'reti = '.$_POST['reti'].'
'; +*/ +if ($mode == "add") { + + if(!$rs_insert = @pg_query("INSERT INTO public.layers_client (client_type,client_code,title,layers,comu_nome,urbanistica,emergenze,fiscalita,mobilita,prot_civile,reti,archiviato,attivo,comune,operatore,data_agg) VALUES(".$_POST['client_type'].",'".$_POST['client_code']."','".$_POST['title']."','".$layers."','".$_POST['comu_nome']."', '".$_POST['urbanistica']."', '".$_POST['emergenze']."', '".$_POST['fiscalita']."', '".$_POST['mobilita']."', '".$_POST['prot_civile']."', '".$_POST['reti']."', false,1,'".$_SESSION['COMUNE_BELF']."', '".$_SESSION['USER_NAME']."', '".date("Y-m-d h:i:sa", time())."'); ")) + + die("ERROR 1: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'NEW RECORD','".$_SESSION['TAB']."','".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 2: " . pg_last_error($conn)); + + //RECUPERA L'ULTIMO ID + if(!$last_id = @pg_query("SELECT layers_client.* FROM public.layers_client ORDER BY client_id DESC LIMIT 1")) + die("ERROR 3: " . pg_last_error($conn)); + while($last_id_result = pg_fetch_assoc($last_id)) { + $_SESSION['TABID'] = $last_id_result['client_id']; + //echo $last_id_result; + } +} + $link = 5; + + +if ($mode == "edit") { + if(!$rs_update = @pg_query(" UPDATE public.layers_client SET client_id=".$_POST['client_id'].", client_type=".$_POST['client_type'].", client_code='".$_POST['client_code']."', title='".$_POST['title']."', layers='".$layers."', comu_nome='".$_POST['comu_nome']."', orderlay=".$_POST['orderlay'].", urbanistica='".$_POST['urbanistica']."', emergenze='".$_POST['emergenze']."', fiscalita='".$_POST['fiscalita']."', mobilita='".$_POST['mobilita']."', prot_civile='".$_POST['prot_civile']."', reti='".$_POST['reti']."', archiviato = false, attivo=".$_POST['attivo'].", comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg='".date("Y-m-d h:i:sa", time())."' WHERE client_id = ".$_SESSION['TABID']."")) + die("ERROR 39: " . pg_last_error($conn)); + + + + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 40: " . pg_last_error($conn)); + } + $link = 5; +} +//############### FINE PROCEDURA LAYERS CLIENT ############### + + +//############### INIZIO PROCEDURA LAYERS CATEGORY ############### +if ($_SESSION['TAB'] == "layers_cat") { +if ($mode == "add") { + if(!$rs_update = @pg_query("INSERT INTO public.layers_cat (cat,archiviato,attivo,comune,operatore,data_agg) ". + " VALUES('".$_POST['cat']."',false,".$_POST['attivo'].",'".$_SESSION['COMUNE_BELF']."','".$_SESSION['USER_NAME']."','".date("Y-m-d h:i:sa", time())."'); ")) + + die("ERROR 41: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'NEW RECORD','".$_SESSION['TAB']."','".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 42: " . pg_last_error($conn)); + + //RECUPERA L'ULTIMO ID + if(!$last_id = @pg_query("SELECT layers_cat.* FROM public.layers_cat ORDER BY layers_cat.cat_id DESC LIMIT 1")) + die("ERROR 6: " . pg_last_error($conn)); + while($last_id_result = pg_fetch_assoc($last_id)) { + $_SESSION['TABID'] = $last_id_result['cat_id']; + //echo $last_id_result; + } + $link = 4; + + } +if ($mode == "edit") { + if(!$rs_update = @pg_query("UPDATE public.layers_cat SET cat = '".$_POST['cat']."', archiviato = false, attivo=".$_POST['attivo'].", comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg='".date("Y-m-d h:i:sa", time())."' WHERE cat_id = ".$_SESSION['TABID']."")) + die("ERROR 43: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 44: " . pg_last_error($conn)); + } + $link = 4; + +} +//############### FINE PROCEDURA LAYERS CATEGORY ############### + +//############### INIZIO PROCEDURA ORDINANZE ############### +if ($_SESSION['TAB'] == "ordinanze") { + + echo 'gid = '.$_POST['gid'].'
'; + echo 'id_old = '.$_POST['id_old'].'
'; + echo 'num_ord = '.$_POST['num_ord'].'
'; + echo 'data_ord = '.$_POST['data_ord'].'
'; + echo 'intestatario = '.$_POST['intestatario'].'
'; + echo 'oggetto = '.$_POST['oggetto'].'
'; + echo 'id_toponom = '.$_POST['id_toponom'].'
'; + echo 'civico = '.$_POST['civico'].'
'; + echo 'tipo_dest = '.$_POST['tipo_dest'].'
'; + echo 'tipo_ord = '.$_POST['tipo_ord'].'
'; + echo 'quartiere = '.$_POST['quartiere'].'
'; + echo 'concessione = '.$_POST['concessione'].'
'; + echo 'oneri = '.$_POST['oneri'].'
'; + echo 'targa = '.$_POST['targa'].'
'; + echo 'stalli = '.$_POST['stalli'].'
'; + echo 'data_scadenza = '.$_POST['data_scadenza'].'
'; + echo 'data_notifica = '.$_POST['data_notifica'].'
'; + echo 'data_revoca = '.$_POST['data_revoca'].'
'; + echo 'stato = '.$_POST['stato'].'
'; + echo 'note = '.$_POST['note'].'
'; + echo 'data_agg = '.$_POST['data_agg'].'
'; + echo 'archiviato = '.$_POST['archiviato'].'
'; + + if ($_POST['num_ord'] == ""){ $_POST['num_ord'] = '-'; } + + if (empty($_POST['data_ord'])) { + $data_ord='1970-01-01'; + } else { + $data_ord= date("Y-m-d", strtotime(str_replace('/', '-', $_POST['data_ord']))); + } + + if ($_POST['intestatario'] == ""){ $_POST['intestatario'] = 99999; } + if ($_POST['oggetto'] == ""){ $_POST['oggetto'] = '-'; } + if ($_POST['id_toponom'] == ""){ $_POST['id_toponom'] = 99999; } + if ($_POST['civico'] == ""){ $_POST['civico'] = '-'; } + if ($_POST['tipo_dest'] == ""){ $_POST['tipo_dest'] = 99; } + if ($_POST['tipo_ord'] == ""){ $_POST['tipo_ord'] = 44; } +// if ($_POST['quartiere'] == ""){ $_POST['quartiere'] = 12; } + if ($_POST['concessione'] == ""){ $_POST['concessione'] = '-'; } + if ($_POST['oneri'] == ""){ $_POST['oneri'] = 0; } + if ($_POST['targa'] == ""){ $_POST['targa'] = '-'; } + if ($_POST['stalli'] == ""){ $_POST['stalli'] = 0; } + + if (empty($_POST['data_scadenza'])) { + $data_scadenza='1970-01-01'; + } else { + $data_scadenza= date("Y-m-d", strtotime(str_replace('/', '-', $_POST['data_scadenza']))); + } + + if (empty($_POST['data_notifica'])) { + $data_notifica='1970-01-01'; + } else { + $data_notifica= date("Y-m-d", strtotime(str_replace('/', '-', $_POST['data_notifica']))); + } + + if (empty($_POST['data_revoca'])) { + $data_revoca='1970-01-01'; + } else { + $data_revoca= date("Y-m-d", strtotime(str_replace('/', '-', $_POST['data_revoca']))); + } + +// if ($_POST['data_scadenza'] == ""){ $_POST['data_scadenza'] = 0; } +// if ($_POST['data_notifica'] == ""){ $_POST['data_notifica'] = 0; } +// if ($_POST['data_revoca'] == ""){ $_POST['data_revoca'] = 0; } + echo "data_scadenza = ".$data_scadenza."
"; + echo "data_notifica = ".$data_notifica."
"; + echo "data_revoca = ".$data_revoca."
"; + + if ($_POST['stato'] == ""){ $_POST['stato'] = 0; } + if ($_POST['note'] == ""){ $_POST['note'] = '-'; } else { $_POST['note'] = str_replace("'", "’" ,$_POST['note']); } + + +if ($mode == "add") { + if(!$rs_update = @pg_query("INSERT INTO ".strtolower($_SESSION['COMUNE_BELF']).".ordinanze (num_ord, data_ord, intestatario, oggetto, id_toponom, civico, tipo_dest, tipo_ord, concessione, oneri, targa, stalli, data_scadenza, data_notifica, data_revoca, stato, note, data_agg, archiviato) ". + " VALUES('".$_POST['num_ord']."', '".$data_ord."', ".$_POST['intestatario'].", '".$_POST['oggetto']."', ".$_POST['id_toponom'].", '".$_POST['civico']."', ".$_POST['tipo_dest'].", ".$_POST['tipo_ord'].", '".$_POST['concessione']."', ".$_POST['oneri'].", '".$_POST['targa']."', ".$_POST['stalli'].", '".$data_scadenza."', '".$data_notifica."', '".$data_revoca."', ".$_POST['stato'].", '".$_POST['note']."', + '".date("Y-m-d h:i:sa", time())."', 0); ")) + + die("ERROR 11: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'NEW RECORD','".$_SESSION['TAB']."','".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 12: " . pg_last_error($conn)); + + //RECUPERA L'ULTIMO ID + if(!$last_id = @pg_query("SELECT * FROM ".strtolower($_SESSION['COMUNE_BELF']).".ordinanze ORDER BY gid DESC LIMIT 1")) + die("ERROR 6: " . pg_last_error($conn)); + while($last_id_result = pg_fetch_assoc($last_id)) { + $_SESSION['TABID'] = $last_id_result['gid']; + + if(!$rs_id_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".ordinanze SET + id_old=".$last_id_result['gid']." WHERE gid = ".$last_id_result['gid']."")) + die("ERROR 13A: " . pg_last_error($conn)); + } + $link = 8; + } + +if ($mode == "edit") { + + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".ordinanze SET gid=".$_POST['gid'].", id_old=".$_POST['id_old'].", num_ord='".$_POST['num_ord']."', data_ord='".$data_ord."', intestatario=".$_POST['intestatario'].", oggetto='".$_POST['oggetto']."', id_toponom=".$_POST['id_toponom'].", civico='".$_POST['civico']."', tipo_dest=".$_POST['tipo_dest'].", tipo_ord=".$_POST['tipo_ord'].", concessione='".$_POST['concessione']."', oneri=".$_POST['oneri'].", targa='".$_POST['targa']."', stalli=".$_POST['stalli'].", data_scadenza='".$data_scadenza."', data_notifica='".$data_notifica."', data_revoca='".$data_revoca."', stato=".$_POST['stato'].", note='".$_POST['note']."', data_agg='".date("Y-m-d h:i:sa", time())."', archiviato=0 WHERE gid = ".$_SESSION['TABID']."")) + + die("ERROR 13B: " . pg_last_error($conn)); + + + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 14: " . pg_last_error($conn)); + + + $link = 8; + } +} +//############### FINE PROCEDURA ORDINANZE ############### + +//############### INIZIO PROCEDURA INTESTATARI ############### +if ($_SESSION['TAB'] == "ord_intestatari") { + + echo 'gid = '.$_POST['gid'].'
'; + echo 'tipo = '.$_POST['tipo_intestatario'].'
'; + echo 'intestatario = '.$_POST['intestatario'].'
'; + echo 'note = '.$_POST['note'].'
'; + echo 'data_agg = '.$_POST['data_agg'].'
'; + + if ($_POST['intestatario'] == ""){ $_POST['intestatario'] = '-'; } else { $_POST['intestatario'] = str_replace("'", "’" ,$_POST['intestatario']); } + if ($_POST['tipo'] == ""){ $_POST['tipo'] = '-'; } + if ($_POST['note'] == ""){ $_POST['note'] = '-'; } else { $_POST['note'] = str_replace("'", "’" ,$_POST['note']); } + + +if ($mode == "add") { + if(!$rs_update = @pg_query("INSERT INTO ".strtolower($_SESSION['COMUNE_BELF']).".ord_intestatari (intestatario, tipo, note, data_agg, archiviato) ". + " VALUES('".$_POST['intestatario']."', '".$_POST['tipo']."', '".$_POST['note']."', '".date("Y-m-d h:i:sa", time())."', 0); ")) + + die("ERROR 11: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'NEW RECORD','".$_SESSION['TAB']."','".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 12: " . pg_last_error($conn)); + + //RECUPERA L'ULTIMO ID + if(!$last_id = @pg_query("SELECT * FROM ".strtolower($_SESSION['COMUNE_BELF']).".ord_intestatari ORDER BY data_agg DESC LIMIT 1")) + die("ERROR 6: " . pg_last_error($conn)); + while($last_id_result = pg_fetch_assoc($last_id)) { + $_SESSION['TABID'] = $last_id_result['gid']; + + if(!$rs_id_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".ord_intestatari SET + id_old=".$last_id_result['gid']." WHERE gid = ".$last_id_result['gid']."")) + die("ERROR 13A: " . pg_last_error($conn)); + } + $link = 9; + } + +if ($mode == "edit") { +/* */ + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".ord_intestatari SET gid=".$_POST['gid'].", id_old=".$_POST['id_old'].", intestatario='".$_POST['intestatario']."', tipo='".$_POST['tipo']."', note='".$_POST['note']."', data_agg='".date("Y-m-d h:i:sa", time())."', archiviato=0 WHERE gid = ".$_SESSION['TABID']."")) + + die("ERROR 13B: " . pg_last_error($conn)); + + + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 14: " . pg_last_error($conn)); + + + $link = 9; + } +} +//############### FINE PROCEDURA INTESTATARI ############### + + +//############### INIZIO PROCEDURA TOPONOMASTICA ############### +if ($_SESSION['TAB'] == "toponomastica") { + + echo 'id = '.$_POST['id'].'
'; + echo 'dug = '.$_POST['dug'].'
'; + echo 'duf = '.$_POST['duf'].'
'; + echo 'gis_id = '.$_POST['gis_id'].'
'; + echo 'sezione = '.$_POST['sezione'].'
'; + echo 'circoscriz = '.$_POST['circoscriz'].'
'; + echo 'note = '.$_POST['note'].'
'; + + if ($_POST['duf'] == ""){ $_POST['duf'] = '-'; } else { $_POST['duf'] = str_replace("'", "’" ,$_POST['duf']); } + if ($_POST['sezione'] == ""){ $_POST['sezione'] = '-'; } + if ($_POST['circoscriz'] == ""){ $_POST['circoscriz'] = '-'; } + if ($_POST['note'] == ""){ $_POST['note'] = '-'; } else { $_POST['note'] = str_replace("'", "’" ,$_POST['note']); } + + +if ($mode == "add") { + if(!$rs_update = @pg_query("INSERT INTO ".strtolower($_SESSION['COMUNE_BELF']).".toponomastica (dug, duf, sezione, circoscriz, note, attivo, data_agg) ". + " VALUES('".$_POST['dug']."', '".$_POST['duf']."', '".$_POST['sezione']."', '".$_POST['circoscriz']."', '".$_POST['note']."', 1, '".date("Y-m-d h:i:sa", time())."'); ")) + + die("ERROR 11: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'NEW RECORD','".$_SESSION['TAB']."','".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 12: " . pg_last_error($conn)); + + //RECUPERA L'ULTIMO ID + if(!$last_id = @pg_query("SELECT * FROM ".strtolower($_SESSION['COMUNE_BELF']).".toponomastica ORDER BY id DESC LIMIT 1")) + die("ERROR 6: " . pg_last_error($conn)); + while($last_id_result = pg_fetch_assoc($last_id)) { + $_SESSION['TABID'] = $last_id_result['id']; + + if(!$rs_id_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".toponomastica SET + gis_id=".$last_id_result['id']." WHERE id = ".$last_id_result['id']."")) + die("ERROR 13A: " . pg_last_error($conn)); + } + $link = 4; + } + +if ($mode == "edit") { +/* */ + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".toponomastica SET dug='".$_POST['dug']."', duf='".$_POST['duf']."', gis_id=".$_POST['gis_id'].", sezione='".$_POST['sezione']."', circoscriz='".$_POST['circoscriz']."', note='".$_POST['note']."', data_agg='".date("Y-m-d h:i:sa", time())."' WHERE id = ".$_SESSION['TABID']."")) + + die("ERROR 13B: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 14: " . pg_last_error($conn)); + + $link = 4; + } +} +//############### FINE PROCEDURA TOPONOMASTICA ############### + + +//############### INIZIO PROCEDURA PASSI ############### +if ($_SESSION['TAB'] == "passi") { + + echo 'id = '.$_POST['id'].'
'; + echo 'idcivico = '.$_POST['idcivico'].'
'; + echo 'prot_parere = '.$_POST['prot_parere'].'
'; + echo 'data_parere = '.$_POST['data_parere'].'
'; + echo 'num_pass = '.$_POST['num_pass'].'
'; + echo 'data_conces = '.$_POST['data_conces'].'
'; + echo 'data_scaden = '.$_POST['data_scaden'].'
'; + echo 'richiedente = '.$_POST['richiedente'].'
'; + echo 'via = '.$_POST['via'].'
'; + echo 'civico = '.$_POST['civico'].'
'; + echo 'circoscriz = '.$_POST['circoscriz'].'
'; + echo 'catasto = '.$_POST['catasto'].'
'; + echo 'tipo_passo = '.$_POST['tipo_passo'].'
'; + echo 'destinazione = '.$_POST['destinazione'].'
'; + echo 'larghezza = '.$_POST['larghezza'].'
'; + echo 'profondita = '.$_POST['profondita'].'
'; + echo 'tipo_suolo = '.$_POST['tipo_suolo'].'
'; + echo 'dist_incrocio = '.$_POST['dist_incrocio'].'
'; + echo 'dist_curva = '.$_POST['dist_curva'].'
'; + echo 'note = '.$_POST['note'].'
'; + echo 'cancello = '.$_POST['cancello'].'
'; + echo 'pedonale = '.$_POST['pedonale'].'
'; + + if ($_POST['id'] == ""){ $_POST['id'] = 0; } + if ($_POST['prot_parere'] == ""){ $_POST['prot_parere'] = '-'; } + + if (empty($_POST['data_parere'])) { + $data_parere='1970-01-01'; + } else { + $data_parere= date("Y-m-d", strtotime(str_replace('/', '-', $_POST['data_parere']))); + } + + if ($_POST['num_pass'] == ""){ $_POST['num_pass'] = '-'; } + + if (empty($_POST['data_conces'])) { + $data_conces='1970-01-01'; + } else { + $data_conces= date("Y-m-d", strtotime(str_replace('/', '-', $_POST['data_conces']))); + } + + if (empty($_POST['data_scaden'])) { + $data_scaden='1970-01-01'; + } else { + $data_scaden= date("Y-m-d", strtotime(str_replace('/', '-', $_POST['data_scaden']))); + } + + if ($_POST['richiedente'] == ""){ $_POST['richiedente'] = '-'; } else { $_POST['richiedente'] = str_replace("'", "’" ,$_POST['richiedente']); } + if ($_POST['via'] == ""){ $_POST['via'] = '-'; } + if ($_POST['civico'] == ""){ $_POST['civico'] = '-'; } + if ($_POST['circoscriz'] == ""){ $_POST['circoscriz'] = '-'; } + if ($_POST['catasto'] == ""){ $_POST['catasto'] = '-'; } + if ($_POST['tipo_passo'] == ""){ $_POST['tipo_passo'] = '-'; } + if ($_POST['destinazione'] == ""){ $_POST['destinazione'] = '-'; } + if ($_POST['larghezza'] == ""){ $_POST['larghezza'] = 0; } + if ($_POST['profondita'] == ""){ $_POST['profondita'] = 0; } + if ($_POST['tipo_suolo'] == ""){ $_POST['tipo_suolo'] = '-'; } + if ($_POST['dist_incrocio'] == ""){ $_POST['dist_incrocio'] = 0; } + if ($_POST['dist_curva'] == ""){ $_POST['dist_curva'] = 0; } + if ($_POST['note'] == ""){ $_POST['note'] = '-'; } else { $_POST['note'] = str_replace("'", "’" ,$_POST['note']); } + if ($_POST['cancello'] == ""){ $_POST['cancello'] = 'f'; }else{ $_POST['cancello'] = 't';} + if ($_POST['pedonale'] == ""){ $_POST['pedonale'] = 'f'; }else{ $_POST['pedonale'] = 't';} + + + +if ($mode == "add") { + if(!$rs_update = @pg_query("INSERT INTO ".strtolower($_SESSION['COMUNE_BELF']).".passi (prot_parere, data_parere, num_pass, data_conces, data_scaden, richiedente, via, civico, catasto, tipo_passo, destinazione, larghezza, profondita, tipo_suolo, dist_incrocio, dist_curva, note, archiviato, attivo, comune, operatore, data_agg, cancello, pedonale) ". + " VALUES('".$_POST['prot_parere']."', '".$data_parere."', '".$_POST['num_pass']."', '".$data_conces."', '".$data_scaden."', '".$_POST['richiedente']."', '".$_POST['via']."', '".$_POST['civico']."', '".$_POST['catasto']."', '".$_POST['tipo_passo']."', '".$_POST['destinazione']."', ".$_POST['larghezza'].", ".$_POST['profondita'].", '".$_POST['tipo_suolo']."', ".$_POST['dist_incrocio'].", ".$_POST['dist_curva'].", '".$_POST['note']."', false, 1, '".$_SESSION['COMUNE_BELF']."', '".$_SESSION['USER_NAME']."', '".date("Y-m-d h:i:sa", time())."', ".$_POST['cancello'].", ".$_POST['pedonale']."); ")) + + die("ERROR 11: " . pg_last_error($conn)); + + //INSERISCE LOG + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'NEW RECORD','".$_SESSION['TAB']."','".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 12: " . pg_last_error($conn)); + + //RECUPERA L'ULTIMO ID + if(!$last_id = @pg_query("SELECT * FROM ".strtolower($_SESSION['COMUNE_BELF']).".passi ORDER BY id DESC LIMIT 1")) + die("ERROR 6: " . pg_last_error($conn)); + while($last_id_result = pg_fetch_assoc($last_id)) { + $_SESSION['TABID'] = $last_id_result['id']; + + if(!$rs_id_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".topo_civici SET + passo_id=".$last_id_result['id']." WHERE id = ".$_POST['idcivico']."")) + die("ERROR 13A: " . pg_last_error($conn)); + } + $link = 4; + } + + +if ($mode == "edit") { + + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".passi SET prot_parere='".$_POST['prot_parere']."', data_parere='".$data_parere."', num_pass='".$_POST['num_pass']."', data_conces='".$data_conces."', data_scaden='".$data_scaden."', richiedente='".$_POST['richiedente']."', via='".$_POST['via']."', civico='".$_POST['civico']."', catasto='".$_POST['catasto']."', tipo_passo='".$_POST['tipo_passo']."', destinazione='".$_POST['destinazione']."', larghezza=".$_POST['larghezza'].", profondita=".$_POST['profondita'].", tipo_suolo='".$_POST['tipo_suolo']."', dist_incrocio=".$_POST['dist_incrocio'].", dist_curva=".$_POST['dist_curva'].", note='".$_POST['note']."', comune = '".$_SESSION['COMUNE_BELF']."', operatore = '".$_SESSION['USER_NAME']."', data_agg='".date("Y-m-d h:i:sa", time())."', cancello='".$_POST['cancello']."', pedonale='".$_POST['pedonale']."' WHERE id = ".$_POST['id']."")) + + die("ERROR 14_B: " . pg_last_error($conn)); + echo "UPDATED
".$_SESSION['TABID']; + + + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 14: " . pg_last_error($conn)); + $link = 10; + } +} +//############### FINE PROCEDURA PASSI ############### + +//############### INIZIO PROCEDURA CIVICI ############### +if ($_SESSION['TAB'] == "topo_civici") { + + echo 'id = '.$_POST['id'].'
'; + echo 'cod_civ = '.$_POST['cod_civ'].'
'; + echo 'accesso = '.$_POST['accesso'].'
'; + echo 'tipo_dest = '.$_POST['tipo_dest'].'
'; + echo 'tipo_civ = '.$_POST['tipo_civ'].'
'; + echo 'civico = '.$_POST['civico'].'
'; + echo 'esponente = '.$_POST['esponente'].'
'; + echo 'id_topo = '.$_POST['id_topo'].'
'; + echo 'toponom = '.$_POST['toponom'].'
'; + echo 'dispari = '.$_POST['dispari'].'
'; + + if (intval($_POST['civico']) % 2 == 0 ) { + $dispari = "PARI"; + } else { + $dispari = "DISPARI"; + } + + echo 'x_civ = '.$_POST['x_civ'].'
'; + echo 'y_civ = '.$_POST['y_civ'].'
'; + echo 'note = '.$_POST['note'].'
'; + echo 'passo_id = '.$_POST['passo_id'].'
'; + + if(!$query3 = @pg_query("SELECT dug, duf FROM ".strtolower($_SESSION['COMUNE_BELF']).".toponomastica WHERE gis_id =".$_POST['id_topo']."")) + die("ERROR STR2: " . pg_last_error($conn)); + while($row3 = pg_fetch_assoc($query3)) { + $toponom = $row3['dug']." ".$row3['duf']; + } + + if(!$query4 = @pg_query("SELECT ST_X(ST_TRANSFORM(the_geom,4326)) AS x_civ, ST_Y(ST_TRANSFORM(the_geom,4326)) AS y_civ FROM ".strtolower($_SESSION['COMUNE_BELF']).".topo_civici WHERE id =".$_POST['id']."")) + die("ERROR STR2: " . pg_last_error($conn)); + while($row4 = pg_fetch_assoc($query4)) { + $x_civ = $row4['x_civ']; + $y_civ = $row4['y_civ']; + } + + if ($_POST['cod_civ'] == ""){ $_POST['cod_civ'] = '-'; } + if ($_POST['tipo_dest'] == ""){ $_POST['tipo_dest'] = '-'; } + if ($_POST['tipo_civ'] == ""){ $_POST['tipo_civ'] = '-'; } + if ($_POST['civico'] == ""){ $_POST['civico'] = '-'; } + if ($_POST['esponente'] == ""){ $_POST['esponente'] = '-'; } + if ($_POST['dispari'] == ""){ $_POST['dispari'] = '-'; } + if ($_POST['note'] == ""){ $_POST['note'] = '-'; } else { $_POST['note'] = str_replace("'", "’" ,$_POST['note']); } + +if ($mode == "edit") { + + if(!$rs_update = @pg_query("UPDATE ".strtolower($_SESSION['COMUNE_BELF']).".topo_civici SET cod_civ='".$_POST['cod_civ']."', accesso='".$_POST['accesso']."', tipo_dest='".$_POST['tipo_dest']."', tipo_civ='".$_POST['tipo_civ']."', civico='".$_POST['civico']."', esponente='".$_POST['esponente']."', id_topo=".$_POST['id_topo'].", toponom='".$toponom."', dispari='".$dispari."', x_civ=".$x_civ.", y_civ=".$y_civ.", note='".$_POST['note']."', data_agg='".date("Y-m-d h:i:sa", time())."' WHERE id = ".$_SESSION['TABID']."")) + + die("ERROR 14_B: " . pg_last_error($conn)); + + if(!$log = @pg_query("INSERT INTO public.auditlog ". + " (data,page,username,action,tab,rec_id,ip) ". + " VALUES('".date("Y-m-d h:i:sa", time())."','".basename($_SERVER['PHP_SELF'])."','".$_SESSION['USER_NAME']."',". + " 'UPDATE RECORD','".$_SESSION['TAB']."',".$_SESSION['TABID'].",'".$_SERVER['REMOTE_ADDR']."');")) + die("ERROR 14: " . pg_last_error($conn)); + $link = 4; + } +} +//############### FINE PROCEDURA CIVICI ############### + + +if ($type == "sub") { +header("location: blank.php?msg=del_ok"); + +} else { + + switch ($link) { + case 1: + $url = "detail_sub.php?idsub=".$_SESSION['TABID']."&subtab=".$_SESSION['SUBTAB']."&action2=subview"; + break; + case 3: + $url = "cdu/cdu2.php?id=".$_SESSION['TABID']; + break; + case 4: + $url = "dataview.php?id=".$_SESSION['TABID']."&obj=".$_SESSION['OBJ'].""; + //$url = $urllist; + break; + case 5: + $url = "client?obj=cly"; + break; + case 6: + $url = "listdata?obj=usr"; + break; + case 7: + $url = "dataview?obj=usr&id=".$_SESSION['TABID'].""; + break; + case 8: + $url = "dataview?obj=ordi&id=".$_SESSION['TABID'].""; + break; + case 9: + $url = "dataview?obj=inte&id=".$_SESSION['TABID'].""; + break; + case 10: + $url = "dataview?obj=".$_SESSION['OBJ']."&id=".$_POST['id']."&idciv=".$_SESSION['TABID'].""; + break; + default: + $type_query = ""; + $link = 1; +} + + header("location: ".$url.""); + //echo "
".$url; + +} +?> \ No newline at end of file