[drupal-devel] [bug] request_uri() hack for tunelled connections
anisotropic
drupal-devel at drupal.org
Sat Apr 2 00:25:20 UTC 2005
Issue status update for http://drupal.org/node/19843
Project: Drupal
Version: 4.5.2
Component: base system
Category: bug reports
Priority: normal
Assigned to: Anonymous
Reported by: anisotropic
Updated by: anisotropic
Status: active
I run a drupal instance at work on our internal network as a FAQ tool,
and had problems using the site while using ssh tunnels from the
outside. I tracked this down to a problem with request_uri() where the
following case was not accounted for:
in $_SERVER
HTTP_HOST is something like this:
hostname:8080
because this is the port the client is using and passing along,
but SERVER_PORT is '80' and REQUEST_URI is just something like
/drupal/?q=support
the following is a quick hack to fix this, intended not as a patch, but
just to illutstrate an edge-case and a way to work around it. There are
no doubt better ways to do this. =)
the quick hack:
<?php
function request_uri() {
// echo "<pre>".print_r($_SERVER, 1)."</pre>\n"; debugging? bah!
if(isset($_SERVER['HTTP_HOST'])) {
$host = explode(':', $_SERVER['HTTP_HOST']);
}
if($host[1] != $_SERVER['SERVER_PORT']) {
// boom, we're tunnelled, better supply an entire url
$uri = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
} else {
if (isset($_SERVER['REQUEST_URI'])) {
$uri = $_SERVER['REQUEST_URI'];
}
else {
if (isset($_SERVER['argv'])) {
$uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['argv'][0];
}
else {
$uri = $_SERVER['PHP_SELF'] .'?'.
$_SERVER['QUERY_STRING'];
}
}
}
return check_url($uri);
}
?>
anisotropic
More information about the drupal-devel
mailing list