elmas156 Posted January 26, 2011 Share Posted January 26, 2011 Hello everyone, I have a general question about something that I've been thinking about doing but have not tried yet. It involves including entire php pages rather than a short snippet of code. Here's my situation: I've created a website that caters to many different schools, each of which is assigned a sub-domain so that they have "their own" web site instead of going to one site and then clicking a link to get to their page. Every site is identical with the exception of a few images. The way I'm currently doing things is to upload every page of code into each folder the each website. Doing it this way, I'm using a lot of disk space and each time I edit one page of code, I have to upload that page to every folder in my directory. It's not too bad with only a few folders, but as more schools use my site, it could become a nightmare! What I'm thinking about doing is to upload all my pages to the parent directory, then on each page in my folders for the sub-domains just include the corresponding page in the parent directory. I will just keep the images for each sub-domain in the corresponding folder. For example, the actual code for the index page in each of my sub-domain folders would be this: <?php include("../indexpage.inc.php"); ?> This way, I use less disk space and if I need to edit some code, I do it once, and upload it once to the parent directory, instead of having to upload it to each and every folder. Does anyone see any problem with doing this? Thanks for your opinion. Quote Link to comment Share on other sites More sharing options...
ChemicalBliss Posted January 26, 2011 Share Posted January 26, 2011 This could be more complicated than you think, depending on how complicated your code is at the moment. Basically what your thinking of is how most PHP programmers include "page content". Think of this structure: Home-> Includes-> school1-> Page1.php Page2.php school2-> Page1.php Page2.php school3-> Page1.php Page2.php Your "index.php" in your "Home" directory would control which website the user wants to see (using URL recognition or other methods). It would then proceed to include the page that was requested, but depending on which website the user wants it from it will grab it from where its needed, for example: User requests Page 1 using the url school1.alltheschools.com?page=1 PHP will recognize "school1" and "page=1". the include will look like: include("./includes/".$school_subdomain."/Page".$_GET['page'].".php"); This as i've explained is a security vulnerability since $_GET['page'] could be anything, and so if your "secure" pages were say, Page1secure.php, they could potentially gain access so jsut be aware of that. Hope this helps Quote Link to comment 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.