diff --git a/application/controllers/File.php b/application/controllers/File.php
index f36a846..4ba96fc 100644
--- a/application/controllers/File.php
+++ b/application/controllers/File.php
@@ -14,7 +14,7 @@ class File extends MY_Controller
if ($title == null) {
redirect(base_url());
} else {
- $file = $this->db->query('SELECT name, type, path FROM files WHERE name = ?', [urldecode($title)])->result_array();
+ $file = $this->db->query('SELECT name, type, path, isUserData FROM files WHERE name = ?', [urldecode($title)])->result_array();
if (!empty($file)) {
$file = $file[0];
@@ -25,7 +25,7 @@ class File extends MY_Controller
header("Content-Disposition: attachment; filename=" . $file['name'] . '.' . explode('/', $file['type'])[1]);
}
- $imagePath = 'files/' . (isset($_GET['w']) || isset($_GET['h']) ? 'thumbs/' : '') . $file['name'] . (isset($_GET['w']) ? '_w' . $_GET['w'] : '') . (isset($_GET['h']) ? '_h' . $_GET['h'] : '') . '.' . explode('.', $file['path'])[1];
+ $imagePath = 'files/' . ($file['isUserData'] ? 'userContent/' : '') . (isset($_GET['w']) || isset($_GET['h']) ? 'thumbs/' : '') . $file['name'] . (isset($_GET['w']) ? '_w' . $_GET['w'] : '') . (isset($_GET['h']) ? '_h' . $_GET['h'] : '') . '.' . explode('.', $file['path'])[1];
if (!file_exists($imagePath)) {
$config['image_library'] = 'gd2';
diff --git a/application/controllers/User.php b/application/controllers/User.php
index e2d5426..785c374 100644
--- a/application/controllers/User.php
+++ b/application/controllers/User.php
@@ -1,74 +1,38 @@
load->model('UserModel', '', TRUE);
+ $this->load->model('PostsModel', '', TRUE);
+ $this->load->model('FileModel', '', TRUE);
+ }
- public function __construct()
- {
- parent::__construct('profile', 'language_names', 'country_names');
- $this->load->model('UserModel', '', TRUE);
- $this->load->model('PostsModel', '', TRUE);
- $this->load->model('FileModel', '', TRUE);
- }
-
- public function index($user = "")
- {
- if ($user == "") {
- $title = "Error - Profile";
- $message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Es wurde kein Nutzername angegeben."];
- } else {
- $user_data = $this->UserModel->getUser($user);
- $user_exists = !empty($user_data);
- if ($user_exists) {
- $user_data = $user_data[0];
- $user_stats = $this->UserModel->getUserStats($user_data['ID']);
-
- $user_posts = $this->PostsModel->getUserPosts($user_data['ID'], 3, 0, 192);
- $user_comments = $this->UserModel->getUserComments($user_data['ID'], 3, 0);
- $user_blog_posts = $this->UserModel->getUserBlogPosts($user_data['ID'], 3, 0);
-
- $date_created = strtotime($user_data['date_created']);
- $user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date_created"), $_SESSION['site_lang']);
- $title = $user_data['displayname'] . " - Profile";
- $isCurrentUserFollowing = false;
- if (isset($_SESSION['user']['ID']))
- $isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
-
- $_SESSION['currentProfilePage'] = $user_data['ID'];
- } else {
- $message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
- $title = "Error - Profile";
- }
- }
-
- $this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
- if (isset($message)) {
- $this->load->view('network/message', $message);
- }
- if (isset($user_data) && isset($user_stats) && isset($user_posts) && isset($user_comments) && isset($user_blog_posts)) {
- $this->load->view('network/user/profile_page', ['data' => $user_data, 'stats' => $user_stats, 'posts' => $user_posts, 'comments' => $user_comments, 'blog_posts' => $user_blog_posts, 'isCurrentUserFollowing' => $isCurrentUserFollowing]);
- }
- $this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
- }
-
- public function comments($user = "")
- {
- if ($user == "") {
- $title = "Error - Profile";
- $message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Es wurde kein Nutzername angegeben."];
- }
-
+ public function index($user = "")
+ {
+ if ($user == "") {
+ $title = "Error - Profile";
+ $message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Es wurde kein Nutzername angegeben."];
+ } else {
$user_data = $this->UserModel->getUser($user);
$user_exists = !empty($user_data);
if ($user_exists) {
$user_data = $user_data[0];
- $dateCreated = strtotime($user_data['date_created']);
- $user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
- $title = $user_data['displayname'] . " - Blog-Kommentare";
+
+ $user_posts = $this->PostsModel->getUserPosts($user_data['ID'], 3, 0, 192);
+ $user_comments = $this->UserModel->getUserComments($user_data['ID'], 3, 0);
+ $user_blog_posts = $this->UserModel->getUserBlogPosts($user_data['ID'], 3, 0);
+
+ $date_created = strtotime($user_data['date_created']);
+ $user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date_created"), $_SESSION['site_lang']);
+ $title = $user_data['displayname'] . " - Profile";
$isCurrentUserFollowing = false;
if (isset($_SESSION['user']['ID']))
$isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
@@ -78,539 +42,582 @@
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
$title = "Error - Profile";
}
-
-
- $this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
- if (isset($message)) {
- $this->load->view('network/message', $message);
- }
- if ($user_exists) {
- $this->load->view('network/blog/user_comments', ['data' => $user_data, 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing]);
- }
- $this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
- $this->load->view('network/blog/user_comments_end', ['data' => $user_data]);
}
- public function getComments()
- {
- $user = (int)$this->input->get('user');
- $amount = (int)$this->input->get('amount');
- $offset = (int)$this->input->get('offset') * $amount;
- $user_comments = $this->UserModel->getUserComments($user, $amount, $offset);
- $comment_user = $this->UserModel->getUserByID($user)[0];
+ $this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
+ if (isset($message)) {
+ $this->load->view('network/message', $message);
+ }
+ if (isset($user_data) && isset($user_stats) && isset($user_posts) && isset($user_comments) && isset($user_blog_posts)) {
+ $this->load->view('network/user/profile_page', ['data' => $user_data, 'stats' => $user_stats, 'posts' => $user_posts, 'comments' => $user_comments, 'blog_posts' => $user_blog_posts, 'isCurrentUserFollowing' => $isCurrentUserFollowing]);
+ }
+ $this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
+ }
- foreach ($user_comments as $comment) {
- $this->load->view('network/blog/comment_item', ['data' => $comment_user, 'c' => $comment]);
- }
+ public function comments($user = "")
+ {
+ if ($user == "") {
+ $title = "Error - Profile";
+ $message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Es wurde kein Nutzername angegeben."];
}
- public function posts($user = "")
- {
- if ($user == "") {
- redirect(base_url('user'));
- }
+ $user_data = $this->UserModel->getUser($user);
+ $user_exists = !empty($user_data);
+ if ($user_exists) {
+ $user_data = $user_data[0];
+ $dateCreated = strtotime($user_data['date_created']);
+ $user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
+ $user_stats = $this->UserModel->getUserStats($user_data['ID']);
+ $title = $user_data['displayname'] . " - Blog-Kommentare";
+ $isCurrentUserFollowing = false;
+ if (isset($_SESSION['user']['ID']))
+ $isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
- $user_data = $this->UserModel->getUser($user);
- $user_exists = !empty($user_data);
- if ($user_exists) {
- $user_data = $user_data[0];
- $dateCreated = strtotime($user_data['date_created']);
- $user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
- $user_stats = $this->UserModel->getUserStats($user_data['ID']);
- $title = $user_data['displayname'] . " - Posts";
- $isCurrentUserFollowing = false;
- if (isset($_SESSION['user']['ID']))
- $isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
-
- $_SESSION['currentProfilePage'] = $user_data['ID'];
- } else {
- $message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
- $title = "Error - Profile";
- }
-
- $this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
- if (isset($message)) {
- $this->load->view('network/message', $message);
- }
- if ($user_exists) {
- $this->load->view('network/user/user_posts', ['data' => $user_data, 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing]);
- }
- $this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
- $this->load->view('network/user/user_posts_end', ['data' => $user_data]);
+ $_SESSION['currentProfilePage'] = $user_data['ID'];
+ } else {
+ $message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
+ $title = "Error - Profile";
}
- public function getPosts()
- {
- $user = (int)$this->input->get('user');
- $amount = (int)$this->input->get('amount');
- $offset = (int)$this->input->get('offset') * $amount;
- $user_posts = $this->PostsModel->getUserPosts($user, $amount, $offset);
- foreach ($user_posts as $post) {
- $this->load->view('network/posts/post_item', $post);
- }
+ $this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
+ if (isset($message)) {
+ $this->load->view('network/message', $message);
+ }
+ if ($user_exists) {
+ $this->load->view('network/blog/user_comments', ['data' => $user_data, 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing]);
+ }
+ $this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
+ $this->load->view('network/blog/user_comments_end', ['data' => $user_data]);
+ }
+
+ public function getComments()
+ {
+ $user = (int)$this->input->get('user');
+ $amount = (int)$this->input->get('amount');
+ $offset = (int)$this->input->get('offset') * $amount;
+ $user_comments = $this->UserModel->getUserComments($user, $amount, $offset);
+ $comment_user = $this->UserModel->getUserByID($user)[0];
+
+ foreach ($user_comments as $comment) {
+ $this->load->view('network/blog/comment_item', ['data' => $comment_user, 'c' => $comment]);
+ }
+ }
+
+ public function posts($user = "")
+ {
+ if ($user == "") {
+ redirect(base_url('user'));
}
- public function blogposts($user = "")
- {
- if ($user == "") {
- redirect(base_url('user'));
- }
+ $user_data = $this->UserModel->getUser($user);
+ $user_exists = !empty($user_data);
+ if ($user_exists) {
+ $user_data = $user_data[0];
+ $dateCreated = strtotime($user_data['date_created']);
+ $user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
+ $user_stats = $this->UserModel->getUserStats($user_data['ID']);
+ $title = $user_data['displayname'] . " - Posts";
+ $isCurrentUserFollowing = false;
+ if (isset($_SESSION['user']['ID']))
+ $isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
- $user_data = $this->UserModel->getUser($user);
- $user_exists = !empty($user_data);
- if ($user_exists) {
- $user_data = $user_data[0];
- $dateCreated = strtotime($user_data['date_created']);
- $user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
- $user_stats = $this->UserModel->getUserStats($user_data['ID']);
- $title = $user_data['displayname'] . " - Posts";
- $isCurrentUserFollowing = false;
- if (isset($_SESSION['user']['ID']))
- $isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
-
- $_SESSION['currentProfilePage'] = $user_data['ID'];
- } else {
- $message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
- $title = "Error - Profile";
- }
-
- $this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
- if (isset($message)) {
- $this->load->view('network/message', $message);
- }
- if ($user_exists) {
- $this->load->view('network/blog/user_blog_posts', ['data' => $user_data, 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing]);
- }
- $this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
- $this->load->view('network/blog/user_blog_posts_end', ['data' => $user_data]);
+ $_SESSION['currentProfilePage'] = $user_data['ID'];
+ } else {
+ $message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
+ $title = "Error - Profile";
}
- public function getBlogPosts()
- {
- $user = (int)$this->input->get('user');
- $amount = (int)$this->input->get('amount');
- $offset = (int)$this->input->get('offset') * $amount;
- $user_posts = $this->UserModel->getUserBlogPosts($user, $amount, $offset);
- $post_user = $this->UserModel->getUserByID($user)[0];
+ $this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
+ if (isset($message)) {
+ $this->load->view('network/message', $message);
+ }
+ if ($user_exists) {
+ $this->load->view('network/user/user_posts', ['data' => $user_data, 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing]);
+ }
+ $this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
+ $this->load->view('network/user/user_posts_end', ['data' => $user_data]);
+ }
- foreach ($user_posts as $post) {
- $this->load->view('network/blog/blog_post_item', ['data' => $post_user, 'post' => $post]);
- }
+ public function getPosts()
+ {
+ $user = (int)$this->input->get('user');
+ $amount = (int)$this->input->get('amount');
+ $offset = (int)$this->input->get('offset') * $amount;
+ $user_posts = $this->PostsModel->getUserPosts($user, $amount, $offset);
+
+ foreach ($user_posts as $post) {
+ $this->load->view('network/posts/post_item', $post);
+ }
+ }
+
+ public function blogposts($user = "")
+ {
+ if ($user == "") {
+ redirect(base_url('user'));
}
- public function publishPost()
- {
- if (!isset($_SESSION['user']) || empty($_SESSION['user'])) {
- ?>
-
-
Veröffentlichen des Posts fehlgeschlagen!
- Du musst in deinen Account eingeloggt sein, um Posts erstellen zu können.
+ $user_data = $this->UserModel->getUser($user);
+ $user_exists = !empty($user_data);
+ if ($user_exists) {
+ $user_data = $user_data[0];
+ $dateCreated = strtotime($user_data['date_created']);
+ $user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
+ $user_stats = $this->UserModel->getUserStats($user_data['ID']);
+ $title = $user_data['displayname'] . " - Posts";
+ $isCurrentUserFollowing = false;
+ if (isset($_SESSION['user']['ID']))
+ $isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
- Bitte erstelle dir entweder
-
kostenlos einen neuen Account
- oder
-
melde dich an
- .
-
- input->post('content');
- if (strlen($content) >= 10000) {
- ?>
-
- Veröffentlichung des Posts fehlgeschlagen! Dein Post ist leider zu lang. Er darf maximal 10.000 Zeichen umfassen.
-
- input->post('replyTo');
- if ($replyTo !== "-1" && !$this->PostsModel->isUUIDValid($replyTo)) {
- ?>
-
- Veröffentlichung des Posts fehlgeschlagen! Der Post, an den du deine Antwort richten willst, existiert nicht (mehr).
- Solltest du dies für einen Fehler halten, versuche es später erneut oder kontaktiere uns.
-
- PostsModel->addReply($_SESSION['user']['ID'], $content, $replyTo);
- } else {
- $postID = $this->PostsModel->addPost($_SESSION['user']['ID'], $content);
- }
-
- $media = $this->input->post('postMedia');
- if (!empty($media)) {
- foreach ($media as $entry) {
- $image = str_replace(' ', '+', $entry['image']);
- $image = substr($image, strpos($image, ',') + 1);
- $image = base64_decode($image);
-
- $fileUrl = $this->FileModel->uploadFileByContent($image, $entry['name'], $entry['type'], $entry['size']);
-
- $this->PostsModel->addImageToPost($postID, $fileUrl);
- }
-
- ?>
-
- "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
+ $title = "Error - Profile";
}
- public function followers($user = "")
- {
- if ($user == "") {
- $title = "Error - Profile";
- $message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Es wurde kein Nutzername angegeben."];
- }
+ $this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
+ if (isset($message)) {
+ $this->load->view('network/message', $message);
+ }
+ if ($user_exists) {
+ $this->load->view('network/blog/user_blog_posts', ['data' => $user_data, 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing]);
+ }
+ $this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
+ $this->load->view('network/blog/user_blog_posts_end', ['data' => $user_data]);
+ }
- $user_data = $this->UserModel->getUser($user);
- $user_exists = !empty($user_data);
- if ($user_exists) {
- $user_data = $user_data[0];
- $dateCreated = strtotime($user_data['date_created']);
- $user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
- $user_stats = $this->UserModel->getUserStats($user_data['ID']);
- $followers = $this->UserModel->getFollowers($user_data['ID']);
- $title = $user_data['displayname'] . " - Follower";
- $isCurrentUserFollowing = false;
- if (isset($_SESSION['user']['ID']))
- $isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
+ public function getBlogPosts()
+ {
+ $user = (int)$this->input->get('user');
+ $amount = (int)$this->input->get('amount');
+ $offset = (int)$this->input->get('offset') * $amount;
+ $user_posts = $this->UserModel->getUserBlogPosts($user, $amount, $offset);
+ $post_user = $this->UserModel->getUserByID($user)[0];
- $_SESSION['currentProfilePage'] = $user_data['ID'];
- } else {
- $message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
- $title = "Error - Profile";
- }
+ foreach ($user_posts as $post) {
+ $this->load->view('network/blog/blog_post_item', ['data' => $post_user, 'post' => $post]);
+ }
+ }
- $this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
- if (isset($message)) {
- $this->load->view('network/message', $message);
- }
- if ($user_exists) {
- $this->load->view('network/user/user_followers', ['data' => $user_data, 'active' => 'followers', 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing, 'followers' => $followers]);
- }
- $this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
+ public function publishPost()
+ {
+ if (!isset($_SESSION['user']) || empty($_SESSION['user'])) {
+ ?>
+
+
Veröffentlichen des Posts fehlgeschlagen!
+ Du musst in deinen Account eingeloggt sein, um Posts erstellen zu können.
+
+ Bitte erstelle dir entweder
+
kostenlos einen neuen Account
+ oder
+
melde dich an
+ .
+
+ "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Es wurde kein Nutzername angegeben."];
- }
-
- $user_data = $this->UserModel->getUser($user);
- $user_exists = !empty($user_data);
- if ($user_exists) {
- $user_data = $user_data[0];
- $dateCreated = strtotime($user_data['date_created']);
- $user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
- $user_stats = $this->UserModel->getUserStats($user_data['ID']);
- $following = $this->UserModel->getFollowing($user_data['ID']);
- $title = $user_data['displayname'] . " - Follower";
- $isCurrentUserFollowing = false;
- if (isset($_SESSION['user']['ID']))
- $isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
-
- $_SESSION['currentProfilePage'] = $user_data['ID'];
- } else {
- $message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
- $title = "Error - Profile";
- }
-
- $this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
- if (isset($message)) {
- $this->load->view('network/message', $message);
- }
- if ($user_exists) {
- $this->load->view('network/user/user_followers', ['data' => $user_data, 'active' => 'following', 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing, 'followers' => $following]);
- }
- $this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
+ $content = $this->input->post('content');
+ if (strlen($content) >= 10000) {
+ ?>
+
+ Veröffentlichung des Posts fehlgeschlagen! Dein Post ist leider zu lang. Er darf maximal 10.000
+ Zeichen umfassen.
+
+ 'error', 'code' => -1];
- echo json_encode($response);
- exit;
+ $replyTo = $this->input->post('replyTo');
+ if ($replyTo !== "-1" && !$this->PostsModel->isUUIDValid($replyTo)) {
+ ?>
+
+ Veröffentlichung des Posts fehlgeschlagen! Der Post, an den du deine Antwort richten willst,
+ existiert nicht (mehr).
+ Solltest du dies für einen Fehler halten, versuche es später erneut oder kontaktiere uns.
+
+ PostsModel->addReply($_SESSION['user']['ID'], $content, $replyTo);
+ } else {
+ $postID = $this->PostsModel->addPost($_SESSION['user']['ID'], $content);
+ }
+
+ $media = $this->input->post('postMedia');
+ if (!empty($media)) {
+ foreach ($media as $entry) {
+ $image = str_replace(' ', '+', $entry['image']);
+ $image = substr($image, strpos($image, ',') + 1);
+ $image = base64_decode($image);
+
+ $fileUrl = $this->FileModel->uploadFileByContent($image, $entry['name'], $entry['type'], $entry['size']);
+
+ $this->PostsModel->addImageToPost($postID, $fileUrl);
}
- $followedUser = $_SESSION['currentProfilePage'];
+ ?>
+
+ "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Es wurde kein Nutzername angegeben."];
+ }
- if (!isset($_SESSION['user']['username'])) {
- $response = ['type' => 'error', 'code' => 0];
- echo json_encode($response);
- exit;
- }
+ $user_data = $this->UserModel->getUser($user);
+ $user_exists = !empty($user_data);
+ if ($user_exists) {
+ $user_data = $user_data[0];
+ $dateCreated = strtotime($user_data['date_created']);
+ $user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
+ $user_stats = $this->UserModel->getUserStats($user_data['ID']);
+ $followers = $this->UserModel->getFollowers($user_data['ID']);
+ $title = $user_data['displayname'] . " - Follower";
+ $isCurrentUserFollowing = false;
+ if (isset($_SESSION['user']['ID']))
+ $isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
- $follower = $_SESSION['user']['ID'];
+ $_SESSION['currentProfilePage'] = $user_data['ID'];
+ } else {
+ $message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
+ $title = "Error - Profile";
+ }
- if ($follower == $followedUser) {
- $response = ['type' => 'error', 'code' => 1];
- echo json_encode($response);
- exit;
- }
+ $this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
+ if (isset($message)) {
+ $this->load->view('network/message', $message);
+ }
+ if ($user_exists) {
+ $this->load->view('network/user/user_followers', ['data' => $user_data, 'active' => 'followers', 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing, 'followers' => $followers]);
+ }
+ $this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
+ }
- if ($this->UserModel->isFollowing($follower, $followedUser)) {
- $this->UserModel->unfollow($follower, $followedUser);
- $response = ['type' => 'success', 'code' => 10];
- echo json_encode($response);
- exit;
- }
+ public function following($user = "")
+ {
+ if ($user == "") {
+ $title = "Error - Profile";
+ $message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Es wurde kein Nutzername angegeben."];
+ }
- $this->UserModel->follow($follower, $followedUser);
- $response = ['type' => 'success', 'code' => 11];
+ $user_data = $this->UserModel->getUser($user);
+ $user_exists = !empty($user_data);
+ if ($user_exists) {
+ $user_data = $user_data[0];
+ $dateCreated = strtotime($user_data['date_created']);
+ $user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
+ $user_stats = $this->UserModel->getUserStats($user_data['ID']);
+ $following = $this->UserModel->getFollowing($user_data['ID']);
+ $title = $user_data['displayname'] . " - Follower";
+ $isCurrentUserFollowing = false;
+ if (isset($_SESSION['user']['ID']))
+ $isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
+
+ $_SESSION['currentProfilePage'] = $user_data['ID'];
+ } else {
+ $message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
+ $title = "Error - Profile";
+ }
+
+ $this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
+ if (isset($message)) {
+ $this->load->view('network/message', $message);
+ }
+ if ($user_exists) {
+ $this->load->view('network/user/user_followers', ['data' => $user_data, 'active' => 'following', 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing, 'followers' => $following]);
+ }
+ $this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
+ }
+
+ public function switchFollowing()
+ {
+ header('Content-Type: application/json');
+ if (!isset($_SESSION['currentProfilePage'])) {
+ $response = ['type' => 'error', 'code' => -1];
echo json_encode($response);
exit;
}
- public function edit($user = "")
- {
- if ($user == "") {
- redirect(base_url('user'));
- }
+ $followedUser = $_SESSION['currentProfilePage'];
- $user_data = $this->UserModel->getUser($user);
- $user_exists = !empty($user_data);
- if ($user_exists) {
- $user_data = $user_data[0];
- // Update Settings
- $newData = [];
- // TODO: Error messages
- // Username
- if (isset($_POST['username'])) {
- if (!preg_match('/[^A-Za-z0-9._]/', $_POST['username'])) {
- if ($this->LoginModel->isAvailable($_POST['username'])) {
- if (strlen($_POST['username']) >= 4) {
- $newData['username'] = strtolower($_POST['username']);
- $newData['displayname'] = $_POST['username'];
- } else {
- $_SESSION['profileEditNotification'] .= "Zu kurzer Nutzername! Dein Name muss 4 Zeichen oder mehr enthalten.
";
- }
- } else {
- $_SESSION['profileEditNotification'] .= "Nutzername bereits vergeben! Ein anderer Nutzer hat anscheinend diesen Namen bereits gewählt.
";
- }
- } else {
- $_SESSION['profileEditNotification'] .= "Ungültiger Nutzername! Dein Name darf nur Groß- (A-Z) und Kleinbuchstaben (a-z), Zahlen (0-9) und Punkte (.) sowie Unterstriche (_).
";
- }
- }
- // Gender
- if (isset($_POST['gender'])) {
- if ($_POST['gender'] == "male" || $_POST['gender'] == "female" || $_POST['gender'] == 'other') {
- $newData['gender'] = $_POST['gender'];
- }
- }
- // Birth date
- if (isset($_POST['birthdate-day']) && isset($_POST['birthdate-month'])) {
- $day = intval($_POST['birthdate-day']);
- $month = intval($_POST['birthdate-month']);
- if ($month > 0 && $month <= 12) {
- $monthDayCount = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
- if ($day <= $monthDayCount[$month - 1]) {
- $newData['birthdate'] = $day . '.' . $month . '.';
- }
- }
- }
- if (isset($_POST['birthdate-year'])) {
+ // code 0: not logged in
+ // code 1: same user
+ // code 10: unfollowed
+ // code 11: now following
- }
- // Language
- if (isset($_POST['language'])) {
- $newData['language'] = $_POST['language'];
- }
- // Country
- if (isset($_POST['country'])) {
- $newData['country'] = $_POST['country'];
- }
- // Biography/About
- if (isset($_POST['biography'])) {
- $newData['about'] = $_POST['biography'];
- }
- // Avatar
- if (isset($_FILES['avatar'])) {
- $image = $this->FileModel->uploadImage('avatar', 4096, $_FILES['avatar']['name'], 200);
- if ($image != null)
- $newData['profile_picture'] = $image;
- unset($_FILES['avatar']);
- }
- // Header
- if (isset($_FILES['header'])) {
-// var_dump($_FILES['header']);
- $image = $this->FileModel->uploadImage('header', 4096, $_FILES['header']['name'], 1920);
-// var_dump($image);
- if ($image != null)
- $newData['header_image'] = $image;
- unset($_FILES['header']);
- }
- // Social Networks
- if (isset($_POST['social-networks'])) {
-
- }
- // Profile color
- if (isset($_POST['color'])) {
-
- }
- // E-Mail-Address
- if (isset($_POST['email'])) {
- if (isset($_POST['email-password']) && !empty($_POST['email-password'])) {
- $loginData = $this->LoginModel->getLoginData($_SESSION['user']['username']);
- if (empty($loginData)) {
- $_SESSION['profileEditNotification'] .= "Ungültiger Account Anscheinend versuchst du die E-Mail-Adresse eines nicht existierenden Accounts zu ändern. Sollte es sich um einen Fehler handeln, kontaktiere bitte das Website-Team!
";
- } else {
- $loginData = $loginData[0];
- $encryptedPassword = $this->LoginModel->getPasswordHash($_POST['email-password'], $loginData['original_name']);
- if ($loginData['password'] == $encryptedPassword) {
- $isRegistered = $this->LoginModel->isRegistered($_POST['email']);
- if ($isRegistered == "") {
- $trashMail = $this->LoginModel->isTrashMail($_POST['email']);
- if ($trashMail == '') {
- $this->LoginModel->changeMailAddress($_POST['email'], $loginData['username']);
- $_SESSION['profileEditNotification'] .= "Deine E-Mail-Adresse wurde geändert! Nun musst du nur noch in deinem Postfach vorbeischauen und die neue Adresse aktivieren.
";
- } else {
- $_SESSION['profileEditNotification'] .= $trashMail;
- }
- } else {
- $_SESSION['profileEditNotification'] .= $isRegistered;
- }
- } else {
- $_SESSION['profileEditNotification'] .= "Ungültiges Passwort! Es scheint als wäre das eingegebene Passwort nicht mit dem richtigen übereinstimmend.
";
- }
- }
- } else {
- $_SESSION['profileEditNotification'] .= "Bitte gib dein Passwort ein! Das Ändern der E-Mail-Adresse ist ein tiefgreifender Eingriff in den Account. Daher benötigen wir zur Sicherheit nochmal dein Passwort.
";
- }
- }
- // Notifications
- if (isset($_POST['email-notifications'])) {
- $newData['receiveEmails'] = filter_var($_POST['email-notifications'], FILTER_VALIDATE_BOOLEAN);
- }
- // Newsletter
- if (isset($_POST['newsletter'])) {
- $newData['receiveNewsletter'] = filter_var($_POST['newsletter'], FILTER_VALIDATE_BOOLEAN);
- }
- // Password
- if (isset($_POST['passwordNew'])) {
- if (isset($_POST['passwordOld'])) {
- $loginData = $this->LoginModel->getLoginData($_SESSION['user']['username']);
- if (!empty($loginData)) {
- $loginData = $loginData[0];
- $encryptedPassword = $this->LoginModel->getPasswordHash($_POST['passwordOld'], $loginData['original_name']);
- if ($encryptedPassword == $loginData['password']) {
- if ($this->LoginModel->checkPassword($_POST['passwordNew'])) {
- if (isset($_POST['passwordNewRepeat']) && $_POST['passwordNew'] == $_POST['passwordNewRepeat']) {
- $this->LoginModel->changePassword($_POST['passwordNew'], $loginData['original_name']);
- $_SESSION['profileEditNotification'] .= "Dein Passwort wurde geändert! Du kannst dich nun damit einloggen
";
- } else {
- $_SESSION['profileEditNotification'] .= "Wiederholtes Passwort falsch! Das Passwort, das du wiederholt hast, stimmt nicht mit dem eigentlichen überein.
";
- }
- } else {
- $_SESSION['profileEditNotification'] .= "Zu unsicheres Passwort! Dein Passwort sollte mindest 8 Zeichen lang sein und jeweils einen Groß-, einen Kleinbuchstaben, eine Zahl und ein Sonderzeichen enthalten.
";
- }
- } else {
- $_SESSION['profileEditNotification'] .= "Altes Passwort falsch! Dein altes eingegebenes Passwort ist falsch!
";
- }
- } else {
- $_SESSION['profileEditNotification'] .= "Ungültiger Account Anscheinend versuchst du die E-Mail-Adresse eines nicht existierenden Accounts zu ändern. Sollte es sich um einen Fehler handeln, kontaktiere bitte das Website-Team!
";
- }
- } else {
- $_SESSION['profileEditNotification'] .= "Altes Passwort fehlend! Bitte gib dein altes Passwort ebenfalls ein!
";
- }
- }
- if (isset($_POST['showAds'])) {
- if (isset($_SESSION['user']) && $_SESSION['user']['rank'] >= 2) {
- $newData['showAds'] = filter_var($_POST['email-notifications'], FILTER_VALIDATE_BOOLEAN);
- } else {
- $_SESSION['profileEditNotification'] .= "Du bist dazu nicht berechtigt! Um diese Einstellung zu verändern, musst du mindestens ein Premium-Nutzer oder höher sein!
";
- }
- }
- if (!empty($newData)) {
- // Add entry to history
- $this->UserModel->insertIntoHistory($user_data);
- // Update profile
- $this->UserModel->updateProfile($newData, $user_data['ID']);
-// redirect(base_url(uri_string()));
- }
-
- $user_stats = $this->UserModel->getUserStats($user_data['ID']);
- $title = $user_data['displayname'] . ' - Profil bearbeiten';
- }
-
- $this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['lib/selectize.css', 'lib/selectize.bootstrap3.css', 'profile_page.css']]);
- $editMessage = isset($_SESSION['profileEditNotification']) ? $_SESSION['profileEditNotification'] : "";
- $_SESSION['profileEditNotification'] = "";
- if (isset($message)) {
- $this->load->view('network/message', $message);
- }
- if ($user_exists) {
- $this->load->view('network/user/profile_edit', ['message' => $editMessage, 'data' => $user_data, 'stats' => $user_stats]);
- }
- $this->load->view('footer', ['additionalScripts' => ['lib/selectize.js', 'profile_page.js', 'profile_edit.js']]);
+ if (!isset($_SESSION['user']['username'])) {
+ $response = ['type' => 'error', 'code' => 0];
+ echo json_encode($response);
+ exit;
}
- public function single_post($username = null, $uuid = null, $origin = null)
- {
- $origin = isset($_GET['o']) ? $_GET['o'] : null;
- if ($origin == null) {
- $origin = base_url('user/' . $username);
- } else {
- $origin = base64_decode(urldecode($origin));
- }
+ $follower = $_SESSION['user']['ID'];
- $this->load->view('header', ['active' => 'profile', 'title' => 'Test']);
- $this->load->view('network/posts/user_post_page', ['origin' => $origin, 'username' => $username, 'uuid' => $uuid]);
- $this->load->view('footer', ['additionalScripts' => ['single-post-page.js']]);
+ if ($follower == $followedUser) {
+ $response = ['type' => 'error', 'code' => 1];
+ echo json_encode($response);
+ exit;
}
- public function single_post_data($username = null, $uuid = null)
- {
- $message = "";
- $post = [];
- $replies = [];
- if ($username == null) {
- $message .= 'Es wurde kein Nutzer angegeben! Es können keine Posts von einem undefinierten Nutzer gefunden werden.
';
- goto display;
- }
- if ($uuid == null) {
- $message .= 'Es wurde keine Post-ID angegeben! Es können keine undefinierten Posts gefunden werden.
';
- goto display;
- }
-
- $user = $this->UserModel->getUser($username);
- if (empty($user)) {
- $message .= 'Es wurde kein Nutzer mit dem angegebenen Namen gefunden! Vielleicht kannst du ja diese Lücke füllen?
';
- goto display;
- }
- $user = $user[0];
-
- $post = $this->PostsModel->getPostDetails($user['ID'], $uuid);
- if (empty($post)) {
- $message .= 'Es wurde kein Post mit der angegebenen ID gefunden! Vielleicht kannst du ja diesen neuen Content erschaffen?
';
- goto display;
- }
- $post = $post[0];
-
- $replies = $this->PostsModel->getPostReplies($post['ID']);
-
- display:
- $this->load->view('network/posts/user_post_content', ['message' => $message, 'post' => $post, 'replies' => $replies]);
-
+ if ($this->UserModel->isFollowing($follower, $followedUser)) {
+ $this->UserModel->unfollow($follower, $followedUser);
+ $response = ['type' => 'success', 'code' => 10];
+ echo json_encode($response);
+ exit;
}
+
+ $this->UserModel->follow($follower, $followedUser);
+ $response = ['type' => 'success', 'code' => 11];
+ echo json_encode($response);
+ exit;
}
+
+ public function edit($user = "")
+ {
+ if ($user == "") {
+ redirect(base_url('user'));
+ }
+
+ $user_data = $this->UserModel->getUser($user);
+ $user_exists = !empty($user_data);
+ if ($user_exists) {
+ $user_data = $user_data[0];
+ // Update Settings
+ $newData = [];
+ // TODO: Error messages
+ // Username
+ if (isset($_POST['username'])) {
+ if (!preg_match('/[^A-Za-z0-9._]/', $_POST['username'])) {
+ if ($this->LoginModel->isAvailable($_POST['username'])) {
+ if (strlen($_POST['username']) >= 4) {
+ $newData['username'] = strtolower($_POST['username']);
+ $newData['displayname'] = $_POST['username'];
+ } else {
+ $_SESSION['profileEditNotification'] .= "Zu kurzer Nutzername! Dein Name muss 4 Zeichen oder mehr enthalten.
";
+ }
+ } else {
+ $_SESSION['profileEditNotification'] .= "Nutzername bereits vergeben! Ein anderer Nutzer hat anscheinend diesen Namen bereits gewählt.
";
+ }
+ } else {
+ $_SESSION['profileEditNotification'] .= "Ungültiger Nutzername! Dein Name darf nur Groß- (A-Z) und Kleinbuchstaben (a-z), Zahlen (0-9) und Punkte (.) sowie Unterstriche (_).
";
+ }
+ }
+ // Gender
+ if (isset($_POST['gender'])) {
+ if ($_POST['gender'] == "male" || $_POST['gender'] == "female" || $_POST['gender'] == 'other') {
+ $newData['gender'] = $_POST['gender'];
+ }
+ }
+ // Birth date
+ if (isset($_POST['birthdate-day']) && isset($_POST['birthdate-month'])) {
+ $day = intval($_POST['birthdate-day']);
+ $month = intval($_POST['birthdate-month']);
+ if ($month > 0 && $month <= 12) {
+ $monthDayCount = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
+ if ($day <= $monthDayCount[$month - 1]) {
+ $newData['birthdate'] = $day . '.' . $month . '.';
+ }
+ }
+ }
+ if (isset($_POST['birthdate-year'])) {
+
+ }
+ // Language
+ if (isset($_POST['language'])) {
+ $newData['language'] = $_POST['language'];
+ }
+ // Country
+ if (isset($_POST['country'])) {
+ $newData['country'] = $_POST['country'];
+ }
+ // Biography/About
+ if (isset($_POST['biography'])) {
+ $newData['about'] = $_POST['biography'];
+ }
+ // Avatar
+ if (isset($_FILES['avatar'])) {
+ $image = $this->FileModel->uploadCroppedImage('avatar', 4096, $_FILES['avatar']['name'], 500, 500);
+ if ($image != null)
+ $newData['profile_picture'] = $image;
+ unset($_FILES['avatar']);
+ }
+ // Header
+ if (isset($_FILES['header'])) {
+ $image = $this->FileModel->uploadImage('header', 4096, $_FILES['header']['name'], 1920);
+ if ($image != null)
+ $newData['header_image'] = $image;
+ unset($_FILES['header']);
+ }
+ // Social Networks
+ if (isset($_POST['social-networks'])) {
+
+ }
+ // Profile color
+ if (isset($_POST['color'])) {
+
+ }
+ // E-Mail-Address
+ if (isset($_POST['email'])) {
+ if (isset($_POST['email-password']) && !empty($_POST['email-password'])) {
+ $loginData = $this->LoginModel->getLoginData($_SESSION['user']['username']);
+ if (empty($loginData)) {
+ $_SESSION['profileEditNotification'] .= "Ungültiger Account Anscheinend versuchst du die E-Mail-Adresse eines nicht existierenden Accounts zu ändern. Sollte es sich um einen Fehler handeln, kontaktiere bitte das Website-Team!
";
+ } else {
+ $loginData = $loginData[0];
+ $encryptedPassword = $this->LoginModel->getPasswordHash($_POST['email-password'], $loginData['original_name']);
+ if ($loginData['password'] == $encryptedPassword) {
+ $isRegistered = $this->LoginModel->isRegistered($_POST['email']);
+ if ($isRegistered == "") {
+ $trashMail = $this->LoginModel->isTrashMail($_POST['email']);
+ if ($trashMail == '') {
+ $this->LoginModel->changeMailAddress($_POST['email'], $loginData['username']);
+ $_SESSION['profileEditNotification'] .= "Deine E-Mail-Adresse wurde geändert! Nun musst du nur noch in deinem Postfach vorbeischauen und die neue Adresse aktivieren.
";
+ } else {
+ $_SESSION['profileEditNotification'] .= $trashMail;
+ }
+ } else {
+ $_SESSION['profileEditNotification'] .= $isRegistered;
+ }
+ } else {
+ $_SESSION['profileEditNotification'] .= "Ungültiges Passwort! Es scheint als wäre das eingegebene Passwort nicht mit dem richtigen übereinstimmend.
";
+ }
+ }
+ } else {
+ $_SESSION['profileEditNotification'] .= "Bitte gib dein Passwort ein! Das Ändern der E-Mail-Adresse ist ein tiefgreifender Eingriff in den Account. Daher benötigen wir zur Sicherheit nochmal dein Passwort.
";
+ }
+ }
+ // Notifications
+ if (isset($_POST['email-notifications'])) {
+ $newData['receiveEmails'] = filter_var($_POST['email-notifications'], FILTER_VALIDATE_BOOLEAN);
+ }
+ // Newsletter
+ if (isset($_POST['newsletter'])) {
+ $newData['receiveNewsletter'] = filter_var($_POST['newsletter'], FILTER_VALIDATE_BOOLEAN);
+ }
+ // Password
+ if (isset($_POST['passwordNew'])) {
+ if (isset($_POST['passwordOld'])) {
+ $loginData = $this->LoginModel->getLoginData($_SESSION['user']['username']);
+ if (!empty($loginData)) {
+ $loginData = $loginData[0];
+ $encryptedPassword = $this->LoginModel->getPasswordHash($_POST['passwordOld'], $loginData['original_name']);
+ if ($encryptedPassword == $loginData['password']) {
+ if ($this->LoginModel->checkPassword($_POST['passwordNew'])) {
+ if (isset($_POST['passwordNewRepeat']) && $_POST['passwordNew'] == $_POST['passwordNewRepeat']) {
+ $this->LoginModel->changePassword($_POST['passwordNew'], $loginData['original_name']);
+ $_SESSION['profileEditNotification'] .= "Dein Passwort wurde geändert! Du kannst dich nun damit einloggen
";
+ } else {
+ $_SESSION['profileEditNotification'] .= "Wiederholtes Passwort falsch! Das Passwort, das du wiederholt hast, stimmt nicht mit dem eigentlichen überein.
";
+ }
+ } else {
+ $_SESSION['profileEditNotification'] .= "Zu unsicheres Passwort! Dein Passwort sollte mindest 8 Zeichen lang sein und jeweils einen Groß-, einen Kleinbuchstaben, eine Zahl und ein Sonderzeichen enthalten.
";
+ }
+ } else {
+ $_SESSION['profileEditNotification'] .= "Altes Passwort falsch! Dein altes eingegebenes Passwort ist falsch!
";
+ }
+ } else {
+ $_SESSION['profileEditNotification'] .= "Ungültiger Account Anscheinend versuchst du die E-Mail-Adresse eines nicht existierenden Accounts zu ändern. Sollte es sich um einen Fehler handeln, kontaktiere bitte das Website-Team!
";
+ }
+ } else {
+ $_SESSION['profileEditNotification'] .= "Altes Passwort fehlend! Bitte gib dein altes Passwort ebenfalls ein!
";
+ }
+ }
+ if (isset($_POST['showAds'])) {
+ if (isset($_SESSION['user']) && $_SESSION['user']['rank'] >= 2) {
+ $newData['showAds'] = filter_var($_POST['email-notifications'], FILTER_VALIDATE_BOOLEAN);
+ } else {
+ $_SESSION['profileEditNotification'] .= "Du bist dazu nicht berechtigt! Um diese Einstellung zu verändern, musst du mindestens ein Premium-Nutzer oder höher sein!
";
+ }
+ }
+ if (!empty($newData)) {
+ // Add entry to history
+ unset($user_data['rankName']);
+ unset($_SESSION['user']);
+ $this->UserModel->insertIntoHistory($user_data);
+ // Update profile
+ $this->UserModel->updateProfile($newData, $user_data['ID']);
+ $this->db->cache_delete('user', $user_data['username']);
+
+ $this->LoginModel->reloadLoginSession($user_data);
+
+ redirect(base_url(uri_string()));
+ }
+
+ $user_stats = $this->UserModel->getUserStats($user_data['ID']);
+ $title = $user_data['displayname'] . ' - Profil bearbeiten';
+ }
+
+ $this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['lib/selectize.css', 'lib/selectize.bootstrap3.css', 'profile_page.css']]);
+ $editMessage = isset($_SESSION['profileEditNotification']) ? $_SESSION['profileEditNotification'] : "";
+ $_SESSION['profileEditNotification'] = "";
+ if (isset($message)) {
+ $this->load->view('network/message', $message);
+ }
+ if ($user_exists) {
+ $this->load->view('network/user/profile_edit', ['message' => $editMessage, 'data' => $user_data, 'stats' => $user_stats]);
+ }
+ $this->load->view('footer', ['additionalScripts' => ['lib/selectize.js', 'profile_page.js', 'profile_edit.js']]);
+ }
+
+ public function single_post($username = null, $uuid = null, $origin = null)
+ {
+ $origin = isset($_GET['o']) ? $_GET['o'] : null;
+ if ($origin == null) {
+ $origin = base_url('user/' . $username);
+ } else {
+ $origin = base64_decode(urldecode($origin));
+ }
+
+ $this->load->view('header', ['active' => 'profile', 'title' => 'Test']);
+ $this->load->view('network/posts/user_post_page', ['origin' => $origin, 'username' => $username, 'uuid' => $uuid]);
+ $this->load->view('footer', ['additionalScripts' => ['single-post-page.js']]);
+ }
+
+ public function single_post_data($username = null, $uuid = null)
+ {
+ $message = "";
+ $post = [];
+ $replies = [];
+ if ($username == null) {
+ $message .= 'Es wurde kein Nutzer angegeben! Es können keine Posts von einem undefinierten Nutzer gefunden werden.
';
+ goto display;
+ }
+ if ($uuid == null) {
+ $message .= 'Es wurde keine Post-ID angegeben! Es können keine undefinierten Posts gefunden werden.
';
+ goto display;
+ }
+
+ $user = $this->UserModel->getUser($username);
+ if (empty($user)) {
+ $message .= 'Es wurde kein Nutzer mit dem angegebenen Namen gefunden! Vielleicht kannst du ja diese Lücke füllen?
';
+ goto display;
+ }
+ $user = $user[0];
+
+ $post = $this->PostsModel->getPostDetails($user['ID'], $uuid);
+ if (empty($post)) {
+ $message .= 'Es wurde kein Post mit der angegebenen ID gefunden! Vielleicht kannst du ja diesen neuen Content erschaffen?
';
+ goto display;
+ }
+ $post = $post[0];
+
+ $replies = $this->PostsModel->getPostReplies($post['ID']);
+
+ display:
+ $this->load->view('network/posts/user_post_content', ['message' => $message, 'post' => $post, 'replies' => $replies]);
+
+ }
+}
diff --git a/application/models/FileModel.php b/application/models/FileModel.php
index 2c8022a..7fdfde8 100644
--- a/application/models/FileModel.php
+++ b/application/models/FileModel.php
@@ -11,9 +11,13 @@ class FileModel extends CI_Model
parent::__construct();
}
- public function uploadFile($original_name, $tmpname, $size, $type)
+ private function getPath($fileName, $userContent) {
+ return 'files/' . ($userContent ? 'userContent/' : '') . $fileName;
+ }
+
+ public function uploadFile($original_name, $tmpname, $size, $type, $userContent = true)
{
- $target_dir = "files" . DIRECTORY_SEPARATOR;
+ $target_dir = "files" . DIRECTORY_SEPARATOR . ($userContent ? 'userContent' . DIRECTORY_SEPARATOR : '');
$filetype = pathinfo(basename($original_name), PATHINFO_EXTENSION);
$target_file = $target_dir . $this->generateName() . '.' . $filetype;
$name = explode('.' . $filetype, explode(DIRECTORY_SEPARATOR, $target_file)[1])[0];
@@ -22,13 +26,13 @@ class FileModel extends CI_Model
die('File couldn\'t be uploaded!');
}
- $this->db->query('INSERT INTO files (name, original_name, type, size, path) VALUES (?, ?, ?, ?, ?)', [$name, $original_name, $type, $size, $target_file]);
+ $this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$name, $original_name, $type, $size, $target_file, $userContent]);
- return "/file/open/" . $name;
+ return "/f/" . $name;
}
- public function uploadImage($name, $max_size, $originalname, $max_width) {
- $config['upload_path'] = './files/';
+ public function uploadImage($name, $max_size, $originalname, $max_width, $userContent = true) {
+ $config['upload_path'] = '.' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . ($userContent ? 'userContent' . DIRECTORY_SEPARATOR : '');
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = $max_size;
$config['file_name'] = $this->generateName() . "." . pathinfo(basename($originalname), PATHINFO_EXTENSION);
@@ -50,13 +54,65 @@ class FileModel extends CI_Model
$this->image_lib->resize();
- $this->db->query('INSERT INTO files (name, original_name, type, size, path) VALUES (?, ?, ?, ?, ?)', [$data['raw_name'], $originalname, $data['file_type'], $data['file_size'] * 1024, 'files/' . $data['file_name']]);
+ $this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$data['raw_name'], $originalname, $data['file_type'], $data['file_size'] * 1024, $this->getPath($data['file_name'], $userContent), $userContent]);
return '/f/' . $data['raw_name'];
}
}
- public function uploadFileByContent($content, $original_name, $fullType, $fileSize) {
- $target_dir = "files" . DIRECTORY_SEPARATOR;
+ public function uploadCroppedImage($name, $max_size, $originalname, $width, $height, $userContent = true) {
+ $config['upload_path'] = '.' . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . ($userContent ? 'userContent' . DIRECTORY_SEPARATOR : '');
+ $config['allowed_types'] = 'gif|jpg|png';
+ $config['max_size'] = $max_size;
+ $config['file_name'] = $this->generateName() . "." . pathinfo(basename($originalname), PATHINFO_EXTENSION);
+
+ $this->load->library('upload', $config);
+
+ if ( ! $this->upload->do_upload($name)) {
+ return null;
+ } else {
+ $data = $this->upload->data();
+
+ // Resize
+ $config['image_library'] = 'gd2';
+ $config['source_image'] = $data['full_path'];
+ $config['maintain_ratio'] = TRUE;
+
+ $size = getimagesize($data['full_path']);
+
+ if($size[0] > $size[1]) {
+ $config['height'] = $height;
+ } else {
+ $config['width'] = $width;
+ }
+
+ $this->load->library('image_lib');
+ $this->image_lib->initialize($config);
+ $this->image_lib->resize();
+
+ $config['source_image'] = $config['upload_path'] . $config['file_name'];
+ $config['maintain_ratio'] = FALSE;
+ $config['height'] = $height;
+ $config['width'] = $width;
+
+ $size = getimagesize($config['source_image']);
+
+ if($size[0] > $size[1]) {
+ $config['x_axis'] = ($size[0] - $width) / 2;
+ } else {
+ $config['y_axis'] = ($size[1] - $height) / 2;
+ }
+
+ $this->image_lib->clear();
+ $this->image_lib->initialize($config);
+ $this->image_lib->crop();
+
+ $this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$data['raw_name'], $originalname, $data['file_type'], $data['file_size'] * 1024, $this->getPath($data['file_name'], $userContent), $userContent]);
+ return '/f/' . $data['raw_name'];
+ }
+ }
+
+ public function uploadFileByContent($content, $original_name, $fullType, $fileSize, $userContent = true) {
+ $target_dir = "files" . DIRECTORY_SEPARATOR . ($userContent ? 'userContent' . DIRECTORY_SEPARATOR : '');
$filetype = pathinfo(basename($original_name), PATHINFO_EXTENSION);
$target_file = $target_dir . $this->generateName() . '.' . $filetype;
$name = explode('.' . $filetype, explode(DIRECTORY_SEPARATOR, $target_file)[1])[0];
@@ -65,7 +121,7 @@ class FileModel extends CI_Model
fwrite($fp, $content);
fclose($fp);
- $this->db->query('INSERT INTO files (name, original_name, type, size, path) VALUES (?, ?, ?, ?, ?)', [$name, $original_name, $fullType, $fileSize, $target_file]);
+ $this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$name, $original_name, $fullType, $fileSize, $target_file, $userContent]);
return '/f/' . $name;
}
diff --git a/application/models/LoginModel.php b/application/models/LoginModel.php
index 3dcfb25..9fa9b26 100644
--- a/application/models/LoginModel.php
+++ b/application/models/LoginModel.php
@@ -69,6 +69,20 @@ class LoginModel extends CI_Model
}
}
+ public function reloadLoginSession($logindata) {
+ $_SESSION['user']['displayname'] = $logindata['displayname'];
+ $_SESSION['user']['username'] = $logindata['username'];
+ $_SESSION['user']['rank'] = $logindata['rank'];
+ $_SESSION['user']['ID'] = $logindata['ID'];
+ $_SESSION['user']['ads'] = $logindata['showAds'];
+ $profilePic = $logindata['profile_picture'];
+ if (empty($profilePic)) {
+ $_SESSION['user']['profilePic'] = '/assets/images/steam.jpg';
+ } else {
+ $_SESSION['user']['profilePic'] = $profilePic;
+ }
+ }
+
public function getUserHash($username, $password, $email, $id)
{
$hash = hash('sha256', $id . '//' . $username . '//' . substr($password, 0, 5) . '//' . substr($email, 0, 5));
diff --git a/application/views/network/user/profile_edit.php b/application/views/network/user/profile_edit.php
index 6874f5c..76c0049 100644
--- a/application/views/network/user/profile_edit.php
+++ b/application/views/network/user/profile_edit.php
@@ -10,1177 +10,1180 @@ $this->load->view('network/user/profile_page_header');
= $message ?>
Profil bearbeiten
-