/** * Private function, returns SVG-formatted game plate for our thumbnail * @param string $string of the form: ‘000000’ (Steam appid) / ‘//example.com/image.png’ (URL) * @param integer $offset translate this nameplate by this value horizontally * @return string a rendered version of $string */ function _gameplate($string, $offset) { $url = ""; foreach (explode(" ", $string) as $data) { // appid numbers if (preg_match('/^([0-9]*)$/i', $data, $appidResult)) { $appid = $appidResult[1]; } else { $url = $data; } } if (isset($appid)) { $images = getAppImages($appid); $url = $images['capsule_lg']; /* TODO check this is all good, all the time */ $localcopy = "/avatars/apps/{$appid}.capsule_184x69.jpg"; if (file_exists('.' . $localcopy) and !is_dir('.' . $localcopy)) { $url = $localcopy; } else { if (writeURLToLocation('http:' . $url, '.' . $localcopy)) { /* TODO verify we always get jpg files back */ $url = $localcopy; } } } return <<<GAMEPLATE \t\t\t\t<g transform="translate({$offset},0)"> \t\t\t\t\t<rect width="190" height="75" x="-3" y="-3" rx="6" ry="6" style="opacity:0.25;fill:#000000;filter:url(#blur)" /> \t\t\t\t\t<image xlink:href="{$url}" width="184" height="69" preserveAspectRatio="xMidYMid meet" clip-path="url(#game-clip)" /> \t\t\t\t</g> GAMEPLATE; }
$revokeURL = "/avatar/?name=" . $grantedName . "&revoke=please"; $body = "<p>This user already has permission, do you want to <a href=\"{$revokeURL}\">revoke it</a> and try again?</p>"; } } // are we supplying query for name + email? → write to log, pull down gravatar image if (isset($_GET['email']) and isset($_GET['name'])) { $action = "Gravatar Upload"; $requestedName = sanitiseName($_GET['name']); // http://en.gravatar.com/site/implement/hash/ $gravatar = md5(strtolower(trim($_GET['email']))); $requestedURL = "http://www.gravatar.com/avatar/" . $gravatar; $hostedURL = '/avatars/' . $requestedName . '.png'; $originalPath = $avatarFilePath . '/original/' . $requestedName . '.png'; $requestedPath = $avatarFilePath . '/' . $requestedName . '.png'; /* this returns false for existing file */ $result = writeURLToLocation($requestedURL, $originalPath, false); if ($result) { $result = resizeAvatar($originalPath, $requestedPath); if ($result) { writeAvatarLog(0, $me, $requestedName, 'gravatar'); $body = "<p>Fetched gravatar for user {$requestedName}. [<img height=\"14\" width=\"14\" src=\"{$requestedURL}\" />] [<img height=\"14\" width=\"14\" src=\"{$hostedURL}\" />]</p><p>These images should match.</p>"; } /* TODO: error for resize. also, change this to failure waterfall */ } else { $style = "panel-danger"; $body = "<p>Failed fetching gravatar for user {$requestedName}, confirm email is attached to their system and we don’t have that user already.</p>"; } } // are we supplying query for revoke + name? → write to log, delete permission if (isset($_GET['revoke']) and isset($_GET['name'])) { $action = "Revoke Avatar Permission";