source: trunk/client/inc/javascript.php@ 352

Last change on this file since 352 was 347, checked in by roby, 3 years ago

Aggiornamento per compatibilità con php7.4

File size: 4.0 KB
Line 
1<?php
2/************************************************************************/
3/* Eleonline - Raccolta e diffusione dei dati elettorali */
4/* by Luciano Apolito & Roberto Gigli */
5/* http://www.eleonline.it */
6/* info@eleonline.it luciano@aniene.net rgigli@libero.it */
7/************************************************************************/
8
9if (stristr(htmlentities($_SERVER['PHP_SELF']), "javascript.php")) {
10 Header("Location: ../index.php");
11 die();
12}
13
14##################################################
15# Include funzioni javascript #
16##################################################
17#timer per tema tour
18# inizio rotazione
19if (isset($_SESSION['ruota']))
20{
21?>
22
23 <script type="text/javascript" language="javascript">
24<!--
25function loadpage() {
26
27thetimer = setTimeout("changepage()", 20000);
28
29
30}
31
32function changepage() {
33
34newlocation = "<?php echo "modules.php?csv=1&block=0&id_cons_gen=".$_GET['id_cons_gen']."&id_comune=".$_GET['id_comune']; ?>"
35location = newlocation
36}
37// --></script>
38
39<?php
40}
41# fine rotazione
42# googlemaps per sezioni
43# variabili nel config.php
44# gkey= chiave google informazioni su come reperirla per il proprio sito qui
45# https://cloud.google.com/maps-platform/user-guide/account-changes/#no-plan
46# googlemaps 1=attivo 2: disattivo
47# funzione by eleonline.it
48#########################################################
49
50
51
52
53
54
55
56function googlemaps(){
57global $dbi,$prefix,$id_comune,$googlemaps,$op,$gkey,$lang;
58# recupera gli inidirizzi
59 $id_sede=$_GET['id_sede'];
60 $sql="SELECT descrizione FROM ".$prefix."_ele_comuni where id_comune='$id_comune' ";
61 $res = $dbi->prepare("$sql");
62 $res->execute();
63 list($comune) = $res->fetch(PDO::FETCH_NUM);
64 $sql="SELECT indirizzo from ".$prefix."_ele_sede where id_sede='$id_sede' ";
65 $res = $dbi->prepare("$sql");
66 $res->execute();
67 list($indirizzo) = $res->fetch(PDO::FETCH_NUM);
68
69 $address=rawurlencode("$indirizzo,$comune,58047");
70
71 $resultGeoCode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$address.'&amp;sensor=false');
72 $output= json_decode($resultGeoCode);
73
74 if($output->status == 'OK'){
75 $latitude = $output->results[0]->geometry->location->lat; //Returns Latitude
76 $longitude = $output->results[0]->geometry->location->lng; // Returns Longitude
77 $location = $output->results[0]->formatted_address;
78 }else{
79 $latitude=0;
80 $longitude=0;
81 $location='';
82 }
83
84
85 $coords['lat'] = $latitude;
86 $coords['long'] = $longitude;
87
88
89
90
91
92/*
93
94
95
96
97 $url = sprintf('http://maps.google.com/maps?output=js&q=%s',rawurlencode($address));
98 $result = false;
99
100 if($result = file_get_contents($url)) {
101 $coords = array();
102
103 if(strpos($result,'errortips') > 1 || strpos($result,'Did you mean:') !== false) {
104 return false;
105 }
106
107 preg_match('!center:\s*{lat:\s*(-?\d+\.\d+),lng:\s*(-?\d+\.\d+)}!U', $result, $matches);
108
109 $coords['lat'] = $matches[1];
110 $coords['long'] = $matches[2];
111 }
112
113*/
114
115
116
117
118# type="text/javascript"
119
120
121echo '
122<script src="http://maps.google.com/maps/api/js?sensor=true&language=it"></script>
123 <script>
124 function maps() {
125 var latlng = new google.maps.LatLng('.$coords['lat'].','.$coords['long'].'); // centro della mappa
126 var myLatlng = new google.maps.LatLng('.$coords['lat'].','.$coords['long'].'); // segnapunto
127 // definizione della mappa
128 var myOptions = {
129 zoom: 16,
130 center: latlng,
131 mapTypeId: google.maps.MapTypeId.ROADMAP,
132 mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR}
133 }
134 mymap = new google.maps.Map(document.getElementById("map"), myOptions);
135 // definizione segnapunto
136 var marker = new google.maps.Marker({
137 position: myLatlng,
138 map: mymap,
139 title:"'.$address.'"
140 });
141
142 }
143 </script>
144';
145
146}
147?>
Note: See TracBrowser for help on using the repository browser.