| @ -1,21 +1,15 @@ | |||
| <?php | |||
| //5-19-17 | |||
| //5-19-17 | |||
| include 'includes/header.php'; | |||
| include 'includes/header.php'; | |||
| echo '<br><div class="w3-row"> | |||
| <div class="w3-half w3-container ">'; | |||
| //add stuff | |||
| echo '<br><div class="w3-row"> | |||
| <div class="w3-half w3-container ">'; | |||
| echo '</div><div class="w3-half w3-container">'; | |||
| include 'user/profile.php'; | |||
| echo '</div><div class="w3-half w3-container">'; | |||
| include 'user/profile.php'; | |||
| echo '</div></div>'; | |||
| echo '</div>'; | |||
| echo '</div>'; | |||
| include 'includes/footer.php'; | |||
| ?> | |||
| include 'includes/footer.php'; | |||
| @ -1,39 +1,31 @@ | |||
| <?php | |||
| //11-24-16 | |||
| require('includes/header.php'); | |||
| if($admin) | |||
| { | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-twothird w3-container">'; | |||
| //users | |||
| include('user/users.php'); | |||
| echo '</div><div class="w3-third w3-container">'; | |||
| //profile | |||
| include('user/profile.php'); | |||
| echo '</div></div>'; | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-twothird w3-container">'; | |||
| //edit user | |||
| include('user/editUser.php'); | |||
| echo '</div><div class="w3-third w3-container">'; | |||
| //new user | |||
| include('user/newUser.php'); | |||
| echo '</div></div>'; | |||
| } | |||
| else | |||
| { | |||
| include('includes/profile.php'); | |||
| } | |||
| require('includes/footer.php'); | |||
| ?> | |||
| //11-24-16 | |||
| require('includes/header.php'); | |||
| if($admin) | |||
| { | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-twothird w3-container">'; | |||
| include('user/users.php'); | |||
| echo '</div><div class="w3-third w3-container">'; | |||
| include('user/profile.php'); | |||
| echo '</div></div>'; | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-twothird w3-container">'; | |||
| include('user/editUser.php'); | |||
| echo '</div><div class="w3-third w3-container">'; | |||
| include('user/newUser.php'); | |||
| echo '</div></div>'; | |||
| } | |||
| else | |||
| { | |||
| include('includes/profile.php'); | |||
| } | |||
| require('includes/footer.php'); | |||
| @ -1,22 +1,18 @@ | |||
| <?php | |||
| //5-16-17 | |||
| //5-16-17 | |||
| //ini_set('display_errors', 1); | |||
| include 'includes/header.php'; | |||
| //ini_set('display_errors', 1); | |||
| include 'includes/header.php'; | |||
| echo '<br><div class="w3-row"> | |||
| <div class="w3-half w3-container ">'; | |||
| include('games/bamboofield.html'); | |||
| echo '<br><div class="w3-row"> | |||
| <div class="w3-half w3-container ">'; | |||
| include('games/bamboofield.html'); | |||
| echo '</div><div class="w3-half w3-container">'; | |||
| include('games/zombiePanda.html'); | |||
| echo '</div><div class="w3-half w3-container">'; | |||
| include('games/zombiePanda.html'); | |||
| echo '</div>'; | |||
| echo '</div>'; | |||
| echo '</div></div>'; | |||
| include 'includes/footer.php'; | |||
| ?> | |||
| include 'includes/footer.php'; | |||
| @ -1,319 +1,276 @@ | |||
| <script> | |||
| window.addEventListener("keydown", function(e) | |||
| window.addEventListener("keydown", function(e) | |||
| { | |||
| // space and arrow keys | |||
| if([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) | |||
| { | |||
| // space and arrow keys | |||
| if([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) | |||
| { | |||
| e.preventDefault(); | |||
| } | |||
| }, false); | |||
| window.onload = function() | |||
| e.preventDefault(); | |||
| } | |||
| }, false); | |||
| window.onload = function() | |||
| { | |||
| var canvasBFc = document.getElementById("canvasBF"); | |||
| var c = canvasBFc.getContext('2d'); | |||
| c.fillStyle= "black"; | |||
| c.fillRect(0,0, canvasBFc.width, canvasBFc.height); | |||
| }; | |||
| function playBF() | |||
| { | |||
| var animate = window.requestAnimationFrame || | |||
| window.webkitRequestAnimationFrame || | |||
| window.mozRequestAnimationFrame || function (callback) | |||
| { | |||
| var canvasBFc = document.getElementById("canvasBF"); | |||
| var c = canvasBFc.getContext('2d'); | |||
| c.fillStyle= "black"; | |||
| c.fillRect(0,0, canvasBFc.width, canvasBFc.height); | |||
| window.setTimeout(callback, 1000 / 60) | |||
| }; | |||
| //entire game | |||
| function playBF() | |||
| var canvasBFc = document.getElementById("canvasBF"); | |||
| var width = 700; | |||
| var height = 700; | |||
| canvasBFc.style.textAligh = 'center'; | |||
| var context = canvasBFc.getContext('2d'); | |||
| var keysDown = {}; | |||
| //player variables; | |||
| var score = 0; | |||
| var alive = true; | |||
| function getRandomIntInclusive(min, max) | |||
| { | |||
| var animate = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (callback) | |||
| min = Math.ceil(min); | |||
| max = Math.floor(max); | |||
| return Math.floor(Math.random() * (max - min + 1)) + min; | |||
| } | |||
| var Player = function(x,y) | |||
| { | |||
| this.x = 350 | |||
| this.y = 650; | |||
| this.width = 10; | |||
| this.height = 10; | |||
| this.speed = 4; | |||
| this.facing = 40; | |||
| this.updateDirection = function(key) | |||
| { | |||
| window.setTimeout(callback, 1000 / 60) | |||
| }; | |||
| var canvasBFc = document.getElementById("canvasBF"); | |||
| var width = 700; | |||
| var height = 700; | |||
| canvasBFc.style.textAligh = 'center'; | |||
| var context = canvasBFc.getContext('2d'); | |||
| var keysDown = {}; | |||
| //player variables; | |||
| var score = 0; | |||
| var alive = true; | |||
| //usefull function | |||
| function getRandomIntInclusive(min, max) | |||
| facing = key; | |||
| } | |||
| this.render = function() | |||
| { | |||
| min = Math.ceil(min); | |||
| max = Math.floor(max); | |||
| return Math.floor(Math.random() * (max - min + 1)) + min; | |||
| context.fillStyle = "rgba(255, 255, 255, 1)"; //white | |||
| context.fillRect(this.x, this.y, this.width, this.height); | |||
| } | |||
| //objects | |||
| var Player = function(x,y) | |||
| this.move = function() | |||
| { | |||
| this.x = 350 | |||
| this.y = 650; | |||
| this.width = 10; | |||
| this.height = 10; | |||
| this.speed = 4; | |||
| this.facing = 40; | |||
| this.updateDirection = function(key) | |||
| { | |||
| facing = key; | |||
| } | |||
| this.render = function() | |||
| for (var key in keysDown) | |||
| { | |||
| context.fillStyle = "rgba(255, 255, 255, 1)"; //white | |||
| context.fillRect(this.x, this.y, this.width, this.height); | |||
| var value = Number(key); | |||
| if(value == 37) //left | |||
| this.x = this.x - this.speed; | |||
| else if(value == 39) | |||
| this.x = this.x + this.speed; | |||
| } | |||
| this.move = function() | |||
| //collisions | |||
| for(i = 0; i < bamboos.length; i++) | |||
| { | |||
| for (var key in keysDown) | |||
| { | |||
| var value = Number(key); | |||
| if(value == 37) //left | |||
| { | |||
| this.x = this.x - this.speed; | |||
| } | |||
| else if(value == 39) | |||
| { | |||
| this.x = this.x + this.speed; | |||
| } | |||
| } | |||
| //collisions | |||
| for(i = 0; i < bamboos.length; i++) | |||
| if(bamboos[i] != -1) | |||
| { | |||
| if(bamboos[i] != -1) | |||
| bb = bamboos[i]; | |||
| //if(Math.abs(bb.x - p.x) <= bb.width) | |||
| if(p.x > bb.x && p.x < bb.x + bb.width || | |||
| p.x + p.width < bb.x + bb.width && p.x + | |||
| p.width > bb.x) | |||
| { | |||
| bb = bamboos[i]; | |||
| //if(Math.abs(bb.x - p.x) <= bb.width) | |||
| if(p.x > bb.x && p.x < bb.x + bb.width || p.x + p.width < bb.x + bb.width && p.x + p.width > bb.x) | |||
| if(p.y > bb.y && p.y < bb.y + bb.height || | |||
| p.y + p.height < bb.y + bb.height && | |||
| p.y + p.height > bb.y) | |||
| { | |||
| if(p.y > bb.y && p.y < bb.y + bb.height || p.y + p.height < bb.y + bb.height && p.y + p.height > bb.y) | |||
| { | |||
| alive = false; | |||
| bb = -1; | |||
| } | |||
| alive = false; | |||
| bb = -1; | |||
| } | |||
| } | |||
| } | |||
| if(this.x < 0) | |||
| { | |||
| this.x += this.speed; | |||
| } | |||
| else if(this.x > width) | |||
| { | |||
| this.x -= this.speed; | |||
| } | |||
| } | |||
| if(this.x < 0) | |||
| this.x += this.speed; | |||
| else if(this.x > width) | |||
| this.x -= this.speed; | |||
| } | |||
| //player object | |||
| var p = new Player(350, 850); | |||
| //object that falls from the sky | |||
| var Bamboo = function() | |||
| } | |||
| //player object | |||
| var p = new Player(350, 850); | |||
| //object that falls from the sky | |||
| var Bamboo = function() | |||
| { | |||
| this.width = 25; | |||
| this.height = 75; | |||
| this.x = getRandomIntInclusive(0, width); | |||
| this.y = -this.height; | |||
| this.speed = 4; | |||
| this.render = function() | |||
| { | |||
| this.width = 25; | |||
| this.height = 75; | |||
| this.x = getRandomIntInclusive(0, width); | |||
| this.y = -this.height; | |||
| this.speed = 4; | |||
| this.render = function() | |||
| { | |||
| context.fillStyle = "rgba(0, 255, 0 , 1)"; //green | |||
| context.fillRect(this.x, this.y, this.width, this.height); | |||
| } | |||
| this.move = function() | |||
| { | |||
| this.y += this.speed; | |||
| if(this.y> height) | |||
| { | |||
| //remove bamboo from array | |||
| score++; | |||
| return true; | |||
| } | |||
| } | |||
| context.fillStyle = "rgba(0, 255, 0 , 1)"; //green | |||
| context.fillRect(this.x, this.y, this.width, this.height); | |||
| } | |||
| var bamboos = []; | |||
| //draws all the objects | |||
| var render = function() | |||
| this.move = function() | |||
| { | |||
| context.fillStyle = "rgba(0, 0,0 ,1)"; | |||
| context.fillRect(0,0, width, height); | |||
| context.fillStyle = "rgba(255, 255,255 ,1)"; | |||
| context.font = "20px Georgia"; | |||
| context.fillText("Score: " + score, 10, 25); | |||
| p.render(); | |||
| for(i= 0; i < bamboos.length; i++) | |||
| this.y += this.speed; | |||
| if(this.y> height) | |||
| { | |||
| if(bamboos[i] != -1) | |||
| { | |||
| bamboos[i].render(); | |||
| } | |||
| //remove bamboo from array | |||
| score++; | |||
| return true; | |||
| } | |||
| //console.log('render was called'); | |||
| //context.fillStyle = "rgba(0, 128, 0 ,1)"; //green | |||
| //context.fillRect(0, 0, 700, 700); | |||
| //console.log(context); | |||
| } | |||
| var update = function() | |||
| } | |||
| var bamboos = []; | |||
| //draws all the objects | |||
| var render = function() | |||
| { | |||
| context.fillStyle = "rgba(0, 0,0 ,1)"; | |||
| context.fillRect(0,0, width, height); | |||
| context.fillStyle = "rgba(255, 255,255 ,1)"; | |||
| context.font = "20px Georgia"; | |||
| context.fillText("Score: " + score, 10, 25); | |||
| p.render(); | |||
| for(i= 0; i < bamboos.length; i++) | |||
| if(bamboos[i] != -1) | |||
| bamboos[i].render(); | |||
| } | |||
| var update = function() | |||
| { | |||
| addBamboo(); | |||
| p.move(); | |||
| for (i = 0; i< bamboos.length; i++) | |||
| if(bamboos[i] != -1) | |||
| if(bamboos[i].move()) | |||
| bamboos[i] = -1; | |||
| addBamboo(); | |||
| } | |||
| var count = 0; | |||
| var limit = 25; | |||
| var addBamboo = function() | |||
| { | |||
| count++; | |||
| if(count == limit) | |||
| { | |||
| addBamboo(); | |||
| p.move(); | |||
| for (i = 0; i< bamboos.length; i++) | |||
| count = 0; | |||
| var bnew = true; | |||
| for(i = 0; i < bamboos.length; i++) | |||
| { | |||
| if(bamboos[i] != -1) | |||
| if(bamboos[i] == -1) | |||
| { | |||
| if(bamboos[i].move()) | |||
| { | |||
| bamboos[i] = -1; | |||
| } | |||
| bamboos[i] = new Bamboo(); | |||
| bnew = false; | |||
| } | |||
| } | |||
| addBamboo(); | |||
| if(bnew) | |||
| bamboos.push(new Bamboo()); | |||
| if(limit > 10) | |||
| limit --; | |||
| } | |||
| var count = 0; | |||
| var limit = 25; | |||
| var addBamboo = function() | |||
| } | |||
| var sent; | |||
| var tic = function() | |||
| { | |||
| if(alive) | |||
| { | |||
| count++; | |||
| if(count == limit) | |||
| { | |||
| count = 0; | |||
| var bnew = true; | |||
| for(i = 0; i < bamboos.length; i++) | |||
| { | |||
| if(bamboos[i] == -1) | |||
| { | |||
| bamboos[i] = new Bamboo(); | |||
| bnew = false; | |||
| } | |||
| } | |||
| if(bnew) | |||
| { | |||
| bamboos.push(new Bamboo()); | |||
| } | |||
| if(limit > 10) | |||
| { | |||
| limit --; | |||
| } | |||
| } | |||
| update(); | |||
| render(); | |||
| } | |||
| var sent; | |||
| var tic = function() | |||
| else | |||
| { | |||
| //console.log('tic was called'); | |||
| if(alive) | |||
| { | |||
| update(); | |||
| render(); | |||
| } | |||
| else | |||
| if(!sent) | |||
| { | |||
| if(!sent) | |||
| { | |||
| context.fillStyle = "rgba(0, 0,0 ,1)"; | |||
| context.fillRect(0,0, width, height); | |||
| context.fillStyle = "rgba(0, 0,0 ,1)"; | |||
| context.fillRect(0,0, width, height); | |||
| context.fillStyle = "rgba(255, 255,255 ,1)"; | |||
| context.font = "20px Georgia"; | |||
| context.fillText("You died with a score of: " + score, 250, 325); | |||
| context.fillStyle = "rgba(255, 255,255 ,1)"; | |||
| context.font = "20px Georgia"; | |||
| context.fillText("You died with a score of: " + | |||
| score, 250, 325); | |||
| document.body.innerHTML += '<form id="dynForm" action="insertScore.php" method="post"><input type="hidden" name="game_new_score" value=true><input type="hidden" name="game" value=1><input type="hidden" name="user_id_score" value=<?php echo $_SESSION['user_id']; ?>><input type="hidden" name="score_validate" value=' + score + '></form>'; | |||
| document.getElementById("dynForm").submit(); | |||
| sent = true; | |||
| } | |||
| document.body.innerHTML += '<form id="dynForm" ' + | |||
| 'action="insertScore.php" method="post"><input ' + | |||
| 'type="hidden" name="game_new_score" value=true>' + | |||
| '<input type="hidden" name="game" value=1><input ' + | |||
| 'type="hidden" name="user_id_score" ' + | |||
| 'value=<?php echo $_SESSION['user_id']; ?>><input ' + | |||
| 'type="hidden" name="score_validate" value=' + score + '></form>'; | |||
| document.getElementById("dynForm").submit(); | |||
| sent = true; | |||
| } | |||
| animate(tic); | |||
| } | |||
| window.addEventListener("keydown", function (event) | |||
| { | |||
| if(event.keyCode >=37 && event.keyCode <=40) | |||
| { | |||
| p.facing = event.keyCode; | |||
| } | |||
| keysDown[event.keyCode] = true; | |||
| }); | |||
| window.addEventListener("keyup", function (event) | |||
| { | |||
| delete keysDown[event.keyCode]; | |||
| }); | |||
| //tic(); | |||
| animate(tic); | |||
| } | |||
| window.addEventListener("keydown", function (event) | |||
| { | |||
| if(event.keyCode >=37 && event.keyCode <=40) | |||
| p.facing = event.keyCode; | |||
| keysDown[event.keyCode] = true; | |||
| }); | |||
| window.addEventListener("keyup", function (event) | |||
| { | |||
| delete keysDown[event.keyCode]; | |||
| }); | |||
| //tic(); | |||
| animate(tic); | |||
| } | |||
| </script> | |||
| <div><canvas id="canvasBF" width="700" height="700"></canvas></div> | |||
| <div><input type="submit" name="play" value="Play Game" onclick="this.blur();playBF()"/></div> | |||
| <div><input type="submit" name="play" value="Play Game" onclick="this.blur(); | |||
| playBF()"/></div> | |||
| @ -1,38 +1,35 @@ | |||
| <?php | |||
| $dir = 2; | |||
| //used for high score | |||
| $game_id = 1; | |||
| $dir = 2; | |||
| //ini_set('display_errors', 1); | |||
| include '../includes/header.php'; | |||
| //used for high score | |||
| $game_id = 1; | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| include('bamboofield.html'); | |||
| //ini_set('display_errors', 1); | |||
| include '../includes/header.php'; | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| include('bamboofield.html'); | |||
| echo '</div><div class="w3-half w3-container">'; | |||
| //include('../includes/profile.php'); | |||
| include('highscore.php'); | |||
| echo '</div></div>'; | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| echo '</div><div class="w3-half w3-container">'; | |||
| //include('../includes/profile.php'); | |||
| include('highscore.php'); | |||
| //edit user | |||
| include('../user/profile.php'); | |||
| echo '</div></div>'; | |||
| echo '</div><div class="w3-half w3-container">'; | |||
| include('userscores.php'); | |||
| echo '</div></div>'; | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| //edit user | |||
| include('../user/profile.php'); | |||
| include '../includes/footer.php'; | |||
| ?> | |||
| echo '</div><div class="w3-half w3-container">'; | |||
| include('userscores.php'); | |||
| echo '</div></div>'; | |||
| include '../includes/footer.php'; | |||
| @ -1,44 +1,41 @@ | |||
| <?php | |||
| //5-17-17 | |||
| echo '<h1 class="w3-text-teal"><center>High Scores</center></h1>'; | |||
| $q = "select * from scores where game = '$game_id' order by score desc limit 20"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<div class="w3-responsive w3-card-4"><table class="w3-table w3-striped w3-bordered"><thead>'; | |||
| echo '<tr class="w3-theme"> | |||
| <td>Rank</td> | |||
| <td>User Name</td> | |||
| <td>Score</td> | |||
| </tr></thead><tbody>'; | |||
| $rank = 0; | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| $rank ++; | |||
| echo '<tr>'; | |||
| echo '<td>' . $rank . '</td>'; | |||
| echo '<td>'; | |||
| $q2 = "select user_name from users where user_id='". $row['user_id'] . "' limit 1"; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| while($row2 = mysqli_fetch_array($r2)) | |||
| { | |||
| echo $row2['user_name']; | |||
| } | |||
| echo '</td>'; | |||
| //score | |||
| echo '<td>' . $row['score'] . '</td>'; | |||
| echo '</tr>'; | |||
| } | |||
| echo '</tbody></table></div>'; | |||
| ?> | |||
| //5-17-17 | |||
| echo '<h1 class="w3-text-teal"><center>High Scores</center></h1>'; | |||
| $q = "select * from scores where game = '$game_id' order by score desc limit 20"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<div class="w3-responsive w3-card-4"><table class="w3-table w3-striped | |||
| w3-bordered"><thead>'; | |||
| echo '<tr class="w3-theme"> | |||
| <td>Rank</td> | |||
| <td>User Name</td> | |||
| <td>Score</td> | |||
| </tr></thead><tbody>'; | |||
| $rank = 0; | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| $rank ++; | |||
| echo '<tr>'; | |||
| echo '<td>' . $rank . '</td>'; | |||
| echo '<td>'; | |||
| $q2 = "select user_name from users where user_id='". $row['user_id'] . | |||
| "' limit 1"; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| while($row2 = mysqli_fetch_array($r2)) | |||
| echo $row2['user_name']; | |||
| echo '</td>'; | |||
| //score | |||
| echo '<td>' . $row['score'] . '</td>'; | |||
| echo '</tr>'; | |||
| } | |||
| echo '</tbody></table></div>'; | |||
| @ -1,42 +1,26 @@ | |||
| <?php | |||
| //5-16-17 | |||
| include_once '../../club_connect.php'; | |||
| if(isset($_POST['game_new_score'])) | |||
| { | |||
| $i_game = mysqli_real_escape_string($dbc, trim($_POST['game'])); | |||
| $i_user_id = mysqli_real_escape_string($dbc, trim($_POST['user_id_score'])); | |||
| $i_score = mysqli_real_escape_string($dbc, trim($_POST['score_validate'])); | |||
| // | |||
| // foreach ($_POST as $key => $value) | |||
| // { | |||
| // echo $value . '<br>'; | |||
| // } | |||
| $q = "insert into scores(game, user_id, score) values('$i_game','$i_user_id','$i_score')"; | |||
| if($i_user_id > 0) | |||
| { | |||
| $r = mysqli_query($dbc, $q); | |||
| } | |||
| // | |||
| // | |||
| // echo '<h1>' . $q . '</h1>'; | |||
| if($i_game == 1) | |||
| { | |||
| header("Location: bamboofield.php"); | |||
| } | |||
| else if($i_game == 2) | |||
| { | |||
| header("Location: zombiePanda.php"); | |||
| } | |||
| } | |||
| //5-16-17 | |||
| ?> | |||
| include_once '../../club_connect.php'; | |||
| if(isset($_POST['game_new_score'])) | |||
| { | |||
| $i_game = mysqli_real_escape_string($dbc, | |||
| trim($_POST['game'])); | |||
| $i_user_id = mysqli_real_escape_string($dbc, | |||
| trim($_POST['user_id_score'])); | |||
| $i_score = mysqli_real_escape_string($dbc, | |||
| trim($_POST['score_validate'])); | |||
| $q = "insert into scores(game, user_id, score) | |||
| values('$i_game','$i_user_id','$i_score')"; | |||
| if($i_user_id > 0) | |||
| $r = mysqli_query($dbc, $q); | |||
| if($i_game == 1) | |||
| header("Location: bamboofield.php"); | |||
| else if($i_game == 2) | |||
| header("Location: zombiePanda.php"); | |||
| } | |||
| @ -1,44 +1,37 @@ | |||
| <?php | |||
| //5-17-17 | |||
| if($loggedIn) | |||
| { | |||
| echo '<h1 class="w3-text-teal"><center>User\'s Personal Records</center></h1>'; | |||
| $q = "select * from scores where user_id='" . $_SESSION['user_id'] . "' and game='$game_id' order by score desc limit 20"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<div class="w3-responsive w3-card-4"><table class="w3-table w3-striped w3-bordered"><thead>'; | |||
| echo '<tr class="w3-theme"> | |||
| <td>User Name</td> | |||
| <td>Score</td> | |||
| </tr></thead><tbody>'; | |||
| //5-17-17 | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<tr>'; | |||
| if($loggedIn) | |||
| { | |||
| echo '<h1 class="w3-text-teal"><center>User\'s Personal Records | |||
| </center></h1>'; | |||
| $q = "select * from scores where user_id='" . $_SESSION['user_id'] | |||
| . "' and game='$game_id' order by score desc limit 20"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<div class="w3-responsive w3-card-4"><table | |||
| class="w3-table w3-striped w3-bordered"><thead>'; | |||
| echo '<tr class="w3-theme"> | |||
| <td>User Name</td> | |||
| <td>Score</td> | |||
| </tr></thead><tbody>'; | |||
| echo '<td>'; | |||
| $q2 = "select user_name from users where user_id='". $row['user_id'] . "' limit 1"; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<tr><td>'; | |||
| while($row2 = mysqli_fetch_array($r2)) | |||
| { | |||
| echo $row2['user_name']; | |||
| } | |||
| $q2 = "select user_name from users where user_id='" | |||
| . $row['user_id'] . "' limit 1"; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| echo '</td>'; | |||
| while($row2 = mysqli_fetch_array($r2)) | |||
| echo $row2['user_name']; | |||
| //score | |||
| echo '<td>' . $row['score'] . '</td>'; | |||
| echo '</td>'; | |||
| echo '</tr>'; | |||
| } | |||
| echo '</tbody></table></div>'; | |||
| //score | |||
| echo '<td>' . $row['score'] . '</td></tr>'; | |||
| } | |||
| ?> | |||
| echo '</tbody></table></div>'; | |||
| } | |||
| @ -1,396 +1,391 @@ | |||
| <script> | |||
| window.addEventListener("keydown", function(e) | |||
| window.addEventListener("keydown", function(e) | |||
| { | |||
| // space and arrow keys | |||
| if([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) | |||
| { | |||
| // space and arrow keys | |||
| if([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) | |||
| { | |||
| e.preventDefault(); | |||
| } | |||
| }, false); | |||
| window.onload = function() | |||
| e.preventDefault(); | |||
| } | |||
| }, false); | |||
| window.onload = function() | |||
| { | |||
| var canvas = document.getElementById("canvasZP"); | |||
| var c = canvas.getContext('2d'); | |||
| c.fillStyle= "black"; | |||
| c.fillRect(0,0,canvas.width,canvas.height); | |||
| }; | |||
| function playZP() | |||
| { | |||
| var animate = window.requestAnimationFrame || | |||
| window.webkitRequestAnimationFrame || | |||
| window.mozRequestAnimationFrame || function (callback) | |||
| { | |||
| var canvas = document.getElementById("canvasZP"); | |||
| var c = canvas.getContext('2d'); | |||
| c.fillStyle= "black"; | |||
| c.fillRect(0,0,canvas.width,canvas.height); | |||
| window.setTimeout(callback, 1000 / 60) | |||
| }; | |||
| function playZP() | |||
| var canvas = document.getElementById("canvasZP"); | |||
| var width = 700; | |||
| var height = 700; | |||
| canvas.style.textAlign = 'center'; | |||
| var context = canvas.getContext('2d'); | |||
| var keysDown = {}; | |||
| var score = 0; | |||
| var dead = false; | |||
| //player | |||
| var Player = function(x,y) | |||
| { | |||
| this.x = x; | |||
| this.y = y; | |||
| this.width = 25; | |||
| this.height = 25; | |||
| var animate = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function (callback) | |||
| { | |||
| window.setTimeout(callback, 1000 / 60) | |||
| }; | |||
| var canvas = document.getElementById("canvasZP"); | |||
| var width = 700; | |||
| var height = 700; | |||
| canvas.style.textAlign = 'center'; | |||
| var context = canvas.getContext('2d'); | |||
| var keysDown = {}; | |||
| var score = 0; | |||
| var dead = false; | |||
| //player | |||
| var Player = function(x,y) | |||
| { | |||
| this.x = x; | |||
| this.y = y; | |||
| this.width = 25; | |||
| this.height = 25; | |||
| this.speed = 3; | |||
| this.facing = 40; | |||
| this.speed = 3; | |||
| this.updateDirection = function(key) | |||
| { | |||
| facing = key; | |||
| } | |||
| this.render = function() | |||
| { | |||
| context.fillStyle = "rgba(0, 45, 160, 1)"; //green | |||
| context.fillRect(this.x, this.y, this.width,this.height); | |||
| } | |||
| this.move = function() | |||
| { | |||
| for (var key in keysDown) | |||
| { | |||
| var value = Number(key); | |||
| if (value == 37) //left | |||
| { | |||
| this.x = this.x - this.speed; | |||
| } | |||
| else if (value == 39) //right | |||
| { | |||
| this.x = this.x + this.speed | |||
| } | |||
| else if(value == 38) //up | |||
| { | |||
| this.y = this.y - this.speed | |||
| } | |||
| else if(value == 40) //down | |||
| { | |||
| this.y = this.y + this.speed | |||
| } | |||
| else if(value == 32) | |||
| { | |||
| var added = false; | |||
| for(i = 0; i< bullets.length; i++) | |||
| { | |||
| if(bullets[i] == -1) | |||
| { | |||
| bullets[i] = new Bullet(); | |||
| added = true; | |||
| break; | |||
| } | |||
| } | |||
| if(added == false) | |||
| { | |||
| bullets.push(new Bullet()); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| this.facing = 40; | |||
| this.updateDirection = function(key) | |||
| { | |||
| facing = key; | |||
| } | |||
| var p = new Player(350, 350); | |||
| //bullet | |||
| var Bullet = function() | |||
| this.render = function() | |||
| { | |||
| this.x = p.x; | |||
| this.y = p.y; | |||
| this.width = 10; | |||
| this.height = 10; | |||
| this.speed = 4; | |||
| this.facing = p.facing; | |||
| context.fillStyle = "rgba(0, 45, 160, 1)"; //green | |||
| context.fillRect(this.x, this.y, this.width,this.height); | |||
| } | |||
| this.move = function() | |||
| this.move = function() | |||
| { | |||
| for (var key in keysDown) | |||
| { | |||
| if (this.facing == 37) //left | |||
| var value = Number(key); | |||
| if (value == 37) //left | |||
| { | |||
| this.x = this.x - this.speed; | |||
| } | |||
| else if (this.facing == 39) //right | |||
| } | |||
| else if (value == 39) //right | |||
| { | |||
| this.x = this.x + this.speed | |||
| } | |||
| else if(this.facing == 38) //up | |||
| else if(value == 38) //up | |||
| { | |||
| this.y = this.y - this.speed | |||
| } | |||
| else if(this.facing == 40) //down | |||
| else if(value == 40) //down | |||
| { | |||
| this.y = this.y + this.speed | |||
| } | |||
| else if(value == 32) | |||
| { | |||
| var added = false; | |||
| } | |||
| for(i = 0; i< bullets.length; i++) | |||
| { | |||
| if(bullets[i] == -1) | |||
| { | |||
| bullets[i] = new Bullet(); | |||
| added = true; | |||
| break; | |||
| } | |||
| } | |||
| if(added == false) | |||
| bullets.push(new Bullet()); | |||
| this.render = function() | |||
| { | |||
| context.fillStyle = "rgba(255, 0, 199, 1)"; //green | |||
| context.fillRect(this.x, this.y, this.width,this.height); | |||
| } | |||
| } | |||
| } | |||
| var bullets = []; | |||
| } | |||
| var p = new Player(350, 350); | |||
| function getRandomIntInclusive(min, max) { | |||
| min = Math.ceil(min); | |||
| max = Math.floor(max); | |||
| return Math.floor(Math.random() * (max - min + 1)) + min; | |||
| } | |||
| //bullet | |||
| var Bullet = function() | |||
| { | |||
| this.x = p.x; | |||
| this.y = p.y; | |||
| this.width = 10; | |||
| this.height = 10; | |||
| this.speed = 4; | |||
| this.facing = p.facing; | |||
| //zombie | |||
| var Zombie = function(x,y) | |||
| this.move = function() | |||
| { | |||
| this.x = x; | |||
| this.y = y; | |||
| this.width = 25; | |||
| this.height = 25; | |||
| this.speed = 3; | |||
| var side = getRandomIntInclusive(0,3); | |||
| var mid = getRandomIntInclusive(0,700); | |||
| if(side === 1) | |||
| { | |||
| this.x = mid; | |||
| this.y = 0; | |||
| } | |||
| else if(side === 2) | |||
| { | |||
| this.x = 700; | |||
| this.y = mid; | |||
| } | |||
| else if(side === 3) | |||
| { | |||
| this.y = 700; | |||
| this.x = mid; | |||
| } | |||
| else | |||
| { | |||
| this.x = 0; | |||
| this.y = mid; | |||
| } | |||
| if (this.facing == 37) //left | |||
| this.x = this.x - this.speed; | |||
| else if (this.facing == 39) //right | |||
| this.x = this.x + this.speed | |||
| else if(this.facing == 38) //up | |||
| this.y = this.y - this.speed | |||
| else if(this.facing == 40) //down | |||
| this.y = this.y + this.speed | |||
| } | |||
| this.render = function() | |||
| { | |||
| context.fillStyle = "rgba(0, 160, 0, 1)"; //green | |||
| context.fillRect(this.x, this.y, this.width,this.height); | |||
| } | |||
| this.render = function() | |||
| { | |||
| context.fillStyle = "rgba(255, 0, 199, 1)"; //green | |||
| context.fillRect(this.x, this.y, this.width,this.height); | |||
| this.move = function() | |||
| { | |||
| if(this.x > p.x + this.speed) | |||
| this.x -= this.speed; | |||
| else if(this.x + this.speed < p.x ) | |||
| this.x += this.speed; | |||
| } | |||
| } | |||
| var bullets = []; | |||
| function getRandomIntInclusive(min, max) { | |||
| min = Math.ceil(min); | |||
| max = Math.floor(max); | |||
| return Math.floor(Math.random() * (max - min + 1)) + min; | |||
| } | |||
| if(this.y > p.y + this.speed) | |||
| this.y -= this.speed; | |||
| else if(this.y + this.speed < p.y ) | |||
| this.y += this.speed; | |||
| } | |||
| //zombie | |||
| var Zombie = function(x,y) | |||
| { | |||
| this.x = x; | |||
| this.y = y; | |||
| this.width = 25; | |||
| this.height = 25; | |||
| this.speed = 3; | |||
| var side = getRandomIntInclusive(0,3); | |||
| var mid = getRandomIntInclusive(0,700); | |||
| if(side === 1) | |||
| { | |||
| this.x = mid; | |||
| this.y = 0; | |||
| } | |||
| else if(side === 2) | |||
| { | |||
| this.x = 700; | |||
| this.y = mid; | |||
| } | |||
| else if(side === 3) | |||
| { | |||
| this.y = 700; | |||
| this.x = mid; | |||
| } | |||
| else | |||
| { | |||
| this.x = 0; | |||
| this.y = mid; | |||
| } | |||
| var zombies = []; | |||
| zombies.push(new Zombie()); | |||
| this.render = function() | |||
| { | |||
| context.fillStyle = "rgba(0, 160, 0, 1)"; //green | |||
| context.fillRect(this.x, this.y, this.width,this.height); | |||
| } | |||
| var render = function() | |||
| this.move = function() | |||
| { | |||
| context.fillStyle = "#000000"; | |||
| context.fillRect(0, 0, width, height); | |||
| if(this.x > p.x + this.speed) | |||
| this.x -= this.speed; | |||
| else if(this.x + this.speed < p.x ) | |||
| this.x += this.speed; | |||
| context.fillStyle = "rgba(255, 255, 255, 1)"; | |||
| context.font= "20px Georgia"; | |||
| context.fillText("Score: " + score,10,25); | |||
| for(i = 0; i< zombies.length; i++) | |||
| { | |||
| if(zombies[i] != -1) | |||
| { | |||
| zombies[i].render(); | |||
| } | |||
| if(this.y > p.y + this.speed) | |||
| this.y -= this.speed; | |||
| else if(this.y + this.speed < p.y ) | |||
| this.y += this.speed; | |||
| } | |||
| } | |||
| var zombies = []; | |||
| zombies.push(new Zombie()); | |||
| } | |||
| for(i = 0; i< bullets.length; i++) | |||
| var render = function() | |||
| { | |||
| context.fillStyle = "#000000"; | |||
| context.fillRect(0, 0, width, height); | |||
| context.fillStyle = "rgba(255, 255, 255, 1)"; | |||
| context.font= "20px Georgia"; | |||
| context.fillText("Score: " + score,10,25); | |||
| for(i = 0; i< zombies.length; i++) | |||
| { | |||
| if(zombies[i] != -1) | |||
| { | |||
| if(bullets[i] != -1) | |||
| { | |||
| bullets[i].render(); | |||
| } | |||
| zombies[i].render(); | |||
| } | |||
| } | |||
| for(i = 0; i< bullets.length; i++) | |||
| { | |||
| if(bullets[i] != -1) | |||
| { | |||
| bullets[i].render(); | |||
| } | |||
| p.render(); | |||
| } | |||
| var update = function() | |||
| p.render(); | |||
| } | |||
| var update = function() | |||
| { | |||
| addZombie(); | |||
| p.move(); | |||
| for(i = 0; i< zombies.length; i++) | |||
| { | |||
| addZombie(); | |||
| p.move(); | |||
| for(i = 0; i< zombies.length; i++) | |||
| for(z = 0;z < bullets.length; z++) | |||
| { | |||
| for(z = 0;z < bullets.length; z++) | |||
| if(zombies[i] != -1 && bullets[z] != -1) | |||
| { | |||
| if(zombies[i] != -1 && bullets[z] != -1) | |||
| if(Math.abs(zombies[i].x - bullets[z].x) < 25 && | |||
| Math.abs(zombies[i].y - bullets[z].y) < 25) | |||
| { | |||
| if(Math.abs(zombies[i].x - bullets[z].x) < 25 && Math.abs(zombies[i].y - bullets[z].y) < 25) | |||
| { | |||
| score++; | |||
| zombies[i] = -1; | |||
| bullets[z] = -1; | |||
| } | |||
| score++; | |||
| zombies[i] = -1; | |||
| bullets[z] = -1; | |||
| } | |||
| } | |||
| if(zombies[i] != -1) | |||
| { | |||
| zombies[i].move(); | |||
| } | |||
| } | |||
| for(i = 0; i< bullets.length; i++) | |||
| if(zombies[i] != -1) | |||
| { | |||
| //checks to see if goes out of bounds | |||
| if(bullets[i].x < 0 || bullets[i].y < 0 || bullets[i].x > 700 || bullets[i].y > 700) | |||
| { | |||
| bullets[i] = -1; | |||
| } | |||
| zombies[i].move(); | |||
| } | |||
| if(bullets[i] != -1) | |||
| { | |||
| } | |||
| for(i = 0; i< bullets.length; i++) | |||
| { | |||
| //checks to see if goes out of bounds | |||
| if(bullets[i].x < 0 || bullets[i].y < 0 || | |||
| bullets[i].x > 700 || bullets[i].y > 700) | |||
| { | |||
| bullets[i] = -1; | |||
| } | |||
| bullets[i].move(); | |||
| } | |||
| if(bullets[i] != -1) | |||
| { | |||
| bullets[i].move(); | |||
| } | |||
| for(i=0; i<zombies.length; i++) | |||
| } | |||
| for(i=0; i<zombies.length; i++) | |||
| { | |||
| if(zombies[i] != -1 && | |||
| Math.abs(p.x - zombies[i].x) < 25 && | |||
| Math.abs(p.y - zombies[i].y) < 25) | |||
| { | |||
| if(zombies[i] != -1 && Math.abs(p.x - zombies[i].x) < 25 && Math.abs(p.y - zombies[i].y) < 25) | |||
| { | |||
| dead = true; | |||
| } | |||
| dead = true; | |||
| } | |||
| } | |||
| var counter2 = 0; | |||
| var counter = 0; | |||
| var rate = 180; | |||
| var addZombie = function() | |||
| } | |||
| var counter2 = 0; | |||
| var counter = 0; | |||
| var rate = 180; | |||
| var addZombie = function() | |||
| { | |||
| counter2++; | |||
| counter++; | |||
| var added = false; | |||
| if(counter >= rate) | |||
| { | |||
| counter2++; | |||
| counter++; | |||
| var added = false; | |||
| if(counter >= rate) | |||
| for(i = 0; i< zombies.length; i++) | |||
| { | |||
| for(i = 0; i< zombies.length; i++) | |||
| if(zombies[i] == -1) | |||
| { | |||
| if(zombies[i] == -1) | |||
| { | |||
| zombies[i] = new Zombie(); | |||
| added = true; | |||
| break; | |||
| } | |||
| zombies[i] = new Zombie(); | |||
| added = true; | |||
| break; | |||
| } | |||
| if(added == false) | |||
| { | |||
| zombies.push(new Zombie()); | |||
| } | |||
| } | |||
| counter = 0; | |||
| if(added == false) | |||
| { | |||
| zombies.push(new Zombie()); | |||
| } | |||
| if(counter2 >= 60) | |||
| counter = 0; | |||
| } | |||
| if(counter2 >= 60) | |||
| { | |||
| if(rate > 30) | |||
| { | |||
| if(rate > 30) | |||
| { | |||
| rate = rate -5; | |||
| } | |||
| counter2 = 0; | |||
| rate = rate -5; | |||
| } | |||
| counter2 = 0; | |||
| } | |||
| } | |||
| var sent = false; | |||
| var sent = false; | |||
| var tic = function() | |||
| var tic = function() | |||
| { | |||
| if(dead) | |||
| { | |||
| if(dead) | |||
| { | |||
| context.fillStyle = "#000000"; | |||
| context.fillRect(0, 0, width, height); | |||
| context.fillStyle = "#000000"; | |||
| context.fillRect(0, 0, width, height); | |||
| context.fillStyle = "rgba(255, 255, 255, 1)"; //green | |||
| context.font= "20px Georgia"; | |||
| context.fillText("You died with a score of " + score,200,340); | |||
| if(!sent) | |||
| { | |||
| document.body.innerHTML += '<form id="dynForm" action="insertScore.php" method="post"><input type="hidden" name="game_new_score" value=true><input type="hidden" name="game" value=2><input type="hidden" name="user_id_score" value=<?php echo $_SESSION['user_id']; ?>><input type="hidden" name="score_validate" value=' + score + '></form>'; | |||
| document.getElementById("dynForm").submit(); | |||
| sent = !sent; | |||
| } | |||
| context.fillStyle = "rgba(255, 255, 255, 1)"; //green | |||
| context.font= "20px Georgia"; | |||
| context.fillText("You died with a score of " + score,200,340); | |||
| } | |||
| else | |||
| if(!sent) | |||
| { | |||
| update(); | |||
| render() | |||
| document.body.innerHTML += '<form id="dynForm" ' + | |||
| 'action="insertScore.php" method="post">' + | |||
| '<input type="hidden" name="game_new_score" ' + | |||
| 'value=true><input type="hidden" name="game" value=2>' + | |||
| '<input type="hidden" name="user_id_score" value=' + | |||
| '<?php echo $_SESSION['user_id']; ?>><input ' + | |||
| 'type="hidden" name="score_validate" value=' + score + '>' + | |||
| '</form>'; | |||
| document.getElementById("dynForm").submit(); | |||
| sent = !sent; | |||
| } | |||
| animate(tic); | |||
| } | |||
| window.addEventListener("keydown", function (event) | |||
| } | |||
| else | |||
| { | |||
| if(event.keyCode >=37 && event.keyCode <=40) | |||
| { | |||
| p.facing = event.keyCode; | |||
| } | |||
| keysDown[event.keyCode] = true; | |||
| }); | |||
| update(); | |||
| render() | |||
| } | |||
| window.addEventListener("keyup", function (event) | |||
| { | |||
| delete keysDown[event.keyCode]; | |||
| }); | |||
| animate(tic); | |||
| } | |||
| window.addEventListener("keydown", function (event) | |||
| { | |||
| if(event.keyCode >=37 && event.keyCode <=40) | |||
| { | |||
| p.facing = event.keyCode; | |||
| } | |||
| keysDown[event.keyCode] = true; | |||
| }); | |||
| </script> | |||
| window.addEventListener("keyup", function (event) | |||
| { | |||
| delete keysDown[event.keyCode]; | |||
| }); | |||
| animate(tic); | |||
| } | |||
| </script> | |||
| <div><canvas id="canvasZP" width="700" height="700"></canvas></div> | |||
| <div><input type="submit" name="play" value="Play Game" onclick="this.blur();playZP()"/></div> | |||
| <div><input type="submit" name="play" value="Play Game" onclick=" | |||
| this.blur();playZP()"/></div> | |||
| @ -1,37 +1,33 @@ | |||
| <?php | |||
| $dir = 2; | |||
| $game_id = 2; | |||
| $dir = 2; | |||
| //ini_set('display_errors', 1); | |||
| include '../includes/header.php'; | |||
| $game_id = 2; | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| include('zombiePanda.html'); | |||
| //ini_set('display_errors', 1); | |||
| include '../includes/header.php'; | |||
| echo '</div><div class="w3-half w3-container">'; | |||
| //include('../includes/profile.php'); | |||
| include('highscore.php'); | |||
| echo '</div></div>'; | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| include('zombiePanda.html'); | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| //edit user | |||
| include('../user/profile.php'); | |||
| echo '</div><div class="w3-half w3-container">'; | |||
| //include('../includes/profile.php'); | |||
| include('highscore.php'); | |||
| echo '</div></div>'; | |||
| echo '</div><div class="w3-half w3-container">'; | |||
| include('userscores.php'); | |||
| echo '</div></div>'; | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| //edit user | |||
| include('../user/profile.php'); | |||
| include '../includes/footer.php'; | |||
| ?> | |||
| echo '</div><div class="w3-half w3-container">'; | |||
| include('userscores.php'); | |||
| echo '</div></div>'; | |||
| include '../includes/footer.php'; | |||
| @ -1,53 +1,54 @@ | |||
| <?php | |||
| //ini_set('display_errors', 1); | |||
| include 'includes/header.php'; | |||
| if($loggedIn) | |||
| { | |||
| //profile | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| //new game or something | |||
| //include 'games/bamboofield.html'; | |||
| echo '</div><div class="w3-half w3-container">'; | |||
| //profile | |||
| include('user/profile.php'); | |||
| echo '</div>'; | |||
| } | |||
| else | |||
| { | |||
| //profile(login) & register | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| //register | |||
| include('user/register.php'); | |||
| echo '</div><div class="w3-half w3-container">'; | |||
| //profile | |||
| include('user/profile.php'); | |||
| echo '</div>'; | |||
| } | |||
| //4-row | |||
| echo '<br><div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-half w3-container"><div style=\'position: relative; width: 100%; height: 0px; padding-bottom: 60%;\'">'; | |||
| echo '<iframe src="https://www.youtube.com/embed/QhJYKBj3K08" frameborder="0" allowfullscreen style=\'position: absolute; left: 0px; top: 0px; width: 100%; height: 100%\'"></iframe>'; | |||
| echo '</div></div>'; | |||
| echo '<div class="w3-half w3-container"><div id="repo1">'; | |||
| echo '<script src="RepoJS/repo.js"></script> | |||
| <script> | |||
| $(\'#repo1\').repo({ user: \'jrtechs\', name: \'Panda-Quotes\' }); | |||
| </script>'; | |||
| echo '</div></div></div>'; | |||
| include 'includes/footer.php'; | |||
| ?> | |||
| //ini_set('display_errors', 1); | |||
| include 'includes/header.php'; | |||
| if($loggedIn) | |||
| { | |||
| //profile | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| //new game or something | |||
| //include 'games/bamboofield.html'; | |||
| echo '</div><div class="w3-half w3-container">'; | |||
| //profile | |||
| include('user/profile.php'); | |||
| echo '</div>'; | |||
| } | |||
| else | |||
| { | |||
| //profile(login) & register | |||
| echo '<div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-half w3-container">'; | |||
| //register | |||
| include('user/register.php'); | |||
| echo '</div><div class="w3-half w3-container">'; | |||
| //profile | |||
| include('user/profile.php'); | |||
| echo '</div>'; | |||
| } | |||
| //4-row | |||
| echo '<br><div class="w3-row w3-padding-32">'; | |||
| echo '<div class="w3-half w3-container"><div style=\'position: relative; | |||
| width: 100%; height: 0px; padding-bottom: 60%;\'">'; | |||
| echo '<iframe src="https://www.youtube.com/embed/QhJYKBj3K08" frameborder="0" | |||
| allowfullscreen style=\'position: absolute; left: 0px; top: 0px; | |||
| width: 100%; height: 100%\'"></iframe>'; | |||
| echo '</div></div>'; | |||
| echo '<div class="w3-half w3-container"><div id="repo1">'; | |||
| echo '<script src="RepoJS/repo.js"></script> | |||
| <script> | |||
| $(\'#repo1\').repo({ user: \'jrtechs\', name: \'Panda-Quotes\' }); | |||
| </script>'; | |||
| echo '</div></div></div>'; | |||
| include 'includes/footer.php'; | |||
| @ -1,102 +1,110 @@ | |||
| <?php | |||
| if($admin) | |||
| if($admin) | |||
| { | |||
| $errors = array(); | |||
| if(isset($_POST['edit_user'])) | |||
| { | |||
| $errors = array(); | |||
| if(isset($_POST['edit_user'])) | |||
| { | |||
| $i_username = mysqli_real_escape_string($dbc, trim($_POST['edit_user_username'])); | |||
| $i_first = mysqli_real_escape_string($dbc, trim($_POST['edit_user_first'])); | |||
| $i_last = mysqli_real_escape_string($dbc, trim($_POST['edit_user_last'])); | |||
| $i_password = mysqli_real_escape_string($dbc, trim($_POST['edit_user_pass'])); | |||
| $i_admin = mysqli_real_escape_string($dbc, trim($_POST['edit_user_admin'])); | |||
| $passcom = $i_password . $i_first; | |||
| $passcom = SHA1($passcom); | |||
| if($i_admin) | |||
| { | |||
| $admin_temp = "true"; | |||
| } | |||
| else | |||
| { | |||
| $admin_temp = "false"; | |||
| } | |||
| $q = "select user_id from users where user_name ='$i_username'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| $q = "update users set first_name ='$i_first' where user_id='" . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q); | |||
| $q = "update users set last_name ='$i_last' where user_id='" . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q); | |||
| $q = "update users set pass ='$passcom' where user_id='" . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q); | |||
| //echo $q; | |||
| $q = "update users set admin =$admin_temp where user_id='" . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q); | |||
| //echo $q; | |||
| } | |||
| header("Location: admin.php"); | |||
| } | |||
| echo '<h1 class="w3-text-teal"><center>Edit User</center></h1>'; | |||
| echo '<form action="admin.php" method ="post" class="w3-container w3-card-4">'; | |||
| $q = "select user_name from users"; | |||
| $i_username = mysqli_real_escape_string($dbc, | |||
| trim($_POST['edit_user_username'])); | |||
| $i_first = mysqli_real_escape_string($dbc, | |||
| trim($_POST['edit_user_first'])); | |||
| $i_last = mysqli_real_escape_string($dbc, | |||
| trim($_POST['edit_user_last'])); | |||
| $i_password = mysqli_real_escape_string($dbc, | |||
| trim($_POST['edit_user_pass'])); | |||
| $i_admin = mysqli_real_escape_string($dbc, | |||
| trim($_POST['edit_user_admin'])); | |||
| $passcom = $i_password . $i_first; | |||
| $passcom = SHA1($passcom); | |||
| if($i_admin) | |||
| $admin_temp = "true"; | |||
| else | |||
| $admin_temp = "false"; | |||
| $q = "select user_id from users where user_name ='$i_username'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<select class="w3-select" name ="edit_user_username">'; | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<option value="' . $row['user_name'] . '">'; | |||
| echo $row['user_name'] . '</option>'; | |||
| } | |||
| echo '</select>'; | |||
| echo '<div class="w3-group"> | |||
| <input class="w3-input" type="text" name="edit_user_first" required> | |||
| <label class="w3-label w3-validate">First Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="edit_user_last" required> | |||
| <label class="w3-label w3-validate">Last Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="password" name="edit_user_pass" maxlength="20" required> | |||
| <label class="w3-label w3-validate">Password</label> | |||
| </div> | |||
| <input class="w3-check" type="checkbox" name="edit_user_admin"> | |||
| <label class="w3-validate">Admin<label> | |||
| <p><input type="submit" name="Submit" value="Edit User" class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" /></p> | |||
| <input type="hidden" name="edit_user" value="TRUE" /> | |||
| </form>'; | |||
| foreach($errors as $msg) | |||
| { | |||
| echo " - $msg<br />"; | |||
| $q = "update users set first_name ='$i_first' where user_id='" | |||
| . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q); | |||
| $q = "update users set last_name ='$i_last' where user_id='" | |||
| . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q); | |||
| $q = "update users set pass ='$passcom' where user_id='" | |||
| . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q); | |||
| //echo $q; | |||
| $q = "update users set admin =$admin_temp where user_id='" | |||
| . $row['user_id'] . "'"; | |||
| $r2 = mysqli_query($dbc, $q); | |||
| //echo $q; | |||
| } | |||
| header("Location: admin.php"); | |||
| } | |||
| ?> | |||
| echo '<h1 class="w3-text-teal"><center>Edit User</center></h1>'; | |||
| echo '<form action="admin.php" method ="post" | |||
| class="w3-container w3-card-4">'; | |||
| $q = "select user_name from users"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<select class="w3-select" name ="edit_user_username">'; | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<option value="' . $row['user_name'] . '">'; | |||
| echo $row['user_name'] . '</option>'; | |||
| } | |||
| echo '</select>'; | |||
| echo '<div class="w3-group"> | |||
| <input class="w3-input" type="text" | |||
| name="edit_user_first" required> | |||
| <label class="w3-label w3-validate">First Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" | |||
| name="edit_user_last" required> | |||
| <label class="w3-label w3-validate">Last Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="password" name="edit_user_pass" | |||
| maxlength="20" required> | |||
| <label class="w3-label w3-validate">Password</label> | |||
| </div> | |||
| <input class="w3-check" type="checkbox" name="edit_user_admin"> | |||
| <label class="w3-validate">Admin<label> | |||
| <p><input type="submit" name="Submit" value="Edit User" | |||
| class="w3-padding-16 w3-hover-dark-grey w3-btn-block | |||
| w3-center-align" /></p> | |||
| <input type="hidden" name="edit_user" value="TRUE" /> | |||
| </form>'; | |||
| foreach($errors as $msg) | |||
| echo " - $msg<br />"; | |||
| } | |||
| @ -1,93 +1,94 @@ | |||
| <?php | |||
| if($admin) | |||
| if($admin) | |||
| { | |||
| $errors = array(); | |||
| if(isset($_POST['newUser'])) | |||
| { | |||
| $errors = array(); | |||
| if(isset($_POST['newUser'])) | |||
| // echo '**********'; | |||
| $i_first = mysqli_real_escape_string($dbc, trim($_POST['first'])); | |||
| $i_last = mysqli_real_escape_string($dbc, trim($_POST['last'])); | |||
| $i_pass = mysqli_real_escape_string($dbc, trim($_POST['pass'])); | |||
| $i_user = mysqli_real_escape_string($dbc, trim($_POST['user_name'])); | |||
| if($i_first && $i_last && $i_pass && $i_user) | |||
| { | |||
| // echo '**********'; | |||
| $i_first = mysqli_real_escape_string($dbc, trim($_POST['first'])); | |||
| $i_last = mysqli_real_escape_string($dbc, trim($_POST['last'])); | |||
| $i_pass = mysqli_real_escape_string($dbc, trim($_POST['pass'])); | |||
| $i_user = mysqli_real_escape_string($dbc, trim($_POST['user_name'])); | |||
| if($i_first && $i_last && $i_pass && $i_user) | |||
| $q = "select user_id from users where user_name='$i_user'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| if(@mysqli_num_rows($r) == 1) | |||
| { | |||
| $q = "select user_id from users where user_name='$i_user'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| if(@mysqli_num_rows($r) == 1) | |||
| { | |||
| $errors['name'] = "That user name is already in use."; | |||
| } | |||
| $errors['name'] = "That user name is already in use."; | |||
| } | |||
| else | |||
| } | |||
| else | |||
| { | |||
| $errors['input'] = "Please fill in all fields!"; | |||
| } | |||
| if(empty($errors)) | |||
| { | |||
| $passcom = $i_pass . $i_first; | |||
| $passcom = SHA1($passcom); | |||
| if(isset($_POST['admin'])) | |||
| { | |||
| $errors['input'] = "Please fill in all fields!"; | |||
| $adminn = "true"; | |||
| } | |||
| if(empty($errors)) | |||
| else | |||
| { | |||
| $passcom = $i_pass . $i_first; | |||
| $passcom = SHA1($passcom); | |||
| if(isset($_POST['admin'])) | |||
| { | |||
| $adminn = "true"; | |||
| } | |||
| else | |||
| { | |||
| $adminn = "false"; | |||
| } | |||
| $q = "insert into users(first_name, last_name, user_name, pass, registration_date, admin) values ('$i_first', '$i_last' , '$i_user', '$passcom', now(), $adminn)"; | |||
| //echo $q; | |||
| $r = mysqli_query($dbc, $q); | |||
| header("Location: admin.php"); | |||
| $adminn = "false"; | |||
| } | |||
| $q = "insert into users(first_name, last_name, user_name, | |||
| pass, registration_date, admin) values | |||
| ('$i_first', '$i_last' , '$i_user', '$passcom', | |||
| now(), $adminn)"; | |||
| //echo $q; | |||
| $r = mysqli_query($dbc, $q); | |||
| header("Location: admin.php"); | |||
| } | |||
| } | |||
| echo '<h1 class="w3-text-teal"><center>Add User</center></h1>'; | |||
| echo '<form action="admin.php" method ="post" | |||
| class="w3-container w3-card-4"> | |||
| echo '<h1 class="w3-text-teal"><center>Add User</center></h1>'; | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="user_name" required> | |||
| <label class="w3-label w3-validate">User Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="first" required> | |||
| <label class="w3-label w3-validate">First Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="last" required> | |||
| <label class="w3-label w3-validate">Last Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="password" name="pass" | |||
| maxlength="20" required> | |||
| <label class="w3-label w3-validate">Password</label> | |||
| </div> | |||
| echo '<form action="admin.php" method ="post" class="w3-container w3-card-4"> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="user_name" required> | |||
| <label class="w3-label w3-validate">User Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="first" required> | |||
| <label class="w3-label w3-validate">First Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="last" required> | |||
| <label class="w3-label w3-validate">Last Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="password" name="pass" maxlength="20" required> | |||
| <label class="w3-label w3-validate">Password</label> | |||
| </div> | |||
| <input class="w3-check" type="checkbox" name="admin"> | |||
| <label class="w3-validate">Admin<label> | |||
| <p><input type="submit" name="Submit" value="Add User" class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" /></p> | |||
| <input type="hidden" name="newUser" value="TRUE" /> | |||
| <input class="w3-check" type="checkbox" name="admin"> | |||
| <label class="w3-validate">Admin<label> | |||
| </form>'; | |||
| <p><input type="submit" name="Submit" value="Add User" | |||
| class="w3-padding-16 w3-hover-dark-grey w3-btn-block | |||
| w3-center-align" /></p> | |||
| <input type="hidden" name="newUser" value="TRUE" /> | |||
| foreach($errors as $msg) | |||
| { | |||
| echo " - $msg<br />"; | |||
| } | |||
| } | |||
| ?> | |||
| </form>'; | |||
| foreach($errors as $msg) | |||
| echo " - $msg<br />"; | |||
| } | |||
| @ -1,180 +1,151 @@ | |||
| <?php | |||
| $errors = array(); | |||
| if(isset($_POST['logout'])) | |||
| { | |||
| $_SESSION = array(); | |||
| echo '<h3>You are now logged out</h3>'; | |||
| if($dir == 2) | |||
| { | |||
| header("Location: ../index.php"); | |||
| } | |||
| else | |||
| { | |||
| header("Location: index.php"); | |||
| } | |||
| } | |||
| $errors = array(); | |||
| if(isset($_POST['logout'])) | |||
| { | |||
| $_SESSION = array(); | |||
| echo '<h3>You are now logged out</h3>'; | |||
| if(isset($_POST['log_in'])) | |||
| if($dir == 2) | |||
| header("Location: ../index.php"); | |||
| else | |||
| header("Location: index.php"); | |||
| } | |||
| if(isset($_POST['log_in'])) | |||
| { | |||
| //echo 'Login procces'; | |||
| if(isset($_POST['user_name'])) | |||
| $i_username = @mysqli_real_escape_string($dbc, | |||
| trim($_POST['user_name'])); | |||
| else | |||
| $errors['User Name'] = 'You need to enter a user name!'; | |||
| if(isset($_POST['password'])) | |||
| $i_password = @mysqli_real_escape_string($dbc, | |||
| trim($_POST['password'])); | |||
| else | |||
| $errors['password'] = "You need to enter a password!"; | |||
| if($i_password && $i_username) | |||
| { | |||
| //echo 'Login procces'; | |||
| if(isset($_POST['user_name'])) | |||
| { | |||
| $i_username = @mysqli_real_escape_string($dbc, trim($_POST['user_name'])); | |||
| } | |||
| else | |||
| { | |||
| $errors['User Name'] = 'You need to enter a user name!'; | |||
| } | |||
| if(isset($_POST['password'])) | |||
| { | |||
| $i_password = @mysqli_real_escape_string($dbc, trim($_POST['password'])); | |||
| } | |||
| else | |||
| { | |||
| $errors['password'] = "You need to enter a password!"; | |||
| } | |||
| if($i_password && $i_username) | |||
| //valid username | |||
| $q3 = "select * from users where user_name='$i_username'"; | |||
| //echo $q3; | |||
| $r3 = mysqli_query($dbc, $q3); | |||
| if(@mysqli_num_rows($r3) == 1) | |||
| { | |||
| //valid username | |||
| $q3 = "select * from users where user_name='$i_username'"; | |||
| //echo $q3; | |||
| $r3 = mysqli_query($dbc, $q3); | |||
| if(@mysqli_num_rows($r3) == 1) | |||
| //echo 'das good'; | |||
| $firstName = ""; | |||
| while($row = mysqli_fetch_array($r3)) | |||
| $firstName = $row['first_name']; | |||
| $q2 = "select * from users where user_name = | |||
| '$i_username' and pass ='" . SHA1($i_password | |||
| . $firstName) . "'"; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| if(@mysqli_num_rows($r2) == 1) | |||
| { | |||
| //echo 'das good'; | |||
| $firstName = ""; | |||
| while($row = mysqli_fetch_array($r3)) | |||
| while($row = mysqli_fetch_array($r2)) | |||
| { | |||
| $firstName = $row['first_name']; | |||
| } | |||
| $q2 = "select * from users where user_name = '$i_username' and pass ='" . SHA1($i_password . $firstName) . "'"; | |||
| //echo $q2; | |||
| $r2 = mysqli_query($dbc, $q2); | |||
| //30 minutes of error seaching to realize if frogot the s in mysqli | |||
| if(@mysqli_num_rows($r2) == 1) | |||
| { | |||
| while($row = mysqli_fetch_array($r2)) | |||
| { | |||
| $_SESSION['use'] = true; | |||
| $_SESSION['fname'] = $firstName; | |||
| $_SESSION['user_id'] = $row['user_id']; | |||
| $_SESSION['username'] = $row['user_name']; | |||
| $_SESSION['agent'] = md5($_SERVER['HTTP_USERAGENT'] . 'salt'); | |||
| if($dir == 2) | |||
| { | |||
| header("Location: ../index.php"); | |||
| } | |||
| else | |||
| { | |||
| header("Location: index.php"); | |||
| } | |||
| } | |||
| } | |||
| else | |||
| { | |||
| $errors['password'] = "You entered an invalid password"; | |||
| $_SESSION['use'] = true; | |||
| $_SESSION['fname'] = $firstName; | |||
| $_SESSION['user_id'] = $row['user_id']; | |||
| $_SESSION['username'] = $row['user_name']; | |||
| $_SESSION['agent'] = md5($_SERVER['HTTP_USERAGENT'] | |||
| . 'salt'); | |||
| if($dir == 2) | |||
| header("Location: ../index.php"); | |||
| else | |||
| header("Location: index.php"); | |||
| } | |||
| } | |||
| else | |||
| { | |||
| $errors['user'] = "You entered an invalid user name!"; | |||
| $errors['password'] = "You entered an invalid password"; | |||
| } | |||
| } | |||
| else | |||
| { | |||
| $errors['user'] = "You entered an invalid user name!"; | |||
| } | |||
| } | |||
| echo '<h1 class="w3-text-teal">'; | |||
| echo '<center>'; | |||
| if($loggedIn) | |||
| } | |||
| echo '<h1 class="w3-text-teal">'; | |||
| echo '<center>'; | |||
| if($loggedIn) | |||
| echo 'Profile'; | |||
| else | |||
| echo 'Log In'; | |||
| echo '</center></h1>'; | |||
| echo '<div class ="w3-card-4 w3-container w3-padding-16">'; | |||
| if($loggedIn) | |||
| { | |||
| echo '<h3 class="w3-center">Welcome ' . $_SESSION['fname'] . '</h3>'; | |||
| if($dir == 2) | |||
| { | |||
| echo 'Profile'; | |||
| echo '<form action="../index.php" method ="post"> | |||
| <input class="w3-padding-16 w3-hover-dark-grey | |||
| w3-btn-block w3-center-align" type="submit" name ="logout" | |||
| value="logout" /> | |||
| <input type="hidden" name="logout" value="TRUE" /> | |||
| </form>'; | |||
| } | |||
| else | |||
| { | |||
| echo 'Log In'; | |||
| echo '<form action="index.php" method ="post"> | |||
| <input class="w3-padding-16 w3-hover-dark-grey w3-btn-block | |||
| w3-center-align" type="submit" name ="logout" value="logout" /> | |||
| <input type="hidden" name="logout" value="TRUE" /> | |||
| </form>'; | |||
| } | |||
| echo '</center></h1>'; | |||
| echo '<div class ="w3-card-4 w3-container w3-padding-16">'; | |||
| if($loggedIn) | |||
| { | |||
| echo '<h3 class="w3-center">Welcome ' . $_SESSION['fname'] . '</h3>'; | |||
| if($dir == 2) | |||
| { | |||
| echo '<form action="../index.php" method ="post"> | |||
| <input class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" type="submit" name ="logout" value="logout" /> | |||
| <input type="hidden" name="logout" value="TRUE" /> | |||
| </form>'; | |||
| } | |||
| else | |||
| { | |||
| echo '<form action="index.php" method ="post"> | |||
| <input class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" type="submit" name ="logout" value="logout" /> | |||
| <input type="hidden" name="logout" value="TRUE" /> | |||
| </form>'; | |||
| } | |||
| } | |||
| else | |||
| { | |||
| if($dir == 2) | |||
| echo '<form action ="../index.php" method ="post">'; | |||
| else | |||
| echo '<form action ="index.php" method ="post">'; | |||
| echo ' | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" value="" name="user_name" | |||
| class="w3-container w3-card-4" required/> | |||
| <label class="w3-label w3-validate">User Name</label> | |||
| </div> | |||
| } | |||
| else | |||
| { | |||
| //prints login form | |||
| if($dir == 2) | |||
| { | |||
| echo '<form action ="../index.php" method ="post">'; | |||
| } | |||
| else | |||
| { | |||
| echo '<form action ="index.php" method ="post">'; | |||
| } | |||
| echo ' | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" value="" name="user_name" class="w3-container w3-card-4" required/> | |||
| <label class="w3-label w3-validate">User Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="password" value="" name="password" class="w3-container w3-card-4" required/> | |||
| <label class="w3-label w3-validate">Password</label> | |||
| </div> | |||
| <input type="submit" name="login" value="login" class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align"/> | |||
| <input type="hidden" name="log_in" value="TRUE"/> | |||
| </form>'; | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="password" value="" name="password" | |||
| class="w3-container w3-card-4" required/> | |||
| <label class="w3-label w3-validate">Password</label> | |||
| </div> | |||
| } | |||
| foreach($errors as $msg) | |||
| { | |||
| echo " - $msg<br />"; | |||
| } | |||
| echo '</div>'; | |||
| <input type="submit" name="login" value="login" | |||
| class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align"/> | |||
| <input type="hidden" name="log_in" value="TRUE"/> | |||
| </form>'; | |||
| } | |||
| foreach($errors as $msg) | |||
| echo " - $msg<br />"; | |||
| ?> | |||
| echo '</div>'; | |||
| @ -1,91 +1,90 @@ | |||
| <?php | |||
| if(!$loggedIn) | |||
| if(!$loggedIn) | |||
| { | |||
| $errors = array(); | |||
| if(isset($_POST['newUser'])) | |||
| { | |||
| $errors = array(); | |||
| if(isset($_POST['newUser'])) | |||
| $i_first = mysqli_real_escape_string($dbc, trim($_POST['first'])); | |||
| $i_last = mysqli_real_escape_string($dbc, trim($_POST['last'])); | |||
| $i_pass = mysqli_real_escape_string($dbc, trim($_POST['pass'])); | |||
| $i_user = mysqli_real_escape_string($dbc, trim($_POST['user_name'])); | |||
| if($i_first && $i_last && $i_pass && $i_user) | |||
| { | |||
| $q = "select user_id from users where user_name='$i_user'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| $i_first = mysqli_real_escape_string($dbc, trim($_POST['first'])); | |||
| $i_last = mysqli_real_escape_string($dbc, trim($_POST['last'])); | |||
| $i_pass = mysqli_real_escape_string($dbc, trim($_POST['pass'])); | |||
| $i_user = mysqli_real_escape_string($dbc, trim($_POST['user_name'])); | |||
| if($i_first && $i_last && $i_pass && $i_user) | |||
| if(@mysqli_num_rows($r) == 1) | |||
| { | |||
| $q = "select user_id from users where user_name='$i_user'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| if(@mysqli_num_rows($r) == 1) | |||
| { | |||
| $errors['name'] = "That user name is already in use."; | |||
| } | |||
| $errors['name'] = "That user name is already in use."; | |||
| } | |||
| else | |||
| } | |||
| else | |||
| { | |||
| $errors['input'] = "Please fill in all fields!"; | |||
| } | |||
| if(empty($errors)) | |||
| { | |||
| $passcom = $i_pass . $i_first; | |||
| $passcom = SHA1($passcom); | |||
| if(isset($_POST['admin'])) | |||
| { | |||
| $errors['input'] = "Please fill in all fields!"; | |||
| $adminn = "true"; | |||
| } | |||
| if(empty($errors)) | |||
| else | |||
| { | |||
| $passcom = $i_pass . $i_first; | |||
| $passcom = SHA1($passcom); | |||
| if(isset($_POST['admin'])) | |||
| { | |||
| $adminn = "true"; | |||
| } | |||
| else | |||
| { | |||
| $adminn = "false"; | |||
| } | |||
| $q = "insert into users(first_name, last_name, user_name, pass, registration_date, admin) values ('$i_first', '$i_last' , '$i_user', '$passcom', now(), false)"; | |||
| $r = mysqli_query($dbc, $q); | |||
| header("Location: index.php"); | |||
| $adminn = "false"; | |||
| } | |||
| $q = "insert into users(first_name, last_name, user_name, pass, | |||
| registration_date, admin) values ('$i_first', '$i_last' | |||
| , '$i_user', '$passcom', now(), false)"; | |||
| $r = mysqli_query($dbc, $q); | |||
| header("Location: index.php"); | |||
| } | |||
| } | |||
| echo '<h1 class="w3-text-teal"><center>Register</center></h1>'; | |||
| echo '<form action="index.php" method ="post" class="w3-container | |||
| w3-card-4"> | |||
| echo '<h1 class="w3-text-teal"><center>Register</center></h1>'; | |||
| echo '<form action="index.php" method ="post" class="w3-container w3-card-4"> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="user_name" required> | |||
| <label class="w3-label w3-validate">User Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="first" required> | |||
| <label class="w3-label w3-validate">First Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="last" required> | |||
| <label class="w3-label w3-validate">Last Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="password" name="pass" maxlength="20" required> | |||
| <label class="w3-label w3-validate">Password</label> | |||
| </div> | |||
| <p><input type="submit" name="Submit" value="Register" class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align" /></p> | |||
| <input type="hidden" name="newUser" value="TRUE" /> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="user_name" required> | |||
| <label class="w3-label w3-validate">User Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="first" required> | |||
| <label class="w3-label w3-validate">First Name</label> | |||
| </div> | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="text" name="last" required> | |||
| <label class="w3-label w3-validate">Last Name</label> | |||
| </div> | |||
| </form>'; | |||
| <div class="w3-group"> | |||
| <input class="w3-input" type="password" name="pass" | |||
| maxlength="20" required> | |||
| <label class="w3-label w3-validate">Password</label> | |||
| </div> | |||
| foreach($errors as $msg) | |||
| { | |||
| echo " - $msg<br />"; | |||
| } | |||
| } | |||
| ?> | |||
| <p><input type="submit" name="Submit" value="Register" | |||
| class="w3-padding-16 w3-hover-dark-grey w3-btn-block | |||
| w3-center-align" /></p> | |||
| <input type="hidden" name="newUser" value="TRUE" /> | |||
| </form>'; | |||
| foreach($errors as $msg) | |||
| echo " - $msg<br />"; | |||
| } | |||
| @ -1,71 +1,61 @@ | |||
| <?php | |||
| //11-24-16 | |||
| if($admin) | |||
| //11-24-16 | |||
| if($admin) | |||
| { | |||
| if(isset($_POST['delUser'])) | |||
| { | |||
| if(isset($_POST['delUser'])) | |||
| { | |||
| $i_id = mysqli_real_escape_string($dbc, trim($_POST['del_user_id'])); | |||
| $q = "delete from users where user_id='$i_id'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| header("Location: admin.php"); | |||
| } | |||
| echo '<h1 class="w3-text-teal"><center>Users</center></h1>'; | |||
| $q = "select * from users order by first_name asc"; | |||
| $i_id = mysqli_real_escape_string($dbc, trim($_POST['del_user_id'])); | |||
| $q = "delete from users where user_id='$i_id'"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<div class="w3-responsive w3-card-4"><table class="w3-table w3-striped w3-bordered"><thead>'; | |||
| echo '<tr class="w3-theme"> | |||
| <td>First Name</td> | |||
| <td>Last Name</td> | |||
| <td>User Name</td> | |||
| <td>Admin</td> | |||
| <td><center>Delete User<center></td> | |||
| </tr></thead><tbody>'; | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<tr>'; | |||
| //first name | |||
| echo '<td>' . $row['first_name'] . '</td>'; | |||
| //last name | |||
| echo '<td>' . $row['last_name'] . '</td>'; | |||
| //username | |||
| echo '<td>' . $row['user_name'] . '</td>'; | |||
| //admin | |||
| if($row['admin']) | |||
| { | |||
| echo '<td>True</td>'; | |||
| } | |||
| else | |||
| { | |||
| echo '<td>False</td>'; | |||
| } | |||
| //del | |||
| echo '<td>'; | |||
| echo '<form action = "admin.php" method = "post"> | |||
| <input type = "submit" name="Delete" value="Delete" class="w3-padding-16 w3-hover-dark-grey w3-btn-block w3-center-align"/> | |||
| <input type="hidden" name="delUser" value="TRUE"> | |||
| <input type="hidden" name="del_user_id" value=' . $row['user_id'] . '> | |||
| </form>'; | |||
| echo '</td>'; | |||
| echo '</tr>'; | |||
| } | |||
| echo '</tbody></table></div>'; | |||
| header("Location: admin.php"); | |||
| } | |||
| echo '<h1 class="w3-text-teal"><center>Users</center></h1>'; | |||
| $q = "select * from users order by first_name asc"; | |||
| $r = mysqli_query($dbc, $q); | |||
| echo '<div class="w3-responsive w3-card-4"><table | |||
| class="w3-table w3-striped w3-bordered"><thead>'; | |||
| echo '<tr class="w3-theme"> | |||
| <td>First Name</td> | |||
| <td>Last Name</td> | |||
| <td>User Name</td> | |||
| <td>Admin</td> | |||
| <td><center>Delete User<center></td> | |||
| </tr></thead><tbody>'; | |||
| while($row = mysqli_fetch_array($r)) | |||
| { | |||
| echo '<tr>'; | |||
| //first name | |||
| echo '<td>' . $row['first_name'] . '</td>'; | |||
| //last name | |||
| echo '<td>' . $row['last_name'] . '</td>'; | |||
| //username | |||
| echo '<td>' . $row['user_name'] . '</td>'; | |||
| //admin | |||
| if($row['admin']) | |||
| echo '<td>True</td>'; | |||
| else | |||
| echo '<td>False</td>'; | |||
| echo '<td><form action = "admin.php" method = "post"> | |||
| <input type = "submit" name="Delete" value="Delete" | |||
| class="w3-padding-16 w3-hover-dark-grey w3-btn-block | |||
| w3-center-align"/> | |||
| <input type="hidden" name="delUser" value="TRUE"> | |||
| <input type="hidden" name="del_user_id" value=' . $row['user_id'] | |||
| . '></form></td></td>'; | |||
| } | |||
| ?> | |||
| echo '</tbody></table></div>'; | |||
| } | |||