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 spa_update_specialrank($id) { check_admin_referer('special-rank-update', 'special-rank-update'); # save special forum ranks if (!empty($_POST['specialrankdesc'])) { $desc = $_POST['specialrankdesc']; $badge = $_POST['specialrankbadge']; $rank = sp_get_sfmeta('special_rank', false, $id); $rank[0]['meta_value']['badge'] = sp_filter_filename_save($badge[$id]); sp_update_sfmeta('special_rank', sp_filter_title_save(trim($desc[$id])), $rank[0]['meta_value'], $id, 1); if ($_POST['currentname'][$id] != $desc[$id]) { spdb_query("UPDATE " . SFSPECIALRANKS . "\n\t\t\t\t\t\tSET special_rank = '" . $desc[$id] . "'\n\t\t\t\t\t\tWHERE special_rank = '" . $_POST['currentname'][$id] . "'"); } } do_action('sph_component_srank_update_save'); $mess = spa_text('Special ranks updated'); return $mess; }
function spa_update_specialrank($id) { check_admin_referer('special-rank-update', 'special-rank-update'); # save special forum ranks if (!empty($_POST['specialrankdesc'])) { $desc = $_POST['specialrankdesc']; $badge = $_POST['specialrankbadge']; $rank = sp_get_sfmeta('special_rank', false, $id); $rank[0]['meta_value']['badge'] = sp_filter_filename_save($badge[$id]); sp_update_sfmeta('special_rank', sp_filter_title_save(trim($desc[$id])), $rank[0]['meta_value'], $id, 1); } do_action('sph_component_srank_update_save'); $mess = spa_text('Special ranks updated'); 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); } } }
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'; } if ($action == 'delbadge') { $file = sp_esc_str($_GET['file']); $path = SF_STORE_DIR . '/' . $spPaths['ranks'] . '/' . $file; @unlink($path); echo '1'; } die;
<?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 sp_add_sfmeta($type, $key, $value, $autoload = 0) { if (empty($type) || empty($key)) { return false; } # Check if already exists $sql = 'SELECT meta_id FROM ' . SFMETA . " WHERE meta_type='{$type}' AND meta_key='{$key}'"; $check = spdb_select('var', $sql); # so - does it? if ($check) { # yes - so needs to be an update call sp_update_sfmeta($type, $key, $value, $check, $autoload); } else { $sql = 'INSERT INTO ' . SFMETA . "(meta_type, meta_key, meta_value, autoload)\n\t\t\t VALUES\n\t\t\t ('{$type}', '{$key}', '" . wp_slash(maybe_serialize($value)) . "',{$autoload})"; spdb_query($sql); } }
function saveData() { global $spVars, $spGlobals; $this->abort = false; $this->newpost['action'] = $this->action; # make the entire class object available for modification before saving # warning: note the passing by reference. other end could wreak havoc do_action_ref_array('sph_new_post_pre_save', array(&$this)); # Write the topic if needed if ($this->action == 'topic') { $this->newpost = apply_filters('sph_new_topic_pre_data_saved', $this->newpost); $spdb = new spdbComplex(); $spdb->table = SFTOPICS; $spdb->fields = array('topic_name', 'topic_slug', 'topic_date', 'forum_id', 'topic_status', 'topic_pinned', 'user_id'); $spdb->data = array($this->newpost['topicname'], $this->newpost['topicslug'], $this->newpost['postdate'], $this->newpost['forumid'], $this->newpost['topicstatus'], $this->newpost['topicpinned'], $this->newpost['userid']); $spdb = apply_filters('sph_new_topic_data', $spdb); $this->newpost['db'] = $spdb->insert(); if ($this->newpost['db'] == true) { $this->newpost['topicid'] = $spVars['insertid']; $this->newpost = apply_filters('sph_new_topic_data_saved', $this->newpost); } else { $this->abort = true; $this->message = sp_text('Unable to save new topic record'); return; } # failsafe: check the topic slug and if empty use the topic id if (empty($this->newpost['topicslug'])) { $this->newpost['topicslug'] = 'topic-' . $this->newpost['topicid']; spdb_query('UPDATE ' . SFTOPICS . " SET topic_slug='" . $this->newpost['topicslug'] . "' WHERE topic_id=" . $this->newpost['topicid']); } } # Write the post # Double check forum id is correct - it has been known for a topic to have just been moved! $this->newpost['forumid'] = spdb_table(SFTOPICS, 'topic_id=' . $this->newpost['topicid'], 'forum_id'); # Get post count in topic to enable post index setting $index = spdb_count(SFPOSTS, 'topic_id = ' . $this->newpost['topicid']); $index++; $this->newpost['postindex'] = $index; # if topic lock set in post reply update topic (post only) if ($this->action == 'post' && $this->newpost['topicstatus']) { spdb_query('UPDATE ' . SFTOPICS . ' SET topic_status=1 WHERE topic_id=' . $this->newpost['topicid']); } $this->newpost = apply_filters('sph_new_post_pre_data_saved', $this->newpost); $spdb = new spdbComplex(); $spdb->table = SFPOSTS; $spdb->fields = array('post_content', 'post_date', 'topic_id', 'forum_id', 'user_id', 'guest_name', 'guest_email', 'post_pinned', 'post_index', 'post_status', 'poster_ip', 'source'); $spdb->data = array($this->newpost['postcontent'], $this->newpost['postdate'], $this->newpost['topicid'], $this->newpost['forumid'], $this->newpost['userid'], $this->newpost['guestname'], $this->newpost['guestemail'], $this->newpost['postpinned'], $this->newpost['postindex'], $this->newpost['poststatus'], $this->newpost['posterip'], $this->newpost['source']); $spdb = apply_filters('sph_new_post_data', $spdb); $this->newpost['db'] = $spdb->insert(); if ($this->newpost['db'] == true) { $this->newpost['postid'] = $spVars['insertid']; $this->newpost = apply_filters('sph_new_post_data_saved', $this->newpost); } else { $this->abort = true; $this->message = sp_text('Unable to save new post message'); return; } # Update the timestamp of the last post sp_update_option('poststamp', $this->newpost['postdate']); $this->returnURL = sp_build_url($this->newpost['forumslug'], $this->newpost['topicslug'], 0, $this->newpost['postid']); if ($this->newpost['poststatus']) { $this->newpost['submsg'] .= ' - ' . sp_text('placed in moderation') . ' '; } # Now for all that post-save processing required if ($this->guest) { $sfguests = sp_get_option('sfguests'); if ($sfguests['storecookie']) { sp_write_guest_cookie($this->newpost['guestname'], $this->newpost['guestemail']); } } else { $postcount = sp_get_member_item($this->newpost['userid'], 'posts'); $postcount++; sp_update_member_item($this->newpost['userid'], 'posts', $postcount); # see if postcount qualifies member for new user group membership # get rankings information if (!$this->admin) { # ignore for admins as they dont belong to user groups global $spGlobals; if (!empty($spGlobals['forum_rank'])) { $index = 0; foreach ($spGlobals['forum_rank'] as $x => $info) { $rankdata['title'][$index] = $x; $rankdata['posts'][$index] = $info['posts']; $rankdata['usergroup'][$index] = $info['usergroup']; $index++; } # sort rankings array_multisort($rankdata['posts'], SORT_ASC, $rankdata['title'], $rankdata['usergroup']); # check for new ranking for ($x = 0; $x < count($rankdata['posts']); $x++) { if ($postcount <= $rankdata['posts'][$x] && !empty($rankdata['usergroup'][$x])) { # if a user group is tied to forum rank add member to the user group if ($rankdata['usergroup'][$x] != 'none') { sp_add_membership($rankdata['usergroup'][$x], $this->newpost['userid']); } break; # only update highest rank } } } } } # set new url for email $this->newpost['url'] = $this->returnURL; # allow plugins to add to post message $this->newpost['submsg'] = apply_filters('sph_post_message', $this->newpost['submsg'], $this->newpost); # add to or remove from admins new post queue if ($this->admin || $this->moderator) { # remove topic from waiting... sp_remove_from_waiting(false, $this->newpost['topicid']); } else { # add topic to waiting sp_add_to_waiting($this->newpost['topicid'], $this->newpost['forumid'], $this->newpost['postid'], $this->newpost['userid']); } # if a new post remove topic from the users new post list if in it if ($this->action == 'post') { sp_remove_users_newposts($this->newpost['topicid'], $this->newpost['userid']); } # do we need to approve any posts in moderation in this topic? if ($this->admin && $spGlobals['admin']['sfadminapprove'] || $this->moderator && $spGlobals['admin']['sfmoderapprove']) { sp_approve_post(true, 0, $this->newpost['topicid'], false, $this->newpost['forumid']); } # if post in moderatiuon then add entry to notices if ($this->newpost['poststatus'] != 0) { $nData = array(); $nData['user_id'] = $this->newpost['userid']; $nData['guest_email'] = $this->newpost['guestemail']; $nData['post_id'] = $this->newpost['postid']; $nData['link'] = $this->newpost['url']; $nData['link_text'] = $this->newpost['topicname']; $nData['message'] = sp_text('Your post is awaiting moderation in the topic'); $nData['expires'] = time() + 30 * 24 * 60 * 60; # 30 days; 24 hours; 60 mins; 60secs sp_add_notice($nData); } # Add this new item to the new tpic/post cache $meta = sp_get_sfmeta_key('topic_cache', 'new'); $cacheSize = sp_get_option('topic_cache'); $a = array(); $a[LISTFORUM] = (int) $this->newpost['forumid']; $a[LISTTOPIC] = (int) $this->newpost['topicid']; $a[LISTPOST] = (int) $this->newpost['postid']; $a[LISTSTATUS] = (int) $this->newpost['poststatus']; if (isset($spGlobals['topic_cache']['new']) && !empty($spGlobals['topic_cache']['new'])) { array_unshift($spGlobals['topic_cache']['new'], $a); if (count($spGlobals['topic_cache']['new']) > $cacheSize) { array_pop($spGlobals['topic_cache']['new']); } } sp_update_sfmeta('topic_cache', 'new', $spGlobals['topic_cache']['new'], $meta, true); # remove group level caches to accommodate new post spdb_query('DELETE FROM ' . SFCACHE . " WHERE cache_id LIKE '%*group'"); # save post in cache for flood control sp_add_cache('floodcontrol', time() + sp_get_option('floodcontrol')); # Update forum, topic and post index data sp_build_post_index($this->newpost['topicid']); sp_build_forum_index($this->newpost['forumid']); # send out email notifications sp_email_notifications($this->newpost); # one final filter - just in case do_action_ref_array('sph_post_new_completed', array(&$this)); # and a final action hook do_action('sph_new_post', $this->newpost); do_action('sph_post_create', $this->newpost); }
sp_response($section); } sp_bump_build($build, 12749); # Start of Upgrade Routines - 5.5.7 ============================================================ sp_bump_build($build, 12756); $section = 12758; if ($build < $section) { # update autoupdate meta to not have full url, just the ahah loader info $spMeta = spdb_table(SFMETA, 'meta_type="autoupdate"'); if (!empty($spMeta)) { foreach ($spMeta as $meta) { if (!empty($meta)) { $value = unserialize($meta->meta_value); $value[1] = str_replace(site_url('', 'http') . '/index.php?', '', $value[1]); $value[1] = str_replace(site_url('', 'https') . '/index.php?', '', $value[1]); sp_update_sfmeta('autoupdate', $meta->meta_key, $value, $meta->meta_id, $meta->autoload); } } } sp_response($section); } $section = 12760; if ($build < $section) { # convert table collation $tables = sp_get_option('installed_tables'); foreach ($tables as $table) { sp_convert_table_to_utf8mb4($table); } sp_response($section); } sp_bump_build($build, 12968);
function spa_save_css_data() { $css = ''; $curTheme = sp_get_option('sp_current_theme'); $css = esc_attr($_POST['spnewcontent']); $css = sp_filter_save_nohtml($css); if ($_POST['metaId'] == 0) { sp_add_sfmeta('css', $curTheme['theme'], $css, true); } else { sp_update_sfmeta('css', $curTheme['theme'], $css, $_POST['metaId'], true); } $msg = spa_text('Custom theme CSS updated'); return $msg; }
} # add new column for meta data to user activity table spdb_query('ALTER TABLE ' . SFUSERACTIVITY . ' ADD (meta_id BIGINT(20))'); sp_response($section); } $section = 11423; if ($build < $section) { spdb_query('ALTER TABLE ' . SFFORUMS . ' ADD (forum_icon_locked varchar(50) default NULL)'); sp_response($section); } $section = 11447; if ($build < $section) { # set autoload flag to true for autoupdates $meta = sp_get_sfmeta('autoupdate', 'user'); if (!empty($meta[0])) { sp_update_sfmeta('autoupdate', 'user', $meta[0]['meta_value'], $meta[0]['meta_id'], 1); } sp_response($section); } # Start of Upgrade Routines - 5.5.1 ============================================================ $section = 11493; if ($build < $section) { # Open build number for 5.5.1 sp_response($section); } $section = 11500; if ($build < $section) { # Begin Database Clean-up routines include SPBOOT . 'install/sp-schema.php'; sp_rebuild_table_list(); sp_response($section);