//Return it return $log; } //Sorts an array based on a given key function syncedSort($s1, $s2) { //Sorts based on date. Shouldn't need to be modified. if (intval($s1["date"]) > intval($s2["date"])) { return -1; } else { return 1; } } //If a POST request was made from the feed if (isset($_POST["ref"]) && trim(strtolower($_POST["ref"])) == "feed") { //Connect to MySQL $con = mysqli_connect(host(), username(), password(), mainDb()); //Get the IDs of all validated users... $user_query = mysqli_query($con, "SELECT * FROM `usr`"); //This will store all the values $master_log = array(); //Loop through each user while ($row = mysqli_fetch_array($user_query)) { //and add their activity to the array $master_log = array_merge($master_log, getRecentActivity($row["id"])); } //Sort the array usort($master_log, "syncedSort"); //Print it echo json_encode($master_log); }
<?php include_once $_SERVER["DOC_ROOT"] . "/scripts/php/core.php"; ?> <div id="recent_activity" class="profile_tab_content"> <?php $log = getRecentActivity($_GET["id"]); if (count($log) === 0) { ?> <h5>This user has no recent activity to display</h5> <?php } else { ?> <?php for ($i = 0; $i < count($log); $i++) { $regdate = date("Y-m-d H:i:s", $log[$i]["date"]); $reldate = getRelativeDT(time(), $log[$i]["date"]); $fulldte = date("l, F jS, Y", $log[$i]["date"]); ?> <div class="post"> <div title="<?php echo $fulldte; ?> " class="date"><?php echo $reldate; ?> ago</div> <a href="<?php echo $log[$i]["link"]; ?> "><?php