1 : <?php
2 :
3 : include_once ("WSFW/lib/wsfw_db.php");
4 : include_once ("WSFW/wsfw_client.php");
5 : include_once ("lib/Panoramio.php");
6 :
7 : class creuRoja{
8 :
9 : private $db;
10 : private $ibiza_travel;
11 : private $panoramio;
12 :
13 : function __construct(){
14 6 : $this->db = new WSFW_Db('localhost', '3306', 'root', '1212lk12', 'evsplatges');
15 6 : $this->ibiza_travel = new WSFW_Client(array(
16 6 : "url" => 'http://webservice.ibiza.travel/soap/index.php?wsdl',
17 6 : "protocol" => "Soap")
18 6 : );
19 6 : $this->panoramio = new WSFW_Client(array(
20 6 : "url" => 'http://www.panoramio.com/map/get_panoramas.php',
21 6 : "protocol" => 'Panoramio')
22 6 : );
23 6 : }
24 :
25 :
26 : function get_beach($beach_id) {
27 0 : return $this->ibiza_travel->call("beach.get", array("beach_id"=>$beach_id, "lang_id"=>"es", "id" => "mj554sk90"));
28 : }
29 :
30 :
31 : function beaches_list() {
32 1 : $data = $this->ibiza_travel->call("ibizatravel.beaches_list", array("lang_id"=>"es", "id" => "mj554sk90"));
33 1 : $beach_list = array();
34 1 : foreach ($data as $beach_data) {
35 1 : $beach_data['estat']=$this->estat_platja($beach_data['beach_id']);
36 1 : $beach_data['foto']="";
37 1 : array_push($beach_list, $beach_data);
38 1 : }
39 1 : return $beach_list;
40 : }
41 :
42 :
43 : function estat_platja($id_beach){
44 :
45 5 : $idp=$this->db->select_unico(array("idp"),"playas","beach_id='$id_beach'");
46 5 : $id=$idp['idp'];
47 5 : $cs=array ("max(fecha) as Data","estado"); $tabla="lecturas,playas";$busqueda="lecturas.idp='$id'";
48 5 : $beach=$this->db->select_unico($cs, $tabla, $busqueda);
49 5 : return $beach;
50 : }
51 :
52 :
53 : function informacio_platja($params) {
54 4 : $params = objectToArray($params);
55 4 : $data = $this->ibiza_travel->call("beach.get", array("beach_id" =>$params['beach_id'],"lang_id"=>"es", "id" => "mj554sk90"));
56 :
57 :
58 4 : $info=$data;
59 :
60 4 : $info['estat']=$this->estat_platja($params['beach_id']);
61 :
62 :
63 4 : $data = $this->panoramio->call(null, array(
64 4 : "set" => "full",
65 4 : "from" => "0",
66 4 : "to" => "1",
67 4 : "minx" => $info["lat"]-0.5,
68 4 : "miny" => $info["lon"]-0.5,
69 4 : "maxx" => $info["lat"]+0.5,
70 4 : "maxy" => $info["lon"]+0.5,
71 4 : ));
72 4 : if ($data["count"]) $info["foto"] = $data["photos"][0];
73 :
74 4 : return $info;
75 : }
76 :
77 :
78 : function SetEstat_Platja($beach_id,$estat) {
79 0 : $cs=array ("id_beach"); $tabla="playas";$busqueda="id_beach=$beach_id";
80 0 : $platja=$this->db->select_unico($cs, $tabla, $busqueda, null, null);
81 0 : $campos=array('id_beach'=>$beach_id,'estat'=>$estat);
82 0 : if ($platja) $this->db->insert("lecturas", $campos);
83 0 : else echo "No existeix aquest identificador de platja";
84 0 : }
85 :
86 : }
87 :
88 : ?>
|