|
|
Better control of site content and access By Red Squirrel 1) The client requests a certain page, and sends the cookie information stored for the CMS. 2) The CMS main page (index.php) loads the validation module, which can be a separate file. 3) The validation module checks to see if the cookie information sent matches with a user in the database, if there is no cookie, the guest profile is used. 4) We make sure the module requested actually exists, if yes we include the file, if not we change the requested module to be the 404 one so when the module loads, it will load a 404 page. 5) If the user has access to this document, we keep going, otherwise we switch to showing the login module instead. 6) The header template is loaded. This is the start of the actual html output. 7) Depending on the document requested (via a query string, such as index.php?document=home) the right file is included, if it's an invalid request we'll load the 404 module. 8) Depending on what the document is suppose to do (ex: load various info from a database) it does it. 9) We then load the footer template, then exit. Of course, this can change depending on how you program it. So a basic structure for this would be to have an index.php that handles all the requests, a auth.php which handles the authentication stuff, a header.php which is mostly html for the header, a module/[name].php for each different page and finally, a footer.php which would be mostly html for the footer. The index.php's job would also be to determine what page to load, let's say we have the url index.php?page=articles it would then load the module/articles.php page. So here's some code for index.php 1: here we simply put the var of the get (index.php?page=) into another var. This is in case we decide to change page= to something else, like module=, it makes it so you have less variables to change. On the line after we just default to home if the var is empty. 2: Here we check to make sure it is valid, I'm sure there's better and more dynamic ways to do this, but to keep things simple, this is how I did it here. 3: Here we include a script that will take care of authenticating the user, we chose to put this after the requested page stuff for a reason, because we'll want the $module variable later in this file. 4: This is where we include a file, probably mostly html that starts to build the layout - the header. 5: Here the right module is loaded. If there are other arguments such as act= they are handled in that file. Html data would also be in this file, to form the actual content, but thanks to css, the colors could still be handled in the header, so change the css values, and you can change all the pages' colors. 6: Finally, we end with the footer, closing off the html output. On the next page we'll take a look at how auth.php will handle logins and such.
Next Page
|
![]() |
This site best viewed in a W3C standard browser at 800*600 or higher Site design by Red Squirrel | Contact © Copyright 2012 Ryan Auclair/IceTeks, All rights reserved |