Images return full URI (excl. host)
This commit is contained in:
@@ -52,6 +52,11 @@ class Config
|
||||
return Config::getInstance()->app["storagePath"];
|
||||
}
|
||||
|
||||
public static function getStorageFSPath(): string
|
||||
{
|
||||
return Config::getInstance()->app["storageFSPath"];
|
||||
}
|
||||
|
||||
public static function getDatabase(): array
|
||||
{
|
||||
return Config::getInstance()->database;
|
||||
|
||||
@@ -8,6 +8,7 @@ use Exception;
|
||||
use Khofmann\Models\User\User;
|
||||
use JsonSerializable;
|
||||
use Khofmann\ApiError\ApiError;
|
||||
use Khofmann\Config\Config;
|
||||
use Khofmann\Database\Database;
|
||||
use PDO;
|
||||
|
||||
@@ -27,7 +28,7 @@ class Post implements JsonSerializable
|
||||
$this->id = $id;
|
||||
$this->user = $user;
|
||||
$this->name = $name;
|
||||
$this->image = $image;
|
||||
$this->image = Config::getStoragePath() . $image;
|
||||
$this->content = $content;
|
||||
$this->postedAt = new DateTime($postedAt);
|
||||
}
|
||||
|
||||
@@ -363,13 +363,13 @@ class User implements JsonSerializable
|
||||
$stmt->bindValue(":ID", $this->id);
|
||||
$stmt->execute();
|
||||
$oldImage = $stmt->fetch(PDO::FETCH_COLUMN, 0);
|
||||
if (strpos($oldImage, "default") === false) unlink(Config::getStoragePath() . $oldImage);
|
||||
if (strpos($oldImage, "default") === false) unlink(Config::getStorageFSPath() . $oldImage);
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
|
||||
if (!empty($image)) {
|
||||
$destinationFilename = sprintf('%s.%s', uniqid(), $image->getExtension());
|
||||
$image->move(Config::getStoragePath() . "profilbilder/$destinationFilename");
|
||||
$image->move(Config::getStorageFSPath() . "profilbilder/$destinationFilename");
|
||||
|
||||
try {
|
||||
$stmt = $db->prepare("UPDATE egb_benutzer SET image = :IMG WHERE id = :ID");
|
||||
@@ -524,7 +524,7 @@ class User implements JsonSerializable
|
||||
'username' => $this->username,
|
||||
'status' => $this->status,
|
||||
'email' => htmlspecialchars($this->email),
|
||||
'image' => $this->image,
|
||||
'image' => Config::getStoragePath() . $this->image,
|
||||
'isAdmin' => $this->isAdmin,
|
||||
'memberSince' => $this->memberSince,
|
||||
'postCount' => $this->postCount,
|
||||
|
||||
Reference in New Issue
Block a user