diff --git a/FVS-Social/chat.php b/FVS-Social/chat.php new file mode 100644 index 0000000..c480b3a --- /dev/null +++ b/FVS-Social/chat.php @@ -0,0 +1,196 @@ +Du musst dich zuerst Einloggen oder Regestrieren
Hier Einloggen
Hier Regestrieren"); +} + +include "db_connect.php"; + +$username = $_GET['user']; +$userId = $_SESSION['user_id']; + +try { + // Benutzerdaten abrufen + $stmt = $pdo->prepare("SELECT id, username, email, created_at FROM users WHERE id = :username"); + $stmt->execute([':username' => $username]); + $selected_user = $stmt->fetch(PDO::FETCH_ASSOC); + + $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_pic2 = $stmt2->fetch(PDO::FETCH_ASSOC); + + $stmt3 = $pdo->prepare(" + SELECT users.id, 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); + + $stmt2 = $pdo->prepare("SELECT file_path FROM profile_pictures WHERE user_id = :user_id"); + $stmt2->execute([':user_id' => $selected_user['id']]); + $profile_pic = $stmt2->fetch(PDO::FETCH_ASSOC); + + + if ($profile_pic) { + $selected_profile_image = $profile_pic['file_path']; + } else { + $selected_profile_image = 'profile-pics/default.jpeg'; + } + + if ($profile_pic2) { + $selected_profile_image1 = $profile_pic2['file_path']; + } else { + $selected_profile_image1 = 'profile-pics/default.jpeg'; + } + + $stmt3 = $pdo->prepare("SELECT COUNT(following_id) AS following_count FROM followers WHERE following_id = :user_id "); + $stmt3->execute([':user_id' => $selected_user['id']]); + $follower_count = $stmt3->fetch(PDO::FETCH_ASSOC)['following_count']; + + $sender_id = $_SESSION['user_id']; + $receiver_id = $_GET['user']; +} catch (PDOException $e) { + die("Fehler: " . $e->getMessage()); +} +?> + + + + + + + + + Profil von <?php echo htmlspecialchars($selected_user['username']); ?> + + + +
+
+ + + +
+
+ +
+

Profil von

+ Profilbild +

Email:

+

Registriert seit:

+

Follower:

+ + Zurück zur Startseite +
+
+ prepare("SELECT * FROM messages + WHERE (sender_id = :sender_id AND receiver_id = :receiver_id) + OR (sender_id = :receiver_id AND receiver_id = :sender_id) + ORDER BY sent_at ASC"); + + $stmt->execute([ + ':sender_id' => $sender_id, + ':receiver_id' => $receiver_id + ]); + $messages = $stmt->fetchAll(PDO::FETCH_ASSOC); + + $stmt3324 = $pdo->prepare("SELECT * FROM users WHERE id = :user_id"); + $stmt3324->execute([':user_id' => $receiver_id]); + $receiver = $stmt3324->fetch(PDO::FETCH_ASSOC); + ?> +

Chat mit Benutzer

+
+ +

: + +

+ +
+ +
+ + + +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + diff --git a/FVS-Social/get_messages.php b/FVS-Social/get_messages.php new file mode 100644 index 0000000..f81588f --- /dev/null +++ b/FVS-Social/get_messages.php @@ -0,0 +1,34 @@ +prepare("SELECT * FROM messages + WHERE (sender_id = :sender_id AND receiver_id = :receiver_id) + OR (sender_id = :receiver_id AND receiver_id = :sender_id) + ORDER BY sent_at ASC"); + +$stmt->execute([ + ':sender_id' => $sender_id, + ':receiver_id' => $receiver_id +]); +$messages = $stmt->fetchAll(PDO::FETCH_ASSOC); + +$stmt3324 = $pdo->prepare("SELECT * FROM users WHERE id = :user_id"); +$stmt3324->execute([':user_id' => $receiver_id]); +$receiver = $stmt3324->fetch(PDO::FETCH_ASSOC); + + +?> + + +

: + +

