Effective way to find particular directory name?
<p>I have a script that I've written that I sell to others who want a virtual gift application on Facebook.  As many of the customers who buy this script don't actually have programming knowledge, I try to simplify things as much as is possible for them by gathering as much data as I can without their input (such as using <code>$_SERVER</code> vars).</p>

<p>I'm running into a problem when trying to establish a static directory for images, though, that the code can read and always know where that directory is.</p>

<p>For instance, on my 'masterfile.php' which is included on most every page I have this:</p>

<pre><code>$app_info['server_url']="http://".$_SERVER['SERVER_NAME'];
$app_info['callback_url']=$app_info['server_url'].dirname($_SERVER['PHP_SELF'])."/";
$app_info['image_url']=$app_info['callback_url'].'images/';
</code></pre>

<p>That gives me all the necessary information I need about where folders are located... unless I'm using a directory inside the parent directory to the entire script (IE: /folder/ajax/).</p>

<p>I'm running into a problem where the 'images' folder needs to always be '/folder/images/' instead of ending up as '/folder/ajax/images/' when working with other directories inside the parent.</p>

<p>I can't just hard code the parent directory name as some customers upload them to directories such as '/folder/folder/folder/folder/script/' - that's why I use <code>$_SERVER['PHP_SELF']</code> to establish the parent directory.</p>

<p>Is there a way (or a variable) that I can use for this problem?  I just need to ensure that the <code>$app_info['callback_url']</code> is always the same, regardless of the current directory.</p>

<p>Thanks!</p>
