From 98cd15fad632043ef20261ef2943e1939f7f8ae4 Mon Sep 17 00:00:00 2001 From: hexstudy Date: Sun, 31 Jan 2016 16:13:42 +0000 Subject: [PATCH] git-svn-id: https://msi/svn/firstRepo/Service/branches/Manut_2.2.3@58 0f545695-f87b-41b6-9a03-7f16563b5454 --- profile.php | 27 ++++++++++++++++++++++----- ricette.php | 37 ++++++++++++++++++------------------- spacciatoripm.php | 15 ++++++++++++++- 3 files changed, 54 insertions(+), 25 deletions(-) diff --git a/profile.php b/profile.php index b6e6ee7..566806b 100644 --- a/profile.php +++ b/profile.php @@ -81,12 +81,17 @@ $app->get('/profile/:keyStore/ricette', function ($keyStore) use ($app) { $app->get('/profile/:keyStore', function ($keyStore) use ($app) { $callbackFn = $app->request()->get('callback'); $mysqlconnetion = new MysqlClass; - $query = "SELECT ProfiloID,TipoAccesso,RisultatiRicerca,TemaUI,Name,Gender,0 AS NumRicette,BloccoNoteUpdated,Email,bSpacciatore,bPrivacy,Cap,Comune,Stato, Provincia,TipoPM, Latitudine, Longitudine from profilo" . + $query = "SELECT ProfiloID,TipoAccesso,RisultatiRicerca,TemaUI,Name,Gender,0 AS NumRicette,BloccoNoteUpdated,Email,bSpacciatore,bPrivacy,Cap,Comune,Stato, Provincia,TipoPM,Note, Latitudine, Longitudine from profilo" . " where ProfiloID = '" . $keyStore . "'"; - $retObj = $mysqlconnetion->queryToObject($query); + $retObj = $mysqlconnetion->queryToObject($query); if($retObj != false) { + $retObj[0]["Name"] = html_entity_decode($retObj[0]["Name"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1'); + $retObj[0]["Note"] = html_entity_decode($retObj[0]["Note"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1'); + $retObj[0]["Comune"] = html_entity_decode($retObj[0]["Comune"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1'); + $retObj[0]["Provincia"] = html_entity_decode($retObj[0]["Provincia"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1'); + $query = "update profilo set PenultimoAccesso = UltimoAccesso, UltimoAccesso = NOW() where ProfiloID = '" . $keyStore . "'"; $mysqlconnetion->insertRecord($query); @@ -110,6 +115,11 @@ $app->get('/profile/province(/:iniz)', function ($iniz = "") use ($app) { $retObj = $mysqlconnetion->queryToObject($query); $mysqlconnetion->disconnetti(); + foreach ($retObj as $ele) { + if($ele["Provincia"]!=null) + $ele["Provincia"] = html_entity_decode($ele["Provincia"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1'); + } + returnJson($app, $callbackFn, $retObj); }); @@ -123,6 +133,11 @@ $app->get('/profile/comuni/:prov(/:iniz)', function ($prov ,$iniz = "") use ($ap $retObj = $mysqlconnetion->queryToObject($query); $mysqlconnetion->disconnetti(); + foreach ($retObj as $ele) { + if($ele["Comune"]!=null) + $ele["Comune"] = html_entity_decode($ele["Comune"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1'); + } + returnJson($app, $callbackFn, $retObj); }); @@ -131,7 +146,8 @@ $app->post('/profile', function () use ($app) { $callbackFn = $app->request()->get('callback'); $json_data_body = json_decode($app->request()->post('dataPair')); $mysqlconnetion = new MysqlClass; - $query = "insert into profilo(ProfiloID, Name, Email, Gender, TipoAccesso, RisultatiRicerca, TemaUI, UltimoAccesso, CreatoIl) values ('" . $json_data_body->keyStore . "', '" . str_replace("'", "''", htmlentities($json_data_body->name, null, "UTF-8")) . "', '" . $json_data_body->email . "', '" . $json_data_body->gender . "', '" . $json_data_body->type . "', '" . $json_data_body->risRic . "', '" . $json_data_body->tema . "', NOW(), NOW())"; + $query = "insert into profilo(ProfiloID, Name, Email, Gender, TipoAccesso, RisultatiRicerca, TemaUI, UltimoAccesso, CreatoIl) values ('" . + $json_data_body->keyStore . "', '" . str_replace("'", "''", htmlentities($json_data_body->name, null, "UTF-8")) . "', '" . $json_data_body->email . "', '" . $json_data_body->gender . "', '" . $json_data_body->type . "', '" . $json_data_body->risRic . "', '" . $json_data_body->tema . "', NOW(), NOW())"; $retNewID = $mysqlconnetion->insertRecord($query); $mysqlconnetion->disconnetti(); @@ -150,8 +166,9 @@ $app->put('/profile', function () use ($app) { ", bPrivacy = " . $json_data_body->privacy . ", Cap = '" . $json_data_body->cap . "', Stato = '" . $json_data_body->stato . - "', Comune = '" . $json_data_body->comune . - "', Provincia = '" . $json_data_body->prov . + "', Comune = '" . htmlentities($json_data_body->comune, null, "UTF-8") . + "', Provincia = '" . htmlentities($json_data_body->prov, null, "UTF-8") . + "', Note = '" . htmlentities($json_data_body->note, null, "UTF-8") . "', TipoPM = " . $json_data_body->tipopm . ", Latitudine = " . $json_data_body->lat . ", Longitudine = " . $json_data_body->lng . diff --git a/ricette.php b/ricette.php index 11f7a2e..04aecc4 100644 --- a/ricette.php +++ b/ricette.php @@ -33,6 +33,24 @@ $app->get('/typeqtys', function () use ($app) { returnJson($app, $callbackFn, $retObj); }); +$app->get('/ricette/authors(/:startWith)', function ($startWith = "") use ($app) { + $callbackFn = $app->request()->get('callback'); + $mysqlconnetion = new MysqlClass; + $query = "select distinct autore from ricette" + . " where 1 = 1"; + + if ($startWith != null && $startWith != "") { + $query = $query . " AND autore like '%" . $startWith . "%'"; + } + + $query = $query . " order by autore"; + + $retObj = $mysqlconnetion->queryToObject($query); + $mysqlconnetion->disconnetti(); + + returnJson($app, $callbackFn, $retObj); +}); + $app->get('/ricette/:catID', function ($categoryID) use ($app) { $callbackFn = $app->request()->get('callback'); $mysqlconnetion = new MysqlClass; @@ -115,25 +133,6 @@ $app->get('/ricette/search/:numItems/:startItem(/:categoryId(/:difficolta(/:tito returnJson($app, $callbackFn, $retObj); }); -$app->get('/ricette/authors(/:startWith)', - function ($startWith = "") use ($app) { - $callbackFn = $app->request()->get('callback'); - $mysqlconnetion = new MysqlClass; - $query = "select distinct autore from ricette" - . " where 1 = 1"; - - if ($startWith != null && $startWith != "") { - $query = $query . " AND autore like '%" . $startWith . "%'"; - } - - $query = $query . " order by autore"; - - $retObj = $mysqlconnetion->queryToObject($query); - $mysqlconnetion->disconnetti(); - - returnJson($app, $callbackFn, $retObj); -}); - $app->get('/ricetta/body/:itemID', function ($itemID) use ($app) { $callbackFn = $app->request()->get('callback'); $mysqlconnetion = new MysqlClass; diff --git a/spacciatoripm.php b/spacciatoripm.php index 90d65dd..e0e1120 100644 --- a/spacciatoripm.php +++ b/spacciatoripm.php @@ -78,11 +78,24 @@ $app->get('/spacciatori/kml', function () use ($app) { $app->get('/spacciatori/bound/:FromLat/:FromLng/:ToLat/:ToLng', function ($FromLat, $FromLng, $ToLat, $ToLng) use ($app) { $callbackFn = $app->request()->get('callback'); $mysqlconnetion = new MysqlClass; - $query = "SELECT ProfiloID as ID, Name, Email, CONCAT(Comune, ', ', Cap, ' - ', Provincia) as Indirizzo, Latitudine, Longitudine, TipoPM FROM `profilo` " . + $query = "SELECT ProfiloID as ID, Name, Email, Comune, Cap, Provincia, Note, \"\" as Indirizzo, Latitudine, Longitudine, TipoPM FROM profilo " . "where bSpacciatore = 1 AND " . "Latitudine BETWEEN " . $ToLat . " AND " . $FromLat . " AND ". "Longitudine BETWEEN " . $ToLng . " AND " . $FromLng; $retObj = $mysqlconnetion->queryToObject($query); + + foreach ($retObj as $ele) { + if($ele["Name"]!=null) + $ele["Name"] = html_entity_decode($ele["Name"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1'); + if($ele["Note"]!=null) + $ele["Note"] = html_entity_decode($ele["Note"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1'); + if($ele["Comune"]!=null) + $ele["Comune"] = html_entity_decode($ele["Comune"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1'); + if($ele["Provincia"]!=null) + $ele["Provincia"] = html_entity_decode($ele["Provincia"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1'); + + $ele["Indirizzo"] = $ele["Comune"] . ", " . $ele["Cap"] . ", " . $ele["Provincia"]; + } $mysqlconnetion->disconnetti(); returnJson($app, $callbackFn, $retObj); }); \ No newline at end of file