aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/adm/style/install/convert.html4
-rw-r--r--phpBB/adm/style/install/error.html4
-rw-r--r--phpBB/adm/style/install/install.html187
-rw-r--r--phpBB/adm/style/install/main.html4
-rw-r--r--phpBB/adm/style/install/update.html4
-rw-r--r--phpBB/includes/functions_install.php179
-rw-r--r--phpBB/install/index.php359
-rw-r--r--phpBB/install/install_install.php1312
-rw-r--r--phpBB/install/install_main.php20
-rw-r--r--phpBB/install/install_update.php30
10 files changed, 795 insertions, 1308 deletions
diff --git a/phpBB/adm/style/install/convert.html b/phpBB/adm/style/install/convert.html
index 783e89d6bf..a9ff57da29 100644
--- a/phpBB/adm/style/install/convert.html
+++ b/phpBB/adm/style/install/convert.html
@@ -1,4 +1,4 @@
-<!-- INCLUDE install_header.html -->
+<!-- INCLUDE install/header.html -->
<!-- IF S_NOT_INSTALLED -->
@@ -131,4 +131,4 @@
</form>
<!-- ENDIF -->
-<!-- INCLUDE install_footer.html --> \ No newline at end of file
+<!-- INCLUDE install/footer.html --> \ No newline at end of file
diff --git a/phpBB/adm/style/install/error.html b/phpBB/adm/style/install/error.html
index ad53433207..f6982650c8 100644
--- a/phpBB/adm/style/install/error.html
+++ b/phpBB/adm/style/install/error.html
@@ -1,8 +1,8 @@
-<!-- INCLUDE install_header.html -->
+<!-- INCLUDE install/header.html -->
<div class="errorbox">
<h3>{MESSAGE_TITLE}</h3>
<p>{MESSAGE_TEXT}</p>
</div>
-<!-- INCLUDE install_footer.html --> \ No newline at end of file
+<!-- INCLUDE install/footer.html --> \ No newline at end of file
diff --git a/phpBB/adm/style/install/install.html b/phpBB/adm/style/install/install.html
index e69de29bb2..a08b52eb7a 100644
--- a/phpBB/adm/style/install/install.html
+++ b/phpBB/adm/style/install/install.html
@@ -0,0 +1,187 @@
+<!-- INCLUDE install/header.html -->
+
+<!-- IF S_SUB eq 'intro' -->
+
+ <h1>{L_INSTALL_INTRO}</h1>
+ <p>{L_INSTALL_INTRO_BODY}</p>
+
+
+ <form id="install_install" method="post" action="{U_ACTION}" onsubmit="submit.disabled = 'disabled';">
+
+ <fieldset class="submit-buttons">
+ <legend>{L_NEXT_STEP}</legend>
+ <input class="button1" type="submit" id="submit" onclick="this.className = 'button1 disabled';" name="submit" value="{L_NEXT_STEP}" />
+ </fieldset>
+
+ </form>
+
+<!-- ELSEIF S_SUB eq 'requirements' -->
+ <h1>{L_REQUIREMENTS_TITLE}</h1>
+ <p>{L_REQUIREMENTS_EXPLAIN}</p>
+
+ <!-- INCLUDE install/snippet_checks.html -->
+
+ <!-- IF S_FAILED -->
+
+ <form id="install_install" method="post" action="{U_ACTION}" onsubmit="submit.disabled = 'disabled';">
+
+ <fieldset class="submit-buttons">
+ <legend>{L_INSTALL_TEST}</legend>
+ <input class="button1" type="submit" id="submit" onclick="this.className = 'button1 disabled';" name="submit" value="{L_INSTALL_TEST}" />
+ </fieldset>
+
+ </form>
+
+ <!-- ELSE -->
+
+ <form id="install_install" method="post" action="{U_ACTION_TEST}" onsubmit="submit.disabled = 'disabled';">
+
+ <fieldset class="submit-buttons" style="float: left;">
+ <legend>{L_INSTALL_TEST}</legend>
+ <input class="button1" type="submit" id="submit" onclick="this.className = 'button1 disabled';" name="submit" value="{L_INSTALL_TEST}" />
+ </fieldset>
+
+ </form>
+
+ <form id="install_start" method="post" action="{U_ACTION}" onsubmit="submit.disabled = 'disabled';">
+
+ <fieldset class="submit-buttons" style="float: right;">
+ <legend>{L_INSTALL_START}</legend>
+ {S_HIDDEN}
+ <input class="button1" type="submit" id="submit" onclick="this.className = 'button1 disabled';" name="submit" value="{L_INSTALL_START}" />
+ </fieldset>
+
+ </form>
+
+ <!-- ENDIF -->
+
+<!-- ELSEIF S_SUB eq 'database' -->
+
+ <!-- IF S_CONNECT_TEST -->
+ <fieldset>
+ <legend>{L_DB_CONNECTION}</legend>
+
+ <!-- IF S_SUCCESS -->
+ <dl>
+ <dt>{L_DB_TEST}:</dt>
+ <dd><strong style="color:green">{L_SUCCESSFUL_CONNECT}</strong></dd>
+ </dl>
+ <!-- ELSE -->
+ <dl>
+ <dt>{L_DB_TEST}:</dt>
+ <dd><strong style="color:red">{ERROR}</strong></dd>
+ </dl>
+ <!-- ENDIF -->
+ </fieldset>
+ <!-- ENDIF -->
+
+ <form id="install_install" method="post" action="{U_ACTION}" onsubmit="submit.disabled = 'disabled';">
+
+ <!-- INCLUDE install/snippet_options.html -->
+
+ <fieldset class="submit-buttons">
+ <legend>{L_NEXT_STEP}</legend>
+ {S_HIDDEN}
+ <input class="button1" type="submit" id="submit" onclick="this.className = 'button1 disabled';" name="submit" value="{L_NEXT_STEP}" />
+ </fieldset>
+
+ </form>
+<!-- ELSEIF S_SUB eq 'administrator' -->
+
+ <!-- INCLUDE install/snippet_checks.html -->
+
+ <form id="install_install" method="post" action="{U_ACTION}" onsubmit="submit.disabled = 'disabled';">
+
+ <!-- INCLUDE install/snippet_options.html -->
+
+ <fieldset class="submit-buttons">
+ <legend>{L_NEXT_STEP}</legend>
+ {S_HIDDEN}
+ <input class="button1" type="submit" id="submit" onclick="this.className = 'button1 disabled';" name="submit" value="{L_NEXT_STEP}" />
+ </fieldset>
+
+ </form>
+
+<!-- ELSEIF S_SUB eq 'config_file' -->
+
+ <!-- IF S_WRITTEN -->
+ <p>{L_CONFIG_FILE_WRITTEN}</p>
+
+ <form id="install_install" method="post" action="{U_ACTION}" onsubmit="submit.disabled = 'disabled';">
+
+ <fieldset class="submit-buttons">
+ <legend>{L_NEXT_STEP}</legend>
+ {S_HIDDEN}
+ <input class="button1" type="submit" id="submit" onclick="this.className = 'button1 disabled';" name="submit" value="{L_NEXT_STEP}" />
+ </fieldset>
+
+ </form>
+
+ <!-- ELSE -->
+ <p>{L_CONFIG_FILE_UNABLE_WRITE}</p>
+
+ <h1>{L_DL_CONFIG}</h1>
+ <p>{L_DL_CONFIG_EXPLAIN}</p>
+
+ <form id="install_install" method="post" action="{U_ACTION}" onsubmit="submit.disabled = 'disabled';">
+
+ <fieldset class="submit-buttons">
+ <legend>{L_DL_CONFIG}</legend>
+ {S_HIDDEN}
+ <input class="button1" type="submit" id="dlconfig" name="dlconfig" value="{L_DL_DOWNLOAD}" />&nbsp;<input class="button1" type="submit" id="dldone" name="dldone" value="{L_DONE}" />
+ </fieldset>
+
+ </form>
+ <!-- ENDIF -->
+
+<!-- ELSEIF S_SUB eq 'advanced' -->
+
+ <p>{L_STAGE_ADVANCED_EXPLAIN}</p>
+
+ <form id="install_install" method="post" action="{U_ACTION}" onsubmit="submit.disabled = 'disabled';">
+
+ <!-- INCLUDE install/snippet_options.html -->
+
+ <fieldset class="submit-buttons">
+ <legend>{L_NEXT_STEP}</legend>
+ {S_HIDDEN}
+ <input class="button1" type="submit" id="submit" onclick="this.className = 'button1 disabled';" name="submit" value="{L_NEXT_STEP}" />
+ </fieldset>
+
+ </form>
+
+<!-- ELSEIF S_SUB eq 'create_table' -->
+
+ <p>{L_STAGE_CREATE_TABLE_EXPLAIN}</p>
+
+ <form id="install_install" method="post" action="{U_ACTION}" onsubmit="submit.disabled = 'disabled';">
+
+ <fieldset class="submit-buttons">
+ <legend>{L_NEXT_STEP}</legend>
+ {S_HIDDEN}
+ <input class="button1" type="submit" id="submit" onclick="this.className = 'button1 disabled';" name="submit" value="{L_NEXT_STEP}" />
+ </fieldset>
+
+ </form>
+
+<!-- ELSEIF S_SUB eq 'final' -->
+
+ <!-- INCLUDE install/snippet_checks.html -->
+
+ <h1>{L_INSTALL_CONGRATS}</h1>
+
+ <p>{L_BODY}</p>
+
+ <form id="install_install" method="post" action="{U_ACTION}" onsubmit="submit.disabled = 'disabled';">
+
+ <fieldset class="submit-buttons">
+ <legend>{L_INSTALL_LOGIN}</legend>
+ <input class="button1" type="submit" id="submit" onclick="this.className = 'button1 disabled';" name="submit" value="{L_INSTALL_LOGIN}" />
+ </fieldset>
+
+ </form>
+
+<!-- ENDIF -->
+
+
+<!-- INCLUDE install/footer.html -->
diff --git a/phpBB/adm/style/install/main.html b/phpBB/adm/style/install/main.html
index 2c318bfd65..64c1a58f37 100644
--- a/phpBB/adm/style/install/main.html
+++ b/phpBB/adm/style/install/main.html
@@ -1,6 +1,6 @@
-<!-- INCLUDE install_header.html -->
+<!-- INCLUDE install/header.html -->
<h1>{TITLE}</h1>
<p>{BODY}</p>
-<!-- INCLUDE install_footer.html --> \ No newline at end of file
+<!-- INCLUDE install/footer.html --> \ No newline at end of file
diff --git a/phpBB/adm/style/install/update.html b/phpBB/adm/style/install/update.html
index 2448f1d39b..640a02d57d 100644
--- a/phpBB/adm/style/install/update.html
+++ b/phpBB/adm/style/install/update.html
@@ -1,4 +1,4 @@
-<!-- INCLUDE install_header.html -->
+<!-- INCLUDE install/header.html -->
<script type="text/javascript">
// <![CDATA[
@@ -399,4 +399,4 @@
<!-- ENDIF -->
-<!-- INCLUDE install_footer.html -->
+<!-- INCLUDE install/footer.html -->
diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php
index b12c0b1a8f..8b91e9617f 100644
--- a/phpBB/includes/functions_install.php
+++ b/phpBB/includes/functions_install.php
@@ -18,6 +18,9 @@ if (!defined('IN_PHPBB'))
/**
* Determine if we are able to load a specified PHP module and do so if possible
+*
+* @param string $dll Name of the DLL without extension. For example 'sqlite'.
+* @return bool Returns true of successfully loaded, else false.
*/
function can_load_dll($dll)
{
@@ -25,112 +28,72 @@ function can_load_dll($dll)
}
/**
-* Returns an array of available DBMS with some data, if a DBMS is specified it will only
-* return data for that DBMS and will load its extension if necessary.
+* Returns an array of available DBMS with some data, if a DBMS is specified it will only return data for that DBMS and will load its extension if necessary.
+*
*/
-function get_available_dbms($dbms = false, $return_unavailable = false, $only_20x_options = false)
+function get_available_dbms($dbms = false, $return_unavailable = false, $only_30x_options = false)
{
- global $lang;
$available_dbms = array(
'firebird' => array(
'LABEL' => 'FireBird',
- 'SCHEMA' => 'firebird',
'MODULE' => 'interbase',
- 'DELIM' => ';;',
- 'COMMENTS' => 'remove_remarks',
- 'DRIVER' => 'firebird',
'AVAILABLE' => true,
- '2.0.x' => false,
+ '3.0.x' => true,
),
'mysqli' => array(
'LABEL' => 'MySQL with MySQLi Extension',
- 'SCHEMA' => 'mysql',
'MODULE' => 'mysqli',
- 'DELIM' => ';',
- 'COMMENTS' => 'remove_remarks',
'DRIVER' => 'mysqli',
'AVAILABLE' => true,
- '2.0.x' => true,
+ '3.0.x' => true,
),
'mysql' => array(
'LABEL' => 'MySQL',
- 'SCHEMA' => 'mysql',
'MODULE' => 'mysql',
- 'DELIM' => ';',
- 'COMMENTS' => 'remove_remarks',
- 'DRIVER' => 'mysql',
'AVAILABLE' => true,
- '2.0.x' => true,
+ '3.0.x' => true,
),
'mssql' => array(
'LABEL' => 'MS SQL Server 2000+',
- 'SCHEMA' => 'mssql',
'MODULE' => 'mssql',
- 'DELIM' => 'GO',
- 'COMMENTS' => 'remove_comments',
- 'DRIVER' => 'mssql',
'AVAILABLE' => true,
- '2.0.x' => true,
+ '3.0.x' => true,
),
'mssql_odbc'=> array(
'LABEL' => 'MS SQL Server [ ODBC ]',
- 'SCHEMA' => 'mssql',
'MODULE' => 'odbc',
- 'DELIM' => 'GO',
- 'COMMENTS' => 'remove_comments',
- 'DRIVER' => 'mssql_odbc',
'AVAILABLE' => true,
- '2.0.x' => true,
+ '3.0.x' => true,
),
'mssql_2005'=> array(
'LABEL' => 'MS SQL Server [ 2005 ]',
- 'SCHEMA' => 'mssql',
'MODULE' => 'sqlsrv',
- 'DELIM' => 'GO',
- 'COMMENTS' => 'remove_comments',
- 'DRIVER' => 'mssql_2005',
'AVAILABLE' => true,
- '2.0.x' => true,
+ '3.0.x' => true,
),
'db2' => array(
'LABEL' => 'IBM DB2',
- 'SCHEMA' => 'db2',
'MODULE' => 'ibm_db2',
- 'DELIM' => ';',
- 'COMMENTS' => 'remove_comments',
- 'DRIVER' => 'db2',
'AVAILABLE' => true,
- '2.0.x' => false,
+ '3.0.x' => false,
),
'oracle' => array(
'LABEL' => 'Oracle',
- 'SCHEMA' => 'oracle',
'MODULE' => 'oci8',
- 'DELIM' => '/',
- 'COMMENTS' => 'remove_comments',
- 'DRIVER' => 'oracle',
'AVAILABLE' => true,
- '2.0.x' => false,
+ '3.0.x' => true,
),
'postgres' => array(
'LABEL' => 'PostgreSQL 7.x/8.x',
- 'SCHEMA' => 'postgres',
'MODULE' => 'pgsql',
- 'DELIM' => ';',
- 'COMMENTS' => 'remove_comments',
- 'DRIVER' => 'postgres',
'AVAILABLE' => true,
- '2.0.x' => true,
+ '3.0.x' => true,
),
'sqlite' => array(
'LABEL' => 'SQLite',
- 'SCHEMA' => 'sqlite',
'MODULE' => 'sqlite',
- 'DELIM' => ';',
- 'COMMENTS' => 'remove_remarks',
- 'DRIVER' => 'sqlite',
'AVAILABLE' => true,
- '2.0.x' => false,
+ '3.0.x' => true,
),
);
@@ -149,7 +112,7 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
// now perform some checks whether they are really available
foreach ($available_dbms as $db_name => $db_ary)
{
- if ($only_20x_options && !$db_ary['2.0.x'])
+ if ($only_30x_options && !$db_ary['3.0.x'])
{
if ($return_unavailable)
{
@@ -186,23 +149,24 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
{
$available_dbms['ANY_DB_SUPPORT'] = $any_db_support;
}
+
return $available_dbms;
}
/**
* Generate the drop down of available database options
*/
-function dbms_select($default = '', $only_20x_options = false)
+function dbms_select($default = '', $only_30x_options = false)
{
- global $lang;
+ $available_dbms = get_available_dbms(false, false, $only_30x_options);
- $available_dbms = get_available_dbms(false, false, $only_20x_options);
$dbms_options = '';
foreach ($available_dbms as $dbms_name => $details)
{
$selected = ($dbms_name == $default) ? ' selected="selected"' : '';
- $dbms_options .= '<option value="' . $dbms_name . '"' . $selected .'>' . $lang['DLL_' . strtoupper($dbms_name)] . '</option>';
+ $dbms_options .= '<option value="' . $dbms_name . '"' . $selected .'>' . phpbb::$user->lang['DLL_' . strtoupper($dbms_name)] . '</option>';
}
+
return $dbms_options;
}
@@ -275,34 +239,26 @@ function get_tables($db)
* @param array $dbms should be of the format of an element of the array returned by {@link get_available_dbms get_available_dbms()}
* necessary extensions should be loaded already
*/
-function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, $dbhost, $dbuser, $dbpasswd, $dbname, $dbport, $prefix_may_exist = false, $load_dbal = true, $unicode_check = true)
+function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, $dbhost, $dbuser, $dbpasswd, $dbname, $dbport, $prefix_may_exist = false, $unicode_check = true)
{
- global $lang;
-
$dbms = $dbms_details['DRIVER'];
- if ($load_dbal)
- {
- // Include the DB layer
- include(PHPBB_ROOT_PATH . 'includes/db/' . $dbms . '.' . PHP_EXT);
- }
+ phpbb::assign('checkdb', phpbb_db_dbal::new_instance($dbms));
+ $db = phpbb::get_instance('checkdb');
- // Instantiate it and set return on error true
- $sql_db = 'dbal_' . $dbms;
- $db = new $sql_db();
$db->sql_return_on_error(true);
// Check that we actually have a database name before going any further.....
if ($dbms_details['DRIVER'] != 'sqlite' && $dbms_details['DRIVER'] != 'oracle' && $dbname === '')
{
- $error[] = $lang['INST_ERR_DB_NO_NAME'];
+ $error[] = phpbb::$user->lang['INST_ERR_DB_NO_NAME'];
return false;
}
// Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea
- if ($dbms_details['DRIVER'] == 'sqlite' && stripos(phpbb_realpath($dbhost), phpbb_realpath('../')) === 0)
+ if ($dbms_details['DRIVER'] == 'sqlite' && stripos(phpbb::$url->realpath($dbhost), phpbb::$url->realpath('../')) === 0)
{
- $error[] = $lang['INST_ERR_DB_FORUM_PATH'];
+ $error[] = phpbb::$user->lang['INST_ERR_DB_FORUM_PATH'];
return false;
}
@@ -313,7 +269,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
case 'mysqli':
if (strspn($table_prefix, '-./\\') !== 0)
{
- $error[] = $lang['INST_ERR_PREFIX_INVALID'];
+ $error[] = phpbb::$user->lang['INST_ERR_PREFIX_INVALID'];
return false;
}
@@ -345,7 +301,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
if (strlen($table_prefix) > $prefix_length)
{
- $error[] = sprintf($lang['INST_ERR_PREFIX_TOO_LONG'], $prefix_length);
+ $error[] = phpbb::$user->lang('INST_ERR_PREFIX_TOO_LONG', $prefix_length);
return false;
}
@@ -353,7 +309,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
if (is_array($db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true)))
{
$db_error = $db->sql_error();
- $error[] = $lang['INST_ERR_DB_CONNECT'] . '<br />' . (($db_error['message']) ? $db_error['message'] : $lang['INST_ERR_DB_NO_ERROR']);
+ $error[] = phpbb::$user->lang['INST_ERR_DB_CONNECT'] . '<br />' . (($db_error['message']) ? $db_error['message'] : phpbb::$user->lang['INST_ERR_DB_NO_ERROR']);
}
else
{
@@ -369,7 +325,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
if (sizeof($table_intersect))
{
- $error[] = $lang['INST_ERR_PREFIX'];
+ $error[] = phpbb::$user->lang['INST_ERR_PREFIX'];
}
}
@@ -377,23 +333,23 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
switch ($dbms_details['DRIVER'])
{
case 'mysql':
- if (version_compare(mysql_get_server_info($db->db_connect_id), '4.1.3', '<'))
+ if (version_compare($db->sql_server_info(true), '4.1.3', '<'))
{
- $error[] = $lang['INST_ERR_DB_NO_MYSQL'];
+ $error[] = phpbb::$user->lang['INST_ERR_DB_NO_MYSQL'];
}
break;
case 'mysqli':
- if (version_compare(mysqli_get_server_info($db->db_connect_id), '4.1.3', '<'))
+ if (version_compare($db->sql_server_info(true), '4.1.3', '<'))
{
- $error[] = $lang['INST_ERR_DB_NO_MYSQLI'];
+ $error[] = phpbb::$user->lang['INST_ERR_DB_NO_MYSQLI'];
}
break;
case 'sqlite':
- if (version_compare(sqlite_libversion(), '2.8.2', '<'))
+ if (version_compare($db->sql_server_info(true), '2.8.2', '<'))
{
- $error[] = $lang['INST_ERR_DB_NO_SQLITE'];
+ $error[] = phpbb::$user->lang['INST_ERR_DB_NO_SQLITE'];
}
break;
@@ -405,7 +361,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
preg_match('#V([\d.]+)#', $val, $match);
if ($match[1] < 2)
{
- $error[] = $lang['INST_ERR_DB_NO_FIREBIRD'];
+ $error[] = phpbb::$user->lang['INST_ERR_DB_NO_FIREBIRD'];
}
$db_info = @ibase_db_info($db->service_handle, $dbname, IBASE_STS_HDR_PAGES);
@@ -413,7 +369,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
$page_size = intval($regs[1]);
if ($page_size < 8192)
{
- $error[] = $lang['INST_ERR_DB_NO_FIREBIRD_PS'];
+ $error[] = phpbb::$user->lang['INST_ERR_DB_NO_FIREBIRD_PS'];
}
}
else
@@ -429,7 +385,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
// if its a UDF, its too old
if ($row)
{
- $error[] = $lang['INST_ERR_DB_NO_FIREBIRD'];
+ $error[] = phpbb::$user->lang['INST_ERR_DB_NO_FIREBIRD'];
}
else
{
@@ -438,7 +394,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
$result = $db->sql_query($sql);
if (!$result) // This can only fail if char_length is not defined
{
- $error[] = $lang['INST_ERR_DB_NO_FIREBIRD'];
+ $error[] = phpbb::$user->lang['INST_ERR_DB_NO_FIREBIRD'];
}
$db->sql_freeresult($result);
}
@@ -467,7 +423,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
if (ibase_errmsg() !== false)
{
- $error[] = $lang['INST_ERR_DB_NO_FIREBIRD_PS'];
+ $error[] = phpbb::$user->lang['INST_ERR_DB_NO_FIREBIRD_PS'];
}
// Kill the old table
@@ -494,12 +450,12 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
if (version_compare($stats['NLS_RDBMS_VERSION'], '9.2', '<'))
{
- $error[] = $lang['INST_ERR_DB_NO_ORACLE'];
+ $error[] = phpbb::$user->lang['INST_ERR_DB_NO_ORACLE'];
}
if ($stats['NLS_CHARACTERSET'] !== 'AL32UTF8')
{
- $error[] = $lang['INST_ERR_DB_NO_ORACLE_NLS'];
+ $error[] = phpbb::$user->lang['INST_ERR_DB_NO_ORACLE_NLS'];
}
}
break;
@@ -514,7 +470,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
if ($row['server_encoding'] !== 'UNICODE' && $row['server_encoding'] !== 'UTF8')
{
- $error[] = $lang['INST_ERR_DB_NO_POSTGRES'];
+ $error[] = phpbb::$user->lang['INST_ERR_DB_NO_POSTGRES'];
}
}
break;
@@ -529,47 +485,4 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
return false;
}
-/**
-* remove_remarks will strip the sql comment lines out of an uploaded sql file
-*/
-function remove_remarks(&$sql)
-{
- $sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql));
-}
-
-/**
-* split_sql_file will split an uploaded sql file into single sql statements.
-* Note: expects trim() to have already been run on $sql.
-*/
-function split_sql_file($sql, $delimiter)
-{
- $sql = str_replace("\r" , '', $sql);
- $data = preg_split('/' . preg_quote($delimiter, '/') . '$/m', $sql);
-
- $data = array_map('trim', $data);
-
- // The empty case
- $end_data = end($data);
-
- if (empty($end_data))
- {
- unset($data[key($data)]);
- }
-
- return $data;
-}
-
-/**
-* For replacing {L_*} strings with preg_replace_callback
-*/
-function adjust_language_keys_callback($matches)
-{
- if (!empty($matches[1]))
- {
- global $lang, $db;
-
- return (!empty($lang[$matches[1]])) ? $db->sql_escape($lang[$matches[1]]) : $db->sql_escape($matches[1]);
- }
-}
-
?> \ No newline at end of file
diff --git a/phpBB/install/index.php b/phpBB/install/index.php
index 407ccec4db..b09330f88b 100644
--- a/phpBB/install/index.php
+++ b/phpBB/install/index.php
@@ -18,109 +18,17 @@ define('IN_INSTALL', true);
if (!defined('PHPBB_ROOT_PATH')) define('PHPBB_ROOT_PATH', './../');
if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
-// Report all errors, except notices
-error_reporting(E_ALL ^ E_NOTICE);
+// Include bootstrap
+include PHPBB_ROOT_PATH . 'includes/core/bootstrap.' . PHP_EXT;
-// @todo Review this test and see if we can find out what it is which prevents PHP 4.2.x from even displaying the page with requirements on it
-if (version_compare(PHP_VERSION, '5.2.0') < 0)
-{
- die('You are running an unsupported PHP version. Please upgrade to PHP 5.2.0 or higher before trying to install phpBB 3.0');
-}
-
-/*
-* Remove variables created by register_globals from the global scope
-* Thanks to Matt Kavanagh
-*/
-function deregister_globals()
-{
- $not_unset = array(
- 'GLOBALS' => true,
- '_GET' => true,
- '_POST' => true,
- '_COOKIE' => true,
- '_REQUEST' => true,
- '_SERVER' => true,
- '_SESSION' => true,
- '_ENV' => true,
- '_FILES' => true,
- 'phpEx' => true,
- 'phpbb_root_path' => true
- );
-
- // Not only will array_merge and array_keys give a warning if
- // a parameter is not an array, array_merge will actually fail.
- // So we check if _SESSION has been initialised.
- if (!isset($_SESSION) || !is_array($_SESSION))
- {
- $_SESSION = array();
- }
-
- // Merge all into one extremely huge array; unset this later
- $input = array_merge(
- array_keys($_GET),
- array_keys($_POST),
- array_keys($_COOKIE),
- array_keys($_SERVER),
- array_keys($_SESSION),
- array_keys($_ENV),
- array_keys($_FILES)
- );
-
- foreach ($input as $varname)
- {
- if (isset($not_unset[$varname]))
- {
- // Hacking attempt. No point in continuing unless it's a COOKIE
- if ($varname !== 'GLOBALS' || isset($_GET['GLOBALS']) || isset($_POST['GLOBALS']) || isset($_SERVER['GLOBALS']) || isset($_SESSION['GLOBALS']) || isset($_ENV['GLOBALS']) || isset($_FILES['GLOBALS']))
- {
- exit;
- }
- else
- {
- $cookie = &$_COOKIE;
- while (isset($cookie['GLOBALS']))
- {
- foreach ($cookie['GLOBALS'] as $registered_var => $value)
- {
- if (!isset($not_unset[$registered_var]))
- {
- unset($GLOBALS[$registered_var]);
- }
- }
- $cookie = &$cookie['GLOBALS'];
- }
- }
- }
-
- unset($GLOBALS[$varname]);
- }
-
- unset($input);
-}
+// Includes functions for the installer
+require PHPBB_ROOT_PATH . 'includes/functions_install.' . PHP_EXT;
-// If we are on PHP >= 6.0.0 we do not need some code
-if (version_compare(PHP_VERSION, '6.0.0-dev', '>='))
-{
- /**
- * @ignore
- */
- define('STRIP', false);
-}
-else
-{
- @set_magic_quotes_runtime(0);
-
- // Be paranoid with passed vars
- if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
- {
- deregister_globals();
- }
-
- define('STRIP', (get_magic_quotes_gpc()) ? true : false);
-}
-
-// Try to override some limits - maybe it helps some...
+// Set time limit to 0
@set_time_limit(0);
+
+/**
+* @todo get memory limit and display notice if it is too low for a conversion (only within conversion)
$mem_limit = @ini_get('memory_limit');
if (!empty($mem_limit))
{
@@ -146,25 +54,9 @@ else
$mem_limit = '128M';
}
@ini_set('memory_limit', $mem_limit);
+*/
-// Include essential scripts
-require(PHPBB_ROOT_PATH . 'includes/functions.' . PHP_EXT);
-
-if (file_exists(PHPBB_ROOT_PATH . 'includes/functions_content.' . PHP_EXT))
-{
- require(PHPBB_ROOT_PATH . 'includes/functions_content.' . PHP_EXT);
-}
-
-include(PHPBB_ROOT_PATH . 'includes/auth.' . PHP_EXT);
-include(PHPBB_ROOT_PATH . 'includes/session.' . PHP_EXT);
-include(PHPBB_ROOT_PATH . 'includes/template.' . PHP_EXT);
-include(PHPBB_ROOT_PATH . 'includes/acm/acm_file.' . PHP_EXT);
-include(PHPBB_ROOT_PATH . 'includes/cache.' . PHP_EXT);
-include(PHPBB_ROOT_PATH . 'includes/functions_admin.' . PHP_EXT);
-include(PHPBB_ROOT_PATH . 'includes/utf/utf_tools.' . PHP_EXT);
-require(PHPBB_ROOT_PATH . 'includes/functions_install.' . PHP_EXT);
-
-// Try and load an appropriate language if required
+/* Try and load an appropriate language if required
$language = basename(request_var('language', ''));
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !$language)
@@ -230,7 +122,26 @@ include(PHPBB_ROOT_PATH . 'language/' . $language . '/acp/board.' . PHP_EXT);
include(PHPBB_ROOT_PATH . 'language/' . $language . '/install.' . PHP_EXT);
include(PHPBB_ROOT_PATH . 'language/' . $language . '/posting.' . PHP_EXT);
-// usually we would need every single constant here - and it would be consistent. For 3.0.x, use a dirty hack... :(
+*/
+
+// Initialize some common config variables
+phpbb::$config += array(
+ 'load_tplcompile' => true,
+ 'cookie_name' => '',
+);
+
+// Register the template and the user object
+phpbb::register('template');
+phpbb::register('user', false, false, 'db', PHPBB_ROOT_PATH . 'language/');
+
+// Init "loose" user session
+phpbb::$user->session_begin();
+
+// Now set users language
+phpbb::$user->set_language(request_var('language', ''));
+
+// And also add the install language file
+phpbb::$user->add_lang('install');
$mode = request_var('mode', 'overview');
$sub = request_var('sub', '');
@@ -238,15 +149,8 @@ $sub = request_var('sub', '');
// Set PHP error handler to ours
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
-$user = new user();
-$auth = new auth();
-$template = new template();
-
-// Set some standard variables we want to force
-phpbb::$config['load_tplcompile'] = '1';
-
-$template->set_custom_template('../adm/style', 'admin');
-$template->assign_var('T_TEMPLATE_PATH', '../adm/style');
+phpbb::$template->set_custom_template('../adm/style', 'admin');
+phpbb::$template->assign_var('T_TEMPLATE_PATH', '../adm/style');
$install = new module();
@@ -257,7 +161,7 @@ $install->load();
$install->page_header();
$install->generate_navigation();
-$template->set_filenames(array(
+phpbb::$template->set_filenames(array(
'body' => $install->get_tpl_name())
);
@@ -282,8 +186,6 @@ class module
*/
function create($module_type, $module_url, $selected_mod = false, $selected_submod = false)
{
- global $db;
-
$module = array();
// Grab module information using Bart's "neat-o-module" system (tm)
@@ -393,22 +295,18 @@ class module
}
define('HEADER_INC', true);
- global $template, $lang, $stage;
+ global $stage;
- $template->assign_vars(array(
- 'L_CHANGE' => $lang['CHANGE'],
- 'L_INSTALL_PANEL' => $lang['INSTALL_PANEL'],
- 'L_SELECT_LANG' => $lang['SELECT_LANG'],
- 'L_SKIP' => $lang['SKIP'],
+ phpbb::$template->assign_vars(array(
'PAGE_TITLE' => $this->get_page_title(),
'T_IMAGE_PATH' => PHPBB_ROOT_PATH . 'adm/images/',
- 'S_CONTENT_DIRECTION' => $lang['DIRECTION'],
- 'S_CONTENT_FLOW_BEGIN' => ($lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
- 'S_CONTENT_FLOW_END' => ($lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
+ 'S_CONTENT_DIRECTION' => phpbb::$user->lang['DIRECTION'],
+ 'S_CONTENT_FLOW_BEGIN' => (phpbb::$user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
+ 'S_CONTENT_FLOW_END' => (phpbb::$user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
'S_CONTENT_ENCODING' => 'UTF-8',
- 'S_USER_LANG' => $lang['USER_LANG'],
+ 'S_USER_LANG' => phpbb::$user->lang['USER_LANG'],
)
);
@@ -425,14 +323,12 @@ class module
*/
function page_footer()
{
- global $db, $template;
-
- $template->display('body');
+ phpbb::$template->display('body');
// Close our DB connection.
- if (!empty($db) && is_object($db))
+ if (phpbb::registered('db'))
{
- $db->sql_close();
+ phpbb::$db->sql_close();
}
if (function_exists('exit_handler'))
@@ -454,52 +350,12 @@ class module
*/
function get_page_title()
{
- global $lang;
-
if (!isset($this->module->page_title))
{
return '';
}
- return (isset($lang[$this->module->page_title])) ? $lang[$this->module->page_title] : $this->module->page_title;
- }
-
- /**
- * Generate an HTTP/1.1 header to redirect the user to another page
- * This is used during the installation when we do not have a database available to call the normal redirect function
- * @param string $page The page to redirect to relative to the installer root path
- */
- function redirect($page)
- {
- // HTTP_HOST is having the correct browser url in most cases...
- $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
- $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
- $secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0;
-
- $script_name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
- if (!$script_name)
- {
- $script_name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
- }
-
- // Replace backslashes and doubled slashes (could happen on some proxy setups)
- $script_name = str_replace(array('\\', '//'), '/', $script_name);
- $script_path = trim(dirname($script_name));
-
- $url = (($secure) ? 'https://' : 'http://') . $server_name;
-
- if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
- {
- // HTTP HOST can carry a port number...
- if (strpos($server_name, ':') === false)
- {
- $url .= ':' . $server_port;
- }
- }
-
- $url .= $script_path . '/' . $page;
- header('Location: ' . $url);
- exit;
+ return (isset(phpbb::$user->lang[$this->module->page_title])) ? phpbb::$user->lang[$this->module->page_title] : $this->module->page_title;
}
/**
@@ -507,8 +363,6 @@ class module
*/
function generate_navigation()
{
- global $lang, $template, $language;
-
if (is_array($this->module_ary))
{
@ksort($this->module_ary);
@@ -517,11 +371,11 @@ class module
$cat = $cat_ary['name'];
$l_cat = (!empty($lang['CAT_' . $cat])) ? $lang['CAT_' . $cat] : preg_replace('#_#', ' ', $cat);
$cat = strtolower($cat);
- $url = $this->module_url . "?mode=$cat&amp;language=$language";
+ $url = $this->module_url . "?mode=$cat&amp;language=" . phpbb::$user->lang_name;
if ($this->mode == $cat)
{
- $template->assign_block_vars('t_block1', array(
+ phpbb::$template->assign_block_vars('t_block1', array(
'L_TITLE' => $l_cat,
'S_SELECTED' => true,
'U_TITLE' => $url,
@@ -532,11 +386,11 @@ class module
$subs = $this->module_ary[$this->id]['subs'];
foreach ($subs as $option)
{
- $l_option = (!empty($lang['SUB_' . $option])) ? $lang['SUB_' . $option] : preg_replace('#_#', ' ', $option);
+ $l_option = (!empty(phpbb::$user->lang['SUB_' . $option])) ? phpbb::$user->lang['SUB_' . $option] : preg_replace('#_#', ' ', $option);
$option = strtolower($option);
- $url = $this->module_url . '?mode=' . $this->mode . "&amp;sub=$option&amp;language=$language";
+ $url = $this->module_url . '?mode=' . $this->mode . "&amp;sub=$option&amp;language=" . phpbb::$user->lang_name;
- $template->assign_block_vars('l_block1', array(
+ phpbb::$template->assign_block_vars('l_block1', array(
'L_TITLE' => $l_option,
'S_SELECTED' => ($this->sub == $option),
'U_TITLE' => $url,
@@ -550,11 +404,11 @@ class module
$matched = false;
foreach ($subs as $option)
{
- $l_option = (!empty($lang['STAGE_' . $option])) ? $lang['STAGE_' . $option] : preg_replace('#_#', ' ', $option);
+ $l_option = (!empty(phpbb::$user->lang['STAGE_' . $option])) ? phpbb::$user->lang['STAGE_' . $option] : preg_replace('#_#', ' ', $option);
$option = strtolower($option);
$matched = ($this->sub == $option) ? true : $matched;
- $template->assign_block_vars('l_block2', array(
+ phpbb::$template->assign_block_vars('l_block2', array(
'L_TITLE' => $l_option,
'S_SELECTED' => ($this->sub == $option),
'S_COMPLETE' => !$matched,
@@ -564,7 +418,7 @@ class module
}
else
{
- $template->assign_block_vars('t_block1', array(
+ phpbb::$template->assign_block_vars('t_block1', array(
'L_TITLE' => $l_cat,
'S_SELECTED' => false,
'U_TITLE' => $url,
@@ -578,106 +432,38 @@ class module
* Output an error message
* If skip is true, return and continue execution, else exit
*/
- function error($error, $line, $file, $skip = false)
+ function error($error, $line, $file)
{
- global $lang, $db, $template;
-
- if ($skip)
- {
- $template->assign_block_vars('checks', array(
- 'S_LEGEND' => true,
- 'LEGEND' => $lang['INST_ERR'],
- ));
-
- $template->assign_block_vars('checks', array(
- 'TITLE' => basename($file) . ' [ ' . $line . ' ]',
- 'RESULT' => '<b style="color:red">' . $error . '</b>',
- ));
-
- return;
- }
+ phpbb::$template->assign_block_vars('checks', array(
+ 'S_LEGEND' => true,
+ 'LEGEND' => phpbb::$user->lang['INST_ERR'],
+ ));
- echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
- echo '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">';
- echo '<head>';
- echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
- echo '<title>' . $lang['INST_ERR_FATAL'] . '</title>';
- echo '<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />';
- echo '</head>';
- echo '<body id="errorpage">';
- echo '<div id="wrap">';
- echo ' <div id="page-header">';
- echo ' </div>';
- echo ' <div id="page-body">';
- echo ' <div id="acp">';
- echo ' <div class="panel">';
- echo ' <span class="corners-top"><span></span></span>';
- echo ' <div id="content">';
- echo ' <h1>' . $lang['INST_ERR_FATAL'] . '</h1>';
- echo ' <p>' . $lang['INST_ERR_FATAL'] . "</p>\n";
- echo ' <p>' . basename($file) . ' [ ' . $line . " ]</p>\n";
- echo ' <p><b>' . $error . "</b></p>\n";
- echo ' </div>';
- echo ' <span class="corners-bottom"><span></span></span>';
- echo ' </div>';
- echo ' </div>';
- echo ' </div>';
- echo ' <div id="page-footer">';
- echo ' Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>';
- echo ' </div>';
- echo '</div>';
- echo '</body>';
- echo '</html>';
-
- if (!empty($db) && is_object($db))
- {
- $db->sql_close();
- }
+ phpbb::$template->assign_block_vars('checks', array(
+ 'TITLE' => basename($file) . ' [ ' . $line . ' ]',
+ 'RESULT' => '<b style="color:red">' . $error . '</b>',
+ ));
- exit_handler();
+ return;
}
/**
* Output an error message for a database related problem
* If skip is true, return and continue execution, else exit
*/
- function db_error($error, $sql, $line, $file, $skip = false)
+ function db_error($error, $sql, $line, $file)
{
- global $lang, $db, $template;
-
- if ($skip)
- {
- $template->assign_block_vars('checks', array(
- 'S_LEGEND' => true,
- 'LEGEND' => $lang['INST_ERR_FATAL'],
- ));
-
- $template->assign_block_vars('checks', array(
- 'TITLE' => basename($file) . ' [ ' . $line . ' ]',
- 'RESULT' => '<b style="color:red">' . $error . '</b><br />&#187; SQL:' . $sql,
- ));
-
- return;
- }
-
- $template->set_filenames(array(
- 'body' => 'install_error.html')
- );
- $this->page_header();
- $this->generate_navigation();
-
- $template->assign_vars(array(
- 'MESSAGE_TITLE' => $lang['INST_ERR_FATAL_DB'],
- 'MESSAGE_TEXT' => '<p>' . basename($file) . ' [ ' . $line . ' ]</p><p>SQL : ' . $sql . '</p><p><b>' . $error . '</b></p>',
+ phpbb::$template->assign_block_vars('checks', array(
+ 'S_LEGEND' => true,
+ 'LEGEND' => phpbb::$user->lang['INST_ERR_FATAL'],
));
- // Rollback if in transaction
- if ($db->transaction)
- {
- $db->sql_transaction('rollback');
- }
+ phpbb::$template->assign_block_vars('checks', array(
+ 'TITLE' => basename($file) . ' [ ' . $line . ' ]',
+ 'RESULT' => '<b style="color:red">' . $error . '</b><br />&#187; SQL:' . $sql,
+ ));
- $this->page_footer();
+ return;
}
/**
@@ -685,7 +471,6 @@ class module
*/
function input_field($name, $type, $value='', $options='')
{
- global $lang;
$tpl_type = explode(':', $type);
$tpl = '';
@@ -713,8 +498,8 @@ class module
$tpl_type_cond = explode('_', $tpl_type[1]);
$type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true;
- $tpl_no = '<label><input type="radio" name="' . $name . '" value="0"' . $key_no . ' class="radio" /> ' . (($type_no) ? $lang['NO'] : $lang['DISABLED']) . '</label>';
- $tpl_yes = '<label><input type="radio" name="' . $name . '" value="1"' . $key_yes . ' class="radio" /> ' . (($type_no) ? $lang['YES'] : $lang['ENABLED']) . '</label>';
+ $tpl_no = '<label><input type="radio" name="' . $name . '" value="0"' . $key_no . ' class="radio" /> ' . (($type_no) ? phpbb::$user->lang['NO'] : phpbb::$user->lang['DISABLED']) . '</label>';
+ $tpl_yes = '<label><input type="radio" name="' . $name . '" value="1"' . $key_yes . ' class="radio" /> ' . (($type_no) ? phpbb::$user->lang['YES'] : phpbb::$user->lang['ENABLED']) . '</label>';
$tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . '&nbsp;&nbsp;' . $tpl_no : $tpl_no . '&nbsp;&nbsp;' . $tpl_yes;
break;
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index d38b833204..407f1725dc 100644
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -53,53 +53,83 @@ class install_install extends module
function main($mode, $sub)
{
- global $lang, $template, $language;
+ phpbb::$template->assign_vars(array(
+ 'S_SUB' => $sub,
+ 'S_LANG_SELECT' => '<select id="language" name="language">' . $this->p_master->inst_language_select(phpbb::$user->lang_name) . '</select>',
+ ));
switch ($sub)
{
case 'intro':
- $this->page_title = $lang['SUB_INTRO'];
-
- $template->assign_vars(array(
- 'TITLE' => $lang['INSTALL_INTRO'],
- 'BODY' => $lang['INSTALL_INTRO_BODY'],
- 'L_SUBMIT' => $lang['NEXT_STEP'],
- 'S_LANG_SELECT' => '<select id="language" name="language">' . $this->p_master->inst_language_select($language) . '</select>',
- 'U_ACTION' => $this->p_master->module_url . "?mode=$mode&amp;sub=requirements&amp;language=$language",
+ $this->page_title = 'SUB_INTRO';
+
+ phpbb::$template->assign_vars(array(
+ 'U_ACTION' => phpbb::$url->append_sid($this->p_master->module_url, "mode=$mode&amp;sub=requirements&amp;language=" . phpbb::$user->lang_name),
));
break;
case 'requirements':
+ $this->page_title = 'STAGE_REQUIREMENTS';
$this->check_server_requirements($mode, $sub);
-
break;
case 'database':
- $this->obtain_database_settings($mode, $sub);
+ $this->page_title = 'STAGE_DATABASE';
+ // Obtain any submitted data
+ $data = $this->get_submitted_data();
+
+ $this->obtain_database_settings($mode, $sub, $data);
break;
case 'administrator':
- $this->obtain_admin_settings($mode, $sub);
+ $this->page_title = 'STAGE_ADMINISTRATOR';
+
+ phpbb::$user->add_lang('acp/board');
+
+ // Obtain any submitted data
+ $data = $this->get_submitted_data();
+
+ $this->obtain_admin_settings($mode, $sub, $data);
break;
case 'config_file':
- $this->create_config_file($mode, $sub);
+ $this->page_title = 'STAGE_CONFIG_FILE';
+
+ // Obtain any submitted data
+ $data = $this->get_submitted_data();
+ $this->create_config_file($mode, $sub, $data);
break;
case 'advanced':
- $this->obtain_advanced_settings($mode, $sub);
+ $this->page_title = 'STAGE_ADVANCED';
+
+ phpbb::$user->add_lang('acp/common');
+ phpbb::$user->add_lang('acp/board');
+ // Obtain any submitted data
+ $data = $this->get_submitted_data();
+
+ $this->obtain_advanced_settings($mode, $sub, $data);
break;
case 'create_table':
- $this->load_schema($mode, $sub);
+ $this->page_title = 'STAGE_CREATE_TABLE';
+
+ // Obtain any submitted data
+ $data = $this->get_submitted_data();
+
+ $this->load_schema($mode, $sub, $data);
break;
case 'final':
+ $this->page_title = 'STAGE_FINAL';
+
+ include PHPBB_ROOT_PATH . 'common.' . PHP_EXT;
+
$this->build_search_index($mode, $sub);
$this->add_modules($mode, $sub);
$this->add_language($mode, $sub);
@@ -112,7 +142,66 @@ class install_install extends module
break;
}
- $this->tpl_name = 'install_install';
+ $this->tpl_name = 'install/install';
+ }
+
+ function build_form($data, $form_array)
+ {
+ foreach ($form_array as $config_key => $vars)
+ {
+ if (!is_array($vars) && strpos($config_key, 'legend') === false)
+ {
+ continue;
+ }
+
+ if (strpos($config_key, 'legend') !== false)
+ {
+ phpbb::$template->assign_block_vars('options', array(
+ 'S_LEGEND' => true,
+ 'LEGEND' => phpbb::$user->lang[$vars],
+ ));
+
+ continue;
+ }
+
+ $options = isset($vars['options']) ? $vars['options'] : '';
+
+ phpbb::$template->assign_block_vars('options', array(
+ 'KEY' => $config_key,
+ 'TITLE' => phpbb::$user->lang[$vars['lang']],
+ 'S_EXPLAIN' => $vars['explain'],
+ 'TITLE_EXPLAIN' => ($vars['explain']) ? phpbb::$user->lang[$vars['lang'] . '_EXPLAIN'] : '',
+ 'CONTENT' => $this->p_master->input_field($config_key, $vars['type'], $data[$config_key], $options),
+ ));
+ }
+ }
+
+ function return_hidden_fields()
+ {
+ $args = func_get_args();
+ $data = array_shift($args);
+
+ $s_hidden_fields = '';
+
+ foreach ($args as $argument)
+ {
+ if (!is_array($argument))
+ {
+ continue;
+ }
+
+ foreach ($argument as $config_key => $vars)
+ {
+ if (!is_array($vars))
+ {
+ continue;
+ }
+
+ $s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
+ }
+ }
+
+ return $s_hidden_fields;
}
/**
@@ -120,168 +209,140 @@ class install_install extends module
*/
function check_server_requirements($mode, $sub)
{
- global $lang, $template, $language;
-
- $this->page_title = $lang['STAGE_REQUIREMENTS'];
-
- $template->assign_vars(array(
- 'TITLE' => $lang['REQUIREMENTS_TITLE'],
- 'BODY' => $lang['REQUIREMENTS_EXPLAIN'],
- ));
-
$passed = array('php' => false, 'db' => false, 'files' => false, 'pcre' => false, 'imagesize' => false,);
// Test for basic PHP settings
- $template->assign_block_vars('checks', array(
+ phpbb::$template->assign_block_vars('checks', array(
'S_LEGEND' => true,
- 'LEGEND' => $lang['PHP_SETTINGS'],
- 'LEGEND_EXPLAIN' => $lang['PHP_SETTINGS_EXPLAIN'],
+ 'LEGEND' => phpbb::$user->lang['PHP_SETTINGS'],
+ 'LEGEND_EXPLAIN' => phpbb::$user->lang['PHP_SETTINGS_EXPLAIN'],
));
// Test the minimum PHP version
- $php_version = PHP_VERSION;
-
- if (version_compare($php_version, '5.2.0') < 0)
+ if (version_compare(PHP_VERSION, '5.2.0') < 0)
{
- $result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
+ $result = '<strong style="color:red">' . phpbb::$user->lang['NO'] . '</strong>';
}
else
{
$passed['php'] = true;
// We also give feedback on whether we're running in safe mode
- $result = '<strong style="color:green">' . $lang['YES'];
+ $result = '<strong style="color:green">' . phpbb::$user->lang['YES'];
if (@ini_get('safe_mode') == '1' || strtolower(@ini_get('safe_mode')) == 'on')
{
- $result .= ', ' . $lang['PHP_SAFE_MODE'];
+ $result .= ', ' . phpbb::$user->lang['PHP_SAFE_MODE'];
}
$result .= '</strong>';
}
- $template->assign_block_vars('checks', array(
- 'TITLE' => $lang['PHP_VERSION_REQD'],
+ phpbb::$template->assign_block_vars('checks', array(
+ 'TITLE' => phpbb::$user->lang['PHP_VERSION_REQD'],
'RESULT' => $result,
-
- 'S_EXPLAIN' => false,
- 'S_LEGEND' => false,
));
// Check for register_globals being enabled
if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
{
- $result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
+ $result = '<strong style="color:red">' . phpbb::$user->lang['NO'] . '</strong>';
}
else
{
- $result = '<strong style="color:green">' . $lang['YES'] . '</strong>';
+ $result = '<strong style="color:green">' . phpbb::$user->lang['YES'] . '</strong>';
}
- $template->assign_block_vars('checks', array(
- 'TITLE' => $lang['PHP_REGISTER_GLOBALS'],
- 'TITLE_EXPLAIN' => $lang['PHP_REGISTER_GLOBALS_EXPLAIN'],
+ phpbb::$template->assign_block_vars('checks', array(
+ 'TITLE' => phpbb::$user->lang['PHP_REGISTER_GLOBALS'],
+ 'TITLE_EXPLAIN' => phpbb::$user->lang['PHP_REGISTER_GLOBALS_EXPLAIN'],
'RESULT' => $result,
'S_EXPLAIN' => true,
- 'S_LEGEND' => false,
));
-
// Check for url_fopen
if (@ini_get('allow_url_fopen') == '1' || strtolower(@ini_get('allow_url_fopen')) == 'on')
{
- $result = '<strong style="color:green">' . $lang['YES'] . '</strong>';
+ $result = '<strong style="color:green">' . phpbb::$user->lang['YES'] . '</strong>';
}
else
{
- $result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
+ $result = '<strong style="color:red">' . phpbb::$user->lang['NO'] . '</strong>';
}
- $template->assign_block_vars('checks', array(
- 'TITLE' => $lang['PHP_URL_FOPEN_SUPPORT'],
- 'TITLE_EXPLAIN' => $lang['PHP_URL_FOPEN_SUPPORT_EXPLAIN'],
+ phpbb::$template->assign_block_vars('checks', array(
+ 'TITLE' => phpbb::$user->lang['PHP_URL_FOPEN_SUPPORT'],
+ 'TITLE_EXPLAIN' => phpbb::$user->lang['PHP_URL_FOPEN_SUPPORT_EXPLAIN'],
'RESULT' => $result,
'S_EXPLAIN' => true,
- 'S_LEGEND' => false,
));
-
// Check for getimagesize
if (@function_exists('getimagesize'))
{
$passed['imagesize'] = true;
- $result = '<strong style="color:green">' . $lang['YES'] . '</strong>';
+ $result = '<strong style="color:green">' . phpbb::$user->lang['YES'] . '</strong>';
}
else
{
- $result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
+ $result = '<strong style="color:red">' . phpbb::$user->lang['NO'] . '</strong>';
}
- $template->assign_block_vars('checks', array(
- 'TITLE' => $lang['PHP_GETIMAGESIZE_SUPPORT'],
- 'TITLE_EXPLAIN' => $lang['PHP_GETIMAGESIZE_SUPPORT_EXPLAIN'],
+ phpbb::$template->assign_block_vars('checks', array(
+ 'TITLE' => phpbb::$user->lang['PHP_GETIMAGESIZE_SUPPORT'],
+ 'TITLE_EXPLAIN' => phpbb::$user->lang['PHP_GETIMAGESIZE_SUPPORT_EXPLAIN'],
'RESULT' => $result,
'S_EXPLAIN' => true,
- 'S_LEGEND' => false,
));
// Check for PCRE UTF-8 support
if (@preg_match('//u', ''))
{
$passed['pcre'] = true;
- $result = '<strong style="color:green">' . $lang['YES'] . '</strong>';
+ $result = '<strong style="color:green">' . phpbb::$user->lang['YES'] . '</strong>';
}
else
{
- $result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
+ $result = '<strong style="color:red">' . phpbb::$user->lang['NO'] . '</strong>';
}
- $template->assign_block_vars('checks', array(
- 'TITLE' => $lang['PCRE_UTF_SUPPORT'],
- 'TITLE_EXPLAIN' => $lang['PCRE_UTF_SUPPORT_EXPLAIN'],
+ phpbb::$template->assign_block_vars('checks', array(
+ 'TITLE' => phpbb::$user->lang['PCRE_UTF_SUPPORT'],
+ 'TITLE_EXPLAIN' => phpbb::$user->lang['PCRE_UTF_SUPPORT_EXPLAIN'],
'RESULT' => $result,
'S_EXPLAIN' => true,
- 'S_LEGEND' => false,
));
// Check for PCRE unicode property support
if (@preg_match('/\p{Ll}/u', 'a'))
{
$passed['pcre'] = true;
- $result = '<strong style="color:green">' . $lang['YES'] . '</strong>';
+ $result = '<strong style="color:green">' . phpbb::$user->lang['YES'] . '</strong>';
}
else
{
- $result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
+ $result = '<strong style="color:red">' . phpbb::$user->lang['NO'] . '</strong>';
}
- $template->assign_block_vars('checks', array(
- 'TITLE' => $lang['PCRE_UNI_PROP_SUPPORT'],
- 'TITLE_EXPLAIN' => $lang['PCRE_UNI_PROP_SUPPORT_EXPLAIN'],
+ phpbb::$template->assign_block_vars('checks', array(
+ 'TITLE' => phpbb::$user->lang['PCRE_UNI_PROP_SUPPORT'],
+ 'TITLE_EXPLAIN' => phpbb::$user->lang['PCRE_UNI_PROP_SUPPORT_EXPLAIN'],
'RESULT' => $result,
'S_EXPLAIN' => true,
- 'S_LEGEND' => false,
));
-/**
-* Better not enabling and adding to the loaded extensions due to the specific requirements needed
- if (!@extension_loaded('mbstring'))
- {
- can_load_dll('mbstring');
- }
-*/
-
+ // MBString passes always. If the extension is loaded it only can interfere with our functions, set to false then
$passed['mbstring'] = true;
if (@extension_loaded('mbstring'))
{
// Test for available database modules
- $template->assign_block_vars('checks', array(
+ phpbb::$template->assign_block_vars('checks', array(
'S_LEGEND' => true,
- 'LEGEND' => $lang['MBSTRING_CHECK'],
- 'LEGEND_EXPLAIN' => $lang['MBSTRING_CHECK_EXPLAIN'],
+ 'LEGEND' => phpbb::$user->lang['MBSTRING_CHECK'],
+ 'LEGEND_EXPLAIN' => phpbb::$user->lang['MBSTRING_CHECK_EXPLAIN'],
));
$checks = array(
@@ -299,43 +360,43 @@ class install_install extends module
case '&':
if (intval($ini_val) & $mb_checks[2])
{
- $result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
+ $result = '<strong style="color:red">' . phpbb::$user->lang['NO'] . '</strong>';
$passed['mbstring'] = false;
}
else
{
- $result = '<strong style="color:green">' . $lang['YES'] . '</strong>';
+ $result = '<strong style="color:green">' . phpbb::$user->lang['YES'] . '</strong>';
}
break;
case '!=':
if ($ini_val != $mb_checks[2])
{
- $result = '<strong style="color:red">' . $lang['NO'] . '</strong>';
+ $result = '<strong style="color:red">' . phpbb::$user->lang['NO'] . '</strong>';
$passed['mbstring'] = false;
}
else
{
- $result = '<strong style="color:green">' . $lang['YES'] . '</strong>';
+ $result = '<strong style="color:green">' . phpbb::$user->lang['YES'] . '</strong>';
}
break;
}
- $template->assign_block_vars('checks', array(
- 'TITLE' => $lang['MBSTRING_' . strtoupper($mb_checks[0])],
- 'TITLE_EXPLAIN' => $lang['MBSTRING_' . strtoupper($mb_checks[0]) . '_EXPLAIN'],
+
+ phpbb::$template->assign_block_vars('checks', array(
+ 'TITLE' => phpbb::$user->lang['MBSTRING_' . strtoupper($mb_checks[0])],
+ 'TITLE_EXPLAIN' => phpbb::$user->lang['MBSTRING_' . strtoupper($mb_checks[0]) . '_EXPLAIN'],
'RESULT' => $result,
'S_EXPLAIN' => true,
- 'S_LEGEND' => false,
));
}
}
// Test for available database modules
- $template->assign_block_vars('checks', array(
+ phpbb::$template->assign_block_vars('checks', array(
'S_LEGEND' => true,
- 'LEGEND' => $lang['PHP_SUPPORTED_DB'],
- 'LEGEND_EXPLAIN' => $lang['PHP_SUPPORTED_DB_EXPLAIN'],
+ 'LEGEND' => phpbb::$user->lang['PHP_SUPPORTED_DB'],
+ 'LEGEND_EXPLAIN' => phpbb::$user->lang['PHP_SUPPORTED_DB_EXPLAIN'],
));
$available_dbms = get_available_dbms(false, true);
@@ -346,31 +407,25 @@ class install_install extends module
{
if (!$db_ary['AVAILABLE'])
{
- $template->assign_block_vars('checks', array(
- 'TITLE' => $lang['DLL_' . strtoupper($db_name)],
- 'RESULT' => '<span style="color:red">' . $lang['UNAVAILABLE'] . '</span>',
-
- 'S_EXPLAIN' => false,
- 'S_LEGEND' => false,
+ phpbb::$template->assign_block_vars('checks', array(
+ 'TITLE' => phpbb::$user->lang['DLL_' . strtoupper($db_name)],
+ 'RESULT' => '<span style="color:red">' . phpbb::$user->lang['UNAVAILABLE'] . '</span>',
));
}
else
{
- $template->assign_block_vars('checks', array(
- 'TITLE' => $lang['DLL_' . strtoupper($db_name)],
- 'RESULT' => '<strong style="color:green">' . $lang['AVAILABLE'] . '</strong>',
-
- 'S_EXPLAIN' => false,
- 'S_LEGEND' => false,
+ phpbb::$template->assign_block_vars('checks', array(
+ 'TITLE' => phpbb::$user->lang['DLL_' . strtoupper($db_name)],
+ 'RESULT' => '<strong style="color:green">' . phpbb::$user->lang['AVAILABLE'] . '</strong>',
));
}
}
// Test for other modules
- $template->assign_block_vars('checks', array(
+ phpbb::$template->assign_block_vars('checks', array(
'S_LEGEND' => true,
- 'LEGEND' => $lang['PHP_OPTIONAL_MODULE'],
- 'LEGEND_EXPLAIN' => $lang['PHP_OPTIONAL_MODULE_EXPLAIN'],
+ 'LEGEND' => phpbb::$user->lang['PHP_OPTIONAL_MODULE'],
+ 'LEGEND_EXPLAIN' => phpbb::$user->lang['PHP_OPTIONAL_MODULE_EXPLAIN'],
));
foreach ($this->php_dlls_other as $dll)
@@ -379,23 +434,17 @@ class install_install extends module
{
if (!can_load_dll($dll))
{
- $template->assign_block_vars('checks', array(
- 'TITLE' => $lang['DLL_' . strtoupper($dll)],
- 'RESULT' => '<strong style="color:red">' . $lang['UNAVAILABLE'] . '</strong>',
-
- 'S_EXPLAIN' => false,
- 'S_LEGEND' => false,
+ phpbb::$template->assign_block_vars('checks', array(
+ 'TITLE' => phpbb::$user->lang['DLL_' . strtoupper($dll)],
+ 'RESULT' => '<strong style="color:red">' . phpbb::$user->lang['UNAVAILABLE'] . '</strong>',
));
continue;
}
}
- $template->assign_block_vars('checks', array(
- 'TITLE' => $lang['DLL_' . strtoupper($dll)],
- 'RESULT' => '<strong style="color:green">' . $lang['AVAILABLE'] . '</strong>',
-
- 'S_EXPLAIN' => false,
- 'S_LEGEND' => false,
+ phpbb::$template->assign_block_vars('checks', array(
+ 'TITLE' => phpbb::$user->lang['DLL_' . strtoupper($dll)],
+ 'RESULT' => '<strong style="color:green">' . phpbb::$user->lang['AVAILABLE'] . '</strong>',
));
}
@@ -430,19 +479,16 @@ class install_install extends module
$img_imagick = str_replace('\\', '/', $magic_home);
}
- $template->assign_block_vars('checks', array(
- 'TITLE' => $lang['APP_MAGICK'],
- 'RESULT' => ($img_imagick) ? '<strong style="color:green">' . $lang['AVAILABLE'] . ', ' . $img_imagick . '</strong>' : '<strong style="color:blue">' . $lang['NO_LOCATION'] . '</strong>',
-
- 'S_EXPLAIN' => false,
- 'S_LEGEND' => false,
+ phpbb::$template->assign_block_vars('checks', array(
+ 'TITLE' => phpbb::$user->lang['APP_MAGICK'],
+ 'RESULT' => ($img_imagick) ? '<strong style="color:green">' . phpbb::$user->lang['AVAILABLE'] . ', ' . htmlspecialchars($img_imagick) . '</strong>' : '<strong style="color:blue">' . phpbb::$user->lang['NO_LOCATION'] . '</strong>',
));
// Check permissions on files/directories we need access to
- $template->assign_block_vars('checks', array(
+ phpbb::$template->assign_block_vars('checks', array(
'S_LEGEND' => true,
- 'LEGEND' => $lang['FILES_REQUIRED'],
- 'LEGEND_EXPLAIN' => $lang['FILES_REQUIRED_EXPLAIN'],
+ 'LEGEND' => phpbb::$user->lang['FILES_REQUIRED'],
+ 'LEGEND_EXPLAIN' => phpbb::$user->lang['FILES_REQUIRED_EXPLAIN'],
));
$directories = array('cache/', 'files/', 'store/');
@@ -480,23 +526,20 @@ class install_install extends module
$passed['files'] = ($exists && $write && $passed['files']) ? true : false;
- $exists = ($exists) ? '<strong style="color:green">' . $lang['FOUND'] . '</strong>' : '<strong style="color:red">' . $lang['NOT_FOUND'] . '</strong>';
- $write = ($write) ? ', <strong style="color:green">' . $lang['WRITABLE'] . '</strong>' : (($exists) ? ', <strong style="color:red">' . $lang['UNWRITABLE'] . '</strong>' : '');
+ $exists = ($exists) ? '<strong style="color:green">' . phpbb::$user->lang['FOUND'] . '</strong>' : '<strong style="color:red">' . phpbb::$user->lang['NOT_FOUND'] . '</strong>';
+ $write = ($write) ? ', <strong style="color:green">' . phpbb::$user->lang['WRITABLE'] . '</strong>' : (($exists) ? ', <strong style="color:red">' . phpbb::$user->lang['UNWRITABLE'] . '</strong>' : '');
- $template->assign_block_vars('checks', array(
+ phpbb::$template->assign_block_vars('checks', array(
'TITLE' => $dir,
'RESULT' => $exists . $write,
-
- 'S_EXPLAIN' => false,
- 'S_LEGEND' => false,
));
}
// Check permissions on files/directories it would be useful access to
- $template->assign_block_vars('checks', array(
+ phpbb::$template->assign_block_vars('checks', array(
'S_LEGEND' => true,
- 'LEGEND' => $lang['FILES_OPTIONAL'],
- 'LEGEND_EXPLAIN' => $lang['FILES_OPTIONAL_EXPLAIN'],
+ 'LEGEND' => phpbb::$user->lang['FILES_OPTIONAL'],
+ 'LEGEND_EXPLAIN' => phpbb::$user->lang['FILES_OPTIONAL_EXPLAIN'],
));
$directories = array('config.' . PHP_EXT, 'images/avatars/upload/');
@@ -516,54 +559,44 @@ class install_install extends module
$write = $exists = false;
}
- $exists_str = ($exists) ? '<strong style="color:green">' . $lang['FOUND'] . '</strong>' : '<strong style="color:red">' . $lang['NOT_FOUND'] . '</strong>';
- $write_str = ($write) ? ', <strong style="color:green">' . $lang['WRITABLE'] . '</strong>' : (($exists) ? ', <strong style="color:red">' . $lang['UNWRITABLE'] . '</strong>' : '');
+ $exists_str = ($exists) ? '<strong style="color:green">' . phpbb::$user->lang['FOUND'] . '</strong>' : '<strong style="color:red">' . phpbb::$user->lang['NOT_FOUND'] . '</strong>';
+ $write_str = ($write) ? ', <strong style="color:green">' . phpbb::$user->lang['WRITABLE'] . '</strong>' : (($exists) ? ', <strong style="color:red">' . phpbb::$user->lang['UNWRITABLE'] . '</strong>' : '');
- $template->assign_block_vars('checks', array(
+ phpbb::$template->assign_block_vars('checks', array(
'TITLE' => $dir,
'RESULT' => $exists_str . $write_str,
-
- 'S_EXPLAIN' => false,
- 'S_LEGEND' => false,
));
}
// And finally where do we want to go next (well today is taken isn't it :P)
- $s_hidden_fields = ($img_imagick) ? '<input type="hidden" name="img_imagick" value="' . addslashes($img_imagick) . '" />' : '';
+ $s_hidden_fields = ($img_imagick) ? '<input type="hidden" name="img_imagick" value="' . htmlspecialchars($img_imagick) . '" />' : '';
- $url = (!in_array(false, $passed)) ? $this->p_master->module_url . "?mode=$mode&amp;sub=database&amp;language=$language" : $this->p_master->module_url . "?mode=$mode&amp;sub=requirements&amp;language=$language ";
- $submit = (!in_array(false, $passed)) ? $lang['INSTALL_START'] : $lang['INSTALL_TEST'];
+ $url = (!in_array(false, $passed)) ? phpbb::$url->append_sid($this->p_master->module_url, "mode=$mode&amp;sub=database&amp;language=" . phpbb::$user->lang_name) : phpbb::$url->build_url();
-
- $template->assign_vars(array(
- 'L_SUBMIT' => $submit,
- 'S_HIDDEN' => $s_hidden_fields,
- 'U_ACTION' => $url,
+ phpbb::$template->assign_vars(array(
+ 'S_FAILED' => in_array(false, $passed),
+ 'S_HIDDEN' => $s_hidden_fields,
+ 'U_ACTION_TEST' => phpbb::$url->build_url(),
+ 'U_ACTION' => $url,
));
}
/**
* Obtain the information required to connect to the database
*/
- function obtain_database_settings($mode, $sub)
+ function obtain_database_settings($mode, $sub, &$data)
{
- global $lang, $template;
-
- $this->page_title = $lang['STAGE_DATABASE'];
-
- // Obtain any submitted data
- $data = $this->get_submitted_data();
-
$connect_test = false;
$error = array();
- $available_dbms = get_available_dbms(false, true);
+
+ $available_dbms = get_available_dbms();
// Has the user opted to test the connection?
if (phpbb_request::is_set_post('testdb'))
{
- if (!isset($available_dbms[$data['dbms']]) || !$available_dbms[$data['dbms']]['AVAILABLE'])
+ if (!isset($available_dbms[$data['dbms']]))
{
- $error['db'][] = $lang['INST_ERR_NO_DB'];
+ $error[] = phpbb::$user->lang['INST_ERR_NO_DB'];
$connect_test = false;
}
else
@@ -571,106 +604,41 @@ class install_install extends module
$connect_test = connect_check_db(true, $error, $available_dbms[$data['dbms']], $data['table_prefix'], $data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport']);
}
- $template->assign_block_vars('checks', array(
- 'S_LEGEND' => true,
- 'LEGEND' => $lang['DB_CONNECTION'],
- 'LEGEND_EXPLAIN' => false,
- ));
-
if ($connect_test)
{
- $template->assign_block_vars('checks', array(
- 'TITLE' => $lang['DB_TEST'],
- 'RESULT' => '<strong style="color:green">' . $lang['SUCCESSFUL_CONNECT'] . '</strong>',
-
- 'S_EXPLAIN' => false,
- 'S_LEGEND' => false,
+ phpbb::$template->assign_vars(array(
+ 'S_CONNECT_TEST' => true,
+ 'S_SUCCESS' => true,
));
}
else
{
- $template->assign_block_vars('checks', array(
- 'TITLE' => $lang['DB_TEST'],
- 'RESULT' => '<strong style="color:red">' . implode('<br />', $error) . '</strong>',
-
- 'S_EXPLAIN' => false,
- 'S_LEGEND' => false,
+ phpbb::$template->assign_vars(array(
+ 'S_CONNECT_TEST' => true,
+ 'ERROR' => implode('<br />', $error),
));
}
}
if (!$connect_test)
{
- // Update the list of available DBMS modules to only contain those which can be used
- $available_dbms_temp = array();
- foreach ($available_dbms as $type => $dbms_ary)
- {
- if (!$dbms_ary['AVAILABLE'])
- {
- continue;
- }
-
- $available_dbms_temp[$type] = $dbms_ary;
- }
-
- $available_dbms = &$available_dbms_temp;
-
// And now for the main part of this page
$data['table_prefix'] = (!empty($data['table_prefix']) ? $data['table_prefix'] : 'phpbb_');
-
- foreach ($this->db_config_options as $config_key => $vars)
- {
- if (!is_array($vars) && strpos($config_key, 'legend') === false)
- {
- continue;
- }
-
- if (strpos($config_key, 'legend') !== false)
- {
- $template->assign_block_vars('options', array(
- 'S_LEGEND' => true,
- 'LEGEND' => $lang[$vars])
- );
-
- continue;
- }
-
- $options = isset($vars['options']) ? $vars['options'] : '';
-
- $template->assign_block_vars('options', array(
- 'KEY' => $config_key,
- 'TITLE' => $lang[$vars['lang']],
- 'S_EXPLAIN' => $vars['explain'],
- 'S_LEGEND' => false,
- 'TITLE_EXPLAIN' => ($vars['explain']) ? $lang[$vars['lang'] . '_EXPLAIN'] : '',
- 'CONTENT' => $this->p_master->input_field($config_key, $vars['type'], $data[$config_key], $options),
- )
- );
- }
+ $this->build_form($data, $this->db_config_options);
}
// And finally where do we want to go next (well today is taken isn't it :P)
- $s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
- $s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />';
+ $s_hidden_fields = $this->return_hidden_fields($data, $this->common_config_options);
+
if ($connect_test)
{
- foreach ($this->db_config_options as $config_key => $vars)
- {
- if (!is_array($vars))
- {
- continue;
- }
- $s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
- }
+ $s_hidden_fields .= $this->return_hidden_fields($data, $this->db_config_options);
}
- $url = ($connect_test) ? $this->p_master->module_url . "?mode=$mode&amp;sub=administrator" : $this->p_master->module_url . "?mode=$mode&amp;sub=database";
+ $url = ($connect_test) ? phpbb::$url->append_sid($this->p_master->module_url, "mode=$mode&amp;sub=administrator") : phpbb::$url->build_url();
$s_hidden_fields .= ($connect_test) ? '' : '<input type="hidden" name="testdb" value="true" />';
- $submit = $lang['NEXT_STEP'];
-
- $template->assign_vars(array(
- 'L_SUBMIT' => $submit,
+ phpbb::$template->assign_vars(array(
'S_HIDDEN' => $s_hidden_fields,
'U_ACTION' => $url,
));
@@ -679,15 +647,8 @@ class install_install extends module
/**
* Obtain the administrator's name, password and email address
*/
- function obtain_admin_settings($mode, $sub)
+ function obtain_admin_settings($mode, $sub, &$data)
{
- global $lang, $template;
-
- $this->page_title = $lang['STAGE_ADMINISTRATOR'];
-
- // Obtain any submitted data
- $data = $this->get_submitted_data();
-
if ($data['dbms'] == '')
{
// Someone's been silly and tried calling this page direct
@@ -695,9 +656,7 @@ class install_install extends module
$this->p_master->redirect('index.' . PHP_EXT . '?mode=install');
}
- $s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
$passed = false;
-
$data['default_lang'] = ($data['default_lang'] !== '') ? $data['default_lang'] : $data['language'];
if (phpbb_request::is_set_post('check'))
@@ -705,140 +664,88 @@ class install_install extends module
$error = array();
// Check the entered email address and password
- if ($data['admin_name'] == '' || $data['admin_pass1'] == '' || $data['admin_pass2'] == '' || $data['board_email1'] == '' || $data['board_email2'] == '')
+ if ($data['admin_name'] == '' || $data['admin_pass1'] == '' || $data['admin_pass2'] == '' || $data['board_email'] == '' || $data['board_contact'] == '')
{
- $error[] = $lang['INST_ERR_MISSING_DATA'];
+ $error[] = phpbb::$user->lang['INST_ERR_MISSING_DATA'];
}
if ($data['admin_pass1'] != $data['admin_pass2'] && $data['admin_pass1'] != '')
{
- $error[] = $lang['INST_ERR_PASSWORD_MISMATCH'];
+ $error[] = phpbb::$user->lang['INST_ERR_PASSWORD_MISMATCH'];
}
// Test against the default username rules
if ($data['admin_name'] != '' && utf8_strlen($data['admin_name']) < 3)
{
- $error[] = $lang['INST_ERR_USER_TOO_SHORT'];
+ $error[] = phpbb::$user->lang['INST_ERR_USER_TOO_SHORT'];
}
if ($data['admin_name'] != '' && utf8_strlen($data['admin_name']) > 20)
{
- $error[] = $lang['INST_ERR_USER_TOO_LONG'];
+ $error[] = phpbb::$user->lang['INST_ERR_USER_TOO_LONG'];
}
// Test against the default password rules
if ($data['admin_pass1'] != '' && utf8_strlen($data['admin_pass1']) < 6)
{
- $error[] = $lang['INST_ERR_PASSWORD_TOO_SHORT'];
+ $error[] = phpbb::$user->lang['INST_ERR_PASSWORD_TOO_SHORT'];
}
if ($data['admin_pass1'] != '' && utf8_strlen($data['admin_pass1']) > 30)
{
- $error[] = $lang['INST_ERR_PASSWORD_TOO_LONG'];
+ $error[] = phpbb::$user->lang['INST_ERR_PASSWORD_TOO_LONG'];
}
- if ($data['board_email1'] != $data['board_email2'] && $data['board_email1'] != '')
+ if ($data['board_email'] != '' && !preg_match('/^' . get_preg_expression('email') . '$/i', $data['board_email']))
{
- $error[] = $lang['INST_ERR_EMAIL_MISMATCH'];
+ $error[] = phpbb::$user->lang['INST_ERR_EMAIL_INVALID'];
}
- if ($data['board_email1'] != '' && !preg_match('/^' . get_preg_expression('email') . '$/i', $data['board_email1']))
+ if ($data['board_contact'] != '' && !preg_match('/^' . get_preg_expression('email') . '$/i', $data['board_contact']))
{
- $error[] = $lang['INST_ERR_EMAIL_INVALID'];
+ $error[] = phpbb::$user->lang['INST_ERR_EMAIL_INVALID'];
}
- $template->assign_block_vars('checks', array(
+ phpbb::$template->assign_block_vars('checks', array(
'S_LEGEND' => true,
- 'LEGEND' => $lang['STAGE_ADMINISTRATOR'],
- 'LEGEND_EXPLAIN' => false,
+ 'LEGEND' => phpbb::$user->lang['STAGE_ADMINISTRATOR'],
));
if (!sizeof($error))
{
$passed = true;
- $template->assign_block_vars('checks', array(
- 'TITLE' => $lang['ADMIN_TEST'],
- 'RESULT' => '<strong style="color:green">' . $lang['TESTS_PASSED'] . '</strong>',
- 'S_EXPLAIN' => false,
- 'S_LEGEND' => false,
+ phpbb::$template->assign_block_vars('checks', array(
+ 'TITLE' => phpbb::$user->lang['ADMIN_TEST'],
+ 'RESULT' => '<strong style="color:green">' . phpbb::$user->lang['TESTS_PASSED'] . '</strong>',
));
}
else
{
- $template->assign_block_vars('checks', array(
- 'TITLE' => $lang['ADMIN_TEST'],
+ phpbb::$template->assign_block_vars('checks', array(
+ 'TITLE' => phpbb::$user->lang['ADMIN_TEST'],
'RESULT' => '<strong style="color:red">' . implode('<br />', $error) . '</strong>',
-
- 'S_EXPLAIN' => false,
- 'S_LEGEND' => false,
));
}
}
+ $s_hidden_fields = '';
+
if (!$passed)
{
- foreach ($this->admin_config_options as $config_key => $vars)
- {
- if (!is_array($vars) && strpos($config_key, 'legend') === false)
- {
- continue;
- }
-
- if (strpos($config_key, 'legend') !== false)
- {
- $template->assign_block_vars('options', array(
- 'S_LEGEND' => true,
- 'LEGEND' => $lang[$vars])
- );
-
- continue;
- }
-
- $options = isset($vars['options']) ? $vars['options'] : '';
-
- $template->assign_block_vars('options', array(
- 'KEY' => $config_key,
- 'TITLE' => $lang[$vars['lang']],
- 'S_EXPLAIN' => $vars['explain'],
- 'S_LEGEND' => false,
- 'TITLE_EXPLAIN' => ($vars['explain']) ? $lang[$vars['lang'] . '_EXPLAIN'] : '',
- 'CONTENT' => $this->p_master->input_field($config_key, $vars['type'], $data[$config_key], $options),
- )
- );
- }
+ $this->build_form($data, $this->admin_config_options);
}
else
{
- foreach ($this->admin_config_options as $config_key => $vars)
- {
- if (!is_array($vars))
- {
- continue;
- }
- $s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
- }
- }
-
- $s_hidden_fields .= ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
- $s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />';
-
- foreach ($this->db_config_options as $config_key => $vars)
- {
- if (!is_array($vars))
- {
- continue;
- }
- $s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
+ $s_hidden_fields .= $this->return_hidden_fields($data, $this->admin_config_options);
}
- $submit = $lang['NEXT_STEP'];
+ $s_hidden_fields .= $this->return_hidden_fields($data, $this->common_config_options, $this->db_config_options);
- $url = ($passed) ? $this->p_master->module_url . "?mode=$mode&amp;sub=config_file" : $this->p_master->module_url . "?mode=$mode&amp;sub=administrator";
+ $url = ($passed) ? phpbb::$url->append_sid($this->p_master->module_url, "mode=$mode&amp;sub=config_file") : phpbb::$url->build_url();
$s_hidden_fields .= ($passed) ? '' : '<input type="hidden" name="check" value="true" />';
- $template->assign_vars(array(
- 'L_SUBMIT' => $submit,
+ phpbb::$template->assign_vars(array(
'S_HIDDEN' => $s_hidden_fields,
'U_ACTION' => $url,
));
@@ -847,15 +754,8 @@ class install_install extends module
/**
* Writes the config file to disk, or if unable to do so offers alternative methods
*/
- function create_config_file($mode, $sub)
+ function create_config_file($mode, $sub, &$data)
{
- global $lang, $template;
-
- $this->page_title = $lang['STAGE_CONFIG_FILE'];
-
- // Obtain any submitted data
- $data = $this->get_submitted_data();
-
if ($data['dbms'] == '')
{
// Someone's been silly and tried calling this page direct
@@ -863,8 +763,7 @@ class install_install extends module
$this->p_master->redirect('index.' . PHP_EXT . '?mode=install');
}
- $s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
- $s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />';
+ $s_hidden_fields = $this->return_hidden_fields($data, $this->common_config_options);
$written = false;
// Create a list of any PHP modules we wish to have loaded
@@ -890,7 +789,7 @@ class install_install extends module
if ($fp === false)
{
// We were unable to create the lock file - abort
- $this->p_master->error($lang['UNABLE_WRITE_LOCK'], __LINE__, __FILE__);
+ trigger_error(phpbb::$user->lang['UNABLE_WRITE_LOCK'], E_USER_ERROR);
}
@fclose($fp);
@@ -966,21 +865,11 @@ class install_install extends module
}
}
- $config_options = array_merge($this->db_config_options, $this->admin_config_options);
-
- foreach ($config_options as $config_key => $vars)
- {
- if (!is_array($vars))
- {
- continue;
- }
- $s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
- }
+ $s_hidden_fields .= $this->return_hidden_fields($data, $this->db_config_options, $this->admin_config_options);
if (!$written)
{
// OK, so it didn't work let's try the alternatives
-
if (phpbb_request::is_set_post('dlconfig'))
{
// They want a copy of the file to download, so send the relevant headers and dump out the data
@@ -991,27 +880,18 @@ class install_install extends module
}
// The option to download the config file is always available, so output it here
- $template->assign_vars(array(
- 'BODY' => $lang['CONFIG_FILE_UNABLE_WRITE'],
- 'L_DL_CONFIG' => $lang['DL_CONFIG'],
- 'L_DL_CONFIG_EXPLAIN' => $lang['DL_CONFIG_EXPLAIN'],
- 'L_DL_DONE' => $lang['DONE'],
- 'L_DL_DOWNLOAD' => $lang['DL_DOWNLOAD'],
+ phpbb::$template->assign_vars(array(
'S_HIDDEN' => $s_hidden_fields,
- 'S_SHOW_DOWNLOAD' => true,
- 'U_ACTION' => $this->p_master->module_url . "?mode=$mode&amp;sub=config_file",
+ 'U_ACTION' => phpbb::$url->build_url(),
));
- return;
}
else
{
- $template->assign_vars(array(
- 'BODY' => $lang['CONFIG_FILE_WRITTEN'],
- 'L_SUBMIT' => $lang['NEXT_STEP'],
+ phpbb::$template->assign_vars(array(
+ 'S_WRITTEN' => true,
'S_HIDDEN' => $s_hidden_fields,
- 'U_ACTION' => $this->p_master->module_url . "?mode=$mode&amp;sub=advanced",
+ 'U_ACTION' => phpbb::$url->append_sid($this->p_master->module_url, "mode=$mode&amp;sub=advanced"),
));
- return;
}
}
@@ -1019,15 +899,8 @@ class install_install extends module
* Provide an opportunity to customise some advanced settings during the install
* in case it is necessary for them to be set to access later
*/
- function obtain_advanced_settings($mode, $sub)
+ function obtain_advanced_settings($mode, $sub, &$data)
{
- global $lang, $template;
-
- $this->page_title = $lang['STAGE_ADVANCED'];
-
- // Obtain any submitted data
- $data = $this->get_submitted_data();
-
if ($data['dbms'] == '')
{
// Someone's been silly and tried calling this page direct
@@ -1035,102 +908,36 @@ class install_install extends module
$this->p_master->redirect('index.' . PHP_EXT . '?mode=install');
}
- $s_hidden_fields = ($data['img_imagick']) ? '<input type="hidden" name="img_imagick" value="' . addslashes($data['img_imagick']) . '" />' : '';
- $s_hidden_fields .= '<input type="hidden" name="language" value="' . $data['language'] . '" />';
-
- // HTTP_HOST is having the correct browser url in most cases...
- $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
-
- // HTTP HOST can carry a port number...
- if (strpos($server_name, ':') !== false)
- {
- $server_name = substr($server_name, 0, strpos($server_name, ':'));
- }
+ $s_hidden_fields = $this->return_hidden_fields($data, $this->common_config_options);
$data['email_enable'] = ($data['email_enable'] !== '') ? $data['email_enable'] : true;
- $data['server_name'] = ($data['server_name'] !== '') ? $data['server_name'] : $server_name;
- $data['server_port'] = ($data['server_port'] !== '') ? $data['server_port'] : ((!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT'));
+ $data['server_name'] = ($data['server_name'] !== '') ? $data['server_name'] : phpbb::$user->system['host'];
+ $data['server_port'] = ($data['server_port'] !== '') ? $data['server_port'] : phpbb::$user->system['port'];
$data['server_protocol'] = ($data['server_protocol'] !== '') ? $data['server_protocol'] : ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://');
$data['cookie_secure'] = ($data['cookie_secure'] !== '') ? $data['cookie_secure'] : ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? true : false);
if ($data['script_path'] === '')
{
- $name = (!empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : getenv('PHP_SELF');
- if (!$name)
- {
- $name = (!empty($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : getenv('REQUEST_URI');
- }
-
// Replace backslashes and doubled slashes (could happen on some proxy setups)
- $name = str_replace(array('\\', '//', '/install'), '/', $name);
- $data['script_path'] = trim(dirname($name));
- }
-
- foreach ($this->advanced_config_options as $config_key => $vars)
- {
- if (!is_array($vars) && strpos($config_key, 'legend') === false)
- {
- continue;
- }
-
- if (strpos($config_key, 'legend') !== false)
- {
- $template->assign_block_vars('options', array(
- 'S_LEGEND' => true,
- 'LEGEND' => $lang[$vars])
- );
-
- continue;
- }
-
- $options = isset($vars['options']) ? $vars['options'] : '';
-
- $template->assign_block_vars('options', array(
- 'KEY' => $config_key,
- 'TITLE' => $lang[$vars['lang']],
- 'S_EXPLAIN' => $vars['explain'],
- 'S_LEGEND' => false,
- 'TITLE_EXPLAIN' => ($vars['explain']) ? $lang[$vars['lang'] . '_EXPLAIN'] : '',
- 'CONTENT' => $this->p_master->input_field($config_key, $vars['type'], $data[$config_key], $options),
- )
- );
- }
-
- $config_options = array_merge($this->db_config_options, $this->admin_config_options);
- foreach ($config_options as $config_key => $vars)
- {
- if (!is_array($vars))
- {
- continue;
- }
- $s_hidden_fields .= '<input type="hidden" name="' . $config_key . '" value="' . $data[$config_key] . '" />';
+ $data['script_path'] = trim(str_replace(array('/install/', '\\install\\'), '', phpbb::$user->page['script_path']));
}
- $submit = $lang['NEXT_STEP'];
-
- $url = $this->p_master->module_url . "?mode=$mode&amp;sub=create_table";
+ $this->build_form($data, $this->advanced_config_options);
+ $s_hidden_fields .= $this->return_hidden_fields($data, $this->db_config_options, $this->admin_config_options);
- $template->assign_vars(array(
- 'BODY' => $lang['STAGE_ADVANCED_EXPLAIN'],
- 'L_SUBMIT' => $submit,
+ phpbb::$template->assign_vars(array(
'S_HIDDEN' => $s_hidden_fields,
- 'U_ACTION' => $url,
+ 'U_ACTION' => phpbb::$url->append_sid($this->p_master->module_url, "mode=$mode&amp;sub=create_table"),
));
}
/**
* Load the contents of the schema into the database and then alter it based on what has been input during the installation
*/
- function load_schema($mode, $sub)
+ function load_schema($mode, $sub, &$data)
{
- global $db, $lang, $template;
-
- $this->page_title = $lang['STAGE_CREATE_TABLE'];
$s_hidden_fields = '';
- // Obtain any submitted data
- $data = $this->get_submitted_data();
-
if ($data['dbms'] == '')
{
// Someone's been silly and tried calling this page direct
@@ -1138,24 +945,6 @@ class install_install extends module
$this->p_master->redirect('index.' . PHP_EXT . '?mode=install');
}
- // HTTP_HOST is having the correct browser url in most cases...
- $server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME'));
- $referer = (!empty($_SERVER['HTTP_REFERER'])) ? strtolower($_SERVER['HTTP_REFERER']) : getenv('HTTP_REFERER');
-
- // HTTP HOST can carry a port number...
- if (strpos($server_name, ':') !== false)
- {
- $server_name = substr($server_name, 0, strpos($server_name, ':'));
- }
-
- $cookie_domain = ($data['server_name'] != '') ? $data['server_name'] : $server_name;
-
- // Try to come up with the best solution for cookie domain...
- if (strpos($cookie_domain, 'www.') === 0)
- {
- $cookie_domain = str_replace('www.', '.', $cookie_domain);
- }
-
// If we get here and the extension isn't loaded it should be safe to just go ahead and load it
$available_dbms = get_available_dbms($data['dbms']);
@@ -1165,89 +954,43 @@ class install_install extends module
$this->p_master->redirect('index.' . PHP_EXT . '?mode=install');
}
- $dbms = $available_dbms[$data['dbms']]['DRIVER'];
-
- // Load the appropriate database class if not already loaded
- include(PHPBB_ROOT_PATH . 'includes/db/' . $dbms . '.' . PHP_EXT);
-
- // Instantiate the database
- $db = new $sql_db();
- $db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false);
+ phpbb::assign('db', phpbb_db_dbal::connect($data['dbms'], $data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false));
- // NOTE: trigger_error does not work here.
- $db->sql_return_on_error(true);
+ // Include the db tools - we work with them to create the tables
+ include PHPBB_ROOT_PATH . 'includes/db/db_tools.' . PHP_EXT;
- // Ok we have the db info go ahead and read in the relevant schema
- // and work on building the table
- $dbms_schema = 'schemas/' . $available_dbms[$data['dbms']]['SCHEMA'] . '_schema.sql';
+ // Load the Schema data (Fill $schema_data)
+ include PHPBB_ROOT_PATH . 'install/schemas/schema_structure.' . PHP_EXT;
- // How should we treat this schema?
- $remove_remarks = $available_dbms[$data['dbms']]['COMMENTS'];
- $delimiter = $available_dbms[$data['dbms']]['DELIM'];
+ // we do not return statements, we simply let them execute
+ $db_tools = new phpbb_db_tools(phpbb::$db);
- include(PHPBB_ROOT_PATH . 'includes/db/db_tools.php');
- include(PHPBB_ROOT_PATH . 'install/schemas/schema_data.php');
-
- // we must set return_statements to true so that we can handle the errors
- $db_tools = new phpbb_db_tools($db, true);
+ // Before we can load the schema data we need (for a new installation) create custom data for the beginning of schema creation and the end
+ $db_tools->sql_install_begin();
foreach ($schema_data as $table_name => $table_data)
{
- // Change prefix
- $table_name = preg_replace('#phpbb_#i', $data['table_prefix'], $table_name);
- $statements = $db_tools->sql_create_table($table_name, $table_data);
+ // Change prefix, we always have phpbb_, therefore we can do a substr() here
+ $table_name = $data['table_prefix'] . substr($table_name, 6);
- foreach ($statements as $sql)
- {
- if (!$db->sql_query($sql))
- {
- $error = $db->sql_error();
- $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__);
- }
- }
+ // Now create the table
+ $db_tools->sql_create_table($table_name, $table_data);
}
- // Ok tables have been built, let's fill in the basic information
- $sql_query = file_get_contents('schemas/schema_data.sql');
+ $db_tools->sql_install_end();
- // Deal with any special comments
- switch ($data['dbms'])
- {
- case 'mssql':
- case 'mssql_odbc':
- case 'mssql_2005':
- $sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2;', $sql_query);
- break;
+ // Now get the schema data
+ include PHPBB_ROOT_PATH . 'install/schemas/schema_data.' . PHP_EXT;
- case 'postgres':
- $sql_query = preg_replace('#\# POSTGRES (BEGIN|COMMIT) \##s', '\1; ', $sql_query);
- break;
- }
-
- // Change prefix
- $sql_query = preg_replace('#phpbb_#i', $data['table_prefix'], $sql_query);
-
- // Change language strings...
- $sql_query = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', 'adjust_language_keys_callback', $sql_query);
+ // Build data array for substituted content ;)
- // Since there is only one schema file we know the comment style and are able to remove it directly with remove_remarks
- remove_remarks($sql_query);
- $sql_query = split_sql_file($sql_query, ';');
+ $cookie_domain = ($data['server_name'] != '') ? $data['server_name'] : phpbb::$user->system['host'];
- foreach ($sql_query as $sql)
+ // Try to come up with the best solution for cookie domain...
+ if (strpos($cookie_domain, 'www.') === 0)
{
- //$sql = trim(str_replace('|', ';', $sql));
- if (!$db->sql_query($sql))
- {
- $error = $db->sql_error();
- $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__);
- }
+ $cookie_domain = str_replace('www.', '.', $cookie_domain);
}
- unset($sql_query);
-
- $current_time = time();
-
- $user_ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : '';
if ($data['script_path'] !== '/')
{
@@ -1265,171 +1008,102 @@ class install_install extends module
}
}
- // Set default config and post data, this applies to all DB's
- $sql_ary = array(
- 'INSERT INTO ' . $data['table_prefix'] . "config (config_name, config_value)
- VALUES ('board_startdate', '$current_time')",
-
- 'INSERT INTO ' . $data['table_prefix'] . "config (config_name, config_value)
- VALUES ('default_lang', '" . $db->sql_escape($data['default_lang']) . "')",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($data['img_imagick']) . "'
- WHERE config_name = 'img_imagick'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($data['server_name']) . "'
- WHERE config_name = 'server_name'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($data['server_port']) . "'
- WHERE config_name = 'server_port'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($data['board_email1']) . "'
- WHERE config_name = 'board_email'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($data['board_email1']) . "'
- WHERE config_name = 'board_contact'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($cookie_domain) . "'
- WHERE config_name = 'cookie_domain'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($lang['default_dateformat']) . "'
- WHERE config_name = 'default_dateformat'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($data['email_enable']) . "'
- WHERE config_name = 'email_enable'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($data['smtp_delivery']) . "'
- WHERE config_name = 'smtp_delivery'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($data['smtp_host']) . "'
- WHERE config_name = 'smtp_host'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($data['smtp_auth']) . "'
- WHERE config_name = 'smtp_auth_method'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($data['smtp_user']) . "'
- WHERE config_name = 'smtp_username'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($data['smtp_pass']) . "'
- WHERE config_name = 'smtp_password'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($data['cookie_secure']) . "'
- WHERE config_name = 'cookie_secure'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($data['force_server_vars']) . "'
- WHERE config_name = 'force_server_vars'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($data['script_path']) . "'
- WHERE config_name = 'script_path'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($data['server_protocol']) . "'
- WHERE config_name = 'server_protocol'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($data['admin_name']) . "'
- WHERE config_name = 'newest_username'",
-
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . md5(mt_rand()) . "'
- WHERE config_name = 'avatar_salt'",
-
- 'UPDATE ' . $data['table_prefix'] . "users
- SET username = '" . $db->sql_escape($data['admin_name']) . "', user_password='" . $db->sql_escape(md5($data['admin_pass1'])) . "', user_ip = '" . $db->sql_escape($user_ip) . "', user_lang = '" . $db->sql_escape($data['default_lang']) . "', user_email='" . $db->sql_escape($data['board_email1']) . "', user_dateformat='" . $db->sql_escape($lang['default_dateformat']) . "', user_email_hash = " . hexdec(crc32($data['board_email1']) . strlen($data['board_email1'])) . ", username_clean = '" . $db->sql_escape(utf8_clean_string($data['admin_name'])) . "'
- WHERE username = 'Admin'",
-
- 'UPDATE ' . $data['table_prefix'] . "moderator_cache
- SET username = '" . $db->sql_escape($data['admin_name']) . "'
- WHERE username = 'Admin'",
-
- 'UPDATE ' . $data['table_prefix'] . "forums
- SET forum_last_poster_name = '" . $db->sql_escape($data['admin_name']) . "'
- WHERE forum_last_poster_name = 'Admin'",
-
- 'UPDATE ' . $data['table_prefix'] . "topics
- SET topic_first_poster_name = '" . $db->sql_escape($data['admin_name']) . "', topic_last_poster_name = '" . $db->sql_escape($data['admin_name']) . "'
- WHERE topic_first_poster_name = 'Admin'
- OR topic_last_poster_name = 'Admin'",
-
- 'UPDATE ' . $data['table_prefix'] . "users
- SET user_regdate = $current_time",
+ $ref = substr(phpbb::$user->system['referer'], strpos(phpbb::$user->system['referer'], '://') + 3);
+
+ $template_data = array(
+ 'BOARD_STARTDATE' => time(),
+ 'CURRENT_TIME' => time(),
+ 'DEFAULT_LANG' => $data['default_lang'],
+ 'DBMS_VERSION' => phpbb::$db->sql_server_info(true),
+ 'IMG_IMAGICK' => $data['img_imagick'],
+ 'SERVER_NAME' => $data['server_name'],
+ 'SERVER_PORT' => $data['server_port'],
+ 'BOARD_EMAIL' => $data['board_email'],
+ 'BOARD_CONTACT' => $data['board_contact'],
+ 'COOKIE_DOMAIN' => $cookie_domain,
+ 'DEFAULT_DATEFORMAT'=> phpbb::$user->lang['default_dateformat'],
+ 'EMAIL_ENABLE' => $data['email_enable'],
+ 'SMTP_DELIVERY' => $data['smtp_delivery'],
+ 'SMTP_HOST' => $data['smtp_host'],
+ 'SMTP_AUTH_METHOD' => $data['smtp_auth'],
+ 'SMTP_USERNAME' => $data['smtp_user'],
+ 'SMTP_PASSWORD' => $data['smtp_pass'],
+ 'COOKIE_SECURE' => $data['cookie_secure'],
+ 'COOKIE_NAME' => 'phpbb3_' . phpbb::$security->gen_rand_string(4),
+ 'FORCE_SERVER_VARS' => $data['force_server_vars'],
+ 'SCRIPT_PATH' => $data['script_path'],
+ 'SERVER_PROTOCOL' => $data['server_protocol'],
+ 'NEWEST_USERNAME' => $data['admin_name'],
+ 'AVATAR_SALT' => md5(phpbb::$security->gen_rand_string()),
+ 'CAPTCHA_PLUGIN' => (@extension_loaded('gd') || can_load_dll('gd')) ? 'phpbb_captcha_gd' : 'phpbb_captcha_nogd',
+ 'REFERER_VALIDATION'=> (!(stripos($ref, phpbb::$user->system['host']) === 0)) ? '0' : '1',
+ 'ADMIN_NAME' => $data['admin_name'],
+ 'ADMIN_NAME_CLEAN' => utf8_clean_string($data['admin_name']),
+ 'ADMIN_PASSWORD' => phpbb::$security->hash_password($data['admin_pass1']),
+ 'ADMIN_EMAIL' => $data['board_contact'],
+ 'ADMIN_EMAIL_HASH' => hexdec(crc32($data['board_contact']) . strlen($data['board_contact'])),
+ 'USER_IP' => phpbb::$user->ip,
+ );
- 'UPDATE ' . $data['table_prefix'] . "posts
- SET post_time = $current_time, poster_ip = '" . $db->sql_escape($user_ip) . "'",
+ // Apply Schema changes
+ $db_tools->db->sql_transaction('begin');
- 'UPDATE ' . $data['table_prefix'] . "topics
- SET topic_time = $current_time, topic_last_post_time = $current_time",
+ foreach ($schema_data as $schema_array)
+ {
+ $schema_array['table'] = $data['table_prefix'] . substr($schema_array['table'], 6);
+ $db_tools->sql_insert_data($schema_array, $template_data);
+ }
- 'UPDATE ' . $data['table_prefix'] . "forums
- SET forum_last_post_time = $current_time",
+ $db_tools->db->sql_transaction('commit');
- 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($db->sql_server_info(true)) . "'
- WHERE config_name = 'dbms_version'",
- );
+ // Update data
+ $db_tools->db->sql_transaction('begin');
- if (@extension_loaded('gd') || can_load_dll('gd'))
+ foreach ($schema_updates as $schema_array)
{
- $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = 'phpbb_captcha_gd'
- WHERE config_name = 'captcha_plugin'";
+ $schema_array['table'] = $data['table_prefix'] . substr($schema_array['table'], 6);
+ $db_tools->sql_update_data($schema_array, $template_data);
}
- $ref = substr($referer, strpos($referer, '://') + 3);
+ $db_tools->db->sql_transaction('commit');
+
+ // We need to insert the role data manually... else the schema array is quite large...
+ $sql = 'SELECT role_id, role_name
+ FROM ' . $data['table_prefix'] . 'acl_roles';
+ $result = phpbb::$db->sql_query($sql);
- if (!(stripos($ref, $server_name) === 0))
+ $role_ids = array();
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
- $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '0'
- WHERE config_name = 'referer_validation'";
+ $role_ids[$row['role_name']] = $row['role_id'];
}
+ phpbb::$db->sql_freeresult($result);
- // We set a (semi-)unique cookie name to bypass login issues related to the cookie name.
- $cookie_name = 'phpbb3_';
- $rand_str = md5(mt_rand());
- $rand_str = str_replace('0', 'z', base_convert($rand_str, 16, 35));
- $rand_str = substr($rand_str, 0, 5);
- $cookie_name .= strtolower($rand_str);
-
- $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config
- SET config_value = '" . $db->sql_escape($cookie_name) . "'
- WHERE config_name = 'cookie_name'";
-
- foreach ($sql_ary as $sql)
+ foreach ($this->role_definitions as $role_ary)
{
- //$sql = trim(str_replace('|', ';', $sql));
+ $role_name = $role_ary[0];
+ $auth_setting = $role_ary[1];
+ $permission = $role_ary[2];
+ $condition = $role_ary[3];
+ $options = $role_ary[4];
+
+ $sql = '';
+ $sql .= 'INSERT INTO ' . $data['table_prefix'] . 'acl_roles_data (role_id, auth_option_id, auth_setting) ';
+ $sql .= 'SELECT ' . $role_ids[$role_name] . ', auth_option_id, ' . $auth_setting . ' ';
+ $sql .= 'FROM ' . $data['table_prefix'] . 'acl_options ';
+ $sql .= "WHERE auth_option LIKE '{$permission}%'";
- if (!$db->sql_query($sql))
+ if ($options !== false)
{
- $error = $db->sql_error();
- $this->p_master->db_error($error['message'], $sql, __LINE__, __FILE__);
+ $sql .= ' AND auth_option ' . $condition . ' (\'' . implode("', '", $options) . "')";
}
- }
-
- $submit = $lang['NEXT_STEP'];
- $url = $this->p_master->module_url . "?mode=$mode&amp;sub=final";
+ phpbb::$db->sql_query($sql);
+ }
- $template->assign_vars(array(
- 'BODY' => $lang['STAGE_CREATE_TABLE_EXPLAIN'],
- 'L_SUBMIT' => $submit,
+ phpbb::$template->assign_vars(array(
'S_HIDDEN' => build_hidden_fields($data),
- 'U_ACTION' => $url,
+ 'U_ACTION' => phpbb::$url->append_sid($this->p_master->module_url, "mode=$mode&amp;sub=final"),
));
}
@@ -1438,60 +1112,20 @@ class install_install extends module
*/
function build_search_index($mode, $sub)
{
- global $db, $lang;
-
- // Obtain any submitted data
- $data = $this->get_submitted_data();
- $table_prefix = $data['table_prefix'];
-
- // If we get here and the extension isn't loaded it should be safe to just go ahead and load it
- $available_dbms = get_available_dbms($data['dbms']);
-
- if (!isset($available_dbms[$data['dbms']]))
- {
- // Someone's been silly and tried providing a non-existant dbms
- $this->p_master->redirect('index.' . PHP_EXT . '?mode=install');
- }
-
- $dbms = $available_dbms[$data['dbms']]['DRIVER'];
-
- // Load the appropriate database class if not already loaded
- include(PHPBB_ROOT_PATH . 'includes/db/' . $dbms . '.' . PHP_EXT);
-
- // Instantiate the database
- $db = new $sql_db();
- $db->sql_connect($data['dbhost'], $data['dbuser'], htmlspecialchars_decode($data['dbpasswd']), $data['dbname'], $data['dbport'], false, false);
-
- // NOTE: trigger_error does not work here.
- $db->sql_return_on_error(true);
-
- include_once(PHPBB_ROOT_PATH . 'includes/constants.' . PHP_EXT);
- include_once(PHPBB_ROOT_PATH . 'includes/search/fulltext_native.' . PHP_EXT);
+ include_once PHPBB_ROOT_PATH . 'includes/search/fulltext_native.' . PHP_EXT;
- /* Fill the config array - it is needed by those functions we call
- $sql = 'SELECT *
- FROM ' . CONFIG_TABLE;
- $result = $db->sql_query($sql);
-
- $config = array();
- while ($row = $db->sql_fetchrow($result))
- {
- $config[$row['config_name']] = $row['config_value'];
- }
- $db->sql_freeresult($result);
-*/
$error = false;
$search = new fulltext_native($error);
$sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id
FROM ' . POSTS_TABLE;
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = phpbb::$db->sql_fetchrow($result))
{
$search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']);
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
}
/**
@@ -1499,9 +1133,7 @@ class install_install extends module
*/
function add_modules($mode, $sub)
{
- global $db, $lang;
-
- include_once(PHPBB_ROOT_PATH . 'includes/acp/acp_modules.' . PHP_EXT);
+ include_once PHPBB_ROOT_PATH . 'modules/acp/acp_modules.' . PHP_EXT;
$_module = new acp_modules();
$module_classes = array('acp', 'mcp', 'ucp');
@@ -1530,13 +1162,6 @@ class install_install extends module
// Add category
$_module->update_module_data($module_data, true);
- // Check for last sql error happened
- if ($db->sql_error_triggered)
- {
- $error = $db->sql_error($db->sql_error_sql);
- $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
- }
-
$categories[$cat_name]['id'] = (int) $module_data['module_id'];
$categories[$cat_name]['parent_id'] = 0;
@@ -1558,13 +1183,6 @@ class install_install extends module
$_module->update_module_data($module_data, true);
- // Check for last sql error happened
- if ($db->sql_error_triggered)
- {
- $error = $db->sql_error($db->sql_error_sql);
- $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
- }
-
$categories[$level2_name]['id'] = (int) $module_data['module_id'];
$categories[$level2_name]['parent_id'] = (int) $categories[$cat_name]['id'];
}
@@ -1597,13 +1215,6 @@ class install_install extends module
);
$_module->update_module_data($module_data, true);
-
- // Check for last sql error happened
- if ($db->sql_error_triggered)
- {
- $error = $db->sql_error($db->sql_error_sql);
- $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
- }
}
}
}
@@ -1617,9 +1228,9 @@ class install_install extends module
WHERE module_basename = 'main'
AND module_class = 'acp'
AND module_mode = 'main'";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
$_module->move_module_by($row, 'move_up', 4);
@@ -1629,9 +1240,9 @@ class install_install extends module
WHERE module_basename = 'permissions'
AND module_class = 'acp'
AND module_mode = 'intro'";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
$_module->move_module_by($row, 'move_up', 4);
@@ -1641,9 +1252,9 @@ class install_install extends module
WHERE module_basename = 'users'
AND module_class = 'acp'
AND module_mode = 'overview'";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
$_module->move_module_by($row, 'move_up', 5);
}
@@ -1656,9 +1267,9 @@ class install_install extends module
WHERE module_basename = 'attachments'
AND module_class = 'ucp'
AND module_mode = 'attachments'";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
$_module->move_module_by($row, 'move_down', 4);
}
@@ -1671,22 +1282,22 @@ class install_install extends module
{
$sql = 'SELECT module_id, left_id, right_id
FROM ' . MODULES_TABLE . "
- WHERE module_langname = '" . $db->sql_escape($cat_name) . "'
- AND module_class = '" . $db->sql_escape($module_class) . "'";
- $result = $db->sql_query_limit($sql, 1);
- $row2 = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ WHERE module_langname = '" . phpbb::$db->sql_escape($cat_name) . "'
+ AND module_class = '" . phpbb::$db->sql_escape($module_class) . "'";
+ $result = phpbb::$db->sql_query_limit($sql, 1);
+ $row2 = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
foreach ($mods as $mod_name)
{
$sql = 'SELECT *
FROM ' . MODULES_TABLE . "
- WHERE module_langname = '" . $db->sql_escape($mod_name) . "'
- AND module_class = '" . $db->sql_escape($module_class) . "'
+ WHERE module_langname = '" . phpbb::$db->sql_escape($mod_name) . "'
+ AND module_class = '" . phpbb::$db->sql_escape($module_class) . "'
AND module_basename <> ''";
- $result = $db->sql_query_limit($sql, 1);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query_limit($sql, 1);
+ $row = phpbb::$db->sql_fetchrow($result);
+ phpbb::$db->sql_freeresult($result);
$module_data = array(
'module_basename' => $row['module_basename'],
@@ -1700,13 +1311,6 @@ class install_install extends module
);
$_module->update_module_data($module_data, true);
-
- // Check for last sql error happened
- if ($db->sql_error_triggered)
- {
- $error = $db->sql_error($db->sql_error_sql);
- $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
- }
}
}
}
@@ -1720,13 +1324,11 @@ class install_install extends module
*/
function add_language($mode, $sub)
{
- global $db, $lang;
-
$dir = @opendir(PHPBB_ROOT_PATH . 'language');
if (!$dir)
{
- $this->error('Unable to access the language directory', __LINE__, __FILE__);
+ trigger_error('Unable to access the language directory', E_USER_ERROR);
}
while (($file = readdir($dir)) !== false)
@@ -1750,13 +1352,7 @@ class install_install extends module
'lang_author' => trim(htmlspecialchars($lang_file[2], ENT_COMPAT, 'UTF-8')),
);
- $db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $lang_pack));
-
- if ($db->sql_error_triggered)
- {
- $error = $db->sql_error($db->sql_error_sql);
- $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
- }
+ phpbb::$db->sql_query('INSERT INTO ' . LANG_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $lang_pack));
$valid_localized = array(
'icon_back_top', 'icon_contact_aim', 'icon_contact_email', 'icon_contact_icq', 'icon_contact_jabber', 'icon_contact_msnm', 'icon_contact_pm', 'icon_contact_yahoo', 'icon_contact_www', 'icon_post_delete', 'icon_post_edit', 'icon_post_info', 'icon_post_quote', 'icon_post_report', 'icon_user_online', 'icon_user_offline', 'icon_user_profile', 'icon_user_search', 'icon_user_warn', 'button_pm_forward', 'button_pm_new', 'button_pm_reply', 'button_topic_locked', 'button_topic_new', 'button_topic_reply',
@@ -1766,9 +1362,9 @@ class install_install extends module
$sql = 'SELECT *
FROM ' . STYLES_IMAGESET_TABLE;
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
- while ($imageset_row = $db->sql_fetchrow($result))
+ while ($imageset_row = phpbb::$db->sql_fetchrow($result))
{
if (@file_exists(PHPBB_ROOT_PATH . "styles/{$imageset_row['imageset_path']}/imageset/{$lang_pack['lang_iso']}/imageset.cfg"))
{
@@ -1811,17 +1407,11 @@ class install_install extends module
}
}
}
- $db->sql_freeresult($result);
+ phpbb::$db->sql_freeresult($result);
if (sizeof($sql_ary))
{
- $db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary);
-
- if ($db->sql_error_triggered)
- {
- $error = $db->sql_error($db->sql_error_sql);
- $this->p_master->db_error($error['message'], $db->sql_error_sql, __LINE__, __FILE__);
- }
+ phpbb::$db->sql_multi_insert(STYLES_IMAGESET_DATA_TABLE, $sql_ary);
}
}
}
@@ -1833,32 +1423,22 @@ class install_install extends module
*/
function add_bots($mode, $sub)
{
- global $db, $lang;
-
- // Obtain any submitted data
- $data = $this->get_submitted_data();
-
- // Fill the config array - it is needed by those functions we call
- $sql = 'SELECT *
- FROM ' . CONFIG_TABLE;
- $result = $db->sql_query($sql);
-
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . "
WHERE group_name_clean = 'bots'";
- $result = $db->sql_query($sql);
- $group_id = (int) $db->sql_fetchfield('group_id');
- $db->sql_freeresult($result);
+ $result = phpbb::$db->sql_query($sql);
+ $group_id = (int) phpbb::$db->sql_fetchfield('group_id');
+ phpbb::$db->sql_freeresult($result);
if (!$group_id)
{
// If we reach this point then something has gone very wrong
- $this->p_master->error($lang['NO_GROUP'], __LINE__, __FILE__);
+ trigger_error('NO_GROUP', E_USER_ERROR);
}
if (!function_exists('user_add'))
{
- include(PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT);
+ include PHPBB_ROOT_PATH . 'includes/functions_user.' . PHP_EXT;
}
foreach ($this->bot_list as $bot_name => $bot_ary)
@@ -1871,10 +1451,10 @@ class install_install extends module
'user_password' => '',
'user_colour' => '9E8DA7',
'user_email' => '',
- 'user_lang' => $data['default_lang'],
+ 'user_lang' => phpbb::$config['default_lang'],
'user_style' => 1,
'user_timezone' => 0,
- 'user_dateformat' => $lang['default_dateformat'],
+ 'user_dateformat' => phpbb::$user->lang['default_dateformat'],
'user_allow_massemail' => 0,
);
@@ -1883,11 +1463,11 @@ class install_install extends module
if (!$user_id)
{
// If we can't insert this user then continue to the next one to avoid inconsistant data
- $this->p_master->db_error('Unable to insert bot into users table', $db->sql_error_sql, __LINE__, __FILE__, true);
+ $this->p_master->db_error('Unable to insert bot into users table', $db->sql_error_sql, __LINE__, __FILE__);
continue;
}
- $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
+ $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', array(
'bot_active' => 1,
'bot_name' => (string) $bot_name,
'user_id' => (int) $user_id,
@@ -1895,7 +1475,7 @@ class install_install extends module
'bot_ip' => (string) $bot_ary[1],
));
- $result = $db->sql_query($sql);
+ $result = phpbb::$db->sql_query($sql);
}
}
@@ -1904,25 +1484,19 @@ class install_install extends module
*/
function email_admin($mode, $sub)
{
- global $auth, $db, $lang, $template, $user;
-
- $this->page_title = $lang['STAGE_FINAL'];
-
// Obtain any submitted data
$data = $this->get_submitted_data();
- $sql = 'SELECT *
- FROM ' . CONFIG_TABLE;
- $result = $db->sql_query($sql);
+ // Normal Login
+ phpbb::$user->login($data['admin_name'], $data['admin_pass1'], false, true, false);
- $user->session_begin();
- $auth->login($data['admin_name'], $data['admin_pass1'], false, true, true);
+ // Admin Login
+ phpbb::$user->login($data['admin_name'], $data['admin_pass1'], false, true, true);
- // OK, Now that we've reached this point we can be confident that everything
- // is installed and working......I hope :)
- // So it's time to send an email to the administrator confirming the details
- // they entered
+ phpbb::$acl->init(phpbb::$user->data);
+ // OK, Now that we've reached this point we can be confident that everything is installed and working......I hope :)
+ /* So it's time to send an email to the administrator confirming the details they entered
if (phpbb::$config['email_enable'])
{
include_once(PHPBB_ROOT_PATH . 'includes/functions_messenger.' . PHP_EXT);
@@ -1931,12 +1505,12 @@ class install_install extends module
$messenger->template('installed', $data['language']);
- $messenger->to($data['board_email1'], $data['admin_name']);
+ $messenger->to($data['board_contact'], $data['admin_name']);
$messenger->headers('X-AntiAbuse: Board servername - ' . phpbb::$config['server_name']);
- $messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
- $messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
- $messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
+ $messenger->headers('X-AntiAbuse: User_id - ' . phpbb::$user->data['user_id']);
+ $messenger->headers('X-AntiAbuse: Username - ' . phpbb::$user->data['username']);
+ $messenger->headers('X-AntiAbuse: User IP - ' . phpbb::$user->ip);
$messenger->assign_vars(array(
'USERNAME' => htmlspecialchars_decode($data['admin_name']),
@@ -1945,15 +1519,13 @@ class install_install extends module
$messenger->send(NOTIFY_EMAIL);
}
-
+*/
// And finally, add a note to the log
add_log('admin', 'LOG_INSTALL_INSTALLED', phpbb::$config['version']);
- $template->assign_vars(array(
- 'TITLE' => $lang['INSTALL_CONGRATS'],
- 'BODY' => sprintf($lang['INSTALL_CONGRATS_EXPLAIN'], phpbb::$config['version'], append_sid('install/index', 'mode=convert&amp;language=' . $data['language']), '../docs/README.html'),
- 'L_SUBMIT' => $lang['INSTALL_LOGIN'],
- 'U_ACTION' => append_sid('adm/index'),
+ phpbb::$template->assign_vars(array(
+ 'L_BODY' => phpbb::$user->lang('INSTALL_CONGRATS_EXPLAIN', phpbb::$config['version'], phpbb::$url->append_sid('install/index', 'mode=convert&amp;language=' . $data['language']), '../docs/README.html'),
+ 'U_ACTION' => phpbb::$url->append_sid('adm/index'),
));
}
@@ -1962,14 +1534,12 @@ class install_install extends module
*/
function mail_auth_select($selected_method)
{
- global $lang;
-
$auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP');
$s_smtp_auth_options = '';
foreach ($auth_methods as $method)
{
- $s_smtp_auth_options .= '<option value="' . $method . '"' . (($selected_method == $method) ? ' selected="selected"' : '') . '>' . $lang['SMTP_' . str_replace('-', '_', $method)] . '</option>';
+ $s_smtp_auth_options .= '<option value="' . $method . '"' . (($selected_method == $method) ? ' selected="selected"' : '') . '>' . phpbb::$user->lang['SMTP_' . str_replace('-', '_', $method)] . '</option>';
}
return $s_smtp_auth_options;
@@ -1993,8 +1563,8 @@ class install_install extends module
'admin_name' => utf8_normalize_nfc(request_var('admin_name', '', true)),
'admin_pass1' => request_var('admin_pass1', '', true),
'admin_pass2' => request_var('admin_pass2', '', true),
- 'board_email1' => strtolower(request_var('board_email1', '')),
- 'board_email2' => strtolower(request_var('board_email2', '')),
+ 'board_email' => strtolower(request_var('board_email', '')),
+ 'board_contact' => strtolower(request_var('board_contact', '')),
'img_imagick' => request_var('img_imagick', ''),
'ftp_path' => request_var('ftp_path', ''),
'ftp_user' => request_var('ftp_user', ''),
@@ -2014,6 +1584,8 @@ class install_install extends module
);
}
+ var $common_config_options = array('language' => array(), 'img_imagick' => array());
+
/**
* The information below will be used to build the input fields presented to the user
*/
@@ -2033,8 +1605,8 @@ class install_install extends module
'admin_name' => array('lang' => 'ADMIN_USERNAME', 'type' => 'text:25:100', 'explain' => true),
'admin_pass1' => array('lang' => 'ADMIN_PASSWORD', 'type' => 'password:25:100', 'explain' => true),
'admin_pass2' => array('lang' => 'ADMIN_PASSWORD_CONFIRM', 'type' => 'password:25:100', 'explain' => false),
- 'board_email1' => array('lang' => 'CONTACT_EMAIL', 'type' => 'text:25:100', 'explain' => false),
- 'board_email2' => array('lang' => 'CONTACT_EMAIL_CONFIRM', 'type' => 'text:25:100', 'explain' => false),
+ 'board_contact' => array('lang' => 'CONTACT_EMAIL', 'type' => 'text:25:100', 'explain' => true),
+ 'board_email' => array('lang' => 'ADMIN_EMAIL', 'type' => 'text:25:100', 'explain' => true),
);
var $advanced_config_options = array(
'legend1' => 'ACP_EMAIL_SETTINGS',
@@ -2232,6 +1804,58 @@ class install_install extends module
),
),
);
+
+ var $role_definitions = array(
+ // Standard Admin (a_)
+ array('ROLE_ADMIN_STANDARD', 1, 'a_', 'NOT IN', array('a_switchperm', 'a_jabber', 'a_phpinfo', 'a_server', 'a_backup', 'a_styles', 'a_clearlogs', 'a_modules', 'a_language', 'a_email', 'a_bots', 'a_search', 'a_aauth', 'a_roles')),
+ // Forum Admin (a_)
+ array('ROLE_ADMIN_FORUM', 1, 'a_', 'IN', array('a_', 'a_authgroups', 'a_authusers', 'a_fauth', 'a_forum', 'a_forumadd', 'a_forumdel', 'a_mauth', 'a_prune', 'a_uauth', 'a_viewauth', 'a_viewlogs')),
+ // User and Groups Admin (a_)
+ array('ROLE_ADMIN_USERGROUP', 1, 'a_', 'IN', array('a_', 'a_authgroups', 'a_authusers', 'a_ban', 'a_group', 'a_groupadd', 'a_groupdel', 'a_ranks', 'a_uauth', 'a_user', 'a_viewauth', 'a_viewlogs')),
+ // Full Admin (a_)
+ array('ROLE_ADMIN_FULL', 1, 'a_', false, false),
+ // All Features (u_)
+ array('ROLE_USER_FULL', 1, 'u_', false, false),
+ // Standard Features (u_)
+ array('ROLE_USER_STANDARD', 1, 'u_', 'NOT IN', array('u_viewonline', 'u_chggrp', 'u_chgname', 'u_ignoreflood', 'u_pm_flash', 'u_pm_forward')),
+ // Limited Features (u_)
+ array('ROLE_USER_LIMITED', 1, 'u_', 'NOT IN', array('u_attach', 'u_viewonline', 'u_chggrp', 'u_chgname', 'u_ignoreflood', 'u_pm_attach', 'u_pm_emailpm', 'u_pm_flash', 'u_savedrafts', 'u_search', 'u_sendemail', 'u_sendim', 'u_masspm', 'u_masspm_group')),
+ // No Private Messages (u_)
+ array('ROLE_USER_NOPM', 1, 'u_', 'IN', array('u_', 'u_chgavatar', 'u_chgcensors', 'u_chgemail', 'u_chgpasswd', 'u_download', 'u_hideonline', 'u_sig', 'u_viewprofile')),
+ array('ROLE_USER_NOPM', 0, 'u_', 'IN', array('u_readpm', 'u_sendpm', 'u_masspm', 'u_masspm_group')),
+ // No Avatar (u_)
+ array('ROLE_USER_NOAVATAR', 1, 'u_', 'NOT IN', array('u_attach', 'u_chgavatar', 'u_viewonline', 'u_chggrp', 'u_chgname', 'u_ignoreflood', 'u_pm_attach', 'u_pm_emailpm', 'u_pm_flash', 'u_savedrafts', 'u_search', 'u_sendemail', 'u_sendim', 'u_masspm', 'u_masspm_group')),
+ array('ROLE_USER_NOAVATAR', 0, 'u_', 'IN', array('u_chgavatar', 'u_masspm', 'u_masspm_group')),
+ // Download and search for guests (u_)
+ array('ROLE_USER_GUESTS', 1, 'u_', 'IN', array('u_', 'u_download', 'u_search')),
+ // Full Moderator (m_)
+ array('ROLE_MOD_FULL', 1, 'm_', false, false),
+ // Standard Moderator (m_)
+ array('ROLE_MOD_STANDARD', 1, 'm_', 'NOT IN', array('m_ban', 'm_chgposter')),
+ // Simple Moderator (m_)
+ array('ROLE_MOD_SIMPLE', 1, 'm_', 'IN', array('m_', 'm_delete', 'm_edit', 'm_info', 'm_report')),
+ // Queue Moderator (m_)
+ array('ROLE_MOD_QUEUE', 1, 'm_', 'IN', array('m_', 'm_approve', 'm_edit')),
+ // Full Access (f_)
+ array('ROLE_FORUM_FULL', 1, 'f_', false, false),
+ // Standard Access (f_)
+ array('ROLE_FORUM_STANDARD', 1, 'f_', 'NOT IN', array('f_announce', 'f_flash', 'f_ignoreflood', 'f_poll', 'f_sticky', 'f_user_lock')),
+ // No Access (f_)
+ array('ROLE_FORUM_NOACCESS', 0, 'f_', 'IN', array('f_')),
+ // Read Only Access (f_)
+ array('ROLE_FORUM_READONLY', 1, 'f_', 'IN', array('f_', 'f_download', 'f_list', 'f_read', 'f_search', 'f_subscribe', 'f_print')),
+ // Limited Access (f_)
+ array('ROLE_FORUM_LIMITED', 1, 'f_', 'NOT IN', array('f_announce', 'f_attach', 'f_bump', 'f_delete', 'f_flash', 'f_icons', 'f_ignoreflood', 'f_poll', 'f_sticky', 'f_user_lock', 'f_votechg')),
+ // Bot Access (f_)
+ array('ROLE_FORUM_BOT', 1, 'f_', 'IN', array('f_', 'f_download', 'f_list', 'f_read', 'f_print')),
+ // On Moderation Queue (f_)
+ array('ROLE_FORUM_ONQUEUE', 1, 'f_', 'NOT IN', array('f_announce', 'f_bump', 'f_delete', 'f_flash', 'f_icons', 'f_ignoreflood', 'f_poll', 'f_sticky', 'f_user_lock', 'f_votechg', 'f_noapprove')),
+ array('ROLE_FORUM_ONQUEUE', 0, 'f_', 'IN', array('f_noapprove')),
+ // Standard Access + Polls (f_)
+ array('ROLE_FORUM_POLLS', 1, 'f_', 'NOT IN', array('f_announce', 'f_flash', 'f_ignoreflood', 'f_sticky', 'f_user_lock')),
+ // Limited Access + Polls (f_)
+ array('ROLE_FORUM_LIMITED_POLLS', 1, 'f_', 'NOT IN', array('f_announce', 'f_attach', 'f_bump', 'f_delete', 'f_flash', 'f_icons', 'f_ignoreflood', 'f_sticky', 'f_user_lock', 'f_votechg')),
+ );
}
?> \ No newline at end of file
diff --git a/phpBB/install/install_main.php b/phpBB/install/install_main.php
index 565b06b0b3..48cd600249 100644
--- a/phpBB/install/install_main.php
+++ b/phpBB/install/install_main.php
@@ -43,34 +43,32 @@ class install_main extends module
function main($mode, $sub)
{
- global $lang, $template, $language;
-
switch ($sub)
{
case 'intro' :
- $title = $lang['SUB_INTRO'];
- $body = $lang['OVERVIEW_BODY'];
+ $title = phpbb::$user->lang['SUB_INTRO'];
+ $body = phpbb::$user->lang['OVERVIEW_BODY'];
break;
case 'license' :
- $title = $lang['GPL'];
- $body = implode("<br/>\n", file('../docs/COPYING'));
+ $title = phpbb::$user->lang['GPL'];
+ $body = implode("<br />\n", file('../docs/COPYING'));
break;
case 'support' :
- $title = $lang['SUB_SUPPORT'];
- $body = $lang['SUPPORT_BODY'];
+ $title = phpbb::$user->lang['SUB_SUPPORT'];
+ $body = phpbb::$user->lang['SUPPORT_BODY'];
break;
}
- $this->tpl_name = 'install_main';
+ $this->tpl_name = 'install/main';
$this->page_title = $title;
- $template->assign_vars(array(
+ phpbb::$template->assign_vars(array(
'TITLE' => $title,
'BODY' => $body,
- 'S_LANG_SELECT' => '<select id="language" name="language">' . $this->p_master->inst_language_select($language) . '</select>',
+ 'S_LANG_SELECT' => '<select id="language" name="language">' . $this->p_master->inst_language_select(phpbb::$user->lang_name) . '</select>',
));
}
}
diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php
index 4da795bb4b..d347c0af59 100644
--- a/phpBB/install/install_update.php
+++ b/phpBB/install/install_update.php
@@ -70,7 +70,7 @@ class install_update extends module
function main($mode, $sub)
{
- global $template, $user, $db, $auth;
+ require PHPBB_ROOT_PATH . 'common.' . PHP_EXT;
$this->tpl_name = 'install_update';
$this->page_title = 'UPDATE_INSTALLATION';
@@ -79,33 +79,13 @@ class install_update extends module
$this->old_location = PHPBB_ROOT_PATH . 'install/update/old/';
$this->new_location = PHPBB_ROOT_PATH . 'install/update/new/';
- // Init DB
- require(PHPBB_ROOT_PATH . 'config.' . PHP_EXT);
- require(PHPBB_ROOT_PATH . 'includes/db/' . $dbms . '.' . PHP_EXT);
- require(PHPBB_ROOT_PATH . 'includes/constants.' . PHP_EXT);
-
- // Special options for conflicts/modified files
- define('MERGE_NO_MERGE_NEW', 1);
- define('MERGE_NO_MERGE_MOD', 2);
- define('MERGE_NEW_FILE', 3);
- define('MERGE_MOD_FILE', 4);
-
- $db = new $sql_db();
-
- // Connect to DB
- $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);
-
- // We do not need this any longer, unset for safety purposes
- unset($dbpasswd);
-
// Force template recompile
phpbb::$config['load_tplcompile'] = 1;
- // First of all, init the user session
- $user->session_begin();
- $auth->acl($user->data);
-
- $user->setup('install');
+ // Start session management
+ phpbb::$user->session_begin();
+ phpbb::$acl->init(phpbb::$user->data);
+ phpbb::$user->setup('viewforum');
// If we are within the intro page we need to make sure we get up-to-date version info
if ($sub == 'intro')