Http://localhost in php script?

apps

#1

I have a blog (WordPress) and a forum (phpBB). I am using a plug in to try to integrate user log in for both.

The script calls for -


if ( $userdata[‘session_logged_in’] )
{
$u_login_logout = ‘…/wordpress/wphpbb-login.php?action=logout&redirect_to=http://localhost’. $_SERVER[‘REQUEST_URI’] . ‘&sid=’ . $userdata[‘session_id’];//‘login.’.$phpEx.’?logout=true&sid=’ . $userdata[‘session_id’]
$l_login_logout = $lang[‘Logout’] . ’ [ ’ . $userdata[‘username’] . ’ ]’;
}
else
{
$u_login_logout = ‘…/wordpress/wphpbb-login.php?&redirect_to=http://localhost’. $_SERVER[‘REQUEST_URI’]; //‘login.’.$phpEx;
$l_login_logout = $lang[‘Login’];
}


I know that normally you have to change “localhost” to “mysql.yourdomain.com

Would this apply here also?


#2

Edited: Oops! I didn’t look at the code closely enough, and gave you a “bum” answer - I’m sorry! :frowning: No, it doesn’t. In the case of defining your MySQL host, you need to replace “localhost” with the appropriate host for your database. In this instance, “localhost” should be replaced with an environment variable to help define paths/urls and, as such, should not have the the name of your MySQL database host substituted for it, rather the varible to represent the path of your server - what Atropos7 said
.

–rlparker


#3

Yes. Obviously one cannot use localhost as the hostname in the URL. You have two options. You can explicitly specify the hostname using your own variable, or implicitly specify it using the superglobal $_SERVER.

For example, one might want to do this:

$redirect_hostname = $_SERVER[‘SERVER_NAME’] ;
$redirect_path = $_SERVER[‘REQUEST_URI’];
$redirect_url = ‘http://’ . $redirect_hostname . $redirect_path;

$u_login_logout = ‘…/wordpress/wphpbb-login.php?action=logout&redirect_to=’ . $redirect_url . ‘&sid=’ . $userdata[‘session_id’];

Edit: It should be obvious but $redirect_hostname should be the hostname of your website.

:cool: [color=#6600CC]Atropos[/color] | openvein.org


#4

How do you know it should be mysql.example.com instead of www.example.com? Just wondering.

tor.eff.org


#5

Good catch on my “bad” advice there… I didn’t look at the code closely enough, and have edited my post, but I believe in this instance if the OP chooses to define the path explicitly, he needs to use the path of his http server, not his mysql server…or am I completely missing this? (which is certainly possible!)

–rlparker


#6

I should have stated I would need “dummied” down answers. :slight_smile: The instructions for the plug in said to use the absolute path.

You said I would need to replace “localhost” with the host for my database.

When I created the database, the “hostname” was prepopulated with “mysql.ylice.net”. I did not change this.

So, would the path be - http://www.ylice.net/mysql.ylice.net/ ?


#7

I’m sorry for the confusion…I think what should go there is either an environment variable that contains your domain, or actual “hardcoding” in your domain, not your database host.

I think what should go in there is:

http://www.ylice.net/

I believe the code is to handle to routing of pages to your site, not interaction with your database (note the other messages in this thread).

What pluy-in are you trying to install?(name - link, etc.)? I’ll go take a look and get a better idea of what is involved if you would like for me to.

–rlparker


#8

You’re right, he does need to specify the hostname of a HTTP server, in particular the one hosting his web site. I’ve edited my post as well.

I assumed OP just needed clarification that he needs to modify the script to use a different hostname. I interprated his statement as an observation that one cannot use localhost based on the documentation or experience with using databases.

:cool: [color=#6600CC]Atropos[/color] | openvein.org


#9

I’m using wphpBB-Login v0.12. It can be found at - http://www.happypoet.com/hackery/wphpbb-login/

I’ll try your suggestion. I know just enough to be dangerous.

I used the path to my database earlier and the forum page was OK, but my main site page was blank.

Thanks for your help.


#10

No probelm - we kinda “borked” up giving you a clean-cut answer on your question, and I apologize. I’ll go over an take a look at the plug-in, though I think , especially from you last post, that you will be “good to go” with your main site url in place of localhost.

Please post back and let us know how it goes, ok? :wink:

–rlparker


#11

Thanks, I will.

I think there are other adjustments I’ll need to make. I can’t seem to find one set of instructions that gives all the same information.

I have done everything that came with the plug in zip, but I found some additional instructions on his website.

I’m headed to update my “localhost” mistake now.


#12

http://www.ylice.net didn’t work.

My main site is still blank.

I"m going to restore everything back to the way it was and see if I can figure it out from a “clean” start.


#13

I’m sorry to hear that…(you did clear all your caches, right?) I just went to your site, and it looks good; you must have already “undone it all”.

I’ looking at the plug-in now, and will post back if I find anything helpful…

–rlparker


#14

I’m giving up. At least for tonight. I put everything back like it was.

This is what the instructions with the plug in said to do -

I kept getting a blank index page.

  1. Done
  2. Done
  3. Done
  4. No clue!
  5. Done
  6. Done
  7. Done
  8. Done
  9. Done
  10. Didn’t work.
  11. Done - this was my “localhost” question.
  12. Not yet!

But, on his website, I also found -

The find function instructions weren’t with the plug in I downloaded.

So, I’ll try again when my head quits hurting.


#15

I understand…I just spent about 30 minutes digging through the site for the plug-in, and now my head is starting to hurt too :frowning: . The documentation is a “mess”, and I’m not real thrilled that installing this plug-in requires editing the “core” files of both phpbb and wp. - that should make upgrades (especially important with PhpBB, given its security history!) a real “joy” (not!).

I’m not 100% sure I yet understand a lot of what I’ve read over there…and I know I’m not sure where the code you supplied was from (wp or phpbb, or the plug-in) - I am 100% sure that the installation seems to be pretty convoluted.

If you feel like giving it a try another time, whay don’t you start a new thread, or maybe you can find someone over on the wordpress.org support forum who has installed this puppy on Dreamhost.

It appears from some of the discussion on the author’s site that mod_security could be impacting the install also, and that is the “Extra Web Security” check-box setting option for domains (see Edit Domain in the Control Panel).

All in all, not encouraging indeed - and I don’t have a spare PHPBB and WP installation laying around to test it with conveniently.

Who knows, maybe it will all look better in the morning…

–rlparker