Merge branch 'master' into kevin-prototype
This commit is contained in:
12
website/queries/calcAge.php
Normal file
12
website/queries/calcAge.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* calculates the age of a user
|
||||
* @param string $bdayAsString
|
||||
* @return int age
|
||||
*/
|
||||
function getAge(string $bdayAsString) : int {
|
||||
$bday = new DateTime($bdayAsString);
|
||||
$today = new DateTime("now");
|
||||
$interval = $bday->diff($today);
|
||||
return $interval->y;
|
||||
}
|
||||
@@ -16,7 +16,6 @@ function selectLimitedFriends($userID, $limit) {
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
`onlinestatus`,
|
||||
`role`
|
||||
FROM
|
||||
`user`
|
||||
@@ -56,7 +55,10 @@ function selectAllFriends($userID) {
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
`onlinestatus`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`,
|
||||
`role`
|
||||
FROM
|
||||
`user`
|
||||
@@ -88,7 +90,10 @@ function selectAllFriendRequests() {
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
`onlinestatus`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`,
|
||||
`role`
|
||||
FROM
|
||||
`user`
|
||||
@@ -235,7 +240,10 @@ function searchSomeFriends($n, $m, $search) {
|
||||
`profilepicture`,
|
||||
'../img/avatar-standard.png'
|
||||
) AS profilepicture,
|
||||
`onlinestatus`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`,
|
||||
`role`
|
||||
FROM
|
||||
`user`
|
||||
|
||||
@@ -110,20 +110,31 @@ function updateSettings() {
|
||||
WHERE
|
||||
`userID` = :userID
|
||||
");
|
||||
$bday = new DateTime();
|
||||
$bday->setDate(test_input($_POST["year"]), test_input($_POST["month"]), test_input($_POST["day"]));
|
||||
checkBday($bday);
|
||||
|
||||
$stmt->bindValue(":fname", test_input($_POST["fname"]));
|
||||
$stmt->bindValue(":lname", test_input($_POST["lname"]));
|
||||
$stmt->bindValue(":location", test_input($_POST["location"]));
|
||||
$stmt->bindValue(":bday", test_input($_POST["bday"]));
|
||||
$stmt->bindValue(":bday", $bday->format("Ymd"));
|
||||
$stmt->bindValue(":bio", test_input($_POST["bio"]));
|
||||
$stmt->bindValue(":showEmail", test_input($_POST["showEmail"]));
|
||||
$stmt->bindValue(":showBday", test_input($_POST["showBday"]));
|
||||
$stmt->bindValue(":showEmail", (array_key_exists("showEmail", $_POST) ? "1" : "0"));
|
||||
$stmt->bindValue(":showBday", (array_key_exists("showBday", $_POST) ? "1" : "0"));
|
||||
|
||||
$stmt->bindValue(":userID", $_SESSION["userID"]);
|
||||
$stmt->execute();
|
||||
throw new HappyAlert("Instellingen zijn opgeslagen.");
|
||||
}
|
||||
|
||||
function checkBday(DateTime $bday) {
|
||||
$today = new DateTime();
|
||||
if ($bday >= $today) {
|
||||
throw new AngryAlert("Jij bent vast niet in de toekomst geboren toch? ;)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change
|
||||
* @throws AngryAlert
|
||||
|
||||
@@ -45,7 +45,10 @@ function selectUser($me, $other) {
|
||||
) AS profilepicture,
|
||||
`bio`,
|
||||
`user`.`creationdate`,
|
||||
`onlinestatus`,
|
||||
CASE `lastactivity` >= DATE_SUB(NOW(),INTERVAL 15 MINUTE)
|
||||
WHEN TRUE THEN 'online'
|
||||
WHEN FALSE THEN 'offline'
|
||||
END AS `onlinestatus`,
|
||||
`role`,
|
||||
`fname`,
|
||||
`lname`,
|
||||
|
||||
Reference in New Issue
Block a user