diff --git a/exam/README.md b/exam/README.md index 5353fda..b3fd71a 100644 --- a/exam/README.md +++ b/exam/README.md @@ -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` \ No newline at end of file +- 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 +``` \ No newline at end of file diff --git a/exam/classes/Config/Config.php b/exam/classes/Config/Config.php index 544c280..a702888 100644 --- a/exam/classes/Config/Config.php +++ b/exam/classes/Config/Config.php @@ -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; diff --git a/exam/classes/Models/Post/Post.php b/exam/classes/Models/Post/Post.php index 56a11c9..728f71e 100644 --- a/exam/classes/Models/Post/Post.php +++ b/exam/classes/Models/Post/Post.php @@ -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); } diff --git a/exam/classes/Models/User/User.php b/exam/classes/Models/User/User.php index 5cad41b..9a89e84 100644 --- a/exam/classes/Models/User/User.php +++ b/exam/classes/Models/User/User.php @@ -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, diff --git a/exam/config/app.php b/exam/config/app.php index 3dac9b6..7beca01 100644 --- a/exam/config/app.php +++ b/exam/config/app.php @@ -1,7 +1,8 @@ "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/" ];