Merge branch 'master' into lars-chat

This commit is contained in:
Lars van Hijfte
2017-01-23 17:08:43 +01:00
43 changed files with 1148 additions and 498 deletions

View File

@@ -3,32 +3,7 @@
<head>
<meta charset="utf-8">
<title>Admin Panel</title>
<script type="text/javascript">
window.onload = function() {
changeFilter();
};
function checkAll(allbox) {
var checkboxes = document.getElementsByName('checkbox-user[]');
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type == 'checkbox') {
checkboxes[i].checked = allbox.checked;
}
}
}
function changeFilter() {
if (document.getElementById('group').checked) {
document.getElementById('admin-filter').style.display = 'none';
document.getElementById('admin-groupfilter').style.display = 'inline-block';
} else {
document.getElementById('admin-filter').style.display = 'inline-block';
document.getElementById('admin-groupfilter').style.display = 'none';
}
}
</script>
<script src="/js/admin.js" charset="utf-8"></script>
<?php
include_once("../queries/user.php");
include_once("../queries/group_page.php");
@@ -39,41 +14,54 @@
<!-- function test_input taken from http://www.w3schools.com/php/php_form_validation.asp -->
<?php
$search = "";
$listnr = 0; // TODO: add page functionality
$currentpage = 1;
$perpage = 20;
$status = $groupstatus = array();
$pagetype = "user";
if (isset($_GET["search"])) {
$search = test_input($_GET["search"]);
}
if (isset($_GET["pagetype"])) {
$pagetype = test_input($_GET["pagetype"]);
}
if (isset($_GET["status"])) {
$status = $_GET["status"];
}
if (isset($_GET["groupstatus"])) {
$groupstatus = $_GET["groupstatus"];
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (!empty($_POST["search"])) {
$search = test_input($_POST["search"]);
}
if (!empty($_POST["pagetype"])) {
$pagetype = test_input($_POST["pagetype"]);
}
if (!empty($_POST["status"])) {
$status = $_POST["status"];
}
if (!empty($_POST["groupstatus"])) {
$groupstatus = $_POST["groupstatus"];
}
if (!empty($_POST["actions"]) && !empty($_POST["userID"])) {
if (isset($_POST["actions"]) && isset($_POST["userID"])) {
changeUserStatusByID($_POST["userID"], $_POST["actions"]);
} elseif (!empty($_POST["actions"]) && !empty($_POST["groupID"])) {
}
if (isset($_POST["actions"]) && isset($_POST["groupID"])) {
changeGroupStatusByID($_POST["groupID"], $_POST["actions"]);
}
if (isset($_POST["batchactions"]) && isset($_POST["checkbox-user"])) {
changeMultipleUserStatusByID($_POST["checkbox-user"], $_POST["batchactions"]);
}
if (isset($_POST["groupbatchactions"]) && isset($_POST["checkbox-group"])) {
changeMultipleGroupStatusByID($_POST["checkbox-group"], $_POST["groupbatchactions"]);
}
if (isset($_POST["pageselect"])) {
$currentpage = $_POST["pageselect"];
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$listn = ($currentpage-1) * $perpage;
$listm = $currentpage * $perpage;
?>
<div class="content">
@@ -81,13 +69,10 @@ function test_input($data) {
<div class="admin-title">
<h1>User Management Panel</h1>
</div> <br>
<form class="admin-actionform"
action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
method="post">
<div class="admin-options">
<form class="admin-searchform"
action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
method="post">
method="get">
<div class="admin-searchbar">
<h2>Search</h2>
<input type="text"
@@ -147,32 +132,86 @@ function test_input($data) {
</div>
</form>
<div class="admin-actions">
<div class="admin-batchactions" id="admin-batchactions">
<h2>Batch Actions: </h2>
<input type="radio" name="actions" id="freeze" value="freeze">
<label for="freeze">Freeze</label><br>
<input type="radio" name="actions" id="ban" value="ban">
<label for="ban">Ban</label><br>
<input type="radio" name="actions" id="restore" value="restore">
<label for="restore">Restore</label><br><br>
<input type="submit" value="Confirm">
<form class="admin-batchform"
id="admin-batchform"
action="<?php htmlspecialchars(basename($_SERVER['REQUEST_URI'])) ?>"
method="post">
<input type="radio" name="batchactions" id="freeze" value="2">
<label for="freeze">Freeze</label><br>
<input type="radio" name="batchactions" id="ban" value="3">
<label for="ban">Ban</label><br>
<input type="radio" name="batchactions" id="restore" value="1">
<label for="restore">Restore</label><br><br>
<input type="submit" value="Confirm">
</form>
</div>
<div class="admin-groupbatchactions" id="admin-groupbatchactions">
<h2>Batch Actions: </h2>
<form class="admin-groupbatchform"
id="admin-groupbatchform"
action="<?php htmlspecialchars(basename($_SERVER['REQUEST_URI'])) ?>"
method="post">
<input type="radio" name="groupbatchactions" id="hide" value="0">
<label for="hide">Hide</label><br>
<input type="radio" name="groupbatchactions" id="public" value="1">
<label for="public">Public</label><br>
<input type="radio" name="groupbatchactions" id="membersonly" value="2">
<label for="membersonly">Member</label><br><br>
<input type="submit" value="Confirm">
</form>
</div>
</div>
<br>
<div class="admin-users">
<h2 class="usertitle">Users:</h2>
<div class="admin-userpage">
<input type="submit" name="prev" value="prev">
1 / 1
<input type="submit" name="next" value="next">
<div class="admin-usertitle">
<div class="admin-userheading">
<h2>Users:</h2>
</div>
<div class="admin-pageui">
<?php
if ($pagetype == "user") {
$pages = countSomeUsersByStatus($search, $status);
} else {
$pages = countSomeGroupsByStatus($search, $groupstatus);
}
$countresults = $pages->fetchColumn();
$mincount = min($listm, $countresults);
$minlist = min($listn + 1, $countresults);
?>
<p class="pagenumber">Current page:</p>
<form class="admin-pageselector"
action="<?php htmlspecialchars(basename($_SERVER['REQUEST_URI'])) ?>"
method="post">
<select class="admin-pageselect"
name="pageselect"
onchange="this.form.submit()"
value="">
<?php
for ($i=1; $i <= ceil($countresults / $perpage); $i++) {
if ($currentpage == $i) {
echo "<option value='$i' selected>$i</option>";
} else {
echo "<option value='$i'>$i</option>";
}
}
?>
</select>
</form>
<p class="entriesshown">
<?php
echo "Showing results $minlist to $mincount out of $countresults";
?>
</div>
</div> <br>
<table class="usertable">
<tr>
<th class="table-checkbox">
<input type="checkbox" name="checkall" onchange="checkAll(this)">
<input type="checkbox" id="checkall" name="checkall" onchange="checkAll(this)">
</th>
<th class="table-username">User</th>
<th class="table-status">Status</th>
@@ -182,21 +221,28 @@ function test_input($data) {
<!-- Table construction via php PDO. -->
<?php
$listn = ($currentpage-1) * $perpage;
$listm = $currentpage * $perpage;
if ($pagetype == 'user') {
$q = search20UsersFromNByStatus($listnr, $search, $status);
$q = searchSomeUsersByStatus($listn, $listm, $search, $status);
while($user = $q->fetch(PDO::FETCH_ASSOC)) {
$userID = $user['userID'];
$username = $user['username'];
$role = $user['role'];
$bancomment = $user['bancomment'];
$thispage = htmlspecialchars($_SERVER['PHP_SELF']);
$thispage = htmlspecialchars(basename($_SERVER['REQUEST_URI']));
$function = "checkCheckAll(document.getElementById('checkall'))";
echo("
<tr>
<td><input type='checkbox'
name='checkbox-user[]'
value='$userID'>
class='checkbox-list'
value='$userID'
form='admin-batchform'
onchange=" . "$function" . ">
</td>
<td>$username</td>
<td>$role</td>
@@ -218,20 +264,24 @@ function test_input($data) {
");
}
} else {
$q = search20GroupsFromNByStatus($listnr, $search, $groupstatus);
$q = searchSomeGroupsByStatus($listn, $listm, $search, $groupstatus);
while ($group = $q->fetch(PDO::FETCH_ASSOC)) {
$groupID = $group['groupID'];
$name = $group['name'];
$role = $group['status'];
$description = $group['description'];
$thispage = htmlspecialchars($_SERVER['PHP_SELF']);
$thispage = htmlspecialchars(basename($_SERVER['REQUEST_URI']));
$function = "checkCheckAll(document.getElementById('checkall'))";
echo("
<tr>
<td><input type='checkbox'
name='checkbox-group[]'
value='$groupID'>
class='checkbox-list'
value='$groupID'
form='admin-groupbatchform'
onchange=" . "$function" . ">
</td>
<td>$name</td>
<td>$role</td>
@@ -243,7 +293,7 @@ function test_input($data) {
<select class='action' name='actions'>
<option value='0'>Hide</option>
<option value='1'>Public</option>
<option value='2'>Members-only</option>
<option value='2'>Members</option>
</select>
<input type='hidden' name='groupID' value='$groupID'>
<input type='submit' value='Confirm'>
@@ -256,10 +306,6 @@ function test_input($data) {
?>
</table>
</div>
</form>
<pre>
<?php print_r($_POST); ?>
</pre>
</div>
</div>
</body>

View File

@@ -36,7 +36,7 @@
?>
</ul>
</nav>
<div class="chat-right right">
<div class="chat-right">
<div id="chat-history" class="chat-history platform">
</div>
<form id="lastIDForm">

View File

@@ -4,7 +4,7 @@
<script src="js/jquery.js"></script>
<script src="js/header.js"></script>
<script src="js/menu.js"></script>
<script src="js/masonry.js"></script>
<script src="js/notifications.js"></script>
<style>
/* Add your css files here. */
@import url("styles/main.css");
@@ -15,7 +15,8 @@
</style>
<?php
include_once("../queries/connect.php");
require_once ("../queries/checkInput.php");
require_once ("../queries/connect.php");
session_start();

View File

@@ -5,7 +5,7 @@ $userinfo = getHeaderInfo();
?>
<header>
<div id="header-logo">
<a href="profile.php"><img src="img/top-logo.png" alt="MyHyvesbook+" /></a>
<a href="profile.php"><img src="/img/top-logo.png" alt="MyHyvesbook+" /></a>
</div>
<div id="header-search">
<form action="search.php" method="get">
@@ -29,3 +29,5 @@ $userinfo = getHeaderInfo();
<img id="own-profile-picture" class="profile-picture" src="<?=$userinfo["profilepicture"]?>"/>
</div>
</header>
<?php include("notification-center.php"); ?>

View File

@@ -1,6 +1,6 @@
<div>
<img style="width:50%;margin-left:25%"
src="img/top-logo.png"
src="/img/top-logo.png"
alt="MyHyvesbook+">
</div>
<div class="platform">
@@ -46,6 +46,6 @@
</form>
<!-- Button for going to the register screen -->
<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" class="button">Registreer een account</a>
</div>
</div>

View File

@@ -3,9 +3,10 @@
<title>MyHyvesbook+</title>
<link rel="stylesheet"
type="text/css"
href="styles/main.css">
href="/styles/main.css">
<link rel="stylesheet"
type="text/css"
href="styles/index.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="/js/jqeury.js"></script>
<script src="/js/registerAndLogin.js"></script>
</head>

View File

@@ -1,5 +1,5 @@
<nav class="menu">
<section id="friends-menu-section">
<section id="friends-menu-section platform">
<h4>
Vrienden
</h4>
@@ -7,7 +7,8 @@
<?php
// Load file.
include_once("../queries/friendship.php");
require_once("../queries/friendship.php");
require_once("../queries/user.php");
// Get all the friends of a user.
$friends = selectAllFriends($_SESSION["userID"]);
@@ -26,7 +27,7 @@
if (!empty($friend["profilepicture"]))
$pf = $friend["profilepicture"];
if ($i > 1)
if ($i > 5)
$extraItem = "extra-menu-items";
// Echo the friend.
@@ -45,13 +46,31 @@
</li>
";
}
if ($i > 1) {
$i -= 1;
$randomUser = selectRandomNotFriendUser($_SESSION["userID"])["username"];
echo "
<li class='friend-item'>
<form action='/profile' method='get'>
<button type='submit'
name='username'
value='$randomUser'>
<div class='friend'>
Klik hier voor een nieuw vriendje :)
</div>
</button>
</form>
</li>
";
if ($i > 5) {
$i -= 5;
echo "
<li class='more-item' id='more-friends-click'>
En nog $i anderen...
</li>";
<li class='more-item' id='more-friends-click'>
En nog $i anderen...
</li>
";
}
?>
</ul>
</section>
@@ -87,17 +106,28 @@
// Echo the friend.
echo "
<a href='#' class='$extraItem'>
<li class='group-item'>
<div class='group'>
<img alt='PF' class='group-picture' src='$picture'/>
$name
</div>
</li>
</a>
<li class='group-item'>
<form action='group.php' method='get'>
<button type='submit'
name='groupname'
value='$name'>
<div class='group'>
<img alt='PF' class='group-picture' src='$picture'/>
$name
</div>
</button>
</form>
</li>
";
}
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;
echo "
<li class='more-item' id='more-groups-click'>

View File

@@ -0,0 +1,16 @@
<nav class="menu" id="notification-center">
<section id="quick-links">
<a href="chat.php"><i class="fa fa-comments-o" data-title="Prive chats"></i></a>
<a href="settings.php"><i class="fa fa-cog" data-title="Instellingen"></i></a>
<a href="profile.php"><i class="fa fa-user" data-title="Profiel"></i></a>
<a href="logout.php"><i class="fa fa-sign-out" data-title="Uitloggen"></i></a>
</section>
<section id="notifocationCenter">
<h4>
Vriendchapsverzoeken
</h4>
<ul class="nav-list" id="friendrequestslist">
</ul>
</section>
</nav>

View File

@@ -2,21 +2,23 @@
<div class="profile-box platform">
<img class="left profile-picture" src="<?php echo $user["profilepicture"] ?>">
<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>
<h1 class="profile-username"><?php echo $user["username"] ?></h1>
<p><?php echo $user["bio"] ?></p>
<h1 class="profile-username"><?=$user["username"]?></h1>
<h5 class="profile-username"><?= $user["fname"]?> <?=$user["lname"]?></h5>
<p><?=$user["bio"]?></p>
</div>
<div class="item-box left platform">
<h2>Vrienden</h2>
<p>
<?php
while($friend = $friends->fetch()) {
echo "<a href='#' data-title='" . $friend["username"] . "'><img class='profile-picture' src='" . $friend["profilepicture"] . "' alt='" . $friend["username"] . "'s profielfoto></a>";
while($friend = $profile_friends->fetch()) {
echo "<a href='/profile/${friend["username"]}/' data-title='${friend["username"]}'><img class='profile-picture' src='${friend["profilepicture"]}' alt='${friend["username"]}'s profielfoto></a>";
}
if($friends->rowCount() === 0) {
if($profile_friends->rowCount() === 0) {
echo "<p>Deze gebruiker heeft nog geen vrienden gemaakt.</p>";
}
?>
@@ -27,11 +29,11 @@
<h2>Groepen</h2>
<p>
<?php
while($group = $groups->fetch()) {
echo "<a href='#' data-title='${group["name"]}'><img class='group-picture' src='${group["picture"]}' alt='${group["name"]}s logo'></a>";
while($group = $profile_groups->fetch()) {
echo "<a href='/group/${group["name"]}/' data-title='${group["name"]}'><img class='group-picture' src='${group["picture"]}' alt='${group["name"]}s logo'></a>";
}
if($groups->rowCount() === 0) {
if($profile_groups->rowCount() === 0) {
echo "<p>Deze gebruiker is nog geen lid van een groep.</p>";
}
?>
@@ -40,6 +42,18 @@
<div class="posts">
<?php
if ($_SESSION["userID"] === $userID) {
?>
<div class="post platform">
<form>
<input type="text" class="newpost" placeholder="Titel">
<textarea class="newpost">Schrijf een berichtje...</textarea>
<input type="submit" value="Plaats!">
</form>
</div>
<?php
}
while($post = $posts->fetch()) {
$nicetime = nicetime($post["creationdate"]);
echo "
@@ -51,4 +65,5 @@
";
}
?>
</div>
</div>

View File

@@ -1,6 +1,6 @@
<div>
<img style="width:50%;margin-left:25%"
src="img/top-logo.png"
src="/img/top-logo.png"
alt="MyHyvesbook+">
</div>
@@ -108,7 +108,7 @@
<!-- Register email -->
<div class="login_containerregister">
<label><b>Email</b></label>
<input type="email"
<input type="text"
placeholder="Voer uw email in"
name="email"
value="<?php echo $email ?>"
@@ -123,13 +123,12 @@
value="Registreer uw account"
name="Submit"
id="frm1_submit">
Registreer uw account
Registreer
</button>
</div>
</form>
<!-- Button for going back to login screen -->
<div class="login_containerlogin">
<a href="https://myhyvesbookplus.nl/~joey/public/login.php" class="button">Login met een account</a>
<!-- Button for going back to login screen -->
<a href="https://myhyvesbookplus.nl/login.php" class="left-arrow">Login</a>
</div>
</div>

File diff suppressed because one or more lines are too long

View File

@@ -68,7 +68,7 @@ $settings = getSettings();
</li>
</ul>
</form>
<form class="settings-profilepictue platform" method="post">
<form class="settings-profilepictue platform" method="post" enctype="multipart/form-data">
<h5>Verander profielfoto</h5>
<ul>
<li>