function get_url($https = null) { if ($https == null) { $https = is_https_enabled(); } $query_string = http_build_query($_GET); return ($https ? "https://" : "http://") . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . ($query_string == "" ? "" : "?{$query_string}"); }
function force_https($permanent_redirect = false) { if (!is_https_enabled()) { if ($permanent_redirect) { header("HTTP/1.1 301 Moved Permanently"); } header("Location: " . get_url(true)); exit; } }
/** * Turn a relative link into an absolute one, including hostname * * @param string $link * @return string */ function make_http($link) { if (strpos($link, "ttp://") > 0) { return $link; } if (strlen($link) > 0 && $link[0] != '/') { $link = get_base_href() . '/' . $link; } $protocol = is_https_enabled() ? "https://" : "http://"; $link = $protocol . $_SERVER["HTTP_HOST"] . $link; $link = str_replace("/./", "/", $link); return $link; }
/** * @param string $link */ public function links_block($link) { global $page; $protocol = is_https_enabled() ? "https://" : "http://"; $page->add_block(new Block("QR Code", "<img alt='QR Code' src='{$protocol}chart.apis.google.com/chart?chs=150x150&cht=qr&chl={$link}' />", "left", 50)); }