includes/acp/acp_update.php
author indvdum (gotoindvdum[at]gmail[dot]com)
Sat, 10 Mar 2012 00:11:31 +0400
changeset 14 88d35b740f20
parent 0 ceef6d64c21d
permissions -rw-r--r--
HG ignore
indvdum@0
     1
<?php
indvdum@0
     2
/**
indvdum@0
     3
*
indvdum@0
     4
* @package acp
indvdum@0
     5
* @version $Id$
indvdum@0
     6
* @copyright (c) 2005 phpBB Group
indvdum@0
     7
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
indvdum@0
     8
*
indvdum@0
     9
*/
indvdum@0
    10
indvdum@0
    11
/**
indvdum@0
    12
* @ignore
indvdum@0
    13
*/
indvdum@0
    14
if (!defined('IN_PHPBB'))
indvdum@0
    15
{
indvdum@0
    16
	exit;
indvdum@0
    17
}
indvdum@0
    18
indvdum@0
    19
/**
indvdum@0
    20
* @package acp
indvdum@0
    21
*/
indvdum@0
    22
class acp_update
indvdum@0
    23
{
indvdum@0
    24
	var $u_action;
indvdum@0
    25
indvdum@0
    26
	function main($id, $mode)
indvdum@0
    27
	{
indvdum@0
    28
		global $config, $db, $user, $auth, $template, $cache;
indvdum@0
    29
		global $phpbb_root_path, $phpbb_admin_path, $phpEx;
indvdum@0
    30
indvdum@0
    31
		$user->add_lang('install');
indvdum@0
    32
indvdum@0
    33
		$this->tpl_name = 'acp_update';
indvdum@0
    34
		$this->page_title = 'ACP_VERSION_CHECK';
indvdum@0
    35
indvdum@0
    36
		// Get current and latest version
indvdum@0
    37
		$errstr = '';
indvdum@0
    38
		$errno = 0;
indvdum@0
    39
indvdum@0
    40
		$info = obtain_latest_version_info(request_var('versioncheck_force', false));
indvdum@0
    41
indvdum@0
    42
		if ($info === false)
indvdum@0
    43
		{
indvdum@0
    44
			trigger_error('VERSIONCHECK_FAIL', E_USER_WARNING);
indvdum@0
    45
		}
indvdum@0
    46
indvdum@0
    47
		$info = explode("\n", $info);
indvdum@0
    48
		$latest_version = trim($info[0]);
indvdum@0
    49
indvdum@0
    50
		$announcement_url = trim($info[1]);
indvdum@0
    51
		$announcement_url = (strpos($announcement_url, '&amp;') === false) ? str_replace('&', '&amp;', $announcement_url) : $announcement_url;
indvdum@0
    52
		$update_link = append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=update');
indvdum@0
    53
indvdum@0
    54
		// next feature release
indvdum@0
    55
		$next_feature_version = $next_feature_announcement_url = false;
indvdum@0
    56
		if (isset($info[2]) && trim($info[2]) !== '')
indvdum@0
    57
		{
indvdum@0
    58
			$next_feature_version = trim($info[2]);
indvdum@0
    59
			$next_feature_announcement_url = trim($info[3]);
indvdum@0
    60
		}
indvdum@0
    61
indvdum@0
    62
		// Determine automatic update...
indvdum@0
    63
		$sql = 'SELECT config_value
indvdum@0
    64
			FROM ' . CONFIG_TABLE . "
indvdum@0
    65
			WHERE config_name = 'version_update_from'";
indvdum@0
    66
		$result = $db->sql_query($sql);
indvdum@0
    67
		$version_update_from = (string) $db->sql_fetchfield('config_value');
indvdum@0
    68
		$db->sql_freeresult($result);
indvdum@0
    69
indvdum@0
    70
		$current_version = (!empty($version_update_from)) ? $version_update_from : $config['version'];
indvdum@0
    71
indvdum@0
    72
		$template->assign_vars(array(
indvdum@0
    73
			'S_UP_TO_DATE'		=> phpbb_version_compare($latest_version, $config['version'], '<='),
indvdum@0
    74
			'S_UP_TO_DATE_AUTO'	=> phpbb_version_compare($latest_version, $current_version, '<='),
indvdum@0
    75
			'S_VERSION_CHECK'	=> true,
indvdum@0
    76
			'U_ACTION'			=> $this->u_action,
indvdum@0
    77
			'U_VERSIONCHECK_FORCE' => append_sid($this->u_action . '&amp;versioncheck_force=1'),
indvdum@0
    78
indvdum@0
    79
			'LATEST_VERSION'	=> $latest_version,
indvdum@0
    80
			'CURRENT_VERSION'	=> $config['version'],
indvdum@0
    81
			'AUTO_VERSION'		=> $version_update_from,
indvdum@0
    82
			'NEXT_FEATURE_VERSION'	=> $next_feature_version,
indvdum@0
    83
indvdum@0
    84
			'UPDATE_INSTRUCTIONS'	=> sprintf($user->lang['UPDATE_INSTRUCTIONS'], $announcement_url, $update_link),
indvdum@0
    85
			'UPGRADE_INSTRUCTIONS'	=> $next_feature_version ? $user->lang('UPGRADE_INSTRUCTIONS', $next_feature_version, $next_feature_announcement_url) : false,
indvdum@0
    86
		));
indvdum@0
    87
	}
indvdum@0
    88
}
indvdum@0
    89
indvdum@0
    90
?>