Having trouble with relative paths...
Posted: Thu Jan 08, 2009 7:25 am
Hey folks.
I'm having some trouble with the following snippet. It works fine on my machine but on some machines it doesn't work.
I've pinned the issue. On some machines the "__FILE__" output includes a ".peep" directory in the path that isn't in the "DOCUMENT_ROOT" readout.
This is the code:
I'm having some trouble with the following snippet. It works fine on my machine but on some machines it doesn't work.
I've pinned the issue. On some machines the "__FILE__" output includes a ".peep" directory in the path that isn't in the "DOCUMENT_ROOT" readout.
Code: Select all
echo dirname(__FILE__);
output:
/home/.peep/user/domain.com/test/Code: Select all
echo $_SERVER['DOCUMENT_ROOT'];
output:
/home/user/domain.comThis is the code:
Code: Select all
$sq_this_site = substr(__FILE__, strlen($_SERVER['DOCUMENT_ROOT']));
$sq_this_dir = dirname(str_replace('\\', '/', $sq_this_site));
$url_protoc = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
$sq_this_sq = $url_protoc.$_SERVER['HTTP_HOST'].'/'.$sq_this_dir;
$sq_this_site = $sq_this_sq.'/?uk='.$sq_unique_key;
$sq_initial_query = $sq_domain.'?cb='.urlencode($sq_this_site);
?>
<link rel="stylesheet" href="<?php echo $sq_this_sq; ?>/cssdocument.css" type="text/css" />
<script src="<?php echo $sq_this_sq; ?>/script1.js" type="text/javascript"></script>
<script src="<?php echo $sq_this_sq; ?>/script2.js" type="text/javascript"></script>
<script src="<?php echo $sq_initial_query; ?>" type="text/javascript"></script>