Fixed failing test
[phpmyadmin.git] / themes / svg_gradient.php
blob7e49037293b05b310c9bf8e9db83696f8cd365d7
1 <?php
2 /**
3 * Theme based generator for SVG gradient.
5 * @package PhpMyAdmin-theme
6 */
7 header('Content-Type: image/svg+xml');
8 header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 3600) . ' GMT');
10 /**
11 * Gets single color from GET parameters validating it.
13 * @param string $get_name Name of parameter in request
14 * @param string $default Default value
16 * @return string Color name or code.
18 function PMA_gradientGetColor($get_name, $default)
20 // get color from GET args, only alphanumeric chcracters
21 $opts = array('options' => array('regexp' => '/^[a-z0-9]+$/i'));
22 $color = filter_input(INPUT_GET, $get_name, FILTER_VALIDATE_REGEXP, $opts);
23 if (preg_match('/^[a-f0-9]{6}$/', $color)) {
24 return '#' . $color;
26 return $color ? $color : $default;
29 $from = PMA_gradientGetColor('from', 'white');
30 $to = PMA_gradientGetColor('to', 'blank');
32 echo '<?xml version="1.0" ?>';
34 <svg
35 xmlns="http://www.w3.org/2000/svg"
36 preserveAspectRatio="none"
37 version="1.0" width="100%" height="100%">
38 <defs>
39 <linearGradient id="linear-gradient" x1="0%" y1="0%" x2="0%" y2="100%">
40 <stop
41 offset="0%"
42 stop-color="<?php echo $from; ?>"
43 stop-opacity="1"
45 <stop
46 offset="100%"
47 stop-color="<?php echo $to; ?>"
48 stop-opacity="1"
50 </linearGradient>
51 </defs>
52 <rect width="100%" height="100%" style="fill:url(#linear-gradient);" />
53 </svg>