-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheader.php
178 lines (136 loc) · 4.59 KB
/
header.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
/**
* Archivo de Inicialización del Sistema
*
* Carga las clases base y ejecuta la solicitud.
*
* @name header.php
* @author PHPost Team
*/
/*
* -------------------------------------------------------------------
* Estableciendo variables importantes
* -------------------------------------------------------------------
*/
if (defined('TS_HEADER'))
return;
// Sesión
if (!isset($_SESSION))
session_start();
// Reporte de errores
error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE ^ E_DEPRECATED);
ini_set('display_errors', TRUE);
// Límite de ejecución
set_time_limit(300);
// Zona horaria
date_default_timezone_set('America/Bogota');
/*
* -------------------------------------------------------------------
* Definiendo constantes
* -------------------------------------------------------------------
*/
define('TS_ROOT', realpath(dirname(__FILE__)));
define('TS_HEADER', TRUE);
define('TS_PHP', TS_ROOT . '/inc/php/');
define('TS_CLASS', TS_ROOT . '/inc/class/');
define('TS_EXTRA', TS_ROOT . '/inc/ext/');
define('TS_AJAX', TS_ROOT . '/inc/ajax/');
define('TS_FILES', TS_ROOT . '/files/');
set_include_path(get_include_path() . PATH_SEPARATOR . realpath('./'));
/*
* -------------------------------------------------------------------
* Agregamos los archivos globales
* -------------------------------------------------------------------
*/
// Contiene las variables de configuración principal
include 'config.inc.php';
// No ha sido instalado el script...
if ($db['hostname'] == 'dbhost')
header("Location: ./install/index.php");
// Funciones
include TS_EXTRA . 'functions.php';
// Nucleo
include TS_CLASS . 'c.core.php';
// Controlador de usuarios
include TS_CLASS . 'c.user.php';
// Monitor de usuario
include TS_CLASS . 'c.monitor.php';
// Actividad de usuario
include TS_CLASS . 'c.actividad.php';
// Mensajes de usuario
include TS_CLASS . 'c.mensajes.php';
// Smarty
include TS_CLASS . 'c.smarty.php';
// Crean requests
include TS_EXTRA . 'QueryString.php';
/*
* -------------------------------------------------------------------
* Inicializamos los objetos principales
* -------------------------------------------------------------------
*/
// Limpiar variables...
cleanRequest();
// Cargamos el nucleo
$tsCore = & tsCore::getInstance();
// Usuario
$tsUser = & tsUser::getInstance();
// Monitor
$tsMonitor = & tsMonitor::getInstance();
// Actividad
$tsActividad = & tsActividad::getInstance();
// Mensajes
$tsMP = & tsMensajes::getInstance();
// Definimos el template a utilizar
$tsTema = $tsCore->settings['tema']['t_path'];
if (empty($tsTema))
$tsTema = 'default';
define('TS_TEMA', $tsTema);
// Smarty
$smarty = & tsSmarty::getInstance();
$currentUrl = $tsCore->currentUrl();
/*
* -------------------------------------------------------------------
* Asignación de variables
* -------------------------------------------------------------------
*/
// Configuraciones
$smarty->assign('tsConfig', $tsCore->settings);
// Obtejo usuario
$smarty->assign('tsUser', $tsUser);
// Cookies
$smarty->assign("tsCookies", $_COOKIE);
// URL actual
$smarty->assign('tsURL', $currentUrl);
/*
* -------------------------------------------------------------------
* Validaciones extra
* -------------------------------------------------------------------
*/
// Baneo por IP
$ip = $_SERVER['X_FORWARDED_FOR'] ? $_SERVER['X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
if (!filter_var($ip, FILTER_VALIDATE_IP))
die('Su ip no se pudo validar.');
if (db_exec('num_rows', db_exec(array(__FILE__, __LINE__), 'query', 'SELECT id FROM w_blacklist WHERE type = \'1\' && value = \'' . $ip . '\' LIMIT 1')))
die('Bloqueado');
// Online/Offline
if ($tsCore->settings['offline'] == 1 && ($tsUser->is_admod != 1 && $tsUser->permisos['govwm'] == false) && $_GET['seccion'] != 'login') {
$smarty->assign('tsTitle', $tsCore->settings['titulo'] . ' - ' . $tsCore->settings['slogan']);
if (empty($_GET['action']))
$smarty->display('t.mantenimiento.tpl');
else
die('Espera un poco...');
exit();
// Banned
} elseif ($tsUser->is_banned) {
$banned_data = $tsUser->getUserBanned();
if (!empty($banned_data)) {
// SI NO ES POR AJAX
if (empty($_GET['action'])) {
$smarty->assign('tsBanned', $banned_data);
$smarty->display('t.suspension.tpl');
} else
die('<div class="msjError">Usuario suspendido</div>');
//
exit;
}
}