Topic: Redirecting Error: Other users redirected to 'localhost' and not IP

Ok, I did not have a problem with this beforehand until today.

Mark and I were working on a second navigational bar and then encountered a weird error suddenly out of the blue.

Below are the steps we did.

______________________________________________________________________

1. We edited main.tpl to put:
<pun_navibar2> under <pun_status>.  (worked)

2. We edited header.php and put in:
// START SUBST - <pun_navlinks2>
$tpl_main = str_replace('<pun_navlinks2>','<div id="brdmenu" class="inbox">'."\n\t\t\t". generate_navlinks2()."\n\t\t".'</div>', $tpl_main);
// END SUBST - <pun_navlinks2>

underneath the <pun_status> indicator code. (worked)

3. We edited functions.php with:
//
// New navbar
//
function generate_navlinks2()
{
    global $pun_config, $lang_common, $pun_user;
   
    // Index and Userlist should always be displayed
    $links[] = '';

    // Are there any additional navlinks we should insert into the array before imploding it?
    if ($pun_config['o_additional_navlinks'] != '')
    {
        if (preg_match_all('#([0-9]+)\s*=\s*(.*?)\n#s', $pun_config['o_additional_navlinks']."\n", $extra_links))
        {
            // Insert any additional links into the $links array (at the correct index)
            for ($i = 0; $i < count($extra_links[1]); ++$i)
                array_splice($links, $extra_links[1][$i], 0, array('<li id="navextra'.($i + 1).'">'.$extra_links[2][$i]));
        }
    }
    return '<ul>'."\n\t\t\t\t".implode($lang_common['Link separator'].'</li>'."\n\t\t\t\t", $links).'</li>'."\n\t\t\t".'</ul>';
}

(worked)

So the navi bar did work when done and at the top bar only the 'manditory links' such as:


    * Index
    * User list
    * Search
    * Profile
    * Messages
    * Administration
    * Logout

Were on the first bar, and on the second was :

    * Shop
    * Bank
    * Lottery
    * Donate
    * Dictionary
    * IRC Chat

as it should be.

______________________________________________________________________

However, suddenly it started redirecting people to 'localhost' instead of my ip like it use to.

Now, I did have http://localhost/Forum as the 'Base URL' in Admin>Options from the very start for the past few months, and it never redirected people when they logged in and out to 'localhost', it redirected them back to the original ip link they came from for the links below:

   * Index
    * User list
    * Search
    * Profile
    * Messages
    * Administration
    * Logout
and also when they go to post a topic, post, and PM message  it redirects them as well. The links on the bottom navi bar are 'extra' and are set up with the IP address, which those work fine and do not redirect the users.

After trying to figure out what happened we are somewhat lost of how to fix this back to how it was.

If I change the Base URL in the Admin>options to the ip that the users normally go to then I am unable to do anything as administrator because then I get the BAD_REFFERER_HTTP error, while they can do stuff. If I leave it at 'localhost' for me then I can work on it but now the users are being suddenly redirected; which never happened before today.

I need help to figure out why this suddenly changed and how to fix it.

Would getting a domain name for the forum and entering THAT as the base url in Admin>options work for both myself and the users?

Or is there another way? Or can we get this working how it was?

~Luna

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

The redirect function has been requiring a proper base URL since 1.2.16.

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

Well, I have been using .16 and just up till today it worked fine. Then suddenly 3 hours ago after Mark and I worked on the second navi bar it did not.

How can I fix this so that it works properly again.

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

http://punbb.org/forums/viewtopic.php?id=18076

Would this work in any way?

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

Yes, but I wouldn't recommend it.

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

I'm afraid I don't use MSN wink

7

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

Use full URI's. If they're all local to the server, prepend them with pun_config['o_base_url'] in your navlink generator, if it makes things easier.

Btw, the purpose of a forum or mailing list is so that problems and answers can be archived. Using alternate communication methods does defeat the purpose somewhat. smile

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

Is there any way for you to just not access the forum via localhost but via the same method as regular users?

9 (edited by Lunactic Inferno 2008-01-28 02:33)

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

Well I am using a full url of http://localhost/Forum like I have been for the past few months, not a broken or part of,  and there has been no problem whatsoever up until today. These users are scattered throughout various countries and are not local to the server whatsoever. This problem has only started as of 4 hours ago after Mark and I worked on the aforementioned files and I have posted exactly what was changed in them or added.

