Building the foundations for some later changes to the installer

This code doesn't actually do anything yet ;-)


git-svn-id: file:///svn/phpbb/trunk@5620 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Graham Eames 2006-03-12 15:52:10 +00:00
parent 1adfb39cba
commit f4cfd3665f
6 changed files with 663 additions and 0 deletions

View file

@ -0,0 +1,25 @@
</div>
</div>
<span class="corners-bottom"><span></span></span>
</div>
</div>
<!--
We request you retain the full copyright notice below including the link to www.phpbb.com.
This not only gives respect to the large amount of time given freely by the developers
but also helps build interest, traffic and use of phpBB. If you (honestly) cannot retain
the full copyright we ask you at least leave in place the "Powered by phpBB" line, with
"phpBB" linked to www.phpbb.com. If you refuse to include even this then support on our
forums may be affected.
The phpBB Group : 2006
// -->
<div id="page-footer">
Powered by phpBB {VERSION} &copy; 2006 <a href="http://www.phpbb.com/">phpBB Group</a>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,41 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="{S_CONTENT_DIRECTION}">
<head>
<meta http-equiv="Content-Type" content="text/html; charset={S_CONTENT_ENCODING}" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="imagetoolbar" content="no" />
<!-- IF META -->{META}<!-- ENDIF -->
<title>{PAGE_TITLE}</title>
<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrap">
<div id="page-header">
<h1>{L_INSTALL_PANEL}</h1>
</div>
<div id="page-body">
<div id="tabs">
<ul>
<!-- BEGIN t_block1 -->
<li<!-- IF t_block1.S_SELECTED --> id="activetab"<!-- ENDIF -->><a href="{t_block1.U_TITLE}"><span>{t_block1.L_TITLE}</span></a></li>
<!-- END t_block1 -->
</ul>
</div>
<div class="panel">
<span class="corners-top"><span></span></span>
<div id="content">
<div id="menu">
<ul>
<!-- BEGIN l_block1 -->
<li<!-- IF l_block1.S_SELECTED --> id="activemenu"<!-- ENDIF -->><a href="{l_block1.U_TITLE}"><span>{l_block1.L_TITLE}</span></a></li>
<!-- END l_block1 -->
</ul>
</div>
<div id="main">

View file

@ -0,0 +1,5 @@
<!-- INCLUDE install_header.html -->
<h2>{TITLE}</h2>
{BODY}
<!-- INCLUDE install_footer.html -->

515
phpBB/install/index.php Executable file
View file

