Flight19 Posted January 12, 2010 Share Posted January 12, 2010 Hello! I am in the process of building a site for which I would ordinarily use include statements to pull page content into the main template. I'm also using a switch statement that involves includes to randomly pull content into a supplementary element on each "page." My problem? The person I am creating this site for has INSISTED on hosting with Yahoo! and Yahoo! places all sorts of restrictions on allowable PHP including the prohibition of include statements and disallowing the client from accessing php.ini and .htaccess files. I am, of course, using CSS for 100% of the styling and I know that I could revert to separate XHTML pages for all of the content and utilize JavaScript for the random content. But with the amount of content that I need to include, the JavaScript in particular would end up being very bulky indeed. Here is the code I ordinarily use to call in the page content: <?php require_once("utils.php"); $_params = getParams(); /* $_pageName = ($_params["page"] != "" ? $_params["page"] : "home"); $_pageName .= ".php"; */ $_pageName = getPage() . ".php"; ?> -and- <div class="text"> <!-- page main content area --> <?php include($_pageName); ?> <!-- end page main content area --> </div> Here is the switch statement I was utilizing for the supplementary content: <div class="feature"> <?php //chooses a random number $num = Rand (0,4) ; //starts the random quote switch loop switch ($num) { case 0: include("features/placeholder.php"); break; case 1: include("features/placeholder2.php"); break; case 2: include("features/placeholder3.php"); break; case 3: include("features/placeholder4.php"); break; case 4: include("features/placeholder5.php"); break; } ?> <div class="feature_bottom"></div></div> Does anyone have a suggestion for accomplishing these tasks without use of the include statement? Any assistance is much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/188236-i-need-a-good-alternative-for-an-include-statement-suggestions/ Share on other sites More sharing options...
wildteen88 Posted January 12, 2010 Share Posted January 12, 2010 The only way to include files is via the use of include or require. Why on earth do Yahoo! not allow the use of include? Quote Link to comment https://forums.phpfreaks.com/topic/188236-i-need-a-good-alternative-for-an-include-statement-suggestions/#findComment-993759 Share on other sites More sharing options...
The Little Guy Posted January 12, 2010 Share Posted January 12, 2010 you could... read a php file and use eval $file = 'someFile.php'; $handle = fopen($file, 'r'); $contents = fread($handle, filesize($file)); fclose($handle); eval($contents); Quote Link to comment https://forums.phpfreaks.com/topic/188236-i-need-a-good-alternative-for-an-include-statement-suggestions/#findComment-993768 Share on other sites More sharing options...
PFMaBiSmAd Posted January 12, 2010 Share Posted January 12, 2010 local inclusion using include(), include_once(), require(), and require_once() will still work normally. Are you really sure they don't allow include/require? The above quote came directly from yahoo's information - http://help.yahoo.com/l/us/yahoo/smallbusiness/webhosting/php/php-37.html Quote Link to comment https://forums.phpfreaks.com/topic/188236-i-need-a-good-alternative-for-an-include-statement-suggestions/#findComment-993769 Share on other sites More sharing options...
Mchl Posted January 12, 2010 Share Posted January 12, 2010 If anything they probably blocked remote includes, which is pretty sane in such an environment. Come on... blocking all includes? It's like disallowing <div> tag in HTML or writing C without header files. Still possible, but who would like that? Quote Link to comment https://forums.phpfreaks.com/topic/188236-i-need-a-good-alternative-for-an-include-statement-suggestions/#findComment-993777 Share on other sites More sharing options...
Flight19 Posted January 12, 2010 Author Share Posted January 12, 2010 Thanks and apologies! It's been a while since I logged into their Yahoo! site and it looks like Yahoo! updated what they allow as of October. When I first uploaded a test chunk of the site around August, Yahoo! was not allowing inclusion and was recommending another statement to access a local path, but when I tested it out, none of my variations worked out. I can see that that they still don't allow access to .htaccess or php.ini files though. I just uploaded new test files to Yahoo! (same PHP as in August but with recent changes to CSS) and it appears to be working. Thank you all for your help! Quote Link to comment https://forums.phpfreaks.com/topic/188236-i-need-a-good-alternative-for-an-include-statement-suggestions/#findComment-993783 Share on other sites More sharing options...
knsito Posted January 12, 2010 Share Posted January 12, 2010 Strange, because I know someone using Yahoo Hosting for several months now and did not have any problem with include/require Quote Link to comment https://forums.phpfreaks.com/topic/188236-i-need-a-good-alternative-for-an-include-statement-suggestions/#findComment-993789 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.