2006-09-02 14:34:20 +00:00
< ? php
2007-10-04 11:33:33 +00:00
/**
2006-09-02 14:34:20 +00:00
*
2014-05-27 20:18:06 +02:00
* This file is part of the phpBB Forum Software package .
*
* @ copyright ( c ) phpBB Limited < https :// www . phpbb . com >
* @ license GNU General Public License , version 2 ( GPL - 2.0 )
*
* For full copyright and license information , please see
* the docs / CREDITS . txt file .
2006-09-02 14:34:20 +00:00
*
*/
/**
2014-05-27 20:18:06 +02:00
* @ todo check for writable cache / store / files directory
2006-09-02 14:34:20 +00:00
*/
2014-05-27 20:18:06 +02:00
2006-09-02 14:34:20 +00:00
if ( ! defined ( 'IN_INSTALL' ))
{
// Someone has tried to access the file directly. This is not a good idea, so exit
exit ;
}
if ( ! empty ( $setmodules ))
{
// If phpBB is not installed we do not include this module
2014-02-22 20:23:30 -08:00
if ( ! phpbb_check_installation_exists ( $phpbb_root_path , $phpEx ) || file_exists ( $phpbb_root_path . 'cache/install_lock' ))
2006-09-02 14:34:20 +00:00
{
return ;
}
$module [] = array (
'module_type' => 'update' ,
'module_title' => 'UPDATE' ,
'module_filename' => substr ( basename ( __FILE__ ), 0 , - strlen ( $phpEx ) - 1 ),
2006-09-08 18:00:38 +00:00
'module_order' => 30 ,
2006-09-02 14:34:20 +00:00
'module_subs' => '' ,
2013-07-29 21:30:01 +02:00
'module_stages' => array ( 'INTRO' , 'VERSION_CHECK' , 'FILE_CHECK' , 'UPDATE_FILES' , 'UPDATE_DB' ),
2006-09-02 14:34:20 +00:00
'module_reqs' => ''
);
}
/**
* Update Installation
*/
class install_update extends module
{
var $p_master ;
var $update_info ;
One commit for those fixes having a very tiny impact (mostly only whitespaces or forgotten spans, etc.)
Although i somehow mistakingly got #20445 and #15249 into it. :/
Removing s_watching_img from watch_topic_forum() function (Bug #20445)
Changing order for post review if more than one post affected (Bug #15249)
Language typos/fixes (Bug #20425, #15719, #15429, #14669, #13479)
Style/Template fixes (Bug #20065, #19405, #19205, #15028, #14934, #14821, #14752, #14497, #13707, #14738)
Tiny code fixes (Bug #20165, #20025, #19795, #14804)
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8350 89ea8834-ac86-4346-8a33-228a782c2dd0
2008-01-30 16:01:15 +00:00
2006-09-02 14:34:20 +00:00
var $old_location ;
var $new_location ;
var $latest_version ;
var $current_version ;
2009-05-19 11:19:06 +00:00
var $update_to_version ;
2006-11-26 12:22:56 +00:00
// Set to false
var $test_update = false ;
2006-09-02 14:34:20 +00:00
function install_update ( & $p_master )
{
$this -> p_master = & $p_master ;
}
function main ( $mode , $sub )
{
2013-07-24 12:24:35 -05:00
global $template , $phpEx , $phpbb_root_path , $user , $db , $config , $cache , $auth , $language ;
2013-04-24 11:26:13 -05:00
global $request , $phpbb_admin_path , $phpbb_adm_relative_path , $phpbb_container ;
2013-07-29 21:30:01 +02:00
// We must enable super globals, otherwise creating a new instance of the request class,
// using the new container with a dbal connection will fail with the following PHP Notice:
// Object of class phpbb_request_deactivated_super_global could not be converted to int
$request -> enable_super_globals ();
2013-04-24 11:26:13 -05:00
// Create a normal container now
2014-03-29 23:02:00 +01:00
if ( file_exists ( $phpbb_root_path . 'install/update/new/config' ))
{
$phpbb_container = phpbb_create_update_container ( $phpbb_root_path , $phpEx , $phpbb_root_path . 'install/update/new/config' );
}
else
{
$phpbb_container = phpbb_create_update_container ( $phpbb_root_path , $phpEx , $phpbb_root_path . 'config' );
}
2013-04-24 11:26:13 -05:00
// Writes into global $cache
$cache = $phpbb_container -> get ( 'cache' );
2006-09-02 14:34:20 +00:00
$this -> tpl_name = 'install_update' ;
2006-12-02 13:19:40 +00:00
$this -> page_title = 'UPDATE_INSTALLATION' ;
2006-09-02 14:34:20 +00:00
$this -> old_location = $phpbb_root_path . 'install/update/old/' ;
$this -> new_location = $phpbb_root_path . 'install/update/new/' ;
// Init DB
require ( $phpbb_root_path . 'config.' . $phpEx );
require ( $phpbb_root_path . 'includes/constants.' . $phpEx );
2007-07-09 11:33:14 +00:00
// Special options for conflicts/modified files
2006-12-06 15:47:50 +00:00
define ( 'MERGE_NO_MERGE_NEW' , 1 );
define ( 'MERGE_NO_MERGE_MOD' , 2 );
define ( 'MERGE_NEW_FILE' , 3 );
define ( 'MERGE_MOD_FILE' , 4 );
2012-11-17 00:24:32 +01:00
$dbms = phpbb_convert_30_dbms_to_31 ( $dbms );
2012-07-21 17:43:43 +02:00
$db = new $dbms ();
2006-09-02 14:34:20 +00:00
// Connect to DB
2007-02-19 04:15:35 +00:00
$db -> sql_connect ( $dbhost , $dbuser , $dbpasswd , $dbname , $dbport , false , false );
2006-09-02 14:34:20 +00:00
// We do not need this any longer, unset for safety purposes
unset ( $dbpasswd );
2011-01-10 02:27:18 +01:00
// We need to fill the config to let internal functions correctly work
2013-09-10 14:01:09 +02:00
$config = new \phpbb\config\db ( $db , new \phpbb\cache\driver\null , CONFIG_TABLE );
2011-01-11 23:25:51 +01:00
set_config ( null , null , null , $config );
set_config_count ( null , null , null , $config );
2006-09-02 14:34:20 +00:00
2007-06-09 11:11:20 +00:00
// Force template recompile
$config [ 'load_tplcompile' ] = 1 ;
2006-09-02 14:34:20 +00:00
// First of all, init the user session
$user -> session_begin ();
$auth -> acl ( $user -> data );
2007-01-28 15:37:11 +00:00
2010-04-12 20:53:57 +02:00
// Overwrite user's language with the selected one.
// Config needs to be changed to ensure that guests also get the selected language.
$config_default_lang = $config [ 'default_lang' ];
$config [ 'default_lang' ] = $language ;
$user -> data [ 'user_lang' ] = $language ;
2013-07-13 16:47:15 -04:00
$user -> add_lang ( array ( 'common' , 'acp/common' , 'acp/board' , 'install' , 'posting' ));
2010-04-12 20:53:57 +02:00
// Reset the default_lang
$config [ 'default_lang' ] = $config_default_lang ;
unset ( $config_default_lang );
2006-09-02 14:34:20 +00:00
// If we are within the intro page we need to make sure we get up-to-date version info
if ( $sub == 'intro' )
{
$cache -> destroy ( '_version_info' );
}
// Set custom template again. ;)
2013-07-29 21:30:01 +02:00
$paths = array ( $phpbb_root_path . 'install/update/new/adm/style' , $phpbb_admin_path . 'style' );
$paths = array_filter ( $paths , 'is_dir' );
2014-05-14 02:16:32 +02:00
$template -> set_custom_style ( array (
array (
'name' => 'adm' ,
'ext_path' => 'adm/style/' ,
2014-05-26 23:44:30 +02:00
),
2014-05-14 02:16:32 +02:00
), $paths );
2006-09-02 14:34:20 +00:00
2010-04-12 20:53:57 +02:00
$template -> assign_vars ( array (
'S_USER_LANG' => $user -> lang [ 'USER_LANG' ],
'S_CONTENT_DIRECTION' => $user -> lang [ 'DIRECTION' ],
'S_CONTENT_ENCODING' => 'UTF-8' ,
'S_CONTENT_FLOW_BEGIN' => ( $user -> lang [ 'DIRECTION' ] == 'ltr' ) ? 'left' : 'right' ,
'S_CONTENT_FLOW_END' => ( $user -> lang [ 'DIRECTION' ] == 'ltr' ) ? 'right' : 'left' ,
));
2006-09-02 14:34:20 +00:00
// Get current and latest version
2014-02-19 16:11:40 -06:00
$version_helper = $phpbb_container -> get ( 'version_helper' );
try
2006-09-02 14:34:20 +00:00
{
2014-02-19 16:11:40 -06:00
$this -> latest_version = $version_helper -> get_latest_on_current_branch ( true );
2006-09-02 14:34:20 +00:00
}
2014-02-19 16:11:40 -06:00
catch ( \RuntimeException $e )
2006-09-02 14:34:20 +00:00
{
2014-02-19 16:11:40 -06:00
$this -> latest_version = false ;
$update_info = array ();
include ( $phpbb_root_path . 'install/update/index.' . $phpEx );
$info = ( empty ( $update_info ) || ! is_array ( $update_info )) ? false : $update_info ;
if ( $info !== false )
{
$this -> latest_version = ( ! empty ( $info [ 'version' ][ 'to' ])) ? trim ( $info [ 'version' ][ 'to' ]) : false ;
}
2006-09-02 14:34:20 +00:00
}
2006-12-10 14:33:21 +00:00
// For the current version we trick a bit. ;)
$this -> current_version = ( ! empty ( $config [ 'version_update_from' ])) ? $config [ 'version_update_from' ] : $config [ 'version' ];
2007-05-17 22:21:29 +00:00
$up_to_date = ( version_compare ( str_replace ( 'rc' , 'RC' , strtolower ( $this -> current_version )), str_replace ( 'rc' , 'RC' , strtolower ( $this -> latest_version )), '<' )) ? false : true ;
2006-09-02 14:34:20 +00:00
// Check for a valid update directory, else point the user to the phpbb.com website
if ( ! file_exists ( $phpbb_root_path . 'install/update' ) || ! file_exists ( $phpbb_root_path . 'install/update/index.' . $phpEx ) || ! file_exists ( $this -> old_location ) || ! file_exists ( $this -> new_location ))
{
$template -> assign_vars ( array (
'S_ERROR' => true ,
'ERROR_MSG' => ( $up_to_date ) ? $user -> lang [ 'NO_UPDATE_FILES_UP_TO_DATE' ] : sprintf ( $user -> lang [ 'NO_UPDATE_FILES_OUTDATED' ], $config [ 'version' ], $this -> current_version , $this -> latest_version ))
);
return ;
}
$this -> update_info = $this -> get_file ( 'update_info' );
// Make sure the update directory holds the correct information
// Since admins are able to run the update/checks more than once we only check if the current version is lower or equal than the version to which we update to.
2007-05-17 16:33:52 +00:00
if ( version_compare ( str_replace ( 'rc' , 'RC' , strtolower ( $this -> current_version )), str_replace ( 'rc' , 'RC' , strtolower ( $this -> update_info [ 'version' ][ 'to' ])), '>' ))
2006-09-02 14:34:20 +00:00
{
$template -> assign_vars ( array (
'S_ERROR' => true ,
'ERROR_MSG' => sprintf ( $user -> lang [ 'INCOMPATIBLE_UPDATE_FILES' ], $config [ 'version' ], $this -> update_info [ 'version' ][ 'from' ], $this -> update_info [ 'version' ][ 'to' ]))
);
return ;
}
2010-07-06 12:03:02 +02:00
// Check if the update files are actually meant to update from the current version
2010-11-10 18:26:02 +01:00
if ( $this -> current_version != $this -> update_info [ 'version' ][ 'from' ])
2010-07-06 12:03:02 +02:00
{
$template -> assign_vars ( array (
'S_ERROR' => true ,
2010-11-10 18:26:02 +01:00
'ERROR_MSG' => sprintf ( $user -> lang [ 'INCOMPATIBLE_UPDATE_FILES' ], $this -> current_version , $this -> update_info [ 'version' ][ 'from' ], $this -> update_info [ 'version' ][ 'to' ]),
2010-07-06 12:03:02 +02:00
));
}
2006-09-02 14:34:20 +00:00
// Check if the update files stored are for the latest version...
2013-07-27 22:37:44 +02:00
if ( version_compare ( strtolower ( $this -> latest_version ), strtolower ( $this -> update_info [ 'version' ][ 'to' ]), '>' ))
2006-09-02 14:34:20 +00:00
{
$template -> assign_vars ( array (
2007-07-12 13:02:29 +00:00
'S_WARNING' => true ,
'WARNING_MSG' => sprintf ( $user -> lang [ 'OLD_UPDATE_FILES' ], $this -> update_info [ 'version' ][ 'from' ], $this -> update_info [ 'version' ][ 'to' ], $this -> latest_version ))
2006-09-02 14:34:20 +00:00
);
}
2009-05-19 11:19:06 +00:00
// We store the "update to" version, because it is not always the latest. ;)
$this -> update_to_version = $this -> update_info [ 'version' ][ 'to' ];
2009-02-28 19:22:27 +00:00
// Fill DB version
if ( empty ( $config [ 'dbms_version' ]))
{
set_config ( 'dbms_version' , $db -> sql_server_info ( true ));
}
2006-12-10 14:33:21 +00:00
if ( $this -> test_update === false )
2006-11-26 12:22:56 +00:00
{
2006-12-10 14:33:21 +00:00
// What about the language file? Got it updated?
2013-07-25 12:29:25 +02:00
if ( in_array ( 'language/' . $language . '/install.' . $phpEx , $this -> update_info [ 'files' ]))
2006-12-10 14:33:21 +00:00
{
2013-07-25 12:29:25 +02:00
$lang = array ();
include ( $this -> new_location . 'language/' . $language . '/install.' . $phpEx );
// this is the user's language.. just merge it
$user -> lang = array_merge ( $user -> lang , $lang );
2006-12-10 14:33:21 +00:00
}
2013-07-25 13:10:45 +02:00
if ( $language != 'en' && in_array ( 'language/en/install.' . $phpEx , $this -> update_info [ 'files' ]))
2006-12-10 14:33:21 +00:00
{
$lang = array ();
2009-08-07 12:50:25 +00:00
include ( $this -> new_location . 'language/en/install.' . $phpEx );
2007-03-13 22:00:55 +00:00
// only add new keys to user's language in english
$new_keys = array_diff ( array_keys ( $lang ), array_keys ( $user -> lang ));
foreach ( $new_keys as $i => $new_key )
{
$user -> lang [ $new_key ] = $lang [ $new_key ];
}
2006-12-10 14:33:21 +00:00
}
2006-11-26 12:22:56 +00:00
}
2006-12-06 15:47:50 +00:00
// Include renderer and engine
$this -> include_file ( 'includes/diff/diff.' . $phpEx );
$this -> include_file ( 'includes/diff/engine.' . $phpEx );
$this -> include_file ( 'includes/diff/renderer.' . $phpEx );
2006-09-02 14:34:20 +00:00
// Make sure we stay at the file check if checking the files again
2013-09-10 14:01:09 +02:00
if ( $request -> variable ( 'check_again' , false , false , \phpbb\request\request_interface :: POST ))
2006-09-02 14:34:20 +00:00
{
$sub = $this -> p_master -> sub = 'file_check' ;
}
switch ( $sub )
{
case 'intro' :
$this -> page_title = 'UPDATE_INSTALLATION' ;
$template -> assign_vars ( array (
'S_INTRO' => true ,
2010-04-12 20:53:57 +02:00
'U_ACTION' => append_sid ( $this -> p_master -> module_url , " language= $language &mode= $mode &sub=version_check " ),
2006-09-02 14:34:20 +00:00
));
// Make sure the update list is destroyed.
$cache -> destroy ( '_update_list' );
2007-10-06 11:45:30 +00:00
$cache -> destroy ( '_diff_files' );
2010-02-23 23:35:48 +00:00
$cache -> destroy ( '_expected_files' );
2006-09-02 14:34:20 +00:00
break ;
case 'version_check' :
$this -> page_title = 'STAGE_VERSION_CHECK' ;
$template -> assign_vars ( array (
'S_VERSION_CHECK' => true ,
2006-12-10 14:33:21 +00:00
2013-07-29 21:30:01 +02:00
'U_ACTION' => append_sid ( $this -> p_master -> module_url , " language= $language &mode= $mode &sub=file_check " ),
2006-09-02 14:34:20 +00:00
2013-07-29 21:30:01 +02:00
'S_UP_TO_DATE' => $up_to_date ,
2006-09-02 14:34:20 +00:00
'LATEST_VERSION' => $this -> latest_version ,
2013-07-29 21:30:01 +02:00
'CURRENT_VERSION' => $this -> current_version ,
));
2006-09-02 14:34:20 +00:00
2007-07-12 13:02:29 +00:00
// Print out version the update package updates to
2013-07-28 02:35:01 +02:00
if ( $this -> latest_version != $this -> update_info [ 'version' ][ 'to' ])
2007-07-12 13:02:29 +00:00
{
$template -> assign_var ( 'PACKAGE_VERSION' , $this -> update_info [ 'version' ][ 'to' ]);
}
2009-10-09 11:59:54 +00:00
// Since some people try to update to RC releases, but phpBB.com tells them the last version is the version they currently run
// we are faced with the updater thinking the database schema is up-to-date; which it is, but should be updated none-the-less
// We now try to cope with this by triggering the update process
if ( version_compare ( str_replace ( 'rc' , 'RC' , strtolower ( $this -> current_version )), str_replace ( 'rc' , 'RC' , strtolower ( $this -> update_info [ 'version' ][ 'to' ])), '<' ))
{
$template -> assign_vars ( array (
'S_UP_TO_DATE' => false ,
));
}
2006-09-02 14:34:20 +00:00
break ;
2006-12-10 14:33:21 +00:00
case 'update_db' :
// Redirect the user to the database update script with some explanations...
$template -> assign_vars ( array (
'S_DB_UPDATE' => true ,
2007-07-12 13:02:29 +00:00
'S_DB_UPDATE_FINISHED' => ( $config [ 'version' ] == $this -> update_info [ 'version' ][ 'to' ]) ? true : false ,
2007-06-17 08:24:10 +00:00
'U_DB_UPDATE' => append_sid ( $phpbb_root_path . 'install/database_update.' . $phpEx , 'type=1&language=' . $user -> data [ 'user_lang' ]),
2010-04-12 20:53:57 +02:00
'U_DB_UPDATE_ACTION' => append_sid ( $this -> p_master -> module_url , " language= $language &mode= $mode &sub=update_db " ),
'U_ACTION' => append_sid ( $this -> p_master -> module_url , " language= $language &mode= $mode &sub=file_check " ),
2013-07-29 21:30:01 +02:00
'L_EVERYTHING_UP_TO_DATE' => $user -> lang ( 'EVERYTHING_UP_TO_DATE' , append_sid ( " { $phpbb_root_path } ucp. $phpEx " , 'mode=login' ), append_sid ( " { $phpbb_root_path } ucp. $phpEx " , 'mode=login&redirect=' . $phpbb_adm_relative_path . 'index.php%3Fi=send_statistics%26mode=send_statistics' )),
2006-12-10 14:33:21 +00:00
));
2013-07-30 01:18:32 +02:00
// Do not display incompatible package note after successful update
if ( $config [ 'version' ] == $this -> update_info [ 'version' ][ 'to' ])
{
$template -> assign_var ( 'S_ERROR' , false );
}
2006-12-10 14:33:21 +00:00
break ;
2006-09-02 14:34:20 +00:00
case 'file_check' :
2010-02-23 23:35:48 +00:00
// retrieve info on what changes should have already been made to the files.
$expected_files = $cache -> get ( '_expected_files' );
if ( ! $expected_files )
{
$expected_files = array ();
}
// Now make sure the previous file collection is no longer valid...
2007-10-06 11:45:30 +00:00
$cache -> destroy ( '_diff_files' );
2006-09-02 14:34:20 +00:00
$this -> page_title = 'STAGE_FILE_CHECK' ;
// Now make sure our update list is correct if the admin refreshes
$action = request_var ( 'action' , '' );
// We are directly within an update. To make sure our update list is correct we check its status.
2013-09-10 14:01:09 +02:00
$update_list = ( $request -> variable ( 'check_again' , false , false , \phpbb\request\request_interface :: POST )) ? false : $cache -> get ( '_update_list' );
2012-07-30 18:44:40 -05:00
$modified = ( $update_list !== false ) ? @ filemtime ( $cache -> get_driver () -> cache_dir . 'data_update_list.' . $phpEx ) : 0 ;
2006-09-02 14:34:20 +00:00
// Make sure the list is up-to-date
if ( $update_list !== false )
{
$get_new_list = false ;
foreach ( $this -> update_info [ 'files' ] as $file )
{
if ( file_exists ( $phpbb_root_path . $file ) && filemtime ( $phpbb_root_path . $file ) > $modified )
{
$get_new_list = true ;
break ;
}
}
}
else
{
$get_new_list = true ;
}
2007-10-14 21:26:07 +00:00
if ( ! $get_new_list && $update_list [ 'status' ] != - 1 )
2007-10-06 11:45:30 +00:00
{
$get_new_list = true ;
}
2006-09-02 14:34:20 +00:00
if ( $get_new_list )
{
2010-02-23 23:35:48 +00:00
$this -> get_update_structure ( $update_list , $expected_files );
2006-09-02 14:34:20 +00:00
$cache -> put ( '_update_list' , $update_list );
2007-10-06 11:45:30 +00:00
// Refresh the page if we are still not finished...
2007-10-14 21:26:07 +00:00
if ( $update_list [ 'status' ] != - 1 )
2007-10-06 11:45:30 +00:00
{
2010-04-12 20:53:57 +02:00
$refresh_url = append_sid ( $this -> p_master -> module_url , " language= $language &mode= $mode &sub=file_check " );
2007-10-06 11:45:30 +00:00
meta_refresh ( 2 , $refresh_url );
$template -> assign_vars ( array (
'S_IN_PROGRESS' => true ,
'S_COLLECTED' => ( int ) $update_list [ 'status' ],
'S_TO_COLLECT' => sizeof ( $this -> update_info [ 'files' ]),
'L_IN_PROGRESS' => $user -> lang [ 'COLLECTING_FILE_DIFFS' ],
'L_IN_PROGRESS_EXPLAIN' => sprintf ( $user -> lang [ 'NUMBER_OF_FILES_COLLECTED' ], ( int ) $update_list [ 'status' ], sizeof ( $this -> update_info [ 'files' ])),
));
return ;
}
2006-09-02 14:34:20 +00:00
}
if ( $action == 'diff' )
{
$this -> show_diff ( $update_list );
return ;
}
if ( sizeof ( $update_list [ 'no_update' ]))
{
$template -> assign_vars ( array (
'S_NO_UPDATE_FILES' => true ,
'NO_UPDATE_FILES' => implode ( ', ' , array_map ( 'htmlspecialchars' , $update_list [ 'no_update' ])))
);
}
2010-02-23 23:35:48 +00:00
$new_expected_files = array ();
2006-09-02 14:34:20 +00:00
// Now assign the list to the template
foreach ( $update_list as $status => $filelist )
{
2007-10-06 11:45:30 +00:00
if ( $status == 'no_update' || ! sizeof ( $filelist ) || $status == 'status' )
2006-09-02 14:34:20 +00:00
{
continue ;
}
2009-01-12 16:58:47 +00:00
/* $template -> assign_block_vars ( 'files' , array (
2006-09-02 14:34:20 +00:00
'S_STATUS' => true ,
'STATUS' => $status ,
'L_STATUS' => $user -> lang [ 'STATUS_' . strtoupper ( $status )],
'TITLE' => $user -> lang [ 'FILES_' . strtoupper ( $status )],
'EXPLAIN' => $user -> lang [ 'FILES_' . strtoupper ( $status ) . '_EXPLAIN' ],
)
2009-01-12 16:58:47 +00:00
); */
2006-09-02 14:34:20 +00:00
foreach ( $filelist as $file_struct )
{
2006-12-10 14:33:21 +00:00
$s_binary = ( ! empty ( $this -> update_info [ 'binary' ]) && in_array ( $file_struct [ 'filename' ], $this -> update_info [ 'binary' ])) ? true : false ;
2006-12-06 15:47:50 +00:00
$filename = htmlspecialchars ( $file_struct [ 'filename' ]);
if ( strrpos ( $filename , '/' ) !== false )
{
$dir_part = substr ( $filename , 0 , strrpos ( $filename , '/' ) + 1 );
$file_part = substr ( $filename , strrpos ( $filename , '/' ) + 1 );
}
else
{
$dir_part = '' ;
$file_part = $filename ;
}
2010-04-12 20:53:57 +02:00
$diff_url = append_sid ( $this -> p_master -> module_url , " language= $language &mode= $mode &sub=file_check&action=diff&status= $status &file= " . urlencode ( $file_struct [ 'filename' ]));
2006-12-06 15:47:50 +00:00
2010-02-23 23:35:48 +00:00
if ( isset ( $file_struct [ 'as_expected' ]) && $file_struct [ 'as_expected' ])
{
$new_expected_files [ $file_struct [ 'filename' ]] = $expected_files [ $file_struct [ 'filename' ]];
}
else
{
$template -> assign_block_vars ( $status , array (
'STATUS' => $status ,
2006-09-02 14:34:20 +00:00
2010-02-23 23:35:48 +00:00
'FILENAME' => $filename ,
'DIR_PART' => $dir_part ,
'FILE_PART' => $file_part ,
'NUM_CONFLICTS' => ( isset ( $file_struct [ 'conflicts' ])) ? $file_struct [ 'conflicts' ] : 0 ,
2006-09-02 14:34:20 +00:00
2010-02-23 23:35:48 +00:00
'S_CUSTOM' => ( $file_struct [ 'custom' ]) ? true : false ,
'S_BINARY' => $s_binary ,
'CUSTOM_ORIGINAL' => ( $file_struct [ 'custom' ]) ? $file_struct [ 'original' ] : '' ,
2006-09-02 14:34:20 +00:00
2010-02-23 23:35:48 +00:00
'U_SHOW_DIFF' => $diff_url ,
'L_SHOW_DIFF' => ( $status != 'up_to_date' ) ? $user -> lang [ 'SHOW_DIFF_' . strtoupper ( $status )] : '' ,
2006-12-06 15:47:50 +00:00
2010-02-23 23:35:48 +00:00
'U_VIEW_MOD_FILE' => $diff_url . '&op=' . MERGE_MOD_FILE ,
'U_VIEW_NEW_FILE' => $diff_url . '&op=' . MERGE_NEW_FILE ,
'U_VIEW_NO_MERGE_MOD' => $diff_url . '&op=' . MERGE_NO_MERGE_MOD ,
'U_VIEW_NO_MERGE_NEW' => $diff_url . '&op=' . MERGE_NO_MERGE_NEW ,
));
}
2006-09-02 14:34:20 +00:00
}
}
2010-02-23 23:35:48 +00:00
$cache -> put ( '_expected_files' , $new_expected_files );
2006-09-02 14:34:20 +00:00
$all_up_to_date = true ;
foreach ( $update_list as $status => $filelist )
{
2007-10-06 11:45:30 +00:00
if ( $status != 'up_to_date' && $status != 'custom' && $status != 'status' && sizeof ( $filelist ))
2006-09-02 14:34:20 +00:00
{
$all_up_to_date = false ;
break ;
}
}
$template -> assign_vars ( array (
'S_FILE_CHECK' => true ,
'S_ALL_UP_TO_DATE' => $all_up_to_date ,
'S_VERSION_UP_TO_DATE' => $up_to_date ,
2013-07-29 21:30:01 +02:00
'S_UP_TO_DATE' => $up_to_date ,
2010-04-12 20:53:57 +02:00
'U_ACTION' => append_sid ( $this -> p_master -> module_url , " language= $language &mode= $mode &sub=file_check " ),
'U_UPDATE_ACTION' => append_sid ( $this -> p_master -> module_url , " language= $language &mode= $mode &sub=update_files " ),
'U_DB_UPDATE_ACTION' => append_sid ( $this -> p_master -> module_url , " language= $language &mode= $mode &sub=update_db " ),
2006-09-02 14:34:20 +00:00
));
2013-07-29 21:30:01 +02:00
// Since some people try to update to RC releases, but phpBB.com tells them the last version is the version they currently run
// we are faced with the updater thinking the database schema is up-to-date; which it is, but should be updated none-the-less
// We now try to cope with this by triggering the update process
if ( version_compare ( str_replace ( 'rc' , 'RC' , strtolower ( $this -> current_version )), str_replace ( 'rc' , 'RC' , strtolower ( $this -> update_info [ 'version' ][ 'to' ])), '<' ))
{
$template -> assign_vars ( array (
'S_UP_TO_DATE' => false ,
));
}
2006-12-10 14:33:21 +00:00
if ( $all_up_to_date )
{
2013-07-06 19:26:37 +02:00
global $phpbb_container ;
2013-06-10 14:44:49 +02:00
$phpbb_log = $phpbb_container -> get ( 'log' );
2006-12-10 14:33:21 +00:00
// Add database update to log
2013-07-06 19:26:37 +02:00
$phpbb_log -> add ( 'admin' , $user -> data [ 'user_id' ], $user -> ip , 'LOG_UPDATE_PHPBB' , time (), array ( $this -> current_version , $this -> update_to_version ));
2006-12-10 14:33:21 +00:00
2007-03-08 16:42:56 +00:00
$db -> sql_return_on_error ( true );
$db -> sql_query ( 'DELETE FROM ' . CONFIG_TABLE . " WHERE config_name = 'version_update_from' " );
$db -> sql_return_on_error ( false );
2007-07-08 16:39:48 +00:00
$cache -> purge ();
2006-12-10 14:33:21 +00:00
}
2006-09-02 14:34:20 +00:00
break ;
case 'update_files' :
$this -> page_title = 'STAGE_UPDATE_FILES' ;
$s_hidden_fields = '' ;
2007-10-06 11:45:30 +00:00
$params = array ();
2007-07-09 11:33:14 +00:00
$conflicts = request_var ( 'conflict' , array ( '' => 0 ));
$modified = request_var ( 'modified' , array ( '' => 0 ));
foreach ( $conflicts as $filename => $merge_option )
2006-09-02 14:34:20 +00:00
{
$s_hidden_fields .= '<input type="hidden" name="conflict[' . htmlspecialchars ( $filename ) . ']" value="' . $merge_option . '" />' ;
2007-10-06 11:45:30 +00:00
$params [] = 'conflict[' . urlencode ( $filename ) . ']=' . urlencode ( $merge_option );
2006-09-02 14:34:20 +00:00
}
2007-07-09 11:33:14 +00:00
foreach ( $modified as $filename => $merge_option )
{
if ( ! $merge_option )
{
continue ;
}
$s_hidden_fields .= '<input type="hidden" name="modified[' . htmlspecialchars ( $filename ) . ']" value="' . $merge_option . '" />' ;
2007-10-06 11:45:30 +00:00
$params [] = 'modified[' . urlencode ( $filename ) . ']=' . urlencode ( $merge_option );
2007-07-09 11:33:14 +00:00
}
2006-09-02 14:34:20 +00:00
$no_update = request_var ( 'no_update' , array ( 0 => '' ));
foreach ( $no_update as $index => $filename )
{
$s_hidden_fields .= '<input type="hidden" name="no_update[]" value="' . htmlspecialchars ( $filename ) . '" />' ;
2007-10-06 11:45:30 +00:00
$params [] = 'no_update[]=' . urlencode ( $filename );
}
// Before the user is choosing his preferred method, let's create the content list...
$update_list = $cache -> get ( '_update_list' );
if ( $update_list === false )
{
trigger_error ( $user -> lang [ 'NO_UPDATE_INFO' ], E_USER_ERROR );
}
// Check if the conflicts data is valid
if ( sizeof ( $conflicts ))
{
$conflict_filenames = array ();
foreach ( $update_list [ 'conflict' ] as $files )
{
$conflict_filenames [] = $files [ 'filename' ];
}
$new_conflicts = array ();
foreach ( $conflicts as $filename => $diff_method )
{
if ( in_array ( $filename , $conflict_filenames ))
{
$new_conflicts [ $filename ] = $diff_method ;
}
}
$conflicts = $new_conflicts ;
}
// Build list for modifications
if ( sizeof ( $modified ))
{
$modified_filenames = array ();
foreach ( $update_list [ 'modified' ] as $files )
{
$modified_filenames [] = $files [ 'filename' ];
}
$new_modified = array ();
foreach ( $modified as $filename => $diff_method )
{
if ( in_array ( $filename , $modified_filenames ))
{
$new_modified [ $filename ] = $diff_method ;
}
}
$modified = $new_modified ;
}
// Check number of conflicting files, they need to be equal. For modified files the number can differ
if ( sizeof ( $update_list [ 'conflict' ]) != sizeof ( $conflicts ))
{
trigger_error ( $user -> lang [ 'MERGE_SELECT_ERROR' ], E_USER_ERROR );
}
// Before we do anything, let us diff the files and store the raw file information "somewhere"
$get_files = false ;
2007-10-15 17:27:22 +00:00
$file_list = $cache -> get ( '_diff_files' );
2010-02-23 23:35:48 +00:00
$expected_files = $cache -> get ( '_expected_files' );
2007-10-06 11:45:30 +00:00
2007-10-14 21:26:07 +00:00
if ( $file_list === false || $file_list [ 'status' ] != - 1 )
2007-10-06 11:45:30 +00:00
{
$get_files = true ;
2006-09-02 14:34:20 +00:00
}
2007-10-06 11:45:30 +00:00
if ( $get_files )
{
if ( $file_list === false )
{
$file_list = array (
'status' => 0 ,
);
}
2010-02-23 23:35:48 +00:00
if ( ! isset ( $expected_files ) || $expected_files === false )
{
$expected_files = array ();
}
2007-10-06 11:45:30 +00:00
$processed = 0 ;
foreach ( $update_list as $status => $files )
{
if ( ! is_array ( $files ))
{
continue ;
}
foreach ( $files as $file_struct )
{
// Skip this file if the user selected to not update it
if ( in_array ( $file_struct [ 'filename' ], $no_update ))
{
2010-02-23 23:35:48 +00:00
$expected_files [ $file_struct [ 'filename' ]] = false ;
2007-10-06 11:45:30 +00:00
continue ;
}
// Already handled... then skip of course...
if ( isset ( $file_list [ $file_struct [ 'filename' ]]))
{
continue ;
}
// Refresh if we reach 5 diffs...
if ( $processed >= 5 )
{
$cache -> put ( '_diff_files' , $file_list );
2010-09-22 21:58:20 +02:00
if ( $request -> variable ( 'download' , false ))
2007-10-06 11:45:30 +00:00
{
$params [] = 'download=1' ;
}
2010-04-12 20:53:57 +02:00
$redirect_url = append_sid ( $this -> p_master -> module_url , " language= $language &mode= $mode &sub=update_files& " . implode ( '&' , $params ));
2007-10-06 11:45:30 +00:00
meta_refresh ( 3 , $redirect_url );
$template -> assign_vars ( array (
'S_IN_PROGRESS' => true ,
'L_IN_PROGRESS' => $user -> lang [ 'MERGING_FILES' ],
'L_IN_PROGRESS_EXPLAIN' => $user -> lang [ 'MERGING_FILES_EXPLAIN' ],
));
return ;
}
2010-02-23 23:35:48 +00:00
if ( file_exists ( $phpbb_root_path . $file_struct [ 'filename' ]))
{
$contents = file_get_contents ( $phpbb_root_path . $file_struct [ 'filename' ]);
if ( isset ( $expected_files [ $file_struct [ 'filename' ]]) && md5 ( $contents ) == $expected_files [ $file_struct [ 'filename' ]])
{
continue ;
}
}
2007-10-06 11:45:30 +00:00
$original_filename = ( $file_struct [ 'custom' ]) ? $file_struct [ 'original' ] : $file_struct [ 'filename' ];
switch ( $status )
{
case 'modified' :
$option = ( isset ( $modified [ $file_struct [ 'filename' ]])) ? $modified [ $file_struct [ 'filename' ]] : 0 ;
switch ( $option )
{
case MERGE_NO_MERGE_NEW :
$contents = file_get_contents ( $this -> new_location . $original_filename );
break ;
case MERGE_NO_MERGE_MOD :
$contents = file_get_contents ( $phpbb_root_path . $file_struct [ 'filename' ]);
break ;
default :
$diff = $this -> return_diff ( $this -> old_location . $original_filename , $phpbb_root_path . $file_struct [ 'filename' ], $this -> new_location . $original_filename );
2009-09-18 18:18:54 +00:00
$contents = implode ( " \n " , $diff -> merged_output ());
2007-10-06 11:45:30 +00:00
unset ( $diff );
break ;
}
2010-02-23 23:35:48 +00:00
$expected_files [ $file_struct [ 'filename' ]] = md5 ( $contents );
2007-10-06 11:45:30 +00:00
$file_list [ $file_struct [ 'filename' ]] = '_file_' . md5 ( $file_struct [ 'filename' ]);
$cache -> put ( $file_list [ $file_struct [ 'filename' ]], base64_encode ( $contents ));
$file_list [ 'status' ] ++ ;
$processed ++ ;
break ;
case 'conflict' :
$option = $conflicts [ $file_struct [ 'filename' ]];
$contents = '' ;
switch ( $option )
{
case MERGE_NO_MERGE_NEW :
$contents = file_get_contents ( $this -> new_location . $original_filename );
break ;
case MERGE_NO_MERGE_MOD :
$contents = file_get_contents ( $phpbb_root_path . $file_struct [ 'filename' ]);
break ;
default :
$diff = $this -> return_diff ( $this -> old_location . $original_filename , $phpbb_root_path . $file_struct [ 'filename' ], $this -> new_location . $original_filename );
if ( $option == MERGE_NEW_FILE )
{
$contents = implode ( " \n " , $diff -> merged_new_output ());
}
else if ( $option == MERGE_MOD_FILE )
{
$contents = implode ( " \n " , $diff -> merged_orig_output ());
}
else
{
unset ( $diff );
break 2 ;
}
unset ( $diff );
break ;
}
2010-02-23 23:35:48 +00:00
$expected_files [ $file_struct [ 'filename' ]] = md5 ( $contents );
2007-10-06 11:45:30 +00:00
$file_list [ $file_struct [ 'filename' ]] = '_file_' . md5 ( $file_struct [ 'filename' ]);
$cache -> put ( $file_list [ $file_struct [ 'filename' ]], base64_encode ( $contents ));
$file_list [ 'status' ] ++ ;
$processed ++ ;
break ;
}
}
}
2010-02-23 23:35:48 +00:00
$cache -> put ( '_expected_files' , $expected_files );
2007-10-06 11:45:30 +00:00
}
2007-10-14 21:26:07 +00:00
$file_list [ 'status' ] = - 1 ;
2007-10-06 11:45:30 +00:00
$cache -> put ( '_diff_files' , $file_list );
2010-09-22 21:58:20 +02:00
if ( $request -> variable ( 'download' , false ))
2006-09-02 14:34:20 +00:00
{
2006-12-03 16:12:03 +00:00
$this -> include_file ( 'includes/functions_compress.' . $phpEx );
2006-09-02 14:34:20 +00:00
$use_method = request_var ( 'use_method' , '' );
$methods = array ( '.tar' );
$available_methods = array ( '.tar.gz' => 'zlib' , '.tar.bz2' => 'bz2' , '.zip' => 'zlib' );
foreach ( $available_methods as $type => $module )
{
if ( !@ extension_loaded ( $module ))
{
continue ;
}
One commit for those fixes having a very tiny impact (mostly only whitespaces or forgotten spans, etc.)
Although i somehow mistakingly got #20445 and #15249 into it. :/
Removing s_watching_img from watch_topic_forum() function (Bug #20445)
Changing order for post review if more than one post affected (Bug #15249)
Language typos/fixes (Bug #20425, #15719, #15429, #14669, #13479)
Style/Template fixes (Bug #20065, #19405, #19205, #15028, #14934, #14821, #14752, #14497, #13707, #14738)
Tiny code fixes (Bug #20165, #20025, #19795, #14804)
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8350 89ea8834-ac86-4346-8a33-228a782c2dd0
2008-01-30 16:01:15 +00:00
2006-09-02 14:34:20 +00:00
$methods [] = $type ;
}
// Let the user decide in which format he wants to have the pack
if ( ! $use_method )
{
$this -> page_title = 'SELECT_DOWNLOAD_FORMAT' ;
$radio_buttons = '' ;
foreach ( $methods as $method )
{
2007-05-16 14:45:13 +00:00
$radio_buttons .= '<label><input type="radio"' . (( ! $radio_buttons ) ? ' id="use_method"' : '' ) . ' class="radio" value="' . $method . '" name="use_method" /> ' . $method . '</label>' ;
2006-09-02 14:34:20 +00:00
}
$template -> assign_vars ( array (
'S_DOWNLOAD_FILES' => true ,
2010-04-12 20:53:57 +02:00
'U_ACTION' => append_sid ( $this -> p_master -> module_url , " language= $language &mode= $mode &sub=update_files " ),
2006-09-02 14:34:20 +00:00
'RADIO_BUTTONS' => $radio_buttons ,
'S_HIDDEN_FIELDS' => $s_hidden_fields )
);
// To ease the update process create a file location map
$update_list = $cache -> get ( '_update_list' );
2006-12-08 15:20:57 +00:00
$script_path = ( $config [ 'force_server_vars' ]) ? (( $config [ 'script_path' ] == '/' ) ? '/' : $config [ 'script_path' ] . '/' ) : $user -> page [ 'root_script_path' ];
2006-09-02 14:34:20 +00:00
foreach ( $update_list as $status => $files )
{
2007-10-06 11:45:30 +00:00
if ( $status == 'up_to_date' || $status == 'no_update' || $status == 'status' )
2006-09-02 14:34:20 +00:00
{
continue ;
}
foreach ( $files as $file_struct )
{
if ( in_array ( $file_struct [ 'filename' ], $no_update ))
{
continue ;
}
$template -> assign_block_vars ( 'location' , array (
'SOURCE' => htmlspecialchars ( $file_struct [ 'filename' ]),
2006-12-08 15:20:57 +00:00
'DESTINATION' => $script_path . htmlspecialchars ( $file_struct [ 'filename' ]),
2006-09-02 14:34:20 +00:00
));
}
}
return ;
}
if ( ! in_array ( $use_method , $methods ))
{
$use_method = '.tar' ;
}
$update_mode = 'download' ;
}
else
{
2006-12-03 16:12:03 +00:00
$this -> include_file ( 'includes/functions_transfer.' . $phpEx );
2006-09-02 14:34:20 +00:00
// Choose FTP, if not available use fsock...
2007-10-06 11:45:30 +00:00
$method = basename ( request_var ( 'method' , '' ));
2006-09-02 14:34:20 +00:00
$submit = ( isset ( $_POST [ 'submit' ])) ? true : false ;
$test_ftp_connection = request_var ( 'test_connection' , '' );
2007-10-06 11:45:30 +00:00
if ( ! $method || ! class_exists ( $method ))
2006-09-02 14:34:20 +00:00
{
$method = 'ftp' ;
$methods = transfer :: methods ();
if ( ! in_array ( 'ftp' , $methods ))
{
$method = $methods [ 0 ];
}
}
$test_connection = false ;
if ( $test_ftp_connection || $submit )
{
2012-09-08 14:40:35 +02:00
$transfer = new $method (
request_var ( 'host' , '' ),
request_var ( 'username' , '' ),
htmlspecialchars_decode ( $request -> untrimmed_variable ( 'password' , '' )),
request_var ( 'root_path' , '' ),
request_var ( 'port' , '' ),
request_var ( 'timeout' , '' )
);
2006-09-02 14:34:20 +00:00
$test_connection = $transfer -> open_session ();
// Make sure that the directory is correct by checking for the existence of common.php
if ( $test_connection === true )
{
// Check for common.php file
if ( ! $transfer -> file_exists ( $phpbb_root_path , 'common.' . $phpEx ))
{
$test_connection = 'ERR_WRONG_PATH_TO_PHPBB' ;
}
}
$transfer -> close_session ();
// Make sure the login details are correct before continuing
if ( $submit && $test_connection !== true )
{
$submit = false ;
$test_ftp_connection = true ;
}
}
2007-10-06 11:45:30 +00:00
$s_hidden_fields .= build_hidden_fields ( array ( 'method' => $method ));
2006-09-02 14:34:20 +00:00
if ( ! $submit )
{
$this -> page_title = 'SELECT_FTP_SETTINGS' ;
2007-07-12 07:08:21 +00:00
if ( ! class_exists ( $method ))
{
trigger_error ( 'Method does not exist.' , E_USER_ERROR );
}
2006-09-02 14:34:20 +00:00
$requested_data = call_user_func ( array ( $method , 'data' ));
foreach ( $requested_data as $data => $default )
{
$template -> assign_block_vars ( 'data' , array (
'DATA' => $data ,
'NAME' => $user -> lang [ strtoupper ( $method . '_' . $data )],
'EXPLAIN' => $user -> lang [ strtoupper ( $method . '_' . $data ) . '_EXPLAIN' ],
2010-09-22 21:58:20 +02:00
'DEFAULT' => $request -> variable ( $data , ( string ) $default ),
2006-09-02 14:34:20 +00:00
));
}
$template -> assign_vars ( array (
'S_CONNECTION_SUCCESS' => ( $test_ftp_connection && $test_connection === true ) ? true : false ,
'S_CONNECTION_FAILED' => ( $test_ftp_connection && $test_connection !== true ) ? true : false ,
'ERROR_MSG' => ( $test_ftp_connection && $test_connection !== true ) ? $user -> lang [ $test_connection ] : '' ,
'S_FTP_UPLOAD' => true ,
'UPLOAD_METHOD' => $method ,
2010-04-12 20:53:57 +02:00
'U_ACTION' => append_sid ( $this -> p_master -> module_url , " language= $language &mode= $mode &sub=update_files " ),
'U_DOWNLOAD_METHOD' => append_sid ( $this -> p_master -> module_url , " language= $language &mode= $mode &sub=update_files&download=1 " ),
2008-10-25 14:12:13 +00:00
'S_HIDDEN_FIELDS' => $s_hidden_fields ,
));
2006-09-02 14:34:20 +00:00
return ;
}
$update_mode = 'upload' ;
}
// Now update the installation or download the archive...
2007-03-06 11:30:12 +00:00
$download_filename = 'update_' . $this -> update_info [ 'version' ][ 'from' ] . '_to_' . $this -> update_info [ 'version' ][ 'to' ];
$archive_filename = $download_filename . '_' . time () . '_' . unique_id ();
2006-09-02 14:34:20 +00:00
// Now init the connection
if ( $update_mode == 'download' )
{
2009-07-17 11:32:27 +00:00
if ( function_exists ( 'phpbb_is_writable' ) && ! phpbb_is_writable ( $phpbb_root_path . 'store/' ))
{
2009-11-15 22:30:07 +00:00
trigger_error ( sprintf ( 'The directory “%s” is not writable.' , $phpbb_root_path . 'store/' ), E_USER_ERROR );
2009-07-17 11:32:27 +00:00
}
2006-09-02 14:34:20 +00:00
if ( $use_method == '.zip' )
{
$compress = new compress_zip ( 'w' , $phpbb_root_path . 'store/' . $archive_filename . $use_method );
}
else
{
$compress = new compress_tar ( 'w' , $phpbb_root_path . 'store/' . $archive_filename . $use_method , $use_method );
}
}
else
{
2012-09-08 14:40:35 +02:00
$transfer = new $method (
request_var ( 'host' , '' ),
request_var ( 'username' , '' ),
htmlspecialchars_decode ( $request -> untrimmed_variable ( 'password' , '' )),
request_var ( 'root_path' , '' ),
request_var ( 'port' , '' ),
request_var ( 'timeout' , '' )
);
2006-09-02 14:34:20 +00:00
$transfer -> open_session ();
}
// Ok, go through the update list and do the operations based on their status
foreach ( $update_list as $status => $files )
{
2007-10-06 11:45:30 +00:00
if ( ! is_array ( $files ))
{
continue ;
}
2006-09-02 14:34:20 +00:00
foreach ( $files as $file_struct )
{
// Skip this file if the user selected to not update it
if ( in_array ( $file_struct [ 'filename' ], $no_update ))
{
continue ;
}
$original_filename = ( $file_struct [ 'custom' ]) ? $file_struct [ 'original' ] : $file_struct [ 'filename' ];
switch ( $status )
{
case 'new' :
case 'new_conflict' :
case 'not_modified' :
2007-10-06 11:45:30 +00:00
2006-09-02 14:34:20 +00:00
if ( $update_mode == 'download' )
{
$compress -> add_custom_file ( $this -> new_location . $original_filename , $file_struct [ 'filename' ]);
}
else
{
if ( $status != 'new' )
{
$transfer -> rename ( $file_struct [ 'filename' ], $file_struct [ 'filename' ] . '.bak' );
}
2007-10-06 11:45:30 +00:00
// New directory too?
$dirname = dirname ( $file_struct [ 'filename' ]);
if ( $dirname && ! file_exists ( $phpbb_root_path . $dirname ))
{
$transfer -> make_dir ( $dirname );
}
2006-09-02 14:34:20 +00:00
$transfer -> copy_file ( $this -> new_location . $original_filename , $file_struct [ 'filename' ]);
}
break ;
case 'modified' :
2006-11-29 15:51:54 +00:00
2007-10-06 11:45:30 +00:00
$contents = base64_decode ( $cache -> get ( $file_list [ $file_struct [ 'filename' ]]));
2006-11-29 15:51:54 +00:00
2006-09-02 14:34:20 +00:00
if ( $update_mode == 'download' )
{
$compress -> add_data ( $contents , $file_struct [ 'filename' ]);
}
else
{
2006-11-29 15:51:54 +00:00
// @todo add option to specify if a backup file should be created?
2006-09-02 14:34:20 +00:00
$transfer -> rename ( $file_struct [ 'filename' ], $file_struct [ 'filename' ] . '.bak' );
$transfer -> write_file ( $file_struct [ 'filename' ], $contents );
}
break ;
case 'conflict' :
2006-11-29 15:51:54 +00:00
2007-10-06 11:45:30 +00:00
$contents = base64_decode ( $cache -> get ( $file_list [ $file_struct [ 'filename' ]]));
2006-09-02 14:34:20 +00:00
if ( $update_mode == 'download' )
{
$compress -> add_data ( $contents , $file_struct [ 'filename' ]);
}
else
{
$transfer -> rename ( $file_struct [ 'filename' ], $file_struct [ 'filename' ] . '.bak' );
$transfer -> write_file ( $file_struct [ 'filename' ], $contents );
}
break ;
}
}
}
if ( $update_mode == 'download' )
{
$compress -> close ();
2007-03-06 11:30:12 +00:00
$compress -> download ( $archive_filename , $download_filename );
2006-09-02 14:34:20 +00:00
@ unlink ( $phpbb_root_path . 'store/' . $archive_filename . $use_method );
exit ;
}
else
{
$transfer -> close_session ();
$template -> assign_vars ( array (
'S_UPLOAD_SUCCESS' => true ,
2010-04-12 20:53:57 +02:00
'U_ACTION' => append_sid ( $this -> p_master -> module_url , " language= $language &mode= $mode &sub=file_check " ))
2006-09-02 14:34:20 +00:00
);
return ;
}
break ;
}
}
/**
* Show file diff
*/
function show_diff ( & $update_list )
{
2012-12-09 19:29:51 -06:00
global $phpbb_root_path , $template , $user , $phpbb_adm_relative_path ;
2006-09-02 14:34:20 +00:00
$this -> tpl_name = 'install_update_diff' ;
2007-06-26 13:53:07 +00:00
2006-09-02 14:34:20 +00:00
$this -> page_title = 'VIEWING_FILE_DIFF' ;
$status = request_var ( 'status' , '' );
$file = request_var ( 'file' , '' );
2009-01-12 16:58:47 +00:00
$diff_mode = request_var ( 'diff_mode' , 'inline' );
2006-09-02 14:34:20 +00:00
// First of all make sure the file is within our file update list with the correct status
$found_entry = array ();
foreach ( $update_list [ $status ] as $index => $file_struct )
{
if ( $file_struct [ 'filename' ] === $file )
{
$found_entry = $update_list [ $status ][ $index ];
}
}
if ( empty ( $found_entry ))
{
2006-11-26 12:22:56 +00:00
trigger_error ( $user -> lang [ 'FILE_DIFF_NOT_ALLOWED' ], E_USER_ERROR );
2006-09-02 14:34:20 +00:00
}
// If the status is 'up_to_date' then we do not need to show a diff
if ( $status == 'up_to_date' )
{
trigger_error ( $user -> lang [ 'FILE_ALREADY_UP_TO_DATE' ], E_USER_ERROR );
}
$original_file = ( $found_entry [ 'custom' ]) ? $found_entry [ 'original' ] : $file ;
// Get the correct diff
switch ( $status )
{
case 'conflict' :
2006-12-06 15:47:50 +00:00
$option = request_var ( 'op' , 0 );
2006-11-29 15:51:54 +00:00
2006-12-06 15:47:50 +00:00
switch ( $option )
{
case MERGE_NO_MERGE_NEW :
case MERGE_NO_MERGE_MOD :
2006-11-29 15:51:54 +00:00
2006-12-06 15:47:50 +00:00
$diff = $this -> return_diff ( array (), ( $option == MERGE_NO_MERGE_NEW ) ? $this -> new_location . $original_file : $phpbb_root_path . $file );
2006-09-02 14:34:20 +00:00
2006-12-06 15:47:50 +00:00
$template -> assign_var ( 'S_DIFF_NEW_FILE' , true );
$diff_mode = 'inline' ;
$this -> page_title = 'VIEWING_FILE_CONTENTS' ;
2006-09-02 14:34:20 +00:00
2006-12-06 15:47:50 +00:00
break ;
2009-01-12 16:58:47 +00:00
// Merge differences and use new phpBB code for conflicted blocks
case MERGE_NEW_FILE :
case MERGE_MOD_FILE :
2006-12-06 15:47:50 +00:00
$diff = $this -> return_diff ( $this -> old_location . $original_file , $phpbb_root_path . $file , $this -> new_location . $original_file );
$template -> assign_vars ( array (
'S_DIFF_CONFLICT_FILE' => true ,
2009-01-12 16:58:47 +00:00
'NUM_CONFLICTS' => $diff -> get_num_conflicts ())
2006-12-06 15:47:50 +00:00
);
2007-06-26 13:53:07 +00:00
2009-01-12 16:58:47 +00:00
$diff = $this -> return_diff ( $phpbb_root_path . $file , ( $option == MERGE_NEW_FILE ) ? $diff -> merged_new_output () : $diff -> merged_orig_output ());
break ;
// Download conflict file
default :
$diff = $this -> return_diff ( $this -> old_location . $original_file , $phpbb_root_path . $file , $this -> new_location . $original_file );
header ( 'Pragma: no-cache' );
header ( " Content-Type: application/octetstream; name= \" $file\ " " );
header ( " Content-disposition: attachment; filename= $file " );
@ set_time_limit ( 0 );
echo implode ( " \n " , $diff -> get_conflicts_content ());
flush ();
exit ;
2006-12-06 15:47:50 +00:00
break ;
}
break ;
case 'modified' :
2007-07-09 11:33:14 +00:00
$option = request_var ( 'op' , 0 );
switch ( $option )
{
case MERGE_NO_MERGE_NEW :
case MERGE_NO_MERGE_MOD :
$diff = $this -> return_diff ( array (), ( $option == MERGE_NO_MERGE_NEW ) ? $this -> new_location . $original_file : $phpbb_root_path . $file );
$template -> assign_var ( 'S_DIFF_NEW_FILE' , true );
$diff_mode = 'inline' ;
$this -> page_title = 'VIEWING_FILE_CONTENTS' ;
break ;
default :
$diff = $this -> return_diff ( $this -> old_location . $original_file , $phpbb_root_path . $original_file , $this -> new_location . $file );
2009-09-18 18:18:54 +00:00
$diff = $this -> return_diff ( $phpbb_root_path . $file , $diff -> merged_output ());
2007-07-09 11:33:14 +00:00
break ;
}
2006-09-02 14:34:20 +00:00
break ;
case 'not_modified' :
case 'new_conflict' :
2006-12-06 15:47:50 +00:00
$diff = $this -> return_diff ( $phpbb_root_path . $file , $this -> new_location . $original_file );
2006-09-02 14:34:20 +00:00
break ;
case 'new' :
2006-11-29 15:51:54 +00:00
2006-12-06 15:47:50 +00:00
$diff = $this -> return_diff ( array (), $this -> new_location . $original_file );
2006-11-29 15:51:54 +00:00
2006-09-02 14:34:20 +00:00
$template -> assign_var ( 'S_DIFF_NEW_FILE' , true );
$diff_mode = 'inline' ;
$this -> page_title = 'VIEWING_FILE_CONTENTS' ;
2006-12-06 15:47:50 +00:00
2006-09-02 14:34:20 +00:00
break ;
}
$diff_mode_options = '' ;
foreach ( array ( 'side_by_side' , 'inline' , 'unified' , 'raw' ) as $option )
{
$diff_mode_options .= '<option value="' . $option . '"' . (( $diff_mode == $option ) ? ' selected="selected"' : '' ) . '>' . $user -> lang [ 'DIFF_' . strtoupper ( $option )] . '</option>' ;
}
// Now the correct renderer
$render_class = 'diff_renderer_' . $diff_mode ;
if ( ! class_exists ( $render_class ))
{
trigger_error ( 'Chosen diff mode is not supported' , E_USER_ERROR );
}
2008-08-15 19:46:51 +00:00
$renderer = new $render_class ();
2006-09-02 14:34:20 +00:00
$template -> assign_vars ( array (
'DIFF_CONTENT' => $renderer -> get_diff_content ( $diff ),
2007-10-14 15:46:44 +00:00
'DIFF_MODE' => $diff_mode ,
2006-09-02 14:34:20 +00:00
'S_DIFF_MODE_OPTIONS' => $diff_mode_options ,
'S_SHOW_DIFF' => true ,
));
2006-11-29 15:51:54 +00:00
unset ( $diff , $renderer );
2006-09-02 14:34:20 +00:00
}
/**
* Collect all file status infos we need for the update by diffing all files
*/
2010-02-23 23:35:48 +00:00
function get_update_structure ( & $update_list , $expected_files )
2006-09-02 14:34:20 +00:00
{
global $phpbb_root_path , $phpEx , $user ;
2007-10-06 11:45:30 +00:00
if ( $update_list === false )
{
$update_list = array (
'up_to_date' => array (),
'new' => array (),
'not_modified' => array (),
'modified' => array (),
'new_conflict' => array (),
'conflict' => array (),
'no_update' => array (),
'status' => 0 ,
);
}
/* if ( ! empty ( $this -> update_info [ 'custom' ]))
{
foreach ( $this -> update_info [ 'custom' ] as $original_file => $file_ary )
{
foreach ( $file_ary as $index => $file )
{
$this -> make_update_diff ( $update_list , $original_file , $file , true );
}
}
} */
2006-09-02 14:34:20 +00:00
// Get a list of those files which are completely new by checking with file_exists...
2007-10-06 11:45:30 +00:00
$num_bytes_processed = 0 ;
2006-09-02 14:34:20 +00:00
foreach ( $this -> update_info [ 'files' ] as $index => $file )
{
2007-12-12 16:18:56 +00:00
if ( is_int ( $update_list [ 'status' ]) && $index < $update_list [ 'status' ])
2007-10-06 11:45:30 +00:00
{
continue ;
}
if ( $num_bytes_processed >= 500 * 1024 )
{
return ;
}
2006-09-02 14:34:20 +00:00
if ( ! file_exists ( $phpbb_root_path . $file ))
{
// Make sure the update files are consistent by checking if the file is in new_files...
if ( ! file_exists ( $this -> new_location . $file ))
{
trigger_error ( $user -> lang [ 'INCOMPLETE_UPDATE_FILES' ], E_USER_ERROR );
}
// If the file exists within the old directory the file got removed and we will write it back
2007-04-02 15:47:23 +00:00
// not a biggie, but we might want to state this circumstance separately later.
2006-09-02 14:34:20 +00:00
// if (file_exists($this->old_location . $file))
// {
// $update_list['removed'][] = $file;
// }
2007-10-06 11:45:30 +00:00
/* Only include a new file as new if the underlying path exist
2006-09-02 14:34:20 +00:00
// The path normally do not exist if the original style or language has been removed
if ( file_exists ( $phpbb_root_path . dirname ( $file )))
{
$this -> get_custom_info ( $update_list [ 'new' ], $file );
$update_list [ 'new' ][] = array ( 'filename' => $file , 'custom' => false );
}
else
{
2007-06-26 13:53:07 +00:00
// Do not include style-related or language-related content
if ( strpos ( $file , 'styles/' ) !== 0 && strpos ( $file , 'language/' ) !== 0 )
{
$update_list [ 'no_update' ][] = $file ;
}
2007-10-06 11:45:30 +00:00
} */
2013-11-07 13:49:55 +01:00
if ( ! phpbb_ignore_new_file_on_update ( $phpbb_root_path , $file ))
2007-10-06 11:45:30 +00:00
{
$this -> get_custom_info ( $update_list [ 'new' ], $file );
$update_list [ 'new' ][] = array ( 'filename' => $file , 'custom' => false );
2006-09-02 14:34:20 +00:00
}
2007-10-06 11:45:30 +00:00
// unset($this->update_info['files'][$index]);
2006-09-02 14:34:20 +00:00
}
2007-10-06 11:45:30 +00:00
else
{
// not modified?
2010-02-23 23:35:48 +00:00
$this -> make_update_diff ( $update_list , $file , $file , $expected_files );
2007-10-06 11:45:30 +00:00
}
$num_bytes_processed += ( file_exists ( $this -> new_location . $file )) ? filesize ( $this -> new_location . $file ) : 100 * 1024 ;
$update_list [ 'status' ] ++ ;
2006-09-02 14:34:20 +00:00
}
2007-10-14 21:26:07 +00:00
$update_list [ 'status' ] = - 1 ;
2007-10-06 11:45:30 +00:00
/* if ( ! sizeof ( $this -> update_info [ 'files' ]))
2006-09-02 14:34:20 +00:00
{
return $update_list ;
}
2006-11-24 14:59:26 +00:00
// Now diff the remaining files to get information about their status (not modified/modified/up-to-date)
2006-09-02 14:34:20 +00:00
// not modified?
foreach ( $this -> update_info [ 'files' ] as $index => $file )
{
$this -> make_update_diff ( $update_list , $file , $file );
}
// Now to the styles...
if ( empty ( $this -> update_info [ 'custom' ]))
{
return $update_list ;
}
foreach ( $this -> update_info [ 'custom' ] as $original_file => $file_ary )
{
foreach ( $file_ary as $index => $file )
{
$this -> make_update_diff ( $update_list , $original_file , $file , true );
}
}
2007-10-06 11:45:30 +00:00
return $update_list ; */
2006-09-02 14:34:20 +00:00
}
/**
* Compare files for storage in update_list
*/
2010-02-23 23:35:48 +00:00
function make_update_diff ( & $update_list , $original_file , $file , $expected_files , $custom = false )
2006-09-02 14:34:20 +00:00
{
global $phpbb_root_path , $user ;
2010-02-23 23:35:48 +00:00
$update_ary = array ( 'filename' => $file , 'custom' => $custom , 'as_expected' => false );
2006-09-02 14:34:20 +00:00
if ( $custom )
{
$update_ary [ 'original' ] = $original_file ;
}
2010-02-23 23:35:48 +00:00
if ( file_exists ( $phpbb_root_path . $file ))
{
$content = file_get_contents ( $phpbb_root_path . $file );
if ( isset ( $expected_files [ $file ]) && // the user already selected what to do with this file
( $expected_files [ $file ] === false || // the user wanted this file to stay the same, so just assume it's alright
$expected_files [ $file ] === md5 ( $content )))
{
// the file contains what it was supposed to contain after the merge
$update_ary [ 'as_expected' ] = true ;
$update_ary [ 'was_ignored' ] = ( $expected_files [ $file ] === false );
$update_list [ 'up_to_date' ][] = $update_ary ;
return ;
}
}
2009-09-18 18:18:54 +00:00
// we only want to know if the files are successfully merged and newlines could result in errors (duplicate addition of lines and such things)
// Therefore we check for empty diffs with two methods, preserving newlines and not preserving them (which mostly works best, therefore the first option)
2006-09-02 14:34:20 +00:00
// On a successfull update the new location file exists but the old one does not exist.
// Check for this circumstance, the new file need to be up-to-date with the current file then...
if ( ! file_exists ( $this -> old_location . $original_file ) && file_exists ( $this -> new_location . $original_file ) && file_exists ( $phpbb_root_path . $file ))
{
2006-11-28 16:34:28 +00:00
$tmp = array (
'file1' => file_get_contents ( $this -> new_location . $original_file ),
2010-02-23 23:35:48 +00:00
'file2' => $content ,
2006-11-28 16:34:28 +00:00
);
2006-09-02 14:34:20 +00:00
// We need to diff the contents here to make sure the file is really the one we expect
2008-08-15 19:46:51 +00:00
$diff = new diff ( $tmp [ 'file1' ], $tmp [ 'file2' ], false );
2006-11-28 16:34:28 +00:00
$empty = $diff -> is_empty ();
unset ( $tmp , $diff );
2006-09-02 14:34:20 +00:00
// if there are no differences we have an up-to-date file...
2006-11-28 16:34:28 +00:00
if ( $empty )
2006-09-02 14:34:20 +00:00
{
$update_list [ 'up_to_date' ][] = $update_ary ;
return ;
}
// If no other status matches we have another file in the way...
$update_list [ 'new_conflict' ][] = $update_ary ;
return ;
}
2007-10-06 11:45:30 +00:00
// Old file removed?
if ( file_exists ( $this -> old_location . $original_file ) && ! file_exists ( $this -> new_location . $original_file ))
{
return ;
}
2007-01-21 18:33:45 +00:00
// Check for existance, else abort immediately
2006-09-02 14:34:20 +00:00
if ( ! file_exists ( $this -> old_location . $original_file ) || ! file_exists ( $this -> new_location . $original_file ))
{
trigger_error ( $user -> lang [ 'INCOMPLETE_UPDATE_FILES' ], E_USER_ERROR );
}
2009-09-18 18:18:54 +00:00
$preserve_cr_ary = array ( false , true );
foreach ( $preserve_cr_ary as $preserve_cr )
{
$tmp = array (
'file1' => file_get_contents ( $this -> old_location . $original_file ),
2010-02-23 23:35:48 +00:00
'file2' => $content ,
2009-09-18 18:18:54 +00:00
);
// We need to diff the contents here to make sure the file is really the one we expect
$diff = new diff ( $tmp [ 'file1' ], $tmp [ 'file2' ], $preserve_cr );
$empty_1 = $diff -> is_empty ();
unset ( $tmp , $diff );
$tmp = array (
'file1' => file_get_contents ( $this -> new_location . $original_file ),
2010-02-23 23:35:48 +00:00
'file2' => $content ,
2009-09-18 18:18:54 +00:00
);
2006-11-28 16:34:28 +00:00
2009-09-18 18:18:54 +00:00
$diff = new diff ( $tmp [ 'file1' ], $tmp [ 'file2' ], $preserve_cr );
$empty_2 = $diff -> is_empty ();
2006-11-28 16:34:28 +00:00
2009-09-18 18:18:54 +00:00
unset ( $tmp , $diff );
2006-11-28 16:34:28 +00:00
2009-09-18 18:18:54 +00:00
// If the file is not modified we are finished here...
if ( $empty_1 )
{
// Further check if it is already up to date - it could happen that non-modified files
// slip through
if ( $empty_2 )
{
$update_list [ 'up_to_date' ][] = $update_ary ;
return ;
}
2006-11-28 16:34:28 +00:00
2009-09-18 18:18:54 +00:00
$update_list [ 'not_modified' ][] = $update_ary ;
return ;
}
2006-11-28 16:34:28 +00:00
2009-09-18 18:18:54 +00:00
// If the file had been modified then we need to check if it is already up to date
2006-09-02 14:34:20 +00:00
2009-09-18 18:18:54 +00:00
// if there are no differences we have an up-to-date file...
2006-11-28 16:34:28 +00:00
if ( $empty_2 )
2006-11-26 17:22:32 +00:00
{
$update_list [ 'up_to_date' ][] = $update_ary ;
return ;
}
2006-09-02 14:34:20 +00:00
}
2009-09-18 18:18:54 +00:00
$conflicts = false ;
2006-09-02 14:34:20 +00:00
2009-09-18 18:18:54 +00:00
foreach ( $preserve_cr_ary as $preserve_cr )
2006-09-02 14:34:20 +00:00
{
2009-09-18 18:18:54 +00:00
// if the file is modified we try to make sure a merge succeed
$tmp = array (
'orig' => file_get_contents ( $this -> old_location . $original_file ),
'final1' => file_get_contents ( $phpbb_root_path . $file ),
'final2' => file_get_contents ( $this -> new_location . $original_file ),
);
2006-09-02 14:34:20 +00:00
2009-09-18 18:18:54 +00:00
$diff = new diff3 ( $tmp [ 'orig' ], $tmp [ 'final1' ], $tmp [ 'final2' ], $preserve_cr );
unset ( $tmp );
2006-11-29 15:51:54 +00:00
2009-09-18 18:18:54 +00:00
if ( ! $diff -> get_num_conflicts ())
{
$tmp = array (
'file1' => file_get_contents ( $phpbb_root_path . $file ),
'file2' => implode ( " \n " , $diff -> merged_output ()),
);
2006-11-29 15:51:54 +00:00
2009-09-18 18:18:54 +00:00
// now compare the merged output with the original file to see if the modified file is up to date
$diff2 = new diff ( $tmp [ 'file1' ], $tmp [ 'file2' ], $preserve_cr );
$empty = $diff2 -> is_empty ();
2006-09-02 14:34:20 +00:00
2009-09-18 18:18:54 +00:00
unset ( $diff , $diff2 );
2006-11-29 15:51:54 +00:00
2009-09-18 18:18:54 +00:00
if ( $empty )
{
$update_list [ 'up_to_date' ][] = $update_ary ;
return ;
}
2009-09-20 16:18:41 +00:00
// If we preserve cr tag it as modified because the conflict would not show in this mode anyway
if ( $preserve_cr )
{
$update_list [ 'modified' ][] = $update_ary ;
return ;
}
2009-09-18 18:18:54 +00:00
}
else
{
// There is one special case... users having merged with a conflicting file... we need to check this
$tmp = array (
'file1' => file_get_contents ( $phpbb_root_path . $file ),
'file2' => implode ( " \n " , $diff -> merged_new_output ()),
);
2007-06-26 13:53:07 +00:00
2009-09-18 18:18:54 +00:00
$diff2 = new diff ( $tmp [ 'file1' ], $tmp [ 'file2' ], $preserve_cr );
$empty = $diff2 -> is_empty ();
2007-06-26 13:53:07 +00:00
2009-09-18 18:18:54 +00:00
if ( ! $empty )
{
unset ( $tmp , $diff2 );
2007-06-26 13:53:07 +00:00
2009-09-18 18:18:54 +00:00
// We check if the user merged with his output
$tmp = array (
'file1' => file_get_contents ( $phpbb_root_path . $file ),
'file2' => implode ( " \n " , $diff -> merged_orig_output ()),
);
2006-11-29 15:51:54 +00:00
2009-09-18 18:18:54 +00:00
$diff2 = new diff ( $tmp [ 'file1' ], $tmp [ 'file2' ], $preserve_cr );
$empty = $diff2 -> is_empty ();
}
2006-09-02 14:34:20 +00:00
2009-09-18 18:18:54 +00:00
if ( ! $empty )
{
$conflicts = $diff -> get_num_conflicts ();
}
2006-11-28 16:34:28 +00:00
2009-09-18 18:18:54 +00:00
unset ( $diff , $diff2 );
2006-09-02 14:34:20 +00:00
2009-09-18 18:18:54 +00:00
if ( $empty )
{
// A conflict got resolved...
$update_list [ 'up_to_date' ][] = $update_ary ;
return ;
}
}
}
2007-06-26 13:53:07 +00:00
2009-09-18 18:18:54 +00:00
if ( $conflicts !== false )
{
$update_ary [ 'conflicts' ] = $conflicts ;
$update_list [ 'conflict' ][] = $update_ary ;
2006-09-02 14:34:20 +00:00
return ;
}
// If no other status matches we have a modified file...
$update_list [ 'modified' ][] = $update_ary ;
}
/**
* Update update_list with custom new files
*/
function get_custom_info ( & $update_list , $file )
{
if ( empty ( $this -> update_info [ 'custom' ]))
{
return ;
}
One commit for those fixes having a very tiny impact (mostly only whitespaces or forgotten spans, etc.)
Although i somehow mistakingly got #20445 and #15249 into it. :/
Removing s_watching_img from watch_topic_forum() function (Bug #20445)
Changing order for post review if more than one post affected (Bug #15249)
Language typos/fixes (Bug #20425, #15719, #15429, #14669, #13479)
Style/Template fixes (Bug #20065, #19405, #19205, #15028, #14934, #14821, #14752, #14497, #13707, #14738)
Tiny code fixes (Bug #20165, #20025, #19795, #14804)
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@8350 89ea8834-ac86-4346-8a33-228a782c2dd0
2008-01-30 16:01:15 +00:00
if ( isset ( $this -> update_info [ 'custom' ][ $file ]))
2006-09-02 14:34:20 +00:00
{
foreach ( $this -> update_info [ 'custom' ][ $file ] as $_file )
{
$update_list [] = array ( 'filename' => $_file , 'custom' => true , 'original' => $file );
}
}
}
/**
* Get remote file
*/
function get_file ( $mode )
{
global $user , $db ;
$errstr = '' ;
$errno = 0 ;
switch ( $mode )
{
case 'update_info' :
global $phpbb_root_path , $phpEx ;
$update_info = array ();
2009-08-07 12:10:34 +00:00
include ( $phpbb_root_path . 'install/update/index.' . $phpEx );
2006-09-02 14:34:20 +00:00
$info = ( empty ( $update_info ) || ! is_array ( $update_info )) ? false : $update_info ;
$errstr = ( $info === false ) ? $user -> lang [ 'WRONG_INFO_FILE_FORMAT' ] : '' ;
if ( $info !== false )
{
2009-08-10 12:12:45 +00:00
// We assume that all file extensions have been renamed to .$phpEx,
// if someone is using a non .php file extension for php files.
// However, in $update_info['files'] we use hardcoded .php.
// We therefore replace .php with .$phpEx.
$info [ 'files' ] = preg_replace ( '/\.php$/i' , " . $phpEx " , $info [ 'files' ]);
2006-11-24 14:59:26 +00:00
// Adjust the update info file to hold some specific style-related information
2006-09-02 14:34:20 +00:00
$info [ 'custom' ] = array ();
2007-06-17 08:24:10 +00:00
/*
// Get custom installed styles...
2012-03-14 23:18:18 +02:00
$sql = ' SELECT style_name , style_path
FROM ' . STYLES_TABLE . "
WHERE LOWER ( style_name ) NOT IN ( 'subsilver2' , 'prosilver' ) " ;
2006-09-02 14:34:20 +00:00
$result = $db -> sql_query ( $sql );
$templates = array ();
while ( $row = $db -> sql_fetchrow ( $result ))
{
$templates [] = $row ;
}
$db -> sql_freeresult ( $result );
if ( sizeof ( $templates ))
{
foreach ( $info [ 'files' ] as $filename )
{
// Template update?
2007-06-17 08:24:10 +00:00
if ( strpos ( strtolower ( $filename ), 'styles/prosilver/template/' ) === 0 )
2006-09-02 14:34:20 +00:00
{
foreach ( $templates as $row )
{
2012-03-14 23:18:18 +02:00
$info [ 'custom' ][ $filename ][] = str_replace ( '/prosilver/' , '/' . $row [ 'style_path' ] . '/' , $filename );
2006-09-02 14:34:20 +00:00
}
}
}
}
2007-06-17 08:24:10 +00:00
*/
2006-09-02 14:34:20 +00:00
}
break ;
default :
trigger_error ( 'Mode for getting remote file not specified' , E_USER_ERROR );
break ;
}
if ( $info === false )
{
trigger_error ( $errstr , E_USER_ERROR );
}
return $info ;
}
2006-12-03 16:12:03 +00:00
/**
* Function for including files ...
*/
function include_file ( $filename )
{
2006-12-06 15:47:50 +00:00
global $phpbb_root_path , $phpEx ;
2006-12-03 16:12:03 +00:00
if ( ! empty ( $this -> update_info [ 'files' ]) && in_array ( $filename , $this -> update_info [ 'files' ]))
{
include_once ( $this -> new_location . $filename );
}
else
{
include_once ( $phpbb_root_path . $filename );
}
}
2006-12-06 15:47:50 +00:00
/**
* Wrapper for returning a diff object
*/
2009-09-18 18:18:54 +00:00
function return_diff ()
2006-12-06 15:47:50 +00:00
{
$args = func_get_args ();
$three_way_diff = ( func_num_args () > 2 ) ? true : false ;
$file1 = array_shift ( $args );
$file2 = array_shift ( $args );
$tmp [ 'file1' ] = ( ! empty ( $file1 ) && is_string ( $file1 )) ? file_get_contents ( $file1 ) : $file1 ;
$tmp [ 'file2' ] = ( ! empty ( $file2 ) && is_string ( $file2 )) ? file_get_contents ( $file2 ) : $file2 ;
if ( $three_way_diff )
{
$file3 = array_shift ( $args );
$tmp [ 'file3' ] = ( ! empty ( $file3 ) && is_string ( $file3 )) ? file_get_contents ( $file3 ) : $file3 ;
2008-08-15 19:46:51 +00:00
$diff = new diff3 ( $tmp [ 'file1' ], $tmp [ 'file2' ], $tmp [ 'file3' ]);
2006-12-06 15:47:50 +00:00
}
else
{
2008-08-15 19:46:51 +00:00
$diff = new diff ( $tmp [ 'file1' ], $tmp [ 'file2' ]);
2006-12-06 15:47:50 +00:00
}
unset ( $tmp );
return $diff ;
}
2006-09-02 14:34:20 +00:00
}