git-svn-id: https://msi/svn/firstRepo/Service/branches/Manut_2.2.3@49 0f545695-f87b-41b6-9a03-7f16563b5454
This commit is contained in:
@@ -1,103 +1,62 @@
|
||||
<?php
|
||||
// inclusione del file contenente la classe
|
||||
require_once "./include.php";
|
||||
use PHPImageWorkshop\ImageWorkshop;
|
||||
require_once('PHPImageWorkshop/ImageWorkshop.php'); // Be sure of the path to the class
|
||||
|
||||
//include "./SimpleImage.php";
|
||||
|
||||
$app->get('/photos/thumbnail/:imageID(/:createImgTag)', function ($imageID, $createImgTag = 0) use ($app) {
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
|
||||
$retObj = $mysqlconnetion->queryToObject("select type_format, image_thumbnail from immagini where id=" . $imageID, false);
|
||||
$mysqlconnetion->disconnetti();
|
||||
|
||||
if($createImgTag)
|
||||
echo '<img src="data:' . $retObj["type_format"] . ';base64,' . base64_encode($retObj['image_thumbnail']) . '"/>';
|
||||
else
|
||||
{
|
||||
$app->contentType($retObj["type_format"]);
|
||||
echo $retObj['image_thumbnail'];
|
||||
}
|
||||
});
|
||||
|
||||
$app->get('/photos/:imageID(/:createImgTag)', function ($imageID, $createImgTag = 0) use ($app) {
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
|
||||
$retObj = $mysqlconnetion->queryToObject("select type_format, image from immagini where id=" . $imageID, false);
|
||||
$mysqlconnetion->disconnetti();
|
||||
|
||||
if($createImgTag)
|
||||
echo '<img src="';
|
||||
echo 'data:' . $retObj["type_format"] . ';base64,'.base64_encode( $retObj['image'] );
|
||||
if($createImgTag)
|
||||
echo '"/>';
|
||||
});
|
||||
|
||||
$app->put('/photos/publish/:imageID', function ($imageID) use ($app) {
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
|
||||
$query = "update immagini set published = 1, published_date = NOW() where ProfiloID = " . $imageID;
|
||||
$mysqlconnetion->disconnetti();
|
||||
$mysqlconnetion->insertRecord($query);
|
||||
$mysqlconnetion->disconnetti();
|
||||
});
|
||||
|
||||
$app->post('/photos', function () use ($app) {
|
||||
$idRicette = $app->request()->post('ricetta_id');
|
||||
$profileID = $app->request()->post('keyStore');
|
||||
$imageFileName = $_FILES['image']["tmp_name"];
|
||||
|
||||
$layer = ImageWorkshop::initFromPath($imageFileName);
|
||||
$layer->resizeByLargestSideInPixel(640, true);
|
||||
|
||||
$layer->save(dirname($imageFileName), basename($imageFileName));
|
||||
|
||||
$imgData = addslashes(file_get_contents($imageFileName));
|
||||
|
||||
$layer->resizeByLargestSideInPixel(300, true);
|
||||
|
||||
$layer->save(dirname($imageFileName), basename($imageFileName));
|
||||
|
||||
$ThumbImageData = addslashes(file_get_contents($imageFileName));
|
||||
|
||||
// istanza della classe
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
//$mysqlconneti on->connetti();
|
||||
$query = "insert into immagini(id_ricette, type_format, image_thumbnail, image, from_profile_id, uploaded_date) " .
|
||||
"values(" . $idRicette . ", '" . image_type_to_mime_type($image->image_type) .
|
||||
"', '" . $ThumbImageData . "', '" . $imgData . "', '" . $profileID . "', NOW())";
|
||||
$newID = $mysqlconnetion->insertRecord($query);
|
||||
$mysqlconnetion->disconnetti();
|
||||
|
||||
echo $newID;
|
||||
});
|
||||
|
||||
$app->put('/photos/:imageID', function ($imageID) use ($app) {
|
||||
$imageFileName = $_FILES['image']["tmp_name"];
|
||||
|
||||
$layer = ImageWorkshop::initFromPath($imageFileName);
|
||||
$layer->resizeByLargestSideInPixel(640, true);
|
||||
|
||||
$layer->save(dirname($imageFileName), basename($imageFileName));
|
||||
|
||||
$imgData = addslashes(file_get_contents($imageFileName));
|
||||
|
||||
$layer->resizeByLargestSideInPixel(300, true);
|
||||
|
||||
$layer->save(dirname($imageFileName), basename($imageFileName));
|
||||
|
||||
$ThumbImageData = addslashes(file_get_contents($imageFileName));
|
||||
|
||||
// istanza della classe
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
//$mysqlconneti on->connetti();
|
||||
$query = "update immagini set (type_format = '" . image_type_to_mime_type($image->image_type) . "', " .
|
||||
"image_thumbnail = '" . $ThumbImageData . "', " .
|
||||
"image = '" . $imgData . "' where id=" . $imageID;
|
||||
|
||||
$newID = $mysqlconnetion->insertRecord($query);
|
||||
$mysqlconnetion->disconnetti();
|
||||
|
||||
return $newID;
|
||||
});
|
||||
<?php
|
||||
|
||||
// inclusione del file contenente la classe
|
||||
require_once "./include.php";
|
||||
require_once "./myDropBoxObj.php";
|
||||
//include "./SimpleImage.php";
|
||||
|
||||
$app->get('/photo/thumbnail/:imageID(/:createImgTag)', function ($imageID, $createImgTag = 0) use ($app, $dirRicetteDropBox) {
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
|
||||
$retObj = $mysqlconnetion->queryToObject("select type_format, id_ricette 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";
|
||||
}
|
||||
|
||||
$folder = $dirRicetteDropBox . "/" . $retObj["id_ricette"];
|
||||
|
||||
$imageFileName = $imageID . "_thumb_ricetta." . $ext;
|
||||
|
||||
$dropBoxObj = new myDropBox();
|
||||
|
||||
if ($createImgTag) {
|
||||
echo '<img src="';
|
||||
echo $dropBoxObj->GetLink($folder . "/" . $imageFileName);
|
||||
echo '"/>';
|
||||
}
|
||||
else
|
||||
$app->response->redirect($dropBoxObj->GetLink($folder . "/" . $imageFileName), 303);
|
||||
});
|
||||
|
||||
$app->get('/photo/:imageID(/:createImgTag)', function ($imageID, $createImgTag = 0) use ($app, $dirRicetteDropBox) {
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
|
||||
$retObj = $mysqlconnetion->queryToObject("select type_format, id_ricette 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";
|
||||
}
|
||||
|
||||
$folder = $dirRicetteDropBox . "/" . $retObj["id_ricette"];
|
||||
|
||||
$imageFileName = $imageID . "_full_ricetta." . $ext;
|
||||
|
||||
$dropBoxObj = new myDropBox();
|
||||
|
||||
if ($createImgTag) {
|
||||
echo '<img src="';
|
||||
echo $dropBoxObj->GetLink($folder . "/" . $imageFileName);
|
||||
echo '"/>';
|
||||
}
|
||||
else
|
||||
$app->response->redirect($dropBoxObj->GetLink($folder . "/" . $imageFileName), 303);
|
||||
});
|
||||
Reference in New Issue
Block a user