Chris P Posted November 10, 2008 Share Posted November 10, 2008 Ok. So I am trying to do an include for a file that is above the root of the website. Its actually part of a subdomain that I have. I have default.php in the root of my site. It calls a file that is above the root in a different folder than site1. This works like a charm. I have another PHP file in a subfolder of the site1 that is trying to call the same file above the root. It doesnt work. stops parsing the file as soon as it tries to load. require($_SERVER["DOCUMENT_ROOT"].'/../blog.liquidarchaeology.com/wp-blog-header.php'); I have tried many variations on the above code but nothing will work. If I move said file to the root of the website then it works mint. But I cant have all my files in the root. Too messy for me. Why is it that I can only access files above to root when processing a file in the root? Link to comment https://forums.phpfreaks.com/topic/132207-solved-include-from-outside-root-works-but-not/ Share on other sites More sharing options...
jajtiii Posted November 10, 2008 Share Posted November 10, 2008 You can definitely include files outside of your web root. Your problem is the server variable that you are using. Assuming you are on a Windows box, try something like : $phpinc = "C:/Inetpub/phpincludes"; Then, in your code, replace $_SERVER["DOCUMENT_ROOT"] with $phpinc. You'll need to make sure that the WebServer has at least Read access to this area on the server/pc. Link to comment https://forums.phpfreaks.com/topic/132207-solved-include-from-outside-root-works-but-not/#findComment-687224 Share on other sites More sharing options...
PFMaBiSmAd Posted November 10, 2008 Share Posted November 10, 2008 It is probably an owner/permissions problem. What you do get if you add the following two lines in your main file immediately after your first opening <?php tag - ini_set ("display_errors", "1"); error_reporting(E_ALL); Link to comment https://forums.phpfreaks.com/topic/132207-solved-include-from-outside-root-works-but-not/#findComment-687225 Share on other sites More sharing options...
Chris P Posted November 10, 2008 Author Share Posted November 10, 2008 Not a windows box. I have even tried specifying the exact path. Like this require('/hsphere/local/home/cphinney/blog.liquidarchaeology.com/wp-blog-header.php'); When that line is in /hsphere/local/home/cphinney/liquidarchaeology.com/default.php it works. When its in /hsphere/local/home/cphinney/liquidarchaeology.com/team/team.php it doesnt. The only diff is that one is in the root of the website and the other is in a folder under that same root. Link to comment https://forums.phpfreaks.com/topic/132207-solved-include-from-outside-root-works-but-not/#findComment-687226 Share on other sites More sharing options...
Chris P Posted November 10, 2008 Author Share Posted November 10, 2008 I get nothing. Not even a blip... The page starts to load and then stops. eg. http://liquidarchaeology.com/Team/team.php Link to comment https://forums.phpfreaks.com/topic/132207-solved-include-from-outside-root-works-but-not/#findComment-687229 Share on other sites More sharing options...
jajtiii Posted November 10, 2008 Share Posted November 10, 2008 I wonder what is in here : wp-blog-header.php You can definitely include 'wp-blog-header.php' in any page on your site. Can you post the code in your header file? Link to comment https://forums.phpfreaks.com/topic/132207-solved-include-from-outside-root-works-but-not/#findComment-687242 Share on other sites More sharing options...
Chris P Posted November 11, 2008 Author Share Posted November 11, 2008 <?php /** * Loads the WordPress environment and template. * * @package WordPress */ if ( !isset($wp_did_header) ) { $wp_did_header = true; require_once( dirname(__FILE__) . '/wp-load.php' ); wp(); require_once( ABSPATH . WPINC . '/template-loader.php' ); } ?> Stock. And working on pages in the root of my site. Just not in subfolders. Link to comment https://forums.phpfreaks.com/topic/132207-solved-include-from-outside-root-works-but-not/#findComment-687462 Share on other sites More sharing options...
jajtiii Posted November 11, 2008 Share Posted November 11, 2008 So, how do you know it is not working? The problem may be that the script is working, but when it tries to parse the includes within the script, they fail. Temporarily change your script to : if ( !isset($wp_did_header)) { echo 'Header defined.'; } else { echo 'Header not defined.'; } My point is that it is likely that the problem exists with your included script. To further prove this, change that script to simply ECHO out the paths, instead of including them. Like : echo dirname(__FILE__) . '/wp-load.php'; More then likely, these paths are not valid from beneath the root directory. Link to comment https://forums.phpfreaks.com/topic/132207-solved-include-from-outside-root-works-but-not/#findComment-687630 Share on other sites More sharing options...
Chris P Posted November 11, 2008 Author Share Posted November 11, 2008 Ok so I was composing an email saying that "of course its not working... see for yourself" but decided that some people may be smarter than me and I tried it your way.... lol I changed to the code you specified and I got "header defined" even on the page that wasn't working. So not wanting to break WP but wanting to get my non blog site working with these files what do you suggest. Link to comment https://forums.phpfreaks.com/topic/132207-solved-include-from-outside-root-works-but-not/#findComment-687728 Share on other sites More sharing options...
Chris P Posted November 11, 2008 Author Share Posted November 11, 2008 I also tried echoing the path and it does come out correct. Would be nice to see some useful error messages. Link to comment https://forums.phpfreaks.com/topic/132207-solved-include-from-outside-root-works-but-not/#findComment-687732 Share on other sites More sharing options...
Chris P Posted November 11, 2008 Author Share Posted November 11, 2008 So I smattered a few echos around the code and tracked down the following; It dies at this line in taxonomy.php $wp_taxonomies['category'] = (object) array('name' => 'category', 'object_type' => 'post', 'hierarchical' => true, 'update_count_callback' => '_update_post_term_count'); Now I am not that PHP savy to know whats going on here or what the folder structure of my website could have to do with this. But an echo before and after this line only shows the echo before. Suggestions apreciated. Link to comment https://forums.phpfreaks.com/topic/132207-solved-include-from-outside-root-works-but-not/#findComment-687762 Share on other sites More sharing options...
Chris P Posted November 11, 2008 Author Share Posted November 11, 2008 Checking the error log reveals the error to be ALERT - canary mismatch on efree() - heap overflow detected (attacker '206.130.179.100', file '/hsphere/local/home/cphinney/blog.liquidarchaeology.com/wp-includes/taxonomy.php', line 18) Link to comment https://forums.phpfreaks.com/topic/132207-solved-include-from-outside-root-works-but-not/#findComment-687776 Share on other sites More sharing options...
Chris P Posted November 11, 2008 Author Share Posted November 11, 2008 Made my first .htaccess file and fixed the darn thing. php_flag zend.ze1_compatibility_mode Off php_value memory_limit 32M Thanks to those that kickjed my ass in the right direction. Link to comment https://forums.phpfreaks.com/topic/132207-solved-include-from-outside-root-works-but-not/#findComment-687797 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.