Misc Links
Forum Archive
News Archive
File DB
 

Ads
 

Advertisement
Age of Valor - Ultima Online Free Shard
AoS/SE/ML/Custom - advanced code, dedicated staff, peerless bosses, non overpowered customs + much much more
 

Latest Forum Topics
Possibly shutting down forum in near future
Posted by Red Squirrel
on Jan 21 2012, 5:19:43 pm

How to solve "ZoneMinder Console - Stopped"
Posted by Red Squirrel
on Jan 14 2012, 12:28:31 am

had fun on last day of 2011
Posted by rovingcowboy
on Jan 01 2012, 5:30:47 pm

Merry Christmas!
Posted by rovingcowboy
on Jan 01 2012, 5:11:32 pm

How to solve SMF directory not writable
Posted by Red Squirrel
on Oct 15 2011, 12:03:38 am

 

Creating your own content management system with php
Better control of site content and access
By Red Squirrel


The following steps will be involved when a page is requested from the CMS system:

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
spacer
16797 Hits Pages: [1] [2] [3] [4] 1 Comments
spacer


Latest comments (newest first)
Posted by Andy on October 10th 2004 (08:52)
LOL I was about to say. WOW this guest is smart. Why can't i find someone like that at my site. laugh.gif
spacer
View all comments
Post comment


Top Articles Latest Articles
- What are .bin files for? (27988 reads)
- Text searching in linux with grep (22605 reads)
- SPFDisk (Special Fdisk) Partition Manager (17074 reads)
- Creating your own content management system with php (16797 reads)
- PSP User's Guide (16567 reads)
- How to Use MDADM Linux Raid (14859 reads)
- What is Cloud Computing? (14887 reads)
- Dynamic Forum Signatures (version 2) (15258 reads)
- Successfully Hacking your iPhone or iTouch (15922 reads)
- Ultima Online Newbie Guide (16386 reads)
corner image

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