0 ) $lines[] = ( $MINI ? '' : 'Rated ' ) . Util::ordinal( $stats['rank'] ) . ' / ' . number_format( $stats['total_ranked'] ) . ' (Top ' . $stats['rank_percent'] . '%)'; $lines[] = 'K/D ' . round( $stats['kdr'], 1 ) . ' - Time ' . $playtimeStr; if( $MINI ) $lines[] = $_SERVER['HTTP_HOST']; insetTextbox( $_WIDTH - $_PADDING, $_PADDING, $lines, 1, $_INSET_BEVEL, 0, $_TEXT_SIZE, $_TEXT_SIZE ); // name, rank $lines = array(); $lines[] = $stats['name']; if( !$MINI ) $lines[] = $stats['army_rank_title'] . ' [' . ucwords( $stats['grade_name'] ) . ']'; // Put all statistics in a box with inset borders if( $MINI ) insetTextbox( $_PADDING + $rank_width, $_PADDING, $lines, 0, $_INSET_BEVEL, 0, $_NAME_SIZE, $_NAME_SIZE, true ); else insetTextbox( $_PADDING + $rank_width, $_PADDING, $lines, 0, $_INSET_BEVEL, 0, $_TEXT_SIZE, $_NAME_SIZE, true ); // last seen if( $stats['current_server_id'] == 0 ) { $line = "Last On: "; $line .= date( "M j", $stats['last_seen'] ); } else { // online now $line = ( $MINI ? "ON: " : "ONLINE: " ); $line .= iconv( "ISO-8859-1", "UTF-8", ( $MINI ? substr( $stats['servername'], 0, 20 ) . '...' : $stats['servername'] ) ); } insetTextline( $_PADDING + $rank_width, $_HEIGHT - $_PADDING, $line, 2 ); // figure out width of hostname //$bounds = imagettfbbox( $size, 0, $font, $_SERVER['HTTP_HOST'] ); if( !$MINI ) insetTextline( $_WIDTH - $_PADDING, $_HEIGHT - $_PADDING, $_SERVER['HTTP_HOST'], 3, $_INSET_BEVEL ); // Draw host name //drawText( $_SERVER['HTTP_HOST'], 583 - $bounds[2], 82 ); // Define the transparent color imagecolortransparent( $im, imagecolorallocate( $im, 255, 0, 255 ) ); // Convert to 8-bit / 256 colors imagetruecolortopalette( $im, true, 256 ); // Save the prepared signature image to disk for later use (cache) // Don't bother caching if the "random" flag is set. // also don't cache if rank is zero, this means tracker is down if ( !$rnd && $stats['rank']!=0 && isset( $signature_cache_file ) ) imagepng( $im, $signature_cache_file ); // finally, output the image header( 'Content-type: image/png' ); imagepng( $im ); imagedestroy( $im ); // functions ////////////////////////////////////////// // draw text in given font and size, at given co-ordinates function drawText( $text, $font, $size, $x, $y ) { global $outline; global $im, $offset, $light, $dark; if( $outline ) Image::draw_outlined_text( $im, $font, $text, $x, $y, $size, $light, $dark, $offset ); else Image::draw_shadowed_text( $im, $font, $text, $x, $y, $size, $light, $dark, $offset ); } // anchor refers to the corner of the text inset that x,y refers to. // 0=TL, 1=TR, 2=BL, 3=BR function insetTextline( $x, $y, $line, $anchor=0, $right_aligned=false, $bevel=0, $padding=0 ) { global $_INSET_BEVEL; if( $bevel == 0 ) $bevel = $_INSET_BEVEL; $arr = array( 0 => $line ); insetTextbox( $x, $y, $arr, $anchor, $bevel, $padding ); } // draw multi-line text, in an inset-bevelled box function insetTextbox( $x, $y, $lineArray, $anchor=0, $bevel=0, $padding=0, $size=0, $header_size=0, $header=false ) { global $line_spacing, $im, $font, $header_font, $offset; global $_TEXT_SIZE, $_NAME_SIZE, $_INSET_BEVEL; if( $size == 0 ) $size = $_TEXT_SIZE; if( $header_size == 0 ) $header_size = $_NAME_SIZE; if( $bevel == 0 ) $bevel = $_INSET_BEVEL; $right_aligned = ( $anchor == 1 || $anchor == 3 ); $bottom_aligned = ( $anchor == 2 || $anchor == 3 ); $multi = sizeof( $lineArray ) > 1; // Determine widest bounding box and calculate height $width = 0; $bounds = 0; $height = 2*( $bevel + $padding ); $xc = -1; $yc = -1; $line_pad = 1; $widths = array(); $heights = array(); $trailers = array(); for( $i = 0; $i < count( $lineArray ); $i++ ) { if( ( $header && $i == 0 ) ) $bounds = imageftbbox( $header_size, 0, $header_font, $lineArray[0] ); else $bounds = imageftbbox( $size, 0, $font, $lineArray[$i] ); $widths[] = $bounds[2]; $heights[] = $bounds[3]-$bounds[5]+$offset; $trailers[] = $bounds[3]; if ( $bounds[2] > $width ) { $width = $bounds[2]; } $height += $heights[$i]; } $height += ( ( count( $lineArray ) -1 ) * $line_pad ); $widest_line = $width; $width += ( 2*( $padding + $bevel ) )+1; // now, correct co-ordinates based on anchor if( $right_aligned ) $x = $x - $width; if( $bottom_aligned ) $y = $y - $height; // Create alpha blended overlay to paint text on $overlay = imagecreate( $width, $height ); imagecolorallocate( $overlay, 127, 127, 127 ); Image::bevel( $overlay, $bevel, '000000', 'ffffff' ); Image::merge( $im, $overlay, $x, $y, 40, '000000' ); // Draw all text $cy = $y + $yc + $bevel + $padding; $text_x = $x + $xc + $bevel + $padding; for( $i = 0; $i < count( $lineArray ); $i++ ) { $cy += $heights[$i]-$trailers[$i]; $line_offset = ( $right_aligned & ( $widths[$i] < $widest_line ) ? ( $widest_line - $widths[$i] ) : 0 ); if( $header & $i == 0 ) drawText( $lineArray[0], $header_font, $header_size, $text_x + $line_offset, $cy ); else drawText( $lineArray[$i], $font, $size, $text_x + $line_offset, $cy ); $cy += $line_pad + $trailers[$i]; } } ?>