示例#1
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;
}
示例#2
0
function sp_construct_database_error($sql, $sqlerror)
{
    global $spStatus, $spGlobals, $wpdb;
    if ($spGlobals['record-errors'] == false) {
        return;
    }
    if (spdb_connection() == false) {
        return;
    }
    $mess = '';
    $trace = debug_backtrace();
    $traceitem = $trace[2];
    $mess .= 'file: ' . $traceitem['file'] . '<br />';
    $mess .= 'line: ' . $traceitem['line'] . '<br />';
    $mess .= 'function: ' . $traceitem['function'] . '<br />';
    $mess .= "error: {$sqlerror}<br /><br />";
    $mess .= $sql;
    $keyCheck = substr(E_ERROR . $traceitem['line'] . substr($traceitem['file'], -30, 30), 0, 45);
    # write out error to our toolbox log if it doesn't exist already
    $e = spdb_table(SFERRORLOG, 'keycheck="' . $keyCheck . '" AND error_type="database"', 'error_count');
    if (empty($e) || $e == 0) {
        @sp_write_error('database', $mess, E_ERROR, $keyCheck);
    } else {
        @sp_update_error($keyCheck, $e);
    }
    # create display message
    include_once SPAPI . 'sp-api-cache.php';
    sp_notify(SPFAILURE, sp_text('Invalid database query'));
}
示例#3
0
    ?>
	<script type="text/javascript">
	jQuery(document).ready(function() {
        setTimeout(function() {
            spjSetProfileDataHeight();
        }, 500);
	})
	</script>
