Prefix"."registry WHERE keyname='version'"); $registry = mysql_fetch_array($r_registry); if( $registry['keyvalue'] != $this->OldVersion ) return 0; else return 1; } function SetError($errmsg) { $this->Error = $errmsg; } function GetError() { return $this->Error; } /* the actual update. * * RETURN VALUES * * 1 - update failed (set error with $this->SetError() ) * 0 - update sucessfull */ function RunUpdate() { /* ============ groupid fixes (0) ================= */ $r_registry = thwb_query("SELECT keyvalue FROM $this->Prefix"."registry WHERE keyname='default_groupid'"); list($default_groupid) = mysql_fetch_row($r_registry); if( $default_groupid == 0 ) { $r_group = thwb_query("SELECT groupid, name, accessmask FROM $this->Prefix"."group WHERE groupid=0"); if( mysql_num_rows($r_group) < 1 ) { /* malicious insert query, groupid has changed (was 0). set to 0. */ $r_defgroup = thwb_query("SELECT groupid FROM $this->Prefix"."group WHERE nodelete=1"); if( mysql_num_rows($r_defgroup) != 1 ) { $this->SetError('Could not detemine default group!'); return 1; } list($defgroupid) = mysql_fetch_row($r_defgroup); thwb_query("UPDATE $this->Prefix"."group SET groupid=0 WHERE groupid='$defgroupid'"); $r_group = thwb_query("SELECT groupid, name, accessmask FROM $this->Prefix"."group WHERE groupid=0"); } /* create new default group with non-zero id */ $group = mysql_fetch_array($r_group); thwb_query("INSERT INTO $this->Prefix"."group (name, accessmask) VALUES ('".$group['name']."', '".$group['accessmask']."')"); $id = mysql_insert_id(); thwb_query("UPDATE $this->Prefix"."registry SET keyvalue='$id' WHERE keyname='default_groupid'"); thwb_query("UPDATE $this->Prefix"."user SET groupid='$id' WHERE groupid='0'"); thwb_query("UPDATE $this->Prefix"."groupboard SET groupid='$id' WHERE groupid='0'"); thwb_query("DELETE FROM $this->Prefix"."group WHERE groupid=0"); } /* ================================================ */ /* fuer diejenigen, die threadcreationtime schon reigehaxt haben mit 2.73 (eg thewall) */ if( !column_exists($this->Prefix.'thread', 'threadcreationtime') ) { thwb_query("ALTER TABLE $this->Prefix"."thread ADD threadcreationtime INT(10) UNSIGNED NOT NULL;"); } /* ebenfalls eine ueberpruefung fuer diejenigen, die den avatar hack schon installiert haben */ if( !column_exists($this->Prefix.'user', 'useravatar') ) { thwb_query("CREATE TABLE $this->Prefix"."avatar ( avatarid int(8) unsigned NOT NULL auto_increment, avatarname varchar(128) NOT NULL default '', avatarurl varchar(255) NOT NULL default '', PRIMARY KEY (avatarid), UNIQUE KEY avatarname (avatarname) ) TYPE=MyISAM;"); thwb_query("ALTER TABLE $this->Prefix"."user ADD useravatar VARCHAR(255) DEFAULT '' NOT NULL"); thwb_query("INSERT INTO $this->Prefix"."registrygroup VALUES (7,'Avatar settings',5);"); thwb_query("INSERT INTO $this->Prefix"."registry VALUES ('useravatar', '0', 'integer', 'Avatar-Settings', 'Enable avatars:
0 - Avatars disabled
1 - Only pre-installed avatars
2 - Only user-defined avatars
3 - Both', 7, 0);"); thwb_query("INSERT INTO $this->Prefix"."registry VALUES ('avatarheight', '64', 'integer', 'Avatar maximum height', 'The maximum height of the user-defined Avatars.', 7, 2);"); thwb_query("INSERT INTO $this->Prefix"."registry VALUES ('avatarwidth', '64', 'integer', 'Avatar maximum width', 'The maximum width of the user-defined Avatars.', 7, 1);"); } /* Board-Version */ thwb_query("UPDATE $this->Prefix"."registry SET keyvalue='".$this->NewVersion."' WHERE keyname='version'"); /* Thread-marking */ /* thwb_query("INSERT INTO $this->Prefix"."registry VALUES ('max_markedthreads', '20', 'integer', 'Maximum marked threads', 'Maximum count of marked threads', 3, 20)");*/ /* queries bitte ohne backtrick (`): probleme mit aelteren mysql versionen ~dp */ /* thwb_query("ALTER TABLE $this->Prefix"."user ADD usermarkedthreads TEXT NOT NULL AFTER usersignature");*/ /* banreason */ thwb_query("ALTER TABLE $this->Prefix"."ban CHANGE banreason banpubreason MEDIUMTEXT NOT NULL"); thwb_query("ALTER TABLE $this->Prefix"."ban ADD banreason MEDIUMTEXT NOT NULL AFTER banpubreason"); /* gzip compression, search */ thwb_query("INSERT INTO $this->Prefix"."registry VALUES ('compression', '0', 'boolean', 'Enable compression?', 'Gzip compression can save a lot of traffic, but requires a bit more cpu time', '2', '14');"); thwb_query("INSERT INTO $this->Prefix"."registry VALUES ('slow_search', '0', 'boolean', 'Case-insensitive (slow) search?', 'Slower, but more precisely.', 2, 15);"); /* group queries */ thwb_query("ALTER TABLE $this->Prefix"."user ADD groupids varchar(128) NOT NULL default ''"); /* alte gruppen konvertieren */ $r_group = thwb_query("SELECT groupid FROM $this->Prefix"."group"); while( $group = mysql_fetch_array($r_group) ) { thwb_query("UPDATE $this->Prefix"."user SET groupids=',".$group['groupid'].",' WHERE groupid='".$group['groupid']."'"); } thwb_query("ALTER TABLE $this->Prefix"."user DROP groupid"); thwb_query("UPDATE $this->Prefix"."user SET userlevel = 0 WHERE userlevel <> 1"); thwb_query("ALTER TABLE $this->Prefix"."user CHANGE userlevel userisadmin TINYINT( 1 ) UNSIGNED DEFAULT '0' NOT NULL"); thwb_query("ALTER TABLE $this->Prefix"."group ADD title VARCHAR( 255 ) NOT NULL"); thwb_query("ALTER TABLE $this->Prefix"."group ADD titlepriority INT NOT NULL"); thwb_query("DELETE FROM $this->Prefix"."registry WHERE keyname='guestmode'"); thwb_query("INSERT INTO $this->Prefix"."group VALUES ('', 'Guest Group', '0', '1', '', '0');"); $id = mysql_insert_id(); thwb_query("INSERT INTO $this->Prefix"."registry VALUES ('guest_groupid', '$id', 'integer', 'Dont modify!', 'Dont modify!', 0, 0);"); /* god admins */ thwb_query("ALTER TABLE $this->Prefix"."user ADD usernodelete TINYINT (1) DEFAULT '0' NOT NULL AFTER userisadmin"); /* guest queries*/ thwb_query("ALTER TABLE $this->Prefix"."board DROP boardnoguests"); /* badwords protection */ thwb_query("CREATE TABLE $this->Prefix"."bannedwords ( wordid int(11) NOT NULL auto_increment, banword varchar(128) NOT NULL default '', modword varchar(128) NOT NULL default '', PRIMARY KEY (wordid), UNIQUE KEY banword (banword) ) TYPE=MyISAM;"); thwb_query("INSERT INTO $this->Prefix"."registry VALUES ('usebwordprot', 3, 'integer', 'Badwords protection', 'do not modify!', 0, 1)"); return 0; } } ?>