58 lines
1.8 KiB
PHP
58 lines
1.8 KiB
PHP
<?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(); |