Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
electrum

Trouble With The Absolute_Url Function Of Chapter 11

Recommended Posts

Hi there,

 

I am really enjoying the book, but I have been having trouble with the login_functions.inc.php script in chapter 11.

 

This is not due to an error in the code, or typeing errors, the script runs fine and does exactly what it is supposed to do. My problem is I cannot use the function myself because of the way my cgi server is set up with my domain name by my ISP.

 

when concatenating the parts of the URL together in the absolute_url() function, with the variables

 

$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);

 

The parts of these variables add up to "http://" . "cgi.usrname.host.com" . "~usrname/folder1/folder2/loggedin.php"

 

The trouble is the path to the loggedin.php script is actually "http://cgi.usrname.host.com/folder1/folder2/loggedin.php"

 

Its also compounded by the trouble that I host under a domain name, so "http://cgi.mydomain.com/folder1/folder2/loggedin.php"

is completely inaccessible. by the header function redirect. (cgi.mydomain.com masks for the cgi.usrname.host.com address)

 

It took me a while to discover this, because the server will automatically search for the nearest index.php script. The page will redirect to index.php

for some reason. and list as "http://cgi.usrname.host.com/~usrname/folder1/folder2/index.php"

Trying to access any other page with that directory structure gives the standard page inaccessible error

 

The cookies are accepted and login occurs with the correct welcome message, (my first name) when the address is typed in properly (in the same session).

(Either "http://cgi.usrname.host.com/folder1/folder2/loggedin.php" or its equivalent "http://cgi.mydomain.com/folder1/folder2/loggedin.php")

 

Is there a fix for this to allow me to be able to use a function like this easily as I would wish? -preferably with equal applicability)

 

I would be most grateful for any help, thank you!

Share this post


Link to post
Share on other sites

Hi again,

 

I managed a rather bodge job of fixing this...

 

simply used str_ireplace to remove '~usrname/' from the path and replace it with an empty string.

 

I would prefer to find some way that would keep this script as universal as possible. Any ideas?

 

Thanks.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...