/**
 * Dropdown usable to select a board
 *
 * @param string $name
 * @param string $label
 * @param string $extra
 * @param boolean $all
 */
function template_select_boards($name, $label = '', $extra = '', $all = false)
{
    global $context, $txt;
    if (!empty($label)) {
        echo '
	<label for="', $name, '">', $label, ' </label>';
    }
    echo '
	<select name="', $name, '" id="', $name, '" ', $extra, ' >';
    if ($all) {
        echo '
		<option value="">', $txt['icons_edit_icons_all_boards'], '</option>';
    }
    foreach ($context['categories'] as $category) {
        echo '
		<optgroup label="', $category['name'], '">';
        foreach ($category['boards'] as $board) {
            echo '
			<option value="', $board['id'], '"', !empty($board['selected']) ? ' selected="selected"' : '', !empty($context['current_board']) && $board['id'] == $context['current_board'] && $context['boards_current_disabled'] ? ' disabled="disabled"' : '', '>', $board['child_level'] > 0 ? str_repeat('&#8195;', $board['child_level'] - 1) . '&#8195;' . (isBrowser('ie8') ? '&#187;' : '&#10148;') : '', $board['name'], '</option>';
        }
        echo '
		</optgroup>';
    }
    echo '
	</select>';
}
Example #2
0
/**
 * This function offers up a download of an event in iCal 2.0 format.
 *
 * follows the conventions in RFC5546 http://tools.ietf.org/html/rfc5546
 * sets events as all day events since we don't have hourly events
 * will honor and set multi day events
 * sets a sequence number if the event has been modified
 *
 * @todo .... allow for week or month export files as well?
 */
function iCalDownload()
{
    global $smcFunc, $sourcedir, $forum_version, $context, $modSettings, $webmaster_email, $mbname;
    // You can't export if the calendar export feature is off.
    if (empty($modSettings['cal_export'])) {
        fatal_lang_error('calendar_export_off', false);
    }
    // Goes without saying that this is required.
    if (!isset($_REQUEST['eventid'])) {
        fatal_lang_error('no_access', false);
    }
    // This is kinda wanted.
    require_once $sourcedir . '/Subs-Calendar.php';
    // Load up the event in question and check it exists.
    $event = getEventProperties($_REQUEST['eventid']);
    if ($event === false) {
        fatal_lang_error('no_access', false);
    }
    // Check the title isn't too long - iCal requires some formatting if so.
    $title = str_split($event['title'], 30);
    foreach ($title as $id => $line) {
        if ($id != 0) {
            $title[$id] = ' ' . $title[$id];
        }
        $title[$id] .= "\n";
    }
    // Format the dates.
    $datestamp = date('Ymd\\THis\\Z', time());
    $datestart = $event['year'] . ($event['month'] < 10 ? '0' . $event['month'] : $event['month']) . ($event['day'] < 10 ? '0' . $event['day'] : $event['day']);
    // Do we have a event that spans several days?
    if ($event['span'] > 1) {
        $dateend = strtotime($event['year'] . '-' . ($event['month'] < 10 ? '0' . $event['month'] : $event['month']) . '-' . ($event['day'] < 10 ? '0' . $event['day'] : $event['day']));
        $dateend += ($event['span'] - 1) * 86400;
        $dateend = date('Ymd', $dateend);
    }
    // This is what we will be sending later
    $filecontents = '';
    $filecontents .= 'BEGIN:VCALENDAR' . "\n";
    $filecontents .= 'METHOD:PUBLISH' . "\n";
    $filecontents .= 'PRODID:-//SimpleMachines//SMF ' . (empty($forum_version) ? 2.0 : strtr($forum_version, array('SMF ' => ''))) . '//EN' . "\n";
    $filecontents .= 'VERSION:2.0' . "\n";
    $filecontents .= 'BEGIN:VEVENT' . "\n";
    $filecontents .= 'ORGANIZER;CN="' . $event['realname'] . '":MAILTO:' . $webmaster_email . "\n";
    $filecontents .= 'DTSTAMP:' . $datestamp . "\n";
    $filecontents .= 'DTSTART;VALUE=DATE:' . $datestart . "\n";
    // more than one day
    if ($event['span'] > 1) {
        $filecontents .= 'DTEND;VALUE=DATE:' . $dateend . "\n";
    }
    // event has changed? advance the sequence for this UID
    if ($event['sequence'] > 0) {
        $filecontents .= 'SEQUENCE:' . $event['sequence'] . "\n";
    }
    $filecontents .= 'SUMMARY:' . implode('', $title);
    $filecontents .= 'UID:' . $event['eventid'] . '@' . str_replace(' ', '-', $mbname) . "\n";
    $filecontents .= 'END:VEVENT' . "\n";
    $filecontents .= 'END:VCALENDAR';
    // Send some standard headers.
    ob_end_clean();
    if (!empty($modSettings['enableCompressedOutput'])) {
        @ob_start('ob_gzhandler');
    } else {
        ob_start();
    }
    // Send the file headers
    header('Pragma: ');
    header('Cache-Control: no-cache');
    if (!isBrowser('gecko')) {
        header('Content-Transfer-Encoding: binary');
    }
    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . 'GMT');
    header('Accept-Ranges: bytes');
    header('Connection: close');
    header('Content-Disposition: attachment; filename="' . $event['title'] . '.ics"');
    if (empty($modSettings['enableCompressedOutput'])) {
        header('Content-Length: ' . $smcFunc['strlen']($filecontents));
    }
    // This is a calendar item!
    header('Content-Type: text/calendar');
    // Chuck out the card.
    echo $filecontents;
    // Off we pop - lovely!
    obExit(false);
}
/**
 * Displays the search results page.
 */
