function sp_do_sp_ProfileLinkTag($args = '')
{
    #check if forum displayed
    if (sp_abort_display_forum()) {
        return;
    }
    global $spThisUser;
    sp_forum_api_support();
    if ($spThisUser->ID == 0 && $spThisUser->ID == '') {
        return;
    }
    $defs = array('linkText' => __('Your Profile', 'sp-ttags'), 'beforeLink' => '', 'afterLink' => '', 'echo' => 1);
    $a = wp_parse_args($args, $defs);
    $a = apply_filters('sph_ProfileLinkTag_args', $a);
    extract($a, EXTR_SKIP);
    # sanitize before use
    $linkText = sp_filter_title_display($linkText);
    $beforeLink = sp_filter_title_display($beforeLink);
    $afterLink = sp_filter_title_display($afterLink);
    $echo = (int) $echo;
    if (!empty($beforeLink)) {
        $beforeLink = trim($beforeLink) . ' ';
    }
    if (!empty($afterLink)) {
        $afterLink = ' ' . trim($afterLink);
    }
    $out = '';
    $out .= "<span>{$beforeLink}<a href='" . sp_url('profile') . "'>{$linkText}</a>{$afterLink}</span>\n";
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}
function sp_build_qurl($param1, $param2 = '', $param3 = '', $param4 = '', $param5 = '', $param6 = '', $param7 = '')
{
    trigger_error('The function sp_build_qurl() has been deprecated and will be removed in a future update. Use WordPress function add_query_arg() instead.', E_USER_WARNING);
    $url = sp_url();
    # first does it need the ?
    if (strpos($url, '?') === false) {
        $url .= '?';
        $and = '';
    } else {
        $and = '&amp;';
    }
    $url .= $and . $param1;
    $and = '&amp;';
    if (!empty($param2)) {
        $url .= $and . $param2;
    }
    if (!empty($param3)) {
        $url .= $and . $param3;
    }
    if (!empty($param4)) {
        $url .= $and . $param4;
    }
    if (!empty($param5)) {
        $url .= $and . $param5;
    }
    if (!empty($param6)) {
        $url .= $and . $param6;
    }
    if (!empty($param7)) {
        $url .= $and . $param7;
    }
    return $url;
}
Example #3
0
function sp_akismet($newpost)
{
    global $spThisUser;
    if (sp_get_auth('bypass_akismet', $newpost['forumid'])) {
        return $newpost;
    }
    if (function_exists('akismet_http_post') == false) {
        return $newpost;
    }
    $akismet = sp_get_option('spAkismet');
    if (empty($akismet) || $akismet == 1) {
        return $newpost;
    }
    $spam = sp_check_akismet($newpost);
    if (true == $spam) {
        if ($akismet == 2) {
            $newpost['poststatus'] = 2;
        }
        if ($akismet == 3) {
            sp_notify(1, __('This post has been identified as spam and has been rejected', 'spab'));
            wp_redirect(sp_url());
            die;
        }
    }
    return $newpost;
}
function sp_build_url($forumslug, $topicslug, $pageid, $postid = 0, $postindex = 0, $rss = 0)
{
    if ($postid != 0 && $pageid == 0) {
        $pageid = sp_determine_page($forumslug, $topicslug, sp_esc_int($postid), sp_esc_int($postindex));
    }
    $url = trailingslashit(sp_url());
    if ($forumslug) {
        $url .= $forumslug;
    }
    if ($topicslug) {
        $url .= '/' . $topicslug;
    }
    if ($rss) {
        if (!empty($forumslug) || !empty($topicslug)) {
            $url .= '/';
        }
        $url .= 'rss';
    }
    if ($pageid > 1) {
        $url .= '/page-' . $pageid;
    }
    $url = user_trailingslashit($url);
    if ($postid) {
        $url .= '#p' . $postid;
    }
    return esc_url($url);
}
Example #5
0
 function wp_new_user_notification($user_id, $notify = '')
 {
     $user = new WP_User($user_id);
     $sflogin = sp_get_option('sflogin');
     $eol = "\r\n";
     $user_login = $user->user_login;
     $user_email = $user->user_email;
     $message = '';
     $message .= sp_text_noesc('New user registration on your website') . ': ' . get_option('blogname') . $eol . $eol;
     $message .= sp_text_noesc('Username') . ': ' . $user_login . $eol;
     $message .= sp_text_noesc('E-mail') . ': ' . $user_email . $eol;
     $message .= sp_text_noesc('Registration IP') . ': ' . sp_get_ip() . $eol;
     $address = apply_filters('sph_admin_new_user_email_addrress', get_option('admin_email'), $user_id);
     $subject = apply_filters('sph_admin_new_user_email_subject', get_option('blogname') . ' ' . sp_text_noesc('New User Registration'), $user_id);
     $msg = apply_filters('sph_admin_new_user_email_msg', $message, $user_id);
     sp_send_email($address, $subject, $msg);
     if ('admin' === $notify || empty($notify)) {
         return;
     }
     # Generate something random for a password reset key.
     $key = wp_generate_password(20, false);
     /** This action is documented in wp-login.php */
     do_action('retrieve_password_key', $user_login, $key);
     # Now insert the key, hashed, into the DB.
     if (empty($wp_hasher)) {
         require_once ABSPATH . WPINC . '/class-phpass.php';
         $wp_hasher = new PasswordHash(8, true);
     }
     $hashed = time() . ':' . $wp_hasher->HashPassword($key);
     global $wpdb;
     $wpdb->update($wpdb->users, array('user_activation_key' => $hashed), array('user_login' => $user_login));
     $mailoptions = sp_get_option('sfnewusermail');
     $subject = stripslashes($mailoptions['sfnewusersubject']);
     $body = stripslashes($mailoptions['sfnewusertext']);
     if (empty($subject) || empty($body)) {
         $subject = get_option('blogname') . ' ' . sp_text_noesc('Your username') . $eol . $eol;
         $body = sp_text_noesc('Username') . ': ' . $user_login . $eol;
         $body .= sp_text_noesc('Login URL') . ': ' . $sflogin['sfloginemailurl'] . $eol;
         $body .= sp_text_noesc('Password Reset URL') . ': ' . network_site_url("wp-login.php?action=rp&key={$key}&login="******"wp-login.php?action=rp&key={$key}&login="******"wp-login.php?action=rp&key={$key}&login=" . rawurlencode($user_login), 'login'), $body);
         $body = str_replace('%NEWLINE%', $eol, $body);
     }
     str_replace('<br />', $eol, $body);
     $address = apply_filters('sph_user_new_user_email_addrress', $user_email, $user_id);
     $subject = apply_filters('sph_user_new_user_email_subject', get_option('blogname') . ' ' . sp_text_noesc('New User Registration'), $user_id);
     $msg = apply_filters('sph_user_new_user_email_msg', $body, $user_id, $user_pass);
     sp_send_email($user_email, $subject, $msg);
 }
function sp_do_sp_GroupLinkTag($args = '')
{
    #check if forum displayed
    if (sp_abort_display_forum()) {
        return;
    }
    $defs = array('groupId' => '', 'linkText' => '%GROUPNAME%', 'beforeLink' => '', 'afterLink' => '', 'listTags' => 0, 'echo' => 1);
    $a = wp_parse_args($args, $defs);
    $a = apply_filters('sph_GroupLinkTag_args', $a);
    extract($a, EXTR_SKIP);
    # sanitize before use
    $groupId = (int) $groupId;
    $linkText = esc_attr($linkText);
    $beforeLink = sp_filter_title_display($beforeLink);
    $afterLink = sp_filter_title_display($afterLink);
    $listTags = (int) $listTags;
    $echo = (int) $echo;
    if (empty($groupId)) {
        return '';
    }
    sp_forum_api_support();
    if (!empty($beforeLink)) {
        $beforeLink = trim($beforeLink) . ' ';
    }
    if (!empty($afterLink)) {
        $afterLink = ' ' . trim($afterLink);
    }
    # check user has access to at kleast ine forum in group
    $canview = false;
    $forums = spdb_table(SFFORUMS, "group_id={$groupId}");
    if ($forums) {
        foreach ($forums as $forum) {
            if (sp_can_view($forum->forum_id, 'forum-title')) {
                $canview = true;
            }
        }
    }
    if ($forums && $canview) {
        $grouprec = spdb_table(SFGROUPS, "group_id={$groupId}", 'row');
        $out = '';
        $linkText = str_replace("%GROUPNAME%", sp_filter_title_display($grouprec->group_name), $linkText);
        if (empty($linkText)) {
            $linkText = sp_filter_title_display($grouprec->group_name);
        }
        if ($listTags) {
            $out .= '<li>';
        }
        $out .= '<span>' . $beforeLink . '<a href="' . add_query_arg(array('group' => $groupId), sp_url()) . '">' . $linkText . '</a>' . $afterLink . '</span>';
        if ($listTags) {
            $out .= '</li>';
        }
    }
    $out = apply_filters('sph_GroupLinkTag', $out);
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}
function spa_save_login_data()
{
    check_admin_referer('forum-adminform_login', 'forum-adminform_login');
    # login
    $sflogin = sp_get_option('sflogin');
    $sflogin['sfregmath'] = isset($_POST['sfregmath']);
    if (!empty($_POST['sfloginurl'])) {
        $sflogin['sfloginurl'] = sp_filter_save_cleanurl($_POST['sfloginurl']);
    } else {
        $sflogin['sfloginurl'] = '';
    }
    if (!empty($_POST['sflogouturl'])) {
        $sflogin['sflogouturl'] = sp_filter_save_cleanurl($_POST['sflogouturl']);
    } else {
        $sflogin['sflogouturl'] = '';
    }
    if (!empty($_POST['sfregisterurl'])) {
        $sflogin['sfregisterurl'] = sp_filter_save_cleanurl($_POST['sfregisterurl']);
    } else {
        $sflogin['sfregisterurl'] = '';
    }
    if (!empty($_POST['sfloginemailurl'])) {
        $sflogin['sfloginemailurl'] = sp_filter_save_cleanurl($_POST['sfloginemailurl']);
    } else {
        $sflogin['sfloginemailurl'] = esc_url(wp_login_url(sp_url()));
    }
    if (!empty($_POST['sptimeout'])) {
        $timeout = sp_esc_int($_POST['sptimeout']);
    }
    if (!$timeout) {
        $timeout = 20;
    }
    $sflogin['sptimeout'] = $timeout;
    sp_update_option('sflogin', $sflogin);
    # RPX support
    $sfrpx = sp_get_option('sfrpx');
    $oldrpx = $sfrpx['sfrpxenable'];
    $sfrpx['sfrpxenable'] = isset($_POST['sfrpxenable']);
    $sfrpx['sfrpxkey'] = sp_esc_str($_POST['sfrpxkey']);
    $sfrpx['sfrpxredirect'] = sp_filter_save_cleanurl($_POST['sfrpxredirect']);
    # change in RPX support?
    if (!$oldrpx && $sfrpx['sfrpxenable']) {
        include_once SPBOOT . 'site/credentials/sp-rpx.php';
        $post_data = array('apiKey' => $_POST['sfrpxkey'], 'format' => 'json');
        $raw = sp_rpx_http_post('https://rpxnow.com/plugin/lookup_rp', $post_data);
        $r = sp_rpx_parse_lookup_rp($raw);
        if ($r) {
            $sfrpx['sfrpxrealm'] = $r['realm'];
        } else {
            $mess = spa_text('Error in RPX API data!');
            return $mess;
        }
    }
    sp_update_option('sfrpx', $sfrpx);
    do_action('sph_component_login_save');
    $mess = spa_text('Login and registration component updated');
    return $mess;
}
 function wp_new_user_notification($user_id, $user_pass = '')
 {
     $user = new WP_User($user_id);
     $sflogin = sp_get_option('sflogin');
     $eol = "\r\n";
     $user_login = $user->user_login;
     $user_email = $user->user_email;
     $message = '';
     $message .= sp_text_noesc('New user registration on your website') . ': ' . get_option('blogname') . $eol . $eol;
     $message .= sp_text_noesc('Username') . ': ' . $user_login . $eol;
     $message .= sp_text_noesc('E-mail') . ': ' . $user_email . $eol;
     $message .= sp_text_noesc('Registration IP') . ': ' . sp_get_ip() . $eol;
     $address = apply_filters('sph_admin_new_user_email_addrress', get_option('admin_email'), $user_id);
     $subject = apply_filters('sph_admin_new_user_email_subject', get_option('blogname') . ' ' . sp_text_noesc('New User Registration'), $user_id);
     $msg = apply_filters('sph_admin_new_user_email_msg', $message, $user_id);
     sp_send_email($address, $subject, $msg);
     if (empty($user_pass)) {
         return;
     }
     $mailoptions = sp_get_option('sfnewusermail');
     $subject = stripslashes($mailoptions['sfnewusersubject']);
     $body = stripslashes($mailoptions['sfnewusertext']);
     if (empty($subject) || empty($body)) {
         $subject = get_option('blogname') . ' ' . sp_text_noesc('Your username and password') . $eol . $eol;
         $body = sp_text_noesc('Username') . ': ' . $user_login . $eol;
         $body .= sp_text_noesc('Password') . ': ' . $user_pass . $eol . $eol;
         $body .= $sflogin['sfloginemailurl'] . $eol;
     } else {
         $blogname = get_bloginfo('name');
         $subject = str_replace('%USERNAME%', $user_login, $subject);
         $subject = str_replace('%PASSWORD%', $user_pass, $subject);
         $subject = str_replace('%BLOGNAME%', $blogname, $subject);
         $subject = str_replace('%SITEURL%', sp_url(), $subject);
         $subject = str_replace('%LOGINURL%', $sflogin['sfloginemailurl'], $subject);
         $body = str_replace('%USERNAME%', $user_login, $body);
         $body = str_replace('%PASSWORD%', $user_pass, $body);
         $body = str_replace('%BLOGNAME%', $blogname, $body);
         $body = str_replace('%SITEURL%', sp_url(), $body);
         $body = str_replace('%LOGINURL%', $sflogin['sfloginemailurl'], $body);
         $body = str_replace('%NEWLINE%', $eol, $body);
     }
     str_replace('<br />', $eol, $body);
     $address = apply_filters('sph_user_new_user_email_addrress', $user_email, $user_id);
     $subject = apply_filters('sph_user_new_user_email_subject', get_option('blogname') . ' ' . sp_text_noesc('New User Registration'), $user_id);
     $msg = apply_filters('sph_user_new_user_email_msg', $body, $user_id, $user_pass);
     sp_send_email($user_email, $subject, $msg);
 }
Example #9
0
function dis_bread_crumbs($str, $mstr = '&gt;')
{
    if (empty($mstr)) {
        $mstr = '&gt;';
    }
    if (substr($_SERVER['REQUEST_URI'], -1) == '/') {
        return '';
    }
    $pstr = '&nbsp;&nbsp;<a href="' . dis_base_url() . '" title="' . $_SERVER['HTTP_HOST'] . '">' . $_SERVER['HTTP_HOST'] . '</a>  ';
    $pstr .= $mstr . ' ';
    $r = sp_url();
    if ($r) {
        if ($r['typename'] == ART_STR) {
            //文章页
            //获取分类链接
            $catname = safe_field('Category1', 'textpattern', 'id=' . $r['id']);
            $row = safe_row('id,name,parent,title', 'txp_category', "type='article' and name='" . $catname . "'");
            if ($row) {
                if ($row['parent'] != '' && $row['parent'] != 'root') {
                    //有上级分类
                    $row1 = safe_row('id,name,parent,title', 'txp_category', "type='article' and name='" . $row['parent'] . "'");
                    if ($row1) {
                        $url1 = get_url($row1['id'], $row1['title'], 'cat');
                        $padd = str_replace('_title_', $row1['title'], $str);
                        $padd = str_replace('_text_', $row1['title'], $padd);
                        $padd = str_replace('_href_', $url1, $padd);
                        $pstr .= $padd . ' ';
                        $pstr .= $mstr . ' ';
                    }
                }
                $url = get_url($row['id'], $row['title'], 'cat');
                $padd = str_replace('_title_', $row['title'], $str);
                $padd = str_replace('_text_', $row['title'], $padd);
                $padd = str_replace('_href_', $url, $padd);
                $pstr .= $padd . ' ';
            }
        } elseif ($r['typename'] == CATE_STR) {
            //分类页
            $r['title'] = safe_field('name', 'txp_category', 'id=\'' . $r['id'] . '\'');
            $padd = str_replace('_title_', $r['title'], $str);
            $padd = str_replace('_text_', $r['title'], $padd);
            $padd = str_replace('_href_', '#', $padd);
            $pstr .= $padd . ' ';
        }
    }
    return $pstr;
}
function sp_wp_list_pages($ptext)
{
    global $spVars, $spGlobals;
    if (!empty($spVars['seotitle'])) {
        $seotitle = $spVars['seotitle'];
        $ptext = str_replace($seotitle, SFPAGETITLE, $ptext);
        $seotitle = html_entity_decode($seotitle, ENT_QUOTES);
        $seotitle = htmlspecialchars($seotitle, ENT_QUOTES, SFCHARSET);
        $ptext = str_replace($seotitle, SFPAGETITLE, $ptext);
        $seotitle = sp_filter_title_save($seotitle);
        $ptext = str_replace($seotitle, SFPAGETITLE, $ptext);
        $ptext = str_replace(strtoupper($seotitle), SFPAGETITLE, $ptext);
    } else {
        if ($spGlobals['display']['pagetitle']['banner'] || $spGlobals['display']['pagetitle']['notitle']) {
            $ptext = str_replace(sp_url() . '"></a>', sp_url() . '">' . SFPAGETITLE . '</a>', $ptext);
        }
    }
    return $ptext;
}
 <?php 
/*
Simple:Press
Barebones SP Theme Custom Test AHAH call
$LastChangedDate: 2014-09-12 07:30:12 +0100 (Fri, 12 Sep 2014) $
$Rev: 11958 $
*/
if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
    die('Access denied - you cannot directly call this file');
}
$url = sp_url() . '?test=on';
echo '<iframe height="100%" width="100%" src="' . $url . '"><iframe>';
die;
/*
Simple:Press
general ahah routines
$LastChangedDate: 2015-08-12 07:21:39 -0700 (Wed, 12 Aug 2015) $
$Rev: 13286 $
*/
if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
    die('Access denied - you cannot directly call this file');
}
sp_forum_api_support();
# get out of here if no action specified
if (empty($_GET['action'])) {
    die;
}
$action = sp_esc_str($_GET['action']);
if ($action == 'page-popup') {
    sp_text('Jump to page:');
    $permalink = trailingslashit(sp_esc_str($_GET['url']));
    $max = sp_esc_str($_GET['max']);
    $out = '<div id="spMainContainer">';
    $out .= '<form action="' . sp_url() . '" method="post" id ="pagejump" name="pagejump">' . "\n";
    $out .= '<input type="hidden" id="url" name="url" value="' . $permalink . '" />' . "\n";
    $out .= '<input type="hidden" id="max" name="max" value="' . $max . '" />' . "\n";
    $out .= '<label>' . sp_text('Enter page you want to go to:') . '</label>';
    $out .= '<input class="spSubmit" type="text" id="page" name="page" value="" />' . "\n";
    $out .= '<div style="text-align:center"><p><input type="submit" class="spButton" name="pagejump" value="' . sp_text('Go') . '" onclick="spjPageJump(); return false;" /></p></div>';
    $out .= '</form></div>' . "\n";
    echo apply_filters('sph_jump_page', $out);
}
die;
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;
}
Example #14
0
 $first = current($spPostList->listData);
 reset($spPostList->listData);
 # Define channel elements for each feed type
 switch ($feed) {
     case 'all':
         $rssTitle = get_bloginfo('name') . ' - ' . sp_text('All Forums');
         $rssLink = sp_url();
         if (isset($rssopt['sfrssfeedkey']) && $rssopt['sfrssfeedkey'] && isset($spThisUser->feedkey)) {
             $atomLink = trailingslashit(sp_build_url('', '', 0, 0, 0, 1)) . user_trailingslashit($spThisUser->feedkey);
         } else {
             $atomLink = sp_build_url('', '', 0, 0, 0, 1);
         }
         break;
     case 'group':
         $rssTitle = get_bloginfo('name') . ' - ' . sp_text('Group') . ': ' . $first->group_name;
         $rssLink = add_query_arg(array('group' => $groupid), sp_url());
         if (isset($rssopt['sfrssfeedkey']) && $rssopt['sfrssfeedkey'] && isset($spThisUser->feedkey)) {
             $atomLink = sp_get_sfqurl(trailingslashit(sp_build_url('', '', 0, 0, 0, 1)) . user_trailingslashit($spThisUser->feedkey)) . 'group=' . $groupid;
         } else {
             $atomLink = sp_get_sfqurl(sp_build_url('', '', 0, 0, 0, 1)) . 'group=' . $groupid;
         }
         break;
     case 'forum':
         $rssTitle = get_bloginfo('name') . ' - ' . sp_text('Forum') . ': ' . $first->forum_name;
         $rssLink = sp_build_url($first->forum_slug, '', 0, 0);
         if (isset($rssopt['sfrssfeedkey']) && $rssopt['sfrssfeedkey'] && isset($spThisUser->feedkey)) {
             $atomLink = trailingslashit(sp_build_url($first->forum_slug, '', 0, 0, 0, 1)) . user_trailingslashit($spThisUser->feedkey);
         } else {
             $atomLink = sp_build_url($first->forum_slug, '', 0, 0, 0, 1);
         }
         break;
<?php

/*
Simple:Press
DESC:
$LastChangedDate: 2014-06-21 20:33:29 -0700 (Sat, 21 Jun 2014) $
$Rev: 11585 $
*/
# ==========================================================================================
#
# 	FORUM PAGE
#	This file loads for forum page loads only
#
# ==========================================================================================
global $spStatus;
$redirect = isset($_SERVER['REDIRECT_URL']) ? $_SERVER['REDIRECT_URL'] : '';
if (!defined('SPMEMBERLIST')) {
    define('SPMEMBERLIST', sp_url('members'));
}
# hack to get around wp_list_pages() bug
if ($spStatus == 'ok') {
    # go for whole row so it gets cached.
    $t = spdb_table(SFWPPOSTS, 'ID=' . sp_get_option('sfpage'), 'row');
    if (!defined('SFPAGETITLE')) {
        define('SFPAGETITLE', $t->post_title);
    }
}
do_action('sph_forum_constants');
function spa_render_sidemenu()
{
    global $sfadminpanels, $spThisUser, $spDevice;
    $target = 'sfmaincontainer';
    $image = SFADMINIMAGES;
    $upgrade = admin_url('admin.php?page=' . SPINSTALLPATH);
    if (isset($_GET['tab']) ? $formid = sp_esc_str($_GET['tab']) : ($formid = '')) {
    }
    if ($spDevice == 'mobile') {
        echo '<div id="spaMobileAdmin">' . "\n";
        echo '<select class="wp-core-ui" onchange="location = this.options[this.selectedIndex].value;">' . "\n";
        foreach ($sfadminpanels as $index => $panel) {
            if (sp_current_user_can($panel[1]) || $panel[0] == 'Admins' && ($spThisUser->admin || $spThisUser->moderator)) {
                echo '<optgroup label="' . $panel[0] . '">' . "\n";
                foreach ($panel[6] as $label => $data) {
                    foreach ($data as $formid => $reload) {
                        # ignore user plugin data for menu
                        if ($formid == 'admin' || $formid == 'save' || $formid == 'form') {
                            continue;
                        }
                        $id = '';
                        if ($reload != '') {
                            $id = ' id="' . esc_attr($reload) . '"';
                        } else {
                            $id = ' id="acc' . esc_attr($formid) . '"';
                        }
                        $sel = '';
                        if (isset($_GET['tab'])) {
                            if ($_GET['tab'] == 'plugin') {
                                if (isset($_GET['admin']) && isset($data['admin']) && $_GET['admin'] == $data['admin']) {
                                    $sel = ' selected="selected" ';
                                }
                            } else {
                                if ($_GET['tab'] == $formid) {
                                    $sel = ' selected="selected" ';
                                }
                            }
                        }
                        echo "<option {$id} {$sel}";
                        $admin = !empty($data['admin']) ? '&admin=' . $data['admin'] : '';
                        $save = !empty($data['save']) ? '&save=' . $data['save'] : '';
                        $form = !empty($data['form']) ? '&form=' . $data['form'] : '';
                        if (empty($admin)) {
                            $base = SFHOMEURL . 'wp-admin/admin.php?page=simple-press/admin';
                        } else {
                            $base = SFHOMEURL . 'wp-admin/admin.php?page=simple-press/admin/panel-plugins/spa-plugins.php';
                            $panel[2] = '';
                        }
                        $http = $base . $panel[2] . '&tab=' . $formid . $admin . $save . $form;
                        echo 'value="' . $http . '">' . $label . '</option>' . "\n";
                    }
                }
                echo '</optgroup>' . "\n";
            }
        }
        echo '</select>' . "\n";
        echo '<a class="button button-secondary" href="' . sp_url() . '">' . spa_text('Go To Forum') . '</a>';
        echo '</div>' . "\n";
    } else {
        echo '<div id="sfsidepanel">' . "\n";
        echo '<div id="sfadminmenu">' . "\n";
        foreach ($sfadminpanels as $index => $panel) {
            if (sp_current_user_can($panel[1]) || $panel[0] == 'Admins' && ($spThisUser->admin || $spThisUser->moderator)) {
                $pName = str_replace(' ', '', $panel[0]);
                echo '<div class="sfsidebutton" id="sfacc' . $pName . '">' . "\n";
                echo '<div class="" title="' . esc_attr($panel[3]) . '"><span class="spa' . $panel[4] . '"></span><a href="#">' . $panel[0] . '</a></div>' . "\n";
                echo '</div>' . "\n";
                echo '<div class="sfmenublock">' . "\n";
                foreach ($panel[6] as $label => $data) {
                    foreach ($data as $formid => $reload) {
                        # ignore user plugin data for menu
                        if ($formid == 'admin' || $formid == 'save' || $formid == 'form') {
                            continue;
                        }
                        echo '<div class="sfsideitem">' . "\n";
                        $id = '';
                        if ($reload != '') {
                            $id = ' id="' . esc_attr($reload) . '"';
                        } else {
                            $id = ' id="acc' . esc_attr($formid) . '"';
                        }
                        $base = esc_js($panel[5]);
                        $admin = !empty($data['admin']) ? $data['admin'] : '';
                        $save = !empty($data['save']) ? $data['save'] : '';
                        $form = !empty($data['form']) ? $data['form'] : '';
                        ?>
								<a<?php 
                        echo $id;
                        ?>
 href="#" onclick="spjLoadForm('<?php 
                        echo $formid;
                        ?>
', '<?php 
                        echo $base;
                        ?>
', '<?php 
                        echo $target;
                        ?>
', '<?php 
                        echo $image;
                        ?>
', '', 'sfopen', '<?php 
                        echo $upgrade;
                        ?>
', '<?php 
                        echo esc_js($admin);
                        ?>
', '<?php 
                        echo esc_js($save);
                        ?>
', '<?php 
                        echo $form;
                        ?>
', '<?php 
                        echo $reload;
                        ?>
');"><?php 
                        echo $label;
                        ?>
</a><?php 
                        echo "\n";
                        ?>
								<?php 
                    }
                    echo '</div>' . "\n";
                }
                echo '</div>' . "\n";
            }
        }
        echo '</div>' . "\n";
        # Help link
        $site = SFHOMEURL . 'index.php?sp_ahah=troubleshooting&amp;sfnonce=' . wp_create_nonce('forum-ahah');
        echo '<br /><input type="button" id="spHelp" class="button-primary" value="' . spa_text('Simple:Press‌ Help and Troubleshooting') . '" onclick="spjTroubleshooting(\'' . $site . '\', \'' . $target . '\');" />' . "\n";
        echo '</div>' . "\n";
    }
}
 function sp_build_search_url()
 {
     global $spVars;
     $s = array();
     $s['forum'] = isset($_GET['forum']) ? $_GET['forum'] : '';
     $s['value'] = $spVars['searchvalue'];
     $s['type'] = $spVars['searchtype'];
     $s['include'] = $spVars['searchinclude'];
     $s = apply_filters('sph_build_search_url', $s);
     return add_query_arg($s, sp_url());
 }
function sp_AddButton($args = '', $label = '', $toolTip = '', $perm = '', $buttonID = '')
{
    global $spThisUser;
    $defs = array('tagId' => $buttonID, 'tagClass' => 'spButton', 'link' => sp_url(), 'icon' => '', 'iconClass' => 'spIcon', 'mobileMenu' => 0, 'echo' => 1);
    $a = wp_parse_args($args, $defs);
    $a = apply_filters('sph_AddButton_args', $a);
    extract($a, EXTR_SKIP);
    # verify optional 'simple' permission check
    if (!empty($perm) && !sp_get_auth($perm)) {
        return;
    }
    # allow for complex permission checking
    $auth = apply_filters('sph_add_button_auth_check', true, $buttonID, $a);
    if (!$auth) {
        return;
    }
    # sanitize before use
    $tagId = esc_attr($tagId);
    $tagClass = esc_attr($tagClass);
    $link = esc_url($link);
    $icon = sanitize_file_name($icon);
    $iconClass = esc_attr($iconClass);
    $mobileMenu = (int) $mobileMenu;
    $echo = (int) $echo;
    $toolTip = esc_attr($toolTip);
    if (!$mobileMenu) {
        $out = "<a class='{$tagClass} vtip' id='{$tagId}' title='{$toolTip}' href='{$link}'>";
        if (!empty($icon)) {
            $out .= "<img class='{$iconClass}' src='" . sp_find_icon(SPTHEMEICONSURL, $icon) . "' alt=''/>";
        }
        if (!empty($label)) {
            $out .= sp_filter_title_display($label);
        }
        $out .= "</a>\n";
    } else {
        $out = "<li class='{$tagClass}' id='{$tagId}'><a href='{$link}'>" . sp_filter_title_display($label) . "</a></li>\n";
    }
    $out = apply_filters('sph_AddButton', $out, $a);
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}
Example #19
0
function sp_rpx_signin_user($auth_info)
{
    $identifier = $auth_info['profile']['identifier'];
    $wpuid = sp_rpx_get_wpuid_by_identifier($identifier);
    # if we don't have the identifier mapped to wp user, create a new one
    if (!$wpuid) {
        $wpuid = sp_rpx_create_wp_user($auth_info);
        if (is_wp_error($wpuid)) {
            sp_notify(SPFAILURE, sp_text('Sorry, cannot create account as the username or email address already exists'));
            wp_redirect(sp_url());
            die;
        }
    }
    # sign the user in
    wp_set_auth_cookie($wpuid, true, false);
    wp_set_current_user($wpuid);
    # redirect them back to the page they were originally on
    wp_redirect($_GET['goback']);
    die;
}
function sp_NewPostListAdmin($newposts)
{
    global $spVars, $spThisUser, $spGlobals, $spDevice;
    $alt = '';
    $nourl = '';
    if ($newposts) {
        $index = array();
        foreach ($newposts as $newpost) {
            $forumid = $newpost['forum_id'];
            $index[$forumid] = count($newpost['topics']);
        }
        # Set up the autoupdate url (for quicklinks refreshing)
        $updateUrl = SFHOMEURL . 'index.php?sp_ahah=autoupdate&amp;sfnonce=' . wp_create_nonce('forum-ahah');
        # Display section heading
        echo '<div class="spAdminQueueHeader">';
        echo '<a id="newpoststop"></a>';
        $options = sp_get_option('spAdminBar');
        if ($spThisUser->admin || $spThisUser->moderator) {
            $p = $spDevice == 'mobile' && current_theme_supports('sp-theme-responsive') ? SPABIMAGESMOB : SPABIMAGES;
            echo '<form class="sfsubhead" action="' . sp_url() . '" method="post" name="removequeue">';
            echo '<input type="hidden" name="doqueue" value="1" />';
            echo '<p class="spLeft">' . __('New/Unread Posts Management', 'spab') . '</p>';
            echo '<a class="spButton spRight" href="javascript:document.removequeue.submit();">' . sp_paint_icon('', $p, "sp_markRead.png") . __('Empty the Admin Postbag', 'spab') . '</a>';
            echo '</form>';
            $removal = true;
            $canremove = '1';
        }
        echo '</div>';
        # Start actual listing display
        echo '<div class="spInlineSection spMessageSuccess" id="spAdminQueueMsg"></div>';
        # Display new posts heading
        sp_SectionStart('tagClass=spAdminQueueSection', 'AdminQueue');
        echo '<p style="text-align:center" class="spAdminBarTitle">' . __('Forums and Topics', 'spab') . '</p>';
        # Start with main forum header
        foreach ($newposts as $newpost) {
            # Display forum name
            echo '<div id="spAdminQueueForum' . $newpost['forum_id'] . '" class="spAdminQueueForum">';
            sp_ColumnStart('tagClass=spColumnSection spLeft&height=30px&width=9%');
            $icon = !empty($newpost['forum_icon']) ? sp_paint_custom_icon('spRopwIcon', SFCUSTOMURL . $newpost['forum_icon']) : sp_paint_icon('spTowIcon', SPTHEMEICONSURL, 'sp_ForumIcon.png');
            echo $icon;
            sp_ColumnEnd();
            sp_ColumnStart('tagClass=spColumnSection spLeft&height=30px&width=90%');
            echo '<p class="spAdminForum">';
            echo '<a class="spRowName" href="' . sp_build_url($newpost['forum_slug'], '', 1, 0) . '">Forum: ' . $newpost['forum_name'] . '</a>';
            echo '</p>';
            echo '<input type="hidden" id="tcount' . $newpost['forum_id'] . '" value="' . $index[$newpost['forum_id']] . '" />';
            sp_ColumnEnd();
            echo '<div class="spClear"></div>';
            echo '</div>';
            # Now for each topic with new posts
            foreach ($newpost['topics'] as $topic) {
                $postcountmod = 0;
                $postcountord = 0;
                # a quick first pass to load the post count variables and check for spam
                $is_spam = false;
                foreach ($topic['posts'] as $post) {
                    if ($post['post_status'] != 0 ? $postcountmod++ : $postcountord++) {
                    }
                    if ($post['post_status'] == 2) {
                        $is_spam = true;
                    }
                    $lastpost_id = $post['post_id'];
                }
                # Display topics in forum
                $class = $postcountmod ? 'spSubmit spModButton' : 'spSubmit spUnreadButton';
                echo '<div id="spAdminQueueTopic' . $topic['topic_id'] . '" class="spAdminQueueTopic">';
                sp_ColumnStart('tagClass=spColumnSection spLeft&height=30px&width=10%');
                echo "<input type='button' name='openicon" . $topic['topic_id'] . "' class='" . $class . "' value='";
                echo esc_attr(__('View', 'spab'));
                if ($is_spam) {
                    echo "\n" . esc_attr(__('Spam', 'spab'));
                }
                echo "' onclick='spjToggleLayer(\"spAdminQueueThisTopic" . $topic['topic_id'] . "\");' />";
                echo '<input type="hidden" id="pcount' . $topic['topic_id'] . '" value="' . $topic['post_count'] . '" />';
                echo '<input type="hidden" id="pcountmod' . $topic['topic_id'] . '" value="' . $postcountmod . '" />';
                echo '<input type="hidden" id="pcountord' . $topic['topic_id'] . '" value="' . $postcountord . '" />';
                sp_ColumnEnd();
                sp_ColumnStart('tagClass=spColumnSection spLeft&height=30px&width=90%');
                echo '<p>' . sp_get_topic_newpost_url($newpost['forum_slug'], $topic['topic_slug'], $topic['topic_name'], $lastpost_id, $post['post_index']) . '</p>';
                $nourl = '';
                if ($topic['post_count'] == 1) {
                    $note = __('There is 1 new post in this topic', 'spab');
                } else {
                    $note = sprintf(__('There are %s new posts in this topic', 'spab'), $topic['post_count']);
                }
                echo '<p class="spLabelSmall">' . $note . '</p>';
                sp_ColumnEnd();
                echo '<div class="spClear"></div>';
                echo '</div>';
                # Start display of post information
                echo '<div id="spAdminQueuePost' . $topic['topic_id'] . '" class="spAdminQueuePost">';
                echo '<div id="spAdminQueueThisTopic' . $topic['topic_id'] . '" class="spPostSection spInlineSection">';
                echo '<p style="text-align:center" class="spAdminBarTitle">' . __('Post Details', 'spab') . '</p>';
                $pindex = 0;
                $mod_required = false;
                # Start the post display loop
                foreach ($topic['posts'] as $post) {
                    $is_spam = false;
                    if ($pindex > 0) {
                        echo '<hr>';
                    }
                    echo '<div id="spAdminQueueThisPost' . $post['post_id'] . '" class="spAdminQueueThisPost">';
                    $pindex++;
                    $lastpost = $pindex == $topic['post_count'] ? true : false;
                    if ($post['post_status'] != 0) {
                        $mod_required = true;
                        echo '<div class="spAdminQueueMod spRight">' . __('Awaiting moderation', 'spab');
                        if ($post['post_status'] == 2) {
                            $is_spam = true;
                            echo '<br />' . __('Akismet marked as spam', 'spab');
                        }
                        echo '</div>';
                    }
                    echo '<b>' . sp_filter_name_display($post['display_name']) . '</b><br /><small>' . $post['user_type'] . '</small>';
                    echo '<br /><small>' . sprintf(__('Post %s in Topic', 'spab'), $post['post_index']) . '</small>';
                    echo '<hr />' . sp_filter_content_display($post['post_content']) . '</td>';
                    echo '</div>';
                    # Set up the ahah base url
                    $basesite = SFHOMEURL . "index.php?sp_ahah=moderation&amp;sfnonce=" . wp_create_nonce('forum-ahah') . "&amp;pid=" . $post['post_id'] . "&amp;tid=" . $topic['topic_id'] . "&amp;fid=" . $newpost['forum_id'];
                    echo '<div id="spAdminQueueThisPostButtons' . $post['post_id'] . '" class="spAdminQueueThisPostButtons">';
                    echo '<table><tr>';
                    if ($topic['post_count'] == 1) {
                        $label = __('This Post', 'spab');
                    } else {
                        $label = __('All Posts', 'spab');
                    }
                    if ($lastpost) {
                        $site = $basesite . '&amp;action=0&amp;canremove=' . $canremove;
                        if ($mod_required) {
                            if (sp_get_auth('moderate_posts', $newpost['forum_id'])) {
                                $posturl = sp_build_url($newpost['forum_slug'], $topic['topic_slug'], 0, $post['post_id'], $post['post_index']);
                            }
                        } else {
                            $posturl = sp_build_url($newpost['forum_slug'], $topic['topic_slug'], 0, $post['post_id'], $post['post_index']);
                        }
                        if ($mod_required) {
                            $m = $spDevice == 'mobile' ? esc_attr(__("Approve & Load", 'spab')) : sp_splice(esc_attr(sprintf(__("Mark %s Approved and go to Topic", 'spab'), $label)), 2);
                            echo '<td><input type="button" class="spSubmit" name="g0-' . $post['post_id'] . '" value="' . $m . '" style="white-space: pre;" onclick="spabModeratePost(\'' . $posturl . '\', \'' . $site . '\', \'' . $removal . '\', \'' . $post['post_id'] . '\', \'' . $newpost['forum_id'] . '\', \'' . $topic['topic_id'] . '\', \'' . $post['post_status'] . '\', \'9\', \'' . $updateUrl . '\');" /></td>';
                            $m = $spDevice == 'mobile' ? esc_attr(__("Approve & Close", 'spab')) : sp_splice(esc_attr(sprintf(__("Mark %s Approved and Close", 'spab'), $label)), 2);
                            echo '<td><input type="button" class="spSubmit" name="a0-' . $post['post_id'] . '" value="' . $m . '" style="white-space: pre;" onclick="spabModeratePost(\'' . $nourl . '\', \'' . $site . '\', \'' . $removal . '\', \'' . $post['post_id'] . '\', \'' . $newpost['forum_id'] . '\', \'' . $topic['topic_id'] . '\', \'' . $post['post_status'] . '\', \'0\', \'' . $updateUrl . '\');" /></td>';
                            if ($spDevice == 'mobile') {
                                echo '</tr></tr>';
                            }
                            $m = $spDevice == 'mobile' ? esc_attr(__("Approve & Reply", 'spab')) : sp_splice(esc_attr(sprintf(__("Mark %s Approved and Quick Reply", 'spab'), $label)), 2);
                            echo '<td><input type="button" class="spSubmit" name="q0-' . $post['post_id'] . '" value="' . $m . '" style="white-space: pre;" onclick="spjToggleLayer(\'sfqform' . $topic['topic_id'] . '\');" /></td>';
                            $qaction = 0;
                        } else {
                            $site = $basesite . '&amp;action=1&amp;canremove=' . $canremove;
                            $m = $spDevice == 'mobile' ? esc_attr(__("Mark Read & Load", 'spab')) : sp_splice(esc_attr(sprintf(__("Mark %s as Read and go to Topic", 'spab'), $label)), 2);
                            echo '<td><input type="button" class="spSubmit" name="g1-' . $post['post_id'] . '" value="' . $m . '" style="white-space: pre;" onclick="spabModeratePost(\'' . $posturl . '\', \'' . $site . '\', \'' . $removal . '\', \'' . $post['post_id'] . '\', \'' . $newpost['forum_id'] . '\', \'' . $topic['topic_id'] . '\', \'' . $post['post_status'] . '\', \'1\', \'' . $updateUrl . '\');" /></td>';
                            $m = $spDevice == 'mobile' ? esc_attr(__("Mark Read & Close", 'spab')) : sp_splice(esc_attr(sprintf(__("Mark %s as Read and Close", 'spab'), $label)), 2);
                            echo '<td><input type="button" class="spSubmit" name="a1-' . $post['post_id'] . '" value="' . $m . '" style="white-space: pre;" onclick="spabModeratePost(\'' . $nourl . '\', \'' . $site . '\', \'' . $removal . '\', \'' . $post['post_id'] . '\', \'' . $newpost['forum_id'] . '\', \'' . $topic['topic_id'] . '\', \'' . $post['post_status'] . '\', \'1\', \'' . $updateUrl . '\');" /></td>';
                            if ($spDevice == 'mobile') {
                                echo '</tr></tr>';
                            }
                            $m = $spDevice == 'mobile' ? esc_attr(__("Mark Read & Reply", 'spab')) : sp_splice(esc_attr(sprintf(__("Mark %s as Read and Quick Reply", 'spab'), $label)), 2);
                            echo '<td><input type="button" class="spSubmit" name="a1-' . $post['post_id'] . '" value="' . $m . '" style="white-space: pre;" onclick="spjToggleLayer(\'sfqform' . $topic['topic_id'] . '\');" /></td>';
                            $qaction = 1;
                        }
                    }
                    if ($removal) {
                        $remsite = $basesite . '&amp;action=2&amp;canremove=' . $canremove;
                        $msg = esc_js(__('Are you sure you want to delete this Post?', 'spab'));
                        $m = $spDevice == 'mobile' ? esc_attr(__("Delete Post", 'spab')) : sp_splice(esc_attr(__("Delete this Post", 'spab')), 0);
                        echo '<td><input type="button" class="spSubmit" name="a2-' . $post['post_id'] . '" value="' . $m . '" style="white-space: pre;" onclick="javascript: if(confirm(\'' . $msg . '\')) {spabModeratePost(\'' . $nourl . '\', \'' . $remsite . '\', \'' . $removal . '\', \'' . $post['post_id'] . '\', \'' . $newpost['forum_id'] . '\', \'' . $topic['topic_id'] . '\', \'' . $post['post_status'] . '\', \'2\', \'' . $updateUrl . '\');}" /></td>';
                        if ($post['user_type'] == 'Member' && $is_spam) {
                            $actionUrl = SFHOMEURL . 'index.php?sp_ahah=remove-spam&amp;sfnonce=' . wp_create_nonce('forum-ahah') . '&amp;postid=' . $post['post_id'] . '&amp;userid=' . $post['user_id'];
                            $updateUrl = SFHOMEURL . 'index.php?sp_ahah=admin-bar-update&amp;target=newposts&amp;sfnonce=' . wp_create_nonce('forum-ahah');
                            echo '</tr></tr>';
                            $m = $spDevice == 'mobile' ? esc_attr(__("Remove Member & All Their Posts", 'spab')) : sp_splice(esc_attr(__("Remove this Member and All their Posts", 'spab')), 2);
                            echo '<td colspan="2"><input type="button" class="spSubmit" name="delSpam-' . $post['post_id'] . '" value="' . $m . '" style="white-space: pre;" onclick="spabRemoveSpam(\'' . $actionUrl . '\', \'' . $updateUrl . '\');" /></td>';
                        }
                    }
                    echo '</tr></table>';
                    # Quick Reply Form
                    if ($lastpost) {
                        $qsavesite = SFHOMEURL . "index.php?sp_ahah=quickreply&amp;sfnonce=" . wp_create_nonce('forum-ahah') . "&amp;tid=" . $topic['topic_id'] . "&amp;fid=" . $newpost['forum_id'];
                        echo '<div id="sfqform' . $topic['topic_id'] . '" class="spInlineSection">';
                        echo '<form action="' . sp_url() . '" method="post" name="addpost' . $topic['topic_id'] . '" onsubmit="return spabSaveQuickReply(this, \'' . $qsavesite . '\', \'' . $site . '\', \'' . $post['post_id'] . '\', \'' . $newpost['forum_id'] . '\', \'' . $topic['topic_id'] . '\', \'' . $post['post_status'] . '\', \'' . $qaction . '\', \'' . $updateUrl . '\')">';
                        echo '<textarea  tabindex="1" class="spControl" name="postitem' . $topic['topic_id'] . '" id="postitem' . $topic['topic_id'] . '" cols="60" rows="8"></textarea>';
                        echo '<br /><input type="submit" tabindex="2" class="spSubmit" id="sfsave' . $topic['topic_id'] . '" name="newpost' . $topic['topic_id'] . '" value="' . esc_attr(__('Save New Post', 'spab')) . '" />';
                        do_action('sph_quickreply_form', $newpost, $topic, $post);
                        echo '</form><br /></div>';
                    }
                    echo '</div>';
                }
                echo '</div>';
                echo '</div>';
            }
        }
        sp_SectionEnd('', 'AdminQueue');
    } else {
        echo '<div class="spMessage">';
        echo __('There are no unread posts', 'spab') . '</div>';
        echo "<div class='spInlineSection' id='spAdminQueueMsg'></div>\n";
    }
}
function sp_MemberListUsergroupSelect($args = '')
{
    global $spMembersList;
    if (empty($spMembersList->userGroups)) {
        return;
    }
    if (!sp_get_auth('view_members_list')) {
        return;
    }
    global $spMembersList;
    $defs = array('tagId' => 'spUsergroupSelect', 'tagClass' => 'spUsergroupSelect', 'selectClass' => 'spControl', 'echo' => 1);
    $a = wp_parse_args($args, $defs);
    $a = apply_filters('sph_MemberListUsergroupSelect_args', $a);
    extract($a, EXTR_SKIP);
    # sanitize before use
    $tagId = esc_attr($tagId);
    $tagClass = esc_attr($tagClass);
    $selectClass = esc_attr($selectClass);
    $echo = (int) $echo;
    $search = !empty($_POST['msearch']) && !isset($_POST['allmembers']) ? '&amp;msearch=' . sp_esc_str($_POST['msearch']) : '';
    $search = !empty($_GET['msearch']) ? '&amp;msearch=' . sp_esc_str($_GET['msearch']) : $search;
    $ug = !empty($_POST['ug']) && !isset($_POST['allmembers']) ? sp_esc_int($_POST['ug']) : '';
    $ug = !empty($_GET['ug']) ? sp_esc_int($_GET['ug']) : $ug;
    $out = "<div id='{$tagId}' class='{$tagClass}'>";
    $out .= "<select class='{$selectClass}' name='sp_usergroup_select' onchange='javascript:spjChangeURL(this)'>";
    $out .= "<option value='#'>" . sp_text('Select Specific Usergroup') . "</option>";
    foreach ($spMembersList->userGroups as $usergroup) {
        $selected = $usergroup['usergroup_id'] == $ug ? "selected='selected'" : '';
        $out .= "<option {$selected} value='" . sp_get_sfqurl(sp_url('members')) . 'ug=' . $usergroup['usergroup_id'] . $search . "'>" . sp_filter_title_display($usergroup['usergroup_name']) . '</option>';
    }
    if (!empty($ug)) {
        $out .= "<option value='" . sp_get_sfqurl(sp_url('members')) . $search . "'>" . sp_text('Reset to Default Usergroups') . "</option>";
    }
    $out .= '</select>';
    $out .= "</div>\n";
    $out = apply_filters('sph_MemberListUsergroupSelect', $out, $a);
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}
Example #22
0
    sp_add_option('spUnZip2', $successExtract2);
    sp_response($section);
}
$section = 6936;
if ($build < $section) {
    # Move storage location folders
    if (sp_get_option('V5DoStorage') == true) {
        sp_move_storage_locations();
    }
    sp_response($section);
}
$section = 6949;
if ($build < $section) {
    $sflogin = sp_get_option('sflogin');
    $sflogin['sfloginurl'] = sp_url();
    $sflogin['sflogouturl'] = sp_url();
    $sflogin['sfregisterurl'] = '';
    $sflogin['sfloginemailurl'] = esc_url(wp_login_url());
    sp_update_option('sflogin', $sflogin);
    sp_response($section);
}
$section = 6962;
if ($build < $section) {
    spdb_query('DELETE FROM ' . SFMEMBERSHIPS . ' WHERE usergroup_id=0');
    sp_response($section);
}
## after alpha start
$section = 7022;
if ($build < $section) {
    spdb_query('ALTER TABLE ' . SFTRACK . ' ADD (pageview varchar(50) NOT NULL)');
    sp_response($section);
function sp_ProfileShowLink($args = '', $label = '')
{
    global $spProfileUser;
    if (!sp_get_auth('view_profiles')) {
        return;
    }
    $defs = array('tagClass' => 'spProfileShowLink', 'echo' => 1);
    $a = wp_parse_args($args, $defs);
    $a = apply_filters('sph_ProfileShowLink_args', $a);
    extract($a, EXTR_SKIP);
    # sanitize before use
    $tagClass = esc_attr($tagClass);
    $label = str_ireplace('%USER%', $spProfileUser->display_name, $label);
    $label = sp_filter_title_display($label);
    $echo = (int) $echo;
    # output the header
    $out = "<a rel='nofollow' class='{$tagClass}' href='" . sp_url('profile/' . $spProfileUser->ID) . "'>{$label}</span></a>\n";
    $out = apply_filters('sph_ProfileShowLink', $out, $spProfileUser, $a);
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}
Example #24
0
if (sp_pm_has_threadlist()) {
    while (sp_pm_loop_threadlist()) {
        sp_pm_threadlist();
        sp_SectionStart('tagId=spPmThreadSection' . $spThisPmThreadList->thread_id . '&tagClass=spPmThreadSection spForumTopicSection ' . ($spThisPmThreadList->read_status ? 'spPmRead' : 'spPmUnread'), 'pmThread');
        # Column 1 of the thread row
        # ----------------------------------------------------------------------
        sp_ColumnStart('tagClass=spColThread1 spColumnSection spLeft&height=55px');
        sp_UserAvatar('context=user&size=50', $spThisPmThreadList->last_sender_id);
        if ($spDevice == 'mobile') {
            sp_InsertBreak();
            sp_PmThreadIndexMessageCount('tagClass=spLabelBordered spCenter&spanClass=');
        }
        sp_ColumnEnd();
        # Column 2 of the thread row
        # ----------------------------------------------------------------------
        echo "<a class='' href='" . sp_url("private-messaging/thread/{$spThisPmThreadList->thread_id}") . "' title='" . __('Click to view this thread', 'sp-pm') . "'>";
        sp_ColumnStart('tagClass=spColThread2 spColumnSection spLeft&height=55px');
        if ($spDevice == 'mobile') {
            # last message
            sp_PmThreadIndexTitle('tagClass=spRowName spLeft');
            sp_InsertBreak();
            sp_PmThreadIndexSender('tagClass=spInRowLabel spLeft&spanClass=', __('Last Received: ', 'sp-pm'));
            sp_InsertBreak();
            sp_PmThreadIndexDate('tagClass=spInRowLabel spLeft&spanClass=&nicedate=1', __('', 'sp-pm'));
            sp_InsertBreak();
            # first message
            sp_PmThreadIndexFirstSender('tagClass=spInRowLabel&spanClass=', __('Started By: ', 'sp-pm'));
        }
        if ($spDevice != 'mobile') {
            # last message
            ?>
Example #25
0
function sp_perform_install($phase, $subphase = 0)
{
    global $current_user, $spVars;
    switch ($phase) {
        case 1:
            # create an array of installed tables to save for uninstall. plugins will add theirs to be sure we get good cleanup
            $tables = array();
            # sfauthcats table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFAUTHCATS . ' (
					authcat_id tinyint(4) NOT NULL auto_increment,
					authcat_name varchar(50) NOT NULL,
					authcat_slug varchar(50) NOT NULL,
					authcat_desc tinytext,
					PRIMARY KEY	 (authcat_id),
					KEY authcat_slug_idx (authcat_slug)
				) ' . spdb_charset();
            spdb_query($sql);
            $tables[] = SFAUTHCATS;
            # sfauths table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFAUTHS . " (\n\t\t\t\t\tauth_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tauth_name varchar(50) NOT NULL,\n\t\t\t\t\tauth_desc text,\n\t\t\t\t\tactive smallint(1) NOT NULL default '0',\n\t\t\t\t\tignored smallint(1) NOT NULL default '0',\n\t\t\t\t\tenabling smallint(1) NOT NULL default '0',\n\t\t\t\t\tadmin_negate smallint(1) NOT NULL default '0',\n\t\t\t\t\tauth_cat bigint(20) NOT NULL default '1',\n\t\t\t\t\twarning tinytext,\n\t\t\t\t\tPRIMARY KEY\t (auth_id),\n\t\t\t\t\tKEY auth_name_idx (auth_name)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFAUTHS;
            # the cache table (5.4.2)
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFCACHE . " (\n\t\t\t\t\tcache_id varchar(40) NOT NULL DEFAULT '',\n\t\t\t\t\tcache_out bigint(6) DEFAULT NULL,\n\t\t\t\t\tcache mediumtext,\n\t\t\t\t\tPRIMARY KEY (cache_id)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFCACHE;
            # sfdefpermissions table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFDEFPERMISSIONS . " (\n\t\t\t\t\tpermission_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tgroup_id bigint(20) NOT NULL default '0',\n\t\t\t\t\tusergroup_id bigint(20) NOT NULL default '0',\n\t\t\t\t\tpermission_role bigint(20) NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY\t (permission_id),\n\t\t\t\t\tKEY group_id_idx (group_id),\n\t\t\t\t\tKEY usergroup_id_idx (usergroup_id),\n\t\t\t\t\tKEY permission_role_idx (permission_role)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFDEFPERMISSIONS;
            # error log table
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFERRORLOG . " (\n\t\t\t\t\tid bigint(20) NOT NULL auto_increment,\n\t\t\t\t\terror_date datetime NOT NULL,\n\t\t\t\t\terror_type varchar(10) NOT NULL,\n\t\t\t\t\terror_cat varchar(13) NOT NULL default 'spaErrOther',\n\t\t\t\t\tkeycheck varchar(45),\n\t\t\t\t\terror_count smallint(6),\n\t\t\t\t\terror_text text,\n\t\t\t\t\tPRIMARY KEY (id)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFERRORLOG;
            # sfforums table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFFORUMS . " (\n\t\t\t\t\tforum_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tforum_name varchar(200) NOT NULL,\n\t\t\t\t\tgroup_id bigint(20) NOT NULL,\n\t\t\t\t\tforum_seq int(4) default NULL,\n\t\t\t\t\tforum_desc text default NULL,\n\t\t\t\t\tforum_status int(4) NOT NULL default '0',\n\t\t\t\t\tforum_disabled smallint(1) NOT NULL default '0',\n\t\t\t\t\tforum_slug varchar(200) NOT NULL,\n\t\t\t\t\tforum_rss text default NULL,\n\t\t\t\t\tforum_icon varchar(50) default NULL,\n\t\t\t\t\tforum_icon_new varchar(50) default NULL,\n\t\t\t\t\tforum_icon_locked varchar(50) default NULL,\n\t\t\t\t\ttopic_icon varchar(50) default NULL,\n\t\t\t\t\ttopic_icon_new varchar(50) default NULL,\n\t\t\t\t\ttopic_icon_locked varchar(50) default NULL,\n\t\t\t\t\ttopic_icon_pinned varchar(50) default NULL,\n\t\t\t\t\tpost_id bigint(20) default NULL,\n\t\t\t\t\tpost_id_held bigint(20) default NULL,\n\t\t\t\t\ttopic_count mediumint(8) default '0',\n\t\t\t\t\tpost_count mediumint(8) default '0',\n\t\t\t\t\tpost_count_held mediumint(8) default '0',\n\t\t\t\t\tforum_rss_private smallint(1) NOT NULL default '0',\n\t\t\t\t\tparent bigint(20) NOT NULL default '0',\n\t\t\t\t\tchildren text default NULL,\n\t\t\t\t\tforum_message text,\n\t\t\t\t\tkeywords varchar(256) default NULL,\n\t\t\t\t\tPRIMARY KEY\t (forum_id),\n\t\t\t\t\tKEY group_id_idx (group_id),\n\t\t\t\t\tKEY forum_slug_idx (forum_slug),\n\t\t\t\t\tKEY post_id_idx (post_id)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFFORUMS;
            # sfgroups table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFGROUPS . ' (
					group_id bigint(20) NOT NULL auto_increment,
					group_name text,
					group_seq int(4) default NULL,
					group_desc text,
					group_rss text,
					group_icon varchar(50) default NULL,
					group_message text,
					PRIMARY KEY	 (group_id)
				) ' . spdb_charset();
            spdb_query($sql);
            $tables[] = SFGROUPS;
            # install log table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFLOG . ' (
					id bigint(20) NOT NULL auto_increment,
					user_id bigint(20) NOT NULL,
					install_date date NOT NULL,
					release_type varchar(20),
					version varchar(10) NOT NULL,
					build int(6) NOT NULL,
					PRIMARY KEY (id)
				) ' . spdb_charset();
            spdb_query($sql);
            $tables[] = SFLOG;
            # install log section table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFLOGMETA . ' (
					id int(11) unsigned NOT NULL AUTO_INCREMENT,
					version varchar(10) DEFAULT NULL,
					log_data tinytext,
					PRIMARY KEY (id)
				) ' . spdb_charset();
            spdb_query($sql);
            $tables[] = SFLOGMETA;
            # sfmembers table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFMEMBERS . " (\n\t\t\t\t\tuser_id bigint(20) NOT NULL default '0',\n\t\t\t\t\tdisplay_name varchar(100) default NULL,\n\t\t\t\t\tmoderator smallint(1) NOT NULL default '0',\n\t\t\t\t\tavatar longtext default NULL,\n\t\t\t\t\tsignature text default NULL,\n\t\t\t\t\tposts int(4) default NULL,\n\t\t\t\t\tlastvisit datetime default NULL,\n\t\t\t\t\tnewposts longtext,\n\t\t\t\t\tchecktime datetime default NULL,\n\t\t\t\t\tadmin smallint(1) NOT NULL default '0',\n\t\t\t\t\tfeedkey varchar(36) default NULL,\n\t\t\t\t\tadmin_options longtext default NULL,\n\t\t\t\t\tuser_options longtext default NULL,\n\t\t\t\t\tauths longtext default NULL,\n\t\t\t\t\tmemberships longtext default NULL,\n\t\t\t\t\tplugin_data longtext default NULL,\n\t\t\t\t\tPRIMARY KEY\t (user_id),\n\t\t\t\t\tKEY admin_idx (admin),\n\t\t\t\t\tKEY moderator_idx (moderator)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFMEMBERS;
            # sfmemberships table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFMEMBERSHIPS . " (\n\t\t\t\t\tmembership_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tuser_id bigint(20) unsigned NOT NULL default '0',\n\t\t\t\t\tusergroup_id bigint(20) unsigned NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY\t (membership_id),\n\t\t\t\t\tKEY user_id_idx (user_id),\n\t\t\t\t\tKEY usergroup_id_idx (usergroup_id)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFMEMBERSHIPS;
            # sfmeta table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFMETA . " (\n\t\t\t\t\tmeta_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tmeta_type varchar(20) NOT NULL,\n\t\t\t\t\tmeta_key varchar(100) default NULL,\n\t\t\t\t\tmeta_value longtext,\n\t\t\t\t\tautoload tinyint(2) NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY (meta_id),\n\t\t\t\t\tKEY meta_type_idx (meta_type),\n\t\t\t\t\tKEY autoload_idx (autoload)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFMETA;
            # user notices table
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFNOTICES . " (\n\t\t\t\t\tnotice_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tuser_id bigint(20) default NULL,\n\t\t\t\t\tguest_email varchar(75) default NULL,\n\t\t\t\t\tpost_id bigint(20) default NULL,\n\t\t\t\t\tlink varchar(255) default NULL,\n\t\t\t\t\tlink_text varchar(200) default NULL,\n\t\t\t\t\tmessage varchar(255) NOT NULL default '',\n\t\t\t\t\texpires int(4) default NULL,\n\t\t\t\t\tPRIMARY KEY (notice_id),\n\t\t\t\t\tKEY user_id_idx (user_id)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFNOTICES;
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFOPTIONS . " (\n\t\t\t\t\toption_id bigint(20) unsigned NOT NULL auto_increment,\n\t\t\t\t\toption_name varchar(64) NOT NULL default '',\n\t\t\t\t\toption_value longtext NOT NULL,\n\t\t\t\t\tPRIMARY KEY (option_name),\n\t\t\t\t\tKEY option_id_idx (option_id)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFOPTIONS;
            # sfpermissions table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFPERMISSIONS . " (\n\t\t\t\t\tpermission_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tforum_id bigint(20) NOT NULL default '0',\n\t\t\t\t\tusergroup_id bigint(20) unsigned NOT NULL default '0',\n\t\t\t\t\tpermission_role bigint(20) NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY\t (permission_id),\n\t\t\t\t\tKEY forum_id_idx (forum_id),\n\t\t\t\t\tKEY usergroup_id_idx (usergroup_id),\n\t\t\t\t\tKEY permission_role_idx (permission_role)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFPERMISSIONS;
            # sfposts table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFPOSTS . " (\n\t\t\t\t\tpost_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tpost_content longtext,\n\t\t\t\t\tpost_date datetime NOT NULL,\n\t\t\t\t\ttopic_id bigint(20) NOT NULL,\n\t\t\t\t\tuser_id bigint(20) default NULL,\n\t\t\t\t\tforum_id bigint(20) NOT NULL,\n\t\t\t\t\tguest_name varchar(50) default NULL,\n\t\t\t\t\tguest_email varchar(75) default NULL,\n\t\t\t\t\tpost_status int(4) NOT NULL default '0',\n\t\t\t\t\tpost_pinned smallint(1) NOT NULL default '0',\n\t\t\t\t\tpost_index mediumint(8) default '0',\n\t\t\t\t\tpost_edit mediumtext,\n\t\t\t\t\tposter_ip varchar(39) NOT NULL default '0.0.0.0',\n\t\t\t\t\tcomment_id bigint(20) default NULL,\n\t\t\t\t\tsource smallint(1) NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY\t (post_id),\n\t\t\t\t\tKEY topic_id_idx (topic_id),\n\t\t\t\t\tKEY forum_id_idx (forum_id),\n\t\t\t\t\tKEY user_id_idx (user_id),\n\t\t\t\t\tKEY guest_name_idx (guest_name),\n\t\t\t\t\tKEY comment_id_idx (comment_id),\n\t\t\t\t\tKEY post_date_idx (post_date)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFPOSTS;
            # sfroles table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFROLES . " (\n\t\t\t\t\trole_id mediumint(8) unsigned NOT NULL auto_increment,\n\t\t\t\t\trole_name varchar(50) NOT NULL default '',\n\t\t\t\t\trole_desc varchar(150) NOT NULL default '',\n\t\t\t\t\trole_auths longtext NOT NULL,\n\t\t\t\t\tPRIMARY KEY\t (role_id)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFROLES;
            # special ranks (5.3.2)
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFSPECIALRANKS . ' (
					id int(11) unsigned NOT NULL AUTO_INCREMENT,
					user_id bigint(20) default NULL,
					special_rank varchar(100),
					PRIMARY KEY (id),
					KEY user_id_idx (user_id),
					KEY special_rank_idx (special_rank)
				) ' . spdb_charset();
            spdb_query($sql);
            $tables[] = SFSPECIALRANKS;
            # sftopics table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFTOPICS . " (\n\t\t\t\t\ttopic_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\ttopic_name varchar(200) NOT NULL,\n\t\t\t\t\ttopic_date datetime NOT NULL,\n\t\t\t\t\ttopic_status int(4) NOT NULL default '0',\n\t\t\t\t\tforum_id bigint(20) NOT NULL,\n\t\t\t\t\tuser_id bigint(20) default NULL,\n\t\t\t\t\ttopic_pinned smallint(1) NOT NULL default '0',\n\t\t\t\t\ttopic_opened bigint(20) NOT NULL default '0',\n\t\t\t\t\ttopic_slug varchar(200) NOT NULL,\n\t\t\t\t\tpost_id bigint(20) default NULL,\n\t\t\t\t\tpost_id_held bigint(20) default NULL,\n\t\t\t\t\tpost_count mediumint(8) default '0',\n\t\t\t\t\tpost_count_held mediumint(8) default '0',\n\t\t\t\t\tPRIMARY KEY\t(topic_id),\n\t\t\t\t\tKEY forum_id_idx (forum_id),\n\t\t\t\t\tKEY topic_slug_idx (topic_slug),\n\t\t\t\t\tKEY user_id_idx (user_id),\n\t\t\t\t\tKEY post_id_idx (post_id)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFTOPICS;
            # sftrack table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFTRACK . " (\n\t\t\t\t\tid bigint(20) NOT NULL auto_increment,\n\t\t\t\t\ttrackuserid bigint(20) default '0',\n\t\t\t\t\ttrackname varchar(50) NOT NULL,\n\t\t\t\t\ttrackdate datetime NOT NULL,\n\t\t\t\t\tforum_id bigint(20) default NULL,\n\t\t\t\t\ttopic_id bigint(20) default NULL,\n\t\t\t\t\tpageview varchar(50) NOT NULL,\n\t\t\t\t\tnotification varchar(1024) default NULL,\n\t\t\t\t\tdevice char(1) default 'D',\n\t\t\t\t\tdisplay varchar(255) default NULL,\n\t\t\t\t\tPRIMARY KEY\t (id),\n\t\t\t\t\tKEY trackuserid_idx (trackuserid),\n\t\t\t\t\tKEY forum_id_idx (forum_id),\n\t\t\t\t\tKEY topic_id_idx (topic_id)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFTRACK;
            # user activity (5.3.2 - in preparation)
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFUSERACTIVITY . ' (
					id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
					user_id bigint(20) NOT NULL,
					type_id smallint(4) NOT NULL,
					item_id bigint(20) NOT NULL,
					meta_id bigint(20) DEFAULT NULL,
					PRIMARY KEY (id),
					KEY type_id_idx (type_id),
					KEY user_id_idx (user_id)
				) ' . spdb_charset();
            spdb_query($sql);
            $tables[] = SFUSERACTIVITY;
            # sfusergroups table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFUSERGROUPS . " (\n\t\t\t\t\tusergroup_id bigint(20) NOT NULL auto_increment,\n\t\t\t\t\tusergroup_name text NOT NULL,\n\t\t\t\t\tusergroup_desc text default NULL,\n\t\t\t\t\tusergroup_badge varchar(50) default NULL,\n\t\t\t\t\tusergroup_join tinyint(4) unsigned NOT NULL default '0',\n\t\t\t\t\tusergroup_is_moderator tinyint(4) unsigned NOT NULL default '0',\n\t\t\t\t\tPRIMARY KEY\t (usergroup_id)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFUSERGROUPS;
            # sfwaiting table def
            $sql = '
				CREATE TABLE IF NOT EXISTS ' . SFWAITING . " (\n\t\t\t\t\ttopic_id bigint(20) NOT NULL,\n\t\t\t\t\tforum_id bigint(20) NOT NULL,\n\t\t\t\t\tpost_count int(4) NOT NULL,\n\t\t\t\t\tpost_id bigint(20) NOT NULL default '0',\n\t\t\t\t\tuser_id bigint(20) unsigned default '0',\n\t\t\t\t\tPRIMARY KEY\t (topic_id)\n\t\t\t\t) " . spdb_charset();
            spdb_query($sql);
            $tables[] = SFWAITING;
            # now save off installed tables
            sp_add_option('installed_tables', $tables);
            echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - ';
            spa_etext('Tables created') . '</h5>';
            break;
        case 2:
            # populate auths
            spa_setup_auth_cats();
            spa_setup_auths();
            # set up the default permissions/roles
            spa_setup_permissions();
            echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - ';
            spa_etext('Permission data built') . '</h5>';
            break;
        case 3:
            # Create default 'Guest' user group data
            $guests = spa_create_usergroup_row('Guests', 'Default Usergroup for guests of the forum', '', '0', '0', false);
            # Create default 'Members' user group data
            $members = spa_create_usergroup_row('Members', 'Default Usergroup for registered users of the forum', '', '0', '0', false);
            # Create default 'Moderators' user group data
            $moderators = spa_create_usergroup_row('Moderators', 'Default Usergroup for moderators of the forum', '', '0', '1', false);
            # Create default user groups
            sp_add_sfmeta('default usergroup', 'sfguests', $guests);
            # default usergroup for guests
            sp_add_sfmeta('default usergroup', 'sfmembers', $members);
            # default usergroup for members
            sp_create_usergroup_meta($members);
            # create default usergroups for existing wp roles
            echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - ';
            spa_etext('Usergroup data built') . '</h5>';
            break;
        case 4:
            $page_args = array('post_status' => 'publish', 'post_type' => 'page', 'post_author' => $current_user->ID, 'ping_status' => 'closed', 'comment_status' => 'closed', 'post_parent' => 0, 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '', 'post_content' => '', 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0, 'post_title' => 'Forum', 'page_template' => 'default');
            $page_id = wp_insert_post($page_args);
            $page = spdb_table(SFWPPOSTS, "ID={$page_id}", 'row');
            sp_add_option('sfslug', $page->post_name);
            # Update the guid for the new page
            $guid = get_permalink($page_id);
            spdb_query('UPDATE ' . SFWPPOSTS . " SET guid='{$guid}' WHERE ID={$page_id}");
            sp_add_option('sfpage', $page_id);
            echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - ';
            spa_etext('Forum page created') . '</h5>';
            break;
        case 5:
            # Create Base Option Records (V1)
            sp_add_option('sfuninstall', false);
            sp_add_option('sfdates', get_option('date_format'));
            sp_add_option('sftimes', get_option('time_format'));
            sp_add_option('sfpermalink', get_permalink(sp_get_option('sfpage')));
            sp_add_option('sflockdown', false);
            $rankdata['posts'] = 2;
            $rankdata['usergroup'] = 'none';
            $rankdata['image'] = 'none';
            sp_add_sfmeta('forum_rank', 'New Member', $rankdata, 1);
            $rankdata['posts'] = 1000;
            $rankdata['usergroup'] = 'none';
            $rankdata['image'] = 'none';
            sp_add_sfmeta('forum_rank', 'Member', $rankdata, 1);
            $sfimage = array();
            $sfimage['enlarge'] = true;
            $sfimage['process'] = true;
            $sfimage['thumbsize'] = 100;
            $sfimage['style'] = 'left';
            $sfimage['constrain'] = true;
            $sfimage['forceclear'] = false;
            sp_add_option('sfimage', $sfimage);
            sp_add_option('sfbadwords', '');
            sp_add_option('sfreplacementwords', '');
            sp_add_option('sfeditormsg', '');
            $sfmail = array();
            $sfmail['sfmailsender'] = get_bloginfo('name');
            $admin_email = get_bloginfo('admin_email');
            $comp = explode('@', $admin_email);
            $sfmail['sfmailfrom'] = $comp[0];
            $sfmail['sfmaildomain'] = $comp[1];
            $sfmail['sfmailuse'] = true;
            sp_add_option('sfmail', $sfmail);
            $sfmail = array();
            $sfmail['sfusespfreg'] = true;
            $sfmail['sfnewusersubject'] = 'Welcome to %BLOGNAME%';
            $sfmail['sfnewusertext'] = 'Welcome %USERNAME% to %BLOGNAME% %NEWLINE%Please find below your login details: %NEWLINE%Username: %USERNAME% %NEWLINE%Password: %PASSWORD% %NEWLINE%%LOGINURL%';
            sp_add_option('sfnewusermail', $sfmail);
            $sfpostmsg = array();
            $sfpostmsg['sfpostmsgtext'] = '';
            $sfpostmsg['sfpostmsgtopic'] = false;
            $sfpostmsg['sfpostmsgpost'] = false;
            sp_add_option('sfpostmsg', $sfpostmsg);
            $sflogin = array();
            $sflogin['sfregmath'] = true;
            $sflogin['sfloginurl'] = sp_url();
            $sflogin['sflogouturl'] = sp_url();
            $sflogin['sfregisterurl'] = '';
            $sflogin['sfloginemailurl'] = esc_url(wp_login_url());
            $sflogin['sptimeout'] = 20;
            sp_add_option('sflogin', $sflogin);
            $sfadminsettings = array();
            $sfadminsettings['sfdashboardstats'] = true;
            $sfadminsettings['sfadminapprove'] = false;
            $sfadminsettings['sfmoderapprove'] = false;
            $sfadminsettings['editnotice'] = true;
            $sfadminsettings['movenotice'] = true;
            sp_add_option('sfadminsettings', $sfadminsettings);
            $sfauto = array();
            $sfauto['sfautoupdate'] = false;
            $sfauto['sfautotime'] = 300;
            sp_add_option('sfauto', $sfauto);
            $sffilters = array();
            $sffilters['sfnofollow'] = false;
            $sffilters['sftarget'] = true;
            $sffilters['sfurlchars'] = 40;
            $sffilters['sffilterpre'] = false;
            $sffilters['sfmaxlinks'] = 0;
            $sffilters['sfnolinksmsg'] = "<b>** you do not have permission to see this link **</b>";
            $sffilters['sfdupemember'] = 0;
            $sffilters['sfdupeguest'] = 0;
            $sffilters['sfmaxsmileys'] = 0;
            sp_add_option('sffilters', $sffilters);
            $sfseo = array();
            $sfseo['sfseo_overwrite'] = false;
            $sfseo['sfseo_blogname'] = false;
            $sfseo['sfseo_pagename'] = false;
            $sfseo['sfseo_homepage'] = true;
            $sfseo['sfseo_topic'] = true;
            $sfseo['sfseo_forum'] = true;
            $sfseo['sfseo_noforum'] = false;
            $sfseo['sfseo_page'] = true;
            $sfseo['sfseo_sep'] = '|';
            sp_add_option('sfseo', $sfseo);
            $sfsigimagesize = array();
            $sfsigimagesize['sfsigwidth'] = 0;
            $sfsigimagesize['sfsigheight'] = 0;
            sp_add_option('sfsigimagesize', $sfsigimagesize);
            # (V4.1.0)
            $sfmembersopt = array();
            $sfmembersopt['sfcheckformember'] = true;
            $sfmembersopt['sfsinglemembership'] = false;
            $sfmembersopt['sfhidestatus'] = true;
            sp_add_option('sfmemberopts', $sfmembersopt);
            $sfcontrols = array();
            $sfcontrols['showtopcount'] = 10;
            $sfcontrols['shownewcount'] = 10;
            $sfcontrols['sfdefunreadposts'] = 50;
            $sfcontrols['sfusersunread'] = false;
            $sfcontrols['sfmaxunreadposts'] = 50;
            sp_add_option('sfcontrols', $sfcontrols);
            $sfblock = array();
            $sfblock['blockadmin'] = false;
            $sfblock['blockprofile'] = false;
            $sfblock['blockroles'] = 'administrator';
            $sfblock['blockredirect'] = get_permalink(sp_get_option('sfpage'));
            sp_add_option('sfblockadmin', $sfblock);
            $sfmetatags = array();
            $sfmetatags['sfdescr'] = '';
            $sfmetatags['sfdescruse'] = 1;
            $sfmetatags['sfusekeywords'] = 2;
            $sfmetatags['sfkeywords'] = 'forum';
            sp_add_option('sfmetatags', $sfmetatags);
            # display array
            $sfdisplay = array();
            $sfdisplay['pagetitle']['notitle'] = false;
            $sfdisplay['pagetitle']['banner'] = '';
            $sfdisplay['forums']['singleforum'] = false;
            $sfdisplay['topics']['perpage'] = 12;
            $sfdisplay['topics']['sortnewtop'] = true;
            $sfdisplay['posts']['perpage'] = 20;
            $sfdisplay['posts']['sortdesc'] = false;
            sp_add_option('sfdisplay', $sfdisplay);
            sp_add_sfmeta('sort_order', 'forum', '', 1);
            sp_add_sfmeta('sort_order', 'topic', '', 1);
            # guest settings
            $sfguests = array();
            $sfguests['reqemail'] = true;
            $sfguests['storecookie'] = true;
            sp_add_option('sfguests', $sfguests);
            # profile management
            $sfprofile = array();
            $sfprofile['nameformat'] = true;
            $sfprofile['fixeddisplayformat'] = 0;
            $sfprofile['namelink'] = 2;
            $sfprofile['displaymode'] = 1;
            $sfprofile['displaypage'] = '';
            $sfprofile['displayquery'] = '';
            $sfprofile['formmode'] = 1;
            $sfprofile['formpage'] = '';
            $sfprofile['formquery'] = '';
            $sfprofile['photosmax'] = 0;
            $sfprofile['photoswidth'] = 0;
            $sfprofile['photosheight'] = 0;
            $sfprofile['firstvisit'] = true;
            $sfprofile['forcepw'] = false;
            sp_add_option('sfprofile', $sfprofile);
            # avatar options
            $sfavatars = array();
            $sfavatars['sfshowavatars'] = true;
            $sfavatars['sfavataruploads'] = true;
            $sfavatars['sfavatarpool'] = false;
            $sfavatars['sfavatarremote'] = false;
            $sfavatars['sfgmaxrating'] = 1;
            $sfavatars['sfavatarsize'] = 50;
            $sfavatars['sfavatarresize'] = true;
            $sfavatars['sfavatarresizequality'] = 90;
            $sfavatars['sfavatarfilesize'] = 10240;
            $sfavatars['sfavatarpriority'] = array(0, 2, 3, 1, 4, 5);
            # gravatar, upload, spf, wp, pool, remote
            sp_add_option('sfavatars', $sfavatars);
            # RSS stuff
            $sfrss = array();
            $sfrss['sfrsscount'] = 15;
            $sfrss['sfrsswords'] = 0;
            $sfrss['sfrsstopicname'] = false;
            $sfrss['sfrssfeedkey'] = true;
            sp_add_option('sfrss', $sfrss);
            sp_add_option('sffiltershortcodes', true);
            sp_add_option('sfwplistpages', true);
            # Script in footer
            sp_add_option('sfscriptfoot', false);
            # the_content filter options
            sp_add_option('sfinloop', false);
            sp_add_option('sfmultiplecontent', true);
            sp_add_option('sfwpheadbypass', false);
            sp_add_option('spwptexturize', false);
            sp_add_option('spheaderspace', 0);
            # auto update stuff in sfmeta
            $autoup = array('spjUserUpdate', 'sp_ahah=autoupdate&amp;sfnonce=' . wp_create_nonce('forum-ahah'));
            sp_add_sfmeta('autoupdate', 'user', $autoup, 1);
            # Set up unique key
            $uKey = substr(chr(rand(97, 122)) . md5(time()), 0, 10);
            sp_add_option('spukey', $uKey);
            # default theme
            $theme = array();
            $theme['theme'] = 'default';
            $theme['style'] = 'default.php';
            $theme['color'] = 'silver';
            sp_add_option('sp_current_theme', $theme);
            $theme = array();
            $theme['active'] = false;
            $theme['theme'] = 'default';
            $theme['style'] = 'default.php';
            $theme['color'] = 'silver';
            $theme['usetemplate'] = false;
            $theme['pagetemplate'] = '';
            $theme['notitle'] = true;
            sp_add_option('sp_mobile_theme', $theme);
            sp_add_option('sp_tablet_theme', $theme);
            sp_add_option('account-name', '');
            sp_add_option('display-name', '');
            sp_add_option('guest-name', '');
            # Create smileys Record
            sp_build_base_smileys();
            # set up daily transient clean up cron
            wp_schedule_event(time(), 'daily', 'sph_transient_cleanup_cron');
            # profile tabs
            spa_new_profile_setup();
            # build the list of moderators per forum
            sp_update_forum_moderators();
            # set up hourly stats generation
            sp_add_option('sp_stats_interval', 3600);
            wp_schedule_event(time(), 'hourly', 'sph_stats_cron');
            # set up weekly news processing
            wp_schedule_event(time(), 'sp_news_interval', 'sph_news_cron');
            sp_add_sfmeta('news', 'news', array('id' => -999.999, 'show' => 0, 'news' => esc_sql(spa_text('Latest Simple Press News will be shown here'))));
            # create initial last post time stamp
            sp_add_option('poststamp', current_time('mysql'));
            # setup mysql search sfmeta values (5.2.0)
            $s = array();
            $v = spdb_select('row', "SHOW VARIABLES LIKE 'ft_min_word_len'");
            empty($v->Value) ? $s['min'] = 4 : ($s['min'] = $v->Value);
            $v = spdb_select('row', "SHOW VARIABLES LIKE 'ft_max_word_len'");
            empty($v->Value) ? $s['max'] = 84 : ($s['max'] = $v->Value);
            sp_add_sfmeta('mysql', 'search', $s, true);
            # combined css and js cache fles
            sp_add_option('combinecss', false);
            sp_add_option('combinejs', false);
            sp_add_option('post_count_delete', false);
            $spError = array();
            $spError['spErrorLogOff'] = false;
            $spError['spNoticesOff'] = false;
            sp_update_option('spErrorOptions', $spError);
            # new posts/topic cached array
            sp_add_sfmeta('topic_cache', 'new', '', true);
            sp_add_option('topic_cache', 200);
            sp_add_option('floodcontrol', 10);
            sp_add_option('captcha-value', time());
            sp_add_option('editpostdays', 7);
            sp_create_inspectors();
            echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - ';
            spa_etext('Default forum options created') . '</h5>';
            break;
        case 6:
            # Create sp-resources folder for the current install - does not include themes, plugins or languages
            $perms = fileperms(SF_STORE_DIR);
            $owners = stat(SF_STORE_DIR);
            if ($perms === false) {
                $perms = 0755;
            }
            $basepath = '';
            if (is_multisite()) {
                # construct multisite storage directory structure and create if necessary
                $basepath .= 'blogs.dir/' . SFBLOGID;
                if (!file_exists(SF_STORE_DIR . '/' . $basepath)) {
                    @mkdir(SF_STORE_DIR . '/' . $basepath, $perms);
                }
                $basepath .= '/files';
                if (!file_exists(SF_STORE_DIR . '/' . $basepath)) {
                    @mkdir(SF_STORE_DIR . '/' . $basepath, $perms);
                }
                $basepath .= '/';
            }
            $basepath .= 'sp-resources';
            if (!file_exists(SF_STORE_DIR . '/' . $basepath)) {
                @mkdir(SF_STORE_DIR . '/' . $basepath, $perms);
            }
            # hive off the basepath for later use - use wp options
            add_option('sp_storage1', SF_STORE_DIR . '/' . $basepath);
            # Did it get created?
            $success = true;
            if (!file_exists(SF_STORE_DIR . '/' . $basepath)) {
                $success = false;
            }
            sp_add_option('spStorageInstall1', $success);
            # Is the ownership correct?
            $ownersgood = false;
            if ($success) {
                $newowners = stat(SF_STORE_DIR . '/' . $basepath);
                if ($newowners['uid'] == $owners['uid'] && $newowners['gid'] == $owners['gid']) {
                    $ownersgood = true;
                } else {
                    @chown(SF_STORE_DIR . '/' . $basepath, $owners['uid']);
                    @chgrp(SF_STORE_DIR . '/' . $basepath, $owners['gid']);
                    $newowners = stat(SF_STORE_DIR . '/' . $basepath);
                    if ($newowners['uid'] == $owners['uid'] && $newowners['gid'] == $owners['gid']) {
                        $ownersgood = true;
                    }
                }
            }
            sp_add_option('spOwnersInstall1', $ownersgood);
            $basepath .= '/';
            $sfconfig = array();
            $sfconfig['avatars'] = $basepath . 'forum-avatars';
            $sfconfig['avatar-pool'] = $basepath . 'forum-avatar-pool';
            $sfconfig['smileys'] = $basepath . 'forum-smileys';
            $sfconfig['ranks'] = $basepath . 'forum-badges';
            $sfconfig['custom-icons'] = $basepath . 'forum-custom-icons';
            $sfconfig['cache'] = $basepath . 'forum-cache';
            # Create sp-resources folder and themes, plugins and languages folders
            # if not multisite, just add to sp-resource created above
            # if multisite try to use set up of main blog (id 1) or create in wp-content if main blog does not have SP installed
            global $wpdb;
            if (is_multisite()) {
                $basepath = 'sp-resources';
                if (!file_exists(SF_STORE_DIR . '/' . $basepath)) {
                    @mkdir(SF_STORE_DIR . '/' . $basepath, $perms);
                }
                # Did it get created?
                $success = true;
                if (!file_exists(SF_STORE_DIR . '/' . $basepath)) {
                    $success = false;
                }
                sp_add_option('spStorageInstall2', $success);
                # Is the ownership correct?
                $ownersgood = false;
                if ($success) {
                    $newowners = stat(SF_STORE_DIR . '/' . $basepath);
                    if ($newowners['uid'] == $owners['uid'] && $newowners['gid'] == $owners['gid']) {
                        $ownersgood = true;
                    } else {
                        @chown(SF_STORE_DIR . '/' . $basepath, $owners['uid']);
                        @chgrp(SF_STORE_DIR . '/' . $basepath, $owners['gid']);
                        $newowners = stat(SF_STORE_DIR . '/' . $basepath);
                        if ($newowners['uid'] == $owners['uid'] && $newowners['gid'] == $owners['gid']) {
                            $ownersgood = true;
                        }
                    }
                }
                sp_add_option('spOwnersInstall2', $ownersgood);
                add_option('sp_storage2', SF_STORE_DIR . '/' . $basepath);
                $basepath .= '/';
                if ($wpdb->blogid == 1) {
                    $sfconfig['language-sp'] = $basepath . 'forum-language/simple-press';
                    $sfconfig['language-sp-plugins'] = $basepath . 'forum-language/sp-plugins';
                    $sfconfig['language-sp-themes'] = $basepath . 'forum-language/sp-themes';
                    $sfconfig['plugins'] = $basepath . 'forum-plugins';
                    $sfconfig['themes'] = $basepath . 'forum-themes';
                } else {
                    $blog_prefix = $wpdb->get_blog_prefix(1);
                    $row = $wpdb->get_row("SELECT * FROM {$blog_prefix}sfoptions WHERE option_name 'sfconfig'");
                    if (is_object($row)) {
                        $mainConfig = unserialize($row->option_value);
                        $sfconfig['language-sp'] = $mainConfig['language-sp'];
                        $sfconfig['language-sp-plugins'] = $mainConfig['language-sp-plugins'];
                        $sfconfig['language-sp-themes'] = $mainConfig['language-sp-themes'];
                        $sfconfig['plugins'] = $mainConfig['plugins'];
                        $sfconfig['themes'] = $mainConfig['themes'];
                    } else {
                        $sfconfig['language-sp'] = $basepath . 'forum-language/simple-press';
                        $sfconfig['language-sp-plugins'] = $basepath . 'forum-language/sp-plugins';
                        $sfconfig['language-sp-themes'] = $basepath . 'forum-language/sp-themes';
                        $sfconfig['plugins'] = $basepath . 'forum-plugins';
                        $sfconfig['themes'] = $basepath . 'forum-themes';
                    }
                }
            } else {
                add_option('sp_storage2', get_option('sp_storage1'));
                sp_add_option('spStorageInstall2', true);
                sp_add_option('spOwnersInstall2', true);
                $sfconfig['language-sp'] = $basepath . 'forum-language/simple-press';
                $sfconfig['language-sp-plugins'] = $basepath . 'forum-language/sp-plugins';
                $sfconfig['language-sp-themes'] = $basepath . 'forum-language/sp-themes';
                $sfconfig['plugins'] = $basepath . 'forum-plugins';
                $sfconfig['themes'] = $basepath . 'forum-themes';
            }
            sp_add_option('sfconfig', $sfconfig);
            echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - ';
            if ($success) {
                spa_etext('Storage location created') . '</h5>';
            } else {
                spa_etext('Storage location creation failed') . '</h5>';
            }
            break;
        case 7:
            # Move and extract zip install archives
            # first do stuff that could be in blogs.dir for multisite
            $successCopy1 = false;
            $successExtract1 = false;
            $zipfile = SF_PLUGIN_DIR . '/sp-startup/install/sp-resources-install-part1.zip';
            $extract_to = get_option('sp_storage1');
            # Copy the zip file
            if (@copy($zipfile, $extract_to . '/sp-resources-install-part1.zip')) {
                $successCopy1 = true;
                # Now try and unzip it
                require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
                $zipfile = $extract_to . '/sp-resources-install-part1.zip';
                $zipfile = str_replace('\\', '/', $zipfile);
                # sanitize for Win32 installs
                $zipfile = preg_replace('|/+|', '/', $zipfile);
                # remove any duplicate slash
                $extract_to = str_replace('\\', '/', $extract_to);
                # sanitize for Win32 installs
                $extract_to = preg_replace('|/+|', '/', $extract_to);
                # remove any duplicate slash
                $archive = new PclZip($zipfile);
                $archive->extract($extract_to);
                if ($archive->error_code == 0) {
                    $successExtract1 = true;
                    # Lets try and remove the zip as it seems to have worked
                    @unlink($zipfile);
                }
            }
            sp_add_option('spCopyZip1', $successCopy1);
            sp_add_option('spUnZip1', $successExtract1);
            # now do stuff that could should not be blogs.dir for multisite
            $successCopy2 = false;
            $successExtract2 = false;
            $zipfile = SF_PLUGIN_DIR . '/sp-startup/install/sp-resources-install-part2.zip';
            $extract_to = get_option('sp_storage2');
            # Copy the zip file
            if (@copy($zipfile, $extract_to . '/sp-resources-install-part2.zip')) {
                $successCopy2 = true;
                # Now try and unzip it
                require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
                $zipfile = $extract_to . '/sp-resources-install-part2.zip';
                $zipfile = str_replace('\\', '/', $zipfile);
                # sanitize for Win32 installs
                $zipfile = preg_replace('|/+|', '/', $zipfile);
                # remove any duplicate slash
                $extract_to = str_replace('\\', '/', $extract_to);
                # sanitize for Win32 installs
                $extract_to = preg_replace('|/+|', '/', $extract_to);
                # remove any duplicate slash
                $archive = new PclZip($zipfile);
                $archive->extract($extract_to);
                if ($archive->error_code == 0) {
                    $successExtract2 = true;
                    # Lets try and remove the zip as it seems to have worked
                    @unlink($zipfile);
                }
            }
            sp_add_option('spCopyZip2', $successCopy2);
            sp_add_option('spUnZip2', $successExtract2);
            echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - ';
            if ($successCopy1 && $successExtract1 && $successCopy2 && $successExtract2) {
                spa_etext('Resources created') . '</h5>';
            } elseif (!$successCopy1 || !$successCopy2) {
                spa_etext('Resources file failed to copy') . '</h5>';
            } elseif (!$successExtract1 || !$successExtract2) {
                spa_etext('Resources file failed to unzip');
                echo ' - ' . $archive->error_string . '</h5>';
            }
            break;
        case 8:
            # CREATE MEMBERS TABLE ---------------------------
            sp_install_members_table($subphase);
            echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - ';
            echo spa_text('Members data created for existing users') . ' ' . (($subphase - 1) * 200 + 1) . ' - ' . $subphase * 200 . '</h5>';
            break;
        case 9:
            # add our caps
            sp_add_caps();
            # grant spf capabilities to installer
            $user = new WP_User($current_user->ID);
            $user->add_cap('SPF Manage Options');
            $user->add_cap('SPF Manage Forums');
            $user->add_cap('SPF Manage User Groups');
            $user->add_cap('SPF Manage Permissions');
            $user->add_cap('SPF Manage Components');
            $user->add_cap('SPF Manage Admins');
            $user->add_cap('SPF Manage Users');
            $user->add_cap('SPF Manage Profiles');
            $user->add_cap('SPF Manage Toolbox');
            $user->add_cap('SPF Manage Plugins');
            $user->add_cap('SPF Manage Themes');
            $user->add_cap('SPF Manage Integration');
            sp_update_member_item($current_user->ID, 'admin', 1);
            # admin your option defaults
            $sfadminoptions = array();
            $sfadminoptions['sfnotify'] = false;
            $sfadminoptions['notify-edited'] = true;
            sp_update_member_item($current_user->ID, 'admin_options', $sfadminoptions);
            echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - ';
            spa_etext('Admin permission data built') . '</h5>';
            break;
        case 10:
            # UPDATE VERSION/BUILD NUMBERS -------------------------
            sp_log_event(SPRELEASE, SPVERSION, SPBUILD);
            # Lets update permalink and force a rewrite rules flush
            sp_update_permalink(true);
            echo '<h5>' . spa_text('Phase') . ' - ' . $phase . ' - ';
            spa_etext('Version number updated') . '</h5>';
            break;
        case 11:
            # REPORTS ERRORS IF COPY OR UNZIP FAILED ---------------
            $sCreate1 = sp_get_option('spStorageInstall1');
            $sCreate2 = sp_get_option('spStorageInstall2');
            $sOwners1 = sp_get_option('spOwnersInstall1');
            $sOwners2 = sp_get_option('spOwnersInstall2');
            $sCopy1 = sp_get_option('spCopyZip1');
            $sUnzip1 = sp_get_option('spUnZip1');
            $sCopy2 = sp_get_option('spCopyZip2');
            $sUnzip2 = sp_get_option('spUnZip2');
            if ($sCreate1 && $sCreate2 && $sCopy1 && $sUnzip1 && $sCopy2 && $sUnzip2 && $sOwners1 && $sOwners2) {
                echo '<h5>' . spa_text('The installation has been completed') . '</h5>';
            } else {
                $image = "<img src='" . SF_PLUGIN_URL . "/sp-startup/install/resources/images/important.png' alt='' style='float:left;padding: 5px 5px 20px 0;' />";
                echo '<h5>';
                spa_etext('YOU WILL NEED TO PERFORM THE FOLLOWING TASKS TO ALLOW SIMPLE:PRESS TO WORK CORRECTLY');
                echo '</h5><br />';
                if (!$sCreate1) {
                    echo $image . '<p style="margin-top:0">[';
                    spa_etext('Storage location part 1 creation failed');
                    echo '] - ';
                    echo spa_text('You will need to manually create a required a folder named') . ': ' . get_option('sp_storage1');
                    echo '</p>';
                } else {
                    if (!$sOwners1) {
                        echo $image . '<p>[';
                        spa_etext('Storage location part 1 ownership failed');
                        echo '] - ';
                        echo spa_text('We were unable to create your folders with the correct server ownership and these will need to be manually changed') . ': ' . get_option('sp_storage1');
                        echo '</p>';
                    }
                }
                if (!$sCreate2) {
                    echo $image . '<p>[';
                    spa_etext('Storage location part 2 creation failed');
                    echo '] - ';
                    echo spa_text('You will need to manually create a required a folder named') . ': ' . get_option('sp_storage2');
                    echo '</p>';
                } elseif (!$sOwners2) {
                    echo $image . '<p>[';
                    spa_etext('Storage location part 2 ownership failed');
                    echo '] - ';
                    echo spa_text('We were unable to create your folders with the correct server ownership and these will need to be manually changed') . ': ' . get_option('sp_storage2');
                    echo '</p>';
                }
                if (!$sCopy1) {
                    echo $image . '<p>[';
                    spa_etext('Resources part 1 file failed to copy');
                    echo '] - ';
                    echo spa_text("You will need to manually copy and extract the file '/simple-press/sp-startup/install/sp-resources-install-part1.zip' to the new folder") . ': ' . get_option('sp_storage1');
                    echo '</p>';
                }
                if (!$sCopy2) {
                    echo $image . '<p>[';
                    spa_etext('Resources part 2 file failed to copy');
                    echo '] - ';
                    echo spa_text("You will need to manually copy and extract the file '/simple-press/sp-startup/install/sp-resources-install-part2.zip' to the new folder") . ': ' . get_option('sp_storage2');
                    echo '</p>';
                }
                if (!$sUnzip1) {
                    echo $image . '<p>[';
                    spa_etext('Resources part 2 file failed to unzip');
                    echo '] - ';
                    echo spa_text("You will need to manually unzip the file 'sp-resources-install-part1.zip' in the new folder") . ': ' . get_option('sp_storage1');
                    echo '</p>';
                }
                if (!$sUnzip2) {
                    echo $image . '<p>[';
                    spa_etext('Resources part 2 file failed to unzip');
                    echo '] - ';
                    echo spa_text("You will need to manually unzip the file 'sp-resources-install-part2.zip' in the new folder") . ': ' . get_option('sp_storage2');
                    echo '</p>';
                }
            }
            delete_option('sfInstallID');
            delete_option('sp_storage1');
            delete_option('sp_storage2');
            sp_delete_option('spStorageInstall1');
            sp_delete_option('spStorageInstall2');
            sp_delete_option('spOwnersInstall1');
            sp_delete_option('spOwnersInstall2');
            sp_delete_option('spCopyZip1');
            sp_delete_option('spCopyZip2');
            sp_delete_option('spUnZip1');
            sp_delete_option('spUnZip2');
            break;
    }
}
function sp_go_network_upgrade($current_version, $current_build)
{
    global $current_user;
    ?>
	<div class="wrap"><br />
		<div class="updated">
		<img class="stayleft" src="<?php 
    echo SFCOMMONIMAGES;
    ?>
sp-mini-logo.png" alt="" title="" />
		<h3><?php 
    spa_etext('Simple:Press is upgrading the Network.');
    ?>
</h3>
		</div><br />
		<div class="wrap sfatag">
			<div class="imessage" id="imagezone"></div>
		</div><br />
		<div class="pbar" id="progressbar"></div><br />
		<div class="wrap sfatag">
			<div class="zmessage" id="errorzone"></div>
			<div id="finishzone"></div><br />
		</div><br />
		<div id="debug">
			</p><b>Please copy the details below and include them on any support forum question you may have:</b><br /><br /></p>
		</div>
	</div>
<?php 
    # get list of network sites
    $sites = wp_get_sites();
    # loop through all blogs and upgrade ones with active simple:press
    foreach ($sites as $site) {
        # switch to network site and see if simple:press is active
        switch_to_blog($site['blog_id']);
        global $wpdb;
        $installed = spdb_select('set', 'SELECT option_id FROM ' . $wpdb->prefix . "sfoptions WHERE option_name='sfversion'");
        if ($installed) {
            $phpfile = SFHOMEURL . 'index.php?sp_ahah=upgrade&sfnonce=' . wp_create_nonce('forum-ahah') . '&sfnetworkid=' . $site['blog_id'];
            $image = SFCOMMONIMAGES . 'working.gif';
            $targetbuild = SPBUILD;
            update_option('sfInstallID', $current_user->ID);
            # use wp option table
            # save the build info
            $out = spa_text('Upgrading Network Site ID') . ': ' . $site['blog_id'] . '<br />';
            sp_update_option('sfStartUpgrade', $current_build);
            # upgrade the network site
            $messages = esc_js(spa_text('Go to Forum Admin')) . '@' . esc_js(spa_text('Upgrade is in progress - please wait')) . '@' . esc_js(spa_text('Upgrade Completed')) . '@' . esc_js(spa_text('Upgrade Aborted')) . '@' . esc_js(spa_text('Go to Forum'));
            $out .= '<script type="text/javascript">' . "\n";
            $out .= 'spjPerformUpgrade("' . $phpfile . '", "' . $current_build . '", "' . $targetbuild . '", "' . $current_build . '", "' . $image . '", "' . $messages . '", "' . sp_url() . '");' . "\n";
            $out .= '</script>' . "\n";
            echo $out;
            # clear any combined css/js cached files
            sp_clear_combined_css('all');
            sp_clear_combined_css('mobile');
            sp_clear_combined_css('tablet');
            sp_clear_combined_scripts('desktop');
            sp_clear_combined_scripts('mobile');
            sp_clear_combined_scripts('tablet');
        }
        restore_current_blog();
    }
}
function sp_get_topic_url($forumslug, $topicslug, $topicname)
{
    global $spVars;
    $out = '';
    $topicname = sp_filter_title_display($topicname);
    if (isset($spVars['searchvalue']) && $spVars['searchvalue']) {
        $out .= '<a href="' . sp_build_url($forumslug, $topicslug, 1, 0);
        if (strpos(sp_url(), '?') === false) {
            $out .= '?value';
        } else {
            $out .= '&amp;value';
        }
        $out .= '=' . $spVars['searchvalue'] . '&amp;type=' . $spVars['searchtype'] . '&amp;include=' . $spVars['searchinclude'] . '&amp;scope=' . '&amp;search=' . $spVars['searchpage'] . '">' . $topicname . "</a>\n";
    } else {
        $out = '<a href="' . sp_build_url($forumslug, $topicslug, 1, 0) . '">' . sp_filter_title_display($topicname) . "</a>\n";
    }
    return $out;
}
 function __construct()
 {
     # Initialise the newpost array
     $this->newpost = array('action' => '', 'error' => '', 'db' => 0, 'submsg' => '', 'emailprefix' => '', 'url' => '', 'userid' => 0, 'forumid' => 0, 'forumslug' => '', 'forumname' => '', 'groupname' => '', 'topicid' => 0, 'topicname' => '', 'topicslug' => '', 'topicpinned' => 0, 'topicstatus' => 0, 'postid' => 0, 'postcontent' => '', 'postdate' => current_time('mysql'), 'guestname' => '', 'guestemail' => '', 'poststatus' => 0, 'postpinned' => 0, 'postindex' => 1, 'postedit' => '', 'posterip' => '', 'postername' => '', 'posteremail' => '', 'source' => 0);
     $this->returnURL = sp_url();
 }
