function showComments($q) { //---get user information---// $sessionid = $_SESSION["sessionid"]; $random = $_SESSION["random"]; $query = "SELECT * FROM sessions WHERE sessionid = '{$sessionid}' AND random = '{$random}' "; $recordSet = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($recordSet); if ($row["userid"] > 0) { $myid = $row["userid"]; } else { $myid = 0; } //---build megaArray---// $megaArray = array(); array_push($megaArray, "comments"); $resultArray = explode(":|:|:|:", pageType($q)); $pageType = $resultArray[0]; $match = $resultArray[1]; $query = "SELECT * FROM comments WHERE locationType = '{$pageType}' AND locationid = '{$match}' "; $recordSet = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($recordSet)) { $arrayComment = array(); if ($myid > 0 and $row["commenterid"] === $myid) { $arrayComment[0] = "editable"; } elseif ($myid > 0 and $row["locationType"] === "profile" and $row["locationid"] === $myid) { $arrayComment[0] = "deletable"; } else { $arrayComment[0] = "readable"; } $arrayComment[1] = $row["commentid"]; $arrayComment[2] = match("users", "userid", "username", $row["commenterid"]); $arrayComment[3] = $row["createDate"]; $arrayComment[4] = unsquiggly($row["comment"]); array_push($megaArray, $arrayComment); } //---return megaArray---// for ($i = 1; $i < count($megaArray); $i++) { $stringifiedComment = implode(":|:|:|:", $megaArray[$i]); $megaArray[$i] = $stringifiedComment; } return implode(":|::|::|:", $megaArray); }
function showSettings() { //---get user information---// $email = ""; $username = ""; $sessionid = $_SESSION["sessionid"]; $random = $_SESSION["random"]; $query = "SELECT * FROM sessions WHERE sessionid = '{$sessionid}' AND random = '{$random}' "; $recordSet = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($recordSet); //---get settings information---// if ($row["userid"] > 0) { $userid = $row["userid"]; $query = "SELECT * FROM sessions WHERE userid = '{$userid}' "; $recordSet = mysql_query($query) or die(mysql_error()); $sessionCount = mysql_num_rows($recordSet); $query = "SELECT * FROM users WHERE userid = '{$userid}' "; $recordSet = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($recordSet); $email = $row["email"]; $username = $row["username"]; $emailNotifications = $row["emailNotifications"]; $about = $row["about"]; $picture = $row["picture"]; $notifications = $row["notifications"]; } //---replace ids with names---// $notifications = unsquiggly($notifications); //---delete old notifications---// $notificationsArray = array_reverse(explode(":||:", $notifications)); if (count($notificationsArray > 12)) { while (count($notificationsArray) > 12) { array_pop($notificationsArray); } $newNotifications = addslashes(implode(":||:", array_reverse($notificationsArray))); $query = "UPDATE users SET notifications = '{$newNotifications}' where userid = '{$userid}' "; mysql_query($query) or die(mysql_error()); } //---return information---// return $userid . ":|:|:|:" . $sessionCount . ":|:|:|:" . $email . ":|:|:|:" . $username . ":|:|:|:" . $emailNotifications . ":|:|:|:" . $about . ":|:|:|:" . $picture . ":|:|:|:" . $notifications; //7 }
function editComment($commentid) { //---get user information---// $sessionid = $_SESSION["sessionid"]; $random = $_SESSION["random"]; $query = "SELECT * FROM sessions WHERE sessionid = '{$sessionid}' AND random = '{$random}' "; $recordSet = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($recordSet); //---get comment text---// if ($row["userid"] > 0) { $myid = $row["userid"]; if (match("comments", "commentid", "commenterid", $commentid) === $myid) { $query = "SELECT * FROM comments WHERE commentid= '{$commentid}' "; $recordSet = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($recordSet); $commentText = unsquiggly($row["comment"]); return "success:|:|:|:" . $commentid . ":|:|:|:" . $commentText; } else { return "failure:|:|:|:strangerComment"; } } else { return "failure:|:|:|:signIn"; } }