changed files to more updated version

This commit is contained in:
2019-09-12 12:02:17 +02:00
parent 53794ac310
commit d50b864082
84 changed files with 1560 additions and 933 deletions

View File

@@ -0,0 +1,47 @@
<?php
require_once './controller/db/DBBoard.php';
require_once './controller/db/DBThread.php';
require_once './controller/db/DBUser.php';
require_once './model/forum/Board.php';
require_once './model/forum/Thread.php';
require_once './model/forum/User.php';
require_once './model/forum/Reply.php';
$boardTable = DBBoard::getBoards();
$threadsTable = [];
$usersTable = [];
$boards = [];
$threads = [];
$users = [];
foreach ($boardTable as $row)
{
$threadsTable = array_merge($threadsTable, DBThread::getThreadsByBoard($row['ID']));
array_push($boards, new Board($row['ID'], $row['name'], $row['permLevel']));
}
foreach($threadsTable as $row)
{
array_push($threads, new Thread($row['ID'],$row['users_ID'],$row['board_ID'],$row['title'],$row['text'],$row['date_created']));
array_push($usersTable, DBUser::getUserByUID($row['users_ID']));
}
foreach($usersTable as $row){
$skipUser = false;
foreach($users as $user){
if($row['ID'] == $user->getId()){
$skipUser = true;
}
}
if(!$skipUser){
array_push($users, new User($row['ID'], $row['username'], $row['email'], $row['password'], $row['reg_date'], $row['login_date'], $row['reg_ip'], $row['permissions']));
}
}
//MVCController::$viewData['boards'] = [new Board(0, "General", 0),new Board(1, "Admin board", 10)];
MVCController::$viewData['boards'] = $boards;
MVCController::$viewData['threads'] = $threads;
MVCController::$viewData['users'] = $users;
MVCController::$viewData['replies'] = [new Reply(0, 0, 0, "op is gay","01-01-1990")];
?>

View File

@@ -0,0 +1,5 @@
<?php
if(isset($_GET['thread'])){
MVCController::$viewData['threadid'] = $_GET['thread'];
}
?>

View File

@@ -0,0 +1,6 @@
<?php
require_once './controller/UserSession.php';
require_once './controller/MVCController.php';
if(UserSession::isUserSignedIn()){
MVCController::getMVCController()->overrideView("boards");
}

View File

@@ -0,0 +1,37 @@
<?php
require_once './controller/db/DBThread.php';
require_once './controller/db/DBReply.php';
require_once './controller/db/DBUser.php';
require_once './model/forum/User.php';
require_once './model/forum/Reply.php';
if(isset($_GET['thread'])) {
$threadid = $_GET['thread'];
} else {
$threadid = - 1;
}
// Get what we need from the database
$threadData = DBThread::getThreadByID($threadid);
$thread = new Thread($threadData['ID'], $threadData['users_ID'], $threadData['board_ID'], $threadData['title'], $threadData['text'], $threadData['date_created']);
$replyData = DBReply::getRepliesByThreadID($threadid);
// array to store our reply objects in
$replies = [ ];
// create reply objects from database rows
foreach ($replyData as $row) {
$reply = new Reply($row['ID'], $row['thread_ID'], $row['users_ID'], $row['content'], $row['date_created']);
array_push($replies, $reply);
$replyOwnerData = DBUser::getUserByUID($reply->getUserID());
$replyOwner = new User($replyOwnerData['ID'], $replyOwnerData['username'], $replyOwnerData['email'], $replyOwnerData['password'], $replyOwnerData['reg_date'], $replyOwnerData['login_date'], $replyOwnerData['reg_ip'], $replyOwnerData['permissions']);
$reply->setOwner($replyOwner);
}
// get the person who started the thread
$threadOwnerData = DBUser::getUserByUID($thread->getUserID());
// create user object
$threadOwner = new User($threadOwnerData['ID'], $threadOwnerData['username'], $threadOwnerData['email'], $threadOwnerData['password'], $threadOwnerData['reg_date'], $threadOwnerData['login_date'], $threadOwnerData['reg_ip'], $threadOwnerData['permissions']);
// assign owner and replies
$thread->setReplies($replies);
$thread->setOwner($threadOwner);
// Store data so it can be used in the view
MVCController::$viewData['thread'] = $thread;
?>

View File

@@ -0,0 +1,5 @@
<?php
require_once('./controller/db/Database.php');
Database::invalidateSession($_COOKIE['usersession']);
session_destroy();
?>

View File

@@ -0,0 +1,13 @@
<?php
require_once './controller/db/Database.php';
require_once './controller/db/DBUser.php';
$key = '';
if(isset($_GET['key'])){
$key = $_GET['key'];
}
if(Database::doesUserActivationKeyExist($key)){
Database::activateUser($key);
}
$completed = true;
?>