Merge branch 'dev' into 'master'
Merge current dev state into the master branch See merge request !2master
commit
ab8f1efa5d
@ -1,2 +1,3 @@
|
||||
/vendor/
|
||||
/logs/*
|
||||
/tmp/
|
||||
|
@ -0,0 +1,8 @@
|
||||
Om phpMyAdmin te gebruiken voor de database moet je het volgende doen:
|
||||
|
||||
Inloggen op http://cpanel.verictas.nl met:
|
||||
|
||||
gebruikersnaam: inforbank
|
||||
wachtwoord: inforban
|
||||
|
||||
Klik op phpMyAdmin onder "Databases".
|
Binary file not shown.
@ -1,10 +1,4 @@
|
||||
RewriteEngine On
|
||||
|
||||
# Some hosts may require you to use the `RewriteBase` directive.
|
||||
# If you need to use the `RewriteBase` directive, it should be the
|
||||
# absolute physical path to the directory that contains this htaccess file.
|
||||
#
|
||||
# RewriteBase /
|
||||
|
||||
RewriteEngine on
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [QSA,L]
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule ^(.*)$ index.php/$1 [NC,L,QSA]
|
||||
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Informatica Eindproject D4p
|
||||
* 6in3, Stedelijk Gymnasium Nijmegen
|
||||
* Docent: Hans de Wolf
|
||||
*
|
||||
* ==================
|
||||
*
|
||||
* Daniel Boutros,
|
||||
* Christiaan Goossens,
|
||||
* Jelmer Hinssen
|
||||
*/
|
||||
|
||||
namespace Inforbank;
|
||||
|
||||
class Application
|
||||
{
|
||||
public static $container;
|
||||
public static $app;
|
||||
|
||||
public static function set($app)
|
||||
{
|
||||
self::$app = $app;
|
||||
self::$container = $app->getContainer();
|
||||
}
|
||||
|
||||
public static function getContainer()
|
||||
{
|
||||
return self::$container;
|
||||
}
|
||||
|
||||
public static function getApplication()
|
||||
{
|
||||
return self::$app;
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Informatica Eindproject D4p
|
||||
* 6in3, Stedelijk Gymnasium Nijmegen
|
||||
* Docent: Hans de Wolf
|
||||
*
|
||||
* ==================
|
||||
*
|
||||
* Daniel Boutros,
|
||||
* Christiaan Goossens,
|
||||
* Jelmer Hinssen
|
||||
*/
|
||||
|
||||
namespace Inforbank\Application\API;
|
||||
|
||||
use \Slim\App;
|
||||
|
||||
class Handler
|
||||
{
|
||||
public function __construct(App $app)
|
||||
{
|
||||
/**
|
||||
* Create the API route group
|
||||
*/
|
||||
$app->group('/api', function () {
|
||||
/**
|
||||
* TransactionRequest API Endpoint
|
||||
*
|
||||
* Requires the following POST arguments:
|
||||
* - clientId
|
||||
* - transactionId
|
||||
* - amount
|
||||
* - description
|
||||
* - returnUrl
|
||||
* - sha1
|
||||
*/
|
||||
$this->post('/transactionRequest', function ($request, $response, $args) {
|
||||
$parsedBody = $request->getParsedBody();
|
||||
|
||||
if (isset($parsedBody['clientId']) && isset($parsedBody['transactionId']) && isset($parsedBody['amount']) && isset($parsedBody['description']) && isset($parsedBody['returnUrl']) && isset($parsedBody['sha1'])) {
|
||||
// Correct request
|
||||
|
||||
$clientSecret = Handler::getClientSecret($parsedBody['clientId']);
|
||||
$sha = sha1($parsedBody['transactionId'] . $parsedBody['amount'] . $clientSecret);
|
||||
|
||||
if ($sha === $parsedBody['sha1']) {
|
||||
$responseJSON = array(
|
||||
"success" => true,
|
||||
"redirect" => "https://example.com"
|
||||
);
|
||||
} else {
|
||||
$response = $response->withStatus(403);
|
||||
$responseJSON = array(
|
||||
"success" => false,
|
||||
"error" => "Incorrect sha1 verification hash."
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$response = $response->withStatus(400);
|
||||
$responseJSON = array(
|
||||
"success" => false,
|
||||
"error" => "Missing one of the following attributes: [clientId, transactionId, amount, description, returnUrl, sha1]"
|
||||
);
|
||||
}
|
||||
|
||||
$body = $response->getBody();
|
||||
$body->write(json_encode($responseJSON));
|
||||
return $response->withBody($body);
|
||||
});
|
||||
|
||||
/**
|
||||
* StatusRequest API Endpoint
|
||||
*
|
||||
* Requires the following POST arguments:
|
||||
* - clientId
|
||||
* - transactionId
|
||||
* - sha1
|
||||
*/
|
||||
$this->post('/statusRequest', function ($request, $response, $args) {
|
||||
$parsedBody = $request->getParsedBody();
|
||||
|
||||
if (isset($parsedBody['clientId']) && isset($parsedBody['transactionId']) && isset($parsedBody['sha1'])) {
|
||||
// Correct request
|
||||
|
||||
$clientSecret = Handler::getClientSecret($parsedBody['clientId']);
|
||||
$sha = sha1($parsedBody['transactionId'] . $clientSecret);
|
||||
|
||||
if ($sha === $parsedBody['sha1']) {
|
||||
$responseJSON = array(
|
||||
"success" => true,
|
||||
"transaction" => array(
|
||||
"status" => "Success",
|
||||
"transactionId" => "notyetfromdb",
|
||||
"someotherrandomkey" => "changethis"
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$response = $response->withStatus(403);
|
||||
$responseJSON = array(
|
||||
"success" => false,
|
||||
"error" => "Incorrect sha1 verification hash."
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$response = $response->withStatus(400);
|
||||
$responseJSON = array(
|
||||
"success" => false,
|
||||
"error" => "Missing one of the following attributes: [clientId, transactionId, sha1]"
|
||||
);
|
||||
}
|
||||
|
||||
$body = $response->getBody();
|
||||
$body->write(json_encode($responseJSON));
|
||||
return $response->withBody($body);
|
||||
});
|
||||
})->add(function ($request, $response, $next) {
|
||||
/**
|
||||
* Add the correct JSON headers to the responses
|
||||
*/
|
||||
$response = $response->withHeader('Content-type', 'application/json');
|
||||
return $next($request, $response);
|
||||
});
|
||||
}
|
||||
|
||||
public static function getClientSecret($clientId)
|
||||
{
|
||||
return '3';
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Informatica Eindproject D4p
|
||||
* 6in3, Stedelijk Gymnasium Nijmegen
|
||||
* Docent: Hans de Wolf
|
||||
*
|
||||
* ==================
|
||||
*
|
||||
* Daniel Boutros,
|
||||
* Christiaan Goossens,
|
||||
* Jelmer Hinssen
|
||||
*/
|
||||
|
||||
namespace Inforbank\Application\Auth;
|
||||
|
||||
use Inforbank\Application;
|
||||
|
||||
class Authorization
|
||||
{
|
||||
public function login($rekeningnr, $passcode)
|
||||
{
|
||||
$container = Application::getContainer();
|
||||
$db = $container->db;
|
||||
|
||||
$rekeningen = $db->rekeningen->where('rekeningnr', $rekeningnr);
|
||||
|
||||
if (count($rekeningen) !== 1) {
|
||||
throw new \Exception("Rekening niet bekend.");
|
||||
}
|
||||
|
||||
$id = $rekeningen->max("id");
|
||||
$klantnr = $rekeningen[$id]['klantid'];
|
||||
|
||||
$klant = $db->klanten->where('id', $klantnr)[$klantnr];
|
||||
|
||||
if ($klant['code'] === $passcode) {
|
||||
$_SESSION['userid'] = $klant['id'];
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getUserID()
|
||||
{
|
||||
return $_SESSION['userid'];
|
||||
}
|
||||
|
||||
public function isUserAuthenticated()
|
||||
{
|
||||
return $this->getUserID() !== null;
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
unset($_SESSION['userid']);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Informatica Eindproject D4p
|
||||
* 6in3, Stedelijk Gymnasium Nijmegen
|
||||
* Docent: Hans de Wolf
|
||||
*
|
||||
* ==================
|
||||
*
|
||||
* Daniel Boutros,
|
||||
* Christiaan Goossens,
|
||||
* Jelmer Hinssen
|
||||
*/
|
||||
|
||||
namespace Inforbank\Application\Auth;
|
||||
|
||||
use Inforbank\Application;
|
||||
use Inforbank\Application\Helper\Redirect;
|
||||
|
||||
class Middleware
|
||||
{
|
||||
public function __invoke($request, $response, $next)
|
||||
{
|
||||
$container = Application::getContainer();
|
||||
|
||||
// Check for an existing session
|
||||
if ($container->auth->isUserAuthenticated()) {
|
||||
return $next($request, $response);
|
||||
} else {
|
||||
// Redirect to the login page
|
||||
return Redirect::create($response, '/login');
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Informatica Eindproject D4p
|
||||
* 6in3, Stedelijk Gymnasium Nijmegen
|
||||
* Docent: Hans de Wolf
|
||||
*
|
||||
* ==================
|
||||
*
|
||||
* Daniel Boutros,
|
||||
* Christiaan Goossens,
|
||||
* Jelmer Hinssen
|
||||
*/
|
||||
|
||||
namespace Inforbank\Application;
|
||||
|
||||
use \Slim\App;
|
||||
|
||||
class Daniel
|
||||
{
|
||||
public function __construct(App $app)
|
||||
{
|
||||
$app->get('/daniel', function ($request, $response, $args) {
|
||||
// Render index view
|
||||
return $this->renderer->render($response, 'Daniel.phtml', $args);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Informatica Eindproject D4p
|
||||
* 6in3, Stedelijk Gymnasium Nijmegen
|
||||
* Docent: Hans de Wolf
|
||||
*
|
||||
* ==================
|
||||
*
|
||||
* Daniel Boutros,
|
||||
* Christiaan Goossens,
|
||||
* Jelmer Hinssen
|
||||
*/
|
||||
|
||||
namespace Inforbank\Application\Helper;
|
||||
|
||||
class IBAN
|
||||
{
|
||||
private function wordToNumbers($word)
|
||||
{
|
||||
$newword = "";
|
||||
$wordarray = str_split($word);
|
||||
foreach ($wordarray as $v) {
|
||||
$newword .= ord(strtolower($v)) - 87;
|
||||
}
|
||||
return $newword;
|
||||
}
|
||||
|
||||
|
||||
public function getIBAN($rekeningnr)
|
||||
{
|
||||
$landcode = "NL"; // NL in vertaling
|
||||
$landnumber = $this->wordToNumbers($landcode);
|
||||
|
||||
|
||||
$bankcode = "INFO";
|
||||
$banknumber = $this->wordToNumbers($bankcode);
|
||||
|
||||
$rekeningnr = str_pad($rekeningnr, 10, 0, STR_PAD_LEFT);
|
||||
|
||||
$bignum = $banknumber . $rekeningnr . $landnumber . "00";
|
||||
|
||||
$modulo97 = '';
|
||||
$checkdigits = '00';
|
||||
|
||||
// begin modulo staartdeling
|
||||
$modulo97 = (int)substr($bignum, 0, 6);
|
||||
$modulo97 = $modulo97 % 97;
|
||||
$modulo97 = (1000000 * $modulo97) + (int)substr($bignum, 6, 6);
|
||||
$modulo97 = $modulo97 % 97;
|
||||
$modulo97 = (1000000 * $modulo97) + (int)substr($bignum, 12, 6);
|
||||
$modulo97 = $modulo97 % 97;
|
||||
$modulo97 = (1000000 * $modulo97) + (int)substr($bignum, 18, 6);
|
||||
$modulo97 = $modulo97 % 97;
|
||||
$checkdigits = 98 - $modulo97;
|
||||
// einde modulo staartdeling
|
||||
if (strlen($checkdigits) < 2) {
|
||||
$checkdigits = '0' . $checkdigits;
|
||||
}
|
||||
|
||||
$rekeningnrarr = str_split($rekeningnr, 4);
|
||||
return $landcode.$checkdigits." ".$bankcode." ".$rekeningnrarr[0]." ".$rekeningnrarr[1]." ".$rekeningnrarr[2];
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Informatica Eindproject D4p
|
||||
* 6in3, Stedelijk Gymnasium Nijmegen
|
||||
* Docent: Hans de Wolf
|
||||
*
|
||||
* ==================
|
||||
*
|
||||
* Daniel Boutros,
|
||||
* Christiaan Goossens,
|
||||
* Jelmer Hinssen
|
||||
*/
|
||||
|
||||
namespace Inforbank\Application\Helper;
|
||||
|
||||
use Inforbank\Application;
|
||||
|
||||
class Klant
|
||||
{
|
||||
public function getCurrentUser()
|
||||
{
|
||||
$container = Application::getContainer();
|
||||
$user = $container->auth->getUserID();
|
||||
|
||||
$db = $container->db;
|
||||
|
||||
$klant = $db->klanten->where('id', $user)[$user];
|
||||
|
||||
return array(
|
||||
'voornaam' => $klant['voornaam'],
|
||||
'tussenvoegsel' => $klant['tussenvoegsel'],
|
||||
'achternaam' => $klant['achternaam'],
|
||||
'bedrijfsnaam' => $klant['bedrijfsnaam'],
|
||||
'straat' => $klant['straat'],
|
||||
'huisnummer' => $klant['huisnummer'],
|
||||
'postcode' => $klant['postcode'],
|
||||
'woonplaats' => $klant['woonplaats']
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Informatica Eindproject D4p
|
||||
* 6in3, Stedelijk Gymnasium Nijmegen
|
||||
* Docent: Hans de Wolf
|
||||
*
|
||||
* ==================
|
||||
*
|
||||
* Daniel Boutros,
|
||||
* Christiaan Goossens,
|
||||
* Jelmer Hinssen
|
||||
*/
|
||||
|
||||
namespace Inforbank\Application\Helper;
|
||||
|
||||
class Redirect
|
||||
{
|
||||
public static function create($response, $path)
|
||||
{
|
||||
$response = $response->withStatus(302);
|
||||
$response = $response->withHeader('Location', Redirect::getBasepath() . $path);
|
||||
return $response;
|
||||
}
|
||||
|
||||
private static function getBasepath()
|
||||
{
|
||||
if (isset($_SERVER['HTTPS'])) {
|
||||
$protocol = ($_SERVER['HTTPS'] && $_SERVER['HTTPS'] != "off") ? "https" : "http";
|
||||
} else {
|
||||
$protocol = 'http';
|
||||
}
|
||||
return $protocol . "://" . $_SERVER['HTTP_HOST'];
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Informatica Eindproject D4p
|
||||
* 6in3, Stedelijk Gymnasium Nijmegen
|
||||
* Docent: Hans de Wolf
|
||||
*
|
||||
* ==================
|
||||
*
|
||||
* Daniel Boutros,
|
||||
* Christiaan Goossens,
|
||||
* Jelmer Hinssen
|
||||
*/
|
||||
|
||||
namespace Inforbank\Application\Helper;
|
||||
|
||||
use Inforbank\Application;
|
||||
|
||||
class Rekeningen
|
||||
{
|
||||
public function getCurrentUserRekeningen()
|
||||
{
|
||||
$container = Application::getContainer();
|
||||
$user = $container->auth->getUserID();
|
||||
|
||||
$db = $container->db;
|
||||
$ibanhelper = new IBAN;
|
||||
|
||||
$rekeningen = $db->rekeningen->where('klantid', $user);
|
||||
|
||||
$returnArray = array();
|
||||
|
||||
foreach ($rekeningen as $rekening) {
|
||||
$returnArray[] = array(
|
||||
"rekeningnr" => $ibanhelper->getIBAN($rekening['rekeningnr']),
|
||||
"saldo" => (double) $rekening['saldo']
|
||||
);
|
||||
}
|
||||
|
||||
return $returnArray;
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Informatica Eindproject D4p
|
||||
* 6in3, Stedelijk Gymnasium Nijmegen
|
||||
* Docent: Hans de Wolf
|
||||
*
|
||||
* ==================
|
||||
*
|
||||
* Daniel Boutros,
|
||||
* Christiaan Goossens,
|
||||
* Jelmer Hinssen
|
||||
*/
|
||||
|
||||
namespace Inforbank\Application;
|
||||
|
||||
use \Slim\App;
|
||||
use Inforbank\Application\Helper\Redirect;
|
||||
|
||||
class Login
|
||||
{
|
||||
public function __construct(App $app)
|
||||
{
|
||||
$app->get('/login', function ($request, $response, $args) {
|
||||
// Render index view
|
||||
return $this->renderer->render($response, 'login.phtml', $args);
|
||||
});
|
||||
|
||||
$app->post('/login', function ($request, $response, $args) {
|
||||
// Render index view
|
||||
$post = $request->getParsedBody();
|
||||
|
||||
try {
|
||||
$resp = $this->auth->login($post['rekeningnr'], $post['pascode']);
|
||||
|
||||
if ($resp) {
|
||||
return Redirect::create($response, '/');
|
||||
} else {
|
||||
return Redirect::create($response, '/login?error');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return Redirect::create($response, '/login?error');
|
||||
}
|
||||
});
|
||||
|
||||
$app->get('/logout', function ($request, $response, $args) {
|
||||
$this->auth->logout();
|
||||
return Redirect::create($response, '/login');
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Informatica Eindproject D4p
|
||||
* 6in3, Stedelijk Gymnasium Nijmegen
|
||||
* Docent: Hans de Wolf
|
||||
*
|
||||
* ==================
|
||||
*
|
||||
* Daniel Boutros,
|
||||
* Christiaan Goossens,
|
||||
* Jelmer Hinssen
|
||||
*/
|
||||
|
||||
namespace Inforbank\Application;
|
||||
|
||||
use \Slim\App;
|
||||
use Inforbank\Application\Helper\Klant;
|
||||
use Inforbank\Application\Helper\Rekeningen;
|
||||
|
||||
class Main
|
||||
{
|
||||
/**
|
||||
* Constructor function
|
||||
* @param App $app App Dependency Injection
|
||||
*
|
||||
* ==============
|
||||
* INSTRUCTIEBLOK
|
||||
* ==============
|
||||
*
|
||||
* Hier wordt onze applicatie gestart. De functie hieronder wordt aangeroepen bij het starten van de app. Hier kun je dus routes toevoegen.
|
||||
*
|
||||
*/
|
||||
public function __construct(App $app)
|
||||
{
|
||||
$app->get('/', function ($request, $response, $args) {
|
||||
// Ophalen klant
|
||||
$klant = Klant::getCurrentUser();
|
||||
$rekeningen = Rekeningen::getCurrentUserRekeningen();
|
||||
|
||||
// Render index view
|
||||
return $this->renderer->render($response, 'index.phtml', [
|
||||
'klant' => $klant,
|
||||
'rekeningen' => $rekeningen
|
||||
]);
|
||||
})->add(new Auth\Middleware());
|
||||
}
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Informatica Eindproject D4p
|
||||
* 6in3, Stedelijk Gymnasium Nijmegen
|
||||
* Docent: Hans de Wolf
|
||||
*
|
||||
* ==================
|
||||
*
|
||||
* Daniel Boutros,
|
||||
* Christiaan Goossens,
|
||||
* Jelmer Hinssen
|
||||
*/
|
||||
|
||||
/**
|
||||
* BOOTSTRAPPING SCRIPT
|
||||
*/
|
||||
|
||||
session_start();
|
||||
|
||||
// Get the Slim framework settings
|
||||
$settings = require __DIR__ . '/settings.php';
|
||||
|
||||
// Create the Slim application object with the settings
|
||||
/**
|
||||
* ==============
|
||||
* INSTRUCTIEBLOK
|
||||
* ==============
|
||||
*
|
||||
* Slim Framework (https://www.slimframework.com/) is een basisframework om routing in PHP gemakkelijker te maken. Je kunt via functies van het Slim\App object verschillende routes aanmaken en daar PHP code aan koppelen. Slim zorgt er dan voor dat je daar automatisch uitkomt als je de opgegeven URL intypt in je browser.
|
||||
*
|
||||
* Slim maakt het ook makkelijker om benodigdheden voor je applicatie (dependencies) op een goede (standaardengebaseerde) manier te koppelen. Dit gebeurt bijvoorbeeld hieronder. Slim gebruikt hiervoor een container (http://php-di.org/doc/understanding-di.html)
|
||||
*
|
||||
*/
|
||||
$app = new \Slim\App($settings);
|
||||
|
||||
/**
|
||||
* Setup dependencies
|
||||
*/
|
||||
|
||||
$container = $app->getContainer();
|
||||
|
||||
// Create the view renderer
|
||||
/**
|
||||
* ==============
|
||||
* INSTRUCTIEBLOK
|
||||
* ==============
|
||||
*
|
||||
* Hier wordt de 'view renderer' aan de dependency container (zie hierboven) toegevoegd. Dit zorgt dat je in je applicatie deze 'view renderer' kunt gebruiken via `$this->renderer`.
|
||||
* De renderer wordt gebruikt om een PHP template (https://en.wikipedia.org/wiki/Web_template_system) aan je URL te koppelen.
|
||||
*
|
||||
* Dit kun je doen in je 'route' (URL) met de volgende code:
|
||||
*
|
||||
* ```
|
||||
* return $this->renderer->render($response, 'index.phtml', $args);
|
||||
* ```
|
||||
*
|
||||
* (index.phtml kan hier vervangen worden door een template adres uit de map templates)
|
||||
*/
|
||||
$container['renderer'] = function ($c) {
|
||||
$settings = $c->get('settings')['renderer'];
|
||||
return new Slim\Views\PhpRenderer($settings['template_path']);
|
||||
};
|
||||
|
||||
// Add the database layer
|
||||
/**
|
||||
* ==============
|
||||
* INSTRUCTIEBLOK
|
||||
* ==============
|
||||
*
|
||||
* Je kunt de database gebruiken in je code via $this->db. Vermijd het direct gebruiken van het PDO object via $this->get('db.pdo').
|
||||
* Je kunt hiervoor beter de ingebouwde functies van NotORM gebruiken.
|
||||
*/
|
||||
$container['db.pdo'] = function ($c) {
|
||||
$settings = $c->get('settings')['db'];
|
||||
$host = $settings['host'];
|
||||
$name = $settings['name'];
|
||||
$user = $settings['user'];
|
||||
$pass = $settings['pass'];
|
||||
$charset = $settings['charset'];
|
||||
|
||||
return new PDO("mysql:dbname=$name;host=$host;charset=$charset", $user, $pass,
|
||||
array(
|
||||
PDO::ATTR_TIMEOUT => 5,
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||||
));
|
||||
};
|
||||
|
||||
$container['db'] = function ($c) {
|
||||
$settings = $c->get('settings')['db'];
|
||||
$pdo = $c->get('db.pdo');
|
||||
return new NotORM($pdo);
|
||||
};
|
||||
|
||||
// Add auth object
|
||||
$container['auth'] = function () {
|
||||
return new \Inforbank\Application\Auth\Authorization();
|
||||
};
|
||||
|
||||
|
||||
// Link static objects
|
||||
Inforbank\Application::set($app);
|
||||
|
||||
// Inject the application main class
|
||||
/**
|
||||
* ==============
|
||||
* INSTRUCTIEBLOK
|
||||
* ==============
|
||||
*
|
||||
* Hieronder wordt de Main class van onze applicatie aangeroepen.
|
||||
*
|
||||
* In object georiënteerd PHP is een applicatie vaak gestructureerd in meerdere 'classes', die ook wel objecten worden genoemd. Een object kan worden gemaakt door het volgende:
|
||||
*
|
||||
*/
|
||||
|
||||
new Inforbank\Application\Login($app);
|
||||
new Inforbank\Application\Daniel($app);
|
||||
new Inforbank\Application\Main($app);
|
||||
|
||||
// Added API handler
|
||||
new Inforbank\Application\API\Handler($app);
|
||||
|
||||
/**
|
||||
* Bij het maken van dit object is in de class de __construct functie aangeroepen met de parameter $app. De functies die daar in staan zullen nu worden uitgevoerd.
|
||||
*
|
||||
* Je kunt de class herkennen uit talen als Java en C(++ of #), omdat ze daar ook worden gebruikt.
|
||||
*
|
||||
* Je kunt voor een beter begrip de volgende sites lezen:
|
||||
* - https://www.sitepoint.com/php-53-namespaces-basics/ (over namespaces (wij gebruiken InfD4p\Application))
|
||||
* - http://php.net/manual/en/language.oop5.basic.php (over de class)
|
||||
*/
|
||||
|
||||
// Run app
|
||||
$app->run();
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
// DIC configuration
|
||||
|
||||
$container = $app->getContainer();
|
||||
|
||||
// view renderer
|
||||
$container['renderer'] = function ($c) {
|
||||
$settings = $c->get('settings')['renderer'];
|
||||
return new Slim\Views\PhpRenderer($settings['template_path']);
|
||||
};
|
@ -1,4 +0,0 @@
|
||||
<?php
|
||||
// Application middleware
|
||||
|
||||
// e.g: $app->add(new \Slim\Csrf\Guard);
|
@ -1,7 +0,0 @@
|
||||
<?php
|
||||
// Routes
|
||||
|
||||
$app->get('/[{name}]', function ($request, $response, $args) {
|
||||
// Render index view
|
||||
return $this->renderer->render($response, 'index.phtml', $args);
|
||||
});
|
@ -0,0 +1,2 @@
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Inforbank</title>
|
||||
<link rel="stylesheet" href="assets/css/main.css">
|
||||
</head>
|
||||
<body>
|
@ -0,0 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>InforBank - Inloggen</title>
|
||||
<link href='//fonts.googleapis.com/css?family=Lato:300' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||
<!--link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous" -->
|
||||
</head>
|
||||
<style>
|
||||
.form-signin {
|
||||
max-width: 330px;
|
||||
padding: 15px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
color: #ff6000;
|
||||
background-color: #2e652c;
|
||||
border-color: #2e6da4;
|
||||
margin-top: 5px;
|
||||
}
|
||||
.jumbotron{
|
||||
//text-align: center;
|
||||
}
|
||||
.form-control{
|
||||
margin: 5px 0;
|
||||
}
|
||||
body{
|
||||
color: #ff6000;
|
||||
}
|
||||
.footer{
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<div class="jumbotron">
|
||||
<div class="container">
|
||||
<h1>InforBank</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<form class="form-signin" method="post">
|
||||
<h2 class="form-signin-heading">Inloggen</h2>
|
||||
<label for="inputUsername" class="sr-only">Rekeningnummer (alleen cijfers)</label>
|
||||
<input type="text" id="inputUsername" name="rekeningnr" class="form-control" placeholder="012456789"/>
|
||||
|
||||
<label for="inputPassword" class="sr-only">Pascode</label>
|
||||
<input type="password" id="inputPassword" name="pascode" class="form-control" placeholder="0000"/>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">Inloggen</button>
|
||||
</form>
|
||||
</div>
|
||||
<footer class="footer">
|
||||
© 2017 Alle rechten voorbehouden
|
||||
</footer>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,38 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Slim 3</title>
|
||||
<link href='//fonts.googleapis.com/css?family=Lato:300' rel='stylesheet' type='text/css'>
|
||||
<style>
|
||||
body {
|
||||
margin: 50px 0 0 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
text-align: center;
|
||||
color: #aaa;
|
||||
font-size: 18px;
|
||||
}
|
||||
<?php include '__header.phtml'; ?>
|
||||
|
||||
h1 {
|
||||
color: #719e40;
|
||||
letter-spacing: -3px;
|
||||
font-family: 'Lato', sans-serif;
|
||||
font-size: 100px;
|
||||
font-weight: 200;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Slim</h1>
|
||||
<div>a microframework for PHP</div>
|
||||
<p>Welkom klant <?= $_SESSION['userid'] ?></p>
|
||||
<a href="/logout">Uitloggen</a>
|
||||
<br/>
|
||||
<pre><?php echo json_encode($klant); ?></pre>
|
||||
<pre><?php echo json_encode($rekeningen); ?></pre>
|
||||
|
||||
<?php if (isset($name)) : ?>
|
||||
<h2>Hello <?= htmlspecialchars($name); ?>!</h2>
|
||||
<?php else: ?>
|
||||
<p>Try <a href="http://www.slimframework.com">SlimFramework</a>
|
||||
<?php endif; ?>
|
||||
</body>
|
||||
</html>
|
||||
<?php include '__footer.phtml'; ?>
|
||||
|
@ -0,0 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>InforBank - Inloggen</title>
|
||||
<link href='//fonts.googleapis.com/css?family=Lato:300' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||
<!--link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous" -->
|
||||
</head>
|
||||
<style>
|
||||
.form-signin {
|
||||
max-width: 330px;
|
||||
padding: 15px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
color: #ff6000;
|
||||
background-color: #2e652c;
|
||||
border-color: #2e6da4;
|
||||
margin-top: 5px;
|
||||
}
|
||||
.jumbotron{
|
||||
//text-align: center;
|
||||
}
|
||||
.form-control{
|
||||
margin: 5px 0;
|
||||
}
|
||||
body{
|
||||
color: #ff6000;
|
||||
}
|
||||
.footer{
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<div class="jumbotron">
|
||||
<div class="container">
|
||||
<h1>InforBank</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<form class="form-signin" method="post">
|
||||
<h2 class="form-signin-heading">Inloggen</h2>
|
||||
<label for="inputUsername" class="sr-only">Rekeningnummer (alleen cijfers)</label>
|
||||
<input type="text" id="inputUsername" name="rekeningnr" class="form-control" placeholder="012456789"/>
|
||||
|
||||
<label for="inputPassword" class="sr-only">Pascode</label>
|
||||
<input type="password" id="inputPassword" name="pascode" class="form-control" placeholder="0000"/>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">Inloggen</button>
|
||||
</form>
|
||||
</div>
|
||||
<footer class="footer">
|
||||
© 2017 Alle rechten voorbehouden
|
||||
</footer>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue