Location: PHPKode > projects > Content*Builder > contentbuilder/system/setup/dump.php
<?php

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_article");
$test1 = mysql_query("CREATE TABLE ".TABLE."_article (
  ide varchar(32) NOT NULL default '',
  title varchar(100) NOT NULL default '',
  intro text,
  content text NOT NULL,
  print char(2) default NULL,
  folder varchar(32) NOT NULL default '',
  userid varchar(32) NOT NULL default '',
  datum datetime NOT NULL default '0000-00-00 00:00:00',
  stage tinyint(4) default NULL,
  mediaID int(6) unsigned NOT NULL default '0',
  iconID int(6) unsigned NOT NULL default '0',
  publishfrom timestamp(8) NOT NULL,
  publishto timestamp(8) NOT NULL,
  mod char(1) default NULL,
  parse tinyint(4) default NULL,
  PRIMARY KEY  (ide)
) TYPE=MyISAM;");
if($test1) { $messageList[] = "Article Table created"; } else { $errorList[] = "Could not create Article Table"; }

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_columns");
$test2 = mysql_query("CREATE TABLE ".TABLE."_columns (
  fname varchar(40) NOT NULL default '',
  fid varchar(4) NOT NULL default '',
  writestatus char(2) NOT NULL default '',
  describt text,
  loadurl varchar(255) default NULL,
  status int(8) default NULL,
  mfolder varchar(4) NOT NULL default '',
  usersallowed text,
  PRIMARY KEY  (fid),
  UNIQUE KEY fid (fid)
) TYPE=MyISAM;");
if($test2) { $messageList[] = "Column Table created"; } else { $errorList[] = "Could not create Column Table"; }

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_comments");
$test3 = mysql_query("CREATE TABLE ".TABLE."_comments (
  ide varchar(32) default NULL,
  cmheadline text NOT NULL,
  cmtext text NOT NULL,
  cmdatum datetime NOT NULL default '0000-00-00 00:00:00',
  cmauthor varchar(49) NOT NULL default '',
  cmemail varchar(49) default NULL,
  cmhomepage varchar(60) default NULL,
  mod char(1) default NULL,
  cid varchar(32) default NULL
) TYPE=MyISAM;");
if($test3) { $messageList[] = "Comment Table created"; } else { $errorList[] = "Could not create Comment Table"; }

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_headlines");
$test4 = mysql_query("CREATE TABLE ".TABLE."_headlines (
  headlineid varchar(32) NOT NULL default '',
  headline text NOT NULL,
  msg text NOT NULL,
  datum timestamp(14) NOT NULL,
  prf char(2) default NULL,
  mod char(1) default NULL,
  PRIMARY KEY  (headlineid)
) TYPE=MyISAM;");
if($test4) { $messageList[] = "Headline Table created"; } else { $errorList[] = "Could not create Headline Table"; }

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_messages");
$test5 = mysql_query("CREATE TABLE ".TABLE."_messages (
  userid varchar(32) default NULL,
  message text,
  created date default NULL,
  level char(1) default NULL
) TYPE=MyISAM;");
if($test5) { $messageList[] = "Messages Table created"; } else { $errorList[] = "Could not create Messages Table"; }

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_metainfo");
$test6 = mysql_query("CREATE TABLE ".TABLE."_metainfo (
  x_id varchar(32) NOT NULL default '',
  x_keywords tinytext,
  x_description tinytext,
  x_author varchar(50) default NULL,
  x_lang char(2) default NULL,
  PRIMARY KEY  (x_id)
) TYPE=MyISAM;");
if($test6) { $messageList[] = "MetaInfo Table created"; } else { $errorList[] = "Could not create MetaInfo Table"; }

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_mm_files");
$test7 = mysql_query("CREATE TABLE ".TABLE."_mm_files (
  fileID int(6) NOT NULL auto_increment,
  branchID int(6) NOT NULL default '0',
  typeID int(6) NOT NULL default '0',
  userid varchar(32) NOT NULL default '',
  filename varchar(100) NOT NULL default '',
  title varchar(255) NOT NULL default '',
  description text NOT NULL,
  keywords varchar(100) NOT NULL default '',
  online char(1) NOT NULL default '',
  parameter varchar(255) NOT NULL default '',
  insertdate datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (fileID),
  UNIQUE KEY project (branchID,filename),
  FULLTEXT KEY description (description)
) TYPE=MyISAM;");
if($test7) { $messageList[] = "File Table created"; } else { $errorList[] = "Could not create File Table"; }

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_mm_folder");
$test8 = mysql_query("CREATE TABLE ".TABLE."_mm_folder (
  name varchar(40) NOT NULL default '',
  branchID int(6) NOT NULL auto_increment,
  parentID int(6) NOT NULL default '0',
  description text,
  module varchar(255) default NULL,
  parameter varchar(255) NOT NULL default '',
  status int(8) default NULL,
  PRIMARY KEY  (branchID),
  UNIQUE KEY fid (branchID)
) TYPE=MyISAM;");
if($test8) { $messageList[] = "File Folder Table created"; } else { $errorList[] = "Could not create Folder Table"; }

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_mm_type");
$test9 = mysql_query("CREATE TABLE ".TABLE."_mm_type (
  typeID int(6) NOT NULL auto_increment,
  name varchar(100) NOT NULL default '',
  extension varchar(100) NOT NULL default '',
  UNIQUE KEY typeID (typeID)
) TYPE=MyISAM;");
if($test9) { $messageList[] = "File Type Table created"; } else { $errorList[] = "Could not create File Type Table"; }

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_options");
$test10 = mysql_query("CREATE TABLE ".TABLE."_options (
  optionID int(4) NOT NULL auto_increment,
  name varchar(32) NOT NULL default '',
  value varchar(255) NOT NULL default '',
  module varchar(32) NOT NULL default '',
  parameter varchar(255) NOT NULL default '',
  UNIQUE KEY name (name,module,parameter),
  UNIQUE KEY optionID (optionID)
) TYPE=MyISAM;");
if($test10) { $messageList[] = "Option Table created"; } else { $errorList[] = "Could not create Option Table"; }

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_perms");
$test11 = mysql_query("CREATE TABLE ".TABLE."_perms (
  permID varchar(32) default NULL,
  system bigint(20) unsigned NOT NULL default '0',
  module bigint(20) unsigned NOT NULL default '0',
  UNIQUE KEY userid (permID)
) TYPE=MyISAM;");
if($test11) { $messageList[] = "Permission Table created"; } else { $errorList[] = "Could not create Permission Table"; }

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_profile");
$test = mysql_query("CREATE TABLE ".TABLE."_profile (
  userid varchar(32) NOT NULL default '',
  name varchar(50) NOT NULL default '',
  lltime datetime default NULL,
  email varchar(50) default NULL,
  company varchar(60) default NULL,
  city varchar(50) default NULL,
  street varchar(100) default NULL,
  tel text,
  fax varchar(20) default NULL,
  icq varchar(18) default NULL,
  describt text,
  initial char(3) default NULL,
  website varchar(60) default NULL,
  skills text,
  birthday date NOT NULL default '0000-00-00',
  portraitID int(6) unsigned NOT NULL default '0',
  PRIMARY KEY  (userid),
  UNIQUE KEY name (name)
) TYPE=MyISAM;");

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_recommend");
$test = mysql_query("CREATE TABLE ".TABLE."_recommend (
  ide varchar(32) NOT NULL default '',
  vote int(11) default NULL,
  ip varchar(30) default NULL
) TYPE=MyISAM;");

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_stats");
$test = mysql_query("CREATE TABLE ".TABLE."_stats (
  userid varchar(32) default NULL,
  useraction varchar(4) default NULL,
  zeit datetime default NULL,
  userip text
) TYPE=MyISAM;");

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_user");
$test13 = mysql_query("CREATE TABLE ".TABLE."_user (
  name varchar(30) NOT NULL default '',
  passwort varchar(32) default NULL,
  userid varchar(32) default NULL,
  fullname varchar(49) default NULL,
  dateadd datetime default NULL,
  email varchar(59) default NULL,
  initial char(3) default NULL,
  del char(1) default NULL,
  ugroup varchar(30) default NULL,
  last_intime int(15) default NULL,
  PRIMARY KEY  (name)
) TYPE=MyISAM;");
if($test13) { $messageList[] = "User Table created"; } else { $errorList[] = "Could not create User Table"; }

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_usergroups");
$test = mysql_query("CREATE TABLE ".TABLE."_usergroups (
  groupID int(6) unsigned NOT NULL auto_increment,
  permID varchar(32) NOT NULL default '',
  name varchar(100) NOT NULL default '',
  PRIMARY KEY  (groupID)
) TYPE=MyISAM;");

