Advertisement
Guest User

adaur

a guest
Aug 29th, 2010
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 58.50 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * Copyright (C) 2008-2010 FluxBB
  5.  * based on code by Rickard Andersson copyright (C) 2002-2008 PunBB
  6.  * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
  7.  * Localized by adaur
  8.  */
  9.  
  10. // The FluxBB version this script installs
  11. define('FORUM_VERSION', '1.4.2');
  12.  
  13. define('FORUM_DB_REVISION', 8);
  14. define('FORUM_SI_REVISION', 1);
  15. define('FORUM_PARSER_REVISION', 1);
  16.  
  17. define('MIN_PHP_VERSION', '4.3.0');
  18. define('MIN_MYSQL_VERSION', '4.1.2');
  19. define('MIN_PGSQL_VERSION', '7.0.0');
  20. define('PUN_SEARCH_MIN_WORD', 3);
  21. define('PUN_SEARCH_MAX_WORD', 20);
  22.  
  23. define('PUN_ROOT', './');
  24.  
  25. // We try to get the admin's language
  26. $language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
  27. $language = $language{0}.$language{1};
  28.  
  29. // Load the install.php language file - maybe this could be improved?
  30. if ($language == 'en' && file_exists(PUN_ROOT.'lang/English/install.php'))
  31. {
  32.     require PUN_ROOT.'lang/English/install.php';
  33.     $defaut_language = 'English';
  34. }
  35. elseif ($language == 'fr' && file_exists(PUN_ROOT.'lang/French/install.php'))
  36. {
  37.     require PUN_ROOT.'lang/French/install.php';
  38.     $defaut_language = 'French';
  39. }
  40. elseif ($language == 'ru' && file_exists(PUN_ROOT.'lang/Russian/install.php'))
  41. {
  42.     require PUN_ROOT.'lang/Russian/install.php';
  43.     $defaut_language = 'Russian';
  44. }
  45. elseif ($language == 'de' && file_exists(PUN_ROOT.'lang/German/install.php'))
  46. {
  47.     require PUN_ROOT.'lang/German/install.php';
  48.     $defaut_language = 'German';
  49. }
  50. else
  51. {
  52.     require PUN_ROOT.'lang/English/install.php';
  53.     $defaut_language = 'English';
  54. }
  55.  
  56. if (file_exists(PUN_ROOT.'config.php'))
  57. {
  58.     // Check to see whether FluxBB is already installed
  59.     include PUN_ROOT.'config.php';
  60.  
  61.     // 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
  62.     if (defined('FORUM'))
  63.         define('PUN', FORUM);
  64.  
  65.     // If PUN is defined, config.php is probably valid and thus the software is installed
  66.     if (defined('PUN'))
  67.         exit($lang_install['Already installed']);
  68. }
  69.  
  70. // Define PUN because email.php requires it
  71. define('PUN', 1);
  72.  
  73. // Make sure we are running at least MIN_PHP_VERSION
  74. if (!function_exists('version_compare') || version_compare(PHP_VERSION, MIN_PHP_VERSION, '<'))
  75.     exit($lang_install['You are running'].PHP_VERSION.'. FluxBB '.FORUM_VERSION.' '.$lang_install['Requires at least'].' '.MIN_PHP_VERSION.' '.$lang_install['Upgrade']);
  76.  
  77. // Load the functions script
  78. require PUN_ROOT.'include/functions.php';
  79.  
  80. // Load UTF-8 functions
  81. require PUN_ROOT.'include/utf8/utf8.php';
  82.  
  83. // Strip out "bad" UTF-8 characters
  84. forum_remove_bad_characters();
  85.  
  86. // Reverse the effect of register_globals
  87. forum_unregister_globals();
  88.  
  89. // Disable error reporting for uninitialized variables
  90. error_reporting(E_ALL);
  91.  
  92. // Force POSIX locale (to prevent functions such as strtolower() from messing up UTF-8 strings)
  93. setlocale(LC_CTYPE, 'C');
  94.  
  95. // Turn off magic_quotes_runtime
  96. if (get_magic_quotes_runtime())
  97.     set_magic_quotes_runtime(0);
  98.  
  99. // Strip slashes from GET/POST/COOKIE (if magic_quotes_gpc is enabled)
  100. if (get_magic_quotes_gpc())
  101. {
  102.     function stripslashes_array($array)
  103.     {
  104.         return is_array($array) ? array_map('stripslashes_array', $array) : stripslashes($array);
  105.     }
  106.  
  107.     $_GET = stripslashes_array($_GET);
  108.     $_POST = stripslashes_array($_POST);
  109.     $_COOKIE = stripslashes_array($_COOKIE);
  110.     $_REQUEST = stripslashes_array($_REQUEST);
  111. }
  112.  
  113. // Turn off PHP time limit
  114. @set_time_limit(0);
  115.  
  116. //
  117. // Generate output to be used for config.php
  118. //
  119. function generate_config_file()
  120. {
  121.     global $db_type, $db_host, $db_name, $db_username, $db_password1, $db_prefix, $cookie_name, $cookie_seed;
  122.  
  123.     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_password1)."';\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";
  124. }
  125.  
  126.  
  127. if (isset($_POST['generate_config']))
  128. {
  129.     header('Content-Type: text/x-delimtext; name="config.php"');
  130.     header('Content-disposition: attachment; filename=config.php');
  131.  
  132.     $db_type = $_POST['db_type'];
  133.     $db_host = $_POST['db_host'];
  134.     $db_name = $_POST['db_name'];
  135.     $db_username = $_POST['db_username'];
  136.     $db_password1 = $_POST['db_password1'];
  137.     $db_prefix = $_POST['db_prefix'];
  138.     $cookie_name = $_POST['cookie_name'];
  139.     $cookie_seed = $_POST['cookie_seed'];
  140.  
  141.     echo generate_config_file();
  142.     exit;
  143. }
  144.  
  145.  
  146. if (!isset($_POST['form_sent']))
  147. {
  148.     // Make an educated guess regarding base_url
  149.     $base_url  = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';  // protocol
  150.     $base_url .= preg_replace('/:(80|443)$/', '', $_SERVER['HTTP_HOST']);                           // host[:port]
  151.     $base_url .= str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']));                          // path
  152.  
  153.     if (substr($base_url, -1) == '/')
  154.         $base_url = substr($base_url, 0, -1);
  155.  
  156.     $db_type = $db_name = $db_username = $db_prefix = $username = $email = '';
  157.     $db_host = 'localhost';
  158.     $title = $lang_install['My FluxBB Forum'];
  159.     $description = '<p><span>'.$lang_install['Description'].'</span></p>';
  160.     $default_lang = $defaut_language;
  161.     $default_style = 'Air';
  162. }
  163. else
  164. {
  165.     $db_type = $_POST['req_db_type'];
  166.     $db_host = pun_trim($_POST['req_db_host']);
  167.     $db_name = pun_trim($_POST['req_db_name']);
  168.     $db_username = pun_trim($_POST['db_username']);
  169.     $db_password1 = pun_trim($_POST['db_password1']);
  170.     $db_password2 = pun_trim($_POST['db_password2']);
  171.     $db_prefix = pun_trim($_POST['db_prefix']);
  172.     $username = pun_trim($_POST['req_username']);
  173.     $email = strtolower(pun_trim($_POST['req_email']));
  174.     $password1 = pun_trim($_POST['req_password1']);
  175.     $password2 = pun_trim($_POST['req_password2']);
  176.     $title = pun_trim($_POST['req_title']);
  177.     $description = pun_trim($_POST['desc']);
  178.     $base_url = pun_trim($_POST['req_base_url']);
  179.     $default_lang = pun_trim($_POST['req_default_lang']);
  180.     $default_style = pun_trim($_POST['req_default_style']);
  181.     $alerts = array();
  182.  
  183.     // Make sure base_url doesn't end with a slash
  184.     if (substr($base_url, -1) == '/')
  185.         $base_url = substr($base_url, 0, -1);
  186.  
  187.     // Validate database password
  188.     if ($db_password1 != $db_password2)
  189.         $alerts[] = $lang_install['Database wrong password'];
  190.  
  191.     // Validate username and passwords
  192.     if (pun_strlen($username) < 2)
  193.         $alerts[] = $lang_install['Username 1'];
  194.     else if (pun_strlen($username) > 25) // This usually doesn't happen since the form element only accepts 25 characters
  195.         $alerts[] = $lang_install['Username 2'];
  196.     else if (!strcasecmp($username, 'Guest'))
  197.         $alerts[] = $lang_install['Username 3'];
  198.     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))
  199.         $alerts[] = $lang_install['Username 4'];
  200.     else if ((strpos($username, '[') !== false || strpos($username, ']') !== false) && strpos($username, '\'') !== false && strpos($username, '"') !== false)
  201.         $alerts[] = $lang_install['Username 5'];
  202.     else if (preg_match('/(?:\[\/?(?:b|u|i|h|colou?r|quote|code|img|url|email|list)\]|\[(?:code|quote|list)=)/i', $username))
  203.         $alerts[] = $lang_install['Username 6'];
  204.  
  205.     if (pun_strlen($password1) < 4)
  206.         $alerts[] = $lang_install['Short password'];
  207.     else if ($password1 != $password2)
  208.         $alerts[] = $lang_install['Passwords not match'];
  209.  
  210.     // Validate email
  211.     require PUN_ROOT.'include/email.php';
  212.  
  213.     if (!is_valid_email($email))
  214.         $alerts[] = $lang_install['Wrong mail'];
  215.  
  216.     if ($title == '')
  217.         $alerts[] = $lang_install['No board title'];
  218.  
  219.     $default_lang = preg_replace('#[\.\\\/]#', '', $default_lang);
  220.     if (!file_exists(PUN_ROOT.'lang/'.$default_lang.'/common.php'))
  221.         $alerts[] = $lang_install['Error default language'];
  222.  
  223.     $default_style = preg_replace('#[\.\\\/]#', '', $default_style);
  224.     if (!file_exists(PUN_ROOT.'style/'.$default_style.'.css'))
  225.         $alerts[] = $lang_install['Error default style'];
  226. }
  227.  
  228. if (!isset($_POST['form_sent']) || !empty($alerts))
  229. {
  230.     // Determine available database extensions
  231.     $dual_mysql = false;
  232.     $db_extensions = array();
  233.     $mysql_innodb = false;
  234.     if (function_exists('mysqli_connect'))
  235.     {
  236.         $db_extensions[] = array('mysqli', 'MySQL Improved');
  237.         $db_extensions[] = array('mysqli_innodb', 'MySQL Improved (InnoDB)');
  238.         $mysql_innodb = true;
  239.     }
  240.     if (function_exists('mysql_connect'))
  241.     {
  242.         $db_extensions[] = array('mysql', 'MySQL Standard');
  243.         $db_extensions[] = array('mysql_innodb', 'MySQL Standard (InnoDB)');
  244.         $mysql_innodb = true;
  245.  
  246.         if (count($db_extensions) > 2)
  247.             $dual_mysql = true;
  248.     }
  249.     if (function_exists('sqlite_open'))
  250.         $db_extensions[] = array('sqlite', 'SQLite');
  251.     if (function_exists('pg_connect'))
  252.         $db_extensions[] = array('pgsql', 'PostgreSQL');
  253.  
  254.     if (empty($db_extensions))
  255.         exit($lang_install['No DB extensions']);
  256.  
  257. ?>
  258. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  259.  
  260. <html>
  261. <head>
  262. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  263. <title><?php echo $lang_install['FluxBB Installation'] ?></title>
  264. <link rel="stylesheet" type="text/css" href="style/<?php echo $default_style ?>.css" />
  265. <script type="text/javascript">
  266. function process_form(the_form)
  267. {
  268.     var element_names = new Object()
  269.     element_names["req_db_type"] = "<?php echo $lang_install['Database type'] ?>"
  270.     element_names["req_db_host"] = "<?php echo $lang_install['Database server hostname'] ?>"
  271.     element_names["req_db_name"] = "<?php echo $lang_install['Database name'] ?>"
  272.     element_names["db_prefix"] = "<?php echo $lang_install['Table prefix'] ?>"
  273.     element_names["req_username"] = "<?php echo $lang_install['Administrator username'] ?>"
  274.     element_names["req_password1"] = "<?php echo $lang_install['Administrator password 1'] ?>"
  275.     element_names["req_password2"] = "<?php echo $lang_install['Administrator password 2'] ?>"
  276.     element_names["req_email"] = "<?php echo $lang_install['Administrator email'] ?>"
  277.     element_names["req_title"] = "<?php echo $lang_install['Board title'] ?>"
  278.     element_names["req_base_url"] = "<?php echo $lang_install['Base URL'] ?>"
  279.  
  280.     if (document.all || document.getElementById)
  281.     {
  282.         for (var i = 0; i < the_form.length; ++i)
  283.         {
  284.             var elem = the_form.elements[i]
  285.             if (elem.name && elem.name.substring(0, 4) == "req_")
  286.             {
  287.                 if (elem.type && (elem.type=="text" || elem.type=="textarea" || elem.type=="password" || elem.type=="file") && elem.value=='')
  288.                 {
  289.                     alert("\"" + element_names[elem.name] + "\" <?php echo $lang_install['Required field'] ?>")
  290.                     elem.focus()
  291.                     return false
  292.                 }
  293.             }
  294.         }
  295.     }
  296.  
  297.     return true
  298. }
  299. </script>
  300. </head>
  301. <body onload="document.getElementById('install').req_db_type.focus();document.getElementById('install').start.disabled=false;">
  302.  
  303. <div id="puninstall" class="pun">
  304. <div class="top-box"><div><!-- Top Corners --></div></div>
  305. <div class="punwrap">
  306.  
  307. <div id="brdheader" class="block">
  308.     <div class="box">
  309.         <div id="brdtitle" class="inbox">
  310.             <h1><span><?php echo $lang_install['FluxBB Installation'] ?></span></h1>
  311.             <div id="brddesc"><p><?php echo $lang_install['Welcome'] ?></p></div>
  312.         </div>
  313.     </div>
  314. </div>
  315.  
  316. <div id="brdmain">
  317. <div class="blockform">
  318.     <h2><span><?php echo $lang_install['Install'] ?></span></h2>
  319.     <div class="box">
  320.         <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;}">
  321.         <div><input type="hidden" name="form_sent" value="1" /></div>
  322.             <div class="inform">
  323. <?php if (!empty($alerts)): ?>              <div class="forminfo error-info">
  324.                     <h3><?php echo $lang_install['Errors'] ?></h3>
  325.                     <ul class="error-list">
  326. <?php
  327.  
  328. foreach ($alerts as $cur_alert)
  329.     echo "\t\t\t\t\t\t".'<li><strong>'.$cur_alert.'</strong></li>'."\n";
  330. ?>
  331.                     </ul>
  332.                 </div>
  333. <?php endif; ?>         </div>
  334.             <div class="inform">
  335.                 <div class="forminfo">
  336.                     <h3><?php echo $lang_install['Database setup'] ?></h3>
  337.                     <p><?php echo $lang_install['Info 1'] ?></p>
  338.                 </div>
  339.                 <fieldset>
  340.                 <legend><?php echo $lang_install['Select database'] ?></legend>
  341.                     <div class="infldset">
  342.                         <p><?php echo $lang_install['Info 2'] ?></p>
  343. <?php if ($dual_mysql): ?>                      <p><?php echo $lang_install['Dual MySQL'] ?></p>
  344. <?php endif; ?><?php if ($mysql_innodb): ?>                     <p><?php echo $lang_install['InnoDB'] ?></p>
  345. <?php endif; ?>                     <label class="required"><strong><?php echo $lang_install['Database type'] ?> <span><?php echo $lang_install['Required'] ?></span></strong>
  346.                         <br /><select name="req_db_type">
  347. <?php
  348.  
  349.     foreach ($db_extensions as $temp)
  350.     {
  351.         if ($temp[0] == $db_type)
  352.             echo "\t\t\t\t\t\t\t".'<option value="'.$temp[0].'" selected="selected">'.$temp[1].'</option>'."\n";
  353.         else
  354.             echo "\t\t\t\t\t\t\t".'<option value="'.$temp[0].'">'.$temp[1].'</option>'."\n";
  355.     }
  356.  
  357. ?>
  358.                         </select>
  359.                         <br /></label>
  360.                     </div>
  361.                 </fieldset>
  362.             </div>
  363.             <div class="inform">
  364.                 <fieldset>
  365.                     <legend><?php echo $lang_install['Database hostname'] ?></legend>
  366.                     <div class="infldset">
  367.                         <p><?php echo $lang_install['Info 3'] ?></p>
  368.                         <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" maxlength="100" /><br /></label>
  369.                     </div>
  370.                 </fieldset>
  371.             </div>
  372.             <div class="inform">
  373.                 <fieldset>
  374.                     <legend><?php echo $lang_install['Database enter name'] ?></legend>
  375.                     <div class="infldset">
  376.                         <p><?php echo $lang_install['Info 4'] ?></p>
  377.                         <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" maxlength="50" /><br /></label>
  378.                     </div>
  379.                 </fieldset>
  380.             </div>
  381.             <div class="inform">
  382.                 <fieldset>
  383.                     <legend><?php echo $lang_install['Database enter informations'] ?></legend>
  384.                     <div class="infldset">
  385.                         <p><?php echo $lang_install['Info 5'] ?></p>
  386.                         <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" maxlength="50" /><br /></label>
  387.                         <label class="conl"><?php echo $lang_install['Database password'] ?><br /><input type="password" name="db_password1" size="30" maxlength="50" /><br /></label>
  388.                         <label class="conl"><?php echo $lang_install['Database confirm password'] ?><br /><input type="password" name="db_password2" size="30" maxlength="50" /><br /></label>
  389.                         <div class="clearer"></div>
  390.                     </div>
  391.                 </fieldset>
  392.             </div>
  393.             <div class="inform">
  394.                 <fieldset>
  395.                     <legend><?php echo $lang_install['Database enter prefix'] ?></legend>
  396.                     <div class="infldset">
  397.                         <p><?php echo $lang_install['Info 6'] ?></p>
  398.                         <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>
  399.                     </div>
  400.                 </fieldset>
  401.             </div>
  402.             <div class="inform">
  403.                 <div class="forminfo">
  404.                     <h3><?php echo $lang_install['Administration setup'] ?></h3>
  405.                     <p><?php echo $lang_install['Info 7'] ?></p>
  406.                 </div>
  407.                 <fieldset>
  408.                     <legend><?php echo $lang_install['Admin enter username'] ?></legend>
  409.                     <div class="infldset">
  410.                         <p><?php echo $lang_install['Info 8'] ?></p>
  411.                         <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>
  412.                     </div>
  413.                 </fieldset>
  414.             </div>
  415.             <div class="inform">
  416.                 <fieldset>
  417.                     <legend><?php echo $lang_install['Admin enter password'] ?></legend>
  418.                     <div class="infldset">
  419.                     <p><?php echo $lang_install['Info 9'] ?></p>
  420.                         <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>
  421.                         <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>
  422.                         <div class="clearer"></div>
  423.                     </div>
  424.                 </fieldset>
  425.             </div>
  426.             <div class="inform">
  427.                 <fieldset>
  428.                     <legend><?php echo $lang_install['Admin enter email'] ?></legend>
  429.                     <div class="infldset">
  430.                         <p><?php echo $lang_install['Info 10'] ?></p>
  431.                         <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>
  432.                     </div>
  433.                 </fieldset>
  434.             </div>
  435.             <div class="inform">
  436.                 <div class="forminfo">
  437.                     <h3><?php echo $lang_install['Board setup'] ?></h3>
  438.                     <p><?php echo $lang_install['Info 11'] ?></p>
  439.                 </div>
  440.                 <fieldset>
  441.                     <legend><?php echo $lang_install['Enter board title'] ?></legend>
  442.                     <div class="infldset">
  443.                         <p><?php echo $lang_install['Info 12'] ?></p>
  444.                         <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>
  445.                     </div>
  446.                 </fieldset>
  447.             </div>
  448.             <div class="inform">
  449.                 <fieldset>
  450.                     <legend><?php echo $lang_install['Enter board description'] ?></legend>
  451.                     <div class="infldset">
  452.                         <p><?php echo $lang_install['Info 13'] ?></p>
  453.                         <label><strong><?php echo $lang_install['Board description'] ?></strong><br /><input id="desc" type="text" name="desc" value="<?php echo pun_htmlspecialchars($description) ?>" size="60" maxlength="255" /><br /></label>
  454.                     </div>
  455.                 </fieldset>
  456.             </div>
  457.             <div class="inform">
  458.                 <fieldset>
  459.                     <legend><?php echo $lang_install['Enter base URL'] ?></legend>
  460.                     <div class="infldset">
  461.                         <p><?php echo $lang_install['Info 14'] ?></p>
  462.                         <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>
  463.                     </div>
  464.                 </fieldset>
  465.             </div>
  466.             <div class="inform">
  467.                 <fieldset>
  468.                     <legend><?php echo $lang_install['Choose the default language'] ?></legend>
  469.                     <div class="infldset">
  470.                         <p><?php echo $lang_install['Info 15'] ?></p>
  471.                         <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">
  472. <?php
  473.  
  474.         $languages = forum_list_langs();
  475.  
  476.         foreach ($languages as $temp)
  477.         {
  478.             if ($temp == $default_lang)
  479.                 echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.$temp.'</option>'."\n";
  480.             else
  481.                 echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.$temp.'</option>'."\n";
  482.         }
  483.  
  484. ?>
  485.                         </select><br /></label>
  486.                     </div>
  487.                 </fieldset>
  488.             </div>
  489.             <div class="inform">
  490.                 <fieldset>
  491.                     <legend><?php echo $lang_install['Choose the default style'] ?></legend>
  492.                     <div class="infldset">
  493.                         <p><?php echo $lang_install['Info 16'] ?></p>
  494.                         <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">
  495. <?php
  496.  
  497.         $styles = forum_list_styles();
  498.  
  499.         foreach ($styles as $temp)
  500.         {
  501.             if ($temp == $default_style)
  502.                 echo "\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.str_replace('_', ' ', $temp).'</option>'."\n";
  503.             else
  504.                 echo "\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.str_replace('_', ' ', $temp).'</option>'."\n";
  505.         }
  506.  
  507. ?>
  508.                         </select><br /></label>
  509.                     </div>
  510.                 </fieldset>
  511.             </div>
  512.             <p class="buttons"><input type="submit" name="start" value="<?php echo $lang_install['Start install'] ?>" /></p>
  513.         </form>
  514.     </div>
  515. </div>
  516. </div>
  517.  
  518. </div>
  519. <div class="end-box"><div><!-- Bottom Corners --></div></div>
  520. </div>
  521.  
  522. </body>
  523. </html>
  524. <?php
  525.  
  526. }
  527. else
  528. {
  529.     // Load the appropriate DB layer class
  530.     switch ($db_type)
  531.     {
  532.         case 'mysql':
  533.             require PUN_ROOT.'include/dblayer/mysql.php';
  534.             break;
  535.  
  536.         case 'mysql_innodb':
  537.             require PUN_ROOT.'include/dblayer/mysql_innodb.php';
  538.             break;
  539.  
  540.         case 'mysqli':
  541.             require PUN_ROOT.'include/dblayer/mysqli.php';
  542.             break;
  543.  
  544.         case 'mysqli_innodb':
  545.             require PUN_ROOT.'include/dblayer/mysqli_innodb.php';
  546.             break;
  547.  
  548.         case 'pgsql':
  549.             require PUN_ROOT.'include/dblayer/pgsql.php';
  550.             break;
  551.  
  552.         case 'sqlite':
  553.             require PUN_ROOT.'include/dblayer/sqlite.php';
  554.             break;
  555.  
  556.         default:
  557.             error('\''.pun_htmlspecialchars($db_type).'\''.$lang_install['DB type not valid']);
  558.     }
  559.  
  560.     // Create the database object (and connect/select db)
  561.     $db = new DBLayer($db_host, $db_username, $db_password1, $db_name, $db_prefix, false);
  562.  
  563.     // Validate prefix
  564.     if (strlen($db_prefix) > 0 && (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $db_prefix) || strlen($db_prefix) > 40))
  565.         error($lang_install['The table prefix'].'\''.$db->prefix.'\''.$lang_install['Error prefix']);
  566.  
  567.     // Do some DB type specific checks
  568.     switch ($db_type)
  569.     {
  570.         case 'mysql':
  571.         case 'mysqli':
  572.         case 'mysql_innodb':
  573.         case 'mysqli_innodb':
  574.             $mysql_info = $db->get_version();
  575.             if (version_compare($mysql_info['version'], MIN_MYSQL_VERSION, '<'))
  576.                 error($lang_install['You are running'].$mysql_version.'. FluxBB '.FORUM_VERSION.' '.$lang_install['Requires at least'].' '.MIN_MYSQL_VERSION.' '.$lang_install['Upgrade']);
  577.             break;
  578.  
  579.         case 'pgsql':
  580.             $pgsql_info = $db->get_version();
  581.             if (version_compare($pgsql_info['version'], MIN_PGSQL_VERSION, '<'))
  582.                 error($lang_install['You are running'].$pgsql_info.'. FluxBB '.FORUM_VERSION.' '.$lang_install['Requires at least'].' '.MIN_PGSQL_VERSION.' '.$lang_install['Upgrade']);
  583.             break;
  584.  
  585.         case 'sqlite':
  586.             if (strtolower($db_prefix) == 'sqlite_')
  587.                 error($lang_install['Prefix reserved']);
  588.             break;
  589.     }
  590.  
  591.  
  592.     // Make sure FluxBB isn't already installed
  593.     $result = $db->query('SELECT 1 FROM '.$db_prefix.'users WHERE id=1');
  594.     if ($db->num_rows($result))
  595.         error($lang_install['A table called 1'].$db_prefix.$lang_install['A table called 2'].$db_name.$lang_install['A table called 3']);
  596.  
  597.     // Check if InnoDB is available
  598.     if ($db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
  599.     {
  600.         $result = $db->query('SHOW VARIABLES LIKE \'have_innodb\'');
  601.         list (, $result) = $db->fetch_row($result);
  602.         if ((strtoupper($result) != 'YES'))
  603.             error($lang_install['InnoDB off']);
  604.     }
  605.  
  606.  
  607.     // Start a transaction
  608.     $db->start_transaction();
  609.  
  610.  
  611.     // Create all tables
  612.     $schema = array(
  613.         'FIELDS'        => array(
  614.             'id'            => array(
  615.                 'datatype'      => 'SERIAL',
  616.                 'allow_null'    => false
  617.             ),
  618.             'username'      => array(
  619.                 'datatype'      => 'VARCHAR(200)',
  620.                 'allow_null'    => true
  621.             ),
  622.             'ip'            => array(
  623.                 'datatype'      => 'VARCHAR(255)',
  624.                 'allow_null'    => true
  625.             ),
  626.             'email'         => array(
  627.                 'datatype'      => 'VARCHAR(80)',
  628.                 'allow_null'    => true
  629.             ),
  630.             'message'       => array(
  631.                 'datatype'      => 'VARCHAR(255)',
  632.                 'allow_null'    => true
  633.             ),
  634.             'expire'        => array(
  635.                 'datatype'      => 'INT(10) UNSIGNED',
  636.                 'allow_null'    => true
  637.             ),
  638.             'ban_creator'   => array(
  639.                 'datatype'      => 'INT(10) UNSIGNED',
  640.                 'allow_null'    => false,
  641.                 'default'       => '0'
  642.             )
  643.         ),
  644.         'PRIMARY KEY'   => array('id'),
  645.         'INDEXES'       => array(
  646.             'username_idx'  => array('username')
  647.         )
  648.     );
  649.  
  650.     if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
  651.         $schema['INDEXES']['username_idx'] = array('username(25)');
  652.  
  653.     $db->create_table('bans', $schema) or error('Unable to create bans table', __FILE__, __LINE__, $db->error());
  654.  
  655.  
  656.     $schema = array(
  657.         'FIELDS'        => array(
  658.             'id'            => array(
  659.                 'datatype'      => 'SERIAL',
  660.                 'allow_null'    => false
  661.             ),
  662.             'cat_name'      => array(
  663.                 'datatype'      => 'VARCHAR(80)',
  664.                 'allow_null'    => false,
  665.                 'default'       => '\'New Category\''
  666.             ),
  667.             'disp_position' => array(
  668.                 'datatype'      => 'INT(10)',
  669.                 'allow_null'    => false,
  670.                 'default'       => '0'
  671.             )
  672.         ),
  673.         'PRIMARY KEY'   => array('id')
  674.     );
  675.  
  676.     $db->create_table('categories', $schema) or error('Unable to create categories table', __FILE__, __LINE__, $db->error());
  677.  
  678.  
  679.     $schema = array(
  680.         'FIELDS'        => array(
  681.             'id'            => array(
  682.                 'datatype'      => 'SERIAL',
  683.                 'allow_null'    => false
  684.             ),
  685.             'search_for'    => array(
  686.                 'datatype'      => 'VARCHAR(60)',
  687.                 'allow_null'    => false,
  688.                 'default'       => '\'\''
  689.             ),
  690.             'replace_with'  => array(
  691.                 'datatype'      => 'VARCHAR(60)',
  692.                 'allow_null'    => false,
  693.                 'default'       => '\'\''
  694.             )
  695.         ),
  696.         'PRIMARY KEY'   => array('id')
  697.     );
  698.  
  699.     $db->create_table('censoring', $schema) or error('Unable to create censoring table', __FILE__, __LINE__, $db->error());
  700.  
  701.  
  702.     $schema = array(
  703.         'FIELDS'        => array(
  704.             'conf_name'     => array(
  705.                 'datatype'      => 'VARCHAR(255)',
  706.                 'allow_null'    => false,
  707.                 'default'       => '\'\''
  708.             ),
  709.             'conf_value'    => array(
  710.                 'datatype'      => 'TEXT',
  711.                 'allow_null'    => true
  712.             )
  713.         ),
  714.         'PRIMARY KEY'   => array('conf_name')
  715.     );
  716.  
  717.     $db->create_table('config', $schema) or error('Unable to create config table', __FILE__, __LINE__, $db->error());
  718.  
  719.  
  720.     $schema = array(
  721.         'FIELDS'        => array(
  722.             'group_id'      => array(
  723.                 'datatype'      => 'INT(10)',
  724.                 'allow_null'    => false,
  725.                 'default'       => '0'
  726.             ),
  727.             'forum_id'      => array(
  728.                 'datatype'      => 'INT(10)',
  729.                 'allow_null'    => false,
  730.                 'default'       => '0'
  731.             ),
  732.             'read_forum'    => array(
  733.                 'datatype'      => 'TINYINT(1)',
  734.                 'allow_null'    => false,
  735.                 'default'       => '1'
  736.             ),
  737.             'post_replies'  => array(
  738.                 'datatype'      => 'TINYINT(1)',
  739.                 'allow_null'    => false,
  740.                 'default'       => '1'
  741.             ),
  742.             'post_topics'   => array(
  743.                 'datatype'      => 'TINYINT(1)',
  744.                 'allow_null'    => false,
  745.                 'default'       => '1'
  746.             )
  747.         ),
  748.         'PRIMARY KEY'   => array('group_id', 'forum_id')
  749.     );
  750.  
  751.     $db->create_table('forum_perms', $schema) or error('Unable to create forum_perms table', __FILE__, __LINE__, $db->error());
  752.  
  753.  
  754.     $schema = array(
  755.         'FIELDS'        => array(
  756.             'id'            => array(
  757.                 'datatype'      => 'SERIAL',
  758.                 'allow_null'    => false
  759.             ),
  760.             'forum_name'    => array(
  761.                 'datatype'      => 'VARCHAR(80)',
  762.                 'allow_null'    => false,
  763.                 'default'       => '\'New forum\''
  764.             ),
  765.             'forum_desc'    => array(
  766.                 'datatype'      => 'TEXT',
  767.                 'allow_null'    => true
  768.             ),
  769.             'redirect_url'  => array(
  770.                 'datatype'      => 'VARCHAR(100)',
  771.                 'allow_null'    => true
  772.             ),
  773.             'moderators'    => array(
  774.                 'datatype'      => 'TEXT',
  775.                 'allow_null'    => true
  776.             ),
  777.             'num_topics'    => array(
  778.                 'datatype'      => 'MEDIUMINT(8) UNSIGNED',
  779.                 'allow_null'    => false,
  780.                 'default'       => '0'
  781.             ),
  782.             'num_posts'     => array(
  783.                 'datatype'      => 'MEDIUMINT(8) UNSIGNED',
  784.                 'allow_null'    => false,
  785.                 'default'       => '0'
  786.             ),
  787.             'last_post'     => array(
  788.                 'datatype'      => 'INT(10) UNSIGNED',
  789.                 'allow_null'    => true
  790.             ),
  791.             'last_post_id'  => array(
  792.                 'datatype'      => 'INT(10) UNSIGNED',
  793.                 'allow_null'    => true
  794.             ),
  795.             'last_poster'   => array(
  796.                 'datatype'      => 'VARCHAR(200)',
  797.                 'allow_null'    => true
  798.             ),
  799.             'sort_by'       => array(
  800.                 'datatype'      => 'TINYINT(1)',
  801.                 'allow_null'    => false,
  802.                 'default'       => '0'
  803.             ),
  804.             'disp_position' => array(
  805.                 'datatype'      => 'INT(10)',
  806.                 'allow_null'    => false,
  807.                 'default'       =>  '0'
  808.             ),
  809.             'cat_id'        => array(
  810.                 'datatype'      => 'INT(10) UNSIGNED',
  811.                 'allow_null'    => false,
  812.                 'default'       =>  '0'
  813.             )
  814.         ),
  815.         'PRIMARY KEY'   => array('id')
  816.     );
  817.  
  818.     $db->create_table('forums', $schema) or error('Unable to create forums table', __FILE__, __LINE__, $db->error());
  819.  
  820.  
  821.     $schema = array(
  822.         'FIELDS'        => array(
  823.             'g_id'                      => array(
  824.                 'datatype'      => 'SERIAL',
  825.                 'allow_null'    => false
  826.             ),
  827.             'g_title'                   => array(
  828.                 'datatype'      => 'VARCHAR(50)',
  829.                 'allow_null'    => false,
  830.                 'default'       => '\'\''
  831.             ),
  832.             'g_user_title'              => array(
  833.                 'datatype'      => 'VARCHAR(50)',
  834.                 'allow_null'    => true
  835.             ),
  836.             'g_moderator'               => array(
  837.                 'datatype'      => 'TINYINT(1)',
  838.                 'allow_null'    => false,
  839.                 'default'       => '0'
  840.             ),
  841.             'g_mod_edit_users'          => array(
  842.                 'datatype'      => 'TINYINT(1)',
  843.                 'allow_null'    => false,
  844.                 'default'       => '0'
  845.             ),
  846.             'g_mod_rename_users'        => array(
  847.                 'datatype'      => 'TINYINT(1)',
  848.                 'allow_null'    => false,
  849.                 'default'       => '0'
  850.             ),
  851.             'g_mod_change_passwords'    => array(
  852.                 'datatype'      => 'TINYINT(1)',
  853.                 'allow_null'    => false,
  854.                 'default'       => '0'
  855.             ),
  856.             'g_mod_ban_users'           => array(
  857.                 'datatype'      => 'TINYINT(1)',
  858.                 'allow_null'    => false,
  859.                 'default'       => '0'
  860.             ),
  861.             'g_read_board'              => array(
  862.                 'datatype'      => 'TINYINT(1)',
  863.                 'allow_null'    => false,
  864.                 'default'       => '1'
  865.             ),
  866.             'g_view_users'              => array(
  867.                 'datatype'      => 'TINYINT(1)',
  868.                 'allow_null'    => false,
  869.                 'default'       => '1'
  870.             ),
  871.             'g_post_replies'            => array(
  872.                 'datatype'      => 'TINYINT(1)',
  873.                 'allow_null'    => false,
  874.                 'default'       => '1'
  875.             ),
  876.             'g_post_topics'             => array(
  877.                 'datatype'      => 'TINYINT(1)',
  878.                 'allow_null'    => false,
  879.                 'default'       => '1'
  880.             ),
  881.             'g_edit_posts'              => array(
  882.                 'datatype'      => 'TINYINT(1)',
  883.                 'allow_null'    => false,
  884.                 'default'       => '1'
  885.             ),
  886.             'g_delete_posts'            => array(
  887.                 'datatype'      => 'TINYINT(1)',
  888.                 'allow_null'    => false,
  889.                 'default'       => '1'
  890.             ),
  891.             'g_delete_topics'           => array(
  892.                 'datatype'      => 'TINYINT(1)',
  893.                 'allow_null'    => false,
  894.                 'default'       => '1'
  895.             ),
  896.             'g_set_title'               => array(
  897.                 'datatype'      => 'TINYINT(1)',
  898.                 'allow_null'    => false,
  899.                 'default'       => '1'
  900.             ),
  901.             'g_search'                  => array(
  902.                 'datatype'      => 'TINYINT(1)',
  903.                 'allow_null'    => false,
  904.                 'default'       => '1'
  905.             ),
  906.             'g_search_users'            => array(
  907.                 'datatype'      => 'TINYINT(1)',
  908.                 'allow_null'    => false,
  909.                 'default'       => '1'
  910.             ),
  911.             'g_send_email'              => array(
  912.                 'datatype'      => 'TINYINT(1)',
  913.                 'allow_null'    => false,
  914.                 'default'       => '1'
  915.             ),
  916.             'g_post_flood'              => array(
  917.                 'datatype'      => 'SMALLINT(6)',
  918.                 'allow_null'    => false,
  919.                 'default'       => '30'
  920.             ),
  921.             'g_search_flood'            => array(
  922.                 'datatype'      => 'SMALLINT(6)',
  923.                 'allow_null'    => false,
  924.                 'default'       => '30'
  925.             ),
  926.             'g_email_flood'             => array(
  927.                 'datatype'      => 'SMALLINT(6)',
  928.                 'allow_null'    => false,
  929.                 'default'       => '60'
  930.             )
  931.         ),
  932.         'PRIMARY KEY'   => array('g_id')
  933.     );
  934.  
  935.     $db->create_table('groups', $schema) or error('Unable to create groups table', __FILE__, __LINE__, $db->error());
  936.  
  937.  
  938.     $schema = array(
  939.         'FIELDS'        => array(
  940.             'user_id'       => array(
  941.                 'datatype'      => 'INT(10) UNSIGNED',
  942.                 'allow_null'    => false,
  943.                 'default'       => '1'
  944.             ),
  945.             'ident'         => array(
  946.                 'datatype'      => 'VARCHAR(200)',
  947.                 'allow_null'    => false,
  948.                 'default'       => '\'\''
  949.             ),
  950.             'logged'        => array(
  951.                 'datatype'      => 'INT(10) UNSIGNED',
  952.                 'allow_null'    => false,
  953.                 'default'       => '0'
  954.             ),
  955.             'idle'          => array(
  956.                 'datatype'      => 'TINYINT(1)',
  957.                 'allow_null'    => false,
  958.                 'default'       => '0'
  959.             ),
  960.             'last_post'         => array(
  961.                 'datatype'      => 'INT(10) UNSIGNED',
  962.                 'allow_null'    => true
  963.             ),
  964.             'last_search'       => array(
  965.                 'datatype'      => 'INT(10) UNSIGNED',
  966.                 'allow_null'    => true
  967.             ),
  968.         ),
  969.         'UNIQUE KEYS'   => array(
  970.             'user_id_ident_idx' => array('user_id', 'ident')
  971.         ),
  972.         'INDEXES'       => array(
  973.             'ident_idx'     => array('ident'),
  974.             'logged_idx'    => array('logged')
  975.         ),
  976.         'ENGINE'        => 'HEAP'
  977.     );
  978.  
  979.     if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
  980.     {
  981.         $schema['UNIQUE KEYS']['user_id_ident_idx'] = array('user_id', 'ident(25)');
  982.         $schema['INDEXES']['ident_idx'] = array('ident(25)');
  983.     }
  984.  
  985.     if ($db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
  986.         $schema['ENGINE'] = 'InnoDB';
  987.  
  988.     $db->create_table('online', $schema) or error('Unable to create online table', __FILE__, __LINE__, $db->error());
  989.  
  990.  
  991.     $schema = array(
  992.         'FIELDS'        => array(
  993.             'id'            => array(
  994.                 'datatype'      => 'SERIAL',
  995.                 'allow_null'    => false
  996.             ),
  997.             'poster'        => array(
  998.                 'datatype'      => 'VARCHAR(200)',
  999.                 'allow_null'    => false,
  1000.                 'default'       => '\'\''
  1001.             ),
  1002.             'poster_id'     => array(
  1003.                 'datatype'      => 'INT(10) UNSIGNED',
  1004.                 'allow_null'    => false,
  1005.                 'default'       => '1'
  1006.             ),
  1007.             'poster_ip'     => array(
  1008.                 'datatype'      => 'VARCHAR(39)',
  1009.                 'allow_null'    => true
  1010.             ),
  1011.             'poster_email'  => array(
  1012.                 'datatype'      => 'VARCHAR(80)',
  1013.                 'allow_null'    => true
  1014.             ),
  1015.             'message'       => array(
  1016.                 'datatype'      => 'MEDIUMTEXT',
  1017.                 'allow_null'    => true
  1018.             ),
  1019.             'hide_smilies'  => array(
  1020.                 'datatype'      => 'TINYINT(1)',
  1021.                 'allow_null'    => false,
  1022.                 'default'       => '0'
  1023.             ),
  1024.             'posted'        => array(
  1025.                 'datatype'      => 'INT(10) UNSIGNED',
  1026.                 'allow_null'    => false,
  1027.                 'default'       => '0'
  1028.             ),
  1029.             'edited'        => array(
  1030.                 'datatype'      => 'INT(10) UNSIGNED',
  1031.                 'allow_null'    => true
  1032.             ),
  1033.             'edited_by'     => array(
  1034.                 'datatype'      => 'VARCHAR(200)',
  1035.                 'allow_null'    => true
  1036.             ),
  1037.             'topic_id'      => array(
  1038.                 'datatype'      => 'INT(10) UNSIGNED',
  1039.                 'allow_null'    => false,
  1040.                 'default'       => '0'
  1041.             )
  1042.         ),
  1043.         'PRIMARY KEY'   => array('id'),
  1044.         'INDEXES'       => array(
  1045.             'topic_id_idx'  => array('topic_id'),
  1046.             'multi_idx'     => array('poster_id', 'topic_id')
  1047.         )
  1048.     );
  1049.  
  1050.     $db->create_table('posts', $schema) or error('Unable to create posts table', __FILE__, __LINE__, $db->error());
  1051.  
  1052.  
  1053.     $schema = array(
  1054.         'FIELDS'        => array(
  1055.             'id'            => array(
  1056.                 'datatype'      => 'SERIAL',
  1057.                 'allow_null'    => false
  1058.             ),
  1059.             'rank'          => array(
  1060.                 'datatype'      => 'VARCHAR(50)',
  1061.                 'allow_null'    => false,
  1062.                 'default'       => '\'\''
  1063.             ),
  1064.             'min_posts'     => array(
  1065.                 'datatype'      => 'MEDIUMINT(8) UNSIGNED',
  1066.                 'allow_null'    => false,
  1067.                 'default'       => '0'
  1068.             )
  1069.         ),
  1070.         'PRIMARY KEY'   => array('id')
  1071.     );
  1072.  
  1073.     $db->create_table('ranks', $schema) or error('Unable to create ranks table', __FILE__, __LINE__, $db->error());
  1074.  
  1075.  
  1076.     $schema = array(
  1077.         'FIELDS'        => array(
  1078.             'id'            => array(
  1079.                 'datatype'      => 'SERIAL',
  1080.                 'allow_null'    => false
  1081.             ),
  1082.             'post_id'       => array(
  1083.                 'datatype'      => 'INT(10) UNSIGNED',
  1084.                 'allow_null'    => false,
  1085.                 'default'       => '0'
  1086.             ),
  1087.             'topic_id'      => array(
  1088.                 'datatype'      => 'INT(10) UNSIGNED',
  1089.                 'allow_null'    => false,
  1090.                 'default'       => '0'
  1091.             ),
  1092.             'forum_id'      => array(
  1093.                 'datatype'      => 'INT(10) UNSIGNED',
  1094.                 'allow_null'    => false,
  1095.                 'default'       => '0'
  1096.             ),
  1097.             'reported_by'   => array(
  1098.                 'datatype'      => 'INT(10) UNSIGNED',
  1099.                 'allow_null'    => false,
  1100.                 'default'       => '0'
  1101.             ),
  1102.             'created'       => array(
  1103.                 'datatype'      => 'INT(10) UNSIGNED',
  1104.                 'allow_null'    => false,
  1105.                 'default'       => '0'
  1106.             ),
  1107.             'message'       => array(
  1108.                 'datatype'      => 'TEXT',
  1109.                 'allow_null'    => true
  1110.             ),
  1111.             'zapped'        => array(
  1112.                 'datatype'      => 'INT(10) UNSIGNED',
  1113.                 'allow_null'    => true
  1114.             ),
  1115.             'zapped_by'     => array(
  1116.                 'datatype'      => 'INT(10) UNSIGNED',
  1117.                 'allow_null'    => true
  1118.             )
  1119.         ),
  1120.         'PRIMARY KEY'   => array('id'),
  1121.         'INDEXES'       => array(
  1122.             'zapped_idx'    => array('zapped')
  1123.         )
  1124.     );
  1125.  
  1126.     $db->create_table('reports', $schema) or error('Unable to create reports table', __FILE__, __LINE__, $db->error());
  1127.  
  1128.  
  1129.     $schema = array(
  1130.         'FIELDS'        => array(
  1131.             'id'            => array(
  1132.                 'datatype'      => 'INT(10) UNSIGNED',
  1133.                 'allow_null'    => false,
  1134.                 'default'       => '0'
  1135.             ),
  1136.             'ident'         => array(
  1137.                 'datatype'      => 'VARCHAR(200)',
  1138.                 'allow_null'    => false,
  1139.                 'default'       => '\'\''
  1140.             ),
  1141.             'search_data'   => array(
  1142.                 'datatype'      => 'MEDIUMTEXT',
  1143.                 'allow_null'    => true
  1144.             )
  1145.         ),
  1146.         'PRIMARY KEY'   => array('id'),
  1147.         'INDEXES'       => array(
  1148.             'ident_idx' => array('ident')
  1149.         )
  1150.     );
  1151.  
  1152.     if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
  1153.         $schema['INDEXES']['ident_idx'] = array('ident(8)');
  1154.  
  1155.     $db->create_table('search_cache', $schema) or error('Unable to create search_cache table', __FILE__, __LINE__, $db->error());
  1156.  
  1157.  
  1158.     $schema = array(
  1159.         'FIELDS'        => array(
  1160.             'post_id'       => array(
  1161.                 'datatype'      => 'INT(10) UNSIGNED',
  1162.                 'allow_null'    => false,
  1163.                 'default'       => '0'
  1164.             ),
  1165.             'word_id'       => array(
  1166.                 'datatype'      => 'INT(10) UNSIGNED',
  1167.                 'allow_null'    => false,
  1168.                 'default'       => '0'
  1169.             ),
  1170.             'subject_match' => array(
  1171.                 'datatype'      => 'TINYINT(1)',
  1172.                 'allow_null'    => false,
  1173.                 'default'       => '0'
  1174.             )
  1175.         ),
  1176.         'INDEXES'       => array(
  1177.             'word_id_idx'   => array('word_id'),
  1178.             'post_id_idx'   => array('post_id')
  1179.         )
  1180.     );
  1181.  
  1182.     $db->create_table('search_matches', $schema) or error('Unable to create search_matches table', __FILE__, __LINE__, $db->error());
  1183.  
  1184.  
  1185.     $schema = array(
  1186.         'FIELDS'        => array(
  1187.             'id'            => array(
  1188.                 'datatype'      => 'SERIAL',
  1189.                 'allow_null'    => false
  1190.             ),
  1191.             'word'          => array(
  1192.                 'datatype'      => 'VARCHAR(20)',
  1193.                 'allow_null'    => false,
  1194.                 'default'       => '\'\'',
  1195.                 'collation'     => 'bin'
  1196.             )
  1197.         ),
  1198.         'PRIMARY KEY'   => array('word'),
  1199.         'INDEXES'       => array(
  1200.             'id_idx'    => array('id')
  1201.         )
  1202.     );
  1203.  
  1204.     if ($db_type == 'sqlite')
  1205.     {
  1206.         $schema['PRIMARY KEY'] = array('id');
  1207.         $schema['UNIQUE KEYS'] = array('word_idx'   => array('word'));
  1208.     }
  1209.  
  1210.     $db->create_table('search_words', $schema) or error('Unable to create search_words table', __FILE__, __LINE__, $db->error());
  1211.  
  1212.  
  1213.     $schema = array(
  1214.         'FIELDS'        => array(
  1215.             'user_id'       => array(
  1216.                 'datatype'      => 'INT(10) UNSIGNED',
  1217.                 'allow_null'    => false,
  1218.                 'default'       => '0'
  1219.             ),
  1220.             'topic_id'      => array(
  1221.                 'datatype'      => 'INT(10) UNSIGNED',
  1222.                 'allow_null'    => false,
  1223.                 'default'       => '0'
  1224.             )
  1225.         ),
  1226.         'PRIMARY KEY'   => array('user_id', 'topic_id')
  1227.     );
  1228.  
  1229.     $db->create_table('subscriptions', $schema) or error('Unable to create subscriptions table', __FILE__, __LINE__, $db->error());
  1230.  
  1231.  
  1232.     $schema = array(
  1233.         'FIELDS'        => array(
  1234.             'id'            => array(
  1235.                 'datatype'      => 'SERIAL',
  1236.                 'allow_null'    => false
  1237.             ),
  1238.             'poster'        => array(
  1239.                 'datatype'      => 'VARCHAR(200)',
  1240.                 'allow_null'    => false,
  1241.                 'default'       => '\'\''
  1242.             ),
  1243.             'subject'       => array(
  1244.                 'datatype'      => 'VARCHAR(255)',
  1245.                 'allow_null'    => false,
  1246.                 'default'       => '\'\''
  1247.             ),
  1248.             'posted'        => array(
  1249.                 'datatype'      => 'INT(10) UNSIGNED',
  1250.                 'allow_null'    => false,
  1251.                 'default'       => '0'
  1252.             ),
  1253.             'first_post_id' => array(
  1254.                 'datatype'      => 'INT(10) UNSIGNED',
  1255.                 'allow_null'    => false,
  1256.                 'default'       => '0'
  1257.             ),
  1258.             'last_post'     => array(
  1259.                 'datatype'      => 'INT(10) UNSIGNED',
  1260.                 'allow_null'    => false,
  1261.                 'default'       => '0'
  1262.             ),
  1263.             'last_post_id'  => array(
  1264.                 'datatype'      => 'INT(10) UNSIGNED',
  1265.                 'allow_null'    => false,
  1266.                 'default'       => '0'
  1267.             ),
  1268.             'last_poster'   => array(
  1269.                 'datatype'      => 'VARCHAR(200)',
  1270.                 'allow_null'    => true
  1271.             ),
  1272.             'num_views'     => array(
  1273.                 'datatype'      => 'MEDIUMINT(8) UNSIGNED',
  1274.                 'allow_null'    => false,
  1275.                 'default'       => '0'
  1276.             ),
  1277.             'num_replies'   => array(
  1278.                 'datatype'      => 'MEDIUMINT(8) UNSIGNED',
  1279.                 'allow_null'    => false,
  1280.                 'default'       => '0'
  1281.             ),
  1282.             'closed'        => array(
  1283.                 'datatype'      => 'TINYINT(1)',
  1284.                 'allow_null'    => false,
  1285.                 'default'       => '0'
  1286.             ),
  1287.             'sticky'        => array(
  1288.                 'datatype'      => 'TINYINT(1)',
  1289.                 'allow_null'    => false,
  1290.                 'default'       => '0'
  1291.             ),
  1292.             'moved_to'      => array(
  1293.                 'datatype'      => 'INT(10) UNSIGNED',
  1294.                 'allow_null'    => true
  1295.             ),
  1296.             'forum_id'      => array(
  1297.                 'datatype'      => 'INT(10) UNSIGNED',
  1298.                 'allow_null'    => false,
  1299.                 'default'       => '0'
  1300.             )
  1301.         ),
  1302.         'PRIMARY KEY'   => array('id'),
  1303.         'INDEXES'       => array(
  1304.             'forum_id_idx'      => array('forum_id'),
  1305.             'moved_to_idx'      => array('moved_to'),
  1306.             'last_post_idx'     => array('last_post'),
  1307.             'first_post_id_idx' => array('first_post_id')
  1308.         )
  1309.     );
  1310.  
  1311.     $db->create_table('topics', $schema) or error('Unable to create topics table', __FILE__, __LINE__, $db->error());
  1312.  
  1313.  
  1314.     $schema = array(
  1315.         'FIELDS'        => array(
  1316.             'id'                => array(
  1317.                 'datatype'      => 'SERIAL',
  1318.                 'allow_null'    => false
  1319.             ),
  1320.             'group_id'          => array(
  1321.                 'datatype'      => 'INT(10) UNSIGNED',
  1322.                 'allow_null'    => false,
  1323.                 'default'       => '3'
  1324.             ),
  1325.             'username'          => array(
  1326.                 'datatype'      => 'VARCHAR(200)',
  1327.                 'allow_null'    => false,
  1328.                 'default'       => '\'\''
  1329.             ),
  1330.             'password'          => array(
  1331.                 'datatype'      => 'VARCHAR(40)',
  1332.                 'allow_null'    => false,
  1333.                 'default'       => '\'\''
  1334.             ),
  1335.             'email'             => array(
  1336.                 'datatype'      => 'VARCHAR(80)',
  1337.                 'allow_null'    => false,
  1338.                 'default'       => '\'\''
  1339.             ),
  1340.             'title'             => array(
  1341.                 'datatype'      => 'VARCHAR(50)',
  1342.                 'allow_null'    => true
  1343.             ),
  1344.             'realname'          => array(
  1345.                 'datatype'      => 'VARCHAR(40)',
  1346.                 'allow_null'    => true
  1347.             ),
  1348.             'url'               => array(
  1349.                 'datatype'      => 'VARCHAR(100)',
  1350.                 'allow_null'    => true
  1351.             ),
  1352.             'jabber'            => array(
  1353.                 'datatype'      => 'VARCHAR(80)',
  1354.                 'allow_null'    => true
  1355.             ),
  1356.             'icq'               => array(
  1357.                 'datatype'      => 'VARCHAR(12)',
  1358.                 'allow_null'    => true
  1359.             ),
  1360.             'msn'               => array(
  1361.                 'datatype'      => 'VARCHAR(80)',
  1362.                 'allow_null'    => true
  1363.             ),
  1364.             'aim'               => array(
  1365.                 'datatype'      => 'VARCHAR(30)',
  1366.                 'allow_null'    => true
  1367.             ),
  1368.             'yahoo'             => array(
  1369.                 'datatype'      => 'VARCHAR(30)',
  1370.                 'allow_null'    => true
  1371.             ),
  1372.             'location'          => array(
  1373.                 'datatype'      => 'VARCHAR(30)',
  1374.                 'allow_null'    => true
  1375.             ),
  1376.             'signature'         => array(
  1377.                 'datatype'      => 'TEXT',
  1378.                 'allow_null'    => true
  1379.             ),
  1380.             'disp_topics'       => array(
  1381.                 'datatype'      => 'TINYINT(3) UNSIGNED',
  1382.                 'allow_null'    => true
  1383.             ),
  1384.             'disp_posts'        => array(
  1385.                 'datatype'      => 'TINYINT(3) UNSIGNED',
  1386.                 'allow_null'    => true
  1387.             ),
  1388.             'email_setting'     => array(
  1389.                 'datatype'      => 'TINYINT(1)',
  1390.                 'allow_null'    => false,
  1391.                 'default'       => '1'
  1392.             ),
  1393.             'notify_with_post'  => array(
  1394.                 'datatype'      => 'TINYINT(1)',
  1395.                 'allow_null'    => false,
  1396.                 'default'       => '0'
  1397.             ),
  1398.             'auto_notify'       => array(
  1399.                 'datatype'      => 'TINYINT(1)',
  1400.                 'allow_null'    => false,
  1401.                 'default'       => '0'
  1402.             ),
  1403.             'show_smilies'      => array(
  1404.                 'datatype'      => 'TINYINT(1)',
  1405.                 'allow_null'    => false,
  1406.                 'default'       => '1'
  1407.             ),
  1408.             'show_img'          => array(
  1409.                 'datatype'      => 'TINYINT(1)',
  1410.                 'allow_null'    => false,
  1411.                 'default'       => '1'
  1412.             ),
  1413.             'show_img_sig'      => array(
  1414.                 'datatype'      => 'TINYINT(1)',
  1415.                 'allow_null'    => false,
  1416.                 'default'       => '1'
  1417.             ),
  1418.             'show_avatars'      => array(
  1419.                 'datatype'      => 'TINYINT(1)',
  1420.                 'allow_null'    => false,
  1421.                 'default'       => '1'
  1422.             ),
  1423.             'show_sig'          => array(
  1424.                 'datatype'      => 'TINYINT(1)',
  1425.                 'allow_null'    => false,
  1426.                 'default'       => '1'
  1427.             ),
  1428.             'timezone'          => array(
  1429.                 'datatype'      => 'FLOAT',
  1430.                 'allow_null'    => false,
  1431.                 'default'       => '0'
  1432.             ),
  1433.             'dst'               => array(
  1434.                 'datatype'      => 'TINYINT(1)',
  1435.                 'allow_null'    => false,
  1436.                 'default'       => '0'
  1437.             ),
  1438.             'time_format'       => array(
  1439.                 'datatype'      => 'TINYINT(1)',
  1440.                 'allow_null'    => false,
  1441.                 'default'       => '0'
  1442.             ),
  1443.             'date_format'       => array(
  1444.                 'datatype'      => 'TINYINT(1)',
  1445.                 'allow_null'    => false,
  1446.                 'default'       => '0'
  1447.             ),
  1448.             'language'          => array(
  1449.                 'datatype'      => 'VARCHAR(25)',
  1450.                 'allow_null'    => false,
  1451.                 'default'       => '\'English\''
  1452.             ),
  1453.             'style'             => array(
  1454.                 'datatype'      => 'VARCHAR(25)',
  1455.                 'allow_null'    => false,
  1456.                 'default'       => '\''.$db->escape($default_style).'\''
  1457.             ),
  1458.             'num_posts'         => array(
  1459.                 'datatype'      => 'INT(10) UNSIGNED',
  1460.                 'allow_null'    => false,
  1461.                 'default'       => '0'
  1462.             ),
  1463.             'last_post'         => array(
  1464.                 'datatype'      => 'INT(10) UNSIGNED',
  1465.                 'allow_null'    => true
  1466.             ),
  1467.             'last_search'       => array(
  1468.                 'datatype'      => 'INT(10) UNSIGNED',
  1469.                 'allow_null'    => true
  1470.             ),
  1471.             'last_email_sent'   => array(
  1472.                 'datatype'      => 'INT(10) UNSIGNED',
  1473.                 'allow_null'    => true
  1474.             ),
  1475.             'registered'        => array(
  1476.                 'datatype'      => 'INT(10) UNSIGNED',
  1477.                 'allow_null'    => false,
  1478.                 'default'       => '0'
  1479.             ),
  1480.             'registration_ip'   => array(
  1481.                 'datatype'      => 'VARCHAR(39)',
  1482.                 'allow_null'    => false,
  1483.                 'default'       => '\'0.0.0.0\''
  1484.             ),
  1485.             'last_visit'        => array(
  1486.                 'datatype'      => 'INT(10) UNSIGNED',
  1487.                 'allow_null'    => false,
  1488.                 'default'       => '0'
  1489.             ),
  1490.             'admin_note'        => array(
  1491.                 'datatype'      => 'VARCHAR(30)',
  1492.                 'allow_null'    => true
  1493.             ),
  1494.             'activate_string'   => array(
  1495.                 'datatype'      => 'VARCHAR(80)',
  1496.                 'allow_null'    => true
  1497.             ),
  1498.             'activate_key'      => array(
  1499.                 'datatype'      => 'VARCHAR(8)',
  1500.                 'allow_null'    => true
  1501.             ),
  1502.         ),
  1503.         'PRIMARY KEY'   => array('id'),
  1504.         'UNIQUE KEYS'   => array(
  1505.             'username_idx'      => array('username')
  1506.         ),
  1507.         'INDEXES'       => array(
  1508.             'registered_idx'    => array('registered')
  1509.         )
  1510.     );
  1511.  
  1512.     if ($db_type == 'mysql' || $db_type == 'mysqli' || $db_type == 'mysql_innodb' || $db_type == 'mysqli_innodb')
  1513.         $schema['UNIQUE KEYS']['username_idx'] = array('username(25)');
  1514.  
  1515.     $db->create_table('users', $schema) or error('Unable to create users table', __FILE__, __LINE__, $db->error());
  1516.  
  1517.  
  1518.     $now = time();
  1519.  
  1520.     // Insert the four preset groups
  1521.     $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, ' : '')."'Administrators', '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());
  1522.  
  1523.     $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, ' : '').$lang_install['Moderators'].', '.$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());
  1524.  
  1525.     $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, ' : '').$lang_install['Guest']."', 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());
  1526.  
  1527.     $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, ' : '').$lang_install['Member']."', 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());
  1528.  
  1529.     // Insert guest and first admin user
  1530.     $db->query('INSERT INTO '.$db_prefix."users (group_id, username, password, email) VALUES(3, '".$lang_install['Member']."', '".$lang_install['Member']."', '".$lang_install['Member']."')")
  1531.         or error('Unable to add guest user. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  1532.  
  1533.     $db->query('INSERT INTO '.$db_prefix."users (group_id, username, password, email, num_posts, last_post, registered, registration_ip, last_visit) VALUES(1, '".$db->escape($username)."', '".pun_hash($password1)."', '$email', 1, ".$now.", ".$now.", '127.0.0.1', ".$now.')')
  1534.         or error('Unable to add administrator user. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  1535.  
  1536.     // Enable/disable avatars depending on file_uploads setting in PHP configuration
  1537.     $avatars = in_array(strtolower(@ini_get('file_uploads')), array('on', 'true', '1')) ? 1 : 0;
  1538.  
  1539.     // Insert config data
  1540.     $config = array(
  1541.         'o_cur_version'             => "'".FORUM_VERSION."'",
  1542.         'o_database_revision'       => "'".FORUM_DB_REVISION."'",
  1543.         'o_searchindex_revision'    => "'".FORUM_SI_REVISION."'",
  1544.         'o_parser_revision'         => "'".FORUM_PARSER_REVISION."'",
  1545.         'o_board_title'             => "'".$db->escape($title)."'",
  1546.         'o_board_desc'              => "'".$db->escape($description)."'",
  1547.         'o_default_timezone'        => "'0'",
  1548.         'o_time_format'             => "'H:i:s'",
  1549.         'o_date_format'             => "'Y-m-d'",
  1550.         'o_timeout_visit'           => "'1800'",
  1551.         'o_timeout_online'          => "'300'",
  1552.         'o_redirect_delay'          => "'1'",
  1553.         'o_show_version'            => "'0'",
  1554.         'o_show_user_info'          => "'1'",
  1555.         'o_show_post_count'         => "'1'",
  1556.         'o_signatures'              => "'1'",
  1557.         'o_smilies'                 => "'1'",
  1558.         'o_smilies_sig'             => "'1'",
  1559.         'o_make_links'              => "'1'",
  1560.         'o_default_lang'            => "'".$db->escape($default_lang)."'",
  1561.         'o_default_style'           => "'".$db->escape($default_style)."'",
  1562.         'o_default_user_group'      => "'4'",
  1563.         'o_topic_review'            => "'15'",
  1564.         'o_disp_topics_default'     => "'30'",
  1565.         'o_disp_posts_default'      => "'25'",
  1566.         'o_indent_num_spaces'       => "'4'",
  1567.         'o_quote_depth'             => "'3'",
  1568.         'o_quickpost'               => "'1'",
  1569.         'o_users_online'            => "'1'",
  1570.         'o_censoring'               => "'0'",
  1571.         'o_ranks'                   => "'1'",
  1572.         'o_show_dot'                => "'0'",
  1573.         'o_topic_views'             => "'1'",
  1574.         'o_quickjump'               => "'1'",
  1575.         'o_gzip'                    => "'0'",
  1576.         'o_additional_navlinks'     => "''",
  1577.         'o_report_method'           => "'0'",
  1578.         'o_regs_report'             => "'0'",
  1579.         'o_default_email_setting'   => "'1'",
  1580.         'o_mailing_list'            => "'".$email."'",
  1581.         'o_avatars'                 => "'".$avatars."'",
  1582.         'o_avatars_dir'             => "'img/avatars'",
  1583.         'o_avatars_width'           => "'60'",
  1584.         'o_avatars_height'          => "'60'",
  1585.         'o_avatars_size'            => "'10240'",
  1586.         'o_search_all_forums'       => "'1'",
  1587.         'o_base_url'                => "'".$db->escape($base_url)."'",
  1588.         'o_admin_email'             => "'".$email."'",
  1589.         'o_webmaster_email'         => "'".$email."'",
  1590.         'o_subscriptions'           => "'1'",
  1591.         'o_smtp_host'               => "NULL",
  1592.         'o_smtp_user'               => "NULL",
  1593.         'o_smtp_pass'               => "NULL",
  1594.         'o_smtp_ssl'                => "'0'",
  1595.         'o_regs_allow'              => "'1'",
  1596.         'o_regs_verify'             => "'0'",
  1597.         'o_announcement'            => "'0'",
  1598.         'o_announcement_message'    => "'".$lang_install['Announcement']."'",
  1599.         'o_rules'                   => "'0'",
  1600.         'o_rules_message'           => "'".$lang_install['Rules']."'",
  1601.         'o_maintenance'             => "'0'",
  1602.         'o_maintenance_message'     => "'".$lang_install['Maintenance message']."'",
  1603.         'o_default_dst'             => "'0'",
  1604.         'o_feed_type'               => "'2'",
  1605.         'p_message_bbcode'          => "'1'",
  1606.         'p_message_img_tag'         => "'1'",
  1607.         'p_message_all_caps'        => "'1'",
  1608.         'p_subject_all_caps'        => "'1'",
  1609.         'p_sig_all_caps'            => "'1'",
  1610.         'p_sig_bbcode'              => "'1'",
  1611.         'p_sig_img_tag'             => "'0'",
  1612.         'p_sig_length'              => "'400'",
  1613.         'p_sig_lines'               => "'4'",
  1614.         'p_allow_banned_email'      => "'1'",
  1615.         'p_allow_dupe_email'        => "'0'",
  1616.         'p_force_guest_email'       => "'1'"
  1617.     );
  1618.  
  1619.     foreach ($config as $conf_name => $conf_value)
  1620.     {
  1621.         $db->query('INSERT INTO '.$db_prefix."config (conf_name, conf_value) VALUES('$conf_name', $conf_value)")
  1622.             or error('Unable to insert into table '.$db_prefix.'config. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  1623.     }
  1624.  
  1625.     // Insert some other default data
  1626.     $subject = $lang_install['Test post'];
  1627.     $message = $lang_install['Message'];
  1628.  
  1629.     $db->query('INSERT INTO '.$db_prefix."ranks (rank, min_posts) VALUES('New member', 0)")
  1630.         or error('Unable to insert into table '.$db_prefix.'ranks. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  1631.  
  1632.     $db->query('INSERT INTO '.$db_prefix."ranks (rank, min_posts) VALUES('".$lang_install['Member']."', 10)")
  1633.         or error('Unable to insert into table '.$db_prefix.'ranks. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  1634.  
  1635.     $db->query('INSERT INTO '.$db_prefix."categories (cat_name, disp_position) VALUES('".$lang_install['Test category']."', 1)")
  1636.         or error('Unable to insert into table '.$db_prefix.'categories. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  1637.  
  1638.     $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('".$lang_install['Test forum']."', '".$lang_install['This is just a test forum']."', 1, 1, ".$now.", 1, '".$db->escape($username)."', 1, 1)")
  1639.         or error('Unable to insert into table '.$db_prefix.'forums. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  1640.  
  1641.     $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)")
  1642.         or error('Unable to insert into table '.$db_prefix.'topics. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  1643.  
  1644.     $db->query('INSERT INTO '.$db_prefix."posts (poster, poster_id, poster_ip, message, posted, topic_id) VALUES('".$db->escape($username)."', 2, '127.0.0.1', '".$db->escape($message)."', ".$now.', 1)')
  1645.         or error('Unable to insert into table '.$db_prefix.'posts. Please check your configuration and try again', __FILE__, __LINE__, $db->error());
  1646.  
  1647.     // Index the test post so searching for it works
  1648.     require PUN_ROOT.'include/search_idx.php';
  1649.     $pun_config['o_default_lang'] = $default_lang;
  1650.     update_search_index('post', 1, $message, $subject);
  1651.  
  1652.     $db->end_transaction();
  1653.  
  1654.  
  1655.     $alerts = array();
  1656.     // Check if the cache directory is writable
  1657.     if (!@is_writable('./cache/'))
  1658.         $alerts[] = $lang_install['Alert cache'];
  1659.  
  1660.     // Check if default avatar directory is writable
  1661.     if (!@is_writable('./img/avatars/'))
  1662.         $alerts[] = $lang_install['Alert avatar'];
  1663.  
  1664.     // Check if we disabled uploading avatars because file_uploads was disabled
  1665.     if ($avatars == '0')
  1666.         $alerts[] = $lang_install['Alert upload'];
  1667.  
  1668.     // Add some random bytes at the end of the cookie name to prevent collisions
  1669.     $cookie_name = 'pun_cookie_'.random_key(6, false, true);
  1670.  
  1671.     // Generate the config.php file data
  1672.     $config = generate_config_file();
  1673.  
  1674.     // Attempt to write config.php and serve it up for download if writing fails
  1675.     $written = false;
  1676.     if (is_writable(PUN_ROOT))
  1677.     {
  1678.         $fh = @fopen(PUN_ROOT.'config.php', 'wb');
  1679.         if ($fh)
  1680.         {
  1681.             fwrite($fh, $config);
  1682.             fclose($fh);
  1683.  
  1684.             $written = true;
  1685.         }
  1686.     }
  1687.  
  1688.  
  1689. ?>
  1690. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  1691.  
  1692. <html>
  1693. <head>
  1694. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  1695. <title><?php echo $lang_install['FluxBB Installation'] ?></title>
  1696. <link rel="stylesheet" type="text/css" href="style/<?php echo $default_style ?>.css" />
  1697. </head>
  1698. <body>
  1699.  
  1700. <div id="puninstall" class="pun">
  1701. <div class="top-box"><div><!-- Top Corners --></div></div>
  1702. <div class="punwrap">
  1703.  
  1704. <div id="brdheader" class="block">
  1705.     <div class="box">
  1706.         <div id="brdtitle" class="inbox">
  1707.             <h1><span><?php echo $lang_install['FluxBB Installation'] ?></span></h1>
  1708.             <div id="brddesc"><p><?php echo $lang_install['FluxBB has been installed'] ?></p></div>
  1709.         </div>
  1710.     </div>
  1711. </div>
  1712.  
  1713. <div id="brdmain">
  1714.  
  1715. <div class="blockform">
  1716.     <h2><span><?php echo $lang_install['Final instructions'] ?></span></h2>
  1717.     <div class="box">
  1718. <?php
  1719.  
  1720. if (!$written)
  1721. {
  1722.  
  1723. ?>
  1724.         <form method="post" action="install.php">
  1725.             <div class="inform">
  1726.                 <div class="forminfo">
  1727.                     <p><?php echo $lang_install['Info 17'] ?></p>
  1728.                     <p><?php echo $lang_install['Info 18'] ?></p>
  1729.                 </div>
  1730.                 <input type="hidden" name="generate_config" value="1" />
  1731.                 <input type="hidden" name="db_type" value="<?php echo $db_type; ?>" />
  1732.                 <input type="hidden" name="db_host" value="<?php echo $db_host; ?>" />
  1733.                 <input type="hidden" name="db_name" value="<?php echo pun_htmlspecialchars($db_name); ?>" />
  1734.                 <input type="hidden" name="db_username" value="<?php echo pun_htmlspecialchars($db_username); ?>" />
  1735.                 <input type="hidden" name="db_password1" value="<?php echo pun_htmlspecialchars($db_password1); ?>" />
  1736.                 <input type="hidden" name="db_prefix" value="<?php echo pun_htmlspecialchars($db_prefix); ?>" />
  1737.                 <input type="hidden" name="cookie_name" value="<?php echo pun_htmlspecialchars($cookie_name); ?>" />
  1738.                 <input type="hidden" name="cookie_seed" value="<?php echo pun_htmlspecialchars($cookie_seed); ?>" />
  1739.  
  1740. <?php if (!empty($alerts)): ?>              <div class="forminfo error-info">
  1741.                     <ul class="error-list">
  1742. <?php
  1743.  
  1744. foreach ($alerts as $cur_alert)
  1745.     echo "\t\t\t\t\t".'<li>'.$cur_alert.'</li>'."\n";
  1746. ?>
  1747.                     </ul>
  1748.                 </div>
  1749. <?php endif; ?>         </div>
  1750.             <p class="buttons"><input type="submit" value="<?php echo $lang_install['Download config.php file'] ?>" /></p>
  1751.         </form>
  1752.  
  1753. <?php
  1754.  
  1755. }
  1756. else
  1757. {
  1758.  
  1759. ?>
  1760.         <div class="fakeform">
  1761.             <div class="inform">
  1762.                 <div class="forminfo">
  1763.                     <p><?php echo $lang_install['FluxBB has been fully installed'] ?></p>
  1764.                 </div>
  1765.             </div>
  1766.         </div>
  1767. <?php
  1768.  
  1769. }
  1770.  
  1771. ?>
  1772.     </div>
  1773. </div>
  1774.  
  1775. </div>
  1776.  
  1777. </div>
  1778. <div class="end-box"><div><!-- Bottom Corners --></div></div>
  1779. </div>
  1780.  
  1781. </body>
  1782. </html>
  1783. <?php
  1784.  
  1785. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement