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_akismet($newpost) { global $spThisUser; if (sp_get_auth('bypass_akismet', $newpost['forumid'])) { return $newpost; } if (function_exists('akismet_http_post') == false) { return $newpost; } $akismet = sp_get_option('spAkismet'); if (empty($akismet) || $akismet == 1) { return $newpost; } $spam = sp_check_akismet($newpost); if (true == $spam) { if ($akismet == 2) { $newpost['poststatus'] = 2; } if ($akismet == 3) { sp_notify(1, __('This post has been identified as spam and has been rejected', 'spab')); wp_redirect(sp_url()); die; } } return $newpost; }
function spa_get_messages_data() { $sfcomps = array(); # custom message for posts $sfpostmsg = array(); $sfpostmsg = sp_get_option('sfpostmsg'); $sflogin = array(); $sflogin = sp_get_option('sflogin'); $sfcomps['sfpostmsgtext'] = sp_filter_text_edit($sfpostmsg['sfpostmsgtext']); $sfcomps['sfpostmsgtopic'] = $sfpostmsg['sfpostmsgtopic']; $sfcomps['sfpostmsgpost'] = $sfpostmsg['sfpostmsgpost']; # custom editor message $sfcomps['sfeditormsg'] = sp_filter_text_edit(sp_get_option('sfeditormsg')); $sneakpeek = sp_get_sfmeta('sneakpeek', 'message'); $adminview = sp_get_sfmeta('adminview', 'message'); $userview = sp_get_sfmeta('userview', 'message'); $sfcomps['sfsneakpeek'] = ''; $sfcomps['sfadminview'] = ''; $sfcomps['sfuserview'] = ''; if (!empty($sneakpeek[0])) { $sfcomps['sfsneakpeek'] = sp_filter_text_edit($sneakpeek[0]['meta_value']); } if (!empty($adminview[0])) { $sfcomps['sfadminview'] = sp_filter_text_edit($adminview[0]['meta_value']); } if (!empty($userview[0])) { $sfcomps['sfuserview'] = sp_filter_text_edit($userview[0]['meta_value']); } $sfcomps['sfsneakredirect'] = sp_filter_url_display($sflogin['sfsneakredirect']); return $sfcomps; }
function spa_save_admins_your_options_data() { global $spThisUser; check_admin_referer('my-admin_options', 'my-admin_options'); # admin settings group $sfadminoptions = ''; $sfadminoptions['sfnotify'] = isset($_POST['sfnotify']); $sfadminoptions['bypasslogout'] = isset($_POST['bypasslogout']); $sfadminoptions['notify-edited'] = isset($_POST['notify-edited']); $sfadminoptions = apply_filters('sph_admin_your_options_change', $sfadminoptions); sp_update_member_item($spThisUser->ID, 'admin_options', $sfadminoptions); $mess = spa_text('Your admin options have been updated'); # do we update moderator options as well? if ($spThisUser->admin && isset($_POST['setmods'])) { $mods = sp_get_option('spModStats'); if ($mods) { foreach ($mods as $mod) { sp_update_member_item($mod['user_id'], 'admin_options', $sfadminoptions); } $mess .= '<br />' . spa_text('Your moderators options have been updated'); } } do_action('sph_admin_your_options_save'); return $mess; }
function sp_do_sp_ForumHomeLinkTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } $defs = array('beforeLink' => '', 'afterLink' => '', 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_ForumHomeLinkTag_args', $a); extract($a, EXTR_SKIP); # sanitize before use $beforeLink = sp_filter_title_display($beforeLink); $afterLink = sp_filter_title_display($afterLink); $echo = (int) $echo; if (!empty($beforeLink)) { $beforeLink = trim($beforeLink) . ' '; } if (!empty($afterLink)) { $afterLink = ' ' . trim($afterLink); } $pid = sp_get_option('sfpage'); $title = spdb_table(SFWPPOSTS, "ID={$pid}", 'post_title'); $out .= '<span>' . $beforeLink . '<a href="' . get_permalink($pid) . '">' . $title . '</a>' . $afterLink . '</span>'; $out = apply_filters('sph_ForumHomeLinkTag', $out); if ($echo) { echo $out; } else { return $out; } }
function sp_rebuild_schema($start, $end) { global $tables, $wpdb; # prepare the one exception! $opTable = $wpdb->prefix . 'sfoptions'; $opKey = 'option_id'; $t = sp_get_option('installed_tables'); for ($x = $start; $x < $end + 1; $x++) { if ($t[$x]) { # get list of indexes $data = $wpdb->get_results("SHOW INDEXES FROM {$t[$x]}"); if ($data) { foreach ($data as $item) { if ($item->Key_name != 'PRIMARY' && ($t[$x] != $opTable && $item->Key_name != $opKey)) { # remove current index spdb_query('ALTER TABLE ' . $t[$x] . " DROP INDEX {$item->Key_name}"); } } } # grab list of table actions $actions = $tables[$t[$x]]; if ($actions) { foreach ($actions as $sql) { # add back index spdb_query($sql); } } } } }
function wp_new_user_notification($user_id, $notify = '') { $user = new WP_User($user_id); $sflogin = sp_get_option('sflogin'); $eol = "\r\n"; $user_login = $user->user_login; $user_email = $user->user_email; $message = ''; $message .= sp_text_noesc('New user registration on your website') . ': ' . get_option('blogname') . $eol . $eol; $message .= sp_text_noesc('Username') . ': ' . $user_login . $eol; $message .= sp_text_noesc('E-mail') . ': ' . $user_email . $eol; $message .= sp_text_noesc('Registration IP') . ': ' . sp_get_ip() . $eol; $address = apply_filters('sph_admin_new_user_email_addrress', get_option('admin_email'), $user_id); $subject = apply_filters('sph_admin_new_user_email_subject', get_option('blogname') . ' ' . sp_text_noesc('New User Registration'), $user_id); $msg = apply_filters('sph_admin_new_user_email_msg', $message, $user_id); sp_send_email($address, $subject, $msg); if ('admin' === $notify || empty($notify)) { return; } # Generate something random for a password reset key. $key = wp_generate_password(20, false); /** This action is documented in wp-login.php */ do_action('retrieve_password_key', $user_login, $key); # Now insert the key, hashed, into the DB. if (empty($wp_hasher)) { require_once ABSPATH . WPINC . '/class-phpass.php'; $wp_hasher = new PasswordHash(8, true); } $hashed = time() . ':' . $wp_hasher->HashPassword($key); global $wpdb; $wpdb->update($wpdb->users, array('user_activation_key' => $hashed), array('user_login' => $user_login)); $mailoptions = sp_get_option('sfnewusermail'); $subject = stripslashes($mailoptions['sfnewusersubject']); $body = stripslashes($mailoptions['sfnewusertext']); if (empty($subject) || empty($body)) { $subject = get_option('blogname') . ' ' . sp_text_noesc('Your username') . $eol . $eol; $body = sp_text_noesc('Username') . ': ' . $user_login . $eol; $body .= sp_text_noesc('Login URL') . ': ' . $sflogin['sfloginemailurl'] . $eol; $body .= sp_text_noesc('Password Reset URL') . ': ' . network_site_url("wp-login.php?action=rp&key={$key}&login="******"wp-login.php?action=rp&key={$key}&login="******"wp-login.php?action=rp&key={$key}&login=" . rawurlencode($user_login), 'login'), $body); $body = str_replace('%NEWLINE%', $eol, $body); } str_replace('<br />', $eol, $body); $address = apply_filters('sph_user_new_user_email_addrress', $user_email, $user_id); $subject = apply_filters('sph_user_new_user_email_subject', get_option('blogname') . ' ' . sp_text_noesc('New User Registration'), $user_id); $msg = apply_filters('sph_user_new_user_email_msg', $body, $user_id, $user_pass); sp_send_email($user_email, $subject, $msg); }
function sp_url($link = '') { $url = sp_get_option('sfpermalink'); if (!empty($link)) { $url = trailingslashit($url) . $link; } $url = user_trailingslashit($url); return esc_url($url); }
function sp_captcha_admin_options_form() { $captcha = sp_get_option('spCaptcha'); spa_paint_open_panel(); spa_paint_open_fieldset(__('Captcha on User Registration', 'sp-cap'), true, 'captcha'); spa_paint_checkbox(__('Add Captcha form to WP registration/signup form', 'sp-cap'), 'registration', $captcha['registration']); spa_paint_close_fieldset(); spa_paint_close_panel(); do_action('sph_captcha_options_panel'); }
function spa_get_inspector_data() { global $spThisUser; $ins = array(); $ins = sp_get_option('spInspect'); $i = $spThisUser->ID; if (empty($ins) || !array_key_exists($i, $ins)) { $ins[$i] = array('con_spVars' => 0, 'con_spGlobals' => 0, 'con_spThisUser' => 0, 'con_spDevice' => 0, 'gv_spGroupView' => 0, 'gv_spThisGroup' => 0, 'gv_spThisForum' => 0, 'gv_spThisForumSubs' => 0, 'fv_spForumView' => 0, 'fv_spThisForum' => 0, 'fv_spThisForumSubs' => 0, 'fv_spThisSubForum' => 0, 'fv_spThisTopic' => 0, 'tv_spTopicView' => 0, 'tv_spThisTopic' => 0, 'tv_spThisPost' => 0, 'tv_spThisPostUser' => 0, 'mv_spMembersList' => 0, 'mv_spThisMemberGroup' => 0, 'mv_spThisMember' => 0, 'tlv_spTopicListView' => 0, 'tlv_spThisListTopic' => 0, 'plv_spPostListView' => 0, 'plv_spThisListPost' => 0, 'pro_spProfileUser' => 0, 'q_spGroupView' => 0, 'q_spGroupViewStats' => 0, 'q_spForumView' => 0, 'q_spForumViewStats' => 0, 'q_spTopicView' => 0, 'q_spMembersView' => 0, 'q_spTopicListView' => 0, 'q_spTopicListViewNew' => 0, 'q_spTopicListViewFirst' => 0, 'q_spPostListView' => 0, 'q_spSearchView' => 0); } return $ins[$i]; }
function sp_captcha_do_install() { $captcha = sp_get_option('spCaptcha'); if (empty($captcha)) { $captcha['registration'] = true; $captcha['dbversion'] = SPCAPTCHADBVERSION; sp_update_option('spCaptcha', $captcha); } # add a new permission into the auths table sp_add_auth('bypass_captcha', __('Can bypass the post captcha check', 'sp-cap'), 1, 0, 0, 0, 6); sp_activate_auth('bypass_captcha'); }
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_toolbox_toolbox_form() { ?> <script type="text/javascript"> jQuery(document).ready(function() { spjAjaxForm('sftoolboxform', ''); }); </script> <?php $sfoptions = spa_get_toolbox_data(); $ahahURL = SFHOMEURL . 'index.php?sp_ahah=toolbox-loader&sfnonce=' . wp_create_nonce('forum-ahah') . '&saveform=toolbox'; ?> <form action="<?php echo $ahahURL; ?> " method="post" id="sftoolboxform" name="sftoolbox"> <?php echo sp_create_nonce('forum-adminform_toolbox'); spa_paint_options_init(); #== TOOLBOX Tab ============================================================ spa_paint_open_tab(spa_text('Toolbox') . ' - ' . spa_text('Toolbox')); spa_paint_open_panel(); spa_paint_open_fieldset(spa_text('Current Version/Build'), false); $version = spa_text('Version:') . ' <strong>' . sp_get_option('sfversion') . '</strong>'; $build = spa_text('Build: ') . ' <strong>' . sp_get_option('sfbuild') . '</strong>'; echo $version . ' ' . $build; spa_paint_close_fieldset(); spa_paint_close_panel(); do_action('sph_toolbox_toolbox_left_panel'); spa_paint_tab_right_cell(); spa_paint_open_panel(); spa_paint_open_fieldset(spa_text('Modify Build Number'), true, 'modify-build-number'); echo '<div class="sfoptionerror">' . spa_text('WARNING: This value should not be changed unless requested by the Simple:Press team in the support forum as it may cause the install/upgrade script to be re-run.') . '</div>'; spa_paint_input(spa_text('Build number'), "sfbuild", sp_get_option('sfbuild'), false, false); spa_paint_checkbox(spa_text('Force upgrade to build number'), "sfforceupgrade", $sfoptions['sfforceupgrade']); spa_paint_close_fieldset(); spa_paint_close_panel(); do_action('sph_toolbox_toolbox_right_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 Toolbox'); ?> " /> </div> <?php spa_paint_close_tab(); ?> </form> <?php }
function sp_akismet_admin_options_form() { $spAkismet = sp_get_option('spAkismet'); spa_paint_open_panel(); spa_paint_open_fieldset(__('Akismet', 'spab'), true, 'akismet'); if (function_exists('akismet_http_post')) { $values = array(__('Do not use Akismet', 'spab'), __('Place Akismet marked spam posts into moderation', 'spab'), __('Do not save Akismet marked spam posts', 'spab')); spa_paint_radiogroup(__('Select Akismet Option', 'spab'), 'spAkismet', $values, $spAkismet, '', false, true); } else { _e('Akismet is not currently active on this site', 'spab'); } spa_paint_close_fieldset(); spa_paint_close_panel(); }
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_update_users_newposts() { global $spThisUser; # Check the users checktime against the last post timestamp to see if we need to do this $checkTime = spdb_zone_mysql_checkdate($spThisUser->checktime); $postTime = sp_get_option('poststamp'); if (strtotime($checkTime) > strtotime($postTime) && !isset($_GET['mark-read'])) { return; } # so there must have been a new post since the last page load for this user $newPostList = $spThisUser->newposts; if (empty($newPostList['topics'])) { # clean it up to be on the safe side unset($newPostList); $newPostList = array(); $newPostList['topics'] = array(); $newPostList['forums'] = array(); } # create new holding array and new checktime (now) $addPostList = array(); $addPostList['topics'] = array(); $addPostList['forums'] = array(); sp_set_server_timezone(); $newCheckTime = sp_apply_timezone(time(), 'mysql'); # Use the current checktime for any new posts since users session began $records = spdb_select('set', "SELECT DISTINCT topic_id, forum_id FROM " . SFPOSTS . "\n\t\t\t\t\t\t\t\t WHERE post_status = 0 AND post_date > '" . $checkTime . "' AND user_id != " . $spThisUser->ID . "\n\t\t\t\t\t\t\t\t ORDER BY post_id DESC LIMIT " . $spThisUser->unreadposts . ";", ARRAY_A); if ($records) { foreach ($records as $r) { if (sp_get_auth('view_forum', $r['forum_id']) && !in_array($r['topic_id'], $newPostList['topics'])) { $addPostList['topics'][] = $r['topic_id']; $addPostList['forums'][] = $r['forum_id']; } } } $addPostList = apply_filters('sph_new_post_list', $addPostList, $newPostList); # now merge the arrays and truncate if necessary $newPostList['topics'] = array_merge($addPostList['topics'], $newPostList['topics']); $newPostList['forums'] = array_merge($addPostList['forums'], $newPostList['forums']); if (count($newPostList['topics']) > $spThisUser->unreadposts) { array_splice($newPostList['topics'], $spThisUser->unreadposts); array_splice($newPostList['forums'], $spThisUser->unreadposts); } # update sfmembers - do it here to ensure both are updated together spdb_query("UPDATE " . SFMEMBERS . " SET newposts='" . serialize($newPostList) . "', checktime='" . $newCheckTime . "' WHERE user_id=" . $spThisUser->ID); $spThisUser->newpostlist = true; $spThisUser->checktime = $newCheckTime; $spThisUser->newposts = $newPostList; }
function sp_logout_redirect() { sp_forum_api_support(); global $spThisUser; $sflogin = sp_get_option('sflogin'); if (!empty($sflogin['sflogouturl'])) { $sfadminoptions = sp_get_member_item($spThisUser->ID, 'admin_options'); if ($spThisUser->moderator && $sfadminoptions['bypasslogout']) { $_REQUEST['redirect_to'] = esc_url(wp_login_url()); } else { $_REQUEST['redirect_to'] = $sflogin['sflogouturl']; } } $redirect = isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''; $_REQUEST['redirect_to'] = apply_filters('sph_logout_redirect', $redirect); }
function wp_new_user_notification($user_id, $user_pass = '') { $user = new WP_User($user_id); $sflogin = sp_get_option('sflogin'); $eol = "\r\n"; $user_login = $user->user_login; $user_email = $user->user_email; $message = ''; $message .= sp_text_noesc('New user registration on your website') . ': ' . get_option('blogname') . $eol . $eol; $message .= sp_text_noesc('Username') . ': ' . $user_login . $eol; $message .= sp_text_noesc('E-mail') . ': ' . $user_email . $eol; $message .= sp_text_noesc('Registration IP') . ': ' . sp_get_ip() . $eol; $address = apply_filters('sph_admin_new_user_email_addrress', get_option('admin_email'), $user_id); $subject = apply_filters('sph_admin_new_user_email_subject', get_option('blogname') . ' ' . sp_text_noesc('New User Registration'), $user_id); $msg = apply_filters('sph_admin_new_user_email_msg', $message, $user_id); sp_send_email($address, $subject, $msg); if (empty($user_pass)) { return; } $mailoptions = sp_get_option('sfnewusermail'); $subject = stripslashes($mailoptions['sfnewusersubject']); $body = stripslashes($mailoptions['sfnewusertext']); if (empty($subject) || empty($body)) { $subject = get_option('blogname') . ' ' . sp_text_noesc('Your username and password') . $eol . $eol; $body = sp_text_noesc('Username') . ': ' . $user_login . $eol; $body .= sp_text_noesc('Password') . ': ' . $user_pass . $eol . $eol; $body .= $sflogin['sfloginemailurl'] . $eol; } else { $blogname = get_bloginfo('name'); $subject = str_replace('%USERNAME%', $user_login, $subject); $subject = str_replace('%PASSWORD%', $user_pass, $subject); $subject = str_replace('%BLOGNAME%', $blogname, $subject); $subject = str_replace('%SITEURL%', sp_url(), $subject); $subject = str_replace('%LOGINURL%', $sflogin['sfloginemailurl'], $subject); $body = str_replace('%USERNAME%', $user_login, $body); $body = str_replace('%PASSWORD%', $user_pass, $body); $body = str_replace('%BLOGNAME%', $blogname, $body); $body = str_replace('%SITEURL%', sp_url(), $body); $body = str_replace('%LOGINURL%', $sflogin['sfloginemailurl'], $body); $body = str_replace('%NEWLINE%', $eol, $body); } str_replace('<br />', $eol, $body); $address = apply_filters('sph_user_new_user_email_addrress', $user_email, $user_id); $subject = apply_filters('sph_user_new_user_email_subject', get_option('blogname') . ' ' . sp_text_noesc('New User Registration'), $user_id); $msg = apply_filters('sph_user_new_user_email_msg', $body, $user_id, $user_pass); sp_send_email($user_email, $subject, $msg); }
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_render_inline_login_form($a) { global $spGlobals, $spDevice; extract($a, EXTR_SKIP); $user_login = ''; $user_pass = ''; $using_cookie = false; $sflogin = sp_get_option('sflogin'); $redirect_to = $_SERVER['REQUEST_URI']; $out = ''; # Add a close button if using a mobile phone if ($spDevice == 'mobile') { $out .= "<div class='spRight'>"; $out .= "<a id='spPanelClose' href='#' onclick='spjResetMobileMenu();'></a>"; $out .= "</div>"; } do_action('sph_login_head', 'sploginform'); $message = ''; $message = apply_filters('sf_filter_login_message', $message); if (!empty($message)) { $out .= $message . "\n"; } $out .= "<fieldset class='{$controlFieldset}'>\n"; $out .= "<form name='loginform' id='loginform' class='{$tagClass}' action='" . site_url('wp-login.php', 'login_post') . "' method='post'>\n"; $sfrpx = sp_get_option('sfrpx'); if ($sfrpx['sfrpxenable']) { $out .= sp_rpx_loginform('spLoginForm', '100%', true); } $out .= "<p><label for='log'>{$labelUserName}<br /><input type='text' class='{$controlInput}' tabindex='84' name='log' id='log' value='" . esc_attr($user_login) . "' size='11' /></label></p>\n"; $out .= "<p><label for='login_password'>{$labelPassword}<br /><input type='password' class='{$controlInput}' tabindex='85' name='pwd' id='login_password' value='' size='11' /></label></p>\n"; $out .= "<p><input type='checkbox' tabindex='86' id='rememberme' name='rememberme' value='forever' /><label for='rememberme'>{$labelRemember}</label></p>\n"; $out .= do_action('login_form'); $out .= "<p class='{$tagClass}'><input type='submit' class='{$controlSubmit}' name='submit' id='submit' value='{$labelSubmit}' tabindex='87' /></p>\n"; $out .= "<input type='hidden' name='redirect_to' value='" . esc_attr($redirect_to) . "' />\n"; $out .= "</form>\n"; if (TRUE == get_option('users_can_register') && !$spGlobals['lockdown'] && $showRegister) { $out .= "<a class='{$controlLink}' href='{$registerLink}'>{$labelRegister}</a>\n"; $out .= $separator; } if ($showLostPass) { $out .= "<a class='{$controlLink}' href='{$passwordLink}'>{$labelLostPass}</a>\n"; } $out .= "</fieldset>\n"; return $out; }
function sp_setup_globals() { global $spGlobals, $current_user, $spBootCache, $spMeta, $spDevice; if ($spBootCache['globals'] == true) { return; } # Main admin options $spGlobals['admin'] = sp_get_option('sfadminsettings'); $spGlobals['lockdown'] = sp_get_option('sflockdown'); $spGlobals['editor'] = 0; # Display array $spGlobals['display'] = sp_get_option('sfdisplay'); # Current theme data $spGlobals['theme'] = sp_get_current_sp_theme(); # if mobile device then force integrated editor toolbar to on if ($spDevice == 'mobile' || $spDevice == 'tablet') { $spGlobals['display']['editor']['toolbar'] = true; if ($spDevice == 'mobile') { $spGlobals['mobile-display'] = sp_get_option('sp_mobile_theme'); } else { $spGlobals['mobile-display'] = sp_get_option('sp_tablet_theme'); } } # Load up sfmeta $spMeta = spdb_table(SFMETA, 'autoload=1'); if (!empty($spMeta)) { foreach ($spMeta as $s) { if (!empty($s)) { $spGlobals[$s->meta_type][$s->meta_key] = maybe_unserialize($s->meta_value); } } } # create topic/post cache if found to be missing! if (!isset($spGlobals['topic_cache']['new']) || empty($spGlobals['topic_cache']['new'])) { $spGlobals['topic_cache']['new'] = sp_rebuild_topic_cache(); } # Pre-define a few others $spGlobals['canonicalurl'] = false; # set up array of disabled forums $spGlobals['disabled_forums'] = spdb_select('col', 'SELECT forum_id FROM ' . SFFORUMS . ' WHERE forum_disabled=1', ARRAY_A); $spBootCache['globals'] = true; }
function sp_admin_bar_do_install() { global $spThisUser; $oldOptions = sp_get_option('sfadminsettings'); $newOptions = sp_get_option('spAdminBar'); if (!isset($oldOptions['sfqueue']) && empty($newOptions)) { $newOptions = array(); $newOptions['dashboardposts'] = false; $newOptions['dbversion'] = SPABDBVERSION; sp_add_option('spAdminBar', $newOptions); $options = sp_get_member_item($spThisUser->ID, 'admin_options'); $options['sfadminbar'] = true; sp_update_member_item($spThisUser->ID, 'admin_options', $options); } else { if (empty($newOptions)) { $newOptions = array(); $newOptions['dashboardposts'] = $oldOptions['sfdashboardposts']; $newOptions['dbversion'] = SPABDBVERSION; sp_add_option('spAdminBar', $newOptions); $options = sp_get_member_item($spThisUser->ID, 'admin_options'); $options['sfadminbar'] = true; sp_update_member_item($spThisUser->ID, 'admin_options', $options); unset($oldOptions['sfqueue']); unset($oldOptions['sfmodasadmin']); unset($oldOptions['sfshowmodposts']); unset($oldOptions['sfbaronly']); unset($oldOptions['sfdashboardposts']); sp_update_option('sfadminsettings', $oldOptions); } } # 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'); # create new Akismet setting $akismet = sp_get_option('spAkismet'); if (empty($akismet)) { sp_add_option('spAkismet', 1); } # get auto update running $autoup = array('spabupdate', 'sp_ahah=admin-bar-update&target=newposts'); sp_add_sfmeta('autoupdate', 'admin', $autoup, 1); }
function sp_featured_do_upgrade_check() { if (!sp_is_plugin_active('featured/sp-featured-plugin.php')) { return; } $options = sp_get_option('featured'); $db = $options['dbversion']; if (empty($db)) { $db = 0; } # quick bail check if ($db == SPFEATUREDDBVERSION) { return; } # apply upgrades as needed # db version upgrades # save data $options['dbversion'] = SPFEATUREDDBVERSION; sp_update_option('featured', $options); }
function sp_rss_excerpt($text) { $rssopt = sp_get_option('sfrss'); $max = $rssopt['sfrsswords']; if ($max == 0) { return $text; } $bits = explode(" ", $text); $text = ''; $end = ''; if (count($bits) < $max) { $max = count($bits); } else { $end = '...'; } $text = ''; for ($x = 0; $x < $max; $x++) { $text .= $bits[$x] . ' '; } return $text . $end; }
function sp_plugins_check_sp_version($plugin) { global $spStatus; if ($plugin == 'simple-press/sp-control.php') { $msg = ''; # get wp admin screen type $screen = get_current_screen(); if (sp_get_option('sfuninstall')) { if (!$screen->is_network) { $msg = '<p style="color:red;">' . spa_text('Simple:Press is READY TO BE REMOVED. When you deactivate it ALL DATA WILL BE DELETED') . '</p>'; } } else { if ($spStatus == 'Upgrade') { if (!$screen->is_network) { $msg = spa_text('Select the forum menu to complete the upgrade of your Simple:Press'); } } else { $xml = sp_load_version_xml(); if (empty($xml)) { return; } $installed_version = sp_get_option('sfversion'); $installed_build = sp_get_option('sfbuild'); if (empty($installed_build)) { return; } if ($xml->core->build > $installed_build) { $msg = spa_text('Latest version available') . ': <strong>' . $xml->core->version . ' ' . spa_text('Build') . ': ' . $xml->core->build . '</strong> - ' . $xml->core->message . '<br />'; $msg .= spa_text('For details and to download please visit') . ' ' . SFPLUGHOME . ' ' . spa_text('or'); $msg .= ' <a href="' . wp_nonce_url(self_admin_url('update-core.php?action=do-plugin-upgrade&plugins=simple-press/sp-control.php'), 'upgrade-core') . '" title="" target="_parent">' . spa_text('update automatically') . '</a>'; } } } if ($msg) { echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update colspanchange"><div class="update-message">' . $msg . '</div></td></tr>'; } } }
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_new_profile_setup() { # set up tabs and menus sp_profile_add_tab(spa_text('Profile')); sp_profile_add_menu(spa_text('Profile'), spa_text('Overview'), SF_PLUGIN_DIR . '/forum/profile/forms/sp-form-overview.php'); sp_profile_add_menu(spa_text('Profile'), spa_text('Edit Profile'), SF_PLUGIN_DIR . '/forum/profile/forms/sp-form-profile.php'); sp_profile_add_menu(spa_text('Profile'), spa_text('Edit Identities'), SF_PLUGIN_DIR . '/forum/profile/forms/sp-form-identities.php'); sp_profile_add_menu(spa_text('Profile'), spa_text('Edit Avatar'), SF_PLUGIN_DIR . '/forum/profile/forms/sp-form-avatar.php'); sp_profile_add_menu(spa_text('Profile'), spa_text('Edit Signature'), SF_PLUGIN_DIR . '/forum/profile/forms/sp-form-signature.php', 0, 1, 'use_signatures'); sp_profile_add_menu(spa_text('Profile'), spa_text('Edit Photos'), SF_PLUGIN_DIR . '/forum/profile/forms/sp-form-photos.php'); sp_profile_add_menu(spa_text('Profile'), spa_text('Account Settings'), SF_PLUGIN_DIR . '/forum/profile/forms/sp-form-account.php'); sp_profile_add_tab(spa_text('Options')); sp_profile_add_menu(spa_text('Options'), spa_text('Edit Global Options'), SF_PLUGIN_DIR . '/forum/profile/forms/sp-form-global-options.php'); sp_profile_add_menu(spa_text('Options'), spa_text('Edit Posting Options'), SF_PLUGIN_DIR . '/forum/profile/forms/sp-form-posting-options.php'); sp_profile_add_menu(spa_text('Options'), spa_text('Edit Display Options'), SF_PLUGIN_DIR . '/forum/profile/forms/sp-form-display-options.php'); sp_profile_add_tab(spa_text('Usergroups')); sp_profile_add_menu(spa_text('Usergroups'), spa_text('Show Memberships'), SF_PLUGIN_DIR . '/forum/profile/forms/sp-form-memberships.php'); sp_profile_add_tab(spa_text('Permissions')); sp_profile_add_menu(spa_text('Permissions'), spa_text('Show Permissions'), SF_PLUGIN_DIR . '/forum/profile/forms/sp-form-permissions.php'); # overview message $spProfile = sp_get_option('sfprofile'); if (empty($spProfile['sfprofiletext'])) { $spProfile['sfprofiletext'] = 'Welcome to the User Profile Overview Panel. From here you can view and update your profile and options as well as view your Usergroup Memberships and Permissions.'; sp_update_option('sfprofile', $spProfile); } }
function sp_GroupHeaderRSSButton($args = '', $label = '', $toolTip = '') { global $spThisUser, $spThisGroup; if (!$spThisGroup->group_rss_active) { return; } $defs = array('tagId' => 'spGroupHeaderRSSButton%ID%', 'tagClass' => 'spLink', 'icon' => 'sp_Feed.png', 'iconClass' => 'spIcon', 'echo' => 1, 'get' => 0); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_GroupHeaderRSSButton_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $icon = sanitize_file_name($icon); $iconClass = esc_attr($iconClass); $toolTip = esc_attr($toolTip); $echo = (int) $echo; $get = (int) $get; $tagId = str_ireplace('%ID%', $spThisGroup->group_id, $tagId); # Get or construct rss url if (empty($spThisGroup->rss)) { $rssOpt = sp_get_option('sfrss'); if ($rssOpt['sfrssfeedkey'] && isset($spThisUser->feedkey)) { $rssUrl = sp_get_sfqurl(trailingslashit(sp_build_url('', '', 0, 0, 0, 1)) . user_trailingslashit($spThisUser->feedkey)) . 'group=' . $spThisGroup->group_id; } else { $sym = strpos(sp_url(), '?') ? '&' : '?'; $rssUrl = trailingslashit(sp_build_url('', '', 0, 0, 0, 1)) . sp_add_get() . "group={$spThisGroup->group_id}"; } } else { $rssUrl = $spThisGroup->rss; } if ($get) { return $rssUrl; } $out = "<a class='{$tagClass} vtip' id='{$tagId}' title='{$toolTip}' rel='nofollow' href='{$rssUrl}'>"; if (!empty($icon)) { $out .= "<img class='{$iconClass}' src='" . sp_find_icon(SPTHEMEICONSURL, $icon) . "' alt=''/>"; } if (!empty($label)) { $out .= sp_filter_title_display($label); } $out .= "</a>\n"; $out = apply_filters('sph_GroupHeaderRSSButton', $out, $a); if ($echo) { echo $out; } else { return $out; } }
function sp_rebuild_topic_cache() { $size = sp_get_option('topic_cache'); if (!isset($size) || $size == 0) { sp_add_option('topic_cache', 200); } $sql = "SELECT DISTINCTROW forum_id, topic_id, post_id, post_status\n\t\t\tFROM " . SFPOSTS . "\n\t\t\tORDER BY post_id DESC\n\t\t\tLIMIT {$size}"; $topics = spdb_select('set', $sql, ARRAY_N); if ($topics) { sp_add_sfmeta('topic_cache', 'new', $topics, true); } # Delete group level cache for good measure spdb_query("DELETE FROM " . SFCACHE . " WHERE cache_id LIKE '%*group'"); return $topics; }
function sp_delete_sp_theme($theme) { $mobileTheme = sp_get_option('sp_mobile_theme'); $tabletTheme = sp_get_option('sp_tablet_theme'); $curTheme = sp_get_option('sp_current_theme'); if ($curTheme['theme'] == $theme) { $mess = spa_text('Sorry, cannot delete the active theme'); } else { if ($mobileTheme['theme'] == $theme) { $mess = spa_text('Sorry, cannot delete the active mobile theme'); } else { if ($tabletTheme['theme'] == $theme) { $mess = spa_text('Sorry, cannot delete the active tablet theme'); } else { sp_remove_dir(SPTHEMEBASEDIR . $theme); do_action('sph_delete_' . trim($theme)); do_action('sph_deleted_sp_theme', trim($theme)); $mess = spa_text('Theme deleted'); } } } return $mess; }