Exemplo 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;
}
Exemplo n.º 2
0
 static function Format($uid, $username, $userGroup, $displayGroup)
 {
     global $mybb;
     $formattedName = format_name($username, $userGroup, $displayGroup);
     $profileUrl = $mybb->settings['bburl'] . "/member.php?action=profile&uid=" . $uid;
     return "<a href=\"{$profileUrl}\">{$formattedName}</a>";
 }
 /**
 This is where you perform the action when the API is called, the parameter given is an instance of stdClass, this method should return an instance of stdClass.
 */
 public function action()
 {
     global $mybb, $db, $cache;
     require_once MYBB_ROOT . "inc/functions_online.php";
     $timesearch = TIME_NOW - $mybb->settings['wolcutoffmins'] * 60;
     switch ($db->type) {
         case "sqlite":
             $sessions = array();
             $query = $db->simple_select("sessions", "sid", "time > {$timesearch}");
             while ($sid = $db->fetch_field($query, "sid")) {
                 $sessions[$sid] = 1;
             }
             $online_count = count($sessions);
             unset($sessions);
             break;
         case "pgsql":
         default:
             $query = $db->simple_select("sessions", "COUNT(sid) as online", "time > {$timesearch}");
             $online_count = $db->fetch_field($query, "online");
             break;
     }
     $query = $db->query("\n\t\t\tSELECT DISTINCT s.sid, s.ip, s.uid, s.time, s.location, u.username, s.nopermission, u.invisible, u.usergroup, u.displaygroup\n\t\t\tFROM " . TABLE_PREFIX . "sessions s\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (s.uid=u.uid)\n\t\t\tWHERE s.time>'{$timesearch}'\n\t\t\t");
     //ORDER BY $sql
     //	LIMIT {$start}, {$perpage}
     $users = array();
     $guests = array();
     $spiders = $cache->read("spiders");
     while ($user = $db->fetch_array($query)) {
         // Fetch the WOL activity
         $user['activity'] = fetch_wol_activity($user['location'], $user['nopermission']);
         $botkey = my_strtolower(str_replace("bot=", '', $user['sid']));
         // Have a registered user
         if ($user['uid'] > 0) {
             if ($users[$user['uid']]['time'] < $user['time'] || !$users[$user['uid']]) {
                 $users[$user['uid']] = $user;
             }
         } else {
             if (my_strpos($user['sid'], "bot=") !== false && $spiders[$botkey]) {
                 $user['bot'] = $spiders[$botkey]['name'];
                 $user['usergroup'] = $spiders[$botkey]['usergroup'];
                 $guests[] = $user;
             } else {
                 $guests[] = $user;
             }
         }
     }
     foreach ($users as &$user) {
         $user["display"] = format_name($user["username"], $user["usergroup"], $user["displaygroup"]);
     }
     $stdClass = new stdClass();
     // remove keys from this otherwise we will get an object of objects, sigh!
     $stdClass->users = array_values($users);
     $stdClass->guests = $guests;
     $stdClass->count = $online_count;
     $stdClass->wolcutoffmins = $mybb->settings["wolcutoffmins"];
     $stdClass->mostonline = $cache->read("mostonline");
     return $stdClass;
 }
function get_recommended_user_func()
{
    global $mybb, $db, $lang, $users, $tapatalk_users;
    $tapatalk_users = array();
    $users = array();
    // Load global language phrases
    $lang->load("memberlist");
    //get tapatalk users
    if (isset($_POST['mode']) && $_POST['mode'] == 2) {
        $sql = "SELECT userid FROM " . TABLE_PREFIX . "tapatalk_users";
        $query = $db->query($sql);
        while ($user = $db->fetch_array($query)) {
            $tapatalk_users[] = $user['userid'];
        }
    }
    // get pm users
    $sql = "SELECT p.toid as uid\n\tFROM " . TABLE_PREFIX . "privatemessages p \n\tWHERE p.uid = " . $mybb->user['uid'] . "\n\tGROUP BY p.toid\n\tLIMIT 0,1000";
    get_recommended_user_list($sql, 'contact');
    // get pm me users
    $sql = "SELECT p.uid as uid\n\tFROM " . TABLE_PREFIX . "privatemessages p \n\tWHERE p.toid = " . $mybb->user['uid'] . "\n\tGROUP BY p.uid\n\tLIMIT 0,1000";
    get_recommended_user_list($sql, 'contact');
    //get sub topic users
    $sql = "SELECT t.uid as uid\n\tFROM " . TABLE_PREFIX . "threadsubscriptions ts \n\tLEFT JOIN " . TABLE_PREFIX . "threads t ON ts.tid = t.tid \n\tWHERE ts.uid = " . $mybb->user['uid'] . "\n\tGROUP BY t.uid\n\tLIMIT 0,1000";
    get_recommended_user_list($sql, 'watch');
    //get sub me topic users
    $sql = "SELECT ts.uid as uid\n\tFROM " . TABLE_PREFIX . "threadsubscriptions ts \n\tRIGHT JOIN " . TABLE_PREFIX . "threads t ON ts.tid = t.tid \n\tWHERE t.uid = " . $mybb->user['uid'] . "\n\tGROUP BY ts.uid\n\tLIMIT 0,1000";
    get_recommended_user_list($sql, 'watch');
    //get like or thank users
    $prefix = "g33k_thankyoulike_";
    if (file_exists('thankyoulike.php') && $db->table_exists($prefix . 'thankyoulike')) {
        $sql = "SELECT thl.puid as uid\n\t\tFROM " . TABLE_PREFIX . $prefix . "thankyoulike thl \n\t\tWHERE thl.uid = " . $mybb->user['uid'] . "\n\t\tGROUP BY thl.puid\n\t\tLIMIT 0,1000";
        get_recommended_user_list($sql, 'like');
        $sql = "SELECT thl.uid as uid\n\t\tFROM " . TABLE_PREFIX . $prefix . "thankyoulike thl \n\t\tWHERE thl.puid = " . $mybb->user['uid'] . "\n\t\tGROUP BY thl.uid\n\t\tLIMIT 0,1000";
        get_recommended_user_list($sql, 'liked');
    }
    $page = intval($_POST['page']);
    $perpage = intval($_POST['perpage']);
    $start = ($page - 1) * $perpage;
    $return_user_lists = array();
    $users_rank = tapa_rank_users($users);
    $total = count($users_rank);
    $users_slice = array_slice($users_rank, $start, $perpage);
    $user_id_str = implode(',', $users_slice);
    $mobi_api_key = loadAPIKey();
    if (!empty($user_id_str)) {
        $sql = "SELECT uid,username,email,avatar FROM " . TABLE_PREFIX . "users WHERE uid IN({$user_id_str})";
        $query = $db->query($sql);
        while ($user = $db->fetch_array($query)) {
            $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
            if ($user['avatar'] != '') {
                $user['avatar'] = absolute_url($user['avatar']);
            }
            $return_user_lists[] = new xmlrpcval(array('username' => new xmlrpcval(basic_clean($user['username']), 'base64'), 'user_id' => new xmlrpcval($user['uid'], 'string'), 'icon_url' => new xmlrpcval($user['avatar'], 'string'), 'type' => new xmlrpcval('', 'string'), 'enc_email' => new xmlrpcval(base64_encode(encrypt(trim($user['email']), $mobi_api_key)), 'string')), 'struct');
        }
    }
    $suggested_users = new xmlrpcval(array('total' => new xmlrpcval($total, 'int'), 'list' => new xmlrpcval($return_user_lists, 'array')), 'struct');
    return new xmlrpcresp($suggested_users);
}
Exemplo n.º 5
0
function post_list()
{
    $posts = scandir("posts/");
    $posts = array_diff($posts, array("..", "."));
    $postDates = array();
    foreach ($posts as $thisPost) {
        $postDates[] = filectime("posts/" . $thisPost);
    }
    $posts = array_combine($postDates, $posts);
    krsort($posts);
    $output = "\n\t<ul id=\"posts\">";
    foreach ($posts as $thisPost) {
        $output .= "\n\t\t<li><a href=\"" . URL . BLOG_DIR . "/post/" . link_name($thisPost) . "\">" . date("Y-m-d", key($posts)) . " - " . format_name($thisPost) . "</a></li>";
    }
    $output .= "\n\t</ul>";
    return $output;
}
Exemplo n.º 6
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;
}
     $start = ($pagecnt - 1) * $perpage;
 } 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);
