6 * @copyright (c) 2005 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 if (!defined('IN_PHPBB'))
26 function main($id, $mode)
28 global $config, $db, $user, $auth, $template, $cache;
29 global $phpbb_root_path, $phpbb_admin_path, $phpEx;
31 $user->add_lang('install');
33 $this->tpl_name = 'acp_update';
34 $this->page_title = 'ACP_VERSION_CHECK';
36 // Get current and latest version
40 $info = obtain_latest_version_info(request_var('versioncheck_force', false));
44 trigger_error('VERSIONCHECK_FAIL', E_USER_WARNING);
47 $info = explode("\n", $info);
48 $latest_version = trim($info[0]);
50 $announcement_url = trim($info[1]);
51 $announcement_url = (strpos($announcement_url, '&') === false) ? str_replace('&', '&', $announcement_url) : $announcement_url;
52 $update_link = append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=update');
54 // next feature release
55 $next_feature_version = $next_feature_announcement_url = false;
56 if (isset($info[2]) && trim($info[2]) !== '')
58 $next_feature_version = trim($info[2]);
59 $next_feature_announcement_url = trim($info[3]);
62 // Determine automatic update...
63 $sql = 'SELECT config_value
64 FROM ' . CONFIG_TABLE . "
65 WHERE config_name = 'version_update_from'";
66 $result = $db->sql_query($sql);
67 $version_update_from = (string) $db->sql_fetchfield('config_value');
68 $db->sql_freeresult($result);
70 $current_version = (!empty($version_update_from)) ? $version_update_from : $config['version'];
72 $template->assign_vars(array(
73 'S_UP_TO_DATE' => phpbb_version_compare($latest_version, $config['version'], '<='),
74 'S_UP_TO_DATE_AUTO' => phpbb_version_compare($latest_version, $current_version, '<='),
75 'S_VERSION_CHECK' => true,
76 'U_ACTION' => $this->u_action,
77 'U_VERSIONCHECK_FORCE' => append_sid($this->u_action . '&versioncheck_force=1'),
79 'LATEST_VERSION' => $latest_version,
80 'CURRENT_VERSION' => $config['version'],
81 'AUTO_VERSION' => $version_update_from,
82 'NEXT_FEATURE_VERSION' => $next_feature_version,
84 'UPDATE_INSTRUCTIONS' => sprintf($user->lang['UPDATE_INSTRUCTIONS'], $announcement_url, $update_link),
85 'UPGRADE_INSTRUCTIONS' => $next_feature_version ? $user->lang('UPGRADE_INSTRUCTIONS', $next_feature_version, $next_feature_announcement_url) : false,