2011-04-12 13:08:54 +02:00
< ? php
2012-04-11 18:49:22 +02:00
// Installation/upgrade file
2013-07-31 08:08:55 +02:00
define ( 'VERSION' , 'v0.9.6-dev-11' );
2012-04-11 18:49:22 +02:00
require 'inc/functions.php' ;
$step = isset ( $_GET [ 'step' ]) ? round ( $_GET [ 'step' ]) : 0 ;
2012-08-27 13:50:15 +02:00
$page = array (
2012-04-11 18:49:22 +02:00
'config' => $config ,
'title' => 'Install' ,
'body' => '' ,
'nojavascript' => true
);
// this breaks the dispaly of licenses if enabled
$config [ 'minify_html' ] = false ;
2012-04-12 16:18:19 +02:00
if ( file_exists ( $config [ 'has_installed' ])) {
2012-04-11 18:49:22 +02:00
// Check the version number
$version = trim ( file_get_contents ( $config [ 'has_installed' ]));
2012-04-12 16:18:19 +02:00
if ( empty ( $version ))
2012-04-11 18:49:22 +02:00
$version = 'v0.9.1' ;
$boards = listBoards ();
2012-04-12 16:18:19 +02:00
switch ( $version ) {
2012-04-11 18:49:22 +02:00
case 'v0.9' :
case 'v0.9.1' :
// Upgrade to v0.9.2-dev
2012-04-12 16:18:19 +02:00
foreach ( $boards as & $_board ) {
2012-04-11 18:49:22 +02:00
// Add `capcode` field after `trip`
query ( sprintf ( " ALTER TABLE `posts_%s` ADD `capcode` VARCHAR( 50 ) NULL AFTER `trip` " , $_board [ 'uri' ])) or error ( db_error ());
2011-09-10 14:26:52 +02:00
2012-04-11 18:49:22 +02:00
// Resize `trip` to 15 characters
query ( sprintf ( " ALTER TABLE `posts_%s` CHANGE `trip` `trip` VARCHAR( 15 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL " , $_board [ 'uri' ])) or error ( db_error ());
}
case 'v0.9.2-dev' :
// Upgrade to v0.9.2-dev-1
// New table: `theme_settings`
query ( " CREATE TABLE IF NOT EXISTS `theme_settings` ( `name` varchar(40) NOT NULL, `value` text, UNIQUE KEY `name` (`name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8; " ) or error ( db_error ());
// New table: `news`
query ( " CREATE TABLE IF NOT EXISTS `news` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` text NOT NULL, `time` int(11) NOT NULL, `subject` text NOT NULL, `body` text NOT NULL, UNIQUE KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; " ) or error ( db_error ());
case 'v0.9.2.1-dev' :
case 'v0.9.2-dev-1' :
// Fix broken version number/mistake
$version = 'v0.9.2-dev-1' ;
// Upgrade to v0.9.2-dev-2
2012-04-12 16:18:19 +02:00
foreach ( $boards as & $_board ) {
2012-04-11 18:49:22 +02:00
// Increase field sizes
query ( sprintf ( " ALTER TABLE `posts_%s` CHANGE `subject` `subject` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL " , $_board [ 'uri' ])) or error ( db_error ());
query ( sprintf ( " ALTER TABLE `posts_%s` CHANGE `name` `name` VARCHAR( 35 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL " , $_board [ 'uri' ])) or error ( db_error ());
}
case 'v0.9.2-dev-2' :
// Upgrade to v0.9.2-dev-3 (v0.9.2)
2012-04-12 16:18:19 +02:00
foreach ( $boards as & $_board ) {
2012-04-11 18:49:22 +02:00
// Add `custom_fields` field
query ( sprintf ( " ALTER TABLE `posts_%s` ADD `embed` TEXT NULL " , $_board [ 'uri' ])) or error ( db_error ());
}
case 'v0.9.2-dev-3' : // v0.9.2-dev-3 == v0.9.2
case 'v0.9.2' :
// Upgrade to v0.9.3-dev-1
// Upgrade `theme_settings` table
query ( " TRUNCATE TABLE `theme_settings` " ) or error ( db_error ());
query ( " ALTER TABLE `theme_settings` ADD `theme` VARCHAR( 40 ) NOT NULL FIRST " ) or error ( db_error ());
query ( " ALTER TABLE `theme_settings` CHANGE `name` `name` VARCHAR( 40 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL " ) or error ( db_error ());
query ( " ALTER TABLE `theme_settings` DROP INDEX `name` " ) or error ( db_error ());
case 'v0.9.3-dev-1' :
query ( " ALTER TABLE `mods` ADD `boards` TEXT NOT NULL " ) or error ( db_error ());
query ( " UPDATE `mods` SET `boards` = '*' " ) or error ( db_error ());
case 'v0.9.3-dev-2' :
2012-04-12 16:18:19 +02:00
foreach ( $boards as & $_board ) {
2012-04-11 18:49:22 +02:00
query ( sprintf ( " ALTER TABLE `posts_%s` CHANGE `filehash` `filehash` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL " , $_board [ 'uri' ])) or error ( db_error ());
}
case 'v0.9.3-dev-3' :
// Board-specifc bans
query ( " ALTER TABLE `bans` ADD `board` SMALLINT NULL AFTER `reason` " ) or error ( db_error ());
case 'v0.9.3-dev-4' :
// add ban ID
query ( " ALTER TABLE `bans` ADD `id` INT NOT NULL AUTO_INCREMENT FIRST, ADD PRIMARY KEY ( `id` ), ADD UNIQUE (`id`) " );
case 'v0.9.3-dev-5' :
2012-04-12 16:18:19 +02:00
foreach ( $boards as & $_board ) {
2012-04-11 18:49:22 +02:00
// Increase subject field size
query ( sprintf ( " ALTER TABLE `posts_%s` CHANGE `subject` `subject` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL " , $_board [ 'uri' ])) or error ( db_error ());
}
case 'v0.9.3-dev-6' :
// change to MyISAM
2012-08-27 13:50:15 +02:00
$tables = array (
2012-04-11 18:49:22 +02:00
'bans' , 'boards' , 'ip_notes' , 'modlogs' , 'mods' , 'mutes' , 'noticeboard' , 'pms' , 'reports' , 'robot' , 'theme_settings' , 'news'
);
2012-04-12 16:18:19 +02:00
foreach ( $boards as & $board ) {
2012-04-11 18:49:22 +02:00
$tables [] = " posts_ { $board [ 'uri' ] } " ;
}
2012-04-12 16:18:19 +02:00
foreach ( $tables as & $table ) {
2012-04-11 18:49:22 +02:00
query ( " ALTER TABLE ` { $table } ` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci " ) or error ( db_error ());
}
case 'v0.9.3-dev-7' :
2012-04-12 16:18:19 +02:00
foreach ( $boards as & $board ) {
2012-04-11 18:49:22 +02:00
query ( sprintf ( " ALTER TABLE `posts_%s` CHANGE `filename` `filename` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL " , $board [ 'uri' ])) or error ( db_error ());
}
case 'v0.9.3-dev-8' :
2012-04-12 16:18:19 +02:00
foreach ( $boards as & $board ) {
2012-04-11 18:49:22 +02:00
query ( sprintf ( " ALTER TABLE `posts_%s` ADD INDEX ( `thread` ) " , $board [ 'uri' ])) or error ( db_error ());
}
case 'v0.9.3-dev-9' :
2012-04-12 16:18:19 +02:00
foreach ( $boards as & $board ) {
2012-04-11 18:49:22 +02:00
query ( sprintf ( " ALTER TABLE `posts_%s`ADD INDEX ( `time` ) " , $board [ 'uri' ])) or error ( db_error ());
query ( sprintf ( " ALTER TABLE `posts_%s`ADD FULLTEXT (`body`) " , $board [ 'uri' ])) or error ( db_error ());
}
case 'v0.9.3-dev-10' :
case 'v0.9.3' :
query ( " ALTER TABLE `bans` DROP INDEX `id` " ) or error ( db_error ());
query ( " ALTER TABLE `pms` DROP INDEX `id` " ) or error ( db_error ());
query ( " ALTER TABLE `boards` DROP PRIMARY KEY " ) or error ( db_error ());
query ( " ALTER TABLE `reports` DROP INDEX `id` " ) or error ( db_error ());
query ( " ALTER TABLE `boards` DROP INDEX `uri` " ) or error ( db_error ());
query ( " ALTER IGNORE TABLE `robot` ADD PRIMARY KEY (`hash`) " ) or error ( db_error ());
query ( " ALTER TABLE `bans` ADD FULLTEXT (`ip`) " ) or error ( db_error ());
query ( " ALTER TABLE `ip_notes` ADD INDEX (`ip`) " ) or error ( db_error ());
query ( " ALTER TABLE `modlogs` ADD INDEX (`time`) " ) or error ( db_error ());
query ( " ALTER TABLE `boards` ADD PRIMARY KEY(`uri`) " ) or error ( db_error ());
query ( " ALTER TABLE `mutes` ADD INDEX (`ip`) " ) or error ( db_error ());
query ( " ALTER TABLE `news` ADD INDEX (`time`) " ) or error ( db_error ());
query ( " ALTER TABLE `theme_settings` ADD INDEX (`theme`) " ) or error ( db_error ());
case 'v0.9.4-dev-1' :
2012-04-12 16:18:19 +02:00
foreach ( $boards as & $board ) {
2012-04-11 18:49:22 +02:00
query ( sprintf ( " ALTER TABLE `posts_%s` ADD `sage` INT( 1 ) NOT NULL AFTER `locked` " , $board [ 'uri' ])) or error ( db_error ());
}
case 'v0.9.4-dev-2' :
2012-04-12 16:18:19 +02:00
if ( ! isset ( $_GET [ 'confirm' ])) {
2012-04-11 18:49:22 +02:00
$page [ 'title' ] = 'License Change' ;
$page [ 'body' ] = '<p style="text-align:center">You are upgrading to a version which uses an amended license. The licenses included with Tinyboard distributions prior to this version (v0.9.4-dev-2) are still valid for those versions, but no longer apply to this and newer versions.</p>' .
'<textarea style="width:700px;height:370px;margin:auto;display:block;background:white;color:black" disabled>' . htmlentities ( file_get_contents ( 'LICENSE.md' )) . ' </ textarea >
< p style = " text-align:center " >
< a href = " ?confirm=1 " > I have read and understood the agreement . Proceed to upgrading .</ a >
</ p > ' ;
2011-10-08 19:04:39 +02:00
2012-04-11 18:49:22 +02:00
file_write ( $config [ 'has_installed' ], 'v0.9.4-dev-2' );
2011-04-30 10:26:22 +02:00
break ;
2012-04-11 18:49:22 +02:00
}
case 'v0.9.4-dev-3' :
case 'v0.9.4-dev-4' :
case 'v0.9.4' :
2012-04-12 16:18:19 +02:00
foreach ( $boards as & $board ) {
2012-04-11 18:49:22 +02:00
query ( sprintf ( " ALTER TABLE `posts_%s`
CHANGE `subject` `subject` VARCHAR ( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,
CHANGE `email` `email` VARCHAR ( 30 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL ,
CHANGE `name` `name` VARCHAR ( 35 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL " , $board['uri'] )) or error(db_error());
}
case 'v0.9.5-dev-1' :
2012-04-12 16:18:19 +02:00
foreach ( $boards as & $board ) {
2012-04-11 18:49:22 +02:00
query ( sprintf ( " ALTER TABLE `posts_%s` ADD `body_nomarkup` TEXT NULL AFTER `body` " , $board [ 'uri' ])) or error ( db_error ());
}
query ( " CREATE TABLE IF NOT EXISTS `cites` ( `board` varchar(8) NOT NULL, `post` int(11) NOT NULL, `target_board` varchar(8) NOT NULL, `target` int(11) NOT NULL, KEY `target` (`target_board`,`target`), KEY `post` (`board`,`post`)) ENGINE=MyISAM DEFAULT CHARSET=utf8; " ) or error ( db_error ());
case 'v0.9.5-dev-2' :
query ( " ALTER TABLE `boards`
CHANGE `uri` `uri` VARCHAR ( 15 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `title` `title` VARCHAR ( 40 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `subtitle` `subtitle` VARCHAR ( 120 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL " ) or error(db_error());
case 'v0.9.5-dev-3' :
// v0.9.5
case 'v0.9.5' :
query ( " ALTER TABLE `boards`
CHANGE `uri` `uri` VARCHAR ( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `title` `title` TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `subtitle` `subtitle` TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL " ) or error(db_error());
2012-04-12 13:56:01 +02:00
case 'v0.9.6-dev-1' :
query ( " CREATE TABLE IF NOT EXISTS `antispam` (
`board` varchar ( 255 ) NOT NULL ,
`thread` int ( 11 ) DEFAULT NULL ,
`hash` bigint ( 20 ) NOT NULL ,
`created` int ( 11 ) NOT NULL ,
`expires` int ( 11 ) DEFAULT NULL ,
`passed` smallint ( 6 ) NOT NULL ,
PRIMARY KEY ( `hash` ),
KEY `board` ( `board` , `thread` )
2012-04-12 15:23:47 +02:00
) ENGINE = MyISAM DEFAULT CHARSET = utf8 ; " ) or error(db_error());
case 'v0.9.6-dev-2' :
query ( " ALTER TABLE `boards`
DROP `id` ,
CHANGE `uri` `uri` VARCHAR ( 120 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL " ) or error(db_error());
query ( " ALTER TABLE `bans` CHANGE `board` `board` VARCHAR( 120 ) NULL DEFAULT NULL " ) or error ( db_error ());
query ( " ALTER TABLE `reports` CHANGE `board` `board` VARCHAR( 120 ) NULL DEFAULT NULL " ) or error ( db_error ());
query ( " ALTER TABLE `modlogs` CHANGE `board` `board` VARCHAR( 120 ) NULL DEFAULT NULL " ) or error ( db_error ());
2012-04-12 16:18:19 +02:00
foreach ( $boards as $board ) {
2012-04-12 15:23:47 +02:00
$query = prepare ( " UPDATE `bans` SET `board` = :newboard WHERE `board` = :oldboard " );
$query -> bindValue ( ':newboard' , $board [ 'uri' ]);
$query -> bindValue ( ':oldboard' , $board [ 'id' ]);
$query -> execute () or error ( db_error ( $query ));
$query = prepare ( " UPDATE `modlogs` SET `board` = :newboard WHERE `board` = :oldboard " );
$query -> bindValue ( ':newboard' , $board [ 'uri' ]);
$query -> bindValue ( ':oldboard' , $board [ 'id' ]);
$query -> execute () or error ( db_error ( $query ));
$query = prepare ( " UPDATE `reports` SET `board` = :newboard WHERE `board` = :oldboard " );
$query -> bindValue ( ':newboard' , $board [ 'uri' ]);
$query -> bindValue ( ':oldboard' , $board [ 'id' ]);
$query -> execute () or error ( db_error ( $query ));
}
2012-04-18 17:32:02 +02:00
case 'v0.9.6-dev-3' :
query ( " ALTER TABLE `antispam` CHANGE `hash` `hash` CHAR( 40 ) NOT NULL " ) or error ( db_error ());
2012-05-05 17:33:10 +02:00
case 'v0.9.6-dev-4' :
query ( " ALTER TABLE `news` DROP INDEX `id`, ADD PRIMARY KEY ( `id` ) " ) or error ( db_error ());
2012-08-26 18:52:31 +02:00
case 'v0.9.6-dev-5' :
query ( " ALTER TABLE `bans` CHANGE `id` `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT " ) or error ( db_error ());
query ( " ALTER TABLE `mods` CHANGE `id` `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT " ) or error ( db_error ());
query ( " ALTER TABLE `news` CHANGE `id` `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT " ) or error ( db_error ());
query ( " ALTER TABLE `noticeboard` CHANGE `id` `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT " ) or error ( db_error ());
query ( " ALTER TABLE `pms` CHANGE `id` `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT " ) or error ( db_error ());
query ( " ALTER TABLE `reports` CHANGE `id` `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT " ) or error ( db_error ());
foreach ( $boards as $board ) {
query ( sprintf ( " ALTER TABLE `posts_%s` CHANGE `id` `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT " , $board [ 'uri' ])) or error ( db_error ());
}
2013-01-19 08:49:00 +01:00
case 'v0.9.6-dev-6' :
foreach ( $boards as & $_board ) {
query ( sprintf ( " CREATE INDEX `thread_id` ON `posts_%s` (`thread`, `id`) " , $_board [ 'uri' ])) or error ( db_error ());
query ( sprintf ( " ALTER TABLE `posts_%s` DROP INDEX `thread` " , $_board [ 'uri' ])) or error ( db_error ());
}
2013-07-16 12:33:37 +02:00
case 'v0.9.6-dev-7' :
query ( " ALTER TABLE `bans` ADD `seen` BOOLEAN NOT NULL " ) or error ( db_error ());
2013-07-24 17:15:55 +02:00
case 'v0.9.6-dev-8' :
query ( " ALTER TABLE `mods` CHANGE `password` `password` CHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'SHA256' " ) or error ( db_error ());
query ( " ALTER TABLE `mods` ADD `salt` CHAR( 32 ) NOT NULL AFTER `password` " ) or error ( db_error ());
$query = query ( " SELECT `id`,`password` FROM `mods` " ) or error ( db_error ());
while ( $user = $query -> fetch ( PDO :: FETCH_ASSOC )) {
if ( strlen ( $user [ 'password' ]) == 40 ) {
mt_srand ( microtime ( true ) * 100000 + memory_get_usage ( true ));
$salt = md5 ( uniqid ( mt_rand (), true ));
$user [ 'salt' ] = $salt ;
$user [ 'password' ] = hash ( 'sha256' , $user [ 'salt' ] . $user [ 'password' ]);
$_query = prepare ( " UPDATE `mods` SET `password` = :password, `salt` = :salt WHERE `id` = :id " );
2013-07-24 17:17:09 +02:00
$_query -> bindValue ( ':id' , $user [ 'id' ]);
2013-07-24 17:15:55 +02:00
$_query -> bindValue ( ':password' , $user [ 'password' ]);
$_query -> bindValue ( ':salt' , $user [ 'salt' ]);
$_query -> execute () or error ( db_error ( $_query ));
}
}
2013-07-31 04:08:56 +02:00
case 'v0.9.6-dev-9' :
2013-07-31 04:13:05 +02:00
sql_open ();
2013-07-31 04:08:56 +02:00
function __query ( $sql ) {
if ( mysql_version () >= 50503 )
return query ( $sql );
else
return query ( str_replace ( 'utf8mb4' , 'utf8' , $sql ));
}
foreach ( $boards as & $board ) {
__query ( sprintf ( " ALTER TABLE `posts_%s`
CHANGE `subject` `subject` VARCHAR ( 100 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
CHANGE `email` `email` VARCHAR ( 30 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
CHANGE `name` `name` VARCHAR ( 35 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
CHANGE `trip` `trip` VARCHAR ( 15 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
CHANGE `capcode` `capcode` VARCHAR ( 50 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
CHANGE `body` `body` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL ,
CHANGE `body_nomarkup` `body_nomarkup` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
CHANGE `thumb` `thumb` VARCHAR ( 50 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
CHANGE `thumbwidth` `thumbwidth` INT ( 11 ) NULL DEFAULT NULL ,
CHANGE `thumbheight` `thumbheight` INT ( 11 ) NULL DEFAULT NULL ,
CHANGE `file` `file` VARCHAR ( 50 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
CHANGE `filename` `filename` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
CHANGE `filehash` `filehash` TEXT CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL ,
CHANGE `password` `password` VARCHAR ( 20 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
CHANGE `ip` `ip` VARCHAR ( 39 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL ,
CHANGE `embed` `embed` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ; " , $board['uri'] )) or error(db_error());
}
__query ( " ALTER TABLE `antispam`
CHANGE `board` `board` VARCHAR ( 120 ) CHARACTER SET ASCII COLLATE ascii_general_ci NOT NULL ,
CHANGE `hash` `hash` CHAR ( 40 ) CHARACTER SET ASCII COLLATE ascii_bin NOT NULL ,
DEFAULT CHARACTER SET ASCII COLLATE ascii_bin ; " ) or error(db_error());
__query ( " ALTER TABLE `bans`
CHANGE `ip` `ip` VARCHAR ( 39 ) CHARACTER SET ASCII COLLATE ascii_general_ci NOT NULL ,
CHANGE `reason` `reason` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
CHANGE `board` `board` VARCHAR ( 120 ) CHARACTER SET ASCII COLLATE ascii_general_ci NULL DEFAULT NULL ,
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ; " ) or error(db_error());
__query ( " ALTER TABLE `boards`
CHANGE `uri` `uri` VARCHAR ( 120 ) CHARACTER SET ASCII COLLATE ascii_general_ci NOT NULL ,
CHANGE `title` `title` TINYTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL ,
CHANGE `subtitle` `subtitle` TINYTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ; " ) or error(db_error());
__query ( " ALTER TABLE `cites`
CHANGE `board` `board` VARCHAR ( 120 ) CHARACTER SET ASCII COLLATE ascii_general_ci NOT NULL ,
CHANGE `target_board` `target_board` VARCHAR ( 120 ) CHARACTER SET ASCII COLLATE ascii_general_ci NOT NULL ,
DEFAULT CHARACTER SET ASCII COLLATE ascii_general_ci ; " ) or error(db_error());
__query ( " ALTER TABLE `ip_notes`
CHANGE `ip` `ip` VARCHAR ( 39 ) CHARACTER SET ASCII COLLATE ascii_general_ci NOT NULL ,
CHANGE `body` `body` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL ,
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ; " ) or error(db_error());
__query ( " ALTER TABLE `modlogs`
CHANGE `ip` `ip` VARCHAR ( 39 ) CHARACTER SET ASCII COLLATE ascii_general_ci NOT NULL ,
CHANGE `board` `board` VARCHAR ( 120 ) CHARACTER SET ASCII COLLATE ascii_general_ci NULL DEFAULT NULL ,
CHANGE `text` `text` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL ,
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ; " ) or error(db_error());
__query ( " ALTER TABLE `mods`
CHANGE `username` `username` VARCHAR ( 30 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL ,
CHANGE `password` `password` CHAR ( 64 ) CHARACTER SET ASCII COLLATE ascii_general_ci NOT NULL COMMENT 'SHA256' ,
CHANGE `salt` `salt` CHAR ( 32 ) CHARACTER SET ASCII COLLATE ascii_general_ci NOT NULL ,
CHANGE `boards` `boards` TEXT CHARACTER SET ASCII COLLATE ascii_general_ci NOT NULL ,
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ; " ) or error(db_error());
__query ( " ALTER TABLE `mutes`
CHANGE `ip` `ip` VARCHAR ( 39 ) CHARACTER SET ASCII COLLATE ascii_general_ci NOT NULL ,
DEFAULT CHARACTER SET ASCII COLLATE ascii_general_ci ; " ) or error(db_error());
__query ( " ALTER TABLE `news`
CHANGE `name` `name` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL ,
CHANGE `subject` `subject` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL ,
CHANGE `body` `body` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL ,
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ; " ) or error(db_error());
__query ( " ALTER TABLE `noticeboard`
CHANGE `subject` `subject` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL ,
CHANGE `body` `body` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL ,
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ; " ) or error(db_error());
__query ( " ALTER TABLE `pms`
CHANGE `message` `message` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL ,
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ; " ) or error(db_error());
__query ( " ALTER TABLE `reports`
CHANGE `ip` `ip` VARCHAR ( 39 ) CHARACTER SET ASCII COLLATE ascii_general_ci NOT NULL ,
CHANGE `board` `board` VARCHAR ( 120 ) CHARACTER SET ASCII COLLATE ascii_general_ci NULL DEFAULT NULL ,
CHANGE `reason` `reason` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL ,
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ; " ) or error(db_error());
__query ( " ALTER TABLE `robot`
CHANGE `hash` `hash` VARCHAR ( 40 ) CHARACTER SET ASCII COLLATE ascii_bin NOT NULL COMMENT 'SHA1' ,
DEFAULT CHARACTER SET ASCII COLLATE ascii_bin ; " ) or error(db_error());
__query ( " ALTER TABLE `theme_settings`
CHANGE `theme` `theme` VARCHAR ( 40 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL ,
CHANGE `name` `name` VARCHAR ( 40 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
CHANGE `value` `value` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL ,
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ; " ) or eror(db_error());
2013-07-31 08:08:55 +02:00
case 'v0.9.6-dev-10' :
query ( " ALTER TABLE `antispam`
CHANGE `board` `board` VARCHAR ( 58 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ; " ) or error(db_error());
query ( " ALTER TABLE `bans`
CHANGE `board` `board` VARCHAR ( 58 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ; " ) or error(db_error());
query ( " ALTER TABLE `boards`
CHANGE `uri` `uri` VARCHAR ( 58 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ; " ) or error(db_error());
query ( " ALTER TABLE `cites`
CHANGE `board` `board` VARCHAR ( 58 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `target_board` `target_board` VARCHAR ( 58 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ; " ) or error(db_error());
query ( " ALTER TABLE `modlogs`
CHANGE `board` `board` VARCHAR ( 58 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ; " ) or error(db_error());
query ( " ALTER TABLE `mods`
CHANGE `boards` `boards` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ; " ) or error(db_error());
query ( " ALTER TABLE `reports`
CHANGE `board` `board` VARCHAR ( 58 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ; " ) or error(db_error());
2012-04-11 18:49:22 +02:00
case false :
// Update version number
file_write ( $config [ 'has_installed' ], VERSION );
$page [ 'title' ] = 'Upgraded' ;
$page [ 'body' ] = '<p style="text-align:center">Successfully upgraded from ' . $version . ' to <strong>' . VERSION . '</strong>.</p>' ;
break ;
default :
$page [ 'title' ] = 'Unknown version' ;
$page [ 'body' ] = '<p style="text-align:center">Tinyboard was unable to determine what version is currently installed.</p>' ;
break ;
case VERSION :
$page [ 'title' ] = 'Already installed' ;
$page [ 'body' ] = '<p style="text-align:center">It appears that Tinyboard is already installed (' . $version . ') and there is nothing to upgrade! Delete <strong>' . $config [ 'has_installed' ] . '</strong> to reinstall.</p>' ;
break ;
}
die ( Element ( 'page.html' , $page ));
}
2012-04-12 16:18:19 +02:00
if ( $step == 0 ) {
2012-04-11 18:49:22 +02:00
// Agreeement
$page [ 'body' ] = '
< textarea style = " width:700px;height:370px;margin:auto;display:block;background:white;color:black " disabled > ' . htmlentities(file_get_contents(' LICENSE . md ')) . ' </ textarea >
< p style = " text-align:center " >
< a href = " ?step=1 " > I have read and understood the agreement . Proceed to installation .</ a >
</ p > ' ;
echo Element ( 'page.html' , $page );
2012-04-12 16:18:19 +02:00
} elseif ( $step == 1 ) {
2012-04-11 18:49:22 +02:00
$page [ 'title' ] = 'Pre-installation test' ;
$page [ 'body' ] = '<table class="test">' ;
function rheader ( $item ) {
global $page , $config ;
2011-04-12 13:08:54 +02:00
2012-04-11 18:49:22 +02:00
$page [ 'body' ] .= '<tr class="h"><th colspan="2">' . $item . '</th></tr>' ;
2011-02-16 09:10:16 +01:00
}
2012-04-11 18:49:22 +02:00
function row ( $item , $result ) {
global $page , $config , $__is_error ;
2012-04-12 16:18:19 +02:00
if ( ! $result )
2012-04-11 18:49:22 +02:00
$__is_error = true ;
$page [ 'body' ] .= '<tr><th>' . $item . '</th><td><img style="width:16px;height:16px" src="' . $config [ 'dir' ][ 'static' ] . ( $result ? 'ok.png' : 'error.png' ) . '" /></td></tr>' ;
}
// Required extensions
rheader ( 'PHP extensions' );
row ( 'PDO' , extension_loaded ( 'pdo' ));
row ( 'GD' , extension_loaded ( 'gd' ));
// GD tests
rheader ( 'GD tests' );
row ( 'JPEG' , function_exists ( 'imagecreatefromjpeg' ));
row ( 'PNG' , function_exists ( 'imagecreatefrompng' ));
row ( 'GIF' , function_exists ( 'imagecreatefromgif' ));
// Database drivers
$drivers = PDO :: getAvailableDrivers ();
rheader ( 'PDO drivers <em>(currently installed drivers)</em>' );
2012-04-12 16:18:19 +02:00
foreach ( $drivers as & $driver ) {
2012-04-11 18:49:22 +02:00
row ( $driver , true );
}
// Permissions
rheader ( 'File permissions' );
row ( '<em>root directory</em> (' . getcwd () . ')' , is_writable ( '.' ));
$page [ 'body' ] .= ' </ table >
< p style = " text-align:center " >
< a href = " ?step=2 " ' .
( isset ( $__is_error ) ? ' onclick="return confirm(\'Are you sure you want to continue when errors exist?\')"' : '' ) .
'>Continue' . ( isset ( $__is_error ) ? ' anyway' : '' ) . ' </ a >
</ p > ' ;
echo Element ( 'page.html' , $page );
2012-04-12 16:18:19 +02:00
} elseif ( $step == 2 ) {
2012-04-11 18:49:22 +02:00
// Basic config
$page [ 'title' ] = 'Configuration' ;
function create_salt () {
return substr ( base64_encode ( sha1 ( rand ())), 0 , rand ( 25 , 31 ));
}
$page [ 'body' ] = '
< form action = " ?step=3 " method = " post " >
< fieldset >
< legend > Database </ legend >
< label for = " db_type " > Type :</ label >
< select id = " db_type " name = " db[type] " > ' ;
2011-01-02 09:18:10 +01:00
2012-04-11 18:49:22 +02:00
$drivers = PDO :: getAvailableDrivers ();
2011-01-02 09:18:10 +01:00
2012-04-12 16:18:19 +02:00
foreach ( $drivers as & $driver ) {
2012-04-11 18:49:22 +02:00
$driver_txt = $driver ;
2012-04-12 16:18:19 +02:00
switch ( $driver ) {
2012-04-11 18:49:22 +02:00
case 'cubrid' :
$driver_txt = 'Cubrid' ;
break ;
case 'dblib' :
$driver_txt = 'FreeTDS / Microsoft SQL Server / Sybase' ;
break ;
case 'firebird' :
$driver_txt = 'Firebird/Interbase 6' ;
break ;
case 'ibm' :
$driver_txt = 'IBM DB2' ;
break ;
case 'informix' :
$driver_txt = 'IBM Informix Dynamic Server' ;
break ;
case 'mysql' :
$driver_txt = 'MySQL' ;
break ;
case 'oci' :
$driver_txt = 'OCI' ;
break ;
case 'odbc' :
$driver_txt = 'ODBC v3 (IBM DB2, unixODBC)' ;
break ;
case 'pgsql' :
$driver_txt = 'PostgreSQL' ;
break ;
case 'sqlite' :
$driver_txt = 'SQLite 3' ;
break ;
case 'sqlite2' :
$driver_txt = 'SQLite 2' ;
break ;
}
$page [ 'body' ] .= '<option value="' . $driver . '">' . $driver_txt . '</option>' ;
2011-02-16 04:44:20 +01:00
}
2011-01-02 09:18:10 +01:00
2012-04-11 18:49:22 +02:00
$page [ 'body' ] .= '
</ select >
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " db_server " > Server :</ label >
< input type = " text " id = " db_server " name = " db[server] " value = " localhost " />
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " db_db " > Database :</ label >
< input type = " text " id = " db_db " name = " db[database] " value = " " />
2011-02-16 04:44:20 +01:00
2013-08-01 06:52:49 +02:00
< label for = " db_prefix " > Table prefix ( optional ) :</ label >
< input type = " text " id = " db_prefix " name = " db[prefix] " value = " " />
2013-08-01 04:14:26 +02:00
2012-04-11 18:49:22 +02:00
< label for = " db_user " > Username :</ label >
< input type = " text " id = " db_user " name = " db[user] " value = " " />
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " db_pass " > Password :</ label >
< input type = " password " id = " db_pass " name = " db[password] " value = " " />
</ fieldset >
< p style = " text-align:center " class = " unimportant " > The following is all later configurable . For more options , < a href = " http://tinyboard.org/docs/?p=Config " > edit your configuration files </ a > after installing .</ p >
< fieldset >
< legend > Cookies </ legend >
< label for = " cookies_mod " > Moderator cookie :</ label >
< input type = " text " id = " cookies_mod " name = " cookies[mod] " value = " ' . $config['cookies'] ['mod'] . ' " />
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " cookies_salt " > Secure salt :</ label >
< input type = " text " id = " cookies_salt " name = " cookies[salt] " value = " ' . create_salt() . ' " size = " 40 " />
</ fieldset >
< fieldset >
< legend > Flood control </ legend >
< label for = " flood_time " > Seconds before each post :</ label >
< input type = " text " id = " flood_time " name = " flood_time " value = " ' . $config['flood_time'] . ' " />
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " flood_time_ip " > Seconds before you can repost something ( post the exact same text ) :</ label >
< input type = " text " id = " flood_time_ip " name = " flood_time_ip " value = " ' . $config['flood_time_ip'] . ' " />
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " flood_time_same " > Same as above , but with a different IP address :</ label >
< input type = " text " id = " flood_time_same " name = " flood_time_same " value = " ' . $config['flood_time_same'] . ' " />
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " max_body " > Maximum post body length :</ label >
< input type = " text " id = " max_body " name = " max_body " value = " ' . $config['max_body'] . ' " />
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " reply_limit " > Replies in a thread before it can no longer be bumped :</ label >
< input type = " text " id = " reply_limit " name = " reply_limit " value = " ' . $config['reply_limit'] . ' " />
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " max_links " > Maximum number of links in a single post :</ label >
< input type = " text " id = " max_links " name = " max_links " value = " ' . $config['max_links'] . ' " />
</ fieldset >
< fieldset >
< legend > Images </ legend >
< label for = " max_filesize " > Maximum image filesize :</ label >
< input type = " text " id = " max_filesize " name = " max_filesize " value = " ' . $config['max_filesize'] . ' " />
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " thumb_width " > Thumbnail width :</ label >
< input type = " text " id = " thumb_width " name = " thumb_width " value = " ' . $config['thumb_width'] . ' " />
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " thumb_height " > Thumbnail height :</ label >
< input type = " text " id = " thumb_height " name = " thumb_height " value = " ' . $config['thumb_height'] . ' " />
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " max_width " > Maximum image width :</ label >
< input type = " text " id = " max_width " name = " max_width " value = " ' . $config['max_width'] . ' " />
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " max_height " > Maximum image height :</ label >
< input type = " text " id = " max_height " name = " max_height " value = " ' . $config['max_height'] . ' " />
</ fieldset >
< fieldset >
< legend > Display </ legend >
< label for = " threads_per_page " > Threads per page :</ label >
< input type = " text " id = " threads_per_page " name = " threads_per_page " value = " ' . $config['threads_per_page'] . ' " />
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " max_pages " > Page limit :</ label >
< input type = " text " id = " max_pages " name = " max_pages " value = " ' . $config['max_pages'] . ' " />
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " threads_preview " > Number of replies to show per thread on the index page :</ label >
< input type = " text " id = " threads_preview " name = " threads_preview " value = " ' . $config['threads_preview'] . ' " />
</ fieldset >
< fieldset >
< legend > Directories </ legend >
< label for = " root " > Root URI ( include trailing slash ) :</ label >
< input type = " text " id = " root " name = " root " value = " ' . $config['root'] . ' " />
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " dir_img " > Image directory :</ label >
< input type = " text " id = " dir_img " name = " dir[img] " value = " ' . $config['dir'] ['img'] . ' " />
2011-02-16 04:44:20 +01:00
2012-04-11 18:49:22 +02:00
< label for = " dir_thumb " > Thumbnail directory :</ label >
< input type = " text " id = " dir_thumb " name = " dir[thumb] " value = " ' . $config['dir'] ['thumb'] . ' " />
< label for = " dir_res " > Thread directory :</ label >
< input type = " text " id = " dir_res " name = " dir[res] " value = " ' . $config['dir'] ['res'] . ' " />
</ fieldset >
< fieldset >
< legend > Miscellaneous </ legend >
< label for = " secure_trip_salt " > Secure trip ( ##) salt:</label>
< input type = " text " id = " secure_trip_salt " name = " secure_trip_salt " value = " ' . create_salt() . ' " size = " 40 " />
</ fieldset >
< p style = " text-align:center " >
< input type = " submit " value = " Complete installation " />
</ p >
</ form >
' ;
echo Element ( 'page.html' , $page );
2012-04-12 16:18:19 +02:00
} elseif ( $step == 3 ) {
2012-04-11 18:49:22 +02:00
$instance_config =
2011-02-16 07:03:50 +01:00
' < ? php
/*
2012-04-11 18:49:22 +02:00
* Instance Configuration
* ----------------------
* Edit this file and not config . php for imageboard configuration .
*
* You can copy values from config . php ( defaults ) and paste them here .
*/
2011-02-16 07:03:50 +01:00
' ;
2012-04-11 18:49:22 +02:00
function create_config_from_array ( & $instance_config , & $array , $prefix = '' ) {
2012-04-12 16:18:19 +02:00
foreach ( $array as $name => $value ) {
if ( is_array ( $value )) {
2012-04-11 18:49:22 +02:00
$instance_config .= " \n " ;
create_config_from_array ( $instance_config , $value , $prefix . '[\'' . addslashes ( $name ) . '\']' );
$instance_config .= " \n " ;
} else {
$instance_config .= ' $config' . $prefix . '[\'' . addslashes ( $name ) . '\'] = ' ;
2012-04-12 16:18:19 +02:00
if ( is_numeric ( $value ))
2012-04-11 18:49:22 +02:00
$instance_config .= $value ;
else
$instance_config .= " ' " . addslashes ( $value ) . " ' " ;
2011-02-16 07:03:50 +01:00
2012-04-11 18:49:22 +02:00
$instance_config .= " ; \n " ;
2011-02-16 07:03:50 +01:00
}
}
2012-04-11 18:49:22 +02:00
}
create_config_from_array ( $instance_config , $_POST );
$instance_config .= " \n " ;
2012-04-12 16:18:19 +02:00
if ( @ file_put_contents ( 'inc/instance-config.php' , $instance_config )) {
2012-04-11 18:49:22 +02:00
header ( 'Location: ?step=4' , true , $config [ 'redirect_http' ]);
} else {
$page [ 'title' ] = 'Manual installation required' ;
$page [ 'body' ] = '
< p > I couldn\ ' t write to < strong > inc / instance - config . php </ strong > with the new configuration , probably due to a permissions error .</ p >
< p > Please complete the installation manually by copying and pasting the following code into the contents of < strong > inc / instance - config . php </ strong >:</ p >
< textarea style = " width:700px;height:370px;margin:auto;display:block;background:white;color:black " > ' . htmlentities($instance_config) . ' </ textarea >
< p style = " text-align:center " >
< a href = " ?step=4 " > Once complete , click here to complete installation .</ a >
</ p >
' ;
2011-03-28 07:24:33 +02:00
echo Element ( 'page.html' , $page );
2012-04-11 18:49:22 +02:00
}
2012-04-12 16:18:19 +02:00
} elseif ( $step == 4 ) {
2012-04-11 18:49:22 +02:00
// SQL installation
buildJavascript ();
$sql = @ file_get_contents ( 'install.sql' ) or error ( " Couldn't load install.sql. " );
2013-07-31 04:08:56 +02:00
sql_open ();
if ( mysql_version () < 50503 )
$sql = str_replace ( 'utf8' , 'utf8mb4' , $sql );
2012-04-11 18:49:22 +02:00
// This code is probably horrible, but what I'm trying
// to do is find all of the SQL queires and put them
// in an array.
preg_match_all ( " /(^| \n )((SET|CREATE|INSERT).+) \n \n /msU " , $sql , $queries );
$queries = $queries [ 2 ];
2012-08-27 13:50:15 +02:00
$queries [] = Element ( 'posts.sql' , array ( 'board' => 'b' ));
2012-04-11 18:49:22 +02:00
$sql_errors = '' ;
2013-08-01 04:14:26 +02:00
foreach ( $queries as $query ) {
$query = preg_replace ( '/^([\w\s]*)`([0-9a-zA-Z$_\x{0080}-\x{FFFF}]+)`/u' , '$1``$2``' , $query );
2012-04-12 16:18:19 +02:00
if ( ! query ( $query ))
2012-04-11 18:49:22 +02:00
$sql_errors .= '<li>' . db_error () . '</li>' ;
}
$boards = listBoards ();
2012-04-12 16:18:19 +02:00
foreach ( $boards as & $_board ) {
2012-04-11 18:49:22 +02:00
setupBoard ( $_board );
buildIndex ();
}
$page [ 'title' ] = 'Installation complete' ;
$page [ 'body' ] = '<p style="text-align:center">Thank you for using Tinyboard. Please remember to report any bugs you discover. <a href="http://tinyboard.org/docs/?p=Config">How do I edit the config files?</a></p>' ;
2012-04-12 16:18:19 +02:00
if ( ! empty ( $sql_errors )) {
2012-04-11 18:49:22 +02:00
$page [ 'body' ] .= '<div class="ban"><h2>SQL errors</h2><p>SQL errors were encountered when trying to install the database. This may be the result of using a database which is already occupied with a Tinyboard installation; if so, you can probably ignore this.</p><p>The errors encountered were:</p><ul>' . $sql_errors . '</ul><p><a href="?step=5">Ignore errors and complete installation.</a></p></div>' ;
} else {
2011-05-20 09:19:27 +02:00
file_write ( $config [ 'has_installed' ], VERSION );
2012-04-12 16:18:19 +02:00
if ( ! file_unlink ( __FILE__ )) {
2011-03-28 07:24:33 +02:00
$page [ 'body' ] .= '<div class="ban"><h2>Delete install.php!</h2><p>I couldn\'t remove <strong>install.php</strong>. You will have to remove it manually.</p></div>' ;
2011-02-16 09:10:16 +01:00
}
2011-01-02 09:18:10 +01:00
}
2012-04-11 18:49:22 +02:00
echo Element ( 'page.html' , $page );
2012-04-12 16:18:19 +02:00
} elseif ( $step == 5 ) {
2012-04-11 18:49:22 +02:00
$page [ 'title' ] = 'Installation complete' ;
$page [ 'body' ] = '<p style="text-align:center">Thank you for using Tinyboard. Please remember to report any bugs you discover.</p>' ;
file_write ( $config [ 'has_installed' ], VERSION );
2012-04-12 16:18:19 +02:00
if ( ! file_unlink ( __FILE__ )) {
2012-04-11 18:49:22 +02:00
$page [ 'body' ] .= '<div class="ban"><h2>Delete install.php!</h2><p>I couldn\'t remove <strong>install.php</strong>. You will have to remove it manually.</p></div>' ;
}
echo Element ( 'page.html' , $page );
}