Hendrik testing #85

Merged
11342374 merged 11 commits from hendrik-testing into master 2017-01-20 14:37:02 +01:00
5 changed files with 77 additions and 20 deletions

View File

@@ -42,11 +42,10 @@ function nicetime($date) {
} }
if(empty($_GET["username"])) { if(empty($_GET["username"])) {
echo "User does not exist!"; $userID = $_SESSION["userID"];
return; } else {
}
$userID = getUserID($_GET["username"]); $userID = getUserID($_GET["username"]);
}
$user = selectUser($userID); $user = selectUser($userID);
$profile_friends = selectAllFriends($userID); $profile_friends = selectAllFriends($userID);

View File

@@ -30,7 +30,7 @@
cursor: pointer; cursor: pointer;
} }
.friend-item:hover { .friend-item:hover, .group-item:hover {
background: #845663; background: #845663;
color: white; color: white;
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
require("connect.php"); require("connect.php");
function getUserID($username) { function getUserID($username) {
@@ -244,4 +245,30 @@ function changeMultipleUserStatusByID($ids, $status) {
return $q; return $q;
} }
?> function selectRandomNotFriendUser($userID) {
$stmt = $GLOBALS["db"]->prepare("
SELECT
`user`.`username`
FROM
`user`
WHERE
`userID` NOT IN (SELECT
`user1ID`
FROM
`friendship`
WHERE `user1ID` = :userID) OR
`userID` NOT IN (SELECT
`user2ID`
FROM
`friendship`
WHERE `user2ID` = :userID)
ORDER BY
RAND()
LIMIT
1
");
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
$stmt->execute();
return $stmt->fetch();
}

View File

@@ -15,7 +15,8 @@
</style> </style>
<?php <?php
include_once("../queries/connect.php"); require_once ("../queries/checkInput.php");
require_once ("../queries/connect.php");
session_start(); session_start();

View File

@@ -7,7 +7,8 @@
<?php <?php
// Load file. // Load file.
include_once("../queries/friendship.php"); require_once("../queries/friendship.php");
require_once("../queries/user.php");
// Get all the friends of a user. // Get all the friends of a user.
$friends = selectAllFriends($_SESSION["userID"]); $friends = selectAllFriends($_SESSION["userID"]);
@@ -45,13 +46,31 @@
</li> </li>
"; ";
} }
$randomUser = selectRandomNotFriendUser($_SESSION["userID"])["username"];
echo "
<li class='friend-item'>
<form action='profile.php' method='get'>
<button type='submit'
name='username'
value='$randomUser'>
<div class='friend'>
Klik hier voor een nieuw vriendje :)
</div>
</button>
</form>
</li>
";
if ($i > 1) { if ($i > 1) {
$i -= 1; $i -= 1;
echo " echo "
<li class='more-item' id='more-friends-click'> <li class='more-item' id='more-friends-click'>
En nog $i anderen... En nog $i anderen...
</li>"; </li>
";
} }
?> ?>
</ul> </ul>
</section> </section>
@@ -87,17 +106,28 @@
// Echo the friend. // Echo the friend.
echo " echo "
<a href='#' class='$extraItem'>
<li class='group-item'> <li class='group-item'>
<form action='group.php' method='get'>
<button type='submit'
name='groupname'
value='$name'>
<div class='group'> <div class='group'>
<img alt='PF' class='group-picture' src='$picture'/> <img alt='PF' class='group-picture' src='$picture'/>
$name $name
</div> </div>
</button>
</form>
</li> </li>
</a>
"; ";
} }
if ($i > 3) {
if ($i == 0) {
echo "<li class='group-item'>
<div class='group'>
Je hoort nergens bij.
</div>
</li>";
} else if ($i > 3) {
$i -= 3; $i -= 3;
echo " echo "
<li class='more-item' id='more-groups-click'> <li class='more-item' id='more-groups-click'>