@ -0,0 +1,515 @@
<?php
/**
*
* @package install
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
define('IN_PHPBB', true);
// Error reporting level and runtime escaping
//error_reporting(E_ERROR | E_WARNING | E_PARSE);
error_reporting(E_ALL);
set_magic_quotes_runtime(0);
@set_time_limit(120);
// Include essential scripts
$phpbb_root_path = './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require($phpbb_root_path . 'includes/functions.'.$phpEx);
include($phpbb_root_path . 'includes/session.'.$phpEx);
include($phpbb_root_path . 'includes/template.'.$phpEx);
include($phpbb_root_path . 'includes/acm/acm_file.'.$phpEx);
include($phpbb_root_path . 'includes/acm/acm_main.'.$phpEx);
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
// Protect against GLOBALS tricks
if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS']))
{
exit;
}
// Protect against _SESSION tricks
if (isset($_SESSION) && !is_array($_SESSION))
{
exit;
}
// Be paranoid with passed vars
if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on')
{
$not_unset = array('_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_SESSION', '_ENV', '_FILES', 'phpEx', 'phpbb_root_path');
// Not only will array_merge give a warning if a parameter
// is not an array, it 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($_GET, $_POST, $_COOKIE, $_SERVER, $_SESSION, $_ENV, $_FILES);
foreach ($input as $varname => $void)
{
if (!in_array($varname, $not_unset))
{
unset(${$varname});
}
}
unset($input);
}
define('STRIP', (get_magic_quotes_gpc()) ? true : false);
// Try and load an appropriate language if required
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE']))// && !$language)
{
$accept_lang_ary = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
foreach ($accept_lang_ary as $accept_lang)
{
// Set correct format ... guess full xx_YY form
$accept_lang = substr($accept_lang, 0, 2) . '_' . strtoupper(substr($accept_lang, 3, 2));
if (file_exists($phpbb_root_path . 'language/' . $accept_lang))
{
$language = $accept_lang;
break;
}
else
{
// No match on xx_YY so try xx
$accept_lang = substr($accept_lang, 0, 2);
if (file_exists($phpbb_root_path . 'language/' . $accept_lang))
{
$language = $accept_lang;
break;
}
}
}
}
// No appropriate language found ... so let's use the first one in the language
// dir, this may or may not be English
if (!$language)
{
$dir = @opendir($phpbb_root_path . 'language');
while ($file = readdir($dir))
{
$path = $phpbb_root_path . 'language/' . $file;
if (!is_file($path) && !is_link($path) && file_exists($path . '/iso.txt'))
{
$language = $file;
break;
}
}
}
// And finally, load the relevant language files
include($phpbb_root_path . 'language/' . $language . '/common.'.$phpEx);
include($phpbb_root_path . 'language/' . $language . '/acp/common.'.$phpEx);
include($phpbb_root_path . 'language/' . $language . '/install.'.$phpEx);
include($phpbb_root_path . 'language/' . $language . '/posting.'.$phpEx);
$mode = request_var('mode', 'overview');
$sub = request_var('sub', '');
$template = new Template();
$template->set_custom_template('../adm/style', 'admin');
$template->assign_var('T_TEMPLATE_PATH', '../adm/style');
$install = new module();
$install->create('install', "index.$phpEx", $mode, $sub);
$install->load();
// Generate the page
$install->page_header();
$install->generate_navigation();
$template->set_filenames(array(
'body' => $install->get_tpl_name())
);
$install->page_footer();
/**
*/
class module
{
var $id = 0;
var $type = 'install';
var $module_ary = array();
var $filename;
var $module_url = '';
var $tpl_name = '';
var $mode;
var $sub;
// Private methods, should not be overwritten
function create($module_type, $module_url, $selected_mod = false, $selected_submod = false)
{
global $db, $config, $phpEx;
$module = array();
// Grab module information using Bart's "neat-o-module" system (tm)
$dir = @opendir('.');
$setmodules = 1;
while ($file = readdir($dir))
{
if (preg_match('#^install_(.*?)\.' . $phpEx . '$#', $file))
{
include($file);
}
}
@closedir($dir);
unset($setmodules);
if (!sizeof($module))
{
$this->error('No installation modules found', __LINE__, __FILE__);
}
foreach($module as $row)
{
// Check any module pre-reqs
if ($row['module_reqs'] != '')
{
}
$this->module_ary[$row['module_order']]['name'] = $row['module_title'];
$this->module_ary[$row['module_order']]['filename'] = $row['module_filename'];
$this->module_ary[$row['module_order']]['subs'] = $row['module_subs'];
$this->module_ary[$row['module_order']]['stages'] = $row['module_stages'];
if (strtolower($selected_mod) == strtolower($row['module_title']))
{
$this->id = (int) $row['module_order'];
$this->filename = (string) $row['module_filename'];
$this->module_url = (string) $module_url;
$this->mode = (string) $selected_mod;
// Check that the sub-mode specified is valid or set a default if not
if (is_array($row['module_subs']))
{
$this->sub = strtolower((in_array(strtoupper($selected_submod), $row['module_subs'])) ? $selected_submod : $row['module_subs'][0]);
}
else
{
$this->sub = '';
}
}
} // END foreach
} // END create
// Load and run the relevant module if applicable
function load($mode = false, $run = true)
{
global $phpbb_root_path, $phpEx;
if ($run)
{
if (!empty($mode))
{
$this->mode = $mode;
}
eval("\$this->module = new $this->filename(\$this);");
if (method_exists($this->module, 'main'))
{
$this->module->main($this->mode, $this->sub);
}
}
} // END load
/**
* Output the standard page header
*/
function page_header()
{
if (defined('HEADER_INC'))
{
return;
}
define('HEADER_INC', true);
global $template, $lang, $stage;
$template->assign_vars(array(
'L_INSTALL_PANEL' => $lang['INSTALL_PANEL'],
'PAGE_TITLE' => $this->get_page_title(),
'META' => $this->get_meta(),
'S_CONTENT_DIRECTION' => $lang['DIRECTION'],
'S_CONTENT_ENCODING' => $lang['ENCODING'],
'S_CONTENT_DIR_LEFT' => $lang['LEFT'],
'S_CONTENT_DIR_RIGHT' => $lang['RIGHT'],
)
);
if (!empty($lang['ENCODING']))
{
header('Content-type: text/html; charset: ' . $lang['ENCODING']);
}
header('Cache-Control: private, no-cache="set-cookie", pre-check=0, post-check=0');
header('Expires: 0');
header('Pragma: no-cache');
return;
}
/**
* Output the standard page footer
*/
function page_footer()
{
global $template;
$template->display('body');
// Close our DB connection.
if (isset($db))
{
$db->sql_close();
}
exit;
}
/**
* Returns desired template name
*/
function get_tpl_name()
{
return $this->module->tpl_name . '.html';
}
/**
* Returns the desired page title
*/
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;
}
/**
* Returns the desired meta tags for the page
*/
function get_meta()
{
return (isset($this->module->meta)) ? $this->module->meta : '';
}
/**
* Generate the navigation tabs
*/
function generate_navigation()
{
global $lang, $template, $phpEx;
if (is_array($this->module_ary))
{
@ksort($this->module_ary);
foreach ($this->module_ary as $cat_ary)
{
$cat = $cat_ary['name'];
$l_cat = (!empty($lang['CAT_' . $cat])) ? $lang['CAT_' . $cat] : preg_replace('#_#', ' ', $cat);
$cat = strtolower($cat);
$url = 'index.' . $phpEx . '?mode=' . $cat;
if ($this->mode == $cat)
{
$template->assign_block_vars('t_block1', array(
'L_TITLE' => $l_cat,
'S_SELECTED' => true,
'U_TITLE' => $url,
));
if (is_array($this->module_ary[$this->id]['subs']))
{
$subs = $this->module_ary[$this->id]['subs'];
foreach ($subs as $option)
{
$l_option = (!empty($lang['SUB_' . $option])) ? $lang['SUB_' . $option] : preg_replace('#_#', ' ', $option);
$option = strtolower($option);
$url = 'index.' . $phpEx . '?mode=' . $this->mode . '&amp;sub=' . $option;
$template->assign_block_vars('l_block1', array(
'L_TITLE' => $l_option,
'S_SELECTED' => ($this->sub == $option),
'U_TITLE' => $url,
));
}
}
}
else
{
$template->assign_block_vars('t_block1', array(
'L_TITLE' => $l_cat,
'S_SELECTED' => false,
'U_TITLE' => $url,
));
}
}
}
}
/**
* Output an error message
* If skip is true, return and continue execution, else exit
* @todo: Really should change the caption based on $skip and calling code at some point
*/
function error($error, $line, $file, $skip = false)
{
global $lang, $db;
if (!$skip)
{
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 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>' . $file . ' [ ' . $line . " ]</p>\n";
echo ' <p><b>' . $error . "</b></p>\n";
if ($skip)
{
return;
}
echo ' </div>';
echo ' <span class="corners-bottom"><span></span></span>';
echo ' </div>';
echo ' </div>';
echo ' <div id="page-footer">';
echo ' Powered by phpBB &copy; ' . date('Y') . ' <a href="http://www.phpbb.com/">phpBB Group</a>';
echo ' </div>';
echo '</div>';
echo '</body>';
echo '</html>';
if (isset($db))
{
$db->sql_close();
}
exit;
}
/**
* 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)
{
global $lang, $db;
$this->page_header();
echo ' <h2 style="color:red;text-align:center">' . $lang['INST_ERR_FATAL'] . "</h2>\n";
echo ' <p>' . $lang['INST_ERR_FATAL_DB'] . "</p>\n";
echo ' <p>' . $file . ' [ ' . $line . " ]</p>\n";
echo ' <p>SQL : ' . $sql . "</p>\n";
echo ' <p><b>' . $error . "</b></p>\n";
if ($skip)
{
return;
}
$db->sql_close();
$this->page_footer();
exit;
}
/**
* Generate the relevant HTML for an input field and the assosciated label and explanatory text
*/
function input_field($name, $lang_key, $type, $value='', $options='')
{
global $lang;
$tpl_type = explode(':', $type);
$tpl = '';
switch ($tpl_type[0])
{
case 'text':
case 'password':
$size = (int) $tpl_type[1];
$maxlength = (int) $tpl_type[2];
$tpl = '<input id="' . $key . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '" value="' . $value . '" />';
break;
case 'textarea':
$rows = (int) $tpl_type[1];
$cols = (int) $tpl_type[2];
$tpl = '<textarea id="' . $key . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $value . '</textarea>';
break;
case 'radio':
$key_yes = ($value) ? ' checked="checked"' : '';
$key_no = (!$value) ? ' checked="checked"' : '';
$tpl_type_cond = explode('_', $tpl_type[1]);
$type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true;
$tpl_no = '<input type="radio" name="' . $name . '" value="0"' . $key_no . ' class="radio" />&nbsp;' . (($type_no) ? $lang['NO'] : $lang['DISABLED']);
$tpl_yes = '<input type="radio" id="' . $key . '" name="' . $name . '" value="1"' . $key_yes . ' class="radio" />&nbsp;' . (($type_no) ? $lang['YES'] : $lang['ENABLED']);
$tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . '&nbsp;&nbsp;' . $tpl_no : $tpl_no . '&nbsp;&nbsp;' . $tpl_yes;
break;
case 'select':
eval('$s_options = ' . str_replace('{VALUE}', $value, $options) . ';');
$tpl = '<select name="' . $name . '">' . $s_options . '</select>';
break;
case 'custom':
eval('$tpl = ' . str_replace('{VALUE}', $value, $options) . ';');
break;
default:
break;
}
return $tpl;
}
}
?>

64
phpBB/install/install_main.php Executable file
View file

@ -0,0 +1,64 @@
<?php
/**
*
* @package install
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
if (!empty($setmodules))
{
$module[] = array(
'module_type' => 'install',
'module_title' => 'OVERVIEW',
'module_filename' => substr(basename(__FILE__), 0, -strlen($phpEx)-1),
'module_order' => 0,
'module_subs' => array('INTRO', 'LICENSE', 'SUPPORT'),
'module_stages' => '',
'module_reqs' => ''
);
return;
}
class install_main extends module
{
function install_main(&$p_master)
{
$this->p_master = &$p_master;
}
function main($mode, $sub)
{
global $lang, $template;
switch($sub)
{
case 'intro' :
$title = $lang['SUB_INTRO'];
$body = $lang['OVERVIEW_BODY'];
break;
case 'license' :
$title = $lang['GPL'];
$body = implode("<br/>\n", file('../docs/COPYING'));
break;
case 'support' :
$title = $lang['SUB_SUPPORT'];
$body = $lang['SUPPORT_BODY'];
break;
}
$this->tpl_name = 'install_main';
$this->page_title = $title;
$template->assign_vars(array(
'TITLE' => $title,
'BODY' => $body,
));
}
}
?>

View file

@ -38,6 +38,9 @@ $lang = array_merge($lang, array(
'CACHE_STORE' => 'Cache type',
'CACHE_STORE_EXPLAIN' => 'The physical location where data is cached, filesystem is prefered.',
'CAT_CONVERT' => 'Convert',
'CAT_INSTALL' => 'Install',
'CAT_OVERVIEW' => 'Overview',
'CONFIG_RETRY' => 'Retry',
'CONTACT_EMAIL' => 'Contact email address',
'CONTACT_EMAIL_CONFIRM' => 'Confirm contact email',
@ -84,6 +87,8 @@ $lang = array_merge($lang, array(
'FTP_UPLOAD' => 'Upload',
'FTP_USERNAME' => 'FTP Username',
'GPL' => 'General Public License',
'INITIAL_CONFIG' => 'Basic Configuration',
'INITIAL_CONFIG_EXPLAIN' => 'Now that install has determined your server can run phpBB you need to supply some specific information. If you do not know how to connect to your database please contact your hosting provider (in the first instance) or use the phpBB support forums. When entering data please ensure you check it thoroughly before continuing.',
'INSTALL_ADVICE' => 'Installation Compatibility',
@ -98,6 +103,7 @@ $lang = array_merge($lang, array(
'INSTALL_OPTIONAL' => 'Optional',
'INSTALL_OPTIONAL_FILES' => 'These files, directories or permissions are optional. The installation routines will attempt to use various techniques to complete if they do not exist or cannot be written to. However, the presence of these files, directories or permissions will speed installation.',
'INSTALL_OPTIONAL_PHP' => 'These modules or applications are optional, you do not need these to use phpBB 3.0. However if you do have them they will will enable greater functionality.',
'INSTALL_PANEL' => 'Installation Panel',
'INSTALL_REQUIRED' => 'Required',
'INSTALL_REQUIRED_FILES' => 'In order to function correctly phpBB needs to be able to access or write to certain files or directories. If you see "Not Found" you need to create the relevant file or directory. If you see "Unwriteable" you need to change the permissions on the file or directory to allow phpBB to write to it.',
'INSTALL_REQUIRED_PHP' => 'You must be running at least PHP 4.3.3 with support for at least one compatible database. If no support modules are shown as available you should contact your hosting provider or review the relevant PHP installation documentation for advice. If "safe mode" is displayed below your PHP installation is running in that mode. This will impose limitations on remote administration and similar features.',
@ -117,6 +123,8 @@ $lang = array_merge($lang, array(
'INST_ERR_PREFIX' => 'Tables with the specified prefix already exist, please choose an alternative.',
'NO_LOCATION' => 'Cannot determine location',
// TODO: Write some explanatory introduction text
'OVERVIEW_BODY' => '<p>Some brief explanatory text about phpBB will go here.</p><p>This installation system will guide you through the process of installing phpBB, converting from a different software package or updating to the latest version of phpBB. For more information on each option, select it from the menu above</p>',
'PHP_AND_APPS' => 'PHP and Applications',
'PHP_REQD_DB' => 'Supported Databases',
@ -134,6 +142,11 @@ $lang = array_merge($lang, array(
'SERVER_NAME_EXPLAIN' => 'The domain name this board runs from',
'SERVER_PORT' => 'Server port',
'SERVER_PORT_EXPLAIN' => 'The port your server is running on, usually 80, only change if different',
'SUB_INTRO' => 'Introduction',
'SUB_LICENSE' => 'License',
'SUB_SUPPORT' => 'Support',
// TODO: Write some text on obtaining support
'SUPPORT_BODY' => '<p>Some text on obtaining support, etc can go here.</p><p>Probably this can be copied from the documentation</p><p>To ensure you stay up to date with the latest news and releases, why not <a href="http://www.phpbb.com/support/" target="_new">subscribe to our mailing list</a></p>',
'TABLE_PREFIX' => 'Prefix for tables in database',
'TESTS_PASSED' => 'Tests passed',