function sp_profile_add_menu($menu, $name, $form, $order = 0, $display = 1, $auth = '') { # sanitize before use $menu = sp_filter_title_save($menu); $slug = sp_create_slug($name, false); $name = sp_filter_title_save($name); $form = str_replace('\\', '/', $form); # sanitize for Win32 installs $display = (int) $display; $auth = sp_esc_str($auth); # get profile tabs $tabs = sp_profile_get_tabs(); if (empty($tabs)) { return false; } # find the requested tab foreach ($tabs as &$tab) { $found = false; if ($tab['name'] == $menu) { # make sure the menu doesnt already exist on this tab if (isset($tab['menus']) && $tab['menus']) { foreach ($tab['menus'] as $thisMenu) { if ($thisMenu['name'] == $name) { return -1; } } } # insert the new menu if (empty($order)) { $order = empty($tab['menus']) ? 0 : count($tab['menus']); } $newtab = array(); $newtab['name'] = $name; $newtab['slug'] = $slug; $newtab['form'] = $form; $newtab['display'] = $display; $newtab['auth'] = $auth; sp_array_insert($tab['menus'], $newtab, $order); # make sure its compact $tab['menus'] = array_values($tab['menus']); # menu added so break out $found = true; break; } } # if tab wasnt found bail if (!$found) { return false; } # save the new profile tabs $result = sp_add_sfmeta('profile', 'tabs', $tabs); return $result; }
function spa_save_smileys_data() { global $spPaths; check_admin_referer('forum-adminform_smileys', 'forum-adminform_smileys'); $mess = ''; # save the smileys $sfsmileys = array(); $path = SF_STORE_DIR . '/' . $spPaths['smileys'] . '/'; $smileyname = $_POST['smname']; for ($x = 0; $x < count($smileyname); $x++) { $file = $_POST['smfile'][$x]; $path_info = pathinfo($path . $file); $fn = strtolower($path_info['filename']); if (file_exists($path . $file)) { if (empty($smileyname[$x])) { $smileyname[$x] = $fn; } $thisname = urldecode(sp_create_slug($smileyname[$x], false)); $code = empty($_POST['smcode'][$x]) ? $fn : $_POST['smcode'][$x]; $code = sp_create_slug($code, false); trim($code, ':'); if (empty($code)) { $code = $thisname; } $code = ':' . $code . ':'; $sfsmileys[$thisname][] = sp_filter_filename_save($_POST['smfile'][$x]); $sfsmileys[$thisname][] = $code; $sfsmileys[$thisname][] = isset($_POST['sminuse-' . $smileyname[$x]]) ? 1 : 0; $sfsmileys[$thisname][] = $x; if (isset($_POST['smbreak-newbreak-' . $x])) { $_POST['smbreak-' . $smileyname[$x]] = $_POST['smbreak-newbreak-' . $x]; } $sfsmileys[$thisname][] = isset($_POST['smbreak-' . $smileyname[$x]]) ? 1 : 0; } } # load current saved smileys to get meta id $meta = sp_get_sfmeta('smileys', 'smileys'); sp_update_sfmeta('smileys', 'smileys', $sfsmileys, $meta[0]['meta_id'], true); do_action('sph_component_smileys_save'); $mess .= spa_text('Smileys component updated'); return $mess; }
function sp_delete_auth_cat($id_or_name) { # if its not id, lets get the id for easy removal of auth cat from auths if (!is_numeric($id_or_name)) { $slug = sp_create_slug($id_or_name, true, SFAUTHCATS, 'authcat_slug'); $id_or_name = spdb_table(SFAUTHCATS, 'authcat_slug="' . $slug . '"', 'authcat_id'); } # now lets delete the auth cat $success = spdb_query('DELETE FROM ' . SFAUTHCATS . " WHERE authcat_id={$id_or_name}"); # if successful, need to remove that cat from the auths and replace with default if ($success) { spdb_query('UPDATE ' . SFAUTHS . " SET auth_cat=0 WHERE authcat_id={$id_or_name}"); } return $success; }
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_PostIndexUserMemberships($args = '', $noMembershipLabel = '', $adminLabel = '') { global $spThisPost, $spThisPostUser, $spPaths; $defs = array('tagId' => 'spPostIndexUserMemberships%ID%', 'tagClass' => 'spPostUserMemberships', 'stacked' => 1, 'showTitle' => 1, 'showBadge' => 1, 'echo' => 1, 'get' => 0); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_PostIndexUserMemberships_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $stacked = (int) $stacked; $showTitle = (int) $showTitle; $showBadge = (int) $showBadge; $echo = (int) $echo; $get = (int) $get; $tagId = str_ireplace('%ID%', $spThisPost->post_id, $tagId); if ($get) { return $spThisPostUser->memberships; } $show = false; $tout = "<div id='{$tagId}' class='{$tagClass}'>"; if (!empty($spThisPostUser->memberships)) { $first = true; $split = $stacked ? '<br />' : ', '; foreach ($spThisPostUser->memberships as $membership) { if (!$first) { $tout .= $split; } if ($showBadge && !empty($membership['usergroup_badge'])) { $show = true; $tout .= "<img src='" . SF_STORE_URL . '/' . $spPaths['ranks'] . '/' . $membership['usergroup_badge'] . "' alt='' />"; $tout .= '<br />'; } if ($showTitle) { $show = true; $tout .= '<span class="spUserGroup-' . sp_create_slug($membership['usergroup_name'], false) . '">' . $membership['usergroup_name'] . '</span><br />'; } $first = false; } } else { if ($spThisPostUser->admin) { if ($showTitle && !empty($adminLabel)) { $show = true; $tout .= sp_filter_title_display($adminLabel); } } else { if (!empty($noMembershipLabel)) { $show = true; $tout .= sp_filter_title_display($noMembershipLabel); } } } $tout .= "</div>\n"; $out = $show ? $tout : ''; $out = apply_filters('sph_PostIndexUserMemberships', $out, $a); if ($echo) { echo $out; } else { return $out; } }
if (isset($_GET['id'])) { $id = sp_esc_int($_GET['id']); } if (isset($_GET['title'])) { $title = sp_esc_str($_GET['title']); } if (isset($_GET['slugaction'])) { $slugaction = sp_esc_str($_GET['slugaction']); } if ($action == 'slug') { $checkdupes = true; if ($slugaction == 'edit') { $checkdupes = false; } $newslug = sp_create_slug($title, $checkdupes, SFFORUMS, 'forum_slug'); $newslug = sp_create_slug($newslug, $checkdupes, SFWPPOSTS, 'post_name'); # must also check WP posts table as WP can mistake forum slug for WP post echo $newslug; } if ($action == 'delicon') { global $spPaths; $file = sp_esc_str($_GET['file']); $path = SF_STORE_DIR . '/' . $spPaths['custom-icons'] . '/' . $file; @unlink($path); } if ($action == 'delimage') { global $spPaths; $file = sp_esc_str($_GET['file']); $path = SF_STORE_DIR . '/' . $spPaths['forum-images'] . '/' . $file; @unlink($path); }
function validateData() { $this->abort = false; $this->newpost['action'] = $this->action; # Check flood control (done here vice validatePermission() so we can use the return to post feature) if (!sp_get_auth('bypass_flood_control', $this->newpost['forumid'], $this->userid)) { $flood = sp_get_cache('floodcontrol'); if (!empty($flood) && time() < $flood) { $this->abort = true; $this->message = sp_text('Flood control exceeded, please slow down - Post cannot be saved yet'); return; } } # Check topic name if (empty($this->newpost['topicname'])) { $this->abort = true; $this->message = sp_text('No topic name has been entered and post cannot be saved'); return; } else { $this->newpost['topicname'] = sp_filter_title_save($this->newpost['topicname'], SFTOPICS, 'topic_name'); } # Check Post Content if (empty($this->newpost['postcontent'])) { $this->abort = true; $this->message = sp_text('No topic post has been entered and post cannot be saved'); return; } else { $this->newpost['postcontent_unescaped'] = sp_filter_content_save($this->newpost['postcontent'], 'new', false, SFPOSTS, 'post_content'); $this->newpost['postcontent'] = sp_filter_content_save($this->newpost['postcontent'], 'new', true, SFPOSTS, 'post_content'); } # Check and set user names/ids etc if ($this->guest) { $sfguests = sp_get_option('sfguests'); if (empty($this->newpost['guestname']) || (empty($this->newpost['guestemail']) || !is_email($this->newpost['guestemail'])) && $sfguests['reqemail']) { $this->abort = true; $this->message = sp_text('Guest name and valid email address required'); return; } # force maximum lengths $this->newpost['guestname'] = substr(sp_filter_name_save($this->newpost['guestname']), 0, 20); $this->newpost['guestemail'] = substr(sp_filter_email_save($this->newpost['guestemail']), 0, 50); $this->newpost['postername'] = $this->newpost['guestname']; $this->newpost['posteremail'] = $this->newpost['guestemail']; # check for blacklisted guest name $blockedGuest = sp_get_option('guest-name'); if (!empty($blockedGuest)) { $names = explode(',', $blockedGuest); foreach ($names as $name) { if (strtolower(trim($name)) == strtolower($this->newpost['guestname'])) { $this->abort = true; $this->message = sp_text('The guest name you have chosen is not allowed on this site'); return; } } } # check that the guest name is not the same as a current user $checkdupe = spdb_table(SFMEMBERS, "display_name='" . $this->newpost['guestname'] . "'", 'display_name'); if (!empty($checkdupe)) { $this->abort = true; $this->message = sp_text('This user name already belongs to a forum member'); return; } } # Check if links allowed or if maxmium links have been exceeded $sffilters = sp_get_option('sffilters'); if (!$this->admin) { $links = $this->count_links(); if (sp_get_auth('create_links', $this->newpost['forumid'], $this->userid)) { if ($sffilters['sfmaxlinks'] > 0 && $links > $sffilters['sfmaxlinks']) { $this->abort = true; $this->message = sp_text('Maximum number of allowed links exceeded') . ': ' . $sffilters['sfmaxlinks'] . ' ' . sp_text('allowed'); return; } } else { if ($links > 0) { $this->abort = true; $this->message = sp_text('You are not allowed to put links in post content'); return; } } } # Check if maxmium smileys have been exceeded if (!$this->admin) { if (isset($sffilters['sfmaxsmileys']) && $sffilters['sfmaxsmileys'] > 0 && $this->count_smileys() > $sffilters['sfmaxsmileys']) { $this->abort = true; $this->message = sp_text('Maximum number of allowed smileys exceeded') . ': ' . $sffilters['sfmaxsmileys'] . ' ' . sp_text('allowed'); return; } } # Check for duplicate post of option is set if ($this->member && $sffilters['sfdupemember'] == true || $this->guest && $sffilters['sfdupeguest'] == true) { # But not admin or moderator if (!$this->admin && !$this->moderator) { $dupecheck = spdb_table(SFPOSTS, 'forum_id = ' . $this->newpost['forumid'] . ' AND topic_id=' . $this->newpost['topicid'] . " AND post_content='" . $this->newpost['postcontent'] . "' AND poster_ip='" . $this->newpost['posterip'] . "'", 'row', '', '', ARRAY_A); if ($dupecheck) { $this->abort = true; $this->message = sp_text('Duplicate post refused'); return; } } } # Establish moderation status $bypassAll = sp_get_auth('bypass_moderation', $this->newpost['forumid'], $this->userid); $bypassOnce = sp_get_auth('bypass_moderation_once', $this->newpost['forumid'], $this->userid); if ($bypassAll == true && $bypassOnce == true) { $this->newpost['poststatus'] = 0; } else { if ($bypassAll == false && $bypassOnce == false) { $this->newpost['poststatus'] = 1; } else { if ($bypassAll == true && $bypassOnce == false) { $this->newpost['poststatus'] = 1; if ($this->member) { $prior = spdb_table(SFPOSTS, 'user_id=' . $this->newpost['userid'] . ' AND post_status=0', 'row', '', '1'); if ($prior) { $this->newpost['poststatus'] = 0; } } else { if ($this->guest) { $prior = spdb_table(SFPOSTS, "guest_name='" . $this->newpost['guestname'] . "' AND guest_email='" . $this->newpost['guestemail'] . "' AND post_status=0", 'row', '', '1'); if ($prior) { $this->newpost['poststatus'] = 0; } } } } else { $this->newpost['poststatus'] = 1; } } } # Finally one or two other data items if ($this->action == 'topic') { $this->newpost['topicslug'] = sp_create_slug($this->newpost['topicname'], true, SFTOPICS, 'topic_slug'); } else { $this->newpost['emailprefix'] = 'Re: '; } $this->newpost['groupname'] = sp_get_group_name_from_forum($this->newpost['forumid']); if (empty($this->newpost['forumname'])) { $this->newpost['forumname'] = spdb_table(SFFORUMS, "forum_slug='" . $this->newpost['forumslug'] . "'", 'forum_name'); } $this->newpost = apply_filters('sph_post_data_validation', $this->newpost); do_action('sph_pre_post_create', $this->newpost); $this->newpost = apply_filters('sph_new_forum_post', $this->newpost); }
function sp_track_online() { global $spThisUser, $spVars, $spDevice; # dont track feed views if ($spVars['pageview'] == 'feed') { return; } # Update tracking if ($spThisUser->member) { # it's a member $trackUserId = $spThisUser->ID; $trackName = $spThisUser->user_login; } else { # Unknown guest $trackUserId = 0; $trackName = $spThisUser->ip; } $track = spdb_table(SFTRACK, "trackname='{$trackName}'", 'row'); $now = current_time('mysql'); $forumId = isset($spVars['forumid']) ? $spVars['forumid'] : 0; $topicId = isset($spVars['topicid']) ? $spVars['topicid'] : 0; $pageview = $spVars['pageview']; # handle sneak peek if (!empty($topicId)) { if (!sp_get_auth('view_forum', $forumId)) { return; } } else { if (!empty($forumId)) { if (!sp_can_view($forumId, 'topic-title')) { return; } } } # update or start tracking if ($track) { # they are still here spdb_query("UPDATE " . SFTRACK . "\n\t\t\t\t SET trackdate='" . $now . "', forum_id=" . $forumId . ", topic_id=" . $topicId . ", pageview='{$pageview}'\n\t\t\t\t WHERE id=" . $track->id); if ($spThisUser->member) { sp_update_users_newposts(); } $spThisUser->trackid = $track->id; $spThisUser->session_first_visit = false; $spThisUser->notification = $track->notification; } else { # newly arrived # set deice being used $device = 'D'; switch ($spDevice) { case 'mobile': $device = 'M'; break; case 'tablet': $device = 'T'; break; case 'desktop': $device = 'D'; break; } # display classes $display = 'spType-' . $spThisUser->usertype; if (!empty($spThisUser->rank)) { $display .= ' spRank-' . sp_create_slug($spThisUser->rank[0]['name'], false); } if (!empty($spThisUser->special_rank)) { foreach ($spThisUser->special_rank as $rank) { $display .= ' spSpecialRank-' . sp_create_slug($rank['name'], false); } } if (!empty($spThisUser->memberships)) { foreach ($spThisUser->memberships as $membership) { $display .= ' spUsergroup-' . sp_create_slug($membership['usergroup_name'], false); } } spdb_query("INSERT INTO " . SFTRACK . "\n\t\t\t \t (trackuserid, trackname, forum_id, topic_id, trackdate, pageview, device, display) VALUES\n\t\t\t \t ({$trackUserId}, '{$trackName}', {$forumId}, {$topicId}, '{$now}', '{$pageview}', '{$device}', '{$display}')"); $spThisUser->trackid = $spVars['insertid']; $spThisUser->session_first_visit = true; if ($spThisUser->member) { sp_update_users_newposts(); } } # Check for expired tracking - some may have left the scene $splogin = sp_get_option('sflogin'); $timeout = $splogin['sptimeout']; if (!$timeout) { $timeout = 20; } $expired = spdb_table(SFTRACK, "trackdate < DATE_SUB('{$now}', INTERVAL {$timeout} MINUTE)"); if ($expired) { # if any Members expired - update user meta foreach ($expired as $expire) { if ($expire->trackuserid > 0) { sp_set_last_visited($expire->trackuserid); } } # finally delete them spdb_query("DELETE FROM " . SFTRACK . "\n\t\t\t\t\tWHERE trackdate < DATE_SUB('{$now}', INTERVAL {$timeout} MINUTE)"); } }
function sp_SectionStart($args = '', $sectionName = '') { $defs = array('tagClass' => 'spPlainSection', 'tagId' => '', 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_SectionStart_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagClass = esc_attr($tagClass); $tagId = esc_attr($tagId); $echo = (int) $echo; # notifiy custom code before we start the section code do_action('sph_BeforeSectionStart', $sectionName, $a); do_action('sph_BeforeSectionStart_' . $sectionName, $a); # specific formatting based on 'defined' names $rowClass = ''; $rowId = ''; switch ($sectionName) { case 'group': global $spGroupView, $spThisGroup; if (isset($spGroupView)) { $rowClass .= $spGroupView->currentGroup % 2 ? ' spOdd' : ' spEven'; } if (isset($spThisGroup)) { $rowId .= "group{$spThisGroup->group_id}"; } break; case 'forumlist': global $spThisGroup; if (isset($spThisGroup)) { $rowId .= "forumlist{$spThisGroup->group_id}"; } break; case 'subforumlist': global $spThisForum; if (isset($spThisForum)) { $rowId .= "subforumlist{$spThisForum->forum_id}"; } break; case 'topiclist': global $spThisForum; if (isset($spThisForum)) { $rowId .= "topiclist{$spThisForum->forum_id}"; } break; case 'postlist': global $spThisTopic; if (isset($spThisTopic)) { $rowId .= "postlist{$spThisTopic->topic_id}"; } break; case 'forum': global $spGroupView, $spThisForum; if (isset($spGroupView)) { $rowClass .= $spGroupView->currentForum % 2 ? ' spOdd' : ' spEven'; } if (isset($spThisForum)) { if ($spThisForum->forum_status) { $rowClass .= ' spLockedForum'; } if (isset($spThisForum->unread) && $spThisForum->unread) { $rowClass .= ' spUnreadPosts'; } $rowId .= "forum{$spThisForum->forum_id}"; } break; case 'subForum': global $spForumView, $spThisSubForum; if (isset($spForumView)) { $rowClass .= $spForumView->currentChild % 2 ? ' spOdd' : ' spEven'; } if (isset($spThisSubForum)) { if ($spThisSubForum->forum_status) { $rowClass .= ' spLockedForum'; } if ($spThisSubForum->unread) { $rowClass .= ' spUnreadPosts'; } $rowId .= "subforum{$spThisSubForum->forum_id}"; } break; case 'topic': global $spForumView, $spThisTopic; if (isset($spForumView)) { $rowClass .= $spForumView->currentTopic % 2 ? ' spOdd' : ' spEven'; } if (isset($spThisTopic)) { if ($spThisTopic->topic_status) { $rowClass .= ' spLockedTopic'; } if ($spThisTopic->topic_pinned) { $rowClass .= ' spPinnedTopic'; } if ($spThisTopic->unread) { $rowClass .= ' spUnreadPosts'; } $rowId .= "topic{$spThisTopic->topic_id}"; } break; case 'post': global $spThisUser, $spTopicView, $spThisTopic, $spThisPost; if (isset($spTopicView)) { $rowClass .= $spTopicView->currentPost % 2 ? ' spOdd' : ' spEven'; } if (isset($spThisPost)) { if ($spThisPost->post_pinned) { $rowClass .= ' spPinnedPost'; } if ($spThisPost->new_post) { $rowClass .= ' spUnreadPosts'; } if ($spThisPost->post_index == 1) { $rowClass .= ' spFirstPost'; } $rowClass .= ' spType-' . $spThisPost->postUser->usertype; if (!empty($spThisPost->postUser->rank)) { $rowClass .= ' spRank-' . sp_create_slug($spThisPost->postUser->rank[0]['name'], false); } if (!empty($spThisPost->postUser->special_rank)) { foreach ($spThisPost->postUser->special_rank as $rank) { $rowClass .= ' spSpecialRank-' . sp_create_slug($rank['name'], false); } } if (!empty($spThisPost->postUser->memberships)) { foreach ($spThisPost->postUser->memberships as $membership) { $rowClass .= ' spUsergroup-' . sp_create_slug($membership['usergroup_name'], false); } } if ($spThisPost->user_id) { if ($spThisPost->user_id == $spThisUser->ID) { $rowClass .= ' spCurUserPost'; } else { $rowClass .= ' spUserPost'; } if ($spThisTopic->topic_starter == $spThisPost->user_id) { $rowClass .= ' spAuthorPost'; } } else { $rowClass .= ' spGuestPost'; } $rowId .= "post{$spThisPost->post_id}"; } break; case 'list': global $spListView, $spThisListTopic; if (isset($spListView)) { $rowClass .= $spListView->currentTopic % 2 ? ' spOdd' : ' spEven'; } if (isset($spThisListTopic)) { $rowId .= "listtopic{$spThisListTopic->topic_id}"; } break; case 'usergroup': global $spMembersList; if (isset($spMembersList)) { $rowClass .= $spMembersList->currentMemberGroup % 2 ? ' spOdd' : ' spEven'; } break; case 'member': global $spMembersList; if (isset($spMembersList)) { $rowClass .= $spMembersList->currentMember % 2 ? ' spOdd' : ' spEven'; } break; case 'memberGroup': global $spThisMemberGroup; if (isset($spThisMemberGroup)) { $rowClass .= ' spUsergroup-' . sp_create_slug($spThisMemberGroup->usergroup_name, false); } break; default: if (!empty($tagId)) { $rowId .= $tagId; } break; } # allow filtering of the row class $rowClass = apply_filters('sph_SectionStartRowClass', $rowClass, $sectionName, $a); $rowId = apply_filters('sph_SectionStartRowID', $rowId, $sectionName, $a); # output section starting div $class = ''; if (!empty($rowId)) { $rowId = " id='{$rowId}'"; } if (!empty($tagClass) || !empty($rowClass)) { $class = " class='{$tagClass}{$rowClass}'"; } $out = "<div{$class}{$rowId}>\n"; $out = apply_filters('sph_SectionStart', $out, $sectionName, $a); if ($echo) { echo $out; # notifiy custom code that section has started # only valid if content is echoed out ($display=1) do_action('sph_AfterSectionStart', $sectionName, $a); do_action('sph_AfterSectionStart_' . $sectionName, $a); } else { return $out; } }
function spa_save_forums_edit_forum() { check_admin_referer('forum-adminform_forumedit', 'forum-adminform_forumedit'); $forumdata = array(); $forumdata['group_id'] = sp_esc_int($_POST['group_id']); if ($_POST['cparent'] == 0) { $forumdata['parent'] = 0; } else { $forumdata['parent'] = sp_esc_int($_POST['parent']); } if ($forumdata['parent'] != $_POST['cparent']) { $forumdata['group_id'] = spdb_table(SFFORUMS, 'forum_id=' . $forumdata['parent'], 'group_id'); } $forum_id = sp_esc_int($_POST['forum_id']); $forumdata['forum_name'] = sp_filter_title_save(trim($_POST['forum_name'])); if (!empty($_POST['cforum_slug'])) { $forumdata['forum_slug'] = sp_create_slug($_POST['cforum_slug'], false); } else { $forumdata['forum_slug'] = sp_create_slug($forumdata['forum_name'], true, SFFORUMS, 'forum_slug'); $forumdata['forum_slug'] = sp_create_slug($forumdata['forum_slug'], true, SFWPPOSTS, 'post_name'); # must also check WP posts table as WP can mistake forum slug for WP post } $forumdata['forum_desc'] = sp_filter_text_save(trim($_POST['forum_desc'])); $forumdata['forum_status'] = 0; if (isset($_POST['forum_status'])) { $forumdata['forum_status'] = 1; } $forumdata['forum_rss_private'] = 0; if (isset($_POST['forum_private'])) { $forumdata['forum_rss_private'] = 1; } $forumdata['forum_keywords'] = sp_filter_title_save(trim($_POST['forum_keywords'])); if (!empty($_POST['forum_icon'])) { # Check new icon exists $forumdata['forum_icon'] = sp_filter_title_save(trim($_POST['forum_icon'])); $path = SFCUSTOMDIR . $forumdata['forum_icon']; if (!file_exists($path)) { $mess = sprintf(spa_text('Custom icon %s does not exist'), $forumdata['forum_icon']); return $mess; } } else { $forumdata['forum_icon'] = null; } if (!empty($_POST['forum_icon_new'])) { # Check new icon exists $forumdata['forum_icon_new'] = sp_filter_title_save(trim($_POST['forum_icon_new'])); $path = SFCUSTOMDIR . $forumdata['forum_icon_new']; if (!file_exists($path)) { $mess = sprintf(spa_text('Custom icon %s does not exist'), $forumdata['forum_icon_new']); return $mess; } } else { $forumdata['forum_icon_new'] = null; } if (!empty($_POST['forum_icon_locked'])) { # Check new icon exists $forumdata['forum_icon_locked'] = sp_filter_title_save(trim($_POST['forum_icon_locked'])); $path = SFCUSTOMDIR . $forumdata['forum_icon_locked']; if (!file_exists($path)) { $mess = sprintf(spa_text('Custom icon %s does not exist'), $forumdata['forum_icon_locked']); return $mess; } } else { $forumdata['forum_icon_locked'] = null; } if (!empty($_POST['topic_icon'])) { # Check new icon exists $forumdata['topic_icon'] = sp_filter_title_save(trim($_POST['topic_icon'])); $path = SFCUSTOMDIR . $forumdata['topic_icon']; if (!file_exists($path)) { $mess = sprintf(spa_text('Custom icon %s does not exist'), $forumdata['topic_icon']); return $mess; } } else { $forumdata['topic_icon'] = null; } if (!empty($_POST['topic_icon_new'])) { # Check new icon exists $forumdata['topic_icon_new'] = sp_filter_title_save(trim($_POST['topic_icon_new'])); $path = SFCUSTOMDIR . $forumdata['topic_icon_new']; if (!file_exists($path)) { $mess = sprintf(spa_text('Custom icon %s does not exist'), $forumdata['topic_icon_new']); return $mess; } } else { $forumdata['topic_icon_new'] = null; } if (!empty($_POST['topic_icon_locked'])) { # Check new icon exists $forumdata['topic_icon_locked'] = sp_filter_title_save(trim($_POST['topic_icon_locked'])); $path = SFCUSTOMDIR . $forumdata['topic_icon_locked']; if (!file_exists($path)) { $mess = sprintf(spa_text('Custom icon %s does not exist'), $forumdata['topic_icon_locked']); return $mess; } } else { $forumdata['topic_icon_locked'] = null; } if (!empty($_POST['topic_icon_pinned'])) { # Check new icon exists $forumdata['topic_icon_pinned'] = sp_filter_title_save(trim($_POST['topic_icon_pinned'])); $path = SFCUSTOMDIR . $forumdata['topic_icon_pinned']; if (!file_exists($path)) { $mess = sprintf(spa_text('Custom icon %s does not exist'), $forumdata['topic_icon_pinned']); return $mess; } } else { $forumdata['topic_icon_pinned'] = null; } if (!empty($_POST['feature_image'])) { # Check new icon exists $forumdata['feature_image'] = sp_filter_title_save(trim($_POST['feature_image'])); $path = SFFEATUREDDIR . $forumdata['feature_image']; if (!file_exists($path)) { $mess = sprintf(spa_text('Featured Image %s does not exist'), $forumdata['feature_image']); return $mess; } } else { $forumdata['feature_image'] = null; } if (isset($_POST['forum_rss'])) { $forumdata['forum_rss'] = sp_filter_save_cleanurl($_POST['forum_rss']); } else { $forumdata['forum_rss'] = sp_filter_save_cleanurl($_POST['cforum_rss']); } $forumdata['forum_message'] = sp_filter_text_save(trim($_POST['forum_message'])); # has the forum changed to a new group if ($forumdata['group_id'] != $_POST['cgroup_id'] && !empty($_POST['cchildren'])) { spa_update_parent_group($_POST['cgroup_id'], $forumdata['group_id'], $forum_id); } # Finally - we can save the updated forum record! if (empty($forumdata['forum_slug'])) { $forumslug = sp_create_slug($forumdata['forum_name'], true, SFFORUMS, 'forum_slug'); $forumslug = sp_create_slug($forumslug, true, SFWPPOSTS, 'post_name'); # must also check WP posts table as WP can mistake forum slug for WP post if (empty($forumslug)) { $forumslug = 'forum-' . $forum_id; } } else { $forumslug = $forumdata['forum_slug']; } $sql = 'UPDATE ' . SFFORUMS . ' SET '; $sql .= 'forum_name="' . $forumdata['forum_name'] . '", '; $sql .= 'forum_slug="' . $forumslug . '", '; $sql .= 'forum_desc="' . $forumdata['forum_desc'] . '", '; $sql .= 'group_id=' . $forumdata['group_id'] . ', '; $sql .= 'forum_status=' . $forumdata['forum_status'] . ', '; $sql .= 'forum_rss_private=' . $forumdata['forum_rss_private'] . ', '; $sql .= 'forum_icon="' . $forumdata['forum_icon'] . '", '; $sql .= 'forum_icon_new="' . $forumdata['forum_icon_new'] . '", '; $sql .= 'forum_icon_locked="' . $forumdata['forum_icon_locked'] . '", '; $sql .= 'topic_icon="' . $forumdata['topic_icon'] . '", '; $sql .= 'topic_icon_new="' . $forumdata['topic_icon_new'] . '", '; $sql .= 'topic_icon_locked="' . $forumdata['topic_icon_locked'] . '", '; $sql .= 'topic_icon_pinned="' . $forumdata['topic_icon_pinned'] . '", '; $sql .= 'feature_image="' . $forumdata['feature_image'] . '", '; $sql .= 'forum_rss="' . $forumdata['forum_rss'] . '", '; $sql .= 'parent=' . $forumdata['parent'] . ', '; $sql .= 'forum_message="' . $forumdata['forum_message'] . '", '; $sql .= 'keywords="' . $forumdata['forum_keywords'] . '" '; $sql .= "WHERE forum_id={$forum_id}"; $success = spdb_query($sql); if ($success == false) { $mess = spa_text('Forum record update failed'); } else { if ($forumdata['parent'] != $_POST['cparent']) { spa_clean_forum_children(); } $mess = spa_text('Forum record update'); do_action('sph_forum_forum_edit', $forum_id); } # if the slug as changed we can try and update internal links in posts if ($_POST['cforum_slug'] != $forumslug) { sp_update_post_urls(sp_esc_str($_POST['cforum_slug']), $forumslug); } # clear out group cache tpo enable change_user sp_flush_cache('group'); return $mess; }
function spa_paint_storage_input($label, $name, $value, $path, $na = false) { global $tab, $tooltips, $spDevice; $found = false; $ok = false; if (file_exists($path)) { $found = true; $ok = true; } if ($found) { $icon1 = '<img src="' . SFADMINIMAGES . 'sp_Yes.png" title="' . spa_text('Location found') . '" alt="" style="vertical-align: middle;" /> '; } else { $icon1 = '<img src="' . SFADMINIMAGES . 'sp_No.png" title="' . spa_text('Location not found') . '" alt="" style="vertical-align: middle;" /> '; $icon2 = '<img src="' . SFADMINIMAGES . 'sp_NoWrite.png" title="' . spa_text('Write - denied') . '" alt="" style="vertical-align: middle;" /> '; } if ($found) { if (is_writable($path)) { $icon2 = '<img src="' . SFADMINIMAGES . 'sp_YesWrite.png" title="' . spa_text('Write - OK') . '" alt="" style="vertical-align: middle;" /> '; } else { $icon2 = '<img src="' . SFADMINIMAGES . 'sp_NoWrite.png" title="' . spa_text('Write - denied') . '" alt="" style="vertical-align: middle;" /> '; $ok = false; } } if ($na) { $icon2 = '<img src="' . SFADMINIMAGES . 'sp_NA.gif" title="" alt="" style="vertical-align: middle;" /> '; $ok = $found; } echo "<tr>\n"; if ($found) { $tdClass = 'wp-core-ui spWFBorder'; } else { $tdClass = 'wp-core-ui badLocation spWFBorder'; } echo "<td class='{$tdClass}' style='width:9%'>\n"; echo "<span class='sfalignleft'>{$icon1}<br />{$icon2}</span></td>"; echo "<td class='{$tdClass}'><strong>{$label}</strong>"; echo '<div class="clearboth"></div>'; echo SF_STORE_RELATIVE_BASE; echo '<input type="text" style="width:50%" class="wp-core-ui " tabindex="' . $tab . '" name="' . $name . '" value="' . esc_attr($value) . '" '; echo "/></td>\n"; if ($spDevice == 'desktop') { echo '<td class="' . $tdClass . '"><img src="' . SFADMINIMAGES . 'sp_Information.png" alt="" class="" title="' . $tooltips[sp_create_slug($name, false)] . '" /></td>'; } echo "</tr>\n"; $tab++; return $ok; }
if ($build < $section) { $users = spdb_select('set', 'SELECT user_id, admin_options FROM ' . SFMEMBERS . ' WHERE admin=1 OR moderator=1'); if ($users) { foreach ($users as $user) { $options = unserialize($user->admin_options); unset($options['colors']); sp_update_member_item($user->user_id, 'admin_options', $options); } } sp_response($section); } # Start of Upgrade Routines - 5.2 ============================================================ $section = 9175; if ($build < $section) { # create new permission for adding links to posts $authslug = sp_create_slug(spa_text('Creating'), false, SFAUTHCATS, ''); $cat = spdb_table(SFAUTHCATS, "authcat_slug='{$authslug}'", 'authcat_id'); sp_add_auth('create_links', spa_text('Can create links in posts'), 1, 0, 0, 0, $cat); # enable permission in roles based on current global flag $sffilters = sp_get_option('sffilters'); if ($sffilters['sfallowlinks']) { $roles = spdb_table(SFROLES); if ($roles) { $auth_id = spdb_table(SFAUTHS, 'auth_name="create_links"', 'auth_id'); foreach ($roles as $role) { $actions = unserialize($role->role_auths); $actions[$auth_id] = 1; spdb_query('UPDATE ' . SFROLES . " SET role_auths='" . serialize($actions) . "' WHERE role_id={$role->role_id}"); } # reset all the auths sp_reset_auths();