Пример #1
0
function trader_give_rep($uid = 1)
{
    global $mybb, $db, $tradefeedbackform, $mypostkey, $templates, $header, $headerinclude, $footer, $lang;
    $lang->load("tradefeedback");
    $uid = intval($uid);
    $action = "give";
    if ($mybb->user['uid'] == $uid) {
        error($lang->feedback_give_self);
    }
    if (!$uid) {
        error($lang->feedback_invalid_user);
    }
    if ($mybb->request_method == "post" && verify_post_check($mybb->input['my_post_key'])) {
        // Make sure they haven't given the same user feedback within the last 24 hours
        $cutoff = TIME_NOW - 86400;
        $queryfirst = $db->simple_select("trade_feedback", "fid", "dateline >= {$cutoff} AND receiver={$uid} & giver=" . $mybb->user['uid']);
        if ($db->num_rows($queryfirst) >= 1) {
            error($lang->feedback_wait_24);
        }
        $new_rep = array("giver" => $mybb->user['uid'], "receiver" => $uid, "dateline" => TIME_NOW, "approved" => 1, "value" => intval($mybb->input['value']), "type" => $db->escape_string($mybb->input['type']), "threadlink" => $db->escape_string($mybb->input['threadlink']), "comments" => $db->escape_string($mybb->input['comments']));
        if ($mybb->settings['trade_approval'] == 1 && $mybb->usergroup['canmodcp'] == 0) {
            $new_rep['approved'] = 0;
        }
        $db->insert_query("trade_feedback", $new_rep);
        $fid = $db->insert_id();
        trader_send_pm($new_rep['receiver'], $fid);
        trader_myalerts($new_rep['receiver'], $fid);
        if ($new_rep['approved'] == 1) {
            trader_rebuild_reputation($uid);
            $message = $lang->give_feedback_added;
        } else {
            $message = $lang->give_feedback_approval_needed;
        }
        $url = $mybb->settings['bburl'] . "/tradefeedback.php?action=view&uid={$uid}";
        redirect($url, $message, "", true);
    } else {
        // Check if we have a thread id
        $tid = intval($mybb->input['tid']);
        if ($tid) {
            $threadlink_value = $mybb->settings['bburl'] . "/" . get_thread_link($tid);
            $query = $db->simple_select("threads", "subject", "tid={$tid}");
            $thread_subject = $db->fetch_field($query, "subject");
            $breadcrumb = $lang->sprintf($lang->give_feedback_fromthread_breadcrumb, $thread_subject);
        } else {
            $threadlink_value = "";
        }
        // Get the member username for confirmation
        $query = $db->simple_select("users", "uid, username", "uid={$uid}");
        $member = $db->fetch_array($query);
        $member['username'] = htmlspecialchars_uni($member['username']);
        add_breadcrumb($lang->sprintf($lang->feedback_profile, $member['username']), get_profile_link($uid));
        add_breadcrumb($lang->sprintf($lang->feedback_page_title, $member['username']), "tradefeedback.php?action=view&uid={$uid}");
        add_breadcrumb($lang->give_feedback . $breadcrumb, "tradefeedback.php?action=give&uid={$uid}");
        $feedback = array('comments' => htmlspecialchars_uni($mybb->input['comments']));
        eval("\$tradefeedbackform = \"" . $templates->get("tradefeedback_give_form") . "\";");
        output_page($tradefeedbackform);
    }
}
Пример #2
0
function parse_alert(MybbStuff_MyAlerts_Entity_Alert $alertToParse)
{
    global $mybb, $lang, $plugins;
    if (!isset($lang->myalerts)) {
        $lang->load('myalerts');
    }
    /** @var MybbStuff_MyAlerts_Formatter_AbstractFormatter $formatter */
    $formatter = MybbStuff_MyAlerts_AlertFormatterManager::getInstance()->getFormatterForAlertType($alertToParse->getType()->getCode());
    $outputAlert = array();
    if ($formatter != null) {
        $plugins->run_hooks('myalerts_alerts_output_start', $alert);
        $formatter->init();
        $fromUser = $alertToParse->getFromUser();
        $maxDimensions = str_replace('|', 'x', $mybb->settings['myalerts_avatar_size']);
        $outputAlert['avatar'] = format_avatar($fromUser['avatar'], $mybb->settings['myalerts_avatar_size'], $maxDimensions);
        $outputAlert['avatar']['image'] = htmlspecialchars_uni($outputAlert['avatar']['image']);
        $outputAlert['id'] = $alertToParse->getId();
        $outputAlert['username'] = htmlspecialchars_uni($fromUser['username']);
        $outputAlert['from_user'] = format_name(htmlspecialchars_uni($fromUser['username']), $fromUser['usergroup'], $fromUser['displaygroup']);
        $outputAlert['from_user_raw_profilelink'] = get_profile_link((int) $fromUser['uid']);
        // htmlspecialchars_uni done by get_profile_link
        $outputAlert['from_user_profilelink'] = build_profile_link($outputAlert['from_user'], $fromUser['uid']);
        $outputAlert['alert_status'] = ' alert--read';
        if ($alertToParse->getUnread()) {
            $outputAlert['alert_status'] = ' alert--unread';
        }
        $outputAlert['message'] = $formatter->formatAlert($alertToParse, $outputAlert);
        $outputAlert['alert_code'] = $alertToParse->getType()->getCode();
        $outputAlert['received_at'] = htmlspecialchars_uni(my_date($mybb->settings['dateformat'], $alertToParse->getCreatedAt()->getTimestamp()));
        $plugins->run_hooks('myalerts_alerts_output_end', $alert);
    }
    return $outputAlert;
}
Пример #3
0
    }
    if (count($errors) == 0) {
        if ($mybb->settings['mail_handler'] == 'smtp') {
            $from = $mybb->input['fromemail'];
        } else {
            $from = "{$mybb->input['fromname']} <{$mybb->input['fromemail']}>";
        }
        $message = $lang->sprintf($lang->email_emailuser, $to_user['username'], $mybb->input['fromname'], $mybb->settings['bbname'], $mybb->settings['bburl'], $mybb->get_input('message'));
        my_mail($to_user['email'], $mybb->get_input('subject'), $message, $from, "", "", false, "text", "", $mybb->input['fromemail']);
        if ($mybb->settings['mail_logging'] > 0) {
            // Log the message
            $log_entry = array("subject" => $db->escape_string($mybb->get_input('subject')), "message" => $db->escape_string($mybb->get_input('message')), "dateline" => TIME_NOW, "fromuid" => $mybb->user['uid'], "fromemail" => $db->escape_string($mybb->input['fromemail']), "touid" => $to_user['uid'], "toemail" => $db->escape_string($to_user['email']), "tid" => 0, "ipaddress" => $db->escape_binary($session->packedip), "type" => 1);
            $db->insert_query("maillogs", $log_entry);
        }
        $plugins->run_hooks("member_do_emailuser_end");
        redirect(get_profile_link($to_user['uid']), $lang->redirect_emailsent);
    } else {
        $mybb->input['action'] = "emailuser";
    }
}
if ($mybb->input['action'] == "emailuser") {
    $plugins->run_hooks("member_emailuser_start");
    // Guests or those without permission can't email other users
    if ($mybb->usergroup['cansendemail'] == 0) {
        error_no_permission();
    }
    // Check group limits
    if ($mybb->usergroup['maxemails'] > 0) {
        if ($mybb->user['uid'] > 0) {
            $user_check = "fromuid='{$mybb->user['uid']}'";
        } else {
 $doneusers = array();
 $query = $db->query("\r\n\t\t\tSELECT s.ip, s.uid, s.time, u.username, u.invisible, u.usergroup, u.displaygroup\r\n\t\t\tFROM " . TABLE_PREFIX . "sessions s\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (s.uid=u.uid)\r\n\t\t\tWHERE s.time > '{$timecut}' AND location2='{$tid}' AND nopermission != 1\r\n\t\t\tORDER BY u.username ASC, s.time DESC\r\n\t\t");
 while ($user = $db->fetch_array($query)) {
     if ($user['uid'] == 0) {
         ++$guestcount;
     } else {
         if (empty($doneusers[$user['uid']]) || $doneusers[$user['uid']] < $user['time']) {
             ++$membercount;
             $doneusers[$user['uid']] = $user['time'];
             $invisiblemark = '';
             if ($user['invisible'] == 1) {
                 $invisiblemark = "*";
                 ++$inviscount;
             }
             if ($user['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid']) {
                 $user['profilelink'] = get_profile_link($user['uid']);
                 $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
                 $user['reading'] = my_date($mybb->settings['timeformat'], $user['time']);
                 eval("\$onlinemembers .= \"" . $templates->get("showthread_usersbrowsing_user", 1, 0) . "\";");
                 $comma = $lang->comma;
             }
         }
     }
 }
 $guestsonline = '';
 if ($guestcount) {
     $guestsonline = $lang->sprintf($lang->users_browsing_thread_guests, $guestcount);
 }
 $onlinesep = '';
 if ($guestcount && $onlinemembers) {
     $onlinesep = $lang->comma;
Пример #5
0
function get_box_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $input = Tapatalk_Input::filterXmlInput(array('box_id' => Tapatalk_Input::INT, 'start_num' => Tapatalk_Input::INT, 'last_num' => Tapatalk_Input::INT), $xmlrpc_params);
    list($start, $limit) = process_page($input['start_num'], $input['last_num']);
    $lang->load("private");
    $parser = new postParser();
    if ($mybb->settings['enablepms'] == 0) {
        return xmlrespfalse($lang->pms_disabled);
    }
    if ($mybb->user['uid'] == '/' || $mybb->user['uid'] == 0 || $mybb->usergroup['canusepms'] == 0) {
        return tt_no_permission();
    }
    if (!$mybb->user['pmfolders']) {
        $mybb->user['pmfolders'] = "1**\$%%\$2**\$%%\$3**\$%%\$4**";
        $sql_array = array("pmfolders" => $mybb->user['pmfolders']);
        $db->update_query("users", $sql_array, "uid = " . $mybb->user['uid']);
    }
    $rand = my_rand(0, 9);
    if ($rand == 5) {
        update_pm_count();
    }
    $foldernames = array();
    $foldersexploded = explode("\$%%\$", $mybb->user['pmfolders']);
    foreach ($foldersexploded as $key => $folders) {
        $folderinfo = explode("**", $folders, 2);
        $folderinfo[1] = get_pm_folder_name($folderinfo[0], $folderinfo[1]);
        $foldernames[$folderinfo[0]] = $folderinfo[1];
    }
    if (!$input['box_id'] || !array_key_exists($input['box_id'], $foldernames)) {
        $input['box_id'] = 1;
    }
    $folder = $input['box_id'];
    $foldername = $foldernames[$folder];
    $lang->pms_in_folder = $lang->sprintf($lang->pms_in_folder, $foldername);
    if ($folder == 2 || $folder == 3) {
        $sender = $lang->sentto;
    } else {
        $sender = $lang->sender;
    }
    // Do Multi Pages
    $query = $db->simple_select("privatemessages", "COUNT(*) AS total", "uid='" . $mybb->user['uid'] . "' AND folder='{$folder}'");
    $count_total = $db->fetch_field($query, 'total');
    $query = $db->simple_select("privatemessages", "COUNT(*) AS unread", "uid='" . $mybb->user['uid'] . "' AND folder='{$folder}' AND readtime = 0");
    $count_unread = $db->fetch_field($query, 'unread');
    // Get all recipients into an array
    $cached_users = $get_users = array();
    $users_query = $db->simple_select("privatemessages", "recipients", "folder='{$folder}' AND uid='{$mybb->user['uid']}'", array('limit_start' => $start, 'limit' => $limit, 'order_by' => 'dateline', 'order_dir' => 'DESC'));
    while ($row = $db->fetch_array($users_query)) {
        $recipients = unserialize($row['recipients']);
        if (is_array($recipients['to']) && count($recipients['to'])) {
            $get_users = array_merge($get_users, $recipients['to']);
        }
        if (is_array($recipients['bcc']) && count($recipients['bcc'])) {
            $get_users = array_merge($get_users, $recipients['bcc']);
        }
    }
    $get_users = implode(',', array_unique($get_users));
    // Grab info
    if ($get_users) {
        $users_query = $db->simple_select("users", "uid, username, usergroup, displaygroup", "uid IN ({$get_users})");
        while ($user = $db->fetch_array($users_query)) {
            $cached_users[$user['uid']] = $user;
        }
    }
    $user_online = $folder == 1 ? ', fu.lastactive, fu.invisible, fu.lastvisit ' : ', tu.lastactive, tu.invisible, tu.lastvisit ';
    $query = $db->query("\n\t\tSELECT pm.*, fu.username AS fromusername, tu.username as tousername, fu.avatar as favatar, tu.avatar as tavatar {$user_online}\n\t\tFROM " . TABLE_PREFIX . "privatemessages pm\n\t\tLEFT JOIN " . TABLE_PREFIX . "users fu ON (fu.uid=pm.fromid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "users tu ON (tu.uid=pm.toid)\n\t\tWHERE pm.folder='{$folder}' AND pm.uid='" . $mybb->user['uid'] . "'\n\t\tORDER BY pm.dateline DESC\n\t\tLIMIT {$start}, {$limit}\n\t");
    $message_list = array();
    if ($db->num_rows($query) > 0) {
        while ($message = $db->fetch_array($query)) {
            $status = 1;
            if ($message['status'] == 0) {
                $msgalt = $lang->new_pm;
            } elseif ($message['status'] == 1) {
                $msgalt = $lang->old_pm;
                $status = 2;
            } elseif ($message['status'] == 3) {
                $msgalt = $lang->reply_pm;
                $status = 3;
            } elseif ($message['status'] == 4) {
                $msgalt = $lang->fwd_pm;
                $status = 4;
            }
            $msg_from = null;
            $msg_to = array();
            $avatar = "";
            $outboxdisplayuserid = 0;
            // Sent Items or Drafts Folder Check
            $recipients = unserialize($message['recipients']);
            if (count($recipients['to']) > 1 || count($recipients['to']) == 1 && count($recipients['bcc']) > 0) {
                foreach ($recipients['to'] as $uid) {
                    $profilelink = get_profile_link($uid);
                    $user = $cached_users[$uid];
                    if (!empty($user['username'])) {
                        $msg_to[] = new xmlrpcval(array("username" => new xmlrpcval($user['username'], "base64"), "user_id" => new xmlrpcval($uid, "string"), "user_type" => check_return_user_type($user['username'])), "struct");
                    }
                    if (($folder == 2 or $folder == 3) && !$outboxdisplayuserid) {
                        $outboxdisplayuserid = $uid;
                    }
                }
                /*if(is_array($recipients['bcc']) && count($recipients['bcc']))
                		{
                			foreach($recipients['bcc'] as $uid)
                			{
                				$profilelink = get_profile_link($uid);
                				$user = $cached_users[$uid];
                				$msg_to[]=new xmlrpcval($user['username'], "base64");
                			}
                		}*/
            } else {
                if ($message['toid']) {
                    $tofromusername = $message['tousername'];
                    $tofromuid = $message['toid'];
                    if (!empty($tofromusername)) {
                        $msg_to[] = new xmlrpcval(array("username" => new xmlrpcval($tofromusername, "base64"), "user_id" => new xmlrpcval($message['toid'], "string"), "user_type" => check_return_user_type($tofromusername)), "struct");
                    }
                }
            }
            $avatar = $message['tavatar'];
            if ($folder != 2 && $folder != 3) {
                $tofromusername = $message['fromusername'];
                $tofromuid = $message['fromid'];
                if ($tofromuid == 0) {
                    $tofromusername = $lang->mybb_engine;
                }
                if (!$tofromusername) {
                    $tofromuid = 0;
                    $tofromusername = $lang->na;
                }
                $msg_from = $tofromusername;
                $avatar = $message['favatar'];
            } else {
                if ($outboxdisplayuserid) {
                    $outboxdisplayuser = get_user($outboxdisplayuserid);
                    $avatar = $outboxdisplayuser['avatar'];
                }
            }
            if (!trim($message['subject'])) {
                $message['subject'] = $lang->pm_no_subject;
            }
            $is_online = false;
            $timecut = TIME_NOW - $mybb->settings['wolcutoff'];
            if ($message['lastactive'] > $timecut && ($message['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1) && $message['lastvisit'] != $message['lastactive']) {
                $is_online = true;
            }
            $new_message = array('msg_id' => new xmlrpcval($message['pmid'], 'string'), 'msg_state' => new xmlrpcval($status, 'int'), 'sent_date' => new xmlrpcval(mobiquo_iso8601_encode($message['dateline']), 'dateTime.iso8601'), 'msg_to' => new xmlrpcval($msg_to, 'array'), 'icon_url' => new xmlrpcval(absolute_url($avatar), 'string'), 'msg_subject' => new xmlrpcval($message['subject'], 'base64'), 'short_content' => new xmlrpcval(process_short_content($message['message'], $parser), 'base64'), 'is_online' => new xmlrpcval($is_online, 'boolean'));
            if ($msg_from !== null) {
                $new_message['msg_from'] = new xmlrpcval($msg_from, 'base64');
            }
            $message_list[] = new xmlrpcval($new_message, "struct");
        }
    }
    $result = new xmlrpcval(array('result' => new xmlrpcval(true, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'), 'total_message_count' => new xmlrpcval($count_total, 'int'), 'total_unread_count' => new xmlrpcval($count_unread, 'int'), 'list' => new xmlrpcval($message_list, 'array')), 'struct');
    return new xmlrpcresp($result);
}
Пример #6
0
/**
 * Builds a friendly named Who's Online location from an "activity" and array of user data. Assumes fetch_wol_activity has already been called.
 *
 * @param array Array containing activity and essential IDs.
 * @return string Location name for the activity being performed.
 */
function build_friendly_wol_location($user_activity)
{
    global $db, $lang, $uid_list, $aid_list, $pid_list, $tid_list, $fid_list, $ann_list, $eid_list, $plugins, $parser, $mybb;
    global $threads, $forums, $forums_linkto, $forum_cache, $posts, $announcements, $events, $usernames, $attachments;
    // Fetch forum permissions for this user
    $unviewableforums = get_unviewable_forums();
    $inactiveforums = get_inactive_forums();
    $fidnot = '';
    $unviewablefids = $inactivefids = array();
    if ($unviewableforums) {
        $fidnot = " AND fid NOT IN ({$unviewableforums})";
        $unviewablefids = explode(',', $unviewableforums);
    }
    if ($inactiveforums) {
        $fidnot .= " AND fid NOT IN ({$inactiveforums})";
        $inactivefids = explode(',', $inactiveforums);
    }
    // Fetch any users
    if (!is_array($usernames) && count($uid_list) > 0) {
        $uid_sql = implode(",", $uid_list);
        if ($uid_sql != $mybb->user['uid']) {
            $query = $db->simple_select("users", "uid,username", "uid IN ({$uid_sql})");
            while ($user = $db->fetch_array($query)) {
                $usernames[$user['uid']] = $user['username'];
            }
        } else {
            $usernames[$mybb->user['uid']] = $mybb->user['username'];
        }
    }
    // Fetch any attachments
    if (!is_array($attachments) && count($aid_list) > 0) {
        $aid_sql = implode(",", $aid_list);
        $query = $db->simple_select("attachments", "aid,pid", "aid IN ({$aid_sql})");
        while ($attachment = $db->fetch_array($query)) {
            $attachments[$attachment['aid']] = $attachment['pid'];
            $pid_list[] = $attachment['pid'];
        }
    }
    // Fetch any announcements
    if (!is_array($announcements) && count($ann_list) > 0) {
        $aid_sql = implode(",", $ann_list);
        $query = $db->simple_select("announcements", "aid,subject", "aid IN ({$aid_sql}) {$fidnot}");
        while ($announcement = $db->fetch_array($query)) {
            $announcement_title = htmlspecialchars_uni($parser->parse_badwords($announcement['subject']));
            $announcements[$announcement['aid']] = $announcement_title;
        }
    }
    // Fetch any posts
    if (!is_array($posts) && count($pid_list) > 0) {
        $pid_sql = implode(",", $pid_list);
        $query = $db->simple_select("posts", "pid,tid", "pid IN ({$pid_sql}) {$fidnot}");
        while ($post = $db->fetch_array($query)) {
            $posts[$post['pid']] = $post['tid'];
            $tid_list[] = $post['tid'];
        }
    }
    // Fetch any threads
    if (!is_array($threads) && count($tid_list) > 0) {
        $perms = array();
        $tid_sql = implode(",", $tid_list);
        $query = $db->simple_select('threads', 'uid, fid, tid, subject, visible, prefix', "tid IN({$tid_sql}) {$fidnot}");
        $threadprefixes = build_prefixes();
        while ($thread = $db->fetch_array($query)) {
            $thread['threadprefix'] = '';
            if ($thread['prefix'] && !empty($threadprefixes[$thread['prefix']])) {
                $thread['threadprefix'] = $threadprefixes[$thread['prefix']]['displaystyle'];
            }
            if (empty($perms[$thread['fid']])) {
                $perms[$thread['fid']] = forum_permissions($thread['fid']);
            }
            if (isset($perms[$thread['fid']]['canonlyviewownthreads']) && $perms[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid'] && !is_moderator($thread['fid'])) {
                continue;
            }
            if (is_moderator($thread['fid']) || $thread['visible'] == 1) {
                $thread_title = '';
                if ($thread['threadprefix']) {
                    $thread_title = $thread['threadprefix'] . '&nbsp;';
                }
                $thread_title .= htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
                $threads[$thread['tid']] = $thread_title;
                $fid_list[] = $thread['fid'];
            }
        }
    }
    // Fetch any forums
    if (!is_array($forums) && count($fid_list) > 0) {
        $fidnot = array_merge($unviewablefids, $inactivefids);
        foreach ($forum_cache as $fid => $forum) {
            if (in_array($fid, $fid_list) && !in_array($fid, $fidnot)) {
                $forums[$fid] = $forum['name'];
                $forums_linkto[$fid] = $forum['linkto'];
            }
        }
    }
    // And finaly any events
    if (!is_array($events) && count($eid_list) > 0) {
        $eid_sql = implode(",", $eid_list);
        $query = $db->simple_select("events", "eid,name", "eid IN ({$eid_sql})");
        while ($event = $db->fetch_array($query)) {
            $events[$event['eid']] = htmlspecialchars_uni($parser->parse_badwords($event['name']));
        }
    }
    // Now we've got everything we need we can put a name to the location
    switch ($user_activity['activity']) {
        // announcement.php functions
        case "announcements":
            if (!empty($announcements[$user_activity['ann']])) {
                $location_name = $lang->sprintf($lang->viewing_announcements, get_announcement_link($user_activity['ann']), $announcements[$user_activity['ann']]);
            } else {
                $location_name = $lang->viewing_announcements2;
            }
            break;
            // attachment.php actions
        // attachment.php actions
        case "attachment":
            $pid = $attachments[$user_activity['aid']];
            $tid = $posts[$pid];
            if (!empty($threads[$tid])) {
                $location_name = $lang->sprintf($lang->viewing_attachment2, $user_activity['aid'], $threads[$tid], get_thread_link($tid));
            } else {
                $location_name = $lang->viewing_attachment;
            }
            break;
            // calendar.php functions
        // calendar.php functions
        case "calendar":
            $location_name = $lang->viewing_calendar;
            break;
        case "calendar_event":
            if (!empty($events[$user_activity['eid']])) {
                $location_name = $lang->sprintf($lang->viewing_event2, get_event_link($user_activity['eid']), $events[$user_activity['eid']]);
            } else {
                $location_name = $lang->viewing_event;
            }
            break;
        case "calendar_addevent":
            $location_name = $lang->adding_event;
            break;
        case "calendar_editevent":
            $location_name = $lang->editing_event;
            break;
        case "contact":
            $location_name = $lang->viewing_contact_us;
            break;
            // editpost.php functions
        // editpost.php functions
        case "editpost":
            $location_name = $lang->editing_post;
            break;
            // forumdisplay.php functions
        // forumdisplay.php functions
        case "forumdisplay":
            if (!empty($forums[$user_activity['fid']])) {
                if ($forums_linkto[$user_activity['fid']]) {
                    $location_name = $lang->sprintf($lang->forum_redirect_to, get_forum_link($user_activity['fid']), $forums[$user_activity['fid']]);
                } else {
                    $location_name = $lang->sprintf($lang->viewing_forum2, get_forum_link($user_activity['fid']), $forums[$user_activity['fid']]);
                }
            } else {
                $location_name = $lang->viewing_forum;
            }
            break;
            // index.php functions
        // index.php functions
        case "index":
            $location_name = $lang->sprintf($lang->viewing_index, $mybb->settings['bbname']);
            break;
            // managegroup.php functions
        // managegroup.php functions
        case "managegroup":
            $location_name = $lang->managing_group;
            break;
            // member.php functions
        // member.php functions
        case "member_activate":
            $location_name = $lang->activating_account;
            break;
        case "member_profile":
            if (!empty($usernames[$user_activity['uid']])) {
                $location_name = $lang->sprintf($lang->viewing_profile2, get_profile_link($user_activity['uid']), $usernames[$user_activity['uid']]);
            } else {
                $location_name = $lang->viewing_profile;
            }
            break;
        case "member_register":
            $location_name = $lang->registering;
            break;
        case "member":
        case "member_login":
            // Guest or member?
            if ($mybb->user['uid'] == 0) {
                $location_name = $lang->logging_in;
            } else {
                $location_name = $lang->logging_in_plain;
            }
            break;
        case "member_logout":
            $location_name = $lang->logging_out;
            break;
        case "member_emailuser":
            $location_name = $lang->emailing_user;
            break;
        case "member_rate":
            $location_name = $lang->rating_user;
            break;
        case "member_resendactivation":
            $location_name = $lang->member_resendactivation;
            break;
        case "member_lostpw":
            $location_name = $lang->member_lostpw;
            break;
            // memberlist.php functions
        // memberlist.php functions
        case "memberlist":
            $location_name = $lang->viewing_memberlist;
            break;
            // misc.php functions
        // misc.php functions
        case "misc_dstswitch":
            $location_name = $lang->changing_dst;
            break;
        case "misc_whoposted":
            if (!empty($threads[$user_activity['tid']])) {
                $location_name = $lang->sprintf($lang->viewing_whoposted2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']]);
            } else {
                $location_name = $lang->viewing_whoposted;
            }
            break;
        case "misc_markread":
            $location_name = $lang->sprintf($lang->marking_read, $mybb->post_code);
            break;
        case "misc_help":
            $location_name = $lang->viewing_helpdocs;
            break;
        case "misc_buddypopup":
            $location_name = $lang->viewing_buddylist;
            break;
        case "misc_smilies":
            $location_name = $lang->viewing_smilies;
            break;
        case "misc_syndication":
            $location_name = $lang->viewing_syndication;
            break;
        case "misc_imcenter":
            $location_name = $lang->viewing_imcenter;
            break;
            // modcp.php functions
        // modcp.php functions
        case "modcp_modlogs":
            $location_name = $lang->viewing_modlogs;
            break;
        case "modcp_announcements":
            $location_name = $lang->managing_announcements;
            break;
        case "modcp_finduser":
            $location_name = $lang->search_for_user;
            break;
        case "modcp_warninglogs":
            $location_name = $lang->managing_warninglogs;
            break;
        case "modcp_ipsearch":
            $location_name = $lang->searching_ips;
            break;
        case "modcp_report":
            $location_name = $lang->viewing_reports;
            break;
        case "modcp_new_announcement":
            $location_name = $lang->adding_announcement;
            break;
        case "modcp_delete_announcement":
            $location_name = $lang->deleting_announcement;
            break;
        case "modcp_edit_announcement":
            $location_name = $lang->editing_announcement;
            break;
        case "modcp_mod_queue":
            $location_name = $lang->managing_modqueue;
            break;
        case "modcp_editprofile":
            $location_name = $lang->editing_user_profiles;
            break;
        case "modcp_banning":
            $location_name = $lang->managing_bans;
            break;
        case "modcp":
            $location_name = $lang->viewing_modcp;
            break;
            // moderation.php functions
        // moderation.php functions
        case "moderation":
            $location_name = $lang->using_modtools;
            break;
            // newreply.php functions
        // newreply.php functions
        case "newreply":
            if (!empty($threads[$user_activity['tid']])) {
                $location_name = $lang->sprintf($lang->replying_thread2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']]);
            } else {
                $location_name = $lang->replying_thread;
            }
            break;
            // newthread.php functions
        // newthread.php functions
        case "newthread":
            if (!empty($forums[$user_activity['fid']])) {
                $location_name = $lang->sprintf($lang->posting_thread2, get_forum_link($user_activity['fid']), $forums[$user_activity['fid']]);
            } else {
                $location_name = $lang->posting_thread;
            }
            break;
            // online.php functions
        // online.php functions
        case "wol":
            $location_name = $lang->viewing_wol;
            break;
        case "woltoday":
            $location_name = $lang->viewing_woltoday;
            break;
            // polls.php functions
        // polls.php functions
        case "newpoll":
            $location_name = $lang->creating_poll;
            break;
        case "editpoll":
            $location_name = $lang->editing_poll;
            break;
        case "showresults":
            $location_name = $lang->viewing_pollresults;
            break;
        case "vote":
            $location_name = $lang->voting_poll;
            break;
            // printthread.php functions
        // printthread.php functions
        case "printthread":
            if (!empty($threads[$user_activity['tid']])) {
                $location_name = $lang->sprintf($lang->printing_thread2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']]);
            } else {
                $location_name = $lang->printing_thread;
            }
            break;
            // private.php functions
        // private.php functions
        case "private_send":
            $location_name = $lang->sending_pm;
            break;
        case "private_read":
            $location_name = $lang->reading_pm;
            break;
        case "private_folders":
            $location_name = $lang->editing_pmfolders;
            break;
        case "private":
            $location_name = $lang->using_pmsystem;
            break;
            /* Ratethread functions */
        /* Ratethread functions */
        case "ratethread":
            $location_name = $lang->rating_thread;
            break;
            // report.php functions
        // report.php functions
        case "report":
            $location_name = $lang->reporting_post;
            break;
            // reputation.php functions
        // reputation.php functions
        case "reputation":
            $location_name = $lang->sprintf($lang->giving_reputation, get_profile_link($user_activity['uid']), $usernames[$user_activity['uid']]);
            break;
        case "reputation_report":
            if (!empty($usernames[$user_activity['uid']])) {
                $location_name = $lang->sprintf($lang->viewing_reputation_report, "reputation.php?uid={$user_activity['uid']}", $usernames[$user_activity['uid']]);
            } else {
                $location_name = $lang->sprintf($lang->viewing_reputation_report2);
            }
            break;
            // search.php functions
        // search.php functions
        case "search":
            $location_name = $lang->sprintf($lang->searching_forum, $mybb->settings['bbname']);
            break;
            // showthread.php functions
        // showthread.php functions
        case "showthread":
            if (!empty($threads[$user_activity['tid']])) {
                $pagenote = '';
                $location_name = $lang->sprintf($lang->reading_thread2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']], $pagenote);
            } else {
                $location_name = $lang->reading_thread;
            }
            break;
        case "showpost":
            if (!empty($posts[$user_activity['pid']]) && !empty($threads[$posts[$user_activity['pid']]])) {
                $pagenote = '';
                $location_name = $lang->sprintf($lang->reading_thread2, get_thread_link($posts[$user_activity['pid']]), $threads[$posts[$user_activity['pid']]], $pagenote);
            } else {
                $location_name = $lang->reading_thread;
            }
            break;
            // showteam.php functions
        // showteam.php functions
        case "showteam":
            $location_name = $lang->viewing_team;
            break;
            // stats.php functions
        // stats.php functions
        case "stats":
            $location_name = $lang->viewing_stats;
            break;
            // usercp.php functions
        // usercp.php functions
        case "usercp_profile":
            $location_name = $lang->updating_profile;
            break;
        case "usercp_editlists":
            $location_name = $lang->managing_buddyignorelist;
            break;
        case "usercp_options":
            $location_name = $lang->updating_options;
            break;
        case "usercp_editsig":
            $location_name = $lang->editing_signature;
            break;
        case "usercp_avatar":
            $location_name = $lang->changing_avatar;
            break;
        case "usercp_subscriptions":
            $location_name = $lang->viewing_subscriptions;
            break;
        case "usercp_favorites":
            $location_name = $lang->viewing_favorites;
            break;
        case "usercp_notepad":
            $location_name = $lang->editing_pad;
            break;
        case "usercp_password":
            $location_name = $lang->editing_password;
            break;
        case "usercp":
            $location_name = $lang->user_cp;
            break;
        case "usercp2_favorites":
            $location_name = $lang->managing_favorites;
            break;
        case "usercp2_subscriptions":
            $location_name = $lang->managing_subscriptions;
            break;
        case "portal":
            $location_name = $lang->viewing_portal;
            break;
            // sendthread.php functions
        // sendthread.php functions
        case "sendthread":
            $location_name = $lang->sending_thread;
            break;
            // warnings.php functions
        // warnings.php functions
        case "warnings_revoke":
            $location_name = $lang->revoking_warning;
            break;
        case "warnings_warn":
            $location_name = $lang->warning_user;
            break;
        case "warnings_view":
            $location_name = $lang->viewing_warning;
            break;
        case "warnings":
            $location_name = $lang->managing_warnings;
            break;
    }
    $plugin_array = array('user_activity' => &$user_activity, 'location_name' => &$location_name);
    $plugins->run_hooks("build_friendly_wol_location_end", $plugin_array);
    if (isset($user_activity['nopermission']) && $user_activity['nopermission'] == 1) {
        $location_name = $lang->viewing_noperms;
    }
    if (!$location_name) {
        $location_name = $lang->sprintf($lang->unknown_location, $user_activity['location']);
    }
    return $location_name;
}
Пример #7
0
/**
 * @param array $view
 *
 * @return string
 */
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'] = my_unserialize($view['conditions']);
    }
    if (!is_array($view['fields'])) {
        $view['fields'] = my_unserialize($view['fields']);
    }
    if (!is_array($view['custom_profile_fields'])) {
        $view['custom_profile_fields'] = my_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", "skype", "google", "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", "threadnum");
    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]) && (int) $view['conditions'][$search_field]) {
            $threshold = TIME_NOW - (int) $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])) {
            $ip_range = fetch_ip_range($view['conditions'][$search_field]);
            if (!is_array($ip_range)) {
                $ip_sql = "{$search_field}=" . $db->escape_binary($ip_range);
            } else {
                $ip_sql = "{$search_field} BETWEEN " . $db->escape_binary($ip_range[0]) . " AND " . $db->escape_binary($ip_range[1]);
            }
            $search_sql .= " AND {$ip_sql}";
        }
    }
    // Post IP searching
    if (!empty($view['conditions']['postip'])) {
        $ip_range = fetch_ip_range($view['conditions']['postip']);
        if (!is_array($ip_range)) {
            $ip_sql = "ipaddress=" . $db->escape_binary($ip_range);
        } else {
            $ip_sql = "ipaddress BETWEEN " . $db->escape_binary($ip_range[0]) . " AND " . $db->escape_binary($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_like($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 = (int) $usergroup;
            if (!$usergroup) {
                continue;
            }
            $additional_sql = '';
            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'] = (int) $view['perpage'];
        // 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'] = $mybb->get_input('page', MyBB::INPUT_INT);
        }
        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 "numthreads":
                $view['sortby'] = "threadnum";
                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('relative', $user['regdate']);
            $user['view']['lastactive'] = my_date('relative', $user['lastactive']);
            // Build popup menu
            $popup = new PopupMenu("user_{$user['uid']}", $lang->options);
            $popup->add_item($lang->view_profile, $mybb->settings['bburl'] . '/' . get_profile_link($user['uid']));
            $popup->add_item($lang->edit_profile_and_settings, "index.php?module=user-users&amp;action=edit&amp;uid={$user['uid']}");
            // Banning options... is this user banned?
            if ($usergroups[$user['usergroup']]['isbannedgroup'] == 1) {
                // Yes, so do we want to edit the ban or pardon his crime?
                $popup->add_item($lang->edit_ban, "index.php?module=user-banning&amp;uid={$user['uid']}#username");
                $popup->add_item($lang->lift_ban, "index.php?module=user-banning&action=lift&uid={$user['uid']}&my_post_key={$mybb->post_code}");
            } else {
                // Not banned... but soon maybe!
                $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) {
                if ($mybb->settings['maxwarningpoints'] < 1) {
                    $mybb->settings['maxwarningpoints'] = 10;
                }
                $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'] && my_substr($user['avatar'], 0, 7) !== 'http://' && my_substr($user['avatar'], 0, 8) !== 'https://') {
                $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'] = "../" . $mybb->settings['useravatar'];
            }
            $user['view']['avatar'] = "<img src=\"" . htmlspecialchars_uni($user['avatar']) . "\" alt=\"\" width=\"{$scaled_avatar['width']}\" height=\"{$scaled_avatar['height']}\" />";
            // Convert IP's to readable
            $user['regip'] = my_inet_ntop($db->unescape_binary($user['regip']));
            $user['lastip'] = my_inet_ntop($db->unescape_binary($user['lastip']));
            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=" . $mybb->get_input('page', MyBB::INPUT_INT);
    }
    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 = \$(\"#search_form\");\n\t\tform.submit(function() {\n\t\t\tvar search = \$('#search_keywords');\n\t\t\tif(search.val() == '' || search.val() == '" . 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 = \$(\"#search_keywords\");\n\t\tsearch.focus(function()\n\t\t{\n\t\t\tvar searched_focus = \$(this);\n\t\t\tif(searched_focus.val() == '" . addcslashes($lang->search_for_user, "'") . "')\n\t\t\t{\n\t\t\t\tsearched_focus.removeClass(\"search_default\");\n\t\t\t\tsearched_focus.val(\"\");\n\t\t\t}\n\t\t});\n\n\t\tsearch.blur(function()\n\t\t{\n\t\t\tvar searched_blur = \$(this);\n\t\t\tif(searched_blur.val() == \"\")\n\t\t\t{\n\t\t\t\tsearched_blur.addClass('search_default');\n\t\t\t\tsearched_blur.val('" . addcslashes($lang->search_for_user, "'") . "');\n\t\t\t}\n\t\t});\n\n\t\t// fix the styling used if we have a different default value\n\t\tif(search.val() != '" . addcslashes($lang->search_for_user, "'") . "')\n\t\t{\n\t\t\t\$(search).removeClass('search_default');\n\t\t}\n\t\t</script>\n";
    $built_view .= "</div>\n";
    // Autocompletion for usernames
    // TODO Select2
    $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=1800"></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">
	<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="submit_button inline_element" name="go" value="' . $lang->go . ' (0)" id="inline_go" />&nbsp;
<input type="button" onclick="javascript:inlineModeration.clearChecked();" value="' . $lang->clear . '" class="submit_button inline_element" />
</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;
}
/**
* Build a list of forum bits.
*
* @param int The parent forum to fetch the child forums for (0 assumes all)
* @param int The depth to return forums with.
* @return array Array of information regarding the child forums of this parent forum
*/
function build_forumbits($pid = 0, $depth = 1)
{
    global $fcache, $moderatorcache, $forumpermissions, $theme, $mybb, $templates, $bgcolor, $collapsed, $lang, $showdepth, $plugins, $parser, $forum_viewers;
    $forum_listing = '';
    // If no forums exist with this parent, do nothing
    if (!is_array($fcache[$pid])) {
        return;
    }
    // Foreach of the forums in this parent
    foreach ($fcache[$pid] as $parent) {
        foreach ($parent as $forum) {
            $forums = $subforums = $sub_forums = '';
            $lastpost_data = '';
            $counters = '';
            $forum_viewers_text = '';
            $forum_viewers_text_plain = '';
            // Get the permissions for this forum
            $permissions = $forumpermissions[$forum['fid']];
            // If this user doesnt have permission to view this forum and we're hiding private forums, skip this forum
            if ($permissions['canview'] != 1 && $mybb->settings['hideprivateforums'] == 1) {
                continue;
            }
            $plugins->run_hooks_by_ref("build_forumbits_forum", $forum);
            // Build the link to this forum
            $forum_url = get_forum_link($forum['fid']);
            // This forum has a password, and the user isn't authenticated with it - hide post information
            $hideinfo = false;
            $showlockicon = 0;
            if ($permissions['canviewthreads'] != 1) {
                $hideinfo = true;
            }
            if ($forum['password'] != '' && $mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'] . $forum['password'])) {
                $hideinfo = true;
                $showlockicon = 1;
            }
            $lastpost_data = array("lastpost" => $forum['lastpost'], "lastpostsubject" => $forum['lastpostsubject'], "lastposter" => $forum['lastposter'], "lastposttid" => $forum['lastposttid'], "lastposteruid" => $forum['lastposteruid']);
            // Fetch subforums of this forum
            if (isset($fcache[$forum['fid']])) {
                $forum_info = build_forumbits($forum['fid'], $depth + 1);
                // Increment forum counters with counters from child forums
                $forum['threads'] += $forum_info['counters']['threads'];
                $forum['posts'] += $forum_info['counters']['posts'];
                $forum['unapprovedthreads'] += $forum_info['counters']['unapprovedthreads'];
                $forum['unapprovedposts'] += $forum_info['counters']['unapprovedposts'];
                $forum['viewers'] += $forum_info['counters']['viewing'];
                // If the child forums' lastpost is greater than the one for this forum, set it as the child forums greatest.
                if ($forum_info['lastpost']['lastpost'] > $lastpost_data['lastpost']) {
                    $lastpost_data = $forum_info['lastpost'];
                }
                $sub_forums = $forum_info['forum_list'];
            }
            // If we are hiding information (lastpost) because we aren't authenticated against the password for this forum, remove them
            if ($hideinfo == true) {
                unset($lastpost_data);
            }
            // If the current forums lastpost is greater than other child forums of the current parent, overwrite it
            if ($lastpost_data['lastpost'] > $parent_lastpost['lastpost']) {
                $parent_lastpost = $lastpost_data;
            }
            if (is_array($forum_viewers) && $forum_viewers[$forum['fid']] > 0) {
                $forum['viewers'] = $forum_viewers[$forum['fid']];
            }
            // Increment the counters for the parent forum (returned later)
            if ($hideinfo != true) {
                $parent_counters['threads'] += $forum['threads'];
                $parent_counters['posts'] += $forum['posts'];
                $parent_counters['unapprovedposts'] += $forum['unapprovedposts'];
                $parent_counters['unapprovedthreads'] += $forum['unapprovedthreads'];
                $parent_counters['viewers'] += $forum['viewers'];
            }
            // Done with our math, lets talk about displaying - only display forums which are under a certain depth
            if ($depth > $showdepth) {
                continue;
            }
            // Get the lightbulb status indicator for this forum based on the lastpost
            $lightbulb = get_forum_lightbulb($forum, $lastpost_data, $showlockicon);
            // Fetch the number of unapproved threads and posts for this forum
            $unapproved = get_forum_unapproved($forum);
            if ($hideinfo == true) {
                unset($unapproved);
            }
            // Sanitize name and description of forum.
            $forum['name'] = preg_replace("#&(?!\\#[0-9]+;)#si", "&amp;", $forum['name']);
            // Fix & but allow unicode
            $forum['description'] = preg_replace("#&(?!\\#[0-9]+;)#si", "&amp;", $forum['description']);
            // Fix & but allow unicode
            $forum['name'] = preg_replace("#&([^\\#])(?![a-z1-4]{1,10};)#i", "&#038;\$1", $forum['name']);
            $forum['description'] = preg_replace("#&([^\\#])(?![a-z1-4]{1,10};)#i", "&#038;\$1", $forum['description']);
            // If this is a forum and we've got subforums of it, load the subforums list template
            if ($depth == 2 && $sub_forums) {
                eval("\$subforums = \"" . $templates->get("forumbit_subforums") . "\";");
            } else {
                if ($depth == 3) {
                    if ($donecount < $mybb->settings['subforumsindex']) {
                        $statusicon = '';
                        // Showing mini status icons for this forum
                        if ($mybb->settings['subforumsstatusicons'] == 1) {
                            $lightbulb['folder'] = "mini" . $lightbulb['folder'];
                            eval("\$statusicon = \"" . $templates->get("forumbit_depth3_statusicon", 1, 0) . "\";");
                        }
                        // Fetch the template and append it to the list
                        eval("\$forum_list .= \"" . $templates->get("forumbit_depth3", 1, 0) . "\";");
                        $comma = ', ';
                    }
                    // Have we reached our max visible subforums? put a nice message and break out of the loop
                    ++$donecount;
                    if ($donecount == $mybb->settings['subforumsindex']) {
                        if (subforums_count($fcache[$pid]) > $donecount) {
                            $forum_list .= $comma . $lang->sprintf($lang->more_subforums, subforums_count($fcache[$pid]) - $donecount);
                        }
                    }
                    continue;
                }
            }
            // Forum is a category, set template type
            if ($forum['type'] == 'c') {
                $forumcat = '_cat';
            } else {
                $forumcat = '_forum';
            }
            if ($forum['linkto'] == '') {
                // No posts have been made in this forum - show never text
                if (($lastpost_data['lastpost'] == 0 || $lastpost_data['lastposter'] == '') && $hideinfo != true) {
                    $lastpost = "<div style=\"text-align: center;\">{$lang->lastpost_never}</div>";
                } elseif ($hideinfo != true) {
                    // Format lastpost date and time
                    $lastpost_date = my_date($mybb->settings['dateformat'], $lastpost_data['lastpost']);
                    $lastpost_time = my_date($mybb->settings['timeformat'], $lastpost_data['lastpost']);
                    // Set up the last poster, last post thread id, last post subject and format appropriately
                    $lastpost_profilelink = build_profile_link($lastpost_data['lastposter'], $lastpost_data['lastposteruid']);
                    $lastpost_link = get_thread_link($lastpost_data['lastposttid'], 0, "lastpost");
                    $lastpost_subject = $full_lastpost_subject = $parser->parse_badwords($lastpost_data['lastpostsubject']);
                    if (my_strlen($lastpost_subject) > 25) {
                        $lastpost_subject = my_substr($lastpost_subject, 0, 25) . "...";
                    }
                    $lastpost_subject = htmlspecialchars_uni($lastpost_subject);
                    $full_lastpost_subject = htmlspecialchars_uni($full_lastpost_subject);
                    // Call lastpost template
                    if ($depth != 1) {
                        eval("\$lastpost = \"" . $templates->get("forumbit_depth{$depth}_forum_lastpost") . "\";");
                    }
                }
                if ($mybb->settings['showforumviewing'] != 0 && $forum['viewers'] > 0) {
                    if ($forum['viewers'] == 1) {
                        $forum_viewers_text = $lang->viewing_one;
                    } else {
                        $forum_viewers_text = $lang->sprintf($lang->viewing_multiple, $forum['viewers']);
                    }
                    $forum_viewers_text_plain = $forum_viewers_text;
                    $forum_viewers_text = "<span class=\"smalltext\">{$forum_viewers_text}</span>";
                }
            }
            // If this forum is a link or is password protected and the user isn't authenticated, set lastpost and counters to "-"
            if ($forum['linkto'] != '' || $hideinfo == true) {
                $lastpost = "<div style=\"text-align: center;\">-</div>";
                $posts = "-";
                $threads = "-";
            } else {
                $posts = my_number_format($forum['posts']);
                $threads = my_number_format($forum['threads']);
            }
            // Moderator column is not off
            if ($mybb->settings['modlist'] != 0) {
                $done_moderators = array();
                $moderators = '';
                // Fetch list of moderators from this forum and its parents
                $parentlistexploded = explode(',', $forum['parentlist']);
                foreach ($parentlistexploded as $mfid) {
                    // This forum has moderators
                    if (is_array($moderatorcache[$mfid])) {
                        // Fetch each moderator from the cache and format it, appending it to the list
                        foreach ($moderatorcache[$mfid] as $moderator) {
                            if (in_array($moderator['uid'], $done_moderators)) {
                                continue;
                            }
                            $moderators .= "{$comma}<a href=\"" . get_profile_link($moderator['uid']) . "\">" . htmlspecialchars_uni($moderator['username']) . "</a>";
                            $comma = ', ';
                            $done_moderators[] = $moderator['uid'];
                        }
                    }
                }
                $comma = '';
                // If we have a moderators list, load the template
                if ($moderators) {
                    eval("\$modlist = \"" . $templates->get("forumbit_moderators") . "\";");
                } else {
                    $modlist = '';
                }
            }
            // Descriptions aren't being shown - blank them
            if ($mybb->settings['showdescriptions'] == 0) {
                $forum['description'] = '';
            }
            // Check if this category is either expanded or collapsed and hide it as necessary.
            $expdisplay = '';
            $collapsed_name = "cat_{$forum['fid']}_c";
            if (isset($collapsed[$collapsed_name]) && $collapsed[$collapsed_name] == "display: show;") {
                $expcolimage = "collapse_collapsed.gif";
                $expdisplay = "display: none;";
                $expaltext = "[+]";
            } else {
                $expcolimage = "collapse.gif";
                $expaltext = "[-]";
            }
            // Swap over the alternate backgrounds
            $bgcolor = alt_trow();
            // Add the forum to the list
            eval("\$forum_list .= \"" . $templates->get("forumbit_depth{$depth}{$forumcat}") . "\";");
        }
    }
    // Return an array of information to the parent forum including child forums list, counters and lastpost information
    return array("forum_list" => $forum_list, "counters" => $parent_counters, "lastpost" => $parent_lastpost);
}
Пример #9
0
    if (is_array($moderatorcache[$mfid])) {
        // Fetch each moderator from the cache and format it, appending it to the list
        foreach ($moderatorcache[$mfid] as $modtype) {
            foreach ($modtype as $moderator) {
                if ($moderator['isgroup']) {
                    if (in_array($moderator['id'], $done_moderators['groups'])) {
                        continue;
                    }
                    $moderator['title'] = htmlspecialchars_uni($moderator['title']);
                    eval("\$moderators .= \"" . $templates->get("forumbit_moderators_group", 1, 0) . "\";");
                    $done_moderators['groups'][] = $moderator['id'];
                } else {
                    if (in_array($moderator['id'], $done_moderators['users'])) {
                        continue;
                    }
                    $moderator['profilelink'] = get_profile_link($moderator['id']);
                    $moderator['username'] = format_name(htmlspecialchars_uni($moderator['username']), $moderator['usergroup'], $moderator['displaygroup']);
                    eval("\$moderators .= \"" . $templates->get("forumbit_moderators_user", 1, 0) . "\";");
                    $done_moderators['users'][] = $moderator['id'];
                }
                $comma = $lang->comma;
            }
        }
    }
    if (!empty($forum_stats[$mfid]['announcements'])) {
        $has_announcements = true;
    }
}
$comma = '';
// If we have a moderators list, load the template
if ($moderators) {
Пример #10
0
 /**
  * This will try to guess the exact page on which the comment identified by $cid exists.
  * @param int $cid The comment ID
  * @param boolean $href whether or not to surround the link with an anchor
  * @param string $link_name if $href is enabled, enter the link name that will be displayed between the anchor opening and closing tags
  * @param string $other_params if you wish to include some other parameters such as target="_blank", do that here, include a space at the beginning
  * @return string the comment link, or an empty string if no comment has been found
  */
 public function build_comment_link($cid, $href = false, $link_name = "", $other_params = "")
 {
     global $db, $settings, $mybb;
     $cid = (int) $cid;
     //SELECT a.*, (select count(*) from `mybb_myprofilecomments` b where a.cid >= b.cid) as cnt FROM `mybb_myprofilecomments` a WHERE a.cid='2'
     $query = $db->query("SELECT a.*, (SELECT COUNT(*) FROM " . TABLE_PREFIX . "myprofilecomments b WHERE a.cid <= b.cid) AS rownum FROM " . TABLE_PREFIX . "myprofilecomments a WHERE a.cid='{$cid}'");
     if ($db->num_rows($query) != 1) {
         return "";
     }
     $comment = $db->fetch_array($query);
     $user = get_user($comment["userid"]);
     $page = ceil($comment["rownum"] / $settings["mpcommentsperpage"]);
     $profile_link = "{$mybb->settings['bburl']}/" . get_profile_link($user["uid"]);
     if ($settings["mpcommentsajaxenabled"]) {
         $complement = "#comments/" . $page . "/highlight/" . $cid;
     } else {
         $complement = "&page={$page}&highlight={$cid}";
     }
     $profile_link .= $complement;
     if ($href) {
         $profile_link = "<a href=\"{$profile_link}\"{$other_params}>{$link_name}</a>";
     }
     return $profile_link;
 }
Пример #11
0
function ougc_awards_profile()
{
    global $mybb, $memprofile, $templates;
    $memprofile['ougc_awards'] = '';
    $limit = (int) $mybb->settings['ougc_awards_profile'];
    $limit = $limit > 100 ? 100 : ($limit < 1 && $limit != -1 ? 1 : $limit);
    if ($limit < 0 && $limit != -1 || my_strpos($templates->cache['member_profile'], '{$memprofile[\'ougc_awards\']}') === false) {
        return;
    }
    global $db, $lang, $theme, $templates, $awards;
    $awards->lang_load();
    $awards->set_url(null, get_profile_link($memprofile['uid']));
    // Query our data.
    if ($limit == -1) {
        // Get awards
        $query = $db->query('
			SELECT u.*, a.*
			FROM ' . TABLE_PREFIX . 'ougc_awards_users u
			LEFT JOIN ' . TABLE_PREFIX . 'ougc_awards a ON (u.aid=a.aid)
			WHERE u.uid=\'' . (int) $memprofile['uid'] . '\' AND a.visible=\'1\'
			ORDER BY u.date desc');
    } else {
        // First we need to figure out the total amount of awards.
        $query = $db->query('
			SELECT COUNT(au.aid) AS awards
			FROM ' . TABLE_PREFIX . 'ougc_awards_users au
			LEFT JOIN ' . TABLE_PREFIX . 'ougc_awards a ON (au.aid=a.aid)
			WHERE au.uid=\'' . (int) $memprofile['uid'] . '\' AND a.visible=\'1\'
			ORDER BY au.date desc
		');
        $awardscount = (int) $db->fetch_field($query, 'awards');
        $page = (string) $mybb->input['view'] == 'awards' ? (int) $mybb->input['page'] : 0;
        if ($page > 0) {
            $start = ($page - 1) * $limit;
            if ($page > ceil($awardscount / $limit)) {
                $start = 0;
                $page = 1;
            }
        } else {
            $start = 0;
            $page = 1;
        }
        // We want to keep $mybb->input['view'] intact for other plugins, ;)
        $multipage = (string) multipage($awardscount, $limit, $page, $awards->build_url('view=awards'));
        eval('$multipage = "' . $templates->get('ougcawards_profile_multipage') . '";');
        $query = $db->query('
			SELECT au.*, a.*
			FROM ' . TABLE_PREFIX . 'ougc_awards_users au
			LEFT JOIN ' . TABLE_PREFIX . 'ougc_awards a ON (au.aid=a.aid)
			WHERE au.uid=\'' . (int) $memprofile['uid'] . '\' AND a.visible=\'1\'
			ORDER BY au.date desc
			LIMIT ' . $start . ', ' . $limit);
    }
    // Output our awards.
    if (!$db->num_rows($query)) {
        eval('$awardlist = "' . $templates->get('ougcawards_profile_row_empty') . '";');
    } else {
        $awardlist = '';
        while ($award = $db->fetch_array($query)) {
            $trow = alt_trow();
            if ($name = $awards->get_award_info('name', $award['aid'])) {
                $award['name'] = $name;
            }
            if ($description = $awards->get_award_info('description', $award['aid'])) {
                $award['description'] = $description;
            }
            if ($reason = $awards->get_award_info('reason', $award['aid'], $award['gid'])) {
                $award['reason'] = $reason;
            }
            if (empty($award['reason'])) {
                $award['reason'] = $lang->ougc_awards_pm_noreason;
            }
            $awards->parse_text($award['reason']);
            $award['image'] = $awards->get_award_icon($award['aid']);
            $award['date'] = $lang->sprintf($lang->ougc_awards_profile_tine, my_date($mybb->settings['dateformat'], $award['date']), my_date($mybb->settings['timeformat'], $award['date']));
            eval('$awardlist .= "' . $templates->get('ougcawards_profile_row') . '";');
        }
    }
    $lang->ougc_awards_profile_title = $lang->sprintf($lang->ougc_awards_profile_title, htmlspecialchars_uni($memprofile['username']));
    eval('$memprofile[\'ougc_awards\'] = "' . $templates->get('ougcawards_profile') . '";');
}
Пример #12
0
     $information = '';
     $logitem['action'] = htmlspecialchars_uni($logitem['action']);
     $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");
     if ($logitem['tsubject']) {
         $information = "<strong>{$lang->thread}</strong> <a href=\"../" . get_thread_link($logitem['tid']) . "\" target=\"_blank\">" . htmlspecialchars_uni($logitem['tsubject']) . "</a><br />";
     }
     if ($logitem['fname']) {
         $information .= "<strong>{$lang->forum}</strong> <a href=\"../" . get_forum_link($logitem['fid']) . "\" target=\"_blank\">" . htmlspecialchars_uni($logitem['fname']) . "</a><br />";
     }
     if (!$logitem['tsubject'] || !$logitem['fname']) {
         $data = unserialize($logitem['data']);
         if ($data['uid']) {
             $information = "<strong>{$lang->user_info}</strong> <a href=\"../" . get_profile_link($data['uid']) . "\" target=\"_blank\">" . htmlspecialchars_uni($data['username']) . "</a>";
         }
         if ($data['aid']) {
             $information = "<strong>{$lang->announcement}</strong> <a href=\"../" . get_announcement_link($data['aid']) . "\" target=\"_blank\">" . htmlspecialchars_uni($data['subject']) . "</a>";
         }
     }
     $table->construct_cell($logitem['profilelink']);
     $table->construct_cell($logitem['dateline'], array("class" => "align_center"));
     $table->construct_cell($logitem['action'], array("class" => "align_center"));
     $table->construct_cell($information);
     $table->construct_cell($logitem['ipaddress'], array("class" => "align_center"));
     $table->construct_row();
 }
 if ($table->num_rows() == 0) {
     $table->construct_cell($lang->no_modlogs, array("colspan" => "5"));
     $table->construct_row();
 /**
  * Build a link to an alert's content so that the system can redirect to it.
  *
  * @param MybbStuff_MyAlerts_Entity_Alert $alert The alert to build the link for.
  *
  * @return string The built alert, preferably an absolute link.
  */
 public function buildShowLink(MybbStuff_MyAlerts_Entity_Alert $alert)
 {
     return get_profile_link($alert->getFromUserId());
 }
 public function gen_profile_link($text, $uid)
 {
     return '<a href="' . $this->settings['bburl'] . '/' . get_profile_link($uid) . '">' . $text . '</a>';
 }
Пример #15
0
         } else {
             $table->construct_cell("{$find_to}<div><a href=\"../" . get_profile_link($log['touid']) . "\">{$log['to_username']}</a></div>");
         }
     } elseif ($log['type'] == 3) {
         $table->construct_cell("<img src=\"styles/{$page->style}/images/icons/maillogs_contact.png\" title=\"{$lang->email_sent_using_contact_form}\" alt=\"\" />", array("width" => 1));
         $table->construct_cell("<a href=\"javascript:MyBB.popupWindow('index.php?module=tools-maillogs&amp;action=view&amp;mid={$log['mid']}', null, true);\">{$log['subject']}</a>");
         if ($log['fromuid'] > 0) {
             $find_from = "<div class=\"float_right\"><a href=\"index.php?module=tools-maillogs&amp;fromuid={$log['fromuid']}\"><img src=\"styles/{$page->style}/images/icons/find.png\" title=\"{$lang->find_emails_by_user}\" alt=\"{$lang->find}\" /></a></div>";
         }
         if (!$log['from_username'] && $log['fromuid'] > 0) {
             $table->construct_cell("{$find_from}<div>{$lang->deleted_user}</div>");
         } elseif ($log['fromuid'] == 0) {
             $log['fromemail'] = htmlspecialchars_uni($log['fromemail']);
             $table->construct_cell("{$find_from}<div>{$log['fromemail']}</div>");
         } else {
             $table->construct_cell("{$find_from}<div><a href=\"../" . get_profile_link($log['fromuid']) . "\">{$log['from_username']}</a></div>");
         }
         $log['toemail'] = htmlspecialchars_uni($log['toemail']);
         $table->construct_cell($log['toemail']);
     }
     $table->construct_cell($log['dateline'], array("class" => "align_center"));
     $table->construct_cell(my_inet_ntop($db->unescape_binary($log['ipaddress'])), array("class" => "align_center"));
     $table->construct_row();
 }
 if ($table->num_rows() == 0) {
     $table->construct_cell($lang->no_logs, array("colspan" => "7"));
     $table->construct_row();
     $table->output($lang->user_email_log);
 } else {
     $table->output($lang->user_email_log);
     $buttons[] = $form->generate_submit_button($lang->delete_selected, array('onclick' => "return confirm('{$lang->confirm_delete_logs}');"));
 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));
 }
Пример #17
0
function chatcat_insert_footer()
{
    global $mybb, $templates, $myval;
    $myval = "";
    if ($mybb->settings['chatcat_enable'] == 1) {
        $apikey = $mybb->settings['chatcat_enable_api'];
        $api_url = '';
        if (strlen($mybb->settings['chatcat_enable_api']) != 0) {
            $user = $mybb->user;
            $api_key = $mybb->settings['chatcat_enable_api'];
            $secret = $mybb->settings['chatcat_secret'];
            $uid = $user['uid'];
            if (function_exists('format_avatar')) {
                $useravatar = format_avatar(htmlspecialchars_uni($user['avatar']), $user['avatardimensions'], my_strtolower($mybb->settings['memberlistmaxavatarsize']));
                if (!empty($useravatar['image'])) {
                    $src = $useravatar['image'];
                }
            }
            $username = $user['username'];
            $dateOfBirth = strtotime($user['birthday']) * 1000;
            //var_dump($user);
            // Get the user's description
            $description = $user['fid2'];
            $location = $user['fid1'];
            $sex = $user['fid3'];
            $params = array('api_key' => $api_key, 'secret' => $secret, 'src' => urlencode($src), 'username' => $username, 'description' => $description, 'uid' => $uid, 'dateOfBirth' => $dateOfBirth, 'location' => $location, 'sex' => $sex, 'homepage' => urlencode($mybb->settings['bburl'] . "/" . get_profile_link($uid)));
            $extension = '?';
            foreach ($params as $key => $value) {
                if ($value) {
                    $extension .= $key . '=' . $value . '&';
                }
            }
            $extension = substr($extension, 0, -1);
            $api_url = $mybb->settings['bburl'] . '/ajaxchat.php' . $extension;
        }
        if ($mybb->settings['chatcat_enable_login'] == '') {
            $login_url = $mybb->settings['bburl'] . '/member.php?action=login';
        } else {
            $login_url = $mybb->settings['chatcat_enable_login'];
            if (!preg_match("@^[hf]tt?ps?://@", $login_url)) {
                $login_url = "http://" . $login_url;
            }
        }
        if ($mybb->settings['chatcat_enable_register'] == '') {
            $register_url = $mybb->settings['bburl'] . '/member.php?action=register';
        } else {
            $register_url = $mybb->settings['chatcat_enable_register'];
            if (!preg_match("@^[hf]tt?ps?://@", $register_url)) {
                $register_url = "http://" . $register_url;
            }
        }
        if ($mybb->settings['chatcat_enable_primary'] != '') {
            $primary_url = $mybb->settings['chatcat_enable_primary'];
        } else {
            $primary_url = $mybb->settings['bburl'];
        }
        ?>

    <div ng-app="myApp" ><ng-include src=" baseURL + 'chatcat.html'" ng-controller="AppController"></ng-include></div>
    <script type="text/javascript">

        // Set options here
        var CC_OPTIONS = {

            
            primaryDomain: '<?php 
        echo $primary_url;
        ?>
',
			        

            // Users can create public chat rooms?
            // If this is true users will be able to setup new
            // public rooms
            usersCanCreatePublicRooms: true,

            // Allow anonymous login?
            anonymousLoginEnabled: false,

            // Enable social login - please email us to get your domain whitelisted
            socialLoginEnabled: true,

            // The URL to contact for single sign on
            singleSignOnURL: '<?php 
        echo $api_url;
        ?>
',
            singleSignOnAPILevel: 1,

            // Optional - if this is set the login box will direct users
            // to log in
            loginURL: '<?php 
        echo $login_url;
        ?>
',

            // Optional - if this is set the login box will direct users
            // to register
            registerURL: '<?php 
        echo $register_url;
        ?>
'

        }

        var ccProtocol = (("https:" == document.location.protocol) ? "https://" : "http://");

    <?php 
        if ($_SERVER['SERVER_NAME'] == 'ccwp') {
            ?>

        // TEST
        document.write(decodeURI("%3Clink rel='stylesheet' href='" + ccProtocol + "chatcat/dist/css/_/cc_styles.min.css' %3E%3C/link%3E"));
        document.write(decodeURI("%3Cscript src='" + ccProtocol + "chatcat/dist/js/all.js' type='text/javascript'%3E%3C/script%3E"));

    <?php 
        } else {
            ?>

        // PRODUCTION
        document.write(decodeURI("%3Clink rel='stylesheet' href='" + ccProtocol + "chatcat.firebaseapp.com/css/_/cc_styles.min.css' %3E%3C/link%3E"));
        document.write(decodeURI("%3Cscript src='" + ccProtocol + "chatcat.firebaseapp.com/js/all.min.js' type='text/javascript'%3E%3C/script%3E"));

    <?php 
        }
        ?>

    </script>

<?php 
    }
}
function asb_staff_online_box_get_online_staff($settings, $width)
{
    global $db, $mybb, $templates, $lang, $cache, $theme;
    if (!$lang->asb_addon) {
        $lang->load('asb_addon');
    }
    // get our setting value
    $max_rows = (int) $settings['max_staff'];
    // if max_rows is set to 0 then show nothing
    if (!$max_rows) {
        return false;
    }
    // store our users and groups here
    $usergroups = array();
    $users = array();
    // get all the groups admin has specified should be shown on showteam.php
    $query = $db->simple_select('usergroups', 'gid, title, usertitle, image', 'showforumteam=1', array('order_by' => 'disporder'));
    while ($usergroup = $db->fetch_array($query)) {
        // store them in our array
        $usergroups[$usergroup['gid']] = $usergroup;
    }
    // get all the users of those specific groups
    $groups_in = implode(',', array_keys($usergroups));
    // if there were no groups . . .
    if (!$groups_in) {
        // there is nothing to show
        return false;
    }
    // set the time based on ACP settings
    $timesearch = TIME_NOW - $mybb->settings['wolcutoff'];
    // get all the users that are in staff groups that have been online within the allowed cutoff time
    $query = $db->query("\n\t\tSELECT\n\t\t\ts.sid, s.ip, s.uid, s.time, s.location,\n\t\t\tu.username, u.invisible, u.usergroup, u.displaygroup, u.avatar\n\t\tFROM {$db->table_prefix}sessions s\n\t\tLEFT JOIN {$db->table_prefix}users u ON (s.uid=u.uid)\n\t\tWHERE\n\t\t\t(displaygroup IN ({$groups_in}) OR (displaygroup='0' AND usergroup IN ({$groups_in}))) AND s.time > '{$timesearch}'\n\t\tORDER BY\n\t\t\tu.username ASC, s.time DESC\n\t");
    // loop through our users
    while ($user = $db->fetch_array($query)) {
        // if displaygroup is not 0 (display primary group) . . .
        if ($user['displaygroup'] != 0) {
            // then use this group
            $group = $user['displaygroup'];
        } else {
            // otherwise use the primary group
            $group = $user['usergroup'];
        }
        // if this user group is in a staff group then add the info to the list
        if ($usergroups[$group]) {
            $usergroups[$group]['user_list'][$user['uid']] = $user;
        }
    }
    // make sure we start from nothing
    $grouplist = '';
    $counter = 1;
    // loop through each user group
    foreach ($usergroups as $usergroup) {
        // if there are no users or we have reached our limit . . .
        if (!isset($usergroup['user_list']) || $counter > $max_rows) {
            // skip an iteration
            continue;
        }
        // we use this for the alternating table row bgcolor
        $bgcolor = '';
        // loop through all users
        foreach ($usergroup['user_list'] as $user) {
            // if we are over our limit
            if ($counter > $max_rows) {
                // don't add any more
                continue;
            }
            // prepare the info
            // alt and title for image are the same
            $staff_avatar_alt = $staff_avatar_title = $user['username'] . '\'s profile';
            // if the user has an avatar then display it, otherwise force the default avatar.
            $staff_avatar_filename = "{$theme['imgdir']}/default_avatar.gif";
            if ($user['avatar'] != '') {
                $staff_avatar_filename = $user['avatar'];
            }
            // avatar properties
            $staff_avatar_dimensions = '100%';
            // user name link properties
            $staff_link_title = $user['username'];
            $staff_username = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
            // link (for avatar and user name)
            $staff_profile_link = get_profile_link($user['uid']);
            // badge alt and title are the same
            $staff_badge_alt = $staff_badge_title = $usergroup['usertitle'];
            // if the user's group has a badge image . . .
            $staff_badge = "{$staff_badge_alt}";
            if ($usergroup['image']) {
                // store it (if nothing is store alt property will display group default usertitle)
                $staff_badge_filename = $usergroup['image'];
                $staff_badge = <<<EOF
<img src="{$staff_badge_filename}" alt="{$staff_badge_alt}" title="{$staff_badge_title}" width="{$staff_badge_width}"/>
EOF;
            }
            // give us an alternating bgcolor
            $bgcolor = alt_trow();
            // incremenet the counter
            ++$counter;
            // add this row to the table
            eval("\$online_staff .= \"" . $templates->get("asb_staff_online_bit") . "\";");
        }
    }
    // if there were staff members online . . .
    if ($online_staff) {
        // show them
        return $online_staff;
    } else {
        // otherwise apologize profusely
        return false;
    }
}
Пример #19
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;
}
Пример #20
0
/**
 * Build the profile link.
 *
 * @param string The Username of the profile.
 * @param int The user id of the profile.
 * @param string The target frame
 * @param string Any onclick javascript.
 * @return string The complete profile link.
 */
function build_profile_link($username = "", $uid = 0, $target = "", $onclick = "")
{
    global $mybb, $lang;
    if (!$username && $uid == 0) {
        // Return Guest phrase for no UID, no guest nickname
        return $lang->guest;
    } elseif ($uid == 0) {
        // Return the guest's nickname if user is a guest but has a nickname
        return $username;
    } else {
        // Build the profile link for the registered user
        if (!empty($target)) {
            $target = " target=\"{$target}\"";
        }
        if (!empty($onclick)) {
            $onclick = " onclick=\"{$onclick}\"";
        }
        return "<a href=\"{$mybb->settings['bburl']}/" . get_profile_link($uid) . "\"{$target}{$onclick}>{$username}</a>";
    }
}
Пример #21
0
/**
 * Constructs the usercp misc menu.
 *
 */
function usercp_menu_misc()
{
    global $db, $mybb, $templates, $theme, $usercpmenu, $lang, $collapsed, $collapsedimg;
    $draftstart = $draftend = '';
    $draftcount = $lang->ucp_nav_drafts;
    $query = $db->simple_select("posts", "COUNT(pid) AS draftcount", "visible = '-2' AND uid = '{$mybb->user['uid']}'");
    $count = $db->fetch_field($query, 'draftcount');
    if ($count > 0) {
        $draftcount = $lang->sprintf($lang->ucp_nav_drafts_active, my_number_format($count));
    }
    if ($mybb->settings['enableattachments'] != 0) {
        eval("\$attachmentop = \"" . $templates->get("usercp_nav_attachments") . "\";");
    }
    if (!isset($collapsedimg['usercpmisc'])) {
        $collapsedimg['usercpmisc'] = '';
    }
    if (!isset($collapsed['usercpmisc_e'])) {
        $collapsed['usercpmisc_e'] = '';
    }
    $profile_link = get_profile_link($mybb->user['uid']);
    eval("\$usercpmenu .= \"" . $templates->get("usercp_nav_misc") . "\";");
}
Пример #22
0
function ps_GetTopReferrers($NumOfRows)
{
    global $mybb, $db, $templates, $theme, $lang, $ps_align;
    $query = $db->query("\n\tSELECT u.uid,u.username,u.usergroup,u.displaygroup,count(*) as refcount \n\tFROM " . TABLE_PREFIX . "users u \n\tLEFT JOIN " . TABLE_PREFIX . "users r ON (r.referrer = u.uid) \n\tWHERE r.referrer = u.uid \n\tGROUP BY r.referrer DESC \n\tORDER BY refcount DESC \n\tLIMIT 0 ," . $NumOfRows);
    while ($topreferrer = $db->fetch_array($query)) {
        $uid = $topreferrer['uid'];
        $username = ps_FormatName(htmlspecialchars_uni($topreferrer['username']), $topreferrer['usergroup'], $topreferrer['displaygroup']);
        $refnum = $topreferrer['refcount'];
        $profilelink = $mybb->settings['bburl'] . '/' . get_profile_link($uid);
        eval("\$topreferrers_row .= \"" . $templates->get("prostats_topreferrers_row") . "\";");
    }
    eval("\$column_topreferrers = \"" . $templates->get("prostats_topreferrers") . "\";");
    return $column_topreferrers;
}
Пример #23
0
}
// Showing list of warnings for a particular user
if (!$mybb->input['action']) {
    if ($mybb->usergroup['canwarnusers'] != 1) {
        error_no_permission();
    }
    $user = get_user(intval($mybb->input['uid']));
    if (!$user['uid']) {
        error($lang->error_invalid_user);
    }
    $group_permissions = user_permissions($user['uid']);
    if ($group_permissions['canreceivewarnings'] != 1) {
        error($lang->error_cant_warn_group);
    }
    $lang->nav_profile = $lang->sprintf($lang->nav_profile, $user['username']);
    add_breadcrumb($lang->nav_profile, get_profile_link($user['uid']));
    add_breadcrumb($lang->nav_warning_log);
    if (!$mybb->settings['postsperpage'] || (int) $mybb->settings['postsperpage'] < 1) {
        $mybb->settings['postsperpage'] = 20;
    }
    // Figure out if we need to display multiple pages.
    $perpage = $mybb->settings['postsperpage'];
    $page = intval($mybb->input['page']);
    $query = $db->simple_select("warnings", "COUNT(wid) AS warning_count", "uid='{$user['uid']}'");
    $warning_count = $db->fetch_field($query, "warning_count");
    $pages = ceil($warning_count / $perpage);
    if ($page > $pages || $page <= 0) {
        $page = 1;
    }
    if ($page) {
        $start = ($page - 1) * $perpage;
/**
 * Constructs the usercp misc menu.
 *
 */
function usercp_menu_misc()
{
    global $db, $mybb, $templates, $theme, $usercpmenu, $lang, $collapsed, $collapsedimg;
    $draftstart = $draftend = $draftcount = '';
    $query = $db->simple_select("posts", "COUNT(*) AS draftcount", "visible='-2' AND uid='" . $mybb->user['uid'] . "'");
    $count = $db->fetch_array($query);
    if ($count['draftcount'] > 0) {
        $draftstart = "<strong>";
        $draftend = "</strong>";
        $draftcount = "(" . my_number_format($count['draftcount']) . ")";
    }
    $profile_link = get_profile_link($mybb->user['uid']);
    eval("\$usercpmenu .= \"" . $templates->get("usercp_nav_misc") . "\";");
}
Пример #25
0
             eval("\$information .= \"" . $templates->get("modcp_modlogs_result_thread") . "\";");
         }
         if ($logitem['fname']) {
             $logitem['forum'] = get_forum_link($logitem['fid']);
             eval("\$information .= \"" . $templates->get("modcp_modlogs_result_forum") . "\";");
         }
         if ($logitem['psubject']) {
             $logitem['psubject'] = htmlspecialchars_uni($logitem['psubject']);
             $logitem['post'] = get_post_link($logitem['pid']);
             eval("\$information .= \"" . $templates->get("modcp_modlogs_result_post") . "\";");
         }
         // Edited a user or managed announcement?
         if (!$logitem['tsubject'] || !$logitem['fname'] || !$logitem['psubject']) {
             $data = my_unserialize($logitem['data']);
             if ($data['uid']) {
                 $information = $lang->sprintf($lang->edited_user_info, htmlspecialchars_uni($data['username']), get_profile_link($data['uid']));
             }
             if ($data['aid']) {
                 $data['subject'] = htmlspecialchars_uni($data['subject']);
                 $data['announcement'] = get_announcement_link($data['aid']);
                 eval("\$information .= \"" . $templates->get("modcp_modlogs_result_announcement") . "\";");
             }
         }
         eval("\$modlogresults .= \"" . $templates->get("modcp_modlogs_result") . "\";");
     }
     if (!$modlogresults) {
         eval("\$modlogresults = \"" . $templates->get("modcp_modlogs_nologs") . "\";");
     }
     eval("\$latestfivemodactions = \"" . $templates->get("modcp_latestfivemodactions") . "\";");
 }
 $query = $db->query("\n\t\tSELECT b.*, a.username AS adminuser, u.username\n\t\tFROM " . TABLE_PREFIX . "banned b\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (b.uid=u.uid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "users a ON (b.admin=a.uid)\n\t\tWHERE b.bantime != '---' AND b.bantime != 'perm'\n\t\tORDER BY lifted ASC\n\t\tLIMIT 5\n\t");
Пример #26
0
function asb_rand_quote_get_quote($settings, $width)
{
    global $db, $mybb, $templates, $lang, $theme;
    if (!$lang->asb_addon) {
        $lang->load('asb_addon');
    }
    // get forums user cannot view
    $unviewable = get_unviewable_forums(true);
    if ($unviewable) {
        $unviewwhere = " AND p.fid NOT IN ({$unviewable})";
    }
    // get inactive forums
    $inactive = get_inactive_forums();
    if ($inactive) {
        $inactivewhere = " AND p.fid NOT IN ({$inactive})";
    }
    if ($settings['important_threads_only']) {
        $important_threads = ' AND NOT t.sticky=0';
    }
    // build the exclude conditions
    $show['fids'] = asb_build_id_list($settings['forum_show_list'], 'p.fid');
    $show['tids'] = asb_build_id_list($settings['thread_show_list'], 'p.tid');
    $hide['fids'] = asb_build_id_list($settings['forum_hide_list'], 'p.fid');
    $hide['tids'] = asb_build_id_list($settings['thread_hide_list'], 'p.tid');
    $where['show'] = asb_build_SQL_where($show, ' OR ');
    $where['hide'] = asb_build_SQL_where($hide, ' OR ', ' NOT ');
    $query_where = $important_threads . $unviewwhere . $inactivewhere . asb_build_SQL_where($where, ' AND ', ' AND ');
    $post_query = $db->query("\n\t\tSELECT\n\t\t\tp.pid, p.message, p.fid, p.tid, p.subject, p.uid,\n\t\t\tu.username, u.usergroup, u.displaygroup, u.avatar,\n\t\t\tt.sticky\n\t\tFROM {$db->table_prefix}posts p\n\t\tLEFT JOIN {$db->table_prefix}users u ON (u.uid=p.uid)\n\t\tLEFT JOIN {$db->table_prefix}threads t ON (t.tid=p.tid)\n\t\tWHERE\n\t\t\tp.visible='1'{$query_where}\n\t\tORDER BY\n\t\t\tRAND()\n\t\tLIMIT 1;");
    // if there was 1 . . .
    if ($db->num_rows($post_query) == 0) {
        return false;
    }
    $rand_post = $db->fetch_array($post_query);
    // build a post parser
    require_once MYBB_ROOT . 'inc/class_parser.php';
    $parser = new postParser();
    // we just need the text and smilies (we'll parse them after we check length)
    $pattern = "|[[\\/\\!]*?[^\\[\\]]*?]|si";
    $new_message = asb_strip_url(preg_replace($pattern, '$1', $rand_post['message']));
    // get some dimensions that make sense in relation to column width
    $asb_width = (int) $width;
    $asb_inner_size = $asb_width * 0.83;
    $avatar_size = (int) ($asb_inner_size / 5);
    $font_size = $asb_width / 4.5;
    $font_size = max(10, min(16, $font_size));
    $username_font_size = (int) ($font_size * 0.9);
    $title_font_size = (int) ($font_size * 0.65);
    $message_font_size = (int) $font_size;
    if (strlen($new_message) < $settings['min_length']) {
        if ($settings['default_text']) {
            $new_message = $settings['default_text'];
        } else {
            // nothing to show
            return false;
        }
    }
    if ($settings['max_length'] && strlen($new_message) > $settings['max_length']) {
        $new_message = substr($new_message, 0, $settings['max_length']) . ' . . .';
    }
    // set up the user name link so that it displays correctly for the display group of the user
    $plain_text_username = htmlspecialchars_uni($rand_post['username']);
    $username = format_name($plain_text_username, $rand_post['usergroup'], $rand_post['displaygroup']);
    $author_link = get_profile_link($rand_post['uid']);
    $post_link = get_post_link($rand_post['pid'], $rand_post['tid']) . '#pid' . $rand_post['pid'];
    $thread_link = get_thread_link($rand_post['tid']);
    // allow smilies, but kill
    $parser_options = array("allow_smilies" => 1);
    $new_message = str_replace(array('<br />', '/me'), array('', " * {$plain_text_username}"), $parser->parse_message($new_message . ' ', $parser_options));
    // if the user has an avatar then display it, otherwise force the default avatar.
    $avatar_filename = "{$theme['imgdir']}/default_avatar.gif";
    if ($rand_post['avatar'] != '') {
        $avatar_filename = $rand_post['avatar'];
    }
    $avatar_alt = $lang->sprintf($lang->asb_random_quote_users_profile, $plain_text_username);
    eval("\$read_more = \"" . $templates->get('asb_rand_quote_read_more') . "\";");
    if (my_strlen($rand_post['subject']) > 40) {
        $rand_post['subject'] = my_substr($rand_post['subject'], 0, 40) . ' . . .';
    }
    if (substr(strtolower($rand_post['subject']), 0, 3) == 're:') {
        $rand_post['subject'] = substr($rand_post['subject'], 3);
    }
    $rand_post['subject'] = htmlspecialchars_uni($parser->parse_badwords($rand_post['subject']));
    $thread_title_link = <<<EOF
<strong><a href="{$thread_link}" title="{$lang->asb_random_quotes_read_more_threadlink_title}"><span style="font-size: {$title_font_size}px;">{$rand_post['subject']}</span></a></strong>
EOF;
    // eval() the template
    eval("\$this_quote = \"" . $templates->get("asb_rand_quote_sidebox") . "\";");
    return $this_quote;
}
Пример #27
0
 $recipients = my_unserialize($message['recipients']);
 $to_users = $bcc_users = '';
 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;
Пример #28
0
    // Check if this forum is password protected and we have a valid password
    check_forum_password($forum['fid']);
    if ($mybb->get_input('sort') != 'username') {
        $sortsql = ' ORDER BY posts DESC';
    } else {
        $sortsql = ' ORDER BY p.username ASC';
    }
    $whoposted = '';
    $query = $db->query("\n\t\tSELECT COUNT(p.pid) AS posts, p.username AS postusername, u.uid, u.username, u.usergroup, u.displaygroup\n\t\tFROM " . TABLE_PREFIX . "posts p\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=p.uid)\n\t\tWHERE tid='" . $tid . "' AND {$show_posts}\n\t\tGROUP BY u.uid, p.username, u.uid, u.username, u.usergroup, u.displaygroup\n\t\t" . $sortsql . "\n\t");
    while ($poster = $db->fetch_array($query)) {
        if ($poster['username'] == '') {
            $poster['username'] = $poster['postusername'];
        }
        $poster_name = format_name($poster['username'], $poster['usergroup'], $poster['displaygroup']);
        if ($poster['uid']) {
            $onclick = "opener.location.href='" . get_profile_link($poster['uid']) . "'; return false;";
        }
        $profile_link = build_profile_link($poster_name, $poster['uid'], '_blank', $onclick);
        $numposts += $poster['posts'];
        eval("\$whoposted .= \"" . $templates->get("misc_whoposted_poster") . "\";");
        $altbg = alt_trow();
    }
    $numposts = my_number_format($numposts);
    $poster['posts'] = my_number_format($poster['posts']);
    eval("\$whop = \"" . $templates->get("misc_whoposted", 1, 0) . "\";");
    echo $whop;
    exit;
} elseif ($mybb->input['action'] == "smilies") {
    $smilies = '';
    if (!empty($mybb->input['popup']) && !empty($mybb->input['editor'])) {
        // make small popup list of smilies
Пример #29
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;
}
Пример #30
0
             $errors[] = $lang->error_stop_forum_spam_fetching;
         }
     }
 }
 if (empty($errors)) {
     if ($mybb->settings['contact_badwords'] == 1) {
         // Load the post parser
         require_once MYBB_ROOT . "inc/class_parser.php";
         $parser = new postParser();
         $parser_options = array('filter_badwords' => 1);
         $mybb->input['subject'] = $parser->parse_message($mybb->input['subject'], $parser_options);
         $mybb->input['message'] = $parser->parse_message($mybb->input['message'], $parser_options);
     }
     $user = $lang->na;
     if ($mybb->user['uid']) {
         $user = $mybb->user['username'] . ' - ' . $mybb->settings['bburl'] . '/' . get_profile_link($mybb->user['uid']);
     }
     $subject = $lang->sprintf($lang->email_contact_subject, $mybb->input['subject']);
     $message = $lang->sprintf($lang->email_contact, $mybb->input['email'], $user, $session->ipaddress, $mybb->input['message']);
     // Email the administrator
     my_mail($contactemail, $subject, $message, $mybb->input['email']);
     $plugins->run_hooks('contact_do_end');
     if ($mybb->settings['mail_logging'] > 0) {
         // Log the message
         $log_entry = array("subject" => $db->escape_string($subject), "message" => $db->escape_string($message), "dateline" => TIME_NOW, "fromuid" => $mybb->user['uid'], "fromemail" => $db->escape_string($mybb->input['email']), "touid" => 0, "toemail" => $db->escape_string($contactemail), "tid" => 0, "ipaddress" => $db->escape_binary($session->packedip), "type" => 3);
         $db->insert_query("maillogs", $log_entry);
     }
     if ($mybb->usergroup['emailfloodtime'] > 0 || isset($sent_count) && $sent_count + 1 >= $mybb->usergroup['maxemails']) {
         redirect('index.php', $lang->contact_success_message, '', true);
     } else {
         redirect('contact.php', $lang->contact_success_message, '', true);