-
Notifications
You must be signed in to change notification settings - Fork 3
/
bootstrap.php
65 lines (49 loc) · 1.38 KB
/
bootstrap.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
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL & ~ E_NOTICE & ~ E_STRICT & ~ E_DEPRECATED & ~ E_WARNING);
setlocale(LC_ALL, "en_US.UTF-8");
require 'fonterator.php';
$query = $_GET['query'];
if (! empty($_GET['base64']))
$query = base64_decode($_GET['base64']);
$query = trim($query, '/');
$queryString = $query;
$query = explode('/', $query);
$query = array_filter($query);
$keys = $values = array();
foreach ($query as $key => $value)
{
if ($key & 1)
$values[] = $value;
else
$keys[] = $value;
}
$query = array_combine($keys, $values);
$cache = (bool) $query['cache'];
unset($query['cache']);
$cachePath = 'static/cache/%s';
$cacheTag = sha1($queryString);
$cacheFile = sprintf($cachePath, $cacheTag) . '.png';
if (file_exists($cacheFile) and ! $query['cache'] and 1 == 0)
{
header('Content-Type: image/png');
readfile($cacheFile);
exit(1);
}
$fontPath = 'static/fonts/%s.ttf';
$fontFile = $query['family'];
if (empty($fontFile) or ! file_exists(sprintf($fontPath, $fontFile)))
$fontFile = 'Lobster';
$fontFile = sprintf($fontPath, $fontFile);
$text = $query['text'];
if (empty($text))
$text = 'Raska';
$text = stripslashes($text);
$color = $query['color'];
if (preg_match('/^#?([0-9a-f]{6})$/i', $color, $matches))
$rgb = $matches[1];
else
$color = 'CC0000';
$fontSize = $query['size'];
if (! filter_var($fontSize, FILTER_VALIDATE_INT))
$fontSize = 36;