commit | author | age
|
d5fedc
|
1 |
<?php |
T |
2 |
|
|
3 |
/** |
|
4 |
* Render SVG gradients for IE 9 |
|
5 |
* |
|
6 |
* Copyright (c) 2012, The Roundcube Dev Team |
|
7 |
* |
|
8 |
* The contents are subject to the Creative Commons Attribution-ShareAlike |
|
9 |
* License. It is allowed to copy, distribute, transmit and to adapt the work |
|
10 |
* by keeping credits to the original autors in the README file. |
|
11 |
* See http://creativecommons.org/licenses/by-sa/3.0/ for details. |
|
12 |
*/ |
|
13 |
|
|
14 |
header('Content-Type: image/svg+xml'); |
|
15 |
header("Expires: ".gmdate("D, d M Y H:i:s", time()+864000)." GMT"); |
|
16 |
header("Cache-Control: max-age=864000"); |
|
17 |
header("Pragma: "); |
|
18 |
|
|
19 |
$svg_stops = ''; |
|
20 |
$color_stops = explode(';', preg_replace('/[^a-f0-9,;%]/i', '', $_GET['c'])); |
|
21 |
$last = count($color_stops) - 1; |
|
22 |
foreach ($color_stops as $i => $stop) { |
|
23 |
list($color, $offset) = explode(',', $stop); |
|
24 |
if ($offset) |
|
25 |
$offset = intval($offset); |
|
26 |
else |
|
27 |
$offset = $i == $last ? 100 : 0; |
|
28 |
|
|
29 |
$svg_stops .= '<stop offset="' . $offset . '%" stop-color="#' . $color . '" stop-opacity="1"/>'; |
|
30 |
} |
|
31 |
|
|
32 |
?> |
|
33 |
<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" version="1.0" width="100%" height="100%"> |
|
34 |
<defs> |
|
35 |
<linearGradient id="LG1" x1="0%" y1="0%" x2="0%" y2="100%" spreadMethod="pad"> |
|
36 |
<?php echo $svg_stops; ?> |
|
37 |
</linearGradient> |
|
38 |
</defs> |
|
39 |
<rect width="100%" height="100%" style="fill:url(#LG1);"/> |
|
40 |
</svg> |