+ diff --git a/FVS-Social/icons/arrow-right.svg b/FVS-Social/icons/arrow-right.svg new file mode 100644 index 0000000..fb155c7 --- /dev/null +++ b/FVS-Social/icons/arrow-right.svg @@ -0,0 +1,2 @@ + + diff --git a/FVS-Social/icons/delete.svg b/FVS-Social/icons/delete.svg new file mode 100644 index 0000000..44a7cb9 --- /dev/null +++ b/FVS-Social/icons/delete.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/FVS-Social/icons/edit.svg b/FVS-Social/icons/edit.svg new file mode 100644 index 0000000..6b71558 --- /dev/null +++ b/FVS-Social/icons/edit.svg @@ -0,0 +1,2 @@ + + diff --git a/FVS-Social/icons/envelope.svg b/FVS-Social/icons/envelope.svg new file mode 100644 index 0000000..b99529c --- /dev/null +++ b/FVS-Social/icons/envelope.svg @@ -0,0 +1,2 @@ + + diff --git a/FVS-Social/icons/exit.svg b/FVS-Social/icons/exit.svg new file mode 100644 index 0000000..3686915 --- /dev/null +++ b/FVS-Social/icons/exit.svg @@ -0,0 +1,2 @@ + + diff --git a/FVS-Social/icons/full_heart.svg b/FVS-Social/icons/full_heart.svg new file mode 100644 index 0000000..963ece5 --- /dev/null +++ b/FVS-Social/icons/full_heart.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/FVS-Social/icons/home.svg b/FVS-Social/icons/home.svg new file mode 100644 index 0000000..5ab3d48 --- /dev/null +++ b/FVS-Social/icons/home.svg @@ -0,0 +1,2 @@ + + diff --git a/FVS-Social/icons/picture.svg b/FVS-Social/icons/picture.svg new file mode 100644 index 0000000..9a7e251 --- /dev/null +++ b/FVS-Social/icons/picture.svg @@ -0,0 +1,2 @@ + + diff --git a/FVS-Social/icons/unlike_heart.svg b/FVS-Social/icons/unlike_heart.svg new file mode 100644 index 0000000..980a9d5 --- /dev/null +++ b/FVS-Social/icons/unlike_heart.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/FVS-Social/icons/user.svg b/FVS-Social/icons/user.svg new file mode 100644 index 0000000..885c92b --- /dev/null +++ b/FVS-Social/icons/user.svg @@ -0,0 +1,2 @@ + + diff --git a/FVS-Social/index.php b/FVS-Social/index.php index 2b4738a..0aa3b29 100644 --- a/FVS-Social/index.php +++ b/FVS-Social/index.php @@ -1,48 +1,70 @@ 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(" + //Daten von Angemeldeten benutzer werden ausgelesen + $stmt1 = $pdo->prepare("SELECT username, email, created_at FROM users WHERE id = :id"); + $stmt1->execute([':id' => $userId]); + $user = $stmt1->fetch(PDO::FETCH_ASSOC); + + + + //Profilbild wird vom angemeldeten benutzer ausgelesen + $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); + + + //Benutzername und Profilbild werden von allen benutzer ausgelesen + $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); + $stmt3->execute(); + $users = $stmt3->fetchAll(PDO::FETCH_ASSOC); + + //Alle beiträge von allen benutzer werden ausgelesen + $stmt4 = $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 + ORDER BY posts.created_at DESC + "); + $stmt4->execute(); + $posts = $stmt4->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()); + + + 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()); +} ?> + @@ -50,22 +72,26 @@ if(!isset($_SESSION['user_id'])) { '; ?> Profile + +
- @@ -73,9 +99,8 @@ if(!isset($_SESSION['user_id'])) {
-
- Posts - - "; - }elseif($page == 'about'){ - echo "

Über mich

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

Einstellungen

-

Profilbild änderen

-
- -
- -
-

Profilbild löschen

-
- -
-

Profilbild änderm

-
- - -
- -

Profilbild änderm

-
- -
- - "; - 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 - ORDER BY posts.created_at DESC - "); - $stmt45->execute(); - $posts = $stmt45->fetchAll(PDO::FETCH_ASSOC); - } - ?> -
+
+ prepare("SELECT COUNT(post_id) AS likes_count FROM likes WHERE post_id = :post_id"); + $stmt5->execute([':post_id' => $post['id']]); + $likes = $stmt5->fetch(PDO::FETCH_ASSOC)['likes_count']; + + $stmt6 = $pdo->prepare("SELECT user_id, post_id FROM likes WHERE post_id = :post_id AND user_id = :user_id"); + $stmt6->execute([':post_id' => $post['id'], ':user_id' => $userId]); + $isLiked = $stmt6->fetch(PDO::FETCH_ASSOC); + ?>
- -

+
+
+ +

+
+ +
+ + +
+ +
+ +

Bild zum Post + +
Likes:

Erstellt am:

- -
- - -
- +
+ +
+ + +
+ +
+ + +
+ + + +
+
+ \ No newline at end of file diff --git a/FVS-Social/like/like.php b/FVS-Social/like/like.php new file mode 100644 index 0000000..e468343 --- /dev/null +++ b/FVS-Social/like/like.php @@ -0,0 +1,23 @@ +prepare("INSERT INTO likes (user_id, post_id) VALUES (:user_id, :post_id)"); + $like_abfrage->execute([':user_id' => $like_id, ':post_id' => $liked_id]); + header("location: ../index.php"); +} +catch(PDOException $e){ + echo $e->getMessage(); +} + + diff --git a/FVS-Social/like/unlike.php b/FVS-Social/like/unlike.php new file mode 100644 index 0000000..5af4a83 --- /dev/null +++ b/FVS-Social/like/unlike.php @@ -0,0 +1,23 @@ +prepare("DELETE FROM likes WHERE user_id = :user_id AND post_id = :post_id"); + $like_abfrage->execute([':user_id' => $like_id, ':post_id' => $liked_id]); + header("location: ../index.php"); +} +catch(PDOException $e){ + echo $e->getMessage(); +} + + diff --git a/FVS-Social/login/login-page.html b/FVS-Social/login/login-page.html index dbcb017..ec4540c 100644 --- a/FVS-Social/login/login-page.html +++ b/FVS-Social/login/login-page.html @@ -20,7 +20,7 @@ Passwort vergessen? -

Noch kein Account?Jetzt Regestrieren!

