Update on the new (old) PHP forum

A few weeks ago, I gave an overly enthusiastic estimate of when I’ll be completing this project. Well it all seems to have been for the best, since I decided the one-page-software scheme isn’t really going to work these days.

While that may be ideal for certain situations, aside from the most primitive of software packages, it really doesn’t seem all that practical to put everything on one page. But I am following the small size protocol in that there will only be very few code pages. So I ended up scrapping everything and starting from scratch.

I will have some form of database abstraction. Though the first release will only have a MySQL class, I’m leaving the methods open so a substitute will be trivial to write in for other databases. The critical ones to support at this point are MySQL and SQLite. The rest will hopefully come later starting with PostgreSQL and MS SQL.

I’m releasing this without a license, but will include my usual disclaimer as found on the experiments page.  So feel free to take it apart as you wish.

In addition to this, I would encourage people to keep in mind, this is being written by a PHP novice. I can’t comment on security and performance yet, since I don’t have any testable code in that area. But I did consider performance second to security. 

  • Sessions and cookies are encrypted when created.
  • Login re-directions that start with “http://” will be checked against the site_url setting which will be the base URL for all on page links.
  • Rijndael 256 with mcrypt for everything (this includes cookie encryption which does run the risk of being a bit large).
  • Passwords and password salts are encrypted before storage in the database.

I understand the choice of encryption might be a bit overkill, but I wanted to see if I could get away with it in a production environment (which I hope to see it running in soon).

I have no idea if some of the methods I used are sound when it comes to PHP standards, but I pursued what I felt were the most reasonable methods of doing things. I don’t think a different point of view could hurt. But if I am doing something horrendously wrong, I would strongly encourage everyone to let me know right away.

I won’t be making the same mistake this time by announcing a release date, so I’ll take the Debian road and say “It’ll be ready when it’s ready.”

Here’s the MySQL DB schema :

DROP TABLE IF EXISTS `messages`;

CREATE TABLE `messages` (
	`id` bigint(20) NOT NULL auto_increment,
	`parent_id` bigint(20) default 0,
	`forum_id` int(25) default 0,
	`title` varchar(255) NOT NULL default '',
	`content` text default '',
	`content_plain` text default '',
	`created` datetime NOT NULL default '0000-00-00 00:00:00',
	`user_id` bigint(20) default 0,
	`author` varchar(50) default '',
	`author_email` varchar(100) default '',
	`author_web` varchar(255) default '',
	`author_ip` varchar(100) default '',
	`reply_count` int(25) default 0,
	`view_count` int(25) default 0,
	`locked` tinyint(4) default 0,
	`sticky` tinyint(4) default 0,
	`last_id` bigint(20) NOT NULL default 0,
	`last_author` varchar(50) NOT NULL default '',
	`last_date` datetime NOT NULL default '0000-00-00 00:00:00',
		PRIMARY KEY (`id`)
) TYPE = MyISAM DEFAULT CHARSET = utf8;


DROP TABLE IF EXISTS `forums`;

CREATE TABLE `forums` (
	`id` int(25) NOT NULL auto_increment,
	`parent_id` int(25) default 0,
	`display_order` int(16) default 0,
	`title` varchar(255) NOT NULL default '',
	`content` text default '',
	`content_plain` text default '',
	`topic_count` int(25) default 0,
	`reply_count` int(25) default 0,
	`last_id` bigint(20) default '0',
	`last_author` varchar(50) default '',
	`last_date` datetime default '0000-00-00 00:00:00',
	`read_only` tinyint(4) default 0,
	`private` tinyint(4) default 0,
		PRIMARY KEY (`id`)
) TYPE = MyISAM DEFAULT CHARSET = utf8;


DROP TABLE IF EXISTS `users`;

CREATE TABLE `users` (
	`id` bigint(20) NOT NULL auto_increment,
	`username` varchar(50) NOT NULL default '',
	`password` text NOT NULL default '',
	`password_salt` text NOT NULL default '',
	`display_name` varchar(100) default '',
	`created` datetime NOT NULL default '0000-00-00 00:00:00',
	`enabled` tinyint(4) default 1,
	`sig` text default '',
	`avatar` text default '',
	`email` varchar(100) default '',
	`web` varchar(255) default '',
	`bio` text default '',
		PRIMARY KEY (`id`)
) TYPE = MyISAM DEFAULT CHARSET = utf8;


DROP TABLE IF EXISTS `pm`;

CREATE TABLE `pm` (
	`id` bigint(20) NOT NULL auto_increment,
	`user_id` bigint(20) default 0,
	`sender_id` bigint(20) default 0,
	`title` varchar(255) NOT NULL default '',
	`content` text default '',
	`created` datetime NOT NULL default '0000-00-00 00:00:00',
	`opened` tinyint(4) default 0,
	`hide_sender` tinyint(4) default 0,
	`hide_reader` tinyint(4) default 0,
		PRIMARY KEY (`id`)
) TYPE = MyISAM DEFAULT CHARSET = utf8;


DROP TABLE IF EXISTS `polls`;

CREATE TABLE `polls` (
	`id` bigint(20) NOT NULL auto_increment,
	`message_id` bigint(20) default 0,
	`question` text NOT NULL default '',
	`multiple` tinyint(4) default 0,
	`option1` varchar(255) default '',
	`option2` varchar(255) default '',
	`option3` varchar(255) default '',
	`option4` varchar(255) default '',
	`option5` varchar(255) default '',
	`option6` varchar(255) default '',
	`option7` varchar(255) default '',
	`option8` varchar(255) default '',
	`option9` varchar(255) default '',
	`option10` varchar(255) default '',
		PRIMARY KEY (`id`)
) TYPE = MyISAM DEFAULT CHARSET = utf8;


DROP TABLE IF EXISTS `pollvotes`;

CREATE TABLE `pollvotes` (
	`id` bigint(20) NOT NULL auto_increment,
	`poll_id` bigint(20) NOT NULL,
	`user_id` bigint(20) NOT NULL,
	`options` varchar(20) default '',
		PRIMARY KEY (`id`)
) TYPE = MyISAM DEFAULT CHARSET = utf8;


DROP TABLE IF EXISTS `banned`;

CREATE TABLE `banned` (
	`id` bigint(20) NOT NULL auto_increment,
	`ip` varchar(100) default '',
	`username` varchar(50) default '',
	`email` varchar(100) default '',
	`reason` varchar(255) default '',
	`ban_date` datetime NOT NULL default '0000-00-00 00:00:00',
	`expires` datetime default '0000-00-00 00:00:00',
		PRIMARY KEY (`id`)
) TYPE = MyISAM DEFAULT CHARSET = utf8;

One thought on “Update on the new (old) PHP forum

  1. Pingback: New (old) PHP forum SQL tables « This page intentionally left ugly

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s