This still does not tell what has happened to suddenly start redirecting users to 'localhost' instead of the links that they all came from of the external address. My own brother even in the house using the internal url base for just being upstairs even redirects him like all the others, they have to manually go in and type in the address bar the link of the ip addresses and take out 'localhost' in order to get it to work.

This is a redirection problem that has suddenly happened out of the blue, this is not a problem that has occurred before between the migration of the forum of 1.2.15 version and 1.2.16.

I need to know what has to be changed or where to look for this problem. I am NOT a coder or a professional programmer that knows everything about this. At the most I can just get lucky enough to make one or two things. Looking through all of the codes and the things we have done, even Mark says that he does not know what happened or went wrong. If he does not know, then surely there is no way in heck that I know either of what to look for since I know less than him.

So I don't have any idea what is causing this or what suddenly made it happen, nor do I know how to fix it; which is why I am posting here. It is not that the version of 1.2.16 is causing it, it is also not the fact that the URL base is improper either, if that was the cause then it would have happened way back in november, not now at the end of january or it even would have happened when upgrading between the versions.

^@@^

10 (edited by Lunactic Inferno 2008-01-28 02:33)

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

I do not have any other computer in the house that can run or maintain this forum since I am hosting it here on my computer. I am not able to access it from another source outside of my house or work on it, that will not solve the problem whatsoever neither.

I do not have an external server computer or any such thing like that, this is only hosted from within my computer with the ports set up through the router so that people may access it, and the sql and apache database and sources are set up as well. It has been working fine until now.

Setting the base url to the other ip address will lock my ability to change, create, or work on the forum completely because it will give ME the bad referrer error since its from within my own computer.

I do not know how to set up the network settings so that /this/ computer may view the forum and work on it through the external ip link or even the lan link of the internal address. If I go to any of the pages with these various ip's alll that I get is a 404 error saying

404 Not Found
The requested URL '/Forum' was not found on this server.

The same goes with any or all other pages that I would try to view in that fashion.

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

I'm telling you that the reason the redirect is happening like that is because of code added in 1.2.16. I don't know why you didn't experience the problem, but you could be the second person I've talked to tonight who upgraded a forum without making all the proper code edits. wink
The most plausible explanation in my mind is that as a part of the changes you made, the redirect function got changed to the proper, secure version which is causing these issues.

Now, as I said, is there any way for you to access the forum in the same way as your visitors rather than via localhost? Can you just enter the IP and browse it like them? If so, that's your best option and it makes the most sense.

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

The forum is listed here: http://75.100.12.215/Forum/index.php

You guys can try it yourselves. For now, I am gonna quickly run off for 5 minutes to make some yummy strawberry-chocolate chip pancakes for supper!
^**^

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

No, I cannot view the forum through the same links as they unless we somehow can get my network connection to allow it. I do not know how to do this, and the only other thing that maybe I can do if we cannot get my computer to view it in that way is to get a domain name for it, and I need to know 100% for sure that entering the domain name for my forum will allow me and everyone to access it in the correct manner before I go off and waste money for no reason.

^@@^ rawr.... syrup anyone?

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

No, a domain name would have the same issue as the outside IP

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

If you're getting a response, then the issue isn't port forwarding, it's the server you have set up

16 (edited by Lunactic Inferno 2008-01-26 04:10)

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

internal link i am using : http://localhost/Forum/index.php
external link that everyone else uses : http://75.100.12.215/Forum/index.php
LAN link in the house : http://192.168.0.4/Forum/index.php

If I use localhost it obviously works and I can set everything up fine through the admin options and whatnot.

If I type in the external link I get 404 Not Found
The requested URL '/Forum' was not found on this server.

If I type in the lan links I get the site the same way as with localhost.

Of course if i set the Base URL to the LAN link of 192.168.0.4 then no one outside of the house can access a darn thing.

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

Actually, in that case your external link is potentially pointing to the web interface of your router when you try to access it from within the LAN.

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

I think so. But that still does not solve the problem for the outside users nor me for accessing the forum properly. I need it to stop redirecting them to the stupid localhost or a lan ip and go BACK to just redirecting them to the ip that they are to use to access the forum, while at the same time I have to be able to access things as well from my own computer to view, use, and change administrator options.

