function sp_admin_bar_do_upgrade_check() { if (!sp_is_plugin_active('admin-bar/sp-admin-bar-plugin.php')) { return; } $options = sp_get_option('spAdminBar'); $db = $options['dbversion']; if (empty($db)) { $db = 0; } # quick bail check if ($db == SPABDBVERSION) { return; } # apply upgrades as needed if ($db < 1) { # empty since plugin did not used db on initial release } if ($db < 2) { # set autoload flag to true for autoupdates $meta = sp_get_sfmeta('autoupdate', 'admin'); if (!empty($meta[0])) { sp_update_sfmeta('autoupdate', 'admin', $meta[0]['meta_value'], $meta[0]['meta_id'], 1); } } if ($db < 3) { # permission for bypassing akismet checks sp_add_auth('bypass_akismet', __('Can bypass akismet check on posts', 'spab'), 1, 0, 0, 0, 3); sp_activate_auth('bypass_akismet'); } # save data $options['dbversion'] = SPABDBVERSION; sp_update_option('spAdminBar', $options); }
function sp_admin_bar_do_deactivate() { global $spGlobals; # remove the auth sp_deactivate_auth('bypass_akismet'); # remove our auto update stuff $up = sp_get_sfmeta('autoupdate', 'admin'); if ($up) { sp_delete_sfmeta($up[0]['meta_id']); } }
function spa_get_mapping_data() { # get default usergroups $sfoptions = array(); $value = sp_get_sfmeta('default usergroup', 'sfmembers'); $sfoptions['sfdefgroup'] = $value[0]['meta_value']; $value = sp_get_sfmeta('default usergroup', 'sfguests'); $sfoptions['sfguestsgroup'] = $value[0]['meta_value']; $sfmemberopts = sp_get_option('sfmemberopts'); $sfoptions['sfsinglemembership'] = $sfmemberopts['sfsinglemembership']; return $sfoptions; }
function spa_themes_css_form() { $css = ''; $id = 0; # get current theme $curTheme = sp_get_option('sp_current_theme'); $rec = sp_get_sfmeta('css', $curTheme['theme']); if ($rec) { $css = $rec[0]['meta_value']; $id = $rec[0]['meta_id']; } ?> <script type="text/javascript"> jQuery(document).ready(function() { spjAjaxForm('speditcss', ''); }); </script> <?php $ahahURL = SFHOMEURL . 'index.php?sp_ahah=themes-loader&sfnonce=' . wp_create_nonce('forum-ahah') . '&saveform=css'; ?> <form action="<?php echo $ahahURL; ?> " method="post" id="speditcss" name="speditcss"> <?php echo sp_create_nonce('forum-adminform_css-editor'); spa_paint_options_init(); spa_paint_open_tab(spa_text('CSS Editor') . ' - ' . spa_text('Custom Simple:Press Theme CSS'), true); spa_paint_open_panel(); spa_paint_open_fieldset(spa_text('CSS Editor'), true, 'css-editor'); echo '<div>'; echo '<textarea rows="25" name="spnewcontent" id="spnewcontent" tabindex="1">' . $css . '</textarea>'; echo '<input type="hidden" name="metaId" value="' . $id . '" />'; echo '</div>'; spa_paint_close_fieldset(); spa_paint_close_panel(); spa_paint_close_container(); ?> <div class="sfform-submit-bar"> <input type="submit" class="button-primary" id="saveit" name="saveit" value="<?php spa_etext('Update CSS'); ?> " /> </div> <?php spa_paint_close_tab(); echo '</form>'; }
function sp_featured_admin_options_form() { $meta = sp_get_sfmeta('featured', 'topics'); $topics = implode(',', $meta[0]['meta_value']); $meta = sp_get_sfmeta('featured', 'posts'); $posts = implode(',', $meta[0]['meta_value']); spa_paint_options_init(); spa_paint_open_tab(__('Featured Topics and Posts Plugin', 'sp-featured'), true); spa_paint_open_panel(); spa_paint_open_fieldset(__('Featured Topics and Posts Options', 'sp-featured'), true, 'featured-lists'); spa_paint_input(__('List of featured topic IDs', 'sp-featured'), 'topic_list', sp_filter_title_display($topics)); spa_paint_input(__('List of featured post IDs', 'sp-featured'), 'post_list', sp_filter_title_display($posts)); spa_paint_close_fieldset(); spa_paint_close_panel(); spa_paint_close_container(); }
function sp_featured_do_install() { $options = sp_get_option('featured'); if (empty($options)) { $options['dbversion'] = SPFEATUREDDBVERSION; sp_update_option('featured', $options); } # set up our sfmeta if needed $check = sp_get_sfmeta('featured', 'topics'); if (empty($check)) { sp_add_sfmeta('featured', 'topics', array(), true); } $check = sp_get_sfmeta('featured', 'posts'); if (empty($check)) { sp_add_sfmeta('featured', 'posts', array(), true); } }
function sp_rebuild_user_auths($userid) { global $spGlobals; $user_auths = array(); $user_auths['global'] = array(); if (sp_is_forum_admin($userid)) { # forum admins get full auths $forums = spdb_table(SFFORUMS); if ($forums) { foreach ($forums as $forum) { foreach ($spGlobals['auths_map'] as $auth) { if ($spGlobals['auths'][$auth]->admin_negate) { $user_auths[$forum->forum_id][$auth] = 0; $user_auths['global'][$auth] = 0; } else { $user_auths[$forum->forum_id][$auth] = 1; $user_auths['global'][$auth] = 1; } } } } } else { $memberships = sp_get_user_memberships($userid); if (empty($memberships)) { $value = sp_get_sfmeta('default usergroup', 'sfguests'); $memberships[0]['usergroup_id'] = $value[0]['meta_value']; } # no memberships means no permissions if (empty($memberships)) { return; } # get the roles $roles_data = spdb_table(SFROLES, 0); foreach ($roles_data as $role) { $roles[$role->role_id] = unserialize($role->role_auths); } # now build auths for user foreach ($memberships as $membership) { # get the permissions for the membership $permissions = spdb_table(SFPERMISSIONS, 'usergroup_id=' . $membership['usergroup_id']); if ($permissions) { foreach ($permissions as $permission) { if (!isset($user_auths[$permission->forum_id])) { $user_auths[$permission->forum_id] = $roles[$permission->permission_role]; } else { foreach (array_keys($roles[$permission->permission_role]) as $auth_id) { if (!isset($user_auths[$permission->forum_id][$auth_id])) { $user_auths[$permission->forum_id][$auth_id] = $roles[$permission->permission_role][$auth_id]; } else { $user_auths[$permission->forum_id][$auth_id] |= $roles[$permission->permission_role][$auth_id]; } } } foreach ($roles[$permission->permission_role] as $auth_id => $auth) { if (empty($user_auths['global'][$auth_id])) { $user_auths['global'][$auth_id] = $auth; } else { $user_auths['global'][$auth_id] |= $auth; } } } } } } # now save the user auths if (!empty($user_auths)) { if (!empty($userid)) { sp_update_member_item($userid, 'auths', $user_auths); } else { sp_update_option('sf_guest_auths', $user_auths); } } return $user_auths; }
function __construct($ident = 0, $current = false, $small = false) { global $spStatus, $spGlobals; $id = 0; if (is_numeric($ident)) { $w = "ID={$ident}"; } else { if ($ident != false) { $w = "user_login='******'"; } } if ($ident) { # Users data $d = spdb_table(SFUSERS, $w, 'row'); if ($d) { $this->ID = $d->ID; $id = $d->ID; } } $includeList = spUser_build_filter_list(); if ($id) { # Others $this->member = true; $this->guest = 0; $this->guest_name = ''; $this->guest_email = ''; $this->offmember = false; $this->usertype = 'User'; # Users data foreach ($d as $key => $item) { if (array_key_exists($key, $includeList)) { $this->{$key} = $item; } } $this->user_registered = sp_member_registration_to_server_tz($this->user_registered); # usermeta data $d = spdb_table(SFUSERMETA, "user_id={$id}"); if ($d) { foreach ($d as $m) { $t = $m->meta_key; if (array_key_exists($t, $includeList)) { $this->{$t} = maybe_unserialize($m->meta_value); } } } # If awaiting installation then dive out now to avoid errors if ($spStatus == 'Install') { return; } # sfmembers data $d = spdb_table(SFMEMBERS, "user_id={$id}", 'row'); #check for ghost user if (empty($d)) { #create the member sp_create_member_data($id); $d = spdb_table(SFMEMBERS, "user_id={$id}", 'row'); } if ($d) { foreach ($d as $key => $item) { if ($key == 'admin_options' && !empty($item)) { $opts = unserialize($item); foreach ($opts as $opt => $set) { $this->{$opt} = $set; } } else { if ($key == 'user_options' && !empty($item)) { $opts = unserialize($item); foreach ($opts as $opt => $set) { $this->{$opt} = $set; } } else { if ($key == 'lastvisit') { $this->lastvisit = $item; } else { $this->{$key} = maybe_unserialize($item); } } } } } # Check for new post list size if (!isset($this->unreadposts) || empty($this->unreadposts)) { $controls = sp_get_option('sfcontrols'); $this->unreadposts = empty($controls['sfunreadposts']) ? 50 : $controls['sfunreadposts']; } # usertype for moderators if ($this->moderator) { $this->usertype = 'Moderator'; } # check for super admins and make admin a moderator as well if ($this->admin || is_multisite() && is_super_admin($id)) { $this->admin = true; $this->moderator = true; $this->usertype = 'Admin'; $ins = sp_get_option('spInspect'); if (!empty($ins) && array_key_exists($id, $ins)) { $this->inspect = $ins[$id]; } else { $this->inspect = ''; } } # plugins can add iterms for members... if (!$small) { do_action_ref_array('sph_user_class_member', array(&$this)); } else { do_action_ref_array('sph_user_class_member_small', array(&$this)); } } else { # some basics for guests $this->ID = 0; $this->guest = true; $this->member = 0; $this->admin = false; $this->moderator = false; $this->display_name = 'guest'; $this->guest_name = ''; $this->guest_email = ''; $this->usertype = 'Guest'; $this->offmember = sp_check_unlogged_user(); $this->timezone = 0; $this->timezone_string = ''; $this->posts = 0; $this->avatar = ''; $this->user_email = ''; $this->auths = sp_get_option('sf_guest_auths'); $this->memberships = sp_get_option('sf_guest_memberships'); # plugins can add iterms for guests... if (!$small) { do_action_ref_array('sph_user_class_guest', array(&$this)); } else { do_action_ref_array('sph_user_class_guest_small', array(&$this)); } } # Only perform this last section if forum is operational if ($spStatus == 'ok') { # Ranking $this->rank = sp_get_user_forum_rank($this->usertype, $id, $this->posts); $this->special_rank = $this->member ? sp_get_user_special_ranks($id) : array(); # if no memberships rebuild them and save if (empty($this->memberships)) { $memberships = array(); if (!empty($id)) { if (!$this->admin) { # get the usergroup memberships for the user and save in sfmembers table $memberships = sp_get_user_memberships($id); sp_update_member_item($id, 'memberships', $memberships); } } else { # user is a guest or unassigned member so get the global permissions from the guest usergroup and save as option $value = sp_get_sfmeta('default usergroup', 'sfguests'); $memberships[] = spdb_table(SFUSERGROUPS, 'usergroup_id=' . $value[0]['meta_value'], 'row', '', '', ARRAY_A); sp_update_option('sf_guest_memberships', $memberships); } # put in the data $this->memberships = $memberships; } # if no auths rebuild them and save if (empty($this->auths)) { $this->auths = sp_rebuild_user_auths($id); } } $this->ip = sp_get_ip(); $this->trackid = -1; # Things to do if user is current user if ($current) { # Set up editor type $spGlobals['editor'] = 0; # for a user... if ($this->member && !empty($this->editor)) { $spGlobals['editor'] = $this->editor; } # and if not defined or is for a guest... if ($spGlobals['editor'] == 0) { $defeditor = sp_get_option('speditor'); if (!empty($defeditor)) { $spGlobals['editor'] = $defeditor; } } # final check to ensure selected editor type is indeed available if ($spGlobals['editor'] == 0 || $spGlobals['editor'] == 1 && !defined('RICHTEXT') || $spGlobals['editor'] == 2 && !defined('HTML') || $spGlobals['editor'] == 3 && !defined('BBCODE')) { $spGlobals['editor'] = PLAINTEXT; if (defined('BBCODE')) { $spGlobals['editor'] = BBCODE; } if (defined('HTML')) { $spGlobals['editor'] = HTML; } if (defined('RICHTEXT')) { $spGlobals['editor'] = RICHTEXT; } } # Grab any notices present if ($this->guest && !empty($this->guest_email)) { $this->user_notices = spdb_table(SFNOTICES, "guest_email='" . $this->guest_email . "'", '', $order = 'notice_id'); } elseif ($this->member && !empty($this->user_email)) { $this->user_notices = spdb_table(SFNOTICES, "user_id=" . $this->ID, '', $order = 'notice_id'); } # plugins can add iterms for the current user (so no small allowed here) do_action_ref_array('sph_current_user_class', array(&$this)); } # Finally filter the data for display foreach ($includeList as $item => $filter) { if (property_exists($this, $item)) { $this->{$item} = spUser_filter_item($this->{$item}, $filter); } } # allow plugins to add items to user class - regardless small or otherwise, current or otherwise do_action_ref_array('sph_user_class', array(&$this)); }
function spa_check_warnings() { global $spGlobals; # not perfect but we can use this call tyo perform any minor # cleanups that may be necessary... so # drop any existing temp members table... spdb_query('DROP TABLE IF EXISTS sftempmembers'); $mess = ''; # check if sp core, plugins or themes update available $update = false; $update_msg = ''; $up = get_site_transient('update_plugins'); if (!empty($up->response)) { foreach ($up->response as $plugin) { if ($plugin->slug == 'simple-press') { $msg = apply_filters('sph_core_update_notice', spa_text('There is a Simple:Press core update available.')); if (!empty($msg)) { $update = true; $update_msg .= $msg . '<br />'; } break; } } } $up = get_site_transient('sp_update_plugins'); if (!empty($up)) { $msg = apply_filters('sph_plugins_update_notice', spa_text('There is one or more Simple:Press plugin updates available')); if (!empty($msg)) { $update = true; $update_msg .= $msg . '<br />'; } } $up = get_site_transient('sp_update_themes'); if (!empty($up)) { $msg = apply_filters('sph_themes_update_notice', spa_text('There is one or more Simple:Press theme updates available')); if (!empty($msg)) { $update = true; $update_msg .= $msg . '<br />'; } } if ($update) { if (is_main_site()) { $mess .= apply_filters('sph_updates_notice', spa_message($update_msg . '<a href="' . self_admin_url('update-core.php') . '">' . spa_text('Click here to view any updates.') . '</a>')); } else { $mess .= apply_filters('sph_updates_notice', spa_message(spa_text('There are some Simple:Press updates avaialable. You may want to notify the network site admin.'))); } } # output warning if no SPF admins are defined $a = $spGlobals['forum-admins']; if (empty($a)) { $mess .= spa_message(spa_text('Warning - There are no SPF admins defined! All WP admins now have SP backend access'), 'error'); } # Check if desktop, tablet and mobile themes are selected and available $cur = sp_get_option('sp_current_theme'); if (empty($cur)) { $mess .= spa_message(spa_text('No main theme has been selected and SP will be unable to display correctly. Please select a theme from the Themes panel'), 'error'); } else { $nostylesheet = !file_exists(SPTHEMEBASEDIR . $cur['theme'] . '/styles/' . $cur['style']); $nooverlay = !empty($cur['color']) && !file_exists(SPTHEMEBASEDIR . $cur['theme'] . '/styles/overlays/' . $cur['color'] . '.php'); $nopoverlay = !empty($cur['color']) && !empty($cur['parent']) && !file_exists(SPTHEMEBASEDIR . $cur['parent'] . '/styles/overlays/' . $cur['color'] . '.php'); if ($nostylesheet || $nooverlay && $nopoverlay) { $mess .= spa_message(spa_text('Either the theme CSS file and/or color Overlay file from the selected theme is missing'), 'error'); } } $mobile = sp_get_option('sp_mobile_theme'); if (!empty($mobile) && $mobile['active']) { $nostylesheet = !file_exists(SPTHEMEBASEDIR . $mobile['theme'] . '/styles/' . $mobile['style']); $nooverlay = !empty($mobile['color']) && !file_exists(SPTHEMEBASEDIR . $mobile['theme'] . '/styles/overlays/' . $mobile['color'] . '.php'); $nopoverlay = !empty($mobile['color']) && !empty($mobile['parent']) && !file_exists(SPTHEMEBASEDIR . $mobile['parent'] . '/styles/overlays/' . $mobile['color'] . '.php'); if ($nostylesheet || $nooverlay && $nopoverlay) { $mess .= spa_message(spa_text('Either the mobile theme CSS file and/or color Overlay file from the selected mobile theme is missing'), 'error'); } } $tablet = sp_get_option('sp_tablet_theme'); if (!empty($tablet) && $tablet['active']) { $nostylesheet = !file_exists(SPTHEMEBASEDIR . $tablet['theme'] . '/styles/' . $tablet['style']); $nooverlay = !empty($tablet['color']) && !file_exists(SPTHEMEBASEDIR . $tablet['theme'] . '/styles/overlays/' . $tablet['color'] . '.php'); $nopoverlay = !empty($tablet['color']) && !empty($tablet['parent']) && !file_exists(SPTHEMEBASEDIR . $tablet['parent'] . '/styles/overlays/' . $tablet['color'] . '.php'); if ($nostylesheet || $nooverlay && $nopoverlay) { $mess .= spa_message(spa_text('Either the tablet theme CSS file and/or color Overlay file from the selected tablet theme is missing'), 'error'); } } # check for missing default members user group $value = sp_get_sfmeta('default usergroup', 'sfmembers'); $ugid = spdb_table(SFUSERGROUPS, "usergroup_id={$value[0]['meta_value']}", 'usergroup_id'); if (empty($ugid)) { $mess .= spa_message(spa_text('Warning - The default user group for new members is undefined! Please visit the SP usergroups admin page, map users to usergroups tab and set the default user group'), 'error'); } # check for missing default guest user group $value = sp_get_sfmeta('default usergroup', 'sfguests'); $ugid = spdb_table(SFUSERGROUPS, "usergroup_id={$value[0]['meta_value']}", 'usergroup_id'); if (empty($ugid)) { $mess .= spa_message(spa_text('Warning - The default user group for guests is undefined! Please visit the SP usergroups admin page, map users to usergroups tab and set the default user group'), 'error'); } # check for unreachable forums because of permissions $done = 0; $usergroups = spdb_table(SFUSERGROUPS); if ($usergroups) { $has_members = false; foreach ($usergroups as $usergroup) { $members = spdb_table(SFMEMBERSHIPS, "usergroup_id={$usergroup->usergroup_id}", 'row', '', '1'); if ($members || $usergroup->usergroup_id == $value[0]['meta_value']) { $has_members = true; break; } } if (!$has_members) { $mess .= spa_message(spa_text('Warning - There are no usergroups that have members! All forums may only be visible to SP admins'), 'error'); $done = 1; } } else { $mess .= spa_message(spa_text('Warning - There are no usergroups defined! All forums may only be visible to SP admins'), 'error'); $done = 1; } $roles = sp_get_all_roles(); if (!$roles) { $mess .= spa_message(spa_text('Warning - There are no permission sets defined! All forums may only be visible to SP admins'), 'error'); $done = 1; } # check if compatible with wp super cache if (function_exists('wp_cache_edit_rejected')) { global $cache_rejected_uri; $slug = '/' . sp_get_option('sfslug') . '/'; if (isset($cache_rejected_uri)) { $found = false; foreach ($cache_rejected_uri as $value) { if ($value == $slug) { $found = true; break; } } if (!$found) { $string = spa_text('WP Super Cache is not properly configured to work with Simple:Press. Please visit your WP Super Cache settings page and in the accepted filenames & rejected URIs section for the pages not to be cached input field, add the following string'); $string .= ':<br /><br />' . $slug . '<br /><br />'; $string .= spa_text('Then, please clear your WP Super Cache cache to remove any cached Simple:Press pages'); $mess .= spa_message($string, 'error'); } } } if ($mess != '') { return $mess; } }
function sp_topicview_query($topicid = 0, $cPage = 1, $forumid = 0) { global $spGlobals, $spThisUser, $spVars; # do we have a valid topic id if ($topicid == 0) { $this->topicViewStatus = 'no data'; return; } else { $WHERE = SFTOPICS . '.topic_id=' . $topicid; } # default to no access $this->topicViewStatus = 'no access'; # some setup vars $startlimit = 0; $lastpage = 0; # how many posts per page? $ppaged = $spGlobals['display']['posts']['perpage']; if (!$ppaged) { $ppaged = 10; } # setup where we are in the post list (paging) if ($cPage != 1) { $startlimit = ($cPage - 1) * $ppaged; } $LIMIT = $startlimit . ', ' . $ppaged; # Set up order by $setSort = false; $reverse = false; $setSort = $spGlobals['display']['posts']['sortdesc']; if (isset($spGlobals['sort_order']['topic'])) { $reverse = array_search($topicid, (array) $spGlobals['sort_order']['topic']) !== false ? true : false; } if (isset($spThisUser->postDESC) && $spThisUser->postDESC) { $reverse = !$reverse; } if ($setSort xor $reverse) { $ORDER = 'post_pinned DESC, ' . SFPOSTS . ".post_id DESC"; } else { $ORDER = 'post_pinned DESC, ' . SFPOSTS . ".post_id ASC"; } # add newpost/sfwaiting support for admins $waitCheck = ', NULL AS new_post'; if ($spThisUser->admin || $spThisUser->moderator) { $waitCheck = ', ' . SFWAITING . '.post_count AS new_post'; } # Discover if this topic is in users new post list $maybeNewPost = false; if ($spThisUser->member && sp_is_in_users_newposts($topicid)) { $maybeNewPost = true; } # retrieve topic and post records $spdb = new spdbComplex(); $spdb->table = SFTOPICS; $spdb->found_rows = true; $spdb->fields = 'group_id, ' . SFTOPICS . '.topic_id, ' . SFTOPICS . '.forum_id, topic_name, topic_slug, topic_status, topic_pinned, topic_icon, topic_opened, ' . SFTOPICS . '.post_count, forum_name, forum_slug, forum_status, forum_disabled, forum_rss_private, ' . SFPOSTS . '.post_id, ' . spdb_zone_datetime('post_date') . ', ' . SFPOSTS . '.user_id, ' . SFTOPICS . '.user_id AS topic_starter, guest_name, guest_email, post_status, post_pinned, post_index, post_edit, poster_ip, source, post_content' . $waitCheck; $spdb->join = array(SFPOSTS . ' ON ' . SFTOPICS . '.topic_id=' . SFPOSTS . '.topic_id', SFFORUMS . ' ON ' . SFTOPICS . '.forum_id=' . SFFORUMS . '.forum_id'); if ($spThisUser->admin || $spThisUser->moderator) { $spdb->left_join = array(SFWAITING . ' ON ' . SFPOSTS . '.post_id=' . SFWAITING . '.post_id'); } $spdb->where = $WHERE; $spdb->orderby = $ORDER; $spdb->limits = $LIMIT; $spdb = apply_filters('sph_topicview_query', $spdb, $this); if (!empty($spThisUser->inspect['q_spTopicView'])) { $spdb->inspect = 'spTopicView'; $spdb->show = true; } $records = $spdb->select(); $t = array(); if ($records) { $tidx = $topicid; $pidx = 0; $r = current($records); if (sp_get_auth('view_forum', $r->forum_id)) { $this->topicViewStatus = 'data'; # construct the parent topic object $t[$tidx] = new stdClass(); $t[$tidx]->topic_id = $r->topic_id; $t[$tidx]->forum_id = $r->forum_id; $t[$tidx]->group_id = $r->group_id; $t[$tidx]->forum_name = sp_filter_title_display($r->forum_name); $t[$tidx]->topic_name = sp_filter_title_display($r->topic_name); $t[$tidx]->topic_slug = $r->topic_slug; $t[$tidx]->topic_opened = $r->topic_opened; $t[$tidx]->forum_status = $r->forum_status; $t[$tidx]->topic_pinned = $r->topic_pinned; $t[$tidx]->forum_disabled = $r->forum_disabled; $t[$tidx]->forum_slug = $r->forum_slug; $t[$tidx]->forum_rss_private = $r->forum_rss_private; $t[$tidx]->topic_permalink = sp_build_url($r->forum_slug, $r->topic_slug, 1, 0); $t[$tidx]->topic_status = $r->topic_status; $t[$tidx]->topic_icon = sanitize_file_name($r->topic_icon); $t[$tidx]->rss = ''; $t[$tidx]->editmode = 0; $t[$tidx]->tools_flag = 1; $t[$tidx]->display_page = $this->topicPage; $t[$tidx]->posts_per_page = $ppaged; $t[$tidx]->unread = 0; # user calc_rows and nor post_count as - for example - some posts may be hiodden by choice. $t[$tidx]->post_count = spdb_select('var', 'SELECT FOUND_ROWS()'); # Can the user create new topics or should we lock the forum? $t[$tidx]->start_topics = sp_get_auth('start_topics', $r->forum_id); $t[$tidx]->reply_topics = sp_get_auth('reply_topics', $r->forum_id); $t[$tidx]->reply_own_topics = sp_get_auth('reply_own_topics', $r->forum_id); # grab topic start info $t[$tidx]->topic_starter = $r->topic_starter; $totalPages = $r->post_count / $ppaged; if (!is_int($totalPages)) { $totalPages = intval($totalPages) + 1; } $t[$tidx]->total_pages = $totalPages; if ($setSort xor $reverse) { if ($cPage == 1) { $lastpage = true; } } else { if ($cPage == $totalPages) { $lastpage = true; } } $t[$tidx]->last_page = $lastpage; $t[$tidx] = apply_filters('sph_topicview_topic_record', $t[$tidx], $r); reset($records); unset($r); # now loop through the post records $newPostFlag = false; $firstPostPage = 1; $pinned = 0; # define post id and post user id arrays for plugins to use in combined filter $p = array(); $u = array(); foreach ($records as $r) { $pidx = $r->post_id; $p[] = $pidx; # prepare for user object $cUser = $spThisUser->ID == $r->user_id; $cSmall = !$cUser; $t[$tidx]->posts[$pidx] = new stdClass(); $t[$tidx]->posts[$pidx]->post_id = $r->post_id; $t[$tidx]->posts[$pidx]->post_date = $r->post_date; $t[$tidx]->posts[$pidx]->user_id = $r->user_id; $t[$tidx]->posts[$pidx]->guest_name = sp_filter_name_display($r->guest_name); $t[$tidx]->posts[$pidx]->guest_email = sp_filter_email_display($r->guest_email); $t[$tidx]->posts[$pidx]->post_status = $r->post_status; $t[$tidx]->posts[$pidx]->post_pinned = $r->post_pinned; $t[$tidx]->posts[$pidx]->post_index = $r->post_index; $t[$tidx]->posts[$pidx]->poster_ip = $r->poster_ip; $t[$tidx]->posts[$pidx]->source = $r->source; $t[$tidx]->posts[$pidx]->post_permalink = sp_build_url($r->forum_slug, $r->topic_slug, $cPage, $r->post_id); $t[$tidx]->posts[$pidx]->edits = ''; $t[$tidx]->posts[$pidx]->last_post = 0; $t[$tidx]->posts[$pidx]->last_post_on_page = 0; $t[$tidx]->posts[$pidx]->first_post_on_page = $firstPostPage; $t[$tidx]->posts[$pidx]->editmode = 0; $t[$tidx]->posts[$pidx]->post_content = sp_filter_content_display($r->post_content); $t[$tidx]->posts[$pidx]->first_pinned = 0; $t[$tidx]->posts[$pidx]->last_pinned = 0; $t[$tidx]->posts[$pidx]->postUser = new stdClass(); $t[$tidx]->posts[$pidx]->postUser = clone sp_get_user($r->user_id, $cUser, $cSmall); # populate the user guest name and email in case the poster is a guest if ($r->user_id == 0) { $t[$tidx]->posts[$pidx]->postUser->guest_name = $t[$tidx]->posts[$pidx]->guest_name; $t[$tidx]->posts[$pidx]->postUser->guest_email = $t[$tidx]->posts[$pidx]->guest_email; $t[$tidx]->posts[$pidx]->postUser->display_name = $t[$tidx]->posts[$pidx]->guest_name; $t[$tidx]->posts[$pidx]->postUser->ip = $t[$tidx]->posts[$pidx]->poster_ip; } # pinned status if ($firstPostPage == 1 && $r->post_pinned) { $t[$tidx]->posts[$pidx]->first_pinned = true; $pinned = $pidx; } if ($firstPostPage == 0 && $pinned > 0 && $r->post_pinned == false) { $t[$tidx]->posts[$pinned]->last_pinned = true; } elseif ($r->post_pinned) { $pinned = $pidx; } $firstPostPage = 0; # Is this a new post for the current user? if ($spThisUser->guest) { $newPostFlag = false; } else { if ($maybeNewPost && strtotime($r->post_date) > strtotime($spThisUser->lastvisit)) { $newPostFlag = true; } if (isset($r->new_post)) { $newPostFlag = true; } } $t[$tidx]->posts[$pidx]->new_post = $newPostFlag; # do we need to hide an admin post? if (!sp_get_auth('view_admin_posts', $r->forum_id) && sp_is_forum_admin($r->user_id)) { $adminview = sp_get_sfmeta('adminview', 'message'); if ($adminview) { $t[$tidx]->posts[$pidx]->post_content = '<div class="spMessage">'; $t[$tidx]->posts[$pidx]->post_content .= sp_filter_text_display($adminview[0]['meta_value']); $t[$tidx]->posts[$pidx]->post_content .= '</div>'; } else { $t[$tidx]->posts[$pidx]->post_content = ''; } } # do we need to hide an others posts? if (sp_get_auth('view_own_admin_posts', $r->forum_id) && !sp_is_forum_admin($r->user_id) && !sp_is_forum_mod($r->user_id) && $spThisUser->ID != $r->user_id) { $userview = sp_get_sfmeta('userview', 'message'); if ($userview) { $t[$tidx]->posts[$pidx]->post_content = '<div class="spMessage">'; $t[$tidx]->posts[$pidx]->post_content .= sp_filter_text_display($userview[0]['meta_value']); $t[$tidx]->posts[$pidx]->post_content .= '</div>'; } else { $t[$tidx]->posts[$pidx]->post_content = ''; } } # Is this post to be edited? if ($spVars['displaymode'] == 'edit' && $spVars['postedit'] == $r->post_id) { $t[$tidx]->editmode = 1; $t[$tidx]->editpost_id = $r->post_id; $t[$tidx]->editpost_content = sp_filter_content_edit($r->post_content); $t[$tidx]->posts[$pidx]->editmode = 1; } # Add edit history if (!empty($r->post_edit) && is_serialized($r->post_edit)) { $edits = unserialize($r->post_edit); $eidx = 0; foreach ($edits as $e) { $t[$tidx]->posts[$pidx]->edits[$eidx] = new stdClass(); $t[$tidx]->posts[$pidx]->edits[$eidx]->by = $e['by']; $t[$tidx]->posts[$pidx]->edits[$eidx]->at = $e['at']; $eidx++; } } if (!in_array($r->user_id, $u)) { $u[] = $r->user_id; } $t[$tidx]->posts[$pidx] = apply_filters('sph_topicview_post_records', $t[$tidx]->posts[$pidx], $r); } # index of post IDs with position in listing $t[$tidx]->post_keys = $p; $t[$tidx]->posts[$pidx]->last_post = $lastpage; $t[$tidx]->posts[$pidx]->last_post_on_page = 1; # save last post on page id $t[$tidx]->last_post_id = $r->post_id; # allow plugins to add more data to combined topic/post data structure $t[$tidx] = apply_filters('sph_topicview_combined_data', $t[$tidx], $p, $u); unset($records); } else { # check for view forum lists but not topic lists if (sp_can_view($r->forum_id, 'forum-title')) { $this->topicViewStatus = 'sneak peek'; } } } return $t; }
echo '<ul class="memberlist">'; for ($x = 0; $x < count($users); $x++) { echo '<li>' . sp_filter_name_display($users[$x]) . '</li>'; } echo '</ul>'; } else { spa_etext('No users with this special rank'); } echo '</fieldset>'; } if ($action == 'delsmiley') { $file = sp_esc_str($_GET['file']); $path = SF_STORE_DIR . '/' . $spPaths['smileys'] . '/' . $file; @unlink($path); # load smiles from sfmeta $meta = sp_get_sfmeta('smileys', 'smileys'); # now cycle through to remove this entry and resave if (!empty($meta[0]['meta_value'])) { $newsmileys = array(); foreach ($meta[0]['meta_value'] as $name => $info) { if ($info[0] != $file) { $newsmileys[$name][0] = sp_filter_title_save($info[0]); $newsmileys[$name][1] = sp_filter_name_save($info[1]); $newsmileys[$name][2] = sp_filter_name_save($info[2]); $newsmileys[$name][3] = $info[3]; $newsmileys[$name][4] = $info[4]; } } sp_update_sfmeta('smileys', 'smileys', $newsmileys, $meta[0]['meta_id'], true); } echo '1';
$batchSQL = sp_esc_int($_GET['batchNum']); $where = ' WHERE admin=0'; if ($_GET['ignoremods']) { $where .= ' AND moderator=0'; } $users = spdb_select('col', 'SELECT user_id FROM ' . SFMEMBERS . $where . ' ORDER BY user_id LIMIT ' . $startSQL . ', ' . $batchSQL); if ($users) { $value = sp_get_sfmeta('default usergroup', 'sfmembers'); $defaultUG = $value[0]['meta_value']; foreach ($users as $thisUser) { if ($_GET['mapoption'] == 2) { spdb_query('DELETE FROM ' . SFMEMBERSHIPS . ' WHERE user_id=' . $thisUser); } $user = new WP_User($thisUser); if (!empty($user->roles) && is_array($user->roles)) { foreach ($user->roles as $role) { $value = sp_get_sfmeta('default usergroup', $role); if (!empty($value)) { $ug = $value[0]['meta_value']; } else { $ug = $defaultUG; } sp_add_membership($ug, $thisUser); } } } # clean up sp_reset_memberships(); sp_reset_auths(); } die;
function sp_get_forum_memberships() { global $spThisUser; if ($spThisUser->admin) { $sql = 'SELECT forum_id FROM ' . SFFORUMS; } else { if ($spThisUser->guest) { $value = sp_get_sfmeta('default usergroup', 'sfguests'); $sql = 'SELECT forum_id FROM ' . SFPERMISSIONS . " WHERE usergroup_id={$value[0]['meta_value']}"; } else { $sql = 'SELECT forum_id FROM ' . SFPERMISSIONS . ' JOIN ' . SFMEMBERSHIPS . ' ON ' . SFPERMISSIONS . '.usergroup_id = ' . SFMEMBERSHIPS . '.usergroup_id WHERE user_id=' . $spThisUser->ID; } } $forums = spdb_select('set', $sql); $fids = array(); if ($forums) { foreach ($forums as $thisForum) { if (sp_get_auth('view_forum', $thisForum->forum_id) || sp_get_auth('view_forum_lists', $thisForum->forum_id) || sp_get_auth('view_forum_topic_lists', $thisForum->forum_id)) { $fids[] = $thisForum->forum_id; } } } return $fids; }
function spa_usergroups_map_users() { ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('#sfmapsettingsform').ajaxForm({ target: '#sfmsgspot', success: function() { jQuery('#sfreloadmu').click(); jQuery('#sfmsgspot').fadeIn(); jQuery('#sfmsgspot').fadeOut(6000); } }); jQuery('#sfmapusersform').ajaxForm({ target: '#sfmsgspot', }); }); </script> <?php global $wp_roles; $sfoptions = spa_get_mapping_data(); $ahahURL = SFHOMEURL . 'index.php?sp_ahah=usergroups-loader&sfnonce=' . wp_create_nonce('forum-ahah') . '&saveform=mapsettings'; ?> <form action="<?php echo $ahahURL; ?> " method="post" id="sfmapsettingsform" name="sfmapsettingsform"> <?php echo sp_create_nonce('forum-adminform_mapusers'); spa_paint_options_init(); spa_paint_open_tab(spa_text('User Groups') . ' - ' . spa_text('User Mapping Settings'), true); spa_paint_open_panel(); spa_paint_open_fieldset(spa_text('User Memberships'), true, 'user-memberships'); echo '<tr><td colspan="2"><br /><div class="sfoptionerror">'; spa_etext('Warning: Use caution when setting the single usergroup membership option below. It should primarily be used in conjunction with a membership plugin (such as Wishlist) where strict usergroup membership is required. Please note that auto usergroup membership by WP role or by forum rank may conflict or overwrite any manual usergroup memberships (such as moderator) you may set if you have single usergroup membership set'); echo '</div><br />'; echo '</td></tr>'; spa_paint_checkbox(spa_text('Users are limited to single usergroup membership'), 'sfsinglemembership', $sfoptions['sfsinglemembership']); echo '<tr><td colspan="2"><p class="subhead">' . spa_text('Default usergroup membership') . ':</p></td></tr>'; spa_paint_select_start(spa_text('Default usergroup for guests'), 'sfguestsgroup', 'sfguestsgroup'); echo spa_create_usergroup_select($sfoptions['sfguestsgroup']); spa_paint_select_end(); spa_paint_select_start(spa_text('Default usergroup for new members'), 'sfdefgroup', 'sfdefgroup'); echo spa_create_usergroup_select($sfoptions['sfdefgroup']); spa_paint_select_end(); $roles = array_keys($wp_roles->role_names); if ($roles) { echo '<tr><td colspan="2"><p class="subhead">' . spa_text('Usergroup memberships based on WP role') . ':</p></td></tr>'; $sfoptions['role'] = array(); foreach ($roles as $index => $role) { $value = sp_get_sfmeta('default usergroup', $role); if ($value) { $group = $value[0]['meta_value']; } else { $group = $sfoptions['sfdefgroup']; } echo '<input type="hidden" class="sfhiddeninput" name="sfoldrole[' . $index . ']" value="' . $group . '" />'; spa_paint_select_start(spa_text('Default usergroup for') . ' ' . $role, "sfrole[{$index}]", 'sfguestsgroup'); echo spa_create_usergroup_select($group); spa_paint_select_end(); } } spa_paint_close_fieldset(); spa_paint_close_panel(); do_action('sph_usergroups_mapping_settings_panel'); spa_paint_close_container(); ?> <div class="sfform-submit-bar"> <input type="submit" class="button-primary" id="saveit" name="saveit" value="<?php spa_etext('Update Mapping Settings'); ?> " /> </div> </form> <?php spa_paint_close_tab(); ?> <div class="sfform-panel-spacer"></div> <?php $ahahURL = SFHOMEURL . 'index.php?sp_ahah=usergroups-loader&sfnonce=' . wp_create_nonce('forum-ahah') . '&saveform=mapusers'; $uCount = spdb_count(SFMEMBERS); $url = SFHOMEURL . 'index.php?sp_ahah=usermapping&sfnonce=' . wp_create_nonce('forum-ahah'); $target = 'sfmsgspot'; $smessage = esc_js(spa_text('Please Wait - Processing')); $emessage = $uCount . ' ' . esc_js(spa_text('Users mapped')); ?> <form action="<?php echo $ahahURL; ?> " method="post" id="sfmapusersform" name="sfmapusersform" onsubmit="spjBatch('sfmapusersform', '<?php echo $url; ?> ', '<?php echo $target; ?> ', '<?php echo $smessage; ?> ', '<?php echo $emessage; ?> ', 0, 500, <?php echo $uCount; ?> );"> <?php echo sp_create_nonce('forum-adminform_mapusers'); spa_paint_options_init(); spa_paint_open_tab(spa_text('User Groups') . ' - ' . spa_text('Map Users'), true); spa_paint_open_panel(); spa_paint_open_fieldset(spa_text('Map Users'), true, 'map-users'); echo '<tr><td colspan="2"><br /><div class="sfoptionerror">'; spa_etext("Warning: Use caution when mapping users. This will adjust your user's memberships in User Groups. Choose the criteria and options carefully. The mapping cannot be undone except by remapping or manual process. Also, make sure you have saved your mapping settings above before mapping as they are two distinct actions."); echo '</div><br />'; echo '</td></tr>'; $values = array(spa_text('Add user membership based on WP role to existing memberships'), spa_text('Replace all user memberships with a single membership based on WP role')); spa_paint_radiogroup(spa_text('Select mapping criteria'), 'mapoption', $values, 2, false, true); spa_paint_checkbox(spa_text('Ignore current SP Moderators when mapping'), 'ignoremods', true); spa_paint_close_fieldset(); spa_paint_close_panel(); do_action('sph_usergroups_map_users_panel'); spa_paint_close_container(); ?> <div class="sfform-submit-bar"> <span><input type="submit" class="button-primary" id="saveit2" name="saveit2" value="<?php spa_etext('Map Users'); ?> " /> <span class="button sfhidden" id='onFinish'></span></span> <br /> <div class="pbar" id="progressbar"></div> </div> </form> <?php spa_paint_close_tab(); }
function sp_do_sp_FeaturedPostsTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } $defs = array('tagId' => 'spFeaturedPostsTag', 'tagClass' => 'spListTag', 'listId' => 'spListItemTag%ID%', 'listClass' => 'spListItemTag', 'linkClass' => 'spLinkTag', 'textClass' => 'spTextTag', 'avatarClass' => 'spAvatarTag', 'listTags' => 1, 'postIds' => '', 'limit' => 5, 'itemOrder' => 'FTUD', 'linkScope' => 'forum', 'beforeForum' => __('Forum: ', 'sp-featured'), 'afterForum' => '<br />', 'beforeTopic' => __('Topic: ', 'sp-featured'), 'afterTopic' => '<br />', 'beforeUser' => __('By: ', 'sp-featured'), 'afterUser' => '', 'beforeDate' => ' -', 'afterDate' => '<br />', 'avatarSize' => 25, 'niceDate' => 1, 'postTip' => 1, 'beforePost' => __('Post: ', 'sp-featured'), 'afterPost' => '<br />', 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_FeaturedPostsTag_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $listClass = esc_attr($listClass); $listId = esc_attr($listId); $linkClass = esc_attr($linkClass); $textClass = esc_attr($textClass); $avatarClass = esc_attr($avatarClass); $listTags = (int) $listTags; $postIds = esc_attr($postIds); $limit = (int) $limit; $itemOrder = esc_attr($itemOrder); $linkScope = esc_attr($linkScope); $beforeForum = sp_filter_title_display($beforeForum); $afterForum = sp_filter_title_display($afterForum); $beforeTopic = sp_filter_title_display($beforeTopic); $afterTopic = sp_filter_title_display($afterTopic); $beforeUser = sp_filter_title_display($beforeUser); $afterUser = sp_filter_title_display($afterUser); $beforeDate = sp_filter_title_display($beforeDate); $afterDate = sp_filter_title_display($afterDate); $avatarSize = (int) $avatarSize; $niceDate = (int) $niceDate; $postTip = (int) $postTip; $beforePost = sp_filter_title_display($beforePost); $afterPst = sp_filter_title_display($afterPost); $echo = (int) $echo; sp_forum_api_support(); global $spPostList, $spThisPostList; # do we have post ids specified? if (empty($postIds)) { $posts = sp_get_sfmeta('featured', 'posts'); $postIds = implode(',', $posts[0]['meta_value']); } $where = SFPOSTS . '.post_id IN (' . $postIds . ')'; $spPostList = new spPostList($where, SFPOSTS . '.post_id DESC', $limit); if (empty($spPostList)) { return; } if (!empty($beforeForum)) { $beforeForum = trim($beforeForum) . ' '; } if (!empty($beforeTopic)) { $beforeTopic = trim($beforeTopic) . ' '; } if (!empty($beforeUser)) { $beforeUser = trim($beforeUser) . ' '; } if (!empty($beforeDate)) { $beforeDate = trim($beforeDate) . ' '; } if (!empty($afterForum)) { $afterForum = ' ' . trim($afterForum); } if (!empty($afterTopic)) { $afterTopic = ' ' . trim($afterTopic); } if (!empty($afterUser)) { $afterUser = '******' . trim($afterUser); } if (!empty($afterDate)) { $afterDate = ' ' . trim($afterDate); } $fLink = $tLink = $aLink = false; if ($linkScope == 'forum') { $fLink = $tLink = true; } if ($linkScope == 'all') { $aLink = true; } # Start building dislay if ($listTags ? $out = "<ul id='{$tagId}' class='{$tagClass}'>" : ($out = "<div id='{$tagId}' class='{$tagClass}'>")) { } # start the loop if (sp_has_postlist()) { while (sp_loop_postlist()) { sp_the_postlist(); $thisId = str_ireplace('%ID%', $spThisPostList->topic_id, $listId); if ($listTags ? $out .= "<li id='{$thisId}' class='{$listClass}'>" : ($out .= "<div id='{$thisId}' class='{$listClass}'>")) { } $title = $postTip ? "title='{$spThisPostList->post_tip}'" : ''; if ($aLink) { $out .= "<a class='{$linkClass}' {$title} href='{$spThisPostList->post_permalink}'>"; } for ($x = 0; $x < strlen($itemOrder); $x++) { switch (substr($itemOrder, $x, 1)) { case 'F': # Forum $out .= $beforeForum; if ($fLink) { $out .= "<a class='{$linkClass}' href='{$spThisPostList->forum_permalink}'>"; } $out .= $spThisPostList->forum_name; if ($fLink) { $out .= '</a>'; } $out .= $afterForum; break; case 'T': # Topic $out .= $beforeTopic; if ($tLink) { $out .= "<a class='{$linkClass}' {$title} href='{$spThisPostList->post_permalink}'>"; } $out .= $spThisPostList->topic_name; if ($tLink) { $out .= '</a>'; } $out .= $afterTopic; break; case 'P': # Post $out .= $beforePost; $out .= $spThisPostList->post_content; $out .= $afterPost; break; case 'E': # Excerpt $out .= $beforePost; $out .= $spThisPostList->post_tip; $out .= $afterPost; break; case 'A': # Avatar $thisUser = sp_get_user($spThisPostList->user_id); $spx = $avatarSize + 10 . 'px'; $out .= sp_UserAvatar("tagClass={$avatarClass}&size={$avatarSize}&link=none&context=user&echo=0", $thisUser); break; case 'U': # user $out .= "<span class='{$textClass}'>{$spThisPostList->display_name}{$afterUser}</span>"; break; case 'D': # date if ($niceDate) { $out .= "<span class='{$textClass}'>" . $beforeDate . sp_nicedate($spThisPostList->post_date) . "{$afterDate}</span>\n"; } else { $out .= "<span class='{$textClass}'>" . $beforeDate . sp_date('d', $spThisPostList->post_date) . "{$afterDate}</span>\n"; } break; default: # Invalid code $out .= '<br />' . __('Invalid Tag Code Found', 'sp-featured') . '<br />'; break; } } if ($aLink) { $out .= '</a>'; } if ($listTags ? $out .= '</li>' : ($out .= '</div>')) { } } } if ($listTags ? $out .= '</ul>' : ($out .= '</div>')) { } $out = apply_filters('sph_FeaturedPostsTag', $out); if ($echo) { echo $out; } else { return $out; } }
function sp_cron_check_news() { $url = 'http://simple-press.com/downloads/simple-press/simple-press-news.xml'; $response = wp_remote_get($url, array('timeout' => 5)); if (is_wp_error($response) || wp_remote_retrieve_response_code($response) != 200) { return; } $body = wp_remote_retrieve_body($response); if (!$body) { return; } $newNews = new SimpleXMLElement($body); if ($newNews) { $data = sp_get_sfmeta('news', 'news'); $cur_id = !empty($data[0]['meta_value']) ? $data[0]['meta_value']['id'] : -999; if ($newNews->news->id != $cur_id) { $curNews = array(); $curNews['id'] = (string) $newNews->news->id; $curNews['show'] = 1; $curNews['news'] = addslashes_gpc((string) $newNews->news[0]->message); sp_add_sfmeta('news', 'news', $curNews, 0); } } }
function sp_profile_get_tabs() { $profile = sp_get_sfmeta('profile', array()); $tabs = !empty($profile) ? $profile[0]['meta_value'] : ''; return $tabs; }
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']) ? '&msearch=' . sp_esc_str($_POST['msearch']) : ''; $search = !empty($_GET['msearch']) ? '&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; $guestUG = sp_get_sfmeta('default usergroup', 'sfguests'); $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) { if ($usergroup['usergroup_id'] != $guestUG[0]['meta_value']) { $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; } }
<?php /* Simple:Press Admin General Ahah file $LastChangedDate: 2012-11-18 10:04:10 -0800 (Sun, 18 Nov 2012) $ $Rev: 9312 $ */ if (preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('Access denied - you cannot directly call this file'); } spa_admin_ahah_support(); if (isset($_GET['action']) && $_GET['action'] == 'news') { $news = sp_get_sfmeta('news', 'news'); if (!empty($news)) { $news[0]['meta_value']['show'] = 0; sp_update_sfmeta('news', 'news', $news[0]['meta_value'], $news[0]['meta_id'], 0); } } die;
function spa_save_housekeeping_data() { check_admin_referer('forum-adminform_housekeeping', 'forum-adminform_housekeeping'); $mess = ''; if (isset($_POST['rebuild-fidx'])) { $forumid = $_POST['forum_id']; if (is_numeric($forumid)) { $topics = spdb_table(SFTOPICS, "forum_id={$forumid}"); if ($topics) { include_once SF_PLUGIN_DIR . '/forum/database/sp-db-management.php'; foreach ($topics as $topic) { sp_build_post_index($topic->topic_id); } # after reubuilding post indexes, rebuild the forum indexes sp_build_forum_index($forumid); do_action('sph_toolbox_housekeeping_forum_index'); $mess = spa_text('Forum indexes rebuilt'); } else { $mess = spa_text('Forum index rebuild failed - no topics in selected forum'); } } else { $mess = spa_text('Forum index rebuild failed - no forum selected'); } } if (isset($_POST['transient-cleanup'])) { include_once SF_PLUGIN_DIR . '/forum/database/sp-db-management.php'; sp_transient_cleanup(); do_action('sph_toolbox_housekeeping_transient'); $mess = spa_text('WP transients cleaned'); } if (isset($_POST['clean-newposts'])) { $days = isset($_POST['sfdays']) ? max(sp_esc_int($_POST['sfdays']), 0) : 30; $users = spdb_select('col', "SELECT user_id FROM " . SFMEMBERS . " WHERE lastvisit < DATE_SUB(CURDATE(), INTERVAL " . $days . " DAY)"); if ($users) { foreach ($users as $user) { spdb_query('UPDATE ' . SFMEMBERS . " SET newposts='a:1:{i:0;i:0;}' WHERE user_id={$user}"); } } do_action('sph_toolbox_housekeeping_newpost'); $mess = spa_text('New posts lists cleaned'); } if (isset($_POST['postcount-cleanup'])) { spdb_query('UPDATE ' . SFMEMBERS . ' SET posts = (SELECT COUNT(*) FROM ' . SFPOSTS . ' WHERE ' . SFPOSTS . '.user_id = ' . SFMEMBERS . '.user_id)'); # force stats to update do_action('sph_stats_cron'); do_action('sph_toolbox_housekeeping_postcount'); $mess = spa_text('User post counts calculated'); } if (isset($_POST['reset-tabs'])) { # clear out current tabs $tabs = sp_get_sfmeta('profile', 'tabs'); sp_delete_sfmeta($tabs[0]['meta_id']); # start adding new ones spa_new_profile_setup(); do_action('sph_toolbox_housekeeping_profile_tabs'); $mess = spa_text('Profile tabs reset'); } if (isset($_POST['reset-auths'])) { sp_reset_auths(); do_action('sph_toolbox_housekeeping_auths'); $mess = spa_text('Auths caches cleaned'); } if (isset($_POST['reset-plugin-data'])) { sp_reset_member_plugindata(); do_action('sph_toolbox_housekeeping_plugindata'); $mess = spa_text('Users Plugin Data reset'); } if (isset($_POST['reset-combinedcss'])) { sp_clear_combined_css('all'); sp_clear_combined_css('mobile'); sp_clear_combined_css('tablet'); do_action('sph_toolbox_housekeeping_ccombined_css'); $mess = spa_text('Combined CSS cache file removed'); } if (isset($_POST['reset-combinedjs'])) { sp_clear_combined_scripts('desktop'); sp_clear_combined_scripts('mobile'); sp_clear_combined_scripts('tablet'); do_action('sph_toolbox_housekeeping_combined_js'); $mess = spa_text('Combined scripts cache files removed'); } if (isset($_POST['flushcache'])) { sp_flush_cache('all'); do_action('sph_toolbox_housekeeping_flush_cache'); $mess = spa_text('General cache flushed'); } do_action('sph_toolbox_housekeeping_save'); return $mess; }
function sp_convert_ranks() { spdb_query('ALTER TABLE ' . SFMEMBERS . ' ADD (special_ranks text default NULL)'); # convert special rank users to new column in sfmembers $special_rankings = sp_get_sfmeta('special_rank'); if ($special_rankings) { foreach ($special_rankings as $rank) { if (empty($rank['meta_value']['users'])) { continue; } $users = $rank['meta_value']['users']; foreach ($users as $user) { $memberData = sp_get_member_item($user, 'special_ranks'); $memberData[] = $rank['meta_key']; sp_update_member_item($user, 'special_ranks', $memberData); } unset($rank['meta_value']['users']); sp_update_sfmeta('special_rank', $rank['meta_key'], $rank['meta_value'], $rank['meta_id'], 1); } } }
function spa_check_warnings() { global $spGlobals; # not perfect but we can use this call tyo perform any minor # cleanups that may be necessary... so # drop any existing temp members table... spdb_query('DROP TABLE IF EXISTS sftempmembers'); $mess = ''; # check if sp core, plugins or themes update available $update = false; $update_msg = ''; $up = get_site_transient('update_plugins'); if (!empty($up->response)) { foreach ($up->response as $plugin) { if ($plugin->slug == 'simple-press') { $msg = apply_filters('sph_core_update_notice', spa_text('There is a Simple:Press core update available.')); if (!empty($msg)) { $update = true; $update_msg .= $msg . '<br />'; } break; } } } $up = get_site_transient('sp_update_plugins'); if (!empty($up)) { $msg = apply_filters('sph_plugins_update_notice', spa_text('There is one or more Simple:Press plugin updates available')); if (!empty($msg)) { $update = true; $update_msg .= $msg . '<br />'; } } $up = get_site_transient('sp_update_themes'); if (!empty($up)) { $msg = apply_filters('sph_themes_update_notice', spa_text('There is one or more Simple:Press theme updates available')); if (!empty($msg)) { $update = true; $update_msg .= $msg . '<br />'; } } if ($update) { if (is_main_site()) { $mess .= apply_filters('sph_updates_notice', spa_message($update_msg . '<a href="' . self_admin_url('update-core.php') . '">' . spa_text('Click here to view any updates.') . '</a>')); } else { $mess .= apply_filters('sph_updates_notice', spa_message(spa_text('There are some Simple:Press updates avaialable. You may want to notify the network site admin.'))); } } # output warning if no SPF admins are defined $a = $spGlobals['forum-admins']; if (empty($a)) { $mess .= spa_message(spa_text('Warning - There are no SPF admins defined! All WP admins now have SP backend access'), 'error'); } # Check if desktop, tablet and mobile themes are selected and available $cur = sp_get_option('sp_current_theme'); if (empty($cur)) { $mess .= spa_message(spa_text('No main theme has been selected and SP will be unable to display correctly. Please select a theme from the Themes panel'), 'error'); } else { $nostylesheet = !file_exists(SPTHEMEBASEDIR . $cur['theme'] . '/styles/' . $cur['style']); $nooverlay = !empty($cur['color']) && !file_exists(SPTHEMEBASEDIR . $cur['theme'] . '/styles/overlays/' . $cur['color'] . '.php'); $nopoverlay = !empty($cur['color']) && !empty($cur['parent']) && !file_exists(SPTHEMEBASEDIR . $cur['parent'] . '/styles/overlays/' . $cur['color'] . '.php'); if ($nostylesheet || $nooverlay && $nopoverlay) { $mess .= spa_message(spa_text('Either the theme CSS file and/or color Overlay file from the selected theme is missing'), 'error'); } } $mobile = sp_get_option('sp_mobile_theme'); if (!empty($mobile) && $mobile['active']) { $nostylesheet = !file_exists(SPTHEMEBASEDIR . $mobile['theme'] . '/styles/' . $mobile['style']); $nooverlay = !empty($mobile['color']) && !file_exists(SPTHEMEBASEDIR . $mobile['theme'] . '/styles/overlays/' . $mobile['color'] . '.php'); $nopoverlay = !empty($mobile['color']) && !empty($mobile['parent']) && !file_exists(SPTHEMEBASEDIR . $mobile['parent'] . '/styles/overlays/' . $mobile['color'] . '.php'); if ($nostylesheet || $nooverlay && $nopoverlay) { $mess .= spa_message(spa_text('Either the mobile theme CSS file and/or color Overlay file from the selected mobile theme is missing'), 'error'); } } $tablet = sp_get_option('sp_tablet_theme'); if (!empty($tablet) && $tablet['active']) { $nostylesheet = !file_exists(SPTHEMEBASEDIR . $tablet['theme'] . '/styles/' . $tablet['style']); $nooverlay = !empty($tablet['color']) && !file_exists(SPTHEMEBASEDIR . $tablet['theme'] . '/styles/overlays/' . $tablet['color'] . '.php'); $nopoverlay = !empty($tablet['color']) && !empty($tablet['parent']) && !file_exists(SPTHEMEBASEDIR . $tablet['parent'] . '/styles/overlays/' . $tablet['color'] . '.php'); if ($nostylesheet || $nooverlay && $nopoverlay) { $mess .= spa_message(spa_text('Either the tablet theme CSS file and/or color Overlay file from the selected tablet theme is missing'), 'error'); } } # check for missing default members user group $value = sp_get_sfmeta('default usergroup', 'sfmembers'); $ugid = spdb_table(SFUSERGROUPS, "usergroup_id={$value[0]['meta_value']}", 'usergroup_id'); if (empty($ugid)) { $mess .= spa_message(spa_text('Warning - The default user group for new members is undefined! Please visit the SP usergroups admin page, map users to usergroups tab and set the default user group'), 'error'); } # check for missing default guest user group $value = sp_get_sfmeta('default usergroup', 'sfguests'); $ugid = spdb_table(SFUSERGROUPS, "usergroup_id={$value[0]['meta_value']}", 'usergroup_id'); if (empty($ugid)) { $mess .= spa_message(spa_text('Warning - The default user group for guests is undefined! Please visit the SP usergroups admin page, map users to usergroups tab and set the default user group'), 'error'); } # check for unreachable forums because of permissions $usergroups = spdb_table(SFUSERGROUPS); if ($usergroups) { $has_members = false; foreach ($usergroups as $usergroup) { $members = spdb_table(SFMEMBERSHIPS, "usergroup_id={$usergroup->usergroup_id}", 'row', '', '1'); if ($members || $usergroup->usergroup_id == $value[0]['meta_value']) { $has_members = true; break; } } if (!$has_members) { $mess .= spa_message(spa_text('Warning - There are no usergroups that have members! All forums may only be visible to SP admins'), 'error'); } } else { $mess .= spa_message(spa_text('Warning - There are no usergroups defined! All forums may only be visible to SP admins'), 'error'); } $roles = sp_get_all_roles(); if (!$roles) { $mess .= spa_message(spa_text('Warning - There are no permission sets defined! All forums may only be visible to SP admins'), 'error'); } # check if compatible with wp super cache if (function_exists('wp_cache_edit_rejected')) { global $cache_rejected_uri; $slug = '/' . sp_get_option('sfslug') . '/'; if (isset($cache_rejected_uri)) { $found = false; foreach ($cache_rejected_uri as $value) { if ($value == $slug) { $found = true; break; } } if (!$found) { $string = spa_text('WP Super Cache is not properly configured to work with Simple:Press. Please visit your WP Super Cache settings page and in the accepted filenames & rejected URIs section for the pages not to be cached input field, add the following string'); $string .= ':</p><p><em>' . $slug . '</em></p><p>'; $string .= spa_text('Then, please clear your WP Super Cache cache to remove any cached Simple:Press pages'); $string .= ':</p><p><em>' . spa_text('For more information please see this') . ' <a href="http://simple-press.com/documentation/codex/faq/troubleshooting/forum-displays-wrong-information/" target="_blank">' . spa_text('FAQ') . '</a></p><p>'; $mess .= spa_message($string, 'error'); } } } # check if compatible with w3 total cache (at leasst check for slug $f = WP_CONTENT_DIR . '/cache/config/master.php'; if (file_exists($f) && is_readable($f)) { $c = file_get_contents($f); $c = substr($c, 13); $config = @unserialize($c); if (key_exists('pgcache.reject.uri', $config) && !empty($config['pgcache.reject.uri'])) { $found = false; $slug = '/' . sp_get_option('sfslug') . '/'; foreach ($config['pgcache.reject.uri'] as $i) { if ($i == $slug) { $found = true; break; } } if (!$found) { $string = spa_text('W3 Total Cache is not properly configured to work with Simple:Press. Please visit your W3 Total Cache settings page and in the accepted filenames & rejected URIs in ALL sections, add the following string'); $string .= ':</p><p><em>' . $slug . '</em></p><p>'; $string .= spa_text('Then, please clear your W3 Total Cache cache to remove any cached Simple:Press pages'); $string .= ':</p><p><em>' . spa_text('For more information please see this') . ' <a href="http://simple-press.com/documentation/codex/faq/troubleshooting/forum-displays-wrong-information/" target="_blank">' . spa_text('FAQ') . '</a></p><p>'; $mess .= spa_message($string, 'error'); } } } # check for server-side UTC timezone $tz = get_option('timezone_string'); if (empty($tz)) { $tz = 'UTC ' . get_option('gmt_offset'); $string = spa_text('You have set your server to use a UTC timezone setting'); $string .= ':</p><p><em>' . $tz . '</em></p><p>'; $string .= spa_text('UTC can give unpredictable results on forum post time stamps. Please select the city setting nearest to you in the WordPress - Settings - General admin page'); $string .= ':</p><p><em>' . spa_text('For more information please see this') . ' <a href="http://simple-press.com/documentation/codex/faq/troubleshooting/why-do-my-new-posts-show-as-posted-minus-seconds-ago/" target="_blank">' . spa_text('FAQ') . '</a></p><p>'; $mess .= spa_message($string, 'error'); } if ($mess != '') { return $mess; } }
function spa_forums_check_memberships($forums) { $value = sp_get_sfmeta('default usergroup', 'sfguests'); $ugid = spdb_table(SFUSERGROUPS, "usergroup_id={$value[0]['meta_value']}", 'usergroup_id'); if (empty($ugid)) { $ugid = 0; } $noMembers = array(); foreach ($forums as $forum) { $has_members = false; $permissions = sp_get_forum_permissions($forum->forum_id); if ($permissions) { foreach ($permissions as $permission) { $members = spdb_table(SFMEMBERSHIPS, "usergroup_id= {$permission->usergroup_id}", 'row', '', '1'); if ($members || $permission->usergroup_id == $ugid) { $has_members = true; break; } } } if (!$has_members) { $noMembers[] = $forum->forum_id; } } return $noMembers; }
function spa_prepare_msbox_list($msbox, $uid) { # drop any existing temp table tp start afresh spdb_query('DROP TABLE IF EXISTS sftempmembers'); switch ($msbox) { case 'usergroup_add': $records = spdb_query('CREATE TABLE sftempmembers AS SELECT DISTINCT ' . SFMEMBERS . '.user_id, ' . SFMEMBERS . '.display_name FROM ' . SFMEMBERSHIPS . ' RIGHT JOIN ' . SFMEMBERS . ' ON ' . SFMEMBERS . '.user_id = ' . SFMEMBERSHIPS . '.user_id WHERE (usergroup_id != ' . $uid . ' AND admin = 0) OR (' . SFMEMBERSHIPS . '.user_id IS NULL AND admin = 0) ORDER BY display_name'); break; case 'usergroup_del': $records = spdb_query('CREATE TABLE sftempmembers AS SELECT DISTINCT ' . SFMEMBERS . '.user_id, ' . SFMEMBERS . '.display_name FROM ' . SFMEMBERSHIPS . ' JOIN ' . SFMEMBERS . ' ON ' . SFMEMBERS . '.user_id = ' . SFMEMBERSHIPS . '.user_id WHERE ' . SFMEMBERSHIPS . '.usergroup_id=' . $uid . ' ORDER BY display_name'); break; case 'rank_add': $specialRank = sp_get_sfmeta('special_rank', false, $uid); $rank = $specialRank[0]['meta_key']; $records = spdb_query('CREATE TABLE sftempmembers AS SELECT DISTINCT ' . SFMEMBERS . '.user_id, ' . SFMEMBERS . '.display_name FROM ' . SFSPECIALRANKS . ' RIGHT JOIN ' . SFMEMBERS . ' ON ' . SFMEMBERS . '.user_id = ' . SFSPECIALRANKS . '.user_id WHERE (special_rank != "' . $rank . '") OR (' . SFSPECIALRANKS . '.user_id IS NULL) ORDER BY display_name'); break; case 'rank_del': $specialRank = sp_get_sfmeta('special_rank', false, $uid); $rank = $specialRank[0]['meta_key']; $records = spdb_query('CREATE TABLE sftempmembers AS SELECT DISTINCT ' . SFMEMBERS . '.user_id, ' . SFMEMBERS . '.display_name FROM ' . SFSPECIALRANKS . ' RIGHT JOIN ' . SFMEMBERS . ' ON ' . SFMEMBERS . '.user_id = ' . SFSPECIALRANKS . '.user_id WHERE (special_rank = "' . $rank . '") ORDER BY display_name'); break; case 'admin_add': $records = spdb_query('CREATE TABLE sftempmembers AS SELECT ' . SFMEMBERS . '.user_id, display_name FROM ' . SFMEMBERS . ' WHERE admin=0 ORDER BY display_name'); break; } }
function spa_save_messages_data() { check_admin_referer('forum-adminform_messages', 'forum-adminform_messages'); # custom message for editor $sfpostmsg = array(); $sfpostmsg['sfpostmsgtext'] = sp_filter_text_save(trim($_POST['sfpostmsgtext'])); $sfpostmsg['sfpostmsgtopic'] = isset($_POST['sfpostmsgtopic']); $sfpostmsg['sfpostmsgpost'] = isset($_POST['sfpostmsgpost']); sp_update_option('sfpostmsg', $sfpostmsg); sp_update_option('sfeditormsg', sp_filter_text_save(trim($_POST['sfeditormsg']))); # if set update, otherwise its empty, so remove if ($_POST['sfsneakpeek'] != '') { sp_add_sfmeta('sneakpeek', 'message', sp_filter_text_save(trim($_POST['sfsneakpeek']))); } else { $msg = sp_get_sfmeta('sneakpeek', 'message'); if (!empty($msg)) { sp_delete_sfmeta($msg[0]['meta_id']); } } $sflogin = array(); $sflogin = sp_get_option('sflogin'); $sflogin['sfsneakredirect'] = sp_filter_save_cleanurl($_POST['sfsneakredirect']); sp_update_option('sflogin', $sflogin); # if set update, otherwise its empty, so remove if ($_POST['sfadminview'] != '') { sp_add_sfmeta('adminview', 'message', sp_filter_text_save(trim($_POST['sfadminview']))); } else { $msg = sp_get_sfmeta('adminview', 'message'); if (!empty($msg)) { sp_delete_sfmeta($msg[0]['meta_id']); } } # if set update, otherwise its empty, so remove if ($_POST['sfuserview'] != '') { sp_add_sfmeta('userview', 'message', sp_filter_text_save(trim($_POST['sfuserview']))); } else { $msg = sp_get_sfmeta('userview', 'message'); if (!empty($msg)) { sp_delete_sfmeta($msg[0]['meta_id']); } } do_action('sph_component_messages_save'); $mess = spa_text('Custom messages updated'); return $mess; }
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; } }
function spa_paint_custom_smileys() { global $spPaths, $tab; $scount = -1; # load smiles from sfmeta $filelist = array(); $meta = sp_get_sfmeta('smileys', 'smileys'); $smeta = $meta[0]['meta_value']; # Open forum-smileys folder and get cntents for matching $path = SF_STORE_DIR . '/' . $spPaths['smileys'] . '/'; $dlist = @opendir($path); if (!$dlist) { echo '<table><tr><td class="sflabel"><strong>' . spa_text('The forum-smileys folder does not exist') . '</strong></td></tr></table>'; return; } # start the table display echo '<table id="sfsmileytable" class="wp-list-table widefat">'; $row = 0; # gather the file data while (false !== ($file = readdir($dlist))) { $path_info = pathinfo($path . $file); $ext = strtolower($path_info['extension']); if ($file != '.' && $file != '..' && ($ext == 'jpg' || $ext == 'jpeg' || $ext == 'png' || $ext == 'gif' || $ext == 'bmp')) { $filelist[] = $file; } } # now to sort them if required $newfiles = count($filelist) + 1; $sortlist = array(); if ($filelist) { foreach ($filelist as $file) { $found = false; if ($meta[0]['meta_value']) { foreach ($meta[0]['meta_value'] as $name => $info) { if ($info[0] == $file) { $found = true; break; } } } if ($found) { if (isset($info[3])) { $sortlist[$info[3]] = $file; } else { $sortlist[] = $file; } } else { $sortlist[$newfiles] = $file; $newfiles++; } } ksort($sortlist); } if ($sortlist) { foreach ($sortlist as $file) { $found = false; echo '<tr id="smiley' . $row . '">'; $row++; if ($meta[0]['meta_value']) { foreach ($meta[0]['meta_value'] as $name => $info) { if ($info[0] == $file) { $found = true; break; } } } if (!$found) { $sname = str_replace('.', '_', $file); $code = str_replace('.', '_', $file); $in_use = false; $break = false; } else { $code = stripslashes($info[1]); $sname = $name; $in_use = $info[2]; $break = isset($info[4]) ? $info[4] : false; } $scount++; # drag handle cell echo '<td class="dragHandle" style="text-align:center;width:2%">'; echo '<img class="spSmiley" src="' . SFSMILEYS . $file . '" alt="" />'; echo '</td>'; # image and file name and inout fields echo '<td class="wp-core-ui">'; spa_paint_open_fieldset($file, false); echo '<input type="hidden" name="smfile[]" value="' . $file . '" />'; spa_paint_input(spa_text('Name'), 'smname[]', $sname, false, true); spa_paint_input(spa_text('Code'), 'smcode[]', $code, false, true); spa_paint_checkbox(spa_text('Break Smileys Row in Editor Display'), "smbreak-{$sname}", $break); spa_paint_checkbox(spa_text('Allow Use of this Smiley'), "sminuse-{$sname}", $in_use); spa_paint_close_fieldset(); echo '</td>'; echo '<td style="text-align: left;vertical-align: middle;margin:0;padding:0 4px 0 0;width:3%">'; $site = esc_url(SFHOMEURL . 'index.php?sp_ahah=components&sfnonce=' . wp_create_nonce('forum-ahah') . "&action=delsmiley&file={$file}"); echo '<img src="' . SFCOMMONIMAGES . 'delete.png" title="' . spa_text('Delete Smiley') . '" alt="" onclick="spjDelRow(\'' . $site . '\', \'smiley' . ($row - 1) . '\');" />'; echo '</td>'; echo '</tr>'; } } echo '</table>'; echo '<input type="hidden" id="smiley-count" name="smiley-count" value="' . $scount . '" />'; closedir($dlist); }
function sp_move_post() { global $spVars, $spGlobals, $spThisUser; # extract data from POST $postid = sp_esc_int($_POST['postid']); $oldtopicid = sp_esc_int($_POST['oldtopicid']); $oldforumid = sp_esc_int($_POST['oldforumid']); $action = sp_esc_str($_POST['moveop']); # determine op type - new or exsiting topic if (isset($_POST['makepostmove1']) || isset($_POST['makepostmove3'])) { # new topic move or exsiting topic move called from notification # extract data from POST $newforumid = sp_esc_int($_POST['forumid']); if (!sp_get_auth('move_posts', $oldforumid) || !sp_get_auth('move_posts', $newforumid)) { if (!is_user_logged_in()) { $msg = sp_text('Access denied - are you logged in?'); } else { $msg = sp_text('Access denied - you do not have permission'); } sp_notify(SPFAILURE, $msg); return; } if (empty($newforumid)) { sp_notify(SPFAILURE, sp_text('Post move abandoned as no forum was selected')); return; } if (isset($_POST['makepostmove1'])) { # create new topic for a new topic post move only $newtopicname = sp_filter_title_save(trim($_POST['newtopicname']), SFTOPICS, 'topic_name'); if (empty($newtopicname)) { sp_notify(SPFAILURE, sp_text('Post move abandoned as no topic was defined')); return; } # start with creating the new topic $newtopicslug = sp_create_slug($newtopicname, true, SFTOPICS, 'topic_slug'); # now create the topic and post records $sql = 'INSERT INTO ' . SFTOPICS . "\n\t\t\t\t (topic_name, topic_slug, topic_date, forum_id, post_count, post_id, post_count_held, post_id_held)\n\t\t\t\t VALUES\n\t\t\t\t ('{$newtopicname}', '{$newtopicslug}', now(), {$newforumid}, 1, {$postid}, 1, {$postid});"; if (spdb_query($sql) == false) { sp_notify(SPFAILURE, sp_text('Post move failed')); return; } $newtopicid = $spVars['insertid']; # check the topic slug and if empty use the topic id if (empty($newtopicslug)) { $newtopicslug = 'topic-' . $newtopicid; $thistopic = spdb_query('UPDATE ' . SFTOPICS . " SET\n\t\t\t\t\t\t\t\t\t\ttopic_slug='{$newtopicslug}'\n\t\t\t\t\t\t\t\t\t\tWHERE topic_id={$newtopicid}"); } } else { # it's a re-entry $newtopicid = sp_esc_int($_POST['newtopicid']); } # Now determine the list of post ids to move $posts = array(); switch ($action) { case 'single': $posts[] = $postid; break; case 'tostart': $sql = "SELECT post_id FROM " . SFPOSTS . " WHERE topic_id = {$oldtopicid} AND post_id <= {$postid}"; $posts = spdb_select('col', $sql); break; case 'toend': $sql = "SELECT post_id FROM " . SFPOSTS . " WHERE topic_id = {$oldtopicid} AND post_id >= {$postid}"; $posts = spdb_select('col', $sql); break; case 'select': $idlist = sp_esc_str(trim($_POST['idlist'], ",")); if (empty($idlist)) { $posts[] = $postid; } else { $where = "topic_id = {$oldtopicid} AND post_index IN ({$idlist})"; $sql = "SELECT post_id FROM " . SFPOSTS . " WHERE topic_id = {$oldtopicid} AND post_index IN ({$idlist})"; $posts = spdb_select('col', $sql); } break; } if (empty($posts)) { sp_notify(SPFAILURE, sp_text('Post move abandoned as no posts were selected')); return; } # loop through and update post records and other housekeeping foreach ($posts as $post) { # update post record $sql = 'UPDATE ' . SFPOSTS . " SET\n\t\t\t\t \ttopic_id={$newtopicid},\n\t\t\t\t \tforum_id={$newforumid},\n\t\t\t\t \tpost_status=0\n\t\t\t\t \tWHERE post_id={$post}"; spdb_query($sql); # update post if in sfwaiting spdb_query("UPDATE " . SFWAITING . " SET forum_id={$newforumid}, topic_id={$newtopicid} WHERE post_id={$post}"); # notify author of move $thisPost = spdb_table(SFPOSTS, "post_id={$post}", 'row'); $sfadminsettings = sp_get_option('sfadminsettings'); if ($sfadminsettings['movenotice'] && $spThisUser->ID != $thisPost->user_id) { $nData = array(); $nData['user_id'] = $thisPost->user_id; $nData['guest_email'] = $thisPost->guest_email; $nData['post_id'] = $post; $nData['link'] = sp_permalink_from_postid($post); $nData['link_text'] = spdb_table(SFTOPICS, "topic_id={$thisPost->topic_id}", 'topic_name'); $nData['message'] = sp_text('A post of yours was moved to'); $nData['expires'] = time() + 30 * 24 * 60 * 60; # 30 days; 24 hours; 60 mins; 60secs sp_add_notice($nData); } } # flush and rebuild topic cache (since one or more posts approved) sp_rebuild_topic_cache(); # rebuild indexing on target topic and forum sp_build_post_index($newtopicid); sp_build_forum_index($newforumid); # determine if any posts left in old topic - just in case - delete or reindex $sql = "SELECT post_id FROM " . SFPOSTS . " WHERE topic_id = {$oldtopicid}"; $posts = spdb_select('col', $sql); if (empty($posts)) { spdb_query("DELETE FROM " . SFTOPICS . " WHERE topic_id=" . $oldtopicid); } else { sp_build_post_index($oldtopicid); sp_build_forum_index($oldforumid); } do_action('sph_move_post', $oldtopicid, $newtopicid, $newforumid, $oldforumid, $postid, $spThisUser->ID); sp_notify(SPSUCCESS, sp_text('Post moved')); } elseif (isset($_POST['makepostmove2'])) { # must be a move to an exisiting topic action sp_add_sfmeta('post_move', 'post_move', $_POST, true); } if (isset($_POST['makepostmove3'])) { # if a re-entry for move to exisiting - clear the sfmeta record $meta = sp_get_sfmeta('post_move', 'post_move'); if ($meta) { $id = $meta[0]['meta_id']; sp_delete_sfmeta($id); unset($spGlobals['post_move']); } } }
function sp_NoForumMessage($args = '', $deniedMessage = '', $definedMessage = '') { global $spForumView; $defs = array('tagId' => 'spNoForumMessage', 'tagClass' => 'spMessage', 'echo' => 1, 'get' => 0); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_NoForumMessage_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $echo = (int) $echo; $get = (int) $get; # is Access denied if ($spForumView->forumViewStatus == 'no access') { $m = sp_filter_title_display($deniedMessage); } elseif ($spForumView->forumViewStatus == 'no data') { $m = sp_filter_title_display($definedMessage); } elseif ($spForumView->forumViewStatus == 'sneak peek') { $sflogin = sp_get_option('sflogin'); if (!empty($sflogin['sfsneakredirect'])) { sp_redirect(apply_filters('sph_sneak_redirect', $sflogin['sfsneakredirect'])); } else { $sneakpeek = sp_get_sfmeta('sneakpeek', 'message'); $m = $sneakpeek ? sp_filter_text_display($sneakpeek[0]['meta_value']) : ''; } } else { return; } if ($get) { return $m; } $out = "<div id='{$tagId}' class='{$tagClass}'>{$m}</div>\n"; $out = apply_filters('sph_NoForumMessage', $out, $a); if ($echo) { echo $out; } else { return $out; } }
function spa_check_for_news() { $news = sp_get_sfmeta('news', 'news'); if (!empty($news)) { if ($news[0]['meta_value']['show']) { return $news[0]['meta_value']['news']; } } }