-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·49 lines (40 loc) · 1.61 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
require 'vendor/autoload.php';
use App\Blockchain\Blockchain;
use App\Database\Database;
use App\Router;
// dépendances Symfony
use Symfony\Component\HttpFoundation\Session\Session;
// constantes globales
define('DIFFICULTY', 3);
define("DEFAUT_TEMPLATE", __DIR__ . '/src/views/layouts/default.php');
$session = new Session();
$session->start();
$db = new Database();
$blocks = $db->getBlockchain();
if( count($blocks) == 0){
$b = new Blockchain(DIFFICULTY);
$e = $b->getBlocks()[0];
$db->addBlock($e->getIndex(),$e->getHash(),0,"",$e->getTime());
}
$router = new Router(__DIR__ . '/src');
$router
->get('/', 'Controllers/HomeController')
->get('/admin', 'Controllers/AdminController')
->post('/admin', 'Controllers/AdminController')
->get('/error', 'Controllers/ErrorController')
->get('/add_candidate', 'Controllers/AddCandidateController')
->post('/add_candidate', 'Controllers/AddCandidateController')
->get('/deconnection', 'Controllers/SignOutController')
->get('/login', 'Controllers/LoginController')
->post('/login', 'Controllers/LoginController')
->get('/create_user', 'Controllers/CreateUserController')
->post('/create_user', 'Controllers/CreateUserController')
->get('/profil', 'Controllers/ProfilController')
->post('/profil', 'Controllers/ProfilController')
->get('/cast', 'Controllers/CastController')
->post('/cast', 'Controllers/CastController')
->get('/candidate_list', 'Controllers/ListCandidateController')
->get('/voter_list', 'Controllers/ListVoterController')
->get('/result', 'Controllers/ListBlockController')
->run();