Пример #1
0
/**
 *
 */
function template_welcome_message()
{
    global $upcontext, $disable_security, $settings, $txt;
    echo '
		<script src="', $settings['default_theme_url'], '/scripts/sha256.js"></script>
		<script src="', $settings['default_theme_url'], '/scripts/admin.js"></script>
		<script><!-- // --><![CDATA[
			var oUpgradeCenter = new elk_AdminIndex({
				bLoadAnnouncements: false,

				bLoadVersions: true,
				slatestVersionContainerId: \'latestVersion\',
				sinstalledVersionContainerId: \'version_warning\',
				sVersionOutdatedTemplate: ', JavaScriptEscape('
				<strong style="text-decoration: underline;">' . $txt['upgrade_warning'] . '</strong><br />
				<div style="padding-left: 6ex;">
					' . sprintf($txt['upgrade_warning_out_of_date'], CURRENT_VERSION, '%currentVersion%') . '
				</div>
				'), ',

				bLoadUpdateNotification: false
			});
		// ]]></script>
		<h3>', sprintf($txt['upgrade_ready_proceed'], CURRENT_VERSION), '</h3>
		<form id="upform" action="', $upcontext['form_url'], '" method="post" accept-charset="UTF-8" name="upform"', empty($upcontext['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $upcontext['rid'] . '\');"' : '', '>
		<input type="hidden" name="', $upcontext['login_token_var'], '" value="', $upcontext['login_token'], '" />
		<div id="version_warning" class="errorbox" style="display: none;">', CURRENT_VERSION, '</div>
		<div id="latestVersion" style="display: none;">???</div>';
    $upcontext['chmod_in_form'] = true;
    template_chmod();
    // For large, SMF pre-1.1 RC2 forums give them a warning about the possible impact of this upgrade!
    if ($upcontext['is_large_forum']) {
        echo '
		<div class="warningbox">
			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br />
			<div>
				', $txt['upgrade_warning_lots_data'], '
			</div>
		</div>';
    }
    // A warning message?
    if (!empty($upcontext['warning'])) {
        echo '
		<div class="warningbox">
			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong><br />
			<div>
				', $upcontext['warning'], '
			</div>
		</div>';
    }
    // Paths are incorrect?
    echo '
		<div class="errorbox" style="', file_exists($settings['default_theme_dir'] . '/scripts/script.js') ? 'display: none' : '', '" id="js_script_missing_error">
			<strong style="text-decoration: underline;">', $txt['upgrade_critical_error'], '</strong><br />
			<div>
				', $txt['upgrade_error_script_js'], '
			</div>
		</div>';
    // Is there someone already doing this?
    if (!empty($upcontext['user']['id']) && (time() - $upcontext['started'] < 72600 || time() - $upcontext['updated'] < 3600)) {
        $ago = time() - $upcontext['started'];
        if ($ago < 60) {
            $ago = $ago . ' seconds';
        } elseif ($ago < 3600) {
            $ago = (int) ($ago / 60) . ' minutes';
        } else {
            $ago = (int) ($ago / 3600) . ' hours';
        }
        $active = time() - $upcontext['updated'];
        if ($active < 60) {
            $updated = $active . ' seconds';
        } elseif ($active < 3600) {
            $updated = (int) ($active / 60) . ' minutes';
        } else {
            $updated = (int) ($active / 3600) . ' hours';
        }
        echo '
		<div class="warningbox">
			<strong style="text-decoration: underline;">', $txt['upgrade_warning'], '</strong>
			<br />
			<div>
				&quot;', $upcontext['user']['name'], '&quot; has been running the upgrade script for the last ', $ago, ' - and was last active ', $updated, ' ago.';
        if ($active < 600) {
            echo '
				We recommend that you do not run this script unless you are sure that ', $upcontext['user']['name'], ' has completed their upgrade.';
        }
        if ($active > $upcontext['inactive_timeout']) {
            echo '
				<br /><br />You can choose to either run the upgrade again from the beginning - or alternatively continue from the last step reached during the last upgrade.';
        } else {
            echo '
				<br /><br />This upgrade script cannot be run until ', $upcontext['user']['name'], ' has been inactive for at least ', $upcontext['inactive_timeout'] > 120 ? round($upcontext['inactive_timeout'] / 60, 1) . ' minutes!' : $upcontext['inactive_timeout'] . ' seconds!';
        }
        echo '
			</div>
		</div>';
    }
    echo '
			<strong>Admin Login: '******'(DISABLED)' : '', '</strong>
			<h3>For security purposes please login with your admin account to proceed with the upgrade.</h3>
			<table>
				<tr style="vertical-align: top;">
					<td><strong ', $disable_security ? 'style="color: lightgray;"' : '', '>Username:</strong></td>
					<td>
						<input type="text" name="user" value="', !empty($upcontext['username']) ? $upcontext['username'] : '', '" ', $disable_security ? 'disabled="disabled"' : '', ' class="input_text" />';
    if (!empty($upcontext['username_incorrect'])) {
        echo '
						<div class="error">Username Incorrect</div>';
    }
    echo '
					</td>
				</tr>
				<tr style="vertical-align: top;">
					<td><strong ', $disable_security ? 'style="color: lightgray;"' : '', '>Password:</strong></td>
					<td>
						<input type="password" name="passwrd" value=""', $disable_security ? ' disabled="disabled"' : '', ' class="input_password" />
						<input type="hidden" name="hash_passwrd" value="" />';
    if (!empty($upcontext['login_hash_error'])) {
        echo '
						<div class="error">Password security has recently been upgraded. Please enter your password again.</div>';
    } elseif (!empty($upcontext['password_failed'])) {
        echo '
						<div class="error">Password Incorrect</div>';
    }
    echo '
					</td>
				</tr>';
    // Can they continue?
    if (!empty($upcontext['user']['id']) && time() - $upcontext['user']['updated'] >= $upcontext['inactive_timeout'] && $upcontext['user']['step'] > 1) {
        echo '
				<tr>
					<td colspan="2">
						<label for="cont"><input type="checkbox" id="cont" name="cont" checked="checked" class="input_check" />Continue from step reached during last execution of upgrade script.</label>
					</td>
				</tr>';
    }
    echo '
			</table><br />
			<span class="smalltext">
				<strong>Note:</strong> If necessary the above security check can be bypassed for users who may administrate a server but not have admin rights on the forum. In order to bypass the above check simply open &quot;upgrade.php&quot; in a text editor and replace &quot;$disable_security = false;&quot; with &quot;$disable_security = true1;&quot; and refresh this page.
			</span>
			<input type="hidden" name="login_attempt" id="login_attempt" value="1" />
			<input type="hidden" name="js_works" id="js_works" value="0" />';
    // Say we want the continue button!
    $upcontext['continue'] = !empty($upcontext['user']['id']) && time() - $upcontext['user']['updated'] < $upcontext['inactive_timeout'] ? 2 : 1;
    // This defines whether javascript is going to work elsewhere :D
    echo '
		<script><!-- // --><![CDATA[
			if (document.getElementById(\'js_works\'))
				document.getElementById(\'js_works\').value = 1;
			var currentVersionRounds = 0;

			// Latest version?
			function ourCurrentVersion()
			{
				var latestVer,
					setLatestVer;

				latestVer = document.getElementById(\'latestVersion\');
				setLatestVer = document.getElementById(\'elkVersion\');

				if (latestVer.innerHTML == \'???\')
				{
					// After few many tries let the use run the script
					if (currentVersionRounds > 9)
						document.getElementById(\'contbutt\').disabled = 0;

					currentVersionRounds++;
					setTimeout(\'ourCurrentVersion()\', 50);
					return;
				}

				if (setLatestVer !== null)
				{
					setLatestVer.innerHTML = latestVer.innerHTML.replace(\'ElkArte \', \'\');
					document.getElementById(\'version_warning\').style.display = \'\';
				}
				document.getElementById(\'contbutt\').disabled = 0;
			}
			addLoadEvent(ourCurrentVersion);

			// This checks that the script file even exists!
			if (typeof(elkSelectText) == \'undefined\')
				document.getElementById(\'js_script_missing_error\').style.display = \'\';

		// ]]></script>';
}
Пример #2
0
function template_upgrade_templates()
{
    global $upcontext, $modSettings, $upgradeurl, $disable_security, $settings, $boarddir, $db_prefix, $boardurl;
    echo '
	<h3>There have been numerous language and template changes since the previous version of SMF. On this step the upgrader can attempt to automatically make these changes in your templates to save you from doing so manually.</h3>
	<form action="', $upcontext['form_url'], '&amp;ssi=1', $upcontext['is_test'] ? '' : ';forreal=1', '" name="upform" id="upform" method="post">';
    // Any files need to be writable?
    $upcontext['chmod_in_form'] = true;
    template_chmod();
    // Language/Template files need an update?
    if ($upcontext['temp_progress'] == 0 && !$upcontext['is_test'] && (!empty($upcontext['languages']) || !empty($upcontext['themes']))) {
        echo '
		The following template files will be updated to ensure they are compatible with this version of SMF. Note that this can only fix a limited number of compatibility issues and in general you should seek out the latest version of these themes/language files.
		<table width="90%" align="center" cellspacing="1" cellpadding="2" style="background-color: black;">
			<tr style="background-color: #eeeeee;">
				<td width="80%"><strong>Area</strong></td>
				<td width="20%" align="center"><strong>Changes Required</strong></td>
			</tr>';
        foreach ($upcontext['languages'] as $language) {
            echo '
				<tr style="background-color: #cccccc;">
					<td width="80%">
						&quot;', $language['name'], '&quot; Language Pack
						<div class="smalltext">(';
            foreach ($language['files'] as $k => $file) {
                echo $file['name'], $k + 1 != count($language['files']) ? ', ' : ')';
            }
            echo '
						</div>
					</td>
					<td width="20%" align="center">', $language['edit_count'] == 0 ? 1 : $language['edit_count'], '</td>
				</tr>';
        }
        foreach ($upcontext['themes'] as $theme) {
            echo '
				<tr style="background-color: #CCCCCC;">
					<td width="80%">
						&quot;', $theme['name'], '&quot; Theme
						<div class="smalltext">(';
            foreach ($theme['files'] as $k => $file) {
                echo $file['name'], $k + 1 != count($theme['files']) ? ', ' : ')';
            }
            echo '
						</div>
					</td>
					<td width="20%" align="center">', $theme['edit_count'] == 0 ? 1 : $theme['edit_count'], '</td>
				</tr>';
        }
        echo '
		</table>';
    } else {
        $langFiles = 0;
        $themeFiles = 0;
        if (!empty($upcontext['languages'])) {
            foreach ($upcontext['languages'] as $lang) {
                $langFiles += count($lang['files']);
            }
        }
        if (!empty($upcontext['themes'])) {
            foreach ($upcontext['themes'] as $theme) {
                $themeFiles += count($theme['files']);
            }
        }
        echo sprintf('Found <strong>%d</strong> language files and <strong>%d</strong> templates requiring an update so far.', $langFiles, $themeFiles) . '<br />';
        // What we're currently doing?
        if (!empty($upcontext['current_message'])) {
            echo '
				', $upcontext['current_message'];
        }
    }
    echo '
		<input type="hidden" name="uptempdone" value="1" />';
    if (!empty($upcontext['languages'])) {
        echo '
		<input type="hidden" name="languages" value="', base64_encode(serialize($upcontext['languages'])), '" />';
    }
    if (!empty($upcontext['themes'])) {
        echo '
		<input type="hidden" name="themes" value="', base64_encode(serialize($upcontext['themes'])), '" />';
    }
    if (!empty($upcontext['writable_files'])) {
        echo '
		<input type="hidden" name="writable_files" value="', base64_encode(serialize($upcontext['writable_files'])), '" />';
    }
    // Offer them the option to upgrade from YaBB SE?
    if (!empty($upcontext['can_upgrade_yabbse'])) {
        echo '
		<br /><label for="conv"><input type="checkbox" name="conv" id="conv" value="1" class="input_check" /> Convert the existing YaBB SE template and set it as default.</label><br />';
    }
    // We'll want a continue button... assuming chmod is OK (Otherwise let them use connect!)
    if (empty($upcontext['chmod']['files']) || $upcontext['is_test']) {
        $upcontext['continue'] = 1;
    }
}