Searching a FAQ ID returns an error message

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Post Reply
calande
Posts: 70
Joined: Sat Sep 02, 2006 7:01 am

Searching a FAQ ID returns an error message

Post by calande »

Please have a look at this site: http://faqs.pcbsd.org

If you search "mount", it returns a list of search results. Now search for "1095", it gives an error message... :shock:

Any idea?
Thanks!
Thorsten
Posts: 15834
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

the mod_rewrite function does not work properly. You'll bre forwarded to http://pcbsdfaqs.cust.nearlyfreespeech. ... _1095.html instead of the correct http://pcbsdfaqs.cust.nearlyfreespeech. ... _1095.html...

We're working on a fix.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
calande
Posts: 70
Joined: Sat Sep 02, 2006 7:01 am

Post by calande »

Thank you Thorsten! :)
Don't worry, this is not a major bug ;)
Thorsten
Posts: 15834
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

it will be fixed in 1.6.5.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
matteo
Posts: 572
Joined: Sun Nov 20, 2005 6:53 pm
Location: Italy

Post by matteo »

Hi,
it seems you have a strange behaviour regarding the dirname function call that does not strip out the slash at the end.
Locate, backup and open the [PATH_TO_PMFINSTALL]/inc/functions.php and search for these lines below:

Code: Select all

    if (is_numeric($begriff) && ($begriff > PMF_SOLUTION_ID_START_VALUE) && ($num > 0)) {
        if (isset($PMF_CONF['mod_rewrite']) && $PMF_CONF['mod_rewrite'] == 'TRUE') {
            header('Location: http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME']).'/solution_id_'.$begriff.'.html');
        } else {
            header('Location: http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME']).'?solution_id='.$begriff);
        }
        exit();
    }
and change them to read:

Code: Select all

    if (is_numeric($begriff) && ($begriff > PMF_SOLUTION_ID_START_VALUE) && ($num > 0)) {
        if (isset($PMF_CONF['mod_rewrite']) && $PMF_CONF['mod_rewrite'] == 'TRUE') {
            header('Location: http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME']).'solution_id_'.$begriff.'.html');
        } else {
            header('Location: http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME']).'?solution_id='.$begriff);
        }
        exit();
    }
Could you post the PHP version and OS of your server?

TIA,
Matteo
phpMyFAQ QA / Developer
Amazon.co.uk Wishlist
calande
Posts: 70
Joined: Sat Sep 02, 2006 7:01 am

Post by calande »

Thank you Matteo, now it works better, at least it doesn't return an error message but it changes the URL :)

Any idea to avoid this?

More info on the server here: http://example.nfshost.com/phpinfo.php
matteo
Posts: 572
Joined: Sun Nov 20, 2005 6:53 pm
Location: Italy

Post by matteo »

Hi,
calande wrote:Thank you Matteo, now it works better, at least it doesn't return an error message but it changes the URL :)

Any idea to avoid this?
It's seems it is using the real hostname and not the virtual host name; try this code below:

Code: Select all

    if (is_numeric($begriff) && ($begriff > PMF_SOLUTION_ID_START_VALUE) && ($num > 0)) {
        if (isset($PMF_CONF['mod_rewrite']) && $PMF_CONF['mod_rewrite'] == 'TRUE') {
            header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']).'solution_id_'.$begriff.'.html');
        } else {
            header('Location: http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']).'?solution_id='.$begriff);
        }
        exit();
    }
Maybe PHP within FreeBSD is the reason for the doubled slash: I'll work on the slash issue.
The final solution will be in PMF 1.6.5. Can I contact you to test the final code?

Regards,
Matteo
phpMyFAQ QA / Developer
Amazon.co.uk Wishlist
calande
Posts: 70
Joined: Sat Sep 02, 2006 7:01 am

Post by calande »

Working fine now :D
Thank you guys! Anyway, if you need to get in touch with me: landemaine-at-gmail-dot-com

;)
matteo
Posts: 572
Joined: Sun Nov 20, 2005 6:53 pm
Location: Italy

Post by matteo »

Hi,
calande wrote:More info on the server here: http://example.nfshost.com/phpinfo.php
there is nothing in your FreeBSD ;). The issue is on PMF code when working under a Virtual Host with no Virtual Folder, here is the code that will be commited in CVS for PMF 1.6.5:

Code: Select all

    if (is_numeric($begriff) && ($begriff > PMF_SOLUTION_ID_START_VALUE) && ($num > 0)) {
        if (isset($PMF_CONF['mod_rewrite']) && $PMF_CONF['mod_rewrite'] == 'TRUE') {
            header('Location: http://'.$_SERVER['HTTP_HOST'].str_replace ('/index.php', '', $_SERVER['PHP_SELF']).'/solution_id_'.$begriff.'.html');
        } else {
            header('Location: http://'.$_SERVER['HTTP_HOST'].str_replace ('/index.php', '', $_SERVER['PHP_SELF']).'/index.php?solution_id='.$begriff);
        }
        exit();
    }
You can remove the phpinfo page now: thanks to bring the issue to our attention.

Ciao,
Matteo
phpMyFAQ QA / Developer
Amazon.co.uk Wishlist
Post Reply