3 # Copyright (C) 2005 Jason Woofenden
5 # This file is part of wfpl.
7 # wfpl is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # wfpl is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with wfpl; see the file COPYING. If not, write to the
19 # Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
23 # return our best guess at the url used to access this page
25 list($protocol, $version) = explode('/', $_SERVER['SERVER_PROTOCOL']);
26 $url = strtolower($protocol);
30 } elseif ($url == 'https') {
37 if($_SERVER['HTTP_HOST']) {
38 $url .= $_SERVER['HTTP_HOST'];
40 $url .= $_SERVER['SERVER_NAME'];
41 if($_SERVER['SERVER_PORT'] != $expected_port) {
42 $url .= ':' . $_SERVER['SERVER_PORT'];
46 $url .= $_SERVER['REQUEST_URI'];
51 function redirect($url, $status = '302 Moved Temporarily', $message = '') {
52 header("HTTP/1.1 $status");
53 header("Location: $url");