Are you sure that was page 321? I have that code on page 305.
I see that it is used in two places: db_insertpics.php and viewpostcard.php. It looks like viewpostcard.php does not use the path -- it is possible that it did in an earlier incarnation, but does not now. It is not currently needed in viewpostcard.php.
However, it IS needed in db_insertpics, and what that little piece of code does is builds up a URL.
As I'm sure you know, a url is made up of parts. The protocol (http, https, ftp, etc.), the server address, the path, and the file. Of course, there is more to it, but that is the basics. Let's look at each piece:
Code:
$path = âhttpâ . ($_SERVER[âHTTPSâ]==âonâ?âsâ:ââ)
This part starts $path with "http" and if you are on a secure connection, adds an "s".
Code:
. â://â . $_SERVER[âSERVER_NAMEâ]
Next, the :// is added, as well as the server address. so now we have "http://www.yourserver.com/".
Code:
strrev(strstr(strrev($_SERVER[âPHP_SELFâ]),â/â))
I'm assuming that if you weren't referring to the $path being in the viewpostcard.php file, then your question might be referring to the above part of the code. What we're doing here is reversing the URL of the page we are currently on. So, if were were on "http://www.myserver.com/path/to/file/somefile.php" it would be reversed to "php.elifemos/elif/ot/htap/moc.revresym.www//:ptth". With me so far? Then, it performs strstr() on that string, returning the string starting with the first "/". In our example, that would be "/elif/ot/htap/moc.revresym.www//:ptth". We then reverse it again, and are left with "http://www.myserver.com/path/to/file/".
It's a quick and dirty way of returning the path, when you need to trim off the filename and any querystring variables.
Sorry for the confusion. Hope that answers your question.