[eluser]InsiteFX[/eluser]
Hi,
This may help you to under stand it.
Code:
--
-- Table structure for ci_sessions
--
DROP TABLE IF EXISTS ci_sessions;
CREATE TABLE IF NOT EXISTS `ci_sessions` (
`session_id` varchar(40) DEFAULT '0' NOT NULL,
`ip_address` varchar(16) DEFAULT '0' NOT NULL,
`user_agent` varchar(50) NOT NULL,
`last_activity` int(10) unsigned DEFAULT 0 NOT NULL,
`user_data` text NOT NULL,
PRIMARY KEY (`session_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;
--
-- Table structure for table groups
--
DROP TABLE IF EXISTS groups;
CREATE TABLE IF NOT EXISTS `groups` (
`id` int(11) NOT NULL,
`title` varchar(30) NOT NULL,
`description` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;
--
-- Table structure for users table
--
DROP TABLE IF EXISTS users;
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_name` varchar(40),
`password` varchar(32),
`user_id` varchar(32),
`user_level` tinyint(1) unsigned NOT NULL,
`email` varchar(255),
`timestamp` int(11) unsigned NOT NULL,
PRIMARY KEY (`id`, `user_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=6 ;
--
-- Table structure for users_online table
--
DROP TABLE IF EXISTS users_online;
CREATE TABLE `users_online` (
`user_name` varchar(40),
`timestamp` int(11) unsigned NOT NULL,
PRIMARY KEY (`user_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;
--
-- Table structure for guests_online table
--
DROP TABLE IF EXISTS guests_online;
CREATE TABLE `guests_online` (
`ip` varchar(16) NOT NULL DEFAULT '0',
`timestamp` int(11) unsigned NOT NULL,
PRIMARY KEY (`ip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;
--
-- Table structure for users_banned table
--
DROP TABLE IF EXISTS users_banned;
CREATE TABLE `users_banned` (
`ip` varchar(16) NOT NULL DEFAULT '0',
`user_name` varchar(40),
`timestamp` int(11) unsigned NOT NULL,
PRIMARY KEY (`user_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ;
When a user comes to the site they are assigned a guest level of 0, and moved to the guests_online table.
If they then login they are removed from the guests_online and moved to the users_online table both with a timestamp.
This should not be hard to add to any of the auth systems out there.
This is from an old auth system that I have I am convering it over in my spare time to a Role Based Access Conntrol system for CodeIgniter.
Enjoy
InsiteFX