function sp_GroupHeaderRSSButton($args = '', $label = '', $toolTip = '')
{
    global $spThisUser, $spThisGroup;
    if (!$spThisGroup->group_rss_active) {
        return;
    }
    $defs = array('tagId' => 'spGroupHeaderRSSButton%ID%', 'tagClass' => 'spLink', 'icon' => 'sp_Feed.png', 'iconClass' => 'spIcon', 'echo' => 1, 'get' => 0);
    $a = wp_parse_args($args, $defs);
    $a = apply_filters('sph_GroupHeaderRSSButton_args', $a);
    extract($a, EXTR_SKIP);
    # sanitize before use
    $tagId = esc_attr($tagId);
    $tagClass = esc_attr($tagClass);
    $icon = sanitize_file_name($icon);
    $iconClass = esc_attr($iconClass);
    $toolTip = esc_attr($toolTip);
    $echo = (int) $echo;
    $get = (int) $get;
    $tagId = str_ireplace('%ID%', $spThisGroup->group_id, $tagId);
    # Get or construct rss url
    if (empty($spThisGroup->rss)) {
        $rssOpt = sp_get_option('sfrss');
        if ($rssOpt['sfrssfeedkey'] && isset($spThisUser->feedkey)) {
            $rssUrl = sp_get_sfqurl(trailingslashit(sp_build_url('', '', 0, 0, 0, 1)) . user_trailingslashit($spThisUser->feedkey)) . 'group=' . $spThisGroup->group_id;
        } else {
            $sym = strpos(sp_url(), '?') ? '&' : '?';
            $rssUrl = trailingslashit(sp_build_url('', '', 0, 0, 0, 1)) . sp_add_get() . "group={$spThisGroup->group_id}";
        }
    } else {
        $rssUrl = $spThisGroup->rss;
    }
    if ($get) {
        return $rssUrl;
    }
    $out = "<a class='{$tagClass} vtip' id='{$tagId}' title='{$toolTip}' rel='nofollow' href='{$rssUrl}'>";
    if (!empty($icon)) {
        $out .= "<img class='{$iconClass}' src='" . sp_find_icon(SPTHEMEICONSURL, $icon) . "' alt=''/>";
    }
    if (!empty($label)) {
        $out .= sp_filter_title_display($label);
    }
    $out .= "</a>\n";
    $out = apply_filters('sph_GroupHeaderRSSButton', $out, $a);
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}
Example #30
0
    $param['forum'] = 'all';
} else {
    $param['forum'] = sp_esc_str($_POST['forumslug']);
}
if (!empty($_POST['searchvalue'])) {
    # standard search
    $searchvalue = trim(stripslashes($_POST['searchvalue']));
    $searchvalue = trim($searchvalue, '"');
    $searchvalue = trim($searchvalue, "'");
    $param['value'] = urlencode($searchvalue);
    $param['type'] = empty($_POST['searchtype']) ? 1 : sp_esc_int($_POST['searchtype']);
    $param['include'] = sp_esc_int($_POST['encompass']);
} elseif (isset($_POST['memberstarted']) && !empty($_POST['memberstarted'])) {
    # member 'started' search
    $id = sp_esc_int($_POST['userid']);
    $param['value'] = $id;
    $param['type'] = 5;
} elseif (isset($_POST['membersearch']) && !empty($_POST['membersearch'])) {
    # member 'posted in' search
    $id = sp_esc_int($_POST['userid']);
    $param['value'] = $id;
    $param['type'] = 4;
} else {
    # Available for plugins to REPLACE search query vars
    $param = apply_filters('sph_prepare_search', $param);
}
# Available for plugins to ADD TO search query vars
$param = apply_filters('sph_add_prepare_search', $param);
$url = add_query_arg($param, sp_url());
wp_redirect($url);
die;