Forums / General Questions / how do include a file outside the zencart directory

how do include a file outside the zencart directory

Locked

Views: 2,160

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
15 Dec 2007, 12:48 AM
#1
apathy avatar

apathy

New Zenner

Join Date:
Sep 2007
Posts:
60
Plugin Contributions:
0

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!??!

15 Dec 2007, 1:37 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: how do include a file outside the zencart directory

apathy:

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.

15 Dec 2007, 8:18 AM
#3
chuck avatar

chuck

Totally Zenned

Join Date:
Jul 2005
Posts:
255
Plugin Contributions:
0

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.

16 Dec 2007, 4:11 AM
#4
apathy avatar

apathy

New Zenner

Join Date:
Sep 2007
Posts:
60
Plugin Contributions:
0

Re: how do include a file outside the zencart directory

chuck:

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?

16 Dec 2007, 4:13 AM
#5
apathy avatar

apathy

New Zenner

Join Date:
Sep 2007
Posts:
60
Plugin Contributions:
0

Re: how do include a file outside the zencart directory

chuck:

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

16 Dec 2007, 4:14 AM
#6
apathy avatar

apathy

New Zenner

Join Date:
Sep 2007
Posts:
60
Plugin Contributions:
0

Re: how do include a file outside the zencart directory

DrByte:

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.

16 Dec 2007, 9:07 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: how do include a file outside the zencart directory

apathy:

DrByte:

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.

17 Dec 2007, 5:49 PM
#8
apathy avatar

apathy

New Zenner

Join Date:
Sep 2007
Posts:
60
Plugin Contributions:
0

Re: how do include a file outside the zencart directory

DrByte:

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.

17 Dec 2007, 6:24 PM
#9
apathy avatar

apathy

New Zenner

Join Date:
Sep 2007
Posts:
60
Plugin Contributions:
0

Re: how do include a file outside the zencart directory

DrByte:

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?

17 Dec 2007, 7:02 PM
#10
apathy avatar

apathy

New Zenner

Join Date:
Sep 2007
Posts:
60
Plugin Contributions:
0

Re: how do include a file outside the zencart directory

apathy:

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.