Updates to install system
This commit is contained in:
@@ -23,23 +23,29 @@ $user->session_begin();
|
|||||||
$auth->acl($user->data);
|
$auth->acl($user->data);
|
||||||
$user->setup('mods/portal_install');
|
$user->setup('mods/portal_install');
|
||||||
|
|
||||||
$version_array = array('0.1.0', 'p3p1.2.2', 'p3p1.2.1', 'p3p1.2.0', 'p3p1.1.0b');
|
$mode = request_var('mode', '');
|
||||||
|
|
||||||
$old_version = 0;
|
$page_title = 'Board3portal v' . $current_version;
|
||||||
$phpbb3portal = false;
|
|
||||||
$installed = $updated = $uninstalled =false;
|
|
||||||
|
|
||||||
$sql = 'SELECT config_value as version
|
if( $user->data['is_registered'] && $user->data['user_type'] == USER_FOUNDER )
|
||||||
|
{
|
||||||
|
$version_array = array('0.1.0', 'p3p1.2.2', 'p3p1.2.1', 'p3p1.2.0', 'p3p1.1.0b');
|
||||||
|
|
||||||
|
$old_version = 0;
|
||||||
|
$phpbb3portal = false;
|
||||||
|
$installed = $updated = $uninstalled =false;
|
||||||
|
|
||||||
|
$sql = 'SELECT config_value as version
|
||||||
FROM ' . PORTAL_CONFIG_TABLE . "
|
FROM ' . PORTAL_CONFIG_TABLE . "
|
||||||
WHERE config_name = 'portal_version'";
|
WHERE config_name = 'portal_version'";
|
||||||
$result = @$db->sql_query_limit( $sql, 1 );
|
$result = @$db->sql_query_limit( $sql, 1 );
|
||||||
if( $db->sql_affectedrows($result) > 0 )
|
if( $db->sql_affectedrows($result) > 0 )
|
||||||
{
|
{
|
||||||
$version = $db->sql_fetchrow( $result );
|
$version = $db->sql_fetchrow( $result );
|
||||||
$old_version = $version['version'];
|
$old_version = $version['version'];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$db->sql_freeresult( $result );
|
$db->sql_freeresult( $result );
|
||||||
$sql = 'SELECT config_value as version
|
$sql = 'SELECT config_value as version
|
||||||
FROM ' . CONFIG_TABLE . "
|
FROM ' . CONFIG_TABLE . "
|
||||||
@@ -51,29 +57,26 @@ else
|
|||||||
$phpbb3portal = true;
|
$phpbb3portal = true;
|
||||||
$old_version = ( strtolower($version['version']) == '1.1.0.b' ) ? '1.1.0b' : $version['version'] ;
|
$old_version = ( strtolower($version['version']) == '1.1.0.b' ) ? '1.1.0b' : $version['version'] ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->sql_freeresult( $result );
|
$db->sql_freeresult( $result );
|
||||||
|
|
||||||
$check_mode = 'none';
|
$check_mode = 'none';
|
||||||
|
|
||||||
if( $old_version == 0 )
|
if( $old_version == 0 )
|
||||||
{
|
{
|
||||||
$check_mode = 'install';
|
$check_mode = 'install';
|
||||||
}
|
}
|
||||||
elseif( $phpbb3portal === TRUE || version_compare( $old_version, $current_version, "<" ) === TRUE )
|
elseif( $phpbb3portal === TRUE || version_compare( $old_version, $current_version, "<" ) === TRUE )
|
||||||
{
|
{
|
||||||
$check_mode = 'update';
|
$check_mode = 'update';
|
||||||
}
|
}
|
||||||
|
|
||||||
$page_title = 'Board3portal v' . $current_version;
|
$confirm = request_var('confirm', 0);
|
||||||
|
|
||||||
$mode = request_var('mode', '');
|
$error_array = array();
|
||||||
$confirm = request_var('confirm', 0);
|
|
||||||
|
|
||||||
$error_array = array();
|
function split_sql_file($sql, $delimiter)
|
||||||
|
{
|
||||||
function split_sql_file($sql, $delimiter)
|
|
||||||
{
|
|
||||||
$sql = str_replace("\r" , '', $sql);
|
$sql = str_replace("\r" , '', $sql);
|
||||||
$data = preg_split('/' . preg_quote($delimiter, '/') . '$/m', $sql);
|
$data = preg_split('/' . preg_quote($delimiter, '/') . '$/m', $sql);
|
||||||
|
|
||||||
@@ -88,10 +91,10 @@ function split_sql_file($sql, $delimiter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function db_error( $error, $sql, $line, $file, $skip = false )
|
function db_error( $error, $sql, $line, $file, $skip = false )
|
||||||
{
|
{
|
||||||
global $error, $lang, $db;
|
global $error, $lang, $db;
|
||||||
|
|
||||||
if( $skip )
|
if( $skip )
|
||||||
@@ -109,10 +112,10 @@ function db_error( $error, $sql, $line, $file, $skip = false )
|
|||||||
include $phpbb_root_path . 'install_portal/style/layout_footer.php';
|
include $phpbb_root_path . 'install_portal/style/layout_footer.php';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_comments(&$output)
|
function remove_comments(&$output)
|
||||||
{
|
{
|
||||||
$lines = explode("\n", $output);
|
$lines = explode("\n", $output);
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
@@ -140,16 +143,16 @@ function remove_comments(&$output)
|
|||||||
|
|
||||||
unset($lines);
|
unset($lines);
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_remarks(&$sql)
|
function remove_remarks(&$sql)
|
||||||
{
|
{
|
||||||
$sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql));
|
$sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql));
|
||||||
}
|
}
|
||||||
|
|
||||||
// What sql_layer should we use?
|
// What sql_layer should we use?
|
||||||
switch ($db->sql_layer)
|
switch ($db->sql_layer)
|
||||||
{
|
{
|
||||||
case 'mysql':
|
case 'mysql':
|
||||||
$db_schema = 'mysql_40';
|
$db_schema = 'mysql_40';
|
||||||
$delimiter = ';';
|
$delimiter = ';';
|
||||||
@@ -208,14 +211,14 @@ switch ($db->sql_layer)
|
|||||||
default:
|
default:
|
||||||
trigger_error('Sorry, unsupported DBMS found.');
|
trigger_error('Sorry, unsupported DBMS found.');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get old version if it is installed.
|
// Get old version if it is installed.
|
||||||
|
|
||||||
switch ($mode)
|
switch ($mode)
|
||||||
{
|
{
|
||||||
// Installing from scratch
|
// Installing from scratch
|
||||||
case 'install':
|
case 'install':
|
||||||
if( $check_mode == 'install' )
|
if( $check_mode == 'install' )
|
||||||
{
|
{
|
||||||
if( $confirm == 1)
|
if( $confirm == 1)
|
||||||
@@ -471,9 +474,9 @@ case 'install':
|
|||||||
{
|
{
|
||||||
include($phpbb_root_path . 'install_portal/style/layout_menu.'.$phpEx);
|
include($phpbb_root_path . 'install_portal/style/layout_menu.'.$phpEx);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// Updating
|
// Updating
|
||||||
case 'update':
|
case 'update':
|
||||||
if( $check_mode == 'update' )
|
if( $check_mode == 'update' )
|
||||||
{
|
{
|
||||||
$confirm = request_var('confirm', '');
|
$confirm = request_var('confirm', '');
|
||||||
@@ -840,9 +843,9 @@ case 'update':
|
|||||||
include($phpbb_root_path . 'install_portal/style/layout_menu.'.$phpEx);
|
include($phpbb_root_path . 'install_portal/style/layout_menu.'.$phpEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
// Uninstalling
|
// Uninstalling
|
||||||
case 'uninstall':
|
case 'uninstall':
|
||||||
if( $old_version != 0 )
|
if( $old_version != 0 )
|
||||||
{
|
{
|
||||||
if( $confirm == 1)
|
if( $confirm == 1)
|
||||||
@@ -884,13 +887,69 @@ case 'uninstall':
|
|||||||
$db->sql_freeresult($result);
|
$db->sql_freeresult($result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sql = 'SELECT right_id, module_id FROM ' . MODULES_TABLE . "
|
||||||
|
WHERE module_langname = 'ACP_PORTAL_GENERAL_INFO'
|
||||||
|
OR module_langname = 'ACP_PORTAL_NEWS_INFO'
|
||||||
|
OR module_langname = 'ACP_PORTAL_ANNOUNCE_INFO'
|
||||||
|
OR module_langname = 'ACP_PORTAL_WELCOME_INFO'
|
||||||
|
OR module_langname = 'ACP_PORTAL_RECENT_INFO'
|
||||||
|
OR module_langname = 'ACP_PORTAL_WORDGRAPH_INFO'
|
||||||
|
OR module_langname = 'ACP_PORTAL_PAYPAL_INFO'
|
||||||
|
OR module_langname = 'ACP_PORTAL_ADS_INFO'
|
||||||
|
OR module_langname = 'ACP_PORTAL_ATTACHMENTS_NUMBER_INFO'
|
||||||
|
OR module_langname = 'ACP_PORTAL_MEMBERS_INFO'
|
||||||
|
OR module_langname = 'ACP_PORTAL_POLLS_INFO'
|
||||||
|
OR module_langname = 'ACP_PORTAL_BOTS_INFO'
|
||||||
|
OR module_langname = 'ACP_PORTAL_MOST_POSTER_INFO'
|
||||||
|
OR module_langname = 'ACP_PORTAL_MINICALENDAR_INFO'";
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$sql = 'DELETE FROM ' . MODULES_TABLE . " WHERE module_id = '{$row['module_id']}'";
|
||||||
|
$db->sql_query($sql);
|
||||||
|
$sql = 'UPDATE ' . MODULES_TABLE . "
|
||||||
|
SET left_id = left_id - 2
|
||||||
|
WHERE module_class = 'acp'
|
||||||
|
AND left_id > {$row['right_id']}";
|
||||||
|
$db->sql_query($sql);
|
||||||
|
|
||||||
|
$sql = 'UPDATE ' . MODULES_TABLE . "
|
||||||
|
SET right_id = right_id - 2
|
||||||
|
WHERE module_class = 'acp'
|
||||||
|
AND right_id > {$row['right_id']}";
|
||||||
|
$db->sql_query($sql);
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
|
$sql = 'SELECT right_id, module_id FROM ' . MODULES_TABLE . "
|
||||||
|
WHERE module_langname = 'ACP_PORTAL_INFO'";
|
||||||
|
$result = $db->sql_query($sql);
|
||||||
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
{
|
||||||
|
$sql = 'DELETE FROM ' . MODULES_TABLE . " WHERE module_id = '{$row['module_id']}'";
|
||||||
|
$db->sql_query($sql);
|
||||||
|
$sql = 'UPDATE ' . MODULES_TABLE . "
|
||||||
|
SET left_id = left_id - 2
|
||||||
|
WHERE module_class = 'acp'
|
||||||
|
AND left_id > {$row['right_id']}";
|
||||||
|
$db->sql_query($sql);
|
||||||
|
|
||||||
|
$sql = 'UPDATE ' . MODULES_TABLE . "
|
||||||
|
SET right_id = right_id - 2
|
||||||
|
WHERE module_class = 'acp'
|
||||||
|
AND right_id > {$row['right_id']}";
|
||||||
|
$db->sql_query($sql);
|
||||||
|
}
|
||||||
|
$db->sql_freeresult($result);
|
||||||
|
|
||||||
$installed = true;
|
$installed = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
include($phpbb_root_path . 'install_portal/style/layout_header.'.$phpEx);
|
include($phpbb_root_path . 'install_portal/style/layout_header.'.$phpEx);
|
||||||
echo '<h1>' . $user->lang['INSTALLER_ERROR'] . '</h1>';
|
echo '<h1>' . $user->lang['INSTALLER_ERROR'] . '</h1>';
|
||||||
echo '<h1>' . $user->lang['INSTALLER_UNINSTALL_OLDVERSION'] . '</h1>';
|
echo '<p>' . $user->lang['INSTALLER_UNINSTALL_OLDVERSION'] . '</p>';
|
||||||
include($phpbb_root_path . 'install_portal/style/layout_footer.'.$phpEx);
|
include($phpbb_root_path . 'install_portal/style/layout_footer.'.$phpEx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -899,13 +958,21 @@ case 'uninstall':
|
|||||||
include($phpbb_root_path . 'install_portal/style/layout_menu.'.$phpEx);
|
include($phpbb_root_path . 'install_portal/style/layout_menu.'.$phpEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
// Welcome page!
|
// Welcome page!
|
||||||
default:
|
default:
|
||||||
|
|
||||||
include($phpbb_root_path . 'install_portal/style/layout_menu.'.$phpEx);
|
include($phpbb_root_path . 'install_portal/style/layout_menu.'.$phpEx);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
include($phpbb_root_path . 'install_portal/style/layout_header.'.$phpEx);
|
||||||
|
echo '<h1>' . $user->lang['INSTALLER_ERROR'] . '</h1>';
|
||||||
|
echo '<p>' . $user->lang['INSTALLER_NEEDS_FOUNDER'] . '</p>';
|
||||||
|
include($phpbb_root_path . 'install_portal/style/layout_footer.'.$phpEx);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -29,6 +29,10 @@ if( !defined('IN_PHPBB') || !defined('IN_PORTAL_INSTALL') )
|
|||||||
<div class="panel">
|
<div class="panel">
|
||||||
<span class="corners-top"><span></span></span>
|
<span class="corners-top"><span></span></span>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
|
<?php
|
||||||
|
if( isset($mode) && isset($old_version) && isset($phpbb3portal) )
|
||||||
|
{
|
||||||
|
?>
|
||||||
<div id="menu">
|
<div id="menu">
|
||||||
<ul>
|
<ul>
|
||||||
<li class="header"><?php echo $user->lang['INSTALLER_MENU']; ?></li>
|
<li class="header"><?php echo $user->lang['INSTALLER_MENU']; ?></li>
|
||||||
@@ -43,5 +47,8 @@ if( $old_version != 0 && $phpbb3portal === false )
|
|||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<a name="maincontent"></a>
|
<a name="maincontent"></a>
|
||||||
Reference in New Issue
Block a user