Ejemplo n.º 1
0
function asb_statistics_build_template($args)
{
    extract($args);
    global ${$template_var}, $mybb, $cache, $templates, $lang;
    // Load global and custom language phrases
    if (!$lang->asb_addon) {
        $lang->load('asb_addon');
    }
    // get forum statistics
    $statistics = $cache->read("stats");
    $statistics['numthreads'] = my_number_format($statistics['numthreads']);
    $statistics['numposts'] = my_number_format($statistics['numposts']);
    $statistics['numusers'] = my_number_format($statistics['numusers']);
    $newestmember = "<strong>{$lang->asb_stats_no_one}</strong>";
    if ($statistics['lastusername']) {
        if ($settings['format_username']) {
            $last_user = get_user($statistics['lastuid']);
            $last_username = format_name($last_user['username'], $last_user['usergroup'], $last_user['displaygroup']);
        } else {
            $last_username = $statistics['lastusername'];
        }
        $newestmember = build_profile_link($last_username, $statistics['lastuid']);
    }
    eval("\$" . $template_var . " = \"" . $templates->get('asb_statistics') . "\";");
    return true;
}
Ejemplo n.º 2
0
function build_attachment_row($attachment, &$table, $use_form = false)
{
    global $mybb, $form;
    $attachment['filename'] = htmlspecialchars_uni($attachment['filename']);
    // Here we do a bit of detection, we want to automatically check for removal any missing attachments and any not assigned to a post uploaded > 24hours ago
    // Check if the attachment exists in the file system
    $checked = false;
    $title = $cell_class = '';
    if (!file_exists(MYBB_ROOT . $mybb->settings['uploadspath'] . "/{$attachment['attachname']}")) {
        $cell_class = "bad_attachment";
        $title = $lang->error_not_found;
        $checked = true;
    } elseif (!$attachment['pid'] && $attachment['dateuploaded'] < TIME_NOW - 60 * 60 * 24 && $attachment['dateuploaded'] != 0) {
        $cell_class = "bad_attachment";
        $title = $lang->error_not_attached;
        $checked = true;
    } else {
        if (!$attachment['tid'] && $attachment['pid']) {
            $cell_class = "bad_attachment";
            $title = $lang->error_does_not_exist;
            $checked = true;
        } else {
            if ($attachment['visible'] == 0) {
                $cell_class = "invisible_attachment";
            }
        }
    }
    if ($cell_class) {
        $cell_class .= " align_center";
    } else {
        $cell_class = "align_center";
    }
    if ($use_form == true && is_object($form)) {
        $table->construct_cell($form->generate_check_box('aids[]', $attachment['aid'], '', array('checked' => $checked)));
    }
    $table->construct_cell(get_attachment_icon(get_extension($attachment['filename'])), array('width' => 1));
    $table->construct_cell("<a href=\"../attachment.php?aid={$attachment['aid']}\" target=\"_blank\">{$attachment['filename']}</a>");
    $table->construct_cell(get_friendly_size($attachment['filesize']), array('class' => $cell_class));
    if ($attachment['user_username']) {
        $attachment['username'] = $attachment['username'];
    }
    $table->construct_cell(build_profile_link($attachment['username'], $attachment['uid'], "_blank"), array("class" => "align_center"));
    $table->construct_cell("<a href=\"../" . get_post_link($attachment['pid']) . "\" target=\"_blank\">" . htmlspecialchars_uni($attachment['subject']) . "</a>", array("class" => "align_center"));
    $table->construct_cell(my_number_format($attachment['downloads']), array("class" => "align_center"));
    if ($attachment['dateuploaded'] > 0) {
        $date = my_date($mybb->settings['dateformat'], $attachment['dateuploaded']) . ", " . my_date($mybb->settings['timeformat'], $attachment['dateuploaded']);
    } else {
        $date = $lang->unknown;
    }
    $table->construct_cell($date, array("class" => "align_center"));
    $table->construct_row();
}
Ejemplo n.º 3
0
/**
 * Build a post bit
 *
 * @param array The post data
 * @param int The type of post bit we're building (1 = preview, 2 = pm, 3 = announcement, else = post)
 * @return string The built post bit
 */