+ diff --git a/FVS-Social/profile-pics/profile_9.png b/FVS-Social/profile-pics/profile_9.png index da6688c..61ec6b4 100644 Binary files a/FVS-Social/profile-pics/profile_9.png and b/FVS-Social/profile-pics/profile_9.png differ diff --git a/FVS-Social/profile.php b/FVS-Social/profile.php index cdbf869..9e497f9 100644 --- a/FVS-Social/profile.php +++ b/FVS-Social/profile.php @@ -10,6 +10,8 @@ if (!isset($_GET['user'])) { die("Kein Benutzer angegeben."); } +$page = isset($_GET['page']) ? $_GET['page'] : 'posts'; + $username = $_GET['user']; $userId = $_SESSION['user_id']; @@ -57,6 +59,7 @@ try { $selected_profile_image1 = 'profile-pics/default.jpeg'; } + $stmt3 = $pdo->prepare("SELECT COUNT(following_id) AS following_count FROM followers WHERE following_id = :user_id "); $stmt3->execute([':user_id' => $selected_user['id']]); $follower_count = $stmt3->fetch(PDO::FETCH_ASSOC)['following_count']; @@ -78,15 +81,17 @@ try {
@@ -94,23 +99,26 @@ try { +
+

Profil von

Profilbild

Email:

Registriert seit:

Follower:

+ + Nicht mehr Folgen +
+ + +
+ Zurück zur Startseite + Posts + Über mich + + Einstellungen +
+ +
+ +

Einstellungen

+

Profilbild änderen

+
+ +
+ +
+

Profilbild löschen

+
+ +
+ +

Profilbild änderm

+
+ + +
+ +

Profilbild änderm

+
+ +
+
+ prepare(" @@ -147,6 +192,7 @@ try { $stmt45->execute([':username' => $username]); $posts = $stmt45->fetchAll(PDO::FETCH_ASSOC); ?> +
@@ -168,7 +214,7 @@ try {
- +
diff --git a/FVS-Social/send_message.php b/FVS-Social/send_message.php new file mode 100644 index 0000000..c85501c --- /dev/null +++ b/FVS-Social/send_message.php @@ -0,0 +1,21 @@ +prepare("INSERT INTO messages (sender_id, receiver_id, message) VALUES (:sender_id, :receiver_id, :message)"); + $stmt->execute([ + ':sender_id' => $sender_id, + ':receiver_id' => $receiver_id, + ':message' => $message + ]); + } +} +header("Location: chat.php?user=$receiver_id"); +exit(); +?> \ No newline at end of file diff --git a/FVS-Social/style.css b/FVS-Social/style.css index 253b8f2..a8e32f8 100644 --- a/FVS-Social/style.css +++ b/FVS-Social/style.css @@ -2,15 +2,150 @@ box-sizing: border-box; } - .profile-pictures, .navigation-body ul li img { width: 50px; height: 50px; border-radius: 50%; } - +.profile-pictures { width: 50px; height: 50px; border-radius: 50%; } +.profile-pictures-header { width: 75px; height: 75px; border-radius: 50%;} + body { + scroll-behavior: smooth; margin: 0; font-family: Arial, sans-serif; background-color: #FAFBFF; } + +a{ + text-decoration: none; + color: black; +} + +ul{ + list-style: none; + padding: 0; +} + +.profile-name-header{ + display: flex; + align-items: center; + justify-content: center; + margin-top: 20px; +} + +.profile-name-header h1{ + margin: 0; + padding-left: 15px; + padding-right: 15px; +} + +.icons{ + list-style: none; + padding: 0 20px 0 20px; +} + +.icons a img { + height: 25px; +} + +.icons img{ + height: 25px; +} + +.icons a { + align-items: center; + width: 100%; + padding: 10px; + display: flex; + flex-direction: row; + gap: 20px; + border-radius: 20px; + font-size: 19px; + transition: all 0.3s ease, transform 0.3s ease; +} + +.like-button { + width: 30px; + height: 30px; + border: none; + background-size: cover; + background-position: center; + background-color: white; + border-radius: 50%; + cursor: pointer; + transition: transform 0.2s ease; +} + +.like-button.unlike { + background-image: url('icons/unlike_heart.svg'); +} + +.like-button.liked { + background-image: url('icons/full_heart.svg'); +} + +.like-button:hover { + transform: scale(1.1); +} + +.like-button:active { + transform: scale(0.9); +} + +.delete-post{ + width: 30px; + height: 30px; + border: none; + background-size: cover; + background-position: center; + background-color: white; + border-radius: 50%; + cursor: pointer; + transition: transform 0.2s ease; + background-image: url("icons/delete.svg"); +} + +.delete-post:hover { + transform: scale(1.1); +} + +.delete-post:active { + transform: scale(0.9); +} + +.post-nav{ + display: flex; + justify-content: space-between; +} + +.post-footer{ + display: flex; + flex-direction: row; +} +.post-footer button{ + margin-right: 5px; + margin-left: 5px; +} + +.user-card{ + list-style: none; + padding: 0 20px 0 20px; +} + +.user-card a{ + align-items: center; + width: 100%; + padding: 10px; + display: flex; + flex-direction: row; + gap: 20px; + border-radius: 20px; + font-size: 19px; + transition: all 0.3s ease, transform 0.3s ease; +} +.navigation-body ul li a:hover{ + background-color: rgba(18, 137, 255, 0.35); +} + + .container { max-width: 1200px; margin: 0 auto; @@ -21,11 +156,6 @@ body { } -.post-pics{ - max-width: 500px; - height: auto; -} - .post-formular-body, .post, .posts-body, .all-posts-body, .profile-header, .navigation-body{ background-color: #FFFFFF; @@ -33,42 +163,73 @@ body { box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.25); width: 100%; border-radius: 20px; + margin-bottom: 30px; } +.container { + display: grid; + grid-template-columns: repeat(12, 1fr); + gap: 15px; +} + +.post-pics{ + height: auto; + width: 90%; + max-width: 400px; + margin: 5px; + padding: 5px; +} + +.post{ + padding: 20px; +} +.post-header { + display: flex; + flex-direction: row; +} +.post-header img{ + margin-right: 10px; +} + [class*="col-"] { - padding: 15px; - flex: 0 0 auto; - box-sizing: border-box; + padding: 15px; + box-sizing: border-box; +} + +.col-1 { grid-column: span 1; } +.col-2 { grid-column: span 2; } +.col-3 { grid-column: span 3; } +.col-4 { grid-column: span 4; } +.col-5 { grid-column: span 5; } +.col-6 { grid-column: span 6; } +.col-7 { grid-column: span 7; } +.col-8 { grid-column: span 8; } +.col-9 { grid-column: span 9; } +.col-10 { grid-column: span 10; } +.col-11 { grid-column: span 11; } +.col-12 { grid-column: span 12; } + +@media (max-width: 768px) { + .container { + grid-template-columns: repeat(6, 1fr); } - - .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; - } + .col-3 { + grid-column: span 12; } - - @media (max-width: 456px){ - [class*="col-"] { - max-width: 90%; - } - .container{ - flex-wrap: wrap; - } - } \ No newline at end of file + .col-9 { + grid-column: span 12; + } +} + +@media (max-width: 456px) { + .container { + grid-template-columns: repeat(6, 1fr); + } + .col-3 { + grid-column: span 12; + } + .col-9 { + grid-column: span 12; + } +} \ No newline at end of file diff --git a/FVS-Social/upload-post/upload-post.php b/FVS-Social/upload-post/upload-post.php index 3575d1c..f6beb56 100644 --- a/FVS-Social/upload-post/upload-post.php +++ b/FVS-Social/upload-post/upload-post.php @@ -1,30 +1,44 @@ -prepare("INSERT INTO posts (user_id, text_content, image_path) VALUES (:user_id, :text_content, :image_path)"); $stmt->execute([ ':user_id' => $user_id, @@ -32,9 +46,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST") { ':image_path' => $image_path ]); - header("Location: ../index.php"); + header("Location: ../index.php"); exit(); } - - ?> \ No newline at end of file