Skip to content

Commit

Permalink
BETA
Browse files Browse the repository at this point in the history
  • Loading branch information
roudnas committed Dec 2, 2019
1 parent f2c9b6b commit 9ead3ed
Show file tree
Hide file tree
Showing 44 changed files with 340 additions and 58 deletions.
30 changes: 29 additions & 1 deletion controllers/AdministrationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public function parse($params) {
$stringManager = new StringManager();
$userManager = new UserManager();
$teamManager = new TeamManager();
$matchesManager = new MatchesManager();

//Admin validation
if (!UserManager::authAdmin()) {
Expand Down Expand Up @@ -143,6 +144,16 @@ public function parse($params) {
$this->addMessage($e);
}
}
if (isset($_POST['bracket-remove'])) {
try {
$matchesManager->dropMatches($_POST['remove-event-id']);
$this->addMessage("Bracket deleted");
$this->log("Bracket of event (".$_POST['remove-event-id'].") removed.", "bracket_drop");
$this->redir("administration");
} catch (PDOException $e) {
$this->addMessage($e);
}
}
if (isset($_POST['game-remove'])) {
try {
$gameManager->deleteGame($_POST['remove-game-id']);
Expand Down Expand Up @@ -190,10 +201,27 @@ public function parse($params) {
$this->addMessage($e);
}
}
if (isset($_POST['user-admin-tool'])) {
if (strlen($_POST['user-to-admin']) > 0) {
if (preg_match("/^[a-zA-Z0-9]+#[a-fA-F0-9]{4}$/", $_POST['user-to-admin']) || preg_match("/^#[a-fA-F0-9]{4}$/", $_POST['user-to-admin'])) {
$fullName = $userManager->parseHexname($_POST['user-to-admin']);
try {
$userManager->adminUser($fullName['hexid'], $_POST['admin-type']);
} catch (PDOException $e) {
$this->addMessage($e);
}
$this->addMessage("User given admin rights");
$this->log("User given admin rights"."//".$_POST['user-to-admin'], "user_admin");
$this->redir("administration");
}
} else
$this->addMessage("Field empty");
}
}
}


}
}


