]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-content/themes/default/images/header-img.php
Wordpress 2.0.11
[autoinstalls/wordpress.git] / wp-content / themes / default / images / header-img.php
1 <?php\r
2 \r
3 $img = 'kubrickheader.jpg';\r
4 \r
5 // If we don't have image processing support, redirect.\r
6 if ( ! function_exists('imagecreatefromjpeg') )\r
7         die(header("Location: kubrickheader.jpg"));\r
8 \r
9 // Assign and validate the color values\r
10 $default = false;\r
11 $vars = array('upper'=>array('r1', 'g1', 'b1'), 'lower'=>array('r2', 'g2', 'b2'));\r
12 foreach ( $vars as $var => $subvars ) {\r
13         if ( isset($_GET[$var]) ) {\r
14                 foreach ( $subvars as $index => $subvar ) {\r
15                         $length = strlen($_GET[$var]) / 3;\r
16                         $v = substr($_GET[$var], $index * $length, $length);\r
17                         if ( $length == 1 ) $v = '' . $v . $v;\r
18                         $$subvar = hexdec( $v );\r
19                         if ( $$subvar < 0 || $$subvar > 255 )\r
20                                 $default = true;\r
21                 }\r
22         } else {\r
23                 $default = true;\r
24         }\r
25 }\r
26 \r
27 if ( $default )\r
28         list ( $r1, $g1, $b1, $r2, $g2, $b2 ) = array ( 105, 174, 231, 65, 128, 182 );\r
29 \r
30 // Create the image\r
31 $im = imagecreatefromjpeg($img);\r
32 \r
33 // Get the background color, define the rectangle height\r
34 $white = imagecolorat( $im, 15, 15 );\r
35 $h = 182;\r
36 \r
37 // Define the boundaries of the rounded edges ( y => array ( x1, x2 ) )\r
38 $corners = array(\r
39         0 => array ( 25, 734 ),\r
40         1 => array ( 23, 736 ),\r
41         2 => array ( 22, 737 ),\r
42         3 => array ( 21, 738 ),\r
43         4 => array ( 21, 738 ),\r
44         177 => array ( 21, 738 ),\r
45         178 => array ( 21, 738 ),\r
46         179 => array ( 22, 737 ),\r
47         180 => array ( 23, 736 ),\r
48         181 => array ( 25, 734 ),\r
49         );\r
50 \r
51 // Blank out the blue thing\r
52 for ( $i = 0; $i < $h; $i++ ) {\r
53         $x1 = 19;\r
54         $x2 = 740;\r
55         imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $white );\r
56 }\r
57 \r
58 // Draw a new color thing\r
59 for ( $i = 0; $i < $h; $i++ ) {\r
60         $x1 = 20;\r
61         $x2 = 739;\r
62         $r = ( $r2 - $r1 != 0 ) ? $r1 + ( $r2 - $r1 ) * ( $i / $h ) : $r1;\r
63         $g = ( $g2 - $g1 != 0 ) ? $g1 + ( $g2 - $g1 ) * ( $i / $h ) : $g1;\r
64         $b = ( $b2 - $b1 != 0 ) ? $b1 + ( $b2 - $b1 ) * ( $i / $h ) : $b1;\r
65         $color = imagecolorallocate( $im, $r, $g, $b );\r
66         if ( array_key_exists($i, $corners) ) {\r
67                 imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $white );\r
68                 list ( $x1, $x2 ) = $corners[$i];\r
69         }\r
70         imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $color );\r
71 }\r
72 \r
73 //die;\r
74 header("Content-Type: image/jpeg");\r
75 imagejpeg($im, '', 92);\r
76 imagedestroy($im);\r
77 ?>\r