It’s been a minute since the last post, and the code posted therein has changed quite a bit. Not too drastic for those pieces but definitely a difference. I’ve come to the conclusion that the Framework should be called BBG Framework. Very original, eh?

So here is the progress thus far:

Controller

index.php as the controller calls the modules, classes and events dynamically. URI rewriting proves useful in this case:
- /index.php?module=account&class=forgot&event=confirm
- /account/forgot/confirm.html

However, this may change in the future being that it is fairly rudimentary, meaning I cannot go beyond three directories (although improbable) without further mod_rewrites. I need to make the rewrite a bit more dynamic:

Options +FollowSymLinks
Options +Indexes
RewriteEngine On

# Change the URI here to whatever you want your homepage to be
RewriteRule ^$ /index.php?module=frontpage [L,QSA]

# Changes /index.php?module=frontpage to /frontpage
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)$ index.php?module=$1 [L,QSA]

# Changes /index.php?module=users&class=login to /users/login
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)/([^/]*)$ index.php?module=$1&class=$2 [L,QSA]

# Changes /index.php?module=users&class=login&event=foo to /users/login/foo.html
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ index.php?module=$1&class=$2&event=$3 [L,QSA]

This is also based off of Joe Stump’s MVC framework.

Modules

Can be easily added to the framework to expand it’s usability.

  • Standard modules included in the BBG Framework will be Account (register, login, logout, forgot, settings), Frontpage, and Profile (members, edit, view).
  • Future (game related) modules included will be Battle (turn based, real time, one time, etc), Attributes (skills, stats), Stores (shopping cart theming system), and Inventory (equipment, item management)

In due time, hopefully I can make modules more dynamic to add into the framework so any community contributed modules can be added very easily.

Built-in Classes

These are extensions of the controller from the module and include normal functions to use in your modules.

  • Display (smarty) - (Completed kinda) Translates the modules and data into something that Smarty can understand. Page wrapper for and whole site includes. Each module has its own dynamically loaded template as well. The display can also be changed to instead use Krumo to debug all info. Future additions will be to add an XML serializer and REST display.
  • Session - (Completed) Basically a $_SESSION wrapper but expands it a bit for better usage.
  • User - (Completed) Handles all the users data (userid, username, email, etc) throughout the framework. The attributes module will run a bit like this as well.
  • Validate - (Completed) Called dynamically via Validate::event(); which can be used to Validate::encrypt($password,$username) (username is used as a dynamic salt) or Validate::email($email) to check to make sure it is a valid address. Also, Validate::randStr($charLength) will return a random upper and lower case alphanumeric string, which is useful for tokens and new passwords.
  • Pagination - (Untested) Used to paginate lists like showing all the members.
  • Mail - (In progress) Handles all the mail that needs to be sent for any forms like registration. There is also an option to turn off the mail() function so instead it will print out the email on screen for testing purposes.
  • Error handling -(In progress) Called dynamically anywhere in the framework via Error::set(‘label’,'Error description goes here’) and Error::get(). Although the get part, should actually be called automatically through the Display layer of the framework.
  • Database Management(Completed) Used very easily like so:

    Database::query("SELECT * FROM users WHERE username = '%s' AND password = '%s',$user,md5($pass));
    $user = Database::getResults('a');

    Any data passed into the query is automatically sanitized. Also, a debug is available to show you all queries just in case.

Future Additions

These include expanding the Framework core to include a better ACL and obviously more security built in. Also, need to port over the original Admin panel to give a User list with quick options to change info on the fly. You’ll be able to monitor activity as well as look at reports and site statistics as well.

Game related admin activities will include Round/Tick/Resource monitoring, Item database management, Attribute management, etc.

If you have any suggestions, I will be more than happy to add them. Of course eventually I’ll have a place for people to make real suggestions that others can vote as well as a forum to actually discuss the framework and contribute to the code.

Anyway, thanks for you time… I know this wasn’t much of an update but I’ve been relearning PHP using OOP with abstract classes and much more to create this Framework. BTW, if you don’t know… its definitely going to be only for PHP5.


Leave a Comment