-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLoader.php
144 lines (120 loc) · 4.48 KB
/
Loader.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* Created by PhpStorm.
* User: Álvaro
* Date: 09/08/2017
* Time: 18:50
*/
//namespace Lerp2PHP;
//include 'Core.php';
include 'Settings.php';
class Loader extends Settings
{
public static $Instance;
public function __construct()
{
//Nothing to do here yet...
}
public function DoLoad()
{
//SESSION START
//session_set_cookie_params(2*7*24*60*60);
//session_start();
//XAMPP DETECTION
//define("PROJECT_FOLDER_NAME", "lerp2dev-beta")
//if(strpos($_SERVER["DOCUMENT_ROOT"], 'xampp') !== false)
// $_SERVER["DOCUMENT_ROOT"] .= "/".PROJECT_FOLDER_NAME;
define("INCLUDES", "includes/", true);
define("ADMIN_INCLUDES", "includes/admin/includes/", true);
define("SESSION_TIME", 60, true);
define("DEBUG", true);
define("MAX_ATTEMPS", 5, true);
define("FLOOD_TIME", 30, true);
define("COMMENT_MIN_LENGTH", 20);
if(!defined("CONNECT"))
define("CONNECT", true);
if(!defined("REGISTER_HIT"))
define("REGISTER_HIT", true);
if(!defined("LOADED_INCLUDED"))
define("LOADED_INCLUDED", true);
// #####################################
// ######### Include Classes ###########
// #####################################
require_once('DevProfiles.php');
require_once('Settings.php');
require_once('Classes/Session.php');
require_once('Classes/Debug.php');
require_once('Classes/Database.php');
require_once('Classes/Utils.php');
require_once('Classes/Actions.php');
require_once('Classes/Users.php');
require_once('Classes/AppLogger.php');
/*require_once('classes/db.class.php');
require_once('classes/dir.class.php');
require_once('classes/lang.class.php');
require_once('classes/core.class.php');
require_once('classes/sessions.class.php');
require_once('classes/settings.class.php');
require_once('classes/managers.class.php');
require_once('classes/content.class.php');
require_once('classes/users.class.php');
require_once('classes/paginator.class.php');
require_once('classes/announcement.class.php');*/
//Prepare Logger for this print
AppLogger::$CurLogger = new AppLogger();
//Setting session:
//Core::$sess = Session::getInstance();
//Set error handler
//parent::getInstance()->SetErrorHandler();
}
}
//Do load...
$loader = new Loader();
$loader->DoLoad();
/**
* Error handler, passes flow over the exception logger with new ErrorException.
*/
function log_error( $num, $str, $file, $line, $context = null )
{
log_exception( new ErrorException( $str, 0, $num, $file, $line ) );
}
/**
* Uncaught exception handler.
*/
function log_exception( Exception $e )
{
global $config;
/*if ( $config["debug"] == true )
{
print "<div style='text-align: center;'>";
print "<h2 style='color: rgb(190, 50, 50);'>Exception Occured:</h2>";
print "<table style='width: 800px; display: inline-block;'>";
print "<tr style='background-color:rgb(230,230,230);'><th style='width: 80px;'>Type</th><td>" . get_class( $e ) . "</td></tr>";
print "<tr style='background-color:rgb(240,240,240);'><th>Message</th><td>{$e->getMessage()}</td></tr>";
print "<tr style='background-color:rgb(230,230,230);'><th>File</th><td>{$e->getFile()}</td></tr>";
print "<tr style='background-color:rgb(240,240,240);'><th>Line</th><td>{$e->getLine()}</td></tr>";
print "</table></div>";
}
else
{
$message = "Type: " . get_class( $e ) . "; Message: {$e->getMessage()}; File: {$e->getFile()}; Line: {$e->getLine()};";
file_put_contents( $config["app_dir"] . "/tmp/logs/exceptions.log", $message . PHP_EOL, FILE_APPEND );
header( "Location: {$config["error_page"]}" );
}*/
Core::ErrorHandling($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine());
exit();
}
/**
* Checks for a fatal error, work around for set_error_handler not working on fatal errors.
*/
function check_for_fatal()
{
$error = error_get_last();
if ( $error["type"] == E_ERROR )
log_error( $error["type"], $error["message"], $error["file"], $error["line"] );
}
register_shutdown_function( "check_for_fatal" );
set_error_handler( "log_error" );
set_exception_handler( "log_exception" );
ini_set( "display_errors", "off" );
error_reporting( E_ALL );