function spa_toolbox_errorlog_form() { ?> <script type="text/javascript"> jQuery(document).ready(function() { spjAjaxForm('sfclearlog', 'sfreloadel'); }); </script> <?php $sflog = spa_get_errorlog_data(); spa_paint_open_tab(spa_text('Toolbox') . ' - ' . spa_text('Error Log'), true); spa_paint_open_fieldset(spa_text('Error Log'), false); echo '<p>' . spa_text('Error Logging can be disabled in the Global Options panel') . '<br /></p>'; echo "<table class='sfhelptext'><tr>"; echo "<td class='spaErrError spaErrCell'><b>" . spa_text('Error') . '</b></td>'; echo "<td class='spaErrWarning spaErrCell'><b>" . spa_text('Warning') . '</b></td>'; echo "<td class='spaErrNotice spaErrCell'><b>" . spa_text('Notice') . '</b></td>'; echo "<td class='spaErrStrict spaErrCell'><b>" . spa_text('Strict') . '</b></td>'; echo "</tr><tr>"; echo "<td class='spaErrCellDesc'>" . spa_text('Errors should be reported to Simple:Press support as they may effect the proper behaviour of your forum') . '</td>'; echo "<td class='spaErrCellDesc'>" . spa_text('Warnings suggest a code conflict of some type that should be investigated but which will not stop Simple:Press execution') . '</td>'; echo "<td class='spaErrCellDesc'>" . spa_text('Notices are generally non-important and have no effect on Simple:Press execution. We make every effort to clear these when we are informed of them') . '</td>'; echo "<td class='spaErrCellDesc'>" . spa_text('If you receive any Strict entries they are non-urgent but please inform Simple:Press support so we can deal with them') . '</td>'; echo "</tr></table><p> </p>"; if (!$sflog) { echo '<p>' . spa_text('There are no Error Log Entries') . '</p>'; } else { echo "<table class='wp-list-table widefat'>"; foreach ($sflog as $log) { echo '<tr>'; echo "<td class='sferror " . $log['error_cat'] . "'>" . sp_date('d', $log['error_date']) . ' ' . sp_date('t', $log['error_date']) . ' | ' . $log['error_cat'] . ' | ' . $log['error_count'] . ' | ' . $log['error_type'] . '<hr />'; echo $log['error_text'] . '</td>'; echo '</tr>'; } echo '</table>'; } spa_paint_close_fieldset(); do_action('sph_toolbox_error_panel'); spa_paint_close_container(); $ahahURL = SFHOMEURL . 'index.php?sp_ahah=toolbox-loader&sfnonce=' . wp_create_nonce('forum-ahah') . '&saveform=sfclearlog'; ?> <form action="<?php echo $ahahURL; ?> " method="post" id="sfclearlog" name="sfclearlog"> <?php echo sp_create_nonce('forum-adminform_clearlog'); ?> <div class="sfform-submit-bar"> <input type="submit" class="button-primary" id="saveit" name="saveit" value="<?php spa_etext('Empty Error Log'); ?> " /> </div> </form> <?php spa_paint_close_tab(); }
function spa_toolbox_log_form() { $sflog = spa_get_log_data(); #== log Tab ========================================================== spa_paint_open_tab(spa_text('Toolbox') . " - " . spa_text('Install Log'), true); if (!$sflog) { spa_etext("There are no Install Log Entries"); return; } spa_paint_open_panel(); spa_paint_open_fieldset(spa_text('Install Log'), false); echo "<table class='wp-list-table widefat'><tr>"; echo '<th>' . spa_text('Version') . '</th>'; echo "<th class='logDetail'>" . "</th>"; echo '<th>' . spa_text('Build') . '</th>'; echo "<th class='logRelease'>" . spa_text('Release') . "</th>"; echo '<th>' . spa_text('Installed') . '</th>'; echo "<th class='logBy'>" . spa_text('By') . "</th>"; echo '</tr>'; foreach ($sflog as $log) { $idVer = 'version' . str_replace('.', '', $log['version']); $idQVer = str_replace('.', '-', $log['version']); echo '<tr>'; echo "<td class='sflabel'>" . $log['version'] . "</td>"; $site = SFHOMEURL . 'index.php?sp_ahah=install-log&sfnonce=' . wp_create_nonce('forum-ahah') . '&log=' . $idQVer; $gif = SFCOMMONIMAGES . 'working.gif'; echo '<td class="logDetail"><input type="button" class="logDetail button" value="' . spa_text('Details') . '" onclick="spjLoadAhah(\'' . $site . '\', \'' . $idVer . '\', \'' . $gif . '\');" /></td>'; echo "<td class='sflabel'>" . $log['build'] . "</td>"; echo "<td class='sflabel logRelease'>" . $log['release_type'] . "</td>"; echo "<td class='sflabel'>" . sp_date('d', $log['install_date']) . "</td>"; echo "<td class='sflabel logBy'>" . sp_filter_name_display($log['display_name']) . "</td>"; echo '</tr>'; echo "<tr><td style='display:none;' class='sflabel' id='" . $idVer . "' colspan='6'></td></tr>"; } echo '</table>'; spa_paint_close_fieldset(); spa_paint_close_panel(); do_action('sph_toolbox_install_panel'); spa_paint_close_container(); echo '<div class="sfform-panel-spacer"></div>'; spa_paint_close_tab(); }
function sp_ProfileShowLastVisit($args = '', $label = '') { global $spProfileUser; if (!sp_get_auth('view_profiles')) { return; } $defs = array('tagClass' => 'spProfileShowLastVisit', 'leftClass' => 'spColumnSection spProfileLeftCol', 'middleClass' => 'spColumnSection spProfileSpacerCol', 'rightClass' => 'spColumnSection spProfileRightCol', 'echo' => 1, 'get' => 0); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_ProfileShowLastVisit_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagClass = esc_attr($tagClass); $leftClass = esc_attr($leftClass); $middleClass = esc_attr($middleClass); $rightClass = esc_attr($rightClass); $label = sp_filter_title_display($label); $echo = (int) $echo; $get = (int) $get; if ($get) { return $spProfileUser->lastvisit; } # output first name $out = ''; $out .= "<div class='{$leftClass}'>"; $out .= "<p class='{$tagClass}'>{$label}:</p>"; $out .= '</div>'; $out .= "<div class='{$middleClass}'></div>"; $out .= "<div class='{$rightClass}'>"; $out .= "<p class='{$tagClass}'>" . sp_date('d', $spProfileUser->lastvisit) . ' ' . sp_date('t', $spProfileUser->lastvisit) . '</p>'; $out .= "</div>\n"; $out = apply_filters('sph_ProfileShowLastVisit', $out, $spProfileUser, $a); if ($echo) { echo $out; } else { return $out; } }
function sp_do_sp_UnansweredPostsTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } $defs = array('tagId' => 'spUnansweredPostsTag', 'tagClass' => 'spListTag', 'listId' => 'spListItemTag%ID%', 'listClass' => 'spListItemTag', 'linkClass' => 'spLinkTag', 'textClass' => 'spTextTag', 'avatarClass' => 'spAvatarTag', 'listTags' => 1, 'forumIds' => '', 'limit' => 5, 'itemOrder' => 'FTUD', 'linkScope' => 'forum', 'beforeForum' => __('Forum: ', 'sp-ttags'), 'afterForum' => '<br />', 'beforeTopic' => __('Topic: ', 'sp-ttags'), 'afterTopic' => '<br />', 'beforeUser' => __('By: ', 'sp-ttags'), 'afterUser' => '', 'beforeDate' => ' -', 'afterDate' => '', 'avatarSize' => 25, 'niceDate' => 1, 'postTip' => 1, 'truncate' => 0, 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_UnansweredPostsTag_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; $forumIds = esc_attr($forumIds); $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; $truncate = (int) $truncate; $echo = (int) $echo; sp_forum_api_support(); global $spPostList, $spThisPostList; $where = SFTOPICS . '.post_count=1'; # do we have forum ids specified? $where .= !empty($forumIds) ? ' AND ' . SFPOSTS . '.forum_id IN (' . $forumIds . ')' : ''; $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 $out = $listTags ? "<ul id='{$tagId}' class='{$tagClass}'>" : "<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); $out .= $listTags ? "<li id='{$thisId}' class='{$listClass}'>" : "<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 .= sp_truncate($spThisPostList->forum_name, $truncate); if ($fLink) { $out .= '</a>'; } $out .= $afterForum; break; case 'T': # Topic $out .= $beforeTopic; if ($tLink) { $out .= "<a class='{$linkClass}' {$title} href='{$spThisPostList->post_permalink}'>"; } $out .= sp_truncate($spThisPostList->topic_name, $truncate); if ($tLink) { $out .= '</a>'; } $out .= $afterTopic; break; case 'A': # Avatar $spx = $avatarSize + 10 . 'px'; $out .= sp_UserAvatar("tagClass={$avatarClass}&size={$avatarSize}&link=none&context=user&echo=0", $spThisPostList); 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-ttags') . '<br />'; break; } } if ($aLink) { $out .= '</a>'; } $out .= $listTags ? '</li>' : '</div>'; } } $out .= $listTags ? '</ul>' : '</div>'; $out = apply_filters('sph_UnansweredPostsTag', $out); if ($echo) { echo $out; } else { return $out; } }
function sp_MemberListRegistered($args = '', $label = '') { global $spThisMember; if (!sp_get_auth('view_members_list')) { return; } $defs = array('tagId' => 'spMembersListRegistration%ID%', 'tagClass' => 'spInRowCount', 'labelClass' => 'spInRowLabel', 'dateClass' => 'spInRowDate', 'stack' => 1, 'echo' => 1, 'get' => 0); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_MemberListRegistered_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $labelClass = esc_attr($labelClass); $dateClass = esc_attr($dateClass); $stack = (int) $stack; $echo = (int) $echo; $get = (int) $get; $tagId = str_ireplace('%ID%', $spThisMember->user_id, $tagId); $att = $stack ? '<br />' : ': '; if ($get) { return $spThisMember->user_registered; } $out = "<div id='{$tagId}' class='{$tagClass}'>"; $out .= "<span class='{$labelClass}'>" . sp_filter_title_display($label) . "{$att}</span>"; $out .= "<span class='{$dateClass}'>" . sp_date('d', $spThisMember->user_registered) . '<br />' . sp_date('t', $spThisMember->user_registered) . '</span>'; $out .= "</div>\n"; $out = apply_filters('sph_MemberListRegistered', $out, $a); if ($echo) { echo $out; } else { return $out; } }
} if (empty($spProfileUser->timezone_string)) { $spProfileUser->timezone_string = get_option('timezone_string'); } if (substr($spProfileUser->timezone_string, 0, 3) == 'UTC') { $spProfileUser->timezone_string = 'UTC'; } date_default_timezone_set($spProfileUser->timezone_string); $tout = ''; $tout .= '<div class="spColumnSection spProfileLeftCol">'; $tout .= '<p class="spProfileLabel">' . sp_text('Your Timezone') . ': </p>'; $tout .= '</div>'; $tout .= '<div class="spColumnSection spProfileSpacerCol"></div>'; $tout .= '<div class="spColumnSection spProfileRightCol">'; $tout .= '<p class="spProfileLabel">' . $spProfileUser->timezone_string . '</p>'; $tout .= '<p><small>' . sp_text('Local Time') . ': ' . sp_date('d', date(SFDATES)) . ' ' . sp_date('t', date(SFTIMES)) . '</small></p>'; $tout .= '<p><small>' . sp_text('Change your timezone on options - display') . '</small></p>'; $tout .= '</div>'; $out .= apply_filters('sph_ProfileUserTimezone', $tout, $userid, $thisSlug); $out = apply_filters('sph_ProfileOverviewFormBottom', $out, $userid); $out = apply_filters('sph_ProfileFormBottom', $out, $userid, $thisSlug); $tout = ''; $tout .= '<div class="spColumnSection spProfileLeftCol"></div>'; $tout .= '<div class="spColumnSection spProfileSpacerCol"></div>'; $tout .= '<div class="spColumnSection spProfileRightCol">'; $tout .= '<form action="' . SFHOMEURL . 'index.php?sp_ahah=search&sfnonce=' . wp_create_nonce('forum-ahah') . '" method="post" id="searchposts" name="searchposts">'; $tout .= '<input type="hidden" class="sfhiddeninput" name="searchoption" id="searchoption" value="2" />'; $tout .= '<input type="hidden" class="sfhiddeninput" name="userid" id="userid" value="' . $userid . '" />'; $tout .= '<div class="spProfileFormSubmit">'; $tout .= '<input type="submit" class="spSubmit" name="membersearch" value="' . sp_text('List Topics You Have Posted To') . '" />'; $tout .= '<input type="submit" class="spSubmit" name="memberstarted" value="' . sp_text('List Topics You Started') . '" />';
function sp_PostForumToolButton($args = '', $label = '', $toolTip = '') { global $spThisTopic, $spThisPost, $spThisPostUser, $spThisUser, $spGuestCookie, $spGlobals; if ($spGlobals['lockdown'] == true && $spThisUser->admin == false) { return; } $show = false; if ($spThisUser->admin || $spThisUser->moderator) { $show = true; } else { $edit_days = sp_get_option('editpostdays'); $post_date = strtotime(sp_date('d', $spThisPost->post_date)); $date_diff = floor((time() - $post_date) / (60 * 60 * 24)); if (sp_get_auth('view_email', $spThisTopic->forum_id) || sp_get_auth('pin_posts', $spThisTopic->forum_id) || sp_get_auth('edit_any_post', $spThisTopic->forum_id) || sp_get_auth('edit_own_posts_forever', $spThisTopic->forum_id) && $spThisUser->member && $spThisPostUser->ID == $spThisUser->ID || sp_get_auth('edit_own_posts_forever', $spThisTopic->forum_id) && $spThisUser->guest && $spThisPost->guest_email == $spGuestCookie->guest_email || sp_get_auth('edit_own_posts_reply', $spThisTopic->forum_id) && $spThisUser->member && $spThisPostUser->ID == $spThisUser->ID && $spThisPost->last_post || sp_get_auth('edit_own_posts_reply', $spThisTopic->forum_id) && $spThisUser->guest && $spThisPost->guest_email == $spGuestCookie->guest_email && $spThisPost->last_post || sp_get_auth('edit_own_posts_for_time', $spThisTopic->forum_id) && $spThisUser->member && $spThisPostUser->ID == $spThisUser->ID && $date_diff <= $edit_days || sp_get_auth('move_posts', $spThisTopic->forum_id) || sp_get_auth('reassign_posts', $spThisTopic->forum_id) || sp_get_auth('delete_any_post', $spThisTopic->forum_id) || sp_get_auth('delete_own_posts', $spThisTopic->forum_id) && $spThisPostUser->user_id == $spThisUser->ID || sp_get_auth('moderate_posts', $spThisTopic->forum_id) && $spThisPost->post_status != 0) { $show = true; } } $show = apply_filters('sph_forum_tools_topic_show', $show); if (!$show) { return; } $defs = array('tagId' => 'spForumToolButton%ID%', 'tagClass' => 'spToolsButton', 'icon' => 'sp_ForumTools.png', 'iconClass' => 'spIcon', 'hide' => 1, 'containerClass' => 'spTopicPostSection'); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_PostForumToolButton_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); $containerClass = esc_attr($containerClass); $hide = (int) $hide; $toolTip = esc_attr($toolTip); $label = sp_filter_title_display($label); $tagId = str_ireplace('%ID%', $spThisPost->post_id, $tagId); $addStyle = ''; if ($hide) { $addStyle = " style='display: none;' "; } $last = $spThisPost->last_post ? 1 : 0; $site = SFHOMEURL . 'index.php?sp_ahah=admintoollinks&sfnonce=' . wp_create_nonce('forum-ahah') . "&action=posttools&post={$spThisPost->post_id}&page={$spThisTopic->display_page}&postnum={$spThisPost->post_index}&name=" . urlencode($spThisPostUser->display_name) . "&forum={$spThisTopic->forum_id}&last={$last}"; $out = "<a class='{$tagClass}' id='{$tagId}' title='{$toolTip}' rel='nofollow' href='javascript:void(null)' {$addStyle} "; $title = esc_js(sp_text('Forum Tools')); $out .= "onclick='spjDialogAjax(this, \"" . $site . "\", \"" . $title . "\", 350, 0, 0);' >"; if (!empty($icon)) { $out .= sp_paint_icon($iconClass, SPTHEMEICONSURL, $icon); } if (!empty($label)) { $out .= $label; } $out .= "</a>\n"; $out = apply_filters('sph_PostForumToolButton', $out, $a); echo $out; # Add script to hover admin buttons - just once if ($spThisTopic->tools_flag && $hide) { ?> <script type='text/javascript'> /* <![CDATA[ */ var sptb = { toolclass : '.<?php echo $containerClass; ?> ' }; /* ]]> */ </script> <?php add_action('wp_footer', 'spjs_AddPostToolsHover'); $spThisTopic->tools_flag = false; } }
function spa_get_members_info($userid) { $data = sp_get_member_row($userid); if (empty($data)) { return ''; } $first = spdb_select('row', ' SELECT ' . SFPOSTS . '.forum_id, forum_name, forum_slug, ' . SFPOSTS . '.topic_id, topic_name, topic_slug, post_date FROM ' . SFPOSTS . ' JOIN ' . SFTOPICS . ' ON ' . SFTOPICS . '.topic_id = ' . SFPOSTS . '.topic_id JOIN ' . SFFORUMS . ' ON ' . SFFORUMS . '.forum_id = ' . SFPOSTS . '.forum_id WHERE ' . SFPOSTS . ".user_id={$userid}\n\t\t\tORDER BY post_date ASC\n\t\t\tLIMIT 1"); if ($first) { $url = '<a href="' . sp_build_url($first->forum_slug, $first->topic_slug, 1, 0) . '">' . sp_filter_title_display($first->topic_name) . '</a>'; $data['first'] = sp_filter_title_display($first->forum_name) . '<br />' . $url . '<br />' . sp_date('d', $first->post_date); } else { $data['first'] = spa_text('No Posts'); } $last = spdb_select('row', ' SELECT ' . SFPOSTS . '.forum_id, forum_name, forum_slug, ' . SFPOSTS . '.topic_id, topic_name, topic_slug, post_date FROM ' . SFPOSTS . ' JOIN ' . SFTOPICS . ' ON ' . SFTOPICS . '.topic_id = ' . SFPOSTS . '.topic_id JOIN ' . SFFORUMS . ' ON ' . SFFORUMS . '.forum_id = ' . SFPOSTS . '.forum_id WHERE ' . SFPOSTS . ".user_id={$userid}\n\t\t\tORDER BY post_date DESC\n\t\t\tLIMIT 1"); if ($last) { $url = '<a href="' . sp_build_url($last->forum_slug, $last->topic_slug, 1, 0) . '">' . sp_filter_title_display($last->topic_name) . '</a>'; $data['last'] = sp_filter_title_display($last->forum_name) . '<br />' . $url . '<br />' . sp_date('d', $last->post_date); } else { $data['last'] = spa_text('No posts'); } if ($data['admin']) { $user_memberships = 'Admin'; $status = 'Admin'; $start = 0; } else { if ($data['moderator']) { $status = 'Moderator'; $start = 1; } else { $status = 'User'; $start = 1; } } $memberships = spdb_table(SFMEMBERSHIPS, "user_id={$userid}", '', '', '', ARRAY_A); if ($memberships) { foreach ($memberships as $membership) { $name = spdb_table(SFUSERGROUPS, 'usergroup_id=' . $membership['usergroup_id'], 'usergroup_name'); if ($start) { $user_memberships = $name; $start = 0; } else { $user_memberships .= ', ' . $name; } } } else { if ($start) { $user_memberships = 'No Memberships'; } } $data['memberships'] = $user_memberships; $rank = sp_get_user_forum_rank($status, $userid, $data['posts']); $data['rank'] = $rank[0]['name']; $user = get_userdata($userid); $data['login'] = $user->user_login; return $data; }
function sp_do_sp_AuthorPostsTag($args = '') { #check if forum displayed if (sp_abort_display_forum()) { return; } $defs = array('tagId' => 'spAuthorPostsTag', 'tagClass' => 'spLinkTag', 'authorId' => '', 'showForum' => 1, 'showDate' => 1, 'limit' => 5, 'listTags' => 0, 'echo' => 1); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_AuthorPostsTag_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $authorId = (int) $authorId; $showForum = (int) $showForum; $showDate = (int) $showDate; $limit = (int) $limit; $listTags = (int) $listTags; $echo = (int) $echo; if (empty($authorId)) { return; } sp_forum_api_support(); if ($limit == 0) { $limit = ''; } # limit to viewable forums based on permissions $where = SFPOSTS . '.user_id = ' . $authorId . ' AND ' . SFPOSTS . '.post_status=0 '; $forum_ids = sp_get_forum_memberships(); # create where clause based on forums that current user can view if ($forum_ids != '') { $where .= "AND " . SFPOSTS . ".forum_id IN (" . implode(",", $forum_ids) . ")"; } else { return ''; } $spdb = new spdbComplex(); $spdb->table = SFPOSTS; $spdb->distinct = true; $spdb->fields = SFPOSTS . '.post_id, ' . SFPOSTS . '.forum_id, ' . SFPOSTS . '.topic_id, ' . spdb_zone_datetime('post_date') . ', post_index, forum_slug, forum_name, topic_slug, topic_name'; $spdb->join = array(SFTOPICS . ' ON ' . SFPOSTS . '.topic_id = ' . SFTOPICS . '.topic_id', SFFORUMS . ' ON ' . SFPOSTS . '.forum_id = ' . SFFORUMS . '.forum_id'); $spdb->where = $where; $spdb->orderby = 'post_date DESC'; $spdb->limits = $limit; $sfposts = $spdb->select(); if (!$listTags) { $out = "<div id='{$tagId}' class='{$tagClass}'>"; $open = '<div>'; $close = '</div>'; } else { $out = "<ul id='{$tagId}' class='{$tagClass}'>"; $open = '<li>'; $close = '</li>'; } if ($sfposts) { foreach ($sfposts as $sfpost) { $out .= $open; if ($showForum) { $out .= sp_filter_title_display($sfpost->forum_name) . '<br />'; } $out .= '<a href="' . sp_build_url($sfpost->forum_slug, $sfpost->topic_slug, 0, $sfpost->post_id, $sfpost->post_index) . '">' . sp_filter_title_display($sfpost->topic_name) . '</a><br />' . "\n"; if ($showDate) { $out .= sp_date('d', $sfpost->post_date) . '<br />'; } $out .= $close; } } else { $out .= $open . __('No posts by this author', 'sp-ttags') . $close; } if (!$listTags) { $out .= '</div>'; } else { $out .= '</ul>'; } $out = apply_filters('sph_AuthorPostsTag', $out); if ($echo) { echo $out; } else { return $out; } }
function sp_LastVisitLabel($args = '', $label = '') { # should we show the last visit label? global $spThisUser; if (empty($spThisUser->lastvisit)) { return; } $defs = array('tagId' => 'spLastVisitLabel', 'tagClass' => 'spLabelSmall', 'echo' => 1, 'get' => 0); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_LastVisitLabel_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $echo = (int) $echo; $get = (int) $get; if ($get) { return $spThisUser->lastvisit; } $label = sp_filter_title_display(str_replace('%LASTVISIT%', sp_date('d', $spThisUser->lastvisit), $label)); $out = "<span id='{$tagId}' class='{$tagClass}'>{$label}</span>\n"; $out = apply_filters('sph_LastVisitLabel', $out, $a); if ($echo) { echo $out; } else { return $out; } }
function sp_ListFirstPost($args = '', $label = '') { global $spThisListTopic; $defs = array('tagId' => 'spListFirstPost%ID%', 'tagClass' => 'spListPostLink', 'labelClass' => 'spListLabel', 'linkClass' => 'spLink', 'iconClass' => 'spIcon', 'icon' => 'sp_ArrowRight.png', 'labelLink' => 0, 'tip' => 1, 'niceDate' => 1, 'date' => 0, 'time' => 0, 'user' => 1, 'truncateUser' => 0, 'break' => 0, 'echo' => 1, 'get' => 0); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_ListFirstPost_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $labelClass = esc_attr($labelClass); $linkClass = esc_attr($linkClass); $iconClass = esc_attr($iconClass); $labelLink = (int) $labelLink; $tip = (int) $tip; $niceDate = (int) $niceDate; $date = (int) $date; $time = (int) $time; $user = (int) $user; $truncateUser = (int) $truncateUser; $break = (int) $break; $icon = sanitize_file_name($icon); $echo = (int) $echo; $get = (int) $get; $tagId = str_ireplace('%ID%', $spThisListTopic->topic_id, $tagId); if ($tip && !empty($spThisListTopic->first_post_tip)) { $title = "title='{$spThisListTopic->first_post_tip}'"; $linkClass .= ''; } else { $title = ''; } $sp = ' '; $out = "<div id='{$tagId}' class='{$tagClass}'>\n"; if ($labelLink) { $out .= "<a class='{$linkClass}' {$title} href='{$spThisListTopic->first_post_permalink}'>\n"; } $out .= "<span class='{$labelClass}'>" . sp_filter_title_display($label) . " \n"; if ($labelLink) { $out .= "</a>\n"; } # Link to post $out .= "<a class='{$linkClass}' {$title} href='{$spThisListTopic->first_post_permalink}'>\n"; $out .= sp_paint_icon($iconClass, SPTHEMEICONSURL, $icon); $out .= "</a></span>\n"; # user $poster = sp_build_name_display($spThisListTopic->first_user_id, sp_truncate($spThisListTopic->first_display_name, $truncateUser)); if (empty($poster)) { $poster = sp_truncate($spThisListTopic->first_guest_name, $truncateUser); } if ($user) { $out .= "<span class='{$labelClass}'>{$poster}</span>\n"; } if ($get) { $getData = new stdClass(); $getData->permalink = $spThisListTopic->first_post_permalink; $getData->topic_name = $spThisListTopic->topic_name; $getData->post_date = $spThisListTopic->first_post_date; $getData->tooltip = $spThisListTopic->first_post_tip; $getData->user = $poster; return $getData; } if ($break) { $sp = "<br />"; } # date/time if ($niceDate) { $out .= "<span class='{$labelClass}'>" . $sp . sp_nicedate($spThisListTopic->first_post_date) . "</span>\n"; } else { if ($date) { $out .= "<span class='{$labelClass}'>" . $sp . sp_date('d', $spThisListTopic->first_post_date); if ($time) { $out .= '-' . sp_date('t', $spThisListTopic->first_post_date); } $out .= "</span>\n"; } } $out .= "</div>\n"; $out = apply_filters('sph_ListFirstPost', $out, $a); if ($echo) { echo $out; } else { return $out; } }
function sp_render_post_tools($post, $forum, $topic, $page, $postnum, $useremail, $guestemail, $displayname, $last) { global $spThisUser; $out = ''; $out .= '<div id="spMainContainer" class="spForumToolsPopup">'; $out .= '<div class="spForumToolsHeader">'; $out .= '<div class="spForumToolsHeaderTitle">' . sp_filter_title_display($topic['topic_name']) . '</div>'; $out .= '<div class="spForumToolsHeaderTitle">' . sp_text('Post') . ' #' . $postnum . '</div>'; $out .= '</div>'; $out .= sp_render_common_tools($forum, $topic, $post, $page); if ($post['post_status'] != 0 && sp_get_auth('moderate_posts', $forum['forum_id'])) { $out .= '<div class="spForumToolsModerate">'; $out .= sp_paint_icon('spIcon', SPTHEMEICONSURL, 'sp_ToolsApprove.png'); $out .= '<a href="javascript:document.postapprove' . $post['post_id'] . '.submit();">' . sp_text('Approve this post') . '</a>'; $out .= '<form action="' . sp_build_url($forum['forum_slug'], $topic['topic_slug'], $page, $post['post_id'], $post['post_index']) . '" method="post" name="postapprove' . $post['post_id'] . '">'; $out .= '<input type="hidden" name="approvepost" value="' . $post['post_id'] . '" />'; $out .= '</form>'; $out .= '</div>'; } if ($post['post_status'] == 0 && sp_get_auth('moderate_posts', $forum['forum_id'])) { $out .= '<div class="spForumToolsModerate">'; $out .= sp_paint_icon('spIcon', SPTHEMEICONSURL, 'sp_ToolsUnapprove.png'); $out .= '<a href="javascript:document.unapprovepost' . $post['post_id'] . '.submit();">' . sp_text('Unapprove this post') . '</a>'; $out .= '<form action="' . sp_build_url($forum['forum_slug'], $topic['topic_slug'], $page, $post['post_id'], $post['post_index']) . '" method="post" name="unapprovepost' . $post['post_id'] . '">'; $out .= '<input type="hidden" name="unapprovepost" value="' . $post['post_id'] . '" />'; $out .= '</form>'; $out .= '</div>'; } if (sp_get_auth('view_email', $forum['forum_id'])) { $email = !empty($useremail) ? $useremail : $guestemail; $content = ''; if ($post['user_id']) { $content .= '<div>' . sp_text('User ID') . ': ' . $post['user_id'] . ' - ' . $displayname . '</div>'; } else { $content .= '<div>' . sp_text('Guest') . '</div>'; } $content .= '<div>' . $email . '</div><div>' . $post['poster_ip'] . '</div>'; $out .= '<div class="spForumToolsEmail">'; $out .= sp_paint_icon('spIcon', SPTHEMEICONSURL, 'sp_ToolsEmail.png'); $title = sp_text("Users email and IP"); $out .= '<a href="javascript:void(null)" onclick="spjDialogHtml(this, \'' . $content . '\', \'' . esc_js($title) . '\', 300, 0, \'center\');">' . $title . '</a>'; $out .= '</div>'; } if (sp_get_auth('pin_posts', $forum['forum_id'])) { $pintext = $post['post_pinned'] ? sp_text('Unpin this post') : sp_text('Pin this post'); $out .= '<div class="spForumToolsPin">'; $out .= sp_paint_icon('spIcon', SPTHEMEICONSURL, 'sp_ToolsPin.png'); $ajaxUrl = SFHOMEURL . 'index.php?sp_ahah=admintools&sfnonce=' . wp_create_nonce('forum-ahah') . '&action=pin-post&post=' . $post['post_id']; $out .= "<a href='javascript:void(null)' onclick='spjPinPost(\"{$ajaxUrl}\");'>{$pintext}</a>"; $out .= '</div>'; } if ($spThisUser->admin) { $out .= '<div class="spForumToolsOrder">'; $out .= sp_paint_icon('spIcon', SPTHEMEICONSURL, 'sp_ToolsSort.png'); $site = SFHOMEURL . 'index.php?sp_ahah=admintools&sfnonce=' . wp_create_nonce('forum-ahah') . '&action=sort-topic&topicid=' . $topic['topic_id']; $out .= '<a href="javascript:void(null)" onclick="spjLoadTool(\'' . $site . '\', \'spMainContainer\', \'\');">' . sp_text('Reverse sort this topic') . '</a>'; $out .= '</div>'; } $edit_days = sp_get_option('editpostdays'); $post_date = strtotime(sp_date('d', $post['post_date'])); $date_diff = floor((time() - $post_date) / (60 * 60 * 24)); if (sp_get_auth('edit_any_post', $forum['forum_id']) || $post['user_id'] == $spThisUser->ID && (sp_get_auth('edit_own_posts_forever', $forum['forum_id']) || sp_get_auth('edit_own_posts_reply', $forum['forum_id']) && $last || sp_get_auth('edit_own_posts_for_time', $forum['forum_id']) && $date_diff <= $edit_days)) { $out .= '<div class="spForumToolsEdit">'; $out .= sp_paint_icon('spIcon', SPTHEMEICONSURL, 'sp_ToolsEdit.png'); $out .= '<a href="javascript:document.admineditpost' . $post['post_id'] . '.submit();">' . sp_text('Edit this post') . '</a>'; $out .= '<form action="' . sp_build_url($forum['forum_slug'], $topic['topic_slug'], $page, $post['post_id'], $post['post_index']) . '" method="post" name="admineditpost' . $post['post_id'] . '">'; $out .= '<input type="hidden" name="postedit" value="' . $post['post_id'] . '" />'; $out .= '</form>'; $out .= '</div>'; } if (sp_get_auth('delete_any_post', $post['forum_id']) || sp_get_auth('delete_own_posts', $forum['forum_id']) && $spThisUser->ID == $post['user_id']) { $out .= '<div class="spForumToolsDelete">'; $out .= sp_paint_icon('spIcon', SPTHEMEICONSURL, 'sp_ToolsDelete.png'); $msg = esc_js(sp_text('Are you sure you want to delete this post?')); $ajaxUrl = SFHOMEURL . 'index.php?sp_ahah=admintools&sfnonce=' . wp_create_nonce('forum-ahah') . '&action=delete-post&killpost=' . $post['post_id'] . '&killposttopic=' . $post['topic_id'] . '&killpostforum=' . $post['forum_id'] . '&killpostposter=' . $post['user_id'] . '&page=' . $page; $out .= "<a href='javascript:void(null)' onclick='spjDeletePost(\"{$ajaxUrl}\", {$post['post_id']}, {$post['topic_id']});'>"; $out .= sp_text('Delete this post'); $out .= '</a>'; $out .= '</div>'; } if (sp_get_auth('move_posts', $post['forum_id'])) { $out .= '<div class="spForumToolsMove">'; $out .= sp_paint_icon('spIcon', SPTHEMEICONSURL, 'sp_ToolsMove.png'); $site = SFHOMEURL . 'index.php?sp_ahah=admintools&sfnonce=' . wp_create_nonce('forum-ahah') . '&action=move-post&id=' . $post['topic_id'] . '&pid=' . $post['post_id'] . '&pix=' . $post['post_index']; $title = sp_text('Move this post'); $out .= '<a rel="nofollow" href="javascript:void(null)" onclick="spjDialogAjax(this, \'' . $site . '\', \'' . esc_js($title) . '\', 400, 0, \'center\');">' . $title . '</a>'; $out .= '</div>'; } if (sp_get_auth('reassign_posts', $post['forum_id'])) { $out .= '<div class="spForumToolsReassign">'; $out .= sp_paint_icon('spIcon', SPTHEMEICONSURL, 'sp_ToolsReassign.png'); $site = SFHOMEURL . 'index.php?sp_ahah=admintools&sfnonce=' . wp_create_nonce('forum-ahah') . '&action=reassign&id=' . $post['topic_id'] . '&pid=' . $post['post_id'] . '&uid=' . $post['user_id']; $title = sp_text('Reassign This Post'); $out .= '<a rel="nofollow" href="javascript:void(null)" onclick="spjDialogAjax(this, \'' . $site . '\', \'' . esc_js($title) . '\', 400, 0, \'center\');">' . $title . '</a>'; $out .= '</div>'; } if ($spThisUser->admin || $spThisUser->moderator) { $out .= '<div class="spForumToolsNofity">'; $out .= sp_paint_icon('spIcon', SPTHEMEICONSURL, 'sp_ToolsNotify.png'); $site = SFHOMEURL . 'index.php?sp_ahah=admintools&sfnonce=' . wp_create_nonce('forum-ahah') . '&action=notify&pid=' . $post['post_id']; $title = sp_text('Notify User'); $out .= '<a rel="nofollow" href="javascript:void(null)" onclick="spjDialogAjax(this, \'' . $site . '\', \'' . esc_js($title) . '\', 400, 0, \'center\');">' . $title . '</a>'; $out .= '</div>'; } if ($spThisUser->admin || $spThisUser->moderator) { $out .= '<div class="spForumToolsProperties">'; $out .= sp_paint_icon('spIcon', SPTHEMEICONSURL, 'sp_ToolsProperties.png'); $site = SFHOMEURL . 'index.php?sp_ahah=admintools&sfnonce=' . wp_create_nonce('forum-ahah') . '&action=properties&forum=' . $post['forum_id'] . '&topic=' . $post['topic_id'] . '&post=' . $post['post_id']; $title = sp_text('View properties'); $out .= '<a rel="nofollow" href="javascript:void(null)" onclick="spjDialogAjax(this, \'' . $site . '\', \'' . esc_js($title) . '\', 400, 0, \'center\');">' . $title . '</a>'; $out .= '</div>'; } $out = apply_filters('sph_add_post_tool', $out, $post, $forum, $topic, $page, $postnum, $useremail, $guestemail, $displayname); $out .= '</div>'; $out = apply_filters('sph_post_tools', $out, $post, $forum, $topic, $page, $postnum, $useremail, $guestemail, $displayname); return $out; }
function sp_ListSearchUserDate($args = '') { global $spThisPostList; $defs = array('tagId' => 'spListPostUserDate%ID%', 'tagClass' => 'spPostUserDate', 'nicedate' => 0, 'date' => 1, 'time' => 1, 'stackdate' => 0, 'echo' => 1, 'get' => 0); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_ListSearchUserDate_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $nicedate = (int) $nicedate; $date = (int) $date; $time = (int) $time; $stackdate = (int) $stackdate; $echo = (int) $echo; $get = (int) $get; $dlb = $stackdate ? '<br />' : ' '; $tagId = str_ireplace('%ID%', $spThisPostList->post_id, $tagId); if ($get) { return $spThisPostList->post_date; } $out = "<div id='{$tagId}' class='{$tagClass}'>"; # date/time if ($nicedate) { $out .= sp_nicedate($spThisPostList->post_date); } else { if ($date) { $out .= sp_date('d', $spThisPostList->post_date); if ($time) { $out .= $dlb . sp_date('t', $spThisPostList->post_date); } } } $out .= "</div>\n"; $out = apply_filters('sph_ListSearchUserDate', $out, $a); if ($echo) { echo $out; } else { return $out; } }
function sp_ForumIndexLastPost($args = '', $lastPostLabel = '', $noTopicsLabel = '') { global $spThisForum; $defs = array('tagId' => 'spForumIndexLastPost%ID%', 'tagClass' => 'spInRowPostLink', 'labelClass' => 'spInRowLabel', 'infoClass' => 'spInRowInfo', 'linkClass' => 'spInRowLastPostLink', 'includeSubs' => 1, 'tip' => 1, 'order' => 'UTD', 'nicedate' => 1, 'date' => 0, 'time' => 0, 'stackdate' => 0, 'user' => 1, 'truncate' => 0, 'truncateUser' => 0, 'itemBreak' => '<br />', 'echo' => 1, 'get' => 0); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_ForumIndexLastPost_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $labelClass = esc_attr($labelClass); $infoClass = esc_attr($infoClass); $linkClass = esc_attr($linkClass); $includeSubs = (int) $includeSubs; $tip = (int) $tip; $order = esc_attr($order); $nicedate = (int) $nicedate; $date = (int) $date; $time = (int) $time; $stackdate = (int) $stackdate; $user = (int) $user; $truncate = (int) $truncate; $truncateUser = (int) $truncateUser; $echo = (int) $echo; $get = (int) $get; if ($includeSubs && $spThisForum->forum_id_sub == 0) { $includeSubs = 0; } $postCount = $includeSubs ? $spThisForum->post_count_sub : $spThisForum->post_count; if ($postCount) { $tagId = str_ireplace('%ID%', $spThisForum->forum_id, $tagId); $posttip = $includeSubs ? $spThisForum->post_tip_sub : $spThisForum->post_tip; if ($tip && !empty($posttip)) { $title = "title='{$posttip}'"; $linkClass .= ' vtip'; } else { $title = ''; } $stackdate ? $dlb = '<br />' : ($dlb = ' - '); # user $poster = $includeSubs ? sp_build_name_display($spThisForum->user_id_sub, sp_truncate($spThisForum->display_name_sub, $truncateUser)) : sp_build_name_display($spThisForum->user_id, sp_truncate($spThisForum->display_name, $truncateUser)); if (empty($poster)) { $poster = $includeSubs ? sp_truncate($spThisForum->guest_name_sub, $truncateUser) : sp_truncate($spThisForum->guest_name, $truncateUser); } # other items $permalink = $includeSubs ? $spThisForum->post_permalink_sub : $spThisForum->post_permalink; $topicname = $includeSubs ? sp_truncate($spThisForum->topic_name_sub, $truncate) : sp_truncate($spThisForum->topic_name, $truncate); $postdate = $includeSubs ? $spThisForum->post_date_sub : $spThisForum->post_date; if ($get) { $getData = new stdClass(); $getData->permalink = $permalink; $getData->topic_name = $topicname; $getData->post_date = $postdate; $getData->user = $poster; return $getData; } $U = $poster; $T = "<a class='{$linkClass}' {$title} href='{$permalink}'>{$topicname}</a>"; if ($nicedate) { $D = sp_nicedate($postdate); } else { if ($date) { $D = sp_date('d', $postdate); if ($time) { $D .= $dlb . sp_date('t', $postdate); } } } } else { if ($get) { $getData = new stdClass(); return $getData; } } $out = "<div id='{$tagId}' class='{$tagClass}'>\n"; if ($postCount) { $out .= "<span class='{$labelClass}'>" . sp_filter_title_display($lastPostLabel) . " \n"; for ($x = 0; $x < strlen($order); $x++) { $i = substr($order, $x, 1); switch ($i) { case 'U': if ($user) { if ($x != 0) { $out .= "<span class='{$labelClass}'>"; } $out .= $U . "</span>\n"; } if ($x != strlen($order) - 1) { if (substr($order, $x + 1, 1) != 'L') { $out .= "<span class='{$labelClass}'>{$itemBreak}</span>"; } } break; case 'T': if ($x == 0) { $out .= $itemBreak . "</span>"; } $out .= "<span class='{$linkClass}'>"; $out .= $T . "</span>\n"; if ($x != strlen($order) - 1) { if (substr($order, $x + 1, 1) != 'L') { $out .= "<span class='{$labelClass}'>{$itemBreak}</span>"; } } break; case 'D': if ($x != 0) { $out .= "<span class='{$labelClass}'>"; } $out .= $D . "</span>\n"; if ($x != strlen($order) - 1) { if (substr($order, $x + 1, 1) != 'L') { $out .= "<span class='{$labelClass}'>{$itemBreak}</span>"; } } break; case 'L': $out .= '<br />'; break; } } } else { $out .= "<span class='{$labelClass}'>" . sp_filter_title_display($noTopicsLabel) . " \n"; $out .= "</span>\n"; } $out .= "</div>\n"; $out = apply_filters('sph_ForumIndexLastPost', $out, $a); if ($echo) { echo $out; } else { return $out; } }
function sp_save_edited_post() { global $spThisUser, $spVars, $spGlobals; # post id of edited post $newpost = array(); $newpost['postid'] = sp_esc_int($_POST['pid']); # no post editng if guest, in post edit mode or lockdwon if ($spVars['displaymode'] == 'edit' && $spVars['postedit'] == $newpost['postid']) { return; } if ($spGlobals['lockdown']) { return; } # data for the post - want to ensure absolute forum id plus used for notifications later $post = spdb_table(SFPOSTS, "post_id={$newpost['postid']}", 'row'); $topic = spdb_table(SFTOPICS, "topic_id={$post->topic_id}", 'row'); # verify we can edit this post $canEdit = false; if (sp_get_auth('edit_any_post', $post->forum_id)) { $canEdit = true; } else { if ($post->user_id == $spThisUser->ID) { $last_post = $newpost['postid'] == $topic->post_id || $post->post_status == 1 && $newpost['postid'] == $topic->post_id_held; $edit_days = sp_get_option('editpostdays'); $post_date = strtotime(sp_date('d', $post->post_date)); $date_diff = floor((time() - $post_date) / (60 * 60 * 24)); if (sp_get_auth('edit_own_posts_forever', $post->forum_id) || sp_get_auth('edit_own_posts_reply', $post->forum_id) && $last_post || sp_get_auth('edit_own_posts_for_time', $post->forum_id) && $date_diff <= $edit_days) { $canEdit = true; } } } if (!$canEdit) { sp_notify(SPFAILURE, sp_text('Edit failed - you do not have permission')); return; } # post info $newpost['postcontent'] = $_POST['postitem']; $newpost['postcontent'] = sp_filter_content_save($newpost['postcontent'], 'edit', true, SFPOSTS, 'post_content'); $newpost['forumid'] = sp_esc_int($_POST['forumid']); $newpost['forumslug'] = sp_esc_str($_POST['forumslug']); $newpost['topicid'] = sp_esc_int($_POST['topicid']); $newpostt['topicslug'] = sp_esc_str($_POST['topicslug']); # post edit array $history = spdb_select('var', 'SELECT post_edit FROM ' . SFPOSTS . " WHERE post_id='{$newpost['postid']}'", ARRAY_A); $postedits = !empty($history) ? unserialize($history) : array(); $x = count($postedits); $edittime = current_time('mysql'); $postedits[$x]['by'] = sp_filter_name_save($spThisUser->display_name); $postedits[$x]['at'] = strtotime($edittime); $newpost['postedits'] = serialize($postedits); $newpost['postcontent'] = apply_filters('sph_post_edit_data', $newpost['postcontent'], $newpost['postid'], $spThisUser->ID); $date_update = ''; if (!empty($_POST['editTimestamp'])) { $yy = sp_esc_int($_POST['tsYear']); $mm = sp_esc_int($_POST['tsMonth']); $dd = sp_esc_int($_POST['tsDay']); $hh = sp_esc_int($_POST['tsHour']); $mn = sp_esc_int($_POST['tsMinute']); $ss = sp_esc_int($_POST['tsSecond']); $dd = $dd > 31 ? 31 : $dd; $hh = $hh > 23 ? $hh - 24 : $hh; $mn = $mn > 59 ? $mn - 60 : $mn; $ss = $ss > 59 ? $ss - 60 : $ss; $newpost['postdate'] = sprintf('%04d-%02d-%02d %02d:%02d:%02d', $yy, $mm, $dd, $hh, $mn, $ss); $date_update = ', post_date = "' . $newpost['postdate'] . '"'; } $sql = 'UPDATE ' . SFPOSTS . " SET post_content='{$newpost['postcontent']}', post_edit='{$newpost['postedits']}'{$date_update} WHERE post_id={$newpost['postid']}"; if (spdb_query($sql) == false) { sp_notify(SPFAILURE, sp_text('Update failed')); } else { sp_notify(SPSUCCESS, sp_text('Updated post saved')); # set up some data for notifications $link = sp_permalink_from_postid($newpost['postid']); # notify admins/mods of edit $users = spdb_select('set', 'SELECT user_id, admin_options FROM ' . SFMEMBERS . " WHERE admin=1 OR moderator=1"); if ($users) { $time = time() + 7 * 24 * 60 * 60; $text = sp_text('A user has edited the post'); foreach ($users as $user) { $options = unserialize($user->admin_options); if ($options['notify-edited'] && $spThisUser->ID != $user->user_id) { # dont notify self $nData = array(); $nData['user_id'] = $user->user_id; $nData['guest_email'] = ''; $nData['post_id'] = $newpost['postid']; $nData['link'] = $link; $nData['link_text'] = $topic->topic_name; $nData['message'] = $text; $nData['expires'] = $time; # 7 days; 24 hours; 60 mins; 60secs sp_add_notice($nData); } } } # notify author of change $sfadminsettings = sp_get_option('sfadminsettings'); if ($sfadminsettings['editnotice'] && $spThisUser->ID != $post->user_id) { $nData = array(); $nData['user_id'] = $post->user_id; $nData['guest_email'] = $post->guest_email; $nData['post_id'] = $newpost['postid']; $nData['link'] = $link; $nData['link_text'] = $topic->topic_name; $nData['message'] = sp_text('An edit has been made to your post'); $nData['expires'] = time() + 30 * 24 * 60 * 60; # 30 days; 24 hours; 60 mins; 60secs sp_add_notice($nData); } } $newpost['userid'] = $spThisUser->ID; $newpost['action'] = 'edit'; do_action('sph_post_edit_after_save', $newpost); }
function sp_TopicIndexLastPost($args = '', $label = '') { global $spThisTopic; $defs = array('tagId' => 'spTopicIndexLastPost%ID%', 'tagClass' => 'spInRowPostLink', 'labelClass' => 'spInRowLabel', 'infoClass' => 'spInRowInfo', 'linkClass' => 'spInRowLastPostLink', 'iconClass' => 'spIcon', 'icon' => 'sp_ArrowRight.png', 'tip' => 1, 'nicedate' => 1, 'date' => 0, 'time' => 0, 'user' => 1, 'stackuser' => 1, 'stackdate' => 0, 'truncateUser' => 0, 'itemBreak' => '<br />', 'echo' => 1, 'get' => 0); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_TopicIndexLastPost_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $labelClass = esc_attr($labelClass); $infoClass = esc_attr($infoClass); $linkClass = esc_attr($linkClass); $iconClass = esc_attr($iconClass); $icon = sanitize_file_name($icon); $tip = (int) $tip; $nicedate = (int) $nicedate; $date = (int) $date; $time = (int) $time; $user = (int) $user; $stackuser = (int) $stackuser; $stackdate = (int) $stackdate; $truncateUser = (int) $truncateUser; $icon = $icon; $echo = (int) $echo; $get = (int) $get; $tagId = str_ireplace('%ID%', $spThisTopic->topic_id, $tagId); if ($tip && !empty($spThisTopic->last_post_tip)) { $title = "title='{$spThisTopic->last_post_tip}'"; $linkClass .= ' vtip'; } else { $title = ''; } $stackuser ? $ulb = '<br />' : ($ulb = ' '); $stackdate ? $dlb = '<br />' : ($dlb = ' - '); $out = "<div id='{$tagId}' class='{$tagClass}'>\n"; $out .= "<span class='{$labelClass}'>" . sp_filter_title_display($label) . "\n"; # Link to post $out .= "<a class='{$linkClass}' {$title} href='{$spThisTopic->last_post_permalink}'>\n"; if (!empty($icon)) { $out .= "<img src='" . sp_find_icon(SPTHEMEICONSURL, $icon) . "' class='{$iconClass}' alt=''/>\n"; } $out .= "</a></span>\n"; # user $poster = sp_build_name_display($spThisTopic->last_user_id, sp_truncate($spThisTopic->last_display_name, $truncateUser)); if (empty($poster)) { $poster = sp_truncate($spThisTopic->last_guest_name, $truncateUser); } if ($user) { $out .= "<span class='{$labelClass}'>{$ulb}{$poster}</span>"; } $out .= $itemBreak; if ($get) { $getData = new stdClass(); $getData->permalink = $spThisTopic->first_post_permalink; $getData->topic_name = $spThisTopic->topic_name; $getData->post_date = $spThisTopic->last_post_date; $getData->tooltip = $spThisTopic->last_post_tip; $getData->user = $poster; return $getData; } # date/time if ($nicedate && isset($spThisTopic->last_post_date)) { $out .= "<span class='{$labelClass}'>" . sp_nicedate($spThisTopic->last_post_date) . "</span>\n"; } else { if ($date && isset($spThisTopic->last_post_date)) { $out .= "<span class='{$labelClass}'>" . sp_date('d', $spThisTopic->last_post_date); if ($time) { $out .= $dlb . sp_date('t', $spThisTopic->last_post_date); } $out .= "</span>\n"; } } $out .= "</div>\n"; $out = apply_filters('sph_TopicIndexLastPost', $out, $a); if ($echo) { echo $out; } else { return $out; } }
function sp_PostIndexUserRegistered($args = '', $label = '') { global $spThisPost, $spThisPostUser; if ($spThisPostUser->guest) { return; } $defs = array('tagId' => 'spPostIndexUserRegistered%ID%', 'tagClass' => 'spPostUserRegistered', 'dateFormat' => 'd', 'echo' => 1, 'get' => 0); $a = wp_parse_args($args, $defs); $a = apply_filters('sph_PostIndexUserRegistered_args', $a); extract($a, EXTR_SKIP); # sanitize before use $tagId = esc_attr($tagId); $tagClass = esc_attr($tagClass); $dateFormat = esc_attr($dateFormat); $text = sp_filter_title_display(str_replace('%DATE%', sp_date($dateFormat, $spThisPostUser->user_registered), $label)); $echo = (int) $echo; $get = (int) $get; $tagId = str_ireplace('%ID%', $spThisPost->post_id, $tagId); if ($get) { return $spThisPostUser->posts; } $out = "<div id='{$tagId}' class='{$tagClass}'>"; $out .= $text; $out .= "</div>\n"; $out = apply_filters('sph_PostIndexUserRegistered', $out, $a); if ($echo) { echo $out; } else { return $out; } }