number = $i; $player->color = $_GET['p' . $i . 'c']; $player->textcolor = $_GET['p' . $i . 'e']; $player->status = $_GET['p' . $i . 's']; $player->turn = $_GET['p' . $i . 't']; $player->online = array_key_exists('p' . $i . 'o', $_GET) ? $_GET['p' . $i . 'o'] : -1; list ($r, $g, $b) = sscanf(dechex_color($player->color), '%2x%2x%2x'); $player->fillcolor = imagecolorallocate($image, $r, $g, $b); if (($player->status == "Joined") && !$player->color && !$player->textcolor) $player->fillcolor = imagecolorallocate($image, 127, 127, 127); // $player->fillcolor = ($player->color || $player->textcolor) ? imagecolorallocate($image, $r, $g, $b) : imagecolorallocate($image, 127, 127, 127); list ($r, $g, $b) = sscanf(dechex_color($player->textcolor), '%2x%2x%2x'); $player->offsetcolor = imagecolorallocate($image, $r, $g, $b); $players[] = $player; } $cursor_color = ($work_mode) ? imagecolorallocate($image, 0, 0, 0) : imagecolorallocate($image, 255, 255, 255); $white_color = imagecolorallocate($image, 255, 255, 255); $black_color = imagecolorallocate($image, 0, 0, 0); $friend_color = imagecolorallocate($image, 0, 255, 0); $enemy_color = imagecolorallocate($image, 255, 0, 0); // $tileimage = @imagecreatefromgif("$IMAGEDIR/boards/crosshatch.gif"); // imagesettile($image, $tileimage); $current_xpos = 0; $current_ypos = $cursor_height + $cursor_offset; foreach ($players as $player) { // draw outer white square // imagefilledrectangle ($image, $current_xpos, $current_ypos, $current_xpos + $box_width, $box_width + $current_ypos, $bkcolor); if (($player->status == "Eliminated") || ($player->status == "Booted") || ($player->status == "Surrendered")) { // draw outer square imagefilledrectangle ($image, $current_xpos, $current_ypos, $current_xpos + $box_width, $box_width + $current_ypos, $player->fillcolor); // imagefilledrectangle ($image, $current_xpos, $current_ypos, $current_xpos + $box_width, $box_width + $current_ypos, $player->offsetcolor); // draw inner white square imagefilledrectangle ($image, $current_xpos + $elim_width, $elim_width + $current_ypos, $current_xpos + $box_width - $elim_width, $box_width - $elim_width + $current_ypos, $white_color); // nice black border imagerectangle ($image, $current_xpos + $elim_width, $elim_width + $current_ypos, $current_xpos + $box_width - $elim_width, $box_width - $elim_width + $current_ypos, $black_color); imagesetthickness ($image, 2); imageline ($image, $current_xpos + $elim_width + 1, $elim_width + $current_ypos + 1, $current_xpos + $box_width - $elim_width - 1, $box_width - $elim_width + $current_ypos - 1, $black_color); imageline ($image, $current_xpos + $box_width - $elim_width - 1, $elim_width + $current_ypos + 1, $current_xpos + $elim_width + 1, $box_width - $elim_width + $current_ypos - 1, $black_color); imagesetthickness ($image, 1); } else if ($player->status) { // draw outer square imagefilledrectangle ($image, $current_xpos, $current_ypos, $current_xpos + $box_width, $box_width + $current_ypos, $player->fillcolor); // if it's this player's turn, draw turn cursor underneath if ($player->turn) imagefilledrectangle ($image, $current_xpos, $box_width + $cursor_offset + $current_ypos, $current_xpos + $box_width, $box_width + $cursor_offset + $cursor_height + $current_ypos, $cursor_color); // if this player is a friend, give them a green bar else if ($player->status == "Friend") imagefilledrectangle ($image, $current_xpos, $box_width + $cursor_offset + $current_ypos, $current_xpos + $box_width, $box_width + $cursor_offset + $cursor_height + $current_ypos, $friend_color); // else if this player is an enemy, give them a red bar else if ($player->status == "Enemy") imagefilledrectangle ($image, $current_xpos, $box_width + $cursor_offset + $current_ypos, $current_xpos + $box_width, $box_width + $cursor_offset + $cursor_height + $current_ypos, $enemy_color); // if this is the actual player, give them a nice BLACK color box so they know who they are if ($player->number == $thisplayer) { imagefilledrectangle ($image, $current_xpos + $inset_width, $inset_width + $current_ypos, $current_xpos + $box_width - $inset_width, $box_width - $inset_width + $current_ypos, $player->offsetcolor); } } else { // empty box (transparent center) imagefilledrectangle ($image, $current_xpos, $current_ypos, $current_xpos + $box_width, $box_width + $current_ypos, $bkcolor); } // online status $online_color = imagecolorallocate($image, 255, 215, 0); $offline_color = imagecolorallocate($image, 128, 128, 128); if ($player->online == 1) imagefilledrectangle ($image, $current_xpos, $current_ypos - $cursor_offset, $current_xpos + $box_width, $current_ypos - $cursor_offset - $cursor_height, $online_color); else if (!$player->online) imagefilledrectangle ($image, $current_xpos, $current_ypos - $cursor_offset, $current_xpos + $box_width, $current_ypos - $cursor_offset - $cursor_height, $offline_color); // create empty box imagerectangle ($image, $current_xpos, $current_ypos, $current_xpos + $box_width, $box_width + $current_ypos, $cursor_color); $current_xpos += $box_width + $box_spacing; } header("Cache-Control: public"); header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + $ONE_DAY * 365)); header('Content-Type: image/png'); imagepng($image); imagedestroy($image); // convert color from decimal to hexadecimal format function dechex_color($number) { $dec_color = dechex($number); $pad_count = 6 - strlen($dec_color); for ($i = 0; $i < $pad_count; ++ $i) $pad .= "0"; return $pad . $dec_color; } ?>