<link rel="stylesheet" type="text/css" href="main.css" /> <title>Report</title> </head> <body id="reportBody"> <div id="mainDiv"> <div id="reportDiv" class="block"> <?php include 'functions.php'; $theString = '<wrapper>' . file_get_contents("reviews.xml") . '</wrapper>'; $theXML = simplexml_load_string($theString); $id = $_GET["id"]; $item = null; foreach ($theXML as $currentItem) { if ($id == $currentItem->id) { $item = $currentItem; break; } } if ($item != null) { $theName = replaceString(interpretFromXML($item->name)); $theDate = $item->date; $theComment = replaceString(interpretFromXML($item->comment)); echo "\n\t\t\t\t\t\t\t<p><span class='userName'>{$theName}</span> said <span class='commentDate'>({$theDate})</span>:</p>\n\t\t\t\t\t\t\t<br/>\n\t\t\t\t\t\t\t<div class='comment'>\n\t\t\t\t\t\t\t\t<p class='commentParagraph'>{$theComment}</p>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<form action='post-report.php' method='post'>\n\t\t\t\t\t\t\t\t<br/>\n\t\t\t\t\t\t\t\tWhat's wrong with this post?\n\t\t\t\t\t\t\t\t<input type='hidden' name='id' value='{$id}' />\n\t\t\t\t\t\t\t\t<textarea id='comment' name='reason' ></textarea>\n\t\t\t\t\t\t\t\t<br/>\n\t\t\t\t\t\t\t\t<br/>\n\t\t\t\t\t\t\t\t<input type='submit' value='Report this post' />\n\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t"; } else { header("Location: review.php"); } ?> </div> </body> </html>
$numOfComments = $_POST["numberOfComments"]; } $commentArray = array(); $i = 0; foreach ($theXML as $item) { $commentArray[$i++] = $item; } if (isset($_POST["commentPage"]) && is_numeric($_POST["commentPage"]) && $_POST["commentPage"]) { $page = min(intval((count($commentArray) - 1) / $numOfComments) + 1, $_POST["commentPage"]); } $commentArray = array_reverse($commentArray); for ($i = ($page - 1) * $numOfComments; $i <= min(count($commentArray) - 1, ($page - 1) * $numOfComments + $numOfComments - 1); $i++) { $theName = replaceString(interpretFromXML($commentArray[$i]->name)); $id = $commentArray[$i]->id; $theDate = $commentArray[$i]->date; $theComment = replaceString(interpretFromXML($commentArray[$i]->comment)); $starSize = $commentArray[$i]->rating * 100 / 5; echo "\n\t\t\t\t\t\t\t\t<p><span class='userName'>{$theName}</span> said <span class='commentDate'>({$theDate})</span>:</p>\n\t\t\t\t\t\t\t\t<p class='report'><a href='report.php?id={$id}'>Report</a></p>\n\t\t\t\t\t\t\t\t<div style='\n\t\t\t\t\t\t\t\t\twidth: {$starSize}" . "px;\n\t\t\t\t\t\t\t\t\theight: 19.05px;\n\t\t\t\t\t\t\t\t\tbackground-image: url(\"stars.png\");\n\t\t\t\t\t\t\t\t\tbackground-size: cover;\n\t\t\t\t\t\t\t\t'></div>\n\t\t\t\t\t\t\t\t<br/>\n\t\t\t\t\t\t\t\t<div class='comment'>\n\t\t\t\t\t\t\t\t\t<p class='commentParagraph'>{$theComment}</p>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t"; } echo "<br/>"; echo "<p class='centerText'>Page {$page}/" . intval((count($commentArray) - 1) / $numOfComments + 1) . "</p>"; if ($page > 1) { echo "\n\t\t\t\t\t\t\t\t<form class='centerText' method='post'>\n\t\t\t\t\t\t\t\t\t<input type='hidden' name='commentPage' value=" . ($page - 1) . " />\n\t\t\t\t\t\t\t\t\t<input type='hidden' name='numberOfComments' value=" . $numOfComments . " />\n\t\t\t\t\t\t\t\t\t<input type='submit' class='pageLink' value=' Previous page...'/>\n\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t"; } if (count($commentArray) - 1 > ($page - 1) * $numOfComments + $numOfComments) { echo "\n\t\t\t\t\t\t\t\t<form class='centerText' method='post'>\n\t\t\t\t\t\t\t\t\t<input type='hidden' name='commentPage' value=" . ($page + 1) . " />\n\t\t\t\t\t\t\t\t\t<input type='hidden' name='numberOfComments' value=" . $numOfComments . " />\n\t\t\t\t\t\t\t\t\t<input type='submit' class='pageLink' value=' Next page...'/>\n\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t"; } if (intval(count($commentArray) / $numOfComments) > 0) { echo "\n\t\t\t\t\t\t\t\t<form class='centerText' method='post'>\n\t\t\t\t\t\t\t\t\t<input type='submit' class='pageLink' value='Go to...'/>\n\t\t\t\t\t\t\t\t\t<input type='text' name='commentPage' value='{$page}' />\n\t\t\t\t\t\t\t\t\t<input type='hidden' name='numberOfComments' value=" . $numOfComments . " />\n\t\t\t\t\t\t\t\t</form>\n\t\t\t\t\t\t\t"; } } else {
if ($theReportedXML != null) { foreach ($theReportedXML as $report) { $reportID = $report->id; $itemID = $item->id; if (intval($reportID) == intval($itemID)) { $show = true; $reportedItem = $report; break; } } } if ($show) { $id = $item->id; $ip = $item->ip; $name = replaceString(interpretFromXML($item->name)); $rating = $item->rating; $date = $item->date; $comment = replaceString(interpretFromXML($item->comment)); $starSize = $rating * 100 / 5; if ($reportedItem != null) { echo "<br/><br/><p class='reportedItem'>The following item was reported for the reason: \n\t\t\t\t\t\t\t\t<a href='dismiss-report.php?id={$id}" . ($reported ? "&showReports=true" : "") . "' class='action'>DISMISS</a><br/>\n\t\t\t\t\t\t\t\t<div class='reportedText'>" . replaceString(interpretFromXML($reportedItem->reason)) . '</div></p>'; } echo "\n\t\t\t\t\t\t\t<a class='action' href='delete-post.php?id={$id}" . ($reported ? "&showReports=true" : "") . "'>DELETE</a><br/>\n\t\t\t\t\t\t\t<span>Comment id: <span class='commentID'>{$id}</span><br/>\n\t\t\t\t\t\t\tIP address: <span class='properties'>{$ip}</span><br/>\n\t\t\t\t\t\t\tName: <span class='properties'>{$name}</span><br/>\n\t\t\t\t\t\t\tRating: {$rating} \n\t\t\t\t\t\t\t<div style='\n\t\t\t\t\t\t\t\twidth: {$starSize}" . "px;\n\t\t\t\t\t\t\t\theight: 19.05px;\n\t\t\t\t\t\t\t\tbackground-image: url(\"stars.png\");\n\t\t\t\t\t\t\t\tbackground-size: cover;\n\t\t\t\t\t\t\t\tdisplay: inline-block;\n\t\t\t\t\t\t\t'></div><br/>\n\t\t\t\t\t\t\tTime: <span class='properties'>{$date}</span><br/>\n\t\t\t\t\t\t\tComment:<br/>\n\t\t\t\t\t\t\t\t<div class='comment'>\"{$comment}\"</div>\n\t\t\t\t\t\t\t<br/><br/>\n\t\t\t\t\t\t"; } } } else { echo "<h1>There is no comments yet</h1>"; } ?> </body> </html>