This commit is contained in:
Kekskurse 2021-01-20 19:51:12 +01:00
parent fbdab7c382
commit 6f4ebf6a96
15 changed files with 288 additions and 69 deletions

View file

@ -32,6 +32,7 @@
<excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/promises" />
<excludeFolder url="file://$MODULE_DIR$/vendor/guzzlehttp/psr7" />
<excludeFolder url="file://$MODULE_DIR$/vendor/hamcrest/hamcrest-php" />
<excludeFolder url="file://$MODULE_DIR$/vendor/intervention/image" />
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/framework" />
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/sail" />
<excludeFolder url="file://$MODULE_DIR$/vendor/laravel/tinker" />

View file

@ -114,6 +114,7 @@
<path value="$PROJECT_DIR$/vendor/mtdowling/jmespath.php" />
<path value="$PROJECT_DIR$/vendor/gumlet/php-image-resize" />
<path value="$PROJECT_DIR$/vendor/erusev/parsedown" />
<path value="$PROJECT_DIR$/vendor/intervention/image" />
</include_path>
</component>
<component name="PhpUnit">

View file

@ -45,10 +45,15 @@ class AccountController extends BaseController
$tenant->template = "default";
$tenant->owner = $user->id;
$tenant->saveOrFail();
return redirect("/login");
Auth::attempt(["username" => $user->username, "password" => $validated["password"]]);
return redirect("/d");
}
public function loginView() {
if(Auth::check()) {
return redirect("/d");
}
return view("account.login");
}

View file

@ -0,0 +1,85 @@
<?php
namespace App\Jobs;
use Ajaxray\PHPWatermark\Watermark;
use App\Models\Access;
use App\Models\Gallery;
use App\Models\Image;
use App\Models\Tenant;
use Gumlet\ImageResize;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
class ResizeImageBackup implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
private $image_id;
private $size;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(int $image_id, int $size)
{
$this->image_id = $image_id;
$this->size = $size;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$image = Image::query()->where("id", "=", $this->image_id)->firstOrFail();
$gallery = Gallery::query()->where("id", "=", $image->gallery)->firstOrFail();
$tenant = Tenant::query()->where("id", "=", $gallery->tenant)->firstOrFail();
$cacheName = "cache/".$tenant->url."_".$gallery->url."_".$image->id;
//Check if orginal size is cached on the current system
if (Storage::disk('cache')->exists($cacheName."_orginal")) {
$file = Storage::disk("cache")->get($cacheName."_orginal");
} else {
$this->addAccessLog($tenant->id, $gallery->id, $image->id, "Access", $image->size);
$file = Storage::disk($image->driver)->get($image->path);
if(env("CACHE_ORGINAL"))
{
Storage::disk("cache")->put($cacheName."_orginal", $file);
}
}
$image = ImageResize::createFromString($file);
$image->resizeToLongSide($this->size, true);
//Watermark
Storage::disk("cache")->put($cacheName."_".$this->size, $image->getImageAsString(IMAGETYPE_JPEG, 100));
}
private function addAccessLog(int $tenant, int $gallery, int $image, string $typ, int $size) {
$access = new Access();
$access->year = date("Y");
$access->month = date("m");
$access->day = date("d");
$access->hour = date("H");
$access->image = $image;
$access->gallery = $gallery;
$access->tenant = $tenant;
$access->typ = $typ;
$access->size = $size;
$access->saveOrFail();
}
}

View file

