-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.php
More file actions
executable file
·46 lines (37 loc) · 1.32 KB
/
map.php
File metadata and controls
executable file
·46 lines (37 loc) · 1.32 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
<?php
require_once (__DIR__ . '/private/settings.php');
require_once (__DIR__ . '/libs/api.uamapgen.php');
require_once (__DIR__ . '/libs/php-svg/autoloader.php');
require_once (__DIR__ . '/libs/api.ubrouting.php');
$mapGen = new UaMapGen();
$statesData = file_get_contents(__DIR__ . '/data/morkstates.json');
$morkStates = json_decode($statesData, true);
if ($mapLabelAppendTimeStamp) {
$mapLabel .= ' ' . date('Y-m-d H:i');
}
//custom title overrides default map label
if (ubRouting::checkGet('customtitle')) {
$mapLabel = ubRouting::get('customtitle','safe');
}
$supportedFormats = array('svg', 'webp', 'png', 'jpeg', 'jpg', 'gif');
$defaultFormat = 'png';
$requestedFormat = $defaultFormat;
foreach ($supportedFormats as $format) {
if (ubRouting::checkGet($format, false)) {
$requestedFormat = $format;
break;
}
}
if ($requestedFormat === 'svg') {
$map = $mapGen->generateSvg($morkStates, $mapLabel);
header('Content-Type: image/svg+xml');
print($map);
} else {
if ($requestedFormat === 'jpg') {
$requestedFormat = 'jpeg';
}
$map = $mapGen->rasterize($morkStates, $mapLabel, $requestedFormat);
header('Content-Type: ' . $map['contentType']);
header('Content-Length: ' . strlen($map['bytes']));
print($map['bytes']);
}