70 lines
2.2 KiB
PHP

<?php
require '../lib/autoload.php';
$f3 = \Base::instance();
/**
* Not required yet
*/
// $htmlpurifier = new \HTMLPurifier();
// $htmlpurifier->purify($input);
$md = \Parsedown::instance();
$f3->set('DEBUG', 3); // development debug
$f3->config('../app/.env.cfg');
$f3->set('DB', new \DB\SQL(
'mysql:host=localhost;port=3306;dbname=' . $f3->get('database.db_name'),
$f3->get('database.username'),
$f3->get('database.password')
));
new \DB\SQL\Session($f3->get('DB'));
$f3->set('SESSION.status', 'running');
// Routing and Controller Setup
// home
$f3->route('GET /', 'HomeController->display');
// auth
$f3->route('GET /login', 'AuthController->showLoginForm');
$f3->route('POST /login', 'AuthController->login');
$f3->route('GET /logout', 'AuthController->logout');
// Example protected route
$f3->route('GET /dashboard', function($f3){
if(!$f3->exists('SESSION.user')){
$f3->reroute('/login');
}
echo 'Welcome to the dashboard' . $f3->get('SESSION.username');
echo '<a href="/logout">logout</a>';
});
// tickets - CRUD (CREATE, READ, UPDATE, DELETE)
$f3->route('GET /tickets', 'TicketController->index'); // view all tickets
$f3->route('GET /ticket/@id', 'TicketController->view'); // view ticket details
$f3->route('GET /ticket/create', 'TicketController->createForm'); // show form to create
$f3->route('POST /ticket/create', 'TicketController->create'); // save
$f3->route('GET /ticket/@id/edit', 'TicketController->editForm'); // edit ticket
$f3->route('POST /ticket/@id/update', 'TicketController->update'); //
// knowledgebase
$f3->route('GET /kb', 'KBController->index');
$f3->route('GET /kb/@id', 'KBController->view');
$f3->route('GET /kb/create', 'KBController->createForm');
$f3->route('POST /kb/create', 'KBController->create');
$f3->route('GET /kb/@id/edit', 'KBController->editForm');
$f3->route('POST /kb/@id/update', 'KBController->update'); // should this be update - "crud"?
// tags
$f3->route('GET /tags', 'TagController->index');
$f3->route('GET /tag/create', 'TagController->createForm');
$f3->route('POST /tag/create', 'TagController->create');
// dashboard
$f3->route('GET /dashboard', 'DashboardController->index');
$f3->run();