diff --git a/FVS-Social/db_connect.php b/FVS-Social/db_connect.php new file mode 100644 index 0000000..45826a3 --- /dev/null +++ b/FVS-Social/db_connect.php @@ -0,0 +1,13 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +} catch (PDOException $e) { + die("Fehler bei der Verbindung zur Datenbank: " . $e->getMessage()); +} +?> \ No newline at end of file diff --git a/FVS-Social/erfolg.html b/FVS-Social/erfolg.html new file mode 100644 index 0000000..822b4b2 --- /dev/null +++ b/FVS-Social/erfolg.html @@ -0,0 +1,11 @@ + + + + + + Document + + +

Erfolg

+ + \ No newline at end of file diff --git a/FVS-Social/img/Logomark.png b/FVS-Social/img/Logomark.png new file mode 100644 index 0000000..a6caba6 Binary files /dev/null and b/FVS-Social/img/Logomark.png differ diff --git a/FVS-Social/img/Logomark2.png b/FVS-Social/img/Logomark2.png new file mode 100644 index 0000000..225b2f3 Binary files /dev/null and b/FVS-Social/img/Logomark2.png differ diff --git a/FVS-Social/index.php b/FVS-Social/index.php new file mode 100644 index 0000000..0bfb5a0 --- /dev/null +++ b/FVS-Social/index.php @@ -0,0 +1,190 @@ + + +Du musst dich zuerst Einloggen oder Regestrieren
Hier Einloggen
Hier Regestrieren"); + } + + include 'db_connect.php'; + + try { + $userId = $_SESSION['user_id']; + + $stmt1 = $pdo->prepare("SELECT username, email, created_at FROM users WHERE id = :id"); + $stmt1->execute([':id' => $userId]); + $user = $stmt1->fetch(PDO::FETCH_ASSOC); + + $stmt2 = $pdo->prepare("SELECT file_path FROM profile_pictures WHERE user_id = :user_id"); + $stmt2->execute([':user_id' => $userId]); + $profile_pic = $stmt2->fetch(PDO::FETCH_ASSOC); + + $stmt3 = $pdo->prepare(" + SELECT users.username, profile_pictures.file_path + FROM users + LEFT JOIN profile_pictures ON users.id = profile_pictures.user_id + ORDER BY profile_pictures.uploaded_at DESC + "); + $stmt3->execute(); + $users = $stmt3->fetchAll(PDO::FETCH_ASSOC); + + + if ($profile_pic) { + $profile_image = $profile_pic['file_path']; + } else { + $profile_image = 'profile-pics/default.jpeg'; + } + + + + if(!$user){ + die("Benutzer nicht gefunden!"); + } + }catch (PDOException $e){ + die("Fehler: " . $e->getMessage()); + } + +?> + + + + + + + '; ?> + Profile + + + +
+
+ + + + +
+ +
+
+

Willkommen, !

+

Email: !

+

Regestriert seit:, !

+ Abmelden + Posts + Über mich + Einstellungen +
+
+ + Posts + + + + "; + + }elseif($page == 'about'){ + echo "

Über mich

"; + }elseif($page == 'settings'){ + echo " +

Einstellungen

+

Profilbild änderen

+
+ +
+ +
+

Profilbild löschen

+
+ +
+ + "; + echo $profile_image; + } + ?> +
+ + +
+ + + + + + "; + + $stmt45 = $pdo->prepare(" + SELECT posts.*, profile_pictures.file_path AS profile_picture, users.username + FROM posts + LEFT JOIN profile_pictures ON posts.user_id = profile_pictures.user_id + LEFT JOIN users ON posts.user_id = users.id + WHERE posts.user_id = :user_id + ORDER BY posts.created_at DESC + "); + $stmt45->execute([':user_id' => $userId]); + $posts = $stmt45->fetchAll(PDO::FETCH_ASSOC); + + + + } + ?> +
+ +
+ +

User # schrieb:

+

+ + + Bild zum Post + + +

Erstellt am:

+
+ + +
+ +
+ + + + + + +
+
+ + \ No newline at end of file diff --git a/FVS-Social/login/login-page-style.css b/FVS-Social/login/login-page-style.css new file mode 100644 index 0000000..c4e6d21 --- /dev/null +++ b/FVS-Social/login/login-page-style.css @@ -0,0 +1,171 @@ +* { + box-sizing: border-box; + } + +body { + margin: 0; + font-family: Arial, sans-serif; + background-color: #FAFBFF; + +} + +.container { + height: 100vh; + max-width: 1200px; + margin: 0 auto; + padding: 0 15px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} + +.login-logo h1{ + margin: 0; +} + +.login-logo{ + height: 50px; + width: 50px; +} + + + +[class*="col-"] { + padding: 0 15px; + flex: 0 0 auto; +} + +.login-body{ + width: 100%; + height: auto; + text-align: center; + background-color: #FFFFFF; + border: solid 1px #ECF0F5; + padding: 12px; + border-radius: 20px; + display: flex; + flex-direction: column; + box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.25); + align-items: center; + +} + +.login-body h2{ + font-size: 40px; + margin-top: 10px; + margin-bottom: 10px; +} + + +.login-form{ + display: flex; + flex-direction: column; + width: 95%; + +} + +.login-form a{ + text-align: right; + text-decoration: none; + color: black; + font-style: italic; + font-size: 15px; + margin-top: 5px; + opacity: 60%; +} + +.login-form input { + margin-top: 15px; + padding: 10px; + border: 1px solid #E2E8F0; + border-radius: 20px; + font-size: 16px; + color: #333; + background-color: #f9f9f9; + outline: none; + transition: border-color 0.3s ease, box-shadow 0.3s ease; +} + +.login-form input:hover { + border-color: #888; +} + + +.login-form input:focus { + border-color: #007BFF; + box-shadow: 0 0 5px rgba(0, 123, 255, 0.5); +} + +.login-form input::placeholder { + color: #aaa; + font-style: italic; + +} + +.login-button{ + padding: 10px; + color: white; + background-color: black; + border: none; + box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.25); + font-size: 15px; + border-radius: 20px; + transition: all 0.3s ease, box-shadow 0.3s ease; + margin-top: 20px; + font-size: 18px; + +} + +.login-button:hover{ + cursor: pointer; + opacity: 75%; +} + +.login-body a, p{ + text-decoration: none; + color: #333; + transition: all 0.3s ease, box-shadow 0.3s ease; + + +} + + +.login-body a:hover{ + opacity: 70%; + +} + + +[class*="col-"] { + padding: 15px; + flex: 0 0 auto; + box-sizing: border-box; +} + +.col-1 { flex: 0 0 8.33%; max-width: 8.33%; } +.col-2 { flex: 0 0 16.66%; max-width: 16.66%; } +.col-3 { flex: 0 0 25%; max-width: 25%; } +.col-4 { flex: 0 0 33.33%; max-width: 33.33%; } +.col-5 { flex: 0 0 41.66%; max-width: 41.66%; } +.col-6 { flex: 0 0 50%; max-width: 50%; } +.col-7 { flex: 0 0 58.33%; max-width: 58.33%; } +.col-8 { flex: 0 0 66.66%; max-width: 66.66%; } +.col-9 { flex: 0 0 75%; max-width: 75%; } +.col-10 { flex: 0 0 83.33%; max-width: 83.33%; } +.col-11 { flex: 0 0 91.66%; max-width: 91.66%; } +.col-12 { flex: 0 0 100%; max-width: 100%; } + + +@media (max-width: 768px){ + [class*="col-"] { + max-width: 70%; + } +} + +@media (max-width: 456px){ + [class*="col-"] { + max-width: 90%; + } +} + diff --git a/FVS-Social/login/login-page.html b/FVS-Social/login/login-page.html new file mode 100644 index 0000000..dbcb017 --- /dev/null +++ b/FVS-Social/login/login-page.html @@ -0,0 +1,27 @@ + + + + + + + FVS-Social + + + +
+ + +
+ +

Log In

+ +

Noch kein Account?Jetzt Regestrieren!

+
+
+ + \ No newline at end of file diff --git a/FVS-Social/login/login.php b/FVS-Social/login/login.php new file mode 100644 index 0000000..bacaf66 --- /dev/null +++ b/FVS-Social/login/login.php @@ -0,0 +1,33 @@ +prepare("SELECT * FROM users WHERE email = :email"); + $stmt->execute([':email' => $email]); + + //überprüfung ob emailadresse ein Benutzer hat + $user =$stmt->fetch(PDO::FETCH_ASSOC); + + if($user && password_verify($password, $user['password'])) { + session_start(); + + $_SESSION['user_id'] = $user['id']; + $_SESSION['username'] = $user['username']; + + header("Location: ../index.php"); + }else{ + echo "Ungültig. Versuche es nochmal: Nochmal versuchen"; + } + }catch (PDOException $e) { + echo "Fehler: " . $e->getMessage(); + } +} +?> \ No newline at end of file diff --git a/FVS-Social/logout.php b/FVS-Social/logout.php new file mode 100644 index 0000000..7c4d544 --- /dev/null +++ b/FVS-Social/logout.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/FVS-Social/profile-pics/default.jpeg b/FVS-Social/profile-pics/default.jpeg new file mode 100644 index 0000000..b46e7c2 Binary files /dev/null and b/FVS-Social/profile-pics/default.jpeg differ diff --git a/FVS-Social/profile-pics/profile_10.jpg b/FVS-Social/profile-pics/profile_10.jpg new file mode 100644 index 0000000..346027e Binary files /dev/null and b/FVS-Social/profile-pics/profile_10.jpg differ diff --git a/FVS-Social/profile-pics/profile_8.jpg b/FVS-Social/profile-pics/profile_8.jpg new file mode 100644 index 0000000..405a937 Binary files /dev/null and b/FVS-Social/profile-pics/profile_8.jpg differ diff --git a/FVS-Social/profile-pics/profile_9.png b/FVS-Social/profile-pics/profile_9.png new file mode 100644 index 0000000..da6688c Binary files /dev/null and b/FVS-Social/profile-pics/profile_9.png differ diff --git a/FVS-Social/signup/signup-page-style.css b/FVS-Social/signup/signup-page-style.css new file mode 100644 index 0000000..4c002f6 --- /dev/null +++ b/FVS-Social/signup/signup-page-style.css @@ -0,0 +1,175 @@ +* { + box-sizing: border-box; + } + +body { + margin: 0; + font-family: Arial, sans-serif; + background-color: #FAFBFF; + +} + +.container { + height: 100vh; + max-width: 1200px; + margin: 0 auto; + padding: 0 15px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + + + +} + +.login-logo h1{ + margin: 0; + +} + +.login-logo{ + height: 50px; + width: 50px; +} + + + +[class*="col-"] { + padding: 0 15px; + flex: 0 0 auto; +} + +.login-body{ + width: 100%; + height: auto; + text-align: center; + background-color: #FFFFFF; + border: solid 1px #ECF0F5; + padding: 12px; + border-radius: 20px; + display: flex; + flex-direction: column; + box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.25); + align-items: center; + +} + +.login-body h2{ + font-size: 40px; + margin-top: 10px; + margin-bottom: 10px; +} + + +.login-form{ + display: flex; + flex-direction: column; + width: 95%; + +} + +.login-form a{ + text-align: right; + text-decoration: none; + color: black; + font-style: italic; + font-size: 15px; + margin-top: 5px; + opacity: 60%; +} + +.login-form input { + margin-top: 15px; + padding: 10px; + border: 1px solid #E2E8F0; + border-radius: 20px; + font-size: 16px; + color: #333; + background-color: #f9f9f9; + outline: none; + transition: border-color 0.3s ease, box-shadow 0.3s ease; +} + +.login-form input:hover { + border-color: #888; +} + + +.login-form input:focus { + border-color: #007BFF; + box-shadow: 0 0 5px rgba(0, 123, 255, 0.5); +} + +.login-form input::placeholder { + color: #aaa; + font-style: italic; + +} + +.login-button{ + padding: 10px; + color: white; + background-color: black; + border: none; + box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.25); + font-size: 15px; + border-radius: 20px; + transition: all 0.3s ease, box-shadow 0.3s ease; + margin-top: 20px; + font-size: 18px; + +} + +.login-button:hover{ + cursor: pointer; + opacity: 75%; +} + +.login-body a, p{ + text-decoration: none; + color: #333; + transition: all 0.3s ease, box-shadow 0.3s ease; + + +} + + +.login-body a:hover{ + opacity: 70%; + +} + + +[class*="col-"] { + padding: 15px; + flex: 0 0 auto; + box-sizing: border-box; +} + +.col-1 { flex: 0 0 8.33%; max-width: 8.33%; } +.col-2 { flex: 0 0 16.66%; max-width: 16.66%; } +.col-3 { flex: 0 0 25%; max-width: 25%; } +.col-4 { flex: 0 0 33.33%; max-width: 33.33%; } +.col-5 { flex: 0 0 41.66%; max-width: 41.66%; } +.col-6 { flex: 0 0 50%; max-width: 50%; } +.col-7 { flex: 0 0 58.33%; max-width: 58.33%; } +.col-8 { flex: 0 0 66.66%; max-width: 66.66%; } +.col-9 { flex: 0 0 75%; max-width: 75%; } +.col-10 { flex: 0 0 83.33%; max-width: 83.33%; } +.col-11 { flex: 0 0 91.66%; max-width: 91.66%; } +.col-12 { flex: 0 0 100%; max-width: 100%; } + + +@media (max-width: 768px){ + [class*="col-"] { + max-width: 70%; + } +} + +@media (max-width: 456px){ + [class*="col-"] { + max-width: 90%; + } +} + diff --git a/FVS-Social/signup/signup-page.html b/FVS-Social/signup/signup-page.html new file mode 100644 index 0000000..d017892 --- /dev/null +++ b/FVS-Social/signup/signup-page.html @@ -0,0 +1,27 @@ + + + + + + + FVS-Social + + + +
+ + +
+ +

Sign Up

+ +

Bereits angemeldet?Jetzt Einloggen!

+
+
+ + \ No newline at end of file diff --git a/FVS-Social/signup/signup.php b/FVS-Social/signup/signup.php new file mode 100644 index 0000000..abd4ac9 --- /dev/null +++ b/FVS-Social/signup/signup.php @@ -0,0 +1,34 @@ +prepare("INSERT INTO users (username, email, password) VALUES (:username, :email, :password)"); + $stmt->execute([ + ':username' => $username, + ':email' => $email, + ':password' => $hashedPassword + ]); + header("Location: ../index.php"); + }catch (PDOException $e){ + if($e->getCode() == 23000){ + header("Location: ../userused.html"); + }else { + echo "Fehler: " . $e->getMessage(); + } + } + +} + + +?> \ No newline at end of file diff --git a/FVS-Social/style.css b/FVS-Social/style.css new file mode 100644 index 0000000..8e00061 --- /dev/null +++ b/FVS-Social/style.css @@ -0,0 +1,103 @@ +* { + box-sizing: border-box; + } + + .profile-pictures, .navigation-body ul li img { width: 50px; height: 50px; border-radius: 50%; } + +body { + margin: 0; + font-family: Arial, sans-serif; + background-color: #FAFBFF; + +} + +.container { + max-width: 1200px; + margin: 0 auto; + padding: 0 15px; + display: flex; + flex-direction: row; + height: auto; +} + + +.navigation-body{ + background-color: #FFFFFF; + border: solid 1px #ECF0F5; + width: 100%; + border-radius: 20px; + +} + + +.profile-header{ + background-color: #FFFFFF; + border: solid 1px #ECF0F5; + width: 100%; + border-radius: 20px; + +} + +.post-pics{ + max-width: 500px; + height: auto; +} + + +.posts-body { + background-color: #FFFFFF; + border: solid 1px #ECF0F5; + width: 100%; + border-radius: 20px; +} + +.post-formular-body, .post{ + background-color: #FFFFFF; + border: solid 1px #ECF0F5; + width: 100%; + border-radius: 20px; +} + +.all-posts-body{ + background-color: #FFFFFF; + border: solid 1px #ECF0F5; + width: 100%; + border-radius: 20px; +} + +[class*="col-"] { + padding: 15px; + flex: 0 0 auto; + box-sizing: border-box; + } + + .col-1 { flex: 0 0 8.33%; max-width: 8.33%; } + .col-2 { flex: 0 0 16.66%; max-width: 16.66%; } + .col-3 { flex: 0 0 25%; max-width: 25%; } + .col-4 { flex: 0 0 33.33%; max-width: 33.33%; } + .col-5 { flex: 0 0 41.66%; max-width: 41.66%; } + .col-6 { flex: 0 0 50%; max-width: 50%; } + .col-7 { flex: 0 0 58.33%; max-width: 58.33%; } + .col-8 { flex: 0 0 66.66%; max-width: 66.66%; } + .col-9 { flex: 0 0 75%; max-width: 75%; } + .col-10 { flex: 0 0 83.33%; max-width: 83.33%; } + .col-11 { flex: 0 0 91.66%; max-width: 91.66%; } + .col-12 { flex: 0 0 100%; max-width: 100%; } + + @media (max-width: 768px){ + [class*="col-"] { + max-width: 70%; + } + .container{ + flex-wrap: wrap; + } + } + + @media (max-width: 456px){ + [class*="col-"] { + max-width: 90%; + } + .container{ + flex-wrap: wrap; + } + } \ No newline at end of file diff --git a/FVS-Social/upload-post/delete-post.php b/FVS-Social/upload-post/delete-post.php new file mode 100644 index 0000000..61a3e53 --- /dev/null +++ b/FVS-Social/upload-post/delete-post.php @@ -0,0 +1,32 @@ +prepare("SELECT * FROM posts WHERE id = :id AND user_id = :user_id"); + $stmt->execute([':id' => $postId, ':user_id' => $userId]); + $post = $stmt->fetch(PDO::FETCH_ASSOC); + + if (!$post) { + die("Post nicht gefunden oder keine Berechtigung, diesen Post zu löschen."); + } + + + $stmt = $pdo->prepare("DELETE FROM posts WHERE id = :id"); + $stmt->execute([':id' => $postId]); + + if (!empty($post['image_path']) && file_exists('../' . $post['image_path'])) { + unlink('../' . $post['image_path']); + } + + header("Location: ../index.php?page=posts"); + exit; + } \ No newline at end of file diff --git a/FVS-Social/upload-post/upload-post.php b/FVS-Social/upload-post/upload-post.php new file mode 100644 index 0000000..9bf6e84 --- /dev/null +++ b/FVS-Social/upload-post/upload-post.php @@ -0,0 +1,41 @@ +prepare("INSERT INTO posts (user_id, text_content, image_path) VALUES (:user_id, :text_content, :image_path)"); + $stmt->execute([ + ':user_id' => $user_id, + ':text_content' => $text_content, + ':image_path' => $image_path + ]); + + + header("Location: ../index.php"); + exit(); +} + + +?> \ No newline at end of file diff --git a/FVS-Social/upload-profile/delete-pb.php b/FVS-Social/upload-profile/delete-pb.php new file mode 100644 index 0000000..40f6f75 --- /dev/null +++ b/FVS-Social/upload-profile/delete-pb.php @@ -0,0 +1,27 @@ +prepare("SELECT file_path FROM profile_pictures WHERE user_id = :id"); +$stmt->execute([':id' => $userId]); +$user = $stmt->fetch(PDO::FETCH_ASSOC); + +if($user && !empty($user['file_path'])){ + $file_Path = "../" . $user['file_path']; + + if(file_exists($file_Path)){ + unlink($file_Path); + } + + $stmt = $pdo->prepare("DELETE FROM profile_pictures WHERE user_id = :id"); + $stmt->execute([':id' => $userId]); +} + +header("Location: ../index.php"); +exit; + + + +?> \ No newline at end of file diff --git a/FVS-Social/upload-profile/upload-post.php b/FVS-Social/upload-profile/upload-post.php new file mode 100644 index 0000000..ba2e1f6 --- /dev/null +++ b/FVS-Social/upload-profile/upload-post.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/FVS-Social/upload-profile/upload.php b/FVS-Social/upload-profile/upload.php new file mode 100644 index 0000000..f73255c --- /dev/null +++ b/FVS-Social/upload-profile/upload.php @@ -0,0 +1,68 @@ + $max_size) { + die("Datei ist zu groß (max. 2MB)."); + } + + + $stmt1 = $pdo->prepare("SELECT file_path FROM profile_pictures WHERE user_id = :id"); + $stmt1->execute([':id' => $user_id]); + $user = $stmt1->fetch(PDO::FETCH_ASSOC); + + if($user && !empty($user['file_path'])){ + $file_Path3 = "../" . $user['file_path']; + + if(file_exists($file_Path3)){ + unlink($file_Path3); + } + + $stmt = $pdo->prepare("DELETE FROM profile_pictures WHERE user_id = :id"); + $stmt->execute([':id' => $user_id]); + } + + $new_file_name = "profile_" . $user_id . "." . $file_ext; + $file_path = $upload_dir . $new_file_name; + $file_path1 = "profile-pics/" . $new_file_name; + if (move_uploaded_file($file_tmp, $file_path)) { + + + $stmt = $pdo->prepare("INSERT INTO profile_pictures (user_id, file_path) VALUES (:user_id, :file_path) + ON DUPLICATE KEY UPDATE file_path = VALUES(file_path)"); + $stmt->execute([':user_id' => $user_id, ':file_path' => $file_path1]); + + header("Location: ../index.php"); + + } else { + echo "Fehler beim Hochladen. Prüfe Folgendes:
"; + echo "Temp-Datei: " . htmlspecialchars($file_tmp) . "
"; + echo "Ziel-Pfad: " . htmlspecialchars($file_path) . "
"; + + if (!is_writable($upload_dir)) { + echo " Fehler: Der Ordner '$upload_dir' ist nicht beschreibbar!
";; + } +} +} +?> \ No newline at end of file diff --git a/FVS-Social/userused.html b/FVS-Social/userused.html new file mode 100644 index 0000000..8c9e015 --- /dev/null +++ b/FVS-Social/userused.html @@ -0,0 +1,11 @@ + + + + + + Document + + +

Benutzer bereits vergeben!

+ + \ No newline at end of file