alecpl
2012-04-19 5d66a4bcf3ad5d584255184776f1f04451c929fc
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  * $Id$
14  */
15
16 header('Content-Type: image/svg+xml');
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']));
23 $last = count($color_stops) - 1;
24 foreach ($color_stops as $i => $stop) {
25     list($color, $offset) = explode(',', $stop);
26     if ($offset)
27         $offset = intval($offset);
28     else
29         $offset = $i == $last ? 100 : 0;
30
31     $svg_stops .= '<stop offset="' . $offset . '%" stop-color="#' . $color . '" stop-opacity="1"/>';
32 }
33
34 ?>
35 <svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" version="1.0" width="100%" height="100%">
36 <defs>
37   <linearGradient id="LG1" x1="0%" y1="0%" x2="0%" y2="100%" spreadMethod="pad">
38     <?php echo $svg_stops; ?>
39   </linearGradient>
40 </defs>
41 <rect width="100%" height="100%" style="fill:url(#LG1);"/>
42 </svg>