Loading...
 
Skip to main content

Use of _SERVER["REQUEST_URI"] in email templates can cause problems in server farm environment

Status
Pending
Subject
Use of _SERVER["REQUEST_URI"] in email templates can cause problems in server farm environment
Version
1.9.x
Category
  • Error
Feature
All / Undefined
Submitted by
PaytonByrd
Lastmod by
PaytonByrd
Rating
(0)
Description

This block of code is not very well behaved, and it appears in a lot of places:
// Now check if the user should be notified by email
$foo = parse_url($_SERVER["REQUEST_URI"]);
$machine = $tikilib->httpPrefix(). dirname($foo["path"]);
$machine = preg_replace("!/$!", "", $machine); // just incase
$smarty->assign('mail_machine', $machine);

In my test environment I'm hitting the website via the LAN machine name and not the public URL. Setting $foo from _SERVER["REQUEST_URI"] is causing the URL to use the LAN machine name and not the fully qualified name.

Technically this will cause the email to use the host name of whatever the user was hitting, but that would be bad in a server farm where you may need to use a scheme such as www1, www2, www3, etc as the user would always go back to that server instead of letting the load balancer figure it out.

I could see this being a problem anywhere the code is using _SERVER["SERVER_NAME"] as well.

To me the root problem here is that the templates are depending on two different sources for the same data (the hostname portion of the URL).

Solution
Use the configured value of the HTTP server name from the login configuration instead.
Importance
3
Priority
15
Demonstrate Bug on Tiki 19+
Demonstrate Bug (older Tiki versions)
Ticket ID
1555
Created
Monday 11 February, 2008 18:57:13 UTC
by Unknown
LastModif
Monday 11 February, 2008 20:01:31 UTC


Show PHP error messages