-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
261 lines (199 loc) · 6.78 KB
/
index.php
File metadata and controls
261 lines (199 loc) · 6.78 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
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<?php
/**
* Monitor(tm) : Rapid Development Framework (http://monitor.colombiassh.org)
* Copyright 2012, OCHA Colombia (http://colombiassh.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* PHP version 5
*
* @category Script
* @package Monitor
* @author Ruben Rojas <rojasr@un.org>
* @copyright 2019 OCHA Colombia (https://salahumanitaria.co)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
* @link https://monitor.salahumanitaria.co Monitor
*/
$cli = (isset($argv)) ? true : false;
if ($cli === false) {
session_start();
if (strpos($_SERVER['SERVER_NAME'], 'salahumanitaria') === false &&
strpos($_SERVER['SERVER_NAME'], 'local') === false &&
strpos($_SERVER['SERVER_NAME'], 'portal2')) {
header('Location: https://monitor.salahumanitaria.co');
}
}
// PHP >= 5.3
//date_default_timezone_set('America/Bogota');
/// define ('BASE', '/'); /// para online
define ('BASE', '/'); // Comienza con slash, se usa al incluir los assets
require 'config.php';
require 'controllers/monitor.php';
$mc = new MonitorController;
if (isset($_SESSION)) {
if (empty($_SESSION['mapa_tipo'])) {
$_SESSION['mapa_tipo'] = 'afectacion';
}
if (empty($_SESSION['acceso'])) {
$_SESSION['acceso'] = 0;
}
}
// Get o CLI
$mod = '';
if ($cli) {
$mod = $argv[1];
}
else {
if (!empty($_GET) && isset($_GET['mod'])) {
$mod = $_GET['mod'];
}
}
// Clean URL
if (!empty($mod)) {
switch($mod) {
case 'totalxd':
if (!empty($_GET['ini']) && is_numeric($_GET['ini'])) {
$ini = $_GET['ini'];
}
if (!empty($_GET['fin']) && is_numeric($_GET['fin'])) {
$fin = $_GET['fin'];
}
$cats = (empty($_GET['c'])) ? '' : $_GET['c'];
$states = (empty($_GET['states'])) ? '' : $_GET['states'];
//$afectacion = (empty($_GET['afectacion'])) ? 0 : $_GET['afectacion'];
$totalxd = $mc->totalxd($ini, $fin, $cats, $states);
header('Content-type: text/json');
header('Content-type: application/json');
echo $totalxd;
break;
case 'getIncidentesPortal':
if (!empty($_GET['ini']) && is_numeric($_GET['ini'])) {
$ini = $_GET['ini'];
}
if (!empty($_GET['fin']) && is_numeric($_GET['fin'])) {
$fin = $_GET['fin'];
}
$cats = (empty($_GET['c'])) ? '' : $_GET['c'];
$states = (empty($_GET['states'])) ? '' : $_GET['states'];
$limiti = (empty($_GET['limiti'])) ? 0 : $_GET['limiti'];
$incidentes = $mc->getIncidentesPortal($ini, $fin, $cats, $states, $limiti);
header('Content-type: text/json');
header('Content-type: application/json');
$cb = false;
if (isset($_GET['callback'])) {
echo $_GET['callback'].'(';
$cb = true;
}
echo json_encode($incidentes);
if ($cb) {
echo ');';
}
break;
case 'getResumenPortalHome':
if (!empty($_GET['ini']) && is_numeric($_GET['ini'])) {
$ini = $_GET['ini'];
}
if (!empty($_GET['fin']) && is_numeric($_GET['fin'])) {
$fin = $_GET['fin'];
}
$incidentes = $mc->getResumenPortalHome($ini, $fin);
header('Content-type: text/json');
header('Content-type: application/json');
echo $_GET['callback'] . '('.json_encode($incidentes).');';
break;
case 'export':
$mc->export($_GET['t'],$_GET['csv'],$_GET['nom']);
break;
case 'download_incidents':
$mc->downloadIncidents($_GET['f']);
break;
case 'session_var':
$mc->setSessionVar($_GET['var'], $_GET['valor']);
break;
case 'genCachePdfDiario':
$mc->genCachePdfDiario();
break;
case 'genCacheReportesDiario':
$mc->genCacheReportesDiario();
break;
case 'genCacheTotalesDiario':
$mc->genCacheTotalesDiario();
break;
case 'totalPeriodo':
$mc->totalPeriodo($_GET['vd'],$_GET['p'],$_GET['v']);
break;
case 'checkCacheJson':
$mc->checkCacheJson();
break;
case 'variacion':
$p1 = $_GET['p1'];
$p2 = $_GET['p2'];
$ecdn = $_GET['ecdn'];
$cats = (empty($_GET['c'])) ? array() : $_GET['c'];
$states = (empty($_GET['states'])) ? array() : $_GET['states'];
header('Content-type: text/json');
header('Content-type: application/json');
echo $mc->variacion($p1,$p2,$ecdn,$cats,$states);
break;
case 'geojson':
header('Content-type: text/json');
header('Content-type: application/json');
$qs = $_GET;
unset($qs['mod']);
unset($qs['cluster']);
unset($qs['server']);
$server = $_GET['server'];
echo $mc->genJson($server.'/json/'.$_GET['cluster'].'/?', $qs);
break;
default:
echo "<img src='media/img/logo.png'>";
break;
}
}
else {
$layout = (empty($_GET['layout'])) ? 'monitor' : $_GET['layout'];
$fl = dirname( __FILE__ ).'/views/'.$layout.'.php';
//$ini = strtotime("-1 week");
$ini = strtotime(date('Y')."-1-1");
$fin = strtotime(date('Y')."-12-31");
$cats_hide = array('ec' => array(
52, //C. Complementaria: Homicidio
53 // C. Complementaria: Intento de homicidio
),
'dn' => array(0)
);
// Se usaba este para mostrar el total por años
//$totalxy = $mc->total($cats_hide);
$yyyy = date('Y');
for ($a=$yyyy;$a>=$config['yyyy_ini'];$a--) {
$totalxy[] = $a;
}
$_t = $mc->totalecdn();
$tec = $_t['ec'];
$tdn = $_t['dn'];
if ($layout != 'portal_home') {
// Categorias para filtros
$cats_db = $mc->getCats();
$cats_f = $cats_db['tree'];
$cats_u = (empty($_GET['c'])) ? $cats_db['h'] : explode(',', $_GET['c']);
}
switch($layout) {
case 'portal':
$state_id = 0;
$centroid = '';
if (!empty($state)){
$state_info = $mc->getStateCentroid($state);
$state_id = $state_info[0];
$centroid = $state_info[1];
}
break;
}
if (file_exists($fl)) {
require $fl;
}
else {
echo '._. No layout ._.';
}
}
?>