?>
2 changes: 2 additions & 0 deletions controllers/EventsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public function parse($params) {
$bracketManager = new BracketManager();
$events = $eventManager->returnEvents();
$eventUrls = array();
$this->header['page_desc'] = "SPSE Gaming Hub - Events";
$this->header['page_keywords'] = "SPSE Gaming, SPSE Esport, SPSE Gaming Events, SPSE Esport Events, SPŠE Esport, SPŠE Gaming, SPŠE Gaming Events, SPŠE Esport Events,";

for ($i=0; $i < count($events); $i++) {
$eventUrls[] = $events[$i]['event_url'];
Expand Down
3 changes: 2 additions & 1 deletion controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
class HomeController extends Controller {
public function parse($params) {
$this->header['page_title'] = "SPSE Gaming Hub";
$this->header['page_desc'] = "Uvodni strana";
$this->header['page_desc'] = "SPSE Gaming Hub - Homepage";
$this->header['page_keywords'] = "SPSE Gaming, SPSE Esport, SPSE Gaming Events, SPSE Esport Events, SPŠE Esport, SPŠE Gaming, SPŠE Gaming Events, SPŠE Esport Events,";
$this->view = "home";
}
}
Expand Down
14 changes: 13 additions & 1 deletion controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@ public function parse($params) {
$this->redir("login");

} if ($params[0] == 'messages' && !empty($params[1]) && in_array($params[1], $messageTypes)) {
$messages = $mesMan->returnMessagesByType($_SESSION['user']['user_id'], $params[1]);

if (empty($params[2]))
$messages = $mesMan->returnMessagesByType($_SESSION['user']['user_id'], $params[1], 0,5);
else if (!empty($params[2]))
$messages = $mesMan->returnMessagesByType($_SESSION['user']['user_id'], $params[1], (int)$params[2]*5-5,(int)$params[2]*5);

if (ceil((int)$mesMan->returnMessagesByTypeCount($_SESSION['user']['user_id'],$params[1])/5) > 1)
$this->data['numOfPages'] = ceil((int)$mesMan->returnMessagesByTypeCount($_SESSION['user']['user_id'],$params[1])/5);
else
$this->data['numOfPages'] = 0;

$this->data['messages'] = $messages;
$this->data['date'] = new DateTime("now");
$this->view = 'messages';

}
else if($params[0] == 'getmessage') {
$messages = $mesMan->returnMessages($_SESSION['user']['user_id']);
Expand Down Expand Up @@ -68,6 +79,7 @@ public function parse($params) {
$this->data['hasTeams'] = $hasTeams;
$this->data['games'] = $games;
$this->header['page_title'] = "Profile";
$this->header['page_desc'] = "SPSE Gaming Hub - Profile page";
$this->view = 'profile';
}

Expand Down
27 changes: 27 additions & 0 deletions controllers/RouterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public function parse($params){
$date = new DateTime();
$teamMan = new TeamManager();
$parsedU = $this->parseURL($params[0]);
$this->header['page_keywords'] = "SPSE Gaming, SPSE Esport, SPSE Gaming Events, SPSE Esport Events, SPŠE Esport, SPŠE Gaming, SPŠE Gaming Events, SPŠE Esport Events,";
if (empty($parsedU[0])) {
$this->redir('home');
}
Expand Down Expand Up @@ -66,6 +67,32 @@ public function parse($params){
$this->addMessage($e);
}
}
if (isset($_POST['mark-message-read'])) {
try {
$mesMan->markMessageAsRead($_POST['message-id']);
$this->redir(substr($_SERVER['REQUEST_URI'],1));
} catch (PDOException $e) {
$this->addMessage($e);
}
}
if (isset($_POST['message-delete'])) {
try {
$mesMan->moveMessageToTrash($_POST['message-id']);
$this->addMessage("Message moved to trash.");
$this->redir(substr($_SERVER['REQUEST_URI'],1));
} catch (PDOException $e) {
$this->addMessage($e);
}
}
if (isset($_POST['message-delete-complete'])) {
try {
$mesMan->deleteMessageById($_POST['message-id']);
$this->addMessage("Message deleted.");
$this->redir(substr($_SERVER['REQUEST_URI'],1));
} catch (PDOException $e) {
$this->addMessage($e);
}
}

if ($this->checkLogged()) {
$this->data['usrname'] = $_SESSION['user']['name'];
Expand Down
2 changes: 1 addition & 1 deletion models/FileManager.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
class FileManager {
public function uploadFile(array $file,bool $image, array $allowedExtensions, $name) {
public function uploadFile(array $file,bool $image, array $allowedExtensions, $name):string {
$uploads = "../SPSEGamingHub/public/uploads/";
$ext = strtolower(pathinfo(basename($file['name']), PATHINFO_EXTENSION));
$targetFile = $uploads . $name . ".".$ext;
Expand Down
13 changes: 13 additions & 0 deletions models/MatchesManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
class MatchesManager {
public function dropMatches($eventId) {
Db::query("DELETE from matches where event_id = ?", array($eventId));
}
}






?>
27 changes: 23 additions & 4 deletions models/MessageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ class MessageManager {
public function returnMessages($userId):array {
return Db::multiQuery("SELECT message_id, message, message_perex, message_type, message_status, message_timestamp, user_senderid, user_receiverid,
user_sendername, user_receivername, invite_team_id from
messages where user_receiverid = ? order by message_timestamp desc limit 5", array($userId));
messages where user_receiverid = ? order by message_timestamp desc", array($userId));
}

public function returnMessagesByType($userId, $messageType):array {
public function returnMessagesByTypeCount($userId,$mesType):int {
return Db::query("SELECT message_id, message, message_perex, message_type, message_status, message_timestamp, user_senderid, user_receiverid,
user_sendername, user_receivername, invite_team_id from
messages where user_receiverid = ? and message_type = ? order by message_timestamp desc", array($userId,$mesType));
}

public function returnMessagesByType($userId, $messageType, $limitD,$limitT):array {
$msgs = Db::multiQuery("SELECT message_id, message, message_perex, message_type, message_status, message_timestamp, timediff(NOW(),message_timestamp) as time_ago, user_senderid, user_receiverid,
user_sendername, user_receivername, invite_team_id from
messages where user_receiverid = ? and message_type = ? order by message_timestamp desc limit 5", array($userId, $messageType));
messages where user_receiverid = ? and message_type = ? order by message_timestamp desc limit ?,?", array($userId, $messageType, $limitD,$limitT));
$realMsgs = array();
foreach ($msgs as $m) {
$e = explode(":", (String)$m['time_ago']);
Expand Down Expand Up @@ -41,7 +47,7 @@ public function returnMessagesByType($userId, $messageType):array {
}

public function returnMessageById($mesId):array {
return Db::singleQuery("SELECT message_id, message, message_perex,message_type, message_status message_timestamp, user_senderid, user_receiverid,
return Db::singleQuery("SELECT message_id, message, message_perex,message_type, message_status, message_timestamp, user_senderid, user_receiverid,
user_sendername, user_receivername, invite_team_id from messages where message_id = ?", array($mesId));
}

Expand All @@ -68,5 +74,18 @@ public function sendMessage($message,$messageType,$timestamp,$senderId,$senderNa
throw new UserError($e);
}
}

public function markMessageAsRead($mesId) {
$mes = $this->returnMessageById($mesId);
Db::edit("messages", array("message_status"=>"read","message_timestamp"=>$mes['message_timestamp']),"where message_id = ?", array($mesId));
}

public function moveMessageToTrash($mesId) {
$mes = $this->returnMessageById($mesId);
Db::edit("messages", array("message_type"=>"trash","message_timestamp"=>$mes['message_timestamp']),"where message_id = ?", array($mesId));
}



}
?>
9 changes: 9 additions & 0 deletions models/UserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ public function verifyUser($hexId):void {
Db::edit("users",array("user_verified"=>1), "where user_hexid = ?", array($hexId));
}

public function adminUser($hexId,$adminType):void {
if ($adminType == "watchman")
Db::edit("users",array("watchman"=>1, "admin"=>"0"), "where user_hexid = ?", array($hexId));
else if ($adminType == "admin")
Db::edit("users",array("admin"=>1, "watchman"=>"0"), "where user_hexid = ?", array($hexId));
else
throw new UserError("Wrong admin type.");
}

public function parseHexname($hexName):array {
$parsedName = explode("#", $hexName);
return array(
Expand Down
10 changes: 6 additions & 4 deletions public/css/master.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ color: #fff;
border-radius: 0 2rem 0 2rem;
}
.eventcard:hover {
opacity: 0.75;
opacity: 0.93;
border: 3px solid orange;
transform:translateX(3px);
transition: all 0.5s ease-out;
Expand Down Expand Up @@ -286,9 +286,11 @@ background: linear-gradient(to right, #605C3C, #3C3B3F); /* W3C, IE 10+/ Edge, F
}
.scrollables {
position: fixed;
left: 5%;
top: 20%;
font-size: 3.5rem;
left: 0;
top: 3%;
font-size: 0.8rem;
border-radius: 0 2rem 2rem 0;
z-index: 99;
}
.scrollables > a {
color: orange;
Expand Down
Binary file added public/images/i-chat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/i-dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/i-fs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/i-mespw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/i-newmes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/i-ok.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/i-players.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/i-refresh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/i-score.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/i-time-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/i-time.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/i-typeinv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/i-typemes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/i-typetrash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/i-unread.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/i-verified.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/soon.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 9 additions & 4 deletions public/js/layoutmodel.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
function loadMessages(msgType) {
showInbox(msgType);
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
let curPageMes;
function loadMessages(msgType,page) {
showInbox(msgType,page);
curPageMes = parseInt(page);
}

function showInbox(msgType) {
function showInbox(msgType,page) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
Expand All @@ -12,7 +17,7 @@ function loadMessages(msgType) {
document.querySelector('.messages-content').innerHTML = response;
}
};
xhttp.open("GET", "profile/messages/"+msgType, true);
xhttp.open("GET", "profile/messages/"+msgType+"/"+page, true);
xhttp.send();
}

Expand Down
Binary file added public/uploads/csgo-ruleset.pdf
Binary file not shown.
Binary file modified public/uploads/hs-ruleset.pdf
Binary file not shown.
Binary file added public/uploads/lol-ruleset.pdf
Binary file not shown.
Binary file added public/uploads/mc-ruleset.pdf
Binary file not shown.
Binary file added public/uploads/ow-ruleset.pdf
Binary file not shown.
80 changes: 74 additions & 6 deletions views/administration.phtml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<section class="administration-wrapper p-5">

<section class="row justify-content-center">
<div class="col-lg-5 col-md-10 bg-dark px-5 py-2">
<h2>Dashboard</h2>
<hr style="background-color:#fff;">
<section class="row justify-content-center align-items-center">
<div class="col-lg-5 col-md-10 bg-dark px-5 py-2" style="height:80vh; border:2px solid orange;">
<h2><img class="mr-3" src="public/images/i-dashboard.png">Dashboard</h2>
<h3>Server time: <?php $time = new DateTime("now");
echo $time->format("H:i:s");?></h3>
<div class="accordion bg-dark" id="accordionExample">
Expand Down Expand Up @@ -47,11 +46,10 @@
<div id="collapseFour" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionExample">
<div class="card-body bg-dark row justify-content-around">
<button type="button" class="btn btn-warning col-5 m-1" data-toggle="modal" data-target=".modal-verification">Verification tool</button>
<button type="button" class="btn btn-warning col-5 m-1" data-toggle="modal" data-target=".modal-admin-tool">Admin tool</button>
</div>
</div>
</div>


</div>
</div>
<div class="col-lg-7 col-md-10 mt-md-2 mb-md-5 mt-sm-2 mb-sm-5 mt-xs-2 mb-xs-5 m-lg-0">
Expand Down Expand Up @@ -274,6 +272,41 @@
</div>
</div>

<div class="modal fade modal-remove-bracket" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Remove event</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="bracket-remove">
<div class="form-group">
<div class="input-group mb-3">
<div class="input-group-prepend">
<label class="input-group-text bg-success" style="color:#FFF;">Event</label>
</div>
<select class="custom-select" name="remove-event-id">
<option selected>Choose an event...</option>
<?php foreach ($events as $event): ?>
<option value="<?=$event['event_id']?>"><?=$event['event_name']?></option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-danger">Remove event bracket</button>
</form>
</div>
</div>
</div>
</div>

<div class="modal fade modal-remove-game" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
Expand Down Expand Up @@ -354,6 +387,41 @@
</div>
</div>

<div class="modal fade modal-admin-tool" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Admin tool</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form method="post">
<input type="hidden" name="user-admin-tool">
<div class="form-group w-50">
<div class="input-group mb-3">
<input class="form-control" id="newMessage_username" onkeyup='loadUserLiveText(this.value,"livesearch", "hint")' type="text" name="user-to-admin" value="" placeholder="Username#HexId" autocomplete="off">
</div>
</div>
<div class="form-group w-50">
<select class="form-control" name="admin-type">
<option value="admin">Admin</option>
<option value="watchman">Watchman</option>
</select>
</div>
<div class="livesearch livehint-invite p-1 my-1 text-center justify-content-center align-items-center" style="display: none;">
<p>Hint:</p>
<hr>
<div class="hint"></div>
</div>
<button type="submit" class="btn btn-warning" name="button">Admin this lad</button>
</form>
</div>
</div>
</div>
</div>


</section>
<script src="public/js/administrationmodel.js"></script>
Expand Down
Loading

0 comments on commit 9ead3ed

Please sign in to comment.