[Jsxe-cvs] SF.net SVN: jsxe: [1221] trunk/web/htdocs
Status: Inactive
Brought to you by:
ian_lewis
|
From: <ian...@us...> - 2006-09-01 12:49:06
|
Revision: 1221
http://svn.sourceforge.net/jsxe/?rev=1221&view=rev
Author: ian_lewis
Date: 2006-09-01 05:49:00 -0700 (Fri, 01 Sep 2006)
Log Message:
-----------
moved redirect function to functions.php
Modified Paths:
--------------
trunk/web/htdocs/functions.php
trunk/web/htdocs/links.php
trunk/web/htdocs/news.php
Modified: trunk/web/htdocs/functions.php
===================================================================
--- trunk/web/htdocs/functions.php 2006-09-01 05:11:19 UTC (rev 1220)
+++ trunk/web/htdocs/functions.php 2006-09-01 12:49:00 UTC (rev 1221)
@@ -88,4 +88,57 @@
// Return the English string:
return $string;
}
+
+// func: redirect($to,$code=307)
+// spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
+function redirect($to,$code=301)
+{
+ $location = null;
+ $sn = $_SERVER['SCRIPT_NAME'];
+ $cp = dirname($sn);
+ if (substr($to,0,4)=='http') $location = $to; // Absolute URL
+ else
+ {
+ $schema = $_SERVER['SERVER_PORT']=='443'?'https':'http';
+ $host = strlen($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:$_SERVER['SERVER_NAME'];
+ if (substr($to,0,1)=='/') $location = "$schema://$host$to";
+ elseif (substr($to,0,1)=='.') // Relative Path
+ {
+ $location = "$schema://$host";
+ $pu = parse_url($to);
+ $cd = dirname($_SERVER['SCRIPT_FILENAME']).'/';
+ $np = realpath($cd.$pu['path']);
+ $np = str_replace($_SERVER['DOCUMENT_ROOT'],'',$np);
+ $location.= $np;
+ if ((isset($pu['query'])) && (strlen($pu['query'])>0)) $location.= '?'.$pu['query'];
+ }
+ }
+
+ $hs = headers_sent();
+ if ($hs==false)
+ {
+ if ($code==301) header("301 Moved Permanently HTTP/1.1"); // Convert to GET
+ elseif ($code==302) header("302 Found HTTP/1.1"); // Conform re-POST
+ elseif ($code==303) header("303 See Other HTTP/1.1"); // dont cache, always use GET
+ elseif ($code==304) header("304 Not Modified HTTP/1.1"); // use cache
+ elseif ($code==305) header("305 Use Proxy HTTP/1.1");
+ elseif ($code==306) header("306 Not Used HTTP/1.1");
+ elseif ($code==307) header("307 Temorary Redirect HTTP/1.1");
+ else trigger_error("Unhandled redirect() HTTP Code: $code",E_USER_ERROR);
+ header("Location: $location");
+ header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
+ }
+ elseif (($hs==true) || ($code==302) || ($code==303))
+ {
+ // todo: draw some javascript to redirect
+ $cover_div_style = 'background-color: #ccc; height: 100%; left: 0px; position: absolute; top: 0px; width: 100%;';
+ echo "<div style='$cover_div_style'>\n";
+ $link_div_style = 'background-color: #fff; border: 2px solid #f00; left: 0px; margin: 5px; padding: 3px; ';
+ $link_div_style.= 'position: absolute; text-align: center; top: 0px; width: 95%; z-index: 99;';
+ echo "<div style='$link_div_style'>\n";
+ echo "<p>Please See: <a href='$to'>".htmlspecialchars($location)."</a></p>\n";
+ echo "</div>\n</div>\n";
+ }
+ exit(0);
+}
?>
\ No newline at end of file
Modified: trunk/web/htdocs/links.php
===================================================================
--- trunk/web/htdocs/links.php 2006-09-01 05:11:19 UTC (rev 1220)
+++ trunk/web/htdocs/links.php 2006-09-01 12:49:00 UTC (rev 1221)
@@ -1,57 +1,6 @@
<?php
-// func: redirect($to,$code=307)
-// spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
-function redirect($to,$code=301)
-{
- $location = null;
- $sn = $_SERVER['SCRIPT_NAME'];
- $cp = dirname($sn);
- if (substr($to,0,4)=='http') $location = $to; // Absolute URL
- else
- {
- $schema = $_SERVER['SERVER_PORT']=='443'?'https':'http';
- $host = strlen($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:$_SERVER['SERVER_NAME'];
- if (substr($to,0,1)=='/') $location = "$schema://$host$to";
- elseif (substr($to,0,1)=='.') // Relative Path
- {
- $location = "$schema://$host";
- $pu = parse_url($to);
- $cd = dirname($_SERVER['SCRIPT_FILENAME']).'/';
- $np = realpath($cd.$pu['path']);
- $np = str_replace($_SERVER['DOCUMENT_ROOT'],'',$np);
- $location.= $np;
- if ((isset($pu['query'])) && (strlen($pu['query'])>0)) $location.= '?'.$pu['query'];
- }
- }
+include("functions.php");
- $hs = headers_sent();
- if ($hs==false)
- {
- if ($code==301) header("301 Moved Permanently HTTP/1.1"); // Convert to GET
- elseif ($code==302) header("302 Found HTTP/1.1"); // Conform re-POST
- elseif ($code==303) header("303 See Other HTTP/1.1"); // dont cache, always use GET
- elseif ($code==304) header("304 Not Modified HTTP/1.1"); // use cache
- elseif ($code==305) header("305 Use Proxy HTTP/1.1");
- elseif ($code==306) header("306 Not Used HTTP/1.1");
- elseif ($code==307) header("307 Temorary Redirect HTTP/1.1");
- else trigger_error("Unhandled redirect() HTTP Code: $code",E_USER_ERROR);
- header("Location: $location");
- header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
- }
- elseif (($hs==true) || ($code==302) || ($code==303))
- {
- // todo: draw some javascript to redirect
- $cover_div_style = 'background-color: #ccc; height: 100%; left: 0px; position: absolute; top: 0px; width: 100%;';
- echo "<div style='$cover_div_style'>\n";
- $link_div_style = 'background-color: #fff; border: 2px solid #f00; left: 0px; margin: 5px; padding: 3px; ';
- $link_div_style.= 'position: absolute; text-align: center; top: 0px; width: 95%; z-index: 99;';
- echo "<div style='$link_div_style'>\n";
- echo "<p>Please See: <a href='$to'>".htmlspecialchars($location)."</a></p>\n";
- echo "</div>\n</div>\n";
- }
- exit(0);
-}
-
// Do stuff here before sending headers
redirect('/get-involved.php')
?>
Modified: trunk/web/htdocs/news.php
===================================================================
--- trunk/web/htdocs/news.php 2006-09-01 05:11:19 UTC (rev 1220)
+++ trunk/web/htdocs/news.php 2006-09-01 12:49:00 UTC (rev 1221)
@@ -1,57 +1,6 @@
<?php
-// func: redirect($to,$code=307)
-// spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
-function redirect($to,$code=301)
-{
- $location = null;
- $sn = $_SERVER['SCRIPT_NAME'];
- $cp = dirname($sn);
- if (substr($to,0,4)=='http') $location = $to; // Absolute URL
- else
- {
- $schema = $_SERVER['SERVER_PORT']=='443'?'https':'http';
- $host = strlen($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:$_SERVER['SERVER_NAME'];
- if (substr($to,0,1)=='/') $location = "$schema://$host$to";
- elseif (substr($to,0,1)=='.') // Relative Path
- {
- $location = "$schema://$host";
- $pu = parse_url($to);
- $cd = dirname($_SERVER['SCRIPT_FILENAME']).'/';
- $np = realpath($cd.$pu['path']);
- $np = str_replace($_SERVER['DOCUMENT_ROOT'],'',$np);
- $location.= $np;
- if ((isset($pu['query'])) && (strlen($pu['query'])>0)) $location.= '?'.$pu['query'];
- }
- }
+include("functions.php");
- $hs = headers_sent();
- if ($hs==false)
- {
- if ($code==301) header("301 Moved Permanently HTTP/1.1"); // Convert to GET
- elseif ($code==302) header("302 Found HTTP/1.1"); // Conform re-POST
- elseif ($code==303) header("303 See Other HTTP/1.1"); // dont cache, always use GET
- elseif ($code==304) header("304 Not Modified HTTP/1.1"); // use cache
- elseif ($code==305) header("305 Use Proxy HTTP/1.1");
- elseif ($code==306) header("306 Not Used HTTP/1.1");
- elseif ($code==307) header("307 Temorary Redirect HTTP/1.1");
- else trigger_error("Unhandled redirect() HTTP Code: $code",E_USER_ERROR);
- header("Location: $location");
- header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
- }
- elseif (($hs==true) || ($code==302) || ($code==303))
- {
- // todo: draw some javascript to redirect
- $cover_div_style = 'background-color: #ccc; height: 100%; left: 0px; position: absolute; top: 0px; width: 100%;';
- echo "<div style='$cover_div_style'>\n";
- $link_div_style = 'background-color: #fff; border: 2px solid #f00; left: 0px; margin: 5px; padding: 3px; ';
- $link_div_style.= 'position: absolute; text-align: center; top: 0px; width: 95%; z-index: 99;';
- echo "<div style='$link_div_style'>\n";
- echo "<p>Please See: <a href='$to'>".htmlspecialchars($location)."</a></p>\n";
- echo "</div>\n</div>\n";
- }
- exit(0);
-}
-
// Do stuff here before sending headers
redirect('/index.php')
?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|