Compare commits
5
Commits
7a8491c572
...
6754a2060b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6754a2060b | ||
|
|
9533309b58 | ||
|
|
d20b6a6758 | ||
|
|
b3bbd9d1f6 | ||
|
|
4170597626 |
+18
-3
@@ -18,6 +18,21 @@ $app->get('/photo/publish/:imageID', function ($imageID) use ($app) {
|
|||||||
$mysqlconnetion->disconnetti();
|
$mysqlconnetion->disconnetti();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$app->get('/photo/set_cover/:imageID', function ($imageID) use ($app) {
|
||||||
|
$mysqlconnetion = new MysqlClass;
|
||||||
|
|
||||||
|
$query = "select id_ricette from immagini where id = " . $imageID;
|
||||||
|
$retObj = $mysqlconnetion->queryToObject($query, false);
|
||||||
|
|
||||||
|
$query = "update immagini set bCover = 0 where id_ricette = " . $retObj["id_ricette"];
|
||||||
|
$mysqlconnetion->insertRecord($query);
|
||||||
|
|
||||||
|
$query = "update immagini set bCover = 1 where id = " . $imageID;
|
||||||
|
$mysqlconnetion->insertRecord($query);
|
||||||
|
|
||||||
|
$mysqlconnetion->disconnetti();
|
||||||
|
});
|
||||||
|
|
||||||
$app->delete('/photo/:imageID', function ($imageID) use ($app,$dirRicetteDropBox) {
|
$app->delete('/photo/:imageID', function ($imageID) use ($app,$dirRicetteDropBox) {
|
||||||
$mysqlconnetion = new MysqlClass;
|
$mysqlconnetion = new MysqlClass;
|
||||||
|
|
||||||
@@ -55,9 +70,9 @@ $app->post('/photo', function () use ($app, $dirRicetteDropBox) {
|
|||||||
// istanza della classe
|
// istanza della classe
|
||||||
$mysqlconnetion = new MysqlClass;
|
$mysqlconnetion = new MysqlClass;
|
||||||
//$mysqlconneti on->connetti();
|
//$mysqlconneti on->connetti();
|
||||||
$query = "insert into immagini(id_ricette, type_format, from_profile_id, uploaded_date) " .
|
$query = "insert into immagini(id_ricette, type_format, from_profile_id, uploaded_date, bCover) " .
|
||||||
"values(" . $idRicette . ", '" . image_type_to_mime_type(exif_imagetype($tmpFileName)) .
|
"values(" . $idRicette . ", '" . image_type_to_mime_type(exif_imagetype($tmpFileName)) .
|
||||||
"', '" . $profileID . "', NOW())";
|
"', '" . $profileID . "', NOW(), 0)";
|
||||||
$newID = $mysqlconnetion->insertRecord($query);
|
$newID = $mysqlconnetion->insertRecord($query);
|
||||||
$ext = image_type_to_extension(exif_imagetype($tmpFileName), FALSE);
|
$ext = image_type_to_extension(exif_imagetype($tmpFileName), FALSE);
|
||||||
|
|
||||||
@@ -76,7 +91,7 @@ $app->post('/photo', function () use ($app, $dirRicetteDropBox) {
|
|||||||
|
|
||||||
$thumb_link = makeThumbImage($dropBoxObj, $layer, 80, dirname($tmpFileName), $thumbFileName, $folder);
|
$thumb_link = makeThumbImage($dropBoxObj, $layer, 80, dirname($tmpFileName), $thumbFileName, $folder);
|
||||||
|
|
||||||
$query = "update immagini set (thumb_link = '" . $thumb_link . "', medium_link ='" . $medium_link . "', full_link = '" . $full_link ."' )" .
|
$query = "update immagini set thumb_link = '" . $thumb_link . "', medium_link ='" . $medium_link . "', full_link = '" . $full_link ."'" .
|
||||||
" where id=" . $newID;
|
" where id=" . $newID;
|
||||||
|
|
||||||
$newID = $mysqlconnetion->insertRecord($query);
|
$newID = $mysqlconnetion->insertRecord($query);
|
||||||
|
|||||||
+1
-1
@@ -191,7 +191,7 @@ $app->get('/photos/', function () use ($app) {
|
|||||||
$app->get('/ricetta/:itemID/photos', function ($itemID) use ($app) {
|
$app->get('/ricetta/:itemID/photos', function ($itemID) use ($app) {
|
||||||
$callbackFn = $app->request()->get('callback');
|
$callbackFn = $app->request()->get('callback');
|
||||||
|
|
||||||
$query = "SELECT id as id_photo, type_format, from_profile_id, uploaded_date, profilo.Name as profile_name, published from immagini" .
|
$query = "SELECT id as id_photo, type_format, from_profile_id, uploaded_date, profilo.Name as profile_name, published, bCover from immagini" .
|
||||||
" INNER JOIN profilo ON profilo.ProfiloID = immagini.from_profile_id".
|
" INNER JOIN profilo ON profilo.ProfiloID = immagini.from_profile_id".
|
||||||
" WHERE id_ricette = " . $itemID;
|
" WHERE id_ricette = " . $itemID;
|
||||||
|
|
||||||
|
|||||||
+13
-4
@@ -56,7 +56,8 @@ $app->get('/ricette/:catID', function ($categoryID) use ($app) {
|
|||||||
$mysqlconnetion = new MysqlClass;
|
$mysqlconnetion = new MysqlClass;
|
||||||
//$mysqlconnetion->connetti();
|
//$mysqlconnetion->connetti();
|
||||||
$query = "select * from (select ID as ricetta_id, titolo, autore, valutazione, difficolta, " .
|
$query = "select * from (select ID as ricetta_id, titolo, autore, valutazione, difficolta, " .
|
||||||
"(select id from immagini where immagini.id_ricette = ricette.id and published = 1 order by published_date limit 1) as firstImage " .
|
"(select id from immagini where immagini.id_ricette = ricette.id and bCover = 1) as firstImage, " .
|
||||||
|
"(select count(id) from immagini where immagini.id_ricette = ricette.id) as countImages " .
|
||||||
"from ricette where ricette.ID_CATEGORIA = " . $categoryID . " order by titolo, autore) as TMP";
|
"from ricette where ricette.ID_CATEGORIA = " . $categoryID . " order by titolo, autore) as TMP";
|
||||||
$retObj = $mysqlconnetion->queryToObject($query);
|
$retObj = $mysqlconnetion->queryToObject($query);
|
||||||
$mysqlconnetion->disconnetti();
|
$mysqlconnetion->disconnetti();
|
||||||
@@ -98,8 +99,8 @@ $app->get('/ricette/:categoryID/lastinserted(/:numItems)', function ($categoryID
|
|||||||
returnJson($app, $callbackFn, $retObj);
|
returnJson($app, $callbackFn, $retObj);
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->get('/ricette/search/:numItems/:startItem(/:categoryId(/:difficolta(/:titolo)))',
|
$app->get('/ricette/search/:numItems/:startItem(/:categoryId(/:difficolta/:autore(/:titolo)))',
|
||||||
function ($numItems = 10, $startItem = 0, $categoryId = 0, $difficolta = 0, $titolo = "") use ($app) {
|
function ($numItems = 10, $startItem = 0, $categoryId = 0, $difficolta = 0,$autore="_", $titolo = "") use ($app) {
|
||||||
$callbackFn = $app->request()->get('callback');
|
$callbackFn = $app->request()->get('callback');
|
||||||
$mysqlconnetion = new MysqlClass;
|
$mysqlconnetion = new MysqlClass;
|
||||||
$queryBase = " from ricette"
|
$queryBase = " from ricette"
|
||||||
@@ -108,6 +109,10 @@ $app->get('/ricette/search/:numItems/:startItem(/:categoryId(/:difficolta(/:tito
|
|||||||
if ($categoryId > 0) {
|
if ($categoryId > 0) {
|
||||||
$queryBase = $queryBase . " AND ID_CATEGORIA = " . $categoryId;
|
$queryBase = $queryBase . " AND ID_CATEGORIA = " . $categoryId;
|
||||||
}
|
}
|
||||||
|
if ($autore != null && $autore != "_") {
|
||||||
|
foreach (explode(" ", htmlentities(urldecode($autore))) as $ele)
|
||||||
|
$queryBase = $queryBase . " AND autore like '%" . urldecode($ele) . "%'";
|
||||||
|
}
|
||||||
if ($titolo != null && $titolo != "") {
|
if ($titolo != null && $titolo != "") {
|
||||||
foreach (explode(" ", htmlentities(urldecode($titolo))) as $ele)
|
foreach (explode(" ", htmlentities(urldecode($titolo))) as $ele)
|
||||||
$queryBase = $queryBase . " AND titolo like '%" . $ele . "%'";
|
$queryBase = $queryBase . " AND titolo like '%" . $ele . "%'";
|
||||||
@@ -117,7 +122,11 @@ $app->get('/ricette/search/:numItems/:startItem(/:categoryId(/:difficolta(/:tito
|
|||||||
}
|
}
|
||||||
$queryBase = $queryBase . " order by titolo, autore";
|
$queryBase = $queryBase . " order by titolo, autore";
|
||||||
|
|
||||||
$query = "select ricette.ID as ricetta_id, categorie.name AS categoria_name, titolo, autore, valutazione, difficolta" . $queryBase . " LIMIT " . $numItems * $startItem . " , " . $numItems;
|
$query = "select * from (select ricette.ID as ricetta_id, categorie.name AS categoria_name, titolo, autore, valutazione, difficolta, " .
|
||||||
|
"(select id from immagini where immagini.id_ricette = ricette.id and bCover = 1) as firstImage, " .
|
||||||
|
"(select count(id) from immagini where immagini.id_ricette = ricette.id) as countImages" .
|
||||||
|
$queryBase . " LIMIT " . $numItems * $startItem . " , " . $numItems . ") as TMP";
|
||||||
|
|
||||||
$retObj2 = $mysqlconnetion->queryToObject($query);
|
$retObj2 = $mysqlconnetion->queryToObject($query);
|
||||||
|
|
||||||
$query = "select COUNT(*) as TotalRecords" . $queryBase;
|
$query = "select COUNT(*) as TotalRecords" . $queryBase;
|
||||||
|
|||||||
+11
-3
@@ -79,9 +79,17 @@ $app->get('/spacciatori/bound/:FromLat/:FromLng/:ToLat/:ToLng', function ($FromL
|
|||||||
$callbackFn = $app->request()->get('callback');
|
$callbackFn = $app->request()->get('callback');
|
||||||
$mysqlconnetion = new MysqlClass;
|
$mysqlconnetion = new MysqlClass;
|
||||||
$query = "SELECT ProfiloID as ID, Name, Email, Comune, Cap, Provincia, Note, \"\" 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 " .
|
"where bSpacciatore = 1 AND ";
|
||||||
"Latitudine BETWEEN " . $ToLat . " AND " . $FromLat . " AND ".
|
if($ToLat < $FromLat)
|
||||||
"Longitudine BETWEEN " . $ToLng . " AND " . $FromLng;
|
$query = $query . "Latitudine BETWEEN " . $ToLat . " AND " . $FromLat . " AND ";
|
||||||
|
else
|
||||||
|
$query = $query . "Latitudine BETWEEN " . $FromLat . " AND " . $ToLat . " AND ";
|
||||||
|
|
||||||
|
if($ToLng < $FromLng)
|
||||||
|
$query = $query . "Longitudine BETWEEN " . $ToLng . " AND " . $FromLng;
|
||||||
|
else
|
||||||
|
$query = $query . "Longitudine BETWEEN " . $FromLng . " AND " . $ToLng;
|
||||||
|
|
||||||
$retObj = $mysqlconnetion->queryToObject($query);
|
$retObj = $mysqlconnetion->queryToObject($query);
|
||||||
|
|
||||||
foreach ($retObj as $ele) {
|
foreach ($retObj as $ele) {
|
||||||
|
|||||||
+2
-2
@@ -97,7 +97,7 @@ function resizeImage($dropBoxObj, $layer, $size, $dir, $fileName, $dirDropBox)
|
|||||||
|
|
||||||
$dropBoxObj->UploadFile($fullPath, $dirDropBox . "/" . $fileName);
|
$dropBoxObj->UploadFile($fullPath, $dirDropBox . "/" . $fileName);
|
||||||
|
|
||||||
echo $dropBoxObj->GetLink($dirDropBox . "/" . $fileName);
|
return $dropBoxObj->GetLink($dirDropBox . "/" . $fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeThumbImage($dropBoxObj, $layer, $size, $dir, $fileName, $dirDropBox)
|
function makeThumbImage($dropBoxObj, $layer, $size, $dir, $fileName, $dirDropBox)
|
||||||
@@ -114,7 +114,7 @@ function makeThumbImage($dropBoxObj, $layer, $size, $dir, $fileName, $dirDropBox
|
|||||||
}
|
}
|
||||||
|
|
||||||
$dropBoxObj->UploadFile($fullPath, $dirDropBox . "/" . $fileName);
|
$dropBoxObj->UploadFile($fullPath, $dirDropBox . "/" . $fileName);
|
||||||
echo $dropBoxObj->GetLink($dirDropBox . "/" . $fileName);
|
return $dropBoxObj->GetLink($dirDropBox . "/" . $fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user