Added assignments for week 7
This commit is contained in:
1 parent
6be2ccd72f
commit
f23115bab6
5 files changed
+68
-16
No files matched your search
@@ -7,4 +7,9 @@ De virtuele machine werkt! Lees de opgave om te beginnen met hacken.
|
||||
<h2><a href="/webshop/">Webshop</a></h2>
|
||||
<a href="/webshop/product_detail_replace.php?id=1">Webshop (replace)</a>
|
||||
|
||||
<h2><a href="/nieuws/">Nieuws</a></h2>
|
||||
<h2><a href="/nieuws/">Nieuws</a></h2>
|
||||
<a href="/nieuws/users.php">Nieuws (users)</a><br>
|
||||
<a href="/nieuws/login.php">Nieuws (login)</a>
|
||||
|
||||
<hr>
|
||||
<footer>Laatste update: 19 maart 2014</footer>
|
||||
@@ -1,5 +1,5 @@
|
||||
var page = require('webpage').create();
|
||||
page.open('http://localhost/nieuws/', 'post', 'email=admin@nieuws.nl&password=sesame', function() {
|
||||
page.open('http://localhost/nieuws/', 'post', 'gebruikersnaam=Admin&wachtwoord=sesame', function() {
|
||||
setTimeout(function(){
|
||||
phantom.exit();
|
||||
}, 1000);
|
||||
|
||||
+9
-10
@@ -2,11 +2,6 @@
|
||||
header('X-XSS-Protection: 0');
|
||||
session_start();
|
||||
|
||||
// Check if admin logged in
|
||||
if(@$_POST['email'] == 'admin@nieuws.nl' && @$_POST['password'] == 'sesame') {
|
||||
$_SESSION['admin'] = true;
|
||||
}
|
||||
|
||||
$connection = new mysqli('localhost', 'nieuws', 'pass', 'nieuws')
|
||||
or die('Kan geen verbinding maken met MySQL');
|
||||
|
||||
@@ -38,12 +33,16 @@ if(isset($_POST['addcomment'])) {
|
||||
<div id="datum"><?php setlocale(LC_ALL, 'nl_NL'); echo strftime("%A %e %B %Y"); ?>. Het laatste nieuws het eerst op NIEUWS.nl</div>
|
||||
|
||||
<?php
|
||||
if(@$_SESSION['admin']) {
|
||||
|
||||
if(isset($_SESSION['gebruikersnaam']))
|
||||
echo '<div class="alert alert-info">Je bent nu ingelogd als '.$_SESSION['gebruikersnaam'].'</div>';
|
||||
|
||||
|
||||
if(isset($_SESSION['admin']))
|
||||
echo '<div class="alert alert-warning">Welkom terug administrator! De geheime code is: "Setec Astronomy".</div>';
|
||||
|
||||
?>
|
||||
<div class="alert alert-warning">
|
||||
Welkom terug administrator! De geheime code is: "Setec Astronomy".
|
||||
</div>
|
||||
<?php }?>
|
||||
|
||||
|
||||
<div id="category">Algemeen / Binnenland</div>
|
||||
|
||||
|
||||
+35
-4
@@ -1,4 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<?php
|
||||
if($_POST) {
|
||||
// Check if admin logged in
|
||||
$connection = new mysqli('localhost', 'nieuws', 'pass', 'nieuws')
|
||||
or die('Kan geen verbinding maken met MySQL');
|
||||
|
||||
$hash = sha1($_POST['wachtwoord'] . '31pEDJUu8bh0lUB9');
|
||||
|
||||
// Check password user, no SQL injection here people!
|
||||
$result = $connection->query("SELECT * FROM gebruikers WHERE gebruikersnaam = '".$connection->real_escape_string($_POST['gebruikersnaam'])."' AND wachtwoord = '".$connection->real_escape_string($hash)."'");
|
||||
|
||||
if($result->num_rows > 0) {
|
||||
session_start();
|
||||
unset($_SESSION['gebruikersnaam']);
|
||||
unset($_SESSION['admin']);
|
||||
|
||||
if($_POST['gebruikersnaam'] == 'Admin')
|
||||
$_SESSION['admin'] = true;
|
||||
|
||||
$_SESSION['gebruikersnaam'] = $_POST['gebruikersnaam'];
|
||||
|
||||
header('Location: /nieuws/index.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
?><!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
@@ -29,9 +55,14 @@
|
||||
<section id="middle">
|
||||
<div id="datum"><?php setlocale(LC_ALL, 'nl_NL'); echo strftime("%A %e %B %Y"); ?>. Het laatste nieuws het eerst op NIEUWS.nl</div>
|
||||
|
||||
<form method="POST" action="index.php" class="form-signin">
|
||||
<input name="email" class="input-block-level" placeholder="E-mail adres">
|
||||
<input name="password" type="pasword" class="input-block-level" placeholder="Wachtwoord">
|
||||
<form method="POST" class="form-signin">
|
||||
<?php
|
||||
if($_POST) {
|
||||
echo '<div class="alert alert-error">Ongeldige gebruikersnaam en wachtwoord</div>';
|
||||
}
|
||||
?>
|
||||
<input name="gebruikersnaam" class="input-block-level" placeholder="Gebruikersnaam">
|
||||
<input name="wachtwoord" type="pasword" class="input-block-level" placeholder="Wachtwoord">
|
||||
|
||||
<button type="submit" class="btn btn-primary">Inloggen</button>
|
||||
</form>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<table border="1">
|
||||
<tr>
|
||||
<th>Gebruikersnaam</th>
|
||||
<th>Wachtwoord</th>
|
||||
</tr>
|
||||
<?php
|
||||
$connection = new mysqli('localhost', 'nieuws', 'pass', 'nieuws')
|
||||
or die('Kan geen verbinding maken met MySQL');
|
||||
|
||||
$result = $connection->query("SELECT * FROM gebruikers");
|
||||
|
||||
while($row = $result->fetch_array()) {
|
||||
echo "<tr><td>{$row['gebruikersnaam']}</td><td>{$row['wachtwoord']}</td></tr>";
|
||||
}
|
||||
|
||||
?>
|
||||
</table>
|
||||
Reference in new issue
Block a user