dokeos   dokeos

dokeos > community > forum
Dokeos Forum Forum Index Dokeos Forum

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

IIS $_SERVER['REQUEST_URI']

 
Post new topic   Reply to topic    Dokeos Forum Forum Index -> Development requests and proposals
View previous topic :: View next topic  
Author Message
ywarnier



Joined: 21 Apr 2004
Posts: 1008
Location: Lima, Peru

PostPosted: Wed Jan 24, 2007 6:06 pm    Post subject: IIS $_SERVER['REQUEST_URI'] Reply with quote

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
View user's profile Send private message
ywarnier



Joined: 21 Apr 2004
Posts: 1008
Location: Lima, Peru

PostPosted: Thu Feb 01, 2007 2:23 am    Post subject: Reply with quote

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
View user's profile Send private message
ywarnier



Joined: 21 Apr 2004
Posts: 1008
Location: Lima, Peru

PostPosted: Thu Feb 01, 2007 10:44 am    Post subject: Reply with quote

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
View user's profile Send private message
Ivan Tcholakov



Joined: 25 Apr 2006
Posts: 198
Location: Bulgaria

PostPosted: Sun Jun 03, 2007 11:00 pm    Post subject: I have tested IIS6 with the following in main_api.lib.php: Reply with quote

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
View user's profile Send private message
Ivan Tcholakov



Joined: 25 Apr 2006
Posts: 198
Location: Bulgaria

PostPosted: Thu Dec 04, 2008 6:45 am    Post subject: This works Reply with quote

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
View user's profile Send private message
ywarnier



Joined: 21 Apr 2004
Posts: 1008
Location: Lima, Peru

PostPosted: Thu Dec 04, 2008 10:24 pm    Post subject: Reply with quote

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
View user's profile Send private message
ywarnier



Joined: 21 Apr 2004
Posts: 1008
Location: Lima, Peru

PostPosted: Sun Dec 07, 2008 4:05 am    Post subject: Reply with quote

SVN#17089 adds the function in main_api.lib.php. Waiting for feedback to apply the change to global.inc.php
Back to top
View user's profile Send private message
ywarnier



Joined: 21 Apr 2004
Posts: 1008
Location: Lima, Peru

PostPosted: Mon Jan 05, 2009 2:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Dokeos Forum Forum Index -> Development requests and proposals All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP