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
|
||||
RewriteRule ^(.*)$ serviceapp.php [QSA,L]
|
||||
</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"
|
||||
+7
-7
@@ -2,16 +2,16 @@
|
||||
class MysqlClass
|
||||
{
|
||||
// parametri per la connessione al database
|
||||
/*private $nomehost = "mysql.hostinger.it";
|
||||
private $nomeuser = "u766568765_lpm";
|
||||
private $password = "8zX2gTIjfwXEdEgaSaWe";
|
||||
private $mydb = "u766568765_lpm";
|
||||
*/
|
||||
private $nomehost = "localhost";
|
||||
private $nomeuser = "root";
|
||||
private $password = "root";
|
||||
|
||||
/*
|
||||
private $nomehost = "sql.gruppolapastamadre.it";
|
||||
private $nomeuser = "w18092_ricuser";
|
||||
private $password = "RTvg0o6IESoqQyx8CCJn";
|
||||
private $mydb = "w18092_ricettario";
|
||||
|
||||
*/
|
||||
private $mydb = "w18092_ricettario";
|
||||
// controllo sulle connessioni attive
|
||||
private $attiva = false;
|
||||
private $connessione = null;
|
||||
|
||||
+4
-1
@@ -14,7 +14,10 @@ $app = new \Slim\Slim();
|
||||
|
||||
$app->hook('slim.before.router', function () use ($app, $allowedHost) {
|
||||
$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))
|
||||
{
|
||||
$app->halt(500, "Generic error occurred");
|
||||
|
||||
+5
-1
@@ -54,6 +54,10 @@ $app->get('/ricetta/body/:itemID', function ($itemID) use ($app) {
|
||||
"where ingredienti.ID_RICETTE = " . $itemID . " order by ingredienti.posizione";
|
||||
|
||||
$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]["procedimento"] = html_entity_decode($retObj[0]["procedimento"],ENT_COMPAT | ENT_HTML401,'ISO-8859-1');
|
||||
@@ -113,7 +117,7 @@ $app->post('/ricetta/body', function () use ($app) {
|
||||
foreach ($json_data_body->ingredienti as $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 (" .
|
||||
|
||||
+31
-15
@@ -4,6 +4,19 @@
|
||||
//include "./MySqlClass.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) {
|
||||
$callbackFn = $app->request()->get('callback');
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
@@ -18,10 +31,11 @@ $app->post('/profile/ricetta', function () use ($app) {
|
||||
$callbackFn = $app->request()->get('callback');
|
||||
$json_data_body = json_decode($app->request()->post('dataPair'));
|
||||
$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 . "')";
|
||||
$retNewID = $mysqlconnetion->insertRecord($query);
|
||||
$mysqlconnetion->disconnetti();
|
||||
|
||||
$mysqlconnetion->disconnetti();
|
||||
returnJson($app, $callbackFn, $retNewID);
|
||||
});
|
||||
|
||||
@@ -67,20 +81,22 @@ $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 from profilo" .
|
||||
$query = "select ProfiloID, TipoAccesso, RisultatiRicerca, TemaUI, Name, Gender, 0 as NumRicette, BloccoNoteUpdated from profilo" .
|
||||
" where ProfiloID = '" . $keyStore . "'";
|
||||
$retObj = $mysqlconnetion->queryToObject($query);
|
||||
|
||||
$query = "update profilo set PenultimoAccesso = UltimoAccesso, UltimoAccesso = NOW() where ProfiloID = '" . $keyStore . "'";
|
||||
$mysqlconnetion->insertRecord($query);
|
||||
|
||||
$query = "SELECT COUNT( * ) as NumRicette FROM ricette WHERE data_creazione > ( SELECT PenultimoAccesso FROM profilo " .
|
||||
"WHERE `ProfiloID` = '" . $keyStore . "' )";
|
||||
|
||||
$retObj2 = $mysqlconnetion->queryToObject($query);
|
||||
|
||||
$retObj[0]["NumRicette"] = $retObj2[0]["NumRicette"];
|
||||
|
||||
|
||||
if($retObj != false)
|
||||
{
|
||||
$query = "update profilo set PenultimoAccesso = UltimoAccesso, UltimoAccesso = NOW() where ProfiloID = '" . $keyStore . "'";
|
||||
$mysqlconnetion->insertRecord($query);
|
||||
|
||||
$query = "SELECT COUNT( * ) as NumRicette FROM ricette WHERE data_creazione > ( SELECT PenultimoAccesso FROM profilo " .
|
||||
"WHERE `ProfiloID` = '" . $keyStore . "' )";
|
||||
|
||||
$retObj2 = $mysqlconnetion->queryToObject($query);
|
||||
|
||||
$retObj[0]["NumRicette"] = $retObj2[0]["NumRicette"];
|
||||
}
|
||||
returnJson($app, $callbackFn, $retObj);
|
||||
});
|
||||
|
||||
@@ -88,7 +104,7 @@ $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 . "', '" . $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);
|
||||
$mysqlconnetion->disconnetti();
|
||||
|
||||
+29
-6
@@ -81,7 +81,6 @@ $app->get('/categoryitems/:categoryID/lastinserted(/:numItems)', function ($cate
|
||||
$app->get('/categoryitems/search/:numItems(/:categoryId(/:difficolta(/:titolo)))',
|
||||
function ($numItems = 10, $categoryId = 0, $difficolta = 0, $titolo = "") use ($app) {
|
||||
$callbackFn = $app->request()->get('callback');
|
||||
//$filterItem = json_decode($app->request()->post('post'));
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
$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"
|
||||
@@ -90,13 +89,14 @@ $app->get('/categoryitems/search/:numItems(/:categoryId(/:difficolta(/:titolo)))
|
||||
$query = $query . " AND ID_CATEGORIA = " . $categoryId;
|
||||
}
|
||||
if ($titolo != null && $titolo != "") {
|
||||
foreach (explode(" ", $titolo) as $ele)
|
||||
foreach (explode(" ", htmlentities(urldecode($titolo))) as $ele)
|
||||
$query = $query . " AND titolo like '%" . $ele . "%'";
|
||||
}
|
||||
if ($difficolta > 0) {
|
||||
$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);
|
||||
$mysqlconnetion->disconnetti();
|
||||
|
||||
@@ -106,6 +106,25 @@ $app->get('/categoryitems/search/:numItems(/:categoryId(/:difficolta(/:titolo)))
|
||||
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;
|
||||
@@ -122,6 +141,10 @@ $app->get('/ricetta/body/:itemID', function ($itemID) use ($app) {
|
||||
"where ingredienti.ID_RICETTE = " . $itemID . " order by ingredienti.posizione";
|
||||
|
||||
$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]["procedimento"] = html_entity_decode($retObj[0]["procedimento"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
|
||||
@@ -167,9 +190,9 @@ $app->get('/ricetta/ingredienti/:itemID', function ($itemID) use ($app) {
|
||||
|
||||
$retObj2 = $mysqlconnetion->queryToObject($query2);
|
||||
|
||||
//$retObj[0]["titolo"] = html_entity_decode($retObj[0]["titolo"]);
|
||||
//$retObj[0]["procedimento"] = html_entity_decode($retObj[0]["procedimento"]);
|
||||
//$retObj[0]["ingredienti"] = $retObj2;
|
||||
foreach ($retObj2 as $ele) {
|
||||
$ele["note"] = html_entity_decode($ele["note"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
|
||||
}
|
||||
|
||||
$mysqlconnetion->disconnetti();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user