function is_user_permitted_to_see_the_file($id1, $id2) { if ($id1 === $id2 || getRelationshipStatus($id1, $id2) === Relationship::FRIENDS) { return true; } return false; }
function getSocialUser() { global $twitterFollowers; global $facebookFriends; global $relationshipStatus; global $politicalViews; global $logFileHandle; $thisUser = getUserBasics(); $yob = substr($thisUser["birthday"], 0, 4); $age = date("Y") - $yob; $userValues["domain"] = getDomain(); fwrite($logFileHandle, "<p>The domain is " . $userValues["domain"]); $userValues["identifier"] = getIdentifier($userValues["domain"]); /******************* Facebook ************************/ if ($userValues["domain"] == "facebook.com") { if ($age > 18 && rand(1, 100) > 20) { $userValues["profile"]["relationshipStatus"] = getRelationshipStatus($age); } // if (!empty($relStatus)) { $userValues["profile"]["relationshipStatus"] = $relStatus; } // get political views if ($thisUser["primaryAddress"]["country"] == "United States") { if (rand(1, 100) > 61) { $polViews = getRandomValue($politicalViews); $userValues["profile"]["politicalViews"] = skewPoliticalViews($polViews, $age, $thisUser["gender"], $thisUser["primaryAddress"]["stateAbbreviation"]); } } $range = getRandomValue($facebookFriends); $numberOfFBfriends = rand($range["min"], $range["max"]); fwrite($logFileHandle, "<p>The number of friends is: " . $numberOfFBfriends); $userValues["friends"] = getFriendsOrFollowersArray($numberOfFBfriends, $userValues["domain"]); //*************** Interests, Movies, Books, Music **************/ // parameters: &attribute_name=profiles%23181683&uuid=ea1bc321-4320-4fbb-8f07-fb939b90cf46&value={"profile":{"interests":[{"interest":"scrapbooking"},{"interest":"cats"},{"interest":"dogs"}],"movies":[{"movie":"Platoon"},{"movie":"Star+Trek+Into+Darkness"}],"books":[{"book":"Call+It+Sleep"},{"book":"The+Death+of+the+Heart"},{"book":"The+French+Lieutenant%27s+Woman"}],"music":[{"music":"Britney+Spears"}]}} $psychInfoTypes = array("interests" => "interest", "movies" => "movie", "books" => "book", "music" => "music"); foreach ($psychInfoTypes as $categoryName => $itemName) { $numberOfItems = getNumberOfItems($itemName); $itemString = $itemName . "s"; if ($itemName == "music") { $itemString = $itemName . " artists"; } fwrite($logFileHandle, "<p>The number of {$itemString} is: " . $numberOfItems); if ($numberOfItems > 0) { $userValues["profile"][$categoryName] = getItems($itemName, $numberOfItems); } } } /********************* Twitter ***********************/ if ($userValues["domain"] == "twitter.com") { $range = getRandomValue($twitterFollowers); $numberOfTWfollowers = rand($range["min"], $range["max"]); fwrite($logFileHandle, "<p>The number of followers is: " . $numberOfTWfollowers); $userValues["followers"] = getFriendsOrFollowersArray($numberOfTWfollowers, $userValues["domain"]); } $thisUser["profiles"] = array(); $thisUser["profiles"][] = $userValues; return $thisUser; }
<?php $title = "Index"; require_once $_SERVER['DOCUMENT_ROOT'] . '/../includes/init.php'; require_once 'templates/header.php'; require_once 'lib/businessLogic.php'; is_logged_in(); $relationship = null; //other user's index page if (isset($_GET['u_id'])) { $user = selectUser($_GET['u_id']); $mineProfile = false; $relationship = getRelationshipStatus($_SESSION['loggedInUser']['u_id'], $_GET['u_id']); $rr = getRelationship($_SESSION['loggedInUser']['u_id'], $_GET['u_id']); } else { //index of a currently logged in user $user = selectUser($_SESSION['loggedInUser']['u_id']); $mineProfile = true; } ?> <main> <div class="container border"> <div id="profile"> <!--public data--> <div class="public"> <img src="/userpic.php?u_id=<?php echo $user['u_id']; ?> &type=public" width="170" height="235" alt="public-picture"> <div>