git-svn-id: https://msi/svn/firstRepo/Service/branches/Manut_2.2.3@28 0f545695-f87b-41b6-9a03-7f16563b5454
This commit is contained in:
@@ -3,10 +3,3 @@
|
|||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
RewriteRule ^(.*)$ serviceapp.php [QSA,L]
|
RewriteRule ^(.*)$ serviceapp.php [QSA,L]
|
||||||
</ifModule>
|
</ifModule>
|
||||||
|
|
||||||
<Limit GET POST PUT DELETE>
|
|
||||||
Allow from *.gruppolapastamadre.it
|
|
||||||
</Limit>
|
|
||||||
|
|
||||||
Header set Access-Control-Allow-Origin *.gruppolapastamadre.it
|
|
||||||
Header set Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"
|
|
||||||
+6
-6
@@ -2,16 +2,16 @@
|
|||||||
class MysqlClass
|
class MysqlClass
|
||||||
{
|
{
|
||||||
// parametri per la connessione al database
|
// parametri per la connessione al database
|
||||||
/*private $nomehost = "mysql.hostinger.it";
|
private $nomehost = "localhost";
|
||||||
private $nomeuser = "u766568765_lpm";
|
private $nomeuser = "root";
|
||||||
private $password = "8zX2gTIjfwXEdEgaSaWe";
|
private $password = "root";
|
||||||
private $mydb = "u766568765_lpm";
|
|
||||||
*/
|
/*
|
||||||
private $nomehost = "sql.gruppolapastamadre.it";
|
private $nomehost = "sql.gruppolapastamadre.it";
|
||||||
private $nomeuser = "w18092_ricuser";
|
private $nomeuser = "w18092_ricuser";
|
||||||
private $password = "RTvg0o6IESoqQyx8CCJn";
|
private $password = "RTvg0o6IESoqQyx8CCJn";
|
||||||
|
*/
|
||||||
private $mydb = "w18092_ricettario";
|
private $mydb = "w18092_ricettario";
|
||||||
|
|
||||||
// controllo sulle connessioni attive
|
// controllo sulle connessioni attive
|
||||||
private $attiva = false;
|
private $attiva = false;
|
||||||
private $connessione = null;
|
private $connessione = null;
|
||||||
|
|||||||
+4
-1
@@ -14,7 +14,10 @@ $app = new \Slim\Slim();
|
|||||||
|
|
||||||
$app->hook('slim.before.router', function () use ($app, $allowedHost) {
|
$app->hook('slim.before.router', function () use ($app, $allowedHost) {
|
||||||
$currentRefererRequest = $app->request()->getReferer();
|
$currentRefererRequest = $app->request()->getReferer();
|
||||||
$currentRefererRequest = substr(substr($currentRefererRequest, 7), 0, strpos(substr($currentRefererRequest, 7), '/'));
|
$currentRefererRequest = substr($currentRefererRequest, 7); //Senza http://
|
||||||
|
$indexDoublePoint = strpos($currentRefererRequest, ':');
|
||||||
|
$indexFirstSlash = strpos($currentRefererRequest, '/');
|
||||||
|
$currentRefererRequest = substr($currentRefererRequest, 0, $indexDoublePoint > 0 && $indexDoublePoint < $indexFirstSlash ? $indexDoublePoint : $indexFirstSlash );
|
||||||
if(!in_array($currentRefererRequest, $allowedHost))
|
if(!in_array($currentRefererRequest, $allowedHost))
|
||||||
{
|
{
|
||||||
$app->halt(500, "Generic error occurred");
|
$app->halt(500, "Generic error occurred");
|
||||||
|
|||||||
+5
-1
@@ -55,6 +55,10 @@ $app->get('/ricetta/body/:itemID', function ($itemID) use ($app) {
|
|||||||
|
|
||||||
$retObj2 = $mysqlconnetion->queryToObject($query2);
|
$retObj2 = $mysqlconnetion->queryToObject($query2);
|
||||||
|
|
||||||
|
foreach ($retObj2 as $ele) {
|
||||||
|
$ele["note"] = html_entity_decode($ele["note"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
|
||||||
|
}
|
||||||
|
|
||||||
$retObj[0]["titolo"] = html_entity_decode($retObj[0]["titolo"],ENT_COMPAT | ENT_HTML401,'ISO-8859-1');
|
$retObj[0]["titolo"] = html_entity_decode($retObj[0]["titolo"],ENT_COMPAT | ENT_HTML401,'ISO-8859-1');
|
||||||
$retObj[0]["procedimento"] = html_entity_decode($retObj[0]["procedimento"],ENT_COMPAT | ENT_HTML401,'ISO-8859-1');
|
$retObj[0]["procedimento"] = html_entity_decode($retObj[0]["procedimento"],ENT_COMPAT | ENT_HTML401,'ISO-8859-1');
|
||||||
$retObj[0]["ingredienti"] = $retObj2;
|
$retObj[0]["ingredienti"] = $retObj2;
|
||||||
@@ -113,7 +117,7 @@ $app->post('/ricetta/body', function () use ($app) {
|
|||||||
foreach ($json_data_body->ingredienti as $arr) {
|
foreach ($json_data_body->ingredienti as $arr) {
|
||||||
$note = "";
|
$note = "";
|
||||||
if ($arr->note != "") {
|
if ($arr->note != "") {
|
||||||
$note = str_replace("'", "''", htmlentities($arr->note));
|
$note = str_replace("'", "''", htmlentities($arr->note, null, "UTF-8"));
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = "insert into ingredienti(ID_TIPO_INGREDIENTI, ID_RICETTE, Quantita, ID_TIPO_QUANTITA, Note, Posizione) values (" .
|
$query = "insert into ingredienti(ID_TIPO_INGREDIENTI, ID_RICETTE, Quantita, ID_TIPO_QUANTITA, Note, Posizione) values (" .
|
||||||
|
|||||||
+20
-4
@@ -4,6 +4,19 @@
|
|||||||
//include "./MySqlClass.php";
|
//include "./MySqlClass.php";
|
||||||
//include "./utility.php";
|
//include "./utility.php";
|
||||||
|
|
||||||
|
$app->get('/profile/statusCache', function () use ($app) {
|
||||||
|
$callbackFn = $app->request()->get('callback');
|
||||||
|
$mysqlconnetion = new MysqlClass;
|
||||||
|
$query = "select 0 as ID_CATEGORIA, MAX(Data_creazione) as LastDateModified from categorie" .
|
||||||
|
" UNION" .
|
||||||
|
" select ID_CATEGORIA, MAX(Data_creazione) as LastDateModified from ricette" .
|
||||||
|
" GROUP BY ID_CATEGORIA";
|
||||||
|
$retObj = $mysqlconnetion->queryToObject($query);
|
||||||
|
$mysqlconnetion->disconnetti();
|
||||||
|
|
||||||
|
returnJson($app, $callbackFn, $retObj);
|
||||||
|
});
|
||||||
|
|
||||||
$app->get('/profile/:keyStore/ricetta/:ricetta_id', function ($keyStore, $ricetta_id) use ($app) {
|
$app->get('/profile/:keyStore/ricetta/:ricetta_id', function ($keyStore, $ricetta_id) use ($app) {
|
||||||
$callbackFn = $app->request()->get('callback');
|
$callbackFn = $app->request()->get('callback');
|
||||||
$mysqlconnetion = new MysqlClass;
|
$mysqlconnetion = new MysqlClass;
|
||||||
@@ -18,10 +31,11 @@ $app->post('/profile/ricetta', function () use ($app) {
|
|||||||
$callbackFn = $app->request()->get('callback');
|
$callbackFn = $app->request()->get('callback');
|
||||||
$json_data_body = json_decode($app->request()->post('dataPair'));
|
$json_data_body = json_decode($app->request()->post('dataPair'));
|
||||||
$mysqlconnetion = new MysqlClass;
|
$mysqlconnetion = new MysqlClass;
|
||||||
|
$query = "update profilo set BloccoNoteUpdated = CURRENT_TIMESTAMP WHERE ProfiloID = '" . $json_data_body->keyStore . "'";
|
||||||
|
$retNewID = $mysqlconnetion->insertRecord($query);
|
||||||
$query = "insert into blocco_note(ricetta_id, ProfiloID) values (" . $json_data_body->ricetta_id . ", '" . $json_data_body->keyStore . "')";
|
$query = "insert into blocco_note(ricetta_id, ProfiloID) values (" . $json_data_body->ricetta_id . ", '" . $json_data_body->keyStore . "')";
|
||||||
$retNewID = $mysqlconnetion->insertRecord($query);
|
$retNewID = $mysqlconnetion->insertRecord($query);
|
||||||
$mysqlconnetion->disconnetti();
|
$mysqlconnetion->disconnetti();
|
||||||
|
|
||||||
returnJson($app, $callbackFn, $retNewID);
|
returnJson($app, $callbackFn, $retNewID);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -67,10 +81,12 @@ $app->get('/profile/:keyStore/ricette', function ($keyStore) use ($app) {
|
|||||||
$app->get('/profile/:keyStore', function ($keyStore) use ($app) {
|
$app->get('/profile/:keyStore', function ($keyStore) use ($app) {
|
||||||
$callbackFn = $app->request()->get('callback');
|
$callbackFn = $app->request()->get('callback');
|
||||||
$mysqlconnetion = new MysqlClass;
|
$mysqlconnetion = new MysqlClass;
|
||||||
$query = "select ProfiloID, TipoAccesso, RisultatiRicerca, TemaUI, Name, Gender, 0 as NumRicette from profilo" .
|
$query = "select ProfiloID, TipoAccesso, RisultatiRicerca, TemaUI, Name, Gender, 0 as NumRicette, BloccoNoteUpdated from profilo" .
|
||||||
" where ProfiloID = '" . $keyStore . "'";
|
" where ProfiloID = '" . $keyStore . "'";
|
||||||
$retObj = $mysqlconnetion->queryToObject($query);
|
$retObj = $mysqlconnetion->queryToObject($query);
|
||||||
|
|
||||||
|
if($retObj != false)
|
||||||
|
{
|
||||||
$query = "update profilo set PenultimoAccesso = UltimoAccesso, UltimoAccesso = NOW() where ProfiloID = '" . $keyStore . "'";
|
$query = "update profilo set PenultimoAccesso = UltimoAccesso, UltimoAccesso = NOW() where ProfiloID = '" . $keyStore . "'";
|
||||||
$mysqlconnetion->insertRecord($query);
|
$mysqlconnetion->insertRecord($query);
|
||||||
|
|
||||||
@@ -80,7 +96,7 @@ $app->get('/profile/:keyStore', function ($keyStore) use ($app) {
|
|||||||
$retObj2 = $mysqlconnetion->queryToObject($query);
|
$retObj2 = $mysqlconnetion->queryToObject($query);
|
||||||
|
|
||||||
$retObj[0]["NumRicette"] = $retObj2[0]["NumRicette"];
|
$retObj[0]["NumRicette"] = $retObj2[0]["NumRicette"];
|
||||||
|
}
|
||||||
returnJson($app, $callbackFn, $retObj);
|
returnJson($app, $callbackFn, $retObj);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -88,7 +104,7 @@ $app->post('/profile', function () use ($app) {
|
|||||||
$callbackFn = $app->request()->get('callback');
|
$callbackFn = $app->request()->get('callback');
|
||||||
$json_data_body = json_decode($app->request()->post('dataPair'));
|
$json_data_body = json_decode($app->request()->post('dataPair'));
|
||||||
$mysqlconnetion = new MysqlClass;
|
$mysqlconnetion = new MysqlClass;
|
||||||
$query = "insert into profilo(ProfiloID, Name, Email, Gender, TipoAccesso, RisultatiRicerca, TemaUI, UltimoAccesso, CreatoIl) values ('" . $json_data_body->keyStore . "', '" . $json_data_body->name . "', '" . $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("'", "''",$json_data_body->name) . "', '" . $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);
|
$retNewID = $mysqlconnetion->insertRecord($query);
|
||||||
$mysqlconnetion->disconnetti();
|
$mysqlconnetion->disconnetti();
|
||||||
|
|||||||
+28
-5
@@ -81,7 +81,6 @@ $app->get('/categoryitems/:categoryID/lastinserted(/:numItems)', function ($cate
|
|||||||
$app->get('/categoryitems/search/:numItems(/:categoryId(/:difficolta(/:titolo)))',
|
$app->get('/categoryitems/search/:numItems(/:categoryId(/:difficolta(/:titolo)))',
|
||||||
function ($numItems = 10, $categoryId = 0, $difficolta = 0, $titolo = "") use ($app) {
|
function ($numItems = 10, $categoryId = 0, $difficolta = 0, $titolo = "") use ($app) {
|
||||||
$callbackFn = $app->request()->get('callback');
|
$callbackFn = $app->request()->get('callback');
|
||||||
//$filterItem = json_decode($app->request()->post('post'));
|
|
||||||
$mysqlconnetion = new MysqlClass;
|
$mysqlconnetion = new MysqlClass;
|
||||||
$query = "select ricette.ID as ricetta_id, categorie.name AS categoria_name, titolo, autore, valutazione, difficolta from ricette"
|
$query = "select ricette.ID as ricetta_id, categorie.name AS categoria_name, titolo, autore, valutazione, difficolta from ricette"
|
||||||
. " INNER JOIN categorie ON categorie.ID = ricette.id_categoria"
|
. " INNER JOIN categorie ON categorie.ID = ricette.id_categoria"
|
||||||
@@ -90,13 +89,14 @@ $app->get('/categoryitems/search/:numItems(/:categoryId(/:difficolta(/:titolo)))
|
|||||||
$query = $query . " AND ID_CATEGORIA = " . $categoryId;
|
$query = $query . " AND ID_CATEGORIA = " . $categoryId;
|
||||||
}
|
}
|
||||||
if ($titolo != null && $titolo != "") {
|
if ($titolo != null && $titolo != "") {
|
||||||
foreach (explode(" ", $titolo) as $ele)
|
foreach (explode(" ", htmlentities(urldecode($titolo))) as $ele)
|
||||||
$query = $query . " AND titolo like '%" . $ele . "%'";
|
$query = $query . " AND titolo like '%" . $ele . "%'";
|
||||||
}
|
}
|
||||||
if ($difficolta > 0) {
|
if ($difficolta > 0) {
|
||||||
$query = $query . " AND difficolta = " . $difficolta;
|
$query = $query . " AND difficolta = " . $difficolta;
|
||||||
}
|
}
|
||||||
$query = $query . " order by titolo, autore LIMIT " . $numItems;
|
$query = $query . " order by titolo, autore LIMIT " . $numItems;
|
||||||
|
|
||||||
$retObj = $mysqlconnetion->queryToObject($query);
|
$retObj = $mysqlconnetion->queryToObject($query);
|
||||||
$mysqlconnetion->disconnetti();
|
$mysqlconnetion->disconnetti();
|
||||||
|
|
||||||
@@ -106,6 +106,25 @@ $app->get('/categoryitems/search/:numItems(/:categoryId(/:difficolta(/:titolo)))
|
|||||||
returnJson($app, $callbackFn, $retObj);
|
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) {
|
$app->get('/ricetta/body/:itemID', function ($itemID) use ($app) {
|
||||||
$callbackFn = $app->request()->get('callback');
|
$callbackFn = $app->request()->get('callback');
|
||||||
$mysqlconnetion = new MysqlClass;
|
$mysqlconnetion = new MysqlClass;
|
||||||
@@ -123,6 +142,10 @@ $app->get('/ricetta/body/:itemID', function ($itemID) use ($app) {
|
|||||||
|
|
||||||
$retObj2 = $mysqlconnetion->queryToObject($query2);
|
$retObj2 = $mysqlconnetion->queryToObject($query2);
|
||||||
|
|
||||||
|
foreach ($retObj2 as $ele) {
|
||||||
|
$ele["note"] = html_entity_decode($ele["note"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
|
||||||
|
}
|
||||||
|
|
||||||
$retObj[0]["titolo"] = html_entity_decode($retObj[0]["titolo"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
|
$retObj[0]["titolo"] = html_entity_decode($retObj[0]["titolo"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
|
||||||
$retObj[0]["procedimento"] = html_entity_decode($retObj[0]["procedimento"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
|
$retObj[0]["procedimento"] = html_entity_decode($retObj[0]["procedimento"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
|
||||||
$retObj[0]["ingredienti"] = $retObj2;
|
$retObj[0]["ingredienti"] = $retObj2;
|
||||||
@@ -167,9 +190,9 @@ $app->get('/ricetta/ingredienti/:itemID', function ($itemID) use ($app) {
|
|||||||
|
|
||||||
$retObj2 = $mysqlconnetion->queryToObject($query2);
|
$retObj2 = $mysqlconnetion->queryToObject($query2);
|
||||||
|
|
||||||
//$retObj[0]["titolo"] = html_entity_decode($retObj[0]["titolo"]);
|
foreach ($retObj2 as $ele) {
|
||||||
//$retObj[0]["procedimento"] = html_entity_decode($retObj[0]["procedimento"]);
|
$ele["note"] = html_entity_decode($ele["note"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
|
||||||
//$retObj[0]["ingredienti"] = $retObj2;
|
}
|
||||||
|
|
||||||
$mysqlconnetion->disconnetti();
|
$mysqlconnetion->disconnetti();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user