-
Notifications
You must be signed in to change notification settings - Fork 2
/
get-logo.php
158 lines (151 loc) · 3.82 KB
/
get-logo.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
<?php
/* Copyright (C) 2018, 2019 Lee C. Bussy (@LBussy)
*
* This file is part of LBussy's BrewPi WWW Remix (BrewPi-WWW-RMX).
*
* BrewPi WWW RMX is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* BrewPi WWW RMX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with BrewPi WWW RMX. If not, see <https://www.gnu.org/licenses/>.
*/
$mimetypes = array(
"image/bmp",
"image/cmu-raster",
"image/fif",
"image/florian",
"image/g3fax",
"image/gif",
"image/ief",
"image/jpeg",
"image/jutvision",
"image/naplps",
"image/pict",
"image/pjpeg",
"image/png",
"image/tiff",
"image/vasa",
"image/vnd.dwg",
"image/vnd.fpx",
"image/vnd.net-fpx",
"image/vnd.rn-realflash",
"image/vnd.rn-realpix",
"image/vnd.wap.wbmp",
"image/vnd.xiff",
"image/xbm",
"image/x-cmu-raster",
"image/x-dwg",
"image/x-icon",
"image/x-jg",
"image/x-jps",
"image/x-niff",
"image/x-pcx",
"image/x-pict",
"image/xpm",
"image/x-portable-anymap",
"image/x-portable-bitmap",
"image/x-portable-graymap",
"image/x-portable-greymap",
"image/x-portable-pixmap",
"image/x-quicktime",
"image/x-rgb",
"image/x-tiff",
"image/x-windows-bmp",
"image/x-xbitmap",
"image/x-xbm",
"image/x-xpixmap",
"image/x-xwd",
"image/x-xwindowdump"
);
$mimeexts = array(
".art",
".bm",
".bmp",
".dwg",
".dxf",
".fif",
".flo",
".fpx",
".g3",
".gif",
".ico",
".ief",
".iefs",
".jfif",
".jfif-tbnl",
".jpe",
".jpeg",
".jpg",
".jps",
".jut",
".mcf",
".nap",
".naplps",
".nif",
".niff",
".pbm",
".pct",
".pcx",
".pgm",
".pic",
".pict",
".pm",
".png",
".pnm",
".ppm",
".qif",
".qti",
".qtif",
".ras",
".rast",
".rf",
".rgb",
".rp",
".svf",
".tif",
".tiff",
".turbot",
".wbmp",
".xbm",
".xif",
".xpm",
".x-png",
".xwd"
);
// Grab the custom logo if it exists, otherwise use the stock one
$custom_logo = glob('images/custom_logo.*');
$logo = (count($custom_logo) ? $custom_logo[0] : 'images/brewpi_logo.png');
if (isset($chamberLoc)) {
// If we are running as multi-index.php, be sure to prepend a chamber path
// It will not read as a multi-chamber otherwise
$logo = $chamberLoc . "/" . $logo;
}
if (file_exists($logo)) {
// Get some additional information about the logo file
$filemime = mime_content_type($logo);
$fileext = pathinfo($logo, PATHINFO_EXTENSION);
// Check to make sure the logo is a valid image
if (in_array ($filemime, $mimetypes) && in_array ("." . $fileext, $mimeexts)) {
// Use chamber path as link on logo if we are multi-chamber
$root = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/';
$logo_code = (substr_count($_SERVER['REQUEST_URI'], '/') - 1 ? '<a href="' . $root . '"><img class="logo" src="' . $logo . '"></a>' : '<img class="logo" src="' . $logo . '">');
// Logo will be resized by CSS
$displayLogo = $logo_code;
} else {
$displayLogo = $logo . " is invalid";
error_log("BrewPi: " . $logo . " is an invalid image.");
}
} else {
$displayLogo = "BrewPi: Missing " . $logo . ".";
error_log("BrewPi: " . $logo . " not found.");
}
echo $displayLogo;
echo "\n";
?>