Re-did everything, Now is modulaar and better bro.

This commit is contained in:
2025-05-16 20:02:49 -04:00
parent 5b50964d06
commit f8ada1d6d1
16 changed files with 1234 additions and 187 deletions

58
index.php Normal file
View File

@ -0,0 +1,58 @@
<?php
// Main entry point for the application
require_once 'config/config.php';
// Parse the URL
$request = $_SERVER['REQUEST_URI'];
$basePath = '/tinkertickets'; // Adjust based on your installation path
$request = str_replace($basePath, '', $request);
// Create database connection
$conn = new mysqli(
$GLOBALS['config']['DB_HOST'],
$GLOBALS['config']['DB_USER'],
$GLOBALS['config']['DB_PASS'],
$GLOBALS['config']['DB_NAME']
);
// Simple router
switch (true) {
case $request == '/' || $request == '':
require_once 'controllers/DashboardController.php';
$controller = new DashboardController($conn);
$controller->index();
break;
case preg_match('/^\/ticket\?id=(\d+)$/', $request, $matches) ||
preg_match('/^\/ticket\/(\d+)$/', $request, $matches):
require_once 'controllers/TicketController.php';
$controller = new TicketController($conn);
$controller->view($matches[1]);
break;
case $request == '/ticket/create':
require_once 'controllers/TicketController.php';
$controller = new TicketController($conn);
$controller->create();
break;
case preg_match('/^\/ticket\/(\d+)\/update$/', $request, $matches):
require_once 'controllers/TicketController.php';
$controller = new TicketController($conn);
$controller->update($matches[1]);
break;
case preg_match('/^\/ticket\/(\d+)\/comment$/', $request, $matches):
require_once 'controllers/CommentController.php';
$controller = new CommentController($conn);
$controller->addComment($matches[1]);
break;
default:
// 404 Not Found
header("HTTP/1.0 404 Not Found");
echo '404 Page Not Found';
break;
}
$conn->close();