98 lines
2.9 KiB
PHP
98 lines
2.9 KiB
PHP
<?php
|
|
|
|
// inclusione del file contenente la classe
|
|
require_once "./include.php";
|
|
require_once "./myDropBoxObj.php";
|
|
//include "./SimpleImage.php";
|
|
|
|
$app->get('/photo/thumbnail/:imageID(/:noRedirect)', function ($imageID, $noRedirect = 0) use ($app, $dirRicetteDropBox) {
|
|
$mysqlconnetion = new MysqlClass;
|
|
|
|
$retObj = $mysqlconnetion->queryToObject("select type_format, id_ricette, thumb_link from immagini where id=" . $imageID, false);
|
|
$mysqlconnetion->disconnetti();
|
|
|
|
|
|
$ext = "png";
|
|
|
|
$retLink = $retObj["thumb_link"];
|
|
|
|
if($retLink == ""){
|
|
$folder = $dirRicetteDropBox . "/" . $retObj["id_ricette"];
|
|
|
|
$imageFileName = $imageID . "_thumb_ricetta." . $ext;
|
|
|
|
$dropBoxObj = new myDropBox();
|
|
|
|
$retLink = $dropBoxObj->GetLink($folder . "/" . $imageFileName);
|
|
}
|
|
|
|
if ($noRedirect) {
|
|
echo $retLink;
|
|
}
|
|
else
|
|
$app->response->redirect($retLink, 303);
|
|
});
|
|
|
|
|
|
$app->get('/photo/medium/:imageID(/:noRedirect)', function ($imageID, $noRedirect = 0) use ($app, $dirRicetteDropBox) {
|
|
$mysqlconnetion = new MysqlClass;
|
|
|
|
$retObj = $mysqlconnetion->queryToObject("select type_format, id_ricette, medium_link from immagini where id=" . $imageID, false);
|
|
$mysqlconnetion->disconnetti();
|
|
$ext = "";
|
|
if ($retObj["type_format"] == "image/jpeg") {
|
|
$ext = "jpeg";
|
|
} else if ($retObj["type_format"] == "image/png") {
|
|
$ext = "png";
|
|
}
|
|
|
|
$retLink = $retObj["medium_link"];
|
|
|
|
if($retLink == ""){
|
|
$folder = $dirRicetteDropBox . "/" . $retObj["id_ricette"];
|
|
|
|
$imageFileName = $imageID . "_medium_ricetta." . $ext;
|
|
|
|
$dropBoxObj = new myDropBox();
|
|
|
|
$retLink = $dropBoxObj->GetLink($folder . "/" . $imageFileName);
|
|
}
|
|
|
|
if ($noRedirect) {
|
|
echo $retLink;
|
|
}
|
|
else
|
|
$app->response->redirect($retLink, 303);
|
|
});
|
|
|
|
$app->get('/photo/:imageID(/:noRedirect)', function ($imageID, $noRedirect = 0) use ($app, $dirRicetteDropBox) {
|
|
$mysqlconnetion = new MysqlClass;
|
|
|
|
$retObj = $mysqlconnetion->queryToObject("select type_format, id_ricette, full_link from immagini where id=" . $imageID, false);
|
|
$mysqlconnetion->disconnetti();
|
|
$ext = "";
|
|
if ($retObj["type_format"] == "image/jpeg") {
|
|
$ext = "jpeg";
|
|
} else if ($retObj["type_format"] == "image/png") {
|
|
$ext = "png";
|
|
}
|
|
|
|
$retLink = $retObj["full_link"];
|
|
|
|
if($retLink == ""){
|
|
$folder = $dirRicetteDropBox . "/" . $retObj["id_ricette"];
|
|
|
|
$imageFileName = $imageID . "_full_ricetta." . $ext;
|
|
|
|
$dropBoxObj = new myDropBox();
|
|
|
|
$retLink = $dropBoxObj->GetLink($folder . "/" . $imageFileName);
|
|
}
|
|
|
|
if ($noRedirect) {
|
|
echo $retLink;
|
|
}
|
|
else
|
|
$app->response->redirect($retLink, 303);
|
|
});
|