git-svn-id: https://msi/svn/firstRepo/Service/branches/Manut_2.2.3@70 0f545695-f87b-41b6-9a03-7f16563b5454
This commit is contained in:
@@ -8,34 +8,36 @@ require_once "./myDropBoxObj.php";
|
|||||||
$app->get('/photo/thumbnail/:imageID(/:noRedirect)', function ($imageID, $noRedirect = 0) use ($app, $dirRicetteDropBox) {
|
$app->get('/photo/thumbnail/:imageID(/:noRedirect)', function ($imageID, $noRedirect = 0) use ($app, $dirRicetteDropBox) {
|
||||||
$mysqlconnetion = new MysqlClass;
|
$mysqlconnetion = new MysqlClass;
|
||||||
|
|
||||||
$retObj = $mysqlconnetion->queryToObject("select type_format, id_ricette from immagini where id=" . $imageID, false);
|
$retObj = $mysqlconnetion->queryToObject("select type_format, id_ricette, thumb_link from immagini where id=" . $imageID, false);
|
||||||
$mysqlconnetion->disconnetti();
|
$mysqlconnetion->disconnetti();
|
||||||
|
|
||||||
|
|
||||||
$ext = "png";
|
$ext = "png";
|
||||||
/*if ($retObj["type_format"] == "image/jpeg") {
|
|
||||||
$ext = "jpeg";
|
$retLink = $retObj["thumb_link"];
|
||||||
} else if ($retObj["type_format"] == "image/png") {
|
|
||||||
$ext = "png";
|
if($retLink == ""){
|
||||||
}*/
|
|
||||||
$folder = $dirRicetteDropBox . "/" . $retObj["id_ricette"];
|
$folder = $dirRicetteDropBox . "/" . $retObj["id_ricette"];
|
||||||
|
|
||||||
$imageFileName = $imageID . "_thumb_ricetta." . $ext;
|
$imageFileName = $imageID . "_thumb_ricetta." . $ext;
|
||||||
|
|
||||||
$dropBoxObj = new myDropBox();
|
$dropBoxObj = new myDropBox();
|
||||||
|
|
||||||
|
$retLink = $dropBoxObj->GetLink($folder . "/" . $imageFileName);
|
||||||
|
}
|
||||||
|
|
||||||
if ($noRedirect) {
|
if ($noRedirect) {
|
||||||
echo $dropBoxObj->GetLink($folder . "/" . $imageFileName);
|
echo $retLink;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$app->response->redirect($dropBoxObj->GetLink($folder . "/" . $imageFileName), 303);
|
$app->response->redirect($retLink, 303);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$app->get('/photo/medium/:imageID(/:noRedirect)', function ($imageID, $noRedirect = 0) use ($app, $dirRicetteDropBox) {
|
$app->get('/photo/medium/:imageID(/:noRedirect)', function ($imageID, $noRedirect = 0) use ($app, $dirRicetteDropBox) {
|
||||||
$mysqlconnetion = new MysqlClass;
|
$mysqlconnetion = new MysqlClass;
|
||||||
|
|
||||||
$retObj = $mysqlconnetion->queryToObject("select type_format, id_ricette from immagini where id=" . $imageID, false);
|
$retObj = $mysqlconnetion->queryToObject("select type_format, id_ricette, medium_link from immagini where id=" . $imageID, false);
|
||||||
$mysqlconnetion->disconnetti();
|
$mysqlconnetion->disconnetti();
|
||||||
$ext = "";
|
$ext = "";
|
||||||
if ($retObj["type_format"] == "image/jpeg") {
|
if ($retObj["type_format"] == "image/jpeg") {
|
||||||
@@ -44,23 +46,29 @@ $app->get('/photo/medium/:imageID(/:noRedirect)', function ($imageID, $noRedirec
|
|||||||
$ext = "png";
|
$ext = "png";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$retLink = $retObj["medium_link"];
|
||||||
|
|
||||||
|
if($retLink == ""){
|
||||||
$folder = $dirRicetteDropBox . "/" . $retObj["id_ricette"];
|
$folder = $dirRicetteDropBox . "/" . $retObj["id_ricette"];
|
||||||
|
|
||||||
$imageFileName = $imageID . "_medium_ricetta." . $ext;
|
$imageFileName = $imageID . "_medium_ricetta." . $ext;
|
||||||
|
|
||||||
$dropBoxObj = new myDropBox();
|
$dropBoxObj = new myDropBox();
|
||||||
|
|
||||||
|
$retLink = $dropBoxObj->GetLink($folder . "/" . $imageFileName);
|
||||||
|
}
|
||||||
|
|
||||||
if ($noRedirect) {
|
if ($noRedirect) {
|
||||||
echo $dropBoxObj->GetLink($folder . "/" . $imageFileName);
|
echo $retLink;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$app->response->redirect($dropBoxObj->GetLink($folder . "/" . $imageFileName), 303);
|
$app->response->redirect($retLink, 303);
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->get('/photo/:imageID(/:noRedirect)', function ($imageID, $noRedirect = 0) use ($app, $dirRicetteDropBox) {
|
$app->get('/photo/:imageID(/:noRedirect)', function ($imageID, $noRedirect = 0) use ($app, $dirRicetteDropBox) {
|
||||||
$mysqlconnetion = new MysqlClass;
|
$mysqlconnetion = new MysqlClass;
|
||||||
|
|
||||||
$retObj = $mysqlconnetion->queryToObject("select type_format, id_ricette from immagini where id=" . $imageID, false);
|
$retObj = $mysqlconnetion->queryToObject("select type_format, id_ricette, full_link from immagini where id=" . $imageID, false);
|
||||||
$mysqlconnetion->disconnetti();
|
$mysqlconnetion->disconnetti();
|
||||||
$ext = "";
|
$ext = "";
|
||||||
if ($retObj["type_format"] == "image/jpeg") {
|
if ($retObj["type_format"] == "image/jpeg") {
|
||||||
@@ -69,15 +77,21 @@ $app->get('/photo/:imageID(/:noRedirect)', function ($imageID, $noRedirect = 0)
|
|||||||
$ext = "png";
|
$ext = "png";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$retLink = $retObj["full_link"];
|
||||||
|
|
||||||
|
if($retLink == ""){
|
||||||
$folder = $dirRicetteDropBox . "/" . $retObj["id_ricette"];
|
$folder = $dirRicetteDropBox . "/" . $retObj["id_ricette"];
|
||||||
|
|
||||||
$imageFileName = $imageID . "_full_ricetta." . $ext;
|
$imageFileName = $imageID . "_full_ricetta." . $ext;
|
||||||
|
|
||||||
$dropBoxObj = new myDropBox();
|
$dropBoxObj = new myDropBox();
|
||||||
|
|
||||||
|
$retLink = $dropBoxObj->GetLink($folder . "/" . $imageFileName);
|
||||||
|
}
|
||||||
|
|
||||||
if ($noRedirect) {
|
if ($noRedirect) {
|
||||||
echo $dropBoxObj->GetLink($folder . "/" . $imageFileName);
|
echo $retLink;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$app->response->redirect($dropBoxObj->GetLink($folder . "/" . $imageFileName), 303);
|
$app->response->redirect($retLink, 303);
|
||||||
});
|
});
|
||||||
|
|||||||
+88
-17
@@ -66,15 +66,20 @@ $app->post('/photo', function () use ($app, $dirRicetteDropBox) {
|
|||||||
|
|
||||||
$dropBoxObj = new myDropBox();
|
$dropBoxObj = new myDropBox();
|
||||||
|
|
||||||
resizeImage($dropBoxObj, $layer, 640, dirname($tmpFileName), $imageFileName, $folder);
|
$full_link = resizeImage($dropBoxObj, $layer, 640, dirname($tmpFileName), $imageFileName, $folder);
|
||||||
|
|
||||||
$imageMediumFileName = $newID . "_medium_ricetta." . $ext;
|
$imageMediumFileName = $newID . "_medium_ricetta." . $ext;
|
||||||
|
|
||||||
resizeImage($dropBoxObj, $layer, 320, dirname($tmpFileName), $imageMediumFileName, $folder);
|
$medium_link = resizeImage($dropBoxObj, $layer, 320, dirname($tmpFileName), $imageMediumFileName, $folder);
|
||||||
|
|
||||||
$thumbFileName = $newID . "_thumb_ricetta." . $ext;
|
$thumbFileName = $newID . "_thumb_ricetta." . $ext;
|
||||||
|
|
||||||
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 ."' )" .
|
||||||
|
" where id=" . $newID;
|
||||||
|
|
||||||
|
$newID = $mysqlconnetion->insertRecord($query);
|
||||||
|
|
||||||
$mysqlconnetion->disconnetti();
|
$mysqlconnetion->disconnetti();
|
||||||
|
|
||||||
@@ -87,25 +92,91 @@ $app->put('/photo/:imageID', function ($imageID) use ($app, $dirRicetteDropBox)
|
|||||||
// istanza della classe
|
// istanza della classe
|
||||||
$mysqlconnetion = new MysqlClass;
|
$mysqlconnetion = new MysqlClass;
|
||||||
//$mysqlconneti on->connetti();
|
//$mysqlconneti on->connetti();
|
||||||
$query = "update immagini set (type_format = '" . image_type_to_mime_type(exif_imagetype($tmpFileName)) . "', " .
|
|
||||||
|
$folder = $dirRicetteDropBox . "/" . $imageID;
|
||||||
|
$imageFileName = $imageID . "_full_ricetta." . $ext;
|
||||||
|
|
||||||
|
$full_link = resizeImage($dropBoxObj, $layer, 640, dirname($tmpFileName), $imageFileName, $folder);
|
||||||
|
|
||||||
|
$imageMediumFileName = $imageID . "_medium_ricetta." . $ext;
|
||||||
|
|
||||||
|
$medium_link = resizeImage($dropBoxObj, $layer, 320, dirname($tmpFileName), $imageMediumFileName, $folder);
|
||||||
|
|
||||||
|
$thumbFileName = $imageID . "_thumb_ricetta." . $ext;
|
||||||
|
|
||||||
|
$thumb_link = makeThumbImage($dropBoxObj, $layer, 80, dirname($tmpFileName), $thumbFileName, $folder);
|
||||||
|
|
||||||
|
$query = "update immagini set (type_format = '" . image_type_to_mime_type(exif_imagetype($tmpFileName)) .
|
||||||
|
"', thumb_link = '" . $thumb_link . "', medium_link ='" . $medium_link . "', full_link = '" . $full_link ."' )" .
|
||||||
" where id=" . $imageID;
|
" where id=" . $imageID;
|
||||||
|
|
||||||
$newID = $mysqlconnetion->insertRecord($query);
|
$newID = $mysqlconnetion->insertRecord($query);
|
||||||
|
|
||||||
$folder = $dirRicetteDropBox . "/" . $newID;
|
|
||||||
$imageFileName = $newID . "_full_ricetta." . $ext;
|
|
||||||
|
|
||||||
resizeImage($dropBoxObj, $layer, 640, dirname($tmpFileName), $imageFileName, $folder);
|
|
||||||
|
|
||||||
$imageMediumFileName = $newID . "_medium_ricetta." . $ext;
|
|
||||||
|
|
||||||
resizeImage($dropBoxObj, $layer, 320, dirname($tmpFileName), $imageMediumFileName, $folder);
|
|
||||||
|
|
||||||
$thumbFileName = $newID . "_thumb_ricetta." . $ext;
|
|
||||||
|
|
||||||
makeThumbImage($dropBoxObj, $layer, 80, dirname($tmpFileName), $thumbFileName, $folder);
|
|
||||||
|
|
||||||
$mysqlconnetion->disconnetti();
|
$mysqlconnetion->disconnetti();
|
||||||
|
|
||||||
return $newID;
|
return $newID;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$app->get('/photo/fixLink', function () use ($app, $dirRicetteDropBox) {
|
||||||
|
ini_set('max_execution_time', 3000);
|
||||||
|
|
||||||
|
$mysqlconnetion = new MysqlClass;
|
||||||
|
|
||||||
|
$retObj2 = $mysqlconnetion->queryToObject("select type_format, id, id_ricette, thumb_link, medium_link, full_link from immagini where published = 1");
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($retObj2 as $retObj) {
|
||||||
|
|
||||||
|
$imageID = $retObj["id"];
|
||||||
|
|
||||||
|
$ext = "";
|
||||||
|
if ($retObj["type_format"] == "image/jpeg") {
|
||||||
|
$ext = "jpeg";
|
||||||
|
} else if ($retObj["type_format"] == "image/png") {
|
||||||
|
$ext = "png";
|
||||||
|
}
|
||||||
|
|
||||||
|
$full_link = $retObj["full_link"];
|
||||||
|
|
||||||
|
if($full_link == ""){
|
||||||
|
$folder = $dirRicetteDropBox . "/" . $retObj["id_ricette"];
|
||||||
|
|
||||||
|
$imageFileName = $imageID . "_full_ricetta." . $ext;
|
||||||
|
|
||||||
|
$dropBoxObj = new myDropBox();
|
||||||
|
|
||||||
|
$full_link = $dropBoxObj->GetLink($folder . "/" . $imageFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
$medium_link = $retObj["medium_link"];
|
||||||
|
|
||||||
|
if($medium_link == ""){
|
||||||
|
$folder = $dirRicetteDropBox . "/" . $retObj["id_ricette"];
|
||||||
|
|
||||||
|
$imageFileName = $imageID . "_medium_ricetta." . $ext;
|
||||||
|
|
||||||
|
$dropBoxObj = new myDropBox();
|
||||||
|
|
||||||
|
$medium_link = $dropBoxObj->GetLink($folder . "/" . $imageFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
$thumb_link = $retObj["thumb_link"];
|
||||||
|
|
||||||
|
if($thumb_link == ""){
|
||||||
|
$folder = $dirRicetteDropBox . "/" . $retObj["id_ricette"];
|
||||||
|
|
||||||
|
$imageFileName = $imageID . "_thumb_ricetta.png";
|
||||||
|
|
||||||
|
$dropBoxObj = new myDropBox();
|
||||||
|
|
||||||
|
$thumb_link = $dropBoxObj->GetLink($folder . "/" . $imageFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = "update immagini set thumb_link = '" . $thumb_link . "', medium_link ='" . $medium_link . "', full_link = '" . $full_link ."'" .
|
||||||
|
" where id=" . $imageID;
|
||||||
|
|
||||||
|
$newID = $mysqlconnetion->insertRecord($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
$mysqlconnetion->disconnetti();
|
||||||
|
});
|
||||||
+4
-1
@@ -52,7 +52,10 @@ class myDropBox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function GetLink($dropBoxPathFile) {
|
public function GetLink($dropBoxPathFile) {
|
||||||
return $this->dropbox->GetLink($dropBoxPathFile, false, false);
|
$exp = null;
|
||||||
|
$ret = $this->dropbox->GetLink($dropBoxPathFile, true, false, $exp);
|
||||||
|
$ret = str_replace("https://www.dropbox.com/", "https://dl.dropboxusercontent.com/" , $ret);
|
||||||
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function CreateFolder($dropBoxPath) {
|
public function CreateFolder($dropBoxPath) {
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ function resizeImage($dropBoxObj, $layer, $size, $dir, $fileName, $dirDropBox)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$dropBoxObj->UploadFile($fullPath, $dirDropBox . "/" . $fileName);
|
$dropBoxObj->UploadFile($fullPath, $dirDropBox . "/" . $fileName);
|
||||||
|
|
||||||
|
echo $dropBoxObj->GetLink($dirDropBox . "/" . $fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeThumbImage($dropBoxObj, $layer, $size, $dir, $fileName, $dirDropBox)
|
function makeThumbImage($dropBoxObj, $layer, $size, $dir, $fileName, $dirDropBox)
|
||||||
@@ -112,6 +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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user