404 Error trying to use Roundcube webmail ???

Discussion in 'General' started by phallstrom, Jan 30, 2008.

  1. phallstrom

    phallstrom Active Member

    Hi -

    I've installed roundcube webmail and am getting a weird error... when it makes AJAX calls it makes them to a URL like this:

    GET https://.....com/roundcubemail/?_task=mail.....

    and I'm getting a 404. Which is odd because if I drop the "?_..." then the page loads (the homepage of roundcube) just fine. That is "https://.....com/roundcubemail/" works. So does "https://.....com/roundcubemail/?".

    "https://.....com/roundcubemail/index.php?_task=mail....." doesn't give me a 404. Not sure what it's supposed to outside of an AJAX call, but at least no 404.

    I'm going bonkers.

    I'm using an instantiated "phpsuexec" template on 3.3.4 on ubuntu gutsy.

    Can anyone think of where to look in the configuration?

  2. phallstrom

    phallstrom Active Member

    Hrm... I think I see why, but how to fix?

    So, in digging through the roundcube source I see this:

    // check client X-header to verify request origin
    if ($OUTPUT->ajax_call)
    if (empty($CONFIG['devel_mode']) && !rc_request_header('X-RoundCube-Referer'))
    header('HTTP/1.1 404 Not Found');
    die("Invalid Request");

    And I changed that "die" line to spit out "ARGH" and sure enough that's the spot I'm hitting.

    So, not knowing much about the code, I'm guessing that litespeed is stripping out the X-RoundCube-Referer header and that isn't making it into PHP.

    Is there a way to make sure that gets passed in?

  3. phallstrom

    phallstrom Active Member

    Figured it out! -- READ THIS LITESPEED STAFF (bug in the phplsapi module)

    Hey all -

    I figured it out. In another section of the code it is calling the php function "getallheaders". Docs: http://us3.php.net/getallheaders

    They say " This function is an alias for apache_request_headers(). Please read the apache_request_headers() documentation for more information on how this function works. This function is only supported when PHP is installed as an Apache module."

    However, when I run the following code "function_exists('getallheaders')" via litespeed it returns true. So litespeed isn't undefining that function, but letting it work -- however it doesn't return *any* of the headers.

    So either litespeed needs to modify that function to return the headers or unset it.

    I added a "if that function exists and the php sapi is not litespeed" check in the code and it works great now.
  4. xing

    xing LiteSpeed Staff

    This is not a bug. The PHP.net documentation clearly states this function is an alias for apache_* function which only works when php is used as an apache module.

    More over, the roundcube developers, are using seldomly used platform specific php function when they can use and access the $_SERVER[HTTP_*] variables for exactly the same thing but compatible with every other web server, not just apache. In another words, bad programming.

    Please look at the comments below the docs at : http://us3.php.net/manual/en/function.apache-request-headers.php
  5. xing

    xing LiteSpeed Staff

    To clarify, you need to not only check wether apache_* exists but check the return result

    if(function_exists('apache_xx') && !apache_xx()) {
    //use apache_
    else {
    //use standard method of $_SERVER[HTTP_]
  6. phallstrom

    phallstrom Active Member

    "This function is only supported when PHP is installed as an Apache module."

    I suppose that can be read either way... I read it as "it's the sapi's responsibility to disable that function unless it's apache". But I suppose reading it the other way "only call this if you've first checked to make sure your running under the apache sapi" works as well :)

    They do have a check in there and if getallheaders() isn't defined access the headers directly.

    So I suppose you're right. It's not so much an issue with litespeed as an issue with *all* sapi's that aren't apache.

    Anyway, the good news is that the next person who hits this will find this post and know the fix :)
  7. mistwang

    mistwang LiteSpeed Staff

    It has been fixed in our latest php-litespeed SAPI 4.5 release.
    Added implementation of getallheaders() and apache_request_headers()

Share This Page