<?php include "include.php"; include "imagick_include.php"; $id = $_GET["id"]; $cacheno = $_GET["c"]; $lastSeason = false; mysql_select_db("rpihockey"); $result = dbquery("SELECT * from players WHERE `id` = '{$id}'"); $row = mysql_fetch_array($result); $result = dbquery("SELECT * from teams WHERE `name` = '" . $row["team"] . "'"); $teamrow = mysql_fetch_array($result); $tColor = rgbhex($teamrow["colorr"], $teamrow["colorg"], $teamrow["colorb"]); $stype = $row["stype"]; if ($stype != "txt") { $result = dbquery("SELECT * FROM stattype WHERE `type` = '{$stype}'"); $slabel = mysql_fetch_array($result); } mysql_select_db("rpits"); // // CACHING SECTION // foreach ($row as $item) { $hash .= $item; } $key = $row["num"] . $row["first"] . $row["last"]; $hash = addslashes($hash); $oldkey = $key; $key = addslashes($key); $result = dbquery("SELECT * from cache WHERE `key` = '{$key}'"); $cacherow = mysql_fetch_array($result);
if (isset($_POST["create_css"]) || isset($_POST["edit_css"])) { //display color picker ?> <h2>Color Picker:</h2> <table style="cursor: pointer;" border="0"> <?php function rgbhex($red, $green, $blue) { return sprintf('#%02X%02X%02X', $red, $green, $blue); } //create table of 216 web safe colors for ($red = 0; $red < 256; $red = $red + 51) { echo "<tr>"; for ($green = 0; $green < 256; $green = $green + 51) { for ($blue = 0; $blue < 256; $blue = $blue + 51) { $hexcolor = rgbhex($red, $green, $blue); echo "<td bgcolor='" . $hexcolor . "' title='" . $hexcolor . "' class='cell' onClick=\"changeColor('" . $hexcolor . "')\"> </td>\n"; } } echo "</tr>"; } ?> </table> <br> <b>Color:</b> <table border="0"><tr> <td id="thecolor" align="left" bgcolor="#000000"><input type="text" id="color_box" value="#000000"/> </td></tr> </table> <br> <?php
function base_color($post) { $url = get_post_meta($post->ID, 'image_url', true); // get the image name $imgname = trim($url); // create a working image $im = imagecreatefromjpeg($imgname); $height = imagesy($im); $top = $height - 400; $width = imagesx($im); // sample five points in the image, based on rule of thirds and center $rgb = array(); $topy = round($height / 3); $bottomy = round($height / 3 * 2); $leftx = round($width / 3); $rightx = round($width / 3 * 2); $centery = round($height / 2); $centerx = round($width / 2); $rgb[1] = imagecolorat($im, $leftx, $topy); $rgb[2] = imagecolorat($im, $rightx, $topy); $rgb[3] = imagecolorat($im, $leftx, $bottomy); $rgb[4] = imagecolorat($im, $rightx, $bottomy); $rgb[5] = imagecolorat($im, $centerx, $centery); // extract each value for r, g, b $r = array(); $g = array(); $b = array(); $hex = array(); $ct = 0; $val = 50; // process points for ($i = 1; $i <= 5; $i++) { $r[$i] = $rgb[$i] >> 16 & 0xff; $g[$i] = $rgb[$i] >> 8 & 0xff; $b[$i] = $rgb[$i] & 0xff; // find darkest color $tmp = $r[$i] + $g[$i] + $b[$i]; if ($tmp < $val) { $val = $tmp; $ct = $i; } $hex[$i] = rgbhex($r[$i], $g[$i], $b[$i]); } return $hex[3]; }
echo(" <td><input type=\"text\" size=\"1\" name=\"womens\" value=\"" . $row["womens"] . "\" /></td>"); echo(" <td><input type=\"text\" size=\"1\" name=\"statsid\" value=\"" . $row["statsid"] . "\" /></td>"); echo(" <td><input type=\"submit\" name=\"update\" value=\"Update\"></td>\n"); echo(" </form>"); echo(" </tr>"); } else { if($row["hidden"] != 1) { echo(" <tr>"); echo(" <td><a name=\"" . $row["id"] . "\">". $row["id"] . "</a></td>\n"); echo(" <td>" . $row["name"] . "</td>\n"); echo(" <td style=\"background:" . rgbhex($row["colorr"],$row["colorg"],$row["colorb"]) . ";\" ></td>"); echo(" <td>" . $row["colorr"] . "</td>\n"); echo(" <td>" . $row["colorg"] . "</td>\n"); echo(" <td>" . $row["colorb"] . "</td>\n"); echo(" <td style=\"background:" . rgbhex($row["logor"],$row["logog"],$row["logob"]) . ";\" ><img width=30 height=30 src=\"teamlogos/" . $row["logo"] . "\" /></td>"); echo(" <td>" . $row["logo"] . "</td>\n"); echo(" <td>" . $row["logor"] . "</td>\n"); echo(" <td>" . $row["logog"] . "</td>\n"); echo(" <td>" . $row["logob"] . "</td>\n"); echo(" <td>" . $row["start"] . "</td>\n"); echo(" <td>" . $row["end"] . "</td>\n"); echo(" <td>" . $row["womens"] . "</td>\n"); if(intval($row["statsid"]) != 0) { echo(" <td><a href=\"statsloader.php?tid=" . $row["statsid"] . "\">CHN Stats (Men only)</a></td>\n"); } else if(strlen($row["statsid"])> 1) { echo(" <td><a href=\"chsloader.php?url=http://collegehockeystats.net/1213/teamstats/" . $row["statsid"] . "&team=".$row["name"]."\">CHS Stats (No +/-)</a></td>\n"); } else { echo("<td></td>"); } echo(" <td><a href=\"" . $_SERVER['PHP_SELF'] . "?edit=1&id=" . $row["id"] . "\">Edit</a></td>\n");
function get_colors($url) { // get the image name $url = trim($url); // create a working image $im = imagecreatefromjpeg($url); $height = imagesy($im); $width = imagesx($im); // sample five points in the image, based on rule of thirds and center $topy = round($height / 3); $bottomy = round($height / 3 * 2); $leftx = round($width / 3); $rightx = round($width / 3 * 2); $centery = round($height / 2); $centerx = round($width / 2); // grab those colors $rgb[] = imagecolorat($im, $leftx, $topy); $rgb[] = imagecolorat($im, $rightx, $topy); $rgb[] = imagecolorat($im, $leftx, $bottomy); $rgb[] = imagecolorat($im, $rightx, $bottomy); $rgb[] = imagecolorat($im, $centerx, $centery); // process points for ($i = 0; $i <= count($rgb) - 1; $i++) { $r[$i] = $rgb[$i] >> 16 & 0xff; $g[$i] = $rgb[$i] >> 8 & 0xff; $b[$i] = $rgb[$i] & 0xff; //rgb list($colors[$i]['r'], $colors[$i]['g'], $colors[$i]['b']) = array($r[$i], $g[$i], $b[$i]); //hsv list($colors[$i]['h'], $colors[$i]['s'], $colors[$i]['v']) = hsv($r[$i], $g[$i], $b[$i]); //hex $colors[$i]['hex'] = rgbhex($r[$i], $g[$i], $b[$i]); } return $colors; }