Exemplo n.º 1
0
function spamalyser_build_post_path(&$logitem)
{
    global $lang, $forums, $mybb;
    $bburl = htmlspecialchars_uni($mybb->settings['bburl'] . '/');
    $subject = htmlspecialchars_uni($logitem['subject']);
    if ($logitem['real_pid']) {
        $subject = '<a href="' . $bburl . get_post_link($logitem['pid'], $logitem['tid']) . '#pid' . $logitem['pid'] . '" target="_blank">' . $subject . '</a>';
    }
    if ($logitem['threadsubject']) {
        if ($logitem['real_tid']) {
            $subject = '<a href="' . $bburl . get_thread_link($logitem['tid']) . '" target="_blank">' . htmlspecialchars_uni($logitem['threadsubject']) . '</a> &raquo; ' . $subject;
        } else {
            $subject = htmlspecialchars_uni($logitem['threadsubject']) . ' &raquo; ' . $subject;
        }
    }
    if (empty($forums)) {
        $forums = $GLOBALS['cache']->read('forums');
    }
    if ($forums[$logitem['fid']]) {
        $subject = '<a href="' . $bburl . get_forum_link($logitem['fid']) . '" target="_blank">' . $forums[$logitem['fid']]['name'] . '</a> &raquo; ' . $subject;
    }
    // new/edit icons
    if ($logitem['event'] == 0) {
        $subject = '<img src="spamalyser_img/post_new.gif" title="' . $lang->icon_new_thread_post . '" alt="' . $lang->icon_alt_new_thread_post . '" style="margin-right: 0.5em; font-size: smaller; vertical-align: middle;" />' . $subject;
    } elseif ($logitem['event'] == 2) {
        $subject = '<img src="spamalyser_img/post_merge.gif" title="' . $lang->icon_merge_post . '" alt="' . $lang->icon_alt_merge_post . '" style="margin-right: 0.5em; font-size: smaller; vertical-align: middle;" />' . $subject;
    } else {
        $subject = '<img src="spamalyser_img/post_edit.gif" title="' . $lang->icon_edit_thread_post . '" alt="' . $lang->icon_alt_edit_thread_post . '" style="margin-right: 0.5em; font-size: smaller; vertical-align: middle;" />' . $subject;
    }
    return $subject;
}
Exemplo n.º 2
0
function trader_give_rep($uid = 1)
{
    global $mybb, $db, $tradefeedbackform, $mypostkey, $templates, $header, $headerinclude, $footer, $lang;
    $lang->load("tradefeedback");
    $uid = intval($uid);
    $action = "give";
    if ($mybb->user['uid'] == $uid) {
        error($lang->feedback_give_self);
    }
    if (!$uid) {
        error($lang->feedback_invalid_user);
    }
    if ($mybb->request_method == "post" && verify_post_check($mybb->input['my_post_key'])) {
        // Make sure they haven't given the same user feedback within the last 24 hours
        $cutoff = TIME_NOW - 86400;
        $queryfirst = $db->simple_select("trade_feedback", "fid", "dateline >= {$cutoff} AND receiver={$uid} & giver=" . $mybb->user['uid']);
        if ($db->num_rows($queryfirst) >= 1) {
            error($lang->feedback_wait_24);
        }
        $new_rep = array("giver" => $mybb->user['uid'], "receiver" => $uid, "dateline" => TIME_NOW, "approved" => 1, "value" => intval($mybb->input['value']), "type" => $db->escape_string($mybb->input['type']), "threadlink" => $db->escape_string($mybb->input['threadlink']), "comments" => $db->escape_string($mybb->input['comments']));
        if ($mybb->settings['trade_approval'] == 1 && $mybb->usergroup['canmodcp'] == 0) {
            $new_rep['approved'] = 0;
        }
        $db->insert_query("trade_feedback", $new_rep);
        $fid = $db->insert_id();
        trader_send_pm($new_rep['receiver'], $fid);
        trader_myalerts($new_rep['receiver'], $fid);
        if ($new_rep['approved'] == 1) {
            trader_rebuild_reputation($uid);
            $message = $lang->give_feedback_added;
        } else {
            $message = $lang->give_feedback_approval_needed;
        }
        $url = $mybb->settings['bburl'] . "/tradefeedback.php?action=view&uid={$uid}";
        redirect($url, $message, "", true);
    } else {
        // Check if we have a thread id
        $tid = intval($mybb->input['tid']);
        if ($tid) {
            $threadlink_value = $mybb->settings['bburl'] . "/" . get_thread_link($tid);
            $query = $db->simple_select("threads", "subject", "tid={$tid}");
            $thread_subject = $db->fetch_field($query, "subject");
            $breadcrumb = $lang->sprintf($lang->give_feedback_fromthread_breadcrumb, $thread_subject);
        } else {
            $threadlink_value = "";
        }
        // Get the member username for confirmation
        $query = $db->simple_select("users", "uid, username", "uid={$uid}");
        $member = $db->fetch_array($query);
        $member['username'] = htmlspecialchars_uni($member['username']);
        add_breadcrumb($lang->sprintf($lang->feedback_profile, $member['username']), get_profile_link($uid));
        add_breadcrumb($lang->sprintf($lang->feedback_page_title, $member['username']), "tradefeedback.php?action=view&uid={$uid}");
        add_breadcrumb($lang->give_feedback . $breadcrumb, "tradefeedback.php?action=give&uid={$uid}");
        $feedback = array('comments' => htmlspecialchars_uni($mybb->input['comments']));
        eval("\$tradefeedbackform = \"" . $templates->get("tradefeedback_give_form") . "\";");
        output_page($tradefeedbackform);
    }
}
Exemplo n.º 3
0
function reportthread_dopost()
{
    require_once MYBB_ROOT . "inc/datahandlers/post.php";
    global $db, $mybb;
    if (intval($mybb->settings['rtt_enabled']) == 1 || preg_replace("/[^a-z]/i", "", $mybb->settings['rtt_enabled']) == "yes") {
        if ($mybb->input['type'] == 'post') {
            $title = "Reported Post By ";
            $post = get_post($mybb->input['pid']);
            $thread = get_thread($post['tid']);
            $forum = get_forum($thread['fid']);
            $tlink = get_thread_link($thread['tid']);
            $flink = get_forum_link($thread['fid']);
            $reason = $mybb->input['reason'];
            if ($reason === 'other') {
                $reason = $mybb->input['comment'];
            }
            $post_data = $mybb->user['username'] . " has reported a post.\r\n\r\nOriginal Thread: [url=" . $mybb->settings['bburl'] . "/{$tlink}]" . $thread['subject'] . "[/url]\r\nForum: [url=" . $mybb->settings['bburl'] . "/{$flink}]" . $forum['name'] . "[/url]\r\n\r\nReason Given:\r\n[quote=\"" . $mybb->user['username'] . "\" dateline=\"" . time() . "\"]" . $reason . "[/quote]\r\n\r\nPost Content:\r\n[quote=\"" . $post['username'] . "\" pid=\"" . $post['pid'] . "\" dateline=\"" . $post['dateline'] . "\"]" . $post['message'] . "[/quote]";
        } else {
            if ($mybb->input['type'] == 'reputation') {
                $title = "Reported Reputation By ";
                $rep = get_reputation_point($mybb->input['pid']);
                $giver = get_user($rep['adduid']);
                $reason = $mybb->input['reason'];
                if ($reason === 'other') {
                    $reason = $mybb->input['comment'];
                }
                $post_data = $mybb->user['username'] . " has reported a reputation point.\r\n\r\nReason Given:\r\n[quote=\"" . $mybb->user['username'] . "\" dateline=\"" . time() . "\"]" . $reason . "[/quote]\r\n\r\nReputation comment:\r\n[quote=\"" . $giver['username'] . "\" dateline=\"" . $rep['dateline'] . "\"]" . $rep['comments'] . "[/quote]";
            }
        }
        $new_thread = array("fid" => $mybb->settings['rtt_fid'], "prefix" => 0, "subject" => $title . $mybb->user['username'], "icon" => 0, "uid" => $mybb->user['uid'], "username" => $mybb->user['username'], "message" => $post_data, "ipaddress" => get_ip(), "posthash" => md5($mybb->user['uid'] . random_str()));
        $posthandler = new PostDataHandler("insert");
        $posthandler->action = "thread";
        $posthandler->set_data($new_thread);
        if ($posthandler->validate_thread()) {
            $thread_info = $posthandler->insert_thread();
        }
    }
}
function akismet_redirect_thread()
{
    global $isspam, $url, $lang, $thread, $mybb;
    if ($isspam && $mybb->settings['akismetswitch'] == 1) {
        $lang->load("akismet", false, true);
        $url = get_thread_link($thread['tid']);
        $url2 = get_forum_link($thread['fid']);
        error("<div align=\"center\">" . $lang->redirect_newreply . "<br /><br />" . $lang->sprintf($lang->redirect_return_forum, $url, $url2) . "</div>", $lang->akismet_error);
    }
}
     }
     if (!$similar_thread['username']) {
         $similar_thread['username'] = $similar_thread['threadusername'];
         $similar_thread['profilelink'] = $similar_thread['threadusername'];
     } else {
         $similar_thread['profilelink'] = build_profile_link($similar_thread['username'], $similar_thread['uid']);
     }
     // If this thread has a prefix, insert a space between prefix and subject
     if ($similar_thread['prefix'] != 0) {
         $prefix = build_prefixes($similar_thread['prefix']);
         $similar_thread['threadprefix'] = $prefix['displaystyle'] . '&nbsp;';
     }
     $similar_thread['subject'] = $parser->parse_badwords($similar_thread['subject']);
     $similar_thread['subject'] = htmlspecialchars_uni($similar_thread['subject']);
     $similar_thread['threadlink'] = get_thread_link($similar_thread['tid']);
     $similar_thread['lastpostlink'] = get_thread_link($similar_thread['tid'], 0, "lastpost");
     $lastpostdate = my_date($mybb->settings['dateformat'], $similar_thread['lastpost']);
     $lastposttime = my_date($mybb->settings['timeformat'], $similar_thread['lastpost']);
     $lastposter = $similar_thread['lastposter'];
     $lastposteruid = $similar_thread['lastposteruid'];
     // Don't link to guest's profiles (they have no profile).
     if ($lastposteruid == 0) {
         $lastposterlink = $lastposter;
     } else {
         $lastposterlink = build_profile_link($lastposter, $lastposteruid);
     }
     $similar_thread['replies'] = my_number_format($similar_thread['replies']);
     $similar_thread['views'] = my_number_format($similar_thread['views']);
     eval("\$similarthreadbits .= \"" . $templates->get("showthread_similarthreads_bit") . "\";");
 }
 if ($count) {
Exemplo n.º 6
0
 }
 $table = new Table();
 $table->construct_header($lang->username, array('width' => '10%'));
 $table->construct_header($lang->date, array("class" => "align_center", 'width' => '15%'));
 $table->construct_header($lang->action, array("class" => "align_center", 'width' => '35%'));
 $table->construct_header($lang->information, array("class" => "align_center", 'width' => '30%'));
 $table->construct_header($lang->ipaddress, array("class" => "align_center", 'width' => '10%'));
 $query = $db->query("\n\t\tSELECT l.*, u.username, u.usergroup, u.displaygroup, t.subject AS tsubject, f.name AS fname, p.subject AS psubject\n\t\tFROM " . TABLE_PREFIX . "moderatorlog l\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=l.uid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=l.tid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "forums f ON (f.fid=l.fid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "posts p ON (p.pid=l.pid)\n\t\t{$where}\n\t\tORDER BY {$sortby} {$order}\n\t\tLIMIT {$start}, {$perpage}\n\t");
 while ($logitem = $db->fetch_array($query)) {
     $information = '';
     $logitem['dateline'] = date("jS M Y, G:i", $logitem['dateline']);
     $trow = alt_trow();
     $username = format_name($logitem['username'], $logitem['usergroup'], $logitem['displaygroup']);
     $logitem['profilelink'] = build_profile_link($username, $logitem['uid']);
     if ($logitem['tsubject']) {
         $information = "<strong>{$lang->thread}</strong> <a href=\"../" . get_thread_link($logitem['tid']) . "\" target=\"_blank\">" . htmlspecialchars_uni($logitem['tsubject']) . "</a><br />";
     }
     if ($logitem['fname']) {
         $information .= "<strong>{$lang->forum}</strong> <a href=\"../" . get_forum_link($logitem['fid']) . "\" target=\"_blank\">" . htmlspecialchars_uni($logitem['fname']) . "</a><br />";
     }
     if ($logitem['psubject']) {
         $information .= "<strong>{$lang->post}</strong> <a href=\"../" . get_post_link($logitem['pid']) . "#pid{$logitem['pid']}\">" . htmlspecialchars_uni($logitem['psubject']) . "</a>";
     }
     $table->construct_cell($logitem['profilelink']);
     $table->construct_cell($logitem['dateline'], array("class" => "align_center"));
     $table->construct_cell($logitem['action'], array("class" => "align_center"));
     $table->construct_cell($information);
     $table->construct_cell($logitem['ipaddress'], array("class" => "align_center"));
     $table->construct_row();
 }
 if ($table->num_rows() == 0) {
Exemplo n.º 7
0
/**
 * Builds a friendly named Who's Online location from an "activity" and array of user data. Assumes fetch_wol_activity has already been called.
 *
 * @param array Array containing activity and essential IDs.
 * @return string Location name for the activity being performed.
 */
function build_friendly_wol_location($user_activity)
{
    global $db, $lang, $uid_list, $aid_list, $pid_list, $tid_list, $fid_list, $ann_list, $eid_list, $plugins, $parser, $mybb;
    global $threads, $forums, $forums_linkto, $forum_cache, $posts, $announcements, $events, $usernames, $attachments;
    // Fetch forum permissions for this user
    $unviewableforums = get_unviewable_forums();
    $inactiveforums = get_inactive_forums();
    $fidnot = '';
    $unviewablefids = $inactivefids = array();
    if ($unviewableforums) {
        $fidnot = " AND fid NOT IN ({$unviewableforums})";
        $unviewablefids = explode(',', $unviewableforums);
    }
    if ($inactiveforums) {
        $fidnot .= " AND fid NOT IN ({$inactiveforums})";
        $inactivefids = explode(',', $inactiveforums);
    }
    // Fetch any users
    if (!is_array($usernames) && count($uid_list) > 0) {
        $uid_sql = implode(",", $uid_list);
        if ($uid_sql != $mybb->user['uid']) {
            $query = $db->simple_select("users", "uid,username", "uid IN ({$uid_sql})");
            while ($user = $db->fetch_array($query)) {
                $usernames[$user['uid']] = $user['username'];
            }
        } else {
            $usernames[$mybb->user['uid']] = $mybb->user['username'];
        }
    }
    // Fetch any attachments
    if (!is_array($attachments) && count($aid_list) > 0) {
        $aid_sql = implode(",", $aid_list);
        $query = $db->simple_select("attachments", "aid,pid", "aid IN ({$aid_sql})");
        while ($attachment = $db->fetch_array($query)) {
            $attachments[$attachment['aid']] = $attachment['pid'];
            $pid_list[] = $attachment['pid'];
        }
    }
    // Fetch any announcements
    if (!is_array($announcements) && count($ann_list) > 0) {
        $aid_sql = implode(",", $ann_list);
        $query = $db->simple_select("announcements", "aid,subject", "aid IN ({$aid_sql}) {$fidnot}");
        while ($announcement = $db->fetch_array($query)) {
            $announcement_title = htmlspecialchars_uni($parser->parse_badwords($announcement['subject']));
            $announcements[$announcement['aid']] = $announcement_title;
        }
    }
    // Fetch any posts
    if (!is_array($posts) && count($pid_list) > 0) {
        $pid_sql = implode(",", $pid_list);
        $query = $db->simple_select("posts", "pid,tid", "pid IN ({$pid_sql}) {$fidnot}");
        while ($post = $db->fetch_array($query)) {
            $posts[$post['pid']] = $post['tid'];
            $tid_list[] = $post['tid'];
        }
    }
    // Fetch any threads
    if (!is_array($threads) && count($tid_list) > 0) {
        $perms = array();
        $tid_sql = implode(",", $tid_list);
        $query = $db->simple_select('threads', 'uid, fid, tid, subject, visible, prefix', "tid IN({$tid_sql}) {$fidnot}");
        $threadprefixes = build_prefixes();
        while ($thread = $db->fetch_array($query)) {
            $thread['threadprefix'] = '';
            if ($thread['prefix'] && !empty($threadprefixes[$thread['prefix']])) {
                $thread['threadprefix'] = $threadprefixes[$thread['prefix']]['displaystyle'];
            }
            if (empty($perms[$thread['fid']])) {
                $perms[$thread['fid']] = forum_permissions($thread['fid']);
            }
            if (isset($perms[$thread['fid']]['canonlyviewownthreads']) && $perms[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid'] && !is_moderator($thread['fid'])) {
                continue;
            }
            if (is_moderator($thread['fid']) || $thread['visible'] == 1) {
                $thread_title = '';
                if ($thread['threadprefix']) {
                    $thread_title = $thread['threadprefix'] . '&nbsp;';
                }
                $thread_title .= htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
                $threads[$thread['tid']] = $thread_title;
                $fid_list[] = $thread['fid'];
            }
        }
    }
    // Fetch any forums
    if (!is_array($forums) && count($fid_list) > 0) {
        $fidnot = array_merge($unviewablefids, $inactivefids);
        foreach ($forum_cache as $fid => $forum) {
            if (in_array($fid, $fid_list) && !in_array($fid, $fidnot)) {
                $forums[$fid] = $forum['name'];
                $forums_linkto[$fid] = $forum['linkto'];
            }
        }
    }
    // And finaly any events
    if (!is_array($events) && count($eid_list) > 0) {
        $eid_sql = implode(",", $eid_list);
        $query = $db->simple_select("events", "eid,name", "eid IN ({$eid_sql})");
        while ($event = $db->fetch_array($query)) {
            $events[$event['eid']] = htmlspecialchars_uni($parser->parse_badwords($event['name']));
        }
    }
    // Now we've got everything we need we can put a name to the location
    switch ($user_activity['activity']) {
        // announcement.php functions
        case "announcements":
            if (!empty($announcements[$user_activity['ann']])) {
                $location_name = $lang->sprintf($lang->viewing_announcements, get_announcement_link($user_activity['ann']), $announcements[$user_activity['ann']]);
            } else {
                $location_name = $lang->viewing_announcements2;
            }
            break;
            // attachment.php actions
        // attachment.php actions
        case "attachment":
            $pid = $attachments[$user_activity['aid']];
            $tid = $posts[$pid];
            if (!empty($threads[$tid])) {
                $location_name = $lang->sprintf($lang->viewing_attachment2, $user_activity['aid'], $threads[$tid], get_thread_link($tid));
            } else {
                $location_name = $lang->viewing_attachment;
            }
            break;
            // calendar.php functions
        // calendar.php functions
        case "calendar":
            $location_name = $lang->viewing_calendar;
            break;
        case "calendar_event":
            if (!empty($events[$user_activity['eid']])) {
                $location_name = $lang->sprintf($lang->viewing_event2, get_event_link($user_activity['eid']), $events[$user_activity['eid']]);
            } else {
                $location_name = $lang->viewing_event;
            }
            break;
        case "calendar_addevent":
            $location_name = $lang->adding_event;
            break;
        case "calendar_editevent":
            $location_name = $lang->editing_event;
            break;
        case "contact":
            $location_name = $lang->viewing_contact_us;
            break;
            // editpost.php functions
        // editpost.php functions
        case "editpost":
            $location_name = $lang->editing_post;
            break;
            // forumdisplay.php functions
        // forumdisplay.php functions
        case "forumdisplay":
            if (!empty($forums[$user_activity['fid']])) {
                if ($forums_linkto[$user_activity['fid']]) {
                    $location_name = $lang->sprintf($lang->forum_redirect_to, get_forum_link($user_activity['fid']), $forums[$user_activity['fid']]);
                } else {
                    $location_name = $lang->sprintf($lang->viewing_forum2, get_forum_link($user_activity['fid']), $forums[$user_activity['fid']]);
                }
            } else {
                $location_name = $lang->viewing_forum;
            }
            break;
            // index.php functions
        // index.php functions
        case "index":
            $location_name = $lang->sprintf($lang->viewing_index, $mybb->settings['bbname']);
            break;
            // managegroup.php functions
        // managegroup.php functions
        case "managegroup":
            $location_name = $lang->managing_group;
            break;
            // member.php functions
        // member.php functions
        case "member_activate":
            $location_name = $lang->activating_account;
            break;
        case "member_profile":
            if (!empty($usernames[$user_activity['uid']])) {
                $location_name = $lang->sprintf($lang->viewing_profile2, get_profile_link($user_activity['uid']), $usernames[$user_activity['uid']]);
            } else {
                $location_name = $lang->viewing_profile;
            }
            break;
        case "member_register":
            $location_name = $lang->registering;
            break;
        case "member":
        case "member_login":
            // Guest or member?
            if ($mybb->user['uid'] == 0) {
                $location_name = $lang->logging_in;
            } else {
                $location_name = $lang->logging_in_plain;
            }
            break;
        case "member_logout":
            $location_name = $lang->logging_out;
            break;
        case "member_emailuser":
            $location_name = $lang->emailing_user;
            break;
        case "member_rate":
            $location_name = $lang->rating_user;
            break;
        case "member_resendactivation":
            $location_name = $lang->member_resendactivation;
            break;
        case "member_lostpw":
            $location_name = $lang->member_lostpw;
            break;
            // memberlist.php functions
        // memberlist.php functions
        case "memberlist":
            $location_name = $lang->viewing_memberlist;
            break;
            // misc.php functions
        // misc.php functions
        case "misc_dstswitch":
            $location_name = $lang->changing_dst;
            break;
        case "misc_whoposted":
            if (!empty($threads[$user_activity['tid']])) {
                $location_name = $lang->sprintf($lang->viewing_whoposted2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']]);
            } else {
                $location_name = $lang->viewing_whoposted;
            }
            break;
        case "misc_markread":
            $location_name = $lang->sprintf($lang->marking_read, $mybb->post_code);
            break;
        case "misc_help":
            $location_name = $lang->viewing_helpdocs;
            break;
        case "misc_buddypopup":
            $location_name = $lang->viewing_buddylist;
            break;
        case "misc_smilies":
            $location_name = $lang->viewing_smilies;
            break;
        case "misc_syndication":
            $location_name = $lang->viewing_syndication;
            break;
        case "misc_imcenter":
            $location_name = $lang->viewing_imcenter;
            break;
            // modcp.php functions
        // modcp.php functions
        case "modcp_modlogs":
            $location_name = $lang->viewing_modlogs;
            break;
        case "modcp_announcements":
            $location_name = $lang->managing_announcements;
            break;
        case "modcp_finduser":
            $location_name = $lang->search_for_user;
            break;
        case "modcp_warninglogs":
            $location_name = $lang->managing_warninglogs;
            break;
        case "modcp_ipsearch":
            $location_name = $lang->searching_ips;
            break;
        case "modcp_report":
            $location_name = $lang->viewing_reports;
            break;
        case "modcp_new_announcement":
            $location_name = $lang->adding_announcement;
            break;
        case "modcp_delete_announcement":
            $location_name = $lang->deleting_announcement;
            break;
        case "modcp_edit_announcement":
            $location_name = $lang->editing_announcement;
            break;
        case "modcp_mod_queue":
            $location_name = $lang->managing_modqueue;
            break;
        case "modcp_editprofile":
            $location_name = $lang->editing_user_profiles;
            break;
        case "modcp_banning":
            $location_name = $lang->managing_bans;
            break;
        case "modcp":
            $location_name = $lang->viewing_modcp;
            break;
            // moderation.php functions
        // moderation.php functions
        case "moderation":
            $location_name = $lang->using_modtools;
            break;
            // newreply.php functions
        // newreply.php functions
        case "newreply":
            if (!empty($threads[$user_activity['tid']])) {
                $location_name = $lang->sprintf($lang->replying_thread2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']]);
            } else {
                $location_name = $lang->replying_thread;
            }
            break;
            // newthread.php functions
        // newthread.php functions
        case "newthread":
            if (!empty($forums[$user_activity['fid']])) {
                $location_name = $lang->sprintf($lang->posting_thread2, get_forum_link($user_activity['fid']), $forums[$user_activity['fid']]);
            } else {
                $location_name = $lang->posting_thread;
            }
            break;
            // online.php functions
        // online.php functions
        case "wol":
            $location_name = $lang->viewing_wol;
            break;
        case "woltoday":
            $location_name = $lang->viewing_woltoday;
            break;
            // polls.php functions
        // polls.php functions
        case "newpoll":
            $location_name = $lang->creating_poll;
            break;
        case "editpoll":
            $location_name = $lang->editing_poll;
            break;
        case "showresults":
            $location_name = $lang->viewing_pollresults;
            break;
        case "vote":
            $location_name = $lang->voting_poll;
            break;
            // printthread.php functions
        // printthread.php functions
        case "printthread":
            if (!empty($threads[$user_activity['tid']])) {
                $location_name = $lang->sprintf($lang->printing_thread2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']]);
            } else {
                $location_name = $lang->printing_thread;
            }
            break;
            // private.php functions
        // private.php functions
        case "private_send":
            $location_name = $lang->sending_pm;
            break;
        case "private_read":
            $location_name = $lang->reading_pm;
            break;
        case "private_folders":
            $location_name = $lang->editing_pmfolders;
            break;
        case "private":
            $location_name = $lang->using_pmsystem;
            break;
            /* Ratethread functions */
        /* Ratethread functions */
        case "ratethread":
            $location_name = $lang->rating_thread;
            break;
            // report.php functions
        // report.php functions
        case "report":
            $location_name = $lang->reporting_post;
            break;
            // reputation.php functions
        // reputation.php functions
        case "reputation":
            $location_name = $lang->sprintf($lang->giving_reputation, get_profile_link($user_activity['uid']), $usernames[$user_activity['uid']]);
            break;
        case "reputation_report":
            if (!empty($usernames[$user_activity['uid']])) {
                $location_name = $lang->sprintf($lang->viewing_reputation_report, "reputation.php?uid={$user_activity['uid']}", $usernames[$user_activity['uid']]);
            } else {
                $location_name = $lang->sprintf($lang->viewing_reputation_report2);
            }
            break;
            // search.php functions
        // search.php functions
        case "search":
            $location_name = $lang->sprintf($lang->searching_forum, $mybb->settings['bbname']);
            break;
            // showthread.php functions
        // showthread.php functions
        case "showthread":
            if (!empty($threads[$user_activity['tid']])) {
                $pagenote = '';
                $location_name = $lang->sprintf($lang->reading_thread2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']], $pagenote);
            } else {
                $location_name = $lang->reading_thread;
            }
            break;
        case "showpost":
            if (!empty($posts[$user_activity['pid']]) && !empty($threads[$posts[$user_activity['pid']]])) {
                $pagenote = '';
                $location_name = $lang->sprintf($lang->reading_thread2, get_thread_link($posts[$user_activity['pid']]), $threads[$posts[$user_activity['pid']]], $pagenote);
            } else {
                $location_name = $lang->reading_thread;
            }
            break;
            // showteam.php functions
        // showteam.php functions
        case "showteam":
            $location_name = $lang->viewing_team;
            break;
            // stats.php functions
        // stats.php functions
        case "stats":
            $location_name = $lang->viewing_stats;
            break;
            // usercp.php functions
        // usercp.php functions
        case "usercp_profile":
            $location_name = $lang->updating_profile;
            break;
        case "usercp_editlists":
            $location_name = $lang->managing_buddyignorelist;
            break;
        case "usercp_options":
            $location_name = $lang->updating_options;
            break;
        case "usercp_editsig":
            $location_name = $lang->editing_signature;
            break;
        case "usercp_avatar":
            $location_name = $lang->changing_avatar;
            break;
        case "usercp_subscriptions":
            $location_name = $lang->viewing_subscriptions;
            break;
        case "usercp_favorites":
            $location_name = $lang->viewing_favorites;
            break;
        case "usercp_notepad":
            $location_name = $lang->editing_pad;
            break;
        case "usercp_password":
            $location_name = $lang->editing_password;
            break;
        case "usercp":
            $location_name = $lang->user_cp;
            break;
        case "usercp2_favorites":
            $location_name = $lang->managing_favorites;
            break;
        case "usercp2_subscriptions":
            $location_name = $lang->managing_subscriptions;
            break;
        case "portal":
            $location_name = $lang->viewing_portal;
            break;
            // sendthread.php functions
        // sendthread.php functions
        case "sendthread":
            $location_name = $lang->sending_thread;
            break;
            // warnings.php functions
        // warnings.php functions
        case "warnings_revoke":
            $location_name = $lang->revoking_warning;
            break;
        case "warnings_warn":
            $location_name = $lang->warning_user;
            break;
        case "warnings_view":
            $location_name = $lang->viewing_warning;
            break;
        case "warnings":
            $location_name = $lang->managing_warnings;
            break;
    }
    $plugin_array = array('user_activity' => &$user_activity, 'location_name' => &$location_name);
    $plugins->run_hooks("build_friendly_wol_location_end", $plugin_array);
    if (isset($user_activity['nopermission']) && $user_activity['nopermission'] == 1) {
        $location_name = $lang->viewing_noperms;
    }
    if (!$location_name) {
        $location_name = $lang->sprintf($lang->unknown_location, $user_activity['location']);
    }
    return $location_name;
}
Exemplo n.º 8
0
        $ismod = false;
    }
    // Make sure we are looking at a real thread here.
    if ($thread['visible'] != 1 && $ismod == false || $thread['visible'] > 1 && $ismod == true) {
        error($lang->error_invalidthread);
    }
    $forumpermissions = forum_permissions($thread['fid']);
    if ($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0 || isset($forumpermissions['canonlyviewownthreads']) && $forumpermissions['canonlyviewownthreads'] != 0 && $thread['uid'] != $mybb->user['uid']) {
        error_no_permission();
    }
    $plugins->run_hooks("usercp2_do_addsubscription");
    add_subscribed_thread($thread['tid'], $mybb->get_input('notification', MyBB::INPUT_INT));
    if ($mybb->get_input('referrer')) {
        $url = htmlspecialchars_uni($mybb->get_input('referrer'));
    } else {
        $url = get_thread_link($thread['tid']);
    }
    redirect($url, $lang->redirect_subscriptionadded);
} elseif ($mybb->get_input('action') == "addsubscription") {
    if ($mybb->get_input('type') == "forum") {
        $forum = get_forum($mybb->get_input('fid', MyBB::INPUT_INT));
        if (!$forum) {
            error($lang->error_invalidforum);
        }
        $forumpermissions = forum_permissions($forum['fid']);
        if ($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0) {
            error_no_permission();
        }
        $plugins->run_hooks("usercp2_addsubscription_forum");
        add_subscribed_forum($forum['fid']);
        if ($server_http_referer) {
Exemplo n.º 9
0
 }
 if ($thread['visible'] != 1) {
     if (is_moderator($forum['fid'])) {
         archive_error($lang->sprintf($lang->error_unapproved_thread, $mybb->settings['bburl'] . "/" . get_thread_link($thread['tid'], $page)));
     } else {
         archive_error($lang->error_invalidthread);
     }
 }
 if ($forumpermissions['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid']) {
     archive_error_no_permission();
 }
 check_forum_password_archive($forum['fid']);
 // Build the navigation
 build_forum_breadcrumb($forum['fid'], 1);
 add_breadcrumb($thread['subject']);
 archive_header($thread['subject'], $thread['subject'], $mybb->settings['bburl'] . "/" . get_thread_link($thread['tid'], $page));
 $plugins->run_hooks("archive_thread_start");
 if (!$mybb->settings['postsperpage'] || (int) $mybb->settings['postsperpage'] < 1) {
     $mybb->settings['postsperpage'] = 20;
 }
 // Paginate this thread
 $perpage = $mybb->settings['postsperpage'];
 $postcount = intval($thread['replies']) + 1;
 $pages = ceil($postcount / $perpage);
 if ($page > $pages) {
     $page = 1;
 }
 if ($page) {
     $start = ($page - 1) * $perpage;
 } else {
     $start = 0;
Exemplo n.º 10
0
    if ($poll['multiple'] == 1) {
        foreach ($vote_options as $vote) {
            if (isset($votesarray[$vote - 1])) {
                --$votesarray[$vote - 1];
                --$poll['numvotes'];
            }
        }
    } else {
        $voteoption = reset($vote_options);
        if (isset($votesarray[$voteoption - 1])) {
            --$votesarray[$voteoption - 1];
            --$poll['numvotes'];
        }
    }
    // check if anything < 0 - possible if Guest vote undoing is allowed (generally Guest unvoting should be disabled >_>)
    if ($poll['numvotes'] < 0) {
        $poll['numvotes'] = 0;
    }
    foreach ($votesarray as $i => $votes) {
        if ($votes < 0) {
            $votesarray[$i] = 0;
        }
    }
    $voteslist = implode("||~|~||", $votesarray);
    $updatedpoll = array("votes" => $db->escape_string($voteslist), "numvotes" => (int) $poll['numvotes']);
    $plugins->run_hooks("polls_do_undovote_process");
    $db->delete_query("pollvotes", "uid='" . $mybb->user['uid'] . "' AND pid='" . $poll['pid'] . "'");
    $db->update_query("polls", $updatedpoll, "pid='" . $poll['pid'] . "'");
    $plugins->run_hooks("polls_do_undovote_end");
    redirect(get_thread_link($poll['tid']), $lang->redirect_unvoted);
}
$perpage = $mybb->settings['postsperpage'];
$postcount = intval($thread['replies']) + 1;
$pages = ceil($postcount / $perpage);
if ($page > $pages) {
    $page = 1;
}
if ($page > 0) {
    $start = ($page - 1) * $perpage;
} else {
    $start = 0;
    $page = 1;
}
if ($postcount > $perpage) {
    $multipage = printthread_multipage($postcount, $perpage, $page, "printthread.php?tid={$tid}");
}
$thread['threadlink'] = get_thread_link($tid);
$postrows = '';
if (is_moderator($forum['fid'])) {
    $visible = "AND (p.visible='0' OR p.visible='1')";
} else {
    $visible = "AND p.visible='1'";
}
$query = $db->query("\r\n    SELECT u.*, u.username AS userusername, p.*\r\n    FROM " . TABLE_PREFIX . "posts p\r\n    LEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=p.uid)\r\n    WHERE p.tid='{$tid}' {$visible}\r\n    ORDER BY p.dateline\r\n\tLIMIT {$start}, {$perpage}\r\n");
while ($postrow = $db->fetch_array($query)) {
    if ($postrow['userusername']) {
        $postrow['username'] = $postrow['userusername'];
    }
    $postrow['subject'] = htmlspecialchars_uni($parser->parse_badwords($postrow['subject']));
    $postrow['date'] = my_date($mybb->settings['dateformat'], $postrow['dateline']);
    $postrow['time'] = my_date($mybb->settings['timeformat'], $postrow['dateline']);
    $postrow['profilelink'] = build_profile_link($postrow['username'], $postrow['uid']);
Exemplo n.º 12
0
function asb_rand_quote_get_quote($settings, $width)
{
    global $db, $mybb, $templates, $lang, $theme;
    if (!$lang->asb_addon) {
        $lang->load('asb_addon');
    }
    // get forums user cannot view
    $unviewable = get_unviewable_forums(true);
    if ($unviewable) {
        $unviewwhere = " AND p.fid NOT IN ({$unviewable})";
    }
    // get inactive forums
    $inactive = get_inactive_forums();
    if ($inactive) {
        $inactivewhere = " AND p.fid NOT IN ({$inactive})";
    }
    if ($settings['important_threads_only']) {
        $important_threads = ' AND NOT t.sticky=0';
    }
    // build the exclude conditions
    $show['fids'] = asb_build_id_list($settings['forum_show_list'], 'p.fid');
    $show['tids'] = asb_build_id_list($settings['thread_show_list'], 'p.tid');
    $hide['fids'] = asb_build_id_list($settings['forum_hide_list'], 'p.fid');
    $hide['tids'] = asb_build_id_list($settings['thread_hide_list'], 'p.tid');
    $where['show'] = asb_build_SQL_where($show, ' OR ');
    $where['hide'] = asb_build_SQL_where($hide, ' OR ', ' NOT ');
    $query_where = $important_threads . $unviewwhere . $inactivewhere . asb_build_SQL_where($where, ' AND ', ' AND ');
    $post_query = $db->query("\n\t\tSELECT\n\t\t\tp.pid, p.message, p.fid, p.tid, p.subject, p.uid,\n\t\t\tu.username, u.usergroup, u.displaygroup, u.avatar,\n\t\t\tt.sticky\n\t\tFROM {$db->table_prefix}posts p\n\t\tLEFT JOIN {$db->table_prefix}users u ON (u.uid=p.uid)\n\t\tLEFT JOIN {$db->table_prefix}threads t ON (t.tid=p.tid)\n\t\tWHERE\n\t\t\tp.visible='1'{$query_where}\n\t\tORDER BY\n\t\t\tRAND()\n\t\tLIMIT 1;");
    // if there was 1 . . .
    if ($db->num_rows($post_query) == 0) {
        return false;
    }
    $rand_post = $db->fetch_array($post_query);
    // build a post parser
    require_once MYBB_ROOT . 'inc/class_parser.php';
    $parser = new postParser();
    // we just need the text and smilies (we'll parse them after we check length)
    $pattern = "|[[\\/\\!]*?[^\\[\\]]*?]|si";
    $new_message = asb_strip_url(preg_replace($pattern, '$1', $rand_post['message']));
    // get some dimensions that make sense in relation to column width
    $asb_width = (int) $width;
    $asb_inner_size = $asb_width * 0.83;
    $avatar_size = (int) ($asb_inner_size / 5);
    $font_size = $asb_width / 4.5;
    $font_size = max(10, min(16, $font_size));
    $username_font_size = (int) ($font_size * 0.9);
    $title_font_size = (int) ($font_size * 0.65);
    $message_font_size = (int) $font_size;
    if (strlen($new_message) < $settings['min_length']) {
        if ($settings['default_text']) {
            $new_message = $settings['default_text'];
        } else {
            // nothing to show
            return false;
        }
    }
    if ($settings['max_length'] && strlen($new_message) > $settings['max_length']) {
        $new_message = substr($new_message, 0, $settings['max_length']) . ' . . .';
    }
    // set up the user name link so that it displays correctly for the display group of the user
    $plain_text_username = htmlspecialchars_uni($rand_post['username']);
    $username = format_name($plain_text_username, $rand_post['usergroup'], $rand_post['displaygroup']);
    $author_link = get_profile_link($rand_post['uid']);
    $post_link = get_post_link($rand_post['pid'], $rand_post['tid']) . '#pid' . $rand_post['pid'];
    $thread_link = get_thread_link($rand_post['tid']);
    // allow smilies, but kill
    $parser_options = array("allow_smilies" => 1);
    $new_message = str_replace(array('<br />', '/me'), array('', " * {$plain_text_username}"), $parser->parse_message($new_message . ' ', $parser_options));
    // if the user has an avatar then display it, otherwise force the default avatar.
    $avatar_filename = "{$theme['imgdir']}/default_avatar.gif";
    if ($rand_post['avatar'] != '') {
        $avatar_filename = $rand_post['avatar'];
    }
    $avatar_alt = $lang->sprintf($lang->asb_random_quote_users_profile, $plain_text_username);
    eval("\$read_more = \"" . $templates->get('asb_rand_quote_read_more') . "\";");
    if (my_strlen($rand_post['subject']) > 40) {
        $rand_post['subject'] = my_substr($rand_post['subject'], 0, 40) . ' . . .';
    }
    if (substr(strtolower($rand_post['subject']), 0, 3) == 're:') {
        $rand_post['subject'] = substr($rand_post['subject'], 3);
    }
    $rand_post['subject'] = htmlspecialchars_uni($parser->parse_badwords($rand_post['subject']));
    $thread_title_link = <<<EOF
<strong><a href="{$thread_link}" title="{$lang->asb_random_quotes_read_more_threadlink_title}"><span style="font-size: {$title_font_size}px;">{$rand_post['subject']}</span></a></strong>
EOF;
    // eval() the template
    eval("\$this_quote = \"" . $templates->get("asb_rand_quote_sidebox") . "\";");
    return $this_quote;
}
Exemplo n.º 13
0
    }
}
// Most viewed threads
$most_viewed = $cache->read("most_viewed_threads");
if (!$most_viewed) {
    $cache->update_most_viewed_threads();
    $most_viewed = $cache->read("most_viewed_threads", true);
}
$mostviews = '';
if (!empty($most_viewed)) {
    foreach ($most_viewed as $key => $thread) {
        if (!in_array($thread['fid'], $unviewableforumsarray)) {
            $thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
            $numberbit = my_number_format($thread['views']);
            $numbertype = $lang->views;
            $thread['threadlink'] = get_thread_link($thread['tid']);
            eval("\$mostviews .= \"" . $templates->get("stats_thread") . "\";");
        }
    }
}
$statistics = $cache->read('statistics');
$mybb->settings['statscachetime'] = (int) $mybb->settings['statscachetime'];
if ($mybb->settings['statscachetime'] < 1) {
    $mybb->settings['statscachetime'] = 0;
}
$interval = (int) $mybb->settings['statscachetime'] * 60860;
if (!$statistics || TIME_NOW - $interval > $statistics['time'] || $mybb->settings['statscachetime'] == 0) {
    $cache->update_statistics();
    $statistics = $cache->read('statistics');
}
// Top forum
Exemplo n.º 14
0
function ps_GetMostViewed($NumOfRows)
{
    global $mybb, $db, $templates, $theme, $lang, $unviewables, $under_mod_forums_arr, $vcheck, $parser, $ps_align;
    if (!is_object($parser)) {
        require_once MYBB_ROOT . 'inc/class_parser.php';
        $parser = new postParser();
    }
    $query = $db->query("\n\t\tSELECT t.subject,t.tid,t.fid,t.lastpost,t.views,t.visible,tr.uid AS truid,tr.dateline \n\t\tFROM " . TABLE_PREFIX . "threads t \n\t\tLEFT JOIN " . TABLE_PREFIX . "threadsread tr ON (tr.tid=t.tid AND tr.uid='" . $mybb->user['uid'] . "') \n\t\tLEFT JOIN " . TABLE_PREFIX . "forums f ON (f.fid = t.fid) \n\t\tWHERE (t.visible = '1' " . $vcheck . ") \n\t\t" . $unviewables['string'] . " \n\t\tAND t.closed NOT LIKE 'moved|%' \n\t\tAND t.visible != '-2' \n\t\tAND f.active = '1' \n\t\tORDER BY t.views DESC \n\t\tLIMIT 0," . $NumOfRows);
    while ($most_views = $db->fetch_array($query)) {
        $subject_long = htmlspecialchars_uni($parser->parse_badwords($most_views['subject']));
        $tid = $most_views['tid'];
        $subject = htmlspecialchars_uni(ps_SubjectLength($parser->parse_badwords($most_views['subject']), NULL, true));
        $views = $most_views['views'];
        $lightbulb['folder'] = "off";
        $highlight = ps_GetHighlight($most_views);
        if ($mybb->user['uid']) {
            if ($most_views['dateline'] && $most_views['truid'] == $mybb->user['uid']) {
                if ($most_views['lastpost'] > $most_views['dateline']) {
                    $lightbulb['folder'] = "on";
                }
            } else {
                if ($most_views['lastpost'] > $mybb->user['lastvisit']) {
                    $lightbulb['folder'] = "on";
                }
            }
        }
        $threadlink = $mybb->settings['bburl'] . '/' . get_thread_link($tid);
        eval("\$readstate_icon = \"" . $templates->get("prostats_readstate_icon") . "\";");
        eval("\$mostviews_row .= \"" . $templates->get("prostats_mostviews_row") . "\";");
    }
    eval("\$column_mostviews = \"" . $templates->get("prostats_mostviews") . "\";");
    return $column_mostviews;
}
function MSB_newthread()
{
    global $mybb, $tid, $settings, $lang, $forum;
    if (!in_array((int) $forum['fid'], explode(',', $mybb->settings['miunashout_folder_acc']))) {
        $lang->load('admin/config_miunashoutbox');
        $name = format_name($mybb->user['username'], $mybb->user['usergroup'], $mybb->user['displaygroup']);
        $link = '[url=' . $settings['bburl'] . '/' . get_thread_link($tid) . ']' . $mybb->input['subject'] . '[/url]';
        $linklang = $lang->sprintf($lang->miunashoutbox_newthread_lang, $link);
        $data = array("nick" => $name, "msg" => $linklang, "nickto" => "0", "uid" => $mybb->user['uid'], "gid" => $mybb->user['usergroup'], "colorsht" => $mybb->settings['miunashout_newpt_color'], "bold" => "NaN", "font" => "NaN", "size" => "NaN", "avatar" => $mybb->user['avatar'], "uidto" => "0," . $thread['uid'] . "", "type" => "system", "token" => msb_token_gen());
        sendPostDataMSB('newposthread', $data);
    }
}
function ougc_showinportal_myalerts_output(&$args)
{
    global $mybb;
    if ($args['alert_type'] != 'ougc_showinportal' || !$mybb->user['myalerts_settings']['ougc_showinportal']) {
        return;
    }
    global $showinportal, $lang;
    $showinportal->lang_load();
    $lang_var = 'ougc_showinportal_myalerts_showinportal';
    if (!$args['content'][0]) {
        $lang_var = 'ougc_showinportal_myalerts_unshowinportal';
    }
    $thread = get_thread($args['tid']);
    if (!$thread) {
        return;
    }
    $args['threadLink'] = $mybb->settings['bburl'] . '/' . get_thread_link($thread['tid']);
    $args['message'] = $lang->sprintf($lang->{$lang_var}, $args['user'], $args['threadLink'], htmlspecialchars_uni($thread['subject']), $args['dateline']);
    $args['rowType'] = 'showinportal';
}
Exemplo n.º 17
0
     if ($readcookie > $forum_read) {
         $lastread = $readcookie;
     } else {
         $lastread = $forum_read;
     }
 }
 // Folder Icons
 if ($thread['doticon']) {
     $folder = "dot_";
     $folder_label .= $lang->icon_dot;
 }
 if ($thread['lastpost'] > $lastread && $lastread) {
     $folder .= "new";
     $folder_label .= $lang->icon_new;
     $new_class = "subject_new";
     $thread['newpostlink'] = get_thread_link($thread['tid'], 0, "newpost");
     eval("\$gotounread = \"" . $templates->get("forumdisplay_thread_gotounread") . "\";");
     $unreadpost = 1;
 } else {
     $folder_label .= $lang->icon_no_new;
     $new_class = "subject_old";
 }
 if ($thread['replies'] >= $mybb->settings['hottopic'] || $thread['views'] >= $mybb->settings['hottopicviews']) {
     $folder .= "hot";
     $folder_label .= $lang->icon_hot;
 }
 // Is our thread visible?
 if ($thread['visible'] == 0) {
     $bgcolor = 'trow_shaded';
 }
 if ($thread['closed'] == 1) {
Exemplo n.º 18
0
     if ($mybb->input['postpoll'] && $forumpermissions['canpostpolls']) {
         $url = "polls.php?action=newpoll&tid={$tid}&polloptions=" . intval($mybb->input['numpolloptions']);
         $lang->redirect_newthread .= $lang->redirect_newthread_poll;
     } else {
         if (!$visible) {
             // Moderated thread
             if ($mybb->user['showredirect'] != 1) {
                 // User must see moderation notice, regardless of redirect settings
                 $mybb->user['showredirect'] = 1;
             }
             $lang->redirect_newthread .= $lang->redirect_newthread_moderation;
             $url = get_forum_link($fid);
         } else {
             // Visible thread
             $lang->redirect_newthread .= $lang->redirect_newthread_thread;
             $url = get_thread_link($tid);
         }
     }
 }
 // Mark any quoted posts so they're no longer selected - attempts to maintain those which weren't selected
 if ($mybb->input['quoted_ids'] && $mybb->cookies['multiquote'] && $mybb->settings['multiquote'] != 0) {
     // We quoted all posts - remove the entire cookie
     if ($mybb->input['quoted_ids'] == "all") {
         my_unsetcookie("multiquote");
     }
 }
 $plugins->run_hooks("newthread_do_newthread_end");
 // Hop to it! Send them to the next page.
 if (!$mybb->input['postpoll']) {
     $lang->redirect_newthread .= $lang->sprintf($lang->redirect_return_forum, get_forum_link($fid));
 }
Exemplo n.º 19
0
         $vote_reputation = "+{$vote_reputation}";
         $status_class = "trow_reputation_positive";
         $vote_type_class = "reputation_positive";
         $vote_type = $lang->positive;
     }
 }
 $vote_reputation = "({$vote_reputation})";
 // Format the date this reputation was last modified
 $last_updated_date = my_date('relative', $reputation_vote['dateline']);
 $last_updated = $lang->sprintf($lang->last_updated, $last_updated_date);
 // Is this rating specific to a post?
 $postrep_given = '';
 if ($reputation_vote['pid']) {
     $postrep_given = $lang->sprintf($lang->postrep_given_nolink, $user['username']);
     if (isset($post_reputation[$reputation_vote['pid']])) {
         $thread_link = get_thread_link($post_reputation[$reputation_vote['pid']]['tid']);
         $subject = htmlspecialchars_uni($parser->parse_badwords($post_reputation[$reputation_vote['pid']]['subject']));
         $thread_link = $lang->sprintf($lang->postrep_given_thread, $thread_link, $subject);
         $link = get_post_link($reputation_vote['pid']) . "#pid{$reputation_vote['pid']}";
         $postrep_given = $lang->sprintf($lang->postrep_given, $link, $user['username'], $thread_link);
     }
 }
 // Does the current user have permission to delete this reputation? Show delete link
 $delete_link = '';
 if ($mybb->usergroup['issupermod'] == 1 || $mybb->usergroup['candeletereputations'] == 1 && $reputation_vote['adduid'] == $mybb->user['uid'] && $mybb->user['uid'] != 0) {
     eval("\$delete_link = \"" . $templates->get("reputation_vote_delete") . "\";");
 }
 $report_link = '';
 if ($mybb->user['uid'] != 0) {
     eval("\$report_link = \"" . $templates->get("reputation_vote_report") . "\";");
 }
Exemplo n.º 20
0
 if (is_array($forum)) {
     foreach ($forum as $fid => $forumrow) {
         $forumpermissions[$fid] = forum_permissions($fid);
     }
 }
 $icon_cache = $cache->read("posticons");
 $query = $db->query("\n\t\t\tSELECT t.*, t.username AS threadusername, u.username, u.avatar, u.avatardimensions\n\t\t\tFROM " . TABLE_PREFIX . "threads t\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid = t.uid)\n\t\t\tWHERE t.fid IN (" . $announcementsfids . ") AND t.tid IN (0{$tids}) AND t.visible='1' AND t.closed NOT LIKE 'moved|%'\n\t\t\tORDER BY t.dateline DESC\n\t\t\tLIMIT 0, {$numannouncements}");
 while ($announcement = $db->fetch_array($query)) {
     // Make sure we can view this announcement
     if ($forumpermissions[$announcement['fid']]['canview'] == 0 || $forumpermissions[$announcement['fid']]['canviewthreads'] == 0 || $forumpermissions[$announcement['fid']]['canonlyviewownthreads'] == 1 && $announcement['uid'] != $mybb->user['uid']) {
         continue;
     }
     $announcement['message'] = $posts[$announcement['tid']]['message'];
     $announcement['pid'] = $posts[$announcement['tid']]['pid'];
     $announcement['smilieoff'] = $posts[$announcement['tid']]['smilieoff'];
     $announcement['threadlink'] = get_thread_link($announcement['tid']);
     if ($announcement['uid'] == 0) {
         $profilelink = htmlspecialchars_uni($announcement['threadusername']);
     } else {
         $profilelink = build_profile_link($announcement['username'], $announcement['uid']);
     }
     if (!$announcement['username']) {
         $announcement['username'] = $announcement['threadusername'];
     }
     $announcement['subject'] = htmlspecialchars_uni($parser->parse_badwords($announcement['subject']));
     if ($announcement['icon'] > 0 && $icon_cache[$announcement['icon']]) {
         $icon = $icon_cache[$announcement['icon']];
         $icon = "<img src=\"{$icon['path']}\" alt=\"{$icon['name']}\" />";
     } else {
         $icon = "&nbsp;";
     }
Exemplo n.º 21
0
 if (!$mybb->settings['postsperpage'] || (int) $mybb->settings['postsperpage'] < 1) {
     $mybb->settings['postsperpage'] = 20;
 }
 if (is_moderator($fid, "canviewunapprove")) {
     $visibility = "(visible='1' OR visible='0')";
 } else {
     $visibility = "visible='1'";
 }
 $query = $db->simple_select("posts", "COUNT(pid) AS post_count", "tid='{$tid}' AND {$visibility}");
 $numposts = $db->fetch_field($query, "post_count");
 if (!$mybb->settings['postsperpage'] || (int) $mybb->settings['postsperpage'] < 1) {
     $mybb->settings['postsperpage'] = 20;
 }
 if ($numposts > $mybb->settings['postsperpage']) {
     $numposts = $mybb->settings['postsperpage'];
     $lang->thread_review_more = $lang->sprintf($lang->thread_review_more, $mybb->settings['postsperpage'], get_thread_link($tid));
     eval("\$reviewmore = \"" . $templates->get("newreply_threadreview_more") . "\";");
 }
 $query = $db->simple_select("posts", "pid", "tid='{$tid}' AND {$visibility}", array("order_by" => "dateline", "order_dir" => "desc", "limit" => $mybb->settings['postsperpage']));
 while ($post = $db->fetch_array($query)) {
     $pidin[] = $post['pid'];
 }
 $pidin = implode(",", $pidin);
 // Fetch attachments
 $query = $db->simple_select("attachments", "*", "pid IN ({$pidin})");
 while ($attachment = $db->fetch_array($query)) {
     $attachcache[$attachment['pid']][$attachment['aid']] = $attachment;
 }
 $query = $db->query("\n\t\t\tSELECT p.*, u.username AS userusername\n\t\t\tFROM " . TABLE_PREFIX . "posts p\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (p.uid=u.uid)\n\t\t\tWHERE pid IN ({$pidin})\n\t\t\tORDER BY dateline DESC\n\t\t");
 $postsdone = 0;
 $altbg = "trow1";
Exemplo n.º 22
0
     }
     if (my_strlen($post['subject']) > 50) {
         $post['subject'] = htmlspecialchars_uni(my_substr($post['subject'], 0, 50) . "...");
     } else {
         $post['subject'] = htmlspecialchars_uni($post['subject']);
     }
     // What we do here is parse the post using our post parser, then strip the tags from it
     $parser_options = array('allow_html' => 0, 'allow_mycode' => 1, 'allow_smilies' => 0, 'allow_imgcode' => 0, 'filter_badwords' => 1);
     $post['message'] = strip_tags($parser->parse_message($post['message'], $parser_options));
     if (my_strlen($post['message']) > 200) {
         $prev = my_substr($post['message'], 0, 200) . "...";
     } else {
         $prev = $post['message'];
     }
     $posted = my_date($mybb->settings['dateformat'], $post['dateline']) . ", " . my_date($mybb->settings['timeformat'], $post['dateline']);
     $thread_url = get_thread_link($post['tid']);
     $post_url = get_post_link($post['pid'], $post['tid']);
     // Inline post moderation
     $inline_mod_checkbox = '';
     if ($is_supermod || is_moderator($post['fid'])) {
         eval("\$inline_mod_checkbox = \"" . $templates->get("search_results_posts_inlinecheck") . "\";");
     } elseif ($is_mod) {
         eval("\$inline_mod_checkbox = \"" . $templates->get("search_results_posts_nocheck") . "\";");
     }
     $plugins->run_hooks("search_results_post");
     eval("\$results .= \"" . $templates->get("search_results_posts_post") . "\";");
 }
 if (!$results) {
     error($lang->error_nosearchresults);
 }
 $multipage = multipage($postcount, $perpage, $page, "search.php?action=results&amp;sid={$sid}&amp;sortby={$sortby}&amp;order={$order}&amp;uid=" . $mybb->input['uid']);
Exemplo n.º 23
0
 if ($tflist_modlog) {
     $where = "WHERE (t.fid <> 0 {$tflist_modlog}) OR (!l.fid)";
 }
 $query = $db->query("\n\t\t\tSELECT l.*, u.username, u.usergroup, u.displaygroup, t.subject AS tsubject, f.name AS fname, p.subject AS psubject\n\t\t\tFROM " . TABLE_PREFIX . "moderatorlog l\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=l.uid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=l.tid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "forums f ON (f.fid=l.fid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "posts p ON (p.pid=l.pid)\n\t\t\t{$where}\n\t\t\tORDER BY l.dateline DESC\n\t\t\tLIMIT 5\n\t\t");
 $modlogresults = '';
 while ($logitem = $db->fetch_array($query)) {
     $information = '';
     $logitem['action'] = htmlspecialchars_uni($logitem['action']);
     $log_date = my_date('relative', $logitem['dateline']);
     $trow = alt_trow();
     $username = format_name($logitem['username'], $logitem['usergroup'], $logitem['displaygroup']);
     $logitem['profilelink'] = build_profile_link($username, $logitem['uid']);
     $logitem['ipaddress'] = my_inet_ntop($db->unescape_binary($logitem['ipaddress']));
     if ($logitem['tsubject']) {
         $logitem['tsubject'] = htmlspecialchars_uni($logitem['tsubject']);
         $logitem['thread'] = get_thread_link($logitem['tid']);
         eval("\$information .= \"" . $templates->get("modcp_modlogs_result_thread") . "\";");
     }
     if ($logitem['fname']) {
         $logitem['forum'] = get_forum_link($logitem['fid']);
         eval("\$information .= \"" . $templates->get("modcp_modlogs_result_forum") . "\";");
     }
     if ($logitem['psubject']) {
         $logitem['psubject'] = htmlspecialchars_uni($logitem['psubject']);
         $logitem['post'] = get_post_link($logitem['pid']);
         eval("\$information .= \"" . $templates->get("modcp_modlogs_result_post") . "\";");
     }
     // Edited a user or managed announcement?
     if (!$logitem['tsubject'] || !$logitem['fname'] || !$logitem['psubject']) {
         $data = my_unserialize($logitem['data']);
         if ($data['uid']) {
                $ret = $custommod->execute(intval($mybb->input['action']), $tids, $pids);
                $lang->custom_tool = $lang->sprintf($lang->custom_tool, $tool['name']);
                log_moderator_action($modlogdata, $lang->custom_tool);
                if ($mybb->input['inlinetype'] == 'search') {
                    clearinline($mybb->input['searchid'], 'search');
                    $lang->redirect_customtool_search = $lang->sprintf($lang->redirect_customtool_search, $tool['name']);
                    $return_url = htmlspecialchars_uni($mybb->input['url']);
                    redirect($return_url, $lang->redirect_customtool_search);
                } else {
                    clearinline($tid, 'thread');
                    if ($ret == 'forum') {
                        $lang->redirect_customtool_forum = $lang->sprintf($lang->redirect_customtool_forum, $tool['name']);
                        moderation_redirect(get_forum_link($fid), $lang->redirect_customtool_forum);
                    } else {
                        $lang->redirect_customtool_thread = $lang->sprintf($lang->redirect_customtool_thread, $tool['name']);
                        moderation_redirect(get_thread_link($tid), $lang->redirect_customtool_thread);
                    }
                }
                break;
            }
        }
        error_no_permission();
        break;
}
// Some little handy functions for our inline moderation
function getids($id, $type)
{
    global $mybb;
    $newids = array();
    $cookie = "inlinemod_" . $type . $id;
    $cookie_ids = explode("|", $mybb->cookies[$cookie]);
        if ($mybb->settings['mail_handler'] == 'smtp') {
            $from = $mybb->user['email'];
        } else {
            $from = "{$mybb->user['username']} <{$mybb->user['email']}>";
        }
        $threadlink = get_thread_link($thread['tid']);
        $message = $lang->sprintf($lang->email_sendtofriend, $mybb->user['username'], $mybb->settings['bbname'], $mybb->settings['bburl'] . "/" . $threadlink, $mybb->input['message']);
        // Send the actual message
        my_mail($mybb->input['email'], $mybb->input['subject'], $message, $from, "", "", false, "text", "", $mybb->user['email']);
        if ($mybb->settings['mail_logging'] > 0) {
            // Log the message
            $log_entry = array("subject" => $db->escape_string($mybb->input['subject']), "message" => $db->escape_string($message), "dateline" => TIME_NOW, "fromuid" => $mybb->user['uid'], "fromemail" => $db->escape_string($mybb->user['email']), "touid" => 0, "toemail" => $db->escape_string($mybb->input['email']), "tid" => $thread['tid'], "ipaddress" => $db->escape_string($session->ipaddress));
            $db->insert_query("maillogs", $log_entry);
        }
        $plugins->run_hooks("sendthread_do_sendtofriend_end");
        redirect(get_thread_link($thread['tid']), $lang->redirect_emailsent);
    } else {
        $mybb->input['action'] = '';
    }
}
if (!$mybb->input['action']) {
    $plugins->run_hooks("sendthread_start");
    // Do we have some errors?
    if (count($errors) >= 1) {
        $errors = inline_error($errors);
        $email = htmlspecialchars_uni($mybb->input['email']);
        $subject = htmlspecialchars_uni($mybb->input['subject']);
        $message = htmlspecialchars_uni($mybb->input['message']);
    } else {
        $errors = '';
        $email = '';
Exemplo n.º 26
0
 /**
  * Insert a thread into the database.
  *
  * @return array Array of new thread details, tid and visibility.
  */
 function insert_thread()
 {
     global $db, $mybb, $plugins, $cache, $lang;
     // Yes, validating is required.
     if (!$this->get_validated()) {
         die("The thread needs to be validated before inserting it into the DB.");
     }
     if (count($this->get_errors()) > 0) {
         die("The thread is not valid.");
     }
     $thread =& $this->data;
     // Fetch the forum this thread is being made in
     $forum = get_forum($thread['fid']);
     // This thread is being saved as a draft.
     if ($thread['savedraft']) {
         $visible = -2;
     } else {
         $forumpermissions = forum_permissions($thread['fid'], $thread['uid']);
         // Decide on the visibility of this post.
         if ($forumpermissions['modthreads'] == 1 && !is_moderator($thread['fid'], "", $thread['uid'])) {
             $visible = 0;
         } else {
             $visible = 1;
         }
         // Are posts from this user being moderated? Change visibility
         if ($mybb->user['uid'] == $thread['uid'] && $mybb->user['moderateposts'] == 1) {
             $visible = 0;
         }
     }
     // Have a post ID but not a thread ID - fetch thread ID
     if (!empty($thread['pid']) && !$thread['tid']) {
         $query = $db->simple_select("posts", "tid", "pid='{$thread['pid']}");
         $thread['tid'] = $db->fetch_field($query, "tid");
     }
     if (isset($thread['pid']) && $thread['pid'] > 0) {
         $query = $db->simple_select("posts", "pid", "pid='{$thread['pid']}' AND uid='{$thread['uid']}' AND visible='-2'");
         $draft_check = $db->fetch_field($query, "pid");
     } else {
         $draft_check = false;
     }
     // Are we updating a post which is already a draft? Perhaps changing it into a visible post?
     if ($draft_check) {
         $this->thread_insert_data = array("subject" => $db->escape_string($thread['subject']), "icon" => (int) $thread['icon'], "username" => $db->escape_string($thread['username']), "dateline" => (int) $thread['dateline'], "lastpost" => (int) $thread['dateline'], "lastposter" => $db->escape_string($thread['username']), "visible" => $visible);
         $plugins->run_hooks("datahandler_post_insert_thread", $this);
         $db->update_query("threads", $this->thread_insert_data, "tid='{$thread['tid']}'");
         $this->post_insert_data = array("subject" => $db->escape_string($thread['subject']), "icon" => (int) $thread['icon'], "username" => $db->escape_string($thread['username']), "dateline" => (int) $thread['dateline'], "message" => $db->escape_string($thread['message']), "ipaddress" => $db->escape_binary(my_inet_pton(get_ip())), "includesig" => $thread['options']['signature'], "smilieoff" => $thread['options']['disablesmilies'], "visible" => $visible);
         $plugins->run_hooks("datahandler_post_insert_thread_post", $this);
         $db->update_query("posts", $this->post_insert_data, "pid='{$thread['pid']}'");
         $this->tid = $thread['tid'];
         $this->pid = $thread['pid'];
     } else {
         $this->thread_insert_data = array("fid" => $thread['fid'], "subject" => $db->escape_string($thread['subject']), "prefix" => (int) $thread['prefix'], "icon" => (int) $thread['icon'], "uid" => $thread['uid'], "username" => $db->escape_string($thread['username']), "dateline" => (int) $thread['dateline'], "lastpost" => (int) $thread['dateline'], "lastposter" => $db->escape_string($thread['username']), "views" => 0, "replies" => 0, "visible" => $visible, "notes" => '');
         $plugins->run_hooks("datahandler_post_insert_thread", $this);
         $this->tid = $db->insert_query("threads", $this->thread_insert_data);
         $this->post_insert_data = array("tid" => $this->tid, "fid" => $thread['fid'], "subject" => $db->escape_string($thread['subject']), "icon" => (int) $thread['icon'], "uid" => $thread['uid'], "username" => $db->escape_string($thread['username']), "dateline" => (int) $thread['dateline'], "message" => $db->escape_string($thread['message']), "ipaddress" => $db->escape_binary(my_inet_pton(get_ip())), "includesig" => $thread['options']['signature'], "smilieoff" => $thread['options']['disablesmilies'], "visible" => $visible);
         $plugins->run_hooks("datahandler_post_insert_thread_post", $this);
         $this->pid = $db->insert_query("posts", $this->post_insert_data);
         // Now that we have the post id for this first post, update the threads table.
         $firstpostup = array("firstpost" => $this->pid);
         $db->update_query("threads", $firstpostup, "tid='{$this->tid}'");
     }
     // If we're not saving a draft there are some things we need to check now
     if (!$thread['savedraft']) {
         if ($thread['options']['subscriptionmethod'] != "" && $thread['uid'] > 0) {
             switch ($thread['options']['subscriptionmethod']) {
                 case "pm":
                     $notification = 2;
                     break;
                 case "email":
                     $notification = 1;
                     break;
                 default:
                     $notification = 0;
             }
             require_once MYBB_ROOT . "inc/functions_user.php";
             add_subscribed_thread($this->tid, $notification, $thread['uid']);
         }
         // Perform any selected moderation tools.
         if (is_moderator($thread['fid'], "", $thread['uid']) && is_array($thread['modoptions'])) {
             $lang->load($this->language_file, true);
             $modoptions = $thread['modoptions'];
             $modlogdata['fid'] = $thread['fid'];
             if (isset($thread['tid'])) {
                 $modlogdata['tid'] = $thread['tid'];
             }
             $modoptions_update = array();
             // Close the thread.
             if (!empty($modoptions['closethread'])) {
                 $modoptions_update['closed'] = 1;
                 log_moderator_action($modlogdata, $lang->thread_closed);
             }
             // Stick the thread.
             if (!empty($modoptions['stickthread'])) {
                 $modoptions_update['sticky'] = 1;
                 log_moderator_action($modlogdata, $lang->thread_stuck);
             }
             // Execute moderation options.
             if ($modoptions_update) {
                 $db->update_query('threads', $modoptions_update, "tid='{$this->tid}'");
             }
         }
         if ($visible == 1) {
             // If we have a registered user then update their post count and last post times.
             if ($thread['uid'] > 0) {
                 $user = get_user($thread['uid']);
                 $update_query = array();
                 // Only update the lastpost column of the user if the date of the thread is newer than their last post.
                 if ($thread['dateline'] > $user['lastpost']) {
                     // Yes this has a single quote within a double quote. It's not a bug.
                     $update_query['lastpost'] = "'{$thread['dateline']}'";
                 }
                 // Update the post count if this forum allows post counts to be tracked
                 if ($forum['usepostcounts'] != 0) {
                     $update_query['postnum'] = "postnum+1";
                 }
                 if ($forum['usethreadcounts'] != 0) {
                     $update_query['threadnum'] = 'threadnum+1';
                 }
                 // Only update the table if we need to.
                 if (!empty($update_query)) {
                     $db->update_query("users", $update_query, "uid='{$thread['uid']}'", 1, true);
                 }
             }
             if (!isset($forum['lastpost'])) {
                 $forum['lastpost'] = 0;
             }
             $done_users = array();
             // Queue up any forum subscription notices to users who are subscribed to this forum.
             $excerpt = my_substr($thread['message'], 0, $mybb->settings['subscribeexcerpt']) . $lang->emailbit_viewthread;
             // Parse badwords
             require_once MYBB_ROOT . "inc/class_parser.php";
             $parser = new postParser();
             $excerpt = $parser->parse_badwords($excerpt);
             $query = $db->query("\n\t\t\t\t\tSELECT u.username, u.email, u.uid, u.language, u.loginkey, u.salt, u.regdate\n\t\t\t\t\tFROM " . TABLE_PREFIX . "forumsubscriptions fs\n\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=fs.uid)\n\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "usergroups g ON (g.gid=u.usergroup)\n\t\t\t\t\tWHERE fs.fid='" . (int) $thread['fid'] . "'\n\t\t\t\t\tAND fs.uid != '" . (int) $thread['uid'] . "'\n\t\t\t\t\tAND u.lastactive > '{$forum['lastpost']}'\n\t\t\t\t\tAND g.isbannedgroup != 1\n\t\t\t\t");
             while ($subscribedmember = $db->fetch_array($query)) {
                 if ($done_users[$subscribedmember['uid']]) {
                     continue;
                 }
                 $done_users[$subscribedmember['uid']] = 1;
                 $forumpermissions = forum_permissions($thread['fid'], $subscribedmember['uid']);
                 if ($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0) {
                     continue;
                 }
                 if (!is_moderator($thread['fid'], "", $subscribedmember['uid']) && $forumpermissions['canonlyviewownthreads'] == 1) {
                     // In a 'view own only' forum and not a moderator
                     continue;
                 }
                 // Determine the language pack we'll be using to send this email in and load it if it isn't already.
                 if ($subscribedmember['language'] != '' && $lang->language_exists($subscribedmember['language'])) {
                     $uselang = $subscribedmember['language'];
                 } else {
                     if ($mybb->settings['bblanguage']) {
                         $uselang = $mybb->settings['bblanguage'];
                     } else {
                         $uselang = "english";
                     }
                 }
                 if ($uselang == $mybb->settings['bblanguage']) {
                     $emailsubject = $lang->emailsubject_forumsubscription;
                     $emailmessage = $lang->email_forumsubscription;
                 } else {
                     if (!isset($langcache[$uselang]['emailsubject_forumsubscription'])) {
                         $userlang = new MyLanguage();
                         $userlang->set_path(MYBB_ROOT . "inc/languages");
                         $userlang->set_language($uselang);
                         $userlang->load("messages");
                         $langcache[$uselang]['emailsubject_forumsubscription'] = $userlang->emailsubject_forumsubscription;
                         $langcache[$uselang]['email_forumsubscription'] = $userlang->email_forumsubscription;
                         unset($userlang);
                     }
                     $emailsubject = $langcache[$uselang]['emailsubject_forumsubscription'];
                     $emailmessage = $langcache[$uselang]['email_forumsubscription'];
                 }
                 $emailsubject = $lang->sprintf($emailsubject, $forum['name']);
                 $post_code = md5($subscribedmember['loginkey'] . $subscribedmember['salt'] . $subscribedmember['regdate']);
                 $emailmessage = $lang->sprintf($emailmessage, $subscribedmember['username'], $thread['username'], $forum['name'], $mybb->settings['bbname'], $thread['subject'], $excerpt, $mybb->settings['bburl'], get_thread_link($this->tid), $thread['fid'], $post_code);
                 $new_email = array("mailto" => $db->escape_string($subscribedmember['email']), "mailfrom" => '', "subject" => $db->escape_string($emailsubject), "message" => $db->escape_string($emailmessage), "headers" => '');
                 $db->insert_query("mailqueue", $new_email);
                 unset($userlang);
                 $queued_email = 1;
             }
             // Have one or more emails been queued? Update the queue count
             if (isset($queued_email) && $queued_email == 1) {
                 $cache->update_mailqueue();
             }
         }
     }
     // Assign any uploaded attachments with the specific posthash to the newly created post.
     if ($thread['posthash']) {
         $thread['posthash'] = $db->escape_string($thread['posthash']);
         $attachmentassign = array("pid" => $this->pid, "posthash" => '');
         $db->update_query("attachments", $attachmentassign, "posthash='{$thread['posthash']}' AND pid='0'");
     }
     if ($visible == 1) {
         update_last_post($this->tid);
         update_forum_counters($thread['fid'], array("threads" => "+1", "posts" => "+1"));
         update_forum_lastpost($thread['fid']);
     } else {
         if ($visible == 0) {
             update_forum_counters($thread['fid'], array("unapprovedthreads" => "+1", "unapprovedposts" => "+1"));
         }
     }
     $query = $db->simple_select("attachments", "COUNT(aid) AS attachmentcount", "pid='{$this->pid}' AND visible='1'");
     $attachmentcount = $db->fetch_field($query, "attachmentcount");
     if ($attachmentcount > 0) {
         update_thread_counters($this->tid, array("attachmentcount" => "+{$attachmentcount}"));
     }
     // Return the post's pid and whether or not it is visible.
     $this->return_values = array("pid" => $this->pid, "tid" => $this->tid, "visible" => $visible);
     $plugins->run_hooks("datahandler_post_insert_thread_end", $this);
     return $this->return_values;
 }
Exemplo n.º 27
0
 /**
  * Build a link to an alert's content so that the system can redirect to
  * it.
  *
  * @param MybbStuff_MyAlerts_Entity_Alert $alert The alert to build the
  *                                               link for.
  *
  * @return string The built alert, preferably an absolute link.
  */
 public function buildShowLink(MybbStuff_MyAlerts_Entity_Alert $alert)
 {
     $alertContent = $alert->getExtraDetails();
     $threadLink = $this->mybb->settings['bburl'] . '/' . get_thread_link((int) $alertContent['tid'], 0, 'newpost');
     return $threadLink;
 }
Exemplo n.º 28
0
 $table->construct_header($lang->uploadedby, array("class" => "align_center", "width" => "20%"));
 $table->construct_header($lang->posted, array("class" => "align_center", "width" => "20%"));
 $table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 3));
 $query = $db->query("\n\t\t\tSELECT a.*, p.subject AS postsubject, p.dateline, p.uid, u.username, t.tid, t.subject AS threadsubject\n\t\t\tFROM  " . TABLE_PREFIX . "attachments a\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "posts p ON (p.pid=a.pid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=p.tid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=p.uid)\n\t\t\tWHERE a.visible='0'\n\t\t\tORDER BY a.dateuploaded DESC\n\t\t\tLIMIT {$start}, {$per_page}\n\t\t");
 while ($attachment = $db->fetch_array($query)) {
     if (!$attachment['dateuploaded']) {
         $attachment['dateuploaded'] = $attachment['dateline'];
     }
     $attachdate = my_date($mybb->settings['dateformat'], $attachment['dateuploaded']);
     $attachtime = my_date($mybb->settings['timeformat'], $attachment['dateuploaded']);
     $attachment['postsubject'] = htmlspecialchars_uni($attachment['postsubject']);
     $attachment['filename'] = htmlspecialchars_uni($attachment['filename']);
     $attachment['threadsubject'] = htmlspecialchars_uni($attachment['threadsubject']);
     $attachment['filesize'] = get_friendly_size($attachment['filesize']);
     $link = get_post_link($attachment['pid'], $attachment['tid']) . "#pid{$attachment['pid']}";
     $thread_link = get_thread_link($attachment['tid']);
     $profile_link = build_profile_link($attachment['username'], $attachment['uid']);
     $table->construct_cell("<a href=\"../attachment.php?aid={$attachment['aid']}\" target=\"_blank\">{$attachment['filename']}</a> ({$attachment['filesize']})<br /><small class=\"modqueue_meta\">{$lang->post} <a href=\"{$link}\">{$attachment['postsubject']}</a></small>");
     $table->construct_cell($profile_link, array("class" => "align_center"));
     $table->construct_cell("{$attachdate}, {$attachtime}", array("class" => "align_center"));
     $table->construct_cell($form->generate_radio_button("attachments[{$attachment['aid']}]", "ignore", $lang->ignore, array('class' => 'radio_ignore', 'checked' => true)), array("class" => "align_center"));
     $table->construct_cell($form->generate_radio_button("attachments[{$attachment['aid']}]", "delete", $lang->delete, array('class' => 'radio_delete', 'checked' => false)), array("class" => "align_center"));
     $table->construct_cell($form->generate_radio_button("attachments[{$attachment['aid']}]", "approve", $lang->approve, array('class' => 'radio_approve', 'checked' => false)), array("class" => "align_center"));
     $table->construct_row();
 }
 $table->output($lang->attachments_awaiting_moderation);
 echo $all_options;
 echo $pagination;
 $buttons[] = $form->generate_submit_button($lang->perform_action);
 $form->output_submit_wrapper($buttons);
 $form->end();
Exemplo n.º 29
0
 $updatepost = array("pid" => $post['pid'], "message" => $message, "editreason" => $editreason, "edit_uid" => $mybb->user['uid']);
 $posthandler->set_data($updatepost);
 // Now let the post handler do all the hard work.
 if (!$posthandler->validate_post()) {
     $post_errors = $posthandler->get_friendly_errors();
     xmlhttp_error($post_errors);
 } else {
     $postinfo = $posthandler->update_post();
     $visible = $postinfo['visible'];
     if ($visible == 0 && !is_moderator($post['fid'], "canviewunapprove")) {
         // Is it the first post?
         if ($thread['firstpost'] == $post['pid']) {
             echo json_encode(array("moderation_thread" => $lang->thread_moderation, 'url' => $mybb->settings['bburl'] . '/' . get_forum_link($thread['fid']), "message" => $post['message']));
             exit;
         } else {
             echo json_encode(array("moderation_post" => $lang->post_moderation, 'url' => $mybb->settings['bburl'] . '/' . get_thread_link($thread['tid']), "message" => $post['message']));
             exit;
         }
     }
 }
 require_once MYBB_ROOT . "inc/class_parser.php";
 $parser = new postParser();
 $parser_options = array("allow_html" => $forum['allowhtml'], "allow_mycode" => $forum['allowmycode'], "allow_smilies" => $forum['allowsmilies'], "allow_imgcode" => $forum['allowimgcode'], "allow_videocode" => $forum['allowvideocode'], "me_username" => $post['username'], "filter_badwords" => 1);
 if ($post['smilieoff'] == 1) {
     $parser_options['allow_smilies'] = 0;
 }
 if ($mybb->user['showimages'] != 1 && $mybb->user['uid'] != 0 || $mybb->settings['guestimages'] != 1 && $mybb->user['uid'] == 0) {
     $parser_options['allow_imgcode'] = 0;
 }
 if ($mybb->user['showvideos'] != 1 && $mybb->user['uid'] != 0 || $mybb->settings['guestvideos'] != 1 && $mybb->user['uid'] == 0) {
     $parser_options['allow_videocode'] = 0;
/**
* Build a list of forum bits.
*
* @param int The parent forum to fetch the child forums for (0 assumes all)
* @param int The depth to return forums with.
* @return array Array of information regarding the child forums of this parent forum
*/
function build_forumbits($pid = 0, $depth = 1)
{
    global $fcache, $moderatorcache, $forumpermissions, $theme, $mybb, $templates, $bgcolor, $collapsed, $lang, $showdepth, $plugins, $parser, $forum_viewers;
    $forum_listing = '';
    // If no forums exist with this parent, do nothing
    if (!is_array($fcache[$pid])) {
        return;
    }
    // Foreach of the forums in this parent
    foreach ($fcache[$pid] as $parent) {
        foreach ($parent as $forum) {
            $forums = $subforums = $sub_forums = '';
            $lastpost_data = '';
            $counters = '';
            $forum_viewers_text = '';
            $forum_viewers_text_plain = '';
            // Get the permissions for this forum
            $permissions = $forumpermissions[$forum['fid']];
            // If this user doesnt have permission to view this forum and we're hiding private forums, skip this forum
            if ($permissions['canview'] != 1 && $mybb->settings['hideprivateforums'] == 1) {
                continue;
            }
            $plugins->run_hooks_by_ref("build_forumbits_forum", $forum);
            // Build the link to this forum
            $forum_url = get_forum_link($forum['fid']);
            // This forum has a password, and the user isn't authenticated with it - hide post information
            $hideinfo = false;
            $showlockicon = 0;
            if ($permissions['canviewthreads'] != 1) {
                $hideinfo = true;
            }
            if ($forum['password'] != '' && $mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'] . $forum['password'])) {
                $hideinfo = true;
                $showlockicon = 1;
            }
            $lastpost_data = array("lastpost" => $forum['lastpost'], "lastpostsubject" => $forum['lastpostsubject'], "lastposter" => $forum['lastposter'], "lastposttid" => $forum['lastposttid'], "lastposteruid" => $forum['lastposteruid']);
            // Fetch subforums of this forum
            if (isset($fcache[$forum['fid']])) {
                $forum_info = build_forumbits($forum['fid'], $depth + 1);
                // Increment forum counters with counters from child forums
                $forum['threads'] += $forum_info['counters']['threads'];
                $forum['posts'] += $forum_info['counters']['posts'];
                $forum['unapprovedthreads'] += $forum_info['counters']['unapprovedthreads'];
                $forum['unapprovedposts'] += $forum_info['counters']['unapprovedposts'];
                $forum['viewers'] += $forum_info['counters']['viewing'];
                // If the child forums' lastpost is greater than the one for this forum, set it as the child forums greatest.
                if ($forum_info['lastpost']['lastpost'] > $lastpost_data['lastpost']) {
                    $lastpost_data = $forum_info['lastpost'];
                }
                $sub_forums = $forum_info['forum_list'];
            }
            // If we are hiding information (lastpost) because we aren't authenticated against the password for this forum, remove them
            if ($hideinfo == true) {
                unset($lastpost_data);
            }
            // If the current forums lastpost is greater than other child forums of the current parent, overwrite it
            if ($lastpost_data['lastpost'] > $parent_lastpost['lastpost']) {
                $parent_lastpost = $lastpost_data;
            }
            if (is_array($forum_viewers) && $forum_viewers[$forum['fid']] > 0) {
                $forum['viewers'] = $forum_viewers[$forum['fid']];
            }
            // Increment the counters for the parent forum (returned later)
            if ($hideinfo != true) {
                $parent_counters['threads'] += $forum['threads'];
                $parent_counters['posts'] += $forum['posts'];
                $parent_counters['unapprovedposts'] += $forum['unapprovedposts'];
                $parent_counters['unapprovedthreads'] += $forum['unapprovedthreads'];
                $parent_counters['viewers'] += $forum['viewers'];
            }
            // Done with our math, lets talk about displaying - only display forums which are under a certain depth
            if ($depth > $showdepth) {
                continue;
            }
            // Get the lightbulb status indicator for this forum based on the lastpost
            $lightbulb = get_forum_lightbulb($forum, $lastpost_data, $showlockicon);
            // Fetch the number of unapproved threads and posts for this forum
            $unapproved = get_forum_unapproved($forum);
            if ($hideinfo == true) {
                unset($unapproved);
            }
            // Sanitize name and description of forum.
            $forum['name'] = preg_replace("#&(?!\\#[0-9]+;)#si", "&amp;", $forum['name']);
            // Fix & but allow unicode
            $forum['description'] = preg_replace("#&(?!\\#[0-9]+;)#si", "&amp;", $forum['description']);
            // Fix & but allow unicode
            $forum['name'] = preg_replace("#&([^\\#])(?![a-z1-4]{1,10};)#i", "&#038;\$1", $forum['name']);
            $forum['description'] = preg_replace("#&([^\\#])(?![a-z1-4]{1,10};)#i", "&#038;\$1", $forum['description']);
            // If this is a forum and we've got subforums of it, load the subforums list template
            if ($depth == 2 && $sub_forums) {
                eval("\$subforums = \"" . $templates->get("forumbit_subforums") . "\";");
            } else {
                if ($depth == 3) {
                    if ($donecount < $mybb->settings['subforumsindex']) {
                        $statusicon = '';
                        // Showing mini status icons for this forum
                        if ($mybb->settings['subforumsstatusicons'] == 1) {
                            $lightbulb['folder'] = "mini" . $lightbulb['folder'];
                            eval("\$statusicon = \"" . $templates->get("forumbit_depth3_statusicon", 1, 0) . "\";");
                        }
                        // Fetch the template and append it to the list
                        eval("\$forum_list .= \"" . $templates->get("forumbit_depth3", 1, 0) . "\";");
                        $comma = ', ';
                    }
                    // Have we reached our max visible subforums? put a nice message and break out of the loop
                    ++$donecount;
                    if ($donecount == $mybb->settings['subforumsindex']) {
                        if (subforums_count($fcache[$pid]) > $donecount) {
                            $forum_list .= $comma . $lang->sprintf($lang->more_subforums, subforums_count($fcache[$pid]) - $donecount);
                        }
                    }
                    continue;
                }
            }
            // Forum is a category, set template type
            if ($forum['type'] == 'c') {
                $forumcat = '_cat';
            } else {
                $forumcat = '_forum';
            }
            if ($forum['linkto'] == '') {
                // No posts have been made in this forum - show never text
                if (($lastpost_data['lastpost'] == 0 || $lastpost_data['lastposter'] == '') && $hideinfo != true) {
                    $lastpost = "<div style=\"text-align: center;\">{$lang->lastpost_never}</div>";
                } elseif ($hideinfo != true) {
                    // Format lastpost date and time
                    $lastpost_date = my_date($mybb->settings['dateformat'], $lastpost_data['lastpost']);
                    $lastpost_time = my_date($mybb->settings['timeformat'], $lastpost_data['lastpost']);
                    // Set up the last poster, last post thread id, last post subject and format appropriately
                    $lastpost_profilelink = build_profile_link($lastpost_data['lastposter'], $lastpost_data['lastposteruid']);
                    $lastpost_link = get_thread_link($lastpost_data['lastposttid'], 0, "lastpost");
                    $lastpost_subject = $full_lastpost_subject = $parser->parse_badwords($lastpost_data['lastpostsubject']);
                    if (my_strlen($lastpost_subject) > 25) {
                        $lastpost_subject = my_substr($lastpost_subject, 0, 25) . "...";
                    }
                    $lastpost_subject = htmlspecialchars_uni($lastpost_subject);
                    $full_lastpost_subject = htmlspecialchars_uni($full_lastpost_subject);
                    // Call lastpost template
                    if ($depth != 1) {
                        eval("\$lastpost = \"" . $templates->get("forumbit_depth{$depth}_forum_lastpost") . "\";");
                    }
                }
                if ($mybb->settings['showforumviewing'] != 0 && $forum['viewers'] > 0) {
                    if ($forum['viewers'] == 1) {
                        $forum_viewers_text = $lang->viewing_one;
                    } else {
                        $forum_viewers_text = $lang->sprintf($lang->viewing_multiple, $forum['viewers']);
                    }
                    $forum_viewers_text_plain = $forum_viewers_text;
                    $forum_viewers_text = "<span class=\"smalltext\">{$forum_viewers_text}</span>";
                }
            }
            // If this forum is a link or is password protected and the user isn't authenticated, set lastpost and counters to "-"
            if ($forum['linkto'] != '' || $hideinfo == true) {
                $lastpost = "<div style=\"text-align: center;\">-</div>";
                $posts = "-";
                $threads = "-";
            } else {
                $posts = my_number_format($forum['posts']);
                $threads = my_number_format($forum['threads']);
            }
            // Moderator column is not off
            if ($mybb->settings['modlist'] != 0) {
                $done_moderators = array();
                $moderators = '';
                // Fetch list of moderators from this forum and its parents
                $parentlistexploded = explode(',', $forum['parentlist']);
                foreach ($parentlistexploded as $mfid) {
                    // This forum has moderators
                    if (is_array($moderatorcache[$mfid])) {
                        // Fetch each moderator from the cache and format it, appending it to the list
                        foreach ($moderatorcache[$mfid] as $moderator) {
                            if (in_array($moderator['uid'], $done_moderators)) {
                                continue;
                            }
                            $moderators .= "{$comma}<a href=\"" . get_profile_link($moderator['uid']) . "\">" . htmlspecialchars_uni($moderator['username']) . "</a>";
                            $comma = ', ';
                            $done_moderators[] = $moderator['uid'];
                        }
                    }
                }
                $comma = '';
                // If we have a moderators list, load the template
                if ($moderators) {
                    eval("\$modlist = \"" . $templates->get("forumbit_moderators") . "\";");
                } else {
                    $modlist = '';
                }
            }
            // Descriptions aren't being shown - blank them
            if ($mybb->settings['showdescriptions'] == 0) {
                $forum['description'] = '';
            }
            // Check if this category is either expanded or collapsed and hide it as necessary.
            $expdisplay = '';
            $collapsed_name = "cat_{$forum['fid']}_c";
            if (isset($collapsed[$collapsed_name]) && $collapsed[$collapsed_name] == "display: show;") {
                $expcolimage = "collapse_collapsed.gif";
                $expdisplay = "display: none;";
                $expaltext = "[+]";
            } else {
                $expcolimage = "collapse.gif";
                $expaltext = "[-]";
            }
            // Swap over the alternate backgrounds
            $bgcolor = alt_trow();
            // Add the forum to the list
            eval("\$forum_list .= \"" . $templates->get("forumbit_depth{$depth}{$forumcat}") . "\";");
        }
    }
    // Return an array of information to the parent forum including child forums list, counters and lastpost information
    return array("forum_list" => $forum_list, "counters" => $parent_counters, "lastpost" => $parent_lastpost);
}