Thomas Bruederli
2013-10-19 49b8e5d0bb712ccf1a1a52bd794d3d7bb905a493
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
2c0d03 14 ini_set('error_reporting', E_ALL &~ (E_NOTICE | E_STRICT));
AM 15
d5fedc 16 header('Content-Type: image/svg+xml');
T 17 header("Expires: ".gmdate("D, d M Y H:i:s", time()+864000)." GMT");
18 header("Cache-Control: max-age=864000");
19 header("Pragma: ");
20
21 $svg_stops = '';
22 $color_stops = explode(';', preg_replace('/[^a-f0-9,;%]/i', '', $_GET['c']));
be72a0 23 $gradient_coords = !empty($_GET['h']) ? 'x1="0%" y1="0%" x2="100%" y2="0%"' : 'x1="0%" y1="0%" x2="0%" y2="100%"';
d5fedc 24 $last = count($color_stops) - 1;
T 25 foreach ($color_stops as $i => $stop) {
26     list($color, $offset) = explode(',', $stop);
27     if ($offset)
28         $offset = intval($offset);
29     else
30         $offset = $i == $last ? 100 : 0;
31
32     $svg_stops .= '<stop offset="' . $offset . '%" stop-color="#' . $color . '" stop-opacity="1"/>';
33 }
34
35 ?>
36 <svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" version="1.0" width="100%" height="100%">
37 <defs>
be72a0 38   <linearGradient id="LG1" <?php echo $gradient_coords; ?> spreadMethod="pad">
d5fedc 39     <?php echo $svg_stops; ?>
T 40   </linearGradient>
41 </defs>
42 <rect width="100%" height="100%" style="fill:url(#LG1);"/>
43 </svg>