[ Index ]
 

Code source de WordPress 2.1.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/wp-content/themes/default/images/ -> header-img.php (source)

   1  <?php
   2  
   3  $img = 'kubrickheader.jpg';
   4  
   5  // If we don't have image processing support, redirect.

   6  if ( ! function_exists('imagecreatefromjpeg') )
   7      die(header("Location: kubrickheader.jpg"));
   8  
   9  // Assign and validate the color values

  10  $default = false;
  11  $vars = array('upper'=>array('r1', 'g1', 'b1'), 'lower'=>array('r2', 'g2', 'b2'));
  12  foreach ( $vars as $var => $subvars ) {
  13      if ( isset($_GET[$var]) ) {
  14          foreach ( $subvars as $index => $subvar ) {
  15              $length = strlen($_GET[$var]) / 3;
  16              $v = substr($_GET[$var], $index * $length, $length);
  17              if ( $length == 1 ) $v = '' . $v . $v;
  18              $$subvar = hexdec( $v );
  19              if ( $$subvar < 0 || $$subvar > 255 )
  20                  $default = true;
  21          }
  22      } else {
  23          $default = true;
  24      }
  25  }
  26  
  27  if ( $default )
  28      list ( $r1, $g1, $b1, $r2, $g2, $b2 ) = array ( 105, 174, 231, 65, 128, 182 );
  29  
  30  // Create the image

  31  $im = imagecreatefromjpeg($img);
  32  
  33  // Get the background color, define the rectangle height

  34  $white = imagecolorat( $im, 15, 15 );
  35  $h = 182;
  36  
  37  // Define the boundaries of the rounded edges ( y => array ( x1, x2 ) )

  38  $corners = array(
  39      0 => array ( 25, 734 ),
  40      1 => array ( 23, 736 ),
  41      2 => array ( 22, 737 ),
  42      3 => array ( 21, 738 ),
  43      4 => array ( 21, 738 ),
  44      177 => array ( 21, 738 ),
  45      178 => array ( 21, 738 ),
  46      179 => array ( 22, 737 ),
  47      180 => array ( 23, 736 ),
  48      181 => array ( 25, 734 ),
  49      );
  50  
  51  // Blank out the blue thing

  52  for ( $i = 0; $i < $h; $i++ ) {
  53      $x1 = 19;
  54      $x2 = 740;
  55      imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $white );
  56  }
  57  
  58  // Draw a new color thing

  59  for ( $i = 0; $i < $h; $i++ ) {
  60      $x1 = 20;
  61      $x2 = 739;
  62      $r = ( $r2 - $r1 != 0 ) ? $r1 + ( $r2 - $r1 ) * ( $i / $h ) : $r1;
  63      $g = ( $g2 - $g1 != 0 ) ? $g1 + ( $g2 - $g1 ) * ( $i / $h ) : $g1;
  64      $b = ( $b2 - $b1 != 0 ) ? $b1 + ( $b2 - $b1 ) * ( $i / $h ) : $b1;
  65      $color = imagecolorallocate( $im, $r, $g, $b );
  66      if ( array_key_exists($i, $corners) ) {
  67          imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $white );
  68          list ( $x1, $x2 ) = $corners[$i];
  69      }
  70      imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $color );
  71  }
  72  
  73  //die;

  74  header("Content-Type: image/jpeg");
  75  imagejpeg($im, '', 92);
  76  imagedestroy($im);
  77  ?>


Généré le : Fri Mar 30 19:41:27 2007 par Balluche grâce à PHPXref 0.7