<?php 
    die;
}
# check for tab press
if (isset($_GET['tab'])) {
    # profile edit, so only admin or logged in user can view
    if (empty($userid) || $spThisUser->ID != $userid && !$spThisUser->admin) {
        sp_notify(SPFAILURE, sp_text('Invalid profile request'));
        $out .= sp_render_queued_notification();
        $out .= '<div class="sfmessagestrip">';
        $out .= apply_filters('sph_ProfileErrorMsg', sp_text('Sorry, an invalid profile request was detected. Do you need to log in?'));
        $out .= '</div>';
        return $out;
    }
    # set up profile for requested user
    sp_SetupUserProfileData($userid);
    # get pressed tab and menu (if pressed)
    $thisTab = sp_esc_str($_GET['tab']);
    $thisMenu = isset($_GET['menu']) ? sp_esc_str($_GET['menu']) : '';
    # get all the tabs meta info
    $tabs = sp_profile_get_tabs();
    if (!empty($tabs)) {
        foreach ($tabs as $tab) {
function sp_ProfileEditMobile($tabSlug = 'profile', $menuSlug = 'overview')
{
    # is this edit for current user of admin edit of user
    global $spVars, $spThisUser;
    if (!empty($spVars['member'])) {
        $userid = (int) $spVars['member'];
    } else {
        $userid = $spThisUser->ID;
    }
    if (empty($userid) || $spThisUser->ID != $userid && !$spThisUser->admin) {
        sp_notify(SPFAILURE, sp_text('Invalid profile request'));
        $out = sp_render_queued_notification();
        $out .= '<div class="spMessage">';
        $out .= apply_filters('sph_ProfileErrorMsg', sp_text('Sorry, an invalid profile request was detected. Do you need to log in?'));
        $out .= '</div>';
        echo $out;
        return;
    }
    # see if query args used to specify tab and/or menu
    if (isset($_GET['ptab'])) {
        $tabSlug = sp_esc_str($_GET['ptab']);
    }
    if (isset($_GET['pmenu'])) {
        $menuSlug = sp_esc_str($_GET['pmenu']);
    }
    # set up the profile data
    global $spProfileUser;
    sp_SetupUserProfileData($userid);
    do_action('sph_profile_edit_before');
    do_action('sph_ProfileStart');
    $tabs = sp_profile_get_tabs();
    if (!empty($tabs)) {
        do_action('sph_profile_edit_before_tabs');
        echo '<div id="spProfileAccordion">';
        echo "<div class='spProfileAccordionTab'>\n";
        $firstTab = $firstMenu = '';
        $tabSlugExist = $menuSlugExist = false;
        foreach ($tabs as $tab) {
            # do we need an auth check?
            $authCheck = empty($tab['auth']) ? true : sp_get_auth($tab['auth'], '', $userid);
            # is this tab being displayed and does user have auth to see it?
            if ($authCheck && $tab['display']) {
                if ($tab['slug'] == $tabSlug) {
                    $tabSlugExist = true;
                }
                if (empty($firstTab)) {
                    $firstTab = $tab['slug'];
                }
                echo '<h2 id="spProfileTabTitle-' . esc_attr($tab['slug']) . '">' . sp_filter_title_display($tab['name']) . "</h2>\n";
                echo "<div id='spProfileTab-" . esc_attr($tab['slug']) . "' class='spProfileAccordionPane'>\n";
                if (!empty($tab['menus'])) {
                    echo "<div class='spProfileAccordionTab'>\n";
                    foreach ($tab['menus'] as $menu) {
                        # do we need an auth check?
                        $authCheck = empty($menu['auth']) ? true : sp_get_auth($menu['auth'], '', $userid);
                        # is this menu being displayed and does user have auth to see it?
                        if ($authCheck && $menu['display']) {
                            if ($menu['slug'] == $menuSlug) {
                                $menuSlugExist = true;
                            }
                            if (empty($firstMenu)) {
                                $firstMenu = $menu['slug'];
                            }
                            $thisSlug = $menu['slug'];
                            # this variable is used in the form action url
                            # special checking for displaying menus
                            $spProfileOptions = sp_get_option('sfprofile');
                            $spAvatars = sp_get_option('sfavatars');
                            $noPhotos = $menu['slug'] == 'edit-photos' && $spProfileOptions['photosmax'] < 1;
                            # dont display edit photos if disabled
                            $noAvatars = $menu['slug'] == 'edit-avatars' && !$spAvatars['sfshowavatars'];
                            # dont display edit avatars if disabled
                            $hideMenu = $noPhotos || $noAvatars;
                            $hideMenu = apply_filters('sph_ProfileMenuHide', $hideMenu, $tab, $menu, $userid);
                            if (!$hideMenu) {
                                echo '<h2 id="spProfileMenuTitle-' . esc_attr($menu['slug']) . '">' . sp_filter_title_display($menu['name']) . "</h2>\n";
                                echo "<div id='spProfileMenu-" . esc_attr($menu['slug']) . "' class='spProfileAccordionPane'>\n";
                                if (!empty($menu['form']) && file_exists($menu['form'])) {
                                    echo "<div class='spProfileAccordionForm'>\n";
                                    include_once $menu['form'];
                                    echo "</div>\n";
                                } else {
                                    echo sp_text('Profile form could not be found') . ': [' . $menu['name'] . ']<br />';
                                    echo sp_text('You might try the forum - toolbox - housekeeping admin form and reset the profile tabs and menus and see if that helps');
                                }
                                echo "</div>\n";
                                # menu pane
                            }
                        }
                    }
                    echo "</div>\n";
                    # menu accordion
                }
                echo "</div>\n";
                # tab pane
            }
        }
        echo "</div>\n";
        # tab accordion
        echo '</div>';
        # profile accordion
        do_action('sph_profile_edit_after_tabs');
        # inline js to create profile tabs
        global $firstTab, $firstMenu;
        $firstTab = $tabSlugExist ? $tabSlug : $firstTab;
        # if selected tab does not exist, use first tab
        $firstMenu = $menuSlugExist ? $menuSlug : $firstMenu;
        # if selected tab does not exist, use first menu in first tab
        # are we forcing password change on first login?
        if (isset($spThisUser->sp_change_pw) && $spThisUser->sp_change_pw) {
            $firstTab = 'profile';
            $firstMenu = 'account-settings';
        }
        add_action('wp_footer', 'sp_ProfileEditFooterMobile');
    }
    do_action('sph_profile_edit_after');
}
示例#5
0
function sp_process_profileshow_view()
{
    global $spVars, $spThisUser;
    if (!empty($spVars['member'])) {
        $userid = (int) $spVars['member'];
        $userid = spdb_table(SFMEMBERS, "user_id={$userid}", 'user_id');
    } else {
        $userid = $spThisUser->ID;
    }
    if (!sp_get_auth('view_profiles') || empty($userid) || $userid < 0) {
        sp_notify(SPFAILURE, sp_text('Invalid profile request'));
        return 'spDefault.php';
    } else {
        global $spProfileUser;
        sp_SetupUserProfileData();
        return 'spProfileShow.php';
    }
}
function sp_populate_support_vars()
{
    global $spVars;
    # Populate the rest of spVars
    if (empty($spVars['page'])) {
        $spVars['page'] = 1;
    }
    if (!empty($spVars['forumslug']) && $spVars['forumslug'] != 'all') {
        $record = spdb_table(SFFORUMS, "forum_slug='" . $spVars['forumslug'] . "'", 'row');
        if ($record) {
            $spVars['groupid'] = $record->group_id;
            $spVars['forumid'] = $record->forum_id;
            if (empty($spVars['groupid'])) {
                $spVars['groupid'] = 0;
            }
            if (empty($spVars['forumid'])) {
                $spVars['forumid'] = 0;
            }
            $spVars['forumname'] = $record->forum_name;
            $spVars['forumdesc'] = $record->forum_desc;
            $spVars['featureimage'] = $record->feature_image;
            # Is it a subforum?
            if (!empty($record->parent)) {
                $forumparent = $record->parent;
                while ($forumparent > 0) {
                    $parent = spdb_table(SFFORUMS, "forum_id={$forumparent}", 'row');
                    if ($parent) {
                        $spVars['parentforumid'][] = $forumparent;
                        $spVars['parentforumslug'][] = $parent->forum_slug;
                        $spVars['parentforumname'][] = $parent->forum_name;
                        $forumparent = $parent->parent;
                    } else {
                        $forumparent = true;
                    }
                }
            }
            $spVars = apply_filters('sph_spvars_forum', $spVars, $record);
        } else {
            $header = apply_filters('sph_404', 404);
            status_header($header);
        }
    }
    if (!empty($spVars['topicslug'])) {
        $record = spdb_table(SFTOPICS, "topic_slug='" . $spVars['topicslug'] . "'", 'row');
        if ($record) {
            $spVars['topicid'] = $record->topic_id;
            if (empty($spVars['topicid'])) {
                $spVars['topicid'] = 0;
            }
            if ($record) {
                $spVars['topicname'] = $record->topic_name;
            }
            # verify forum slug matches forum slug based on topic and do canonical redirect if doesnt match (moved?)
            $forum = spdb_table(SFFORUMS, "forum_id='" . $record->forum_id . "'", 'row');
            if ($forum->forum_slug != $spVars['forumslug']) {
                $url = sp_build_url($forum->forum_slug, $spVars['topicslug'], $spVars['page'], 0);
                wp_redirect(esc_url($url), 301);
            }
            $spVars = apply_filters('sph_spvars_topic', $spVars, $record);
        } else {
            $header = apply_filters('sph_404', 404);
            status_header($header);
        }
    }
    # Add Search Vars
    if (isset($_GET['search'])) {
        if ($_GET['search'] != '') {
            $spVars['searchpage'] = intval($_GET['search']);
        }
        $spVars['searchpage'] = sp_esc_int($spVars['searchpage']);
        if (isset($_GET['type']) ? $spVars['searchtype'] = intval($_GET['type']) : ($spVars['searchtype'] = 1)) {
        }
        $spVars['searchtype'] = sp_esc_int($spVars['searchtype']);
        if ($spVars['searchtype'] == 0 || empty($spVars['searchtype'])) {
            $spVars['searchtype'] = 1;
        }
        if (isset($_GET['include']) ? $spVars['searchinclude'] = intval($_GET['include']) : ($spVars['searchinclude'] = 1)) {
        }
        $spVars['searchinclude'] = sp_esc_int($spVars['searchinclude']);
        if ($spVars['searchinclude'] == 0 || empty($spVars['searchinclude'])) {
            $spVars['searchinclude'] = 1;
        }
        if (isset($_GET['value']) ? $spVars['searchvalue'] = sp_filter_save_nohtml(urldecode($_GET['value'])) : ($spVars['searchvalue'] = '')) {
        }
        $spVars['searchvalue'] = sp_filter_table_prefix($spVars['searchvalue']);
        $spVars['newsearch'] = isset($_GET['new']) ? true : false;
        if (empty($spVars['searchvalue']) || $spVars['searchvalue'] == '') {
            $spVars['searchpage'] = 0;
            $spVars['searchtype'] = 0;
            $spVars['searchinclude'] = 0;
            sp_notify(SPFAILURE, sp_text('Invalid search query'));
            wp_redirect(sp_url());
        }
    } else {
        $spVars['searchpage'] = 0;
    }
    $spVars['searchresults'] = 0;
    $spVars = apply_filters('sph_support_vars', $spVars);
}
    ?>
	<script type="text/javascript">
	jQuery(document).ready(function() {
        setTimeout(function() {
            spjSetProfileDataHeight();
        }, 500);
	})
	</script>
<?php 
    die;
}
# check for tab press
if (isset($_GET['tab'])) {
    # profile edit, so only admin or logged in user can view
    if (empty($userid) || $spThisUser->ID != $userid && !$spThisUser->admin) {
        sp_notify(1, sp_text('Invalid profile request'));
        $out .= sp_render_queued_notification();
        $out .= '<div class="sfmessagestrip">';
        $out .= apply_filters('sph_ProfileErrorMsg', sp_text('Sorry, an invalid profile request was detected. Do you need to log in?'));
        $out .= '</div>';
        return $out;
    }
    # set up profile for requested user
    sp_SetupUserProfileData($userid);
    # get pressed tab and menu (if pressed)
    $thisTab = sp_esc_str($_GET['tab']);
    $thisMenu = isset($_GET['menu']) ? sp_esc_str($_GET['menu']) : '';
    # get all the tabs meta info
    $tabs = sp_profile_get_tabs();
    if (!empty($tabs)) {
        foreach ($tabs as $tab) {
示例#8
0
function sp_build_forum_index($forumid, $returnmsg = false)
{
    if (!$forumid) {
        return '';
    }
    # get the topic count for this forum
    $topiccount = spdb_count(SFTOPICS, "forum_id={$forumid}");
    # get the post count and post count held
    $postcount = spdb_sum(SFTOPICS, 'post_count', "forum_id={$forumid}");
    $postcountheld = spdb_sum(SFTOPICS, 'post_count_held', "forum_id={$forumid}");
    # get the last post id and last post held id that appeared in a topic within this forum
    $postid = spdb_table(SFPOSTS, "forum_id={$forumid}", 'post_id', 'post_id DESC', '1');
    $postidheld = spdb_table(SFPOSTS, "forum_id={$forumid} AND post_status=0", 'post_id', 'post_id DESC', '1');
    if (!$topiccount) {
        $topiccount = 0;
    }
    if (!$postcount) {
        $postcount = 0;
    }
    if (!isset($postid)) {
        $postid = 'NULL';
    }
    if (!$postcountheld) {
        $postcountheld = 0;
    }
    if (!isset($postidheld)) {
        $postidheld = 'NULL';
    }
    # update forum record
    spdb_query('UPDATE ' . SFFORUMS . " SET\n\t\t\t\tpost_id={$postid},\n\t\t\t\tpost_id_held={$postidheld},\n\t\t\t\tpost_count={$postcount},\n\t\t\t\tpost_count_held={$postcountheld},\n\t\t\t\ttopic_count={$topiccount}\n\t\t\t\tWHERE forum_id={$forumid}");
    if ($returnmsg) {
        sp_notify(SPSUCCESS, sp_text('Verification complete'));
    }
}
function sp_render_forum($content)
{
    global $spIsForum, $spContentLoaded, $spVars, $spGlobals, $spThisUser, $spStatus;
    # make sure we are at least in the html body before outputting any content
    if (!sp_get_option('sfwpheadbypass') && !did_action('wp_head')) {
        return '';
    }
    if ($spIsForum && !post_password_required(get_post(sp_get_option('sfpage')))) {
        # Limit forum display to within the wp loop?
        if (sp_get_option('sfinloop') && !in_the_loop()) {
            return $content;
        }
        # Has forum content already been loaded and are we limiting?
        if (!sp_get_option('sfmultiplecontent') && $spContentLoaded) {
            return $content;
        }
        $spContentLoaded = true;
        sp_set_server_timezone();
        # offer a way for forum display to be short circuited but always show for admins unless an upgrade
        $message = sp_abort_display_forum();
        $content .= $message;
        if (!empty($message) && (!$spThisUser->admin || $spStatus != 'ok')) {
            return $content;
        }
        # process query arg actions
        # check for edit operation. Need tp check for '_x' in case using mobile as buttin is an image
        if (isset($_POST['editpost']) || isset($_POST['editpost_x'])) {
            sp_save_edited_post();
        }
        if (isset($_POST['edittopic'])) {
            sp_save_edited_topic();
        }
        if (isset($_POST['ordertopicpins'])) {
            sp_promote_pinned_topic();
        }
        if (isset($_POST['makepostreassign'])) {
            sp_reassign_post();
        }
        if (isset($_POST['approvepost'])) {
            sp_approve_post(false, sp_esc_int($_POST['approvepost']), $spVars['topicid']);
        }
        if (isset($_POST['unapprovepost'])) {
            sp_unapprove_post(sp_esc_int($_POST['unapprovepost']));
        }
        if (isset($_POST['doqueue'])) {
            sp_remove_waiting_queue();
        }
        if (isset($_POST['notifyuser'])) {
            sp_post_notification(sp_esc_str($_POST['sp_notify_user']), sp_esc_str($_POST['message']), sp_esc_int($_POST['postid']));
        }
        # move a topic and redirect to that topic
        if (isset($_POST['maketopicmove'])) {
            if (empty($_POST['forumid'])) {
                sp_notify(1, sp_text('Destination forum not selected'));
                return;
            }
            sp_move_topic();
            $forumslug = spdb_table(SFFORUMS, 'forum_id=' . sp_esc_int(sp_esc_int($_POST['forumid'])), 'forum_slug');
            $topicslug = spdb_table(SFTOPICS, 'topic_id=' . sp_esc_int(sp_esc_int($_POST['currenttopicid'])), 'topic_slug');
            $returnURL = sp_build_url($forumslug, $topicslug, 0);
            sp_redirect($returnURL);
        }
        # move a post and redirect to the post
        if (isset($_POST['makepostmove1']) || isset($_POST['makepostmove2']) || isset($_POST['makepostmove3'])) {
            sp_move_post();
            if (isset($_POST['makepostmove1'])) {
                $returnURL = sp_permalink_from_postid(sp_esc_int($_POST['postid']));
                sp_redirect($returnURL);
            }
        }
        # cancel a post move
        if (isset($_POST['cancelpostmove'])) {
            $meta = sp_get_sfmeta('post_move', 'post_move');
            if ($meta) {
                $id = $meta[0]['meta_id'];
                sp_delete_sfmeta($id);
                unset($spGlobals['post_move']);
            }
        }
        # rebuild the forum and post indexes
        if (isset($_POST['rebuildforum']) || isset($_POST['rebuildtopic'])) {
            sp_build_post_index(sp_esc_int($_POST['topicid']), true);
            sp_build_forum_index(sp_esc_int($_POST['forumid']), false);
        }
        # Set display mode if topic view (for editing posts)
        if ($spVars['pageview'] == 'topic' && isset($_POST['postedit'])) {
            $spVars['displaymode'] = 'edit';
            $spVars['postedit'] = $_POST['postedit'];
        } else {
            $spVars['displaymode'] = 'posts';
        }
        # clean cache of timed our records
        sp_clean_cache();
        #--Scratch Pad Area---Please Leave Here---------
        #--End Scratch Pad Area-------------------------
        # let other plugins check for posted actions
        do_action('sph_setup_forum');
        # do we use output buffering?
        $ob = sp_get_option('sfuseob');
        if ($ob) {
            ob_start();
        }
        # set up some stuff before wp page content
        $content .= sp_display_banner();
        $content = apply_filters('sph_before_wp_page_content', $content);
        # run any other wp filters on page content but exclude ours
        if (!$ob) {
            remove_filter('the_content', 'sp_render_forum', 1);
            $content = apply_filters('the_content', $content);
            $content = wpautop($content);
            add_filter('the_content', 'sp_render_forum', 1);
        }
        # set up some stuff after wp page content
        $content = apply_filters('sph_after_wp_page_content', $content);
        $content .= '<div id="dialogcontainer" style="display:none;"></div>';
        $content .= sp_js_check();
        # echo any wp page content
        echo $content;
        # now add our content
        do_action('sph_before_template_processing');
        sp_process_template();
        do_action('sph_after_template_processing');
        # Return if using output buffering
        if ($ob) {
            $forum = ob_get_contents();
            ob_end_clean();
            return $forum;
        }
    }
    # not returning any content since we output it already unless password needed
    if (post_password_required(get_post(sp_get_option('sfpage')))) {
        return $content;
    }
}
示例#10
0
# ready for some unique and topic/post form specific checks ------------------------
$spamcheck = sp_check_spammath($p->newpost['forumid']);
if ($spamcheck[0] == true) {
    sp_return_to_post($p->returnURL, $spamcheck[1]);
    die;
}
# now we can save to the database --------------------------------------------------
$p->saveData();
if ($p->abort) {
    sp_return_to_post($p->returnURL, $p->message);
    die;
} else {
    if ($p->action == 'topic') {
        sp_notify(0, sp_text('New topic saved') . $p->newpost['submsg']);
    } else {
        sp_notify(0, sp_text('New post saved') . $p->newpost['submsg']);
    }
}
do_action('sph_editor_post_create', $p->newpost);
$p->returnURL = apply_filters('sph_new_forum_post_returnurl', $p->returnURL);
wp_redirect($p->returnURL);
die;
# ==================================================================================
# Return to editor if problem
function sp_return_to_post($returnURL, $message)
{
    # place details in the cache
    $failure = array();
    $failure['message'] = sp_text('Unable to save') . '<br>' . $message;
    if (isset($_POST['newtopicname']) ? $failure['newtopicname'] = $_POST['newtopicname'] : ($failure['newtopicname'] = '')) {
    }
 function sp_searchview_query($searchType, $searchInclude)
 {
     global $spVars, $spThisUser;
     # some defaults
     $useLimit = true;
     $TABLE = '';
     $JOIN = '';
     $FIELDS = SFPOSTS . '.topic_id';
     $WHERE = '';
     $ORDERBY = SFPOSTS . '.topic_id DESC';
     # (WHERE) Post content search criteria
     if ($searchType == 1 || $searchType == 2 || $searchType == 3) {
         $useLimit = false;
         # Standard forum search
         if ($searchInclude == 1) {
             # Include = 1 - posts
             $WHERE = $this->searchTerm;
             $TABLE = SFPOSTS;
         } elseif ($searchInclude == 2) {
             # Include = 2 - titles
             $WHERE = $this->searchTerm;
             $TABLE = SFTOPICS;
             $FIELDS = SFTOPICS . '.topic_id';
             $ORDERBY = SFTOPICS . '.topic_id DESC';
         } elseif ($searchInclude == 3) {
             # Include = 3 - posts and titles
             $WHERE = $this->searchTerm;
             $TABLE = SFPOSTS;
             $JOIN = array(SFTOPICS . ' ON ' . SFPOSTS . '.topic_id = ' . SFTOPICS . '.topic_id');
         } else {
             # Plugns can set an alternate TABLE and MATCH statement based on the 'Include' parameter
             $TABLE = apply_filters('sph_search_type_table', SFTOPICS, $searchType, $searchInclude);
             $WHERE = apply_filters('sph_search_include_where', '', $this->searchTerm, $searchType, $searchInclude);
         }
     } elseif ($searchType == 4) {
         # Member 'posted in'
         $WHERE = "user_id={$this->searchTerm}";
         $TABLE = SFPOSTS;
     } elseif ($searchType == 5) {
         # Member 'started'
         $WHERE = "user_id={$this->searchTerm} AND post_index=1";
         $TABLE = SFPOSTS;
     } else {
         # Plugns can set an alternate TABLE and WHERE clause based on the 'Type' parameter
         $TABLE = apply_filters('sph_search_type_table', SFTOPICS, $searchType, $searchInclude);
         $WHERE = apply_filters('sph_search_type_where', '', $this->searchTerm, $searchType, $searchInclude);
     }
     # check if the WHERE clause is empty - probably comes from a legacy url
     if (empty($WHERE)) {
         sp_notify(1, sp_text('Unable to complete this search request'));
         return;
     }
     # Query
     $spdb = new spdbComplex();
     $spdb->table = $TABLE;
     $spdb->fields = $FIELDS;
     if (!empty($JOIN)) {
         $spdb->join = $JOIN;
     }
     $spdb->distinct = true;
     $spdb->found_rows = true;
     $spdb->where = $WHERE . ' AND ' . $TABLE . '.' . $this->forumWhere;
     $spdb->orderby = $ORDERBY;
     if ($useLimit) {
         $spdb->limits = $this->limit;
     }
     # Plugins can alter the final SQL
     $spdb = apply_filters('sph_search_query', $spdb, $this->searchTerm, $searchType, $searchInclude, $this);
     if (!empty($spThisUser->inspect['q_spSearchView'])) {
         $spdb->inspect = 'q_spSearchView';
         $spdb->show = true;
     }
     $records = $spdb->select('col');
     $spVars['searchresults'] = spdb_select('var', 'SELECT FOUND_ROWS()');
     $this->searchCount = $spVars['searchresults'];
     $this->searchInclude = $searchInclude;
     $this->searchType = $searchType;
     return $records;
 }
示例#12
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;
}
# ready for some unique and topic/post form specific checks ------------------------
$spamcheck = sp_check_spammath($p->newpost['forumid']);
if ($spamcheck[0] == true) {
    sp_return_to_post($p->returnURL, $spamcheck[1]);
    die;
}
# now we can save to the database --------------------------------------------------
$p->saveData();
if ($p->abort) {
    sp_return_to_post($p->returnURL, $p->message);
    die;
} else {
    if ($p->action == 'topic') {
        sp_notify(SPSUCCESS, sp_text('New topic saved') . $p->newpost['submsg']);
    } else {
        sp_notify(SPSUCCESS, sp_text('New post saved') . $p->newpost['submsg']);
    }
}
do_action('sph_editor_post_create', $p->newpost);
$p->returnURL = apply_filters('sph_new_forum_post_returnurl', $p->returnURL);
wp_redirect($p->returnURL);
die;
# ==================================================================================
# Return to editor if problem
function sp_return_to_post($returnURL, $message)
{
    # place details in the cache
    $failure = array();
    $failure['message'] = sp_text('Unable to save') . '<br>' . $message;
    if (isset($_POST['newtopicname']) ? $failure['newtopicname'] = $_POST['newtopicname'] : ($failure['newtopicname'] = '')) {
    }