Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

huge update

 - move to PHP5
 - some small changes and fixes
 - some big changes
 - blinky support
  • Loading branch information...
commit b22e9e2320267c944b9fc6b7720628007aab6213 1 parent d796298
Igor igorw authored
2  changelog.xml
View
@@ -69,6 +69,8 @@
<changelog lang="en">
<change>[Fix] Updated version number in footer.</change>
<change>[Fix] Added some more security.</change>
+ <change>[Change] Partial rewrite.</change>
+ <change>[Change] Blinky (easymod) support.</change>
</changelog>
</entry>
</history>
6 includes/db/mssql.php
View
@@ -1,10 +1,10 @@
<?php
-/**
+/**
*
* @package quickinstall
* @version $Id$
-* @copyright (c) 2007 eviL3
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @copyright (c) 2007, 2008 eviL3
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
6 includes/db/mysql.php
View
@@ -1,10 +1,10 @@
<?php
-/**
+/**
*
* @package quickinstall
* @version $Id$
-* @copyright (c) 2007 eviL3
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @copyright (c) 2007, 2008 eviL3
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
6 includes/db/mysqli.php
View
@@ -1,10 +1,10 @@
<?php
-/**
+/**
*
* @package quickinstall
* @version $Id$
-* @copyright (c) 2007 eviL3
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @copyright (c) 2007, 2008 eviL3
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
30 includes/db/sqlite.php
View
@@ -1,10 +1,10 @@
<?php
-/**
+/**
*
* @package quickinstall
* @version $Id$
-* @copyright (c) 2007 eviL3
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @copyright (c) 2007, 2008 eviL3
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
@@ -24,16 +24,16 @@ class dbal_sqlite_qi extends dbal_sqlite
{
/**
* Connection error
- *
+ *
* @var string
*/
var $error = '';
-
+
/**
* Used for $this->server
*/
var $port;
-
+
/**
* Connect to server
*/
@@ -43,12 +43,12 @@ function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = fals
$this->user = $sqluser;
$this->server = $sqlserver . (($port) ? ':' . $port : '');
$this->dbname = $database;
-
+
$this->port = $port;
-
+
// connect to db
$this->sql_select_db($this->server);
-
+
return ($this->db_connect_id) ? true : array('message' => $error);
}
@@ -64,30 +64,30 @@ function sql_select_db($dbname)
if (empty($dbname))
{
global $quickinstall_path;
-
+
$dbname = $quickinstall_path . 'cache/sqlite_db';
}
-
+
// if file doesn't exist, attempt to create it.
if (!is_writable(dirname($dbname)))
{
trigger_error('SQLite: unable to write to dir ' . dirname($dbname), E_USER_ERROR);
}
-
+
$fp = @fopen($dbname, 'a');
@fclose($fp);
@chmod($dbname, 0777);
}
-
+
$this->server = $dbname . (($this->port) ? ':' . $this->port : '');
-
+
$this->db_connect_id = ($this->persistency) ? @sqlite_popen($this->server, 0666, $this->error) : @sqlite_open($this->server, 0666, $this->error);
if ($this->db_connect_id)
{
@sqlite_query('PRAGMA short_column_names = 1', $this->db_connect_id);
}
-
+
return $this->db_connect_id;
}
}
103 includes/functions_files.php
View
@@ -1,10 +1,10 @@
<?php
-/**
+/**
*
* @package quickinstall
* @version $Id$
-* @copyright (c) 2007 eviL3
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @copyright (c) 2007, 2008 eviL3
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
@@ -18,47 +18,45 @@
/**
* Useful class for directory and file actions
- * Can't use self because that's php5 only
*/
class file_functions
{
- function delete_file($file)
+ public static function delete_file($file)
{
return unlink($file);
}
-
- function copy_file($src_file, $dst_file)
+
+ public static function copy_file($src_file, $dst_file)
{
return copy($src_file, $dst_file);
}
-
- function move_file($src_file, $dst_file)
+
+ public static function move_file($src_file, $dst_file)
{
- file_functions::copy_file($src_file, $dst_file);
- file_functions::delete_file($src_file);
+ self::copy_file($src_file, $dst_file);
+ self::delete_file($src_file);
}
-
- function copy_dir($src_dir, $dst_dir)
+
+ public static function copy_dir($src_dir, $dst_dir)
{
- file_functions::dir_slash($src_dir);
- file_functions::dir_slash($dst_dir);
-
+ self::append_slash($src_dir);
+ self::append_slash($dst_dir);
+
if (!is_dir($dst_dir))
{
mkdir($dst_dir);
}
-
- $d = dir($src_dir);
- while (false !== ($file = $d->read()))
+
+ foreach (scandir($src_dir) as $file)
{
- if (in_array($file, array('.', '..')))
+ if (in_array($file, array('.', '..'), true))
{
continue;
}
-
+
$src_file = $src_dir . $file;
$dst_file = $dst_dir . $file;
-
+
if (is_file($src_file))
{
if (is_file($dst_file))
@@ -69,7 +67,7 @@ function copy_dir($src_dir, $dst_dir)
{
$ow = 1;
}
-
+
if ($ow > 0)
{
if (copy($src_file, $dst_file))
@@ -80,82 +78,77 @@ function copy_dir($src_dir, $dst_dir)
}
else if (is_dir($src_file))
{
- file_functions::copy_dir($src_file, $dst_file);
+ self::copy_dir($src_file, $dst_file);
}
}
- $d->close();
}
-
- function delete_dir($dir, $empty = false)
+
+ public static function delete_dir($dir, $empty = false)
{
- file_functions::dir_slash($dir);
-
+ self::append_slash($dir);
+
if (!file_exists($dir) || !is_dir($dir) || !is_readable($dir))
{
return false;
}
-
- $d = dir($dir);
- while (false !== ($file = $d->read()))
+
+ foreach (scandir($dir) as $file)
{
- if (in_array($file, array('.', '..')))
+ if (in_array($file, array('.', '..'), true))
{
continue;
}
-
- if (is_dir($dir . $file))
+
+ if (is_dir($dir . $file))
{
- file_functions::delete_dir($dir . $file);
+ self::delete_dir($dir . $file);
}
else
{
- file_functions::delete_file($dir . $file);
+ self::delete_file($dir . $file);
}
}
- $d->close();
-
+
if (!$empty)
{
@rmdir($dir);
}
}
-
- function delete_files($dir, $files_ary, $recursive = true)
+
+ public static function delete_files($dir, $files_ary, $recursive = true)
{
- file_functions::dir_slash($dir);
-
- $d = dir($dir);
- while (false !== ($file = $d->read()))
+ self::append_slash($dir);
+
+ foreach (scandir($dir) as $file)
{
- if (in_array($file, array('.', '..')))
+ if (in_array($file, array('.', '..'), true))
{
continue;
}
-
+
if (is_dir($dir . $file))
{
if ($recursive)
{
- file_functions::delete_files($dir . $file, $files_ary, true);
+ self::delete_files($dir . $file, $files_ary, true);
}
}
-
- if (in_array($file, $files_ary))
+
+ if (in_array($file, $files_ary, true))
{
if (is_dir($dir . $file))
{
- file_functions::delete_dir($dir . $file);
+ self::delete_dir($dir . $file);
}
else
{
- file_functions::delete_file($dir . $file);
+ self::delete_file($dir . $file);
}
}
}
- $d->close();
}
-
- function dir_slash(&$dir)
+
+ public static function append_slash(&$dir)
{
if ($dir[strlen($dir) - 1] != '/')
{
142 includes/functions_install.php
View
@@ -0,0 +1,142 @@
+<?php
+/**
+*
+* @package quickinstall
+* @version $Id$
+* @copyright (c) 2007, 2008 eviL3
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_QUICKINSTALL'))
+{
+ exit;
+}
+
+/**
+ * Dummy p_master
+ */
+class p_master_dummy
+{
+ public $module_url;
+
+ public function db_error($message, $sql = false, $line = false, $file = false)
+ {
+ trigger_error($message);
+ }
+
+ public function error($message, $sql = false, $line = false, $file = false)
+ {
+ trigger_error($message);
+ }
+
+ public function redirect($url)
+ {
+ qi::redirect($url);
+ }
+}
+
+/**
+ * Dummy module
+ */
+class module
+{
+}
+
+/**
+ * Load a schema (and execute)
+ *
+ * @param string $install_path
+ */
+function load_schema($install_path = '', $install_dbms = false)
+{
+ global $db;
+ global $table_prefix;
+
+ static $available_dbms = false;
+
+ if ($install_dbms === false)
+ {
+ global $dbms;
+ $install_dbms = $dbms;
+ }
+
+ if (!function_exists('get_available_dbms'))
+ {
+ global $phpbb_root_path, $phpEx;
+ include($phpbb_root_path . 'includes/functions_install.' . $phpEx);
+ }
+
+ if (!$available_dbms)
+ {
+ $available_dbms = get_available_dbms($install_dbms);
+
+ if ($install_dbms == 'mysql')
+ {
+ if (version_compare($db->mysql_version, '4.1.3', '>='))
+ {
+ $available_dbms[$install_dbms]['SCHEMA'] .= '_41';
+ }
+ else
+ {
+ $available_dbms[$install_dbms]['SCHEMA'] .= '_40';
+ }
+ }
+ }
+
+ $remove_remarks = $available_dbms[$install_dbms]['COMMENTS'];
+ $delimiter = $available_dbms[$install_dbms]['DELIM'];
+
+ $dbms_schema = $install_path . $available_dbms[$install_dbms]['SCHEMA'] . '_schema.sql';
+
+ if (file_exists($dbms_schema))
+ {
+ $sql_query = @file_get_contents($dbms_schema);
+ $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);
+
+ $remove_remarks($sql_query);
+
+ $sql_query = split_sql_file($sql_query, $delimiter);
+
+ foreach ($sql_query as $sql)
+ {
+ $db->sql_query($sql);
+ }
+ unset($sql_query);
+ }
+
+ if (file_exists($install_path . 'schema_data.sql'))
+ {
+ $sql_query = file_get_contents($install_path . 'schema_data.sql');
+
+ switch ($install_dbms)
+ {
+ case 'mssql':
+ case 'mssql_odbc':
+ $sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2;', $sql_query);
+ break;
+
+ case 'postgres':
+ $sql_query = preg_replace('#\# POSTGRES (BEGIN|COMMIT) \##s', '\1; ', $sql_query);
+ break;
+ }
+
+ $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);
+ $sql_query = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', 'adjust_language_keys_callback', $sql_query);
+
+ remove_remarks($sql_query);
+
+ $sql_query = split_sql_file($sql_query, ';');
+
+ foreach ($sql_query as $sql)
+ {
+ $db->sql_query($sql);
+ }
+ unset($sql_query);
+ }
+}
+
+?>
32 includes/functions_module.php
View
@@ -3,7 +3,7 @@
*
* @package quickinstall
* @version $Id$
-* @copyright (c) 2007 eviL3
+* @copyright (c) 2007, 2008 eviL3
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
@@ -23,32 +23,34 @@
class module_handler
{
- var $modules_path;
-
- function module_handler($modules_path)
+ protected $modules_path;
+ protected $modules_prefix;
+
+ public function __construct($modules_path, $modules_prefix = '')
{
- $this->modules_path = $modules_path;
+ $this->modules_path = (string) $modules_path;
+ $this->modules_prefix = (string) $modules_prefix;
}
-
- function load($module, $default, $sub = false)
+
+ public function load($module, $default)
{
global $phpEx, $user;
-
+
// just some security (thanks lordlebrand)
- //$module = str_replace(array('.', '/', '\\'), '', $module);
$module = basename($module);
-
- if (!file_exists($this->modules_path . (($sub !== false) ? $sub . '/' : '') . $module . '.' . $phpEx))
+
+ if (!file_exists($this->modules_path . $this->modules_prefix . $module . '.' . $phpEx))
{
$module = $default;
}
-
- if (!@include($this->modules_path . (($sub !== false) ? $sub . '/' : '') . $module . '.' . $phpEx))
+
+ if (false === @include($this->modules_path . $this->modules_prefix . $module . '.' . $phpEx))
{
trigger_error(sprintf($user->lang['NO_MODULE'], $module), E_USER_ERROR);
}
-
- return new $module;
+
+ $class_name = $this->modules_prefix . $module;
+ return new $class_name();
}
}
271 includes/functions_quickinstall.php
View
@@ -1,10 +1,10 @@
<?php
-/**
+/**
*
* @package quickinstall
* @version $Id$
-* @copyright (c) 2007 eviL3
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @copyright (c) 2007, 2008 eviL3
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
@@ -17,106 +17,6 @@
}
/**
-* Error and message handler, call with trigger_error if reqd
-*/
-function msg_handler_qi($errno, $msg_text, $errfile, $errline)
-{
- global $phpEx, $phpbb_root_path, $msg_title, $msg_long_text, $quickinstall_path;
- global $user;
-
- // Message handler is stripping text. In case we need it, we are possible to define long text...
- if (isset($msg_long_text) && $msg_long_text && !$msg_text)
- {
- $msg_text = $msg_long_text;
- }
-
- switch ($errno)
- {
- case E_NOTICE:
- case E_WARNING:
-
- // Check the error reporting level and return if the error level does not match
- // Additionally do not display notices if we suppress them via @
- // If DEBUG is defined the default level is E_ALL
- if (($errno & ((defined('DEBUG') && error_reporting()) ? E_ALL : error_reporting())) == 0)
- {
- return;
- }
-
- // remove complete path to installation, with the risk of changing backslashes meant to be there
- $errfile = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $errfile);
- $msg_text = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $msg_text);
-
- echo '<b>[phpBB Debug] PHP Notice</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n";
-
- return;
-
- break;
-
- case E_USER_ERROR:
- case E_USER_WARNING:
- case E_USER_NOTICE:
-
- $msg_title = (isset($msg_title)) ? (isset($user->lang[$msg_title]) ? $user->lang[$msg_title] : $msg_title) : (isset($user->lang['GENERAL_ERROR']) ? $user->lang['GENERAL_ERROR'] : 'General Error');
- $msg_text = (isset($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text;
- $l_return_index = '<a href="' . qi::url('main') . '">Return to quickinstall main page</a>';
-
- 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>' . $msg_title . '</title>';
- echo '<link href="' . $quickinstall_path . 'style/style.css" rel="stylesheet" type="text/css" media="screen" />';
- echo '</head>';
- echo '<body id="errorpage">';
- echo '<div id="wrap">';
- echo ' <div id="page-header">';
- echo ' ' . $l_return_index;
- echo ' </div>';
- echo ' <div id="page-body">';
- echo ' <div id="acp">';
- echo ' <div class="panel">';
- echo ' <span class="corners-top"><span></span></span>';
- echo ' <div id="content">';
-
- echo ' <h1>' . $msg_title . '</h1>';
- echo ' <div>' . $msg_text . '</div>';
-
- echo ' </div>';
- echo ' <span class="corners-bottom"><span></span></span>';
- echo ' </div>';
- echo ' </div>';
- echo ' </div>';
- echo ' <div id="page-footer">';
- echo ' Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>';
- echo ' </div>';
- echo '</div>';
- echo '</body>';
- echo '</html>';
-
- exit;
- break;
- }
-
- // If we notice an error not handled here we pass this back to PHP by returning false
- // This may not work for all php versions
- return false;
-}
-
-/**
-* For replacing {L_*} strings with preg_replace_callback (taken from functions_install.php)
-*/
-function adjust_language_keys_callback_qi($matches)
-{
- if (!empty($matches[1]))
- {
- global $user, $db;
-
- return (!empty($user->lang[$matches[1]])) ? $db->sql_escape($user->lang[$matches[1]]) : $db->sql_escape($matches[1]);
- }
-}
-
-/**
* Class with functions usefull for qi. Some stuff is from the install functions, this class is to be used statically.
*/
class qi
@@ -124,7 +24,7 @@ class qi
/**
* Output the standard page header
*/
- function page_header($page_title = '', $page_about = '')
+ public static function page_header($page_title = '', $page_about = '')
{
if (defined('HEADER_INC'))
{
@@ -139,15 +39,15 @@ function page_header($page_title = '', $page_about = '')
'PAGE_ABOUT' => $page_about,
'T_THEME_PATH' => 'style',
'T_IMAGE_PATH' => $quickinstall_path . 'style/images/',
-
- 'U_ABOUT' => qi::url('about'),
- 'U_MANAGE' => qi::url('manage'),
- 'U_MAIN' => qi::url('main'),
+
+ 'U_ABOUT' => self::url('about'),
+ 'U_MANAGE' => self::url('manage'),
+ 'U_MAIN' => self::url('main'),
'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'],
'S_CONTENT_ENCODING' => 'UTF-8',
'S_USER_LANG' => $user->lang['USER_LANG'],
-
+
'TRANSLATION_INFO' => $user->lang['TRANSLATION_INFO'],
'QI_VERSION' => $qi_config['qi_version'],
'PHPBB_VERSION' => $qi_config['phpbb_version'],
@@ -160,16 +60,16 @@ function page_header($page_title = '', $page_about = '')
return;
}
-
+
/**
* Output the standard page footer
*/
- function page_footer()
+ public static function page_footer()
{
global $db, $template;
$template->display('body');
-
+
// Close our DB connection.
if (!empty($db) && is_object($db))
{
@@ -178,13 +78,13 @@ function page_footer()
exit;
}
-
+
/**
* Generate an HTTP/1.1 header to redirect the user to another page
* This is used during the installation when we do not have a database available to call the normal redirect function
* @param string $page The page to redirect to relative to the qi root path
*/
- function redirect($page)
+ public static function redirect($page)
{
$server_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME');
$server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT');
@@ -211,13 +111,13 @@ function redirect($page)
header('Location: ' . $url);
exit;
}
-
+
/**
* Add Language Items
*
* @param mixed $lang_set specifies the language entries to include
*/
- function add_lang($lang_set)
+ public static function add_lang($lang_set)
{
global $user;
@@ -231,36 +131,36 @@ function add_lang($lang_set)
if (!is_array($lang_file))
{
- qi::set_lang($user->lang, $lang_file);
+ self::set_lang($user->lang, $lang_file);
}
else
{
- qi::add_lang($lang_file);
+ self::add_lang($lang_file);
}
}
unset($lang_set);
}
else if ($lang_set)
{
- qi::set_lang($user->lang, $lang_set);
+ self::set_lang($user->lang, $lang_set);
}
}
-
+
/**
* Set language entry (called by add_lang)
* @access private
*/
- function set_lang(&$lang, $lang_file)
+ public static function set_lang(&$lang, $lang_file)
{
global $phpEx, $qi_config, $quickinstall_path;
$lang_path = $quickinstall_path . 'language/' . basename($qi_config['qi_lang']) . '/';
-
+
if (!file_exists($lang_path) || !is_dir($lang_path))
{
trigger_error("Could not find language $lang_path", E_USER_ERROR);
}
-
+
$language_filename = $lang_path . $lang_file . '.' . $phpEx;
if ((include($language_filename)) === false)
@@ -268,11 +168,11 @@ function set_lang(&$lang, $lang_file)
trigger_error("Language file $language_filename couldn't be opened.", E_USER_ERROR);
}
}
-
+
/**
* Format user date
*/
- function format_date($gmepoch, $format = false, $forcedate = false)
+ public static function format_date($gmepoch, $format = false, $forcedate = false)
{
global $user, $qi_config;
static $midnight;
@@ -317,11 +217,11 @@ function format_date($gmepoch, $format = false, $forcedate = false)
return strtr(@gmdate(str_replace('|', '', $format), $gmepoch + $qi_config['qi_tz'] + $qi_config['qi_dst']), $lang_dates);
}
-
- function url($mode, $params = false)
+
+ public static function url($mode, $params = false)
{
global $quickinstall_path, $phpEx;
-
+
if (is_array($params))
{
$_params = '';
@@ -331,47 +231,98 @@ function url($mode, $params = false)
}
$params = &$_params;
}
-
+
return $quickinstall_path . 'index.' . $phpEx . '?mode=' . $mode . ($params ? ('&amp;' . $params) : '');
}
-}
-if (!function_exists('file_put_contents'))
-{
- if (!defined('FILE_APPEND'))
- {
- /**
- * @ignore
- */
- define('FILE_APPEND', 1);
- }
-
/**
- * File get contents for PHP4
- *
- * @param string $filename
- * @param mixed $data
- * @param mixed $flag
- * @return mixed Bytes written
- */
- function file_put_contents($filename, $data, $flag = false)
+ * Error and message handler, call with trigger_error if reqd
+ */
+ public static function msg_handler($errno, $msg_text, $errfile, $errline)
{
- $mode = ($flag == FILE_APPEND || strtoupper($flag) == 'FILE_APPEND') ? 'a' : 'w';
- $f = @fopen($filename, $mode);
-
- if ($f === false)
+ global $phpEx, $phpbb_root_path, $msg_title, $msg_long_text, $quickinstall_path;
+ global $user;
+
+ // Message handler is stripping text. In case we need it, we are possible to define long text...
+ if (isset($msg_long_text) && $msg_long_text && !$msg_text)
{
- return false;
+ $msg_text = $msg_long_text;
}
-
- if (is_array($data))
+
+ switch ($errno)
{
- $data = implode('', $data);
+ case E_NOTICE:
+ case E_WARNING:
+
+ // Check the error reporting level and return if the error level does not match
+ // Additionally do not display notices if we suppress them via @
+ // If DEBUG is defined the default level is E_ALL
+ if (($errno & ((defined('DEBUG') && error_reporting()) ? E_ALL : error_reporting())) == 0)
+ {
+ return;
+ }
+
+ // remove complete path to installation, with the risk of changing backslashes meant to be there
+ $errfile = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $errfile);
+ $msg_text = str_replace(array(phpbb_realpath($phpbb_root_path), '\\'), array('', '/'), $msg_text);
+
+ echo '<b>[phpBB Debug] PHP Notice</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $msg_text . '</b><br />' . "\n";
+
+ return;
+
+ break;
+
+ case E_USER_ERROR:
+ case E_USER_WARNING:
+ case E_USER_NOTICE:
+
+ // uncomment for debug
+ //echo "$errfile:$errline";
+
+ $msg_title = (isset($msg_title)) ? (isset($user->lang[$msg_title]) ? $user->lang[$msg_title] : $msg_title) : (isset($user->lang['GENERAL_ERROR']) ? $user->lang['GENERAL_ERROR'] : 'General Error');
+ $msg_text = (isset($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text;
+ $l_return_index = '<a href="' . qi::url('main') . '">Return to quickinstall main page</a>';
+
+ 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>' . $msg_title . '</title>';
+ echo '<link href="' . $quickinstall_path . 'style/style.css" rel="stylesheet" type="text/css" media="screen" />';
+ echo '</head>';
+ echo '<body id="errorpage">';
+ echo '<div id="wrap">';
+ echo ' <div id="page-header">';
+ echo ' ' . $l_return_index;
+ echo ' </div>';
+ echo ' <div id="page-body">';
+ echo ' <div id="acp">';
+ echo ' <div class="panel">';
+ echo ' <span class="corners-top"><span></span></span>';
+ echo ' <div id="content">';
+
+ echo ' <h1>' . $msg_title . '</h1>';
+ echo ' <div>' . $msg_text . '</div>';
+
+ echo ' </div>';
+ echo ' <span class="corners-bottom"><span></span></span>';
+ echo ' </div>';
+ echo ' </div>';
+ echo ' </div>';
+ echo ' <div id="page-footer">';
+ echo ' Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a>';
+ echo ' </div>';
+ echo '</div>';
+ echo '</body>';
+ echo '</html>';
+
+ exit;
+ break;
}
-
- $bytes_written = fwrite($f, $data);
- fclose($f);
- return $bytes_written;
+
+ // If we notice an error not handled here we pass this back to PHP by returning false
+ // This may not work for all php versions
+ return false;
}
}
76 includes/functions_xml.php
View
@@ -1,76 +0,0 @@
-<?php
-/**
-*
-* @package quickinstall
-* @version $Id$
-* @copyright (c) 2007 eviL3
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
-*
-*/
-
-/**
-* @ignore
-*/
-if (!defined('IN_QUICKINSTALL'))
-{
- exit;
-}
-
-/**
- * Code by geoffers@gmail.com
- * From: http://php.net/xml
- */
-class simple_parser
-{
- var $parser;
- var $error_code;
- var $error_string;
- var $current_line;
- var $current_column;
- var $data = array();
- var $datas = array();
-
- function parse($data)
- {
- $this->parser = xml_parser_create('UTF-8');
- xml_set_object($this->parser, $this);
- xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1);
- xml_set_element_handler($this->parser, 'tag_open', 'tag_close');
- xml_set_character_data_handler($this->parser, 'cdata');
- if (!xml_parse($this->parser, $data))
- {
- $this->data = array();
- $this->error_code = xml_get_error_code($this->parser);
- $this->error_string = xml_error_string($this->error_code);
- $this->current_line = xml_get_current_line_number($this->parser);
- $this->current_column = xml_get_current_column_number($this->parser);
- }
- else
- {
- $this->data = $this->data['child'];
- }
- xml_parser_free($this->parser);
- }
-
- function tag_open($parser, $tag, $attribs)
- {
- // added by eviL3 because big tags suck <3
- $tag = strtolower($tag);
- $this->data['child'][$tag][] = array('data' => '', 'attribs' => $attribs, 'child' => array());
- $this->datas[] =& $this->data;
- $this->data =& $this->data['child'][$tag][count($this->data['child'][$tag])-1];
- }
-
- function cdata($parser, $cdata)
- {
- $this->data['data'] .= $cdata;
- }
-
- function tag_close($parser, $tag)
- {
- $this->data =& $this->datas[count($this->datas)-1];
- array_pop($this->datas);
- }
-}
-
-?>
25 includes/hooks/hook_example.php
View
@@ -1,25 +0,0 @@
-<?php
-/**
-*
-* @package quickinstall
-* @version $Id$
-* @copyright (c) 2007 eviL3
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
-*
-*/
-
-/**
- * @ignore
- */
-if (!defined('IN_QUICKINSTALL'))
-{
- exit;
-}
-
-/**
- * This is an example hook file.
- * Hooks for quickinstall are simply files that are auto included and run after installation of the board.
- * You could add any code you like below :) You can even use $db for sql queries.
- */
-
-?>
37 includes/install_install_qi.php
View
@@ -0,0 +1,37 @@
+<?php
+/**
+*
+* @package quickinstall
+* @version $Id$
+* @copyright (c) 2007, 2008 eviL3
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_QUICKINSTALL'))
+{
+ exit;
+}
+
+/**
+ * Our extension to install_install
+ */
+class install_install_qi extends install_install
+{
+ protected $data = array();
+
+ public function set_data($data)
+ {
+ $this->data = $data;
+ }
+
+ public function get_submitted_data()
+ {
+ return $this->data;
+ }
+}
+
+?>
37 includes/install_mod_qi.php
View
@@ -0,0 +1,37 @@
+<?php
+/**
+*
+* @package quickinstall
+* @version $Id$
+* @copyright (c) 2007, 2008 eviL3
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_QUICKINSTALL'))
+{
+ exit;
+}
+
+/**
+ * Our extension to install_install
+ */
+class install_mod_qi extends install_mod
+{
+ protected $data = array();
+
+ public function set_data($data)
+ {
+ $this->data = $data;
+ }
+
+ public function get_submitted_data()
+ {
+ return $this->data;
+ }
+}
+
+?>
11 includes/qi_config.php
View
@@ -3,7 +3,7 @@
*
* @package quickinstall
* @version $Id$
-* @copyright (c) 2007 eviL3
+* @copyright (c) 2007, 2008 eviL3
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
@@ -30,8 +30,8 @@
'dbhost' => '',
'dbport' => '',
// 'dbname' => '',
- 'dbuser' => '',
- 'dbpasswd' => '',
+ 'dbuser' => 'root',
+ 'dbpasswd' => 'pass',
'table_prefix' => 'phpbb_',
@@ -39,7 +39,7 @@
* do not modify this line!
*/
'qi_version' => '1.0.7-dev',
-
+
/**
* this is for lazy me who forgets to change it in the footer
*/
@@ -98,6 +98,7 @@
* you have to remove // from the line below, so it should look like this:
* @define('QI_INSTALLED', true);
*/
-//@define('QI_INSTALLED', true);
+@define('QI_INSTALLED', true);
+@define('DEBUG', true);
?>
72 index.php
View
@@ -1,10 +1,10 @@
<?php
-/**
+/**
*
* @package quickinstall
* @version $Id$
-* @copyright (c) 2007 eviL3
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @copyright (c) 2007, 2008 eviL3
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
@@ -22,63 +22,9 @@
//error_reporting(E_ALL);
error_reporting(E_ALL ^ E_NOTICE);
-if (version_compare(PHP_VERSION, '4.3.3') < 0)
-{
- die('You are running an unsupported PHP version. Please upgrade to PHP 4.3.3 or higher before trying to do anything with phpBB 3.0');
-}
-
-/*
-* Remove variables created by register_globals from the global scope
-* Thanks to Matt Kavanagh
-*/
-function deregister_globals()
+if (version_compare(PHP_VERSION, '5.1.0') < 0)
{
- $not_unset = array(
- 'GLOBALS' => true,
- '_GET' => true,
- '_POST' => true,
- '_COOKIE' => true,
- '_REQUEST' => true,
- '_SERVER' => true,
- '_SESSION' => true,
- '_ENV' => true,
- '_FILES' => true,
- 'phpEx' => true,
- 'phpbb_root_path' => true
- );
-
- // Not only will array_merge and array_keys give a warning if
- // a parameter is not an array, array_merge will actually fail.
- // So we check if _SESSION has been initialised.
- if (!isset($_SESSION) || !is_array($_SESSION))
- {
- $_SESSION = array();
- }
-
- // Merge all into one extremely huge array; unset
- // this later
- $input = array_merge(
- array_keys($_GET),
- array_keys($_POST),
- array_keys($_COOKIE),
- array_keys($_SERVER),
- array_keys($_SESSION),
- array_keys($_ENV),
- array_keys($_FILES)
- );
-
- foreach ($input as $varname)
- {
- if (isset($not_unset[$varname]))
- {
- // Hacking attempt. No point in continuing.
- exit;
- }
-
- unset($GLOBALS[$varname]);
- }
-
- unset($input);
+ die('You are running an unsupported PHP version. Please upgrade to PHP 5.1.0 or higher before trying to do anything with phpBB 3.0');
}
// If we are on PHP >= 6.0.0 we do not need some code
@@ -118,7 +64,7 @@ function deregister_globals()
}
// Set PHP error handler to ours
-set_error_handler('msg_handler_qi');
+set_error_handler(array('qi', 'msg_handler'));
if (!defined('QI_INSTALLED'))
{
@@ -144,7 +90,7 @@ function deregister_globals()
if (!isset($available_dbms[$dbms]['DRIVER']))
{
- trigger_error('The ' . $dbms . ' dbms is either not supported, or the php extension for it could not be loaded.', E_USER_ERROR);
+ trigger_error("The $dbms dbms is either not supported, or the php extension for it could not be loaded.", E_USER_ERROR);
}
// Load the appropriate database class if not already loaded
@@ -164,7 +110,7 @@ function deregister_globals()
$auth = new auth();
$cache = new cache();
$template = new template();
-$module = new module_handler($quickinstall_path . 'modules/');
+$module = new module_handler($quickinstall_path . 'modules/', 'qi_');
// Set some standard variables we want to force
$config = array(
@@ -182,6 +128,6 @@ function deregister_globals()
qi::add_lang(array('qi', 'phpbb'));
// Load the main module
-$module->load('qi_' . request_var('mode', 'main'), 'qi_main');
+$module->load(request_var('mode', 'main'), 'qi_main');
?>
4 language/en/install.php
View
@@ -5,8 +5,8 @@
*
* @package quickinstall
* @version $Id$
-* @copyright (c) 2007 eviL3
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @copyright (c) 2007, 2008 eviL3
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
6 language/en/phpbb.php
View
@@ -5,8 +5,8 @@
*
* @package quickinstall
* @version $Id$
-* @copyright (c) 2007 eviL3
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @copyright (c) 2007, 2008 eviL3
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
@@ -31,7 +31,7 @@
'DIRECTION' => 'ltr',
'DATE_FORMAT' => '|d M Y|', // 01 Jan 2007
'USER_LANG' => 'en-gb',
-
+
'datetime' => array(
'TODAY' => 'Today',
'TOMORROW' => 'Tomorrow',
43 language/en/qi.php
View
@@ -5,8 +5,8 @@
*
* @package quickinstall
* @version $Id$
-* @copyright (c) 2007 eviL3
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @copyright (c) 2007, 2008 eviL3
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
@@ -46,45 +46,47 @@
'ABOUT_QUICKINSTALL' => 'About phpBB3 QuickInstall',
'ADMIN_NAME' => 'Administrator username',
'ADMIN_PASS' => 'Administrator password',
-
+
'BACK_TO_MAIN' => '<a href="%s">Return back to the main page</a>',
'BACK_TO_MANAGE' => '<a href="%s">Return back to the management page</a>',
+ 'BLINKY' => 'Blinky',
'BOARD_CREATED' => 'Board created successfully!',
'BOARD_DBNAME' => 'Board database name',
'BOARD_DESC' => 'Board description',
'BOARD_NAME' => 'Board name',
'BOARDS_DELETED' => 'The boards were deleted successfully.',
'BOARDS_DELETED_TITLE' => 'Boards deleted',
-
+
'CHANGELOG' => 'Changelog',
-
+
'DB_PREFIX' => 'Database table prefix',
'DELETE' => 'Delete',
'DELETE_FILES_IF_EXIST' => 'Delete files if they exist',
'DIR_EXISTS' => 'The directory %s already exists.',
'DROP_DB_IF_EXISTS' => 'Drop database if it exists',
-
+
'ENABLED' => 'Enabled',
-
+
'GENERAL_ERROR' => 'General Error',
-
+
'INCLUDE_MODS' => 'Include MODs',
'INCLUDE_MODS_EXPLAIN' => 'Select folders from the sources/mods/ folder in this list, those files will then be copied to your new board’s root dir, also overwriting old files (so you can have premodded boards in here for example). If you select “None”, it will not be used (because it’s a pain to deselect items).',
'INSTALL_BOARD' => 'Install a board',
-
+
'LICENSE' => 'License?',
- 'LICENSE_EXPLAIN' => 'This script is released under the terms of the <a href="gpl.txt">GNU General Public License version 2</a>. This is mainly because it uses large portions of phpBB’s code, which is also released under this license, and requires any modifications to use it too. But also because it’s a great license that keeps free software free :).',
-
+ 'LICENSE_EXPLAIN' => 'This script is released under the terms of the <a href="license.txt">GNU General Public License version 2</a>. This is mainly because it uses large portions of phpBB’s code, which is also released under this license, and requires any modifications to use it too. But also because it’s a great license that keeps free software free :).',
+
'MANAGE_BOARDS' => 'Manage boards',
'MIGHT_TAKE_LONG' => '<strong>Please note:</strong> Creation of the board can take a while, perhaps even a minute or longer, so don’t submit the form twice.',
-
+
'NO_BOARDS' => 'You have no boards.',
'NO_DB' => 'No database selected.',
+ 'NO_MODULE' => 'The module %s could not be loaded.',
'NONE' => 'None',
-
+
'OPTIONS' => 'Options',
'OPTIONS_ADVANCED' => 'Advanced options',
-
+
'QI_ABOUT' => 'About',
'QI_ABOUT_ABOUT' => 'Big brother loves you and wants you to be happy.',
'QI_MAIN' => 'Main page',
@@ -92,33 +94,34 @@
'QI_MANAGE' => 'Manage boards',
'QI_MANAGE_ABOUT' => 'o_O',
'QUICKINSTALL' => 'phpBB QuickInstall',
-
+
'REDIRECT' => 'Redirect',
-
+
'SELECT' => 'Select',
'STAR_MANDATORY' => '* = mandatory',
'SUBMIT' => 'Submit',
'SUCCESS' => 'Success',
-
+
'UP_TO_DATE' => 'Big brother says you are up to date.',
'UP_TO_DATE_NOT' => 'Big brother says you are not up to date.',
'UPDATE_CHECK_FAILED' => 'Big brother’s version check failed.',
'UPDATE_TO' => '<a href="%1$s">Update to version %2$s.</a>',
-
+
'VERSION_CHECK' => 'Big brother version check',
'VISIT_BOARD' => '<a href="%s">Visit the board</a>',
-
+
'WHAT' => 'What?',
'WHAT_EXPLAIN' => 'phpBB3 QuickInstall is a script to quickly install phpBB. Pretty obvious... ;-)',
'WHO_ELSE' => 'Who else?',
'WHO_ELSE_EXPLAIN' => '<ul><li>' . implode('</li><li>', array(
'Credits go to the phpBB team, especially the development team which created such a wonderful software.',
+ 'Thanks to the phpBB.com MOD team (especially josh) for blinky, which is included in this package.',
'Thanks to Mike TUMS for the nice logo!',
'Thanks to the beta testers!',
'Thanks to the phpBB community including phpBB.com, startrekguide.com and phpBBModders.net!',
)) . '</li></ul>',
'WHO_WHEN' => 'Who? When?',
- 'WHO_WHEN_EXPLAIN' => 'phpBB3 QuickInstall was created by Igor &quot;eviL&lt;3&quot; Wiedler in the summer of 2007.',
+ 'WHO_WHEN_EXPLAIN' => 'phpBB3 QuickInstall was created by Igor &quot;eviL&lt;3&quot; Wiedler in the summer of 2007. It was partially rewritten in march 2008.',
'WHY' => 'Why?',
'WHY_EXPLAIN' => 'Just as with phpBB2, if you do a lot of modding (creating modifications), you cannot put all MODs into a single phpBB installation. So it’s best to have separate installations. Now the problem is that it’s a pain to copy the files and go through the installation process every time. To speed up this process, quickinstall was born.',
));
0  gpl.txt → license.txt
View
File renamed without changes
50 modules/qi_about.php
View
@@ -1,10 +1,10 @@
<?php
-/**
+/**
*
* @package quickinstall
* @version $Id$
-* @copyright (c) 2007 eviL3
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @copyright (c) 2007, 2008 eviL3
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
@@ -21,53 +21,53 @@
*/
class qi_about
{
- function qi_about()
+ public function __construct()
{
global $db, $template, $user;
global $quickinstall_path, $phpbb_root_path, $phpEx, $config, $qi_config;
-
+
if ($qi_config['version_check'])
{
// we use this for get_remote_file()
include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
-
+
// Get current and latest version
$errstr = '';
$errno = 0;
-
+
$info = get_remote_file('phpbbmodders.net', '/mods/phpbb_quickinstall_3.0.x', 'updatecheck.txt', $errstr, $errno);
-
+
if ($info !== false)
{
list($latest_version, $announcement_url) = explode("\n", $info);
$up_to_date = (version_compare(str_replace('rc', 'RC', strtolower($qi_config['qi_version'])), str_replace('rc', 'RC', strtolower($latest_version)), '<')) ? false : true;
-
+
$template->assign_vars(array(
'UP_TO_DATE' => $up_to_date,
'L_UPDATE' => sprintf($user->lang['UPDATE_TO'], $announcement_url, $latest_version),
));
}
}
-
+
$changelog_file = $quickinstall_path . 'changelog.xml';
if ($use_changelog = file_exists($changelog_file))
{
// let's get the changelog :)
- include($quickinstall_path . 'includes/functions_xml.' . $phpEx);
-
- $xml_parser = new simple_parser();
- $xml_parser->parse(file_get_contents($changelog_file));
-
- foreach ($xml_parser->data['history'][0]['child']['entry'] as &$entry)
+ include($quickinstall_path . 'sources/blinky/includes/mod_parser.' . $phpEx);
+
+ $xml_parser = new xml_array();
+ $data = $xml_parser->parse(file_get_contents($changelog_file));
+
+ foreach ($data[0]['children']['ENTRY'] as &$entry)
{
- list($year, $month, $day) = explode('-', $entry['child']['date'][0]['data']);
-
+ list($year, $month, $day) = explode('-', $entry['children']['DATE'][0]['data']);
+
$template->assign_block_vars('history', array(
'DATE' => qi::format_date(mktime(null, null, null, intval($month), intval($day), intval($year)), 'Y-m-d'),
- 'VERSION' => $entry['child']['version'][0]['data'],
+ 'VERSION' => $entry['children']['VERSION'][0]['data'],
));
-
- foreach ($entry['child']['changelog'][0]['child']['change'] as &$change)
+
+ foreach ($entry['children']['CHANGELOG'][0]['children']['CHANGE'] as &$change)
{
$template->assign_block_vars('history.changelog', array(
'CHANGE' => htmlspecialchars($change['data']),
@@ -75,19 +75,19 @@ function qi_about()
}
}
}
-
+
$template->assign_vars(array(
'S_ALLOW_VERSION_CHECK' => $qi_config['version_check'],
'S_ALLOW_CHANGELOG' => $use_changelog,
));
-
+
// Output page
qi::page_header($user->lang['QI_ABOUT'], $user->lang['QI_ABOUT_ABOUT']);
-
+
$template->set_filenames(array(
'body' => 'about_body.html')
);
-
+
qi::page_footer();
}
}
829 modules/qi_create.php
View
@@ -3,7 +3,7 @@
*
* @package quickinstall
* @version $Id$
-* @copyright (c) 2007 eviL3
+* @copyright (c) 2007, 2008 eviL3
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
@@ -21,10 +21,13 @@
*/
class qi_create
{
- function qi_create()
+ public function __construct()
{
- global $db, $user, $auth;
- global $quickinstall_path, $phpbb_root_path, $phpEx, $config, $qi_config, $available_dbms, $msg_title;
+ global $db, $user, $auth, $cache;
+ global $quickinstall_path, $phpbb_root_path, $phpEx, $config, $qi_config, $msg_title;
+
+ // include installation functions
+ include($quickinstall_path . 'includes/functions_install.' . $phpEx);
$config = array_merge($config, array(
'rand_seed' => md5(mt_rand()),
@@ -32,14 +35,17 @@ function qi_create()
));
// load installer lang
- qi::add_lang('install');
+ qi::add_lang(array('install', 'phpbb'));
+
+ // phpbb's install uses $lang instead of $user->lang
+ $GLOBALS['lang'] = &$user->lang;
// request variables
$dbname = htmlspecialchars_decode(request_var('dbname', '', true));
$redirect = request_var('redirect', true);
$drop_db = request_var('drop_db', false);
$delete_files = request_var('delete_files', false);
- $include_mods = request_var('include_mods', array(0 => ''), true);
+ $blinky = request_var('blinky', false);
foreach (array('site_name', 'site_desc', 'table_prefix', 'admin_name', 'admin_pass') as $r)
{
if ($_r = request_var($r, '', true))
@@ -54,110 +60,98 @@ function qi_create()
'CONFIG_SITENAME' => $qi_config['site_name'],
));
- // if "none" is selected, reset
- if (in_array($user->lang['NONE'], $include_mods))
- {
- $include_mods = array();
- }
-
// smaller ^^
list($dbms, $table_prefix) = array(&$qi_config['dbms'], &$qi_config['table_prefix']);
- if (!$dbname)
- {
- trigger_error('NO_DB');
- }
- if ($drop_db)
- {
- $db->sql_query('DROP DATABASE IF EXISTS ' . $qi_config['database_prefix'] . $dbname);
- }
-
- if ($dbms == 'sqlite' || $dbms == 'firebird')
- {
- $db->sql_query('CREATE DATABASE ' . $quickinstall_path . 'cache/' . $qi_config['database_prefix'] . $dbname);
- $db->sql_select_db($quickinstall_path . 'cache/' . $qi_config['database_prefix'] . $dbname);
- }
- else
- {
- $db->sql_query('CREATE DATABASE ' . $qi_config['database_prefix'] . $dbname);
- $db->sql_select_db($qi_config['database_prefix'] . $dbname);
- }
+ // copy all of our files
+ $board_dir = $quickinstall_path . $qi_config['boards_dir'] . $dbname . '/';
- // If mysql is chosen, we need to adjust the schema filename slightly to reflect the correct version. ;)
- if ($dbms == 'mysql')
+ if (file_exists($board_dir))
{
- if (version_compare($db->mysql_version, '4.1.3', '>='))
+ if ($delete_files)
{
- $available_dbms[$dbms]['SCHEMA'] .= '_41';
+ file_functions::delete_dir($board_dir);
}
else
{
- $available_dbms[$dbms]['SCHEMA'] .= '_40';
+ trigger_error(sprintf($user->lang['DIR_EXISTS'], $board_dir));
}
}
- // Ok we have the db info go ahead and read in the relevant schema
- // and work on building the table
- $dbms_schema = $phpbb_root_path . 'install/schemas/' . $available_dbms[$dbms]['SCHEMA'] . '_schema.sql';
-
- // How should we treat this schema?
- $remove_remarks = $available_dbms[$dbms]['COMMENTS'];
- $delimiter = $available_dbms[$dbms]['DELIM'];
+ file_functions::copy_dir($quickinstall_path . 'sources/phpBB3/', $board_dir);
- $sql_query = @file_get_contents($dbms_schema);
+ // copy extra files
+ file_functions::copy_dir($quickinstall_path . 'sources/extra/', $board_dir);
- $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);
+ if ($dbms == 'sqlite' || $dbms == 'firebird')
+ {
+ $qi_config['dbhost'] = $qi_config['database_prefix'] . $dbname;
- $remove_remarks($sql_query);
+ // temp remove some
+ list($qi_config['database_prefix'], $dbname, $temp1, $temp2) = array('', '', &$qi_config['database_prefix'], &$dbname);
+ }
- $sql_query = split_sql_file($sql_query, $delimiter);
+ // Write to config.php ;)
+ $config_data = "<?php\n";
+ $config_data .= "// phpBB 3.0.x auto-generated configuration file\n// Do not change anything in this file!\n";
+ $config_data_array = array(
+ 'dbms' => $dbms,
+ 'dbhost' => $qi_config['dbhost'],
+ 'dbport' => $qi_config['dbport'],
+ 'dbname' => $qi_config['database_prefix'] . $dbname,
+ 'dbuser' => $qi_config['dbuser'],
+ 'dbpasswd' => htmlspecialchars_decode($qi_config['dbpasswd']),
+ 'table_prefix' => $table_prefix,
+ 'acm_type' => 'file',
+ 'load_extensions' => '',
+ );
- foreach ($sql_query as $sql)
+ foreach ($config_data_array as $key => $value)
{
- if (!$db->sql_query($sql))
- {
- $error = $db->sql_error();
- trigger_error($error['message']);
- }
+ $config_data .= "\${$key} = '" . str_replace("'", "\\'", str_replace('\\', '\\\\', $value)) . "';\n";
}
- unset($sql_query);
+ unset($config_data_array);
- // Ok tables have been built, let's fill in the basic information
- $sql_query = file_get_contents($phpbb_root_path . 'install/schemas/schema_data.sql');
+ $config_data .= "\n@define('PHPBB_INSTALLED', true);\n";
+ $config_data .= "@define('DEBUG', true);\n";
+ $config_data .= "@define('DEBUG_EXTRA', true);\n";
+ $config_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused!
+ file_put_contents($board_dir . 'config.' . $phpEx, $config_data);
- // Deal with any special comments
- switch ($dbms)
+ if ($dbms == 'sqlite' || $dbms == 'firebird')
{
- case 'mssql':
- case 'mssql_odbc':
- $sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2;', $sql_query);
- break;
-
- case 'postgres':
- $sql_query = preg_replace('#\# POSTGRES (BEGIN|COMMIT) \##s', '\1; ', $sql_query);
- break;
+ // and now restore
+ list($qi_config['database_prefix'], $dbname) = array(&$temp1, &$temp2);
}
- // Change prefix
- $sql_query = preg_replace('#phpbb_#i', $table_prefix, $sql_query);
+ // update phpbb_root_path
+ $phpbb_root_path = $board_dir;
- // Change language strings...
- $sql_query = preg_replace_callback('#\{L_([A-Z0-9\-_]*)\}#s', 'adjust_language_keys_callback_qi', $sql_query);
+ // start with db installation
+ if (!$dbname)
+ {
+ trigger_error('NO_DB');
+ }
- // 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, ';');
+ if ($drop_db)
+ {
+ $db->sql_query('DROP DATABASE IF EXISTS ' . $qi_config['database_prefix'] . $dbname);
+ }
- foreach ($sql_query as $sql)
+ if ($dbms == 'sqlite' || $dbms == 'firebird')
{
- if (!$db->sql_query($sql))
- {
- $error = $db->sql_error();
- trigger_error($error['message']);
- }
+ $db->sql_query('CREATE DATABASE ' . $quickinstall_path . 'cache/' . $qi_config['database_prefix'] . $dbname);
+ $db->sql_select_db($quickinstall_path . 'cache/' . $qi_config['database_prefix'] . $dbname);
+ }
+ else
+ {
+ $db->sql_query('CREATE DATABASE ' . $qi_config['database_prefix'] . $dbname);
+ $db->sql_select_db($qi_config['database_prefix'] . $dbname);
}
- unset($sql_query);
+
+ // perform sql
+ load_schema($phpbb_root_path . 'install/schemas/', $dbms);
$current_time = time();
$user_ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : '';
@@ -293,127 +287,69 @@ function qi_create()
}
$db->sql_freeresult($result);
+ // include install_install.php
+ define('IN_INSTALL', true);
+ include($phpbb_root_path . 'install/install_install.' . $phpEx);
+ include($quickinstall_path . 'includes/install_install_qi.' . $phpEx);
+
+ $install = new install_install_qi($p_master = new p_master_dummy());
+ $install->set_data(array(
+ 'dbms' => $dbms,
+ 'dbhost' => $qi_config['dbhost'],
+ 'dbport' => $qi_config['dbport'],
+ 'dbuser' => $qi_config['dbuser'],
+ 'dbpasswd' => $qi_config['dbpasswd'],
+ 'dbname' => $dbname,
+ 'table_prefix' => $table_prefix,
+ 'default_lang' => $qi_config['default_lang'],
+ 'admin_name' => $qi_config['admin_name'],
+ 'admin_pass1' => $qi_config['admin_pass'],
+ 'admin_pass2' => $qi_config['admin_pass'],
+ 'board_email1' => $qi_config['board_email'],
+ 'board_email2' => $qi_config['board_email'],
+ 'email_enable' => $qi_config['email_enable'],
+ 'smtp_delivery' => $qi_config['smtp_delivery'],
+ 'smtp_host' => $qi_config['smtp_host'],
+ 'smtp_auth' => $qi_config['smtp_auth'],
+ 'smtp_user' => $qi_config['smtp_user'],
+ 'smtp_pass' => $qi_config['smtp_pass'],
+ 'cookie_secure' => $qi_config['cookie_secure'],
+ 'server_protocol' => $qi_config['server_protocol'],
+ 'server_name' => $qi_config['server_name'],
+ 'server_port' => $qi_config['server_port'],
+ 'script_path' => $script_path,
+ ));
+ $install->add_modules(false, false);
+ $install->add_language(false, false);
+ $install->add_bots(false, false);
- $this->add_modules();
- $this->add_language();
-
- // add bots
- $sql = 'SELECT group_id
- FROM ' . GROUPS_TABLE . "
- WHERE group_name = 'BOTS'";
- $result = $db->sql_query($sql);
- $group_id = (int) $db->sql_fetchfield('group_id');
- $db->sql_freeresult($result);
-
- if (!$group_id)
- {
- // If we reach this point then something has gone very wrong
- trigger_error('NO_GROUP');
- }
-
- if (!function_exists('user_add'))
- {
- include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
- }
-
- foreach ($this->bot_list as $bot_name => $bot_ary)
+ // now blinky (easymod)
+ if ($blinky)
{
- $user_row = array(
- 'user_type' => USER_IGNORE,
- 'group_id' => $group_id,
- 'username' => $bot_name,
- 'user_regdate' => time(),
- 'user_password' => '',
- 'user_colour' => '9E8DA7',
- 'user_email' => '',
- 'user_lang' => $qi_config['default_lang'],
- 'user_style' => 1,
- 'user_timezone' => 0,
- 'user_dateformat' => $user->lang['default_dateformat'],
- 'user_allow_massemail' => 0,
- );
-
- $user_id = user_add($user_row);
-
- if (!$user_id)
- {
- // If we can't insert this user then continue to the next one to avoid inconsistant data
- trigger_error('Unable to insert bot into users table');
- continue;
- }
-
- $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
- 'bot_active' => 1,
- 'bot_name' => (string) $bot_name,
- 'user_id' => (int) $user_id,
- 'bot_agent' => (string) $bot_ary[0],
- 'bot_ip' => (string) $bot_ary[1],
+ // todo: add blinky code
+ file_functions::copy_dir($quickinstall_path . 'sources/blinky/', $board_dir);
+
+ require("{$phpbb_root_path}install/install_mod.$phpEx");
+ require("{$quickinstall_path}includes/install_mod_qi.$phpEx");
+ require("{$phpbb_root_path}includes/functions_convert.$phpEx");
+ require("{$phpbb_root_path}includes/functions_mods.$phpEx");
+ require("{$phpbb_root_path}includes/functions_transfer.$phpEx");
+
+ $user->lang['FILE_EDITS'] = '';
+
+ $install = new install_mod_qi($p_master = new p_master_dummy());
+ $install->set_data(array(
+ 'method' => '',
+ 'host' => '',
+ 'username' => '',
+ 'root_path' => '',
+ 'port' => 21,
+ 'timeout' => 10,
));
-
- $result = $db->sql_query($sql);
- }
-
- // SQL done, now get those files over ;)
- $board_dir = $quickinstall_path . $qi_config['boards_dir'] . $dbname . '/';
-
- if (file_exists($board_dir))
- {
- if ($delete_files)
- {
- file_functions::delete_dir($board_dir);
- }
- else
- {
- trigger_error(sprintf($user->lang['DIR_EXISTS'], $board_dir));
- }
- }
-
- file_functions::copy_dir($quickinstall_path . 'sources/phpBB3/', $board_dir);
-
- if ($dbms == 'sqlite' || $dbms == 'firebird')
- {
- $qi_config['dbhost'] = $qi_config['database_prefix'] . $dbname;
-
- // temp remove some
- list($qi_config['database_prefix'], $dbname, $temp1, $temp2) = array('', '', &$qi_config['database_prefix'], &$dbname);
- }
-
- // Write to config.php ;)
- $config_data = "<?php\n";
- $config_data .= "// phpBB3 quickinstall auto-generated configuration file\n// Do not change anything in this file!\n";
- $config_data .= "\$dbms = '" . $available_dbms[$dbms]['DRIVER'] . "';\n";
- $config_data .= "\$dbhost = '{$qi_config['dbhost']}';\n";
- $config_data .= "\$dbport = '{$qi_config['dbport']}';\n";
- $config_data .= "\$dbname = '{$qi_config['database_prefix']}$dbname';\n";
- $config_data .= "\$dbuser = '{$qi_config['dbuser']}';\n";
- $config_data .= "\$dbpasswd = '{$qi_config['dbpasswd']}';\n\n";
- $config_data .= "\$table_prefix = '$table_prefix';\n";
- $config_data .= "\$acm_type = 'file';\n";
- $config_data .= "@define('PHPBB_INSTALLED', true);\n";
- $config_data .= "@define('DEBUG', true);\n";
- $config_data .= "@define('DEBUG_EXTRA', true);\n";
- $config_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused!
- file_put_contents($board_dir . 'config.' . $phpEx, $config_data);
-
- if ($dbms == 'sqlite' || $dbms == 'firebird')
- {
- // and now restore
- list($qi_config['database_prefix'], $dbname) = array(&$temp1, &$temp2);
- }
-
- // clean up
- file_functions::delete_files($board_dir, array('Thumbs.db', 'DS_Store', 'CVS', '.svn'));
-
- // remove install dir
- file_functions::delete_dir($board_dir . 'install/');
-
- // now our custom mods
- if (sizeof($include_mods))
- {
- foreach ($include_mods as $mod)
- {
- file_functions::copy_dir($quickinstall_path . 'sources/mods/' . $mod . '/', $board_dir);
- }
+ $install->add_config(false, false);
+ $install->perform_edits(false, false);
+ load_schema($phpbb_root_path . 'install/schemas/mods_manager/', $dbms);
+ $install->add_modules(false, false);
}
// login
@@ -422,7 +358,7 @@ function qi_create()
// add log entry :D
$user->ip = &$user_ip;
- add_log('admin', 'LOG_INSTALL_INSTALLED', 'QuickInstall');
+ add_log('admin', 'LOG_INSTALL_INSTALLED_QI', $qi_config['qi_version']);
if ($dbms == 'sqlite' || $dbms == 'firebird')
{
@@ -431,20 +367,14 @@ function qi_create()
$db->sql_select_db($board_dir . $qi_config['database_prefix'] . $dbname);
}
- // don't forget our hooks
- if ($dh = opendir($quickinstall_path . 'includes/hooks/'))
- {
- while (false !== ($file = readdir($dh)))
- {
- if (!preg_match('#hook_(.*)\.' . preg_quote($phpEx, '#') . '#s', $file))
- {
- continue;
- }
+ // clean up
+ file_functions::delete_files($board_dir, array('Thumbs.db', 'DS_Store', 'CVS', '.svn'));
- @include($quickinstall_path . 'includes/hooks/' . $file);
- }
- closedir($dh);
- }
+ // remove install dir
+ file_functions::delete_dir($board_dir . 'install/');
+
+ // purge cache
+ $cache->purge();
// if he wants to be redirected, redirect him
if ($redirect)
@@ -456,481 +386,6 @@ function qi_create()
$msg_title = 'SUCCESS';
trigger_error($user->lang['BOARD_CREATED'] . '<br /><br />' . sprintf($user->lang['VISIT_BOARD'], $board_dir));
}
-
- /**
- * Populate the module tables (taken from install_install)
- */
- function add_modules()
- {
- global $db, $phpbb_root_path, $phpEx;
-
- include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx);
-
- $_module = &new acp_modules();
- $module_classes = array('acp', 'mcp', 'ucp');
-
- // Add categories
- foreach ($module_classes as $module_class)
- {
- $categories = array();
-
- // Set the module class
- $_module->module_class = $module_class;
-
- foreach ($this->module_categories[$module_class] as $cat_name => $subs)
- {
- $module_data = array(
- 'module_basename' => '',
- 'module_enabled' => 1,
- 'module_display' => 1,
- 'parent_id' => 0,
- 'module_class' => $module_class,
- 'module_langname' => $cat_name,
- 'module_mode' => '',
- 'module_auth' => '',
- );
-
- // Add category
- $_module->update_module_data($module_data, true);
-
- // Check for last sql error happened
- if ($db->sql