Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- require_once 'vendor/autoload.php';
- $app = new SlimSlim(array(
- 'templates.path' => './template',
- 'debug' => true
- ));
- require("config/database.php");
- require_once("vendor/dabble/dabble/src/Dabble/Database.php");
- require_once("vendor/dabble/dabble/src/Dabble/Result.php");
- $db = new DabbleDatabase(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
- session_start();
- date_default_timezone_set("Europe/Rome");
- require 'app/GeCo.php';
- $app->run();
- ?>
- <?php
- require_once('classes/Login.php');
- use loginLogin;
- $app->get('/', function () use ($app) {
- $app->redirect('/dashboard');
- });
- $app->get('/login', function () use ($app) {
- $page = 'login.php';
- $app->render($page);
- });
- $app->get('/dashboard', function () use ($app) {
- $page = 'dashboard.php';
- $app->render($page);
- })->name('dash');;
- $app->post('/login', function () use ($app,$db) {
- try {
- $result=[];
- $username = $_POST['username'];
- $password = $_POST['password'];
- $login = new Login($db);
- $result = $login->checkLogin($username,$password);
- }catch (Exception $e) {
- error_log(json_encode(print_r($e->getTrace(), 1)));
- } finally {
- if ($result) {
- $_SESSION['loggedUser'] = $username;
- $_SESSION['password']=md5($password);
- $app->redirect('/dashboard');
- } else {
- header ( 'Content-Type: application/json' );
- echo json_encode('Nessun utente trovato con questi dati.');
- exit();
- }
- }
- });
- RewriteEngine On
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteRule ^ index.php [QSA,L]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement