function get($email, $size = null) { $default = config::get('lepton.avatars.gravatars.default', 'identicon'); if (!$size) { $size = config::get('lepton.avatars.defaultsize', 64); } return (request::isSecure() ? 'https://secure.gravatar.com' : 'http://www.gravatar.com') . "/avatar.php?" . "gravatar_id=" . md5(strtolower($email)) . "&default=" . urlencode($default) . "&size=" . $size; }
/** * Constructor * * @param string $uri The URI to route * @param string $domain The domain to route * @param bool $secure True if connection made via SSL */ public function __construct($buri = '/') { if (isset($_SERVER['REQUEST_URI'])) { $uri = $_SERVER['REQUEST_URI']; } else { $uri = $buri; } if (isset($_SERVER['HTTP_HOST'])) { $domain = strtolower($_SERVER['HTTP_HOST']); } else { if (isset($_SERVER['SERVER_NAME'])) { $domain = strtolower($_SERVER['SERVER_NAME']); } else { $domain = 'localhost'; } } $secure = true; // Parse query string if (strpos($uri, '?')) { $base = substr($uri, 0, strpos($uri, '?')); $rest = substr($uri, strpos($uri, '?') + 1); // Apache mod_rewrite workaround for existing folders - requests // are routed as /uri/?/uri if the folder exists. if ($base != '/' && file_exists('.' . $base) && substr($rest, 0, strlen($base) - 1) . '/' == $base) { // folder match, reroute the $rest. // TODO: Query string arguments should be passed on if (strpos($rest, '&') > 0) { $params = substr($rest, strpos($rest, '&') + 1); } response::redirect($base . '?' . $params); } else { // Parse the querystring $qsl = explode('&', $rest); foreach ($qsl as $qsi) { if (preg_match('/^(.*)=(.*)$/', $qsi, $keys)) { $_GET[$keys[1]] = urldecode($keys[2]); $_REQUEST[$keys[1]] = urldecode($keys[2]); } } $uri = $base; } } // Quick fix for first index being '/index_php' when invoked via // apache - hopefully sorts bug with php oauth. if (arr::hasKey($_GET, '/index_php')) { array_shift($_GET); array_shift($_GET); } // Assign the URI and start parsing $this->_uri = $uri; $this->_domain = $domain; $this->_secure = request::isSecure(); foreach (explode('/', $this->_uri) as $segment) { if ($segment != '') { $this->_urisegments[] = $segment; } } }
/** * @brief Get the full query URL * * @return string The full query URL */ static function getURL() { if (isset($_SERVER['HTTP_HOST'])) { if (request::isSecure()) { $proto = 'https://'; $port = intval($_SERVER['SERVER_PORT']) != 443 ? ':' . $_SERVER['SERVER_PORT'] : ''; } else { $proto = 'http://'; $port = intval($_SERVER['SERVER_PORT']) != 80 ? ':' . $_SERVER['SERVER_PORT'] : ''; } if (arr::hasKey($_SERVER, 'REQUEST_URI')) { $uri = $_SERVER['REQUEST_URI']; } else { if (arr::hasKey($_SERVER, 'REQUEST_URL')) { $uri = $_SERVER['REQUEST_URL']; $querystring = request::getRawQueryString(); $uri .= $querystring; } } return $proto . $_SERVER['HTTP_HOST'] . $port . $uri; } else { return null; } }