function build_postbit($post, $post_type = 0)
{
    global $db, $altbg, $theme, $mybb, $postcounter;
    global $titlescache, $page, $templates, $forumpermissions, $attachcache;
    global $lang, $ismod, $inlinecookie, $inlinecount, $groupscache, $fid;
    global $plugins, $parser, $cache, $ignored_users, $hascustomtitle;
    $hascustomtitle = 0;
    // Set default values for any fields not provided here
    foreach (array('subject_extra', 'attachments', 'button_rep', 'button_warn', 'button_reply_pm', 'button_replyall_pm', 'button_forward_pm', 'button_delete_pm') as $post_field) {
        if (empty($post[$post_field])) {
            $post[$post_field] = '';
        }
    }
    // Set up the message parser if it doesn't already exist.
    if (!$parser) {
        require_once MYBB_ROOT . "inc/class_parser.php";
        $parser = new postParser();
    }
    $unapproved_shade = '';
    if ($post['visible'] == 0 && $post_type == 0) {
        $altbg = $unapproved_shade = 'trow_shaded';
    } elseif ($altbg == 'trow1') {
        $altbg = 'trow2';
    } else {
        $altbg = 'trow1';
    }
    $post['fid'] = $fid;
    switch ($post_type) {
        case 1:
            // Message preview
            global $forum;
            $parser_options['allow_html'] = $forum['allowhtml'];
            $parser_options['allow_mycode'] = $forum['allowmycode'];
            $parser_options['allow_smilies'] = $forum['allowsmilies'];
            $parser_options['allow_imgcode'] = $forum['allowimgcode'];
            $parser_options['allow_videocode'] = $forum['allowvideocode'];
            $parser_options['me_username'] = $post['username'];
            $parser_options['filter_badwords'] = 1;
            $id = 0;
            break;
        case 2:
            // Private message
            global $message, $pmid;
            $parser_options['allow_html'] = $mybb->settings['pmsallowhtml'];
            $parser_options['allow_mycode'] = $mybb->settings['pmsallowmycode'];
            $parser_options['allow_smilies'] = $mybb->settings['pmsallowsmilies'];
            $parser_options['allow_imgcode'] = $mybb->settings['pmsallowimgcode'];
            $parser_options['allow_videocode'] = $mybb->settings['pmsallowvideocode'];
            $parser_options['me_username'] = $post['username'];
            $parser_options['filter_badwords'] = 1;
            $id = $pmid;
            break;
        case 3:
            // Announcement
            global $announcementarray, $message;
            $parser_options['allow_html'] = $announcementarray['allowhtml'];
            $parser_options['allow_mycode'] = $announcementarray['allowmycode'];
            $parser_options['allow_smilies'] = $announcementarray['allowsmilies'];
            $parser_options['allow_imgcode'] = 1;
            $parser_options['allow_videocode'] = 1;
            $parser_options['me_username'] = $post['username'];
            $parser_options['filter_badwords'] = 1;
            break;
        default:
            // Regular post
            global $forum, $thread, $tid;
            $oldforum = $forum;
            $id = intval($post['pid']);
            $parser_options['allow_html'] = $forum['allowhtml'];
            $parser_options['allow_mycode'] = $forum['allowmycode'];
            $parser_options['allow_smilies'] = $forum['allowsmilies'];
            $parser_options['allow_imgcode'] = $forum['allowimgcode'];
            $parser_options['allow_videocode'] = $forum['allowvideocode'];
            $parser_options['filter_badwords'] = 1;
            if (!$post['username']) {
                $post['username'] = $lang->guest;
            }
            if ($post['userusername']) {
                $parser_options['me_username'] = $post['userusername'];
            } else {
                $parser_options['me_username'] = $post['username'];
            }
            break;
    }
    // Sanatize our custom profile fields for use in templates, if people choose to use them
    foreach ($post as $post_field => $field_value) {
        if (substr($post_field, 0, 3) != 'fid') {
            continue;
        }
        $post[$post_field] = htmlspecialchars_uni($field_value);
    }
    if (!$postcounter) {
        // Used to show the # of the post
        if ($page > 1) {
            if (!$mybb->settings['postsperpage'] || (int) $mybb->settings['postsperpage'] < 1) {
                $mybb->settings['postsperpage'] = 20;
            }
            $postcounter = $mybb->settings['postsperpage'] * ($page - 1);
        } else {
            $postcounter = 0;
        }
        $post_extra_style = "border-top-width: 0;";
    } elseif ($mybb->input['mode'] == "threaded") {
        $post_extra_style = "border-top-width: 0;";
    } else {
        $post_extra_style = "margin-top: 5px;";
    }
    if (!$altbg) {
        // Define the alternate background colour if this is the first post
        $altbg = "trow1";
    }
    $postcounter++;
    // Format the post date and time using my_date
    $post['postdate'] = my_date($mybb->settings['dateformat'], $post['dateline']);
    $post['posttime'] = my_date($mybb->settings['timeformat'], $post['dateline']);
    // Dont want any little 'nasties' in the subject
    $post['subject'] = $parser->parse_badwords($post['subject']);
    // Pm's have been htmlspecialchars_uni()'ed already.
    if ($post_type != 2) {
        $post['subject'] = htmlspecialchars_uni($post['subject']);
    }
    if (empty($post['subject'])) {
        $post['subject'] = '&nbsp;';
    }
    $post['author'] = $post['uid'];
    // Get the usergroup
    if ($post['userusername']) {
        if (!$post['displaygroup']) {
            $post['displaygroup'] = $post['usergroup'];
        }
        $usergroup = $groupscache[$post['displaygroup']];
    } else {
        $usergroup = $groupscache[1];
    }
    if (!is_array($titlescache)) {
        $cached_titles = $cache->read("usertitles");
        if (!empty($cached_titles)) {
            foreach ($cached_titles as $usertitle) {
                $titlescache[$usertitle['posts']] = $usertitle;
            }
        }
        if (is_array($titlescache)) {
            krsort($titlescache);
        }
        unset($usertitle, $cached_titles);
    }
    // Work out the usergroup/title stuff
    $post['groupimage'] = '';
    if (!empty($usergroup['image'])) {
        $language = $mybb->settings['bblanguage'];
        if (!empty($mybb->user['language'])) {
            $language = $mybb->user['language'];
        }
        $usergroup['image'] = str_replace("{lang}", $language, $usergroup['image']);
        $usergroup['image'] = str_replace("{theme}", $theme['imgdir'], $usergroup['image']);
        eval("\$post['groupimage'] = \"" . $templates->get("postbit_groupimage") . "\";");
        if ($mybb->settings['postlayout'] == "classic") {
            $post['groupimage'] .= "<br />";
        }
    }
    if ($post['userusername']) {
        // This post was made by a registered user
        $post['username'] = $post['userusername'];
        $post['profilelink_plain'] = get_profile_link($post['uid']);
        $post['username_formatted'] = format_name($post['username'], $post['usergroup'], $post['displaygroup']);
        $post['profilelink'] = build_profile_link($post['username_formatted'], $post['uid']);
        if (trim($post['usertitle']) != "") {
            $hascustomtitle = 1;
        }
        if ($usergroup['usertitle'] != "" && !$hascustomtitle) {
            $post['usertitle'] = $usergroup['usertitle'];
        } elseif (is_array($titlescache) && !$usergroup['usertitle']) {
            reset($titlescache);
            foreach ($titlescache as $key => $titleinfo) {
                if ($post['postnum'] >= $key) {
                    if (!$hascustomtitle) {
                        $post['usertitle'] = $titleinfo['title'];
                    }
                    $post['stars'] = $titleinfo['stars'];
                    $post['starimage'] = $titleinfo['starimage'];
                    break;
                }
            }
        }
        if ($usergroup['stars']) {
            $post['stars'] = $usergroup['stars'];
        }
        if (empty($post['starimage'])) {
            $post['starimage'] = $usergroup['starimage'];
        }
        if ($post['starimage'] && $post['stars']) {
            // Only display stars if we have an image to use...
            $post['starimage'] = str_replace("{theme}", $theme['imgdir'], $post['starimage']);
            $post['userstars'] = '';
            for ($i = 0; $i < $post['stars']; ++$i) {
                $post['userstars'] .= "<img src=\"" . $post['starimage'] . "\" border=\"0\" alt=\"*\" />";
            }
            $post['userstars'] .= "<br />";
        }
        $postnum = $post['postnum'];
        $post['postnum'] = my_number_format($post['postnum']);
        // Determine the status to show for the user (Online/Offline/Away)
        $timecut = TIME_NOW - $mybb->settings['wolcutoff'];
        if ($post['lastactive'] > $timecut && ($post['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1) && $post['lastvisit'] != $post['lastactive']) {
            eval("\$post['onlinestatus'] = \"" . $templates->get("postbit_online") . "\";");
        } else {
            if ($post['away'] == 1 && $mybb->settings['allowaway'] != 0) {
                eval("\$post['onlinestatus'] = \"" . $templates->get("postbit_away") . "\";");
            } else {
                eval("\$post['onlinestatus'] = \"" . $templates->get("postbit_offline") . "\";");
            }
        }
        if ($post['avatar'] != "" && ($mybb->user['showavatars'] != 0 || !$mybb->user['uid'])) {
            $post['avatar'] = htmlspecialchars_uni($post['avatar']);
            $avatar_dimensions = explode("|", $post['avatardimensions']);
            if ($avatar_dimensions[0] && $avatar_dimensions[1]) {
                list($max_width, $max_height) = explode("x", my_strtolower($mybb->settings['postmaxavatarsize']));
                if ($avatar_dimensions[0] > $max_width || $avatar_dimensions[1] > $max_height) {
                    require_once MYBB_ROOT . "inc/functions_image.php";
                    $scaled_dimensions = scale_image($avatar_dimensions[0], $avatar_dimensions[1], $max_width, $max_height);
                    $avatar_width_height = "width=\"{$scaled_dimensions['width']}\" height=\"{$scaled_dimensions['height']}\"";
                } else {
                    $avatar_width_height = "width=\"{$avatar_dimensions[0]}\" height=\"{$avatar_dimensions[1]}\"";
                }
            }
            eval("\$post['useravatar'] = \"" . $templates->get("postbit_avatar") . "\";");
            $post['avatar_padding'] = "padding-right: 10px;";
        } else {
            $post['useravatar'] = '';
            $post['avatar_padding'] = '';
        }
        eval("\$post['button_find'] = \"" . $templates->get("postbit_find") . "\";");
        if ($mybb->settings['enablepms'] == 1 && $post['receivepms'] != 0 && $mybb->usergroup['cansendpms'] == 1 && my_strpos("," . $post['ignorelist'] . ",", "," . $mybb->user['uid'] . ",") === false) {
            eval("\$post['button_pm'] = \"" . $templates->get("postbit_pm") . "\";");
        }
        if ($post_type != 3 && $mybb->settings['enablereputation'] == 1 && $mybb->settings['postrep'] == 1 && $mybb->usergroup['cangivereputations'] == 1 && $usergroup['usereputationsystem'] == 1 && ($mybb->settings['posrep'] || $mybb->settings['neurep'] || $mybb->settings['negrep']) && $post['uid'] != $mybb->user['uid']) {
            if (!$post['pid']) {
                $post['pid'] = 0;
            }
            eval("\$post['button_rep'] = \"" . $templates->get("postbit_rep_button") . "\";");
        }
        if ($post['website'] != "") {
            $post['website'] = htmlspecialchars_uni($post['website']);
            eval("\$post['button_www'] = \"" . $templates->get("postbit_www") . "\";");
        } else {
            $post['button_www'] = "";
        }
        if ($post['hideemail'] != 1 && $mybb->usergroup['cansendemail'] == 1) {
            eval("\$post['button_email'] = \"" . $templates->get("postbit_email") . "\";");
        } else {
            $post['button_email'] = "";
        }
        $post['userregdate'] = my_date($mybb->settings['regdateformat'], $post['regdate']);
        // Work out the reputation this user has (only show if not announcement)
        if ($post_type != 3 && $usergroup['usereputationsystem'] != 0 && $mybb->settings['enablereputation'] == 1) {
            $post['userreputation'] = get_reputation($post['reputation'], $post['uid']);
            eval("\$post['replink'] = \"" . $templates->get("postbit_reputation") . "\";");
        }
        // Showing the warning level? (only show if not announcement)
        if ($post_type != 3 && $mybb->settings['enablewarningsystem'] != 0 && $usergroup['canreceivewarnings'] != 0 && ($mybb->usergroup['canwarnusers'] != 0 || $mybb->user['uid'] == $post['uid'] && $mybb->settings['canviewownwarning'] != 0)) {
            $warning_level = round($post['warningpoints'] / $mybb->settings['maxwarningpoints'] * 100);
            if ($warning_level > 100) {
                $warning_level = 100;
            }
            $warning_level = get_colored_warning_level($warning_level);
            // If we can warn them, it's not the same person, and we're in a PM or a post.
            if ($mybb->usergroup['canwarnusers'] != 0 && $post['uid'] != $mybb->user['uid'] && ($post_type == 0 || $post_type == 2)) {
                eval("\$post['button_warn'] = \"" . $templates->get("postbit_warn") . "\";");
                $warning_link = "warnings.php?uid={$post['uid']}";
            } else {
                $warning_link = "usercp.php";
            }
            eval("\$post['warninglevel'] = \"" . $templates->get("postbit_warninglevel") . "\";");
        }
        eval("\$post['user_details'] = \"" . $templates->get("postbit_author_user") . "\";");
    } else {
        // Message was posted by a guest or an unknown user
        $post['profilelink'] = format_name($post['username'], 1);
        if ($usergroup['usertitle']) {
            $post['usertitle'] = $usergroup['usertitle'];
        } else {
            $post['usertitle'] = $lang->guest;
        }
        $usergroup['title'] = $lang->na;
        $post['userregdate'] = $lang->na;
        $post['postnum'] = $lang->na;
        $post['button_profile'] = '';
        $post['button_email'] = '';
        $post['button_www'] = '';
        $post['signature'] = '';
        $post['button_pm'] = '';
        $post['button_find'] = '';
        $post['onlinestatus'] = '';
        $post['replink'] = '';
        eval("\$post['user_details'] = \"" . $templates->get("postbit_author_guest") . "\";");
    }
    $post['button_edit'] = '';
    $post['button_quickdelete'] = '';
    $post['button_quote'] = '';
    $post['button_quickquote'] = '';
    $post['button_report'] = '';
    // For private messages, fetch the reply/forward/delete icons
    if ($post_type == 2 && $post['pmid']) {
        global $replyall;
        eval("\$post['button_reply_pm'] = \"" . $templates->get("postbit_reply_pm") . "\";");
        eval("\$post['button_forward_pm'] = \"" . $templates->get("postbit_forward_pm") . "\";");
        eval("\$post['button_delete_pm'] = \"" . $templates->get("postbit_delete_pm") . "\";");
        if ($replyall == true) {
            eval("\$post['button_replyall_pm'] = \"" . $templates->get("postbit_replyall_pm") . "\";");
        }
    }
    if (!$post_type) {
        // Figure out if we need to show an "edited by" message
        $post['editedmsg'] = '';
        if ($post['edituid'] != 0 && $post['edittime'] != 0 && $post['editusername'] != "" && ($mybb->settings['showeditedby'] != 0 && $usergroup['cancp'] == 0 || $mybb->settings['showeditedbyadmin'] != 0 && $usergroup['cancp'] == 1)) {
            $post['editdate'] = my_date($mybb->settings['dateformat'], $post['edittime']);
            $post['edittime'] = my_date($mybb->settings['timeformat'], $post['edittime']);
            $post['editnote'] = $lang->sprintf($lang->postbit_edited, $post['editdate'], $post['edittime']);
            $post['editedprofilelink'] = build_profile_link($post['editusername'], $post['edituid']);
            eval("\$post['editedmsg'] = \"" . $templates->get("postbit_editedby") . "\";");
        }
        if ((is_moderator($fid, "caneditposts") || $forumpermissions['caneditposts'] == 1 && $mybb->user['uid'] == $post['uid']) && $mybb->user['uid'] != 0) {
            eval("\$post['button_edit'] = \"" . $templates->get("postbit_edit") . "\";");
        }
        // Quick Delete button
        $can_delete = 0;
        if ($mybb->user['uid'] == $post['uid']) {
            if ($forumpermissions['candeletethreads'] == 1 && $postcounter == 1) {
                $can_delete = 1;
            } else {
                if ($forumpermissions['candeleteposts'] == 1 && $postcounter != 1) {
                    $can_delete = 1;
                }
            }
        }
        if ((is_moderator($fid, "candeleteposts") || $can_delete == 1) && $mybb->user['uid'] != 0) {
            eval("\$post['button_quickdelete'] = \"" . $templates->get("postbit_quickdelete") . "\";");
        }
        // Inline moderation stuff
        if ($ismod) {
            if (isset($mybb->cookies[$inlinecookie]) && my_strpos($mybb->cookies[$inlinecookie], "|" . $post['pid'] . "|")) {
                $inlinecheck = "checked=\"checked\"";
                $inlinecount++;
            } else {
                $inlinecheck = "";
            }
            eval("\$post['inlinecheck'] = \"" . $templates->get("postbit_inlinecheck") . "\";");
            if ($post['visible'] == 0) {
                $invisiblepost = 1;
            }
        } else {
            $post['inlinecheck'] = "";
        }
        $post['postlink'] = get_post_link($post['pid'], $post['tid']);
        eval("\$post['posturl'] = \"" . $templates->get("postbit_posturl") . "\";");
        global $forum, $thread;
        if ($forum['open'] != 0 && ($thread['closed'] != 1 || is_moderator($forum['fid']))) {
            eval("\$post['button_quote'] = \"" . $templates->get("postbit_quote") . "\";");
        }
        if ($forumpermissions['canpostreplys'] != 0 && ($thread['closed'] != 1 || is_moderator($fid)) && $mybb->settings['multiquote'] != 0 && $forum['open'] != 0 && !$post_type) {
            eval("\$post['button_multiquote'] = \"" . $templates->get("postbit_multiquote") . "\";");
        }
        if ($mybb->user['uid'] != "0") {
            eval("\$post['button_report'] = \"" . $templates->get("postbit_report") . "\";");
        }
        if ($mybb->settings['logip'] != "no") {
            if ($mybb->settings['logip'] == "show") {
                eval("\$post['iplogged'] = \"" . $templates->get("postbit_iplogged_show") . "\";");
            } else {
                if ($mybb->settings['logip'] == "hide" && is_moderator($fid, "canviewips")) {
                    eval("\$post['iplogged'] = \"" . $templates->get("postbit_iplogged_hiden") . "\";");
                } else {
                    $post['iplogged'] = "";
                }
            }
        } else {
            $post['iplogged'] = "";
        }
    } elseif ($post_type == 3) {
        if ($mybb->usergroup['issupermod'] == 1 || is_moderator($fid)) {
            eval("\$post['button_edit'] = \"" . $templates->get("announcement_edit") . "\";");
            eval("\$post['button_quickdelete'] = \"" . $templates->get("announcement_quickdelete") . "\";");
        }
    }
    if ($post['smilieoff'] == 1) {
        $parser_options['allow_smilies'] = 0;
    }
    // If we have incoming search terms to highlight - get it done.
    if (!empty($mybb->input['highlight'])) {
        $parser_options['highlight'] = $mybb->input['highlight'];
        $post['subject'] = $parser->highlight_message($post['subject'], $parser_options['highlight']);
    }
    $post['message'] = $parser->parse_message($post['message'], $parser_options);
    get_post_attachments($id, $post);
    if ($post['includesig'] != 0 && $post['username'] && $post['signature'] != "" && ($mybb->user['uid'] == 0 || $mybb->user['showsigs'] != 0) && ($post['suspendsignature'] == 0 || $post['suspendsignature'] == 1 && $post['suspendsigtime'] != 0 && $post['suspendsigtime'] < TIME_NOW) && $usergroup['canusesig'] == 1 && ($usergroup['canusesigxposts'] == 0 || $usergroup['canusesigxposts'] > 0 && $postnum > $usergroup['canusesigxposts'])) {
        $sig_parser = array("allow_html" => $mybb->settings['sightml'], "allow_mycode" => $mybb->settings['sigmycode'], "allow_smilies" => $mybb->settings['sigsmilies'], "allow_imgcode" => $mybb->settings['sigimgcode'], "me_username" => $post['username'], "filter_badwords" => 1);
        if ($usergroup['signofollow']) {
            $sig_parser['nofollow_on'] = 1;
        }
        $post['signature'] = $parser->parse_message($post['signature'], $sig_parser);
        eval("\$post['signature'] = \"" . $templates->get("postbit_signature") . "\";");
    } else {
        $post['signature'] = "";
    }
    $icon_cache = $cache->read("posticons");
    if ($post['icon'] > 0 && $icon_cache[$post['icon']]) {
        $icon = $icon_cache[$post['icon']];
        $icon['path'] = htmlspecialchars_uni($icon['path']);
        $icon['name'] = htmlspecialchars_uni($icon['name']);
        $post['icon'] = "<img src=\"{$icon['path']}\" alt=\"{$icon['name']}\" style=\"vertical-align: middle;\" />&nbsp;";
    } else {
        $post['icon'] = "";
    }
    $post_visibility = '';
    switch ($post_type) {
        case 1:
            // Message preview
            $post = $plugins->run_hooks("postbit_prev", $post);
            break;
        case 2:
            // Private message
            $post = $plugins->run_hooks("postbit_pm", $post);
            break;
        case 3:
            // Announcement
            $post = $plugins->run_hooks("postbit_announcement", $post);
            break;
        default:
            // Regular post
            $post = $plugins->run_hooks("postbit", $post);
            // Is this author on the ignore list of the current user? Hide this post
            $ignore_bit = '';
            if (is_array($ignored_users) && $post['uid'] != 0 && isset($ignored_users[$post['uid']]) && $ignored_users[$post['uid']] == 1) {
                $ignored_message = $lang->sprintf($lang->postbit_currently_ignoring_user, $post['username']);
                eval("\$ignore_bit = \"" . $templates->get("postbit_ignored") . "\";");
                $post_visibility = "display: none;";
            }
            break;
    }
    if ($mybb->settings['postlayout'] == "classic") {
        eval("\$postbit = \"" . $templates->get("postbit_classic") . "\";");
    } else {
        eval("\$postbit = \"" . $templates->get("postbit") . "\";");
    }
    $GLOBALS['post'] = "";
    return $postbit;
}
Ejemplo n.º 4
0
         $timeremaining = nice_time($remaining, array('short' => 1, 'seconds' => false)) . "";
         if ($remaining < 3600) {
             $timeremaining = "<span style=\"color: red;\">({$timeremaining} {$lang->ban_remaining})</span>";
         } else {
             if ($remaining < 86400) {
                 $timeremaining = "<span style=\"color: maroon;\">({$timeremaining} {$lang->ban_remaining})</span>";
             } else {
                 if ($remaining < 604800) {
                     $timeremaining = "<span style=\"color: green;\">({$timeremaining} {$lang->ban_remaining})</span>";
                 } else {
                     $timeremaining = "({$timeremaining} {$lang->ban_remaining})";
                 }
             }
         }
     }
     $memban['adminuser'] = build_profile_link($memban['adminuser'], $memban['admin']);
     // Display a nice warning to the user
     eval('$bannedbit = "' . $templates->get('member_profile_banned') . '";');
 }
 $adminoptions = '';
 if ($mybb->usergroup['cancp'] == 1 && $mybb->config['hide_admin_links'] != 1) {
     eval("\$adminoptions = \"" . $templates->get("member_profile_adminoptions") . "\";");
 }
 $modoptions = $viewnotes = $editnotes = $editprofile = $banuser = $manageuser = '';
 $can_purge_spammer = purgespammer_show($memprofile['postnum'], $memprofile['usergroup'], $memprofile['uid']);
 if ($mybb->usergroup['canmodcp'] == 1 || $can_purge_spammer) {
     $memprofile['usernotes'] = nl2br(htmlspecialchars_uni($memprofile['usernotes']));
     if (!empty($memprofile['usernotes'])) {
         if (strlen($memprofile['usernotes']) > 100) {
             eval("\$viewnotes = \"" . $templates->get("member_profile_modoptions_viewnotes") . "\";");
             $memprofile['usernotes'] = my_substr($memprofile['usernotes'], 0, 100) . "... {$viewnotes}";
Ejemplo n.º 5
0
    add_breadcrumb($lang->nav_onlinetoday);
    $plugins->run_hooks("online_today_start");
    $todaycount = 0;
    $stime = TIME_NOW - 60 * 60 * 24;
    $todayrows = '';
    $query = $db->query("\n\t\tSELECT u.*\n\t\tFROM " . TABLE_PREFIX . "users u\n\t\tLEFT JOIN " . TABLE_PREFIX . "usergroups g ON (g.gid=u.usergroup)\n\t\tWHERE u.lastactive > {$stime}\n\t\tORDER BY u.lastactive DESC\n\t");
    while ($online = $db->fetch_array($query)) {
        if ($online['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $online['uid'] == $mybb->user['uid']) {
            if ($online['invisible'] == 1) {
                $invisiblemark = "*";
            } else {
                $invisiblemark = "";
            }
            $username = $online['username'];
            $username = format_name($username, $online['usergroup'], $online['displaygroup']);
            $online['profilelink'] = build_profile_link($username, $online['uid']);
            $onlinetime = my_date($mybb->settings['timeformat'], $online['lastactive']);
            eval("\$todayrows .= \"" . $templates->get("online_today_row") . "\";");
        }
        ++$todaycount;
    }
    if ($todaycount == 1) {
        $onlinetoday = $lang->member_online_today;
    } else {
        $onlinetoday = $lang->sprintf($lang->members_were_online_today, $todaycount);
    }
    $plugins->run_hooks("online_today_end");
    eval("\$today = \"" . $templates->get("online_today") . "\";");
    output_page($today);
} else {
    $plugins->run_hooks("online_start");
/**
 * Build a navigation tree for threaded display.
 *
 * @param unknown_type $replyto
 * @param unknown_type $indent
 * @return unknown
 */
function buildtree($replyto = "0", $indent = "0")
{
    global $tree, $mybb, $theme, $mybb, $pid, $tid, $templates, $parser;
    if ($indent) {
        $indentsize = 13 * $indent;
    } else {
        $indentsize = 0;
    }
    ++$indent;
    if (is_array($tree[$replyto])) {
        foreach ($tree[$replyto] as $key => $post) {
            $postdate = my_date($mybb->settings['dateformat'], $post['dateline']);
            $posttime = my_date($mybb->settings['timeformat'], $post['dateline']);
            $post['subject'] = htmlspecialchars_uni($parser->parse_badwords($post['subject']));
            if (!$post['subject']) {
                $post['subject'] = "[" . $lang->no_subject . "]";
            }
            $post['profilelink'] = build_profile_link($post['username'], $post['uid']);
            if ($mybb->input['pid'] == $post['pid']) {
                eval("\$posts .= \"" . $templates->get("showthread_threaded_bitactive") . "\";");
            } else {
                eval("\$posts .= \"" . $templates->get("showthread_threaded_bit") . "\";");
            }
            if ($tree[$post['pid']]) {
                $posts .= buildtree($post['pid'], $indent);
            }
        }
        --$indent;
    }
    return $posts;
}
Ejemplo n.º 7
0
 $banned_cache = array();
 while ($banned = $db->fetch_array($query)) {
     $banned['remaining'] = $banned['lifted'] - TIME_NOW;
     $banned_cache[$banned['remaining'] . $banned['uid']] = $banned;
     unset($banned);
 }
 // Get the banned users
 $bannedusers = '';
 foreach ($banned_cache as $banned) {
     $profile_link = build_profile_link($banned['username'], $banned['uid']);
     // Only show the edit & lift links if current user created ban, or is super mod/admin
     $edit_link = '';
     if ($mybb->user['uid'] == $banned['admin'] || !$banned['adminuser'] || $mybb->usergroup['issupermod'] == 1 || $mybb->usergroup['cancp'] == 1) {
         eval("\$edit_link = \"" . $templates->get("modcp_banning_edit") . "\";");
     }
     $admin_profile = build_profile_link($banned['adminuser'], $banned['admin']);
     $trow = alt_trow();
     if ($banned['reason']) {
         $banned['reason'] = htmlspecialchars_uni($parser->parse_badwords($banned['reason']));
     } else {
         $banned['reason'] = $lang->na;
     }
     if ($banned['lifted'] == 'perm' || $banned['lifted'] == '' || $banned['bantime'] == 'perm' || $banned['bantime'] == '---') {
         $banlength = $lang->permanent;
         $timeremaining = $lang->na;
     } else {
         $banlength = $bantimes[$banned['bantime']];
         $remaining = $banned['remaining'];
         $timeremaining = nice_time($remaining, array('short' => 1, 'seconds' => false)) . "";
         if ($remaining <= 0) {
             $timeremaining = "<span style=\"color: red;\">({$lang->ban_ending_imminently})</span>";
Ejemplo n.º 8
0
 $users = "";
 while ($user = $db->fetch_array($query)) {
     $altbg = alt_trow();
     $regdate = my_date('relative', $user['regdate']);
     $post = $user;
     $sendpm = $email = '';
     if ($mybb->settings['enablepms'] == 1 && $post['receivepms'] != 0 && $mybb->usergroup['cansendpms'] == 1 && my_strpos("," . $post['ignorelist'] . ",", "," . $mybb->user['uid'] . ",") === false) {
         eval("\$sendpm = \"" . $templates->get("postbit_pm") . "\";");
     }
     if ($user['hideemail'] != 1) {
         eval("\$email = \"" . $templates->get("postbit_email") . "\";");
     } else {
         $email = '';
     }
     $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
     $user['profilelink'] = build_profile_link($user['username'], $user['uid']);
     if (in_array($user['uid'], $leaders_array)) {
         $leader = $lang->leader;
     } else {
         $leader = '';
     }
     // Checkbox for user management - only if current user is allowed
     $checkbox = '';
     if ($groupleader['canmanagemembers'] == 1) {
         eval("\$checkbox = \"" . $templates->get("managegroup_user_checkbox") . "\";");
     }
     eval("\$users .= \"" . $templates->get("managegroup_user") . "\";");
 }
 if (!$users) {
     eval("\$users = \"" . $templates->get("managegroup_no_users") . "\";");
 }
Ejemplo n.º 9
0
                    $folder_label .= $lang->icon_hot;
                }
                // Is our thread visible?
                if ($thread['visible'] == 0) {
                    $bgcolor = 'trow_shaded';
                }
                if ($thread['closed'] == 1) {
                    $folder .= "lock";
                    $folder_label .= $lang->icon_lock;
                }
                $folder .= "folder";
                $lastpostdate = my_date('relative', $thread['lastpost']);
                $lastposter = $thread['lastposter'];
                $lastposteruid = $thread['lastposteruid'];
                if ($lastposteruid == 0) {
                    $lastposterlink = $lastposter;
                } else {
                    $lastposterlink = build_profile_link($lastposter, $lastposteruid);
                }
                $thread['replies'] = my_number_format($thread['replies']);
                $thread['views'] = my_number_format($thread['views']);
                $thread['author'] = build_profile_link($thread['username'], $thread['uid']);
                eval("\$latest_threads_threads .= \"" . $templates->get("usercp_latest_threads_threads") . "\";");
            }
        }
        eval("\$latest_threads = \"" . $templates->get("usercp_latest_threads") . "\";");
    }
    $plugins->run_hooks("usercp_end");
    eval("\$usercp = \"" . $templates->get("usercp") . "\";");
    output_page($usercp);
}
Ejemplo n.º 10
0
function home_action_handler($action)
{
    global $page, $db, $lang, $plugins;
    $page->active_module = "home";
    $actions = array('preferences' => array('active' => 'preferences', 'file' => 'preferences.php'), 'credits' => array('active' => 'credits', 'file' => 'credits.php'), 'version_check' => array('active' => 'version_check', 'file' => 'version_check.php'), 'dashboard' => array('active' => 'dashboard', 'file' => 'index.php'));
    if (!isset($actions[$action])) {
        $page->active_action = "dashboard";
    } else {
        $page->active_action = $actions[$action]['active'];
    }
    $actions = $plugins->run_hooks("admin_home_action_handler", $actions);
    if ($page->active_action == "dashboard") {
        // Quick Access
        $sub_menu = array();
        $sub_menu['10'] = array("id" => "add_forum", "title" => $lang->add_new_forum, "link" => "index.php?module=forum-management&action=add");
        $sub_menu['20'] = array("id" => "search", "title" => $lang->search_for_users, "link" => "index.php?module=user-users&action=search");
        $sub_menu['30'] = array("id" => "themes", "title" => $lang->themes, "link" => "index.php?module=style-themes");
        $sub_menu['40'] = array("id" => "templates", "title" => $lang->templates, "link" => "index.php?module=style-templates");
        $sub_menu['50'] = array("id" => "plugins", "title" => $lang->plugins, "link" => "index.php?module=config-plugins");
        $sub_menu['60'] = array("id" => "backupdb", "title" => $lang->database_backups, "link" => "index.php?module=tools-backupdb");
        $sub_menu = $plugins->run_hooks("admin_home_menu_quick_access", $sub_menu);
        $sidebar = new SidebarItem($lang->quick_access);
        $sidebar->add_menu_items($sub_menu, $page->active_action);
        $page->sidebar .= $sidebar->get_markup();
        // Online Administrators in the last 30 minutes
        $timecut = TIME_NOW - 60 * 30;
        $query = $db->simple_select("adminsessions", "uid, ip, useragent", "lastactive > {$timecut}");
        $online_users = "<ul class=\"menu online_admins\">";
        $online_admins = array();
        // If there's only 1 user online, it has to be us.
        if ($db->num_rows($query) == 1) {
            $user = $db->fetch_array($query);
            global $mybb;
            // Are we on a mobile device?
            // Stolen from http://stackoverflow.com/a/10989424
            $user_type = "desktop";
            if (is_mobile($user["useragent"])) {
                $user_type = "mobile";
            }
            $online_admins[$mybb->user['username']] = array("uid" => $mybb->user['uid'], "username" => $mybb->user['username'], "ip" => $user["ip"], "type" => $user_type);
        } else {
            $uid_in = array();
            while ($user = $db->fetch_array($query)) {
                $uid_in[] = $user['uid'];
                $user_type = "desktop";
                if (is_mobile($user['useragent'])) {
                    $user_type = "mobile";
                }
                $online_admins[$user['uid']] = array("ip" => $user['ip'], "type" => $user_type);
            }
            $query = $db->simple_select("users", "uid, username", "uid IN(" . implode(',', $uid_in) . ")", array('order_by' => 'username'));
            while ($user = $db->fetch_array($query)) {
                $online_admins[$user['username']] = array("uid" => $user['uid'], "username" => $user['username'], "ip" => $online_admins[$user['uid']]['ip'], "type" => $online_admins[$user['uid']]['type']);
                unset($online_admins[$user['uid']]);
            }
        }
        $done_users = array();
        asort($online_admins);
        foreach ($online_admins as $user) {
            if (!isset($done_users["{$user['uid']}.{$user['ip']}"])) {
                if ($user['type'] == "mobile") {
                    $class = " class=\"mobile_user\"";
                } else {
                    $class = "";
                }
                $ip_address = my_inet_ntop($db->unescape_binary($user['ip']));
                $online_users .= "<li title=\"{$lang->ipaddress} {$ip_address}\"{$class}>" . build_profile_link($user['username'] . ' (' . $ip_address . ')', $user['uid'], "_blank") . "</li>";
                $done_users["{$user['uid']}.{$user['ip']}"] = 1;
            }
        }
        $online_users .= "</ul>";
        $sidebar = new SidebarItem($lang->online_admins);
        $sidebar->set_contents($online_users);
        $page->sidebar .= $sidebar->get_markup();
    }
    if (isset($actions[$action])) {
        $page->active_action = $actions[$action]['active'];
        return $actions[$action]['file'];
    } else {
        $page->active_action = "dashboard";
        return "index.php";
    }
}
/**
* 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);
}
Ejemplo n.º 12
0
 $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();
 $page->output_footer();
Ejemplo n.º 13
0
function asb_top_poster_build_template($args)
{
    extract($args);
    global ${$template_var}, $db, $templates, $lang, $theme;
    if (!$lang->asb_addon) {
        $lang->load('asb_addon');
    }
    if (!$settings['time_frame']) {
        $settings['time_frame'] = 1;
    }
    $timesearch = TIME_NOW - 86400 * $settings['time_frame'];
    // build user group exclusions (if any)
    $show = asb_build_id_list($settings['group_show_list'], 'u.usergroup');
    $hide = asb_build_id_list($settings['group_hide_list'], 'u.usergroup');
    $where['show'] = asb_build_SQL_where($show, ' OR ');
    $where['hide'] = asb_build_SQL_where($hide, ' OR ', ' NOT ');
    $group_where = asb_build_SQL_where($where, ' AND ', ' AND ');
    $group_by = 'p.uid';
    if ($db->type == 'pgsql') {
        $group_by = $db->build_fields_string('users', 'u.');
    }
    $query = $db->query(<<<EOF
SELECT u.uid, u.username, u.usergroup, u.displaygroup, u.avatar, COUNT(*) AS poststoday
FROM {$db->table_prefix}posts p
LEFT JOIN {$db->table_prefix}users u ON (p.uid=u.uid)
WHERE p.dateline > {$timesearch}{$group_where}
GROUP BY {$group_by} ORDER BY poststoday DESC
LIMIT 1
EOF
);
    // some defaults
    $top_poster = $lang->asb_top_poster_no_one;
    $top_poster_posts = $lang->asb_top_poster_no_posts;
    $top_poster_text = $lang->asb_top_poster_no_top_poster;
    $top_poster_avatar = '';
    $ret_val = false;
    // adjust language for time frame
    switch ($settings['time_frame']) {
        case 7:
            $top_poster_timeframe = $lang->asb_top_poster_one_week;
            break;
        case 14:
            $top_poster_timeframe = $lang->asb_top_poster_two_weeks;
            break;
        case 30:
            $top_poster_timeframe = $lang->asb_top_poster_one_month;
            break;
        case 90:
            $top_poster_timeframe = $lang->asb_top_poster_three_months;
            break;
        case 180:
            $top_poster_timeframe = $lang->asb_top_poster_six_months;
            break;
        case 365:
            $top_poster_timeframe = $lang->asb_top_poster_one_year;
            break;
        default:
            $top_poster_timeframe = $lang->asb_top_poster_one_day;
    }
    $user = $db->fetch_array($query);
    // if we have a user . . .
    if ($user['poststoday']) {
        // default to default :p
        $avatar_width = (int) $width * 0.83;
        if ((int) $settings['avatar_size']) {
            $avatar_width = (int) $settings['avatar_size'];
        }
        // default to guest
        $top_poster = $lang->guest;
        if ($user['uid']) {
            $username = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
            $top_poster = build_profile_link($username, $user['uid']);
        }
        $top_poster_posts = $user['poststoday'];
        $post_lang = $lang->asb_top_poster_posts;
        if ($top_poster_posts == 1) {
            $post_lang = $lang->asb_top_poster_post;
        }
        $top_poster_avatar_src = "{$theme['imgdir']}/default_avatar.gif";
        if ($user['avatar'] != '') {
            $top_poster_avatar_src = $user['avatar'];
        }
        eval("\$top_poster_avatar = \"" . $templates->get('asb_top_poster_avatar') . "\";");
        $top_poster_text = $lang->sprintf($lang->asb_top_poster_congrats, $top_poster, $top_poster_timeframe, $top_poster_posts, $post_lang);
        $ret_val = true;
    }
    eval("\$\$template_var = \"" . $templates->get('asb_top_poster') . "\";");
    // return true if your box has something to show, or false if it doesn't.
    return $ret_val;
}
Ejemplo n.º 14
0
     }
     $user_usergroup = $groupscache[$event['displaygroup']];
 } else {
     $user_usergroup = $groupscache[1];
 }
 if (!is_array($titles_cache)) {
     // Get user titles (i guess we should improve this, maybe in version3.
     $query = $db->simple_select("usertitles", "*", "", array('order_by' => 'posts', 'order_dir' => 'DESC'));
     while ($usertitle = $db->fetch_array($query)) {
         $titles_cache[$usertitle['posts']] = $usertitle;
     }
     unset($usertitle);
 }
 // Event made by registered user
 if ($event['uid'] > 0 && $event['username']) {
     $event['profilelink'] = build_profile_link(format_name($event['username'], $event['usergroup'], $event['displaygroup']), $event['uid']);
     if (trim($event['usertitle']) != "") {
         $hascustomtitle = 1;
     }
     if ($user_usergroup['usertitle'] != "" && !$hascustomtitle) {
         $event['usertitle'] = $user_usergroup['usertitle'];
     } elseif (is_array($titles_cache) && !$user_usergroup['usertitle']) {
         reset($titles_cache);
         foreach ($titles_cache as $key => $title) {
             if ($event['postnum'] >= $key) {
                 if (!$hascustomtitle) {
                     $event['usertitle'] = $title['title'];
                 }
                 $event['stars'] = $title['stars'];
                 $event['starimage'] = $title['starimage'];
                 break;
Ejemplo n.º 15
0
 }
 $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;";
     }
     if ($announcement['avatar'] != '') {
         $avatar_dimensions = explode("|", $announcement['avatardimensions']);
         if ($avatar_dimensions[0] && $avatar_dimensions[1]) {
             $avatar_width_height = "width=\"{$avatar_dimensions[0]}\" height=\"{$avatar_dimensions[1]}\"";
Ejemplo n.º 16
0
    }
    // If there are one or more birthdays, show them.
    if ($bdaycount > 0 || $hiddencount > 0) {
        eval('$birthdays = "' . $templates->get('index_birthdays') . '";');
    }
}
// Build the forum statistics to show on the index page.
$forumstats = '';
if ($mybb->settings['showindexstats'] != 0) {
    // First, load the stats cache.
    $stats = $cache->read('stats');
    // Check who's the newest member.
    if (!$stats['lastusername']) {
        $newestmember = $lang->nobody;
    } else {
        $newestmember = build_profile_link($stats['lastusername'], $stats['lastuid']);
    }
    // Format the stats language.
    $lang->stats_posts_threads = $lang->sprintf($lang->stats_posts_threads, my_number_format($stats['numposts']), my_number_format($stats['numthreads']));
    $lang->stats_numusers = $lang->sprintf($lang->stats_numusers, my_number_format($stats['numusers']));
    $lang->stats_newestuser = $lang->sprintf($lang->stats_newestuser, $newestmember);
    // Find out what the highest users online count is.
    $mostonline = $cache->read('mostonline');
    if ($onlinecount > $mostonline['numusers']) {
        $time = TIME_NOW;
        $mostonline['numusers'] = $onlinecount;
        $mostonline['time'] = $time;
        $cache->update('mostonline', $mostonline);
    }
    $recordcount = $mostonline['numusers'];
    $recorddate = my_date($mybb->settings['dateformat'], $mostonline['time']);
Ejemplo n.º 17
0
 if ($warning['expired'] != $last_expired || $first) {
     if ($warning['expired'] == 0) {
         eval("\$warnings .= \"" . $templates->get("warnings_active_header") . "\";");
     } else {
         eval("\$warnings .= \"" . $templates->get("warnings_expired_header") . "\";");
     }
 }
 $last_expired = $warning['expired'];
 $first = false;
 $post_link = "";
 if ($warning['post_subject']) {
     $warning['post_subject'] = $parser->parse_badwords($warning['post_subject']);
     $warning['post_subject'] = htmlspecialchars_uni($warning['post_subject']);
     $post_link = "<br /><small>{$lang->warning_for_post} <a href=\"" . get_post_link($warning['pid']) . "#pid{$warning['pid']}\">{$warning['post_subject']}</a></small>";
 }
 $issuedby = build_profile_link($warning['username'], $warning['issuedby']);
 $date_issued = my_date($mybb->settings['dateformat'], $warning['dateline']) . ", " . my_date($mybb->settings['timeformat'], $warning['dateline']);
 if ($warning['type_title']) {
     $warning_type = $warning['type_title'];
 } else {
     $warning_type = $warning['title'];
 }
 $warning_type = htmlspecialchars_uni($warning_type);
 if ($warning['points'] > 0) {
     $warning['points'] = "+{$warning['points']}";
 }
 $points = $lang->sprintf($lang->warning_points, $warning['points']);
 if ($warning['expired'] != 1) {
     if ($warning['expires'] == 0) {
         $expires = $lang->never;
     } else {
Ejemplo n.º 18
0
         $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;
         }
         $post['message'] = $parser->parse_message($post['message'], $parser_options);
         // Is there an attachment in this post?
         if (is_array($acache[$post['pid']])) {
             foreach ($acache[$post['pid']] as $aid => $attachment) {
                 $post['message'] = str_replace("[attachment={$attachment['aid']}]", "[<a href=\"" . $mybb->settings['bburl'] . "/attachment.php?aid={$attachment['aid']}\">attachment={$attachment['aid']}</a>]", $post['message']);
             }
         }
         // Damn thats a lot of parsing, now to determine which username to show..
         if ($post['userusername']) {
             $post['username'] = $post['userusername'];
         }
         $post['username'] = build_profile_link($post['username'], $post['uid']);
         $plugins->run_hooks("archive_thread_post");
         // Finally show the post
         echo "<div class=\"post\">\n<div class=\"header\">\n<div class=\"author\"><h2>{$post['username']}</h2></div>";
         echo "<div class=\"dateline\">{$post['date']}</div>\n</div>\n<div class=\"message\">{$post['message']}</div>\n</div>\n";
     }
     archive_multipage($postcount, $perpage, $page, "{$base_url}thread-{$id}");
     $plugins->run_hooks("archive_thread_end");
     archive_footer();
     break;
     // Display a category or a forum.
 // Display a category or a forum.
 case "forum":
     // Check if we have permission to view this forum
     $forumpermissions = forum_permissions($forum['fid']);
     if ($forumpermissions['canview'] != 1) {
Ejemplo n.º 19
0
 $table->construct_header($lang->expires, array("class" => "align_center", 'width' => '20%'));
 $table->construct_header($lang->issued_by, array("class" => "align_center", 'width' => '15%'));
 $table->construct_header($lang->options, array("class" => "align_center", 'width' => '5%'));
 while ($row = $db->fetch_array($query)) {
     if (!$row['username']) {
         $row['username'] = $lang->guest;
     }
     $trow = alt_trow();
     $username = format_name($row['username'], $row['usergroup'], $row['displaygroup']);
     if (!$row['uid']) {
         $username_link = $username;
     } else {
         $username_link = build_profile_link($username, $row['uid'], "_blank");
     }
     $mod_username = format_name($row['mod_username'], $row['mod_usergroup'], $row['mod_displaygroup']);
     $mod_username_link = build_profile_link($mod_username, $row['mod_uid'], "_blank");
     $issued_date = my_date($mybb->settings['dateformat'], $row['dateline']) . ' ' . my_date($mybb->settings['timeformat'], $row['dateline']);
     $revoked_text = '';
     if ($row['daterevoked'] > 0) {
         $revoked_date = my_date($mybb->settings['dateformat'], $row['daterevoked']) . ' ' . my_date($mybb->settings['timeformat'], $row['daterevoked']);
         $revoked_text = "<br /><small><strong>{$lang->revoked}</strong> {$revoked_date}</small>";
     }
     if ($row['expires'] > 0) {
         $expire_date = my_date($mybb->settings['dateformat'], $row['expires']) . ' ' . my_date($mybb->settings['timeformat'], $row['expires']);
     } else {
         $expire_date = $lang->never;
     }
     $title = $row['title'];
     if (empty($row['title'])) {
         $title = $row['custom_title'];
     }
Ejemplo n.º 20
0
     }
 }
 $reputation_votes = '';
 foreach ($reputation_cache as $reputation_vote) {
     // Get the reputation for the user who posted this comment
     if ($reputation_vote['adduid'] == 0) {
         $reputation_vote['user_reputation'] = 0;
     }
     $reputation_vote['user_reputation'] = get_reputation($reputation_vote['user_reputation'], $reputation_vote['adduid']);
     // Format the username of this poster
     if (!$reputation_vote['username']) {
         $reputation_vote['username'] = $lang->na;
         $reputation_vote['user_reputation'] = '';
     } else {
         $reputation_vote['username'] = format_name($reputation_vote['username'], $reputation_vote['user_usergroup'], $reputation_vote['user_displaygroup']);
         $reputation_vote['username'] = build_profile_link($reputation_vote['username'], $reputation_vote['uid']);
         $reputation_vote['user_reputation'] = "({$reputation_vote['user_reputation']})";
     }
     $vote_reputation = (int) $reputation_vote['reputation'];
     // This is a negative reputation
     if ($vote_reputation < 0) {
         $status_class = "trow_reputation_negative";
         $vote_type_class = "reputation_negative";
         $vote_type = $lang->negative;
     } else {
         if ($vote_reputation == 0) {
             $status_class = "trow_reputation_neutral";
             $vote_type_class = "reputation_neutral";
             $vote_type = $lang->neutral;
         } else {
             $vote_reputation = "+{$vote_reputation}";
Ejemplo n.º 21
0
     $start = 0;
     $pagecnt = 1;
 }
 $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();
Ejemplo n.º 22
0
/**
 * Build a post bit
 *
 * @param array $post The post data
 * @param int $post_type The type of post bit we're building (1 = preview, 2 = pm, 3 = announcement, else = post)
 * @return string The built post bit
 */
function build_postbit($post, $post_type = 0)
{
    global $db, $altbg, $theme, $mybb, $postcounter, $profile_fields;
    global $titlescache, $page, $templates, $forumpermissions, $attachcache;
    global $lang, $ismod, $inlinecookie, $inlinecount, $groupscache, $fid;
    global $plugins, $parser, $cache, $ignored_users, $hascustomtitle;
    $hascustomtitle = 0;
    // Set default values for any fields not provided here
    foreach (array('pid', 'aid', 'pmid', 'posturl', 'button_multiquote', 'subject_extra', 'attachments', 'button_rep', 'button_warn', 'button_purgespammer', 'button_pm', 'button_pubkey', 'button_reply_pm', 'button_replyall_pm', 'button_forward_pm', 'button_delete_pm', 'replink', 'warninglevel') as $post_field) {
        if (empty($post[$post_field])) {
            $post[$post_field] = '';
        }
    }
    // Set up the message parser if it doesn't already exist.
    if (!$parser) {
        require_once MYBB_ROOT . "inc/class_parser.php";
        $parser = new postParser();
    }
    if (!function_exists("purgespammer_show")) {
        require_once MYBB_ROOT . "inc/functions_user.php";
    }
    $unapproved_shade = '';
    if (isset($post['visible']) && $post['visible'] == 0 && $post_type == 0) {
        $altbg = $unapproved_shade = 'unapproved_post';
    } elseif (isset($post['visible']) && $post['visible'] == -1 && $post_type == 0) {
        $altbg = $unapproved_shade = 'unapproved_post deleted_post';
    } elseif ($altbg == 'trow1') {
        $altbg = 'trow2';
    } else {
        $altbg = 'trow1';
    }
    $post['fid'] = $fid;
    switch ($post_type) {
        case 1:
            // Message preview
            global $forum;
            $parser_options['allow_html'] = $forum['allowhtml'];
            $parser_options['allow_mycode'] = $forum['allowmycode'];
            $parser_options['allow_smilies'] = $forum['allowsmilies'];
            $parser_options['allow_imgcode'] = $forum['allowimgcode'];
            $parser_options['allow_videocode'] = $forum['allowvideocode'];
            $parser_options['me_username'] = $post['username'];
            $parser_options['filter_badwords'] = 1;
            $id = 0;
            break;
        case 2:
            // Private message
            global $message, $pmid;
            $idtype = 'pmid';
            $parser_options['allow_html'] = $mybb->settings['pmsallowhtml'];
            $parser_options['allow_mycode'] = $mybb->settings['pmsallowmycode'];
            $parser_options['allow_smilies'] = $mybb->settings['pmsallowsmilies'];
            $parser_options['allow_imgcode'] = $mybb->settings['pmsallowimgcode'];
            $parser_options['allow_videocode'] = $mybb->settings['pmsallowvideocode'];
            $parser_options['me_username'] = $post['username'];
            $parser_options['filter_badwords'] = 1;
            $id = $pmid;
            break;
        case 3:
            // Announcement
            global $announcementarray, $message;
            $parser_options['allow_html'] = $announcementarray['allowhtml'];
            $parser_options['allow_mycode'] = $announcementarray['allowmycode'];
            $parser_options['allow_smilies'] = $announcementarray['allowsmilies'];
            $parser_options['allow_imgcode'] = 1;
            $parser_options['allow_videocode'] = 1;
            $parser_options['me_username'] = $post['username'];
            $parser_options['filter_badwords'] = 1;
            $id = $announcementarray['aid'];
            break;
        default:
            // Regular post
            global $forum, $thread, $tid;
            $oldforum = $forum;
            $id = (int) $post['pid'];
            $idtype = 'pid';
            $parser_options['allow_html'] = $forum['allowhtml'];
            $parser_options['allow_mycode'] = $forum['allowmycode'];
            $parser_options['allow_smilies'] = $forum['allowsmilies'];
            $parser_options['allow_imgcode'] = $forum['allowimgcode'];
            $parser_options['allow_videocode'] = $forum['allowvideocode'];
            $parser_options['filter_badwords'] = 1;
            if (!$post['username']) {
                $post['username'] = $lang->guest;
            }
            if ($post['userusername']) {
                $parser_options['me_username'] = $post['userusername'];
            } else {
                $parser_options['me_username'] = $post['username'];
            }
            break;
    }
    if (!$postcounter) {
        // Used to show the # of the post
        if ($page > 1) {
            if (!$mybb->settings['postsperpage'] || (int) $mybb->settings['postsperpage'] < 1) {
                $mybb->settings['postsperpage'] = 20;
            }
            $postcounter = $mybb->settings['postsperpage'] * ($page - 1);
        } else {
            $postcounter = 0;
        }
        $post_extra_style = "border-top-width: 0;";
    } elseif ($mybb->input['mode'] == "threaded") {
        $post_extra_style = "border-top-width: 0;";
    } else {
        $post_extra_style = "margin-top: 5px;";
    }
    if (!$altbg) {
        // Define the alternate background colour if this is the first post
        $altbg = "trow1";
    }
    $postcounter++;
    // Format the post date and time using my_date
    //$post['postdate'] = my_date('relative', $post['dateline']);
    $post['postdate'] = date('Y-m-d', $post['dateline']);
    // Dont want any little 'nasties' in the subject
    $post['subject'] = $parser->parse_badwords($post['subject']);
    // Pm's have been htmlspecialchars_uni()'ed already.
    if ($post_type != 2) {
        $post['subject'] = htmlspecialchars_uni($post['subject']);
    }
    if (empty($post['subject'])) {
        $post['subject'] = '&nbsp;';
    }
    $post['author'] = $post['uid'];
    $post['subject_title'] = $post['subject'];
    // Get the usergroup
    if ($post['userusername']) {
        if (!$post['displaygroup']) {
            $post['displaygroup'] = $post['usergroup'];
        }
        $usergroup = $groupscache[$post['displaygroup']];
    } else {
        $usergroup = $groupscache[1];
    }
    if (!is_array($titlescache)) {
        $cached_titles = $cache->read("usertitles");
        if (!empty($cached_titles)) {
            foreach ($cached_titles as $usertitle) {
                $titlescache[$usertitle['posts']] = $usertitle;
            }
        }
        if (is_array($titlescache)) {
            krsort($titlescache);
        }
        unset($usertitle, $cached_titles);
    }
    // Work out the usergroup/title stuff
    $post['groupimage'] = '';
    if (!empty($usergroup['image'])) {
        $language = $mybb->settings['bblanguage'];
        if (!empty($mybb->user['language'])) {
            $language = $mybb->user['language'];
        }
        $usergroup['image'] = str_replace("{lang}", $language, $usergroup['image']);
        $usergroup['image'] = str_replace("{theme}", $theme['imgdir'], $usergroup['image']);
        eval("\$post['groupimage'] = \"" . $templates->get("postbit_groupimage") . "\";");
        if ($mybb->settings['postlayout'] == "classic") {
            $post['groupimage'] .= "<br />";
        }
    }
    if ($post['userusername']) {
        // This post was made by a registered user
        $post['username'] = $post['userusername'];
        $post['profilelink_plain'] = get_profile_link($post['uid']);
        $post['username_formatted'] = format_name($post['username'], $post['usergroup'], $post['displaygroup']);
        $post['profilelink'] = build_profile_link($post['username_formatted'], $post['uid']);
        if (trim($post['usertitle']) != "") {
            $hascustomtitle = 1;
        }
        if ($usergroup['usertitle'] != "" && !$hascustomtitle) {
            $post['usertitle'] = $usergroup['usertitle'];
        } elseif (is_array($titlescache) && !$usergroup['usertitle']) {
            reset($titlescache);
            foreach ($titlescache as $key => $titleinfo) {
                if ($post['postnum'] >= $key) {
                    if (!$hascustomtitle) {
                        $post['usertitle'] = $titleinfo['title'];
                    }
                    $post['stars'] = $titleinfo['stars'];
                    $post['starimage'] = $titleinfo['starimage'];
                    break;
                }
            }
        }
        $post['usertitle'] = htmlspecialchars_uni($post['usertitle']);
        if ($usergroup['stars']) {
            $post['stars'] = $usergroup['stars'];
        }
        if (empty($post['starimage'])) {
            $post['starimage'] = $usergroup['starimage'];
        }
        if ($post['starimage'] && $post['stars']) {
            // Only display stars if we have an image to use...
            $post['starimage'] = str_replace("{theme}", $theme['imgdir'], $post['starimage']);
            $post['userstars'] = '';
            for ($i = 0; $i < $post['stars']; ++$i) {
                eval("\$post['userstars'] .= \"" . $templates->get("postbit_userstar", 1, 0) . "\";");
            }
            $post['userstars'] .= "<br />";
        }
        $postnum = $post['postnum'];
        $post['postnum'] = my_number_format($post['postnum']);
        $post['threadnum'] = my_number_format($post['threadnum']);
        // Determine the status to show for the user (Online/Offline/Away)
        /*
        $timecut = TIME_NOW - $mybb->settings['wolcutoff'];
        if($post['lastactive'] > $timecut && ($post['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1) && $post['lastvisit'] != $post['lastactive'])
        {
        	eval("\$post['onlinestatus'] = \"".$templates->get("postbit_online")."\";");
        }
        else
        {
        	if($post['away'] == 1 && $mybb->settings['allowaway'] != 0)
        	{
        		eval("\$post['onlinestatus'] = \"".$templates->get("postbit_away")."\";");
        	}
        	else
        	{
        		eval("\$post['onlinestatus'] = \"".$templates->get("postbit_offline")."\";");
        	}
        }
        */
        // Show as always offline
        eval("\$post['onlinestatus'] = \"" . $templates->get("postbit_offline") . "\";");
        $post['useravatar'] = '';
        if (isset($mybb->user['showavatars']) && $mybb->user['showavatars'] != 0 || $mybb->user['uid'] == 0) {
            $useravatar = format_avatar($post['avatar'], $post['avatardimensions'], $mybb->settings['postmaxavatarsize']);
            eval("\$post['useravatar'] = \"" . $templates->get("postbit_avatar") . "\";");
        }
        $post['button_find'] = '';
        if ($mybb->usergroup['cansearch'] == 1) {
            eval("\$post['button_find'] = \"" . $templates->get("postbit_find") . "\";");
        }
        if ($mybb->settings['enablepms'] == 1 && $post['receivepms'] != 0 && $mybb->usergroup['cansendpms'] == 1 && my_strpos("," . $post['ignorelist'] . ",", "," . $mybb->user['uid'] . ",") === false) {
            //eval("\$post['button_pm'] = \"".$templates->get("postbit_pm")."\";");
        }
        $post['button_rep'] = '';
        if ($post_type != 3 && $mybb->settings['enablereputation'] == 1 && $mybb->settings['postrep'] == 1 && $mybb->usergroup['cangivereputations'] == 1 && $usergroup['usereputationsystem'] == 1 && ($mybb->settings['posrep'] || $mybb->settings['neurep'] || $mybb->settings['negrep']) && $post['uid'] != $mybb->user['uid'] && $post['visible'] == 1) {
            if (!$post['pid']) {
                $post['pid'] = 0;
            }
            eval("\$post['button_rep'] = \"" . $templates->get("postbit_rep_button") . "\";");
        }
        if ($post['website'] != "" && !is_member($mybb->settings['hidewebsite']) && $usergroup['canchangewebsite'] == 1) {
            $post['website'] = htmlspecialchars_uni($post['website']);
            eval("\$post['button_www'] = \"" . $templates->get("postbit_www") . "\";");
        } else {
            $post['button_www'] = "";
        }
        if ($post['hideemail'] != 1 && $mybb->usergroup['cansendemail'] == 1) {
            eval("\$post['button_email'] = \"" . $templates->get("postbit_email") . "\";");
        } else {
            $post['button_email'] = "";
        }
        $post['userregdate'] = $lang->na;
        //my_date($mybb->settings['regdateformat'], $post['regdate']);
        // Work out the reputation this user has (only show if not announcement)
        if ($post_type != 3 && $usergroup['usereputationsystem'] != 0 && $mybb->settings['enablereputation'] == 1) {
            $post['userreputation'] = get_reputation($post['reputation'], $post['uid']);
            eval("\$post['replink'] = \"" . $templates->get("postbit_reputation") . "\";");
        }
        // Showing the warning level? (only show if not announcement)
        if ($post_type != 3 && $mybb->settings['enablewarningsystem'] != 0 && $usergroup['canreceivewarnings'] != 0 && ($mybb->usergroup['canwarnusers'] != 0 || $mybb->user['uid'] == $post['uid'] && $mybb->settings['canviewownwarning'] != 0)) {
            if ($mybb->settings['maxwarningpoints'] < 1) {
                $mybb->settings['maxwarningpoints'] = 10;
            }
            $warning_level = round($post['warningpoints'] / $mybb->settings['maxwarningpoints'] * 100);
            if ($warning_level > 100) {
                $warning_level = 100;
            }
            $warning_level = get_colored_warning_level($warning_level);
            // If we can warn them, it's not the same person, and we're in a PM or a post.
            if ($mybb->usergroup['canwarnusers'] != 0 && $post['uid'] != $mybb->user['uid'] && ($post_type == 0 || $post_type == 2)) {
                eval("\$post['button_warn'] = \"" . $templates->get("postbit_warn") . "\";");
                $warning_link = "warnings.php?uid={$post['uid']}";
            } else {
                $post['button_warn'] = '';
                $warning_link = "usercp.php";
            }
            eval("\$post['warninglevel'] = \"" . $templates->get("postbit_warninglevel") . "\";");
        }
        if ($post_type != 3 && $post_type != 1 && purgespammer_show($post['postnum'], $post['usergroup'], $post['uid'])) {
            eval("\$post['button_purgespammer'] = \"" . $templates->get('postbit_purgespammer') . "\";");
        }
        // Display profile fields on posts - only if field is filled in
        if (is_array($profile_fields)) {
            foreach ($profile_fields as $field) {
                $fieldfid = "fid{$field['fid']}";
                if (!empty($post[$fieldfid])) {
                    $post['fieldvalue'] = '';
                    $post['fieldname'] = htmlspecialchars_uni($field['name']);
                    $thing = explode("\n", $field['type'], "2");
                    $type = trim($thing[0]);
                    $useropts = explode("\n", $post[$fieldfid]);
                    if (is_array($useropts) && ($type == "multiselect" || $type == "checkbox")) {
                        foreach ($useropts as $val) {
                            if ($val != '') {
                                eval("\$post['fieldvalue_option'] .= \"" . $templates->get("postbit_profilefield_multiselect_value") . "\";");
                            }
                        }
                        if ($post['fieldvalue_option'] != '') {
                            eval("\$post['fieldvalue'] .= \"" . $templates->get("postbit_profilefield_multiselect") . "\";");
                        }
                    } else {
                        $field_parser_options = array("allow_html" => $field['allowhtml'], "allow_mycode" => $field['allowmycode'], "allow_smilies" => $field['allowsmilies'], "allow_imgcode" => $field['allowimgcode'], "allow_videocode" => $field['allowvideocode'], "filter_badwords" => 1);
                        if ($customfield['type'] == "textarea") {
                            $field_parser_options['me_username'] = $post['username'];
                        } else {
                            $field_parser_options['nl2br'] = 0;
                        }
                        if ($mybb->user['showimages'] != 1 && $mybb->user['uid'] != 0 || $mybb->settings['guestimages'] != 1 && $mybb->user['uid'] == 0) {
                            $field_parser_options['allow_imgcode'] = 0;
                        }
                        $post['fieldvalue'] = $parser->parse_message($post[$fieldfid], $field_parser_options);
                    }
                    eval("\$post['profilefield'] .= \"" . $templates->get("postbit_profilefield") . "\";");
                }
            }
        }
        eval("\$post['user_details'] = \"" . $templates->get("postbit_author_user") . "\";");
    } else {
        // Message was posted by a guest or an unknown user
        $post['profilelink'] = format_name($post['username'], 1);
        if ($usergroup['usertitle']) {
            $post['usertitle'] = $usergroup['usertitle'];
        } else {
            $post['usertitle'] = $lang->guest;
        }
        $post['usertitle'] = htmlspecialchars_uni($post['usertitle']);
        $usergroup['title'] = $lang->na;
        $post['userregdate'] = $lang->na;
        $post['postnum'] = $lang->na;
        $post['button_profile'] = '';
        $post['button_email'] = '';
        $post['button_www'] = '';
        $post['signature'] = '';
        $post['button_pm'] = $lang->na;
        $post['button_find'] = '';
        $post['onlinestatus'] = '';
        $post['replink'] = '';
        eval("\$post['user_details'] = \"" . $templates->get("postbit_author_guest") . "\";");
    }
    $post['button_edit'] = '';
    $post['button_quickdelete'] = '';
    $post['button_quickrestore'] = '';
    $post['button_quote'] = '';
    $post['button_quickquote'] = '';
    $post['button_report'] = '';
    $post['button_reply_pm'] = '';
    $post['button_replyall_pm'] = '';
    $post['button_forward_pm'] = '';
    $post['button_delete_pm'] = '';
    // For private messages, fetch the reply/forward/delete icons
    if ($post_type == 2 && $post['pmid']) {
        global $replyall;
        eval("\$post['button_reply_pm'] = \"" . $templates->get("postbit_reply_pm") . "\";");
        eval("\$post['button_forward_pm'] = \"" . $templates->get("postbit_forward_pm") . "\";");
        eval("\$post['button_delete_pm'] = \"" . $templates->get("postbit_delete_pm") . "\";");
        if ($replyall == true) {
            eval("\$post['button_replyall_pm'] = \"" . $templates->get("postbit_replyall_pm") . "\";");
        }
    }
    $post['editedmsg'] = '';
    if (!$post_type) {
        // Figure out if we need to show an "edited by" message
        if ($post['edituid'] != 0 && $post['edittime'] != 0 && $post['editusername'] != "" && ($mybb->settings['showeditedby'] != 0 && $usergroup['cancp'] == 0 || $mybb->settings['showeditedbyadmin'] != 0 && $usergroup['cancp'] == 1)) {
            //$post['editdate'] = my_date('relative', $post['edittime']);
            $post['editdate'] = $lang->na;
            $post['editnote'] = $lang->sprintf($lang->postbit_edited, $post['editdate']);
            $post['editedprofilelink'] = build_profile_link($post['editusername'], $post['edituid']);
            $editreason = "";
            if ($post['editreason'] != "") {
                $post['editreason'] = $parser->parse_badwords($post['editreason']);
                $post['editreason'] = htmlspecialchars_uni($post['editreason']);
                eval("\$editreason = \"" . $templates->get("postbit_editedby_editreason") . "\";");
            }
            eval("\$post['editedmsg'] = \"" . $templates->get("postbit_editedby") . "\";");
        }
        $time = TIME_NOW;
        if (is_moderator($fid, "caneditposts") || $forumpermissions['caneditposts'] == 1 && $mybb->user['uid'] == $post['uid'] && $thread['closed'] != 1 && $mybb->usergroup['edittimelimit'] == 0 && $mybb->user['uid'] != 0) {
            eval("\$post['button_edit'] = \"" . $templates->get("postbit_edit") . "\";");
        }
        // Quick Delete button
        $can_delete_thread = $can_delete_post = 0;
        if ($mybb->user['uid'] == $post['uid'] && $thread['closed'] == 0) {
            if ($forumpermissions['candeletethreads'] == 1 && $postcounter == 1) {
                $can_delete_thread = 1;
            } else {
                if ($forumpermissions['candeleteposts'] == 1 && $postcounter != 1) {
                    $can_delete_post = 1;
                }
            }
        }
        $postbit_qdelete = $postbit_qrestore = '';
        if ($mybb->user['uid'] != 0) {
            if ((is_moderator($fid, "candeleteposts") || is_moderator($fid, "cansoftdeleteposts") || $can_delete_post == 1) && $postcounter != 1) {
                $postbit_qdelete = $lang->postbit_qdelete_post;
                $display = '';
                if ($post['visible'] == -1) {
                    $display = "none";
                }
                eval("\$post['button_quickdelete'] = \"" . $templates->get("postbit_quickdelete") . "\";");
            } else {
                if ((is_moderator($fid, "candeletethreads") || is_moderator($fid, "cansoftdeletethreads") || $can_delete_thread == 1) && $postcounter == 1) {
                    $postbit_qdelete = $lang->postbit_qdelete_thread;
                    $display = '';
                    if ($post['visible'] == -1) {
                        $display = "none";
                    }
                    eval("\$post['button_quickdelete'] = \"" . $templates->get("postbit_quickdelete") . "\";");
                }
            }
            // Restore Post
            if (is_moderator($fid, "canrestoreposts") && $postcounter != 1) {
                $display = "none";
                if ($post['visible'] == -1) {
                    $display = '';
                }
                $postbit_qrestore = $lang->postbit_qrestore_post;
                eval("\$post['button_quickrestore'] = \"" . $templates->get("postbit_quickrestore") . "\";");
            } else {
                if (is_moderator($fid, "canrestorethreads") && $postcounter == 1) {
                    $display = "none";
                    if ($post['visible'] == -1) {
                        $display = "";
                    }
                    $postbit_qrestore = $lang->postbit_qrestore_thread;
                    eval("\$post['button_quickrestore'] = \"" . $templates->get("postbit_quickrestore") . "\";");
                }
            }
        }
        // Inline moderation stuff
        if ($ismod) {
            if (isset($mybb->cookies[$inlinecookie]) && my_strpos($mybb->cookies[$inlinecookie], "|" . $post['pid'] . "|")) {
                $inlinecheck = "checked=\"checked\"";
                $inlinecount++;
            } else {
                $inlinecheck = "";
            }
            eval("\$post['inlinecheck'] = \"" . $templates->get("postbit_inlinecheck") . "\";");
            if ($post['visible'] == 0) {
                $invisiblepost = 1;
            }
        } else {
            $post['inlinecheck'] = "";
        }
        $post['postlink'] = get_post_link($post['pid'], $post['tid']);
        $post_number = my_number_format($postcounter);
        eval("\$post['posturl'] = \"" . $templates->get("postbit_posturl") . "\";");
        global $forum, $thread;
        if ($forum['open'] != 0 && ($thread['closed'] != 1 || is_moderator($forum['fid'], "canpostclosedthreads")) && ($thread['uid'] == $mybb->user['uid'] || $forumpermissions['canonlyreplyownthreads'] != 1)) {
            eval("\$post['button_quote'] = \"" . $templates->get("postbit_quote") . "\";");
        }
        if ($forumpermissions['canpostreplys'] != 0 && ($thread['uid'] == $mybb->user['uid'] || $forumpermissions['canonlyreplyownthreads'] != 1) && ($thread['closed'] != 1 || is_moderator($fid, "canpostclosedthreads")) && $mybb->settings['multiquote'] != 0 && $forum['open'] != 0 && !$post_type) {
            eval("\$post['button_multiquote'] = \"" . $templates->get("postbit_multiquote") . "\";");
        }
        if ($mybb->user['uid'] != "0") {
            eval("\$post['button_report'] = \"" . $templates->get("postbit_report") . "\";");
        }
    } elseif ($post_type == 3) {
        if ($mybb->usergroup['canmodcp'] == 1 && $mybb->usergroup['canmanageannounce'] == 1 && is_moderator($fid, "canmanageannouncements")) {
            eval("\$post['button_edit'] = \"" . $templates->get("announcement_edit") . "\";");
            eval("\$post['button_quickdelete'] = \"" . $templates->get("announcement_quickdelete") . "\";");
        }
    }
    $post['iplogged'] = '';
    $show_ips = $mybb->settings['logip'];
    //$ipaddress = my_inet_ntop($db->unescape_binary($post['ipaddress']));
    $ipaddress = '127.0.0.1';
    // Show post IP addresses... PMs now can have IP addresses too as of 1.8!
    if ($post_type == 2) {
        $show_ips = $mybb->settings['showpmip'];
    }
    if (!$post_type || $post_type == 2) {
        if ($show_ips != "no" && !empty($post['ipaddress'])) {
            if ($show_ips == "show") {
                eval("\$post['iplogged'] = \"" . $templates->get("postbit_iplogged_show") . "\";");
            } else {
                if ($show_ips == "hide" && (is_moderator($fid, "canviewips") || $mybb->usergroup['issupermod'])) {
                    $action = 'getip';
                    if ($post_type == 2) {
                        $action = 'getpmip';
                    }
                    eval("\$post['iplogged'] = \"" . $templates->get("postbit_iplogged_hiden") . "\";");
                }
            }
        }
    }
    if (isset($post['smilieoff']) && $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;
    }
    // If we have incoming search terms to highlight - get it done.
    if (!empty($mybb->input['highlight'])) {
        $parser_options['highlight'] = $mybb->input['highlight'];
        $post['subject'] = $parser->highlight_message($post['subject'], $parser_options['highlight']);
    }
    $post['message'] = $parser->parse_message($post['message'], $parser_options);
    // Validate key
    $keyinfo = user_key_info($post['uid']);
    $post['signstatus'];
    if ($keyinfo['status'] == "OK") {
        $post['signstatus'] = "<span style=\"color: #07a407;\" title=\"Fingerprint: {$keyinfo['fingerprint']}\">✓ podpisano przez {$post['profilelink']}</span>";
    }
    // Jid link
    $ujid = user_jid($post['uid']);
    $post['jidlink'] = $ujid;
    // User key
    $post['userpubkey'] = $keyinfo['key'];
    if ($keyinfo['key'] != "") {
        eval("\$post['button_pubkey'] = \"" . $templates->get("postbit_pubkey") . "\";");
    } else {
        $post['button_pubkey'];
    }
    $post['attachments'] = '';
    if ($mybb->settings['enableattachments'] != 0) {
        get_post_attachments($id, $post);
    }
    if (isset($post['includesig']) && $post['includesig'] != 0 && $post['username'] && $post['signature'] != "" && ($mybb->user['uid'] == 0 || $mybb->user['showsigs'] != 0) && ($post['suspendsignature'] == 0 || $post['suspendsignature'] == 1 && $post['suspendsigtime'] != 0 && $post['suspendsigtime'] < TIME_NOW) && $usergroup['canusesig'] == 1 && ($usergroup['canusesigxposts'] == 0 || $usergroup['canusesigxposts'] > 0 && $postnum > $usergroup['canusesigxposts']) && !is_member($mybb->settings['hidesignatures'])) {
        $sig_parser = array("allow_html" => $mybb->settings['sightml'], "allow_mycode" => $mybb->settings['sigmycode'], "allow_smilies" => $mybb->settings['sigsmilies'], "allow_imgcode" => $mybb->settings['sigimgcode'], "me_username" => $post['username'], "filter_badwords" => 1);
        if ($usergroup['signofollow']) {
            $sig_parser['nofollow_on'] = 1;
        }
        if ($mybb->user['showimages'] != 1 && $mybb->user['uid'] != 0 || $mybb->settings['guestimages'] != 1 && $mybb->user['uid'] == 0) {
            $sig_parser['allow_imgcode'] = 0;
        }
        $post['signature'] = $parser->parse_message($post['signature'], $sig_parser);
        eval("\$post['signature'] = \"" . $templates->get("postbit_signature") . "\";");
    } else {
        $post['signature'] = "";
    }
    $icon_cache = $cache->read("posticons");
    if (isset($post['icon']) && $post['icon'] > 0 && $icon_cache[$post['icon']]) {
        $icon = $icon_cache[$post['icon']];
        $icon['path'] = htmlspecialchars_uni($icon['path']);
        $icon['path'] = str_replace("{theme}", $theme['imgdir'], $icon['path']);
        $icon['name'] = htmlspecialchars_uni($icon['name']);
        eval("\$post['icon'] = \"" . $templates->get("postbit_icon") . "\";");
    } else {
        $post['icon'] = "";
    }
    $post_visibility = $ignore_bit = '';
    switch ($post_type) {
        case 1:
            // Message preview
            $post = $plugins->run_hooks("postbit_prev", $post);
            break;
        case 2:
            // Private message
            $post = $plugins->run_hooks("postbit_pm", $post);
            break;
        case 3:
            // Announcement
            $post = $plugins->run_hooks("postbit_announcement", $post);
            break;
        default:
            // Regular post
            $post = $plugins->run_hooks("postbit", $post);
            // Is this author on the ignore list of the current user? Hide this post
            if (is_array($ignored_users) && $post['uid'] != 0 && isset($ignored_users[$post['uid']]) && $ignored_users[$post['uid']] == 1) {
                $ignored_message = $lang->sprintf($lang->postbit_currently_ignoring_user, $post['username']);
                eval("\$ignore_bit = \"" . $templates->get("postbit_ignored") . "\";");
                $post_visibility = "display: none;";
            }
            break;
    }
    if ($mybb->settings['postlayout'] == "classic") {
        eval("\$postbit = \"" . $templates->get("postbit_classic") . "\";");
    } else {
        eval("\$postbit = \"" . $templates->get("postbit") . "\";");
    }
    $GLOBALS['post'] = "";
    return $postbit;
}
Ejemplo n.º 23
0
 } else {
     $start = 0;
     $current_page = 1;
 }
 $pagination = draw_admin_pagination($current_page, $per_page, $ban_count, "index.php?module=user-banning&amp;page={page}");
 $table = new Table();
 $table->construct_header($lang->user);
 $table->construct_header($lang->ban_lifts_on, array("class" => "align_center", "width" => 150));
 $table->construct_header($lang->time_left, array("class" => "align_center", "width" => 150));
 $table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 2, "width" => 200));
 $table->construct_header($lang->moderation, array("class" => "align_center", "colspan" => 1, "width" => 200));
 // Fetch bans
 $query = $db->query("\n\t\tSELECT b.*, a.username AS adminuser, u.username\n\t\tFROM " . TABLE_PREFIX . "banned b\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (b.uid=u.uid) \n\t\tLEFT JOIN " . TABLE_PREFIX . "users a ON (b.admin=a.uid) \n\t\tORDER BY lifted ASC\n\t\tLIMIT {$start}, {$per_page}\n\t");
 // Get the banned users
 while ($ban = $db->fetch_array($query)) {
     $profile_link = build_profile_link($ban['username'], $ban['uid'], "_blank");
     $ban_date = my_date($mybb->settings['dateformat'], $ban['dateline']);
     if ($ban['lifted'] == 'perm' || $ban['lifted'] == '' || $ban['bantime'] == 'perm' || $ban['bantime'] == '---') {
         $ban_period = $lang->permenantly;
         $time_remaining = $lifts_on = $lang->na;
     } else {
         $ban_period = $lang->for . " " . $ban_times[$ban['bantime']];
         $remaining = $ban['lifted'] - TIME_NOW;
         $time_remaining = nice_time($remaining, array('short' => 1, 'seconds' => false)) . "";
         if ($remaining < 3600) {
             $time_remaining = "<span style=\"color: red;\">{$time_remaining}</span>";
         } else {
             if ($remaining < 86400) {
                 $time_remaining = "<span style=\"color: maroon;\">{$time_remaining}</span>";
             } else {
                 if ($remaining < 604800) {
Ejemplo n.º 24
0
function firstpreview_pm()
{
    global $mybb, $db, $charset, $headerinclude, $header;
    $header = '<div class="arrow-down"></div>' . $header;
    // Add jQuery and noConflict for MyBB 1.6.*
    $jquery = '';
    $noconflict = '';
    if ($mybb->version < "1.7.0") {
        $jquery = '<script type="text/javascript">
//<![CDATA[
if (!window.jQuery)
{
document.write(unescape("%3Cscript src=\\"http://code.jquery.com/jquery-latest.min.js\\" type=\\"text/javascript\\"%3E%3C/script%3E"));
}
//]]>
</script>';
        $noconflict = 'jQuery.noConflict();';
    }
    // Background color
    $bg_color = '#aaaaaa';
    if (isset($mybb->settings['firstpreview_bg']) && preg_match('/^#([0-9a-f]{1,6})$/i', $mybb->settings['firstpreview_bg'])) {
        $bg_color = htmlspecialchars_uni($mybb->settings['firstpreview_bg']);
    }
    // Close button
    $close_preview = '#close_preview{display:none;cursor:pointer;background:#000;color:#fff;float:right;font-size:1em;font-weight:bold;text-align:center;width:20px;height:20px;border-radius:5px}';
    if (isset($mybb->settings['firstpreview_close']) && $mybb->settings['firstpreview_close'] == 1) {
        $close_preview = '#close_preview{cursor:pointer;background:#000;color:#fff;float:right;font-size:1em;font-weight:bold;text-align:center;width:20px;height:20px;border-radius:5px}';
    }
    // Insert the code
    $headerinclude .= '
	<!-- start: first_preview_plugin -->
	<style type="text/css">
	.modal_firstpost{text-align:left;border-radius:7px;-moz-border-radius:7px;-webkit-border-radius:7px;border:1px solid ' . $bgcolor . ';display:none;position:absolute;z-index:29000;width:390px;height:180px;overflow:hidden}
	.fpreview{z-index:29001;width:390px;height:180px;overflow:auto;background:' . $bg_color . '}
	.arrow-down{display:none;position:absolute;z-index:28999;width:0;height:0;border-left:20px solid transparent;border-right:20px solid transparent;border-top:20px solid ' . $bg_color . '}
	.prev_content{padding:10px;height:auto;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;-ms-hyphens:auto;-o-hyphens:auto;hyphens:auto;background:none}
	' . $close_preview . '
	</style>
	' . $jquery . '
	<script type="text/javascript">
	//<![CDATA[
	' . $noconflict . '
	<!--
	if(use_xmlhttprequest == 1) {
		jQuery(document).ready(function(e){e(".pmprev").on("touchenter mouseenter",function(){id=e(this).attr("id");pmid=id.replace(/[^\\d.]/g,"");var t=e(this).offset().left;var n=e(this).offset().top-200;showPost=setTimeout(function(){e.ajax({url:"private.php?pmid="+pmid+"&firstpm=1",type:"post",complete:function(t){e(".modal_firstpost").html(t.responseText)}});e(".modal_firstpost").fadeIn("slow");e(".modal_firstpost").css("top",n);e(".modal_firstpost").css("left",t);e(".arrow-down").fadeIn("slow");e(".arrow-down").css("top",n+180);e(".arrow-down").css("left",t+20);},1500)});e(".pmprev").on("mouseleave touchleave touchend",function(){clearTimeout(showPost);});e(".modal_firstpost").on("mouseleave touchmove",function(){e(".modal_firstpost").fadeOut("slow");e(".arrow-down").fadeOut("fast")});e(".modal_firstpost").on("click", "#close_preview", function(){e(".modal_firstpost").fadeOut("slow");e(".arrow-down").fadeOut("fast")})});
	}
	//]]>
	</script>
	<!-- end: first_preview_plugin -->
	';
    // Get the pm preview
    if (isset($mybb->input['firstpm']) && $mybb->input['firstpm'] == 1 && $mybb->request_method == "post") {
        $pmid = (int) $mybb->input['pmid'];
        $query = $db->simple_select('privatemessages', '*', "pmid = '" . $pmid . "'");
        $pm = $db->fetch_array($query);
        // Load the users own messages only
        if ($pm['uid'] != $mybb->user['uid']) {
            return;
        }
        require_once MYBB_ROOT . "inc/class_parser.php";
        $parser = new postParser();
        $pm['subject'] = htmlspecialchars_uni($parser->parse_badwords($pm['subject']));
        $user = get_user($pm['fromid']);
        $idtype = 'pmid';
        $parser_options['allow_html'] = $mybb->settings['pmsallowhtml'];
        $parser_options['allow_mycode'] = $mybb->settings['pmsallowmycode'];
        $parser_options['allow_smilies'] = $mybb->settings['pmsallowsmilies'];
        $parser_options['allow_imgcode'] = $mybb->settings['pmsallowimgcode'];
        $parser_options['allow_videocode'] = $mybb->settings['pmsallowvideocode'];
        $parser_options['me_username'] = $user['username'];
        $parser_options['filter_badwords'] = 1;
        $id = $pmid;
        $pm['message'] = $parser->parse_message($pm['message'], $parser_options);
        $pmdate = my_date($mybb->settings['dateformat'], $pm['dateline']);
        $pmtime = my_date($mybb->settings['timeformat'], $pm['dateline']);
        $pmsent = ' (' . $pmdate . ', ' . $pmtime . ')';
        if (isset($mybb->settings['firstpreview_html']) && $mybb->settings['firstpreview_html'] != 1) {
            $pm['message'] = strip_tags($pm['message'], "<br><p><ul><ol><li>");
        }
        if (!empty($mybb->settings['firstpreview_length']) && $mybb->settings['firstpreview_length'] != "0" && my_strlen($pm['message']) > (int) $mybb->settings['firstpreview_length']) {
            $pm['message'] = preg_replace("!<a([^>]+)>!isU", "", $pm['message']);
            $pm['message'] = str_replace("</a>", "", $pm['message']);
            $pm['message'] = my_substr($pm['message'], 0, (int) $mybb->settings['firstpreview_length']) . '...<p><a href="private.php?action=read&amp;pmid=' . (int) $pm['pmid'] . '">more</a></p>';
        }
        $preview = "<div class=\"fpreview\"><span id=\"close_preview\">&#10060;</span>\n\t\t<div class=\"thead\" style=\"text-align:center; font-weight:bold; min-height:20px;\">" . $pm['subject'] . "</div>\n\t\t<div class=\"tcat\" style=\"padding-left:10px;\">" . build_profile_link(format_name(htmlspecialchars_uni($user['username']), (int) $user['usergroup'], (int) $user['displaygroup']), (int) $pm['fromid']) . "<span class=\"smalltext\">" . $pmsent . "</span></div>\n\t\t<div class=\"prev_content\">" . $pm['message'] . "</div>\n\t\t</div>";
        header("Content-type: text/plain; charset={$charset}");
        echo $preview;
        exit;
    }
}
Ejemplo n.º 25
0
         } else {
             $tofromusername = $lang->not_sent;
         }
     }
 } else {
     $tofromusername = $message['fromusername'];
     $tofromuid = $message['fromid'];
     if ($tofromuid == 0) {
         $tofromusername = $lang->mybb_engine;
     }
     if (!$tofromusername) {
         $tofromuid = 0;
         $tofromusername = $lang->na;
     }
 }
 $tofromusername = build_profile_link($tofromusername, $tofromuid);
 if ($mybb->usergroup['candenypmreceipts'] == 1 && $message['receipt'] == '1' && $message['folder'] != '3' && $message['folder'] != 2) {
     eval("\$denyreceipt = \"" . $templates->get("private_messagebit_denyreceipt") . "\";");
 } else {
     $denyreceipt = '';
 }
 if ($message['icon'] > 0 && $icon_cache[$message['icon']]) {
     $icon = $icon_cache[$message['icon']];
     $icon['path'] = str_replace("{theme}", $theme['imgdir'], $icon['path']);
     $icon['path'] = htmlspecialchars_uni($icon['path']);
     $icon['name'] = htmlspecialchars_uni($icon['name']);
     eval("\$icon = \"" . $templates->get("private_messagebit_icon") . "\";");
 } else {
     $icon = '&#009;';
 }
 if (!trim($message['subject'])) {
Ejemplo n.º 26
0
function newpoints_shop_admin_stats()
{
    global $form, $db, $lang, $mybb;
    newpoints_lang_load("newpoints_shop");
    echo "<br />";
    // table
    $table = new Table();
    $table->construct_header($lang->newpoints_shop_item, array('width' => '30%'));
    $table->construct_header($lang->newpoints_shop_username, array('width' => '30%'));
    $table->construct_header($lang->newpoints_shop_price, array('width' => '20%', 'class' => 'align_center'));
    $table->construct_header($lang->newpoints_shop_date, array('width' => '20%', 'class' => 'align_center'));
    $query = $db->simple_select('newpoints_log', '*', 'action=\'shop_purchase\'', array('order_by' => 'date', 'order_dir' => 'DESC', 'limit' => intval($mybb->settings['newpoints_shop_lastpurchases'])));
    while ($stats = $db->fetch_array($query)) {
        $data = explode('-', $stats['data']);
        $item = newpoints_shop_get_item($data[0]);
        $table->construct_cell(htmlspecialchars_uni($item['name']));
        $link = build_profile_link(htmlspecialchars_uni($stats['username']), intval($stats['uid']));
        $table->construct_cell($link);
        $table->construct_cell(newpoints_format_points($data[1]), array('class' => 'align_center'));
        $table->construct_cell(my_date($mybb->settings['dateformat'], intval($stats['date']), '', false) . ", " . my_date($mybb->settings['timeformat'], intval($stats['date'])), array('class' => 'align_center'));
        $table->construct_row();
    }
    if ($table->num_rows() == 0) {
        $table->construct_cell($lang->newpoints_error_gathering, array('colspan' => 4));
        $table->construct_row();
    }
    $table->output($lang->newpoints_stats_lastpurchases);
}
 } else {
     $start = 0;
     $pagecnt = 1;
 }
 $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->information, array('class' => 'align_center', 'width' => '65%'));
 $table->construct_header($lang->ipaddress, array('class' => 'align_center', 'width' => '10%'));
 $query = $db->query("\n\t\tSELECT l.*, u.username, u.usergroup, u.displaygroup\n\t\tFROM " . TABLE_PREFIX . "adminlog l\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=l.uid)\n\t\tWHERE 1=1 {$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'], "_blank");
     $logitem['data'] = unserialize($logitem['data']);
     // Get detailed information from meta
     $information = get_admin_log_action($logitem);
     $table->construct_cell($logitem['profilelink']);
     $table->construct_cell($logitem['dateline'], 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) {
     $table->construct_cell($lang->no_adminlogs, array('colspan' => '4'));
     $table->construct_row();
 }
 $table->output($lang->admin_logs);
 // Do we need to construct the pagination?
Ejemplo n.º 28
0
     default:
         $query = $db->query("\n\t\t\t\tSELECT g.gid, COUNT(u.uid) AS users\n\t\t\t\tFROM " . TABLE_PREFIX . "users u\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "usergroups g ON (CONCAT(',', u.additionalgroups, ',') LIKE CONCAT('%,', g.gid, ',%'))\n\t\t\t\tWHERE g.gid != '0' AND g.gid is not NULL GROUP BY g.gid\n\t\t\t");
 }
 while ($groupcount = $db->fetch_array($query)) {
     $secondaryusers[$groupcount['gid']] = $groupcount['users'];
 }
 $query = $db->query("\n\t\tSELECT g.gid, COUNT(r.uid) AS users\n\t\tFROM " . TABLE_PREFIX . "joinrequests r\n\t\tLEFT JOIN " . TABLE_PREFIX . "usergroups g ON (g.gid=r.gid)\n\t\tGROUP BY g.gid\n\t");
 $joinrequests = array();
 while ($joinrequest = $db->fetch_array($query)) {
     $joinrequests[$joinrequest['gid']] = $joinrequest['users'];
 }
 // Fetch group leaders
 $leaders = array();
 $query = $db->query("\n\t\tSELECT u.username, u.uid, l.gid\n\t\tFROM " . TABLE_PREFIX . "groupleaders l\n\t\tINNER JOIN " . TABLE_PREFIX . "users u ON (u.uid=l.uid)\n\t\tORDER BY u.username ASC\n\t");
 while ($leader = $db->fetch_array($query)) {
     $leaders[$leader['gid']][] = build_profile_link($leader['username'], $leader['uid'], "_blank");
 }
 $form_container = new FormContainer($lang->user_groups);
 $form_container->output_row_header($lang->group);
 $form_container->output_row_header($lang->number_of_users, array("class" => "align_center", 'width' => '75'));
 $form_container->output_row_header($lang->order, array("class" => "align_center", 'width' => '5%'));
 $form_container->output_row_header($lang->controls, array("class" => "align_center"));
 $query = $db->simple_select("usergroups", "*", "", array('order_by' => 'disporder'));
 while ($usergroup = $db->fetch_array($query)) {
     if ($usergroup['type'] > 1) {
         $icon = "<img src=\"styles/default/images/icons/custom.png\" alt=\"{$lang->custom_user_group}\" style=\"vertical-align: middle;\" />";
     } else {
         $icon = "<img src=\"styles/default/images/icons/default.png\" alt=\"{$lang->default_user_group}\" style=\"vertical-align: middle;\" />";
     }
     $leaders_list = '';
     if (isset($leaders[$usergroup['gid']])) {
Ejemplo n.º 29
0
         exit;
     }
 } else {
     if ($mybb->input['action'] == "get_buddyselect") {
         // Send our headers.
         header("Content-type: text/plain; charset={$charset}");
         if ($mybb->user['buddylist'] != "") {
             $query_options = array("order_by" => "username", "order_dir" => "asc");
             $plugins->run_hooks("xmlhttp_get_buddyselect_start");
             $timecut = TIME_NOW - $mybb->settings['wolcutoff'];
             $query = $db->simple_select("users", "uid, username, usergroup, displaygroup, lastactive, lastvisit, invisible", "uid IN ({$mybb->user['buddylist']})", $query_options);
             $online = array();
             $offline = array();
             while ($buddy = $db->fetch_array($query)) {
                 $buddy_name = format_name($buddy['username'], $buddy['usergroup'], $buddy['displaygroup']);
                 $profile_link = build_profile_link($buddy_name, $buddy['uid'], '_blank');
                 if ($buddy['lastactive'] > $timecut && ($buddy['invisible'] == 0 || $mybb->user['usergroup'] == 4) && $buddy['lastvisit'] != $buddy['lastactive']) {
                     eval("\$online[] = \"" . $templates->get("xmlhttp_buddyselect_online") . "\";");
                 } else {
                     eval("\$offline[] = \"" . $templates->get("xmlhttp_buddyselect_offline") . "\";");
                 }
             }
             $online = implode("", $online);
             $offline = implode("", $offline);
             $plugins->run_hooks("xmlhttp_get_buddyselect_end");
             eval("\$buddy_select = \"" . $templates->get("xmlhttp_buddyselect") . "\";");
             echo $buddy_select;
         } else {
             xmlhttp_error($lang->buddylist_error);
         }
     }
Ejemplo n.º 30
0
/**
 * Build a Who's Online row for a specific user
 *
 * @param array Array of user information including activity information
 * @return string Formatted online row
 */
function build_wol_row($user)
{
    global $mybb, $lang, $templates, $theme, $session, $db;
    // We have a registered user
    if ($user['uid'] > 0) {
        // Only those with "canviewwolinvis" permissions can view invisible users
        if ($user['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid']) {
            // Append an invisible mark if the user is invisible
            if ($user['invisible'] == 1) {
                $invisible_mark = "*";
            } else {
                $invisible_mark = '';
            }
            $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
            $online_name = build_profile_link($user['username'], $user['uid']) . $invisible_mark;
        }
    } elseif (!empty($user['bot'])) {
        $online_name = format_name($user['bot'], $user['usergroup']);
    } else {
        $online_name = format_name($lang->guest, 1);
    }
    $online_time = my_date($mybb->settings['timeformat'], $user['time']);
    // Fetch the location name for this users activity
    $location = build_friendly_wol_location($user['activity']);
    // Can view IPs, then fetch the IP template
    if ($mybb->usergroup['canviewonlineips'] == 1) {
        $user['ip'] = my_inet_ntop($db->unescape_binary($user['ip']));
        if ($mybb->usergroup['canmodcp'] == 1 && $mybb->usergroup['canuseipsearch'] == 1) {
            eval("\$lookup = \"" . $templates->get("online_row_ip_lookup") . "\";");
        }
        eval("\$user_ip = \"" . $templates->get("online_row_ip") . "\";");
    } else {
        $user_ip = $lookup = $user['ip'] = '';
    }
    // And finally if we have permission to view this user, return the completed online row
    if ($user['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid']) {
        eval("\$online_row = \"" . $templates->get("online_row") . "\";");
    }
    return $online_row;
}