function mysql2AssocArray($mysqlPostRow) { global $db, $userPosition, $forumId, $usersForumId; $postId = $mysqlPostRow['id']; // Times $htmlDatetime = date('c', $mysqlPostRow['post_time']); $readableTime = date('D, d M Y H:i:s', $mysqlPostRow['post_time']); $niceTime = nicetime($mysqlPostRow['post_time']); // User and message $forumUser = html_entity_decode($mysqlPostRow['sender']); $forumUser = smilify($forumUser, $forumUser); $forumMessage = URL2link(smilify(nl2br(html_entity_decode($mysqlPostRow['message'])), $forumUser)); // ip address, delete, edit button $headerActions = $userPosition == 'Webmaster' ? decode_ip($mysqlPostRow['ipaddress']) . ' <a class="forum-post-delete" style="color:black;" title="Delete post" href="forum/delete/' . $postId . '"> <i class="fa fa-trash-o"></i> <span class="sr-only">Delete</span> </a>' : ''; if ($mysqlPostRow['users_forum_id'] == $usersForumId || $userPosition == 'Webmaster') { $headerActions .= ' <a class="forum-post-edit" style="color:black;" title="Edit post" href="forum/edit/' . $postId . '"> <i class="fa fa-pencil"></i> <span class="sr-only">Edit</span> </a>'; } // Likes $likeCount = mysqli_query($db, "SELECT count(1) c FROM forum_plusone WHERE message = {$postId} LIMIT 1"); $likeCount = mysqli_fetch_array($likeCount)['c']; if (mysqli_num_rows(mysqli_query($db, "SELECT 1 FROM forum_plusone WHERE message = {$postId} AND cookie = '{$usersForumId}' LIMIT 1"))) { $likedClass = 'liked'; $likeTitle = 'Approved'; } else { $likedClass = 'not-liked'; $likeTitle = 'Approve Post'; } return array('id' => $mysqlPostRow['id'], 'parentPostId' => $mysqlPostRow['parent_id'], 'htmlDatetime' => $htmlDatetime, 'readableTime' => $readableTime, 'niceTime' => $niceTime, 'forumUser' => $forumUser, 'forumMessage' => $forumMessage, 'headerActions' => $headerActions, 'likeCount' => $likeCount, 'likedClass' => $likedClass, 'likeTitle' => $likeTitle); }
$event = mysqli_real_escape_string($db, $_POST['eventname']); // intialize to be blank, not used $email = NULL; $confirmed = 1; $auth = ''; $insert_post = mysqli_query($db, "INSERT INTO photo_comments (photoid, event, sender, email, post_time, message, ipaddress, confirmed, auth) VALUES('{$photoid}', '{$event}', '{$sender}', '{$email}', '" . time() . "', '{$message}', '{$user_ip}', '{$confirmed}', '{$auth}')"); if (!$insert_post) { die(json_encode(array('error' => mysqli_error($db)))); } else { $special = $userPosition == 'Webmaster' ? $client_ip : ''; die(json_encode(array('newComment' => array('sender' => smilify(html_entity_decode($_POST['sender']), $_POST['sender']), 'message' => URL2link(smilify(nl2br(html_entity_decode($_POST['message'])), $_POST['sender'])), 'htmlDatetime' => date('c', time()), 'readableTime' => date('D, d M Y H:i:s', time()), 'niceTime' => nicetime(time()), 'special' => $special)))); } } else { if ($_POST['action'] == 'getComments') { $photoid = mysqli_real_escape_string($db, $_POST['photoid']); $event = mysqli_real_escape_string($db, $_POST['eventname']); $photo_comments = mysqli_query($db, "SELECT * FROM photo_comments WHERE photoid='{$photoid}' AND event='{$event}' "); if (mysqli_num_rows($photo_comments) == 0) { die(json_encode(array('empty' => 'no comments'))); } else { $comments = array(); while ($comment = mysqli_fetch_array($photo_comments, MYSQL_ASSOC)) { $datetime = date('G:i j/M/y', $comment['post_time']); $nicetime = nicetime($comment['post_time']); $special = $userPosition == 'Webmaster' ? decode_ip($comment['ipaddress']) : ''; $comments[] = array('sender' => smilify(html_entity_decode($comment['sender']), $comment['sender']), 'message' => URL2link(smilify(nl2br(html_entity_decode($comment['message'])), $comment['sender'])), 'htmlDatetime' => date('c', $comment['post_time']), 'readableTime' => date('D, d M Y H:i:s', $comment['post_time']), 'niceTime' => nicetime($comment['post_time']), 'special' => $special); } die(json_encode(array('comments' => $comments))); } } }
$specific_posts = mysqli_query($db, "SELECT * FROM forum_posts WHERE id='" . $_GET['id'] . "' AND forum='" . $forum . "' ORDER BY `post_time` DESC"); echo "<h3 class=\"col-xs-12\">Showing " . $_GET['title'] . " post</h3>"; } elseif (isset($_GET['person'])) { $specific_posts = mysqli_query($db, "SELECT * FROM forum_posts WHERE sender='" . $_GET['person'] . "' AND forum='" . $forum . "' ORDER BY `post_time` DESC"); echo "<h3 class=\"col-xs-12\">Showing posts submitted by " . $_GET['person'] . "</h3>"; } elseif (isset($_GET['day'])) { $specific_posts = mysqli_query($db, "SELECT * FROM forum_posts WHERE post_time>='" . $_GET['day'] . "' AND post_time <'" . ($_GET['day'] + 86400) . "' AND forum='" . $forum . "' ORDER BY `post_time` DESC"); echo "<h3 class=\"col-xs-12\">Showing all posts from " . date('j M Y', $_GET['day']) . "</h3>"; } while ($specific_post = mysqli_fetch_array($specific_posts, MYSQL_ASSOC)) { $htmlDatetime = date('c', $specific_post['post_time']); $readableTime = date('D, d M Y H:i:s', $specific_post['post_time']); $niceTime = nicetime($specific_post['post_time']); $forumUserEmoji = html_entity_decode($specific_post['sender']); $forumUser = smilify($forumUserEmoji, $forumUserEmoji); $forumMessage = URL2link(smilify(nl2br(html_entity_decode($specific_post['message'])), $forumUserEmoji)); ?> <div class="col-xs-12 forum-post"> <div class="post-header"> <!--top bar with name, time and other details. bottom border--> <strong class="post-header-name"><?php echo $forumUser; ?> </strong> <small class="post-header-time"> <time datetime="<?php echo $htmlDatetime; ?> " title="<?php echo $readableTime; ?> ">