function template_results()
{
    global $context, $settings, $options, $txt, $scripturl, $message;
    // Let them know if we ignored a word in the search
    if (!empty($context['search_ignored'])) {
        echo '
		<div id="search_results">
			<h3 class="category_header">
				', $txt['generic_warning'], '
			</h3>
			<p class="warningbox">', $txt['search_warning_ignored_word' . (count($context['search_ignored']) == 1 ? '' : 's')], ': ', implode(', ', $context['search_ignored']), '</p>
		</div>';
    }
    // Or perhaps they made a spelling error, lets give them a hint
    if (isset($context['did_you_mean']) || empty($context['topics'])) {
        echo '
			<div id="search_results">
				<h2 class="category_header">', $txt['search_adjust_query'], '</h2>
				<div class="roundframe">';
        // Did they make any typos or mistakes, perhaps?
        if (isset($context['did_you_mean'])) {
            echo '
					<p>', $txt['search_did_you_mean'], ' <a href="', $scripturl, '?action=search;sa=results;params=', $context['did_you_mean_params'], '">', $context['did_you_mean'], '</a>.</p>';
        }
        echo '
					<form action="', $scripturl, '?action=search;sa=results" method="post" accept-charset="UTF-8">
						<dl class="settings">
							<dt class="righttext">
								<label for="search"><strong>', $txt['search_for'], ':</strong></label>
							</dt>
							<dd>
								<input type="text" id="search" name="search" value="', $context['search_params']['search'], '" maxlength="', $context['search_string_limit'], '" size="40" class="input_text" />
							</dd>
						</dl>
						<div class="submitbutton" >
							<input type="submit" name="edit_search" value="', $txt['search_adjust_submit'], '" class="button_submit" />
							<input type="hidden" name="searchtype" value="', $context['search_params']['searchtype'], '" />
							<input type="hidden" name="userspec" value="', $context['search_params']['userspec'], '" />
							<input type="hidden" name="show_complete" value="', $context['search_params']['show_complete'], '" />
							<input type="hidden" name="subject_only" value="', $context['search_params']['subject_only'], '" />
							<input type="hidden" name="minage" value="', $context['search_params']['minage'], '" />
							<input type="hidden" name="maxage" value="', $context['search_params']['maxage'], '" />
							<input type="hidden" name="sort" value="', $context['search_params']['sort'], '" />
						</div>';
        if (!empty($context['search_params']['brd'])) {
            foreach ($context['search_params']['brd'] as $board_id) {
                echo '
						<input type="hidden" name="brd[', $board_id, ']" value="', $board_id, '" />';
            }
        }
        echo '
					</form>
				</div>
			</div>
			<br />';
    }
    // Quick moderation set to checkboxes? Oh, how fun :/.
    if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
        echo '
			<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="UTF-8" name="topicForm" id="topicForm" class="search_results_posts', $context['compact'] ? ' compact_view' : '', '">';
    }
    echo '
				<h3 class="category_header hdicon cat_img_search">
					<span class="floatright">';
    if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
        echo '
						<input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');" class="input_check" />';
    }
    echo '
					</span>
					', $txt['mlist_search_results'], ':&nbsp;', $context['search_params']['search'], '
				</h3>';
    // Was anything even found?
    if (!empty($context['topics'])) {
        template_pagesection();
    } else {
        echo '
				<div class="roundframe">', $txt['find_no_results'], '</div>';
    }
    if ($context['compact']) {
        echo '
				<ul class="topic_listing compact_view search_results_posts">';
    } else {
        echo '
				<ul class="core_posts topic_listing search_results_posts">';
    }
    // While we have results to show ...
    $controller = $context['get_topics'][0];
    while ($topic = $controller->{$context['get_topics'][1]}()) {
        if ($context['compact']) {
            // We start with locked and sticky topics.
            if ($topic['is_sticky'] && $topic['is_locked']) {
                $color_class = 'locked_row sticky_row';
            } elseif ($topic['is_sticky']) {
                $color_class = 'sticky_row';
            } elseif ($topic['is_locked']) {
                $color_class = 'locked_row';
            } else {
                $color_class = 'basic_row';
            }
        } else {
            $color_class = $message['alternate'] == 0 ? 'windowbg' : 'windowbg2';
        }
        foreach ($topic['matches'] as $message) {
            echo '
					<li class="', $color_class, '">
						<div class="topic_details">
							<div class="counter">', $message['counter'], '</div>
							<h5>', $topic['board']['link'], ' / <a href="', $scripturl, '?topic=', $topic['id'], '.msg', $message['id'], '#msg', $message['id'], '">', $message['subject_highlighted'], '</a></h5>
							<span class="smalltext">&#171;&nbsp;', $txt['by'], '&nbsp;<strong>', $message['member']['link'], '</strong> ', $txt['on'], '&nbsp;<em>', $message['time'], '</em>&nbsp;&#187;</span>';
            echo '
						</div>';
            if (!$context['compact'] || $message['body_highlighted'] != '') {
                echo '
						<div class="topic_body">', $message['body_highlighted'], '</div>';
            }
            if (!empty($topic['buttons'])) {
                template_quickbutton_strip($topic['buttons'], $topic['tests']);
            }
            if (!empty($options['display_quick_mod'])) {
                echo '
						<p class="topic_moderation">';
                if ($options['display_quick_mod'] == 1) {
                    echo '
							<input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check" />';
                } else {
                    if ($topic['quick_mod']['remove']) {
                        echo '
							<a href="', $scripturl, '?action=quickmod;actions%5B', $topic['id'], '%5D=remove;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['quickmod_confirm'], '\');"><img src="', $settings['images_url'], '/icons/quick_remove.png" style="width: 16px;" alt="', $txt['remove_topic'], '" title="', $txt['remove_topic'], '" /></a>';
                    }
                    if ($topic['quick_mod']['lock']) {
                        echo '
							<a href="', $scripturl, '?action=quickmod;actions%5B', $topic['id'], '%5D=lock;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['quickmod_confirm'], '\');"><img src="', $settings['images_url'], '/icons/quick_lock.png" style="width: 16px;" alt="', $txt[$topic['is_locked'] ? 'set_unlock' : 'set_lock'], '" title="', $txt[$topic['is_locked'] ? 'set_unlock' : 'set_lock'], '" /></a>';
                    }
                    if ($topic['quick_mod']['lock'] || $topic['quick_mod']['remove']) {
                        echo '
							<br />';
                    }
                    if ($topic['quick_mod']['sticky']) {
                        echo '
							<a href="', $scripturl, '?action=quickmod;actions%5B', $topic['id'], '%5D=sticky;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['quickmod_confirm'], '\');"><img src="', $settings['images_url'], '/icons/quick_sticky.png" style="width: 16px;" alt="', $txt[$topic['is_sticky'] ? 'set_nonsticky' : 'set_sticky'], '" title="', $txt[$topic['is_sticky'] ? 'set_nonsticky' : 'set_sticky'], '" /></a>';
                    }
                    if ($topic['quick_mod']['move']) {
                        echo '
							<a href="', $scripturl, '?action=movetopic;topic=', $topic['id'], '.0"><img src="', $settings['images_url'], '/icons/quick_move.png" style="width: 16px;" alt="', $txt['move_topic'], '" title="', $txt['move_topic'], '" /></a>';
                    }
                }
                echo '
						</p>';
            }
            echo '
					</li>';
        }
    }
    echo '
				</ul>';
    // If we have results show a page index
    if (!empty($context['topics'])) {
        template_pagesection();
    }
    // Quick moderation enabled, then show an action area
    if (!empty($context['topics']) && !empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1) {
        echo '
				<div class="search_controls floatright">
					<div class="additional_row">
						<select class="qaction" name="qaction"', $context['can_move'] ? ' onchange="this.form.move_to.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '>
							<option value="">&nbsp;</option>';
        foreach ($context['qmod_actions'] as $qmod_action) {
            if ($context['can_' . $qmod_action]) {
                echo '
							<option value="' . $qmod_action . '">' . (isBrowser('ie8') ? '&#187;' : '&#10148;') . '&nbsp;', $txt['quick_mod_' . $qmod_action] . '</option>';
            }
        }
        echo '
						</select>';
        // Show a list of boards they can move the topic to.
        if ($context['can_move']) {
            echo '
						<span id="quick_mod_jump_to">&nbsp;</span>';
        }
        echo '
						<input type="hidden" name="redirect_url" value="', $scripturl . '?action=search;sa=results;params=' . $context['params'], '" />
						<input class="button_submit" type="submit" value="', $txt['quick_mod_go'], '" onclick="return document.forms.topicForm.qaction.value != \'\' &amp;&amp; confirm(\'', $txt['quickmod_confirm'], '\');" />

					</div>
				</div>';
        echo '
				<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
			</form>';
    }
    // Show a jump to box for easy navigation.
    echo '
			<div class="floatright" id="search_jump_to">&nbsp;</div>';
    if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) {
        addInlineJavascript('
		aJumpTo[aJumpTo.length] = new JumpTo({
			sContainerId: "quick_mod_jump_to",
			sClassName: "qaction",
			sJumpToTemplate: "%dropdown_list%",
			sCurBoardName: "' . $context['jump_to']['board_name'] . '",
			sBoardChildLevelIndicator: "&#8195;",
			sBoardPrefix: "' . (isBrowser('ie8') ? '&#187;' : '&#10148;') . '&nbsp;",
			sCatClass: "jump_to_header",
			sCatPrefix: "",
			bNoRedirect: true,
			bDisabled: true,
			sCustomName: "move_to"
		});', true);
    }
    addInlineJavascript('
		aJumpTo[aJumpTo.length] = new JumpTo({
			sContainerId: "search_jump_to",
			sJumpToTemplate: "<label class=\\"smalltext\\" for=\\"%select_id%\\">' . $context['jump_to']['label'] . ':<" + "/label> %dropdown_list%",
			iCurBoardId: 0,
			iCurBoardChildLevel: 0,
			sCurBoardName: "' . $context['jump_to']['board_name'] . '",
			sBoardChildLevelIndicator: "&#8195;",
			sBoardPrefix: "' . (isBrowser('ie8') ? '&#187;' : '&#10148;') . '&nbsp;",
			sCatClass: "jump_to_header",
			sCatPrefix: "",
			sGoButtonLabel: "' . $txt['quick_mod_go'] . '"
		});', true);
}
Example #4
0
/**
 * !!!Compatibility!!!
 *
 * This is not directly required any longer, but left for mod usage
 *
 * The harder one - wysiwyg to BBC!
 *
 * @param string $text
 * @return string
 */
function html_to_bbc($text)
{
    global $modSettings, $scripturl, $context;
    $db = database();
    // Replace newlines with spaces, as that's how browsers usually interpret them.
    $text = preg_replace("~\\s*[\r\n]+\\s*~", ' ', $text);
    // Though some of us love paragraphs, the parser will do better with breaks.
    $text = preg_replace('~</p>\\s*?<p~i', '</p><br /><p', $text);
    $text = preg_replace('~</p>\\s*(?!<)~i', '</p><br />', $text);
    // Safari/webkit wraps lines in Wysiwyg in <div>'s.
    if (isBrowser('webkit')) {
        $text = preg_replace(array('~<div(?:\\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br />', ''), $text);
    }
    // If there's a trailing break get rid of it - Firefox tends to add one.
    $text = preg_replace('~<br\\s?/?' . '>$~i', '', $text);
    // Remove any formatting within code tags.
    if (strpos($text, '[code') !== false) {
        $text = preg_replace('~<br\\s?/?' . '>~i', '#elk_br_spec_grudge_cool!#', $text);
        $parts = preg_split('~(\\[/code\\]|\\[code(?:=[^\\]]+)?\\])~i', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
        // Only mess with stuff outside [code] tags.
        for ($i = 0, $n = count($parts); $i < $n; $i++) {
            // Value of 2 means we're inside the tag.
            if ($i % 4 == 2) {
                $parts[$i] = strip_tags($parts[$i]);
            }
        }
        $text = strtr(implode('', $parts), array('#elk_br_spec_grudge_cool!#' => '<br />'));
    }
    // Remove scripts, style and comment blocks.
    $text = preg_replace('~<script[^>]*[^/]?' . '>.*?</script>~i', '', $text);
    $text = preg_replace('~<style[^>]*[^/]?' . '>.*?</style>~i', '', $text);
    $text = preg_replace('~\\<\\!--.*?-->~i', '', $text);
    $text = preg_replace('~\\<\\!\\[CDATA\\[.*?\\]\\]\\>~i', '', $text);
    // Do the smileys ultra first!
    preg_match_all('~<img\\s+[^<>]*?id="*smiley_\\d+_([^<>]+?)[\\s"/>]\\s*[^<>]*?/*>(?:\\s)?~i', $text, $matches);
    if (!empty($matches[0])) {
        // Easy if it's not custom.
        if (empty($modSettings['smiley_enable'])) {
            $smileysfrom = array('>:D', ':D', '::)', '>:(', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)');
            $smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif');
            foreach ($matches[1] as $k => $file) {
                $found = array_search($file, $smileysto);
                // Note the weirdness here is to stop double spaces between smileys.
                if ($found) {
                    $matches[1][$k] = '-[]-elk_smily_start#|#' . htmlspecialchars($smileysfrom[$found]) . '-[]-elk_smily_end#|#';
                } else {
                    $matches[1][$k] = '';
                }
            }
        } else {
            // Load all the smileys.
            $names = array();
            foreach ($matches[1] as $file) {
                $names[] = $file;
            }
            $names = array_unique($names);
            if (!empty($names)) {
                $request = $db->query('', '
					SELECT code, filename
					FROM {db_prefix}smileys
					WHERE filename IN ({array_string:smiley_filenames})', array('smiley_filenames' => $names));
                $mappings = array();
                while ($row = $db->fetch_assoc($request)) {
                    $mappings[$row['filename']] = htmlspecialchars($row['code']);
                }
                $db->free_result($request);
                foreach ($matches[1] as $k => $file) {
                    if (isset($mappings[$file])) {
                        $matches[1][$k] = '-[]-elk_smily_start#|#' . $mappings[$file] . '-[]-elk_smily_end#|#';
                    }
                }
            }
        }
        // Replace the tags!
        $text = str_replace($matches[0], $matches[1], $text);
        // Now sort out spaces
        $text = str_replace(array('-[]-elk_smily_end#|#-[]-elk_smily_start#|#', '-[]-elk_smily_end#|#', '-[]-elk_smily_start#|#'), ' ', $text);
    }
    // Only try to buy more time if the client didn't quit.
    if (connection_aborted() && $context['server']['is_apache']) {
        @apache_reset_timeout();
    }
    $parts = preg_split('~(<[A-Za-z]+\\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
    $replacement = '';
    $stack = array();
    foreach ($parts as $part) {
        if (preg_match('~(<([A-Za-z]+)\\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1) {
            // If it's being closed instantly, we can't deal with it...yet.
            if ($matches[5] === '/') {
                continue;
            } else {
                // Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.)
                $styles = explode(';', strtr($matches[3], array('&quot;' => '')));
                $curElement = $matches[2];
                $precedingStyle = $matches[1];
                $afterStyle = $matches[4];
                $curCloseTags = '';
                $extra_attr = '';
                foreach ($styles as $type_value_pair) {
                    // Remove spaces and convert uppercase letters.
                    $clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':'));
                    // Something like 'font-weight: bold' is expected here.
                    if (strpos($clean_type_value_pair, ':') === false) {
                        continue;
                    }
                    // Capture the elements of a single style item (e.g. 'font-weight' and 'bold').
                    list($style_type, $style_value) = explode(':', $type_value_pair);
                    $style_value = trim($style_value);
                    switch (trim($style_type)) {
                        case 'font-weight':
                            if ($style_value === 'bold') {
                                $curCloseTags .= '[/b]';
                                $replacement .= '[b]';
                            }
                            break;
                        case 'text-decoration':
                            if ($style_value == 'underline') {
                                $curCloseTags .= '[/u]';
                                $replacement .= '[u]';
                            } elseif ($style_value == 'line-through') {
                                $curCloseTags .= '[/s]';
                                $replacement .= '[s]';
                            }
                            break;
                        case 'text-align':
                            if ($style_value == 'left') {
                                $curCloseTags .= '[/left]';
                                $replacement .= '[left]';
                            } elseif ($style_value == 'center') {
                                $curCloseTags .= '[/center]';
                                $replacement .= '[center]';
                            } elseif ($style_value == 'right') {
                                $curCloseTags .= '[/right]';
                                $replacement .= '[right]';
                            }
                            break;
                        case 'font-style':
                            if ($style_value == 'italic') {
                                $curCloseTags .= '[/i]';
                                $replacement .= '[i]';
                            }
                            break;
                        case 'color':
                            $curCloseTags .= '[/color]';
                            $replacement .= '[color=' . $style_value . ']';
                            break;
                        case 'font-size':
                            // Sometimes people put decimals where decimals should not be.
                            if (preg_match('~(\\d)+\\.\\d+(p[xt])~i', $style_value, $dec_matches) === 1) {
                                $style_value = $dec_matches[1] . $dec_matches[2];
                            }
                            $curCloseTags .= '[/size]';
                            $replacement .= '[size=' . $style_value . ']';
                            break;
                        case 'font-family':
                            // Only get the first freaking font if there's a list!
                            if (strpos($style_value, ',') !== false) {
                                $style_value = substr($style_value, 0, strpos($style_value, ','));
                            }
                            $curCloseTags .= '[/font]';
                            $replacement .= '[font=' . strtr($style_value, array("'" => '')) . ']';
                            break;
                            // This is a hack for images with dimensions embedded.
                        // This is a hack for images with dimensions embedded.
                        case 'width':
                        case 'height':
                            if (preg_match('~[1-9]\\d*~i', $style_value, $dimension) === 1) {
                                $extra_attr .= ' ' . $style_type . '="' . $dimension[0] . '"';
                            }
                            break;
                        case 'list-style-type':
                            if (preg_match('~none|disc|circle|square|decimal|decimal-leading-zero|lower-roman|upper-roman|lower-alpha|upper-alpha|lower-greek|lower-latin|upper-latin|hebrew|armenian|georgian|cjk-ideographic|hiragana|katakana|hiragana-iroha|katakana-iroha~i', $style_value, $listType) === 1) {
                                $extra_attr .= ' listtype="' . $listType[0] . '"';
                            }
                            break;
                    }
                }
                // Preserve some tags stripping the styling.
                if (in_array($matches[2], array('a', 'font', 'td'))) {
                    $replacement .= $precedingStyle . $afterStyle;
                    $curCloseTags = '</' . $matches[2] . '>' . $curCloseTags;
                }
                // If there's something that still needs closing, push it to the stack.
                if (!empty($curCloseTags)) {
                    array_push($stack, array('element' => strtolower($curElement), 'closeTags' => $curCloseTags));
                } elseif (!empty($extra_attr)) {
                    $replacement .= $precedingStyle . $extra_attr . $afterStyle;
                }
            }
        } elseif (preg_match('~</([A-Za-z]+)>~', $part, $matches) === 1) {
            // Is this the element that we've been waiting for to be closed?
            if (!empty($stack) && strtolower($matches[1]) === $stack[count($stack) - 1]['element']) {
                $byebyeTag = array_pop($stack);
                $replacement .= $byebyeTag['closeTags'];
            } else {
                $replacement .= $part;
            }
        } else {
            $replacement .= $part;
        }
    }
    // Now put back the replacement in the text.
    $text = $replacement;
    // We are not finished yet, request more time.
    if (connection_aborted() && $context['server']['is_apache']) {
        @apache_reset_timeout();
    }
    // Let's pull out any legacy alignments.
    while (preg_match('~<([A-Za-z]+)\\s+[^<>]*?(align="*(left|center|right)"*)[^<>]*?(/?)>~i', $text, $matches) === 1) {
        // Find the position in the text of this tag over again.
        $start_pos = strpos($text, $matches[0]);
        if ($start_pos === false) {
            break;
        }
        // End tag?
        if ($matches[4] != '/' && strpos($text, '</' . $matches[1] . '>', $start_pos) !== false) {
            $end_length = strlen('</' . $matches[1] . '>');
            $end_pos = strpos($text, '</' . $matches[1] . '>', $start_pos);
            // Remove the align from that tag so it's never checked again.
            $tag = substr($text, $start_pos, strlen($matches[0]));
            $content = substr($text, $start_pos + strlen($matches[0]), $end_pos - $start_pos - strlen($matches[0]));
            $tag = str_replace($matches[2], '', $tag);
            // Put the tags back into the body.
            $text = substr($text, 0, $start_pos) . $tag . '[' . $matches[3] . ']' . $content . '[/' . $matches[3] . ']' . substr($text, $end_pos);
        } else {
            // Just get rid of this evil tag.
            $text = substr($text, 0, $start_pos) . substr($text, $start_pos + strlen($matches[0]));
        }
    }
    // Let's do some special stuff for fonts - cause we all love fonts.
    while (preg_match('~<font\\s+([^<>]*)>~i', $text, $matches) === 1) {
        // Find the position of this again.
        $start_pos = strpos($text, $matches[0]);
        $end_pos = false;
        if ($start_pos === false) {
            break;
        }
        // This must have an end tag - and we must find the right one.
        $lower_text = strtolower($text);
        $start_pos_test = $start_pos + 4;
        // How many starting tags must we find closing ones for first?
        $start_font_tag_stack = 0;
        while ($start_pos_test < strlen($text)) {
            // Where is the next starting font?
            $next_start_pos = strpos($lower_text, '<font', $start_pos_test);
            $next_end_pos = strpos($lower_text, '</font>', $start_pos_test);
            // Did we past another starting tag before an end one?
            if ($next_start_pos !== false && $next_start_pos < $next_end_pos) {
                $start_font_tag_stack++;
                $start_pos_test = $next_start_pos + 4;
            } elseif ($start_font_tag_stack) {
                $start_font_tag_stack--;
                $start_pos_test = $next_end_pos + 4;
            } else {
                $end_pos = $next_end_pos;
                break;
            }
        }
        if ($end_pos === false) {
            break;
        }
        // Now work out what the attributes are.
        $attribs = fetchTagAttributes($matches[1]);
        $tags = array();
        $sizes_equivalence = array(1 => '8pt', '10pt', '12pt', '14pt', '18pt', '24pt', '36pt');
        foreach ($attribs as $s => $v) {
            if ($s == 'size') {
                // Cast before empty chech because casting a string results in a 0 and we don't have zeros in the array! ;)
                $v = (int) trim($v);
                $v = empty($v) ? 1 : $v;
                $tags[] = array('[size=' . $sizes_equivalence[$v] . ']', '[/size]');
            } elseif ($s == 'face') {
                $tags[] = array('[font=' . trim(strtolower($v)) . ']', '[/font]');
            } elseif ($s == 'color') {
                $tags[] = array('[color=' . trim(strtolower($v)) . ']', '[/color]');
            }
        }
        // As before add in our tags.
        $before = $after = '';
        foreach ($tags as $tag) {
            $before .= $tag[0];
            if (isset($tag[1])) {
                $after = $tag[1] . $after;
            }
        }
        // Remove the tag so it's never checked again.
        $content = substr($text, $start_pos + strlen($matches[0]), $end_pos - $start_pos - strlen($matches[0]));
        // Put the tags back into the body.
        $text = substr($text, 0, $start_pos) . $before . $content . $after . substr($text, $end_pos + 7);
    }
    // Almost there, just a little more time.
    if (connection_aborted() && $context['server']['is_apache']) {
        @apache_reset_timeout();
    }
    if (count($parts = preg_split('~<(/?)(li|ol|ul)([^>]*)>~i', $text, null, PREG_SPLIT_DELIM_CAPTURE)) > 1) {
        // A toggle that dermines whether we're directly under a <ol> or <ul>.
        $inList = false;
        // Keep track of the number of nested list levels.
        $listDepth = 0;
        // Map what we can expect from the HTML to what is supported.
        $listTypeMapping = array('1' => 'decimal', 'A' => 'upper-alpha', 'a' => 'lower-alpha', 'I' => 'upper-roman', 'i' => 'lower-roman', 'disc' => 'disc', 'square' => 'square', 'circle' => 'circle');
        // $i: text, $i + 1: '/', $i + 2: tag, $i + 3: tail.
        for ($i = 0, $numParts = count($parts) - 1; $i < $numParts; $i += 4) {
            $tag = strtolower($parts[$i + 2]);
            $isOpeningTag = $parts[$i + 1] === '';
            if ($isOpeningTag) {
                switch ($tag) {
                    case 'ol':
                    case 'ul':
                        // We have a problem, we're already in a list.
                        if ($inList) {
                            // Inject a list opener, we'll deal with the ol/ul next loop.
                            array_splice($parts, $i, 0, array('', '', str_repeat("\t", $listDepth) . '[li]', ''));
                            $numParts = count($parts) - 1;
                            // The inlist status changes a bit.
                            $inList = false;
                        } else {
                            $inList = true;
                            if ($tag === 'ol') {
                                $listType = 'decimal';
                            } elseif (preg_match('~type="?(' . implode('|', array_keys($listTypeMapping)) . ')"?~', $parts[$i + 3], $match) === 1) {
                                $listType = $listTypeMapping[$match[1]];
                            } else {
                                $listType = null;
                            }
                            $listDepth++;
                            $parts[$i + 2] = '[list' . ($listType === null ? '' : ' type=' . $listType) . ']' . "\n";
                            $parts[$i + 3] = '';
                        }
                        break;
                    case 'li':
                        // This is how it should be: a list item inside the list.
                        if ($inList) {
                            $parts[$i + 2] = str_repeat("\t", $listDepth) . '[li]';
                            $parts[$i + 3] = '';
                            // Within a list item, it's almost as if you're outside.
                            $inList = false;
                        } else {
                            // We are apparently in a list item.
                            if ($listDepth > 0) {
                                $parts[$i + 2] = '[/li]' . "\n" . str_repeat("\t", $listDepth) . '[li]';
                                $parts[$i + 3] = '';
                            } else {
                                // Quickly create a list with an item.
                                $listDepth++;
                                $parts[$i + 2] = '[list]' . "\n\t" . '[li]';
                                $parts[$i + 3] = '';
                            }
                        }
                        break;
                }
            } else {
                switch ($tag) {
                    case 'ol':
                    case 'ul':
                        // As we expected it, closing the list while we're in it.
                        if ($inList) {
                            $inList = false;
                            $listDepth--;
                            $parts[$i + 1] = '';
                            $parts[$i + 2] = str_repeat("\t", $listDepth) . '[/list]';
                            $parts[$i + 3] = '';
                        } else {
                            // We're in a list item.
                            if ($listDepth > 0) {
                                // Inject closure for this list item first.
                                // The content of $parts[$i] is left as is!
                                array_splice($parts, $i + 1, 0, array('', '[/li]' . "\n", '', ''));
                                $numParts = count($parts) - 1;
                                // Now that we've closed the li, we're in list space.
                                $inList = true;
                            } else {
                                $parts[$i + 1] = '';
                                $parts[$i + 2] = '';
                                $parts[$i + 3] = '';
                            }
                        }
                        break;
                    case 'li':
                        if ($inList) {
                            // There's no use for a </li> after <ol> or <ul>, ignore.
                            $parts[$i + 1] = '';
                            $parts[$i + 2] = '';
                            $parts[$i + 3] = '';
                        } else {
                            // Remove the trailing breaks from the list item.
                            $parts[$i] = preg_replace('~\\s*<br\\s*' . '/?' . '>\\s*$~', '', $parts[$i]);
                            $parts[$i + 1] = '';
                            $parts[$i + 2] = '[/li]' . "\n";
                            $parts[$i + 3] = '';
                            // And we're back in the [list] space.
                            $inList = true;
                        }
                        break;
                }
            }
            // If we're in the [list] space, no content is allowed.
            if ($inList && trim(preg_replace('~\\s*<br\\s*' . '/?' . '>\\s*~', '', $parts[$i + 4])) !== '') {
                // Fix it by injecting an extra list item.
                array_splice($parts, $i + 4, 0, array('', '', 'li', ''));
                $numParts = count($parts) - 1;
            }
        }
        $text = implode('', $parts);
        if ($inList) {
            $listDepth--;
            $text .= str_repeat("\t", $listDepth) . '[/list]';
        }
        for ($i = $listDepth; $i > 0; $i--) {
            $text .= '[/li]' . "\n" . str_repeat("\t", $i - 1) . '[/list]';
        }
    }
    // I love my own image...
    while (preg_match('~<img\\s+([^<>]*)/*>~i', $text, $matches) === 1) {
        // Find the position of the image.
        $start_pos = strpos($text, $matches[0]);
        if ($start_pos === false) {
            break;
        }
        $end_pos = $start_pos + strlen($matches[0]);
        $params = '';
        $had_params = array();
        $src = '';
        $attrs = fetchTagAttributes($matches[1]);
        foreach ($attrs as $attrib => $value) {
            if (in_array($attrib, array('width', 'height'))) {
                $params .= ' ' . $attrib . '=' . (int) $value;
            } elseif ($attrib == 'alt' && trim($value) != '') {
                $params .= ' alt=' . trim($value);
            } elseif ($attrib == 'src') {
                $src = trim($value);
            }
        }
        $tag = '';
        if (!empty($src)) {
            // Attempt to fix the path in case it's not present.
            if (preg_match('~^https?://~i', $src) === 0 && is_array($parsedURL = parse_url($scripturl)) && isset($parsedURL['host'])) {
                $baseURL = (isset($parsedURL['scheme']) ? $parsedURL['scheme'] : 'http') . '://' . $parsedURL['host'] . (empty($parsedURL['port']) ? '' : ':' . $parsedURL['port']);
                if (substr($src, 0, 1) === '/') {
                    $src = $baseURL . $src;
                } else {
                    $src = $baseURL . (empty($parsedURL['path']) ? '/' : preg_replace('~/(?:index\\.php)?$~', '', $parsedURL['path'])) . '/' . $src;
                }
            }
            $tag = '[img' . $params . ']' . $src . '[/img]';
        }
        // Replace the tag
        $text = substr($text, 0, $start_pos) . $tag . substr($text, $end_pos);
    }
    // The final bits are the easy ones - tags which map to tags which map to tags - etc etc.
    $tags = array('~<b(\\s(.)*?)*?' . '>~i' => '[b]', '~</b>~i' => '[/b]', '~<i(\\s(.)*?)*?' . '>~i' => '[i]', '~</i>~i' => '[/i]', '~<u(\\s(.)*?)*?' . '>~i' => '[u]', '~</u>~i' => '[/u]', '~<strong(\\s(.)*?)*?' . '>~i' => '[b]', '~</strong>~i' => '[/b]', '~<em(\\s(.)*?)*?' . '>~i' => '[i]', '~</em>~i' => '[/i]', '~<s(\\s(.)*?)*?' . '>~i' => "[s]", '~</s>~i' => "[/s]", '~<strike(\\s(.)*?)*?' . '>~i' => '[s]', '~</strike>~i' => '[/s]', '~<del(\\s(.)*?)*?' . '>~i' => '[s]', '~</del>~i' => '[/s]', '~<center(\\s(.)*?)*?' . '>~i' => '[center]', '~</center>~i' => '[/center]', '~<pre(\\s(.)*?)*?' . '>~i' => '[pre]', '~</pre>~i' => '[/pre]', '~<sub(\\s(.)*?)*?' . '>~i' => '[sub]', '~</sub>~i' => '[/sub]', '~<sup(\\s(.)*?)*?' . '>~i' => '[sup]', '~</sup>~i' => '[/sup]', '~<tt(\\s(.)*?)*?' . '>~i' => '[tt]', '~</tt>~i' => '[/tt]', '~<table(\\s(.)*?)*?' . '>~i' => '[table]', '~</table>~i' => '[/table]', '~<tr(\\s(.)*?)*?' . '>~i' => '[tr]', '~</tr>~i' => '[/tr]', '~<(td|th)\\s[^<>]*?colspan="?(\\d{1,2})"?.*?' . '>~ie' => 'str_repeat(\'[td][/td]\', $2 - 1) . \'[td]\'', '~<(td|th)(\\s(.)*?)*?' . '>~i' => '[td]', '~</(td|th)>~i' => '[/td]', '~<br(?:\\s[^<>]*?)?' . '>~i' => "\n", '~<hr[^<>]*>(\\n)?~i' => "[hr]\n\$1", '~(\\n)?\\[hr\\]~i' => "\n[hr]", '~^\\n\\[hr\\]~i' => "[hr]", '~<blockquote(\\s(.)*?)*?' . '>~i' => "&lt;blockquote&gt;", '~</blockquote>~i' => "&lt;/blockquote&gt;", '~<ins(\\s(.)*?)*?' . '>~i' => "&lt;ins&gt;", '~</ins>~i' => "&lt;/ins&gt;");
    $text = preg_replace(array_keys($tags), array_values($tags), $text);
    // Please give us just a little more time.
    if (connection_aborted() && $context['server']['is_apache']) {
        @apache_reset_timeout();
    }
    // Take care of any urls in the text
    $text = convert_urls($text);
    $text = strip_tags($text);
    // Some tags often end up as just dummy tags - remove those.
    $text = preg_replace('~\\[[bisu]\\]\\s*\\[/[bisu]\\]~', '', $text);
    // Fix up entities.
    $text = preg_replace('~&#38;~i', '&#38;#38;', $text);
    $text = legalise_bbc($text);
    return $text;
}
/**
 * View the details of a moderation report
 */
function template_viewmodreport()
{
    global $context, $scripturl, $txt;
    echo '
					<div id="modcenter">
						<form action="', $scripturl, '?action=moderate;area=reports;report=', $context['report']['id'], '" method="post" accept-charset="UTF-8">
							<h3 class="category_header">
								', sprintf($txt['mc_viewmodreport'], $context['report']['message_link'], $context['report']['author']['link']), '
							</h3>
							<div class="windowbg2">
								<p class="warningbox">', sprintf($txt['mc_modreport_summary'], $context['report']['num_reports'], $context['report']['last_updated']), '</p>
								<div class="content">
									', $context['report']['body'], '
								</div>
								<ul class="quickbuttons">
									<li class="listlevel1">
										<a class="linklevel1 close_button" href="', $scripturl, '?action=moderate;area=reports;close=', (int) (!$context['report']['closed']), ';rid=', $context['report']['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $context['report']['closed'] ? $txt['mc_reportedp_open'] : $txt['mc_reportedp_close'], '</a>
									</li>
									<li class="listlevel1">
										<a class="linklevel1 ignore_button" href="', $scripturl, '?action=moderate;area=reports;ignore=', (int) (!$context['report']['ignore']), ';rid=', $context['report']['id'], ';', $context['session_var'], '=', $context['session_id'], '" ', !$context['report']['ignore'] ? 'onclick="return confirm(' . JavaScriptEscape($txt['mc_reportedp_ignore_confirm']) . ');"' : '', '>', $context['report']['ignore'] ? $txt['mc_reportedp_unignore'] : $txt['mc_reportedp_ignore'], '</a>
									</li>
								</ul>
							</div>
							<h3 class="category_header">', $txt['mc_modreport_whoreported_title'], '</h3>';
    foreach ($context['report']['comments'] as $comment) {
        echo '
							<div class="windowbg">
								<div class="content">
									<p class="smalltext">', sprintf($txt['mc_modreport_whoreported_data'], $comment['member']['link'] . (empty($comment['member']['id']) && !empty($comment['member']['ip']) ? ' (' . $comment['member']['ip'] . ')' : ''), $comment['time']), '</p>
									<p>', $comment['message'], '</p>
								</div>
							</div>';
    }
    echo '
							<h3 class="category_header">', $txt['mc_modreport_mod_comments'], '</h3>
							<div class="windowbg2">
								<div class="content">';
    if (empty($context['report']['mod_comments'])) {
        echo '
									<p class="successbox">', $txt['mc_modreport_no_mod_comment'], '</p>';
    }
    foreach ($context['report']['mod_comments'] as $comment) {
        echo '<p>', $comment['member']['link'], ': ', $comment['message'], ' <em class="smalltext">(', $comment['time'], ')</em></p>';
    }
    echo '
									<textarea rows="2" cols="60" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 60%; min-width: 60%' : 'width: 100%') . ';" name="mod_comment"></textarea>
									<div class="submitbutton">
										<input type="submit" name="add_comment" value="', $txt['mc_modreport_add_mod_comment'], '" class="button_submit" />
									</div>
								</div>
							</div>';
    template_show_list('moderation_actions_list');
    echo '
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
						</form>
					</div>';
}
Example #6
0
/**
 * The main sub template above the content.
 */
function template_html_above()
{
    global $context, $settings, $scripturl, $txt, $modSettings;
    // Show right to left and the character set for ease of translating.
    echo '<!DOCTYPE html>
<html ', $context['right_to_left'] ? ' dir="rtl"' : '', '>
<head>
	<title>', $context['page_title_html_safe'], '</title>';
    // Tell IE to render the page in standards not compatibility mode. really for ie >= 8
    // Note if this is not in the first 4k, its ignored, thats why its here
    if (isBrowser('ie')) {
        echo '
	<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />';
    }
    // load in any css from mods or themes so they can overwrite if wanted
    template_css();
    // Save some database hits, if a width for multiple wrappers is set in admin.
    if (!empty($settings['forum_width'])) {
        echo '
	<style>
		#wrapper, .frame {
			width: ', $settings['forum_width'], ';
		}
	</style>';
    }
    // Quick and dirty testing of RTL horrors. Remove before production build.
    //echo '
    //<link rel="stylesheet" href="', $settings['theme_url'], '/css/rtl.css?alp21" />';
    // RTL languages require an additional stylesheet.
    if ($context['right_to_left']) {
        echo '
		<link rel="stylesheet" href="', $settings['theme_url'], '/css/rtl.css?alp21" />';
        if (!empty($context['theme_variant'])) {
            echo '
		<link rel="stylesheet" href="', $settings['theme_url'], '/css/rtl', $context['theme_variant'], '.css?alp21" />';
        }
    }
    echo '
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="viewport" content="width=device-width" />
	<meta name="description" content="', $context['page_title_html_safe'], '" />', !empty($context['meta_keywords']) ? '
	<meta name="keywords" content="' . $context['meta_keywords'] . '" />' : '';
    // Please don't index these Mr Robot.
    if (!empty($context['robot_no_index'])) {
        echo '
	<meta name="robots" content="noindex" />';
    }
    // Present a canonical url for search engines to prevent duplicate content in their indices.
    if (!empty($context['canonical_url'])) {
        echo '
	<link rel="canonical" href="', $context['canonical_url'], '" />';
    }
    // Show all the relative links, such as help, search, contents, and the like.
    echo '
	<link rel="help" href="', $scripturl, '?action=help" />
	<link rel="contents" href="', $scripturl, '" />', $context['allow_search'] ? '
	<link rel="search" href="' . $scripturl . '?action=search" />' : '';
    // If RSS feeds are enabled, advertise the presence of one.
    if (!empty($modSettings['xmlnews_enable']) && (!empty($modSettings['allow_guestAccess']) || $context['user']['is_logged'])) {
        echo '
	<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $scripturl, '?type=rss2;action=.xml" />
	<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $scripturl, '?type=atom;action=.xml" />';
    }
    // If we're viewing a topic, these should be the previous and next topics, respectively.
    if (!empty($context['links']['next'])) {
        echo '<link rel="next" href="', $context['links']['next'], '" />';
    } else {
        if (!empty($context['current_topic'])) {
            echo '<link rel="next" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=next" />';
        }
    }
    if (!empty($context['links']['prev'])) {
        echo '<link rel="prev" href="', $context['links']['prev'], '" />';
    } else {
        if (!empty($context['current_topic'])) {
            echo '<link rel="prev" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=prev" />';
        }
    }
    // If we're in a board, or a topic for that matter, the index will be the board's index.
    if (!empty($context['current_board'])) {
        echo '
	<link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0" />';
    }
    // load in any javascript files from mods and themes
    template_javascript();
    // Output any remaining HTML headers. (from mods, maybe?)
    echo $context['html_headers'];
    // A little help for our friends
    echo '
	<!--[if lt IE 9]>
		<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->';
    echo '
</head>
<body id="', $context['browser_body_id'], '" class="action_', !empty($context['current_action']) ? htmlspecialchars($context['current_action']) : (!empty($context['current_board']) ? 'messageindex' : (!empty($context['current_topic']) ? 'display' : 'home')), !empty($context['current_board']) ? ' board_' . htmlspecialchars($context['current_board']) : '', '">';
}
Example #7
0
 /**
  * This function will display the contact information for the forum, as well a form to fill in.
  * Accessed by action=coppa
  */
 public function action_coppa()
 {
     global $context, $modSettings, $txt;
     loadLanguage('Login');
     loadTemplate('Register');
     // No User ID??
     if (!isset($_GET['member'])) {
         fatal_lang_error('no_access', false);
     }
     // Get the user details...
     require_once SUBSDIR . '/Members.subs.php';
     $member = getBasicMemberData((int) $_GET['member'], array('authentication' => true));
     // If doesn't exist or not pending coppa
     if (empty($member) || $member['is_activated'] != 5) {
         fatal_lang_error('no_access', false);
     }
     if (isset($_GET['form'])) {
         // Some simple contact stuff for the forum.
         $context['forum_contacts'] = (!empty($modSettings['coppaPost']) ? $modSettings['coppaPost'] . '<br /><br />' : '') . (!empty($modSettings['coppaFax']) ? $modSettings['coppaFax'] . '<br />' : '');
         $context['forum_contacts'] = !empty($context['forum_contacts']) ? $context['forum_name_html_safe'] . '<br />' . $context['forum_contacts'] : '';
         // Showing template?
         if (!isset($_GET['dl'])) {
             // Shortcut for producing underlines.
             $context['ul'] = '<u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</u>';
             Template_Layers::getInstance()->removeAll();
             $context['sub_template'] = 'coppa_form';
             $context['page_title'] = replaceBasicActionUrl($txt['coppa_form_title']);
             $context['coppa_body'] = str_replace(array('{PARENT_NAME}', '{CHILD_NAME}', '{USER_NAME}'), array($context['ul'], $context['ul'], $member['member_name']), replaceBasicActionUrl($txt['coppa_form_body']));
         } else {
             // The data.
             $ul = '                ';
             $crlf = "\r\n";
             $data = $context['forum_contacts'] . $crlf . $txt['coppa_form_address'] . ':' . $crlf . $txt['coppa_form_date'] . ':' . $crlf . $crlf . $crlf . replaceBasicActionUrl($txt['coppa_form_body']);
             $data = str_replace(array('{PARENT_NAME}', '{CHILD_NAME}', '{USER_NAME}', '<br>', '<br />'), array($ul, $ul, $member['member_name'], $crlf, $crlf), $data);
             // Send the headers.
             header('Connection: close');
             header('Content-Disposition: attachment; filename="approval.txt"');
             header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream'));
             header('Content-Length: ' . count($data));
             echo $data;
             obExit(false);
         }
     } else {
         $context += array('page_title' => $txt['coppa_title'], 'sub_template' => 'coppa');
         $context['coppa'] = array('body' => str_replace('{MINIMUM_AGE}', $modSettings['coppaAge'], replaceBasicActionUrl($txt['coppa_after_registration'])), 'many_options' => !empty($modSettings['coppaPost']) && !empty($modSettings['coppaFax']), 'post' => empty($modSettings['coppaPost']) ? '' : $modSettings['coppaPost'], 'fax' => empty($modSettings['coppaFax']) ? '' : $modSettings['coppaFax'], 'phone' => empty($modSettings['coppaPhone']) ? '' : str_replace('{PHONE_NUMBER}', $modSettings['coppaPhone'], $txt['coppa_send_by_phone']), 'id' => $_GET['member']);
     }
 }
Example #8
0
function template_groupMembership()
{
    global $context, $settings, $options, $scripturl, $modSettings, $txt;
    // The main containing header.
    echo '
		<form action="', $scripturl, '?action=profile;area=groupmembership;save" method="post" accept-charset="', $context['character_set'], '" name="creator" id="creator">
			<div class="cat_bar">
				<h3 class="catbg">
					<img src="', $settings['images_url'], '/icons/profile_sm.png" alt="" class="icon" />', $txt['profile'], '
				</h3>
			</div>
			<p class="description">', $txt['groupMembership_info'], '</p>';
    // Do we have an update message?
    if (!empty($context['update_message'])) {
        echo '
			<div class="infobox">
				', $context['update_message'], '.
			</div>';
    }
    // Requesting membership to a group?
    if (!empty($context['group_request'])) {
        echo '
			<div class="groupmembership">
				<div class="cat_bar">
					<h3 class="catbg">', $txt['request_group_membership'], '</h3>
				</div>
				<div class="roundframe">
					', $txt['request_group_membership_desc'], ':
					<textarea name="reason" rows="4" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 99%; min-width: 99%' : 'width: 99%') . ';"></textarea>
					<div class="righttext" style="margin: 0.5em 0.5% 0 0.5%;">
						<input type="hidden" name="gid" value="', $context['group_request']['id'], '" />
						<input type="submit" name="req" value="', $txt['submit_request'], '" class="button_submit" />
					</div>
				</div>
			</div>';
    } else {
        echo '
			<table border="0" width="100%" cellspacing="0" cellpadding="4" class="table_grid">
				<thead>
					<tr class="catbg">
						<th class="first_th" scope="col" ', $context['can_edit_primary'] ? ' colspan="2"' : '', '>', $txt['current_membergroups'], '</th>
						<th class="last_th" scope="col"></th>
					</tr>
				</thead>
				<tbody>';
        $alternate = true;
        foreach ($context['groups']['member'] as $group) {
            echo '
					<tr class="', $alternate ? 'windowbg' : 'windowbg2', '" id="primdiv_', $group['id'], '">';
            if ($context['can_edit_primary']) {
                echo '
						<td width="4%">
							<input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '" ', $group['is_primary'] ? 'checked="checked"' : '', ' onclick="highlightSelected(\'primdiv_' . $group['id'] . '\');" ', $group['can_be_primary'] ? '' : 'disabled="disabled"', ' class="input_radio" />
						</td>';
            }
            echo '
						<td>
							<label for="primary_', $group['id'], '"><strong>', empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>', '</strong>', !empty($group['desc']) ? '<br /><span class="smalltext">' . $group['desc'] . '</span>' : '', '</label>
						</td>
						<td width="15%" class="righttext">';
            // Can they leave their group?
            if ($group['can_leave']) {
                echo '
							<a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>';
            }
            echo '
						</td>
					</tr>';
            $alternate = !$alternate;
        }
        echo '
				</tbody>
			</table>';
        if ($context['can_edit_primary']) {
            echo '
			<div class="padding righttext">
				<input type="submit" value="', $txt['make_primary'], '" class="button_submit" />
			</div>';
        }
        // Any groups they can join?
        if (!empty($context['groups']['available'])) {
            echo '
			<br />
			<table border="0" width="100%" cellspacing="0" cellpadding="4" class="table_grid">
				<thead>
					<tr class="catbg">
						<th class="first_th" scope="col">
							', $txt['available_groups'], '
						</th>
						<th class="last_th" scope="col"></th>
					</tr>
				</thead>
				<tbody>';
            $alternate = true;
            foreach ($context['groups']['available'] as $group) {
                echo '
					<tr class="', $alternate ? 'windowbg' : 'windowbg2', '">
						<td>
							<strong>', empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>', '</strong>', !empty($group['desc']) ? '<br /><span class="smalltext">' . $group['desc'] . '</span>' : '', '
						</td>
						<td width="15%" class="lefttext">';
                if ($group['type'] == 3) {
                    echo '
							<a href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">', $txt['join_group'], '</a>';
                } elseif ($group['type'] == 2 && $group['pending']) {
                    echo '
							', $txt['approval_pending'];
                } elseif ($group['type'] == 2) {
                    echo '
							<a href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '">', $txt['request_group'], '</a>';
                }
                //				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '" />';
                echo '
						</td>
					</tr>';
                $alternate = !$alternate;
            }
            echo '
				</tbody>
			</table>';
        }
        // Javascript for the selector stuff.
        echo '
		<script type="text/javascript"><!-- // --><![CDATA[
		var prevClass = "";
		var prevDiv = "";
		function highlightSelected(box)
		{
			if (prevClass != "")
			{
				prevDiv.className = prevClass;
			}
			prevDiv = document.getElementById(box);
			prevClass = prevDiv.className;

			prevDiv.className = "highlight2";
		}';
        if (isset($context['groups']['member'][$context['primary_group']])) {
            echo '
		highlightSelected("primdiv_' . $context['primary_group'] . '");';
        }
        echo '
	// ]]></script>';
    }
    if (!empty($context['token_check'])) {
        echo '
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '" />';
    }
    echo '
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
				<input type="hidden" name="u" value="', $context['id_member'], '" />
			</form>';
}
Example #9
0
function BookOfUnknown()
{
    global $context;
    if (strpos($_GET['action'], 'mozilla') !== false && !isBrowser('gecko')) {
        redirectexit('http://www.getfirefox.com/');
    } elseif (strpos($_GET['action'], 'mozilla') !== false) {
        redirectexit('about:mozilla');
    }
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
	<head>
		<title>The Book of Unknown, ', @$_GET['verse'] == '2:18' ? '2:18' : '4:16', '</title>
		<style type="text/css">
			em
			{
				font-size: 1.3em;
				line-height: 0;
			}
		</style>
	</head>
	<body style="background-color: #444455; color: white; font-style: italic; font-family: serif;">
		<div style="margin-top: 12%; font-size: 1.1em; line-height: 1.4; text-align: center;">';
    if (@$_GET['verse'] == '2:18') {
        echo '
			Woe, it was that his name wasn\'t <em>known</em>, that he came in mystery, and was recognized by none.&nbsp;And it became to be in those days <em>something</em>.&nbsp; Something not yet <em id="unknown" name="[Unknown]">unknown</em> to mankind.&nbsp; And thus what was to be known the <em>secret project</em> began into its existence.&nbsp; Henceforth the opposition was only <em>weary</em> and <em>fearful</em>, for now their match was at arms against them.';
    } else {
        echo '
			And it came to pass that the <em>unbelievers</em> dwindled in number and saw rise of many <em>proselytizers</em>, and the opposition found fear in the face of the <em>x</em> and the <em>j</em> while those who stood with the <em>something</em> grew stronger and came together.&nbsp; Still, this was only the <em>beginning</em>, and what lay in the future was <em id="unknown" name="[Unknown]">unknown</em> to all, even those on the right side.';
    }
    echo '
		</div>
		<div style="margin-top: 2ex; font-size: 2em; text-align: right;">';
    if (@$_GET['verse'] == '2:18') {
        echo '
			from <span style="font-family: Georgia, serif;"><strong><a href="http://www.unknownbrackets.com/about:unknown" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 2:18</span>';
    } else {
        echo '
			from <span style="font-family: Georgia, serif;"><strong><a href="http://www.unknownbrackets.com/about:unknown" style="color: white; text-decoration: none; cursor: text;">The Book of Unknown</a></strong>, 4:16</span>';
    }
    echo '
		</div>
	</body>
</html>';
    obExit(false);
}
    /**
     * List all members who are awaiting approval / activation, sortable on different columns.
     *
     * What it does:
     * - It allows instant approval or activation of (a selection of) members.
     * - Called by ?action=admin;area=viewmembers;sa=browse;type=approve
     * or ?action=admin;area=viewmembers;sa=browse;type=activate.
     * - The form submits to ?action=admin;area=viewmembers;sa=approve.
     * - Requires the moderate_forum permission.
     *
     * @uses the admin_browse sub template of the ManageMembers template.
     */
    public function action_browse()
    {
        global $txt, $context, $scripturl, $modSettings;
        // Not a lot here!
        $context['page_title'] = $txt['admin_members'];
        $context['sub_template'] = 'admin_browse';
        $context['browse_type'] = isset($_REQUEST['type']) ? $_REQUEST['type'] : (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 1 ? 'activate' : 'approve');
        if (isset($context['tabs'][$context['browse_type']])) {
            $context['tabs'][$context['browse_type']]['is_selected'] = true;
        }
        // Allowed filters are those we can have, in theory.
        $context['allowed_filters'] = $context['browse_type'] == 'approve' ? array(3, 4, 5) : array(0, 2);
        $context['current_filter'] = isset($_REQUEST['filter']) && in_array($_REQUEST['filter'], $context['allowed_filters']) && !empty($context['activation_numbers'][$_REQUEST['filter']]) ? (int) $_REQUEST['filter'] : -1;
        // Sort out the different sub areas that we can actually filter by.
        $context['available_filters'] = array();
        foreach ($context['activation_numbers'] as $type => $amount) {
            // We have some of these...
            if (in_array($type, $context['allowed_filters']) && $amount > 0) {
                $context['available_filters'][] = array('type' => $type, 'amount' => $amount, 'desc' => isset($txt['admin_browse_filter_type_' . $type]) ? $txt['admin_browse_filter_type_' . $type] : '?', 'selected' => $type == $context['current_filter']);
            }
        }
        // If the filter was not sent, set it to whatever has people in it!
        if ($context['current_filter'] == -1 && !empty($context['available_filters'][0]['amount'])) {
            $context['current_filter'] = $context['available_filters'][0]['type'];
            $context['available_filters'][0]['selected'] = true;
        }
        // This little variable is used to determine if we should flag where we are looking.
        $context['show_filter'] = $context['current_filter'] != 0 && $context['current_filter'] != 3 || count($context['available_filters']) > 1;
        // The columns that can be sorted.
        $context['columns'] = array('id_member' => array('label' => $txt['admin_browse_id']), 'member_name' => array('label' => $txt['admin_browse_username']), 'email_address' => array('label' => $txt['admin_browse_email']), 'member_ip' => array('label' => $txt['admin_browse_ip']), 'date_registered' => array('label' => $txt['admin_browse_registered']));
        // Are we showing duplicate information?
        if (isset($_GET['showdupes'])) {
            $_SESSION['showdupes'] = (int) $_GET['showdupes'];
        }
        $context['show_duplicates'] = !empty($_SESSION['showdupes']);
        // Determine which actions we should allow on this page.
        if ($context['browse_type'] == 'approve') {
            // If we are approving deleted accounts we have a slightly different list... actually a mirror ;)
            if ($context['current_filter'] == 4) {
                $context['allowed_actions'] = array('reject' => $txt['admin_browse_w_approve_deletion'], 'ok' => $txt['admin_browse_w_reject']);
            } else {
                $context['allowed_actions'] = array('ok' => $txt['admin_browse_w_approve'], 'okemail' => $txt['admin_browse_w_approve'] . ' ' . $txt['admin_browse_w_email'], 'require_activation' => $txt['admin_browse_w_approve_require_activate'], 'reject' => $txt['admin_browse_w_reject'], 'rejectemail' => $txt['admin_browse_w_reject'] . ' ' . $txt['admin_browse_w_email']);
            }
        } elseif ($context['browse_type'] == 'activate') {
            $context['allowed_actions'] = array('ok' => $txt['admin_browse_w_activate'], 'okemail' => $txt['admin_browse_w_activate'] . ' ' . $txt['admin_browse_w_email'], 'delete' => $txt['admin_browse_w_delete'], 'deleteemail' => $txt['admin_browse_w_delete'] . ' ' . $txt['admin_browse_w_email'], 'remind' => $txt['admin_browse_w_remind'] . ' ' . $txt['admin_browse_w_email']);
        }
        // Create an option list for actions allowed to be done with selected members.
        $allowed_actions = '
				<option selected="selected" value="">' . $txt['admin_browse_with_selected'] . ':</option>
				<option value="" disabled="disabled">' . str_repeat('&#8212;', strlen($txt['admin_browse_with_selected'])) . '</option>';
        // ie8 fonts don't have the glyph coverage we desire
        $arrow = isBrowser('ie8') ? '&#187;&nbsp;' : '&#10148;&nbsp;';
        foreach ($context['allowed_actions'] as $key => $desc) {
            $allowed_actions .= '
				<option value="' . $key . '">' . $arrow . $desc . '</option>';
        }
        // Setup the Javascript function for selecting an action for the list.
        $javascript = '
			function onSelectChange()
			{
				if (document.forms.postForm.todo.value == "")
					return;

				var message = "";';
        // We have special messages for approving deletion of accounts - it's surprisingly logical - honest.
        if ($context['current_filter'] == 4) {
            $javascript .= '
				if (document.forms.postForm.todo.value.indexOf("reject") != -1)
					message = "' . $txt['admin_browse_w_delete'] . '";
				else
					message = "' . $txt['admin_browse_w_reject'] . '";';
        } else {
            $javascript .= '
				if (document.forms.postForm.todo.value.indexOf("delete") != -1)
					message = "' . $txt['admin_browse_w_delete'] . '";
				else if (document.forms.postForm.todo.value.indexOf("reject") != -1)
					message = "' . $txt['admin_browse_w_reject'] . '";
				else if (document.forms.postForm.todo.value == "remind")
					message = "' . $txt['admin_browse_w_remind'] . '";
				else
					message = "' . ($context['browse_type'] == 'approve' ? $txt['admin_browse_w_approve'] : $txt['admin_browse_w_activate']) . '";';
        }
        $javascript .= '
				if (confirm(message + " ' . $txt['admin_browse_warn'] . '"))
					document.forms.postForm.submit();
			}';
        $listOptions = array('id' => 'approve_list', 'items_per_page' => $modSettings['defaultMaxMembers'], 'base_href' => $scripturl . '?action=admin;area=viewmembers;sa=browse;type=' . $context['browse_type'] . (!empty($context['show_filter']) ? ';filter=' . $context['current_filter'] : ''), 'default_sort_col' => 'date_registered', 'get_items' => array('file' => SUBSDIR . '/Members.subs.php', 'function' => 'list_getMembers', 'params' => array('is_activated = {int:activated_status}', array('activated_status' => $context['current_filter']), $context['show_duplicates'])), 'get_count' => array('file' => SUBSDIR . '/Members.subs.php', 'function' => 'list_getNumMembers', 'params' => array('is_activated = {int:activated_status}', array('activated_status' => $context['current_filter']))), 'columns' => array('id_member' => array('header' => array('value' => $txt['member_id']), 'data' => array('db' => 'id_member'), 'sort' => array('default' => 'id_member', 'reverse' => 'id_member DESC')), 'user_name' => array('header' => array('value' => $txt['username']), 'data' => array('sprintf' => array('format' => '<a href="' . strtr($scripturl, array('%' => '%%')) . '?action=profile;u=%1$d">%2$s</a>', 'params' => array('id_member' => false, 'member_name' => false))), 'sort' => array('default' => 'member_name', 'reverse' => 'member_name DESC')), 'email' => array('header' => array('value' => $txt['email_address']), 'data' => array('sprintf' => array('format' => '<a href="mailto:%1$s">%1$s</a>', 'params' => array('email_address' => true))), 'sort' => array('default' => 'email_address', 'reverse' => 'email_address DESC')), 'ip' => array('header' => array('value' => $txt['ip_address']), 'data' => array('sprintf' => array('format' => '<a href="' . strtr($scripturl, array('%' => '%%')) . '?action=trackip;searchip=%1$s">%1$s</a>', 'params' => array('member_ip' => false))), 'sort' => array('default' => 'INET_ATON(member_ip)', 'reverse' => 'INET_ATON(member_ip) DESC')), 'hostname' => array('header' => array('value' => $txt['hostname']), 'data' => array('function' => create_function('$rowData', '
							return host_from_ip($rowData[\'member_ip\']);
						'), 'class' => 'smalltext')), 'date_registered' => array('header' => array('value' => $context['current_filter'] == 4 ? $txt['viewmembers_online'] : $txt['date_registered']), 'data' => array('function' => create_function('$rowData', '
							return standardTime($rowData[\'' . ($context['current_filter'] == 4 ? 'last_login' : 'date_registered') . '\']);
						')), 'sort' => array('default' => $context['current_filter'] == 4 ? 'mem.last_login DESC' : 'date_registered DESC', 'reverse' => $context['current_filter'] == 4 ? 'mem.last_login' : 'date_registered')), 'duplicates' => array('header' => array('value' => $txt['duplicates'], 'style' => 'width: 20%;'), 'data' => array('function' => create_function('$rowData', '
							global $scripturl, $txt;

							$member_links = array();
							foreach ($rowData[\'duplicate_members\'] as $member)
							{
								if ($member[\'id\'])
									$member_links[] = \'<a href="\' . $scripturl . \'?action=profile;u=\' . $member[\'id\'] . \'" \' . (!empty($member[\'is_banned\']) ? \'class="alert"\' : \'\') . \'>\' . $member[\'name\'] . \'</a>\';
								else
									$member_links[] = $member[\'name\'] . \' (\' . $txt[\'guest\'] . \')\';
							}
							return implode (\', \', $member_links);
						'), 'class' => 'smalltext')), 'check' => array('header' => array('value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />', 'class' => 'centertext'), 'data' => array('sprintf' => array('format' => '<input type="checkbox" name="todoAction[]" value="%1$d" class="input_check" />', 'params' => array('id_member' => false)), 'class' => 'centertext'))), 'javascript' => $javascript, 'form' => array('href' => $scripturl . '?action=admin;area=viewmembers;sa=approve;type=' . $context['browse_type'], 'name' => 'postForm', 'include_start' => true, 'include_sort' => true, 'hidden_fields' => array('orig_filter' => $context['current_filter'])), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '
						<a class="linkbutton" href="' . $scripturl . '?action=admin;area=viewmembers;sa=browse;showdupes=' . ($context['show_duplicates'] ? 0 : 1) . ';type=' . $context['browse_type'] . (!empty($context['show_filter']) ? ';filter=' . $context['current_filter'] : '') . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . ($context['show_duplicates'] ? $txt['dont_check_for_duplicate'] : $txt['check_for_duplicate']) . '</a>
						<select name="todo" onchange="onSelectChange();">
							' . $allowed_actions . '
						</select>
						<noscript>
							<input type="submit" value="' . $txt['go'] . '" class="right_submit" /><br class="clear_right" />
						</noscript>
					', 'class' => 'floatright')));
        // Pick what column to actually include if we're showing duplicates.
        if ($context['show_duplicates']) {
            unset($listOptions['columns']['email']);
        } else {
            unset($listOptions['columns']['duplicates']);
        }
        // Only show hostname on duplicates as it takes a lot of time.
        if (!$context['show_duplicates'] || !empty($modSettings['disableHostnameLookup'])) {
            unset($listOptions['columns']['hostname']);
        }
        // Is there any need to show filters?
        if (isset($context['available_filters'])) {
            $listOptions['list_menu'] = array('show_on' => 'top', 'links' => array());
            foreach ($context['available_filters'] as $filter) {
                $listOptions['list_menu']['links'][] = array('is_selected' => $filter['selected'], 'href' => $scripturl . '?action=admin;area=viewmembers;sa=browse;type=' . $context['browse_type'] . ';filter=' . $filter['type'], 'label' => $filter['desc'] . ' - ' . $filter['amount'] . ' ' . ($filter['amount'] == 1 ? $txt['user'] : $txt['users']));
            }
        }
        // Now that we have all the options, create the list.
        require_once SUBSDIR . '/GenericList.class.php';
        createList($listOptions);
    }
/**
 * Template for choosing group membership.
 */
function template_groupMembership()
{
    global $context, $scripturl, $txt;
    // The main containing header.
    echo '
		<form action="', $scripturl, '?action=profile;area=groupmembership;save" method="post" accept-charset="UTF-8" name="creator" id="creator">
			<h2 class="category_header hdicon cat_img_profile">
				', $txt['profile'], '
			</h2>
			<p class="description">', $txt['groupMembership_info'], '</p>';
    // Do we have an update message?
    if (!empty($context['update_message'])) {
        echo '
			<div class="successbox">
				', $context['update_message'], '.
			</div>';
    }
    // Requesting membership to a group?
    if (!empty($context['group_request'])) {
        echo '
			<div class="groupmembership">
				<h3 class="category_header">', $txt['request_group_membership'], '</h3>
				<div class="roundframe">
					', $txt['request_group_membership_desc'], ':
					<textarea name="reason" rows="4" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 100%; min-width: 100%' : 'width: 99%') . ';"></textarea>
					<div class="submitbutton">
						<input type="hidden" name="gid" value="', $context['group_request']['id'], '" />
						<input type="submit" name="req" value="', $txt['submit_request'], '" class="button_submit" />
					</div>
				</div>
			</div>';
    } else {
        echo '
			<table class="table_grid">
				<thead>
					<tr class="table_head">
						<th scope="col" ', $context['can_edit_primary'] ? ' colspan="2"' : '', '>', $txt['current_membergroups'], '</th>
						<th scope="col"></th>
					</tr>
				</thead>
				<tbody>';
        foreach ($context['groups']['member'] as $group) {
            echo '
					<tr  id="primdiv_', $group['id'], ' "class="windowbg">';
            if ($context['can_edit_primary']) {
                echo '
						<td>
							<input type="radio" name="primary" id="primary_', $group['id'], '" value="', $group['id'], '" ', $group['is_primary'] ? 'checked="checked" ' : '', $group['can_be_primary'] ? '' : 'disabled="disabled" ', ' class="input_radio" />
						</td>';
            }
            echo '
						<td>
							<label for="primary_', $group['id'], '"><strong>', empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>', '</strong>', !empty($group['desc']) ? '<br /><span class="smalltext">' . $group['desc'] . '</span>' : '', '</label>
						</td>
						<td class="grid17 righttext">';
            // Can they leave their group?
            if ($group['can_leave']) {
                echo '
							<a href="' . $scripturl . '?action=profile;save;u=' . $context['id_member'] . ';area=groupmembership;' . $context['session_var'] . '=' . $context['session_id'] . ';gid=' . $group['id'] . ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">' . $txt['leave_group'] . '</a>';
            }
            echo '
						</td>
					</tr>';
        }
        echo '
				</tbody>
			</table>';
        if ($context['can_edit_primary']) {
            echo '
			<div class="submitbutton">
				<input type="submit" value="', $txt['make_primary'], '" class="button_submit" />
			</div>';
        }
        // Any groups they can join?
        if (!empty($context['groups']['available'])) {
            echo '
			<br />
			<table class="table_grid">
				<thead>
					<tr class="table_head">
						<th scope="col">
							', $txt['available_groups'], '
						</th>
						<th scope="col"></th>
					</tr>
				</thead>
				<tbody>';
            foreach ($context['groups']['available'] as $group) {
                echo '
					<tr class="windowbg">
						<td>
							<strong>', empty($group['color']) ? $group['name'] : '<span style="color: ' . $group['color'] . '">' . $group['name'] . '</span>', '</strong>', !empty($group['desc']) ? '<br /><span class="smalltext">' . $group['desc'] . '</span>' : '', '
						</td>
						<td class="lefttext">';
                if ($group['type'] == 3) {
                    echo '
							<a class="linkbutton_right" href="', $scripturl, '?action=profile;save;u=', $context['id_member'], ';area=groupmembership;', $context['session_var'], '=', $context['session_id'], ';gid=', $group['id'], ';', $context[$context['token_check'] . '_token_var'], '=', $context[$context['token_check'] . '_token'], '">', $txt['join_group'], '</a>';
                } elseif ($group['type'] == 2 && $group['pending']) {
                    echo '
							', $txt['approval_pending'];
                } elseif ($group['type'] == 2) {
                    echo '
							<a class="linkbutton_right" href="', $scripturl, '?action=profile;u=', $context['id_member'], ';area=groupmembership;request=', $group['id'], '">', $txt['request_group'], '</a>';
                }
                // @todo
                //				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '" />';
                echo '
						</td>
					</tr>';
            }
            echo '
				</tbody>
			</table>';
        }
        // Javascript for the selector stuff.
        echo '
		<script><!-- // --><![CDATA[
			var prevClass = "",
				prevDiv = "";';
        if (isset($context['groups']['member'][$context['primary_group']])) {
            echo '
			initHighlightSelection("primdiv_' . $context['primary_group'] . '");';
        }
        echo '
		// ]]></script>';
    }
    if (!empty($context['token_check'])) {
        echo '
				<input type="hidden" name="', $context[$context['token_check'] . '_token_var'], '" value="', $context[$context['token_check'] . '_token'], '" />';
    }
    echo '
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
				<input type="hidden" name="u" value="', $context['id_member'], '" />
			</form>';
}
Example #12
0
/**
 * Simple Machines Forum (SMF)
 *
 * @package SMF
 * @author Simple Machines
 * @copyright 2012 Simple Machines
 * @license http://www.simplemachines.org/about/smf/license.php BSD
 *
 * @version 2.1 Alpha 1
 */
function template_main()
{
    global $context, $settings, $options, $txt, $scripturl, $modSettings;
    // Let them know, if their report was a success!
    if ($context['report_sent']) {
        echo '
			<div class="infobox">
				', $txt['report_sent'], '
			</div>';
    }
    // Show the anchor for the top and for the first message. If the first message is new, say so.
    echo '

			<a id="msg', $context['first_message'], '"></a>', $context['first_new_message'] ? '<a id="new"></a>' : '';
    // Is this topic also a poll?
    if ($context['is_poll']) {
        echo '
			<div id="poll">
				<div class="cat_bar">
					<h3 class="catbg">
						<img src="', $settings['images_url'], '/topic/', $context['poll']['is_locked'] ? 'normal_poll_locked' : 'normal_poll', '.png" alt="" class="icon" /> ', $txt['poll'], '
					</h3>
				</div>
				<div class="windowbg">
					<div class="content" id="poll_options">
						<h4 id="pollquestion">
							', $context['poll']['question'], '
						</h4>';
        // Are they not allowed to vote but allowed to view the options?
        if ($context['poll']['show_results'] || !$context['allow_vote']) {
            echo '
					<dl class="options">';
            // Show each option with its corresponding percentage bar.
            foreach ($context['poll']['options'] as $option) {
                echo '
						<dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt>
						<dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">';
                if ($context['allow_poll_view']) {
                    echo '
							', $option['bar_ndt'], '
							<span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>';
                }
                echo '
						</dd>';
            }
            echo '
					</dl>';
            if ($context['allow_poll_view']) {
                echo '
						<p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>';
            }
        } else {
            echo '
						<form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">';
            // Show a warning if they are allowed more than one option.
            if ($context['poll']['allowed_warning']) {
                echo '
							<p class="smallpadding">', $context['poll']['allowed_warning'], '</p>';
            }
            echo '
							<ul class="reset options">';
            // Show each option with its button - a radio likely.
            foreach ($context['poll']['options'] as $option) {
                echo '
								<li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>';
            }
            echo '
							</ul>
							<div class="submitbutton">
								<input type="submit" value="', $txt['poll_vote'], '" class="button_submit" />
								<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
							</div>
						</form>';
        }
        // Is the clock ticking?
        if (!empty($context['poll']['expire_time'])) {
            echo '
						<p><strong>', $context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on'], ':</strong> ', $context['poll']['expire_time'], '</p>';
        }
        echo '
					</div>
				</div>
			</div>
			<div id="pollmoderation">';
        template_button_strip($context['poll_buttons']);
        echo '
			</div>';
    }
    // Does this topic have some events linked to it?
    if (!empty($context['linked_calendar_events'])) {
        echo '
			<div class="linked_events">
				<div class="title_bar">
					<h3 class="titlebg headerpadding">', $txt['calendar_linked_events'], '</h3>
				</div>
				<div class="windowbg">
					<div class="content">
						<ul class="reset">';
        foreach ($context['linked_calendar_events'] as $event) {
            echo '
							<li>
								', $event['can_edit'] ? '<a href="' . $event['modify_href'] . '"> <img src="' . $settings['images_url'] . '/icons/calendar_modify.png" alt="" title="' . $txt['modify'] . '" class="edit_event" /></a> ' : '', '<strong>', $event['title'], '</strong>: ', $event['start_date'], $event['start_date'] != $event['end_date'] ? ' - ' . $event['end_date'] : '', '
							</li>';
        }
        echo '
						</ul>
					</div>
				</div>
			</div>';
    }
    // Show the page index... "Pages: [1]".
    echo '
			<div class="pagesection">
				', template_button_strip($context['normal_buttons'], 'right'), '
				', !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . '<a href="#bot" class="topbottom floatleft">' . $txt['go_down'] . '</a>' : '', '
				<div class="pagelinks floatleft">
					', $context['page_index'], '
				</div>
			</div>';
    // Show the topic information - icon, subject, etc.
    echo '
			<div id="forumposts">
				<div class="cat_bar">
					<h3 class="catbg">
						<img src="', $settings['images_url'], '/topic/', $context['class'], '.png" alt="" />
						', $txt['topic'], ': ', $context['subject'], '&nbsp;<span>(', $txt['read'], ' ', $context['num_views'], ' ', $txt['times'], ')</span>
						<span class="nextlinks floatright">', $context['previous_next'], '</span>
					</h3>
				</div>';
    echo '
				<form action="', $scripturl, '?action=quickmod2;topic=', $context['current_topic'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;" onsubmit="return oQuickModify.bInEditMode ? oQuickModify.modifySave(\'' . $context['session_id'] . '\', \'' . $context['session_var'] . '\') : false">';
    $ignoredMsgs = array();
    $removableMessageIDs = array();
    $alternate = false;
    // Get all the messages...
    while ($message = $context['get_message']()) {
        $ignoring = false;
        $alternate = !$alternate;
        if ($message['can_remove']) {
            $removableMessageIDs[] = $message['id'];
        }
        // Are we ignoring this message?
        if (!empty($message['is_ignored'])) {
            $ignoring = true;
            $ignoredMsgs[] = $message['id'];
        }
        // Show the message anchor and a "new" anchor if this message is new.
        if ($message['id'] != $context['first_message']) {
            echo '
				<a id="msg', $message['id'], '"></a>', $message['first_new'] ? '<a id="new"></a>' : '';
        }
        echo '
				<div class="', $message['approved'] ? $message['alternate'] == 0 ? 'windowbg' : 'windowbg2' : 'approvebg', '">
					<div class="post_wrapper">';
        // Show information about the poster of this message.
        echo '
						<div class="poster">
							<ul class="dropmenu">
								<li>
									<h4>';
        // Show a link to the member's profile.
        echo '
										<a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">
											<span style="padding: 6px; display: block;">', $message['member']['name'], '</span>';
        // Show avatars, images, etc.?
        if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image'])) {
            echo '

											', $message['member']['avatar']['image'], '';
        }
        echo '
										</a>
									</h4>';
        // [WIP] The new member info dropdown starts here. Note that conditionals have not been fully checked yet.
        echo '
									<ul class="smalltext" id="msg_', $message['id'], '_extra_info"', $ignoring ? ' style="display:none;"' : '', '>';
        // Don't show these things for guests.
        if (!$message['member']['is_guest']) {
            // Show the post group if and only if they have no other group or the option is on, and they are in a post group.
            if ((empty($settings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '') {
                echo '
										<li class="postgroup">', $message['member']['post_group'], '</li>';
            }
            // Show how many posts they have made.
            if (!isset($context['disabled_fields']['posts'])) {
                echo '
										<li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
            }
            // Is karma display enabled?  Total or +/-?
            if ($modSettings['karmaMode'] == '1') {
                echo '
										<li class="karma">', $modSettings['karmaLabel'], ' ', $message['member']['karma']['good'] - $message['member']['karma']['bad'], '</li>';
            } elseif ($modSettings['karmaMode'] == '2') {
                echo '
										<li class="karma">', $modSettings['karmaLabel'], ' +', $message['member']['karma']['good'], '/-', $message['member']['karma']['bad'], '</li>';
            }
            // Is this user allowed to modify this member's karma?
            if ($message['member']['karma']['allow']) {
                echo '
										<li class="karma_allow">
											<a href="', $scripturl, '?action=modifykarma;sa=applaud;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.' . $context['start'], ';m=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaApplaudLabel'], '</a>
											<a href="', $scripturl, '?action=modifykarma;sa=smite;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';m=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaSmiteLabel'], '</a>
										</li>';
            }
            // Show the member's gender icon?
            if (!empty($settings['show_gender']) && $message['member']['gender']['image'] != '' && !isset($context['disabled_fields']['gender'])) {
                echo '
										<li class="gender">', $txt['gender'], ': ', $message['member']['gender']['image'], '</li>';
            }
            // Show their personal text?
            if (!empty($settings['show_blurb']) && $message['member']['blurb'] != '') {
                echo '
										<li class="blurb">', $message['member']['blurb'], '</li>';
            }
            // Any custom fields to show as icons?
            if (!empty($message['member']['custom_fields'])) {
                $shown = false;
                foreach ($message['member']['custom_fields'] as $custom) {
                    if ($custom['placement'] != 1 || empty($custom['value'])) {
                        continue;
                    }
                    if (empty($shown)) {
                        $shown = true;
                        echo '
										<li class="im_icons">
											<ol>';
                    }
                    echo '
												<li>', $custom['value'], '</li>';
                }
                if ($shown) {
                    echo '
											</ol>
										</li>';
                }
            }
            // This shows the popular messaging icons.
            if ($message['member']['has_messenger'] && $message['member']['can_view_profile']) {
                echo '
										<li class="im_icons">
											<hr />
											<ol>
												', !empty($message['member']['icq']['link']) ? '<li>' . $message['member']['icq']['link'] . '</li>' : '', '
												', !empty($message['member']['msn']['link']) ? '<li>' . $message['member']['msn']['link'] . '</li>' : '', '
												', !empty($message['member']['aim']['link']) ? '<li>' . $message['member']['aim']['link'] . '</li>' : '', '
												', !empty($message['member']['yim']['link']) ? '<li>' . $message['member']['yim']['link'] . '</li>' : '', '
											</ol>
										</li>';
            }
            // Show the website and email address buttons.
            if ($message['member']['show_profile_buttons']) {
                echo '
										<li class="profile">
											<ol>';
                // Don't show an icon if they haven't specified a website.
                if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website'])) {
                    echo '
												<li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', $settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/www_sm.png" alt="' . $message['member']['website']['title'] . '" />' : $txt['www'], '</a></li>';
                }
                // Don't show the email address if they want it hidden.
                if (in_array($message['member']['show_email'], array('yes', 'yes_permission_override', 'no_through_forum')) && $context['can_send_email']) {
                    echo '
												<li><a href="', $scripturl, '?action=emailuser;sa=email;msg=', $message['id'], '" rel="nofollow">', $settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.png" alt="' . $txt['email'] . '" title="' . $txt['email'] . '" />' : $txt['email'], '</a></li>';
                }
                echo '
											</ol>
										</li>';
            }
            // Any custom fields for standard placement?
            if (!empty($message['member']['custom_fields'])) {
                foreach ($message['member']['custom_fields'] as $custom) {
                    if (empty($custom['placement']) || empty($custom['value'])) {
                        echo '
										<li class="custom">', $custom['title'], ': ', $custom['value'], '</li>';
                    }
                }
            }
        } elseif (!empty($message['member']['email']) && in_array($message['member']['show_email'], array('yes', 'yes_permission_override', 'no_through_forum')) && $context['can_send_email']) {
            echo '
										<li class="email"><a href="', $scripturl, '?action=emailuser;sa=email;msg=', $message['id'], '" rel="nofollow">', $settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.png" alt="' . $txt['email'] . '" title="' . $txt['email'] . '" />' : $txt['email'], '</a></li>';
        }
        // Stuff for the staff to wallop them with.
        // Maybe they want to report this post to the moderator(s)?
        if ($context['can_report_moderator']) {
            echo '
										<li class="report_link"><hr /><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li>';
        }
        // Can we issue a warning because of this post?  Remember, we can't give guests warnings.
        if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest']) {
            echo '
										<li class="issue_warning"><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><img src="', $settings['images_url'], '/warn.png" alt="', $txt['issue_warning_post'], '" title="', $txt['issue_warning_post'], '" /></a></li>';
        }
        //echo '
        //						<img class="centericon" src="', $settings['images_url'], '/ip.png" alt="" />';
        // Show the IP to this user for this post - because you can moderate?
        if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip'])) {
            echo '
										<li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>';
        } elseif ($message['can_see_ip']) {
            echo '
										<li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>';
        } elseif (!$context['user']['is_guest']) {
            echo '
										<li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>';
        } else {
            echo '
										<li class="poster_ip">', $txt['logged'], '</li>';
        }
        // Done with the information about the poster... on to the post itself.
        echo '
									</ul>
								</li>';
        // Show the post group icons, but not for guests.
        if (!$message['member']['is_guest']) {
            echo '
								<li class="icons">', $message['member']['group_icons'], '</li>';
        }
        // Show the member's primary group (like 'Administrator') if they have one.
        if (!empty($message['member']['group'])) {
            echo '
								<li class="membergroup">', $message['member']['group'], '</li>';
        }
        // Show the member's custom title, if they have one.
        if (!empty($message['member']['title'])) {
            echo '
								<li class="title">', $message['member']['title'], '</li>';
        }
        // Show online and offline buttons? PHP could do with a little bit of cleaning up here for brevity, but it works.
        // The plan is to make these buttons act sensibly, and link to your own inbox in your own posts (with new PM notification).
        // Still has a little bit of hard-coded text. This may be a place where translators should be able to write inclusive strings,
        // instead of dealing with $txt['by'] etc in the markup. Must be brief to work, anyway. Cannot ramble on at all.
        if ($context['can_send_pm'] && $message['is_message_author']) {
            echo '
								<li class="poster_online"><a href="', $scripturl, '?action=pm">', $txt['pm_short'], ' ', $context['user']['unread_messages'] > 0 ? '[<strong>' . $context['user']['unread_messages'] . '</strong>]' : '', '</a></li>';
        }
        if ($context['can_send_pm'] && !$message['is_message_author'] && !$message['member']['is_guest']) {
            if (!empty($modSettings['onlineEnable'])) {
                echo '
								<li class="poster_online"><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $message['member']['name'] . ' is online' : $message['member']['name'] . ' is offline', '">', $txt['send_message'], ' <img src="' . $message['member']['online']['image_href'] . '" alt="" /></a></li>';
            } else {
                echo '
								<li class="poster_online"><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '">', $txt['send_message'], '</a></li>';
            }
        }
        if (!$context['can_send_pm'] && !empty($modSettings['onlineEnable'])) {
            echo '
								<li class="poster_online">', $message['member']['online']['is_online'] ? $txt['online'] : $txt['offline'], '<img src="' . $message['member']['online']['image_href'] . '" alt="" /></li>';
        }
        // Are we showing the warning status?
        // Don't show these things for guests.
        if (!$message['member']['is_guest'] && $message['member']['can_see_warning']) {
            echo '
								<li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<img src="', $settings['images_url'], '/warning_', $message['member']['warning_status'], '.png" alt="', $txt['user_warn_' . $message['member']['warning_status']], '" />', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>';
        }
        echo '
							</ul>';
        echo '
						</div>
						<div class="postarea">
							<div class="keyinfo">
								<div class="messageicon" ', $message['icon_url'] !== $settings['images_url'] . '/post/xx.png' ? '' : 'style="position: absolute; z-index: -1;"', '>
									<img src="', $message['icon_url'] . '" alt=""', $message['can_modify'] ? ' id="msg_icon_' . $message['id'] . '"' : '', ' />
								</div>
								<h5 id="subject_', $message['id'], '">
									<a href="', $message['href'], '" rel="nofollow" title="', !empty($message['counter']) ? $txt['reply_noun'] . ' #' . $message['counter'] : '', ' - ', $message['subject'], '">', $message['time'], '</a>';
        // Show "<< Last Edit: Time by Person >>" if this post was edited.
        if ($settings['show_modify'] && !empty($message['modified']['name'])) {
            echo '
									<span class="smalltext modified" id="modified_', $message['id'], '">
										', $txt['last_edit'], ': ', $message['modified']['time'], ' ', $txt['by'], ' ', $message['modified']['name'], '
									</span>';
        }
        echo '
								</h5>
								<div id="msg_', $message['id'], '_quick_mod"', $ignoring ? ' style="display:none;"' : '', '></div>
							</div>';
        // Ignoring this user? Hide the post.
        if ($ignoring) {
            echo '
							<div id="msg_', $message['id'], '_ignored_prompt">
								', $txt['ignoring_user'], '
								<a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
							</div>';
        }
        // Show the post itself, finally!
        echo '
							<div class="post">';
        if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id']) {
            echo '
								<div class="approve_post">
									', $txt['post_awaiting_approval'], '
								</div>';
        }
        echo '
								<div class="inner" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>', $message['body'], '</div>
							</div>';
        // Assuming there are attachments...
        if (!empty($message['attachment'])) {
            echo '
							<div id="msg_', $message['id'], '_footer" class="attachments"', $ignoring ? ' style="display:none;"' : '', '>';
            $last_approved_state = 1;
            $attachments_per_line = 4;
            $i = 0;
            foreach ($message['attachment'] as $attachment) {
                // Show a special box for unapproved attachments...
                if ($attachment['is_approved'] != $last_approved_state) {
                    $last_approved_state = 0;
                    echo '
								<fieldset>
									<legend>', $txt['attach_awaiting_approve'];
                    if ($context['can_approve']) {
                        echo '
										&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]';
                    }
                    echo '
									</legend>';
                }
                echo '
									<div class="floatleft">';
                if ($attachment['is_image']) {
                    echo '
										<div class="attachments_top">';
                    if ($attachment['thumbnail']['has_thumb']) {
                        echo '
											<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" /></a>';
                    } else {
                        echo '
											<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '"/>';
                    }
                    echo '
										</div>';
                }
                echo '
										<div class="attachments_bot">
											<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*" />&nbsp;' . $attachment['name'] . '</a> ';
                if (!$attachment['is_approved'] && $context['can_approve']) {
                    echo '
											[<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>]&nbsp;|&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] ';
                }
                echo '
											<br />', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br />' . $txt['attach_viewed'] : '<br />' . $txt['attach_downloaded']) . ' ' . $attachment['downloads'] . ' ' . $txt['attach_times'] . '
										</div>';
                echo '
									</div>';
                // Next attachment line ?
                if (++$i % $attachments_per_line === 0) {
                    echo '
									<hr />';
                }
            }
            // If we had unapproved attachments clean up.
            if ($last_approved_state == 0) {
                echo '
								</fieldset>';
            }
            echo '
							</div>';
        }
        echo '
						</div>';
        // Show the quickbuttons, for various operations on posts.
        if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
            echo '
						<ul class="quickbuttons">';
        }
        // Maybe we can approve it, maybe we should?
        if ($message['can_approve']) {
            echo '
							<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"  class="approve_button">', $txt['approve'], '</a></li>';
        }
        // Can they reply? Have they turned on quick reply?
        if ($context['can_quote'] && !empty($options['display_quick_reply'])) {
            echo '
							<li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');" class="quote_button">', $txt['quote'], '</a></li>';
        } elseif ($context['can_quote']) {
            echo '
							<li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" class="quote_button">', $txt['quote'], '</a></li>';
        }
        // Can the user modify the contents of this post?  Show the modify inline image.
        if ($message['can_modify']) {
            echo '
							<li class="quick_edit"><img src="', $settings['images_url'], '/icons/modify_inline.png" alt="', $txt['modify_msg'], '" title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" style="cursor: pointer; display: none; margin: 0 0 0 0;" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\')" />', $txt['quick_edit'], '</li>';
        }
        // Can the user modify the contents of this post?
        if ($message['can_modify']) {
            echo '
							<li class="post_options">', $txt['post_options'], '';
        }
        echo '
								<ul>';
        // Can the user modify the contents of this post?
        if ($message['can_modify']) {
            echo '
									<li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '" class="modify_button">', $txt['modify'], '</a></li>';
        }
        // How about... even... remove it entirely?!
        if ($message['can_remove']) {
            echo '
									<li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['remove_message'], '?\');" class="remove_button">', $txt['remove'], '</a></li>';
        }
        // What about splitting it off the rest of the topic?
        if ($context['can_split'] && !empty($context['real_num_replies'])) {
            echo '
									<li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '" class="split_button">', $txt['split'], '</a></li>';
        }
        // Can we restore topics?
        if ($context['can_restore_msg']) {
            echo '
									<li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" class="restore_button">', $txt['restore_message'], '</a></li>';
        }
        // Maybe we can unapprove it?
        if ($message['can_unapprove']) {
            echo '
									<li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"  class="unapprove_button">', $txt['unapprove'], '</a></li>';
        }
        echo '
								</ul>
							</li>';
        // Show a checkbox for quick moderation?
        if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove']) {
            echo '
							<li class="inline_mod_check" style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>';
        }
        if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg']) {
            echo '
						</ul>';
        }
        echo '
						<div class="moderatorbar">';
        // Are there any custom profile fields for above the signature?
        if (!empty($message['member']['custom_fields'])) {
            $shown = false;
            foreach ($message['member']['custom_fields'] as $custom) {
                if ($custom['placement'] != 2 || empty($custom['value'])) {
                    continue;
                }
                if (empty($shown)) {
                    $shown = true;
                    echo '
							<div class="custom_fields_above_signature">
								<ul class="reset nolist">';
                }
                echo '
									<li>', $custom['value'], '</li>';
            }
            if ($shown) {
                echo '
								</ul>
							</div>';
            }
        }
        // Show the member's signature?
        if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled']) {
            echo '
							<div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>', $message['member']['signature'], '</div>';
        }
        echo '
						</div>
					</div>
				</div>
				<hr class="post_separator" />';
    }
    echo '
				</form>
			</div>';
    // Show the page index... "Pages: [1]".
    echo '
			<div class="pagesection">
				', template_button_strip($context['normal_buttons'], 'right'), '
				', !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . '<a href="#top" class="topbottom floatleft">' . $txt['go_up'] . '</a>' : '', '
				<div class="pagelinks floatleft">
					', $context['page_index'], '
				</div>
			</div>';
    // Show the lower breadcrumbs.
    theme_linktree();
    echo '
			<div id="moderationbuttons">', template_button_strip($context['mod_buttons'], 'bottom', array('id' => 'moderationbuttons_strip')), '</div>';
    // Show the jumpto box, or actually...let Javascript do it.
    echo '
			<div class="plainbox" id="display_jump_to">&nbsp;</div>';
    if ($context['can_reply'] && !empty($options['display_quick_reply'])) {
        echo '
			<a id="quickreply"></a>
			<div class="tborder" id="quickreplybox">
				<div class="cat_bar">
					<h3 class="catbg">
						<a href="javascript:oQuickReply.swap();"><img src="', $settings['images_url'], '/', $options['display_quick_reply'] > 1 ? 'collapse' : 'expand', '.png" alt="+" id="quickReplyExpand" class="icon" /></a>
						<a href="javascript:oQuickReply.swap();">', $txt['quick_reply'], '</a>
					</h3>
				</div>
				<div id="quickReplyOptions"', $options['display_quick_reply'] > 1 ? '' : ' style="display: none"', '>
					<div class="roundframe">
						<p class="smalltext lefttext">', $txt['quick_reply_desc'], '</p>
						', $context['is_locked'] ? '<p class="alert smalltext">' . $txt['quick_reply_warning'] . '</p>' : '', $context['oldTopicError'] ? '<p class="alert smalltext">' . sprintf($txt['error_old_topic'], $modSettings['oldTopicDays']) . '</p>' : '', '
						', $context['can_reply_approved'] ? '' : '<em>' . $txt['wait_for_approval'] . '</em>', '
						', !$context['can_reply_approved'] && $context['require_verification'] ? '<br />' : '', '
						<form action="', $scripturl, '?board=', $context['current_board'], ';action=post2" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify" onsubmit="submitonce(this);" style="margin: 0;">
							<input type="hidden" name="topic" value="', $context['current_topic'], '" />
							<input type="hidden" name="subject" value="', $context['response_prefix'], $context['subject'], '" />
							<input type="hidden" name="icon" value="xx" />
							<input type="hidden" name="from_qr" value="1" />
							<input type="hidden" name="notify" value="', $context['is_marked_notify'] || !empty($options['auto_notify']) ? '1' : '0', '" />
							<input type="hidden" name="not_approved" value="', !$context['can_reply_approved'], '" />
							<input type="hidden" name="goback" value="', empty($options['return_to_post']) ? '0' : '1', '" />
							<input type="hidden" name="last_msg" value="', $context['topic_last_message'], '" />
							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
							<input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" />';
        // Guests just need more.
        if ($context['user']['is_guest']) {
            echo '
							<strong>', $txt['name'], ':</strong> <input type="text" name="guestname" value="', $context['name'], '" size="25" class="input_text" tabindex="', $context['tabindex']++, '" />
							<strong>', $txt['email'], ':</strong> <input type="text" name="email" value="', $context['email'], '" size="25" class="input_text" tabindex="', $context['tabindex']++, '" /><br />';
        }
        // Is visual verification enabled?
        if ($context['require_verification']) {
            echo '
							<strong>', $txt['verification'], ':</strong>', template_control_verification($context['visual_verification_id'], 'quick_reply'), '<br />';
        }
        if ($options['display_quick_reply'] < 3) {
            echo '
							<div class="quickReplyContent">
								<textarea cols="600" rows="7" name="message" tabindex="', $context['tabindex']++, '"></textarea>
							</div>';
        } else {
            // Show the actual posting area...
            if ($context['show_bbc']) {
                echo '
							<div id="bbcBox_message"></div>';
            }
            // What about smileys?
            if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) {
                echo '
							<div id="smileyBox_message"></div>';
            }
            echo '
							', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), '
							<script type="text/javascript"><!-- // --><![CDATA[
								function insertQuoteFast(messageid)
								{
									if (window.XMLHttpRequest)
										getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=quotefast;quote=\' + messageid + \';xml;pb=', $context['post_box_name'], ';mode=\' + (oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled ? 1 : 0), onDocReceived);
									else
										reqWin(smf_prepareScriptUrl(smf_scripturl) + \'action=quotefast;quote=\' + messageid + \';pb=', $context['post_box_name'], ';mode=\' + (oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled ? 1 : 0), 240, 90);
									return false;
								}
								function onDocReceived(XMLDoc)
								{
									var text = \'\';
									for (var i = 0, n = XMLDoc.getElementsByTagName(\'quote\')[0].childNodes.length; i < n; i++)
										text += XMLDoc.getElementsByTagName(\'quote\')[0].childNodes[i].nodeValue;
									oEditorHandle_', $context['post_box_name'], '.insertText(text, false, true);

									ajax_indicator(false);
								}
							// ]]></script>';
        }
        echo '
							<div class="padding">
								<input type="submit" name="post" value="', $txt['post'], '" onclick="return submitThisOnce(this);" accesskey="s" tabindex="', $context['tabindex']++, '" class="button_submit" />
								<input type="submit" name="preview" value="', $txt['preview'], '" onclick="return submitThisOnce(this);" accesskey="p" tabindex="', $context['tabindex']++, '" class="button_submit" />';
        if ($context['show_spellchecking']) {
            echo '
								<input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'postmodify\', \'message\');" tabindex="', $context['tabindex']++, '" class="button_submit" />';
        }
        if ($context['drafts_save'] && !empty($options['drafts_show_saved_enabled'])) {
            echo '
								<input type="submit" name="save_draft" value="', $txt['draft_save'], '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" tabindex="', $context['tabindex']++, '" class="button_submit" />
								<input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '" />';
        }
        if (!empty($context['drafts_autosave']) && !empty($options['drafts_autosave_enabled'])) {
            echo '
								<div class="clear righttext padding"><span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon" />&nbsp;</span><span id="draft_lastautosave" ></span></div>';
        }
        echo '
							</div>
						</form>
					</div>
				</div>
			</div>';
    } else {
        echo '
		<br class="clear" />';
    }
    if (!empty($context['drafts_autosave']) && !empty($options['drafts_autosave_enabled'])) {
        echo '
			<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/drafts.js?alp21"></script>
			<script type="text/javascript"><!-- // --><![CDATA[
				var oDraftAutoSave = new smf_DraftAutoSave({
					sSelf: \'oDraftAutoSave\',
					sLastNote: \'draft_lastautosave\',
					sLastID: \'id_draft\',', !empty($context['post_box_name']) ? '
					sSceditorID: \'' . $context['post_box_name'] . '\',' : '', '
					sType: \'', !empty($options['display_quick_reply']) && $options['display_quick_reply'] > 2 ? 'quick' : 'quick', '\',
					iBoard: ', empty($context['current_board']) ? 0 : $context['current_board'], ',
					iFreq: ', empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000, '
				});
			// ]]></script>';
    }
    if ($context['show_spellchecking']) {
        echo '
			<form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"><input type="hidden" name="spellstring" value="" /></form>
				<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/spellcheck.js"></script>';
    }
    echo '
				<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/topic.js"></script>
				<script type="text/javascript"><!-- // --><![CDATA[';
    if (!empty($options['display_quick_reply'])) {
        echo '
					var oQuickReply = new QuickReply({
						bDefaultCollapsed: ', !empty($options['display_quick_reply']) && $options['display_quick_reply'] > 1 ? 'false' : 'true', ',
						iTopicId: ', $context['current_topic'], ',
						iStart: ', $context['start'], ',
						sScriptUrl: smf_scripturl,
						sImagesUrl: smf_images_url,
						sContainerId: "quickReplyOptions",
						sImageId: "quickReplyExpand",
						sImageCollapsed: "collapse.png",
						sImageExpanded: "expand.png",
						sJumpAnchor: "quickreply",
						bIsFull: ', !empty($options['display_quick_reply']) && $options['display_quick_reply'] > 2 ? 'true' : 'false', '
					});';
    }
    if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $context['can_remove_post']) {
        echo '
					var oInTopicModeration = new InTopicModeration({
						sSelf: \'oInTopicModeration\',
						sCheckboxContainerMask: \'in_topic_mod_check_\',
						aMessageIds: [\'', implode('\', \'', $removableMessageIDs), '\'],
						sSessionId: smf_session_id,
						sSessionVar: smf_session_var,
						sButtonStrip: \'moderationbuttons\',
						sButtonStripDisplay: \'moderationbuttons_strip\',
						bUseImageButton: false,
						bCanRemove: ', $context['can_remove_post'] ? 'true' : 'false', ',
						sRemoveButtonLabel: \'', $txt['quickmod_delete_selected'], '\',
						sRemoveButtonImage: \'delete_selected.png\',
						sRemoveButtonConfirm: \'', $txt['quickmod_confirm'], '\',
						bCanRestore: ', $context['can_restore_msg'] ? 'true' : 'false', ',
						sRestoreButtonLabel: \'', $txt['quick_mod_restore'], '\',
						sRestoreButtonImage: \'restore_selected.png\',
						sRestoreButtonConfirm: \'', $txt['quickmod_confirm'], '\',
						bCanSplit: ', $context['can_split'] ? 'true' : 'false', ',
						sSplitButtonLabel: \'', $txt['quickmod_split_selected'], '\',
						sSplitButtonImage: \'split_selected.png\',
						sSplitButtonConfirm: \'', $txt['quickmod_confirm'], '\',
						sFormId: \'quickModForm\'
					});';
    }
    echo '
					$(".quick_edit").css("display", "inline");
					if (\'XMLHttpRequest\' in window)
					{
						var oQuickModify = new QuickModify({
							sScriptUrl: smf_scripturl,
							bShowModify: ', $settings['show_modify'] ? 'true' : 'false', ',
							iTopicId: ', $context['current_topic'], ',
							sTemplateBodyEdit: ', JavaScriptEscape('
								<div id="quick_edit_body_container" style="width: 90%">
									<div id="error_box" style="padding: 4px;" class="error"></div>
									<textarea class="editor" name="message" rows="12" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 100%; min-width: 100%' : 'width: 100%') . '; margin-bottom: 10px;" tabindex="' . $context['tabindex']++ . '">%body%</textarea><br />
									<input type="hidden" name="\' + smf_session_var + \'" value="\' + smf_session_id + \'" />
									<input type="hidden" name="topic" value="' . $context['current_topic'] . '" />
									<input type="hidden" name="msg" value="%msg_id%" />
									<div class="righttext">
										<input type="submit" name="post" value="' . $txt['save'] . '" tabindex="' . $context['tabindex']++ . '" onclick="return oQuickModify.modifySave(\'' . $context['session_id'] . '\', \'' . $context['session_var'] . '\');" accesskey="s" class="button_submit" />&nbsp;&nbsp;' . ($context['show_spellchecking'] ? '<input type="button" value="' . $txt['spell_check'] . '" tabindex="' . $context['tabindex']++ . '" onclick="spellCheck(\'quickModForm\', \'message\');" class="button_submit" />&nbsp;&nbsp;' : '') . '<input type="submit" name="cancel" value="' . $txt['modify_cancel'] . '" tabindex="' . $context['tabindex']++ . '" onclick="return oQuickModify.modifyCancel();" class="button_submit" />
									</div>
								</div>'), ',
							sTemplateSubjectEdit: ', JavaScriptEscape('<input type="text" style="width: 90%;" name="subject" value="%subject%" size="80" maxlength="80" tabindex="' . $context['tabindex']++ . '" class="input_text" />'), ',
							sTemplateBodyNormal: ', JavaScriptEscape('%body%'), ',
							sTemplateSubjectNormal: ', JavaScriptEscape('<a href="' . $scripturl . '?topic=' . $context['current_topic'] . '.msg%msg_id%#msg%msg_id%" rel="nofollow">%subject%</a>'), ',
							sTemplateTopSubject: ', JavaScriptEscape($txt['topic'] . ': %subject% &nbsp;(' . $txt['read'] . ' ' . $context['num_views'] . ' ' . $txt['times'] . ')'), ',
							sErrorBorderStyle: ', JavaScriptEscape('1px solid red'), $context['can_reply'] && !empty($options['display_quick_reply']) ? ',
							sFormRemoveAccessKeys: \'postmodify\'' : '', '
						});

						aJumpTo[aJumpTo.length] = new JumpTo({
							sContainerId: "display_jump_to",
							sJumpToTemplate: "<label class=\\"smalltext\\" for=\\"%select_id%\\">', $context['jump_to']['label'], ':<" + "/label> %dropdown_list%",
							iCurBoardId: ', $context['current_board'], ',
							iCurBoardChildLevel: ', $context['jump_to']['child_level'], ',
							sCurBoardName: "', $context['jump_to']['board_name'], '",
							sBoardChildLevelIndicator: "==",
							sBoardPrefix: "=> ",
							sCatSeparator: "-----------------------------",
							sCatPrefix: "",
							sGoButtonLabel: "', $txt['go'], '"
						});

						aIconLists[aIconLists.length] = new IconList({
							sBackReference: "aIconLists[" + aIconLists.length + "]",
							sIconIdPrefix: "msg_icon_",
							sScriptUrl: smf_scripturl,
							bShowModify: ', $settings['show_modify'] ? 'true' : 'false', ',
							iBoardId: ', $context['current_board'], ',
							iTopicId: ', $context['current_topic'], ',
							sSessionId: smf_session_id,
							sSessionVar: smf_session_var,
							sLabelIconList: "', $txt['message_icon'], '",
							sBoxBackground: "transparent",
							sBoxBackgroundHover: "#ffffff",
							iBoxBorderWidthHover: 1,
							sBoxBorderColorHover: "#adadad" ,
							sContainerBackground: "#ffffff",
							sContainerBorder: "1px solid #adadad",
							sItemBorder: "1px solid #ffffff",
							sItemBorderHover: "1px dotted gray",
							sItemBackground: "transparent",
							sItemBackgroundHover: "#e0e0f0"
						});
					}';
    if (!empty($ignoredMsgs)) {
        echo '
					ignore_toggles([', implode(', ', $ignoredMsgs), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');';
    }
    echo '
				// ]]></script>';
}
Example #13
0
/**
 * Downloads an attachment or avatar, and increments the download count.
 * It requires the view_attachments permission. (not for avatars!)
 * It disables the session parser, and clears any previous output.
 * It depends on the attachmentUploadDir setting being correct.
 * It is accessed via the query string ?action=dlattach.
 * Views to attachments and avatars do not increase hits and are not logged in the "Who's Online" log.
 */
function Download()
{
    global $txt, $modSettings, $user_info, $scripturl, $context, $sourcedir, $topic, $smcFunc;
    // Some defaults that we need.
    $context['character_set'] = empty($modSettings['global_character_set']) ? empty($txt['lang_character_set']) ? 'ISO-8859-1' : $txt['lang_character_set'] : $modSettings['global_character_set'];
    $context['utf8'] = $context['character_set'] === 'UTF-8';
    $context['no_last_modified'] = true;
    // Make sure some attachment was requested!
    if (!isset($_REQUEST['attach']) && !isset($_REQUEST['id'])) {
        fatal_lang_error('no_access', false);
    }
    $_REQUEST['attach'] = isset($_REQUEST['attach']) ? (int) $_REQUEST['attach'] : (int) $_REQUEST['id'];
    if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'avatar') {
        $request = $smcFunc['db_query']('', '
			SELECT id_folder, filename, file_hash, fileext, id_attach, attachment_type, mime_type, approved, id_member
			FROM {db_prefix}attachments
			WHERE id_attach = {int:id_attach}
				AND id_member > {int:blank_id_member}
			LIMIT 1', array('id_attach' => $_REQUEST['attach'], 'blank_id_member' => 0));
        $_REQUEST['image'] = true;
    } else {
        // This checks only the current board for $board/$topic's permissions.
        isAllowedTo('view_attachments');
        // Make sure this attachment is on this board.
        // @todo: We must verify that $topic is the attachment's topic, or else the permission check above is broken.
        $request = $smcFunc['db_query']('', '
			SELECT a.id_folder, a.filename, a.file_hash, a.fileext, a.id_attach, a.attachment_type, a.mime_type, a.approved, m.id_member
			FROM {db_prefix}attachments AS a
				INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg AND m.id_topic = {int:current_topic})
				INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board AND {query_see_board})
			WHERE a.id_attach = {int:attach}
			LIMIT 1', array('attach' => $_REQUEST['attach'], 'current_topic' => $topic));
    }
    if ($smcFunc['db_num_rows']($request) == 0) {
        fatal_lang_error('no_access', false);
    }
    list($id_folder, $real_filename, $file_hash, $file_ext, $id_attach, $attachment_type, $mime_type, $is_approved, $id_member) = $smcFunc['db_fetch_row']($request);
    $smcFunc['db_free_result']($request);
    // If it isn't yet approved, do they have permission to view it?
    if (!$is_approved && ($id_member == 0 || $user_info['id'] != $id_member) && ($attachment_type == 0 || $attachment_type == 3)) {
        isAllowedTo('approve_posts');
    }
    // Update the download counter (unless it's a thumbnail).
    if ($attachment_type != 3) {
        $smcFunc['db_query']('attach_download_increase', '
			UPDATE LOW_PRIORITY {db_prefix}attachments
			SET downloads = downloads + 1
			WHERE id_attach = {int:id_attach}', array('id_attach' => $id_attach));
    }
    $filename = getAttachmentFilename($real_filename, $_REQUEST['attach'], $id_folder, false, $file_hash);
    // This is done to clear any output that was made before now.
    ob_end_clean();
    if (!empty($modSettings['enableCompressedOutput']) && @filesize($filename) <= 4194304 && in_array($file_ext, array('txt', 'html', 'htm', 'js', 'doc', 'docx', 'rtf', 'css', 'php', 'log', 'xml', 'sql', 'c', 'java'))) {
        @ob_start('ob_gzhandler');
    } else {
        ob_start();
        header('Content-Encoding: none');
    }
    // No point in a nicer message, because this is supposed to be an attachment anyway...
    if (!file_exists($filename)) {
        loadLanguage('Errors');
        header((preg_match('~HTTP/1\\.[01]~i', $_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0') . ' 404 Not Found');
        header('Content-Type: text/plain; charset=' . (empty($context['character_set']) ? 'ISO-8859-1' : $context['character_set']));
        // We need to die like this *before* we send any anti-caching headers as below.
        die('404 - ' . $txt['attachment_not_found']);
    }
    // If it hasn't been modified since the last time this attachement was retrieved, there's no need to display it again.
    if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
        list($modified_since) = explode(';', $_SERVER['HTTP_IF_MODIFIED_SINCE']);
        if (strtotime($modified_since) >= filemtime($filename)) {
            ob_end_clean();
            // Answer the question - no, it hasn't been modified ;).
            header('HTTP/1.1 304 Not Modified');
            exit;
        }
    }
    // Check whether the ETag was sent back, and cache based on that...
    $eTag = '"' . substr($_REQUEST['attach'] . $real_filename . filemtime($filename), 0, 64) . '"';
    if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) && strpos($_SERVER['HTTP_IF_NONE_MATCH'], $eTag) !== false) {
        ob_end_clean();
        header('HTTP/1.1 304 Not Modified');
        exit;
    }
    // Send the attachment headers.
    header('Pragma: ');
    if (!isBrowser('gecko')) {
        header('Content-Transfer-Encoding: binary');
    }
    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT');
    header('Accept-Ranges: bytes');
    header('Connection: close');
    header('ETag: ' . $eTag);
    // Make sure the mime type warrants an inline display.
    if (isset($_REQUEST['image']) && !empty($mime_type) && strpos($mime_type, 'image/') !== 0) {
        unset($_REQUEST['image']);
    } elseif (!empty($mime_type) && (isset($_REQUEST['image']) || !in_array($file_ext, array('jpg', 'gif', 'jpeg', 'x-ms-bmp', 'png', 'psd', 'tiff', 'iff')))) {
        header('Content-Type: ' . strtr($mime_type, array('image/bmp' => 'image/x-ms-bmp')));
    } else {
        header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream'));
        if (isset($_REQUEST['image'])) {
            unset($_REQUEST['image']);
        }
    }
    // Convert the file to UTF-8, cuz most browsers dig that.
    $utf8name = !$context['utf8'] && function_exists('iconv') ? iconv($context['character_set'], 'UTF-8', $real_filename) : (!$context['utf8'] && function_exists('mb_convert_encoding') ? mb_convert_encoding($real_filename, 'UTF-8', $context['character_set']) : $real_filename);
    $fixchar = create_function('$n', '
		if ($n < 32)
			return \'\';
		elseif ($n < 128)
			return chr($n);
		elseif ($n < 2048)
			return chr(192 | $n >> 6) . chr(128 | $n & 63);
		elseif ($n < 65536)
			return chr(224 | $n >> 12) . chr(128 | $n >> 6 & 63) . chr(128 | $n & 63);
		else
			return chr(240 | $n >> 18) . chr(128 | $n >> 12 & 63) . chr(128 | $n >> 6 & 63) . chr(128 | $n & 63);');
    $disposition = !isset($_REQUEST['image']) ? 'attachment' : 'inline';
    // Different browsers like different standards...
    if (isBrowser('firefox')) {
        header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace('~&#(\\d{3,8});~e', '$fixchar(\'$1\')', $utf8name)));
    } elseif (isBrowser('opera')) {
        header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace('~&#(\\d{3,8});~e', '$fixchar(\'$1\')', $utf8name) . '"');
    } elseif (isBrowser('ie')) {
        header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace('~&#(\\d{3,8});~e', '$fixchar(\'$1\')', $utf8name)) . '"');
    } else {
        header('Content-Disposition: ' . $disposition . '; filename="' . $utf8name . '"');
    }
    // If this has an "image extension" - but isn't actually an image - then ensure it isn't cached cause of silly IE.
    if (!isset($_REQUEST['image']) && in_array($file_ext, array('gif', 'jpg', 'bmp', 'png', 'jpeg', 'tiff'))) {
        header('Cache-Control: no-cache');
    } else {
        header('Cache-Control: max-age=' . 525600 * 60 . ', private');
    }
    header('Content-Length: ' . filesize($filename));
    // Try to buy some time...
    @set_time_limit(600);
    // Recode line endings for text files, if enabled.
    if (!empty($modSettings['attachmentRecodeLineEndings']) && !isset($_REQUEST['image']) && in_array($file_ext, array('txt', 'css', 'htm', 'html', 'php', 'xml'))) {
        if (strpos($_SERVER['HTTP_USER_AGENT'], 'Windows') !== false) {
            $callback = create_function('$buffer', 'return preg_replace(\'~[\\r]?\\n~\', "\\r\\n", $buffer);');
        } elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
            $callback = create_function('$buffer', 'return preg_replace(\'~[\\r]?\\n~\', "\\r", $buffer);');
        } else {
            $callback = create_function('$buffer', 'return preg_replace(\'~[\\r]?\\n~\', "\\n", $buffer);');
        }
    }
    // Since we don't do output compression for files this large...
    if (filesize($filename) > 4194304) {
        // Forcibly end any output buffering going on.
        while (@ob_get_level() > 0) {
            @ob_end_clean();
        }
        $fp = fopen($filename, 'rb');
        while (!feof($fp)) {
            if (isset($callback)) {
                echo $callback(fread($fp, 8192));
            } else {
                echo fread($fp, 8192);
            }
            flush();
        }
        fclose($fp);
    } elseif (isset($callback) || @readfile($filename) === null) {
        echo isset($callback) ? $callback(file_get_contents($filename)) : file_get_contents($filename);
    }
    obExit(false);
}
Example #14
0
function template_email_members_compose()
{
    global $context, $settings, $options, $txt, $scripturl;
    echo '
		<div id="preview_section"', isset($context['preview_message']) ? '' : ' style="display: none;"', '>
			<div class="cat_bar">
				<h3 class="catbg">
					<span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span>
				</h3>
			</div>
			<div class="windowbg">
				<div class="content">
					<div class="post" id="preview_body">
						', empty($context['preview_message']) ? '<br />' : $context['preview_message'], '
					</div>
				</div>
			</div>
		</div><br />';
    echo '
	<div id="admincenter">
		<form name="newsmodify" action="', $scripturl, '?action=admin;area=news;sa=mailingsend" method="post" accept-charset="', $context['character_set'], '">
			<div class="cat_bar">
				<h3 class="catbg">
					<a href="', $scripturl, '?action=helpadmin;help=email_members" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.png" alt="', $txt['help'], '" class="icon" /></a> ', $txt['admin_newsletters'], '
				</h3>
			</div>
			<div class="information">
				', $txt['email_variables'], '
			</div>
			<div class="windowbg">
				<div class="content">
				<div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors">
					<dl>
						<dt>
							<strong id="error_serious">', $txt['error_while_submitting'], '</strong>
						</dt>
						<dd class="error" id="error_list">
							', empty($context['post_error']['messages']) ? '' : implode('<br />', $context['post_error']['messages']), '
						</dd>
					</dl>
				</div>
				<dl id="post_header">
					<dt class="clear_left">
						<span', isset($context['post_error']['no_subject']) ? ' class="error"' : '', ' id="caption_subject">', $txt['subject'], ':</span>
					</dt>
					<dd id="pm_subject">
						<input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="60" maxlength="60"', isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', '/>
					</dd>
				</dl><hr class="clear" />
				<div id="bbcBox_message"></div>';
    // What about smileys?
    if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup'])) {
        echo '
				<div id="smileyBox_message"></div>';
    }
    // Show BBC buttons, smileys and textbox.
    echo '
				', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
    echo '
					<ul class="reset">
						<li><label for="send_pm"><input type="checkbox" name="send_pm" id="send_pm" ', !empty($context['send_pm']) ? 'checked="checked"' : '', 'class="input_check" onclick="checkboxes_status(this);" /> ', $txt['email_as_pms'], '</label></li>
						<li><label for="send_html"><input type="checkbox" name="send_html" id="send_html" ', !empty($context['send_html']) ? 'checked="checked"' : '', 'class="input_check" onclick="checkboxes_status(this);" /> ', $txt['email_as_html'], '</label></li>
						<li><label for="parse_html"><input type="checkbox" name="parse_html" id="parse_html" checked="checked" disabled="disabled" class="input_check" /> ', $txt['email_parsed_html'], '</label></li>
					</ul>
				<p id="shortcuts" class="smalltext">
					', isBrowser('is_firefox') ? $txt['shortcuts_firefox'] : $txt['shortcuts'], '
				</p>
				<p id="post_confirm_strip" class="righttext">
					', template_control_richedit_buttons($context['post_box_name']), '
				</p>
				</div>
			</div>
			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
			<input type="hidden" name="email_force" value="', $context['email_force'], '" />
			<input type="hidden" name="total_emails" value="', $context['total_emails'], '" />
			<input type="hidden" name="max_id_member" value="', $context['max_id_member'], '" />';
    foreach ($context['recipients'] as $key => $values) {
        echo '
			<input type="hidden" name="', $key, '" value="', implode($key == 'emails' ? ';' : ',', $values), '" />';
    }
    echo '
		<script type="text/javascript"><!-- // --><![CDATA[';
    // The functions used to preview a posts without loading a new page.
    echo '
			var txt_preview_title = "', $txt['preview_title'], '";
			var txt_preview_fetch = "', $txt['preview_fetch'], '";
			function previewPost()
			{';
    if (isBrowser('is_firefox')) {
        echo '
				// Firefox doesn\'t render <marquee> that have been put it using javascript
				if (document.forms.newsmodify.elements[', JavaScriptEscape($context['post_box_name']), '].value.indexOf(\'[move]\') != -1)
				{
					return submitThisOnce(document.forms.newsmodify);
				}';
    }
    echo '
				if (window.XMLHttpRequest)
				{
					// Opera didn\'t support setRequestHeader() before 8.01.
					// @todo Remove support for old browsers
					if (\'opera\' in window)
					{
						var test = new XMLHttpRequest();
						if (!(\'setRequestHeader\' in test))
							return submitThisOnce(document.forms.newsmodify);
					}
					// @todo Currently not sending poll options and option checkboxes.
					var x = new Array();
					var textFields = [\'subject\', ', JavaScriptEscape($context['post_box_name']), '];
					var checkboxFields = [\'send_html\', \'send_pm\'];

					for (var i = 0, n = textFields.length; i < n; i++)
						if (textFields[i] in document.forms.newsmodify)
						{
							// Handle the WYSIWYG editor.
							if (textFields[i] == ', JavaScriptEscape($context['post_box_name']), ' && ', JavaScriptEscape('oEditorHandle_' . $context['post_box_name']), ' in window && oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled)
								x[x.length] = \'message_mode=1&\' + textFields[i] + \'=\' + oEditorHandle_', $context['post_box_name'], '.getText(false).replace(/&#/g, \'&#38;#\').php_to8bit().php_urlencode();
							else
								x[x.length] = textFields[i] + \'=\' + document.forms.newsmodify[textFields[i]].value.replace(/&#/g, \'&#38;#\').php_to8bit().php_urlencode();
						}
					for (var i = 0, n = checkboxFields.length; i < n; i++)
						if (checkboxFields[i] in document.forms.newsmodify && document.forms.newsmodify.elements[checkboxFields[i]].checked)
							x[x.length] = checkboxFields[i] + \'=\' + document.forms.newsmodify.elements[checkboxFields[i]].value;

					x[x.length] = \'item=newsletterpreview\';

					sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=xmlhttp;sa=previews;xml\', x.join(\'&\'), onDocSent);

					document.getElementById(\'preview_section\').style.display = \'\';
					setInnerHTML(document.getElementById(\'preview_subject\'), txt_preview_title);
					setInnerHTML(document.getElementById(\'preview_body\'), txt_preview_fetch);

					return false;
				}
				else
					return submitThisOnce(document.forms.newsmodify);
			}
			function onDocSent(XMLDoc)
			{
				if (!XMLDoc)
				{
					document.forms.newsmodify.preview.onclick = new function ()
					{
						return true;
					}
					document.forms.newsmodify.preview.click();
				}

				// Show the preview section.
				var preview = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'preview\')[0];
				setInnerHTML(document.getElementById(\'preview_subject\'), preview.getElementsByTagName(\'subject\')[0].firstChild.nodeValue);

				var bodyText = \'\';
				for (var i = 0, n = preview.getElementsByTagName(\'body\')[0].childNodes.length; i < n; i++)
					bodyText += preview.getElementsByTagName(\'body\')[0].childNodes[i].nodeValue;

				setInnerHTML(document.getElementById(\'preview_body\'), bodyText);
				document.getElementById(\'preview_body\').className = \'post\';

				// Show a list of errors (if any).
				var errors = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'errors\')[0];
				var errorList = new Array();
				for (var i = 0, numErrors = errors.getElementsByTagName(\'error\').length; i < numErrors; i++)
					errorList[errorList.length] = errors.getElementsByTagName(\'error\')[i].firstChild.nodeValue;
				document.getElementById(\'errors\').style.display = numErrors == 0 ? \'none\' : \'\';
				setInnerHTML(document.getElementById(\'error_list\'), numErrors == 0 ? \'\' : errorList.join(\'<br />\'));

				// Adjust the color of captions if the given data is erroneous.
				var captions = errors.getElementsByTagName(\'caption\');
				for (var i = 0, numCaptions = errors.getElementsByTagName(\'caption\').length; i < numCaptions; i++)
					if (document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')))
						document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')).className = captions[i].getAttribute(\'class\');

				if (errors.getElementsByTagName(\'post_error\').length == 1)
					document.forms.newsmodify.', $context['post_box_name'], '.style.border = \'1px solid red\';
				else if (document.forms.newsmodify.', $context['post_box_name'], '.style.borderColor == \'red\' || document.forms.newsmodify.', $context['post_box_name'], '.style.borderColor == \'red red red red\')
				{
					if (\'runtimeStyle\' in document.forms.newsmodify.', $context['post_box_name'], ')
						document.forms.newsmodify.', $context['post_box_name'], '.style.borderColor = \'\';
					else
						document.forms.newsmodify.', $context['post_box_name'], '.style.border = null;
				}
				location.hash = \'#\' + \'preview_section\';
			}';
    echo '
		// ]]></script>';
    echo '
		<script type="text/javascript"><!-- // --><![CDATA[
			function checkboxes_status (item)
			{
				if (item.id == \'send_html\')
					document.getElementById(\'parse_html\').disabled = !document.getElementById(\'parse_html\').disabled;
				if (item.id == \'send_pm\')
				{
					if (!document.getElementById(\'send_html\').checked)
						document.getElementById(\'parse_html\').disabled = true;
					else
						document.getElementById(\'parse_html\').disabled = false;
					document.getElementById(\'send_html\').disabled = !document.getElementById(\'send_html\').disabled;
				}
			}
		// ]]></script>
		</form>
	</div>';
}
Example #15
0
if (!isBrowser('gecko')) {
    header('Content-Transfer-Encoding: binary');
}
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 525600 * 60) . ' GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($filename)) . ' GMT');
header('Accept-Ranges: bytes');
header('Connection: close');
header('ETag: ' . $eTag);
header('Content-Type: image/png');
$disposition = 'inline';
// Different browsers like different standards...
if (isBrowser('firefox')) {
    header('Content-Disposition: ' . $disposition . '; filename*=UTF-8\'\'' . rawurlencode(preg_replace_callback('~&#(\\d{3,8});~', 'fixchar__callback', $real_filename)));
} elseif (isBrowser('opera')) {
    header('Content-Disposition: ' . $disposition . '; filename="' . preg_replace_callback('~&#(\\d{3,8});~', 'fixchar__callback', $real_filename) . '"');
} elseif (isBrowser('ie')) {
    header('Content-Disposition: ' . $disposition . '; filename="' . urlencode(preg_replace_callback('~&#(\\d{3,8});~', 'fixchar__callback', $real_filename)) . '"');
} else {
    header('Content-Disposition: ' . $disposition . '; filename="' . $real_filename . '"');
}
header('Cache-Control: max-age=' . 525600 * 60 . ', private');
if (empty($modSettings['enableCompressedOutput']) || $filesize > 4194304) {
    header('Content-Length: ' . $filesize);
}
// Try to buy some time...
@set_time_limit(600);
// Since we don't do output compression for files this large...
if ($filesize > 4194304) {
    // Forcibly end any output buffering going on.
    while (ob_get_level() > 0) {
        @ob_end_clean();
/**
 * The lower icons and jump to.
 */
function template_topic_listing_below()
{
    global $context, $txt, $options;
    if ($context['no_topic_listing']) {
        return;
    }
    template_pagesection('normal_buttons', 'right');
    // Show breadcrumbs at the bottom too.
    theme_linktree();
    echo '
	<div id="topic_icons" class="description">
		<div class="floatright" id="message_index_jump_to">&nbsp;</div>';
    if (!$context['no_topic_listing']) {
        template_basicicons_legend();
    }
    echo '
			<script><!-- // --><![CDATA[';
    if (!empty($context['using_relative_time'])) {
        echo '
				$(\'.topic_latest\').addClass(\'relative\');';
    }
    if (!empty($context['can_quick_mod']) && $options['display_quick_mod'] == 1 && !empty($context['topics']) && $context['can_move']) {
        echo '
				aJumpTo[aJumpTo.length] = new JumpTo({
					sContainerId: "quick_mod_jump_to",
					sClassName: "qaction",
					sJumpToTemplate: "%dropdown_list%",
					iCurBoardId: ', $context['current_board'], ',
					iCurBoardChildLevel: ', $context['jump_to']['child_level'], ',
					sCurBoardName: "', $context['jump_to']['board_name'], '",
					sBoardChildLevelIndicator: "&#8195;",
					sBoardPrefix: "', isBrowser('ie8') ? '&#187; ' : '&#10148; ', '",
					sCatClass: "jump_to_header",
					sCatPrefix: "",
					bNoRedirect: true,
					bDisabled: true,
					sCustomName: "move_to"
				});';
    }
    echo '
				aJumpTo[aJumpTo.length] = new JumpTo({
					sContainerId: "message_index_jump_to",
					sJumpToTemplate: "<label class=\\"smalltext\\" for=\\"%select_id%\\">', $context['jump_to']['label'], ':<" + "/label> %dropdown_list%",
					iCurBoardId: ', $context['current_board'], ',
					iCurBoardChildLevel: ', $context['jump_to']['child_level'], ',
					sCurBoardName: "', $context['jump_to']['board_name'], '",
					sBoardChildLevelIndicator: "&#8195;",
					sBoardPrefix: "', isBrowser('ie8') ? '&#187; ' : '&#10148; ', '",
					sCatPrefix: "",
					sCatClass: "jump_to_header",
					sGoButtonLabel: "', $txt['quick_mod_go'], '"
				});
			// ]]></script>
	</div>';
    // Javascript for inline editing.
    echo '
	<script><!-- // --><![CDATA[
		var oQuickModifyTopic = new QuickModifyTopic({
			aHidePrefixes: Array("lockicon", "stickyicon", "pages", "newicon"),
			bMouseOnDiv: false,
		});
	// ]]></script>';
}
Example #17
0
/**
 * Template for the email to members page in admin panel.
 * It allows to select members and membergroups.
 */
function template_email_members()
{
    global $context, $txt, $scripturl;
    echo '
	<div id="admincenter">
		<form action="', $scripturl, '?action=admin;area=news;sa=mailingcompose" method="post" id="admin_newsletters" class="flow_hidden" accept-charset="UTF-8">
			<h2 class="category_header">', $txt['admin_newsletters'], '</h2>
			<div class="information">
				', $txt['admin_news_select_recipients'], '
			</div>
			<div id="include_panel_header">
				<h3 class="category_header">
					', $txt['include_these'], '
				</h3>
			</div>
			<div class="windowbg">
				<div class="content">
					<dl class="settings">
						<dt>
							<strong>', $txt['admin_news_select_group'], ':</strong><br />
							<span class="smalltext">', $txt['admin_news_select_group_desc'], '</span>
						</dt>
						<dd>';
    template_list_groups_collapsible('groups');
    echo '
						</dd>
						<dt>
							<strong><label for="emails">', $txt['admin_news_select_email'], '</label>:</strong><br />
							<span class="smalltext">', $txt['admin_news_select_email_desc'], '</span>
						</dt>
						<dd>
							<textarea id="emails" name="emails" rows="5" cols="30" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 98%; min-width: 98%' : 'width: 98%') . ';"></textarea>
						</dd>
						<dt>
							<strong><label for="members">', $txt['admin_news_select_members'], '</label>:</strong><br />
							<span class="smalltext">', $txt['admin_news_select_members_desc'], '</span>
						</dt>
						<dd>
							<input type="text" name="members" id="members" value="" size="30" class="input_text" />
							<span id="members_container"></span>
						</dd>
					</dl>
					<hr class="bordercolor" />
					<dl class="settings">
						<dt>
							<label for="email_force"><strong>', $txt['admin_news_select_override_notify'], ':</strong></label><br />
							<span class="smalltext">', $txt['email_force'], '</span>
						</dt>
						<dd>
							<input type="checkbox" name="email_force" id="email_force" value="1" class="input_check" />
						</dd>
					</dl>
				</div>
			</div>
			<div id="exclude_panel_header">
				<h3 class="category_header">
					<span id="category_toggle">&nbsp;
						<span id="upshrink_ic" class="', empty($context['admin_preferences']['apn']) ? 'collapse' : 'expand', '" style="display: none;" title="', $txt['hide'], '"></span>
					</span>
					<a href="#" id="exclude_panel_link" >', $txt['exclude_these'], '</a>
				</h3>
			</div>
			<div id="exclude_panel_div" class="windowbg">
				<div class="content">
					<dl class="settings">
						<dt>
							<strong>', $txt['admin_news_select_excluded_groups'], ':</strong><br />
							<span class="smalltext">', $txt['admin_news_select_excluded_groups_desc'], '</span>
						</dt>
						<dd>';
    template_list_groups_collapsible('exclude_groups');
    echo '
						<dt>
							<strong>', $txt['admin_news_select_excluded_members'], ':</strong><br />
							<span class="smalltext">', $txt['admin_news_select_excluded_members_desc'], '</span>
						</dt>
						<dd>
							<input type="text" name="exclude_members" id="exclude_members" value="" size="30" class="input_text" />
							<span id="exclude_members_container"></span>
						</dd>
					</dl>
				</div>
			</div>
			<div class="submitbutton">
				<input type="submit" value="', $txt['admin_next'], '" class="button_submit" />
				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
			</div>
		</form>
	</div>';
    // This is some javascript for the simple/advanced toggling and member suggest
    addInlineJavascript('
		var oAdvancedPanelToggle = new elk_Toggle({
			bToggleEnabled: true,
			bCurrentlyCollapsed: ' . (empty($context['admin_preferences']['apn']) ? 'false' : 'true') . ',
			aSwappableContainers: [
				\'exclude_panel_div\'
			],
			aSwapClasses: [
				{
					sId: \'upshrink_ic\',
					classExpanded: \'collapse\',
					titleExpanded: ' . JavaScriptEscape($txt['hide']) . ',
					classCollapsed: \'expand\',
					titleCollapsed: ' . JavaScriptEscape($txt['show']) . '
				}
			],
			aSwapLinks: [
				{
					sId: \'exclude_panel_link\',
					msgExpanded: ' . JavaScriptEscape($txt['exclude_these']) . ',
					msgCollapsed: ' . JavaScriptEscape($txt['exclude_these']) . '
				}
			],
			oThemeOptions: {
				bUseThemeSettings: ' . ($context['user']['is_guest'] ? 'false' : 'true') . ',
				sOptionName: \'admin_preferences\',
				sSessionVar: elk_session_var,
				sSessionId: elk_session_id,
				sThemeId: \'1\',
				sAdditionalVars: \';admin_key=apn\'
			}
		});

		var oMemberSuggest = new smc_AutoSuggest({
			sSelf: \'oMemberSuggest\',
			sSessionId: elk_session_id,
			sSessionVar: elk_session_var,
			sSuggestId: \'members\',
			sControlId: \'members\',
			sSearchType: \'member\',
			bItemList: true,
			sPostName: \'member_list\',
			sURLMask: \'action=profile;u=%item_id%\',
			sTextDeleteItem: \'' . $txt['autosuggest_delete_item'] . '\',
			sItemListContainerId: \'members_container\',
			aListItems: []
		});

		var oExcludeMemberSuggest = new smc_AutoSuggest({
			sSelf: \'oExcludeMemberSuggest\',
			sSessionId: elk_session_id,
			sSessionVar: elk_session_var,
			sSuggestId: \'exclude_members\',
			sControlId: \'exclude_members\',
			sSearchType: \'member\',
			bItemList: true,
			sPostName: \'exclude_member_list\',
			sURLMask: \'action=profile;u=%item_id%\',
			sTextDeleteItem: \'' . $txt['autosuggest_delete_item'] . '\',
			sItemListContainerId: \'exclude_members_container\',
			aListItems: []
		});', true);
}
/**
 * Add a new language
 */
function template_add_language()
{
    global $context, $txt, $scripturl;
    echo '
	<div id="admincenter">
		<form id="admin_form_wrapper"action="', $scripturl, '?action=admin;area=languages;sa=add;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="UTF-8">
			<h2 class="category_header">', $txt['add_language'], '</h2>
			<div class="windowbg">
				<div class="content">
					<fieldset>
						<legend>', $txt['add_language_elk'], '</legend>
						<label for="lang_add" class="smalltext">', $txt['add_language_elk_browse'], '</label>
						<input type="text" id="lang_add" name="lang_add" size="40" value="', !empty($context['elk_search_term']) ? $context['elk_search_term'] : '', '" class="input_text" />';
    // Do we have some errors? Too bad.
    if (!empty($context['langfile_error'])) {
        // Display a little error box.
        echo '
						<div>
							<br />
							<p class="errorbox">', $txt['add_language_error_' . $context['langfile_error']], '</p>
						</div>';
    }
    echo '
					</fieldset>', isBrowser('is_ie') ? '<input type="text" name="ie_fix" style="display: none;" class="input_text" /> ' : '', '
					<input type="submit" name="lang_add_sub" value="', $txt['search'], '" class="right_submit" />
					<br />
				</div>
			</div>
		';
    // Had some results?
    if (!empty($context['languages'])) {
        echo '
			<div class="information">', $txt['add_language_elk_found'], '</div>';
        template_show_list('languages');
    }
    echo '
		</form>
	</div>';
}
Example #19
0
/**
 * The area above the post box,
 * Typically holds subject, preview, info messages, message icons, etc
 */
function template_postarea_above()
{
    global $context, $scripturl, $txt, $modSettings;
    // Start the javascript...
    echo '
		<script><!-- // --><![CDATA[';
    // When using Go Back due to fatal_error, allow the form to be re-submitted with changes.
    if (isBrowser('is_firefox')) {
        echo '
			window.addEventListener("pageshow", reActivate, false);';
    }
    // Start with message icons - and any missing from this theme.
    echo '
			var icon_urls = {';
    foreach ($context['icons'] as $icon) {
        echo '
				\'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ',';
    }
    echo '
			};';
    // End of the javascript
    echo '
		// ]]></script>';
    // Start the form and display the link tree.
    echo '
		<form action="', $scripturl, '?action=', $context['destination'], ';', empty($context['current_board']) ? '' : 'board=' . $context['current_board'], '" method="post" accept-charset="UTF-8" name="postmodify" id="postmodify" class="flow_hidden" onsubmit="', $context['becomes_approved'] ? '' : 'alert(\'' . $txt['js_post_will_require_approval'] . '\');', 'submitonce(this);smc_saveEntities(\'postmodify\', [\'subject\', \'', $context['post_box_name'], '\', \'guestname\', \'evtitle\', \'question\'], \'options\');revalidateMentions(\'postmodify\', \'', $context['post_box_name'], '\');" enctype="multipart/form-data">';
    // If the user wants to see how their message looks - the preview section is where it's at!
    echo '
			<div id="preview_section" class="forumposts"', isset($context['preview_message']) ? '' : ' style="display: none;"', '>
				<h3 class="category_header">
					<span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span>
				</h3>
				<div class="post" id="preview_body">
					', empty($context['preview_message']) ? '<br />' : $context['preview_message'], '
				</div>
			</div>';
    // Start the main table.
    echo '
			<div class="forumposts">', isset($context['current_topic']) ? '<input type="hidden" name="topic" value="' . $context['current_topic'] . '" />' : '', '
				<h3 class="category_header">', $context['page_title'], '</h3>
				<div class="windowbg">
					<div class="editor_wrapper">';
    // If an error occurred, explain what happened.
    template_show_error('post_error');
    if (!empty($context['attachment_error_keys'])) {
        template_attachment_errors();
    }
    // If this won't be approved let them know!
    // @todo why not use the template_show_error above?
    if (!$context['becomes_approved']) {
        echo '
						<div class="successbox">
							', $txt['wait_for_approval'], '
							<input type="hidden" name="not_approved" value="1" />
						</div>';
    }
    // If it's locked, show a message to warn the replyer.
    // @todo why not output it only for locked topics and why not use the template_show_error above?
    echo '
						<p class="information"', $context['locked'] ? '' : ' style="display: none"', ' id="lock_warning">
							', $txt['topic_locked_no_reply'], '
						</p>';
    if (!empty($context['drafts_autosave'])) {
        echo '
						<div id="draft_section" class="successbox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>
							', sprintf($txt['draft_saved'], $scripturl . '?action=profile;u=' . $context['user']['id'] . ';area=showdrafts'), '
						</div>';
    }
    // The post header... important stuff
    echo '
						<dl id="post_header">';
    // Guests have to put in their name and email...
    if (isset($context['name']) && isset($context['email'])) {
        echo '
							<dt>
								<label for="guestname"', isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '', ' id="caption_guestname">', $txt['name'], ':</label>
							</dt>
							<dd>
								<input type="text" id="guestname" name="guestname" size="25" value="', $context['name'], '" tabindex="', $context['tabindex']++, '" class="input_text" required="required" />
							</dd>';
        if (empty($modSettings['guest_post_no_email'])) {
            echo '
							<dt>
								<label for="email"', isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '', ' id="caption_email">', $txt['email'], ':</label>
							</dt>
							<dd>
								<input type="email" id="email" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" required="required" />
							</dd>';
        }
    }
    // Now show the subject box for this post.
    echo '
							<dt class="clear">
								<label for="post_subject"', isset($context['post_error']['no_subject']) ? ' class="error"' : '', ' id="caption_subject">', $txt['subject'], ':</label>
							</dt>
							<dd>
								<input id="post_subject" type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80"', isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', ' placeholder="', $txt['subject'], '" required="required" />
							</dd>
							<dt class="clear_left">
								<label for="icon">', $txt['message_icon'], '</label>:
							</dt>
							<dd>
								<select name="icon" id="icon" onchange="showimage()">';
    // Loop through each message icon allowed, adding it to the drop down list.
    foreach ($context['icons'] as $icon) {
        echo '
									<option value="', $icon['value'], '"', $icon['value'] == $context['icon'] ? ' selected="selected"' : '', '>', $icon['name'], '</option>';
    }
    echo '
								</select>
								<img src="', $context['icon_url'], '" id="icons" alt="" />
							</dd>';
    if (!empty($context['show_boards_dropdown'])) {
        echo '
							<dt class="clear_left">
								<label for="post_in_board">', $txt['post_in_board'], '</label>:
							</dt>
							<dd>', template_select_boards('post_in_board'), '
							</dd>';
    }
    echo '
						</dl>';
}
Example #20
0
/**
 * Load the template/language file using eval or require? (with eval we can show an error message!)
 *
 * What it does:
 * - loads the template or language file specified by filename.
 * - uses eval unless disableTemplateEval is enabled.
 * - outputs a parse error if the file did not exist or contained errors.
 * - attempts to detect the error and line, and show detailed information.
 *
 * @param string $filename
 * @param bool $once = false, if true only includes the file once (like include_once)
 */
function template_include($filename, $once = false)
{
    global $context, $settings, $txt, $scripturl, $modSettings, $boardurl;
    global $maintenance, $mtitle, $mmessage;
    static $templates = array();
    // We want to be able to figure out any errors...
    @ini_set('track_errors', '1');
    // Don't include the file more than once, if $once is true.
    if ($once && in_array($filename, $templates)) {
        return;
    } else {
        $templates[] = $filename;
    }
    // Are we going to use eval?
    if (empty($modSettings['disableTemplateEval'])) {
        $file_found = file_exists($filename) && eval('?' . '>' . rtrim(file_get_contents($filename))) !== false;
        $settings['current_include_filename'] = $filename;
    } else {
        $file_found = file_exists($filename);
        if ($once && $file_found) {
            require_once $filename;
        } elseif ($file_found) {
            require $filename;
        }
    }
    if ($file_found !== true) {
        @ob_end_clean();
        if (!empty($modSettings['enableCompressedOutput'])) {
            ob_start('ob_gzhandler');
        } else {
            ob_start();
        }
        if (isset($_GET['debug'])) {
            header('Content-Type: application/xhtml+xml; charset=UTF-8');
        }
        // Don't cache error pages!!
        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Cache-Control: no-cache');
        if (!isset($txt['template_parse_error'])) {
            $txt['template_parse_error'] = 'Template Parse Error!';
            $txt['template_parse_error_message'] = 'It seems something has gone sour on the forum with the template system.  This problem should only be temporary, so please come back later and try again.  If you continue to see this message, please contact the administrator.<br /><br />You can also try <a href="javascript:location.reload();">refreshing this page</a>.';
            $txt['template_parse_error_details'] = 'There was a problem loading the <span style="font-family: monospace;"><strong>%1$s</strong></span> template or language file.  Please check the syntax and try again - remember, single quotes (<span style="font-family: monospace;">\'</span>) often have to be escaped with a slash (<span style="font-family: monospace;">\\</span>).  To see more specific error information from PHP, try <a href="%2$s%1$s" class="extern">accessing the file directly</a>.<br /><br />You may want to try to <a href="javascript:location.reload();">refresh this page</a> or <a href="%3$s">use the default theme</a>.';
            $txt['template_parse_undefined'] = 'An undefined error occurred during the parsing of this template';
        }
        // First, let's get the doctype and language information out of the way.
        echo '<!DOCTYPE html>
<html ', !empty($context['right_to_left']) ? 'dir="rtl"' : '', '>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
        if (!empty($maintenance) && !allowedTo('admin_forum')) {
            echo '
		<title>', $mtitle, '</title>
	</head>
	<body>
		<h3>', $mtitle, '</h3>
		', $mmessage, '
	</body>
</html>';
        } elseif (!allowedTo('admin_forum')) {
            echo '
		<title>', $txt['template_parse_error'], '</title>
	</head>
	<body>
		<h3>', $txt['template_parse_error'], '</h3>
		', $txt['template_parse_error_message'], '
	</body>
</html>';
        } else {
            require_once SUBSDIR . '/Package.subs.php';
            $error = fetch_web_data($boardurl . strtr($filename, array(BOARDDIR => '', strtr(BOARDDIR, '\\', '/') => '')));
            if (empty($error) && ini_get('track_errors') && !empty($php_errormsg)) {
                $error = $php_errormsg;
            } elseif (empty($error)) {
                $error = $txt['template_parse_undefined'];
            }
            $error = strtr($error, array('<b>' => '<strong>', '</b>' => '</strong>'));
            echo '
		<title>', $txt['template_parse_error'], '</title>
	</head>
	<body>
		<h3>', $txt['template_parse_error'], '</h3>
		', sprintf($txt['template_parse_error_details'], strtr($filename, array(BOARDDIR => '', strtr(BOARDDIR, '\\', '/') => '')), $boardurl, $scripturl . '?theme=1');
            if (!empty($error)) {
                echo '
		<hr />

		<div style="margin: 0 20px;"><span style="font-family: monospace;">', strtr(strtr($error, array('<strong>' . BOARDDIR => '<strong>...', '<strong>' . strtr(BOARDDIR, '\\', '/') => '<strong>...')), '\\', '/'), '</span></div>';
            }
            // I know, I know... this is VERY COMPLICATED.  Still, it's good.
            if (preg_match('~ <strong>(\\d+)</strong><br( /)?' . '>$~i', $error, $match) != 0) {
                $data = file($filename);
                $data2 = highlight_php_code(implode('', $data));
                $data2 = preg_split('~\\<br( /)?\\>~', $data2);
                // Fix the PHP code stuff...
                if (!isBrowser('gecko')) {
                    $data2 = str_replace("\t", '<span style="white-space: pre;">' . "\t" . '</span>', $data2);
                } else {
                    $data2 = str_replace('<pre style="display: inline;">' . "\t" . '</pre>', "\t", $data2);
                }
                // Now we get to work around a bug in PHP where it doesn't escape <br />s!
                $j = -1;
                foreach ($data as $line) {
                    $j++;
                    if (substr_count($line, '<br />') == 0) {
                        continue;
                    }
                    $n = substr_count($line, '<br />');
                    for ($i = 0; $i < $n; $i++) {
                        $data2[$j] .= '&lt;br /&gt;' . $data2[$j + $i + 1];
                        unset($data2[$j + $i + 1]);
                    }
                    $j += $n;
                }
                $data2 = array_values($data2);
                array_unshift($data2, '');
                echo '
		<div style="margin: 2ex 20px; width: 96%; overflow: auto;"><pre style="margin: 0;">';
                // Figure out what the color coding was before...
                $line = max($match[1] - 9, 1);
                $last_line = '';
                for ($line2 = $line - 1; $line2 > 1; $line2--) {
                    if (strpos($data2[$line2], '<') !== false) {
                        if (preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line2], $color_match) != 0) {
                            $last_line = $color_match[1];
                        }
                        break;
                    }
                }
                // Show the relevant lines...
                for ($n = min($match[1] + 4, count($data2) + 1); $line <= $n; $line++) {
                    if ($line == $match[1]) {
                        echo '</pre><div style="background: #ffb0b5;"><pre style="margin: 0;">';
                    }
                    echo '<span style="color: black;">', sprintf('%' . strlen($n) . 's', $line), ':</span> ';
                    if (isset($data2[$line]) && $data2[$line] != '') {
                        echo substr($data2[$line], 0, 2) == '</' ? preg_replace('~^</[^>]+>~', '', $data2[$line]) : $last_line . $data2[$line];
                    }
                    if (isset($data2[$line]) && preg_match('~(<[^/>]+>)[^<]*$~', $data2[$line], $color_match) != 0) {
                        $last_line = $color_match[1];
                        echo '</', substr($last_line, 1, 4), '>';
                    } elseif ($last_line != '' && strpos($data2[$line], '<') !== false) {
                        $last_line = '';
                    } elseif ($last_line != '' && $data2[$line] != '') {
                        echo '</', substr($last_line, 1, 4), '>';
                    }
                    if ($line == $match[1]) {
                        echo '</pre></div><pre style="margin: 0;">';
                    } else {
                        echo "\n";
                    }
                }
                echo '</pre></div>';
            }
            echo '
	</body>
</html>';
        }
        die;
    }
}
Example #21
0
function template_verification_sound()
{
    global $context, $settings, $options, $txt, $scripturl;
    echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
		<title>', $txt['visual_verification_sound'], '</title>
		<meta name="robots" content="noindex" />
		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?alp21" />
		<style type="text/css">';
    // Just show the help text and a "close window" link.
    echo '
		</style>
	</head>
	<body style="margin: 1ex;">
		<div class="windowbg description" style="text-align: center;">';
    if (isBrowser('is_ie')) {
        echo '
			<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" type="audio/x-wav">
				<param name="AutoStart" value="1" />
				<param name="FileName" value="', $context['verification_sound_href'], '" />
			</object>';
    } else {
        echo '
			<object type="audio/x-wav" data="', $context['verification_sound_href'], '">
				<a href="', $context['verification_sound_href'], '" rel="nofollow">', $context['verification_sound_href'], '</a>
			</object>';
    }
    echo '
		<br />
		<a href="', $context['verification_sound_href'], ';sound" rel="nofollow">', $txt['visual_verification_sound_again'], '</a><br />
		<a href="', $context['verification_sound_href'], '" rel="nofollow">', $txt['visual_verification_sound_direct'], '</a><br /><br />
		<a href="javascript:self.close();">', $txt['visual_verification_sound_close'], '</a><br />
		</div>
	</body>
</html>';
}
/**
 * Embeds a shoutbox block on a page
 *
 * @param mixed[] $shoutbox
 */
function template_shoutbox_embed($shoutbox)
{
    global $context, $scripturl, $settings, $txt;
    echo '
	<form method="post">
		<div class="shoutbox_container">
			<div class="shoutbox_info">
				<div id="shoutbox_load_', $shoutbox['id'], '" style="float: right; display: none;"><i class="fa fa-spinner fa-spin"></i></div>
				<a ', sp_embed_class('refresh'), ' href="', $scripturl, '?action=shoutbox;shoutbox_id=', $shoutbox['id'], '" onclick="sp_refresh_shout(', $shoutbox['id'], ', last_refresh_', $shoutbox['id'], '); return false;"></a>
				<a ', sp_embed_class('history'), ' href="', $scripturl, '?action=shoutbox;shoutbox_id=', $shoutbox['id'], '"></a>';
    if ($context['can_shout']) {
        echo ' <a ', sp_embed_class('smiley'), ' href="#smiley" onclick="sp_collapse_object(\'sb_smiley_', $shoutbox['id'], '\', false); return false;"></a> <a ', sp_embed_class('style'), ' href="#style" onclick="sp_collapse_object(\'sb_style_', $shoutbox['id'], '\', false); return false;"></a>';
    }
    echo '
			</div>';
    if ($context['can_shout']) {
        // Smiley box
        echo '
			<div id="sp_object_sb_smiley_', $shoutbox['id'], '" style="display: none;">';
        foreach ($shoutbox['smileys']['normal'] as $smiley) {
            echo '
				<a href="javascript:void(0);" onclick="replaceText(\' ', $smiley['code'], '\', document.getElementById(\'new_shout_', $shoutbox['id'], '\')); return false;"><img src="', $settings['smileys_url'], '/', $smiley['filename'], '" alt="', $smiley['description'], '" title="', $smiley['description'], '" /></a>';
        }
        if (!empty($shoutbox['smileys']['popup'])) {
            echo '
					<a onclick="sp_showMoreSmileys(\'', $shoutbox['id'], '\', \'', $txt['more_smileys_title'], '\', \'', $txt['more_smileys_pick'], '\', \'', $txt['more_smileys_close_window'], '\', \'', $settings['theme_url'], '\', \'', $settings['smileys_url'], '\'); return false;" href="javascript:void(0);">[', $txt['more_smileys'], ']</a>';
        }
        // BBC box
        echo '
			</div>
			<div id="sp_object_sb_style_', $shoutbox['id'], '" class="shoutbox_bbc_container" style="display: none;">';
        // For each bbc code we allow in this shoutbox
        foreach ($shoutbox['bbc'] as $image => $tag) {
            if (!in_array($tag['code'], $shoutbox['allowed_bbc'])) {
                continue;
            }
            // Add all enabled shoutbox BBC buttons
            echo '
				<a href="#" class="shoutbox-button shoutbox-', $image, '" title="', $tag['description'], '" ';
            // Set the button click action
            if (!isset($tag['after'])) {
                echo 'onclick="replaceText(\'', $tag['before'], '\', document.getElementById(\'new_shout_', $shoutbox['id'], '\')); return false;">';
            } else {
                echo 'onclick="sp_surroundText(\'', $tag['before'], '\', \'', $tag['after'], '\', document.getElementById(\'new_shout_', $shoutbox['id'], '\')); return false;">';
            }
            echo '
					<div></div>
				</a>';
        }
        echo '
			</div>';
    }
    // The shouts!
    echo '
			<div class="shoutbox_body">
				<ul class="shoutbox_list_compact" id="shouts_', $shoutbox['id'], '"', !empty($shoutbox['height']) ? ' style="height: ' . $shoutbox['height'] . 'px;"' : '', '>';
    if (!empty($shoutbox['warning'])) {
        echo '
					<li class="shoutbox_warning">', $shoutbox['warning'], '</li>';
    }
    if (!empty($shoutbox['shouts'])) {
        foreach ($shoutbox['shouts'] as $shout) {
            echo '
					<li>', !$shout['is_me'] ? '<strong>' . $shout['author']['link'] . ':</strong> ' : '', $shout['text'], '<br />', !empty($shout['delete_link_js']) ? '<span class="shoutbox_delete">' . $shout['delete_link_js'] . '</span>' : '', '<span class="smalltext shoutbox_time">', $shout['time'], '</span></li>';
        }
    } else {
        echo '
					<li>', $txt['sp_shoutbox_no_shout'], '</li>';
    }
    echo '
				</ul>
			</div>';
    // Show an input box, if they can use it
    if ($context['can_shout']) {
        echo '
			<div class="submitbutton">
				<input type="text" name="new_shout" id="new_shout_', $shoutbox['id'], '" class="shoutbox_input floatleft input_text"', isBrowser('is_ie8') ? ' onkeypress="if (sp_catch_enter(event)) { sp_submit_shout(' . $shoutbox['id'] . ', \'' . $context['session_var'] . '\', \'' . $context['session_id'] . '\'); return false; }"' : '', ' />
				<input type="submit" name="submit_shout" value="', $txt['sp_shoutbox_button'], '" class="right_submit" onclick="sp_submit_shout(', $shoutbox['id'], ', \'', $context['session_var'], '\', \'', $context['session_id'], '\'); return false;" />
			</div>';
    }
    echo '
		</div>
		<input type="hidden" name="shoutbox_id" value="', $shoutbox['id'], '" />
		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
	</form>

	<script><!-- // --><![CDATA[
		var last_refresh_', $shoutbox['id'], ' = ', time(), ';';
    if ($shoutbox['reverse']) {
        echo '
		var objDiv = document.getElementById("shouts_', $shoutbox['id'], '");
		objDiv.scrollTop = objDiv.scrollHeight;';
    }
    if (!empty($shoutbox['refresh'])) {
        echo '
		var interval_id_', $shoutbox['id'], ' = setInterval("sp_auto_refresh_', $shoutbox['id'], '()", ', $shoutbox['refresh'], ' * 1000);
		function sp_auto_refresh_', $shoutbox['id'], '()
		{
			if (window.XMLHttpRequest)
			{
				sp_refresh_shout(', $shoutbox['id'], ', last_refresh_', $shoutbox['id'], ');
				last_refresh_', $shoutbox['id'], ' += ', $shoutbox['refresh'], ';
			}
			else
				clearInterval(interval_id_', $shoutbox['id'], ');
		}';
    }
    // Setup the data for the popup smileys.
    if (!empty($shoutbox['smileys']['popup'])) {
        echo '
		if (sp_smileys == undefined)
			var sp_smileys = [';
        foreach ($shoutbox['smileys']['popup'] as $smiley) {
            echo '
					["', $smiley['code'], '","', $smiley['filename'], '","', $smiley['js_description'], '"]';
            if (empty($smiley['last'])) {
                echo ',';
            }
        }
        echo ']';
        echo '
		if (sp_moreSmileysTemplate == undefined)
		{
			var sp_moreSmileysTemplate = ', JavaScriptEscape('<!DOCTYPE html>
<html>
	<head>
		<title>' . $txt['more_smileys_title'] . '</title>
		<link rel="stylesheet" type="text/css" href="' . $settings['theme_url'] . '/css/index' . $context['theme_variant'] . '.css" />
	</head>
	<body id="help_popup">
		<div class="padding">
			<h3 class="category_header">
				' . $txt['more_smileys_pick'] . '
			</h3>
			<div class="padding">
				%smileyRows%
			</div>
			<div class="smalltext centertext">
				<a href="javascript:window.close();">' . $txt['more_smileys_close_window'] . '</a>
			</div>
		</div>
	</body>
</html>'), '
		}';
    }
    echo '
	// ]]></script>';
}
Example #23
0
/**
 * Creates a box that can be used for richedit stuff like BBC, Smileys etc.
 * @param mixed[] $editorOptions associative array of options => value
 *  must contain:
 *   - id => unique id for the css
 *   - value => text for the editor or blank
 *  Optionaly
 *   - height => height of the intial box
 *   - width => width of the box (100%)
 *   - force_rich => force wysiwyg to be enabled
 *   - disable_smiley_box => boolean to turn off the smiley box
 *   - labels => array(
 *       - 'post_button' => $txt['for post button'],
 *     ),
 *   - preview_type => 2 how to act on preview click, see template_control_richedit_buttons
 */
function create_control_richedit($editorOptions)
{
    global $txt, $modSettings, $options, $context, $settings, $user_info, $scripturl;
    static $bbc_tags;
    $db = database();
    // Load the Post language file... for the moment at least.
    loadLanguage('Post');
    if (!empty($context['drafts_save']) || !empty($context['drafts_pm_save'])) {
        loadLanguage('Drafts');
    }
    // Every control must have a ID!
    assert(isset($editorOptions['id']));
    assert(isset($editorOptions['value']));
    // Is this the first richedit - if so we need to ensure things are initialised and that we load all of the needed files
    if (empty($context['controls']['richedit'])) {
        // Store the name / ID we are creating for template compatibility.
        $context['post_box_name'] = $editorOptions['id'];
        // Some general stuff.
        $settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set'];
        if (!empty($context['drafts_autosave']) && !empty($options['drafts_autosave_enabled'])) {
            $context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 30000 : $modSettings['drafts_autosave_frequency'] * 1000;
        }
        // This really has some WYSIWYG stuff.
        loadTemplate('GenericControls', 'jquery.sceditor');
        if (!empty($context['theme_variant']) && file_exists($settings['theme_dir'] . '/css/' . $context['theme_variant'] . '/jquery.sceditor.elk' . $context['theme_variant'] . '.css')) {
            loadCSSFile($context['theme_variant'] . '/jquery.sceditor.elk' . $context['theme_variant'] . '.css');
        }
        // JS makes the editor go round
        loadJavascriptFile(array('jquery.sceditor.min.js', 'jquery.sceditor.bbcode.min.js', 'jquery.sceditor.elkarte.js', 'post.js', 'splittag.plugin.js', 'dropAttachments.js'));
        addJavascriptVar(array('post_box_name' => $editorOptions['id'], 'elk_smileys_url' => $settings['smileys_url'], 'bbc_quote_from' => $txt['quote_from'], 'bbc_quote' => $txt['quote'], 'bbc_search_on' => $txt['search_on']), true);
        // Editor language file
        if (!empty($txt['lang_locale'])) {
            loadJavascriptFile($scripturl . '?action=jslocale;sa=sceditor', array('defer' => true), 'sceditor_language');
        }
        // Drafts?
        if ((!empty($context['drafts_save']) || !empty($context['drafts_pm_save'])) && !empty($context['drafts_autosave']) && !empty($options['drafts_autosave_enabled'])) {
            loadJavascriptFile('drafts.plugin.js');
        }
        // Mentions?
        if (!empty($context['mentions_enabled'])) {
            loadJavascriptFile(array('jquery.atwho.js', 'jquery.caret.min.js', 'mentioning.plugin.js'));
        }
        // Our not so concise shortcut line
        $context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) || !empty($context['drafts_pm_save']) ? '_drafts' : '') . (isBrowser('is_firefox') ? '_firefox' : '')];
        // Spellcheck?
        $context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && function_exists('pspell_new');
        if ($context['show_spellchecking']) {
            // Some hidden information is needed in order to make spell check work.
            if (!isset($_REQUEST['xml'])) {
                $context['insert_after_template'] .= '
		<form name="spell_form" id="spell_form" method="post" accept-charset="UTF-8" target="spellWindow" action="' . $scripturl . '?action=spellcheck">
			<input type="hidden" name="spellstring" value="" />
			<input type="hidden" name="fulleditor" value="" />
		</form>';
            }
            loadJavascriptFile('spellcheck.js', array('defer' => true));
        }
    }
    // Start off the editor...
    $context['controls']['richedit'][$editorOptions['id']] = array('id' => $editorOptions['id'], 'value' => $editorOptions['value'], 'rich_active' => !empty($options['wysiwyg_default']) || !empty($editorOptions['force_rich']) || !empty($_REQUEST[$editorOptions['id'] . '_mode']), 'disable_smiley_box' => !empty($editorOptions['disable_smiley_box']), 'columns' => isset($editorOptions['columns']) ? $editorOptions['columns'] : 60, 'rows' => isset($editorOptions['rows']) ? $editorOptions['rows'] : 18, 'width' => isset($editorOptions['width']) ? $editorOptions['width'] : '100%', 'height' => isset($editorOptions['height']) ? $editorOptions['height'] : '250px', 'form' => isset($editorOptions['form']) ? $editorOptions['form'] : 'postmodify', 'bbc_level' => !empty($editorOptions['bbc_level']) ? $editorOptions['bbc_level'] : 'full', 'preview_type' => isset($editorOptions['preview_type']) ? (int) $editorOptions['preview_type'] : 1, 'labels' => !empty($editorOptions['labels']) ? $editorOptions['labels'] : array(), 'locale' => !empty($txt['lang_locale']) ? $txt['lang_locale'] : 'en_US');
    // Switch between default images and back... mostly in case you don't have an PersonalMessage template, but do have a Post template.
    if (isset($settings['use_default_images']) && $settings['use_default_images'] == 'defaults' && isset($settings['default_template'])) {
        $temp1 = $settings['theme_url'];
        $settings['theme_url'] = $settings['default_theme_url'];
        $temp2 = $settings['images_url'];
        $settings['images_url'] = $settings['default_images_url'];
        $temp3 = $settings['theme_dir'];
        $settings['theme_dir'] = $settings['default_theme_dir'];
    }
    if (empty($bbc_tags)) {
        // The below array is used to show a command button in the editor, the execution
        // and display details of any added buttons must be defined in the javascript files
        // see  jquery.sceditor.elkarte.js under the $.sceditor.plugins.bbcode.bbcode area
        // for examples of how to use the .set command to add codes.  Include your new
        // JS with addInlineJavascript() or loadJavascriptFile()
        $bbc_tags['row1'] = array(array('bold', 'italic', 'underline', 'strike', 'superscript', 'subscript'), array('left', 'center', 'right', 'pre', 'tt'), array('font', 'size', 'color'));
        $bbc_tags['row2'] = array(array('quote', 'code', 'table'), array('bulletlist', 'orderedlist', 'horizontalrule'), array('spoiler', 'footnote'), array('image', 'link', 'email'));
        // Allow mods to add BBC buttons to the toolbar, actions are defined in the JS
        call_integration_hook('integrate_bbc_buttons', array(&$bbc_tags));
        // Show the wysiwyg format and toggle buttons?
        $bbc_tags['row2'][] = array('removeformat', 'source');
        // Generate a list of buttons that shouldn't be shown
        $disabled_tags = array();
        if (!empty($modSettings['disabledBBC'])) {
            $disabled_tags = explode(',', $modSettings['disabledBBC']);
        }
        // Map codes to tags
        $translate_tags_to_code = array('b' => 'bold', 'i' => 'italic', 'u' => 'underline', 's' => 'strike', 'img' => 'image', 'url' => 'link', 'sup' => 'superscript', 'sub' => 'subscript', 'hr' => 'horizontalrule');
        // Remove the toolbar buttons for any bbc tags that have been turned off in the ACP
        foreach ($disabled_tags as $tag) {
            // list is special, its prevents two tags
            if ($tag === 'list') {
                $context['disabled_tags']['bulletlist'] = true;
                $context['disabled_tags']['orderedlist'] = true;
            } elseif (isset($translate_tags_to_code[$tag])) {
                $context['disabled_tags'][$translate_tags_to_code[$tag]] = true;
            }
            // Tag is the same as the code, like font, color, size etc
            $context['disabled_tags'][trim($tag)] = true;
        }
        // Build our toolbar, taking in to account any bbc codes from integration
        $context['bbc_toolbar'] = array();
        foreach ($bbc_tags as $row => $tagRow) {
            if (!isset($context['bbc_toolbar'][$row])) {
                $context['bbc_toolbar'][$row] = array();
            }
            $tagsRow = array();
            // For each row of buttons defined, lets build our tags
            foreach ($tagRow as $tags) {
                foreach ($tags as $tag) {
                    // Just add this code in the existing grouping
                    if (!isset($context['disabled_tags'][$tag])) {
                        $tagsRow[] = $tag;
                    }
                }
                // If the row is not empty, and the last added tag is not a space, add a space.
                if (!empty($tagsRow) && $tagsRow[count($tagsRow) - 1] != 'space') {
                    $tagsRow[] = 'space';
                }
            }
            // Build that beautiful button row
            if (!empty($tagsRow)) {
                $context['bbc_toolbar'][$row][] = implode(',', $tagsRow);
            }
        }
    }
    // Initialize smiley array... if not loaded before.
    if (empty($context['smileys']) && empty($editorOptions['disable_smiley_box'])) {
        $context['smileys'] = array('postform' => array(), 'popup' => array());
        // Load smileys - don't bother to run a query if we're not using the database's ones anyhow.
        if (empty($modSettings['smiley_enable']) && $user_info['smiley_set'] != 'none') {
            $context['smileys']['postform'][] = array('smileys' => array(array('code' => ':)', 'filename' => 'smiley.gif', 'description' => $txt['icon_smiley']), array('code' => ';)', 'filename' => 'wink.gif', 'description' => $txt['icon_wink']), array('code' => ':D', 'filename' => 'cheesy.gif', 'description' => $txt['icon_cheesy']), array('code' => ';D', 'filename' => 'grin.gif', 'description' => $txt['icon_grin']), array('code' => '>:(', 'filename' => 'angry.gif', 'description' => $txt['icon_angry']), array('code' => ':))', 'filename' => 'laugh.gif', 'description' => $txt['icon_laugh']), array('code' => ':(', 'filename' => 'sad.gif', 'description' => $txt['icon_sad']), array('code' => ':o', 'filename' => 'shocked.gif', 'description' => $txt['icon_shocked']), array('code' => '8)', 'filename' => 'cool.gif', 'description' => $txt['icon_cool']), array('code' => '???', 'filename' => 'huh.gif', 'description' => $txt['icon_huh']), array('code' => '::)', 'filename' => 'rolleyes.gif', 'description' => $txt['icon_rolleyes']), array('code' => ':P', 'filename' => 'tongue.gif', 'description' => $txt['icon_tongue']), array('code' => ':-[', 'filename' => 'embarrassed.gif', 'description' => $txt['icon_embarrassed']), array('code' => ':-X', 'filename' => 'lipsrsealed.gif', 'description' => $txt['icon_lips']), array('code' => ':-\\', 'filename' => 'undecided.gif', 'description' => $txt['icon_undecided']), array('code' => ':-*', 'filename' => 'kiss.gif', 'description' => $txt['icon_kiss']), array('code' => 'O:)', 'filename' => 'angel.gif', 'description' => $txt['icon_angel']), array('code' => ':\'(', 'filename' => 'cry.gif', 'description' => $txt['icon_cry'], 'isLast' => true)), 'isLast' => true);
        } elseif ($user_info['smiley_set'] != 'none') {
            if (($temp = cache_get_data('posting_smileys', 480)) == null) {
                $request = $db->query('', '
					SELECT code, filename, description, smiley_row, hidden
					FROM {db_prefix}smileys
					WHERE hidden IN (0, 2)
					ORDER BY smiley_row, smiley_order', array());
                while ($row = $db->fetch_assoc($request)) {
                    $row['filename'] = htmlspecialchars($row['filename'], ENT_COMPAT, 'UTF-8');
                    $row['description'] = htmlspecialchars($row['description'], ENT_COMPAT, 'UTF-8');
                    $context['smileys'][empty($row['hidden']) ? 'postform' : 'popup'][$row['smiley_row']]['smileys'][] = $row;
                }
                $db->free_result($request);
                foreach ($context['smileys'] as $section => $smileyRows) {
                    $last_row = null;
                    foreach ($smileyRows as $rowIndex => $smileys) {
                        $context['smileys'][$section][$rowIndex]['smileys'][count($smileys['smileys']) - 1]['isLast'] = true;
                        $last_row = $rowIndex;
                    }
                    if ($last_row !== null) {
                        $context['smileys'][$section][$last_row]['isLast'] = true;
                    }
                }
                cache_put_data('posting_smileys', $context['smileys'], 480);
            } else {
                $context['smileys'] = $temp;
            }
            // The smiley popup may take advantage of Jquery UI ....
            if (!empty($context['smileys']['popup'])) {
                $modSettings['jquery_include_ui'] = true;
            }
        }
    }
    // Set a flag so the sub template knows what to do...
    $context['show_bbc'] = !empty($modSettings['enableBBC']) && !empty($settings['show_bbc']);
    // Switch the URLs back... now we're back to whatever the main sub template is.  (like folder in PersonalMessage.)
    if (isset($settings['use_default_images']) && $settings['use_default_images'] == 'defaults' && isset($settings['default_template'])) {
        $settings['theme_url'] = $temp1;
        $settings['images_url'] = $temp2;
        $settings['theme_dir'] = $temp3;
    }
    if (!empty($editorOptions['live_errors'])) {
        loadLanguage('Errors');
        addInlineJavascript('
	error_txts[\'no_subject\'] = ' . JavaScriptEscape($txt['error_no_subject']) . ';
	error_txts[\'no_message\'] = ' . JavaScriptEscape($txt['error_no_message']) . ';

	var subject_err = new errorbox_handler({
		self: \'subject_err\',
		error_box_id: \'post_error\',
		error_checks: [{
			code: \'no_subject\',
			efunction: function(box_value) {
				if (box_value.length === 0)
					return true;
				else
					return false;
			}
		}],
		check_id: "post_subject"
	});

	var body_err_' . $editorOptions['id'] . ' = new errorbox_handler({
		self: \'body_err_' . $editorOptions['id'] . '\',
		error_box_id: \'post_error\',
		error_checks: [{
			code: \'no_message\',
			efunction: function(box_value) {
				if (box_value.length === 0)
					return true;
				else
					return false;
			}
		}],
		editor_id: \'' . $editorOptions['id'] . '\',
		editor: ' . JavaScriptEscape('
		(function () {
			return $editor_data[\'' . $editorOptions['id'] . '\'].val();
		});') . '
	});', true);
    }
}
Example #24
0
/**
 * Dumps the database.
 *
 * What it does:
 * - It writes all of the database to standard output.
 * - It uses gzip compression if compress is set in the URL/post data.
 * - It may possibly time out, and mess up badly if you were relying on it. :P
 * - The data dumped depends on whether "struct" and "data" are passed.
 * - It is called from ManageMaintenance.controller.php.
 */
function DumpDatabase2()
{
    global $db_name, $scripturl, $modSettings, $db_prefix, $db_show_debug;
    // We'll need a db to dump :P
    $database = database();
    // We don't need debug when dumping the database
    $modSettings['disableQueryCheck'] = true;
    $db_show_debug = false;
    // You can't dump nothing!
    if (!isset($_REQUEST['struct']) && !isset($_REQUEST['data'])) {
        $_REQUEST['data'] = true;
    }
    // Attempt to stop from dying...
    @set_time_limit(600);
    $time_limit = ini_get('max_execution_time');
    $start_time = time();
    // @todo ... fail on not getting the requested memory?
    setMemoryLimit('256M');
    $memory_limit = memoryReturnBytes(ini_get('memory_limit')) / 4;
    $current_used_memory = 0;
    $db_backup = '';
    $output_function = 'un_compressed';
    @ob_end_clean();
    // Start saving the output... (don't do it otherwise for memory reasons.)
    if (isset($_REQUEST['compress']) && function_exists('gzencode')) {
        $output_function = 'gzencode';
        // Send faked headers so it will just save the compressed output as a gzip.
        header('Content-Type: application/x-gzip');
        header('Accept-Ranges: bytes');
        header('Content-Encoding: none');
        // Gecko browsers... don't like this. (Mozilla, Firefox, etc.)
        if (!isBrowser('gecko')) {
            header('Content-Transfer-Encoding: binary');
        }
        // The file extension will include .gz...
        $extension = '.sql.gz';
    } else {
        // Get rid of the gzipping alreading being done.
        if (!empty($modSettings['enableCompressedOutput'])) {
            @ob_end_clean();
        } elseif (ob_get_length() != 0) {
            ob_clean();
        }
        // Tell the client to save this file, even though it's text.
        header('Content-Type: ' . (isBrowser('ie') || isBrowser('opera') ? 'application/octetstream' : 'application/octet-stream'));
        header('Content-Encoding: none');
        // This time the extension should just be .sql.
        $extension = '.sql';
    }
    // This should turn off the session URL parser.
    $scripturl = '';
    // Send the proper headers to let them download this file.
    header('Content-Disposition: attachment; filename="' . $db_name . '-' . (empty($_REQUEST['struct']) ? 'data' : (empty($_REQUEST['data']) ? 'structure' : 'complete')) . '_' . strftime('%Y-%m-%d') . $extension . '"');
    header('Cache-Control: private');
    header('Connection: close');
    // This makes things simpler when using it so very very often.
    $crlf = "\r\n";
    // SQL Dump Header.
    $db_chunks = '-- ==========================================================' . $crlf . '--' . $crlf . '-- Database dump of tables in `' . $db_name . '`' . $crlf . '-- ' . standardTime(time(), false) . $crlf . '--' . $crlf . '-- ==========================================================' . $crlf . $crlf;
    // Get all tables in the database....for our installation
    $real_prefix = preg_match('~^(`?)(.+?)\\1\\.(.*?)$~', $db_prefix, $match) === 1 ? $match[3] : $db_prefix;
    $tables = $database->db_list_tables(false, $real_prefix . '%');
    // Dump each table.
    foreach ($tables as $tableName) {
        // Are we dumping the structures?
        if (isset($_REQUEST['struct'])) {
            $db_chunks .= $crlf . '--' . $crlf . '-- Table structure for table `' . $tableName . '`' . $crlf . '--' . $crlf . $crlf . $database->db_table_sql($tableName) . ';' . $crlf;
        } else {
            // This is needed to speedup things later
            $database->db_table_sql($tableName);
        }
        // How about the data?
        if (!isset($_REQUEST['data']) || substr($tableName, -10) == 'log_errors') {
            continue;
        }
        $first_round = true;
        $close_table = false;
        // Are there any rows in this table?
        while ($get_rows = $database->insert_sql($tableName, $first_round)) {
            if (empty($get_rows)) {
                break;
            }
            // Time is what we need here!
            if (function_exists('apache_reset_timeout')) {
                @apache_reset_timeout();
            } elseif (!empty($time_limit) && $start_time + $time_limit - 20 > time()) {
                $start_time = time();
                @set_time_limit(150);
            }
            // for the first pass, start the output with a custom line...
            if ($first_round) {
                $db_chunks .= $crlf . '--' . $crlf . '-- Dumping data in `' . $tableName . '`' . $crlf . '--' . $crlf . $crlf;
                $first_round = false;
            }
            $db_chunks .= $get_rows;
            $current_used_memory += Util::strlen($db_chunks);
            $db_backup .= $db_chunks;
            unset($db_chunks);
            $db_chunks = '';
            if ($current_used_memory > $memory_limit) {
                echo $output_function($db_backup);
                $current_used_memory = 0;
                // This is probably redundant
                unset($db_backup);
                $db_backup = '';
            }
            $close_table = true;
        }
        // No rows to get - skip it.
        if ($close_table) {
            $db_backup .= '-- --------------------------------------------------------' . $crlf;
        }
    }
    // write the last line
    $db_backup .= $crlf . '-- Done' . $crlf;
    echo $output_function($db_backup);
    exit;
}
Example #25
0
/**
 * Below is the template for adding/editing an board on the forum.
 */
function template_modify_board()
{
    global $context, $scripturl, $txt, $modSettings;
    // The main table header.
    echo '
	<div id="manage_boards">
		<form action="', $scripturl, '?action=admin;area=manageboards;sa=board2" method="post" accept-charset="UTF-8">
			<input type="hidden" name="boardid" value="', $context['board']['id'], '" />
			<h2 class="category_header">
				', isset($context['board']['is_new']) ? $txt['mboards_new_board_name'] : $txt['boardsEdit'], '
			</h2>
			<div class="windowbg">
				<div class="content">
					<dl class="settings">';
    // Option for choosing the category the board lives in.
    echo '

						<dt>
							<strong><label for="new_cat">', $txt['mboards_category'], '</label>:</strong>
						</dt>
						<dd>
							<select id="new_cat" name="new_cat" onchange="if (this.form.order) {this.form.order.disabled = this.options[this.selectedIndex].value != 0; this.form.board_order.disabled = this.options[this.selectedIndex].value != 0 || this.form.order.options[this.form.order.selectedIndex].value == \'\';}">';
    foreach ($context['categories'] as $category) {
        echo '
								<option', $category['selected'] ? ' selected="selected"' : '', ' value="', $category['id'], '">', $category['name'], '</option>';
    }
    echo '
							</select>
						</dd>';
    // If this isn't the only board in this category let the user choose where the board is to live.
    if (isset($context['board']['is_new']) && count($context['board_order']) > 0 || count($context['board_order']) > 1) {
        echo '
						<dt>
							<strong><label for="order">', $txt['order'], '</label>:</strong>
						</dt>
						<dd>';
        // The first select box gives the user the option to position it before, after or as a child of another board.
        echo '
							<select id="order" name="placement" onchange="this.form.board_order.disabled = this.options[this.selectedIndex].value == \'\';">
								', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : '', '
								<option value="after">' . $txt['mboards_order_after'] . '...</option>
								<option value="child">' . $txt['mboards_order_child_of'] . '...</option>
								<option value="before">' . $txt['mboards_order_before'] . '...</option>
							</select>';
        // The second select box lists all the boards in the category.
        echo '
							<select id="board_order" name="board_order" ', isset($context['board']['is_new']) ? '' : 'disabled="disabled"', '>
									', !isset($context['board']['is_new']) ? '<option value="">(' . $txt['mboards_unchanged'] . ')</option>' : '';
        foreach ($context['board_order'] as $order) {
            echo '
								<option', $order['selected'] ? ' selected="selected"' : '', ' value="', $order['id'], '">', $order['name'], '</option>';
        }
        echo '
							</select>
						</dd>';
    }
    // Options for board name and description.
    echo '
						<dt>
							<strong><label for="board_name">', $txt['full_name'], '</label>:</strong><br />
							<span class="smalltext">', $txt['name_on_display'], '</span>
						</dt>
						<dd>
							<input type="text" id="board_name" name="board_name" value="', $context['board']['name'], '" size="30" class="input_text" />
						</dd>
						<dt>
							<strong><label for="desc">', $txt['mboards_description'], '</label>:</strong><br />
							<span class="smalltext">', $txt['mboards_description_desc'], '</span>
						</dt>
						<dd>
							<textarea id="desc" name="desc" rows="3" cols="35" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 99%; min-width: 99%' : 'width: 99%') . ';">', $context['board']['description'], '</textarea>
						</dd>
						<dt>
							<strong><label for="profile">', $txt['permission_profile'], '</label>:</strong><br />
							<span class="smalltext">', $context['can_manage_permissions'] ? sprintf($txt['permission_profile_desc'], $scripturl . '?action=admin;area=permissions;sa=profiles;' . $context['session_var'] . '=' . $context['session_id']) : strip_tags($txt['permission_profile_desc']), '</span>
						</dt>
						<dd>
							<select id="profile" name="profile">';
    if (isset($context['board']['is_new'])) {
        echo '
								<option value="-1">[', $txt['permission_profile_inherit'], ']</option>';
    }
    foreach ($context['profiles'] as $id => $profile) {
        echo '
								<option value="', $id, '" ', $id == $context['board']['profile'] ? 'selected="selected"' : '', '>', $profile['name'], '</option>';
    }
    echo '
							</select>
						</dd>
						<dt>
							<strong>', $txt['mboards_groups'], ':</strong><br />
							<span class="smalltext">', empty($modSettings['deny_boards_access']) ? $txt['mboards_groups_desc'] : $txt['boardsaccess_option_desc'], '</span>';
    echo '
						</dt>
						<dd>';
    if (!empty($modSettings['deny_boards_access'])) {
        echo '
							<table>
								<tr>
									<td></td>
									<th>', $txt['permissions_option_on'], '</th>
									<th>', $txt['permissions_option_off'], '</th>
									<th>', $txt['permissions_option_deny'], '</th>
									<th></th>
								</tr>';
    }
    // List all the membergroups so the user can choose who may access this board.
    foreach ($context['groups'] as $group) {
        if (empty($modSettings['deny_boards_access'])) {
            echo '
							<label for="groups_', $group['id'], '">
								<input type="checkbox" name="groups[', $group['id'], ']" value="allow" id="groups_', $group['id'], '"', $group['allow'] ? ' checked="checked"' : '', ' class="input_check" />
								<span', $group['is_post_group'] ? ' class="post_group" title="' . $txt['mboards_groups_post_group'] . '"' : '', $group['id'] == 0 ? ' class="regular_members" title="' . $txt['mboards_groups_regular_members'] . '"' : '', '>
									', $group['name'], '
								</span>
							</label>
							<br />';
        } else {
            echo '
								<tr>
									<td>
										<span', $group['is_post_group'] ? ' class="post_group" title="' . $txt['mboards_groups_post_group'] . '"' : '', $group['id'] == 0 ? ' class="regular_members" title="' . $txt['mboards_groups_regular_members'] . '"' : '', '>
											', $group['name'], '
										</span>
									</td>
									<td>
										<input type="radio" name="groups[', $group['id'], ']" value="allow" id="groups_', $group['id'], '_a"', $group['allow'] ? ' checked="checked"' : '', ' class="input_radio" />
									</td>
									<td>
										<input type="radio" name="groups[', $group['id'], ']" value="ignore" id="groups_', $group['id'], '_x"', !$group['allow'] && !$group['deny'] ? ' checked="checked"' : '', ' class="input_radio" />
									</td>
									<td>
										<input type="radio" name="groups[', $group['id'], ']" value="deny" id="groups_', $group['id'], '_d"', $group['deny'] ? ' checked="checked"' : '', ' class="input_radio" />
									</td>
									<td></td>
								</tr>';
        }
    }
    if (empty($modSettings['deny_boards_access'])) {
        echo '
							<span class="select_all_box">
								<em><label for="check_all">', $txt['check_all'], '</label></em> <input type="checkbox" id="check_all" class="input_check" onclick="invertAll(this, this.form, \'groups[\');" />
							</span>
							<br />
							<br />
						</dd>';
    } else {
        echo '
								<tr class="select_all_box">
									<td>
									</td>
									<td>
										<input type="radio" name="select_all" class="input_radio" onclick="selectAllRadio(this, this.form, \'groups\', \'allow\');" />
									</td>
									<td>
										<input type="radio" name="select_all" class="input_radio" onclick="selectAllRadio(this, this.form, \'groups\', \'ignore\');" />
									</td>
									<td>
										<input type="radio" name="select_all" class="input_radio" onclick="selectAllRadio(this, this.form, \'groups\', \'deny\');" />
									</td>
									<td>
										<em>', $txt['check_all'], '</em>
									</td>
								</tr>
							</table>
						</dd>';
    }
    // Options to choose moderators, specify as announcement board and choose whether to count posts here.
    echo '
						<dt>
							<strong><label for="moderators">', $txt['mboards_moderators'], '</label>:</strong><br />
							<span class="smalltext">', $txt['mboards_moderators_desc'], '</span><br />
						</dt>
						<dd>
							<input type="text" name="moderators" id="moderators" value="', $context['board']['moderator_list'], '" size="30" class="input_text" />
							<div id="moderator_container"></div>
						</dd>
					</dl>
					<hr />';
    // Add a select all box for the allowed groups section
    echo '
					<script><!-- // --><![CDATA[
						$(document).ready(function () {
							$(".select_all_box").each(function () {
								$(this).removeClass(\'select_all_box\');
							});
						});
					// ]]></script>';
    if (empty($context['board']['is_recycle']) && empty($context['board']['topics'])) {
        echo '
					<dl class="settings">
						<dt>
							<strong><label for="redirect_enable">', $txt['mboards_redirect'], '</label>:</strong><br />
							<span class="smalltext">', $txt['mboards_redirect_desc'], '</span><br />
						</dt>
						<dd>
							<input type="checkbox" id="redirect_enable" name="redirect_enable"', $context['board']['redirect'] != '' ? ' checked="checked"' : '', ' onclick="refreshOptions();" class="input_check" />
						</dd>
					</dl>';
    }
    if (!empty($context['board']['is_recycle'])) {
        echo '
					<div class="infobox">', $txt['mboards_redirect_disabled_recycle'], '<br />', $txt['mboards_recycle_disabled_delete'], '</div>';
    }
    if (empty($context['board']['is_recycle']) && !empty($context['board']['topics'])) {
        echo '
					<div class="infobox">
						<strong>', $txt['mboards_redirect'], '</strong><br />
						', $txt['mboards_redirect_disabled'], '
					</div>';
    }
    if (!$context['board']['topics'] && empty($context['board']['is_recycle'])) {
        echo '
					<div id="redirect_address_div">
						<dl class="settings">
							<dt>
								<strong><label for="redirect_address">', $txt['mboards_redirect_url'], '</label>:</strong><br />
								<span class="smalltext">', $txt['mboards_redirect_url_desc'], '</span><br />
							</dt>
							<dd>
								<input type="text" id="redirect_address" name="redirect_address" value="', $context['board']['redirect'], '" size="40" class="input_text" />
							</dd>
						</dl>
					</div>';
        if ($context['board']['redirect']) {
            echo '
					<div id="reset_redirect_div">
						<dl class="settings">
							<dt>
								<strong><label for="reset_redirect">', $txt['mboards_redirect_reset'], '</label>:</strong><br />
								<span class="smalltext">', $txt['mboards_redirect_reset_desc'], '</span><br />
							</dt>
							<dd>
								<input type="checkbox" id="reset_redirect" name="reset_redirect" class="input_check" />
								<em>(', sprintf($txt['mboards_current_redirects'], $context['board']['posts']), ')</em>
							</dd>
						</dl>
					</div>';
        }
    }
    echo '
					<div id="count_posts_div">
						<dl class="settings">
							<dt>
								<strong><label for="count">', $txt['mboards_count_posts'], '</label>:</strong><br />
								<span class="smalltext">', $txt['mboards_count_posts_desc'], '</span><br />
							</dt>
							<dd>
								<input type="checkbox" id="count" name="count" ', $context['board']['count_posts'] ? ' checked="checked"' : '', ' class="input_check" />
							</dd>
						</dl>
					</div>';
    // Here the user can choose to force this board to use a theme other than the default theme for the forum.
    echo '
					<div id="board_theme_div">
						<dl class="settings">
							<dt>
								<strong><label for="boardtheme">', $txt['mboards_theme'], '</label>:</strong><br />
								<span class="smalltext">', $txt['mboards_theme_desc'], '</span><br />
							</dt>
							<dd>
								<select name="boardtheme" id="boardtheme" onchange="refreshOptions();">
									<option value="0"', $context['board']['theme'] == 0 ? ' selected="selected"' : '', '>', $txt['mboards_theme_default'], '</option>';
    foreach ($context['themes'] as $theme) {
        echo '
									<option value="', $theme['id'], '"', $context['board']['theme'] == $theme['id'] ? ' selected="selected"' : '', '>', $theme['name'], '</option>';
    }
    echo '
								</select>
							</dd>
						</dl>
					</div>
					<div id="override_theme_div">
						<dl class="settings">
							<dt>
								<strong><label for="override_theme">', $txt['mboards_override_theme'], '</label>:</strong><br />
								<span class="smalltext">', $txt['mboards_override_theme_desc'], '</span><br />
							</dt>
							<dd>
								<input type="checkbox" id="override_theme" name="override_theme"', $context['board']['override_theme'] ? ' checked="checked"' : '', ' class="input_check" />
							</dd>
						</dl>
					</div>';
    echo '
					<div class="submitbutton">
						<input type="hidden" name="rid" value="', $context['redirect_location'], '" />
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
						<input type="hidden" name="', $context['admin-be-' . $context['board']['id'] . '_token_var'], '" value="', $context['admin-be-' . $context['board']['id'] . '_token'], '" />';
    // If this board has no children don't bother with the next confirmation screen.
    if ($context['board']['no_children']) {
        echo '
						<input type="hidden" name="no_children" value="1" />';
    }
    if (isset($context['board']['is_new'])) {
        echo '
						<input type="hidden" name="cur_cat" value="', $context['board']['category'], '" />
						<input type="submit" name="add" value="', $txt['mboards_new_board'], '" onclick="return !isEmptyText(this.form.board_name);" class="button_submit" />';
    } else {
        echo '
						<input type="submit" name="edit" value="', $txt['modify'], '" onclick="return !isEmptyText(this.form.board_name);" class="button_submit" />';
    }
    if (!isset($context['board']['is_new']) && empty($context['board']['is_recycle'])) {
        echo '
						<span', $context['board']['is_recycle'] ? ' style="visibility:hidden">' : '>', '<input type="submit" name="delete" value="', $txt['mboards_delete_board'], '" onclick="return confirm(\'', $txt['boardConfirm'], '\');"', ' class="button_submit" /></span>';
    }
    echo '
					</div>
				</div>
			</div>
		</form>
	</div>';
    $js = '
		var oModeratorSuggest = new smc_AutoSuggest({
			sSelf: \'oModeratorSuggest\',
			sSessionId: elk_session_id,
			sSessionVar: elk_session_var,
			sSuggestId: \'moderators\',
			sControlId: \'moderators\',
			sSearchType: \'member\',
			bItemList: true,
			sPostName: \'moderator_list\',
			sURLMask: \'action=profile;u=%item_id%\',
			sTextDeleteItem: \'' . $txt['autosuggest_delete_item'] . '\',
			sItemListContainerId: \'moderator_container\',
			aListItems: [';
    foreach ($context['board']['moderators'] as $id_member => $member_name) {
        $js .= '
					{
						sItemId: ' . JavaScriptEscape($id_member) . ',
						sItemName: ' . JavaScriptEscape($member_name) . '
					}' . ($id_member == $context['board']['last_moderator_id'] ? '' : ',');
    }
    $js .= '
			]
		});';
    addInlineJavascript($js, true);
    // Javascript for deciding what to show.
    echo '
	<script><!-- // --><![CDATA[
		function refreshOptions()
		{
			var redirect = document.getElementById("redirect_enable"),
				redirectEnabled = redirect ? redirect.checked : false,
				nonDefaultTheme = document.getElementById("boardtheme").value == 0 ? false : true;

			// What to show?
			document.getElementById("override_theme_div").style.display = redirectEnabled || !nonDefaultTheme ? "none" : "";
			document.getElementById("board_theme_div").style.display = redirectEnabled ? "none" : "";
			document.getElementById("count_posts_div").style.display = redirectEnabled ? "none" : "";';
    if (!$context['board']['topics'] && empty($context['board']['is_recycle'])) {
        echo '
			document.getElementById("redirect_address_div").style.display = redirectEnabled ? "" : "none";';
        if ($context['board']['redirect']) {
            echo '
			document.getElementById("reset_redirect_div").style.display = redirectEnabled ? "" : "none";';
        }
    }
    echo '
		}

		refreshOptions();
	// ]]></script>';
}
Example #26
0
/**
 * Rewrite URLs to include the session ID.
 *
 * What it does:
 * - rewrites the URLs outputted to have the session ID, if the user
 *   is not accepting cookies and is using a standard web browser.
 * - handles rewriting URLs for the queryless URLs option.
 * - can be turned off entirely by setting $scripturl to an empty
 *   string, ''. (it wouldn't work well like that anyway.)
 *
 * @param string $buffer
 * @return string
 */
function ob_sessrewrite($buffer)
{
    global $scripturl, $modSettings, $context;
    // If $scripturl is set to nothing, or the SID is not defined (SSI?) just quit.
    if ($scripturl == '' || !defined('SID')) {
        return $buffer;
    }
    // Do nothing if the session is cookied, or they are a crawler - guests are caught by redirectexit().
    if (empty($_COOKIE) && SID != '' && !isBrowser('possibly_robot')) {
        $buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '(?!\\?' . preg_quote(SID, '/') . ')\\??/', '"' . $scripturl . '?' . SID . '&amp;', $buffer);
    } elseif (isset($_GET['debug'])) {
        $buffer = preg_replace('/(?<!<link rel="canonical" href=)"' . preg_quote($scripturl, '/') . '\\??/', '"' . $scripturl . '?debug;', $buffer);
    }
    // This should work even in 4.2.x, just not CGI without cgi.fix_pathinfo.
    if (!empty($modSettings['queryless_urls']) && (!$context['server']['is_cgi'] || ini_get('cgi.fix_pathinfo') == 1 || @get_cfg_var('cgi.fix_pathinfo') == 1) && ($context['server']['is_apache'] || $context['server']['is_lighttpd'] || $context['server']['is_litespeed'])) {
        // Let's do something special for session ids!
        $buffer = preg_replace_callback('~"' . preg_quote($scripturl, '~') . '\\?((?:board|topic)=[^#"]+?)(#[^"]*?)?"~', 'buffer_callback', $buffer);
    }
    // Return the changed buffer.
    return $buffer;
}
Example #27
0
/**
 * This function performs all additional stuff...
 */
function MessageActionsApply()
{
    global $txt, $context, $user_info, $options, $smcFunc;
    checkSession('request');
    if (isset($_REQUEST['del_selected'])) {
        $_REQUEST['pm_action'] = 'delete';
    }
    if (isset($_REQUEST['pm_action']) && $_REQUEST['pm_action'] != '' && !empty($_REQUEST['pms']) && is_array($_REQUEST['pms'])) {
        foreach ($_REQUEST['pms'] as $pm) {
            $_REQUEST['pm_actions'][(int) $pm] = $_REQUEST['pm_action'];
        }
    }
    if (empty($_REQUEST['pm_actions'])) {
        redirectexit($context['current_label_redirect']);
    }
    // If we are in conversation, we may need to apply this to every message in the conversation.
    if ($context['display_mode'] == 2 && isset($_REQUEST['conversation'])) {
        $id_pms = array();
        foreach ($_REQUEST['pm_actions'] as $pm => $dummy) {
            $id_pms[] = (int) $pm;
        }
        $request = $smcFunc['db_query']('', '
			SELECT id_pm_head, id_pm
			FROM {db_prefix}personal_messages
			WHERE id_pm IN ({array_int:id_pms})', array('id_pms' => $id_pms));
        $pm_heads = array();
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            $pm_heads[$row['id_pm_head']] = $row['id_pm'];
        }
        $smcFunc['db_free_result']($request);
        $request = $smcFunc['db_query']('', '
			SELECT id_pm, id_pm_head
			FROM {db_prefix}personal_messages
			WHERE id_pm_head IN ({array_int:pm_heads})', array('pm_heads' => array_keys($pm_heads)));
        // Copy the action from the single to PM to the others.
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            if (isset($pm_heads[$row['id_pm_head']]) && isset($_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]])) {
                $_REQUEST['pm_actions'][$row['id_pm']] = $_REQUEST['pm_actions'][$pm_heads[$row['id_pm_head']]];
            }
        }
        $smcFunc['db_free_result']($request);
    }
    $to_delete = array();
    $to_label = array();
    $label_type = array();
    foreach ($_REQUEST['pm_actions'] as $pm => $action) {
        if ($action === 'delete') {
            $to_delete[] = (int) $pm;
        } else {
            if (substr($action, 0, 4) == 'add_') {
                $type = 'add';
                $action = substr($action, 4);
            } elseif (substr($action, 0, 4) == 'rem_') {
                $type = 'rem';
                $action = substr($action, 4);
            } else {
                $type = 'unk';
            }
            if ($action == '-1' || $action == '0' || (int) $action > 0) {
                $to_label[(int) $pm] = (int) $action;
                $label_type[(int) $pm] = $type;
            }
        }
    }
    // Deleting, it looks like?
    if (!empty($to_delete)) {
        deleteMessages($to_delete, $context['display_mode'] == 2 ? null : $context['folder']);
    }
    // Are we labeling anything?
    if (!empty($to_label) && $context['folder'] == 'inbox') {
        $updateErrors = 0;
        // Get information about each message...
        $request = $smcFunc['db_query']('', '
			SELECT id_pm, labels
			FROM {db_prefix}pm_recipients
			WHERE id_member = {int:current_member}
				AND id_pm IN ({array_int:to_label})
			LIMIT ' . count($to_label), array('current_member' => $user_info['id'], 'to_label' => array_keys($to_label)));
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            $labels = $row['labels'] == '' ? array('-1') : explode(',', trim($row['labels']));
            // Already exists?  Then... unset it!
            $ID_LABEL = array_search($to_label[$row['id_pm']], $labels);
            if ($ID_LABEL !== false && $label_type[$row['id_pm']] !== 'add') {
                unset($labels[$ID_LABEL]);
            } elseif ($label_type[$row['id_pm']] !== 'rem') {
                $labels[] = $to_label[$row['id_pm']];
            }
            if (!empty($options['pm_remove_inbox_label']) && $to_label[$row['id_pm']] != '-1' && ($key = array_search('-1', $labels)) !== false) {
                unset($labels[$key]);
            }
            $set = implode(',', array_unique($labels));
            if ($set == '') {
                $set = '-1';
            }
            // Check that this string isn't going to be too large for the database.
            if ($set > 60) {
                $updateErrors++;
            } else {
                $smcFunc['db_query']('', '
					UPDATE {db_prefix}pm_recipients
					SET labels = {string:labels}
					WHERE id_pm = {int:id_pm}
						AND id_member = {int:current_member}', array('current_member' => $user_info['id'], 'id_pm' => $row['id_pm'], 'labels' => $set));
            }
        }
        $smcFunc['db_free_result']($request);
        // Any errors?
        // @todo Separate the sprintf?
        if (!empty($updateErrors)) {
            fatal_lang_error('labels_too_many', true, array($updateErrors));
        }
    }
    // Back to the folder.
    $_SESSION['pm_selected'] = array_keys($to_label);
    redirectexit($context['current_label_redirect'] . (count($to_label) == 1 ? '#msg' . $_SESSION['pm_selected'][0] : ''), count($to_label) == 1 && isBrowser('ie'));
}
Example #28
0
/**
 * The main sub template above the content.
 */
function template_html_above()
{
    global $context, $settings, $scripturl, $txt, $modSettings;
    // Show right to left and the character set for ease of translating.
    echo '<!DOCTYPE html>
<html', $context['right_to_left'] ? ' dir="rtl"' : '', '>
<head>
	<title>', $context['page_title_html_safe'], '</title>';
    // Tell IE to render the page in standards not compatibility mode. really for ie >= 8
    // Note if this is not in the first 4k, its ignored, that's why its here
    if (isBrowser('ie')) {
        echo '
	<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />';
    }
    // load in any css from addons or themes so they can overwrite if wanted
    template_css();
    // Save some database hits, if a width for multiple wrappers is set in admin.
    if (!empty($settings['forum_width'])) {
        echo '
	<style>
		.wrapper {width: ', $settings['forum_width'], ';}
	</style>';
    }
    echo '
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="viewport" content="width=device-width" />
	<meta name="mobile-web-app-capable" content="yes" />
	<meta name="description" content="', $context['page_title_html_safe'], '" />', !empty($context['meta_keywords']) ? '
	<meta name="keywords" content="' . $context['meta_keywords'] . '" />' : '';
    // OpenID enabled? Advertise the location of our endpoint using YADIS protocol.
    if (!empty($modSettings['enableOpenID'])) {
        echo '
	<meta http-equiv="x-xrds-location" content="' . $scripturl . '?action=xrds" />';
    }
    // Please don't index these Mr Robot.
    if (!empty($context['robot_no_index'])) {
        echo '
	<meta name="robots" content="noindex" />';
    }
    // Present a canonical url for search engines to prevent duplicate content in their indices.
    if (!empty($context['canonical_url'])) {
        echo '
	<link rel="canonical" href="', $context['canonical_url'], '" />';
    }
    // Show all the relative links, such as help, search, contents, and the like.
    echo '
	<link rel="shortcut icon" sizes="196x196" href="' . $settings['images_url'] . '/mobile.png" />
	<link rel="help" href="', $scripturl, '?action=help" />
	<link rel="contents" href="', $scripturl, '" />', $context['allow_search'] ? '
	<link rel="search" href="' . $scripturl . '?action=search" />' : '';
    // If RSS feeds are enabled, advertise the presence of one.
    if (!empty($context['newsfeed_urls'])) {
        echo '
	<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['rss'], '" href="', $context['newsfeed_urls']['rss'], '" />
	<link rel="alternate" type="application/rss+xml" title="', $context['forum_name_html_safe'], ' - ', $txt['atom'], '" href="', $context['newsfeed_urls']['atom'], '" />';
    }
    // If we're viewing a topic, these should be the previous and next topics, respectively.
    if (!empty($context['links']['next'])) {
        echo '<link rel="next" href="', $context['links']['next'], '" />';
    } elseif (!empty($context['current_topic'])) {
        echo '<link rel="next" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=next" />';
    }
    if (!empty($context['links']['prev'])) {
        echo '<link rel="prev" href="', $context['links']['prev'], '" />';
    } elseif (!empty($context['current_topic'])) {
        echo '<link rel="prev" href="', $scripturl, '?topic=', $context['current_topic'], '.0;prev_next=prev" />';
    }
    // If we're in a board, or a topic for that matter, the index will be the board's index.
    if (!empty($context['current_board'])) {
        echo '
	<link rel="index" href="', $scripturl, '?board=', $context['current_board'], '.0" />';
    }
    // load in any javascript files from addons and themes
    template_javascript();
    // Output any remaining HTML headers. (from addons, maybe?)
    echo $context['html_headers'];
    // A little help for our friends
    echo '
	<!--[if lt IE 9]>
		<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->';
    echo '
</head>
<body id="', $context['browser_body_id'], '" class="action_', !empty($context['current_action']) ? htmlspecialchars($context['current_action'], ENT_COMPAT, 'UTF-8') : (!empty($context['current_board']) ? 'messageindex' : (!empty($context['current_topic']) ? 'display' : 'home')), !empty($context['current_board']) ? ' board_' . htmlspecialchars($context['current_board'], ENT_COMPAT, 'UTF-8') : '', '">';
}
Example #29
0
/**
 * Used to display items below the page, like page navigation
 */
function template_pages_and_buttons_below()
{
    global $context, $txt;
    // Show the page index... "Pages: [1]".
    template_pagesection('normal_buttons', 'right');
    // Show the lower breadcrumbs.
    theme_linktree();
    if (can_see_button_strip($context['mod_buttons'])) {
        echo '
			<i class="fa fa-2x fa-bars hamburger_30" data-id="moderationbuttons"></i>';
    }
    echo '
			<div id="moderationbuttons" class="hide_30 hamburger_30_target">', template_button_strip($context['mod_buttons'], 'bottom', array('id' => 'moderationbuttons_strip')), '</div>';
    // Show the jump-to box, or actually...let Javascript do it.
    echo '
			<div id="display_jump_to">&nbsp;</div>
			<script><!-- // --><![CDATA[
				aJumpTo[aJumpTo.length] = new JumpTo({
					sContainerId: "display_jump_to",
					sJumpToTemplate: "<label class=\\"smalltext\\" for=\\"%select_id%\\">', $context['jump_to']['label'], ':<" + "/label> %dropdown_list%",
					iCurBoardId: ', $context['current_board'], ',
					iCurBoardChildLevel: ', $context['jump_to']['child_level'], ',
					sCurBoardName: "', $context['jump_to']['board_name'], '",
					sBoardChildLevelIndicator: "&#8195;",
					sBoardPrefix: "', isBrowser('ie8') ? '&#187; ' : '&#10148; ', '",
					sCatClass: "jump_to_header",
					sCatPrefix: "",
					sGoButtonLabel: "', $txt['go'], '"
				});
			// ]]></script>';
    // Tooltips for likes
    echo '
			<script><!-- // --><![CDATA[
				$(".like_button, .unlike_button, .likes_button").SiteTooltip({hoverIntent: {sensitivity: 10, interval: 150, timeout: 50}});
			// ]]></script>';
}
/**
 * Add a new language
 *
 */
function template_add_language()
{
    global $context, $settings, $options, $txt, $scripturl;
    echo '
	<div id="admincenter">
		<form action="', $scripturl, '?action=admin;area=languages;sa=add;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
			<div class="cat_bar">
				<h3 class="catbg">
					', $txt['add_language'], '
				</h3>
			</div>
			<div class="windowbg">
				<div class="content">
					<fieldset>
						<legend>', $txt['add_language_smf'], '</legend>
						<label class="smalltext">', $txt['add_language_smf_browse'], '</label>
						<input type="text" name="smf_add" size="40" value="', !empty($context['smf_search_term']) ? $context['smf_search_term'] : '', '" class="input_text" />';
    // Do we have some errors? Too bad.
    if (!empty($context['smf_error'])) {
        // Display a little error box.
        echo '
						<div><br /><p class="errorbox">', $txt['add_language_error_' . $context['smf_error']], '</p></div>';
    }
    echo '
					</fieldset>', isBrowser('is_ie') ? '<input type="text" name="ie_fix" style="display: none;" class="input_text" /> ' : '', '
					<input type="submit" name="smf_add_sub" value="', $txt['search'], '" class="button_submit" />
					<br />
				</div>
			</div>
		';
    // Had some results?
    if (!empty($context['smf_languages'])) {
        echo '
			<div class="information">', $txt['add_language_smf_found'], '</div>';
        template_show_list('smf_languages');
    }
    echo '
		</form>
	</div>';
}