Exemplo n.º 8
0
         }
         if ($customfieldval) {
             $customfield['name'] = htmlspecialchars_uni($customfield['name']);
             eval("\$customfields .= \"" . $templates->get("member_profile_customfields_field") . "\";");
             $bgcolor = alt_trow();
         }
     }
 }
 if ($customfields) {
     eval("\$profilefields = \"" . $templates->get("member_profile_customfields") . "\";");
 }
 $memprofile['postnum'] = my_number_format($memprofile['postnum']);
 $lang->ppd_percent_total = $lang->sprintf($lang->ppd_percent_total, my_number_format($ppd), $post_percent);
 $memprofile['threadnum'] = my_number_format($memprofile['threadnum']);
 $lang->tpd_percent_total = $lang->sprintf($lang->tpd_percent_total, my_number_format($tpd), $thread_percent);
 $formattedname = format_name($memprofile['username'], $memprofile['usergroup'], $memprofile['displaygroup']);
 $bannedbit = '';
 if ($memperms['isbannedgroup'] == 1 && $mybb->usergroup['canbanusers'] == 1) {
     // Fetch details on their ban
     $query = $db->simple_select('banned b LEFT JOIN ' . TABLE_PREFIX . 'users a ON (b.admin=a.uid)', 'b.*, a.username AS adminuser', "b.uid='{$uid}'", array('limit' => 1));
     $memban = $db->fetch_array($query);
     if ($memban['reason']) {
         $memban['reason'] = htmlspecialchars_uni($parser->parse_badwords($memban['reason']));
     } else {
         $memban['reason'] = $lang->na;
     }
     if ($memban['lifted'] == 'perm' || $memban['lifted'] == '' || $memban['bantime'] == 'perm' || $memban['bantime'] == '---') {
         $banlength = $lang->permanent;
         $timeremaining = $lang->na;
     } else {
         // Set up the array of ban times.
    static function render_shout($data, $static = false)
    {
        global $mybb, $lang;
        $id = $data['id'];
        $text = $data['text'];
        $date = my_date($mybb->settings['dvz_sb_dateformat'], $data['date']);
        if ($uid = self::isPvt($text)) {
            if ($uid != $mybb->user['uid'] && $data['username'] != $mybb->user['username']) {
                return;
            }
            $replace = array("/pvt", $uid);
            $lang->load('custom');
            $usernameString = self::getUsername($uid, $data);
            $text = str_replace($replace, "", $text);
        }
        $text = dvz_shoutbox::parse($text, $data['username']);
        if ($usernameString) {
            $replace = array('<p>', '</p>');
            $text = $usernameString . str_replace($replace, "", $text);
        }
        $avatar = '<a href="/member.php?action=profile&' . $data['uid'] . '"><img src="' . (empty($data['avatar']) ? 'images/default_avatar.png' : $data['avatar']) . '" alt="avatar" /></a>';
        $user = '******' . (int) $data['uid'] . '"><a>' . format_name($data['username'], $data['usergroup'], $data['displaygroup']) . '</a></span>';
        $notes = null;
        $attributes = null;
        $own = $data['uid'] == $mybb->user['uid'];
        if ($static) {
            if (dvz_shoutbox::access_mod()) {
                $notes .= '<span class="ip">' . $data['ip'] . '</span>';
            }
            if (dvz_shoutbox::access_mod() || dvz_shoutbox::access_mod_own() && $own) {
                $notes .= '<a href="" class="mod edit">E</a><a href="" class="mod del">X</a>';
            }
        }
        if (dvz_shoutbox::access_mod() || dvz_shoutbox::access_mod_own() && $own) {
            $attributes .= ' data-mod';
        }
        if ($own) {
            $attributes .= ' data-own';
        }
        $notes .= '<a href="" class="mod report">REPORT</a>';
        return '
<div class="entry" data-id="' . $id . '" data-username="******"' . $attributes . '>
    <div class="avatar">' . $avatar . '</div>
    <div class="user">' . $user . ':</div>
    <div class="text">' . $text . '</div>
    <div class="info"><span class="date">' . $date . '</span>' . $notes . '</div>
</div>';
    }
Exemplo n.º 10
0
 $table->construct_header($lang->date_issued, array("class" => "align_center", 'width' => '20%'));
 $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'];
Exemplo n.º 11
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;
}
Exemplo n.º 12
0
     }
     if (!$event['starimage']) {
         $event['starimage'] = $user_usergroup['starimage'];
     }
     for ($i = 0; $i < $post['stars']; ++$i) {
         $event['userstars'] .= "<img src=\"" . $event['starimage'] . "\" border=\"0\" alt=\"*\" />";
     }
     if ($event['userstars'] && $event['starimage'] && $event['stars']) {
         $event['userstars'] .= "<br />";
     }
 } else {
     if (!$event['username']) {
         $event['username'] = $lang->guest;
     }
     $event['username'] = $event['username'];
     $event['profilelink'] = format_name($event['username'], 1);
     if ($user_usergroup['usertitle']) {
         $event['usertitle'] = $user_usergroup['usertitle'];
     } else {
         $event['usertitle'] = $lang->guest;
     }
 }
 if ($event['ignoretimezone'] == 0) {
     $offset = $event['timezone'];
 } else {
     $offset = $mybb->user['timezone'];
 }
 $event['starttime_user'] = $event['starttime'] + $offset * 3600;
 // Events over more than one day
 $time_period = '';
 if ($event['endtime'] > 0 && $event['endtime'] != $event['starttime']) {
Exemplo n.º 13
0
						<div class="assign-to-popup hide">
							<a href="" class="close action toggler"><span class="replace">close</span></a>
							<p class="popup-label">Assign to</p>
							<ul class="assign-user-list">
								<?php 
                foreach ($active_users as $u) {
                    ?>
								<li class="<?php 
                    echo $u->id == $item['assigned'] ? 'assigned ' : '';
                    ?>
user"><a rel="<?php 
                    echo $u->id;
                    ?>
" href=""><?php 
                    echo format_name($u) . ' (' . format_name_as_initials($u) . ')';
                    ?>
</a></li>
								<?php 
                }
                ?>
							</ul>
						</div>

						<?php 
            }
            ?>
						<?php 
        }
        ?>
Exemplo n.º 14
0
 public function buddylist_process($buddylist, $count, $memprofile, $limit, $page)
 {
     global $lang, $templates, $settings, $mybb, $theme;
     MyProfileUtils::lang_load_myprofile();
     if (count($buddylist) == 0) {
         /* show them we've got no friends :( */
         $count_friends_text = $lang->sprintf($lang->mp_buddylist_no_friend, $memprofile["username"]);
         $count_colspan = 1;
     } else {
         $count_friends_text = $lang->sprintf($lang->mp_buddylist_friends, $memprofile["username"], $count, count($buddylist));
         $count_colspan = 4;
         $buddylist_content = "";
         for ($col = 0; $col < count($buddylist); $col += 4) {
             $row_content = "";
             for ($row = 0; $row < 4; $row++) {
                 if (isset($buddylist[$col + $row])) {
                     $buddy = $buddylist[$col + $row];
                     $td_class = alt_trow();
                     $profile_link = get_profile_link($buddy["uid"]);
                     list($avatar_src, $avatar_width_height) = array_values(format_avatar($buddy["avatar"], $buddy["avatardimensions"], $settings["mpbuddylistavatarmaxdimensions"]));
                     $username = format_name(htmlspecialchars_uni($buddy["username"]), $buddy["usergroup"], $buddy["displaygroup"]);
                     eval("\$row_content .= \"" . $templates->get('myprofile_buddylist_buddy') . "\";");
                 } else {
                     $td_class = alt_trow();
                     $td_colspan = 4 - $row;
                     $td_width = $td_colspan * 20;
                     eval("\$row_content .= \"" . $templates->get('myprofile_buddylist_spacer') . "\";");
                     break;
                 }
             }
             eval("\$buddylist_content .= \"" . $templates->get('myprofile_buddylist_row') . "\";");
         }
     }
     $buddylist_pagination = multipage($count, $limit, $page, "javascript:MyProfile.buddylistLoadPage({page});");
     if ($buddylist_pagination == null) {
         $buddylist_pagination_style = 'style="display: none;"';
     }
     eval("\$buddylist_count .= \"" . $templates->get('myprofile_buddylist_buddy_count') . "\";");
     eval("\$myprofile_buddylist .= \"" . $templates->get('myprofile_buddylist', 1, 0) . "\";");
     return array("html" => $myprofile_buddylist, "count" => $count, "shown" => count($buddylist));
 }
Exemplo n.º 15
0
function teamonline_show()
{
    global $cache, $groupscache, $db, $mybb, $teamonline, $lang, $theme, $templates, $online;
    $lang->load('teamonline');
    if ($mybb->settings['teamonline_gid']) {
        $gid = " IN (" . $mybb->settings['teamonline_gid'] . ")";
        $timesearch = TIME_NOW - $mybb->settings['wolcutoffmins'] * 60;
        $teamonline_row = '';
        $trowbg = alt_trow();
        $query = $db->query("\n\t\t\tSELECT s.sid, s.ip, s.uid, u.username, s.time, u.avatar, u.usergroup, u.displaygroup, u.invisible\n\t\t\tFROM " . TABLE_PREFIX . "sessions s\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (s.uid=u.uid)\n\t\t\tWHERE u.usergroup {$gid} AND time>'{$timesearch}'\n\t\t\tORDER BY u.username ASC, s.time DESC\n\t\t\t");
        if (!$db->num_rows($query)) {
            eval("\$teamonline_no = \"" . $templates->get("teamonline_no") . "\";");
            $invisible = 0;
            $membercount = 0;
        } else {
            if (!is_array($groupscache)) {
                $groupscache = $cache->read("usergroups");
            }
            while ($online = $db->fetch_array($query)) {
                $invisible_mark = '';
                if ($online['invisible'] == 1) {
                    $invisible_mark = '*';
                }
                if ($online['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $online['uid'] == $mybb->user['uid']) {
                    $avatar_teamonline = format_avatar($online['avatar']);
                    $online['username'] = format_name($online['username'], $online['usergroup'], $online['displaygroup']);
                    $online['profilelink'] = build_profile_link($online['username'], $online['uid']) . $invisible_mark;
                    $online['groupname'] = $groupscache[$online['usergroup']]['title'];
                    eval("\$teamonline_row .= \"" . $templates->get("teamonline_row") . "\";");
                }
                $invisible += $online['invisible'];
                $membercount++;
            }
        }
        eval("\$teamonline = \"" . $templates->get("teamonline") . "\";");
    }
}
Exemplo n.º 16
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;
}
Exemplo n.º 17
0
     // We still have birthdays - display them in our list!
     if (!empty($today_bdays)) {
         foreach ($today_bdays as $bdayuser) {
             if ($bdayuser['displaygroup'] == 0) {
                 $bdayuser['displaygroup'] = $bdayuser['usergroup'];
             }
             // If this user's display group can't be seen in the birthday list, skip it
             if ($groupscache[$bdayuser['displaygroup']] && $groupscache[$bdayuser['displaygroup']]['showinbirthdaylist'] != 1) {
                 continue;
             }
             $age = '';
             $bday = explode('-', $bdayuser['birthday']);
             if ($year > $bday['2'] && $bday['2'] != '') {
                 $age = ' (' . ($year - $bday['2']) . ')';
             }
             $bdayuser['username'] = format_name($bdayuser['username'], $bdayuser['usergroup'], $bdayuser['displaygroup']);
             $bdayuser['profilelink'] = build_profile_link($bdayuser['username'], $bdayuser['uid']);
             eval('$bdays .= "' . $templates->get('index_birthdays_birthday', 1, 0) . '";');
             ++$bdaycount;
             $comma = $lang->comma;
         }
     }
 }
 if ($hiddencount > 0) {
     if ($bdaycount > 0) {
         $bdays .= ' - ';
     }
     $bdays .= "{$hiddencount} {$lang->birthdayhidden}";
 }
 // If there are one or more birthdays, show them.
 if ($bdaycount > 0 || $hiddencount > 0) {
Exemplo n.º 18
0
        $start = ($mybb->input['page'] - 1) * $limit;
    } else {
        $start = 0;
        $mybb->input['page'] = 1;
    }
    $query = $db->simple_select('ougc_awards_users au LEFT JOIN ' . TABLE_PREFIX . 'users u ON (u.uid=au.uid)', 'au.*, u.username, u.usergroup, u.displaygroup', 'au.aid=\'' . (int) $award['aid'] . '\'', array('limit_start' => $start, 'limit' => $limit));
    if (!$db->num_rows($query)) {
        $table->construct_cell('<div align="center">' . $lang->ougc_awards_users_empty . '</div>', array('colspan' => 6));
        $table->construct_row();
        $table->output($sub_tabs['ougc_awards_users']['description']);
    } else {
        $query2 = $db->simple_select('ougc_awards_users', 'COUNT(uid) AS users', 'aid=\'' . (int) $award['aid'] . '\'');
        $givedscount = (int) $db->fetch_field($query2, 'users');
        echo draw_admin_pagination($mybb->input['page'], $limit, $givedscount, $view['url'] . 'index.php?module=user-ougc_awards&amp;action=users&amp;aid=' . $award['aid']);
        while ($gived = $db->fetch_array($query)) {
            $gived['username'] = format_name(htmlspecialchars_uni($gived['username']), $gived['usergroup'], $gived['displaygroup']);
            $table->construct_cell("<a href=\"index.php?module=user-users&action=edit&uid={$gived['uid']}\">{$gived['username']}</a>");
            $table->construct_cell(htmlspecialchars_uni($gived['reason']));
            $table->construct_cell($lang->sprintf($lang->ougc_awards_users_time, my_date($mybb->settings['dateformat'], intval($gived['date'])), my_date($mybb->settings['timeformat'], intval($gived['date']))), array('class' => 'align_center'));
            $table->construct_cell("<a href=\"index.php?module=user-ougc_awards&amp;action=user&amp;aid={$gived['aid']}&amp;uid={$gived['uid']}\">{$lang->ougc_awards_tab_edit}</a>", array('class' => 'align_center'));
            $table->construct_row();
        }
        $table->output($sub_tabs['ougc_awards_users']['description']);
    }
    $page->output_footer();
} elseif ($mybb->get_input('action') == 'user') {
    if (!($award = $awards->get_award($mybb->input['aid']))) {
        $awards->admin_redirect($lang->ougc_awards_error_invaliduser, true);
    }
    $awards->set_url(array('action' => 'user', 'aid' => $award['aid']));
    if (!($gived = $awards->get_gived_award($award['aid'], $mybb->get_input('uid', 1)))) {
Exemplo n.º 19
0
function search_user_func()
{
    global $mybb, $db, $lang, $cache;
    // Load global language phrases
    $lang->load("memberlist");
    if ($mybb->settings['enablememberlist'] == 0) {
        return xmlrespfalse($lang->memberlist_disabled);
    }
    //$plugins->run_hooks("memberlist_start");
    if ($mybb->usergroup['canviewmemberlist'] == 0) {
        return tt_no_permission();
    }
    $colspan = 5;
    $search_url = '';
    // Incoming sort field?
    $mybb->input['sort'] = $mybb->settings['default_memberlist_sortby'];
    switch ($mybb->input['sort']) {
        case "regdate":
            $sort_field = "u.regdate";
            break;
        case "lastvisit":
            $sort_field = "u.lastactive";
            break;
        case "reputation":
            $sort_field = "u.reputation";
            break;
        case "postnum":
            $sort_field = "u.postnum";
            break;
        case "referrals":
            $sort_field = "u.referrals";
            break;
        default:
            $sort_field = "u.username";
            $mybb->input['sort'] = 'username';
            break;
    }
    //$sort_selected[$mybb->input['sort']] = " selected=\"selected\"";
    // Incoming sort order?
    $mybb->input['order'] = strtolower($mybb->settings['default_memberlist_order']);
    if ($mybb->input['order'] == "ascending" || !$mybb->input['order'] && $mybb->input['sort'] == 'username') {
        $sort_order = "ASC";
        $mybb->input['order'] = "ascending";
    } else {
        $sort_order = "DESC";
        $mybb->input['order'] = "descending";
    }
    //$order_check[$mybb->input['order']] = " checked=\"checked\"";
    // Incoming results per page?
    $mybb->input['perpage'] = intval($mybb->input['perpage']);
    if ($mybb->input['perpage'] > 0 && $mybb->input['perpage'] <= 500) {
        $per_page = $mybb->input['perpage'];
    } else {
        if ($mybb->settings['membersperpage']) {
            $per_page = $mybb->input['perpage'] = intval($mybb->settings['membersperpage']);
        } else {
            $per_page = $mybb->input['perpage'] = 20;
        }
    }
    $search_query = '1=1';
    // Searching for a matching username
    $search_username = htmlspecialchars_uni(trim($mybb->input['username']));
    if ($search_username != '') {
        $username_like_query = $db->escape_string_like($search_username);
        // Name begins with
        if ($mybb->input['username_match'] == "begins") {
            $search_query .= " AND u.username LIKE '" . $username_like_query . "%'";
        } else {
            $search_query .= " AND u.username LIKE '%" . $username_like_query . "%'";
        }
    }
    $query = $db->simple_select("users u", "COUNT(*) AS users", "{$search_query}");
    $num_users = $db->fetch_field($query, "users");
    $page = intval($mybb->input['page']);
    if ($page && $page > 0) {
        $start = ($page - 1) * $per_page;
    } else {
        $start = 0;
        $page = 1;
    }
    //$search_url = htmlspecialchars_uni($search_url);
    $multipage = multipage($num_users, $per_page, $page, $search_url);
    // Cache a few things
    $usergroups_cache = $cache->read('usergroups');
    $query = $db->simple_select("usertitles", "*", "", array('order_by' => 'posts', 'order_dir' => 'DESC'));
    while ($usertitle = $db->fetch_array($query)) {
        $usertitles_cache[$usertitle['posts']] = $usertitle;
    }
    $query = $db->query("\n\t\tSELECT u.*, f.*\n\t\tFROM " . TABLE_PREFIX . "users u\n\t\tLEFT JOIN " . TABLE_PREFIX . "userfields f ON (f.ufid=u.uid)\n\t\tWHERE {$search_query}\n\t\tORDER BY {$sort_field} {$sort_order}\n\t\tLIMIT {$start}, {$per_page}\n\t");
    while ($user = $db->fetch_array($query)) {
        //$user = $plugins->run_hooks("memberlist_user", $user);
        if (!$user['username']) {
            continue;
        }
        $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
        if ($user['avatar'] != '') {
            $user['avatar'] = absolute_url($user['avatar']);
        } else {
            $user['avatar'] = "";
        }
        $users[] = $user;
    }
    $total = $num_users;
    if (!empty($users)) {
        foreach ($users as $user) {
            $return_user_lists[] = new xmlrpcval(array('username' => new xmlrpcval(basic_clean($user['username']), 'base64'), 'user_id' => new xmlrpcval($user['uid'], 'string'), 'icon_url' => new xmlrpcval($user['avatar'], 'string')), 'struct');
        }
    }
    $suggested_users = new xmlrpcval(array('total' => new xmlrpcval($total, 'int'), 'list' => new xmlrpcval($return_user_lists, 'array')), 'struct');
    return new xmlrpcresp($suggested_users);
}
Exemplo n.º 20
0
function print_eventdetails_html($details, $user)
{
    $mcount = 0;
    foreach ($details['members'] as $key => $value) {
        if (!empty($value['username'])) {
            $uname = " (" . $value['username'] . ")";
        } else {
            $uname = "";
        }
        $memberhtml .= n(8) . "<li class=\"textbox\">" . $value['realname'] . $uname . "</li>\n";
        $mcount++;
    }
    $itemhtml .= n(4) . "<fieldset>\n";
    $itemhtml .= n(6) . "<ul class=\"pageitem\">\n";
    $itemhtml .= n(8) . "<li class=\"textbox\"><span class=\"header\">Event Details</span></li>\n";
    $itemhtml .= n(8) . "<li class=\"textbox\">Event: " . $details['eventname'] . "</li>\n";
    $itemhtml .= n(8) . "<li class=\"textbox\">Description: " . $details['eventdescr'] . "</li>\n";
    $itemhtml .= n(8) . "<li class=\"textbox\">Date: " . $details['event_date'] . "</li>\n";
    $name = format_name($user, $details['organizerusername'], $details['organizerreal']);
    //$itemhtml .= n(8) . "<li class=\"textbox\">Paid by: " . $details['ownerreal'] . $uname . "</li>\n";
    $itemhtml .= n(8) . "<li class=\"textbox\">Submitted by: {$name}</li>\n";
    $itemhtml .= n(8) . "<li class=\"textbox\">Default expense: " . $details['type'] . "</li>\n";
    $itemhtml .= n(8) . "<li class=\"textbox\">Expense total: " . $details['expsum'] . " (" . $details['expcount'] . " expenses)</li>\n";
    $itemhtml .= n(8) . "<li class=\"textbox\"><span class=\"header\">Participants</span></li>\n";
    $itemhtml .= $memberhtml;
    $itemhtml .= n(6) . "</ul>\n";
    $itemhtml .= n(4) . "</fieldset>\n";
    echo $itemhtml;
}
Exemplo n.º 21
0
if ($mybb->input['action'] == "today") {
    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 {
Exemplo n.º 22
0
         $post_reputation[$post['pid']] = $post;
     }
 }
 $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 {
Exemplo n.º 23
0
 if (count($recipients['to']) > 1 || count($recipients['to']) == 1 && isset($recipients['bcc']) && count($recipients['bcc']) > 0) {
     foreach ($recipients['to'] as $uid) {
         $profilelink = get_profile_link($uid);
         $user = $cached_users[$uid];
         $username = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
         if (!$user['username']) {
             $username = $lang->na;
         }
         eval("\$to_users .= \"" . $templates->get("private_multiple_recipients_user") . "\";");
     }
     if (isset($recipients['bcc']) && is_array($recipients['bcc']) && count($recipients['bcc'])) {
         eval("\$bcc_users = \"" . $templates->get("private_multiple_recipients_bcc") . "\";");
         foreach ($recipients['bcc'] as $uid) {
             $profilelink = get_profile_link($uid);
             $user = $cached_users[$uid];
             $username = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
             if (!$user['username']) {
                 $username = $lang->na;
             }
             eval("\$bcc_users .= \"" . $templates->get("private_multiple_recipients_user") . "\";");
         }
     }
     eval("\$tofromusername = \"" . $templates->get("private_multiple_recipients") . "\";");
 } else {
     if ($message['toid']) {
         $tofromusername = $message['tousername'];
         $tofromuid = $message['toid'];
     } else {
         $tofromusername = $lang->not_sent;
     }
 }
Exemplo n.º 24
0
function userlink_big($id, $name, $power)
{
    $fname = format_name($name, $power);
    return "<a href='index.php?showuser={$id}' class='userlink' style='font-size: 12px;{$fname['1']}'>{$fname['0']}</a>";
}
Exemplo n.º 25
0
function build_users_view($view)
{
    global $mybb, $db, $cache, $lang, $user_view_fields, $page;
    $view_title = '';
    if ($view['title']) {
        $title_string = "view_title_{$view['vid']}";
        if ($lang->{$title_string}) {
            $view['title'] = $lang->{$title_string};
        }
        $view_title .= " (" . htmlspecialchars_uni($view['title']) . ")";
    }
    // Build the URL to this view
    if (!isset($view['url'])) {
        $view['url'] = "index.php?module=user-users";
    }
    if (!is_array($view['conditions'])) {
        $view['conditions'] = unserialize($view['conditions']);
    }
    if (!is_array($view['fields'])) {
        $view['fields'] = unserialize($view['fields']);
    }
    if (!is_array($view['custom_profile_fields'])) {
        $view['custom_profile_fields'] = unserialize($view['custom_profile_fields']);
    }
    if (isset($mybb->input['username'])) {
        $view['conditions']['username'] = $mybb->input['username'];
    }
    if ($view['vid']) {
        $view['url'] .= "&amp;vid={$view['vid']}";
    } else {
        // If this is a custom view we need to save everything ready to pass it on from page to page
        global $admin_session;
        if (!$mybb->input['search_id']) {
            $search_id = md5(random_str());
            $admin_session['data']['user_views'][$search_id] = $view;
            update_admin_session('user_views', $admin_session['data']['user_views']);
            $mybb->input['search_id'] = $search_id;
        }
        $view['url'] .= "&amp;search_id=" . htmlspecialchars_uni($mybb->input['search_id']);
    }
    if (isset($mybb->input['username'])) {
        $view['url'] .= "&amp;username="******"&amp;", "&", $view['url'])) {
        update_admin_session('last_users_url', str_replace("&amp;", "&", $view['url']));
    }
    if (isset($view['conditions']['referrer'])) {
        $view['url'] .= "&amp;action=referrers&amp;uid=" . htmlspecialchars_uni($view['conditions']['referrer']);
    }
    // Do we not have any views?
    if (empty($view)) {
        return false;
    }
    $table = new Table();
    // Build header for table based view
    if ($view['view_type'] != "card") {
        foreach ($view['fields'] as $field) {
            if (!$user_view_fields[$field]) {
                continue;
            }
            $view_field = $user_view_fields[$field];
            $field_options = array();
            if ($view_field['width']) {
                $field_options['width'] = $view_field['width'];
            }
            if ($view_field['align']) {
                $field_options['class'] = "align_" . $view_field['align'];
            }
            $table->construct_header($view_field['title'], $field_options);
        }
        $table->construct_header("<input type=\"checkbox\" name=\"allbox\" onclick=\"inlineModeration.checkAll(this);\" />");
        // Create a header for the "select" boxes
    }
    $search_sql = '1=1';
    // Build the search SQL for users
    // List of valid LIKE search fields
    $user_like_fields = array("username", "email", "website", "icq", "aim", "yahoo", "msn", "signature", "usertitle");
    foreach ($user_like_fields as $search_field) {
        if (!empty($view['conditions'][$search_field]) && !$view['conditions'][$search_field . '_blank']) {
            $search_sql .= " AND u.{$search_field} LIKE '%" . $db->escape_string_like($view['conditions'][$search_field]) . "%'";
        } else {
            if (!empty($view['conditions'][$search_field . '_blank'])) {
                $search_sql .= " AND u.{$search_field} != ''";
            }
        }
    }
    // EXACT matching fields
    $user_exact_fields = array("referrer");
    foreach ($user_exact_fields as $search_field) {
        if (!empty($view['conditions'][$search_field])) {
            $search_sql .= " AND u.{$search_field}='" . $db->escape_string($view['conditions'][$search_field]) . "'";
        }
    }
    // LESS THAN or GREATER THAN
    $direction_fields = array("postnum");
    foreach ($direction_fields as $search_field) {
        $direction_field = $search_field . "_dir";
        if (isset($view['conditions'][$search_field]) && ($view['conditions'][$search_field] || $view['conditions'][$search_field] === '0') && $view['conditions'][$direction_field]) {
            switch ($view['conditions'][$direction_field]) {
                case "greater_than":
                    $direction = ">";
                    break;
                case "less_than":
                    $direction = "<";
                    break;
                default:
                    $direction = "=";
            }
            $search_sql .= " AND u.{$search_field}{$direction}'" . $db->escape_string($view['conditions'][$search_field]) . "'";
        }
    }
    // Registration searching
    $reg_fields = array("regdate");
    foreach ($reg_fields as $search_field) {
        if (!empty($view['conditions'][$search_field]) && intval($view['conditions'][$search_field])) {
            $threshold = TIME_NOW - intval($view['conditions'][$search_field]) * 24 * 60 * 60;
            $search_sql .= " AND u.{$search_field} >= '{$threshold}'";
        }
    }
    // IP searching
    $ip_fields = array("regip", "lastip");
    foreach ($ip_fields as $search_field) {
        if (!empty($view['conditions'][$search_field])) {
            // IPv6 IP
            if (strpos($view['conditions'][$search_field], ":") !== false) {
                $view['conditions'][$search_field] = str_replace("*", "%", $view['conditions'][$search_field]);
                $ip_sql = "{$search_field} LIKE '" . $db->escape_string($view['conditions'][$search_field]) . "'";
            } else {
                $ip_range = fetch_longipv4_range($view['conditions'][$search_field]);
                if (!is_array($ip_range)) {
                    $ip_sql = "long{$search_field}='{$ip_range}'";
                } else {
                    $ip_sql = "long{$search_field} > '{$ip_range[0]}' AND long{$search_field} < '{$ip_range[1]}'";
                }
            }
            $search_sql .= " AND {$ip_sql}";
        }
    }
    // Post IP searching
    if (!empty($view['conditions']['postip'])) {
        // IPv6 IP
        if (strpos($view['conditions']['postip'], ":") !== false) {
            $view['conditions']['postip'] = str_replace("*", "%", $view['conditions']['postip']);
            $ip_sql = "ipaddress LIKE '" . $db->escape_string($view['conditions']['postip']) . "'";
        } else {
            $ip_range = fetch_longipv4_range($view['conditions']['postip']);
            if (!is_array($ip_range)) {
                $ip_sql = "longipaddress='{$ip_range}'";
            } else {
                $ip_sql = "longipaddress > '{$ip_range[0]}' AND longipaddress < '{$ip_range[1]}'";
            }
        }
        $ip_uids = array(0);
        $query = $db->simple_select("posts", "uid", $ip_sql);
        while ($uid = $db->fetch_field($query, "uid")) {
            $ip_uids[] = $uid;
        }
        $search_sql .= " AND u.uid IN(" . implode(',', $ip_uids) . ")";
        unset($ip_uids);
    }
    // Custom Profile Field searching
    if ($view['custom_profile_fields']) {
        $userfield_sql = '1=1';
        foreach ($view['custom_profile_fields'] as $column => $input) {
            if (is_array($input)) {
                foreach ($input as $value => $text) {
                    if ($value == $column) {
                        $value = $text;
                    }
                    if ($value == $lang->na) {
                        continue;
                    }
                    if (strpos($column, '_blank') !== false) {
                        $column = str_replace('_blank', '', $column);
                        $userfield_sql .= ' AND ' . $db->escape_string($column) . " != ''";
                    } else {
                        $userfield_sql .= ' AND ' . $db->escape_string($column) . "='" . $db->escape_string($value) . "'";
                    }
                }
            } else {
                if (!empty($input)) {
                    if ($input == $lang->na) {
                        continue;
                    }
                    if (strpos($column, '_blank') !== false) {
                        $column = str_replace('_blank', '', $column);
                        $userfield_sql .= ' AND ' . $db->escape_string($column) . " != ''";
                    } else {
                        $userfield_sql .= ' AND ' . $db->escape_string($column) . " LIKE '%" . $db->escape_string($input) . "%'";
                    }
                }
            }
        }
        if ($userfield_sql != '1=1') {
            $userfield_uids = array(0);
            $query = $db->simple_select("userfields", "ufid", $userfield_sql);
            while ($userfield = $db->fetch_array($query)) {
                $userfield_uids[] = $userfield['ufid'];
            }
            $search_sql .= " AND u.uid IN(" . implode(',', $userfield_uids) . ")";
            unset($userfield_uids);
        }
    }
    // Usergroup based searching
    if (isset($view['conditions']['usergroup'])) {
        if (!is_array($view['conditions']['usergroup'])) {
            $view['conditions']['usergroup'] = array($view['conditions']['usergroup']);
        }
        foreach ($view['conditions']['usergroup'] as $usergroup) {
            $usergroup = intval($usergroup);
            if (!$usergroup) {
                continue;
            }
            switch ($db->type) {
                case "pgsql":
                case "sqlite":
                    $additional_sql .= " OR ','||additionalgroups||',' LIKE '%,{$usergroup},%'";
                    break;
                default:
                    $additional_sql .= "OR CONCAT(',',additionalgroups,',') LIKE '%,{$usergroup},%'";
            }
        }
        $search_sql .= " AND (u.usergroup IN (" . implode(",", array_map('intval', $view['conditions']['usergroup'])) . ") {$additional_sql})";
    }
    // COPPA users only?
    if (isset($view['conditions']['coppa'])) {
        $search_sql .= " AND u.coppauser=1 AND u.usergroup=5";
    }
    // Extra SQL?
    if (isset($view['extra_sql'])) {
        $search_sql .= $view['extra_sql'];
    }
    // Lets fetch out how many results we have
    $query = $db->query("\n\t\tSELECT COUNT(u.uid) AS num_results\n\t\tFROM " . TABLE_PREFIX . "users u\n\t\tWHERE {$search_sql}\n\t");
    $num_results = $db->fetch_field($query, "num_results");
    // No matching results then return false
    if (!$num_results) {
        return false;
    } else {
        if (!$view['perpage']) {
            $view['perpage'] = 20;
        }
        $view['perpage'] = intval($view['perpage']);
        // Establish which page we're viewing and the starting index for querying
        // Establish which page we're viewing and the starting index for querying
        if (!isset($mybb->input['page'])) {
            $mybb->input['page'] = 1;
        } else {
            $mybb->input['page'] = intval($mybb->input['page']);
        }
        if ($mybb->input['page']) {
            $start = ($mybb->input['page'] - 1) * $view['perpage'];
        } else {
            $start = 0;
            $mybb->input['page'] = 1;
        }
        $from_bit = "";
        if (isset($mybb->input['from']) && $mybb->input['from'] == "home") {
            $from_bit = "&amp;from=home";
        }
        switch ($view['sortby']) {
            case "regdate":
            case "lastactive":
            case "postnum":
            case "reputation":
                $view['sortby'] = $db->escape_string($view['sortby']);
                break;
            case "numposts":
                $view['sortby'] = "postnum";
                break;
            case "warninglevel":
                $view['sortby'] = "warningpoints";
                break;
            default:
                $view['sortby'] = "username";
        }
        if ($view['sortorder'] != "desc") {
            $view['sortorder'] = "asc";
        }
        $usergroups = $cache->read("usergroups");
        // Fetch matching users
        $query = $db->query("\n\t\t\tSELECT u.*\n\t\t\tFROM " . TABLE_PREFIX . "users u\n\t\t\tWHERE {$search_sql}\n\t\t\tORDER BY {$view['sortby']} {$view['sortorder']}\n\t\t\tLIMIT {$start}, {$view['perpage']}\n\t\t");
        $users = '';
        while ($user = $db->fetch_array($query)) {
            $comma = $groups_list = '';
            $user['view']['username'] = "******"index.php?module=user-users&amp;action=edit&amp;uid={$user['uid']}\">" . format_name($user['username'], $user['usergroup'], $user['displaygroup']) . "</a>";
            $user['view']['usergroup'] = htmlspecialchars_uni($usergroups[$user['usergroup']]['title']);
            if ($user['additionalgroups']) {
                $additional_groups = explode(",", $user['additionalgroups']);
                foreach ($additional_groups as $group) {
                    $groups_list .= $comma . htmlspecialchars_uni($usergroups[$group]['title']);
                    $comma = $lang->comma;
                }
            }
            if (!$groups_list) {
                $groups_list = $lang->none;
            }
            $user['view']['additionalgroups'] = "<small>{$groups_list}</small>";
            $user['view']['email'] = "<a href=\"mailto:" . htmlspecialchars_uni($user['email']) . "\">" . htmlspecialchars_uni($user['email']) . "</a>";
            $user['view']['regdate'] = my_date($mybb->settings['dateformat'], $user['regdate']) . ", " . my_date($mybb->settings['timeformat'], $user['regdate']);
            $user['view']['lastactive'] = my_date($mybb->settings['dateformat'], $user['lastactive']) . ", " . my_date($mybb->settings['timeformat'], $user['lastactive']);
            // Build popup menu
            $popup = new PopupMenu("user_{$user['uid']}", $lang->options);
            $popup->add_item($lang->edit_profile_and_settings, "index.php?module=user-users&amp;action=edit&amp;uid={$user['uid']}");
            $popup->add_item($lang->ban_user, "index.php?module=user-banning&amp;uid={$user['uid']}#username");
            if ($user['usergroup'] == 5) {
                if ($user['coppauser']) {
                    $popup->add_item($lang->approve_coppa_user, "index.php?module=user-users&amp;action=activate_user&amp;uid={$user['uid']}&amp;my_post_key={$mybb->post_code}{$from_bit}");
                } else {
                    $popup->add_item($lang->approve_user, "index.php?module=user-users&amp;action=activate_user&amp;uid={$user['uid']}&amp;my_post_key={$mybb->post_code}{$from_bit}");
                }
            }
            $popup->add_item($lang->delete_user, "index.php?module=user-users&amp;action=delete&amp;uid={$user['uid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->user_deletion_confirmation}')");
            $popup->add_item($lang->show_referred_users, "index.php?module=user-users&amp;action=referrers&amp;uid={$user['uid']}");
            $popup->add_item($lang->show_ip_addresses, "index.php?module=user-users&amp;action=ipaddresses&amp;uid={$user['uid']}");
            $popup->add_item($lang->show_attachments, "index.php?module=forum-attachments&amp;results=1&amp;username="******"-";
            }
            if ($mybb->settings['enablewarningsystem'] != 0 && $usergroups[$user['usergroup']]['canreceivewarnings'] != 0) {
                $warning_level = round($user['warningpoints'] / $mybb->settings['maxwarningpoints'] * 100);
                if ($warning_level > 100) {
                    $warning_level = 100;
                }
                $user['view']['warninglevel'] = get_colored_warning_level($warning_level);
            }
            if ($user['avatar'] && !stristr($user['avatar'], 'http://')) {
                $user['avatar'] = "../{$user['avatar']}";
            }
            if ($view['view_type'] == "card") {
                $scaled_avatar = fetch_scaled_avatar($user, 80, 80);
            } else {
                $scaled_avatar = fetch_scaled_avatar($user, 34, 34);
            }
            if (!$user['avatar']) {
                $user['avatar'] = "styles/{$page->style}/images/default_avatar.gif";
            }
            $user['view']['avatar'] = "<img src=\"" . htmlspecialchars_uni($user['avatar']) . "\" alt=\"\" width=\"{$scaled_avatar['width']}\" height=\"{$scaled_avatar['height']}\" />";
            if ($view['view_type'] == "card") {
                $users .= build_user_view_card($user, $view, $i);
            } else {
                build_user_view_table($user, $view, $table);
            }
        }
        // If card view, we need to output the results
        if ($view['view_type'] == "card") {
            $table->construct_cell($users);
            $table->construct_row();
        }
    }
    if (!isset($view['table_id'])) {
        $view['table_id'] = "users_list";
    }
    $switch_view = "<div class=\"float_right\">";
    $switch_url = $view['url'];
    if ($mybb->input['page'] > 0) {
        $switch_url .= "&amp;page=" . intval($mybb->input['page']);
    }
    if ($view['view_type'] != "card") {
        $switch_view .= "<strong>{$lang->table_view}</strong> | <a href=\"{$switch_url}&amp;type=card\" style=\"font-weight: normal;\">{$lang->card_view}</a>";
    } else {
        $switch_view .= "<a href=\"{$switch_url}&amp;type=table\" style=\"font-weight: normal;\">{$lang->table_view}</a> | <strong>{$lang->card_view}</strong>";
    }
    $switch_view .= "</div>";
    // Do we need to construct the pagination?
    if ($num_results > $view['perpage']) {
        $pagination = draw_admin_pagination($mybb->input['page'], $view['perpage'], $num_results, $view['url'] . "&amp;type={$view['view_type']}");
        $search_class = "float_right";
        $search_style = "";
    } else {
        $search_class = '';
        $search_style = "text-align: right;";
    }
    $search_action = $view['url'];
    // stop &username= in the query string
    if ($view_upos = strpos($search_action, '&amp;username='******'post', 'search_form', 0, '', true);
    $built_view = $search->construct_return;
    $built_view .= "<div class=\"{$search_class}\" style=\"padding-bottom: 3px; margin-top: -9px; {$search_style}\">";
    $built_view .= $search->generate_hidden_field('action', 'search') . "\n";
    if (isset($view['conditions']['username'])) {
        $default_class = '';
        $value = $view['conditions']['username'];
    } else {
        $default_class = "search_default";
        $value = $lang->search_for_user;
    }
    $built_view .= $search->generate_text_box('username', $value, array('id' => 'search_keywords', 'class' => "{$default_class} field150 field_small")) . "\n";
    $built_view .= "<input type=\"submit\" class=\"search_button\" value=\"{$lang->search}\" />\n";
    if ($view['popup']) {
        $built_view .= " <div style=\"display: inline\">{$view['popup']}</div>\n";
    }
    $built_view .= "<script type='text/javascript'>\n\t\tvar form = document.getElementById('search_form');\n\t\tform.onsubmit = function() {\n\t\t\tvar search = document.getElementById('search_keywords');\n\t\t\tif(search.value == '' || search.value == '" . addcslashes($lang->search_for_user, "'") . "')\n\t\t\t{\n\t\t\t\tsearch.focus();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tvar search = document.getElementById('search_keywords');\n\t\tsearch.onfocus = function()\n\t\t{\n\t\t\tif(this.value == '" . addcslashes($lang->search_for_user, "'") . "')\n\t\t\t{\n\t\t\t\t\$(this).removeClassName('search_default');\n\t\t\t\tthis.value = '';\n\t\t\t}\n\t\t}\n\t\tsearch.onblur = function()\n\t\t{\n\t\t\tif(this.value == '')\n\t\t\t{\n\t\t\t\t\$(this).addClassName('search_default');\n\t\t\t\tthis.value = '" . addcslashes($lang->search_for_user, "'") . "';\n\t\t\t}\n\t\t}\n\t\t// fix the styling used if we have a different default value\n\t\tif(search.value != '" . addcslashes($lang->search_for_user, "'") . "')\n\t\t{\n\t\t\t\$(search).removeClassName('search_default');\n\t\t}\n\t\t</script>\n";
    $built_view .= "</div>\n";
    // Autocompletion for usernames
    $built_view .= '
	<script type="text/javascript" src="../jscripts/autocomplete.js?ver=140"></script>
	<script type="text/javascript">
	<!--
		new autoComplete("search_keywords", "../xmlhttp.php?action=get_users", {valueSpan: "username"});
	// -->
	</script>';
    $built_view .= $search->end();
    if (isset($pagination)) {
        $built_view .= $pagination;
    }
    if ($view['view_type'] != "card") {
        $checkbox = '';
    } else {
        $checkbox = "<input type=\"checkbox\" name=\"allbox\" onclick=\"inlineModeration.checkAll(this)\" /> ";
    }
    $built_view .= $table->construct_html("{$switch_view}<div>{$checkbox}{$lang->users}{$view_title}</div>", 1, "", $view['table_id']);
    if (isset($pagination)) {
        $built_view .= $pagination;
    }
    $built_view .= '
<script type="text/javascript" src="' . $mybb->settings['bburl'] . '/jscripts/inline_moderation.js?ver=1400"></script>
<form action="index.php?module=user-users" method="post">
<input type="hidden" name="my_post_key" value="' . $mybb->post_code . '" />
<input type="hidden" name="action" value="inline_edit" />
<div class="float_right"><span class="smalltext"><strong>' . $lang->inline_edit . '</strong></span>
<select name="inline_action" class="inline_select">
	<option value="multiactivate">' . $lang->inline_activate . '</option>
	<option value="multiban">' . $lang->inline_ban . '</option>
	<option value="multiusergroup">' . $lang->inline_usergroup . '</option>
	<option value="multidelete">' . $lang->inline_delete . '</option>
	<option value="multiprune">' . $lang->inline_prune . '</option>
</select>
<input type="submit" class="button" name="go" value="' . $lang->go . ' (0)" id="inline_go" />&nbsp;
<input type="button" onclick="javascript:inlineModeration.clearChecked();" value="' . $lang->clear . '" class="button" />
</div>
</form>
<br style="clear: both;" />
<script type="text/javascript">
<!--
	var go_text = "' . $lang->go . '";
	var all_text = "1";
	var inlineType = "user";
	var inlineId = "acp";
// -->
</script>';
    return $built_view;
}
Exemplo n.º 26
0
    static function render_shout($data, $static = false)
    {
        global $mybb;
        $id = $data['id'];
        $text = self::parse($data['text'], $data['username']);
        $date = htmlspecialchars_uni(my_date($mybb->settings['dvz_sb_dateformat'], $data['date']));
        $username = htmlspecialchars_uni($data['username']);
        $user = '******' . (int) $data['uid'] . '">' . format_name($username, $data['usergroup'], $data['displaygroup']) . '</a>';
        $avatar = '<img src="' . (empty($data['avatar']) ? htmlspecialchars_uni($mybb->settings['useravatar']) : htmlspecialchars_uni($data['avatar'])) . '" alt="avatar" />';
        $notes = null;
        $attributes = null;
        $own = $data['uid'] == $mybb->user['uid'];
        if ($static) {
            if (self::access_mod()) {
                $notes .= '<span class="ip">' . my_inet_ntop($data['ipaddress']) . '</span>';
            }
            if (self::access_mod() || self::access_mod_own() && $own) {
                $notes .= '<a href="" class="mod edit">E</a><a href="" class="mod del">X</a>';
            }
        }
        if (self::access_mod() || self::access_mod_own() && $own) {
            $attributes .= ' data-mod';
        }
        if ($own) {
            $attributes .= ' data-own';
        }
        return '
<div class="entry" data-id="' . $id . '" data-username="******"' . $attributes . '>
    <div class="avatar">' . $avatar . '</div>
    <div class="user">' . $user . '</div>
    <div class="text">' . $text . '</div>
    <div class="info">' . $notes . '<span class="date">' . $date . '</span></div>
</div>';
    }
function akismet_admin()
{
    global $mybb, $db, $page, $lang;
    if ($page->active_action != "akismet") {
        return;
    }
    $page->add_breadcrumb_item($lang->akismet);
    if ($mybb->input['delete_all'] && $mybb->request_method == "post") {
        // User clicked no
        if ($mybb->input['no']) {
            admin_redirect("index.php?module=forum-akismet");
        }
        if ($mybb->request_method == "post") {
            // Delete the template
            $db->delete_query("posts", "visible = '-4'");
            // Log admin action
            log_admin_action();
            flash_message($lang->success_deleted_spam, 'success');
            admin_redirect("index.php?module=forum-akismet");
        } else {
            $page->output_confirm_action("index.php?module=forum-akismet&amp;delete_all=1", $lang->confirm_spam_deletion);
        }
    }
    if ($mybb->input['unmark'] && $mybb->request_method == "post") {
        $unmark = $mybb->input['akismet'];
        if (empty($unmark)) {
            flash_message($lang->error_unmark, 'error');
            admin_redirect("index.php?module=forum-akismet");
        }
        $posts_in = '';
        $comma = '';
        foreach ($unmark as $key => $val) {
            $posts_in .= $comma . intval($key);
            $comma = ',';
        }
        $query = $db->simple_select("posts", "pid, tid", "pid IN ({$posts_in}) AND replyto = '0'");
        while ($post = $db->fetch_array($query)) {
            $threadp[] = $post['tid'];
        }
        if (!is_array($threadp)) {
            $threadp = array();
        }
        $thread_list = implode(',', $threadp);
        $query = $db->query("\r\n\t\t\tSELECT p.tid, f.usepostcounts, p.uid, p.fid, p.dateline, p.replyto, t.lastpost, t.lastposter, t.lastposteruid, t.subject\r\n\t\t\tFROM " . TABLE_PREFIX . "posts p\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=p.tid)\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "forums f ON (f.fid=p.fid)\r\n\t\t\tWHERE p.pid IN ({$posts_in}) AND p.visible = '-4'\r\n\t\t");
        while ($post = $db->fetch_array($query)) {
            // Fetch the last post for this forum
            $query2 = $db->query("\r\n\t\t\t\tSELECT tid, lastpost, lastposter, lastposteruid, subject\r\n\t\t\t\tFROM " . TABLE_PREFIX . "threads\r\n\t\t\t\tWHERE fid='{$post['fid']}' AND visible='1' AND closed NOT LIKE 'moved|%'\r\n\t\t\t\tORDER BY lastpost DESC\r\n\t\t\t\tLIMIT 0, 1\r\n\t\t\t");
            $lastpost = $db->fetch_array($query2);
            if ($post['lastpost'] > $lastpost['lastpost']) {
                $lastpost['lastpost'] = $post['lastpost'];
                $lastpost['lastposter'] = $post['lastposter'];
                $lastpost['lastposteruid'] = $post['lastposteruid'];
                $lastpost['subject'] = $post['subject'];
                $lastpost['tid'] = $post['tid'];
            }
            $update_count = array("lastpost" => intval($lastpost['lastpost']), "lastposter" => $db->escape_string($lastpost['lastposter']), "lastposteruid" => intval($lastpost['lastposteruid']), "lastposttid" => intval($lastpost['tid']), "lastpostsubject" => $db->escape_string($lastpost['subject']));
            $db->update_query("forums", $update_count, "fid='{$post['fid']}'");
            $query2 = $db->query("\r\n\t\t\t\tSELECT u.uid, u.username, p.username AS postusername, p.dateline\r\n\t\t\t\tFROM " . TABLE_PREFIX . "posts p\r\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=p.uid)\r\n\t\t\t\tWHERE p.tid='{$post['tid']}' AND p.visible='1' OR p.pid = '{$post['pid']}'\r\n\t\t\t\tORDER BY p.dateline DESC\r\n\t\t\t\tLIMIT 1");
            $lastpost = $db->fetch_array($query2);
            $query2 = $db->query("\r\n\t\t\t\tSELECT u.uid, u.username, p.username AS postusername, p.dateline\r\n\t\t\t\tFROM " . TABLE_PREFIX . "posts p\r\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=p.uid)\r\n\t\t\t\tWHERE p.tid='{$post['tid']}'\r\n\t\t\t\tORDER BY p.dateline ASC\r\n\t\t\t\tLIMIT 0,1\r\n\t\t\t");
            $firstpost = $db->fetch_array($query2);
            if (!$firstpost['username']) {
                $firstpost['username'] = $firstpost['postusername'];
            }
            if (!$lastpost['username']) {
                $lastpost['username'] = $lastpost['postusername'];
            }
            if (!$lastpost['dateline']) {
                $lastpost['username'] = $firstpost['username'];
                $lastpost['uid'] = $firstpost['uid'];
                $lastpost['dateline'] = $firstpost['dateline'];
            }
            $lastpost['username'] = $db->escape_string($lastpost['username']);
            $firstpost['username'] = $db->escape_string($firstpost['username']);
            $query2 = $db->simple_select("users", "akismetstopped", "uid='{$post['uid']}'");
            $akismetstopped = $db->fetch_field($query2, "akismetstopped") - 1;
            if ($akismetstopped < 0) {
                $akismetstopped = 0;
            }
            $db->update_query("users", array('akismetstopped' => $akismetstopped), "uid='{$post['uid']}'");
            $update_array = array('username' => $firstpost['username'], 'uid' => intval($firstpost['uid']), 'lastpost' => intval($lastpost['dateline']), 'lastposter' => $lastpost['username'], 'lastposteruid' => intval($lastpost['uid']));
            $db->update_query("threads", $update_array, "tid='{$post['tid']}'");
            if ($post['usepostcounts'] != 0) {
                $db->write_query("UPDATE " . TABLE_PREFIX . "users SET postnum=postnum+1 WHERE uid = '{$post['uid']}'");
            }
            $newthreads = $newreplies = 0;
            if ($post['replyto'] == 0) {
                ++$newthreads;
            } else {
                ++$newreplies;
            }
            update_thread_counters($post['tid'], array('replies' => '+' . $newreplies));
            update_forum_counters($post['fid'], array('threads' => '+' . $newthreads, 'posts' => '+1'));
        }
        $approve = array("visible" => 1);
        if ($thread_list) {
            $db->update_query("threads", $approve, "tid IN ({$thread_list})");
        }
        $db->update_query("posts", $approve, "pid IN ({$posts_in})");
        // Log admin action
        log_admin_action();
        flash_message($lang->success_unmarked, 'success');
        admin_redirect("index.php?module=forum-akismet");
    }
    if ($mybb->input['delete'] && $mybb->request_method == "post") {
        $deletepost = $mybb->input['akismet'];
        if (empty($deletepost)) {
            flash_message($lang->error_deletepost, 'error');
            admin_redirect("index.php?module=forum-akismet");
        }
        $posts_in = '';
        $comma = '';
        foreach ($deletepost as $key => $val) {
            $posts_in .= $comma . intval($key);
            $comma = ',';
        }
        $query = $db->simple_select("posts", "pid, tid", "pid IN ({$posts_in}) AND replyto = '0'");
        while ($post = $db->fetch_array($query)) {
            $threadp[$post['pid']] = $post['tid'];
        }
        if (!is_array($threadp)) {
            $threadp = array();
        }
        require_once MYBB_ROOT . "inc/functions_upload.php";
        foreach ($deletepost as $pid => $val) {
            if (array_key_exists($pid, $threadp)) {
                $db->delete_query("posts", "pid IN ({$posts_in})");
                $db->delete_query("attachments", "pid IN ({$posts_in})");
                // Get thread info
                $query = $db->simple_select("threads", "poll", "tid='" . $threadp[$pid] . "'");
                $poll = $db->fetch_field($query, 'poll');
                // Delete threads, redirects, favorites, polls, and poll votes
                $db->delete_query("threads", "tid='" . $threadp[$pid] . "'");
                $db->delete_query("threads", "closed='moved|" . $threadp[$pid] . "'");
                $db->delete_query("threadsubscriptions", "tid='" . $threadp[$pid] . "'");
                $db->delete_query("polls", "tid='" . $threadp[$pid] . "'");
                $db->delete_query("pollvotes", "pid='{$poll}'");
            }
            // Remove attachments
            remove_attachments($pid);
            // Delete the post
            $db->delete_query("posts", "pid='{$pid}'");
        }
        // Log admin action
        log_admin_action();
        flash_message($lang->success_spam_deleted, 'success');
        admin_redirect("index.php?module=forum-akismet");
    }
    if (!$mybb->input['action']) {
        require MYBB_ROOT . "inc/class_parser.php";
        $parser = new postParser();
        $page->output_header($lang->akismet);
        $form = new Form("index.php?module=forum-akismet", "post");
        $table = new Table();
        $table->construct_header($form->generate_check_box("checkall", 1, '', array('class' => 'checkall')), array('width' => '5%'));
        $table->construct_header("Title / Username / Post", array('class' => 'align_center'));
        $mybb->input['page'] = intval($mybb->input['page']);
        if ($mybb->input['page'] > 0) {
            $start = $mybb->input['page'] * 20;
        } else {
            $start = 0;
        }
        $query = $db->simple_select("posts", "COUNT(pid) as spam", "visible = '-4'");
        $total_rows = $db->fetch_field($query, 'spam');
        if ($start > $total_rows) {
            $start = $total_rows - 20;
        }
        if ($start < 0) {
            $start = 0;
        }
        $query = $db->simple_select("posts", "*", "visible = '-4'", array('limit_start' => $start, 'limit' => '20', 'order_by' => 'dateline', 'order_dir' => 'desc'));
        while ($post = $db->fetch_array($query)) {
            if ($post['uid'] != 0) {
                $username = "******"../" . str_replace("{uid}", $post['uid'], PROFILE_URL) . "\" target=\"_blank\">" . format_name($post['username'], $post['usergroup'], $post['displaygroup']) . "</a>";
            } else {
                $username = $post['username'];
            }
            $table->construct_cell($form->generate_check_box("akismet[{$post['pid']}]", 1, ''));
            $table->construct_cell("<span style=\"float: right;\">{$lang->username} {$username}</span> <span style=\"float: left;\">{$lang->title}: " . htmlspecialchars_uni($post['subject']) . " <strong>(" . my_date($mybb->settings['dateformat'], $post['dateline']) . ", " . my_date($mybb->settings['timeformat'], $post['dateline']) . ")</strong></span>");
            $table->construct_row();
            $parser_options = array("allow_html" => 0, "allow_mycode" => 0, "allow_smilies" => 0, "allow_imgcode" => 0, "me_username" => $post['username'], "filter_badwords" => 1);
            $post['message'] = $parser->parse_message($post['message'], $parser_options);
            $table->construct_cell($post['message'], array("colspan" => 2));
            $table->construct_row();
        }
        $num_rows = $table->num_rows();
        if ($num_rows == 0) {
            $table->construct_cell($lang->no_spam_found, array("class" => "align_center", "colspan" => 2));
            $table->construct_row();
        }
        $table->output($lang->detected_spam_messages);
        echo "<br />" . draw_admin_pagination($mybb->input['page'], 20, $total_rows, "index.php?module=forum-akismet&amp;page={page}");
        $buttons[] = $form->generate_submit_button($lang->unmark_selected, array('name' => 'unmark'));
        $buttons[] = $form->generate_submit_button($lang->deleted_selected, array('name' => 'delete'));
        if ($num_rows > 0) {
            $buttons[] = $form->generate_submit_button($lang->delete_all, array('name' => 'delete_all', 'onclick' => "return confirm('{$lang->confirm_spam_deletion}');"));
        }
        $form->output_submit_wrapper($buttons);
        $form->end();
        $page->output_footer();
    }
    exit;
}
Exemplo n.º 28
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;
}
Exemplo n.º 29
0
         echo json_encode($lang->invalid_username);
         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);
         }
Exemplo n.º 30
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;
    }
}