Images return full URI (excl. host)
This commit is contained in:
parent
215ed1bc7f
commit
93e5cebce0
@ -1,3 +1,7 @@
|
||||
# Voraussetzungen um das React Projekt zu bauen
|
||||
- Node 18
|
||||
- PNPM
|
||||
|
||||
# Veränderungen Datenbank
|
||||
|
||||
## Tabelle `egb_benutzer`
|
||||
@ -11,4 +15,35 @@
|
||||
## Tabelle `egb_gaestebuch`
|
||||
- Abänderung der Spalte `benutzer_id`: Non-Nullable gemacht
|
||||
- Abänderung der Spalte `beitrag`: Non-Nullable gemacht
|
||||
- Hinzufüge eines Foreign Key Constraints auf `benutzer_id`
|
||||
- Hinzufüge eines Foreign Key Constraints auf `benutzer_id`
|
||||
|
||||
# Notwendige Anpassung für die Verzeichnisstruktur eines anderen Hosters
|
||||
|
||||
## PHP
|
||||
|
||||
### `classes/Models/User.php`
|
||||
- Link in der Confirmation E-Mail
|
||||
|
||||
### `config/app.php`
|
||||
- Alle Pfade
|
||||
|
||||
## JS
|
||||
|
||||
### `react/vite.config.ts`
|
||||
- `base` Pfad
|
||||
|
||||
### `react/src/i18n.ts`
|
||||
- `loadPath` Pfad
|
||||
|
||||
### `react/src/main.tsx`
|
||||
- `createRouter.basepath` Pfad
|
||||
|
||||
### `react/src/api/Api.ts`
|
||||
- `BASE` API Url
|
||||
|
||||
### Projekt bauen
|
||||
```
|
||||
cd react
|
||||
pnpm install
|
||||
pnpm build
|
||||
```
|
||||
@ -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,
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
"basePath" => "phpCourse/exam/",
|
||||
"basePath" => "/phpCourse/exam/",
|
||||
"storagePath" => "/phpCourse/exam/storage/",
|
||||
"baseFSPath" => "/home/k/khofmann/public_html/phpCourse/exam/",
|
||||
"storagePath" => "/home/k/khofmann/public_html/phpCourse/exam/storage/"
|
||||
"storageFSPath" => "/home/k/khofmann/public_html/phpCourse/exam/storage/"
|
||||
];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user