| View previous topic :: View next topic |
| Author |
Message |
ywarnier
Joined: 21 Apr 2004 Posts: 1008 Location: Lima, Peru
|
Posted: Wed Jan 24, 2007 6:06 pm Post subject: IIS $_SERVER['REQUEST_URI'] |
|
|
Since we use it in some places in Dokeos, I thought it was worth mentioning it somewhere. Apparently, IIS doesn't deal correctly with the PHP $_SERVER['REQUEST_URI'] (this probably applies to specific versions of PHP) and that causes, for example, the resourcelinker.php script to remove links to any second-level directory when surfing through the documents to include, in the learning path tool.
Apparently, this page http://neosmart.net/blog/2006/100-apache-compliant-request_uri-for-iis-and-windows/ offers a solution which, even if not really easy to install, will work perfectly. The available request_uri.inc script is apparently enough to get you sorted with a lot of problems, and might be enough for Dokeos.
I don't know, I haven't tested since the IIS+Dokeos server I'm trying to fix is not accessible directly and I have to play with sending files to someone that will apply them.
However, I believe the information might be useful to some people around here. |
|
| |
| Back to top |
|
 |
ywarnier
Joined: 21 Apr 2004 Posts: 1008 Location: Lima, Peru
|
Posted: Thu Feb 01, 2007 2:23 am Post subject: |
|
|
Yet another side-effect of REQUEST_URI not being handled by IIS can be seen using the studentView (in the top-right corner).
This link should be formed using the following code:
| Code: |
if (!strstr($_SERVER['REQUEST_URI'], "?"))
{
$sourceurl = $_SERVER['PHP_SELF']."?";
}
else
{
$sourceurl = $_SERVER['REQUEST_URI'];
}
|
...which means that if there is a "?" in the REQUEST_URI, the REQUEST_URI is used (meaning the PHP_SELF + the parameters that went with it), otherwise only the PHP_SELF is used, which normally doesn't involve anything important.
But in IIS case, there *should be* parameters in the REQUEST_URI, but the REQUEST_URI is empty. This means that parameters were there, but will not continue to be there, just because the REQUEST_URI is handled in a bad way. To circumvene this, we can go through the $_GET array and rebuild stuff manually, but it's not very practical. |
|
| |
| Back to top |
|
 |
ywarnier
Joined: 21 Apr 2004 Posts: 1008 Location: Lima, Peru
|
Posted: Thu Feb 01, 2007 10:44 am Post subject: |
|
|
A possible fix to the previous example would be:
| Code: |
if (!strstr($_SERVER['REQUEST_URI'], "?"))
{
$sourceurl = $_SERVER['PHP_SELF']."?";
if(is_array($_GET)){
foreach($_GET as $key=>$value){
$sourceurl .= $key."=".$value."&";
}
$sourceurl = substr($sourceurl,0,-1);
}
}
else
{
$sourceurl = $_SERVER['REQUEST_URI'];
}
|
|
|
| |
| Back to top |
|
 |
Ivan Tcholakov
Joined: 25 Apr 2006 Posts: 198 Location: Bulgaria
|
Posted: Sun Jun 03, 2007 11:00 pm Post subject: I have tested IIS6 with the following in main_api.lib.php: |
|
|
| Code: |
// Added by Ivan Tcholakov, 28-JUN-2006.
// Problem to fix: The $_SERVER["REQUEST_URI"] is empty in IIS6.
// Every reference to $_SERVER['REQUEST_URI'] elsewhere in Dokeos should be replaced with calling api_request_uri().
function api_request_uri()
{
if (!empty($_SERVER['REQUEST_URI']))
{
return $_SERVER['REQUEST_URI'];
}
else
{
$uri = $_SERVER['SCRIPT_NAME'];
if (!empty($_SERVER['QUERY_STRING']))
{
$uri .= '?'.$_SERVER['QUERY_STRING'];
}
$_SERVER['REQUEST_URI'] = $uri;
return $uri;
}
}
|
And the system (for production use) was:
Dokeos Community Release 2.0.4
Windows Server 2003 - IIS6.
This fix did not obstruct the running of Dokeos under Apache.
Regards. |
|
| |
| Back to top |
|
 |
Ivan Tcholakov
Joined: 25 Apr 2006 Posts: 198 Location: Bulgaria
|
Posted: Thu Dec 04, 2008 6:45 am Post subject: This works |
|
|
I found a confirmation here: http://forums.lifetype.net/viewtopic.php?f=7&t=9161.
Maybe it is time to fix this problem in the repository source? I mean Dokeos 1.8.x (x >= 6).
:)
Regards.
Update: 04-DEC-2008.
I don't like the following suggestion:
| Code: | | // Every reference to $_SERVER['REQUEST_URI'] elsewhere in Dokeos should be replaced with calling api_request_uri(). |
It means more work than in this idea in details:
Let us place this function in main_api.lib.php, at the end. Then, in the file global.inc.php let us find the place where the main API file is to be included (currently the lines 45, 46):
| Code: | // include the main Dokeos platform library file
require_once($includePath.'/lib/main_api.lib.php'); |
Let us make this place to be:
| Code: | // include the main Dokeos platform library file
require_once($includePath.'/lib/main_api.lib.php');
// Fixing the problem of IIS6 which does not support $_SERVER['REQUEST_URI']
api_request_uri(); |
Nothing else should be touched. I think, this will work. Right now I have no possibility to test this with IIS6 (+ Windows Server 2003). If somebody tried, any feedback will be useful.
With best regards.
Update, 07-DEC-2008:
Sorry, my mistake. Instead of the correct function name api_request_uri() in the last code line above I had written api_get_request_uri(). This has been corrected. The code is OK now.
Last edited by Ivan Tcholakov on Sun Dec 07, 2008 5:23 am; edited 6 times in total |
|
| |
| Back to top |
|
 |
ywarnier
Joined: 21 Apr 2004 Posts: 1008 Location: Lima, Peru
|
Posted: Thu Dec 04, 2008 10:24 pm Post subject: |
|
|
| Feedback of at least 3 people to tell me if it works and I can apply this patch to Dokeos safely would be really appreciated. In fact, the change is ready for 1.8.6, I just have to press "Commit", but I would like to ensure more than one person has tried it... |
|
| |
| Back to top |
|
 |
ywarnier
Joined: 21 Apr 2004 Posts: 1008 Location: Lima, Peru
|
Posted: Sun Dec 07, 2008 4:05 am Post subject: |
|
|
| SVN#17089 adds the function in main_api.lib.php. Waiting for feedback to apply the change to global.inc.php |
|
| |
| Back to top |
|
 |
ywarnier
Joined: 21 Apr 2004 Posts: 1008 Location: Lima, Peru
|
Posted: Mon Jan 05, 2009 2:56 pm Post subject: |
|
|
| Meanwhile no additional feedback has been produced, I have been testing the patch all the way and it didn't break anything, so I'm applying it now (SVN#17534). I have opened http://projects.dokeos.com/index.php?do=details&task_id=3424 and added (shortly) the history of this bug so that we keep a track at development level. |
|
| |
| Back to top |
|
 |
|