Jump to content


Photo

Absolute Paths in UniServer Zero


  • Please log in to reply
2 replies to this topic

#1 drjekyll-1

drjekyll-1

    Newbie

  • Member
  • Pip
  • 2 posts
  • Main OS: Windows 7

Posted 08 October 2014 - 05:57 PM

Hey guys,

Love Uniserver but am having a little problem.  I just got the new (Zero XI 11.3.3) Uniserver upgrading from Mona 4.1.  Yeah long overdue.  I use it locally to test websites before throwing them on the production server so I need all the files to be just like they would be on the production server without having to make any adaptations before uploading them.

I am working out of the home directory with all my sites just like the production server.  

In Mona I had absolute links set up to where a PHP line like this would work (the way it works on the production server).

require_once("home/webfolder/public_html/common/scripts/globalscript.php");

XI has no problem getting to the folder where the index file is just as it is set up in the virtual hosts but any absolute link in the script is broken.  Now, XI requires this to make it work.

require_once("D:/UniServerZ/home/webfolder/public_html/common/scripts/globalscript.php") 

There are several absolute links in each site and many sites to deal with.  I'd rather not have to change each sites links everytime I go to production with a site I am testing.  

I know Mona set up a drive to work from but XI does not is there a way to simulate this in XI so that my absolute paths still work without modification?

I apologize if this is an elementary question or one that has been covered before.  I looked but did not find anything.  I appreciate any help.

Thanks

 



#2 Ric

Ric

    Project Manager

  • Admin
  • PipPipPipPipPip
  • 1,535 posts
  • Gender:Male
  • Location:Cambridge,UK
  • Interests:Electronics
    Internet in general
    Open source projects
  • SourceForge IDmpgcan
  • Wiki ID: Ric
  • Main OS: Windows XP

Posted 09 October 2014 - 01:31 PM

Are you sure this works on Mona?

require_once("home/webfolder/public_html/common/scripts/globalscript.php");

Its a relative path from the current working directory. Absolute baths generally start with forward slash (start search from root folder top-level)
I think it should be:

require_once("/home/webfolder/public_html/common/scripts/globalscript.php");

Anyway back to original question

I know Mona set up a drive to work from but XI does not is there a way to simulate this in XI

Assuming you are not running servers as a service its very easy to simulate a drive.
Create a batch file us_run.bat with the following content:

SUBST X: C:\11_3_3_ZeroXI\UniServerZ
X:
Start UniController.exe

Replace X with a drive letter you wish to use e.g D replace C:\11_3_3_ZeroXI\UniServerZ with the full path to folder UniServerZ on your PC.
Double click on us_run.bat  the above creates a new virtual drive X and runs the servers at the top-level.

The above if it works! Is an interim solution. You should never ever use absolute paths more specifically hard code absolute paths. By all means use absolute paths however ensure these are dynamically calculated see PHP manual require_once

All the best
Ric



#3 drjekyll-1

drjekyll-1

    Newbie

  • Member
  • Pip
  • 2 posts
  • Main OS: Windows 7

Posted 09 October 2014 - 05:35 PM

Thanks Ric,

Yes you are correct I left out the leading forward slash.  Thanks for the temporary workaround and the require_once reference.  I cannot remember for the life of me why I needed a hard coded link in the first place but I will start fixing.  Please excuse if this is a stupid question but are hard coded paths a security risk or just a PITA?  I searched the web but could not find any detail of them being risky.  The workaround did not work though.  It says "Failed to start default browser and opens a browser window with file:///X:/home/us_splash/us_zero_ref.html as a url.  Funny though after some time it will eventually open it normally with this url http://localhost/us_splash/index.php.   My site does not work at all.  PHPmyadmin eventually opens as well.  Thanks






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users