Location: PHPKode > projects > Wallpaper Script > Wallpapers_Script/Wallpapers_Script/install/schema.txt
DROP TABLE IF EXISTS `{|DBPREFIX|}added_permissions`;
DROP TABLE IF EXISTS `{|DBPREFIX|}categories`;
DROP TABLE IF EXISTS `{|DBPREFIX|}colors`;
DROP TABLE IF EXISTS `{|DBPREFIX|}colors_rel`;
DROP TABLE IF EXISTS `{|DBPREFIX|}comments`;
DROP TABLE IF EXISTS `{|DBPREFIX|}downloads`;
DROP TABLE IF EXISTS `{|DBPREFIX|}groups`;
DROP TABLE IF EXISTS `{|DBPREFIX|}hits`;
DROP TABLE IF EXISTS `{|DBPREFIX|}partners`;
DROP TABLE IF EXISTS `{|DBPREFIX|}permissions`;
DROP TABLE IF EXISTS `{|DBPREFIX|}searches`;
DROP TABLE IF EXISTS `{|DBPREFIX|}search_queries`;
DROP TABLE IF EXISTS `{|DBPREFIX|}sessions`;
DROP TABLE IF EXISTS `{|DBPREFIX|}site_settings`;
DROP TABLE IF EXISTS `{|DBPREFIX|}tags`;
DROP TABLE IF EXISTS `{|DBPREFIX|}tags_rel`;
DROP TABLE IF EXISTS `{|DBPREFIX|}tag_exclusion`;
DROP TABLE IF EXISTS `{|DBPREFIX|}users`;
DROP TABLE IF EXISTS `{|DBPREFIX|}votes`;
DROP TABLE IF EXISTS `{|DBPREFIX|}wallpapers`;
DROP TABLE IF EXISTS `{|DBPREFIX|}schedule`;
DROP TABLE IF EXISTS `{|DBPREFIX|}scheduled_wallpapers`;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}added_permissions` (
  `ID` int(10) NOT NULL auto_increment,
  `item_id` int(11) NOT NULL,
  `item_type` enum('user','group') NOT NULL,
  `area` int(11) NOT NULL,
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `item_id` (`area`,`item_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}categories` (
  `ID` int(11) NOT NULL auto_increment,
  `id_parent` int(11) NOT NULL default '0',
  `is_locked` tinyint(1) default '0',
  `issubcat` varchar(11) default NULL,
  `title` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `description` text CHARACTER SET utf8 COLLATE utf8_unicode_ci,
  `meta_description` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci default NULL,
  `meta_keywords` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci default NULL,
  `order1` int(11) default '0',
  `items_counter` int(11) default '0',
  `subcats_counter` int(11) default '0',
  `lft` int(11) default NULL,
  `rgt` int(11) default NULL,
  PRIMARY KEY  (`ID`),
  KEY `id_parent` (`id_parent`),
  KEY `lft` (`lft` , `rgt`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}colors` (
  `ID` int(11) NOT NULL auto_increment,
  `color` varchar(255) NOT NULL,
  `occurences` int(11) default '1',
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `color` (`color`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}colors_rel` (
  `color_id` int(11) NOT NULL,
  `item_id` int(11) NOT NULL,
  PRIMARY KEY `color_id` (`color_id`,`item_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}comments` (
  `ID` int(11) NOT NULL auto_increment,
  `item_id` int(11) NOT NULL,
  `c_name` varchar(255) NOT NULL,
  `c_email` varchar(255) default '',
  `c_url` text,
  `c_comment` text NOT NULL,
  `date_added` int(10) NOT NULL,
  `active` smallint(1) default '0',
  PRIMARY KEY  (`ID`),
  KEY `item_id` (`item_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}downloads` (
  `item_id` int(11) NOT NULL,
  `ip` varchar(32) default NULL,
  PRIMARY KEY `item_id` (`item_id`,`ip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}groups` (
  `ID` tinyint(3) NOT NULL auto_increment,
  `title` varchar(255) NOT NULL,
  `description` varchar(255) default NULL,
  `login_redirect` varchar(255) default NULL,
  `logout_redirect` varchar(255) default NULL,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}hits` (
  `item_id` int(11) default NULL,
  `ip` varchar(50) default NULL,
  PRIMARY KEY `item_id` (`item_id`,`ip`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}partners` (
  `ID` int(11) NOT NULL auto_increment,
  `title` varchar(255) NOT NULL,
  `description` tinytext,
  `link` tinytext NOT NULL,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}permissions` (
  `ID` int(11) NOT NULL auto_increment,
  `label` varchar(55) NOT NULL,
  `parent_id` int(11) default '0',
  `editable` tinyint(1) NOT NULL default '0',
  PRIMARY KEY  (`ID`),
  KEY `parent_id` (`parent_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}searches` (
  `ID` int(11) NOT NULL auto_increment,
  `search_string` varchar(255) NOT NULL,
  `date_added` varchar(11) NOT NULL,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}search_queries` (
  `ID` int(11) NOT NULL auto_increment,
  `query` text NOT NULL,
  `date_added` varchar(11) NOT NULL,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}sessions` (
  `session_id` varchar(40) NOT NULL default '0',
  `ip_address` varchar(16) NOT NULL default '0',
  `user_agent` varchar(50) NOT NULL,
  `last_activity` int(10) unsigned NOT NULL default '0',
  `user_data` text default NULL,
  `uri_string` varchar(255) default '',
  PRIMARY KEY  (`session_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}site_settings` (
  `ID` int(11) NOT NULL auto_increment,
  `label` varchar(255) NOT NULL,
  `value` text NOT NULL,
  PRIMARY KEY  (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}tags` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `tag` varchar(255) NOT NULL,
  `occurences` int(11) DEFAULT '1',
  `exclude` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`ID`),
  UNIQUE KEY `tag` (`tag`),
  KEY `exclude` (`exclude`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}tags_rel` (
  `tag_id` int(11) NOT NULL,
  `item_id` int(11) NOT NULL,
  PRIMARY KEY `tag_id` (`tag_id`,`item_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}users` (
  `ID` int(11) NOT NULL auto_increment,
  `Username` varchar(255) NOT NULL,
  `Password` varchar(255) NOT NULL,
  `date_registered` int(11) NOT NULL,
  `Temp_pass` varchar(55) default NULL,
  `Temp_pass_active` tinyint(1) NOT NULL default '0',
  `Email` varchar(255) NOT NULL,
  `Active` int(11) NOT NULL default '0',
  `Level_access` int(11) NOT NULL default '2',
  `Random_key` varchar(32) default NULL,
  `auto_approve` tinyint(1) default '0',
  PRIMARY KEY  (`ID`),
  UNIQUE KEY `Username` (`Username`),
  UNIQUE KEY `Email` (`Email`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}votes` (
  `item_id` int(11) NOT NULL default '0',
  `visitor_ip` varchar(32) NOT NULL default '127.0.0.1',
  `vote_value` varchar(2) NOT NULL default '0',
  PRIMARY KEY `item_id` (`item_id`,`visitor_ip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `{|DBPREFIX|}wallpapers` (
  `ID` int(11) NOT NULL auto_increment,
  `user_id` int(11) NOT NULL,
  `file_title` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `title_alias` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci default NULL,
  `cat_id` int(11) NOT NULL,
  `parent_id` int(11) default '0',
  `active` tinyint(1) default '0',
  `description` text CHARACTER SET utf8 COLLATE utf8_unicode_ci,
  `type` enum('normal', 'wide', 'iphone', 'psp', 'hd', 'multi', 'other') default 'normal',
  `height` int(11) default NULL,
  `width` int(11) default NULL,
  `date_added` varchar(11) NOT NULL,
  `downloads` int(11) default '0',
  `hits` int(11) default '0',
  `rating` float default '0',
  `hash` varchar(55) default NULL,
  PRIMARY KEY  (`ID`),
  KEY `parent_id` ( `parent_id` , `active` ),
  KEY `height` ( `height` , `width` ),
  KEY `cat_id` (`cat_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

INSERT INTO `{|DBPREFIX|}groups` (`ID`, `title`, `description`, `login_redirect`, `logout_redirect`) VALUES (1, 'Admins', 'The admin(s) with full rights', 'admin', 'login'), (2, 'Members', 'The default members group', 'members', 'login');
INSERT INTO `{|DBPREFIX|}users` (`ID`, `Username`, `Password`, `date_registered`, `Temp_pass`, `Temp_pass_active`, `Email`, `Active`, `Level_access`) VALUES (1, '{|ADMIN_USERNAME|}', '{|ADMIN_PASSWORD|}', {|NOW|}, NULL, 0, '{|ADMIN_EMAIL|}', 1, 1);
INSERT INTO `{|DBPREFIX|}site_settings` (`label`,`value`) VALUES ('WS_VERSION', '3.4.0');
INSERT INTO `{|DBPREFIX|}site_settings` (`label`,`value`) VALUES ('bg_pattern', '0.jpg');
INSERT INTO `{|DBPREFIX|}added_permissions` (`ID`, `item_id`, `item_type`, `area`) VALUES(1, 2, 'group', 3);
INSERT INTO `{|DBPREFIX|}permissions` (`ID`, `label`, `parent_id`, `editable`) VALUES
(1, 'Wallpapers', 0, 0),
(2, 'view', 1, 0),
(3, 'create', 1, 0),
(4, 'edit', 1, 0),
(5, 'delete', 1, 0),
(6, 'activate', 1, 0),
(7, 'suspend', 1, 0),
(8, 'Users', 0, 0),
(9, 'view', 8, 0),
(10, 'create', 8, 0),
(11, 'edit', 8, 0),
(12, 'delete', 8, 0),
(13, 'activate', 8, 0),
(14, 'suspend', 8, 0),
(15, 'Groups', 0, 0),
(16, 'view', 15, 0),
(17, 'create', 15, 0),
(18, 'edit', 15, 0),
(19, 'delete', 15, 0),
(20, 'activate', 15, 0),
(21, 'suspend', 15, 0),
(22, 'Categories', 0, 0),
(23, 'view', 22, 0),
(24, 'create', 22, 0),
(25, 'edit', 22, 0),
(26, 'delete', 22, 0),
(27, 'lock', 22, 0),
(28, 'unlock', 22, 0),
(29, 'Permissions', 0, 0),
(30, 'view', 29, 0),
(31, 'create', 29, 0),
(32, 'edit', 29, 0),
(33, 'delete', 29, 0),
(34, 'Site settings', 0, 0),
(35, 'view', 34, 0),
(36, 'edit', 34, 0),
(37, 'Contact', 8, 0),
(38, 'Tag cloud', 0, 0),
(39, 'add_exclusion', 38, 0),
(40, 'edit', 38, 0),
(41, 'delete_exclusion', 38, 0),
(42, 'Partners', 0, 0),
(43, 'add', 42, 0),
(44, 'edit', 42, 0),
(45, 'delete', 42, 0),
(46, 'Comments', 0, 0),
(47, 'manage', 46, 0);

CREATE  TABLE IF NOT EXISTS `{|DBPREFIX|}schedule` (
  `id` INT(11) NOT NULL AUTO_INCREMENT ,
  `amount` INT(11) NOT NULL ,
  `interval` INT NOT NULL ,
  `last_run` int(10) DEFAULT NULL,
  PRIMARY KEY (`id`) )
ENGINE = InnoDB;


CREATE  TABLE IF NOT EXISTS `{|DBPREFIX|}scheduled_wallpapers` (
  `schedule_id` INT(11) NOT NULL ,
  `wallpaper_id` INT(11) NOT NULL ,
  PRIMARY KEY (`schedule_id`,`wallpaper_id`) ,
  KEY `fk_scheduled_wallpapers_schedule` (`schedule_id`) ,
  KEY `fk_scheduled_wallpapers_wallpaper` (`wallpaper_id`) 
)
ENGINE = InnoDB;

ALTER TABLE `{|DBPREFIX|}scheduled_wallpapers`
  ADD CONSTRAINT `fk_scheduled_wallpapers_schedule` FOREIGN KEY (`schedule_id`) REFERENCES `{|DBPREFIX|}schedule` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `fk_scheduled_wallpapers_wallpaper` FOREIGN KEY (`wallpaper_id`) REFERENCES `{|DBPREFIX|}wallpapers` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE;
Return current item: Wallpaper Script