-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
124 lines (115 loc) · 4.19 KB
/
index.php
File metadata and controls
124 lines (115 loc) · 4.19 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
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
115
116
117
118
119
120
121
122
123
124
<?php
/**
* index.php
*
* Using the .htaccess rerouting: all traffic should be directed to/through index.php.
* In this file we initiate all models we will need, authenticate sessions, set
* template objects, and call appload to initialize the appropriate controller/method.
*
* @version 2.0
* @author Joey Kimsey <JoeyKimsey@thetempusproject.com>
* @link https://TheTempusProject.com
* @license https://opensource.org/licenses/MIT [MIT LICENSE]
*/
namespace TheTempusProject;
use TempusProjectCore\Classes\Pagination;
use TempusProjectCore\Core\Controller;
use TempusProjectCore\Functions\Routes;
use TempusProjectCore\Core\Template;
use TempusProjectCore\Classes\Config;
use TempusProjectCore\Classes\Debug;
use TempusProjectCore\Classes\Issue;
use TempusProjectCore\Classes\Input;
use TempusProjectCore\Classes\Redirect;
use TempusProjectCore\App;
require_once "init.php";
class Appload extends Controller
{
protected static $initiated = false;
protected static $session;
protected static $message;
/**
* The constructor takes care of everything that we will need before
* finally calling appload to instantiate the appropriate controller/method.
*
* @param string $urlDirected - A custom url for initiating the app
*/
public function __construct($urlDirected = null)
{
// Prevents the application from initiating twice.
if (self::$initiated === true) {
return;
} else {
self::$initiated = true;
}
parent::__construct();
self::$session = $this->model('sessions');
self::$message = $this->model('message');
// Authenticate our session
self::$session->authenticate();
// Populate some of the Template Data
self::$template->set('SITENAME', Config::get('main/name'));
self::$template->set('RECAPTCHA_SITE_KEY', Config::get('recaptcha/siteKey'));
self::$template->set('RECAPTCHA', '');
// self::$template->set('RECAPTCHA', Template::standardView('recaptcha'));
self::$template->set('RURL', Routes::getUrl());
self::$template->addFilter('member', '#{MEMBER}(.*?){/MEMBER}#is', (self::$isMember ? '$1' : ''), true);
self::$template->addFilter('mod', '#{MOD}(.*?){/MOD}#is', (self::$isMod ? '$1' : ''), true);
self::$template->addFilter('admin', '#{ADMIN}(.*?){/ADMIN}#is', (self::$isAdmin ? '$1' : ''), true);
self::$message->loadInterface();
// This needs to be moved somewhere else if possible
if (self::$isAdmin) {
if (file_exists(self::$location . "install.php")) {
if (Debug::status()) {
Debug::warn("You have not removed the installer yet.");
} else {
Issue::error("You have not removed the installer. This is a security risk that should be corrected immediately.");
}
}
}
if (!empty($urlDirected)) {
$app = new App($urlDirected);
} else {
$app = new App();
}
}
}
/**
* Instantiate the new instance of our application.
*
* You can add to the conditional for any pages that you want to have
* access to outside of the typical .htaccess redirect method.
*/
Debug::group('Initiating TTP Application');
if (Input::exists('tracking')) {
switch (Input::get('tracking')) {
case 'pixel':
$appload = new Appload('Tracking/pixel');
redirect::to('Images/pixel.png');
break;
default:
$appload = new Appload('Tracking/index');
break;
}
} elseif (Input::exists('error')) {
switch (Input::get('error')) {
case 'image404':
Debug::error('Image not found');
redirect::to('Images/imageNotFound.png');
break;
case 'upload404':
# code...
break;
case '404':
# code...
break;
default:
$appload = new Appload('error/' . Input::exists('error'));
break;
}
} elseif (stripos($_SERVER['REQUEST_URI'], 'install.php')) {
$appload = new Appload('install/index');
} else {
$appload = new Appload();
}
Debug::gend();