bmobm Posted June 9, 2007 Share Posted June 9, 2007 I have a website which is running PHPProbid. I have tried to register on their forums but after 3 weeks of trying i am giving up in the hope that someone else may be able to assist me with my problem. My directory is similer to this: ROOT | | ------------------- | | | | probid folder | | | | another folder another folder example here (this will give you a better idea of what it looks like and what i mean) Any way i want tp put an index file in the ROOT folder which calles files from within the probid folder. i.e. the header and footer and main categories which appear on the left side of the pages. basically i want the index (which will be outside of the probid directory) to look like THIS which is IN the probid directory. But i dont what the log in our register boxes in the main part of the page just what you can see header, left side and Footer. I have tried to link to these pages but i am getting a permissions error and i have tried just about every thing my personal knowledge of PHP can do (which isnt much lol) I realise that i will also need some help with MySQL also as the categories and the login ect work via that but i will sort that once i have managed to make the index with a header, footer and the side bar. If any one can help me out i would be very greatful. Thank you all in advance Quote Link to comment https://forums.phpfreaks.com/topic/54868-using-includes-from-ourside-the-directory/ Share on other sites More sharing options...
shedokan Posted June 9, 2007 Share Posted June 9, 2007 do you mean like include the files? are you trying to do this? include this file http://www.yourwebsite.com/dir/file.php from here http://www.yourwebsite.com/dir/file.php Quote Link to comment https://forums.phpfreaks.com/topic/54868-using-includes-from-ourside-the-directory/#findComment-271348 Share on other sites More sharing options...
bmobm Posted June 9, 2007 Author Share Posted June 9, 2007 when you visit www.mysite.co.uk its redirected to a sub directory of www.subdirectory.mysite.co.uk i need to call files from www.mysite.co.uk/subdirectory/themes/chosen_theme/ to an index which will be in the ROOT directory which is 1 level up from the subdirectory does this make sense? click HERE for a rough idea of what i mean Quote Link to comment https://forums.phpfreaks.com/topic/54868-using-includes-from-ourside-the-directory/#findComment-271353 Share on other sites More sharing options...
chigley Posted June 9, 2007 Share Posted June 9, 2007 Try include("../file.php"); I'm really not sure if that'll work though... Quote Link to comment https://forums.phpfreaks.com/topic/54868-using-includes-from-ourside-the-directory/#findComment-271356 Share on other sites More sharing options...
bmobm Posted June 9, 2007 Author Share Posted June 9, 2007 but i thought that would only work from within the directoy the other files which call the files i want reside in. ../ i thought meant the directory the files are in and the /folder/folder/file.php path to the one i want? Does this still work when calling files to a files outside of this directory? To be honest its almost like a chmod prob if you get what i mean. its like the files im trying to call are protected from being called or linked to from out side the probid directory. am i making sense here? Quote Link to comment https://forums.phpfreaks.com/topic/54868-using-includes-from-ourside-the-directory/#findComment-271360 Share on other sites More sharing options...
shedokan Posted June 9, 2007 Share Posted June 9, 2007 you can do : include("../path/to/file.php") Quote Link to comment https://forums.phpfreaks.com/topic/54868-using-includes-from-ourside-the-directory/#findComment-271369 Share on other sites More sharing options...
bmobm Posted June 9, 2007 Author Share Posted June 9, 2007 would it work if i for example took a page from inside the script directory (copied it) and put it in the ROOT directory and then just changed the path to the includes ie include("../subdirectory/themes/chosen theme/file.php") understanding that "../" means the directory the file USING the includes is in Is it possible that the files have some protection to stop them being callef outside of the directory they are intended to be used in?? if si is there a way around this? Quote Link to comment https://forums.phpfreaks.com/topic/54868-using-includes-from-ourside-the-directory/#findComment-271376 Share on other sites More sharing options...
bmobm Posted June 9, 2007 Author Share Posted June 9, 2007 the files i want to include mainly are these files include_once ("config/config.php"); include ("themes/".$setts['default_theme']."/header.php"); include ("themes/".$setts['default_theme']."/footer.php"); ?> so if my directory for the themes is mysite.co.uk/subdirectory/themes.choosen_theme/file.php and i want to include the files to a document in mysite.co.uk do i change the include to include ("../subdirectory/themes/".$setts['default_theme']."/header.php"); and include ("../subdirectory/themes/".$setts['default_theme']."/header.php"); oh ive just noticed something also there is a MySQL query in there aswell isnt there? for the defult theme. would i need to make any amendments for that to work or should it still work? Quote Link to comment https://forums.phpfreaks.com/topic/54868-using-includes-from-ourside-the-directory/#findComment-271395 Share on other sites More sharing options...
shedokan Posted June 9, 2007 Share Posted June 9, 2007 if you put the file that has include("../path/to/file.php") in it so you need to delete the ../ Quote Link to comment https://forums.phpfreaks.com/topic/54868-using-includes-from-ourside-the-directory/#findComment-271438 Share on other sites More sharing options...
bmobm Posted June 9, 2007 Author Share Posted June 9, 2007 ive just tried this: <?php include ("/home/username/public_html/header.php"); include ("/home/username/public_html/mainpage.php"); include ("/home/username/public_html/footer.php"); ?> but im getting errors still, as shown below Warning: main() [function.main]: open_basedir restriction in effect. File(/home/username/public_html/header.php) is not within the allowed path(s): (/home/bmobm/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/bmobm/public_html/indextest1.php on line 2 Warning: main(/home/username/public_html/header.php) [function.main]: failed to open stream: Operation not permitted in /home/bmobm/public_html/indextest1.php on line 2 Warning: main() [function.main]: open_basedir restriction in effect. File(/home/username/public_html/header.php) is not within the allowed path(s): (/home/bmobm/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/bmobm/public_html/indextest1.php on line 2 Warning: main(/home/username/public_html/header.php) [function.main]: failed to open stream: Operation not permitted in /home/bmobm/public_html/indextest1.php on line 2 Warning: main() [function.include]: Failed opening '/home/username/public_html/header.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/bmobm/public_html/indextest1.php on line 2 Warning: main() [function.main]: open_basedir restriction in effect. File(/home/username/public_html/mainpage.php) is not within the allowed path(s): (/home/bmobm/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/bmobm/public_html/indextest1.php on line 3 Warning: main(/home/username/public_html/mainpage.php) [function.main]: failed to open stream: Operation not permitted in /home/bmobm/public_html/indextest1.php on line 3 Warning: main() [function.main]: open_basedir restriction in effect. File(/home/username/public_html/mainpage.php) is not within the allowed path(s): (/home/bmobm/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/bmobm/public_html/indextest1.php on line 3 Warning: main(/home/username/public_html/mainpage.php) [function.main]: failed to open stream: Operation not permitted in /home/bmobm/public_html/indextest1.php on line 3 Warning: main() [function.include]: Failed opening '/home/username/public_html/mainpage.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/bmobm/public_html/indextest1.php on line 3 Warning: main() [function.main]: open_basedir restriction in effect. File(/home/username/public_html/footer.php) is not within the allowed path(s): (/home/bmobm/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/bmobm/public_html/indextest1.php on line 4 Warning: main(/home/username/public_html/footer.php) [function.main]: failed to open stream: Operation not permitted in /home/bmobm/public_html/indextest1.php on line 4 Warning: main() [function.main]: open_basedir restriction in effect. File(/home/username/public_html/footer.php) is not within the allowed path(s): (/home/bmobm/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/bmobm/public_html/indextest1.php on line 4 Warning: main(/home/username/public_html/footer.php) [function.main]: failed to open stream: Operation not permitted in /home/bmobm/public_html/indextest1.php on line 4 Warning: main() [function.include]: Failed opening '/home/username/public_html/footer.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/bmobm/public_html/indextest1.php on line 4 by the way what does open_basedir restriction in effect mean? Quote Link to comment https://forums.phpfreaks.com/topic/54868-using-includes-from-ourside-the-directory/#findComment-271524 Share on other sites More sharing options...
the_oliver Posted June 9, 2007 Share Posted June 9, 2007 http://www.supanames.com/support/open_basedir.html - has a good explination. Odvious question: Is the web users (apache usualy) actualy permited to read that file? I had this problem a while back and found that selinux was the problem. dont know if thats of any relivance to you. Quote Link to comment https://forums.phpfreaks.com/topic/54868-using-includes-from-ourside-the-directory/#findComment-271543 Share on other sites More sharing options...
bmobm Posted June 10, 2007 Author Share Posted June 10, 2007 Ok ,ive got it narrowed down to this: it seems that the scripts require a defined constant and i need to ensure that other files are also included, which isnt happening at the moment. so i will need to somehow make sure those other files are in the proper directory for inclusion by the header/footer, either by manually editing the header/footer, or moving the files to a different directory, which could then break even more stuff. lol somebody on another forum suggested that Your best bet would probably be to make sure your new directory structure matches the themes (or whatever it looks like you're trying to integrate) directory structure, aside from it being in a subdirectory. but being new to all this i dont actually know what he means. BUT ive come up with a plan.............. what do you think about this idea???? would it work if i copied the probid directory structure (just the files and folders which the includes are trying to call) to the ROOT. in the same structure as they are in the probid directory. thus making the index (which is in the ROOT) think its still inside the probid directory, and if i only call the files which i need for the index then this shouldnt use up to much space.......... is this right? but would i need to modify any settings for the database or will it still be able to find the database from either directory? (i think thats a question for the MySQL forum lol. ) Quote Link to comment https://forums.phpfreaks.com/topic/54868-using-includes-from-ourside-the-directory/#findComment-271616 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.