<?php require 'config/initialize.php'; mustBeAuthenticated(); if (isset($_POST['post'])) { $message = sanitizeString($_POST['message'], $connection); $visible = sanitizeString($_POST['visible'], $connection); if ($message != "") { $authorID = getByUsername($_SESSION['user'], $connection)->fetch_array(MYSQLI_ASSOC)[id]; post($authorID, $message, $visible, $connection); header('Location: index.php'); } else { header('Location: index.php'); } } view('post/index');
<?php require 'config/initialize.php'; mustBeAuthenticated(); $user = getByUsername($_GET['username'], $connection); if ($user->num_rows) { $user = $user->fetch_array(MYSQLI_ASSOC); $posts = getUserPosts($user['id'], $connection); $publicPosts = getUserSpecificPosts($user['id'], 2, $connection); $pendingStatus = isPending($_SESSION['id'], $user['id'], $connection)->fetch_array(MYSQLI_ASSOC); view('main/detail', ['user' => $user, 'posts' => $posts, 'publicPosts' => $publicPosts, 'pendingStatus' => $pendingStatus]); } else { header('location:/'); }
<?php require 'config/initialize.php'; if (isset($_SESSION['user'])) { $userInfo = getByUsername($_SESSION['user'], $connection)->fetch_array(MYSQLI_ASSOC); $publicPosts = getPublicPostsWithAuthors($connection); $pendingFollowers = getPendingFollowers($_SESSION['id'], $connection); $followersFollowersArray = array(); foreach ($pendingFollowers as $pendingFollower) { $item = getByID($pendingFollower['follower'], $connection)->fetch_array(MYSQLI_ASSOC); array_push($followersFollowersArray, $item); } } view('main/index', ['userInfo' => $userInfo, 'publicPosts' => $publicPosts, 'followersFollowersArray' => $followersFollowersArray]);
function testLoginP() { $g = getValue('rememberMe'); $un = getValue('unCookie'); $pw = getValue('pwCookie'); $uID = getSession('userId'); $username = getByUserID($uID); $p = getParentStatus($uID); $y = testUserP($username, $pw, $p); $uID2 = getByUsername($un); $p2 = getParentStatus($uID2); $z = testUserP($un, $pw, $p2); if ($g and $p2 == 1) { setSession('loggedIn', true); } else { } $ret = getSession('loggedIn', false); setSession('returnURL', $_SERVER['PHP_SELF']); if ($ret == true && $p == 1) { return $ret; } else { header("Location: JobshadowLogin.php"); } }