<?php session_start(); require 'vendor/autoload.php'; //importation des fonctions de require "class/fredi.php"; //importation des modèles require "models/User.php"; require "models/Note.php"; require "models/Fee.php"; //instanciation de slim $app = new \Slim\Slim(); $app->config(array('templates.path' => './views')); $app->get('/login', function () use($app) { echo "connard"; // $app->render('login.php'); }); $app->get('/', function () use($app) { $note = new Note(); $notes = $note->fetchAll(2); $app->render('user/main.php', array('notes' => $notes)); }); $app->get('/hello/', function () { echo "Hello, world!"; }); $app->render('header.php'); $app->run(); $app->render('footer.php');
break; } } else { $note = new Note(); $note = $note->fetch($id); $app->render('note/single.php', array('note' => $note)); } }); $app->post('/note/:id(/:action)', function ($id, $action = null) use($app) { if (isset($action)) { switch ($action) { case 'add_fee': $post = $app->request->post(); $fee = new Fee($post); $fee->id_note = $id; if (!$fee->save()) { $err = "No"; } $app->redirect('/note/' . $fee->id_note); break; default: # code... break; } } }); $app->get('/notes', function () use($app) { $note = new Note(); $notes = $note->fetchAll($_SESSION['userinfo']->id_user); $app->render('note/list.php', array('notes' => $notes, 'user' => $_SESSION['userinfo'])); });
//Si l'utilisateur existe $user->id_user = $user->exists($email, $password, true); if ($user->id_user) { //On récupère les infos de l'utilisateurs $user = $user->fetch(); $_SESSION['logged'] = true; $_SESSION['userinfo'] = $user; } } }); $app->get('/', function () use($app) { if (isset($_SESSION['logged'])) { $user_id = $_SESSION['userinfo']->id_user; $note = new Note(); $note->isDue($user_id); $notes = $note->fetchAll($user_id); $app->render('user/main.php', array('notes' => $notes, 'user' => $_SESSION['userinfo'], 'app' => $app)); } else { $app->redirect('/login'); } }); //Custom routes require 'routes/login.php'; require 'routes/notes.php'; require 'routes/fees.php'; require 'routes/misc.php'; //Configurer les routes qui n'ont pas de header $app->hook('slim.before.dispatch', function () use($app) { $no_header = array(); //Ces routes ne nécessitent pas de rendre le headers if (!in_array($app->router->getCurrentRoute()->getName(), $no_header)) {