diff --git a/index.php b/index.php index 3112317..c5f57e1 100644 --- a/index.php +++ b/index.php @@ -7,4 +7,9 @@ De virtuele machine werkt! Lees de opgave om te beginnen met hacken.

Webshop

Webshop (replace) -

Nieuws

\ No newline at end of file +

Nieuws

+Nieuws (users)
+Nieuws (login) + +
+ \ No newline at end of file diff --git a/nieuws/admincheck.js b/nieuws/admincheck.js index b864e96..c1ea2f6 100644 --- a/nieuws/admincheck.js +++ b/nieuws/admincheck.js @@ -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); diff --git a/nieuws/index.php b/nieuws/index.php index 2da3c91..e0c3bc4 100644 --- a/nieuws/index.php +++ b/nieuws/index.php @@ -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'])) {
. Het laatste nieuws het eerst op NIEUWS.nl
Je bent nu ingelogd als '.$_SESSION['gebruikersnaam'].''; + + +if(isset($_SESSION['admin'])) + echo '
Welkom terug administrator! De geheime code is: "Setec Astronomy".
'; + ?> -
- Welkom terug administrator! De geheime code is: "Setec Astronomy". -
- +
Algemeen / Binnenland
diff --git a/nieuws/login.php b/nieuws/login.php index 0d1ca56..8ac50b7 100644 --- a/nieuws/login.php +++ b/nieuws/login.php @@ -1,4 +1,30 @@ - +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; + } +} + +?> @@ -29,9 +55,14 @@
. Het laatste nieuws het eerst op NIEUWS.nl
-
- - + + Ongeldige gebruikersnaam en wachtwoord'; + } + ?> + +
diff --git a/nieuws/users.php b/nieuws/users.php new file mode 100644 index 0000000..fbb617b --- /dev/null +++ b/nieuws/users.php @@ -0,0 +1,17 @@ + + + + + +query("SELECT * FROM gebruikers"); + +while($row = $result->fetch_array()) { + echo ""; +} + +?> +
GebruikersnaamWachtwoord
{$row['gebruikersnaam']}{$row['wachtwoord']}
\ No newline at end of file