function sp_post_editor_default_buttons($out, $spThisTopic, $a, $toolbar)
{
    global $spGlobals, $spVars, $spThisUser, $spDevice;
    extract($a, EXTR_SKIP);
    # sanitize
    $labelSmileys = sp_filter_title_display($labelSmileys);
    $labelOptions = sp_filter_title_display($labelOptions);
    $tipSmileysButton = esc_attr($tipSmileysButton);
    $tipOptionsButton = esc_attr($tipOptionsButton);
    # work out what we need to display
    $display = array();
    $display['smileys'] = false;
    $display['options'] = false;
    if (sp_get_auth('can_use_smileys', $spThisTopic->forum_id)) {
        $display['smileys'] = true;
    }
    if (sp_get_auth('lock_topics', $spThisTopic->forum_id) || sp_get_auth('pin_posts', $spThisTopic->forum_id) || $spThisUser->admin || $spThisUser->moderator) {
        $display['options'] = true;
    }
    $display = apply_filters('sph_post_editor_display_options', $display);
    if ($display['smileys']) {
        if ($spDevice == 'mobile' && array_key_exists('iconMobileSmileys', $a) && !empty($a['iconMobileSmileys'])) {
            # display mobile icon
            $out .= "<img src='" . sp_paint_file_icon(SPTHEMEICONSURL, "{$iconMobileSmileys}") . "' class='spIcon' id='spSmileysButton' onclick='spjOpenEditorBox(\"spSmileysBox\");' />";
        } else {
            # display default button
            $out .= "<input type='button' class='spSubmit spLeft' title='{$tipSmileysButton}' id='spSmileysButton' value='{$labelSmileys}' onclick='spjOpenEditorBox(\"spSmileysBox\");' />";
        }
    }
    if ($display['options']) {
        if ($spDevice == 'mobile' && array_key_exists('iconMobileOptions', $a) && !empty($a['iconMobileOptions'])) {
            # display mobile icon
            $out .= "<img src='" . sp_paint_file_icon(SPTHEMEICONSURL, "{$iconMobileOptions}") . "' class='spIcon' id='spOptionsButton' onclick='spjOpenEditorBox(\"spOptionsBox\");' />";
        } else {
            # display default button
            $out .= "<input type='button' class='spSubmit spLeft' title='{$tipOptionsButton}' id='spOptionsButton' value='{$labelOptions}' onclick='spjOpenEditorBox(\"spOptionsBox\");' />";
        }
    }
    return $out;
}
function sp_ForumIndexPostsIcon($args = '', $toolTip = '')
{
    global $spThisForum, $spGlobals, $spThisUser;
    if (!$spThisForum->unread) {
        return;
    }
    $defs = array('tagId' => 'spForumIndexPostsIcon%ID%', 'tagClass' => 'spIcon', 'icon' => 'sp_ForumStatusPost.png', 'openIcon' => 'sp_GroupOpen.png', 'closeIcon' => 'sp_GroupClose.png', 'popup' => 1, 'first' => 0, 'echo' => 1, 'get' => 0);
    $a = wp_parse_args($args, $defs);
    $a = apply_filters('sph_ForumIndexPostsIcon_args', $a);
    extract($a, EXTR_SKIP);
    # sanitize before use
    $tagId = esc_attr($tagId);
    $tagClass = esc_attr($tagClass);
    $popupIcon = sp_paint_icon('', SPTHEMEICONSURL, sanitize_file_name($icon));
    $openIcon = sp_paint_file_icon(SPTHEMEICONSURL, sanitize_file_name($openIcon));
    $closeIcon = sp_paint_file_icon(SPTHEMEICONSURL, sanitize_file_name($closeIcon));
    $popup = (int) $popup;
    $first = (int) $first;
    $echo = (int) $echo;
    $get = (int) $get;
    $tagId = str_ireplace('%ID%', $spThisForum->forum_id, $tagId);
    $out = '';
    # show new posts icon
    if ($spThisForum->unread) {
        $toolTip = str_ireplace('%COUNT%', $spThisForum->unread, $toolTip);
        $site = SFHOMEURL . "index.php?sp_ahah=newpostpopup&amp;action=forum&amp;id={$spThisForum->forum_id}&amp;popup={$popup}&amp;first={$first}&amp;sfnonce=" . wp_create_nonce('forum-ahah');
        $linkId = 'spNewPostPopup' . $spThisForum->forum_id;
        $out .= "<a id='{$tagId}' class='{$tagClass}' title='{$toolTip}' rel='nofollow' id='{$linkId}' href='javascript:void(null)' ";
        if ($popup) {
            $out .= "onclick='spjDialogAjax(this, \"{$site}\", \"{$toolTip}\", 600, 0, 0);'>";
        } else {
            $target = 'spInlineTopics' . $spThisForum->forum_id;
            $spinner = SFCOMMONIMAGES . 'working.gif';
            $out .= "onclick='spjInlineTopics(\"{$target}\", \"{$site}\", \"{$spinner}\", \"{$tagId}\", \"{$openIcon}\", \"{$closeIcon}\");'>";
        }
        if ($popup) {
            $out .= $popupIcon;
        } else {
            $out .= "<img src='{$openIcon}' alt=''>";
        }
        $out .= "</a>\n";
        $out = apply_filters('sph_ForumIndexPostsIcon', $out, $a);
    }
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}
function sp_render_add_topic_form($args)
{
    global $spVars, $spGlobals, $spThisForum, $spThisUser, $spGuestCookie;
    include_once SF_PLUGIN_DIR . '/forum/content/forms/sp-form-components.php';
    $toolbar = $spGlobals['display']['editor']['toolbar'];
    $defs = array('tagClass' => 'spForm', 'hide' => 1, 'controlFieldset' => 'spEditorFieldset', 'controlInput' => 'spControl', 'controlSubmit' => 'spSubmit', 'controlOrder' => 'cancel|save', 'maxTitleLength' => 200, 'labelHeading' => sp_text('Add Topic'), 'labelGuestName' => sp_text('Guest name (required)'), 'labelGuestEmail' => sp_text('Guest email (required)'), 'labelModerateAll' => sp_text('NOTE: new posts are subject to administrator approval before being displayed'), 'labelModerateOnce' => sp_text('NOTE: first posts are subject to administrator approval before being displayed'), 'labelTopicName' => sp_text('Topic name'), 'labelSmileys' => sp_text('Smileys'), 'labelOptions' => sp_text('Options'), 'labelOptionLock' => sp_text('Lock this topic'), 'labelOptionPin' => sp_text('Pin this post'), 'labelOptionTime' => sp_text('Edit post timestamp'), 'labelMath' => sp_text('Math Required'), 'labelMathSum' => sp_text('What is the sum of'), 'labelPostButtonReady' => sp_text('Submit Topic'), 'labelPostButtonMath' => sp_text('Do Math To Save'), 'labelPostCancel' => sp_text('Cancel'), 'tipSmileysButton' => sp_text('Open/Close to Add a Smiley'), 'tipOptionsButton' => sp_text('Open/Close to select Posting Options'), 'tipSubmitButton' => sp_text('Save the New Topic'), 'tipCancelButton' => sp_text('Cancel the New Topic'));
    $a = wp_parse_args($args, $defs);
    extract($a, EXTR_SKIP);
    # sanitize
    $tagClass = esc_attr($tagClass);
    $hide = (int) $hide;
    $controlFieldset = esc_attr($controlFieldset);
    $controlInput = esc_attr($controlInput);
    $maxTitleLength = (int) $maxTitleLength;
    $labelHeading = sp_filter_title_display($labelHeading);
    $labelGuestName = sp_filter_title_display($labelGuestName);
    $labelGuestEmail = sp_filter_title_display($labelGuestEmail);
    $labelModerateAll = sp_filter_title_display($labelModerateAll);
    $labelModerateOnce = sp_filter_title_display($labelModerateOnce);
    $labelTopicName = sp_filter_title_display($labelTopicName);
    # Check for a failure package in case this is a redirect
    $f = sp_get_cache('post');
    if (isset($f['guestname']) ? $guestnameval = $f['guestname'] : ($guestnameval = $spGuestCookie->guest_name)) {
    }
    if (isset($f['guestemail']) ? $guestemailval = $f['guestemail'] : ($guestemailval = $spGuestCookie->guest_email)) {
    }
    if (isset($f['newtopicname']) ? $topicnameval = $f['newtopicname'] : ($topicnameval = '')) {
    }
    if (isset($f['postitem']) ? $postitemval = $f['postitem'] : ($postitemval = '')) {
    }
    if (isset($f['message']) ? $failmessage = $f['message'] : ($failmessage = '')) {
    }
    $captchaValue = sp_get_option('captcha-value');
    $out = '';
    # Grab above editor message if there is one
    $postmsg = sp_get_option('sfpostmsg');
    # Grab in-editor message if one
    $inEdMsg = sp_filter_text_display(sp_get_option('sfeditormsg'));
    if ($hide ? $hide = ' style="display:none;"' : ($hide = '')) {
    }
    $out .= '<div id="spPostForm"' . $hide . '>' . "\n";
    $out .= "<form class='{$tagClass}' action='" . SFHOMEURL . "index.php?sp_ahah=post&amp;sfnonce=" . wp_create_nonce('forum-ahah') . "' method='post' id='addtopic' name='addtopic' onsubmit='return spjValidatePostForm(this, {$spThisUser->guest}, 1, \"" . sp_paint_file_icon(SPTHEMEICONSURL, 'sp_Success.png') . "\");'>\n";
    $out .= sp_create_nonce('forum-userform_addtopic');
    $out .= '<div class="spEditor">' . "\n";
    $out = apply_filters('sph_topic_editor_top', $out, $spThisForum);
    $out .= "<fieldset class='{$controlFieldset}'>\n";
    $out .= "<legend>{$labelHeading}: " . $spThisForum->forum_name . "</legend>\n";
    $out .= "<input type='hidden' name='action' value='topic' />\n";
    $out .= "<input type='hidden' name='forumid' value='{$spThisForum->forum_id}' />\n";
    $out .= "<input type='hidden' name='forumslug' value='{$spThisForum->forum_slug}' />\n";
    $out .= "<input type='hidden' name='captcha' value='{$captchaValue}' />\n";
    # input field that plugins can use
    $out .= "<input type='hidden' id='spEditorCustomValue' name='spEditorCustomValue' value='' />\n";
    # plugins can add before the header
    $out = apply_filters('sph_topic_before_editor_header', $out, $spThisForum, $a);
    $tout = '';
    $tout .= '<div class="spEditorSection">';
    # let plugins add stuff at top of editor header
    $tout = apply_filters('sph_topic_editor_header_top', $tout, $spThisForum, $a);
    if (!empty($postmsg['sfpostmsgtopic'])) {
        $tout .= '<div class="spEditorMessage">' . sp_filter_text_display($postmsg['sfpostmsgtext']) . '</div>' . "\n";
    }
    # create an empty div to allow plugins to add something
    $tout .= '<div id="spEditorCustomDiv"></div>';
    if ($spThisUser->guest) {
        $tout .= '<div class="spEditorSectionLeft">' . "\n";
        $tout .= "<div class='spEditorTitle'>{$labelGuestName}:\n";
        $tout .= "<input type='text' tabindex='100' class='{$controlInput}' name='guestname' value='{$guestnameval}' /></div>\n";
        $tout .= '</div>' . "\n";
        $sfguests = sp_get_option('sfguests');
        if ($sfguests['reqemail']) {
            $tout .= '<div class="spEditorSectionRight">' . "\n";
            $tout .= "<div class='spEditorTitle'>{$labelGuestEmail}:\n";
            $tout .= "<input type='text' tabindex='101' class='{$controlInput}' name='guestemail' value='{$guestemailval}' /></div>\n";
            $tout .= '</div>' . "\n";
        }
        $tout .= '<div class="spClear"></div>' . "\n";
    }
    if (!sp_get_auth('bypass_moderation', $spThisForum->forum_id)) {
        $tout .= "<p class='spLabelSmall'>{$labelModerateAll}</p>\n";
    } elseif (!sp_get_auth('bypass_moderation_once', $spThisForum->forum_id)) {
        $tout .= "<p class='spLabelSmall'>{$labelModerateOnce}</p>\n";
    }
    $tout2 = '';
    $tout2 .= "<div class='spEditorTitle'>{$labelTopicName}: \n";
    $tout2 .= "<input id='spTopicTitle' type='text' tabindex='102' class='{$controlInput}' maxlength='{$maxTitleLength}' name='newtopicname' value='{$topicnameval}'/>\n";
    $tout2 = apply_filters('sph_topic_editor_name', $tout2, $a);
    $tout2 .= '</div>' . "\n";
    $tout .= apply_filters('sph_topic_editor_title', $tout2, $spThisForum, $a);
    # let plugins add stuff at bottom of editor header
    $tout = apply_filters('sph_topic_editor_header_bottom', $tout, $spThisForum, $a);
    $tout .= '</div>' . "\n";
    # allow plugins to filter just the header
    $out .= apply_filters('sph_topic_editor_header', $tout, $spThisForum, $a);
    # do we have content? Or just add any inline message
    if (empty($postitemval)) {
        $postitemval = $inEdMsg;
    }
    # Display the selected editor
    $tout = '';
    $tout .= '<div id="spEditorContent">' . "\n";
    $tout .= sp_setup_editor(103, $postitemval);
    $tout .= '</div>' . "\n";
    # allow plugins to filter the editor content
    $out .= apply_filters('sph_topic_editor_content', $tout, $spThisForum, $a);
    # define area above toolbar for plugins to add components
    $section = apply_filters('sph_topic_editor_above_toolbar', '', $spThisForum, $a);
    if (!empty($section)) {
        $tout = '';
        $tout .= '<div class="spEditorSection">';
        $tout .= $section;
        $tout .= '</div>' . "\n";
        $out .= apply_filters('sph_topic_editor_above_toolbar_end', $tout, $spThisForum, $a);
    }
    # DEFINE NEW FAILURE AREA HERE
    # define validation failure notice area
    $out .= "<div class='spClear'></div>\n";
    $out .= "<div id='spPostNotifications'>{$failmessage}</div>\n";
    # TOOLBAR
    # define toolbar - submit buttons on right, plugin extensions on left
    $toolbarRight = apply_filters('sph_topic_editor_toolbar_submit', '', $spThisForum, $a, 'toolbar');
    $toolbarLeft = apply_filters('sph_topic_editor_toolbar_buttons', '', $spThisForum, $a, 'toolbar');
    if (!empty($toolbarRight) || !empty($toolbarLeft)) {
        # Submit section
        $tout = '';
        $tout .= '<div class="spEditorSection spEditorToolbar">';
        $tout .= $toolbarRight;
        # toolbar for plugins to add buttons
        $tout .= $toolbarLeft;
        $out .= apply_filters('sph_topic_editor_toolbar', $tout, $spThisForum, $a, 'toolbar');
        $out .= '<div style="clear:both"></div>';
        $out .= '</div>' . "\n";
    }
    # START SMILEYS/OPTIONS
    # let plugins add stuff at top of editor footer
    $tout = '';
    $tout = apply_filters('sph_topic_editor_footer_top', $tout, $spThisForum, $a);
    # smileys and options
    $tout = apply_filters('sp_topic_editor_inline_footer', $tout, $spThisForum, $a, 'inline');
    # let plugins add stuff at end of editor footer
    $tout = apply_filters('sph_topic_editor_footer_bottom', $tout, $spThisForum, $a);
    # plugins can remove or adjust whole footer
    $out .= apply_filters('sph_topic_editor_footer', $tout, $spThisForum, $a);
    # allow plugins to insert stuff after editor footer
    $out = apply_filters('sph_topic_editor_after_footer', $out, $spThisForum, $a);
    # START SUBMIT SECTION
    # define submit section of no toolbar in use
    if (!$toolbar) {
        $out .= '<div class="spEditorSubmit">' . "\n";
        $out = apply_filters('sph_topic_editor_submit_top', $out, $spThisForum, $a);
        # let plugins add/remove the controls area
        $tout = apply_filters('sp_topic_editor_inline_submit', '', $spThisForum, $a, 'inline');
        # let plugins add stuff at end of editor submit bottom
        $out .= apply_filters('sph_topic_editor_submit_bottom', $tout, $spThisForum, $a);
        $out .= '</div>' . "\n";
    }
    # close it up
    $out .= '</fieldset>' . "\n";
    $out = apply_filters('sph_topic_editor_bottom', $out, $spThisForum, $a);
    $out .= '</div>' . "\n";
    $out .= '</form>' . "\n";
    $out .= '</div>' . "\n";
    # let plugins add stuff beneath the editor
    $out = apply_filters('sph_topic_editor_beneath', $out, $spThisForum, $a);
    return $out;
}
function spa_dashboard_forum()
{
    global $spGlobals, $spThisUser, $spStatus;
    $out = '';
    # check we have an installed version
    if ($spStatus != 'ok') {
        $out .= '<div style="border: 1px solid #eeeeee; padding: 10px; font-weight: bold;">' . "\n";
        $out .= '<p><img style="vertical-align:bottom;border:none;" src="' . sp_paint_file_icon(SPTHEMEICONSURL, 'sp_Information.png') . '" alt="" />' . "\n";
        $out .= '&nbsp;&nbsp;' . sprintf(spa_text('The forum is temporarily unavailable while awaiting %s'), $spStatus) . '</p>';
        if ($spThisUser->admin) {
            $out .= '&nbsp;&nbsp;<a style="text-decoration: underline;" href="' . SFADMINUPGRADE . '">' . spa_text('Perform Upgrade') . '</a>';
        }
        $out .= '</div>';
        echo $out;
        return;
    }
    $out .= '<div id="sf-dashboard">';
    echo $out;
    do_action('sph_dashboard_start');
    if ($spGlobals['admin']['sfdashboardstats']) {
        include_once SF_PLUGIN_DIR . '/forum/content/sp-common-view-functions.php';
        include_once SF_PLUGIN_DIR . '/forum/content/sp-template-control.php';
        echo '<br /><table class="sfdashtable">';
        echo '<tr>';
        echo '<td>';
        sp_OnlineStats('link_names=0', '<b>' . spa_text('Most Users Ever Online') . ': </b>', '<b>' . spa_text('Currently Online') . ': </b>', '<b>' . spa_text('Currently Browsing this Page') . ': </b>', spa_text('Guest(s)'));
        echo '</td>';
        echo '<td>';
        sp_ForumStats('', '<b>' . spa_text('Forum Stats') . ': </b>', spa_text('Groups') . ': ', spa_text('Forums') . ': ', spa_text('Topics') . ': ', spa_text('Posts') . ': ');
        echo '</td>';
        echo '<td>';
        sp_MembershipStats('', '<b>' . spa_text('Member Stats') . ': </b>', spa_text('There are %COUNT% Members'), spa_text('There have been %COUNT% Guest Posters'), spa_text('There are %COUNT% Moderators'), spa_text('There are %COUNT% Admins'));
        echo '</td>';
        echo '<td>';
        sp_TopPostersStats('link_names=0', '<b>' . spa_text('Top Posters') . ': </b>');
        echo '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td colspan="4">';
        sp_NewMembers('link_names=0', '<b>' . spa_text('Newest Members') . ': </b>');
        echo '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td colspan="4">';
        sp_ModsList('link_names=0', '<b>' . spa_text('Moderators') . ': </b>');
        echo '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td colspan="4">';
        sp_AdminsList('link_names=0', '<b>' . spa_text('Administrators') . ': </b>');
        echo '</td>';
        echo '</tr></table><br />';
    }
    do_action('sph_dashboard_end');
    $out = '';
    $out .= '<p><br /><a href="' . sp_url() . '">' . spa_text('Go To Forum') . '</a></p>';
    $out .= '</div>';
    echo $out;
}
function sp_TopicIndexPageLinks($args = '', $label = '', $toolTip = '', $jumpToolTip = '')
{
    global $spThisForum, $spGlobals, $jumpID;
    # can be empty if request is for a bogus forunm slug
    if (empty($spThisForum)) {
        return;
    }
    $topics_per_page = $spGlobals['display']['topics']['perpage'];
    if (!$topics_per_page) {
        $topics_per_page = 20;
    }
    $defs = array('tagClass' => 'spPageLinks', 'prevIcon' => 'sp_ArrowLeft.png', 'nextIcon' => 'sp_ArrowRight.png', 'jumpIcon' => 'sp_Jump.png', 'iconClass' => 'spIcon', 'pageLinkClass' => 'spPageLinks', 'curPageClass' => 'spCurrent', 'linkClass' => 'spLink', 'showLinks' => 4, 'showEmpty' => 0, 'showJump' => 1, 'echo' => 1);
    $a = wp_parse_args($args, $defs);
    $a = apply_filters('sph_TopicIndexPageLinks_args', $a);
    extract($a, EXTR_SKIP);
    # sanitize before use
    $tagClass = esc_attr($tagClass);
    if (!empty($prevIcon)) {
        $prevIcon = sp_paint_file_icon(SPTHEMEICONSURL, sanitize_file_name($prevIcon));
    }
    if (!empty($nextIcon)) {
        $nextIcon = sp_paint_file_icon(SPTHEMEICONSURL, sanitize_file_name($nextIcon));
    }
    if (!empty($jumpIcon)) {
        $jumpIcon = sp_paint_file_icon(SPTHEMEICONSURL, sanitize_file_name($jumpIcon));
    }
    $iconClass = esc_attr($iconClass);
    $pageLinkClass = esc_attr($pageLinkClass);
    $curPageClass = esc_attr($curPageClass);
    $linkClass = esc_attr($linkClass);
    $showLinks = (int) $showLinks;
    $showEmpty = (int) $showEmpty;
    $showJump = (int) $showJump;
    $label = sp_filter_title_display($label);
    $toolTip = esc_attr($toolTip);
    $jumpToolTip = esc_attr($jumpToolTip);
    $echo = (int) $echo;
    if ($topics_per_page >= $spThisForum->topic_count) {
        if ($showEmpty) {
            echo "<div class='{$tagClass}'></div>";
        }
        return;
    }
    global $spVars;
    $curToolTip = str_ireplace('%PAGE%', $spVars['page'], $toolTip);
    if (isset($jumpID) ? $jumpID++ : ($jumpID = 1)) {
    }
    $out = "<div class='{$tagClass}'>";
    $totalPages = $spThisForum->topic_count / $topics_per_page;
    if (!is_int($totalPages)) {
        $totalPages = intval($totalPages) + 1;
    }
    $out .= "<span class='{$pageLinkClass}'>{$label}</span>";
    $out .= sp_page_prev($spVars['page'], $showLinks, $spThisForum->forum_permalink, $pageLinkClass, $iconClass, $prevIcon, $nextIcon, $toolTip, '');
    $url = $spThisForum->forum_permalink;
    if ($spVars['page'] > 1) {
        $url = user_trailingslashit(trailingslashit($url) . 'page-' . $spVars['page']);
    }
    $out .= "<a href='{$url}' class='{$pageLinkClass} {$curPageClass}' title='{$curToolTip}'>" . $spVars['page'] . '</a>';
    $out .= sp_page_next($spVars['page'], $totalPages, $showLinks, $spThisForum->forum_permalink, $pageLinkClass, $iconClass, $prevIcon, $nextIcon, $toolTip, '');
    if ($showJump) {
        $out .= '<span class="spPageJump">';
        $site = SFHOMEURL . 'index.php?sp_ahah=manage-forum&amp;action=page-popup&amp;url=' . $spThisForum->forum_permalink . '&amp;max=' . $totalPages . '&amp;sfnonce=' . wp_create_nonce('forum-ahah');
        $out .= "<a id='jump-{$jumpID}' rel='nofollow' class='{$linkClass}' title='{$jumpToolTip}' href='javascript:void(null)' onclick='spjDialogAjax(this, \"{$site}\", \"{$jumpToolTip}\", 250, 0, 0);'>";
        $out .= "<img src='{$jumpIcon}' class='{$iconClass}' alt='' />";
        $out .= '</a>';
        $out .= '</span>';
    }
    $out .= "</div>\n";
    $out = apply_filters('sph_TopicIndexPageLinks', $out, $a);
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}
function sp_format_display_image($match)
{
    global $spPaths, $spVars;
    preg_match('/width\\s*=\\s*"([^"]*)"|width\\s*=\\s*\'([^\']*)\'/i', $match[0], $width);
    $out = '';
    $sfimage = array();
    $sfimage = sp_get_option('sfimage');
    preg_match('/title\\s*=\\s*"([^"]*)"|title\\s*=\\s*\'([^\']*)\'/i', $match[0], $title);
    preg_match('/alt\\s*=\\s*"([^"]*)"|alt\\s*=\\s*\'([^\']*)\'/i', $match[0], $alt);
    preg_match('/width\\s*=\\s*"([^"]*)"|width\\s*=\\s*\'([^\']*)\'/i', $match[0], $width);
    preg_match('/height\\s*=\\s*"([^"]*)"|height\\s*=\\s*\'([^\']*)\'/i', $match[0], $height);
    preg_match('/src\\s*=\\s*"([^"]*)"|src\\s*=\\s*\'([^\']*)\'/i', $match[0], $src);
    preg_match('/style\\s*=\\s*"([^"]*)"|style\\s*=\\s*\'([^\']*)\'/i', $match[0], $style);
    preg_match('/class\\s*=\\s*"([^"]*)"|class\\s*=\\s*\'([^\']*)\'/i', $match[0], $class);
    # if no src attribute then bail now
    if (empty($src[1])) {
        return;
    }
    if (isset($class[1]) && strpos($class[1], 'wp-image') === 0) {
        return $match[0];
    }
    # is this a smiley?
    if (strpos($src[1], 'plugins/emotions') || strpos($src[1], $spPaths['smileys'])) {
        return str_replace('img ', 'img class="spSmiley" style="margin:0"', $match[0]);
    } elseif (strpos($src[1], 'images/smilies')) {
        return str_replace('class="spSmiley"', 'class="spWPSmiley" style="max-height:1em;margin:0"', $match[0]);
    }
    # is any of this needed?
    if ($sfimage['enlarge'] == false && $sfimage['process'] == false) {
        return $match[0];
    }
    $thumb = $sfimage['thumbsize'];
    if (empty($thumb) || $thumb < 100) {
        $thumb = 100;
    }
    if (empty($style[1])) {
        if ($sfimage['style'] == 'left' || $sfimage['style'] == 'right') {
            $style[1] = 'float: ' . $sfimage['style'];
        } else {
            $style[1] = 'vertical-align: ' . $sfimage['style'];
        }
    }
    # Might be inherited image with wp standard alignleft and alignright in use
    if (isset($class[1])) {
        if (strpos($class[1], 'alignleft') !== false) {
            $style[1] = 'float: left';
        } else {
            if (strpos($class[1], 'alignright') !== false) {
                $style[1] = 'float: right';
            } else {
                if (strpos($class[1], 'aligncenter') !== false) {
                    $style[1] = 'margin: 0 auto';
                }
            }
        }
    }
    $iclass = '';
    $mclass = 'sfmouseother';
    $mstyle = '';
    switch ($style[1]) {
        case 'float: left':
            $iclass = 'sfimageleft';
            $mclass = 'sfmouseleft';
            break;
        case 'float: right':
            $iclass = 'sfimageright';
            $mclass = 'sfmouseright';
            break;
        case 'margin: 0 auto':
            $iclass = 'sfimagecenter';
            # mouse icon not possible with center unless we can work it out
            $mclass = 'na';
            break;
        case 'vertical-align: baseline':
            $iclass = 'sfimagebaseline';
            break;
        case 'vertical-align: top':
            $iclass = 'sfimagetop';
            break;
        case 'vertical-align: middle':
            $iclass = 'sfimagemiddle';
            break;
        case 'vertical-align: bottom':
            $iclass = 'sfimagebottom';
            break;
        case 'vertical-align: text-top':
            $iclass = 'sfimagetexttop';
            break;
        case 'vertical-align: text-bottom':
            $iclass = 'sfimagetextbottom';
            break;
    }
    if (empty($width[1])) {
        $size = sp_get_image_size($src[1], true);
        if ($size) {
            if ($size[0]) {
                $width[1] = $size[0];
                $height[1] = $size[1];
            } else {
                $width[1] = 0;
                $height[1] = 0;
            }
        } elseif (ini_get('allow_url_fopen') == true && $size == false) {
            return '[' . sp_text('Image Can Not Be Found') . ']';
        }
    }
    if (isset($src[1])) {
        $thissrc = 'src="' . $src[1] . '" ';
    } else {
        $thissrc = '';
    }
    if (isset($title[1])) {
        $thistitle = 'title="' . $title[1] . '" ';
    } else {
        $thistitle = '';
    }
    if (isset($alt[1])) {
        $thisalt = 'alt="' . $alt[1] . '" ';
    } else {
        $thisalt = '';
    }
    if ((int) $width[1] > (int) $thumb) {
        # is width > thumb size
        $thiswidth = 'width="' . $thumb . '" ';
        $anchor = true;
    } else {
        if (!empty($width[1]) && $width > 0) {
            # width is smaller than thumb, so use the width {
            $thiswidth = 'width="' . $width[1] . '" ';
            $mclass = '';
            $anchor = false;
        } else {
            # couldn't determine width, so don't output it
            $thiswidth = '';
            $mclass = '';
            $anchor = false;
        }
    }
    if (!empty($iclass)) {
        $thisformat = ' class="' . $iclass . '" ';
    } else {
        $thisformat = ' style="' . $style[1] . '" ';
    }
    if ($anchor) {
        $w = !empty($width) && $width[1] ? $width[1] : 'auto';
        $h = !empty($height) && $height[1] ? $height[1] : 'auto';
        # Use popup or not?
        if ($sfimage['enlarge'] == true) {
            $out = '<a href="javascript:void(null)" class="" title="' . sp_text('Click image to enlarge') . '" onclick="spjPopupImage(\'' . $src[1] . '\', \'' . $w . '\', \'' . $h . '\', \'' . $sfimage['constrain'] . '\');" >';
            $out = apply_filters('sph_display_image_popup', $out, $src[1]);
        } else {
            $out = '<a href="' . $src[1] . '" ' . $thistitle . '>';
        }
    }
    # let plugins play with the adjusted image elements
    $image_array = compact($thissrc . $thiswidth . $thisformat . $thistitle . $thisalt);
    $image_array = apply_filters('sph_display_image_data', $image_array, $src, $width, $height, $title, $alt, $style, $class);
    extract($image_array);
    $out .= '<img ' . $thissrc . $thiswidth . $thisformat . $thistitle . $thisalt . '/>';
    if ($mclass) {
        $mouse = '<img src="' . sp_paint_file_icon(SPTHEMEICONSURL, 'sp_Mouse.png') . '" class="' . $iclass . ' ' . $mclass . '" alt="" ' . $mstyle . '/>';
        $out .= apply_filters('sph_display_image_mouse', $mouse);
    }
    if ($anchor) {
        $out .= '</a>';
    }
    if ($sfimage['forceclear']) {
        $out .= '<div style="clear:both"></div>';
    }
    return $out;
}
function sp_forum_footer()
{
    global $spVars, $spGlobals, $spThisUser, $spMobile, $spDevice;
    do_action('sph_footer_start');
    # wait for page load and run JS inits
    ?>
	<script type='text/javascript'>
		var jspf = jQuery.noConflict();
		jspf(document).ready(function() {
			<?php 
    # Quicklinks selects
    ?>
			jspf("#spQuickLinksForumSelect, #spQuickLinksTopicSelect").msDropDown();
			jspf('#spQuickLinksForum').show();
			jspf('#spQuickLinksTopic').show();
			<?php 
    # Checkboxes/radio buttons and tooltips
    if (defined('SP_USE_PRETTY_CBOX') && SP_USE_PRETTY_CBOX == true) {
        ?>
				jspf("input[type=checkbox],input[type=radio]").prettyCheckboxes();
			<?php 
    }
    ?>

			if (sp_platform_vars.device == 'desktop' && sp_platform_vars.tooltips == true) {
				jspf(document).tooltip( {
					tooltipClass: "ttip",
					position: {
						my: "left+20 top",
						at: "left bottom+10"
					},
					track: false,
					content: function() {
						var element = jspf(this);
						if (element.prop("nodeName") == "IFRAME") {
							return '';
						} else {
							return element.attr( "title" );
						}
					}
				});
			}

			<?php 
    # if fragment postID and head padding add padding
    ?>
			var hash = jspf(location).attr('hash');
			if (hash && sp_platform_vars.headpadding > 0) {
				jspf('html, body').animate({ scrollTop: (Math.round(jspf(hash).offset().top) - parseInt(sp_platform_vars.headpadding)) }, 'fast');
			}

			<?php 
    # pre-load 'wait' image
    ?>
				waitImage = new Image(32,32);
				waitImage.src = '<?php 
    echo sp_paint_file_icon(SPFIMAGES, 'sp_Wait.png');
    ?>
';
				successImage = new Image(32,32);
				successImage.src = '<?php 
    echo sp_paint_file_icon(SPFIMAGES, 'sp_Success.png');
    ?>
';
				failureImage = new Image(32,32);
				failureImage.src = '<?php 
    echo sp_paint_file_icon(SPFIMAGES, 'sp_Failure.png');
    ?>
';
			<?php 
    # check if this is a redirect from a failed save
    if ($spVars['pageview'] == 'topic' || $spVars['pageview'] == 'forum') {
        ?>
				if (jspf('#spPostNotifications').html() != null) {
					if (jspf('#spPostNotifications').html() != '') {
						jspf('#spPostNotifications').show();
						spjOpenEditor('spPostForm', 'post');
					}
				}
			<?php 
    }
    # turn on auto update of required
    $sfauto = array();
    $sfauto = sp_get_option('sfauto');
    if ($sfauto['sfautoupdate']) {
        $timer = $sfauto['sfautotime'] * 1000;
        $autoup = $spGlobals['autoupdate'];
        $arg = '';
        foreach ($autoup as $up) {
            $list = implode($up, ',');
            $list = str_replace('sp_ahah=', site_url() . '/index.php?sp_ahah=', $list);
            $list .= '&amp;sfnonce=' . wp_create_nonce('forum-ahah');
            if ($arg != '') {
                $arg .= '%';
            }
            $arg .= $list;
        }
        ?>
				spjAutoUpdate("<?php 
        echo $arg;
        ?>
", "<?php 
        echo $timer;
        ?>
");
			<?php 
    }
    # fix for Bootstrap stealing button object from jQuery UI
    ?>
			try {
				var btn = jspf.fn.button.noConflict() // reverts $.fn.button to jqueryui btn
				jspf.fn.btn = btn // assigns bootstrap button functionality to $.fn.btn
			} catch (e) { }

			<?php 
    # Show message if leaving page during edit
    if ($spVars['pageview'] == 'topic' || $spVars['pageview'] == 'forum') {
        ?>
				var showConfirm = false;
				var edContent = '';
				window.onbeforeunload = confirmExit;
				<?php 
        if ($spGlobals['editor'] != 1) {
            ?>
					jspf('#postitem').keyup(function() {
						showConfirm = true;
					});
				<?php 
        }
        ?>

				function confirmExit() {
					if(sp_platform_vars.saveprocess == 0 && jspf('#spPostForm').css('display') == 'block') {
						<?php 
        if ($spGlobals['editor'] == 1) {
            ?>
						edContent = tinymce.activeEditor.getContent();
						<?php 
        }
        ?>

						if(showConfirm || edContent != '') {
							return '<?php 
        sp_etext('You have entered text into the post editor which may be lost');
        ?>
';
						}
					}
				}

			<?php 
    }
    ?>
		});
	</script>
	<?php 
    do_action('sph_footer_end');
}
function sp_find_icon($path, $file)
{
    trigger_error('The function sp_find_icon() has been deprecated and will be removed in a future update. Use the new function sp_paint_file_icon() instead.', E_USER_WARNING);
    return sp_paint_file_icon($path, $file);
}
function sp_QuickLinksTopicMobile($args = '', $label = '')
{
    global $spThisUser;
    $defs = array('tagIdControl' => 'spQuickLinksTopicMobile', 'tagClass' => 'spControl', 'tagIdList' => 'spQuickLinksMobileList', 'listClass' => 'spQuickLinksList', 'listDataClass' => 'spQuickLinksGroup', 'openIcon' => 'sp_GroupOpen.png', 'closeIcon' => 'sp_GroupClose.png', 'length' => 40, 'show' => 20, 'echo' => 1);
    $a = wp_parse_args($args, $defs);
    $a = apply_filters('sph_QuickLinksTopicMobile_args', $a);
    extract($a, EXTR_SKIP);
    # sanitize before use
    $tagIdControl = esc_attr($tagIdControl);
    $tagClass = esc_attr($tagClass);
    $tagIdList = esc_attr($tagIdList);
    $listClass = esc_attr($listClass);
    $listDataClass = esc_attr($listDataClass);
    $openIcon = sp_paint_file_icon(SPTHEMEICONSURL, sanitize_file_name($openIcon));
    $closeIcon = sp_paint_file_icon(SPTHEMEICONSURL, sanitize_file_name($closeIcon));
    $length = (int) $length;
    $show = (int) $show;
    $echo = (int) $echo;
    if (!empty($label)) {
        $label = sp_filter_title_display($label);
    }
    if (empty($length)) {
        $length = 40;
    }
    $out = '';
    if (!empty($spThisUser->newposts['topics'])) {
        $spList = new spTopicList(array_slice($spThisUser->newposts['topics'], 0, $show, true), $show, true, '', 0, 1, 'topic quick links mobile');
    } else {
        $spList = new spTopicList('', $show, true, '', 0, 1, 'topic quick links mobile');
    }
    if (!empty($spList->listData)) {
        $out .= "<div class='{$tagClass}' id='{$tagIdControl}'>\n";
        $out .= "<p id='spQLTitle' onclick='spjOpenQL(\"{$tagIdList}\", \"spQLOpener\", \"{$openIcon}\", \"{$closeIcon}\");'>{$label}<span id='spQLOpener'><img src='{$openIcon}' /></span></p>\n";
        $out .= "</div>";
        $out .= sp_InsertBreak('echo=false');
        $out .= "<div id='{$tagIdList}' class='{$listClass}' style='display:none'>\n";
        $thisForum = 0;
        $group = false;
        foreach ($spList->listData as $spPost) {
            if ($spPost->forum_id != $thisForum) {
                if ($group) {
                    $out .= '</div>';
                }
                $out .= "<div class='{$listDataClass}'><p>" . sp_create_name_extract($spPost->forum_name, $length) . "</p>\n";
                $thisForum = $spPost->forum_id;
                $group = true;
            }
            $class = 'spPostRead';
            $image = "<img src='" . sp_paint_file_icon(SPTHEMEICONSURL, "sp_QLBalloonNone.png") . "' alt='' />";
            if ($spPost->post_status != 0) {
                $class = 'spPostMod';
                $image = "<img src='" . sp_paint_file_icon(SPTHEMEICONSURL, "sp_QLBalloonRed.png") . "' alt='' />";
            } elseif (sp_is_in_users_newposts($spPost->topic_id)) {
                $class = 'spPostNew';
                $image = "<img src='" . sp_paint_file_icon(SPTHEMEICONSURL, "sp_QLBalloonBlue.png") . "' alt='' />";
            }
            $out .= "<p><a class='{$class}' href='{$spPost->post_permalink}'>{$image}&nbsp;&nbsp;" . sp_create_name_extract($spPost->topic_name, $length) . "</a></p>\n";
        }
        $out .= "</div></div>\n";
    }
    $out = apply_filters('sph_QuickLinksTopicMobile', $out, $a);
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}
Example #10
0
<?php

/*
Simple:Press
Forum RSS Feeds
$LastChangedDate: 2015-05-16 12:11:22 -0700 (Sat, 16 May 2015) $
$Rev: 12892 $
*/
if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
    die('Access denied - you cannot directly call this file');
}
global $spVars, $spThisUser, $spPostList, $spThisPostList;
# check installed version is correct
if (sp_get_system_status() != 'ok') {
    $out .= '<img style="style="vertical-align:bottom;border:none;"" src="' . sp_paint_file_icon(SPTHEMEICONSURL, 'sp_Information.png') . '" alt="" />' . "\n";
    $out .= '&nbsp;&nbsp;' . sp_text('The forum is temporarily unavailable while being upgraded to a new version');
    echo $out;
}
# are we doing feed keys? If so reset user to that f the passed feedkey - else leave as guest
$rssopt = sp_get_option('sfrss');
if (isset($rssopt['sfrssfeedkey']) && $rssopt['sfrssfeedkey']) {
    # get the user requesting feed
    $feedkey = $spVars['feedkey'];
    $userid = spdb_table(SFMEMBERS, "feedkey='{$feedkey}'", 'user_id');
    $spThisUser = sp_get_user($userid, true);
}
# = Support Functions ===========================
function sp_rss_filter($text)
{
    echo convert_chars(ent2ncr($text));
}
function sp_MemberListPageLinks($args = '', $label = '', $toolTip = '')
{
    if (!sp_get_auth('view_members_list')) {
        return;
    }
    global $spMembersList;
    $defs = array('tagId' => 'spMemberPageLinks', 'tagClass' => 'spPageLinks', 'prevIcon' => 'sp_ArrowLeft.png', 'nextIcon' => 'sp_ArrowRight.png', 'iconClass' => 'spIcon', 'pageLinkClass' => 'spPageLinks', 'curPageClass' => 'spCurrent', 'showLinks' => 4, 'echo' => 1);
    $a = wp_parse_args($args, $defs);
    $a = apply_filters('sph_MemberListPageLinks_args', $a);
    extract($a, EXTR_SKIP);
    # sanitize before use
    $tagId = esc_attr($tagId);
    $tagClass = esc_attr($tagClass);
    if (!empty($prevIcon)) {
        $prevIcon = sp_paint_file_icon(SPTHEMEICONSURL, sanitize_file_name($prevIcon));
    }
    if (!empty($nextIcon)) {
        $nextIcon = sp_paint_file_icon(SPTHEMEICONSURL, sanitize_file_name($nextIcon));
    }
    $iconClass = esc_attr($iconClass);
    $pageLinkClass = esc_attr($pageLinkClass);
    $curPageClass = esc_attr($curPageClass);
    $showLinks = (int) $showLinks;
    $label = sp_filter_title_display($label);
    $toolTip = esc_attr($toolTip);
    $echo = (int) $echo;
    global $spVars;
    $curToolTip = str_ireplace('%PAGE%', $spVars['page'], $toolTip);
    if (isset($_POST['allmembers'])) {
        $search = '';
        $ug = '';
    } else {
        if (isset($_GET['page'])) {
            $spVars['page'] = sp_esc_int($_GET['page']);
        }
        $search = !empty($_POST['msearch']) ? sp_esc_str($_POST['msearch']) : '';
        $search = !empty($_GET['msearch']) ? sp_esc_str($_GET['msearch']) : $search;
        $ug = !empty($_POST['ug']) ? sp_esc_int($_POST['ug']) : '';
        $ug = !empty($_GET['ug']) ? sp_esc_int($_GET['ug']) : $ug;
    }
    $out = "<div id='{$tagId}' class='{$tagClass}'>";
    $totalPages = $spMembersList->totalMemberCount / $spMembersList->membersNumber;
    if (!is_int($totalPages)) {
        $totalPages = intval($totalPages) + 1;
    }
    $out .= "<span class='{$pageLinkClass}'>{$label}</span>";
    $out .= sp_page_prev($spVars['page'], $showLinks, SPMEMBERLIST, $pageLinkClass, $iconClass, $prevIcon, $nextIcon, $toolTip, $search, $ug);
    $url = SPMEMBERLIST;
    if ($spVars['page'] > 1) {
        $url = user_trailingslashit(trailingslashit($url) . 'page-' . $spVars['page']);
    }
    if (!empty($search)) {
        $param['msearch'] = $search;
        $url = add_query_arg($param, esc_url($url));
        $url = sp_filter_wp_ampersand($url);
    }
    if (!empty($ug)) {
        $param['ug'] = $ug;
        $url = add_query_arg($param, esc_url($url));
        $url = sp_filter_wp_ampersand($url);
    }
    $out .= "<a href='{$url}' class='{$pageLinkClass} {$curPageClass}' title='{$curToolTip}'>" . $spVars['page'] . '</a>';
    $out .= sp_page_next($spVars['page'], $totalPages, $showLinks, SPMEMBERLIST, $pageLinkClass, $iconClass, $prevIcon, $nextIcon, $toolTip, $search, $ug);
    $out .= "</div>\n";
    $out = apply_filters('sph_MemberListPageLinks', $out, $a);
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}
function sp_SearchPageLinks($args = '', $label = '', $toolTip = '')
{
    global $spSearchView, $spVars;
    $items_per_page = $spSearchView->searchShow;
    if (!$items_per_page) {
        $items_per_page = 30;
    }
    if ($items_per_page >= $spSearchView->searchCount) {
        return '';
    }
    $defs = array('tagClass' => 'spPageLinks', 'prevIcon' => 'sp_ArrowLeft.png', 'nextIcon' => 'sp_ArrowRight.png', 'iconClass' => 'spIcon', 'pageLinkClass' => 'spPageLinks', 'curPageClass' => 'spCurrent', 'showLinks' => 4, 'echo' => 1);
    $a = wp_parse_args($args, $defs);
    $a = apply_filters('sph_SearchPageLinks_args', $a);
    extract($a, EXTR_SKIP);
    # sanitize before use
    $tagClass = esc_attr($tagClass);
    if (!empty($prevIcon)) {
        $prevIcon = sp_paint_file_icon(SPTHEMEICONSURL, sanitize_file_name($prevIcon));
    }
    if (!empty($nextIcon)) {
        $nextIcon = sp_paint_file_icon(SPTHEMEICONSURL, sanitize_file_name($nextIcon));
    }
    $iconClass = esc_attr($iconClass);
    $pageLinkClass = esc_attr($pageLinkClass);
    $curPageClass = esc_attr($curPageClass);
    $showLinks = (int) $showLinks;
    $label = sp_filter_title_display($label);
    $toolTip = esc_attr($toolTip);
    $echo = (int) $echo;
    $curToolTip = str_ireplace('%PAGE%', $spVars['searchpage'], $toolTip);
    $out = "<div class='{$tagClass}'>";
    $totalPages = $spSearchView->searchCount / $items_per_page;
    if (!is_int($totalPages)) {
        $totalPages = intval($totalPages) + 1;
    }
    $out .= "<span class='{$pageLinkClass}'>{$label}</span>";
    $out .= sp_page_prev($spVars['searchpage'], $showLinks, $spSearchView->searchPermalink, $pageLinkClass, $iconClass, $prevIcon, $nextIcon, $toolTip, $spVars['searchpage']);
    $url = $spSearchView->searchPermalink;
    if ($spVars['searchpage'] > 1) {
        $url = user_trailingslashit(trailingslashit($spSearchView->searchPermalink) . '&amp;search=' . $spVars['searchpage']);
    }
    $out .= "<a href='{$url}' class='{$pageLinkClass} {$curPageClass}' title='{$curToolTip}'>" . $spVars['searchpage'] . '</a>';
    $out .= sp_page_next($spVars['searchpage'], $totalPages, $showLinks, $spSearchView->searchPermalink, $pageLinkClass, $iconClass, $prevIcon, $nextIcon, $toolTip, $spVars['searchpage']);
    $out .= "</div>\n";
    $out = apply_filters('sph_SearchPageLinks', $out, $a);
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}