// Datensätze für den Anfang
$test15 = mysql_query("INSERT INTO ".TABLE."_mm_folder VALUES ('Articles', 1, 0, 'Alle Dateien, die zu Artikeln gehören', 'art', 'protected', 10011)");
$test14 = mysql_query("INSERT INTO ".TABLE."_mm_folder VALUES ('General', 2, 0, NULL, 'system', 'protected', 10021)");
if($test14 && $test15) { $messageList[] = "Added Default File Folders "; }

$test16 = mysql_query("INSERT INTO ".TABLE."_mm_type VALUES (1, 'Icon', 'gif')");
$test17 = mysql_query("INSERT INTO ".TABLE."_mm_type VALUES (2, 'Image', 'jpg; jpeg; gif; png')");
$test18 = mysql_query("INSERT INTO ".TABLE."_mm_type VALUES (3, 'Archiv', 'zip; ace; gz; tar; rar')");
$test19 = mysql_query("INSERT INTO ".TABLE."_mm_type VALUES (4, 'Portrait', 'gif; jpg; png')");
if($test16 && $test17 && $test18 && $test19) { $messageList[] = "Added Default File Types "; }

$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (1, 'userlog', '1', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (2, 'errorlog', '1', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (3, 'iconheight', '30', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (4, 'iconwidth', '307', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (5, 'maxfileup', '54000', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (6, 'maxiconup', '600', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (7, 'caching', '1', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (8, 'lang', 'de', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (9, 'change_author', '', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (10, 'refresh_date', '', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (11, 'requireintro', '1', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (12, 'user_self', '1', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (13, 'comment', '1', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (14, 'file_jpg', '1', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (15, 'file_gif', '', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (16, 'file_zip', '1', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (17, 'file_tar', '1', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (18, 'file_list', '1', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (19, 'timepost', '', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (20, 'seticon', '1', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (21, 'artstatus', '1', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (22, 'stats', '0', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (23, 'rate', '1', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (24, 'icon_cat', '1', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (25, 'generalMedia', '1', 'art', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (26, 'mmLocation', 'plugins/media_manager', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (27, 'imageTypeID', '2', 'art', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (28, 'iconTypeID', '1', 'art', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (29, 'portraitTID', '4', 'system', '')");
$test = mysql_query("INSERT INTO ".TABLE."_options VALUES (30, 'generalMedia', '2', 'system', '')");
$test20 = mysql_query("INSERT INTO ".TABLE."_options VALUES (31, 'defaultEditor', '3', 'system', '')");
if($test20) { $messageList[] = "Added Default Options"; }

// meikelator: add polls-sqltable creation ...
$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_pollsanswer");
$test101 = mysql_query("CREATE TABLE ".TABLE."_pollsanswer (
  id bigint(20) unsigned NOT NULL auto_increment,
  poll bigint(20) unsigned NOT NULL default '0',
  answer varchar(255) NOT NULL default '',
  type enum('default','writein') NOT NULL default 'default',
  count bigint(20) unsigned NOT NULL default '0',
  PRIMARY KEY  (id),
  KEY poll (poll),
  KEY type (type)
) TYPE=MyISAM;");
if($test101) { $messageList[] = "Pollsanswer Table created"; } else { $errorList[] = "Could not create Pollsanswer Table"; }

$test = mysql_query("DROP TABLE IF EXISTS ".TABLE."_pollsquery");
$test102 = mysql_query("CREATE TABLE ".TABLE."_pollsquery (
  id bigint(20) unsigned NOT NULL auto_increment,
  query text NOT NULL,
  description text NOT NULL,
  valid_from datetime NOT NULL default '0000-00-00 00:00:00',
  valid_until datetime NOT NULL default '0000-00-00 00:00:00',
  type enum('checkbox','option') NOT NULL default 'checkbox',
  param varchar(20) NOT NULL default '',
  options set('order_query','order_result','allow_write_ins') NOT NULL default '',
  displayed bigint(20) unsigned NOT NULL default '0',
  users bigint(20) unsigned NOT NULL default '0',
  active enum('yes','no') NOT NULL default 'yes',
  PRIMARY KEY  (id),
  KEY valid_from (valid_from),
  KEY valid_until (valid_until),
  KEY active (active)
) TYPE=MyISAM;");
if($test102) { $messageList[] = "PollsQuery Table created"; } else { $errorList[] = "Could not create PollsQuery Table"; }
// end meikelator

// start 0.5.1 - 0.5.2 Updates
$test = mysql_query("ALTER TABLE ".TABLE."_columns ADD groupsAllowed BIGINT(10) UNSIGNED");
$test = mysql_query("ALTER TABLE ".TABLE."_columns COMMENT = 'v.01'");
	
$counter = 0;
$query = mysql_query("SELECT * FROM ".TABLE."_usergroups");
while($resultRow = mysql_fetch_object($query)) {
	$tmpID[]   = pow(2, $counter);
	$gID[]     = $resultRow->groupID;
	$gName[]   = $resultRow->name;
	$gPermID[] = $resultRow->permID;
	++$counter;
}
$tmpQuery = mysql_query("DELETE FROM ".TABLE."_usergroups");
$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_usergroups CHANGE groupID groupID BIGINT(20) UNSIGNED NOT NULL COMMENT = 'v0.1'");
if(is_array($gID)) {
	foreach($gID as $k => $v) {
		$tmpQuery = mysql_query("INSERT INTO ".TABLE."_usergroups VALUES ('".$gID[$k]."', '".$gPermID[$k]."', '".$gName[$k]."')");
	}
}
$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_usergroups COMMENT = 'v0.1'");

$tmpQuery = mysql_query("CREATE TABLE ".TABLE."_art_content (
  ide int(6) unsigned NOT NULL default '0',
  language int(4) unsigned NOT NULL default '0',
  title varchar(255) NOT NULL default '',
  description text NOT NULL,
  intro text NOT NULL,
  content text NOT NULL,
  keywords varchar(255) NOT NULL default '',
  UNIQUE KEY ide (ide,language)
) TYPE=MyISAM;");


$tmpQuery = mysql_query("CREATE TABLE ".TABLE."_art_general (
  ide int(6) unsigned NOT NULL auto_increment,
  folderID varchar(32) NOT NULL default '',
  userID varchar(32) NOT NULL default '',
  mediaID int(6) unsigned NOT NULL default '0',
  iconID int(6) unsigned NOT NULL default '0',
  title varchar(255) NOT NULL default '',
  datetime datetime NOT NULL default '0000-00-00 00:00:00',
  publishFrom timestamp(14) NOT NULL,
  publishTo timestamp(14) NOT NULL,
  stage int(4) unsigned NOT NULL default '0',
  parse int(4) unsigned NOT NULL default '0',
  options bigint(32) unsigned NOT NULL default '0',
  languages bigint(32) unsigned NOT NULL default '0',
  PRIMARY KEY  (ide)
) TYPE=MyISAM;");

$tmpQuery = mysql_query("INSERT INTO ".TABLE."_columns VALUES ('Default Rubrik', 'f9c3', 'o', 'Dies ist eine standardmäßig eingerichtete Rubrik.', '', 10011, '', '', 0)");
$tmpQuery = mysql_query("INSERT INTO ".TABLE."_options VALUES (31, 'COLUMN_mainFolder', '1', 'system', '')");
$tmpQuery = mysql_query("INSERT INTO ".TABLE."_options VALUES (32, 'artAmount', '10', 'system', '')");
$tmpQuery = mysql_query("INSERT INTO ".TABLE."_options VALUES (33, 'skinDir', 'templates/default/', 'system', '')");
$tmpQuery = mysql_query("INSERT INTO ".TABLE."_options VALUES (34, 'BTPL_location', '../', 'system', '')");
$tmpQuery = mysql_query("INSERT INTO ".TABLE."_options VALUES (35, 'default_lang', '1', 'art', '')");
$tmpQuery = mysql_query("INSERT INTO ".TABLE."_mm_folder VALUES ('Gallerie', 3, 0, NULL, 'gallery', 'protected', 10031)");
$tmpQuery = mysql_query("INSERT INTO ".TABLE."_options VALUES (36, 'gallery', '3', 'gallery', '1')");
$tmpQuery = mysql_query("INSERT INTO ".TABLE."_options VALUES (37, 'allowedTypes', '2', 'gallery', '2')");
$tmpQuery = mysql_query("INSERT INTO ".TABLE."_article VALUES ('2003-05-18-0411', 'Willkommen', '<P>Willkommen in Content*Builder 0.6.0</P>\r\n<P>Wenn dieser Artikel erscheint, wurde das Setup erfolgreich ausgeführt und Content*Builder ist eingerichtet. </P>', 'n/a', '', 'f9c3', 'd7fc7777611f792e2cec47f91bef0550', '2003-05-18 11:04:58', 3, '', 0, 20030518, 00000000, '', 3)");
$tmpQuery = mysql_query("INSERT INTO ".TABLE."_metainfo VALUES ('2003-05-18-0411', '', '', '', 'de')");
$tmpQuery = mysql_query("INSERT INTO ".TABLE."_pollsquery VALUES (1, 'Wie wird Content*Builder eingesetzt?', 'Test Poll', '2003-05-18 10:52:39', '2004-05-18 10:52:39', 'option', '', '', 0, 0, 'yes')");
$tmpQuery = mysql_query("INSERT INTO ".TABLE."_pollsanswer VALUES (1, 1, 'privat', 'default', 0)");
$tmpQuery = mysql_query("INSERT INTO ".TABLE."_pollsanswer VALUES (2, 1, 'kommerziell', 'default', 0)");
$tmpQuery = mysql_query("INSERT INTO ".TABLE."_art_general VALUES (1, 'f9c3', 'd7fc7777611f792e2cec47f91bef0550', 0, 0, 'Erster mehrsprachiger Artikel', '2003-05-18 11:13:18', 20030518111419, 00000000000000, 3, 3, 0, 3)");
$tmpQuery = mysql_query("INSERT INTO ".TABLE."_art_content VALUES (1, 1, 'Deutsche Artikel Version', '', '<P>Dies ist die deutsche Artikel Version des mehrsprachigen Artikel Managements.</P>', '<P>&nbsp;</P>', '')");
$tmpQuery = mysql_query("INSERT INTO ".TABLE."_art_content VALUES (1, 2, 'English Version', '', '<P>This is the english version of the multilanguage Article Management</P>', '<P>&nbsp;</P>', '')");

// end 0.5.1 - 0.5.2 Updates

// start 0.5.2 - 0.5.3 Updates
#AM Update
$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_article ADD template VARCHAR( 255 ) DEFAULT 'default' NOT NULL");
$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_article COMMENT = 'v.01'");
#CM Update
$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_columns ADD skin VARCHAR( 255 ) NOT NULL");
$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_columns COMMENT = 'v.02'");
# MM Update
$counter = 0;
$query = mysql_query("SELECT * FROM ".TABLE."_mm_folder");
while($resultRow = mysql_fetch_object($query)) {
	$branchID[]     = $resultRow->branchID;
}
$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_mm_folder ADD branchName VARCHAR( 255 ) NOT NULL AFTER branchID");
if(is_array($branchID)) {
	foreach($branchID as $k => $v) {
		$tmpQuery = mysql_query("UPDATE ".TABLE."_mm_folder SET branchName = '$v' WHERE branchID = '$v'");
	}
}
$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_mm_folder ADD UNIQUE (branchName)");
$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_mm_folder COMMENT = 'v0.1'");
// end 0.5.2 - 0.5.3 Updates

// start 0.5.3 - 0.6 Updates
	$tmpQuery = mysql_query("CREATE TABLE ".TABLE."_comment (
		commentID INT(10) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 
		type VARCHAR(20) NOT NULL, 
		entryID VARCHAR(20) NOT NULL, 
		author VARCHAR(50) NOT NULL, 
		title VARCHAR(255) NOT NULL, 
		text TEXT NOT NULL, 
		datetime DATETIME NOT NULL,
		homepage VARCHAR(255) NOT NULL, 
		email VARCHAR(100) NOT NULL
	);");  
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_comment COMMENT = 'v0.1'");
	// add art templates for articleML
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_art_general ADD template VARCHAR( 255 ) DEFAULT 'default' NOT NULL");
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_art_general COMMENT = 'v.01'");
	// Update column table
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_columns CHANGE groupsAllowed groupsAllowed VARCHAR( 255 ) NULL");
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_columns COMMENT = 'v.03'");
	// Update File Table
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_mm_files ADD thumbnailID VARCHAR(100) NOT NULL");
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_mm_files CHANGE online options BIGINT(32) UNSIGNED NOT NULL");
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_mm_files COMMENT = 'v0.1'");
	// Update poll table ... Add IP Lock table
	$tmpQuery = mysql_query("CREATE TABLE ".TABLE."_ip_table (
		insertID INT(8) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, 
		ip VARCHAR(15) NOT NULL, 
		time VARCHAR(10) DEFAULT NULL, 
		module CHAR(20) NOT NULL,
		entryID VARCHAR(20) NOT NULL);");
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_ip_table COMMENT = 'v0.1'");
	// Update User Tables
	$tmpQuery = mysql_query("CREATE TABLE ".TABLE."_user_group_relation (
		userID VARCHAR(32) NOT NULL, 
		groupID INT(6) NOT NULL);");
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_user_group_relation ADD UNIQUE (userID,groupID)");
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_user_group_relation COMMENT = 'v.01'");
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_usergroups ADD groupType int(10) unsigned NOT NULL default '0'");
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_usergroups COMMENT = 'v0.2'");
// end 0.5.3 - 0.6 Updates

// start 0.6.0 - 0.6.0 Comment Update
	$query = mysql_query("SELECT * FROM ".TABLE."_comments");
	while($resultRow = mysql_fetch_object($query)) {
		$tmpQuery = mysql_query("INSERT INTO ".TABLE."_comment (type, entryID, author, title, text, datetime, homepage, email) VALUES ('article', '".$resultRow->ide."', '".$resultRow->cmauthor."', '".$resultRow->cmheadline."', '".$resultRow->cmtext."', '".$resultRow->cmdatum."', '".$resultRow->cmhomepage."', '".$resultRow->cmemail."')");
	}
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_comment COMMENT = 'v0.2'");
// end 0.6.0 - 0.6.0 Comment Update

// start 0.6.0 - 0.6.1 Update
	/*
	* Article2 Nested Set Update
	*/
	$tmpQuery = mysql_query("ALTER TABLE ".TABLE."_art_general ADD parentID INT( 10 ) UNSIGNED NOT NULL, ADD rootID INT( 10 ) UNSIGNED NOT NULL, ADD leftID INT( 10 ) UNSIGNED DEFAULT '1' NOT NULL, ADD rightID INT( 10 ) UNSIGNED DEFAULT '2' NOT NULL, ADD level INT( 10 ) UNSIGNED DEFAULT '1' NOT NULL, ADD order_num INT( 10 ) UNSIGNED DEFAULT '1' NOT NULL");
	$tmpQuery = mysql_query("UPDATE ".TABLE."_art_general SET rootID = ide");
	
	/* 
	* Folder Nested Set Update
	*/
	require_once("../../".$cbDirLib."CB_NestedSet.class.php");
	
	$sql = "DROP TABLE IF EXISTS ".TABLE."_columns_temp";
	mysql_query($sql);
	
	$sql = 'CREATE TABLE '.TABLE.'_columns_temp( fname varchar( 40 ) NOT NULL default \'\',';
	$sql .= 'fid int( 10 ) unsigned NOT NULL default \'0\',';
	$sql .= 'writestatus char( 2 ) NOT NULL default \'\',';
	$sql .= 'describt text,';
	$sql .= 'loadurl varchar( 255 ) default NULL ,';
	$sql .= 'status int( 8 ) default NULL ,';
	$sql .= 'mfolder int( 10 ) unsigned NOT NULL default \'0\',';
	$sql .= 'usersallowed text,';
	$sql .= 'groupsAllowed varchar( 255 ) default NULL ,';
	$sql .= 'skin varchar( 255 ) NOT NULL default \'\',';
	$sql .= 'rootID int( 10 ) unsigned NOT NULL default \'0\',';
	$sql .= 'leftID int( 10 ) unsigned NOT NULL default \'0\',';
	$sql .= 'rightID int( 10 ) unsigned NOT NULL default \'0\',';
	$sql .= 'level int( 10 ) unsigned NOT NULL default \'0\',';
	$sql .= 'order_num int( 10 ) unsigned NOT NULL default \'0\',';
	$sql .= ' KEY rootID( rootID ) ,';
	$sql .= ' KEY leftID( leftID ) ,';
	$sql .= ' KEY rightID( rightID ) ,';
	$sql .= ' KEY level ( level ) ,';
	$sql .= ' KEY order_num( order_num ) ) TYPE = MYISAM ';
 	mysql_query($sql);
	/* 
	* Initialisierung der NeSet Array's für das 
	* Folder Nested Set Objekt 
	*/
	$folderParams = array (
		'table'  => TABLE.'_columns_temp',
		'id'     => 'fid',
		'parent' => 'mfolder',
		'root'   => 'rootID',
		'l'   => 'leftID',
		'r'  => 'rightID',
		'level'  => 'level',
		'norder'  => 'order_num'
	);
	
	$folderAdditional = array (
		'name'          => 'fname',
		'status'        => 'status',
		'writestatus'   => 'writestatus',
		'description'   => 'describt',
		'loadurl'       => 'loadurl',
		'usersallowed'  => 'usersallowed',
		'groupsAllowed' => 'groupsAllowed',
		'skin'          => 'skin'
	);
	
	$nestedSet = CB_NestedSet::factory($folderParams, $folderAdditional);
	
	$counter = 1;
	$nodeQuery = mysql_query("SELECT SUBSTRING(status,5) as level, status, fname, fid, mfolder, writestatus, describt, loadurl, usersallowed, groupsAllowed, skin FROM ".TABLE."_columns ORDER BY level ASC");
	while($nodeRow = mysql_fetch_object($nodeQuery)) {
		if($nodeRow->status != null) {
			$ns_values = array (
				"name"          => $nodeRow->fname,
				"status"        => $nodeRow->status,
				"writestatus"   => $nodeRow->writestatus,
				"description"   => $nodeRow->describt,
				"loadurl"       => $nodeRow->loadurl,
				"usersallowed"  => $nodeRow->usersallowed,
				"groupsAllowed" => $nodeRow->groupsAllowed,
				"skin"          => $nodeRow->skin
			);
			if($nodeRow->mfolder == "" || $nodeRow->mfolder == "0") {
				$new_id = $nestedSet->createRootNode($ns_values);
			} else {
				$mfolder = $nodeRow->mfolder;
				$new_id = $nestedSet->createSubNode($oldID_newID[$mfolder], $ns_values);
			}
			$oldID_newID[$nodeRow->fid] = $new_id;
		}
	}
	foreach ($oldID_newID as $k => $v) {
		mysql_query("UPDATE ".TABLE."_article SET folder = '$v' WHERE folder = '$k'");
		mysql_query("UPDATE ".TABLE."_art_general SET folderID = '$v' WHERE folderID = '$k'");
	}
	mysql_query("CREATE TABLE IF NOT EXISTS ".TABLE."_columns_backup SELECT * FROM ".TABLE."_columns");
	mysql_query("DROP TABLE ".TABLE."_columns");
	mysql_query("RENAME TABLE ".TABLE."_columns_temp TO ".TABLE."_columns");
	
	// Statistik Update
	mysql_query("ALTER TABLE ".TABLE."_sext_statistik CHANGE time datetime DATETIME DEFAULT '0' NOT NULL");	
// end 0.6.0 - 0.6.1 Update


// start 0.6.3 Event
	$sql = "CREATE TABLE ".TABLE."_events (";
	$sql .= "  eventID int(10) unsigned NOT NULL auto_increment,";
	$sql .= "  title varchar(255) NOT NULL default '',";
	$sql .= "  description text NOT NULL,";
	$sql .= "  insertDate datetime NOT NULL default '0000-00-00 00:00:00',";
	$sql .= "  eventDate datetime NOT NULL default '0000-00-00 00:00:00',";
	$sql .= "  userID varchar(32) NOT NULL default '',";
	$sql .= "  PRIMARY KEY  (eventID)";
	$sql .= ") TYPE=MyISAM;";
	mysql_query($sql);
	
	mysql_query("ALTER TABLE ".TABLE."_profile DROP name, DROP lltime, DROP email, DROP initial;");
// end 0.6.3 Event

// start 0.6.5 Community & Newsletter & Multiple Folder
	$sql = "CREATE TABLE ".TABLE."_art_folder (";
	$sql .= "  articleID int(10) unsigned NOT NULL default '0',";
	$sql .= "  folderID int(10) unsigned NOT NULL default '0',";
	$sql .= "  PRIMARY KEY  (articleID,folderID)";
	$sql .= ") TYPE=MyISAM;";
	mysql_query($sql);
	
	$sql = "CREATE TABLE ".TABLE."_community_activation (";
	$sql .= "  userID int(10) unsigned NOT NULL default '0',";
	$sql .= "  activationCode varchar(32) NOT NULL default '',";
	$sql .= "  datetime datetime NOT NULL default '0000-00-00 00:00:00',";
	$sql .= "  PRIMARY KEY  (userID)";
	$sql .= ") TYPE=MyISAM;";
	mysql_query($sql);
	
	$sql = "CREATE TABLE ".TABLE."_community_user (";
	$sql .= "  userID int(10) unsigned NOT NULL auto_increment,";
	$sql .= "  name varchar(50) NOT NULL default '',";
	$sql .= "  fullname varchar(50) NOT NULL default '',";
	$sql .= "  password varchar(32) NOT NULL default '',";
	$sql .= "  registerDate datetime NOT NULL default '0000-00-00 00:00:00',";
	$sql .= "  lastLogin datetime NOT NULL default '0000-00-00 00:00:00',";
	$sql .= "  email varchar(100) NOT NULL default '',";
	$sql .= "  options bigint(10) unsigned NOT NULL default '0',";
	$sql .= "  PRIMARY KEY  (userID),";
	$sql .= "  UNIQUE KEY name (name)";
	$sql .= ") TYPE=MyISAM;";
	mysql_query($sql);
	
	$sql = "CREATE TABLE ".TABLE."_nl_category (";
	$sql .= "  userID varchar(32) NOT NULL default '',";
	$sql .= "  categoryID int(10) unsigned NOT NULL auto_increment,";
	$sql .= "  name varchar(255) NOT NULL default '',";
	$sql .= "  description text NOT NULL,";
	$sql .= "  options int(10) unsigned NOT NULL default '0',";
	$sql .= "  datetime datetime NOT NULL default '0000-00-00 00:00:00',";
	$sql .= "  PRIMARY KEY  (categoryID)";
	$sql .= ") TYPE=MyISAM;";
	mysql_query($sql);
	
	$sql = "CREATE TABLE ".TABLE."_nl_content (";
	$sql .= "  userID varchar(32) NOT NULL default '',";
	$sql .= "  newsletterID int(10) unsigned NOT NULL default '0',";
	$sql .= "  typeID int(10) unsigned NOT NULL default '0',";
	$sql .= "  text text NOT NULL,";
	$sql .= "  PRIMARY KEY  (newsletterID,typeID),";
	$sql .= "  FULLTEXT KEY text (text)";
	$sql .= ") TYPE=MyISAM;";
	mysql_query($sql);
	
	$sql = "CREATE TABLE ".TABLE."_nl_general (";
	$sql .= "  userID varchar(32) NOT NULL default '',";
	$sql .= "  newsletterID int(10) unsigned NOT NULL auto_increment,";
	$sql .= "  categoryID int(10) unsigned NOT NULL default '0',";
	$sql .= "  templateID INT(10) UNSIGNED NOT NULL,"; 
	$sql .= "  title varchar(255) NOT NULL default '',";
	$sql .= "  sendTime datetime NOT NULL default '0000-00-00 00:00:00',";
	$sql .= "  options int(10) unsigned NOT NULL default '0',";
	$sql .= "  PRIMARY KEY  (newsletterID)";
	$sql .= ") TYPE=MyISAM;";
	mysql_query($sql);
	
	$sql = "CREATE TABLE ".TABLE."_nl_subscription (";
	$sql .= "  userID int(10) unsigned NOT NULL default '0',";
	$sql .= "  categoryID int(10) unsigned NOT NULL default '0',";
	$sql .= "  typeID int(10) unsigned NOT NULL default '1',";
	$sql .= "  PRIMARY KEY  (userID,categoryID),";
	$sql .= "  KEY categoryID (categoryID)";
	$sql .= ") TYPE=MyISAM;";
	mysql_query($sql);
	
	mysql_query("INSERT INTO ".TABLE."_options (name, value, module, parameter) VALUES ('defaultEditor', '3', 'system', '');");
	mysql_query("INSERT INTO ".TABLE."_options (name, value, module, parameter) VALUES ('sortMethod', '1', 'art', '');");
	mysql_query("INSERT INTO ".TABLE."_options (name, value, module, parameter) VALUES ('from', 'hide@address.com', 'newsletter', '');");
	mysql_query("INSERT INTO ".TABLE."_options (name, value, module, parameter) VALUES ('requireUserActivation', '1', 'community', '');");
	mysql_query("INSERT INTO ".TABLE."_options (name, value, module, parameter) VALUES ('sendMethod', 'mail', 'newsletter', '');");
	
	mysql_query("ALTER TABLE ".TABLE."_columns CHANGE leftID leftID INT(10) UNSIGNED DEFAULT '1' NOT NULL");
	mysql_query("ALTER TABLE ".TABLE."_columns CHANGE rightID rightID INT(10) UNSIGNED DEFAULT '2' NOT NULL");
	mysql_query("ALTER TABLE ".TABLE."_columns CHANGE level level INT(10) UNSIGNED DEFAULT '1' NOT NULL");
// end 0.6.5 Community & Newsletter

// start 0.6.5 _ 2 Column Multi Language
	
	$sql = "CREATE TABLE ".TABLE."_language (";
	$sql .= "  entryID int(10) unsigned NOT NULL auto_increment,";
	$sql .= "  type varchar(255) NOT NULL default '',";
	$sql .= "  typeID int(10) unsigned NOT NULL default '0',";
	$sql .= "  languageID int(10) unsigned NOT NULL default '0',";
	$sql .= "  text text NOT NULL,";
	$sql .= "  PRIMARY KEY  (entryID),";
	$sql .= "  UNIQUE KEY type (type,typeID,languageID)";
	$sql .= ") TYPE=MyISAM;";
	mysql_query($sql);

// end 0.6.5 _ 2 Column Multi Language

// start 0.6.5 -> 0.7.1 
	$sql  = "CREATE TABLE ".TABLE."_permission (";
	$sql .= "  permissionID int(4) NOT NULL auto_increment,";
	$sql .= "  name varchar(64) NOT NULL default '',";
	$sql .= "  type varchar(64) NOT NULL default '',";
	$sql .= "  value int(10) unsigned NOT NULL default '0',";
	$sql .= "  parameter varchar(64) NOT NULL default '',";
	$sql .= "  PRIMARY KEY  (permissionID),";
	$sql .= "  UNIQUE KEY name (name,parameter,type)";
	$sql .= ") TYPE=MyISAM;";
	mysql_query($sql);
	
	mysql_query("ALTER TABLE ".TABLE."_columns ADD options INT(10) UNSIGNED DEFAULT '1' NOT NULL AFTER mfolder;");

	$sql =  "CREATE TABLE ".TABLE."_forum_category (".
			"  categoryID int(10) unsigned NOT NULL auto_increment,".
			"  name varchar(255) NOT NULL default '',".
			"  description text NOT NULL,".
			"  options int(10) unsigned NOT NULL default '0',".
			"  datetime datetime NOT NULL default '0000-00-00 00:00:00',".
			"  parentID int(10) unsigned NOT NULL default '0',".
			"  rootID int(10) unsigned NOT NULL default '0',".
			"  leftID int(10) unsigned NOT NULL default '0',".
			"  rightID int(10) unsigned NOT NULL default '0',".
			"  level int(10) unsigned NOT NULL default '0',".
			"  order_num int(10) unsigned NOT NULL default '0',".
			"  PRIMARY KEY  (categoryID)".
			") TYPE=MyISAM;";
			
	if(mysql_query($sql)) {
		$messageList[] = "Forum Kategorie Table created";
	}
			
	$sql = "INSERT INTO ".TABLE."_forum_category VALUES (1, 'Test Forum', 'Dies ist ein kleines Test Forum ... Mal schauen wie das alles so weiter geht :)', 1, '2004-05-02 14:56:10', 0, 1, 1, 2, 1, 1);";
	
	if(mysql_query($sql)) {
		$messageList[] = "Test Forum created";
	}
	
	$sql = "CREATE TABLE ".TABLE."_forum_message (".
			"  messageID int(10) unsigned NOT NULL auto_increment,".
			"  userID int(10) unsigned NOT NULL default '0',".
			"  title varchar(255) NOT NULL default '',".
			"  message text NOT NULL,".
			"  originalMessage text NOT NULL,".
			"  insertDate datetime NOT NULL default '0000-00-00 00:00:00',".
			"  editDate datetime NOT NULL default '0000-00-00 00:00:00',".
			"  parentID int(10) unsigned NOT NULL default '0',".
			"  rootID int(10) unsigned NOT NULL default '0',".
			"  leftID int(10) unsigned NOT NULL default '0',".
			"  rightID int(10) unsigned NOT NULL default '0',".
			"  level int(10) unsigned NOT NULL default '0',".
			"  order_num int(10) unsigned NOT NULL default '0',".
			"  PRIMARY KEY  (messageID)".
			") TYPE=MyISAM;";
	
	if(mysql_query($sql)) {
		$messageList[] = "Forum Message Table created";
	}
	
	$sql = "CREATE TABLE ".TABLE."_forum_thread (".
			"  rootID int(10) unsigned NOT NULL default '0',".
			"  categoryID int(10) unsigned NOT NULL default '0',".
			"  options int(10) unsigned NOT NULL default '0',".
			"  lastModified datetime NOT NULL default '0000-00-00 00:00:00'".
			") TYPE=MyISAM;";
	
	if(mysql_query($sql)) {
		$messageList[] = "Forum Thread Table created";
	}
	
	mysql_query("ALTER TABLE ".TABLE."_forum_thread ADD lastModifiedBy INT( 10 ) UNSIGNED NOT NULL;");
	
	define("ADMIN",         1 << 0);  // wer weiss was 1 << 0 bedeutet, darf vielleicht Admin werden
	define("COL_MNG",       1 << 8);  // Rubriken verwalten duerfen
	
	$groupQuery = mysql_query("SELECT * FROM ".TABLE."_usergroups AS ugroup LEFT JOIN cb_perms as perm ON ugroup.permID = perm.permID");
	while($groupRow = mysql_fetch_assoc($groupQuery)) {
		$groupRow['system'] &= ~COL_MNG;
		mysql_query("UPDATE ".TABLE."_perms SET system = '".$groupRow['system']."' WHERE permID = '".$groupRow['permID']."'");
		mysql_query("INSERT INTO ".TABLE."_permission (name, type, value, parameter) VALUES ('general', 'columnPerms', '31', '".$groupRow['groupID']."')");
		$messageList[] = "Permission Column Management for group ".$groupRow['name']." removed";
		$messageList[] = "General Permission Set for group ".$groupRow['name']." created";
	}
	
	$userQuery = mysql_query("SELECT * FROM ".TABLE."_user AS user LEFT JOIN cb_perms as perm ON user.userid = perm.permID");
	while($userRow = mysql_fetch_assoc($userQuery)) {
		if(!(ADMIN & $userRow['system'])) {
			$userRow['system'] &= ~COL_MNG;
			mysql_query("UPDATE ".TABLE."_perms SET system = '".$userRow['system']."' WHERE permID = '".$userRow['permID']."'");
			$messageList[] = "Permission 'Column Management' for user ".$userRow['fullname']." removed";
		}
	}
// end 0.7.1

// Test User
$test21 = mysql_query("INSERT INTO ".TABLE."_user VALUES ('Admin', '1a1dc91c907325c69271ddf0c944bc72', 'd7fc7777611f792e2cec47f91bef0550', 'Admin User', '2002-10-19 01:01:30', NULL, 'AD', NULL, NULL, NULL)");
$test22 = mysql_query("INSERT INTO ".TABLE."_perms VALUES ('d7fc7777611f792e2cec47f91bef0550', 81919, 0)");
if($test21 && $test22) { $messageList[] = "Added Default User:\r\n<br>Login: Admin\r\n<br>Password: pass\r\n<br><b>Please change password after login. This is the Super User<br>Please delete this Setup Script<br><a href=\"../../index.php\">Login</a>"; }

?>

Return current item: Content*Builder