Jump to content

Recommended Posts

hi there ...

At my job, we have multiple people working on a website for a client.

Most of us use macs to do this and our server is running apache on BSD.

In order for us to view our work on our local machines as well as on our dev server (also a mac) I need to have some code that can automatically determine the path to the include directory where the site's configuration file lives.

locally on our machines we would look at the site at:  http://127.0.0.1/~user/domain (files in the user's ~/Sites directory)
the dev server on http://devserver/doman (files in /Library/WebServer/Documents)
the production server on http://www.domain.com/ (files in /home/web/sites/domain)

the following code SEEMS to handle this ... buy studying the path and looking to see if Library or Users exists in the path (then it is local or dev) and if not, then it is the live server.

[code]


$uri  =  explode("/", $_SERVER['PATH_TRANSLATED']);
$path_site  =  "http://".$_SERVER['HTTP_HOST'].(ereg('Library|Users', $uri[1]) ? ($uri[3] == "Sites" ? "/~$uri[2]/".$uri[(array_search($site,$uri))] : "/".$uri[(array_search($site,$uri))]) : ((array_search($site,$uri)) > 4 ? "/".$uri[(array_search($site,$uri))] : ""));


[/code]


However, I am getting the following error in the php errorlog ONLY on the live server:


[Thu Jul  6 13:00:02 2006] [error] PHP Warning:  array_search() [<a href='function.array-search'>function.array-search</a>]: Wrong datatype for second argument in /home/web/sites/domain/include/config.php on line 46


Can anyone tell me what I am doing wrong, or even if I should worry about this error?  The sites work just fine on all machines so it looks like it is working but I do not like error messages.

Also ...

can anyone offer a better way to do this? if my way is flawed?

thanks in advance

Gordon
This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.