Results 1 to 10 of 10
  1. #1
    Join Date
    Sep 2007
    Posts
    60
    Plugin Contributions
    0

    Default how do include a file outside the zencart directory

    for my zencart is at dev.lapsf.com/estore folder

    when trying to edit a file in the zencart by adding an include such as:

    require_once('/left_nav.html');

    (in order to get the file located at dev.lapsf.com/left_nav.html)

    i get this error:


    Warning: main(/left_nav.html) [function.main]: failed to open stream:
    No such file or directory in
    D:\Share\Client_Sites\lapsf.com\estore\includes\templates\lapsf\common\tpl_main_ page.php
    on line 57

    Fatal error: main() [function.require]: Failed opening required
    '/left_nav.html' (include_path='.;C:\php5\pear') in
    D:\Share\Client_Sites\lapsf.com\estore\includes\templates\lapsf\common\tpl_main_ page.php
    on line 57


    why doesnt the "/" refer to the root directory.. is there a filepath setting i need to change? am i insane!??!

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: how do include a file outside the zencart directory

    Quote Originally Posted by apathy View Post
    why doesnt the "/" refer to the root directory.. is there a filepath setting i need to change? am i insane!??!
    Actually, it *does* refer to the root directory ... of your actual server. Not of your website.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Jul 2005
    Posts
    537
    Plugin Contributions
    0

    Default Re: how do include a file outside the zencart directory

    Ah, ya. I got stuck on that one quite awhile ago. I didn't realize that the "root" wasn't the same to the browser as it was to apache (or IIS for that matter).

    "/" means "root"
    But the "root" of the filesystem would be, in your case, "D:\"
    and the "root" according to the browser would be "D:\Share\Client_Sites\lapsf.com\"

    Sometimes you can just use the reference to the file directly, if it exists in the same folder as your store root .... ie: if your "left_nav.html" file exists inside your D:\Share\CLient_Sites\lapsf.com\estore folder, you can just do an include on "left_nav.html". If it's up a level, in the lapsf.com folder instead, you could use "../left_nav.html"

    Maybe that gives you some ideas.

  4. #4
    Join Date
    Sep 2007
    Posts
    60
    Plugin Contributions
    0

    Default Re: how do include a file outside the zencart directory

    Quote Originally Posted by chuck View Post
    Ah, ya. I got stuck on that one quite awhile ago. I didn't realize that the "root" wasn't the same to the browser as it was to apache (or IIS for that matter).

    "/" means "root"
    But the "root" of the filesystem would be, in your case, "D:\"
    and the "root" according to the browser would be "D:\Share\Client_Sites\lapsf.com\"

    Sometimes you can just use the reference to the file directly, if it exists in the same folder as your store root .... ie: if your "left_nav.html" file exists inside your D:\Share\CLient_Sites\lapsf.com\estore folder, you can just do an include on "left_nav.html". If it's up a level, in the lapsf.com folder instead, you could use "../left_nav.html"

    Maybe that gives you some ideas.

    hmm im a bit confused still. i come from a linux bg and have to work on IIS.. does this have something to do with it?

  5. #5
    Join Date
    Sep 2007
    Posts
    60
    Plugin Contributions
    0

    Default Re: how do include a file outside the zencart directory

    Quote Originally Posted by chuck View Post
    Ah, ya. I got stuck on that one quite awhile ago. I didn't realize that the "root" wasn't the same to the browser as it was to apache (or IIS for that matter).

    "/" means "root"
    But the "root" of the filesystem would be, in your case, "D:\"
    and the "root" according to the browser would be "D:\Share\Client_Sites\lapsf.com\"

    Sometimes you can just use the reference to the file directly, if it exists in the same folder as your store root .... ie: if your "left_nav.html" file exists inside your D:\Share\CLient_Sites\lapsf.com\estore folder, you can just do an include on "left_nav.html". If it's up a level, in the lapsf.com folder instead, you could use "../left_nav.html"

    Maybe that gives you some ideas.
    btw i did try doing things like ../../../../ until i got to the correct directory also.. i also tried using foward slashes /../../.

    so is it safe to say that this in MY error though? not something i need to change in Zencart correct? That would really help me narrow it down. i feel REALLY retarded being stumped on this! but as i said.. this may be some sort of linux/IIS(ugh..) issue...

  6. #6
    Join Date
    Sep 2007
    Posts
    60
    Plugin Contributions
    0

    Default Re: how do include a file outside the zencart directory

    Quote Originally Posted by DrByte View Post
    Actually, it *does* refer to the root directory ... of your actual server. Not of your website.

    i know that.. which is why that *should* make sense and work.

  7. #7
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: how do include a file outside the zencart directory

    Quote Originally Posted by apathy View Post
    Quote Originally Posted by DrByte View Post
    Actually, it *does* refer to the root directory ... of your actual server. Not of your website.

    i know that.. which is why that *should* make sense and work.
    No, it's exactly opposite to what you wanted.


    You wanted it to load
    D:\Share\Client_Sites\lapsf.com\left_nav.html

    But instead you told it to load:
    /left_nav.html

    ... which looks for "left_nav.html" at the root of the server's hard drive, not the webroot.

    If you intend to use PHP's "require" or "include" commands, you have to remember that PHP looks at files according to the Operating System of the server ... NOT the webroot the way a browser would.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8
    Join Date
    Sep 2007
    Posts
    60
    Plugin Contributions
    0

    Default Re: how do include a file outside the zencart directory

    Quote Originally Posted by DrByte View Post
    No, it's exactly opposite to what you wanted.


    You wanted it to load
    D:\Share\Client_Sites\lapsf.com\left_nav.html

    But instead you told it to load:
    /left_nav.html

    ... which looks for "left_nav.html" at the root of the server's hard drive, not the webroot.

    If you intend to use PHP's "require" or "include" commands, you have to remember that PHP looks at files according to the Operating System of the server ... NOT the webroot the way a browser would.
    i am working on a dreaded windows machine for the first time. this must be the problem. UGH!!!!!!!!!! thanks.

  9. #9
    Join Date
    Sep 2007
    Posts
    60
    Plugin Contributions
    0

    Default Re: how do include a file outside the zencart directory

    Quote Originally Posted by DrByte View Post
    No, it's exactly opposite to what you wanted.


    You wanted it to load
    D:\Share\Client_Sites\lapsf.com\left_nav.html

    But instead you told it to load:
    /left_nav.html

    ... which looks for "left_nav.html" at the root of the server's hard drive, not the webroot.

    If you intend to use PHP's "require" or "include" commands, you have to remember that PHP looks at files according to the Operating System of the server ... NOT the webroot the way a browser would.
    alright i am confused now. from tpl_main_page.php inside D:\Share\Client_Sites\lapsf.com\estore\includes\templates\lapsf\common\
    i tried including files in the same directory.. worked fine.. i also tried including file up one directory from and it worked fine, but if i try to include something out of the D:\Share\Client_Sites\lapsf.com\estore\includes\templates\lapsf\ .. in other words if i try to include something inside the template folder or above i get a fatal error where as including anything in the lapsf folder or common folder does not. and yest he file exists in all the places i tried to call it. is there a reason i cant seem to move out of the lapsf folder?

  10. #10
    Join Date
    Sep 2007
    Posts
    60
    Plugin Contributions
    0

    Default Re: how do include a file outside the zencart directory

    Quote Originally Posted by apathy View Post
    alright i am confused now. from tpl_main_page.php inside D:\Share\Client_Sites\lapsf.com\estore\includes\templates\lapsf\common\
    i tried including files in the same directory.. worked fine.. i also tried including file up one directory from and it worked fine, but if i try to include something out of the D:\Share\Client_Sites\lapsf.com\estore\includes\templates\lapsf\ .. in other words if i try to include something inside the template folder or above i get a fatal error where as including anything in the lapsf folder or common folder does not. and yest he file exists in all the places i tried to call it. is there a reason i cant seem to move out of the lapsf folder?

    nevermind i am very retarded.. i think i figured it out. i got confused because i was including in an include and was not looking at the file where everything is being included's location.. insteaded i was lookinng at the include.

 

 

Similar Threads

  1. Reading session variables outside of the zencart directory
    By refreshmentshop in forum General Questions
    Replies: 5
    Last Post: 22 Sep 2009, 09:53 AM
  2. How can I include a php file in the header section?
    By Andy_R in forum General Questions
    Replies: 3
    Last Post: 11 Sep 2009, 05:50 PM
  3. How to move ZENCART to the parent Directory
    By soultrain99 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 17 Jun 2008, 12:19 AM
  4. Using Zencart Info Outside of the zencart Directory
    By thisandthat in forum General Questions
    Replies: 6
    Last Post: 29 Dec 2007, 05:29 PM
  5. Replies: 0
    Last Post: 23 Nov 2006, 08:27 PM

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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR