aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/install/install_install.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/install/install_install.php')
-rw-r--r--phpBB/install/install_install.php1312
1 files changed, 468 insertions, 844 deletions
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