';
+
+$get_posts = $dbc->prepare('SELECT posts.* FROM posts, users WHERE posts.post_by_id = users.user_id AND users.user_level > 1 AND posts.deleted = 0 ORDER BY posts.date_time DESC LIMIT 25');
+$get_posts->execute();
+$posts_result = $get_posts->get_result();
+
+while($posts = $posts_result->fetch_array()){
+ $get_title = $dbc->prepare('SELECT title_id, title_name, title_icon FROM titles WHERE title_id = ? LIMIT 1');
+ $get_title->bind_param('i', $posts['post_title']);
+ $get_title->execute();
+ $title_result = $get_title->get_result();
+ $title = $title_result->fetch_assoc();
+
+ $get_user = $dbc->prepare('SELECT users.*, profiles.* FROM users INNER JOIN profiles ON profiles.user_id = ? WHERE users.user_id = ?');
+ $get_user->bind_param('ii', $posts['post_by_id'], $posts['post_by_id']);
+ $get_user->execute();
+ $user_result = $get_user->get_result();
+ $user = $user_result->fetch_assoc();
+
+ echo '
+
+
';
+
+ $check_followed = $dbc->prepare('SELECT * FROM follows WHERE follow_by = ? AND follow_to = ? LIMIT 1');
+ $check_followed->bind_param('ii', $_SESSION['user_id'], $user['user_id']);
+ $check_followed->execute();
+ $followed_result = $check_followed->get_result();
+
+ if (($followed_result->num_rows == 0) && ($_SESSION['user_id'] != $user['user_id']) && !empty($_SESSION['signed_in'])){
+ echo '
+ ';
+ }
+
+ echo '
'. htmlspecialchars($user['nickname'], ENT_QUOTES) .'
+
+
';
+
+ if (!empty($posts['post_image'])){
+ echo '
';
+ }
+
+
+ echo '
'. (mb_strlen($posts['text']) > 199 ? htmlspecialchars(mb_substr($posts['text'],0,200), ENT_QUOTES) .'...' : htmlspecialchars($posts['text'], ENT_QUOTES)) . '
';
+
+
+ echo '
'. humanTiming(strtotime($posts['date_time'])) .'
';
+
+ $yeah_count = $dbc->prepare('SELECT COUNT(yeah_by) FROM yeahs WHERE type = "post" AND yeahs.yeah_post = ?');
+ $yeah_count->bind_param('i', $posts['id']);
+ $yeah_count->execute();
+ $result_count = $yeah_count->get_result();
+ $yeah_amount = $result_count->fetch_assoc();
+
+ echo '
' . $yeah_amount['COUNT(yeah_by)'] . '
';
+
+ $reply_count = $dbc->prepare('SELECT COUNT(reply_id) FROM replies WHERE reply_post = ? AND deleted = 0');
+ $reply_count->bind_param('i', $posts['id']);
+ $reply_count->execute();
+ $result_count = $reply_count->get_result();
+ $reply_amount = $result_count->fetch_assoc();
+
+ echo '
' . $reply_amount['COUNT(reply_id)'] . '
+
';
+}
\ No newline at end of file
diff --git a/yeah.php b/yeah.php
new file mode 100644
index 0000000..f8860fb
--- /dev/null
+++ b/yeah.php
@@ -0,0 +1,69 @@
+prepare('INSERT INTO yeahs (yeah_post, type, date_time, yeah_by) VALUES (?, ?, NOW(), ?)');
+ $yeah->bind_param('isi', $_POST['postId'], $_POST['yeahType'], $_SESSION['user_id']);
+ $yeah->execute();
+
+ $get_user = $dbc->prepare('SELECT * FROM posts INNER JOIN profiles ON user_id = post_by_id WHERE id = ?');
+ $get_user->bind_param('i', $_POST['postId']);
+ $get_user->execute();
+ $user_result = $get_user->get_result();
+ $user = $user_result->fetch_assoc();
+
+ if ($user['yeah_notifs'] == 1) {
+ notify($user['post_by_id'], 0, $_POST['postId']);
+ }
+
+ $check_nah = $dbc->prepare('SELECT * FROM nahs WHERE nah_post = ? AND type = 0 AND nah_by = ?');
+ $check_nah->bind_param('ii', $_POST['postId'], $_SESSION['user_id']);
+ $check_nah->execute();
+ $nah_result = $check_nah->get_result();
+
+ if (!$nah_result->num_rows == 0) {
+ $delete_nah = $dbc->prepare('DELETE FROM nahs WHERE nah_post = ? AND type = 0 AND nah_by = ?');
+ $delete_nah->bind_param('ii', $_POST['postId'], $_SESSION['user_id']);
+ $delete_nah->execute();
+ }
+
+ echo 'success';
+ }
+ } else {
+ if (!checkReplyCreator($_POST['postId'], $_SESSION['user_id'])) {
+ $yeah = $dbc->prepare('INSERT INTO yeahs (yeah_post, type, date_time, yeah_by) VALUES (?, ?, NOW(), ?)');
+ $yeah->bind_param('isi', $_POST['postId'], $_POST['yeahType'], $_SESSION['user_id']);
+ $yeah->execute();
+
+ $get_user = $dbc->prepare('SELECT * FROM replies INNER JOIN profiles ON user_id = reply_by_id WHERE reply_id = ?');
+ $get_user->bind_param('i', $_POST['postId']);
+ $get_user->execute();
+ $user_result = $get_user->get_result();
+ $user = $user_result->fetch_assoc();
+
+ if($user['yeah_notifs']==1){
+ notify($user['reply_by_id'], 1, $_POST['postId']);
+ }
+
+ $check_nah = $dbc->prepare('SELECT * FROM nahs WHERE nah_post = ? AND type = 1 AND nah_by = ?');
+ $check_nah->bind_param('ii', $_POST['postId'], $_SESSION['user_id']);
+ $check_nah->execute();
+ $nah_result = $check_nah->get_result();
+
+ if (!$nah_result->num_rows == 0) {
+ $delete_nah = $dbc->prepare('DELETE FROM nahs WHERE nah_post = ? AND type = 1 AND nah_by = ?');
+ $delete_nah->bind_param('ii', $_POST['postId'], $_SESSION['user_id']);
+ $delete_nah->execute();
+ }
+
+ echo 'success';
+ }
+ }
+ }
+ }
+}
\ No newline at end of file