@ -2,6 +2,7 @@
namespace App\Jobs;
use Ajaxray\PHPWatermark\Watermark;
use App\Models\Access;
use App\Models\Gallery;
use App\Models\Image;
@ -15,6 +16,7 @@ use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\ImageManager;
class ResizeImage implements ShouldQueue
{
@ -42,6 +44,7 @@ class ResizeImage implements ShouldQueue
*/
public function handle()
{
//Get Database Entitiys
$image = Image::query()->where("id", "=", $this->image_id)->firstOrFail();
$gallery = Gallery::query()->where("id", "=", $image->gallery)->firstOrFail();
$tenant = Tenant::query()->where("id", "=", $gallery->tenant)->firstOrFail();
@ -59,12 +62,63 @@ class ResizeImage implements ShouldQueue
}
}
$image = ImageResize::createFromString($file);
$image->resizeToLongSide($this->size);
Storage::disk("cache")->put($cacheName."_".$this->size, $image->getImageAsString(IMAGETYPE_JPEG, 100));
$manager = new ImageManager(array('driver' => 'imagick'));
$img = $manager->make($file);
$newHeight = $img->getHeight();
$newWidth = $img->getWidth();
if($img->getWidth() > $img->getHeight()) {
$newWidth = $this->size;
$newHeight = $img->getHeight() * ($newWidth / $img->getWidth() );
} else {
$newHeight = $this->size;
$newWidth = $img->getWidth() * ($newHeight / $img->getHeight());
}
$tmpfname = tempnam("/tmp", "FOO").".jpg";
$img->resize($newWidth, $newHeight);
//$img->blur(50);
if($this->size > 500) {
$watermark = $manager->make(storage_path("logo-sample.png"));
if($watermark->getWidth() > $img->getWidth()) {
$newWidth = $img->getWidth() / 1.2;
$newHeight = $watermark->getHeight() * ($newWidth / $watermark->getWidth());
$watermark->resize($newWidth, $newHeight);
}
if($watermark->getHeight() > $img->getHeight()) {
$newHeight = $img->getHeight() / 1.1;
$newWidth = $watermark->getWidth() * ($newHeight / $watermark->getHeight());
$watermark->resize($newWidth, $newHeight);
}
$watermark->opacity(40);
$img->insert($watermark, 'center');
$img->resizeCanvas(0, 28, 'top', true, "#000000");
$img->text('www.kuvia.cloud/'.$tenant->url, $img->getWidth() - 10, $img->getHeight() - 25, function($font) {
$font->file(storage_path("OpenSans-Light.ttf"));
$font->size(18);
$font->color('#ffffff');
$font->align('right');
$font->valign('top');
//$font->angle(45);
});
}
$img->save($tmpfname);
Storage::disk("cache")->put($cacheName."_".$this->size, file_get_contents($tmpfname));
unlink($tmpfname);
//Watermark
//Storage::disk("cache")->put($cacheName."_".$this->size, $image->getImageAsString(IMAGETYPE_JPEG, 100));
}
private function addAccessLog(int $tenant, int $gallery, int $image, string $typ, int $size) {
$access = new Access();
$access->year = date("Y");

View file

@ -15,6 +15,7 @@
"fruitcake/laravel-cors": "^2.0",
"gumlet/php-image-resize": "1.9.*",
"guzzlehttp/guzzle": "^7.0.1",
"intervention/image": "^2.5",
"laravel/framework": "^8.12",
"laravel/tinker": "^2.5",
"league/flysystem-aws-s3-v3": "~1.0"

193
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "fdbb8e19644f726c76bfec23d2f51743",
"content-hash": "fd0ab766a01c2bf348b0108782d792d7",
"packages": [
{
"name": "almasaeed2010/adminlte",
@ -107,16 +107,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.171.15",
"version": "3.171.20",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "26c7f2deb05110c62e38cc867658f1ef89123365"
"reference": "02aaf7007c5678a6358ea924cd85531300aa1747"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/26c7f2deb05110c62e38cc867658f1ef89123365",
"reference": "26c7f2deb05110c62e38cc867658f1ef89123365",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/02aaf7007c5678a6358ea924cd85531300aa1747",
"reference": "02aaf7007c5678a6358ea924cd85531300aa1747",
"shasum": ""
},
"require": {
@ -191,9 +191,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.171.15"
"source": "https://github.com/aws/aws-sdk-php/tree/3.171.20"
},
"time": "2021-01-11T19:28:59+00:00"
"time": "2021-01-19T19:13:08+00:00"
},
{
"name": "brick/math",
@ -1135,17 +1135,91 @@
"time": "2020-09-30T07:37:11+00:00"
},
{
"name": "laravel/framework",
"version": "v8.21.0",
"name": "intervention/image",
"version": "2.5.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "a61cab167c35f465a923737ee6e6fb99cd5fde88"
"url": "https://github.com/Intervention/image.git",
"reference": "abbf18d5ab8367f96b3205ca3c89fb2fa598c69e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/a61cab167c35f465a923737ee6e6fb99cd5fde88",
"reference": "a61cab167c35f465a923737ee6e6fb99cd5fde88",
"url": "https://api.github.com/repos/Intervention/image/zipball/abbf18d5ab8367f96b3205ca3c89fb2fa598c69e",
"reference": "abbf18d5ab8367f96b3205ca3c89fb2fa598c69e",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"guzzlehttp/psr7": "~1.1",
"php": ">=5.4.0"
},
"require-dev": {
"mockery/mockery": "~0.9.2",
"phpunit/phpunit": "^4.8 || ^5.7"
},
"suggest": {
"ext-gd": "to use GD library based image processing.",
"ext-imagick": "to use Imagick based image processing.",
"intervention/imagecache": "Caching extension for the Intervention Image library"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
},
"laravel": {
"providers": [
"Intervention\\Image\\ImageServiceProvider"
],
"aliases": {
"Image": "Intervention\\Image\\Facades\\Image"
}
}
},
"autoload": {
"psr-4": {
"Intervention\\Image\\": "src/Intervention/Image"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Oliver Vogel",
"email": "oliver@olivervogel.com",
"homepage": "http://olivervogel.com/"
}
],
"description": "Image handling and manipulation library with support for Laravel integration",
"homepage": "http://image.intervention.io/",
"keywords": [
"gd",
"image",
"imagick",
"laravel",
"thumbnail",
"watermark"
],
"support": {
"issues": "https://github.com/Intervention/image/issues",
"source": "https://github.com/Intervention/image/tree/master"
},
"time": "2019-11-02T09:15:47+00:00"
},
{
"name": "laravel/framework",
"version": "v8.23.1",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "a813df1b248ca305e5f5ce23ea981ed6c6905504"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/a813df1b248ca305e5f5ce23ea981ed6c6905504",
"reference": "a813df1b248ca305e5f5ce23ea981ed6c6905504",
"shasum": ""
},
"require": {
@ -1299,7 +1373,7 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2021-01-05T15:43:10+00:00"
"time": "2021-01-19T14:10:48+00:00"
},
{
"name": "laravel/tinker",
@ -1618,16 +1692,16 @@
},
{
"name": "league/mime-type-detection",
"version": "1.5.1",
"version": "1.7.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/mime-type-detection.git",
"reference": "353f66d7555d8a90781f6f5e7091932f9a4250aa"
"reference": "3b9dff8aaf7323590c1d2e443db701eb1f9aa0d3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/353f66d7555d8a90781f6f5e7091932f9a4250aa",
"reference": "353f66d7555d8a90781f6f5e7091932f9a4250aa",
"url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/3b9dff8aaf7323590c1d2e443db701eb1f9aa0d3",
"reference": "3b9dff8aaf7323590c1d2e443db701eb1f9aa0d3",
"shasum": ""
},
"require": {
@ -1635,8 +1709,9 @@
"php": "^7.2 || ^8.0"
},
"require-dev": {
"phpstan/phpstan": "^0.12.36",
"phpunit/phpunit": "^8.5.8"
"friendsofphp/php-cs-fixer": "^2.18",
"phpstan/phpstan": "^0.12.68",
"phpunit/phpunit": "^8.5.8 || ^9.3"
},
"type": "library",
"autoload": {
@ -1657,7 +1732,7 @@
"description": "Mime-type detection for Flysystem",
"support": {
"issues": "https://github.com/thephpleague/mime-type-detection/issues",
"source": "https://github.com/thephpleague/mime-type-detection/tree/1.5.1"
"source": "https://github.com/thephpleague/mime-type-detection/tree/1.7.0"
},
"funding": [
{
@ -1669,7 +1744,7 @@
"type": "tidelift"
}
],
"time": "2020-10-18T11:50:25+00:00"
"time": "2021-01-18T20:58:21+00:00"
},
{
"name": "monolog/monolog",
@ -2422,16 +2497,16 @@
},
{
"name": "psy/psysh",
"version": "v0.10.5",
"version": "v0.10.6",
"source": {
"type": "git",
"url": "https://github.com/bobthecow/psysh.git",
"reference": "7c710551d4a2653afa259c544508dc18a9098956"
"reference": "6f990c19f91729de8b31e639d6e204ea59f19cf3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/7c710551d4a2653afa259c544508dc18a9098956",
"reference": "7c710551d4a2653afa259c544508dc18a9098956",
"url": "https://api.github.com/repos/bobthecow/psysh/zipball/6f990c19f91729de8b31e639d6e204ea59f19cf3",
"reference": "6f990c19f91729de8b31e639d6e204ea59f19cf3",
"shasum": ""
},
"require": {
@ -2460,7 +2535,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.10.x-dev"
"dev-main": "0.10.x-dev"
}
},
"autoload": {
@ -2492,9 +2567,9 @@
],
"support": {
"issues": "https://github.com/bobthecow/psysh/issues",
"source": "https://github.com/bobthecow/psysh/tree/v0.10.5"
"source": "https://github.com/bobthecow/psysh/tree/v0.10.6"
},
"time": "2020-12-04T02:51:30+00:00"
"time": "2021-01-18T15:53:43+00:00"
},
{
"name": "ralouphie/getallheaders",
@ -2707,16 +2782,16 @@
},
{
"name": "swiftmailer/swiftmailer",
"version": "v6.2.4",
"version": "v6.2.5",
"source": {
"type": "git",
"url": "https://github.com/swiftmailer/swiftmailer.git",
"reference": "56f0ab23f54c4ccbb0d5dcc67ff8552e0c98d59e"
"reference": "698a6a9f54d7eb321274de3ad19863802c879fb7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/56f0ab23f54c4ccbb0d5dcc67ff8552e0c98d59e",
"reference": "56f0ab23f54c4ccbb0d5dcc67ff8552e0c98d59e",
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/698a6a9f54d7eb321274de3ad19863802c879fb7",
"reference": "698a6a9f54d7eb321274de3ad19863802c879fb7",
"shasum": ""
},
"require": {
@ -2766,7 +2841,7 @@
],
"support": {
"issues": "https://github.com/swiftmailer/swiftmailer/issues",
"source": "https://github.com/swiftmailer/swiftmailer/tree/v6.2.4"
"source": "https://github.com/swiftmailer/swiftmailer/tree/v6.2.5"
},
"funding": [
{
@ -2778,7 +2853,7 @@
"type": "tidelift"
}
],
"time": "2020-12-08T18:02:06+00:00"
"time": "2021-01-12T09:35:59+00:00"
},
{
"name": "symfony/console",
@ -5645,16 +5720,16 @@
},
{
"name": "laravel/sail",
"version": "v1.1.0",
"version": "v1.2.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/sail.git",
"reference": "277d868441b49898caf0ce3cb4e19b439e419133"
"reference": "c28c1b77d9aada131861c89bc406813859b62844"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/sail/zipball/277d868441b49898caf0ce3cb4e19b439e419133",
"reference": "277d868441b49898caf0ce3cb4e19b439e419133",
"url": "https://api.github.com/repos/laravel/sail/zipball/c28c1b77d9aada131861c89bc406813859b62844",
"reference": "c28c1b77d9aada131861c89bc406813859b62844",
"shasum": ""
},
"require": {
@ -5700,7 +5775,7 @@
"issues": "https://github.com/laravel/sail/issues",
"source": "https://github.com/laravel/sail"
},
"time": "2021-01-05T16:40:11+00:00"
"time": "2021-01-19T15:26:58+00:00"
},
{
"name": "mockery/mockery",
@ -5834,16 +5909,16 @@
},
{
"name": "nunomaduro/collision",
"version": "v5.1.0",
"version": "v5.2.0",
"source": {
"type": "git",
"url": "https://github.com/nunomaduro/collision.git",
"reference": "7c2b95589bf81e274e61e47f7672a1b2c3e06eaa"
"reference": "aca954fd03414ba0dd85d7d8e42ba9b251893d1f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nunomaduro/collision/zipball/7c2b95589bf81e274e61e47f7672a1b2c3e06eaa",
"reference": "7c2b95589bf81e274e61e47f7672a1b2c3e06eaa",
"url": "https://api.github.com/repos/nunomaduro/collision/zipball/aca954fd03414ba0dd85d7d8e42ba9b251893d1f",
"reference": "aca954fd03414ba0dd85d7d8e42ba9b251893d1f",
"shasum": ""
},
"require": {
@ -5853,16 +5928,16 @@
"symfony/console": "^5.0"
},
"require-dev": {
"fideloper/proxy": "^4.4.0",
"friendsofphp/php-cs-fixer": "^2.16.4",
"fruitcake/laravel-cors": "^2.0.1",
"laravel/framework": "^8.0",
"laravel/tinker": "^2.4.1",
"brianium/paratest": "^6.1",
"fideloper/proxy": "^4.4.1",
"friendsofphp/php-cs-fixer": "^2.17.3",
"fruitcake/laravel-cors": "^2.0.3",
"laravel/framework": "^9.0",
"nunomaduro/larastan": "^0.6.2",
"nunomaduro/mock-final-classes": "^1.0",
"orchestra/testbench": "^6.0",
"phpstan/phpstan": "^0.12.36",
"phpunit/phpunit": "^9.3.3"
"orchestra/testbench": "^7.0",
"phpstan/phpstan": "^0.12.64",
"phpunit/phpunit": "^9.5.0"
},
"type": "library",
"extra": {
@ -5918,7 +5993,7 @@
"type": "patreon"
}
],
"time": "2020-10-29T14:50:40+00:00"
"time": "2021-01-13T10:00:08+00:00"
},
{
"name": "phar-io/manifest",
@ -6576,16 +6651,16 @@
},
{
"name": "phpunit/phpunit",
"version": "9.5.0",
"version": "9.5.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "8e16c225d57c3d6808014df6b1dd7598d0a5bbbe"
"reference": "e7bdf4085de85a825f4424eae52c99a1cec2f360"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8e16c225d57c3d6808014df6b1dd7598d0a5bbbe",
"reference": "8e16c225d57c3d6808014df6b1dd7598d0a5bbbe",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e7bdf4085de85a825f4424eae52c99a1cec2f360",
"reference": "e7bdf4085de85a825f4424eae52c99a1cec2f360",
"shasum": ""
},
"require": {
@ -6663,7 +6738,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.0"
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.1"
},
"funding": [
{
@ -6675,7 +6750,7 @@
"type": "github"
}
],
"time": "2020-12-04T05:05:53+00:00"
"time": "2021-01-17T07:42:25+00:00"
},
{
"name": "sebastian/cli-parser",

View file

@ -6,7 +6,7 @@
<div class="col-md-12">
<h1>Dashboard</h1>
<div class="alert alert-danger" role="alert">
This system is in development mode, all data will be removed!
This system is in alpha mode, if you found issue contact hello@kekskurse.de
</div>
</div>
</div>

View file

@ -24,10 +24,7 @@
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Settings</a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#">Pages</a>
<a class="dropdown-item" href="#">Statistics</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="/t/new">New Tenant</a>
<a class="dropdown-item" href="/s/watermark">Watermark</a>
</div>
</li>
</ul>

View file

@ -1,7 +1,7 @@
@extends('layout/template')
@section('content')
<div class="row" style="background-color: #607c89;min-height: calc(100vh - 600px);max-height: calc(100vh - 200px);padding-top:20px;">
<div class="row" style="background-color: #607c89;min-height: calc(100vh - 400px);max-height: calc(100vh - 200px);padding-top:20px;">
<div class="col-md-12" style="text-align: center;">
<div>
<div class="fotorama" data-nav="thumbs" data-keyboard="true" data-ratio="800/600" data-width="1200" data-maxheight="80%" data-allowfullscreen="true">

BIN
storage/Justus-Roman.ttf Normal file

Binary file not shown.

BIN
storage/OpenSans-Light.ttf Normal file

Binary file not shown.

BIN
storage/Unbenannt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

BIN
storage/logo-sample.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB