PageRenderTime 57ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  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. 'default' => '1'
  1423. ),
  1424. 'show_img_sig' => array(
  1425. 'datatype' => 'TINYINT(1)',
  1426. 'allow_null' => false,
  1427. 'default' => '1'
  1428. ),
  1429. 'show_avatars' => array(
  1430. 'datatype' => 'TINYINT(1)',
  1431. 'allow_null' => false,
  1432. 'default' => '1'
  1433. ),
  1434. 'show_sig' => array(
  1435. 'datatype' => 'TINYINT(1)',
  1436. 'allow_null' => false,
  1437. 'default' => '1'
  1438. ),
  1439. 'timezone' => array(
  1440. 'datatype' => 'FLOAT',
  1441. 'allow_null' => false,
  1442. 'default' => '0'
  1443. ),
  1444. 'dst' => array(
  1445. 'datatype' => 'TINYINT(1)',
  1446. 'allow_null' => false,
  1447. 'default' => '0'
  1448. ),
  1449. 'time_format' => array(
  1450. 'datatype' => 'TINYINT(1)',
  1451. 'allow_null' => false,
  1452. 'default' => '0'
  1453. ),
  1454. 'date_format' => array(
  1455. 'datatype' => 'TINYINT(1)',
  1456. 'allow_null' => false,
  1457. 'default' => '0'
  1458. ),
  1459. 'language' => array(
  1460. 'datatype' => 'VARCHAR(25)',
  1461. 'allow_null' => false,
  1462. 'default' => '\'English\''
  1463. ),
  1464. 'style' => array(
  1465. 'datatype' => 'VARCHAR(25)',
  1466. 'allow_null' => false,
  1467. 'default' => '\''.$db->escape($default_style).'\''
  1468. ),
  1469. 'num_posts' => array(
  1470. 'datatype' => 'INT(10) UNSIGNED',
  1471. 'allow_null' => false,
  1472. 'default' => '0'
  1473. ),
  1474. 'last_post' => array(
  1475. 'datatype' => 'INT(10) UNSIGNED',
  1476. 'allow_null' => true
  1477. ),
  1478. 'last_search' => array(
  1479. 'datatype' => 'INT(10) UNSIGNED',
  1480. 'allow_null' => true
  1481. ),
  1482. 'last_email_sent' => array(
  1483. 'datatype' => 'INT(10) UNSIGNED',
  1484. 'allow_null' => true
  1485. ),
  1486. 'registered' => array(
  1487. 'datatype' => 'INT(10) UNSIGNED',
  1488. 'allow_null' => false,
  1489. 'default' => '0'
  1490. ),
  1491. 'registration_ip' => array(
  1492. 'datatype' => 'VARCHAR(39)',
  1493. 'allow_null' => false,
  1494. 'default' => '\'0.0.0.0\''
  1495. ),
  1496. 'last_visit' => array(
  1497. 'datatype' => 'INT(10) UNSIGNED',
  1498. 'allow_null' => false,
  1499. 'default' => '0'
  1500. ),
  1501. 'admin_note' => array(
  1502. 'datatype' => 'VARCHAR(30)',
  1503. 'allow_null' => true
  1504. ),
  1505. 'activate_string' => array(
  1506. 'datatype' => 'VARCHAR(80)',
  1507. 'allow_null' => true
  1508. ),
  1509. 'activate_key' => array(
  1510. 'datatype' => 'VARCHAR(8)',
  1511. 'allow_null' => true
  1512. ),
  1513. ),
  1514. 'PRIMARY KEY' => array('id'),
  1515. 'UNIQUE KEYS' => array(
  1516. 'username_idx' => array('username')
  1517. ),
  1518. 'INDEXES' => array(
  1519. 'registered_idx' => array('registered')
  1520. )
  1521. );
  1522. if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
  1523. $schema['UNIQUE KEYS']['username_idx'] = array('username(25)');
  1524. $db->create_table('users', $schema) or error('Unable to create users table', __FILE__, __LINE__, $db->error());
  1525. /*---------- EvE-BB INSTALL TABLE CONSTRUCTION ---------*/
  1526. //API Auth table, used to fetch/store API data so we can then get the more detailed info. It's also used for cross reference.
  1527. $schema = array(
  1528. 'FIELDS' => array(
  1529. 'user_id' => array(
  1530. 'datatype' => 'INT(10) UNSIGNED',
  1531. 'allow_null' => false
  1532. ),
  1533. 'api_character_id' => array(
  1534. 'datatype' => 'INT(10) UNSIGNED',
  1535. 'allow_null' => false
  1536. ),
  1537. 'api_user_id' => array(
  1538. 'datatype' => 'INT(10) UNSIGNED',
  1539. 'allow_null' => false,
  1540. 'default' => '0'
  1541. ),
  1542. 'api_key' => array(
  1543. 'datatype' => 'VARCHAR(64)',
  1544. 'allow_null' => false
  1545. ),
  1546. 'cak_type' => array(
  1547. 'datatype' => 'INT(10) UNSIGNED',
  1548. 'default' => '0'
  1549. )
  1550. ),
  1551. 'PRIMARY KEY' => array('api_character_id')
  1552. );
  1553. $db->create_table('api_auth', $schema) or error('Unable to create api table', __FILE__, __LINE__, $db->error());
  1554. //API Character Details, used to store the "non array" data of a character - skills, attributes, titles, etc, will be stored on another table, but not atm.
  1555. $schema = array(
  1556. 'FIELDS' => array(
  1557. 'user_id' => array(
  1558. 'datatype' => 'INT(10) UNSIGNED',
  1559. 'allow_null' => false
  1560. ),
  1561. 'character_id' => array(
  1562. 'datatype' => 'INT(10) UNSIGNED',
  1563. 'allow_null' => false
  1564. ),
  1565. 'character_name' => array(
  1566. 'datatype' => 'VARCHAR(100)',
  1567. 'allow_null' => true
  1568. ),
  1569. 'corp_id' => array(
  1570. 'datatype' => 'INT(10) UNSIGNED',
  1571. 'allow_null' => false
  1572. ),
  1573. 'corp_name' => array(
  1574. 'datatype' => 'VARCHAR(50)',
  1575. 'allow_null' => true
  1576. ),
  1577. 'ally_id' => array(
  1578. 'datatype' => 'INT(10) UNSIGNED',
  1579. 'allow_null' => false
  1580. ),
  1581. 'ally_name' => array(
  1582. 'datatype' => 'VARCHAR(50)',
  1583. 'allow_null' => true
  1584. ),
  1585. 'dob' => array(
  1586. 'datatype' => 'VARCHAR(20)',
  1587. 'allow_null' => true
  1588. ),
  1589. 'race' => array(
  1590. 'datatype' => 'VARCHAR(12)',
  1591. 'allow_null' => true
  1592. ),
  1593. 'blood_line' => array(
  1594. 'datatype' => 'VARCHAR(24)',
  1595. 'allow_null' => true
  1596. ),
  1597. 'ancestry' => array(
  1598. 'datatype' => 'VARCHAR(24)',
  1599. 'allow_null' => true
  1600. ),
  1601. 'gender' => array(
  1602. 'datatype' => 'VARCHAR(6)',
  1603. 'allow_null' => true
  1604. ),
  1605. 'clone_name' => array(
  1606. 'datatype' => 'VARCHAR(24)',
  1607. 'allow_null' => true
  1608. ),
  1609. 'clone_sp' => array(
  1610. 'datatype' => 'INT(10) UNSIGNED',
  1611. 'allow_null' => true,
  1612. 'default' => '0'
  1613. ),
  1614. 'balance' => array(
  1615. 'datatype' => 'FLOAT',
  1616. 'allow_null' => true,
  1617. 'default' => '0.0'
  1618. ),
  1619. 'last_update' => array(
  1620. 'datatype' => 'INT(10) UNSIGNED',
  1621. 'allow_null' => false,
  1622. 'default' => '0'
  1623. ),
  1624. 'roles' => array(
  1625. 'datatype' => 'VARCHAR(64)',
  1626. 'allow_null' => false,
  1627. 'default' => '0'
  1628. ),
  1629. 'active' => array(
  1630. 'datatype' => 'TINYINT(1)',
  1631. 'allow_null' => false,
  1632. 'default' => '1'
  1633. )
  1634. ),
  1635. 'PRIMARY KEY' => array('character_id'),
  1636. 'INDEXES' => array(
  1637. 'api_characters_user_id_idx' => array('user_id'),
  1638. 'api_characters_corp_id_idx' => array('corp_id'),
  1639. 'api_characters_ally_id_idx' => array('ally_id'),
  1640. 'api_characters_last_update_idx' => array('last_update')
  1641. )
  1642. );
  1643. $db->create_table('api_characters', $schema) or error('Unable to create api table', __FILE__, __LINE__, $db->error());
  1644. //API Selected Character - support for multiple characters being allowed.
  1645. $schema = array(
  1646. 'FIELDS' => array(
  1647. 'user_id' => array(
  1648. 'datatype' => 'INT(10) UNSIGNED',
  1649. 'allow_null' => false
  1650. ),
  1651. 'character_id' => array(
  1652. 'datatype' => 'INT(10) UNSIGNED',
  1653. 'allow_null' => false
  1654. )
  1655. ),
  1656. 'PRIMARY KEY' => array('user_id'),
  1657. 'INDEXES' => array(
  1658. 'api_selected_char_character_id_idx' => array('character_id')
  1659. )
  1660. );
  1661. $db->create_table('api_selected_char', $schema) or error('Unable to create api table', __FILE__, __LINE__, $db->error());
  1662. //API Groups -reference table to assign certain groupID's to corpID's.
  1663. $schema = array(
  1664. 'FIELDS' => array(
  1665. 'id' => array(
  1666. 'datatype' => 'INT(10) UNSIGNED',
  1667. 'allow_null' => false
  1668. ),
  1669. 'group_id' => array(
  1670. 'datatype' => 'INT(10) UNSIGNED',
  1671. 'allow_null' => false
  1672. ),
  1673. 'type' => array(
  1674. 'datatype' => 'TINYINT(4) UNSIGNED',
  1675. 'allow_null' => false,
  1676. 'default' => '0'
  1677. ),
  1678. 'priority' => array(
  1679. 'datatype' => 'INT(10) UNSIGNED',
  1680. 'allow_null' => false,
  1681. 'default' => '1'
  1682. ),
  1683. 'role' => array(
  1684. 'datatype' => 'VARCHAR(64)',
  1685. 'allow_null' => false,
  1686. 'default' => '0'
  1687. )
  1688. ),
  1689. 'PRIMARY KEY' => array('id', 'group_id', 'role')
  1690. );
  1691. $db->create_table('api_groups', $schema) or error('Unable to create api table', __FILE__, __LINE__, $db->error());
  1692. //Allowed corps.
  1693. $schema = array(
  1694. 'FIELDS' => array(
  1695. 'corporationID' => array(
  1696. 'datatype' => 'INT(10) UNSIGNED',
  1697. 'allow_null' => false
  1698. ),
  1699. 'corporationName' => array(
  1700. 'datatype' => 'VARCHAR(255)',
  1701. 'allow_null' => false
  1702. ),
  1703. 'ticker' => array(
  1704. 'datatype' => 'VARCHAR(10)',
  1705. 'allow_null' => false
  1706. ),
  1707. 'ceoID' => array(
  1708. 'datatype' => 'INT(10) UNSIGNED',
  1709. 'allow_null' => false
  1710. ),
  1711. 'ceoName' => array(
  1712. 'datatype' => 'VARCHAR(255)',
  1713. 'allow_null' => false
  1714. ),
  1715. 'description' => array(
  1716. 'datatype' => 'VARCHAR(3000)',
  1717. 'allow_null' => true
  1718. ),
  1719. 'url' => array(
  1720. 'datatype' => 'VARCHAR(150)',
  1721. 'allow_null' => true
  1722. ),
  1723. 'allianceID' => array(
  1724. 'datatype' => 'INT(10) UNSIGNED',
  1725. 'allow_null' => false,
  1726. 'default' => '0'
  1727. ),
  1728. 'taxRate' => array(
  1729. 'datatype' => 'FLOAT',
  1730. 'allow_null' => false
  1731. ),
  1732. 'allowed' => array(
  1733. 'datatype' => 'TINYINT(1) UNSIGNED',
  1734. 'allow_null' => false,
  1735. 'default' => '0'
  1736. )
  1737. ),
  1738. 'PRIMARY KEY' => array('corporationID'),
  1739. 'INDEXES' => array(
  1740. 'api_allowed_corps_alliance_id_idx' => array('allianceID'),
  1741. 'api_allowed_corps_allowed_idx' => array('allowed')
  1742. )
  1743. );
  1744. $db->create_table('api_allowed_corps', $schema) or error('Unable to create api table', __FILE__, __LINE__, $db->error());
  1745. //Allowed corps.
  1746. $schema = array(
  1747. 'FIELDS' => array(
  1748. 'allianceID' => array(
  1749. 'datatype' => 'INT(10) UNSIGNED',
  1750. 'allow_null' => false
  1751. ),
  1752. 'allianceName' => array(
  1753. 'datatype' => 'VARCHAR(255)',
  1754. 'allow_null' => false
  1755. ),
  1756. 'ticker' => array(
  1757. 'datatype' => 'VARCHAR(10)',
  1758. 'allow_null' => false
  1759. ),
  1760. 'executorCorpID' => array(
  1761. 'datatype' => 'INT(10) UNSIGNED',
  1762. 'allow_null' => false
  1763. ),
  1764. 'memberCount' => array(
  1765. 'datatype' => 'INT(10) UNSIGNED',
  1766. 'allow_null' => false,
  1767. 'default' => '0'
  1768. ),
  1769. 'startDate' => array(
  1770. 'datatype' => 'VARCHAR(20)',
  1771. 'allow_null' => true
  1772. ),
  1773. 'allowed' => array(
  1774. 'datatype' => 'TINYINT(1) UNSIGNED',
  1775. 'allow_null' => false,
  1776. 'default' => '0'
  1777. )
  1778. ),
  1779. 'PRIMARY KEY' => array('allianceID'),
  1780. 'INDEXES' => array(
  1781. 'api_allowed_alliance_allowed_idx' => array('allowed')
  1782. )
  1783. );
  1784. $db->create_table('api_allowed_alliance', $schema) or error('Unable to create api table', __FILE__, __LINE__, $db->error());
  1785. //Alliance member corps
  1786. $schema = array(
  1787. 'FIELDS' => array(
  1788. 'allianceID' => array(
  1789. 'datatype' => 'INT(10) UNSIGNED',
  1790. 'allow_null' => false
  1791. ),
  1792. 'corporationID' => array(
  1793. 'datatype' => 'INT(10) UNSIGNED',
  1794. 'allow_null' => false
  1795. ),
  1796. 'startDate' => array(
  1797. 'datatype' => 'VARCHAR(20)',
  1798. 'allow_null' => false
  1799. )
  1800. ),
  1801. 'PRIMARY KEY' => array('corporationID')
  1802. );
  1803. $db->create_table('api_alliance_corps', $schema) or error('Unable to create api table', __FILE__, __LINE__, $db->error());
  1804. //Alliance list.
  1805. $schema = array(
  1806. 'FIELDS' => array(
  1807. 'allianceID' => array(
  1808. 'datatype' => 'INT(10) UNSIGNED',
  1809. 'allow_null' => false
  1810. ),
  1811. 'name' => array(
  1812. 'datatype' => 'VARCHAR(255)',
  1813. 'allow_null' => false
  1814. ),
  1815. 'shortName' => array(
  1816. 'datatype' => 'VARCHAR(10)',
  1817. 'allow_null' => false
  1818. ),
  1819. 'executorCorpID' => array(
  1820. 'datatype' => 'INT (10) UNSIGNED',
  1821. 'allow_null' => false
  1822. ),
  1823. 'memberCount' => array(
  1824. 'datatype' => 'INT (10) UNSIGNED',
  1825. 'allow_null' => false
  1826. ),
  1827. 'startDate' => array(
  1828. 'datatype' => 'VARCHAR(20)',
  1829. 'allow_null' => false
  1830. )
  1831. ),
  1832. 'PRIMARY KEY' => array('allianceID')
  1833. );
  1834. $db->create_table('api_alliance_list', $schema) or error('Unable to create api table', __FILE__, __LINE__, $db->error());
  1835. //Skill Types
  1836. $schema = array(
  1837. 'FIELDS' => array(
  1838. 'typeID' => array(
  1839. 'datatype' => 'INT(10) UNSIGNED',
  1840. 'allow_null' => false
  1841. ),
  1842. 'typeName' => array(
  1843. 'datatype' => 'VARCHAR(100)',
  1844. 'allow_null' => false
  1845. ),
  1846. 'description' => array(
  1847. 'datatype' => 'VARCHAR(3000)',
  1848. 'allow_null' => false
  1849. ),
  1850. 'groupName' => array(
  1851. 'datatype' => 'VARCHAR(100)',
  1852. 'allow_null' => false
  1853. )
  1854. ),
  1855. 'PRIMARY KEY' => array('typeID')
  1856. );
  1857. $db->create_table('api_skill_types', $schema) or error('Unable to create skill types table', __FILE__, __LINE__, $db->error());
  1858. //SkillQueue table.
  1859. $schema = array(
  1860. 'FIELDS' => array(
  1861. 'character_id' => array(
  1862. 'datatype' => 'INT(10) UNSIGNED',
  1863. 'allow_null' => false
  1864. ),
  1865. 'queuePosition' => array(
  1866. 'datatype' => 'INT(10) UNSIGNED',
  1867. 'allow_null' => false
  1868. ),
  1869. 'typeID' => array(
  1870. 'datatype' => 'INT(10) UNSIGNED',
  1871. 'allow_null' => false
  1872. ),
  1873. 'level' => array(
  1874. 'datatype' => 'INT(10) UNSIGNED',
  1875. 'allow_null' => false
  1876. ),
  1877. 'startSP' => array(
  1878. 'datatype' => 'INT(10) UNSIGNED',
  1879. 'allow_null' => false
  1880. ),
  1881. 'endSP' => array(
  1882. 'datatype' => 'INT(10) UNSIGNED',
  1883. 'allow_null' => false
  1884. ),
  1885. 'startTime' => array(
  1886. 'datatype' => 'VARCHAR(25)',
  1887. 'allow_null' => false
  1888. ),
  1889. 'endTime' => array(
  1890. 'datatype' => 'VARCHAR(25)',
  1891. 'allow_null' => false
  1892. ),
  1893. 'last_update' => array(
  1894. 'datatype' => 'INT(10) UNSIGNED',
  1895. 'allow_null' => false
  1896. )
  1897. ),
  1898. 'PRIMARY KEY' => array('character_id', 'typeID', 'queuePosition')
  1899. );
  1900. $db->create_table('api_skill_queue', $schema) or error('Unable to create skill queue table', __FILE__, __LINE__, $db->error());
  1901. //Multiple Group Table.
  1902. $schema = array(
  1903. 'FIELDS' => array(
  1904. 'user_id' => array(
  1905. 'datatype' => 'INT(10) UNSIGNED',
  1906. 'allow_null' => false
  1907. ),
  1908. 'group_id' => array(
  1909. 'datatype' => 'INT(10) UNSIGNED',
  1910. 'allow_null' => false
  1911. )
  1912. ),
  1913. 'PRIMARY KEY' => array('user_id', 'group_id')
  1914. );
  1915. $db->create_table('groups_users', $schema) or error('Unable to create groups table', __FILE__, __LINE__, $db->error());
  1916. //Teamspeak3 table
  1917. $schema = array(
  1918. 'FIELDS' => array(
  1919. 'user_id' => array(
  1920. 'datatype' => 'INT(10) UNSIGNED',
  1921. 'allow_null' => false,
  1922. 'default' => '0'
  1923. ),
  1924. 'username' => array(
  1925. 'datatype' => 'VARCHAR(100)',
  1926. 'allow_null' => false
  1927. ),
  1928. 'token' => array(
  1929. 'datatype' => 'VARCHAR(100)',
  1930. 'allow_null' => false
  1931. )
  1932. ),
  1933. 'PRIMARY KEY' => array('user_id')
  1934. );
  1935. $db->create_table('teamspeak3', $schema) or error('Unable to create teamspeak3 table', __FILE__, __LINE__, $db->error());
  1936. //Session table
  1937. $schema = array(
  1938. 'FIELDS' => array(
  1939. 'user_id' => array(
  1940. 'datatype' => 'INT(10) UNSIGNED',
  1941. 'allow_null' => false,
  1942. 'default' => '0'
  1943. ),
  1944. 'token' => array(
  1945. 'datatype' => 'VARCHAR(32)',
  1946. 'allow_null' => false
  1947. ),
  1948. 'stamp' => array(
  1949. 'datatype' => 'INT(10) UNSIGNED',
  1950. 'allow_null' => false
  1951. ),
  1952. 'length' => array(
  1953. 'datatype' => 'INT(10) UNSIGNED',
  1954. 'allow_null' => false
  1955. ),
  1956. 'ip' => array(
  1957. 'datatype' => 'VARCHAR(32)',
  1958. 'allow_null' => false
  1959. )
  1960. ),
  1961. 'PRIMARY KEY' => array('user_id')
  1962. );
  1963. $db->create_table('session', $schema) or error('Unable to create session table', __FILE__, __LINE__, $db->error());
  1964. /*---------- EvE-BB INSTALL TABLE CONSTRUCTION ---------*/
  1965. $now = time();
  1966. // Insert the four preset groups
  1967. $db->query('INSERT INTO '.$db->prefix.'groups ('.($db_type != 'pgsql' ? 'g_id, ' : '').'g_title, g_user_title, g_moderator, g_mod_edit_users, g_mod_rename_users, g_mod_change_passwords, g_mod_ban_users, g_read_board, g_view_users, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_send_email, g_post_flood, g_search_flood, g_email_flood) VALUES('.($db_type != 'pgsql' ? '1, ' : '').'\''.$db->escape($lang_install['Administrators']).'\', \''.$db->escape($lang_install['Administrator']).'\', 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0)') or error('Unable to add group', __FILE__, __LINE__, $db->error());
  1968. //
  1969. $db->query('INSERT INTO '.$db->prefix.'groups ('.($db_type != 'pgsql' ? 'g_id, ' : '').'g_title, g_user_title, g_moderator, g_mod_edit_users, g_mod_rename_users, g_mod_change_passwords, g_mod_ban_users, g_read_board, g_view_users, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_send_email, g_post_flood, g_search_flood, g_email_flood) VALUES('.($db_type != 'pgsql' ? '2, ' : '').'\''.$db->escape($lang_install['Moderators']).'\', \''.$db->escape($lang_install['Moderator']).'\', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0)') or error('Unable to add group', __FILE__, __LINE__, $db->error());
  1970. //
  1971. $db->query('INSERT INTO '.$db->prefix.'groups ('.($db_type != 'pgsql' ? 'g_id, ' : '').'g_title, g_user_title, g_moderator, g_mod_edit_users, g_mod_rename_users, g_mod_change_passwords, g_mod_ban_users, g_read_board, g_view_users, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_send_email, g_post_flood, g_search_flood, g_email_flood) VALUES('.($db_type != 'pgsql' ? '3, ' : '').'\''.$db->escape($lang_install['Guests']).'\', NULL, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 60, 30, 0)') or error('Unable to add group', __FILE__, __LINE__, $db->error());
  1972. //
  1973. $db->query('INSERT INTO '.$db->prefix.'groups ('.($db_type != 'pgsql' ? 'g_id, ' : '').'g_title, g_user_title, g_moderator, g_mod_edit_users, g_mod_rename_users, g_mod_change_passwords, g_mod_ban_users, g_read_board, g_view_users, g_post_replies, g_post_topics, g_edit_posts, g_delete_posts, g_delete_topics, g_set_title, g_search, g_search_users, g_send_email, g_post_flood, g_search_flood, g_email_flood) VALUES('.($db_type != 'pgsql' ? '4, ' : '').'\''.$db->escape($lang_install['Members']).'\', NULL, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 60, 30, 60)') or error('Unable to add group', __FILE__, __LINE__, $db->error());
  1974. // Insert guest and first admin user
  1975. $db->query('INSERT INTO '.$db_prefix.'users (group_id, username, password, email) VALUES(3, \''.$db->escape($lang_install['Guest']).'\', \''.$db->escape($lang_install['Guest']).'\', \''.$db->escape($lang_install['Guest']).'\')')
  1976. or error('Unable to add guest user. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  1977. $db->query('INSERT INTO '.$db_prefix.'users (group_id, username, password, email, language, style, num_posts, last_post, registered, registration_ip, last_visit) VALUES(1, \''.$db->escape($username).'\', \''.pun_hash($password1).'\', \''.$email.'\', \''.$db->escape($default_lang).'\', \''.$db->escape($default_style).'\', 1, '.$now.', '.$now.', \''.get_remote_address().'\', '.$now.')')
  1978. or error('Unable to add administrator user. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  1979. /*---------- EvE-BB INSTALL TABLE DATA ---------*/
  1980. //Our function to handle this relies on $db being fully formed, so we do this manually.
  1981. $db->query('INSERT INTO '.$db_prefix."api_auth (user_id, api_character_id, api_user_id, api_key) VALUES(2, ".$api_character_id.", ".$api_user_id.", '".$db->escape($api_key)."')")
  1982. or error('Unable to add administrator user api data. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  1983. $char;
  1984. if (!$char = update_character_sheet(2, null, $char_sheet)) {
  1985. error("Unable to fetch character data from the API server. Please verify it is currently online and try again.", __FILE__, __LINE__, $db->error());
  1986. } //End if.
  1987. $corp;
  1988. if (!$corp = add_corp_from_character($char)) {
  1989. error("Unable to fetch corporation data from the API server. Please verify it is currently online and try again.", __FILE__, __LINE__, $db->error());
  1990. } //End if.
  1991. //We try, but don't care past this point.
  1992. update_characters(2, $cak);
  1993. select_character(2, $char);
  1994. //Now we get the (massive) skill types SQL and insert it.
  1995. if (!file_exists(PUN_ROOT.'install/api_skill_types_sql.php')) {
  1996. error('Can not find the install directory and it\'s associated data.');
  1997. } //End if.
  1998. require(PUN_ROOT.'install/api_skill_types_sql.php');
  1999. foreach ($api_skill_types as $sql) {
  2000. $db->query($sql) or error('Unable to load the skills into the database.<br/>'.$sql, __FILE__, __LINE__, $db->error());
  2001. } //End foreach().
  2002. /*---------- EvE-BB INSTALL TABLE DATA ---------*/
  2003. // Enable/disable avatars depending on file_uploads setting in PHP configuration
  2004. $avatars = in_array(strtolower(@ini_get('file_uploads')), array('on', 'true', '1')) ? 1 : 0;
  2005. // Insert config data
  2006. $config = array(
  2007. 'o_cur_version' => "'".FORUM_VERSION."'",
  2008. 'o_database_revision' => "'".FORUM_DB_REVISION."'",
  2009. 'o_searchindex_revision' => "'".FORUM_SI_REVISION."'",
  2010. 'o_parser_revision' => "'".FORUM_PARSER_REVISION."'",
  2011. 'o_board_title' => "'".$db->escape($title)."'",
  2012. 'o_board_desc' => "'".$db->escape($description)."'",
  2013. 'o_default_timezone' => "'0'",
  2014. 'o_time_format' => "'H:i:s'",
  2015. 'o_date_format' => "'Y-m-d'",
  2016. 'o_timeout_visit' => "'1800'",
  2017. 'o_timeout_online' => "'300'",
  2018. 'o_redirect_delay' => "'1'",
  2019. 'o_show_version' => "'0'",
  2020. 'o_show_user_info' => "'1'",
  2021. 'o_show_post_count' => "'1'",
  2022. 'o_signatures' => "'1'",
  2023. 'o_smilies' => "'1'",
  2024. 'o_smilies_sig' => "'1'",
  2025. 'o_make_links' => "'1'",
  2026. 'o_default_lang' => "'".$db->escape($default_lang)."'",
  2027. 'o_default_style' => "'".$db->escape($default_style)."'",
  2028. 'o_allow_style' => "'1'",
  2029. 'o_default_user_group' => "'4'",
  2030. 'o_topic_review' => "'15'",
  2031. 'o_disp_topics_default' => "'30'",
  2032. 'o_disp_posts_default' => "'25'",
  2033. 'o_indent_num_spaces' => "'4'",
  2034. 'o_quote_depth' => "'3'",
  2035. 'o_quickpost' => "'1'",
  2036. 'o_users_online' => "'1'",
  2037. 'o_censoring' => "'0'",
  2038. 'o_ranks' => "'1'",
  2039. 'o_show_dot' => "'0'",
  2040. 'o_topic_views' => "'1'",
  2041. 'o_quickjump' => "'1'",
  2042. 'o_gzip' => "'0'",
  2043. 'o_additional_navlinks' => "''",
  2044. 'o_report_method' => "'0'",
  2045. 'o_regs_report' => "'0'",
  2046. 'o_default_email_setting' => "'1'",
  2047. 'o_mailing_list' => "'".$email."'",
  2048. 'o_avatars' => "'".$avatars."'",
  2049. 'o_avatars_dir' => "'img/avatars'",
  2050. 'o_avatars_width' => "'60'",
  2051. 'o_avatars_height' => "'60'",
  2052. 'o_avatars_size' => "'10240'",
  2053. 'o_search_all_forums' => "'1'",
  2054. 'o_base_url' => "'".$db->escape($base_url)."'",
  2055. 'o_admin_email' => "'".$email."'",
  2056. 'o_webmaster_email' => "'".$email."'",
  2057. 'o_forum_subscriptions' => "'1'",
  2058. 'o_topic_subscriptions' => "'1'",
  2059. 'o_smtp_host' => "NULL",
  2060. 'o_smtp_user' => "NULL",
  2061. 'o_smtp_pass' => "NULL",
  2062. 'o_smtp_ssl' => "'0'",
  2063. 'o_regs_allow' => "'1'",
  2064. 'o_regs_verify' => "'0'",
  2065. 'o_announcement' => "'0'",
  2066. 'o_announcement_message' => "'".$db->escape($lang_install['Announcement'])."'",
  2067. 'o_rules' => "'0'",
  2068. 'o_rules_message' => "'".$db->escape($lang_install['Rules'])."'",
  2069. 'o_maintenance' => "'0'",
  2070. 'o_maintenance_message' => "'".$db->escape($lang_install['Maintenance message'])."'",
  2071. 'o_default_dst' => "'0'",
  2072. 'o_feed_type' => "'2'",
  2073. 'o_feed_ttl' => "'0'",
  2074. 'p_message_bbcode' => "'1'",
  2075. 'p_message_img_tag' => "'1'",
  2076. 'p_message_all_caps' => "'1'",
  2077. 'p_subject_all_caps' => "'1'",
  2078. 'p_sig_all_caps' => "'1'",
  2079. 'p_sig_bbcode' => "'1'",
  2080. 'p_sig_img_tag' => "'0'",
  2081. 'p_sig_length' => "'400'",
  2082. 'p_sig_lines' => "'4'",
  2083. 'p_allow_banned_email' => "'1'",
  2084. 'p_allow_dupe_email' => "'0'",
  2085. 'p_force_guest_email' => "'1'",
  2086. /*---------- EvE-BB INSTALL Options ---------*/
  2087. 'o_eve_enabled' => "'1'",
  2088. 'o_eve_use_iga' => "'1'",
  2089. 'o_eve_use_corp_name' => "'1'",
  2090. 'o_eve_use_corp_ticker' => "'0'",
  2091. 'o_eve_use_ally_name' => "'1'",
  2092. 'o_eve_use_ally_ticker' => "'0'",
  2093. 'o_eve_cache_char_sheet' => "'1'", //No idea why I put this in... Leaving it in for now until I remember it's purpose.
  2094. 'o_eve_cache_char_sheet_interval' => "'4'", //4 hours
  2095. 'o_eve_rules_interval' => "'4'", //4 hours
  2096. 'o_eve_auth_interval' => "'4'", //4 hours
  2097. 'o_eve_use_cron' => "'1'", //Default to yes as of 1.1.2
  2098. 'o_eve_use_banner' => "'1'",
  2099. 'o_eve_restrict_reg_corp' => "'1'",
  2100. 'o_eve_restricted_group' => "'4'",
  2101. 'o_eve_last_auth_check' => "'".time()."'",
  2102. 'o_eve_banner' => "'eve-bb-blank-1.jpg'",
  2103. 'o_eve_banner_dir' => "'img/banners'",
  2104. 'o_eve_banner_size' => "'819200'",
  2105. 'o_eve_banner_width' => "'1000'",
  2106. 'o_eve_banner_height' => "'150'",
  2107. 'o_eve_banner_text_enable' => "'1'",
  2108. 'o_eve_max_groups' => "'100'",
  2109. 'o_hide_stats' => "'0'",
  2110. //New since 1.1.2+
  2111. 'o_eve_cur_version' => "'".EVE_BB_VERSION."'",
  2112. 'o_eve_cak_mask' => "'33947656'",
  2113. 'o_eve_cak_type' => "'1'",
  2114. 'o_eve_use_image_server' => "'0'",
  2115. 'o_eve_char_pic_size' => "'128'",
  2116. 'o_use_fopen' => (defined('EVEBB_CURL')) ? "'0'" : "'1'"
  2117. /*---------- EvE-BB INSTALL Options ---------*/
  2118. );
  2119. foreach ($config as $conf_name => $conf_value)
  2120. {
  2121. $sql = 'INSERT INTO '.$db_prefix.'config (conf_name, conf_value) VALUES(\''.$conf_name.'\', '.$conf_value.')';
  2122. $db->query($sql)
  2123. or error('Unable to insert into table '.$db_prefix.'config. Please check your configuration and try again<br />'.$sql, __FILE__, __LINE__, $db->error());
  2124. }
  2125. // Insert some other default data
  2126. $subject = $lang_install['Test post'];
  2127. $message = $lang_install['Message'];
  2128. $db->query('INSERT INTO '.$db_prefix.'ranks (rank, min_posts) VALUES(\''.$db->escape($lang_install['New member']).'\', 0)')
  2129. or error('Unable to insert into table '.$db_prefix.'ranks. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  2130. $db->query('INSERT INTO '.$db_prefix.'ranks (rank, min_posts) VALUES(\''.$db->escape($lang_install['Member']).'\', 10)')
  2131. or error('Unable to insert into table '.$db_prefix.'ranks. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  2132. $db->query('INSERT INTO '.$db_prefix.'categories (cat_name, disp_position) VALUES(\''.$db->escape($lang_install['Test category']).'\', 1)')
  2133. or error('Unable to insert into table '.$db_prefix.'categories. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  2134. $db->query('INSERT INTO '.$db_prefix.'forums (forum_name, forum_desc, num_topics, num_posts, last_post, last_post_id, last_poster, disp_position, cat_id) VALUES(\''.$db->escape($lang_install['Test forum']).'\', \''.$db->escape($lang_install['This is just a test forum']).'\', 1, 1, '.$now.', 1, \''.$db->escape($username).'\', 1, 1)')
  2135. or error('Unable to insert into table '.$db_prefix.'forums. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  2136. $db->query('INSERT INTO '.$db_prefix.'topics (poster, subject, posted, first_post_id, last_post, last_post_id, last_poster, forum_id) VALUES(\''.$db->escape($username).'\', \''.$db->escape($subject).'\', '.$now.', 1, '.$now.', 1, \''.$db->escape($username).'\', 1)')
  2137. or error('Unable to insert into table '.$db_prefix.'topics. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  2138. $db->query('INSERT INTO '.$db_prefix.'posts (poster, poster_id, poster_ip, message, posted, topic_id) VALUES(\''.$db->escape($username).'\', 2, \''.get_remote_address().'\', \''.$db->escape($message).'\', '.$now.', 1)')
  2139. or error('Unable to insert into table '.$db_prefix.'posts. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  2140. /*---------- EvE-BB INSTALL TABLE INPUT ---------*/
  2141. $db->query('INSERT INTO '.$db->prefix.'forum_perms( group_id, forum_id, read_forum, post_replies, post_topics) VALUES(2,1,1,1,1)')
  2142. or error('Unable to insert into table '.$db_prefix.'forum_perms. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  2143. $db->query('INSERT INTO '.$db->prefix.'forum_perms( group_id, forum_id, read_forum, post_replies, post_topics) VALUES(3,1,1,0,0)')
  2144. or error('Unable to insert into table '.$db_prefix.'forum_perms. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  2145. $db->query('INSERT INTO '.$db->prefix.'forum_perms( group_id, forum_id, read_forum, post_replies, post_topics) VALUES(4,1,1,1,1)')
  2146. or error('Unable to insert into table '.$db_prefix.'forum_perms. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  2147. /*---------- EvE-BB INSTALL TABLE INPUT ---------*/
  2148. // Index the test post so searching for it works
  2149. require PUN_ROOT.'include/search_idx.php';
  2150. $pun_config['o_default_lang'] = $default_lang;
  2151. update_search_index('post', 1, $message, $subject);
  2152. $db->end_transaction();
  2153. //Install our now-included mods - Private Messagin, Sub Forums, Attachments, RSS Feed and Poll Support.
  2154. install_npms();
  2155. install_subforum();
  2156. install_attach(rtrim(dirname(__FILE__), '/\\') . DIRECTORY_SEPARATOR.'attachments/');
  2157. install_feed();
  2158. install_poll();
  2159. $alerts = array();
  2160. // Check if we disabled uploading avatars because file_uploads was disabled
  2161. if ($avatars == '0')
  2162. $alerts[] = $lang_install['Alert upload'];
  2163. // Add some random bytes at the end of the cookie name to prevent collisions
  2164. $cookie_name = 'pun_cookie_'.random_key(6, false, true);
  2165. // Generate the config.php file data
  2166. $config = generate_config_file();
  2167. // Attempt to write config.php and serve it up for download if writing fails
  2168. $written = false;
  2169. if (is_writable(PUN_ROOT))
  2170. {
  2171. $fh = @fopen(PUN_ROOT.'config.php', 'wb');
  2172. if ($fh)
  2173. {
  2174. fwrite($fh, $config);
  2175. fclose($fh);
  2176. $written = true;
  2177. }
  2178. }
  2179. //All has gone well! Now lets send them their login details.
  2180. if (!function_exists('pun_mail')) {
  2181. include(PUN_ROOT.'include/email.php');
  2182. } //End if.
  2183. //Try and send it via localhost.
  2184. $pun_config['o_smtp_host'] = "localhost";
  2185. $pun_config['o_smtp_user'] = "";
  2186. $pun_config['o_smtp_pass'] = "";
  2187. pun_mail($email, 'Your new EveBB login details',
  2188. "Your new EveBB install has successfully completed!
  2189. Your Details
  2190. Username: ".$username."
  2191. Password: ".$password1."
  2192. We hope you enjoy your new EveBB install!");
  2193. ?>
  2194. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2195. <html>
  2196. <head>
  2197. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  2198. <title><?php echo $lang_install['FluxBB Installation'] ?></title>
  2199. <link rel="stylesheet" type="text/css" href="style/<?php echo $default_style ?>.css" />
  2200. </head>
  2201. <body>
  2202. <div id="puninstall" class="pun">
  2203. <div class="top-box"><div><!-- Top Corners --></div></div>
  2204. <div class="punwrap">
  2205. <div id="brdheader" class="block">
  2206. <div class="box">
  2207. <div id="brdtitle" class="inbox">
  2208. <h1><span><?php echo sprintf($lang_install['FluxBB Installation'], EVE_BB_VERSION); ?></span></h1>
  2209. <div id="brddesc"><p><?php echo $lang_install['FluxBB has been installed'] ?></p></div>
  2210. </div>
  2211. </div>
  2212. </div>
  2213. <div id="brdmain">
  2214. <div class="blockform">
  2215. <h2><span><?php echo $lang_install['Final instructions'] ?></span></h2>
  2216. <div class="box">
  2217. <?php
  2218. if (!$written)
  2219. {
  2220. ?>
  2221. <form method="post" action="install.php">
  2222. <div class="inform">
  2223. <div class="forminfo">
  2224. <p><?php echo $lang_install['Info 17'] ?></p>
  2225. <p><?php echo $lang_install['Info 18'] ?></p>
  2226. <p><?php echo $lang_install['Evebb_details'] ?></p>
  2227. <br/>
  2228. <p>
  2229. <?php echo $lang_install['Evebb_username'] ?> <?php echo $username; ?><br/>
  2230. <?php echo $lang_install['Evebb_password'] ?> <?php echo $password1; ?>
  2231. </p>
  2232. </div>
  2233. <input type="hidden" name="generate_config" value="1" />
  2234. <input type="hidden" name="db_type" value="<?php echo $db_type; ?>" />
  2235. <input type="hidden" name="db_host" value="<?php echo $db_host; ?>" />
  2236. <input type="hidden" name="db_name" value="<?php echo pun_htmlspecialchars($db_name); ?>" />
  2237. <input type="hidden" name="db_username" value="<?php echo pun_htmlspecialchars($db_username); ?>" />
  2238. <input type="hidden" name="db_password1" value="<?php echo pun_htmlspecialchars($db_password); ?>" />
  2239. <input type="hidden" name="db_prefix" value="<?php echo pun_htmlspecialchars($db_prefix); ?>" />
  2240. <input type="hidden" name="cookie_name" value="<?php echo pun_htmlspecialchars($cookie_name); ?>" />
  2241. <input type="hidden" name="cookie_seed" value="<?php echo pun_htmlspecialchars($cookie_seed); ?>" />
  2242. <?php if (!empty($alerts)): ?> <div class="forminfo error-info">
  2243. <ul class="error-list">
  2244. <?php
  2245. foreach ($alerts as $cur_alert)
  2246. echo "\t\t\t\t\t".'<li>'.$cur_alert.'</li>'."\n";
  2247. ?>
  2248. </ul>
  2249. </div>
  2250. <?php endif; ?> </div>
  2251. <p class="buttons"><input type="submit" value="<?php echo $lang_install['Download config.php file'] ?>" /></p>
  2252. </form>
  2253. <?php
  2254. }
  2255. else
  2256. {
  2257. ?>
  2258. <div class="fakeform">
  2259. <div class="inform">
  2260. <div class="forminfo">
  2261. <p><?php echo $lang_install['FluxBB fully installed'] ?></p>
  2262. <p><?php echo $lang_install['Evebb_details'] ?></p>
  2263. <p>
  2264. <?php echo $lang_install['Evebb_username'] ?> <?php echo $username; ?><br/>
  2265. <?php echo $lang_install['Evebb_password'] ?> <?php echo $password1; ?>
  2266. </p>
  2267. </div>
  2268. </div>
  2269. </div>
  2270. <?php
  2271. }
  2272. ?>
  2273. </div>
  2274. </div>
  2275. </div>
  2276. </div>
  2277. <div class="end-box"><div><!-- Bottom Corners --></div></div>
  2278. </div>
  2279. </body>
  2280. </html>
  2281. <?php
  2282. }
  2283. /**
  2284. * This massively long function makes the DB ready for sub forums.
  2285. */
  2286. function install_subforum() {
  2287. global $db;
  2288. $db->add_field('forums', 'parent_forum_id', 'INT', true, 0);
  2289. } //End install_subform().
  2290. /**
  2291. * Installs the tables for the Private Messaging System.
  2292. */
  2293. function install_npms() {
  2294. global $db, $db_type, $pun_config;
  2295. $schema = array(
  2296. 'FIELDS' => array(
  2297. 'bl_id' => array(
  2298. 'datatype' => 'INT(10) UNSIGNED',
  2299. 'allow_null' => false,
  2300. 'default' => '0'
  2301. ),
  2302. 'bl_user_id' => array(
  2303. 'datatype' => 'INT(10) UNSIGNED',
  2304. 'allow_null' => false,
  2305. 'default' => '0'
  2306. ),
  2307. 'bl_user' => array(
  2308. 'datatype' => 'VARCHAR(200)',
  2309. 'allow_null' => false,
  2310. 'default' => '\'\''
  2311. ),
  2312. ),
  2313. 'INDEXES' => array(
  2314. 'bl_id_idx' => array('bl_id'),
  2315. 'bl_user_id_idx' => array('bl_user_id')
  2316. )
  2317. );
  2318. $db->create_table('pms_new_block', $schema) or error('Unable to create pms_new_block table', __FILE__, __LINE__, $db->error());
  2319. $schema = array(
  2320. 'FIELDS' => array(
  2321. 'id' => array(
  2322. 'datatype' => 'SERIAL',
  2323. 'allow_null' => false
  2324. ),
  2325. 'poster' => array(
  2326. 'datatype' => 'VARCHAR(200)',
  2327. 'allow_null' => false,
  2328. 'default' => '\'\''
  2329. ),
  2330. 'poster_id' => array(
  2331. 'datatype' => 'INT(10) UNSIGNED',
  2332. 'allow_null' => false,
  2333. 'default' => '1'
  2334. ),
  2335. 'poster_ip' => array(
  2336. 'datatype' => 'VARCHAR(39)',
  2337. 'allow_null' => true
  2338. ),
  2339. 'message' => array(
  2340. 'datatype' => 'TEXT',
  2341. 'allow_null' => true
  2342. ),
  2343. 'hide_smilies' => array(
  2344. 'datatype' => 'TINYINT(1)',
  2345. 'allow_null' => false,
  2346. 'default' => '0'
  2347. ),
  2348. 'posted' => array(
  2349. 'datatype' => 'INT(10) UNSIGNED',
  2350. 'allow_null' => false,
  2351. 'default' => '0'
  2352. ),
  2353. 'edited' => array(
  2354. 'datatype' => 'INT(10) UNSIGNED',
  2355. 'allow_null' => true
  2356. ),
  2357. 'edited_by' => array(
  2358. 'datatype' => 'VARCHAR(200)',
  2359. 'allow_null' => true
  2360. ),
  2361. 'post_seen' => array(
  2362. 'datatype' => 'TINYINT(1)',
  2363. 'allow_null' => false,
  2364. 'default' => '0'
  2365. ),
  2366. 'post_new' => array(
  2367. 'datatype' => 'TINYINT(1)',
  2368. 'allow_null' => false,
  2369. 'default' => '1'
  2370. ),
  2371. 'topic_id' => array(
  2372. 'datatype' => 'INT(10) UNSIGNED',
  2373. 'allow_null' => false,
  2374. 'default' => '0'
  2375. )
  2376. ),
  2377. 'PRIMARY KEY' => array('id'),
  2378. 'INDEXES' => array(
  2379. 'topic_id_idx' => array('topic_id'),
  2380. 'multi_idx' => array('poster_id', 'topic_id')
  2381. )
  2382. );
  2383. $db->create_table('pms_new_posts', $schema) or error('Unable to create pms_new_posts table', __FILE__, __LINE__, $db->error());
  2384. $schema = array(
  2385. 'FIELDS' => array(
  2386. 'id' => array(
  2387. 'datatype' => 'SERIAL',
  2388. 'allow_null' => false
  2389. ),
  2390. 'topic' => array(
  2391. 'datatype' => 'VARCHAR(255)',
  2392. 'allow_null' => false,
  2393. 'default' => '\'\''
  2394. ),
  2395. 'starter' => array(
  2396. 'datatype' => 'VARCHAR(200)',
  2397. 'allow_null' => false,
  2398. 'default' => '\'\''
  2399. ),
  2400. 'starter_id' => array(
  2401. 'datatype' => 'INT(10) UNSIGNED',
  2402. 'allow_null' => false,
  2403. 'default' => '0'
  2404. ),
  2405. 'to_user' => array(
  2406. 'datatype' => 'VARCHAR(200)',
  2407. 'allow_null' => false,
  2408. 'default' => '\'\''
  2409. ),
  2410. 'to_id' => array(
  2411. 'datatype' => 'INT(10) UNSIGNED',
  2412. 'allow_null' => false,
  2413. 'default' => '0'
  2414. ),
  2415. 'replies' => array(
  2416. 'datatype' => 'MEDIUMINT(8) UNSIGNED',
  2417. 'allow_null' => false,
  2418. 'default' => '0'
  2419. ),
  2420. 'last_posted' => array(
  2421. 'datatype' => 'INT(10) UNSIGNED',
  2422. 'allow_null' => false,
  2423. 'default' => '0'
  2424. ),
  2425. 'last_poster' => array(
  2426. 'datatype' => 'TINYINT(1)',
  2427. 'allow_null' => false,
  2428. 'default' => '0'
  2429. ),
  2430. 'see_st' => array(
  2431. 'datatype' => 'INT(10) UNSIGNED',
  2432. 'allow_null' => false,
  2433. 'default' => '0'
  2434. ),
  2435. 'see_to' => array(
  2436. 'datatype' => 'INT(10) UNSIGNED',
  2437. 'allow_null' => false,
  2438. 'default' => '0'
  2439. ),
  2440. 'topic_st' => array(
  2441. 'datatype' => 'TINYINT(4)',
  2442. 'allow_null' => false,
  2443. 'default' => '0'
  2444. ),
  2445. 'topic_to' => array(
  2446. 'datatype' => 'TINYINT(4)',
  2447. 'allow_null' => false,
  2448. 'default' => '0'
  2449. ),
  2450. ),
  2451. 'PRIMARY KEY' => array('id'),
  2452. 'INDEXES' => array(
  2453. 'multi_idx_st' => array('starter_id', 'topic_st'),
  2454. 'multi_idx_to' => array('to_id', 'topic_to')
  2455. )
  2456. );
  2457. $db->create_table('pms_new_topics', $schema) or error('Unable to create pms_new_topics table', __FILE__, __LINE__, $db->error());
  2458. $db->add_field('groups', 'g_pm', 'TINYINT(1)', false, 1) or error('Unable to add g_pm field', __FILE__, __LINE__, $db->error());
  2459. $db->add_field('groups', 'g_pm_limit', 'INT(10) UNSIGNED', false, 100) or error('Unable to add g_pm_limit field', __FILE__, __LINE__, $db->error());
  2460. $db->add_field('users', 'messages_enable', 'TINYINT(1)', false, 1) or error('Unable to add messages_enable field', __FILE__, __LINE__, $db->error());
  2461. $db->add_field('users', 'messages_email', 'TINYINT(1)', false, 0) or error('Unable to add messages_email field', __FILE__, __LINE__, $db->error());
  2462. $db->add_field('users', 'messages_flag', 'TINYINT(1)', false, 0) or error('Unable to add messages_flag field', __FILE__, __LINE__, $db->error());
  2463. $db->add_field('users', 'messages_new', 'INT(10) UNSIGNED', false, 0) or error('Unable to add messages_new field', __FILE__, __LINE__, $db->error());
  2464. $db->add_field('users', 'messages_all', 'INT(10) UNSIGNED', false, 0) or error('Unable to add messages_all field', __FILE__, __LINE__, $db->error());
  2465. $db->add_field('users', 'pmsn_last_post', 'INT(10) UNSIGNED', true) or error('Unable to add pmsn_last_post field', __FILE__, __LINE__, $db->error());
  2466. $db->query('UPDATE '.$db->prefix.'groups SET g_pm_limit=0 WHERE g_id='.PUN_ADMIN) or error('Unable to merge groups', __FILE__, __LINE__, $db->error());
  2467. // Insert config data
  2468. $config = array(
  2469. 'o_pms_enabled' => '1',
  2470. 'o_pms_min_kolvo' => '0',
  2471. 'o_pms_flasher' => '0',
  2472. );
  2473. while (list($conf_name, $conf_value) = @each($config))
  2474. {
  2475. if (!array_key_exists($conf_name, $pun_config))
  2476. $db->query('INSERT INTO '.$db->prefix."config (conf_name, conf_value) VALUES('$conf_name', $conf_value)")
  2477. or error('Unable to insert into table '.$db->prefix.'config. Please check your configuration and try again.');
  2478. }
  2479. // Delete all .php files in the cache (someone might have visited the forums while we were updating and thus, generated incorrect cache files)
  2480. forum_clear_cache();
  2481. } //End install_npms().
  2482. /**
  2483. * Installs the database for the attachements.
  2484. */
  2485. function install_attach($basepath='')
  2486. {
  2487. global $db, $db_type, $pun_config, $mod_version;
  2488. //include PUN_ROOT.'include/attach/attach_incl.php';
  2489. //first check so that the path seems reasonable
  2490. if(!((substr($basepath,0,1) == '/' || substr($basepath,1,1) == ':') && substr($basepath,-1) == '/'))
  2491. error('The pathname specified doesn\'t comply with the rules set. Go back and make sure that it\'s the complete path, and that it ends with a slash and that it either start with a slash (example: "/home/username/attachments/", on *nix servers (unix, linux, bsd, solaris etc.)) or a driveletter (example: "C:/webpages/attachments/" on windows servers)');
  2492. // create the files table
  2493. $schema_files = array(
  2494. 'FIELDS' => array(
  2495. 'id' => array(
  2496. 'datatype' => 'SERIAL',
  2497. 'allow_null' => false
  2498. ),
  2499. 'owner' => array(
  2500. 'datatype' => 'INT(10)',
  2501. 'allow_null' => false,
  2502. 'default' => '0'
  2503. ),
  2504. 'post_id' => array(
  2505. 'datatype' => 'INT(10)',
  2506. 'allow_null' => false,
  2507. 'default' => '0'
  2508. ),
  2509. 'filename' => array(
  2510. 'datatype' => 'VARCHAR(255)',
  2511. 'allow_null' => false,
  2512. ),
  2513. 'extension' => array(
  2514. 'datatype' => 'VARCHAR(64)',
  2515. 'allow_null' => false,
  2516. ),
  2517. 'mime' => array(
  2518. 'datatype' => 'VARCHAR(64)',
  2519. 'allow_null' => false
  2520. ),
  2521. 'location' => array(
  2522. 'datatype' => 'TEXT',
  2523. 'allow_null' => false
  2524. ),
  2525. 'size' => array(
  2526. 'datatype' => 'INT(10)',
  2527. 'allow_null' => false,
  2528. 'default' => '0'
  2529. ),
  2530. 'downloads' => array(
  2531. 'datatype' => 'INT(10)',
  2532. 'allow_null' => false,
  2533. 'default' => '0'
  2534. )
  2535. ),
  2536. 'PRIMARY KEY' => array('id'),
  2537. );
  2538. $db->create_table('attach_2_files', $schema_files) or error('Unable to create table "attach_2_files"', __FILE__, __LINE__, $db->error());
  2539. // create the files table
  2540. $schema_rules = array(
  2541. 'FIELDS' => array(
  2542. 'id' => array(
  2543. 'datatype' => 'SERIAL',
  2544. 'allow_null' => false
  2545. ),
  2546. 'forum_id' => array(
  2547. 'datatype' => 'INT(10)',
  2548. 'allow_null' => false,
  2549. 'default' => '0'
  2550. ),
  2551. 'group_id' => array(
  2552. 'datatype' => 'INT(10)',
  2553. 'allow_null' => false,
  2554. 'default' => '0'
  2555. ),
  2556. 'rules' => array(
  2557. 'datatype' => 'INT(10)',
  2558. 'allow_null' => false,
  2559. 'default' => '0'
  2560. ),
  2561. 'size' => array(
  2562. 'datatype' => 'INT(10)',
  2563. 'allow_null' => false,
  2564. 'default' => '0'
  2565. ),
  2566. 'per_post' => array(
  2567. 'datatype' => 'TINYINT(4)',
  2568. 'allow_null' => false,
  2569. 'default' => '1'
  2570. ),
  2571. 'file_ext' => array(
  2572. 'datatype' => 'TEXT',
  2573. 'allow_null' => false
  2574. ),
  2575. ),
  2576. 'PRIMARY KEY' => array('id'),
  2577. );
  2578. $db->create_table('attach_2_rules', $schema_rules) or error('Unable to create table "attach_2_rules"', __FILE__, __LINE__, $db->error());
  2579. //ok path could be correct, try to make a subfolder :D
  2580. $newname = attach_generate_pathname($basepath);
  2581. if(!attach_create_subfolder($newname,$basepath))
  2582. error('Unable to create new subfolder with name "'.$newname.'", make sure php has write access to that folder!',__FILE__,__LINE__);
  2583. // ok, add the stuff needed in the config cache
  2584. $attach_config = array( 'attach_always_deny' => 'html"htm"php"php3"php4"php5"exe"com"bat',
  2585. 'attach_basefolder' => $basepath,
  2586. 'attach_create_orphans' => '1',
  2587. 'attach_cur_version' => $mod_version,
  2588. 'attach_icon_folder' => 'img/attach/',
  2589. 'attach_icon_extension' => 'txt"log"doc"pdf"wav"mp3"ogg"avi"mpg"mpeg"png"jpg"jpeg"gif"zip"rar"7z"gz"tar',
  2590. 'attach_icon_name' => 'text.png"text.png"doc.png"doc.png"audio.png"audio.png"audio.png"video.png"video.png"video.png"image.png"image.png"image.png"image.png"compress.png"compress.png"compress.png"compress.png"compress.png',
  2591. 'attach_max_size' => '100000',
  2592. 'attach_subfolder' => $newname,
  2593. 'attach_use_icon' => '1');
  2594. foreach($attach_config AS $key => $value)
  2595. $db->query("INSERT INTO ".$db->prefix."config (conf_name, conf_value) VALUES ('$key', '".$db->escape($value)."')") or error('Unable to add column "'.$key.'" to config table', __FILE__, __LINE__, $db->error());
  2596. // and now, update the cache...
  2597. require_once PUN_ROOT.'include/cache.php';
  2598. generate_config_cache();
  2599. } //End install_attach()
  2600. function attach_create_subfolder($newfolder='',$basepath){
  2601. // check to see if that folder is there already, then just update the config ...
  2602. if(!is_dir($basepath.$newfolder)){
  2603. // if the folder doesn't exist, try to create it
  2604. if(!mkdir($basepath.$newfolder,0775))
  2605. error('Unable to create new subfolder with name \''.$basepath.$newfolder.'\' with mode 0755',__FILE__,__LINE__);
  2606. // create a .htaccess and index.html file in the new subfolder
  2607. if(!copy($basepath.'.htaccess', $basepath.$newfolder.'/.htaccess'))
  2608. error('Unable to copy .htaccess file to new subfolder with name \''.$basepath.$newfolder.'\'',__FILE__,__LINE__);
  2609. if(!copy($basepath.'index.html', $basepath.$newfolder.'/index.html'))
  2610. error('Unable to copy index.html file to new subfolder with name \''.$basepath.$newfolder.'\'',__FILE__,__LINE__);
  2611. // if the folder was created continue
  2612. }
  2613. // return true if everything has gone as planned, return false if the new folder could not be created (rights etc?)
  2614. return true;
  2615. }
  2616. function attach_generate_pathname($storagepath=''){
  2617. if(strlen($storagepath)!=0){
  2618. //we have to check so that path doesn't exist already...
  2619. $not_unique=true;
  2620. while($not_unique){
  2621. $newdir = attach_generate_pathname();
  2622. if(!is_dir($storagepath.$newdir))return $newdir;
  2623. }
  2624. }else
  2625. return substr(md5(time().'54ÂŁ7 k3yw0rd, r3pl4ce |f U w4nt t0'),0,32);
  2626. }
  2627. function attach_generate_filename($storagepath, $messagelenght=0, $filesize=0){
  2628. $not_unique=true;
  2629. while($not_unique){
  2630. $newfile = md5(attach_generate_pathname().$messagelenght.$filesize.'Some more salt keyworbs, change if you want to').'.attach';
  2631. if(!is_file($storagepath.$newfile))return $newfile;
  2632. }
  2633. }
  2634. /**
  2635. * Installs the table for RSS feed support.
  2636. */
  2637. function install_feed() {
  2638. global $db;
  2639. $db->query('CREATE TABLE '.$db->prefix.'feeds ( url varchar(255) NOT NULL default \'\', max int(11) NOT NULL default 0, closed tinyint(1) NOT NULL default 0, forum_id int(11) NOT NULL default 0, last_post INT(10) NOT NULL default 0, num_posts INT(10) NOT NULL default 0, PRIMARY KEY (url) )' );
  2640. } //End install_feed().
  2641. /**
  2642. * Installs the tables for poll support.
  2643. */
  2644. function install_poll()
  2645. {
  2646. global $db, $db_type, $pun_config;
  2647. $db->add_field('topics', 'poll_type', 'TINYINT(4)', false, 0) or error('Unable to add poll_type field', __FILE__, __LINE__, $db->error());
  2648. $db->add_field('topics', 'poll_time', 'INT(10) UNSIGNED', false, 0) or error('Unable to add poll_time field', __FILE__, __LINE__, $db->error());
  2649. $db->add_field('topics', 'poll_term', 'TINYINT(4)', false, 0) or error('Unable to add poll_term field', __FILE__, __LINE__, $db->error());
  2650. $db->add_field('topics', 'poll_kol', 'INT(10) UNSIGNED', false, 0) or error('Unable to add poll_kol field', __FILE__, __LINE__, $db->error());
  2651. $schema = array(
  2652. 'FIELDS' => array(
  2653. 'tid' => array(
  2654. 'datatype' => 'INT(10) UNSIGNED',
  2655. 'allow_null' => false,
  2656. 'default' => '0'
  2657. ),
  2658. 'question' => array(
  2659. 'datatype' => 'TINYINT(4)',
  2660. 'allow_null' => false,
  2661. 'default' => '0'
  2662. ),
  2663. 'field' => array(
  2664. 'datatype' => 'TINYINT(4)',
  2665. 'allow_null' => false,
  2666. 'default' => '0'
  2667. ),
  2668. 'choice' => array(
  2669. 'datatype' => 'VARCHAR(255)',
  2670. 'allow_null' => false,
  2671. 'default' => '\'\''
  2672. ),
  2673. 'votes' => array(
  2674. 'datatype' => 'INT(10) UNSIGNED',
  2675. 'allow_null' => false,
  2676. 'default' => '0'
  2677. )
  2678. ),
  2679. 'PRIMARY KEY' => array('tid', 'question', 'field')
  2680. );
  2681. $db->create_table('poll', $schema) or error('Unable to create table poll', __FILE__, __LINE__, $db->error());
  2682. $schema = array(
  2683. 'FIELDS' => array(
  2684. 'tid' => array(
  2685. 'datatype' => 'INT(10) UNSIGNED',
  2686. 'allow_null' => false
  2687. ),
  2688. 'uid' => array(
  2689. 'datatype' => 'INT(10) UNSIGNED',
  2690. 'allow_null' => false
  2691. ),
  2692. 'rez' => array(
  2693. 'datatype' => 'TEXT',
  2694. 'allow_null' => true
  2695. )
  2696. ),
  2697. 'PRIMARY KEY' => array('tid', 'uid')
  2698. );
  2699. $db->create_table('poll_voted', $schema) or error('Unable to create table poll_voted', __FILE__, __LINE__, $db->error());
  2700. // Insert config data
  2701. $config = array(
  2702. 'o_poll_enabled' => "'0'",
  2703. 'o_poll_max_ques' => "'3'",
  2704. 'o_poll_max_field' => "'20'",
  2705. 'o_poll_time' => "'60'",
  2706. 'o_poll_term' => "'3'",
  2707. 'o_poll_guest' => "'0'",
  2708. );
  2709. while (list($conf_name, $conf_value) = @each($config))
  2710. {
  2711. $db->query('INSERT INTO '.$db->prefix."config (conf_name, conf_value) VALUES('$conf_name', $conf_value)")
  2712. or error('Unable to insert into table '.$db->prefix.'config. Please check your configuration and try again.');
  2713. }
  2714. forum_clear_cache();
  2715. }