SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist cronsrcs's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_server['path_translated'], $_server['document_root']

    I have just taken over some PHP code written by another developer.

    I have just setup a development environment where I develop locally on my PC (PHP 4.4.0, Apache 2.0.54, MySQL 4.1.14), test on a staging server 4.4.0 (Apache 2.0.54, MySQL 4.1.14) and then deploy to the production server that is running PHP 4.4.3, Apache 1.3.37 and MySQL 4.0.25.

    I have recently obtained a copy of all the site files from the production server and placed on the local dev environment and staging servers. I also created and populated the MySQL DB tables....So effectively I have a mirror image of the production server on my local machine and also the staging server.

    My question / problem is to do with the value of $_SERVER['document_root'] and $_SERVER['path_translated']......

    My site files are stored in the following folders:

    Local Development (Win XP) - C:\xampp\htdocs\domain_name
    Staging Server (Linix Debian) - /opt/lampp/htdocs/domain_name

    The value of the $_SERVER['path_translated'] values are as follows:

    Local Development: C:/xampp/htdocs/xampp/phpinfo.php
    Staging Server: /opt/lampp/htdocs/xampp/phpinfo.php
    Production Server: /home/nicegroup/public_html/phpinfo.php

    My problem occurs on the login page for an admin section to the site, as the previous developer has used the following code:

    Code:
    if (!$DOCUMENT_ROOT) 
    {
    $DOCUMENT_ROOT = 
      substr(stripslashes($PATH_TRANSLATED),0,-strlen(stripslashes($PATH_INFO))+1);
    }
    
    include("$DOCUMENT_ROOT/admin/libs/admin_auth.inc.php");
    This works fine for the Production Server, but the file paths are incorrect on Development and Staging - what is the best way to overcome this problem?
    www.silver-rocket.com
    Creative Solutions for this planet and beyond...
    www.onelifeonebus.com
    Fear fading away, not burning out.

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Is register_global on?

    http://www.php.net/register_globals
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Evangelist cronsrcs's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Local Dev - ON
    Staging Server - OFF
    Production Server - ON

    Poor coding relying on register_globals being ON, but as I said, its code that I have inherited!

    I am thinking that my best option is going to be to create virtual hosts so that the file structure on the dev and staging servers are similar....
    www.silver-rocket.com
    Creative Solutions for this planet and beyond...
    www.onelifeonebus.com
    Fear fading away, not burning out.

  4. #4
    SitePoint Evangelist cronsrcs's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry - staging server is now on as well - thought that it would be best to have all 3 environments the same
    www.silver-rocket.com
    Creative Solutions for this planet and beyond...
    www.onelifeonebus.com
    Fear fading away, not burning out.

  5. #5
    SitePoint Evangelist cronsrcs's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    500
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just for anyone else who may experience this problem in the future - I solved this by creating VirtualHosts in my httpd.conf file.

    So instead of accessing my sites like this

    127.0.0.1/mysite

    I can now access like this:

    mysite.local.com

    Sweet
    www.silver-rocket.com
    Creative Solutions for this planet and beyond...
    www.onelifeonebus.com
    Fear fading away, not burning out.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •