forked from AppStateESS/InternshipInventory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
114 lines (93 loc) · 3.47 KB
/
index.php
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
/**
* This file is part of Internship Inventory.
*
* Internship Inventory is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Internship Inventory is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License version 3
* along with Internship Inventory. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2011-2018 Appalachian State University
*/
namespace Intern;
/**
* @author Micah Carter
*/
// Make sure the source directory is defined
if (!defined('PHPWS_SOURCE_DIR')) {
include '../../config/core/404.html';
exit();
}
require_once(PHPWS_SOURCE_DIR . 'mod/intern/inc/defines.php');
// Check some permissions
if (!\Current_User::isLogged()) {
// Fix by replacing the Users module
\PHPWS_Core::reroute('../secure');
}
// This is wrong, but it'll have to do for now.
// TODO: some sort of command pattern
$content = null;
if(DEBUG){
$inventory = new InternshipInventory();
$inventory->handleRequest();
$content = $inventory->getContent();
}else{
try{
$inventory = new InternshipInventory();
$inventory->handleRequest();
$content = $inventory->getContent();
}catch(\Exception $e){
$user = \Current_User::getUserObj();
$e->username = $user->getUsername();
if(isset($_SERVER['HTTP_REFERER'])){
$e->referrer = $_SERVER['HTTP_REFERER'];
}else{
$e->referrer = 'None';
}
$e->remoteAddr = $_SERVER['REMOTE_ADDR'];
if (extension_loaded('newrelic')) { // Ensure PHP agent is available
newrelic_notice_error($e->getMessage(), $e);
}
try{
\NQ::simple('intern', \Intern\UI\NotifyUI::ERROR, 'The Intern Inventory has experienced an error. The software engineers have been notified about this problem. We apologize for the inconvenience.');
$email = new \Intern\Email\ExceptionEmail(\Intern\InternSettings::getInstance(), $e);
$email->send();
\NQ::close();
$notifyUI = new \Intern\UI\NotifyUI();
$notifyUI->display();
\PHPWS_Core::goBack();
}catch(\Exception $e){
$message2 = $e;
echo "The Intern Inventory has experienced a major internal error. Attempting to email an admin and then exit.";
$message = "Something terrible has happened, and the exception catch-all threw an exception.\n\nThe first exception was:\n\n$message2";
mail('[email protected]', 'A Major Intern Inventory Error Has Occurred', $message);
exit();
}
}
}
/**
* Plug content into TopUI. Show notifications. Add Style.
*/
if (isset($content)) {
if ($content === false) {
\NQ::close();
\PHPWS_Core::reroute('index.php?module=intern');
}
}
// Add top menu bar to theme
\PHPWS_Core::initModClass('intern', 'UI/TopUI.php');
UI\TopUI::plug();
// Get Notifications, add to layout
$nv = new UI\NotifyUI();
$notifications = $nv->display();
\Layout::add($notifications);
// Add content to Layout
\Layout::addStyle('intern', 'style.css');
\Layout::add($content);