-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathezproxyeditor.php
More file actions
64 lines (51 loc) · 1.9 KB
/
ezproxyeditor.php
File metadata and controls
64 lines (51 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* ezproxyeditor.php
*
* Main entry point for the EZProxy Editor application.
* Handles routing and rendering of views.
*
* @package PCC_EPE
* @version 1.0
*/
use PCC_EPE\Models\Config;
// Include the Composer autoloader
require_once __DIR__ . '/vendor/autoload.php';
// Include the initialization file
require_once 'ezpe-initialize.php';
// Authenticate the user
$auth = new PCC_EPE\Controllers\Authentication();
$casUser = phpCAS::getUser();
$authenticatedUser = $auth->checkUser($casUser);
var_dump($authenticatedUser);
// Debug output for CAS user
error_log("CAS Authenticated User: " . var_export($authenticatedUser, true), 3, '/var/log/cas_debug.log');
if (!$authenticatedUser) {
// Redirect to a "Not Authorized" page or show an error
header('Location: ' . BASEURL . '/unauthorized');
exit();
}
// Debug output for router base path
error_log("Router Base Path: " . var_export(Config::$router->getBasePath(), true), 3, '/var/log/cas_debug.log');
// Match the current request
$match = Config::$router->match();
// Debug output for router match
error_log("Router Match: " . var_export($match, true), 3, '/var/log/cas_debug.log');
if ($match) {
list($controller, $method) = explode('#', $match['target']);
if (is_callable(array($controller, $method))) {
call_user_func_array(array(new $controller, $method), array($match['params']));
} else {
// Handle the error
header($_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
echo "404 Not Found";
error_log("Error: 404 Not Found - Controller method not callable", 3, '/var/log/cas_debug.log');
}
} else {
// No route was matched
header($_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
echo "404 Not Found";
error_log("Error: 404 Not Found - No route matched", 3, '/var/log/cas_debug.log');
}
// Output headers after routing logic
header("Content-Type: text/html; charset=utf-8");