Marijn button #99
14
website/.htaccess
Normal file
14
website/.htaccess
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
Options +FollowSymLinks
|
||||||
|
RewriteEngine On
|
||||||
|
|
||||||
|
ErrorDocument 404 /error404.jpg
|
||||||
|
|
||||||
|
RewriteCond %{SCRIPT_FILENAME} !-d
|
||||||
|
RewriteCond %{SCRIPT_FILENAME} !-f
|
||||||
|
|
||||||
|
# Resolve .php file for extensionless php urls
|
||||||
|
RewriteRule ^([^/.]+)$ $1.php [L]
|
||||||
|
|
||||||
|
RewriteRule ^([^/.]+)\/$ $1.php [L]
|
||||||
|
|
||||||
|
RewriteRule ^profile/([A-z0-9]+)\/?$ profile.php?username=$1 [NC]
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<?xml version='1.0'?>
|
|
||||||
<MySQL_INIT>
|
|
||||||
<mysql_host>localhost</mysql_host>
|
|
||||||
<mysql_database>myhyvesbookplus</mysql_database>
|
|
||||||
<mysql_username>mhbp</mysql_username>
|
|
||||||
<mysql_password>qdtboXhCHJyL2szC</mysql_password>
|
|
||||||
</MySQL_INIT>
|
|
||||||
@@ -4,25 +4,32 @@
|
|||||||
include("../views/login_head.php");
|
include("../views/login_head.php");
|
||||||
require_once("../queries/connect.php");
|
require_once("../queries/connect.php");
|
||||||
include_once("../queries/login.php");
|
include_once("../queries/login.php");
|
||||||
|
include_once("../queries/checkInput.php")
|
||||||
?>
|
?>
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
if(isset($_SESSION["userID"])){
|
||||||
|
echo "<script>
|
||||||
|
window.onload=checkLoggedIn();
|
||||||
|
</script>";
|
||||||
|
}
|
||||||
|
|
||||||
// Define variables and set to empty values
|
// Define variables and set to empty values
|
||||||
$uname = $psw ="";
|
$uname = $psw ="";
|
||||||
$loginErr ="";
|
$loginErr ="";
|
||||||
|
|
||||||
// Trying to login
|
// Trying to login
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
$uname=strtolower($_POST["uname"]);
|
|
||||||
// Empty username or password field
|
// Empty username or password field
|
||||||
if (empty($_POST["uname"]) || empty($_POST["psw"])) {
|
if (empty($_POST["uname"]) || empty($_POST["psw"])) {
|
||||||
$loginErr = "Gebruikersnaam of wachtwoord is niet ingevuld";
|
$loginErr = "Gebruikersnaam of wachtwoord is niet ingevuld";
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$psw=$_POST["psw"];
|
$uname = strtolower(test_input($_POST["uname"]));
|
||||||
|
$psw = test_input($_POST["psw"]);
|
||||||
$hash = getUser()["password"];
|
$hash = getUser()["password"];
|
||||||
$userid = getUser()["userID"];
|
$userid = getUser()["userID"];
|
||||||
|
|
||||||
@@ -41,5 +48,18 @@
|
|||||||
/* This view adds login view */
|
/* This view adds login view */
|
||||||
include("../views/login-view.php");
|
include("../views/login-view.php");
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function checkLoggedIn() {
|
||||||
|
if (confirm("You are already logged in!\Do you want to logout?\Press ok to logout.") == true) {
|
||||||
|
unset($_SESSION["userID"]);
|
||||||
|
header("Location: login.php");
|
||||||
|
} else {
|
||||||
|
header("location: profile.php");
|
||||||
|
}
|
||||||
|
document.getElementById("demo").innerHTML = x;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ if(empty($_GET["username"])) {
|
|||||||
$userID = getUserID($_GET["username"]);
|
$userID = getUserID($_GET["username"]);
|
||||||
|
|
||||||
$user = selectUser($userID);
|
$user = selectUser($userID);
|
||||||
$friends = selectAllFriends($userID);
|
$profile_friends = selectAllFriends($userID);
|
||||||
$groups = selectAllUserGroups($userID);
|
$profile_groups = selectAllUserGroups($userID);
|
||||||
$posts = selectAllUserPosts($userID);
|
$posts = selectAllUserPosts($userID);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
include("../views/login_head.php");
|
include("../views/login_head.php");
|
||||||
require_once("../queries/connect.php");
|
require_once("../queries/connect.php");
|
||||||
include_once("../queries/register.php");
|
include_once("../queries/register.php");
|
||||||
|
include_once("../queries/checkInput.php");
|
||||||
?>
|
?>
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
@@ -17,127 +17,25 @@
|
|||||||
|
|
||||||
// Trying to register an account
|
// Trying to register an account
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
if (empty($_POST["name"])) {
|
checkInputChoice("name", "lettersAndSpace");
|
||||||
$nameErr = "Naam is verplicht!";
|
checkInputChoice("surname", "lettersAndSpace");
|
||||||
$correct = false;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$name = test_input($_POST["name"]);
|
|
||||||
if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
|
|
||||||
$nameErr = "Alleen letters en spaties zijn toegestaan!";
|
|
||||||
$correct = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($_POST["surname"])) {
|
|
||||||
$surnameErr = "Achternaam is verplicht!";
|
|
||||||
$correct = false;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$surname = test_input($_POST["surname"]);
|
|
||||||
if (!preg_match("/^[a-zA-Z ]*$/",$surname)) {
|
|
||||||
$surnameErr = "Alleen letters en spaties zijn toegestaan!";
|
|
||||||
$correct = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (empty($_POST["bday"])) {
|
if (empty($_POST["bday"])) {
|
||||||
$bdayErr = "Geboortedatum is verplicht!";
|
$bdayErr = "Geboortedatum is verplicht!";
|
||||||
$correct = false;
|
$correct = false;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($_POST["username"])) {
|
|
||||||
$usernameErr = "Gebruikersnaam is verplicht!";
|
|
||||||
$correct = false;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$username = test_input($_POST["username"]);
|
$bday = test_input($_POST["bday"]);
|
||||||
if (strlen($username) < 6) {
|
|
||||||
$usernameErr = "Gebruikersnaam moet minstens 6 karakters bevatten";
|
|
||||||
$correct = false;
|
|
||||||
|
|
||||||
} else if (getExistingUsername() == 1){
|
|
||||||
$usernameErr = "Gebruikersnaam bestaat al";
|
|
||||||
$correct = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($_POST["password"])) {
|
checkInputChoice("username", "username");
|
||||||
$passwordErr = "Wachtwoord is verplicht!";
|
checkInputChoice("password", "longerEight");
|
||||||
$correct = false;
|
checkInputChoice("confirmpassword", "");
|
||||||
|
matchPassword();
|
||||||
} else {
|
checkInputChoice("location", "lettersAndSpace");
|
||||||
$password = test_input($_POST["password"]);
|
checkInputChoice("email", "email");
|
||||||
if (strlen($password) < 8) {
|
registerCheck();
|
||||||
$passwordErr = "Wachtwoord moet minstens 8 karakters bevatten";
|
|
||||||
$correct = false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($_POST["confirmpassword"])) {
|
|
||||||
$confirmpasswordErr = "Herhaal wachtwoord!";
|
|
||||||
$correct = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_POST["password"] != $_POST["confirmpassword"]) {
|
|
||||||
$confirmpasswordErr = "Wachtwoorden matchen niet";
|
|
||||||
$correct = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($_POST["location"])) {
|
|
||||||
$locationErr = "Straatnaam is verplicht!";
|
|
||||||
$correct = false;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$location = test_input($_POST["location"]);
|
|
||||||
if (!preg_match("/^[a-zA-Z ]*$/",$location)) {
|
|
||||||
$locationErr = "Alleen letters en spaties zijn toegestaan!";
|
|
||||||
$correct = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($_POST["email"])) {
|
|
||||||
$emailErr = "Email is verplicht!";
|
|
||||||
$correct = false;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$email = test_input($_POST["email"]);
|
|
||||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
||||||
$emailErr = "Geldige email invullen!";
|
|
||||||
$correct = false;
|
|
||||||
|
|
||||||
} else if (getExistingEmail() == 1){
|
|
||||||
$emailErr = "Email bestaat al";
|
|
||||||
$correct = false;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checks if everything is filled in correctly
|
|
||||||
if ($correct == false){
|
|
||||||
$genericErr = "Bepaalde velden zijn verkeerd of niet ingevuld!";
|
|
||||||
|
|
||||||
} else {
|
|
||||||
registerAccount();
|
|
||||||
header("location: login.php");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_input($data) {
|
|
||||||
$data = trim($data);
|
|
||||||
$data = stripslashes($data);
|
|
||||||
$data = htmlspecialchars($data);
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This view adds register view */
|
/* This view adds register view */
|
||||||
include("../views/register-view.php");
|
include("../views/register-view.php");
|
||||||
?>
|
?>
|
||||||
|
|||||||
105
website/queries/checkInput.php
Normal file
105
website/queries/checkInput.php
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Function for checking inputfields
|
||||||
|
* @param variable $variable Give name of the inputfield.
|
||||||
|
* @param string $option Give the name of the option.
|
||||||
|
* @return sets correct to false and gives value to error message if it doesn't pass the checks.
|
||||||
|
*/
|
||||||
|
function checkInputChoice($variable, $option){
|
||||||
|
if (empty($_POST[$variable])) {
|
||||||
|
$GLOBALS[$variable . "Err"] = "Verplicht!";
|
||||||
|
$GLOBALS["correct"] = false;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$GLOBALS[$variable] = test_input($_POST[$variable]);
|
||||||
|
switch ($option) {
|
||||||
|
case "lettersAndSpace":
|
||||||
|
checkonly($variable);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "username";
|
||||||
|
username($variable);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "longerEight";
|
||||||
|
longerEight($variable);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "email";
|
||||||
|
validateEmail($variable);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Checks for only letters and spaces. */
|
||||||
|
function checkOnly($variable){
|
||||||
|
if (!preg_match("/^[a-zA-Z ]*$/",$GLOBALS[$variable])) {
|
||||||
|
$GLOBALS[$variable . "Err"] = "Alleen letters en spaties zijn toegestaan!";
|
||||||
|
$correct = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* checks if username exist and if its longer than 6 characters. */
|
||||||
|
function username($variable){
|
||||||
|
if (strlen($GLOBALS[$variable]) < 6) {
|
||||||
|
$GLOBALS[$variable . "Err"] = "Gebruikersnaam moet minstens 6 karakters bevatten";
|
||||||
|
$correct = false;
|
||||||
|
} else if (getExistingUsername() == 1) {
|
||||||
|
$GLOBALS[$variable . "Err"] = "Gebruikersnaam bestaat al";
|
||||||
|
$correct = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* checks if an input is longer that 8 characters. */
|
||||||
|
function longerEight($variable){
|
||||||
|
if (strlen($GLOBALS[$variable]) < 8) {
|
||||||
|
$GLOBALS[$variable . "Err"] = "Moet minstens 8 karakters bevatten";
|
||||||
|
$correct = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* checks if an input is a valid email. */
|
||||||
|
function validateEmail($variable){
|
||||||
|
if (!filter_var($GLOBALS[$variable], FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$GLOBALS[$variable . "Err"] = "Geldige email invullen!";
|
||||||
|
$correct = false;
|
||||||
|
|
||||||
|
} else if (getExistingEmail() == 1){
|
||||||
|
$GLOBALS[$variable . "Err"] = "Email bestaat al";
|
||||||
|
$correct = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* checks if two passwords matches. */
|
||||||
|
function matchPassword(){
|
||||||
|
if ($_POST["password"] != $_POST["confirmpassword"]) {
|
||||||
|
$GLOBALS["confirmpasswordErr"] = "Wachtwoorden matchen niet";
|
||||||
|
$GLOBALS["correct"] = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checks if everything is filled in correctly
|
||||||
|
function registerCheck(){
|
||||||
|
if ($GLOBALS["correct"] == false){
|
||||||
|
$GLOBALS["genericErr"] = "Bepaalde velden zijn verkeerd of niet ingevuld!";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
registerAccount();
|
||||||
|
header("location: login.php");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* removes weird characters of an input. */
|
||||||
|
function test_input($data) {
|
||||||
|
$data = trim($data);
|
||||||
|
$data = stripslashes($data);
|
||||||
|
$data = htmlspecialchars($data);
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -7,7 +7,7 @@ function selectAllFriends($userID) {
|
|||||||
`username`,
|
`username`,
|
||||||
IFNULL(
|
IFNULL(
|
||||||
`profilepicture`,
|
`profilepicture`,
|
||||||
'img/notbad.jpg'
|
'../img/notbad.jpg'
|
||||||
) AS profilepicture,
|
) AS profilepicture,
|
||||||
`onlinestatus`,
|
`onlinestatus`,
|
||||||
`role`
|
`role`
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ function selectUser($userID) {
|
|||||||
`username`,
|
`username`,
|
||||||
IFNULL(
|
IFNULL(
|
||||||
`profilepicture`,
|
`profilepicture`,
|
||||||
'img/notbad.png'
|
'../img/notbad.jpg'
|
||||||
) AS profilepicture,
|
) AS profilepicture,
|
||||||
`bio`,
|
`bio`,
|
||||||
`role`,
|
`role`,
|
||||||
|
|||||||
@@ -46,6 +46,6 @@
|
|||||||
</form>
|
</form>
|
||||||
<!-- Button for going to the register screen -->
|
<!-- Button for going to the register screen -->
|
||||||
<div class="login_containerlogin">
|
<div class="login_containerlogin">
|
||||||
<a href="https://myhyvesbookplus.nl/~joey/public/register.php" class="button">Registreer een account</a>
|
<a href="https://myhyvesbookplus.nl/register.php" class="button">Registreer een account</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,18 +4,19 @@
|
|||||||
<div class="profile-button">
|
<div class="profile-button">
|
||||||
<p><img src="img/add-friend.png"> Als vriend toevoegen</p>
|
<p><img src="img/add-friend.png"> Als vriend toevoegen</p>
|
||||||
</div>
|
</div>
|
||||||
<h1 class="profile-username"><?php echo $user["username"] ?></h1>
|
<h1 class="profile-username"><?= $user["fname"]?> <?=$user["lname"]?> (<?=$user["username"]?>)</h1>
|
||||||
<p><?php echo $user["bio"] ?></p>
|
<p><?=$user["bio"]?></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="item-box left platform">
|
<div class="item-box left platform">
|
||||||
<h2>Vrienden</h2>
|
<h2>Vrienden</h2>
|
||||||
<p>
|
<p>
|
||||||
<?php
|
<?php
|
||||||
while($friend = $friends->fetch()) {
|
while($friend = $profile_friends->fetch()) {
|
||||||
echo "<a href='#' data-title='" . $friend["username"] . "'><img class='profile-picture' src='" . $friend["profilepicture"] . "' alt='" . $friend["username"] . "'s profielfoto></a>";
|
echo "<a href='#' data-title='${friend["username"]}'><img class='profile-picture' src='${friend["profilepicture"]}' alt='${friend["username"]}'s profielfoto></a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($friends->rowCount() === 0) {
|
if($friends->rowCount() === 0) {
|
||||||
echo "<p>Deze gebruiker heeft nog geen vrienden gemaakt.</p>";
|
echo "<p>Deze gebruiker heeft nog geen vrienden gemaakt.</p>";
|
||||||
}
|
}
|
||||||
@@ -27,7 +28,7 @@
|
|||||||
<h2>Groepen</h2>
|
<h2>Groepen</h2>
|
||||||
<p>
|
<p>
|
||||||
<?php
|
<?php
|
||||||
while($group = $groups->fetch()) {
|
while($group = $profile_groups->fetch()) {
|
||||||
echo "<a href='#' data-title='${group["name"]}'><img class='group-picture' src='${group["picture"]}' alt='${group["name"]}s logo'></a>";
|
echo "<a href='#' data-title='${group["name"]}'><img class='group-picture' src='${group["picture"]}' alt='${group["name"]}s logo'></a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,3 +53,4 @@
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
@@ -108,7 +108,7 @@
|
|||||||
<!-- Register email -->
|
<!-- Register email -->
|
||||||
<div class="login_containerregister">
|
<div class="login_containerregister">
|
||||||
<label><b>Email</b></label>
|
<label><b>Email</b></label>
|
||||||
<input type="email"
|
<input type="text"
|
||||||
placeholder="Voer uw email in"
|
placeholder="Voer uw email in"
|
||||||
name="email"
|
name="email"
|
||||||
value="<?php echo $email ?>"
|
value="<?php echo $email ?>"
|
||||||
@@ -130,6 +130,6 @@
|
|||||||
|
|
||||||
<!-- Button for going back to login screen -->
|
<!-- Button for going back to login screen -->
|
||||||
<div class="login_containerlogin">
|
<div class="login_containerlogin">
|
||||||
<a href="https://myhyvesbookplus.nl/~joey/public/login.php" class="button">Login met een account</a>
|
<a href="https://myhyvesbookplus.nl/login.php" class="button">Login met een account</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user