GetAll("SHOW TABLES FROM `$database`;"); foreach ($tablesResults AS $row) $tables[] = $row[0]; return(in_array($tableName, $tables)); } function pgsql_table_exists($database, $tableName) { global $tc_db; $tables = array(); $tablesResults = $tc_db->GetAll(" select table_name from information_schema.tables where table_schema='public' and table_type='BASE TABLE'"); foreach ($tablesResults AS $row) $tables[] = $row[0]; return(in_array($tableName, $tables)); } function sqlite_table_exists($database, $tableName) { global $tc_db; $tables = array(); $tablesResults = $tc_db->GetAll("SELECT name FROM sqlite_master WHERE type = 'table'" ); foreach ($tablesResults AS $row) $tables[] = $row[0]; return(in_array($tableName, $tables)); } function CreateSalt() { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $salt = ''; for ($i = 0; $i < 3; ++$i) { $salt .= $chars[mt_rand(0, strlen($chars) - 1)]; } return $salt; } ?> Kusaba X Installation

Kusaba X Installation

Checking configuration file...'; if (file_exists('config.php')) { require 'config.php'; require KU_ROOTDIR . 'inc/functions.php'; if (KU_RANDOMSEED!="ENTER RANDOM LETTERS/NUMBERS HERE"&&KU_RANDOMSEED!="") { echo 'Configuration appears correct.'; echo '

Checking database...

'; $reqiredtables = array("ads","announcements","banlist","bannedhashes","blotter","boards","board_filetypes","embeds","events","filetypes","front","loginattempts","modlog","module_settings","posts","reports","sections","staff","watchedthreads","wordfilter"); foreach ($reqiredtables as $tablename) { if (KU_DBTYPE == 'mysql' || KU_DBTYPE == 'mysqli') { if (!mysql_table_exists(KU_DBDATABASE,KU_DBPREFIX.$tablename)) { die("Couldn't find the table ".KU_DBPREFIX.$tablename." in the database. Please insert the mySQL dump."); } } if (KU_DBTYPE == 'postgres7' || KU_DBTYPE == 'postgres8' || KU_DBTYPE == 'postgres') { if (!pgsql_table_exists(KU_DBDATABASE,KU_DBPREFIX.$tablename)) { die("Couldn't find the table ".KU_DBPREFIX.$tablename." in the database. Please insert the PostgreSQL dump."); } } if (KU_DBTYPE == 'sqlite') { if (!sqlite_table_exists(KU_DBDATABASE,KU_DBPREFIX.$tablename)) { die("Couldn't find the table ".KU_DBPREFIX.$tablename." in the database. Please insert the SQLite dump."); } } } echo 'Database appears correct.'; echo '

Inserting default administrator account...

'; $result_exists = $tc_db->GetOne("SELECT COUNT(*) FROM `".KU_DBPREFIX."staff` WHERE `username` = 'admin'"); if ($result_exists==0) { $salt = CreateSalt(); $result = $tc_db->Execute("INSERT INTO `".KU_DBPREFIX."staff` ( `username` , `salt`, `password` , `type` , `addedon` ) VALUES ( 'admin' , '".$salt."', '".md5("admin".$salt)."' , '1' , '".time()."' )"); echo 'Account inserted.'; $result = true; } else { echo 'There is already an administrator account inserted.'; $result = true; } if ($result) { require_once KU_ROOTDIR . 'inc/classes/menu.class.php'; $menu_class = new Menu(); $menu_class->Generate(); echo '

Done!

Installation has finished! The default administrator account is admin with the password of admin.

Delete this and the install-mysql.php file from the server, then add some boards!'; echo '


DELETE THIS AND install-mysql.php RIGHT NOW!

'; } else { echo 'Error inserting SQL. Please add $tc_db->debug = true; just before ?> in config.php to turn on debugging, and check the error message.'; } } else { echo 'Please enter a random string into the KU_RANDOMSEED value.'; } } else { echo 'Unable to locate config.php'; } ?>