PageRenderTime 55ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

/install.php

https://github.com/Dratone/EveBB
PHP | 3008 lines | 2674 code | 218 blank | 116 comment | 151 complexity | 5e92b966425aa7114dddb578498bc45b MD5 | raw file
Possible License(s): GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * Copyright (C) 2008-2010 FluxBB
  4. * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
  5. * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
  6. */
  7. // The FluxBB version this script installs
  8. define('FORUM_VERSION', '1.4.5');
  9. define('EVE_BB_VERSION', '1.1.14');
  10. define('FORUM_DB_REVISION', 12);
  11. define('FORUM_SI_REVISION', 2);
  12. define('FORUM_PARSER_REVISION', 2);
  13. define('MIN_PHP_VERSION', '4.4.0');
  14. define('MIN_MYSQL_VERSION', '4.1.2');
  15. define('MIN_PGSQL_VERSION', '7.0.0');
  16. define('PUN_SEARCH_MIN_WORD', 3);
  17. define('PUN_SEARCH_MAX_WORD', 20);
  18. // Define a few commonly used constants
  19. define('PUN_UNVERIFIED', 0);
  20. define('PUN_ADMIN', 1);
  21. define('PUN_MOD', 2);
  22. define('PUN_GUEST', 3);
  23. define('PUN_MEMBER', 4);
  24. //Functions for EvE-BB
  25. define('EVE_ENABLED', 1);
  26. define('PUN_ROOT', dirname(__FILE__).'/');
  27. //Determine if we can/should use cURL where possible.
  28. if (extension_loaded('curl') && $pun_config['o_use_fopen'] != '1') {
  29. define('EVEBB_CURL', 1);
  30. } //End if.
  31. require(PUN_ROOT.'include/request.php');
  32. $pun_request = new Request();
  33. // If we've been passed a default language, use it
  34. $install_lang = isset($_REQUEST['install_lang']) ? trim($_REQUEST['install_lang']) : 'English';
  35. // If such a language pack doesn't exist, or isn't up-to-date enough to translate this page, default to English
  36. if (!file_exists(PUN_ROOT.'lang/'.$install_lang.'/install.php'))
  37. $install_lang = 'English';
  38. require PUN_ROOT.'lang/'.$install_lang.'/install.php';
  39. if (file_exists(PUN_ROOT.'config.php'))
  40. {
  41. // Check to see whether FluxBB is already installed
  42. include PUN_ROOT.'config.php';
  43. // If we have the 1.3-legacy constant defined, define the proper 1.4 constant so we don't get an incorrect "need to install" message
  44. if (defined('FORUM'))
  45. define('PUN', FORUM);
  46. // If PUN is defined, config.php is probably valid and thus the software is installed
  47. if (defined('PUN'))
  48. exit($lang_install['Already installed']);
  49. }
  50. // Define PUN because email.php requires it
  51. define('PUN', 1);
  52. // If the cache directory is not specified, we use the default setting
  53. if (!defined('FORUM_CACHE_DIR'))
  54. define('FORUM_CACHE_DIR', PUN_ROOT.'cache/');
  55. // Make sure we are running at least MIN_PHP_VERSION
  56. if (!function_exists('version_compare') || version_compare(PHP_VERSION, MIN_PHP_VERSION, '<'))
  57. exit(sprintf($lang_install['You are running error'], 'PHP', PHP_VERSION, FORUM_VERSION, MIN_PHP_VERSION));
  58. // Load the functions script
  59. require PUN_ROOT.'include/functions.php';
  60. // Load the eve functions script
  61. require PUN_ROOT.'include/eve_functions.php';
  62. // Load UTF-8 functions
  63. require PUN_ROOT.'include/utf8/utf8.php';
  64. // Strip out "bad" UTF-8 characters
  65. forum_remove_bad_characters();
  66. // Reverse the effect of register_globals
  67. forum_unregister_globals();
  68. // Disable error reporting for uninitialized variables
  69. error_reporting(E_ALL);
  70. // Force POSIX locale (to prevent functions such as strtolower() from messing up UTF-8 strings)
  71. setlocale(LC_CTYPE, 'C');
  72. // Turn off magic_quotes_runtime
  73. if (get_magic_quotes_runtime())
  74. set_magic_quotes_runtime(0);
  75. // Strip slashes from GET/POST/COOKIE (if magic_quotes_gpc is enabled)
  76. if (get_magic_quotes_gpc())
  77. {
  78. function stripslashes_array($array)
  79. {
  80. return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array);
  81. }
  82. $_GET = stripslashes_array($_GET);
  83. $_POST = stripslashes_array($_POST);
  84. $_COOKIE = stripslashes_array($_COOKIE);
  85. $_REQUEST = stripslashes_array($_REQUEST);
  86. }
  87. // Turn off PHP time limit
  88. @set_time_limit(0);
  89. //Make sure we have full scope for character data.
  90. $char_sheet;
  91. //
  92. // Generate output to be used for config.php
  93. //
  94. function generate_config_file()
  95. {
  96. global $db_type, $db_host, $db_name, $db_username, $db_password, $db_prefix, $cookie_name, $cookie_seed;
  97. return '<?php'."\n\n".'$db_type = \''.$db_type."';\n".'$db_host = \''.$db_host."';\n".'$db_name = \''.addslashes($db_name)."';\n".'$db_username = \''.addslashes($db_username)."';\n".'$db_password = \''.addslashes($db_password)."';\n".'$db_prefix = \''.addslashes($db_prefix)."';\n".'$p_connect = false;'."\n\n".'$cookie_name = '."'".$cookie_name."';\n".'$cookie_domain = '."'';\n".'$cookie_path = '."'/';\n".'$cookie_secure = 0;'."\n".'$cookie_seed = \''.random_key(16, false, true)."';\n\ndefine('PUN', 1);\n";
  98. }
  99. if (isset($_POST['generate_config']))
  100. {
  101. header('Content-Type: text/x-delimtext; name="config.php"');
  102. header('Content-disposition: attachment; filename=config.php');
  103. $db_type = $_POST['db_type'];
  104. $db_host = $_POST['db_host'];
  105. $db_name = $_POST['db_name'];
  106. $db_username = $_POST['db_username'];
  107. $db_password = $_POST['db_password'];
  108. $db_prefix = $_POST['db_prefix'];
  109. $cookie_name = $_POST['cookie_name'];
  110. $cookie_seed = $_POST['cookie_seed'];
  111. echo generate_config_file();
  112. exit;
  113. }
  114. if (!isset($_POST['form_sent']))
  115. {
  116. // Make an educated guess regarding base_url
  117. $base_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://'; // protocol
  118. $base_url .= preg_replace('/:(80|443)$/', '', $_SERVER['HTTP_HOST']); // host[:port]
  119. $base_url .= str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])); // path
  120. if (substr($base_url, -1) == '/')
  121. $base_url = substr($base_url, 0, -1);
  122. $db_type = $db_name = $db_username = $db_prefix = $username = $email = '';
  123. $db_prefix = 'evebb_';
  124. $api_user_id = $api_character_id = $api_key = '';
  125. $db_host = 'localhost';
  126. $title = $lang_install['My FluxBB Forum'];
  127. $description = '<p><span>'.$lang_install['Description'].'</span></p>';
  128. $default_lang = $install_lang;
  129. $default_style = 'evebbgray';
  130. }
  131. else
  132. {
  133. $db_type = $_POST['req_db_type'];
  134. $db_host = pun_trim($_POST['req_db_host']);
  135. $db_name = pun_trim($_POST['req_db_name']);
  136. $db_username = pun_trim($_POST['db_username']);
  137. $db_password = pun_trim($_POST['db_password']);
  138. $db_prefix = pun_trim($_POST['db_prefix']);
  139. //$username = pun_trim($_POST['req_username']);
  140. $email = strtolower(pun_trim($_POST['req_email']));
  141. $api_user_id = $_POST['api_user_id'];
  142. $api_character_id = $_POST['api_character_id'];
  143. $api_key = $_POST['api_key'];
  144. $password1 = pun_trim($_POST['req_password1']);
  145. $password2 = pun_trim($_POST['req_password2']);
  146. $title = pun_trim($_POST['req_title']);
  147. $description = pun_trim($_POST['desc']);
  148. $base_url = pun_trim($_POST['req_base_url']);
  149. $default_lang = pun_trim($_POST['req_default_lang']);
  150. $default_style = pun_trim($_POST['req_default_style']);
  151. $alerts = array();
  152. // Make sure base_url doesn't end with a slash
  153. if (substr($base_url, -1) == '/')
  154. $base_url = substr($base_url, 0, -1);
  155. /*---------- EVE-BB DATA CHECKS ---------*/
  156. //return;
  157. if (strlen($api_key) > 64 && strlen($api_key) < 20) {
  158. $alerts[] = 'Incorrect API Verification Code Lengt. Found '.strlen($api_key).', but expected between 20 and 64 inclusive.';
  159. } //End if.
  160. if (!is_numeric($api_user_id)) {
  161. $alerts[] = 'Incorrect API Key ID format.';
  162. } //End if.
  163. if (!is_numeric($api_character_id)) {
  164. $alerts[] = 'Incorrect API Character ID format.<br/> Please make sure you fetch your characters and select an active character from the list.';
  165. } //End if.
  166. /*---------- EVE-BB DATA CHECKS ---------*/
  167. if (pun_strlen($password1) < 4)
  168. $alerts[] = $lang_install['Short password'];
  169. else if ($password1 != $password2)
  170. $alerts[] = $lang_install['Passwords not match'];
  171. // Validate email
  172. require PUN_ROOT.'include/email.php';
  173. if (!is_valid_email($email))
  174. $alerts[] = $lang_install['Wrong email'];
  175. if ($title == '')
  176. $alerts[] = $lang_install['No board title'];
  177. $languages = forum_list_langs();
  178. if (!in_array($default_lang, $languages))
  179. $alerts[] = $lang_install['Error default language'];
  180. $styles = forum_list_styles();
  181. if (!in_array($default_style, $styles))
  182. $alerts[] = $lang_install['Error default style'];
  183. // Check if the cache directory is writable
  184. if (!@is_writable(FORUM_CACHE_DIR))
  185. $alerts[] = sprintf($lang_install['Alert cache'], FORUM_CACHE_DIR);
  186. // Check if default avatar directory is writable
  187. if (!@is_writable(PUN_ROOT.'img/avatars/'))
  188. $alerts[] = sprintf($lang_install['Alert avatar'], PUN_ROOT.'img/avatars/');
  189. /*---------- EVE-BB DATA CHECKS ---------*/
  190. //Now we get the character data.
  191. if (empty($alerts)) {
  192. //We need the escape feature of the DB, so it's been promoted!
  193. // Load the appropriate DB layer class
  194. // Validate prefix
  195. if (strlen($db_prefix) > 0 && (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $db_prefix) || strlen($db_prefix) > 40))
  196. error(sprintf($lang_install['Table prefix error'], $db->prefix));
  197. // Load the appropriate DB layer class
  198. switch ($db_type)
  199. {
  200. case 'mysql':
  201. require PUN_ROOT.'include/dblayer/mysql.php';
  202. break;
  203. case 'mysql_innodb':
  204. require PUN_ROOT.'include/dblayer/mysql_innodb.php';
  205. break;
  206. case 'mysqli':
  207. require PUN_ROOT.'include/dblayer/mysqli.php';
  208. break;
  209. case 'mysqli_innodb':
  210. require PUN_ROOT.'include/dblayer/mysqli_innodb.php';
  211. break;
  212. case 'pgsql':
  213. require PUN_ROOT.'include/dblayer/pgsql.php';
  214. break;
  215. case 'sqlite':
  216. require PUN_ROOT.'include/dblayer/sqlite.php';
  217. break;
  218. default:
  219. error(sprintf($lang_install['DB type not valid'], pun_htmlspecialchars($db_type)));
  220. }
  221. // Create the database object (and connect/select db)
  222. $db = new DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, false);
  223. $username = 'EveBB-User';
  224. // Do some DB type specific checks
  225. switch ($db_type)
  226. {
  227. case 'mysql':
  228. case 'mysqli':
  229. case 'mysql_innodb':
  230. case 'mysqli_innodb':
  231. $mysql_info = $db->get_version();
  232. if (version_compare($mysql_info['version'], MIN_MYSQL_VERSION, '<'))
  233. error(sprintf($lang_install['You are running error'], 'MySQL', $mysql_info['version'], FORUM_VERSION, MIN_MYSQL_VERSION));
  234. break;
  235. case 'pgsql':
  236. $pgsql_info = $db->get_version();
  237. if (version_compare($pgsql_info['version'], MIN_PGSQL_VERSION, '<'))
  238. error(sprintf($lang_install['You are running error'], 'PostgreSQL', $pgsql_info['version'], FORUM_VERSION, MIN_PGSQL_VERSION));
  239. break;
  240. case 'sqlite':
  241. if (strtolower($db_prefix) == 'sqlite_')
  242. error($lang_install['Prefix reserved']);
  243. break;
  244. default:
  245. error(sprintf($lang_install['DB type not valid'], pun_htmlspecialchars($db_type)));
  246. }
  247. //Lets validate the API info first.
  248. $cak = new CAK($api_user_id, $api_key, $api_character_id);
  249. if (($cak_err = $cak->validate(true)) != CAK_OK) {
  250. switch ($cak_err) {
  251. case(CAK_NOT_INIT):
  252. $alerts[] = "[$cak_err]: An internal error has occured while dealing with the API information. Well damn.";
  253. break;
  254. case(CAK_VCODE_LEN):
  255. $alerts[] = "[$cak_err]: Your API Verification Code does not meet security requirements.<br/> Please generate a vcode between 20 and 64 characters in length.";
  256. break;
  257. case(CAK_ID_NOT_NUM):
  258. $alerts[] = "[$cak_err]: Your API Key ID is not a valid ID.";
  259. break;
  260. case(CAK_BAD_VCODE):
  261. $alerts[] = "[$cak_err]: Your API Verification Code is not valid.";
  262. break;
  263. } //End switch().
  264. } else if (($cak_err = $cak->validate_mask()) != CAK_OK) {
  265. switch ($cak_err) {
  266. case(CAK_BAD_FETCH):
  267. $alerts[] = "[$cak_err]: Unable to fetch information from the API server. Please ensure the API server is currently operational.";
  268. break;
  269. case(CAK_BAD_KEY):
  270. $alerts[] = "[$cak_err]: Your API Detials are not correct, please ensure they are correct and try again.";
  271. break;
  272. case(CAK_BAD_MASK):
  273. $alerts[] = "[$cak_err]: Unable to locate a non-zero access mask for your CAK.";
  274. break;
  275. case(CAK_EXPIRE_SET):
  276. $alerts[] = "[$cak_err]: Your CAK is set to expire; EveBB does not support this option. (By choice)";
  277. break;
  278. case(CAK_BAD_TYPE):
  279. $alerts[] = "[$cak_err]: Your CAK type is not allowed by the administrators of this forum. If you are using character based CAK's, please try account based instead.";
  280. break;
  281. } //End switch().
  282. } //End if - else if.
  283. // Create the database object (and connect/select db)
  284. $db = new DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, false);
  285. if (empty($alerts)){
  286. if (!$char_sheet = fetch_character_api($cak)) {
  287. $alerts[] = "Unable to fetch character API information. Please insure that the API server is functioning.";
  288. } else {
  289. $username = substr(strip_special($char_sheet->name), 0, 25);
  290. } //End if - else.
  291. } //End if.
  292. } //End if.
  293. /*---------- EVE-BB DATA CHECKS ---------*/
  294. // Validate username and passwords
  295. if (pun_strlen($username) < 2)
  296. $alerts[] = $lang_install['Username 1'];
  297. else if (pun_strlen($username) > 25) // This usually doesn't happen since the form element only accepts 25 characters
  298. $alerts[] = $lang_install['Username 2'];
  299. else if (!strcasecmp($username, 'Guest'))
  300. $alerts[] = $lang_install['Username 3'];
  301. else if (preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $username) || preg_match('/((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))/', $username))
  302. $alerts[] = $lang_install['Username 4'];
  303. else if ((strpos($username, '[') !== false || strpos($username, ']') !== false) && strpos($username, '\'') !== false && strpos($username, '"') !== false)
  304. $alerts[] = $lang_install['Username 5'];
  305. else if (preg_match('/(?:\[\/?(?:b|u|i|h|colou?r|quote|code|img|url|email|list)\]|\[(?:code|quote|list)=)/i', $username))
  306. $alerts[] = $lang_install['Username 6'];
  307. }
  308. if (!isset($_POST['form_sent']) || !empty($alerts))
  309. {
  310. // Determine available database extensions
  311. $dual_mysql = false;
  312. $db_extensions = array();
  313. $mysql_innodb = false;
  314. if (function_exists('mysqli_connect'))
  315. {
  316. $db_extensions[] = array('mysqli', 'MySQL Improved');
  317. $db_extensions[] = array('mysqli_innodb', 'MySQL Improved (InnoDB)');
  318. $mysql_innodb = true;
  319. }
  320. if (function_exists('mysql_connect'))
  321. {
  322. $db_extensions[] = array('mysql', 'MySQL Standard');
  323. $db_extensions[] = array('mysql_innodb', 'MySQL Standard (InnoDB)');
  324. $mysql_innodb = true;
  325. if (count($db_extensions) > 2)
  326. $dual_mysql = true;
  327. }
  328. if (function_exists('sqlite_open'))
  329. $db_extensions[] = array('sqlite', 'SQLite');
  330. if (function_exists('pg_connect'))
  331. $db_extensions[] = array('pgsql', 'PostgreSQL');
  332. if (empty($db_extensions))
  333. error($lang_install['No DB extensions']);
  334. // Fetch a list of installed languages
  335. $languages = forum_list_langs();
  336. ?>
  337. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  338. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
  339. <head>
  340. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  341. <title><?php echo $lang_install['FluxBB Installation'] ?></title>
  342. <link rel="stylesheet" type="text/css" href="style/<?php echo $default_style ?>.css" />
  343. <script type="text/javascript" src="apiFetching.js"></script>
  344. <script type="text/javascript">
  345. /* <![CDATA[ */
  346. function process_form(the_form)
  347. {
  348. var element_names = {
  349. "req_db_type": "<?php echo $lang_install['Database type'] ?>",
  350. "req_db_host": "<?php echo $lang_install['Database server hostname'] ?>",
  351. "req_db_name": "<?php echo $lang_install['Database name'] ?>",
  352. "db_prefix": "<?php echo $lang_install['Table prefix'] ?>",
  353. "req_password1": "<?php echo $lang_install['Administrator password 1'] ?>",
  354. "req_password2": "<?php echo $lang_install['Administrator password 2'] ?>",
  355. "req_email": "<?php echo $lang_install['Administrator email'] ?>",
  356. "req_title": "<?php echo $lang_install['Board title'] ?>",
  357. "req_base_url": "<?php echo $lang_install['Base URL'] ?>"
  358. };
  359. if (document.all || document.getElementById)
  360. {
  361. for (var i = 0; i < the_form.length; ++i)
  362. {
  363. var elem = the_form.elements[i];
  364. if (elem.name && (/^req_/.test(elem.name)))
  365. {
  366. if (!elem.value && elem.type && (/^(?:text(?:area)?|password|file)$/i.test(elem.type)))
  367. {
  368. alert('"' + element_names[elem.name] + '" <?php echo $lang_install['Required field'] ?>');
  369. elem.focus();
  370. return false;
  371. }
  372. }
  373. }
  374. }
  375. return true;
  376. }
  377. /* ]]> */
  378. </script>
  379. </head>
  380. <body onload="document.getElementById('install').req_db_type.focus();document.getElementById('install').start.disabled=false;">
  381. <div id="puninstall" class="pun">
  382. <div class="top-box"><div><!-- Top Corners --></div></div>
  383. <div class="punwrap">
  384. <div id="brdheader" class="block">
  385. <div class="box">
  386. <div id="brdtitle" class="inbox">
  387. <h1><span><?php echo $lang_install['FluxBB Installation'] ?></span></h1>
  388. <div id="brddesc"><p><?php echo $lang_install['Install message'] ?></p><p><?php echo $lang_install['Welcome'] ?></p></div>
  389. </div>
  390. </div>
  391. </div>
  392. <div id="brdmain">
  393. <?php if (count($languages) > 1): ?><div class="blockform">
  394. <h2><span><?php echo $lang_install['Choose install language'] ?></span></h2>
  395. <div class="box">
  396. <form id="install" method="post" action="install.php">
  397. <div class="inform">
  398. <fieldset>
  399. <legend><?php echo $lang_install['Install language'] ?></legend>
  400. <div class="infldset">
  401. <p><?php echo $lang_install['Choose install language info'] ?></p>
  402. <label><strong><?php echo $lang_install['Install language'] ?></strong>
  403. <br /><select name="install_lang">
  404. <?php
  405. foreach ($languages as $temp)
  406. {
  407. if ($temp == $install_lang)
  408. echo "\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.$temp.'</option>'."\n";
  409. else
  410. echo "\t\t\t\t\t".'<option value="'.$temp.'">'.$temp.'</option>'."\n";
  411. }
  412. ?>
  413. </select>
  414. <br /></label>
  415. </div>
  416. </fieldset>
  417. </div>
  418. <p class="buttons"><input type="submit" name="start" value="<?php echo $lang_install['Change language'] ?>" /></p>
  419. </form>
  420. </div>
  421. </div>
  422. <?php endif; ?>
  423. <div class="blockform">
  424. <h2><span><?php echo sprintf($lang_install['Install'], EVE_BB_VERSION) ?></span></h2>
  425. <div class="box">
  426. <form id="install" method="post" action="install.php" onsubmit="this.start.disabled=true;if(process_form(this)){return true;}else{this.start.disabled=false;return false;}">
  427. <div><input type="hidden" name="form_sent" value="1" /><input type="hidden" name="install_lang" value="<?php echo pun_htmlspecialchars($install_lang) ?>" /></div>
  428. <div class="inform">
  429. <?php if (!empty($alerts)): ?> <div class="forminfo error-info">
  430. <h3><?php echo $lang_install['Errors'] ?></h3>
  431. <ul class="error-list">
  432. <?php
  433. foreach ($alerts as $cur_alert)
  434. echo "\t\t\t\t\t\t".'<li><strong>'.$cur_alert.'</strong></li>'."\n";
  435. ?>
  436. </ul>
  437. </div>
  438. <?php endif; ?> </div>
  439. <div class="inform">
  440. <div class="forminfo">
  441. <h3><?php echo $lang_install['Database setup'] ?></h3>
  442. <p><?php echo $lang_install['Info 1'] ?></p>
  443. </div>
  444. <fieldset>
  445. <legend><?php echo $lang_install['Select database'] ?></legend>
  446. <div class="infldset">
  447. <p><?php echo $lang_install['Info 2'] ?></p>
  448. <?php if ($dual_mysql): ?> <p><?php echo $lang_install['Dual MySQL'] ?></p>
  449. <?php endif; ?><?php if ($mysql_innodb): ?> <p><?php echo $lang_install['InnoDB'] ?></p>
  450. <?php endif; ?> <label class="required"><strong><?php echo $lang_install['Database type'] ?> <span><?php echo $lang_install['Required'] ?></span></strong>
  451. <br /><select name="req_db_type">
  452. <?php
  453. foreach ($db_extensions as $temp)
  454. {
  455. if ($temp[0] == $db_type)
  456. echo "\t\t\t\t\t\t\t".'<option value="'.$temp[0].'" selected="selected">'.$temp[1].'</option>'."\n";
  457. else
  458. echo "\t\t\t\t\t\t\t".'<option value="'.$temp[0].'">'.$temp[1].'</option>'."\n";
  459. }
  460. ?>
  461. </select>
  462. <br /></label>
  463. </div>
  464. </fieldset>
  465. </div>
  466. <div class="inform">
  467. <fieldset>
  468. <legend><?php echo $lang_install['Database hostname'] ?></legend>
  469. <div class="infldset">
  470. <p><?php echo $lang_install['Info 3'] ?></p>
  471. <label class="required"><strong><?php echo $lang_install['Database server hostname'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input type="text" name="req_db_host" value="<?php echo pun_htmlspecialchars($db_host) ?>" size="50" /><br /></label>
  472. </div>
  473. </fieldset>
  474. </div>
  475. <div class="inform">
  476. <fieldset>
  477. <legend><?php echo $lang_install['Database enter name'] ?></legend>
  478. <div class="infldset">
  479. <p><?php echo $lang_install['Info 4'] ?></p>
  480. <label class="required"><strong><?php echo $lang_install['Database name'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input id="req_db_name" type="text" name="req_db_name" value="<?php echo pun_htmlspecialchars($db_name) ?>" size="30" /><br /></label>
  481. </div>
  482. </fieldset>
  483. </div>
  484. <div class="inform">
  485. <fieldset>
  486. <legend><?php echo $lang_install['Database enter informations'] ?></legend>
  487. <div class="infldset">
  488. <p><?php echo $lang_install['Info 5'] ?></p>
  489. <label class="conl"><?php echo $lang_install['Database username'] ?><br /><input type="text" name="db_username" value="<?php echo pun_htmlspecialchars($db_username) ?>" size="30" /><br /></label>
  490. <label class="conl"><?php echo $lang_install['Database password'] ?><br /><input type="password" name="db_password" size="30" /><br /></label>
  491. <div class="clearer"></div>
  492. </div>
  493. </fieldset>
  494. </div>
  495. <div class="inform">
  496. <fieldset>
  497. <legend><?php echo $lang_install['Database enter prefix'] ?></legend>
  498. <div class="infldset">
  499. <p><?php echo $lang_install['Info 6'] ?></p>
  500. <label><?php echo $lang_install['Table prefix'] ?><br /><input id="db_prefix" type="text" name="db_prefix" value="<?php echo pun_htmlspecialchars($db_prefix) ?>" size="20" maxlength="30" /><br /></label>
  501. </div>
  502. </fieldset>
  503. </div>
  504. <?php
  505. /* We're keeping this here for record. It is being replaced by the characters name.
  506. <div class="inform">
  507. <div class="forminfo">
  508. <h3><?php echo $lang_install['Administration setup'] ?></h3>
  509. <p><?php echo $lang_install['Info 7'] ?></p>
  510. </div>
  511. <fieldset>
  512. <legend><?php echo $lang_install['Admin enter username'] ?></legend>
  513. <div class="infldset">
  514. <p><?php echo $lang_install['Info 8'] ?></p>
  515. <label class="required"><strong><?php echo $lang_install['Administrator username'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input type="text" name="req_username" value="<?php echo pun_htmlspecialchars($username) ?>" size="25" maxlength="25" /><br /></label>
  516. </div>
  517. </fieldset>
  518. </div>
  519. */
  520. ?>
  521. <div class="inform">
  522. <fieldset>
  523. <legend><?php echo $lang_install['Admin enter password'] ?></legend>
  524. <div class="infldset">
  525. <p><?php echo $lang_install['Info 9'] ?></p>
  526. <label class="conl required"><strong><?php echo $lang_install['Password'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input id="req_password1" type="password" name="req_password1" size="16" /><br /></label>
  527. <label class="conl required"><strong><?php echo $lang_install['Confirm password'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input type="password" name="req_password2" size="16" /><br /></label>
  528. <div class="clearer"></div>
  529. </div>
  530. </fieldset>
  531. </div>
  532. <div class="inform">
  533. <fieldset>
  534. <legend><?php echo $lang_install['Admin enter email'] ?></legend>
  535. <div class="infldset">
  536. <p><?php echo $lang_install['Info 10'] ?></p>
  537. <label class="required"><strong><?php echo $lang_install['Administrator email'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input id="req_email" type="text" name="req_email" value="<?php echo pun_htmlspecialchars($email) ?>" size="50" maxlength="80" /><br /></label>
  538. </div>
  539. </fieldset>
  540. </div>
  541. <div class="inform">
  542. <fieldset>
  543. <legend><?php echo $lang_install['Evebb_admin_api_legend'] ?></legend>
  544. <div class="infldset">
  545. <p><?php echo $lang_install['Evebb_admin_api_info1'] ?></p>
  546. <label class="required"><strong><?php echo $lang_install['Evebb_admin_api_id'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input id="api_user_id" type="text" name="api_user_id" value="<?php echo pun_htmlspecialchars($api_user_id) ?>" size="50" maxlength="80" /><br /></label>
  547. <label class="required"><strong><?php echo $lang_install['Evebb_admin_api_key'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input id="api_key" type="text" name="api_key" value="<?php echo pun_htmlspecialchars($api_key) ?>" size="50" maxlength="80" /><br /></label><br/>
  548. <span id="api_holder"><a class="fetch_chars" href="index.php" onclick="fetchCharacters(); return false;"><span id="char_fetch_text"><?php echo $lang_install['Evebb_admin_api_fetch'] ?></span></a></span>
  549. <p><?php echo $lang_install['Evebb_admin_api_info2'] ?></p>
  550. <div class="clearer"></div>
  551. </div>
  552. </fieldset>
  553. </div>
  554. <div class="inform">
  555. <div class="forminfo">
  556. <h3><?php echo $lang_install['Board setup'] ?></h3>
  557. <p><?php echo $lang_install['Info 11'] ?></p>
  558. </div>
  559. <fieldset>
  560. <legend><?php echo $lang_install['Enter board title'] ?></legend>
  561. <div class="infldset">
  562. <p><?php echo $lang_install['Info 12'] ?></p>
  563. <label class="required"><strong><?php echo $lang_install['Board title'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input id="req_title" type="text" name="req_title" value="<?php echo pun_htmlspecialchars($title) ?>" size="60" maxlength="255" /><br /></label>
  564. </div>
  565. </fieldset>
  566. </div>
  567. <div class="inform">
  568. <fieldset>
  569. <legend><?php echo $lang_install['Enter board description'] ?></legend>
  570. <div class="infldset">
  571. <p><?php echo $lang_install['Info 13'] ?></p>
  572. <label><?php echo $lang_install['Board description'] ?><br /><input id="desc" type="text" name="desc" value="<?php echo pun_htmlspecialchars($description) ?>" size="60" maxlength="255" /><br /></label>
  573. </div>
  574. </fieldset>
  575. </div>
  576. <div class="inform">
  577. <fieldset>
  578. <legend><?php echo $lang_install['Enter base URL'] ?></legend>
  579. <div class="infldset">
  580. <p><?php echo $lang_install['Info 14'] ?></p>
  581. <label class="required"><strong><?php echo $lang_install['Base URL'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><input id="req_base_url" type="text" name="req_base_url" value="<?php echo pun_htmlspecialchars($base_url) ?>" size="60" maxlength="100" /><br /></label>
  582. </div>
  583. </fieldset>
  584. </div>
  585. <div class="inform">
  586. <fieldset>
  587. <legend><?php echo $lang_install['Choose the default language'] ?></legend>
  588. <div class="infldset">
  589. <p><?php echo $lang_install['Info 15'] ?></p>
  590. <label class="required"><strong><?php echo $lang_install['Default language'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><select id="req_default_lang" name="req_default_lang">
  591. <?php
  592. $languages = forum_list_langs();
  593. foreach ($languages as $temp)
  594. {
  595. if ($temp == $default_lang)
  596. echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.$temp.'</option>'."\n";
  597. else
  598. echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.$temp.'</option>'."\n";
  599. }
  600. ?>
  601. </select><br /></label>
  602. </div>
  603. </fieldset>
  604. </div>
  605. <div class="inform">
  606. <fieldset>
  607. <legend><?php echo $lang_install['Choose the default style'] ?></legend>
  608. <div class="infldset">
  609. <p><?php echo $lang_install['Info 16'] ?></p>
  610. <label class="required"><strong><?php echo $lang_install['Default style'] ?> <span><?php echo $lang_install['Required'] ?></span></strong><br /><select id="req_default_style" name="req_default_style">
  611. <?php
  612. $styles = forum_list_styles();
  613. foreach ($styles as $temp)
  614. {
  615. if ($temp == $default_style)
  616. echo "\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.str_replace('_', ' ', $temp).'</option>'."\n";
  617. else
  618. echo "\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.str_replace('_', ' ', $temp).'</option>'."\n";
  619. }
  620. ?>
  621. </select><br /></label>
  622. </div>
  623. </fieldset>
  624. </div>
  625. <p class="buttons"><input type="submit" name="start" value="<?php echo $lang_install['Start install'] ?>" /></p>
  626. </form>
  627. </div>
  628. </div>
  629. </div>
  630. </div>
  631. <div class="end-box"><div><!-- Bottom Corners --></div></div>
  632. </div>
  633. </body>
  634. </html>
  635. <?php
  636. }
  637. else
  638. {
  639. //We created the DB earlier, so the checks move to there.
  640. // Make sure FluxBB isn't already installed
  641. $result = $db->query('SELECT 1 FROM '.$db_prefix.'users WHERE id=1');
  642. if ($db->num_rows($result))
  643. error(sprintf($lang_install['Existing table error'], $db_prefix, $db_name));
  644. // Check if InnoDB is available
  645. if ($db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
  646. {
  647. $result = $db->query('SHOW VARIABLES LIKE \'have_innodb\'');
  648. list (, $result) = $db->fetch_row($result);
  649. if ((strtoupper($result) != 'YES'))
  650. error($lang_install['InnoDB off']);
  651. }
  652. // Start a transaction
  653. $db->start_transaction();
  654. // Create all tables
  655. $schema = array(
  656. 'FIELDS' => array(
  657. 'id' => array(
  658. 'datatype' => 'SERIAL',
  659. 'allow_null' => false
  660. ),
  661. 'username' => array(
  662. 'datatype' => 'VARCHAR(200)',
  663. 'allow_null' => true
  664. ),
  665. 'ip' => array(
  666. 'datatype' => 'VARCHAR(255)',
  667. 'allow_null' => true
  668. ),
  669. 'email' => array(
  670. 'datatype' => 'VARCHAR(80)',
  671. 'allow_null' => true
  672. ),
  673. 'message' => array(
  674. 'datatype' => 'VARCHAR(255)',
  675. 'allow_null' => true
  676. ),
  677. 'expire' => array(
  678. 'datatype' => 'INT(10) UNSIGNED',
  679. 'allow_null' => true
  680. ),
  681. 'ban_creator' => array(
  682. 'datatype' => 'INT(10) UNSIGNED',
  683. 'allow_null' => false,
  684. 'default' => '0'
  685. )
  686. ),
  687. 'PRIMARY KEY' => array('id'),
  688. 'INDEXES' => array(
  689. 'username_idx' => array('username')
  690. )
  691. );
  692. if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
  693. $schema['INDEXES']['username_idx'] = array('username(25)');
  694. $db->create_table('bans', $schema) or error('Unable to create bans table', __FILE__, __LINE__, $db->error());
  695. $schema = array(
  696. 'FIELDS' => array(
  697. 'id' => array(
  698. 'datatype' => 'SERIAL',
  699. 'allow_null' => false
  700. ),
  701. 'cat_name' => array(
  702. 'datatype' => 'VARCHAR(80)',
  703. 'allow_null' => false,
  704. 'default' => '\'New Category\''
  705. ),
  706. 'disp_position' => array(
  707. 'datatype' => 'INT(10)',
  708. 'allow_null' => false,
  709. 'default' => '0'
  710. )
  711. ),
  712. 'PRIMARY KEY' => array('id')
  713. );
  714. $db->create_table('categories', $schema) or error('Unable to create categories table', __FILE__, __LINE__, $db->error());
  715. $schema = array(
  716. 'FIELDS' => array(
  717. 'id' => array(
  718. 'datatype' => 'SERIAL',
  719. 'allow_null' => false
  720. ),
  721. 'search_for' => array(
  722. 'datatype' => 'VARCHAR(60)',
  723. 'allow_null' => false,
  724. 'default' => '\'\''
  725. ),
  726. 'replace_with' => array(
  727. 'datatype' => 'VARCHAR(60)',
  728. 'allow_null' => false,
  729. 'default' => '\'\''
  730. )
  731. ),
  732. 'PRIMARY KEY' => array('id')
  733. );
  734. $db->create_table('censoring', $schema) or error('Unable to create censoring table', __FILE__, __LINE__, $db->error());
  735. $schema = array(
  736. 'FIELDS' => array(
  737. 'conf_name' => array(
  738. 'datatype' => 'VARCHAR(255)',
  739. 'allow_null' => false,
  740. 'default' => '\'\''
  741. ),
  742. 'conf_value' => array(
  743. 'datatype' => 'TEXT',
  744. 'allow_null' => true
  745. )
  746. ),
  747. 'PRIMARY KEY' => array('conf_name')
  748. );
  749. $db->create_table('config', $schema) or error('Unable to create config table', __FILE__, __LINE__, $db->error());
  750. $schema = array(
  751. 'FIELDS' => array(
  752. 'group_id' => array(
  753. 'datatype' => 'INT(10)',
  754. 'allow_null' => false,
  755. 'default' => '0'
  756. ),
  757. 'forum_id' => array(
  758. 'datatype' => 'INT(10)',
  759. 'allow_null' => false,
  760. 'default' => '0'
  761. ),
  762. 'read_forum' => array(
  763. 'datatype' => 'TINYINT(1)',
  764. 'allow_null' => false,
  765. 'default' => '1'
  766. ),
  767. 'post_replies' => array(
  768. 'datatype' => 'TINYINT(1)',
  769. 'allow_null' => false,
  770. 'default' => '1'
  771. ),
  772. 'post_topics' => array(
  773. 'datatype' => 'TINYINT(1)',
  774. 'allow_null' => false,
  775. 'default' => '1'
  776. )
  777. ),
  778. 'PRIMARY KEY' => array('group_id', 'forum_id')
  779. );
  780. $db->create_table('forum_perms', $schema) or error('Unable to create forum_perms table', __FILE__, __LINE__, $db->error());
  781. $schema = array(
  782. 'FIELDS' => array(
  783. 'id' => array(
  784. 'datatype' => 'SERIAL',
  785. 'allow_null' => false
  786. ),
  787. 'forum_name' => array(
  788. 'datatype' => 'VARCHAR(80)',
  789. 'allow_null' => false,
  790. 'default' => '\'New forum\''
  791. ),
  792. 'forum_desc' => array(
  793. 'datatype' => 'TEXT',
  794. 'allow_null' => true
  795. ),
  796. 'redirect_url' => array(
  797. 'datatype' => 'VARCHAR(100)',
  798. 'allow_null' => true
  799. ),
  800. 'moderators' => array(
  801. 'datatype' => 'TEXT',
  802. 'allow_null' => true
  803. ),
  804. 'num_topics' => array(
  805. 'datatype' => 'MEDIUMINT(8) UNSIGNED',
  806. 'allow_null' => false,
  807. 'default' => '0'
  808. ),
  809. 'num_posts' => array(
  810. 'datatype' => 'MEDIUMINT(8) UNSIGNED',
  811. 'allow_null' => false,
  812. 'default' => '0'
  813. ),
  814. 'last_post' => array(
  815. 'datatype' => 'INT(10) UNSIGNED',
  816. 'allow_null' => true
  817. ),
  818. 'last_post_id' => array(
  819. 'datatype' => 'INT(10) UNSIGNED',
  820. 'allow_null' => true
  821. ),
  822. 'last_poster' => array(
  823. 'datatype' => 'VARCHAR(200)',
  824. 'allow_null' => true
  825. ),
  826. 'sort_by' => array(
  827. 'datatype' => 'TINYINT(1)',
  828. 'allow_null' => false,
  829. 'default' => '0'
  830. ),
  831. 'disp_position' => array(
  832. 'datatype' => 'INT(10)',
  833. 'allow_null' => false,
  834. 'default' => '0'
  835. ),
  836. 'cat_id' => array(
  837. 'datatype' => 'INT(10) UNSIGNED',
  838. 'allow_null' => false,
  839. 'default' => '0'
  840. )
  841. ),
  842. 'PRIMARY KEY' => array('id')
  843. );
  844. $db->create_table('forums', $schema) or error('Unable to create forums table', __FILE__, __LINE__, $db->error());
  845. $schema = array(
  846. 'FIELDS' => array(
  847. 'g_id' => array(
  848. 'datatype' => 'SERIAL',
  849. 'allow_null' => false
  850. ),
  851. 'g_title' => array(
  852. 'datatype' => 'VARCHAR(50)',
  853. 'allow_null' => false,
  854. 'default' => '\'\''
  855. ),
  856. 'g_user_title' => array(
  857. 'datatype' => 'VARCHAR(50)',
  858. 'allow_null' => true
  859. ),
  860. 'g_moderator' => array(
  861. 'datatype' => 'TINYINT(1)',
  862. 'allow_null' => false,
  863. 'default' => '0'
  864. ),
  865. 'g_mod_edit_users' => array(
  866. 'datatype' => 'TINYINT(1)',
  867. 'allow_null' => false,
  868. 'default' => '0'
  869. ),
  870. 'g_mod_rename_users' => array(
  871. 'datatype' => 'TINYINT(1)',
  872. 'allow_null' => false,
  873. 'default' => '0'
  874. ),
  875. 'g_mod_change_passwords' => array(
  876. 'datatype' => 'TINYINT(1)',
  877. 'allow_null' => false,
  878. 'default' => '0'
  879. ),
  880. 'g_mod_ban_users' => array(
  881. 'datatype' => 'TINYINT(1)',
  882. 'allow_null' => false,
  883. 'default' => '0'
  884. ),
  885. 'g_read_board' => array(
  886. 'datatype' => 'TINYINT(1)',
  887. 'allow_null' => false,
  888. 'default' => '1'
  889. ),
  890. 'g_view_users' => array(
  891. 'datatype' => 'TINYINT(1)',
  892. 'allow_null' => false,
  893. 'default' => '1'
  894. ),
  895. 'g_post_replies' => array(
  896. 'datatype' => 'TINYINT(1)',
  897. 'allow_null' => false,
  898. 'default' => '1'
  899. ),
  900. 'g_post_topics' => array(
  901. 'datatype' => 'TINYINT(1)',
  902. 'allow_null' => false,
  903. 'default' => '1'
  904. ),
  905. 'g_edit_posts' => array(
  906. 'datatype' => 'TINYINT(1)',
  907. 'allow_null' => false,
  908. 'default' => '1'
  909. ),
  910. 'g_delete_posts' => array(
  911. 'datatype' => 'TINYINT(1)',
  912. 'allow_null' => false,
  913. 'default' => '1'
  914. ),
  915. 'g_delete_topics' => array(
  916. 'datatype' => 'TINYINT(1)',
  917. 'allow_null' => false,
  918. 'default' => '1'
  919. ),
  920. 'g_set_title' => array(
  921. 'datatype' => 'TINYINT(1)',
  922. 'allow_null' => false,
  923. 'default' => '1'
  924. ),
  925. 'g_search' => array(
  926. 'datatype' => 'TINYINT(1)',
  927. 'allow_null' => false,
  928. 'default' => '1'
  929. ),
  930. 'g_search_users' => array(
  931. 'datatype' => 'TINYINT(1)',
  932. 'allow_null' => false,
  933. 'default' => '1'
  934. ),
  935. 'g_send_email' => array(
  936. 'datatype' => 'TINYINT(1)',
  937. 'allow_null' => false,
  938. 'default' => '1'
  939. ),
  940. 'g_post_flood' => array(
  941. 'datatype' => 'SMALLINT(6)',
  942. 'allow_null' => false,
  943. 'default' => '30'
  944. ),
  945. 'g_search_flood' => array(
  946. 'datatype' => 'SMALLINT(6)',
  947. 'allow_null' => false,
  948. 'default' => '30'
  949. ),
  950. 'g_email_flood' => array(
  951. 'datatype' => 'SMALLINT(6)',
  952. 'allow_null' => false,
  953. 'default' => '60'
  954. ),
  955. 'g_locked' => array(
  956. 'datatype' => 'TINYINT(1)',
  957. 'allow_null' => false,
  958. 'default' => '0'
  959. )
  960. ),
  961. 'PRIMARY KEY' => array('g_id')
  962. );
  963. $db->create_table('groups', $schema) or error('Unable to create groups table', __FILE__, __LINE__, $db->error());
  964. $schema = array(
  965. 'FIELDS' => array(
  966. 'user_id' => array(
  967. 'datatype' => 'INT(10) UNSIGNED',
  968. 'allow_null' => false,
  969. 'default' => '1'
  970. ),
  971. 'ident' => array(
  972. 'datatype' => 'VARCHAR(200)',
  973. 'allow_null' => false,
  974. 'default' => '\'\''
  975. ),
  976. 'logged' => array(
  977. 'datatype' => 'INT(10) UNSIGNED',
  978. 'allow_null' => false,
  979. 'default' => '0'
  980. ),
  981. 'idle' => array(
  982. 'datatype' => 'TINYINT(1)',
  983. 'allow_null' => false,
  984. 'default' => '0'
  985. ),
  986. 'last_post' => array(
  987. 'datatype' => 'INT(10) UNSIGNED',
  988. 'allow_null' => true
  989. ),
  990. 'last_search' => array(
  991. 'datatype' => 'INT(10) UNSIGNED',
  992. 'allow_null' => true
  993. ),
  994. ),
  995. 'UNIQUE KEYS' => array(
  996. 'user_id_ident_idx' => array('user_id', 'ident')
  997. ),
  998. 'INDEXES' => array(
  999. 'ident_idx' => array('ident'),
  1000. 'logged_idx' => array('logged')
  1001. ),
  1002. 'ENGINE' => 'HEAP'
  1003. );
  1004. if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
  1005. {
  1006. $schema['UNIQUE KEYS']['user_id_ident_idx'] = array('user_id', 'ident(25)');
  1007. $schema['INDEXES']['ident_idx'] = array('ident(25)');
  1008. }
  1009. if ($db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
  1010. $schema['ENGINE'] = 'InnoDB';
  1011. $db->create_table('online', $schema) or error('Unable to create online table', __FILE__, __LINE__, $db->error());
  1012. $schema = array(
  1013. 'FIELDS' => array(
  1014. 'id' => array(
  1015. 'datatype' => 'SERIAL',
  1016. 'allow_null' => false
  1017. ),
  1018. 'poster' => array(
  1019. 'datatype' => 'VARCHAR(200)',
  1020. 'allow_null' => false,
  1021. 'default' => '\'\''
  1022. ),
  1023. 'poster_id' => array(
  1024. 'datatype' => 'INT(10) UNSIGNED',
  1025. 'allow_null' => false,
  1026. 'default' => '1'
  1027. ),
  1028. 'poster_ip' => array(
  1029. 'datatype' => 'VARCHAR(39)',
  1030. 'allow_null' => true
  1031. ),
  1032. 'poster_email' => array(
  1033. 'datatype' => 'VARCHAR(80)',
  1034. 'allow_null' => true
  1035. ),
  1036. 'message' => array(
  1037. 'datatype' => 'MEDIUMTEXT',
  1038. 'allow_null' => true
  1039. ),
  1040. 'hide_smilies' => array(
  1041. 'datatype' => 'TINYINT(1)',
  1042. 'allow_null' => false,
  1043. 'default' => '0'
  1044. ),
  1045. 'posted' => array(
  1046. 'datatype' => 'INT(10) UNSIGNED',
  1047. 'allow_null' => false,
  1048. 'default' => '0'
  1049. ),
  1050. 'edited' => array(
  1051. 'datatype' => 'INT(10) UNSIGNED',
  1052. 'allow_null' => true
  1053. ),
  1054. 'edited_by' => array(
  1055. 'datatype' => 'VARCHAR(200)',
  1056. 'allow_null' => true
  1057. ),
  1058. 'topic_id' => array(
  1059. 'datatype' => 'INT(10) UNSIGNED',
  1060. 'allow_null' => false,
  1061. 'default' => '0'
  1062. )
  1063. ),
  1064. 'PRIMARY KEY' => array('id'),
  1065. 'INDEXES' => array(
  1066. 'topic_id_idx' => array('topic_id'),
  1067. 'multi_idx' => array('poster_id', 'topic_id')
  1068. )
  1069. );
  1070. $db->create_table('posts', $schema) or error('Unable to create posts table', __FILE__, __LINE__, $db->error());
  1071. $schema = array(
  1072. 'FIELDS' => array(
  1073. 'id' => array(
  1074. 'datatype' => 'SERIAL',
  1075. 'allow_null' => false
  1076. ),
  1077. 'rank' => array(
  1078. 'datatype' => 'VARCHAR(50)',
  1079. 'allow_null' => false,
  1080. 'default' => '\'\''
  1081. ),
  1082. 'min_posts' => array(
  1083. 'datatype' => 'MEDIUMINT(8) UNSIGNED',
  1084. 'allow_null' => false,
  1085. 'default' => '0'
  1086. )
  1087. ),
  1088. 'PRIMARY KEY' => array('id')
  1089. );
  1090. $db->create_table('ranks', $schema) or error('Unable to create ranks table', __FILE__, __LINE__, $db->error());
  1091. $schema = array(
  1092. 'FIELDS' => array(
  1093. 'id' => array(
  1094. 'datatype' => 'SERIAL',
  1095. 'allow_null' => false
  1096. ),
  1097. 'post_id' => array(
  1098. 'datatype' => 'INT(10) UNSIGNED',
  1099. 'allow_null' => false,
  1100. 'default' => '0'
  1101. ),
  1102. 'topic_id' => array(
  1103. 'datatype' => 'INT(10) UNSIGNED',
  1104. 'allow_null' => false,
  1105. 'default' => '0'
  1106. ),
  1107. 'forum_id' => array(
  1108. 'datatype' => 'INT(10) UNSIGNED',
  1109. 'allow_null' => false,
  1110. 'default' => '0'
  1111. ),
  1112. 'reported_by' => array(
  1113. 'datatype' => 'INT(10) UNSIGNED',
  1114. 'allow_null' => false,
  1115. 'default' => '0'
  1116. ),
  1117. 'created' => array(
  1118. 'datatype' => 'INT(10) UNSIGNED',
  1119. 'allow_null' => false,
  1120. 'default' => '0'
  1121. ),
  1122. 'message' => array(
  1123. 'datatype' => 'TEXT',
  1124. 'allow_null' => true
  1125. ),
  1126. 'zapped' => array(
  1127. 'datatype' => 'INT(10) UNSIGNED',
  1128. 'allow_null' => true
  1129. ),
  1130. 'zapped_by' => array(
  1131. 'datatype' => 'INT(10) UNSIGNED',
  1132. 'allow_null' => true
  1133. )
  1134. ),
  1135. 'PRIMARY KEY' => array('id'),
  1136. 'INDEXES' => array(
  1137. 'zapped_idx' => array('zapped')
  1138. )
  1139. );
  1140. $db->create_table('reports', $schema) or error('Unable to create reports table', __FILE__, __LINE__, $db->error());
  1141. $schema = array(
  1142. 'FIELDS' => array(
  1143. 'id' => array(
  1144. 'datatype' => 'INT(10) UNSIGNED',
  1145. 'allow_null' => false,
  1146. 'default' => '0'
  1147. ),
  1148. 'ident' => array(
  1149. 'datatype' => 'VARCHAR(200)',
  1150. 'allow_null' => false,
  1151. 'default' => '\'\''
  1152. ),
  1153. 'search_data' => array(
  1154. 'datatype' => 'MEDIUMTEXT',
  1155. 'allow_null' => true
  1156. )
  1157. ),
  1158. 'PRIMARY KEY' => array('id'),
  1159. 'INDEXES' => array(
  1160. 'ident_idx' => array('ident')
  1161. )
  1162. );
  1163. if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
  1164. $schema['INDEXES']['ident_idx'] = array('ident(8)');
  1165. $db->create_table('search_cache', $schema) or error('Unable to create search_cache table', __FILE__, __LINE__, $db->error());
  1166. $schema = array(
  1167. 'FIELDS' => array(
  1168. 'post_id' => array(
  1169. 'datatype' => 'INT(10) UNSIGNED',
  1170. 'allow_null' => false,
  1171. 'default' => '0'
  1172. ),
  1173. 'word_id' => array(
  1174. 'datatype' => 'INT(10) UNSIGNED',
  1175. 'allow_null' => false,
  1176. 'default' => '0'
  1177. ),
  1178. 'subject_match' => array(
  1179. 'datatype' => 'TINYINT(1)',
  1180. 'allow_null' => false,
  1181. 'default' => '0'
  1182. )
  1183. ),
  1184. 'INDEXES' => array(
  1185. 'word_id_idx' => array('word_id'),
  1186. 'post_id_idx' => array('post_id')
  1187. )
  1188. );
  1189. $db->create_table('search_matches', $schema) or error('Unable to create search_matches table', __FILE__, __LINE__, $db->error());
  1190. $schema = array(
  1191. 'FIELDS' => array(
  1192. 'id' => array(
  1193. 'datatype' => 'SERIAL',
  1194. 'allow_null' => false
  1195. ),
  1196. 'word' => array(
  1197. 'datatype' => 'VARCHAR(20)',
  1198. 'allow_null' => false,
  1199. 'default' => '\'\'',
  1200. 'collation' => 'bin'
  1201. )
  1202. ),
  1203. 'PRIMARY KEY' => array('word'),
  1204. 'INDEXES' => array(
  1205. 'id_idx' => array('id')
  1206. )
  1207. );
  1208. if ($db_type == 'sqlite')
  1209. {
  1210. $schema['PRIMARY KEY'] = array('id');
  1211. $schema['UNIQUE KEYS'] = array('word_idx' => array('word'));
  1212. }
  1213. $db->create_table('search_words', $schema) or error('Unable to create search_words table', __FILE__, __LINE__, $db->error());
  1214. $schema = array(
  1215. 'FIELDS' => array(
  1216. 'user_id' => array(
  1217. 'datatype' => 'INT(10) UNSIGNED',
  1218. 'allow_null' => false,
  1219. 'default' => '0'
  1220. ),
  1221. 'topic_id' => array(
  1222. 'datatype' => 'INT(10) UNSIGNED',
  1223. 'allow_null' => false,
  1224. 'default' => '0'
  1225. )
  1226. ),
  1227. 'PRIMARY KEY' => array('user_id', 'topic_id')
  1228. );
  1229. $db->create_table('topic_subscriptions', $schema) or error('Unable to create topic subscriptions table', __FILE__, __LINE__, $db->error());
  1230. $schema = array(
  1231. 'FIELDS' => array(
  1232. 'user_id' => array(
  1233. 'datatype' => 'INT(10) UNSIGNED',
  1234. 'allow_null' => false,
  1235. 'default' => '0'
  1236. ),
  1237. 'forum_id' => array(
  1238. 'datatype' => 'INT(10) UNSIGNED',
  1239. 'allow_null' => false,
  1240. 'default' => '0'
  1241. )
  1242. ),
  1243. 'PRIMARY KEY' => array('user_id', 'forum_id')
  1244. );
  1245. $db->create_table('forum_subscriptions', $schema) or error('Unable to create forum subscriptions table', __FILE__, __LINE__, $db->error());
  1246. $schema = array(
  1247. 'FIELDS' => array(
  1248. 'id' => array(
  1249. 'datatype' => 'SERIAL',
  1250. 'allow_null' => false
  1251. ),
  1252. 'poster' => array(
  1253. 'datatype' => 'VARCHAR(200)',
  1254. 'allow_null' => false,
  1255. 'default' => '\'\''
  1256. ),
  1257. 'subject' => array(
  1258. 'datatype' => 'VARCHAR(255)',
  1259. 'allow_null' => false,
  1260. 'default' => '\'\''
  1261. ),
  1262. 'posted' => array(
  1263. 'datatype' => 'INT(10) UNSIGNED',
  1264. 'allow_null' => false,
  1265. 'default' => '0'
  1266. ),
  1267. 'first_post_id' => array(
  1268. 'datatype' => 'INT(10) UNSIGNED',
  1269. 'allow_null' => false,
  1270. 'default' => '0'
  1271. ),
  1272. 'last_post' => array(
  1273. 'datatype' => 'INT(10) UNSIGNED',
  1274. 'allow_null' => false,
  1275. 'default' => '0'
  1276. ),
  1277. 'last_post_id' => array(
  1278. 'datatype' => 'INT(10) UNSIGNED',
  1279. 'allow_null' => false,
  1280. 'default' => '0'
  1281. ),
  1282. 'last_poster' => array(
  1283. 'datatype' => 'VARCHAR(200)',
  1284. 'allow_null' => true
  1285. ),
  1286. 'num_views' => array(
  1287. 'datatype' => 'MEDIUMINT(8) UNSIGNED',
  1288. 'allow_null' => false,
  1289. 'default' => '0'
  1290. ),
  1291. 'num_replies' => array(
  1292. 'datatype' => 'MEDIUMINT(8) UNSIGNED',
  1293. 'allow_null' => false,
  1294. 'default' => '0'
  1295. ),
  1296. 'closed' => array(
  1297. 'datatype' => 'TINYINT(1)',
  1298. 'allow_null' => false,
  1299. 'default' => '0'
  1300. ),
  1301. 'sticky' => array(
  1302. 'datatype' => 'TINYINT(1)',
  1303. 'allow_null' => false,
  1304. 'default' => '0'
  1305. ),
  1306. 'moved_to' => array(
  1307. 'datatype' => 'INT(10) UNSIGNED',
  1308. 'allow_null' => true
  1309. ),
  1310. 'forum_id' => array(
  1311. 'datatype' => 'INT(10) UNSIGNED',
  1312. 'allow_null' => false,
  1313. 'default' => '0'
  1314. )
  1315. ),
  1316. 'PRIMARY KEY' => array('id'),
  1317. 'INDEXES' => array(
  1318. 'forum_id_idx' => array('forum_id'),
  1319. 'moved_to_idx' => array('moved_to'),
  1320. 'last_post_idx' => array('last_post'),
  1321. 'first_post_id_idx' => array('first_post_id')
  1322. )
  1323. );
  1324. $db->create_table('topics', $schema) or error('Unable to create topics table', __FILE__, __LINE__, $db->error());
  1325. $schema = array(
  1326. 'FIELDS' => array(
  1327. 'id' => array(
  1328. 'datatype' => 'SERIAL',
  1329. 'allow_null' => false
  1330. ),
  1331. 'group_id' => array(
  1332. 'datatype' => 'INT(10) UNSIGNED',
  1333. 'allow_null' => false,
  1334. 'default' => '3'
  1335. ),
  1336. 'username' => array(
  1337. 'datatype' => 'VARCHAR(200)',
  1338. 'allow_null' => false,
  1339. 'default' => '\'\''
  1340. ),
  1341. 'password' => array(
  1342. 'datatype' => 'VARCHAR(40)',
  1343. 'allow_null' => false,
  1344. 'default' => '\'\''
  1345. ),
  1346. 'email' => array(
  1347. 'datatype' => 'VARCHAR(80)',
  1348. 'allow_null' => false,
  1349. 'default' => '\'\''
  1350. ),
  1351. 'title' => array(
  1352. 'datatype' => 'VARCHAR(50)',
  1353. 'allow_null' => true
  1354. ),
  1355. 'realname' => array(
  1356. 'datatype' => 'VARCHAR(40)',
  1357. 'allow_null' => true
  1358. ),
  1359. 'url' => array(
  1360. 'datatype' => 'VARCHAR(100)',
  1361. 'allow_null' => true
  1362. ),
  1363. 'jabber' => array(
  1364. 'datatype' => 'VARCHAR(80)',
  1365. 'allow_null' => true
  1366. ),
  1367. 'icq' => array(
  1368. 'datatype' => 'VARCHAR(12)',
  1369. 'allow_null' => true
  1370. ),
  1371. 'msn' => array(
  1372. 'datatype' => 'VARCHAR(80)',
  1373. 'allow_null' => true
  1374. ),
  1375. 'aim' => array(
  1376. 'datatype' => 'VARCHAR(30)',
  1377. 'allow_null' => true
  1378. ),
  1379. 'yahoo' => array(
  1380. 'datatype' => 'VARCHAR(30)',
  1381. 'allow_null' => true
  1382. ),
  1383. 'location' => array(
  1384. 'datatype' => 'VARCHAR(30)',
  1385. 'allow_null' => true
  1386. ),
  1387. 'signature' => array(
  1388. 'datatype' => 'TEXT',
  1389. 'allow_null' => true
  1390. ),
  1391. 'disp_topics' => array(
  1392. 'datatype' => 'TINYINT(3) UNSIGNED',
  1393. 'allow_null' => true
  1394. ),
  1395. 'disp_posts' => array(
  1396. 'datatype' => 'TINYINT(3) UNSIGNED',
  1397. 'allow_null' => true
  1398. ),
  1399. 'email_setting' => array(
  1400. 'datatype' => 'TINYINT(1)',
  1401. 'allow_null' => false,
  1402. 'default' => '1'
  1403. ),
  1404. 'notify_with_post' => array(
  1405. 'datatype' => 'TINYINT(1)',
  1406. 'allow_null' => false,
  1407. 'default' => '0'
  1408. ),
  1409. 'auto_notify' => array(
  1410. 'datatype' => 'TINYINT(1)',
  1411. 'allow_null' => false,
  1412. 'default' => '0'
  1413. ),
  1414. 'show_smilies' => array(
  1415. 'datatype' => 'TINYINT(1)',
  1416. 'allow_null' => false,
  1417. 'default' => '1'
  1418. ),
  1419. 'show_img' => array(
  1420. 'datatype' => 'TINYINT(1)',
  1421. 'allow_null' => false,
  1422. 'defa…

Large files files are truncated, but you can click here to view the full file