if ($multiple_sessions_field_hidden) {
     $Form->hidden('edited_user_set_login_multiple_sessions', $multiple_sessions_value);
 } else {
     $Form->checkbox('edited_user_set_login_multiple_sessions', $multiple_sessions_value, T_('Multiple sessions'), T_('Check this if you want to be able to log in from different computers/browsers at the same time. Otherwise, logging in from a new computer/browser will automatically disconnect you on the previous one.'), '', 1, $multiple_sessions_field_disabled);
 }
 // Session time out for the current user
 $timeout_sessions = $UserSettings->get('timeout_sessions', $edited_User->ID);
 $def_timeout_session = $Settings->get('timeout_sessions');
 if (empty($timeout_sessions)) {
     $timeout_sessions_selected = 'default';
     $timeout_sessions = $def_timeout_session;
 } else {
     $timeout_sessions_selected = 'custom';
 }
 if ($current_User->ID == $edited_User->ID || $current_User->check_perm('users', 'edit')) {
     $Form->radio_input('edited_user_timeout_sessions', $timeout_sessions_selected, array(array('value' => 'default', 'label' => T_('Use default duration.'), 'note' => duration_format($def_timeout_session), 'onclick' => 'jQuery("[id$=timeout_sessions]").hide();'), array('value' => 'custom', 'label' => T_('Use custom duration...'), 'onclick' => 'jQuery("[id$=timeout_sessions]").show();')), T_('Session timeout'), array('lines' => true));
     // Note: jQuery is not used below ( display:none is used instead ),
     // Note: because using jQuery leads to 'timeout_sessions_container' flash for 'default duration' on page load.
     $fieldstart = $Form->fieldstart;
     if ($timeout_sessions_selected == 'default') {
         // Hide the field to customize a session duration when default duration is selected
         $Form->fieldstart = str_replace('>', ' style="display:none">', $Form->fieldstart);
     }
     if ($timeout_sessions > $Settings->get('auto_prune_stats') * 86400 && $timeout_sessions > $def_timeout_session) {
         // Display a warning if the user session can be deleted earlier
         $timeout_sessions_warning = '<br /><span class="red">' . sprintf(T_('WARNING: The session will actually die earlier because the sessions table is pruned after %d days.'), intval($Settings->get('auto_prune_stats'))) . '</span>';
     } else {
         // No warning, because the custom user session duration will be used
         $timeout_sessions_warning = '';
     }
     $Form->duration_input('timeout_sessions', $timeout_sessions, T_('Custom duration'), 'months', 'seconds', array('minutes_step' => 1, 'note' => $timeout_sessions_warning));
Example #2
0
function template_arcade_game_highscore()
{
    global $scripturl, $txt, $context, $settings;
    if (isset($context['arcade']['submit'])) {
        if ($context['arcade']['submit'] == 'newscore') {
            $score =& $context['arcade']['new_score'];
            echo '
	<div class="cat_bar">
		<h3 class="catbg">
			', $txt['arcade_submit_score'], '
		</h3>
	</div>
	<div class="windowbg2">
		<span class="topslice"><span></span></span>
		<div style="padding: 0 0.5em">';
            // No permission to save
            if (!$score['saved']) {
                echo '
			<div>
				', $txt[$score['error']], '<br />
				<strong>', $txt['arcade_score'], ':</strong> ', $score['score'], '
			</div>';
            } else {
                echo '
			<div>
				', $txt['arcade_score_saved'], '<br />
				<strong>', $txt['arcade_score'], ':</strong> ', $score['score'], '<br />';
                if ($score['is_new_champion']) {
                    echo '
				', $txt['arcade_you_are_now_champion'], '<br />';
                } elseif ($score['is_personal_best']) {
                    echo '
				', $txt['arcade_this_is_your_best'], '<br />';
                }
                if ($score['can_comment']) {
                    echo '
			</div>
			<div>
				<form action="', $scripturl, '?action=arcade;sa=highscore;game=', $context['game']['id'], ';score=', $score['id'], '" method="post">
					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
					<input type="text" id="new_comment" name="new_comment" style="width: 95%;" />
					<input class="button_submit" type="submit" name="csave" value="', $txt['arcade_save'], '" />
				</form>
			</div>';
                }
            }
            echo '
		</div>
		<span class="botslice"><span></span></span>
	</div>
	<br />';
        } elseif ($context['arcade']['submit'] == 'askname') {
            echo '
	<div class="cat_bar">
		<h3 class="catbg">
			', $txt['arcade_submit_score'], '
		</h3>
	</div>
	<div class="windowbg2">
		<span class="topslice"><span></span></span>
		<div style="padding: 0 0.5em">
			<form action="', $scripturl, '?action=arcade;sa=save" method="post">
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
				<input type="text" name="name" style="width: 95%;" />
				<input class="button_submit" type="submit" value="', $txt['arcade_save'], '" />
			</form>
		</div>
	</div><br />';
        }
    }
    echo '
	<form name="score" action="', $scripturl, '?action=arcade;sa=highscore" method="post">
		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
		<input type="hidden" name="game" value="', $context['game']['id'], '" />
		<div class="cat_bar">
			<h3 class="catbg">
				', $txt['arcade_highscores'], '
			</h3>
		</div>
		<div class="pagesection">
			<div class="pagelinks floatleft">', $txt['pages'], ': ', $context['page_index'], !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . '&nbsp;&nbsp;<a href="#bot"><b>' . $txt['go_down'] . '</b></a>' : '', '</div>
			', template_button_strip($context['arcade']['buttons'], 'right'), '
		</div>
		<div class="score_table">
			<table cellspacing="0" class="table_grid">
				<thead>
					<tr class="catbg">';
    // Is there games?
    if (!empty($context['arcade']['scores'])) {
        echo '
						<th scope="col" class="first_th" width="5">', $txt['arcade_position'], '</th>
						<th scope="col">', $txt['arcade_member'], '</th>
						<th scope="col"> ', $txt['arcade_comment'], '</th>
						<th scope="col" class="', !$context['arcade']['can_admin_arcade'] ? ' last_th' : '', '">', $txt['arcade_score'], '</th>';
        if ($context['arcade']['can_admin_arcade']) {
            echo '
						<th scope="col" class="last_th" align="center" width="15"><input type="checkbox" onclick="invertAll(this, this.form, \'scores[]\');" class="check" /></th>';
        }
    } else {
        echo '
						<th scope="col" class="first_th" width="8%">&nbsp;</th>
						<th class="smalltext" colspan="', !$context['arcade']['can_admin_arcade'] ? '2' : '3', '"><strong>', $txt['arcade_no_scores'], '</strong></th>
						<th scope="col" class="last_th" width="8%">&nbsp;</th>';
    }
    echo '
					</tr>
				</thead>
				<tbody>';
    $edit_button = create_button('modify.gif', 'arcade_edit', '', 'title="' . $txt['arcade_edit'] . '"');
    foreach ($context['arcade']['scores'] as $score) {
        $div_con = addslashes(sprintf($txt['arcade_when'], $score['time'], duration_format($score['duration'])));
        echo '
					<tr class="', $score['own'] ? 'windowbg3' : 'windowbg', '"', !empty($score['highlight']) ? ' style="font-weight: bold;"' : '', ' onmouseover="arcadeBox(\'', $div_con, '\')" onmousemove="arcadeBoxMove(event)" onmouseout="arcadeBox(\'\')">
						<td class="windowbg2" align="center">', $score['position'], '</td>
						<td>', $score['member']['link'], '</td>
						<td width="300" class="windowbg2">';
        if ($score['can_edit'] && empty($score['edit'])) {
            echo '
							<div id="comment', $score['id'], '" class="floatleft">
								', $score['comment'], '
							</div>
							<div id="edit', $score['id'], '" class="floatleft" style="display: none;">
								<input type="text" id="c', $score['id'], '" value="', $score['raw_comment'], '" style="width: 95%;"  />
								<input type="button" onclick="arcadeCommentEdit(', $score['id'], ', ', $context['game']['id'], ', 1); return false;" name="csave" value="', $txt['arcade_save'], '" />
							</div>
							<a id="editlink', $score['id'], '" onclick="arcadeCommentEdit(', $score['id'], ', ', $context['game']['id'], ', 0); return false;" href="', $scripturl, '?action=arcade;sa=highscore;game=', $context['game']['id'], ';edit;score=', $score['id'], '" class="floatright">', $edit_button, '</a>';
        } elseif ($score['can_edit'] && !empty($score['edit'])) {
            echo '
							<input type="hidden" name="score" value="', $score['id'], '" />
							<input type="text" name="new_comment" id="c', $score['id'], '" value="', $score['raw_comment'], '" style="width: 95%;" />
							<input class="button_submit" type="submit" name="csave" value="', $txt['arcade_save'], '" />';
        } else {
            echo $score['comment'];
        }
        echo '
						</td>
						<td align="center">', $score['score'], '</td>';
        if ($context['arcade']['can_admin_arcade']) {
            echo '
						<td class="windowbg2" align="center"><input type="checkbox" name="scores[]" value="', $score['id'], '" class="check" /></td>';
        }
        echo '
					</tr>';
    }
    echo '
			</tbody>';
    if ($context['arcade']['can_admin_arcade']) {
        echo '
			<tfoot>
				<tr class="titlebg">
					<td colspan="', $context['arcade']['can_admin_arcade'] ? '6' : '5', '" align="right">
						<select name="qaction">
							<option value="">--------</option>
							<option value="delete">', $txt['arcade_delete_selected'], '</option>
						</select>
						<input value="', $txt['go'], '" onclick="return document.forms.score.qaction.value != \'\' && confirm(\'', $txt['arcade_are_you_sure'], '\');" class="button_submit" type="submit" />
					</td>
				</tr>
			</tfoot>';
    }
    echo '
			</table>
		</div>
	</form>';
}
Example #3
0
function ArcadeStats_LongestChampions($count = 10, $time = -1, $where = false)
{
    global $db_prefix, $scripturl, $txt, $smcFunc;
    if (!$where) {
        $where = '1 = 1';
        $order = 'CASE WHEN champion_from > 0 THEN (CASE WHEN champion_to = 0 THEN UNIX_TIMESTAMP() ELSE champion_to END - champion_from) ELSE 0 END DESC';
    } elseif ($where == 'current') {
        $where = 'champion_to = 0';
        $order = 'champion_from';
    } elseif ($where == 'past') {
        $where = 'champion_to > 0';
        $order = 'champion_to - champion_from';
    }
    $request = $smcFunc['db_query']('', '
		SELECT game.id_game, game.game_name,
			CASE WHEN champion_from > 0 THEN (CASE WHEN champion_to = 0 THEN UNIX_TIMESTAMP() ELSE champion_to END - champion_from) ELSE 0 END AS champion_duration,
			IFNULL(mem.id_member, 0) AS id_member, IFNULL(mem.real_name, {string:empty}) AS real_name, CASE WHEN champion_to = 0 THEN 1 ELSE 0 END AS current
		FROM {db_prefix}arcade_scores AS score
			LEFT JOIN {db_prefix}arcade_games AS game ON (game.id_game = score.id_game)
			LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = score.id_member)
		WHERE ' . $where . '
		GROUP BY score.id_score
		HAVING champion_duration > 0
		ORDER BY ' . $order . '
		LIMIT {int:count}', array('count' => $count, 'empty' => ''));
    $top = array();
    $max = -1;
    while ($score = $smcFunc['db_fetch_assoc']($request)) {
        if ($max == -1) {
            $max = $score['champion_duration'];
        }
        $top[] = array('game_name' => $score['game_name'], 'game_link' => '<a href="' . $scripturl . '?action=arcade;sa=play;game=' . $score['id_game'] . '">' . $score['game_name'] . '</a>', 'member_name' => $score['real_name'], 'member_link' => !empty($score['real_name']) ? '<a href="' . $scripturl . '?action=profile;u=' . $score['id_member'] . '">' . $score['real_name'] . '</a>' : $txt['guest'], 'duration' => duration_format($score['champion_duration']), 'precent' => $score['champion_duration'] / $max * 100, 'current' => $score['current'] == 1);
    }
    $smcFunc['db_free_result']($request);
    if (count($top) == 0) {
        return false;
    } elseif ($count > 1) {
        return $top;
    } else {
        return $top[0];
    }
}