If there is a way for me to connect to the external ip address then I need to know how to set that up so that I can do so, then change the base url to the external link once both I, myself, and others can access it through that link.

Each time that any of them log in or do anything at all its redirecting them, if the code for 1.2.16 version of this forum has caused this change then that bites.. I don't know anyone else that has had this problem at all and I don't know how to fix it myself.

19 (edited by Lunactic Inferno 2008-01-28 02:34)

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

Does anyone even know how to fix this.

Why is it that no one ever changes the crud so that it can remain the same for people that operate the forum from their computer, instead of everyone having to mess their files up trying to fix it. To me it sort of sounds stupid for someone to not be able to properly work as an administrator on their own forum just because of a stupid bad referrer protocol or leaving it redirect their users into oblivion to the point that they get tired of the same reoccurring problem every day.

All I need is for the thing to stop redirecting the users to 'localhost', I ended up changing the stupid base url to the external link but no, as always, /I/ can no longer work on anything on the site or delete even my own posts and messages because of the referrer error that just wondrously continues to happen. Obviously now changing the 'cache' file option back to 'localhost' no longer even works, cause then it just stupidly refreshes the whole darn thing back to the external link every single time, it does not matter if you delete all the cache files or not. The problem is just simply un-ending.

This is so stupid. Now I cannot do anything on my own forum as an administrator, let alone log in unless I stupidly continue to manually change the dumb config option under the cache folder each and every time that I click any and all links to go anywhere or do any thing. All it does is change it back and screw it all up.

Ive been racking my brain trying to get around this problem and I am just stumped... Its been 7 hours now working on this one continuous problem. Maybe someone can just give me a code to allow two base url's to be added so that both myself and others from the external link can use the forum without getting the dumb referrer error or being threatened with being redirected aimlessly....

The sad problem is, that I was going to start working on the shop mod but since I cant even work on anything, theres no way that its letting me check out 'creating items' since it blocks my ability to do so with that god darn referrer error. So yeah, it won' t even allow so much as that.

I am going to bed, this whole thing is starting to become more than a little aggrivating.

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

Try this:
include/functions.php

FIND

//
// Make sure that HTTP_REFERER matches $pun_config['o_base_url']/$script
//
function confirm_referrer($script)
{
    global $pun_config, $lang_common;

    if (!preg_match('#^'.preg_quote(str_replace('www.', '', $pun_config['o_base_url']).'/'.$script, '#').'#i', str_replace('www.', '', (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''))))
        message($lang_common['Bad referrer']);
}

REPLACE WITH

//
// Make sure that HTTP_REFERER matches $pun_config['o_base_url']/$script
//
function confirm_referrer($script)
{
    global $pun_config, $lang_common;

    $base_url = 'http://localhost/Forum';

    if (!preg_match('#^'.preg_quote(str_replace('www.', '', $base_url).'/'.$script, '#').'#i', str_replace('www.', '', (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''))))
        message($lang_common['Bad referrer']);
}

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

Smartys wrote:

No, a domain name would have the same issue as the outside IP

Actually, a domain would solve the problem because then he could add the domain to his hosts file and point it to 127.0.0.1 smile

In my opinion, the real issue is why he can't access the site using the external IP from within the network. He must be using port forwarding in order for people to access the site externally, but for some reason, it's blocking him from accessing it from within the network.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Redirecting Error: Other users redirected to 'localhost' and not IP

After almost a full day we finally got things working appropriately. Smarty, Mark, and myself ended up throwing snippets of script here there and everywhere in functions.php and admin_options to overthrow this.. dumb tyrant of unholy er.... coding... demons..

^>>^

^<<^

Or something like that.

For anyone that has this problem in the future, my gods, I feel your pain. I am backing all the stuff up now so that in case someone needs the corrections that we had to do to fix my forum, it will be made available upon request or if someone needs them again we know that the codes created DO work appropriately.

Thankyou guys so much for a rather hard problem that kept being persistent. It all worked out though. Back to business! Rickard, thank you as well I tried the domain thing and I might look into it some other day, I couldn't manage to set up the ip to be DNS with the domain name. I know less than I thought I once remembered of how to set that up, lol. Its been SOOOO long though.

Arigatoo, have a nice sleep guys, this kitty is out!

~Luna