Ejemplo n.º 1
0
function xthreads_search_result(&$data, $tplname)
{
    global $threadfields, $threadfield_cache, $forumcache, $mybb;
    // need to set these variables before doing threadfields stuff!
    $data['threaddate'] = my_date($mybb->settings['dateformat'], $data['dateline']);
    $data['threadtime'] = my_date($mybb->settings['timeformat'], $data['dateline']);
    xthreads_set_threadforum_urlvars('thread', $data['tid']);
    xthreads_set_threadforum_urlvars('forum', $data['fid']);
    if (!empty($threadfield_cache)) {
        // make threadfields array
        $threadfields = array();
        // clear previous threadfields
        if ($GLOBALS['thread_ids']) {
            $tidlist =& $GLOBALS['thread_ids'];
        } elseif ($GLOBALS['tids']) {
            $tidlist =& $GLOBALS['tids'];
        } else {
            $tidlist = '';
        }
        foreach ($threadfield_cache as $k => &$v) {
            if ($v['forums'] && strpos(',' . $v['forums'] . ',', ',' . $data['fid'] . ',') === false) {
                continue;
            }
            xthreads_get_xta_cache($v, $tidlist);
            $threadfields[$k] =& $data['xthreads_' . $k];
            xthreads_sanitize_disp($threadfields[$k], $v, $data['username'] !== '' ? $data['username'] : $data['userusername']);
        }
    }
    // template hack
    xthreads_portalsearch_cache_hack($GLOBALS['forum_tpl_prefixes'][$data['fid']], $tplname);
}
Ejemplo n.º 2
0
 /**
  * Parses quotes with post id and/or dateline.
  *
  * @param string The message to be parsed
  * @param string The username to be parsed
  * @param boolean Are we formatting as text?
  * @return string The parsed message.
  */
 function mycode_parse_post_quotes($message, $username, $text_only = false)
 {
     global $lang, $templates, $theme, $mybb;
     $linkback = $date = "";
     $message = trim($message);
     $message = preg_replace("#(^<br(\\s?)(\\/?)>|<br(\\s?)(\\/?)>\$)#i", "", $message);
     if (!$message) {
         return '';
     }
     $message = str_replace('\\"', '"', $message);
     $username = str_replace('\\"', '"', $username) . "'";
     $delete_quote = true;
     preg_match("#pid=(?:&quot;|\"|')?([0-9]+)[\"']?(?:&quot;|\"|')?#i", $username, $match);
     if (intval($match[1])) {
         $pid = intval($match[1]);
         $url = $mybb->settings['bburl'] . "/" . get_post_link($pid) . "#pid{$pid}";
         if (defined("IN_ARCHIVE")) {
             $linkback = " <a href=\"{$url}\">[ -> ]</a>";
         } else {
             eval("\$linkback = \" " . $templates->get("postbit_gotopost", 1, 0) . "\";");
         }
         $username = preg_replace("#(?:&quot;|\"|')? pid=(?:&quot;|\"|')?[0-9]+[\"']?(?:&quot;|\"|')?#i", '', $username);
         $delete_quote = false;
     }
     unset($match);
     preg_match("#dateline=(?:&quot;|\"|')?([0-9]+)(?:&quot;|\"|')?#i", $username, $match);
     if (intval($match[1])) {
         $dateline = intval($match[1]);
         if ($match[1] < TIME_NOW) {
             $postdate = my_date($mybb->settings['dateformat'], intval($match[1]));
             $posttime = my_date($mybb->settings['timeformat'], intval($match[1]));
             $date = " ({$postdate} {$posttime})";
         }
         $username = preg_replace("#(?:&quot;|\"|')? dateline=(?:&quot;|\"|')?[0-9]+(?:&quot;|\"|')?#i", '', $username);
         $delete_quote = false;
     }
     if ($delete_quote) {
         $username = my_substr($username, 0, my_strlen($username) - 1);
     }
     if ($text_only) {
         return "\n" . htmlspecialchars_uni($username) . " {$lang->wrote}{$date}\n--\n{$message}\n--\n";
     } else {
         $span = "";
         if (!$delete_quote) {
             $span = "<span>{$date}</span>";
         }
         $username = preg_replace('/^\\\'/is', '', $username);
         $userinfo = tt_get_user_id_by_name($username);
         if (!empty($userinfo)) {
             $uid = $userinfo['uid'];
         }
         return "[quote " . (isset($uid) ? "uid={$uid} " : '') . (!empty($username) ? "name=\"{$username}\" " : '') . (isset($pid) ? "post={$pid} " : '') . (isset($dateline) ? "timestamp={$dateline}" : '') . "]{$message}[/quote]\n";
     }
 }
function dbListEvents($db)
{
    echo "*List of currently open events:*\n\n";
    $result = $db->query('SELECT events.*, IFNULL(SUM(attendees.attendee_num),0) AS attendee_num FROM events LEFT JOIN attendees ON events.id = attendees.event_id GROUP BY events.id ORDER BY `event_time` ASC');
    foreach ($result as $r) {
        echo '*' . $r['event_name'] . '* @ *' . my_date($r['event_time']) . '* by *' . $r['event_owner'] . '* (*' . $r['attendee_num'] . '*)';
        if ($r['event_rsvp'] != NULL) {
            echo ' (RSVP: ' . my_date($r['event_rsvp']) . ')';
        }
        if ($r['event_note'] != NULL) {
            echo ' ' . $r['event_note'];
        }
        echo "\n\n";
    }
}
 /**
 This is where you perform the action when the API is called, the parameter given is an instance of stdClass, this method should return an instance of stdClass.
 */
 public function action()
 {
     global $mybb;
     $stdClass = new stdClass();
     $timestamp = "";
     if (isset($mybb->input["timestamp"])) {
         $timestamp = (string) $mybb->input["timestamp"];
     }
     $ty = 1;
     if (isset($mybb->input["ty"]) && in_array($mybb->input["ty"], array("0", "1"))) {
         $ty = (int) $mybb->input["ty"];
     }
     $stdClass->date = my_date($mybb->settings['dateformat'], $timestamp, "", $ty);
     $stdClass->time = my_date($mybb->settings['timeformat'], $timestamp, "", $ty);
     $stdClass->timestamp = $timestamp;
     return $stdClass;
 }
Ejemplo n.º 5
0
    if ($errors) {
        $page->output_inline_error($errors);
    }
    if ($mybb->input['uid'] && !$mybb->input['username']) {
        $user = get_user($mybb->input['uid']);
        $mybb->input['username'] = $user['username'];
    }
    $form_container = new FormContainer($lang->ban_a_user);
    $form_container->output_row($lang->ban_username, $lang->autocomplete_enabled, $form->generate_text_box('username', $mybb->input['username'], array('id' => 'username')), 'username');
    $form_container->output_row($lang->ban_reason, "", $form->generate_text_box('reason', $mybb->input['reason'], array('id' => 'reason')), 'reason');
    if (count($banned_groups) > 1) {
        $form_container->output_row($lang->ban_group, $lang->add_ban_group_desc, $form->generate_select_box('usergroup', $banned_groups, $mybb->input['usergroup'], array('id' => 'usergroup')), 'usergroup');
    }
    foreach ($ban_times as $time => $period) {
        if ($time != "---") {
            $friendly_time = my_date("D, jS M Y @ g:ia", ban_date2timestamp($time));
            $period = "{$period} ({$friendly_time})";
        }
        $length_list[$time] = $period;
    }
    $form_container->output_row($lang->ban_time, "", $form->generate_select_box('bantime', $length_list, $mybb->input['bantime'], array('id' => 'bantime')), 'bantime');
    $form_container->end();
    // Autocompletion for usernames
    echo '
	<script type="text/javascript" src="../jscripts/autocomplete.js?ver=140"></script>
	<script type="text/javascript">
	<!--
		new autoComplete("username", "../xmlhttp.php?action=get_users", {valueSpan: "username"});
	// -->
	</script>';
    $buttons[] = $form->generate_submit_button($lang->ban_user);
/**
 * Build a navigation tree for threaded display.
 *
 * @param unknown_type $replyto
 * @param unknown_type $indent
 * @return unknown
 */
function buildtree($replyto = "0", $indent = "0")
{
    global $tree, $mybb, $theme, $mybb, $pid, $tid, $templates, $parser;
    if ($indent) {
        $indentsize = 13 * $indent;
    } else {
        $indentsize = 0;
    }
    ++$indent;
    if (is_array($tree[$replyto])) {
        foreach ($tree[$replyto] as $key => $post) {
            $postdate = my_date($mybb->settings['dateformat'], $post['dateline']);
            $posttime = my_date($mybb->settings['timeformat'], $post['dateline']);
            $post['subject'] = htmlspecialchars_uni($parser->parse_badwords($post['subject']));
            if (!$post['subject']) {
                $post['subject'] = "[" . $lang->no_subject . "]";
            }
            $post['profilelink'] = build_profile_link($post['username'], $post['uid']);
            if ($mybb->input['pid'] == $post['pid']) {
                eval("\$posts .= \"" . $templates->get("showthread_threaded_bitactive") . "\";");
            } else {
                eval("\$posts .= \"" . $templates->get("showthread_threaded_bit") . "\";");
            }
            if ($tree[$post['pid']]) {
                $posts .= buildtree($post['pid'], $indent);
            }
        }
        --$indent;
    }
    return $posts;
}
Ejemplo n.º 7
0
 function update_birthdays()
 {
     global $db;
     $birthdays = array();
     // Get today, yesturday, and tomorrow's time (for different timezones)
     $bdaytime = TIME_NOW;
     $bdaydate = my_date("j-n", $bdaytime, '', 0);
     $bdaydatetomorrow = my_date("j-n", $bdaytime + 86400, '', 0);
     $bdaydateyesterday = my_date("j-n", $bdaytime - 86400, '', 0);
     $query = $db->simple_select("users", "uid, username, usergroup, displaygroup, birthday, birthdayprivacy", "birthday LIKE '{$bdaydate}-%' OR birthday LIKE '{$bdaydateyesterday}-%' OR birthday LIKE '{$bdaydatetomorrow}-%'");
     while ($bday = $db->fetch_array($query)) {
         // Pop off the year from the birthday because we don't need it.
         $bday['bday'] = explode('-', $bday['birthday']);
         array_pop($bday['bday']);
         $bday['bday'] = implode('-', $bday['bday']);
         if ($bday['birthdayprivacy'] != 'all') {
             ++$birthdays[$bday['bday']]['hiddencount'];
             continue;
         }
         // We don't need any excess caleries in the cache
         unset($bday['birthdayprivacy']);
         $birthdays[$bday['bday']]['users'][] = $bday;
     }
     $this->update("birthdays", $birthdays);
 }
function akismet_admin()
{
    global $mybb, $db, $page, $lang;
    if ($page->active_action != "akismet") {
        return;
    }
    $page->add_breadcrumb_item($lang->akismet);
    if ($mybb->input['delete_all'] && $mybb->request_method == "post") {
        // User clicked no
        if ($mybb->input['no']) {
            admin_redirect("index.php?module=forum-akismet");
        }
        if ($mybb->request_method == "post") {
            // Delete the template
            $db->delete_query("posts", "visible = '-4'");
            // Log admin action
            log_admin_action();
            flash_message($lang->success_deleted_spam, 'success');
            admin_redirect("index.php?module=forum-akismet");
        } else {
            $page->output_confirm_action("index.php?module=forum-akismet&amp;delete_all=1", $lang->confirm_spam_deletion);
        }
    }
    if ($mybb->input['unmark'] && $mybb->request_method == "post") {
        $unmark = $mybb->input['akismet'];
        if (empty($unmark)) {
            flash_message($lang->error_unmark, 'error');
            admin_redirect("index.php?module=forum-akismet");
        }
        $posts_in = '';
        $comma = '';
        foreach ($unmark as $key => $val) {
            $posts_in .= $comma . intval($key);
            $comma = ',';
        }
        $query = $db->simple_select("posts", "pid, tid", "pid IN ({$posts_in}) AND replyto = '0'");
        while ($post = $db->fetch_array($query)) {
            $threadp[] = $post['tid'];
        }
        if (!is_array($threadp)) {
            $threadp = array();
        }
        $thread_list = implode(',', $threadp);
        $query = $db->query("\r\n\t\t\tSELECT p.tid, f.usepostcounts, p.uid, p.fid, p.dateline, p.replyto, t.lastpost, t.lastposter, t.lastposteruid, t.subject\r\n\t\t\tFROM " . TABLE_PREFIX . "posts p\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=p.tid)\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "forums f ON (f.fid=p.fid)\r\n\t\t\tWHERE p.pid IN ({$posts_in}) AND p.visible = '-4'\r\n\t\t");
        while ($post = $db->fetch_array($query)) {
            // Fetch the last post for this forum
            $query2 = $db->query("\r\n\t\t\t\tSELECT tid, lastpost, lastposter, lastposteruid, subject\r\n\t\t\t\tFROM " . TABLE_PREFIX . "threads\r\n\t\t\t\tWHERE fid='{$post['fid']}' AND visible='1' AND closed NOT LIKE 'moved|%'\r\n\t\t\t\tORDER BY lastpost DESC\r\n\t\t\t\tLIMIT 0, 1\r\n\t\t\t");
            $lastpost = $db->fetch_array($query2);
            if ($post['lastpost'] > $lastpost['lastpost']) {
                $lastpost['lastpost'] = $post['lastpost'];
                $lastpost['lastposter'] = $post['lastposter'];
                $lastpost['lastposteruid'] = $post['lastposteruid'];
                $lastpost['subject'] = $post['subject'];
                $lastpost['tid'] = $post['tid'];
            }
            $update_count = array("lastpost" => intval($lastpost['lastpost']), "lastposter" => $db->escape_string($lastpost['lastposter']), "lastposteruid" => intval($lastpost['lastposteruid']), "lastposttid" => intval($lastpost['tid']), "lastpostsubject" => $db->escape_string($lastpost['subject']));
            $db->update_query("forums", $update_count, "fid='{$post['fid']}'");
            $query2 = $db->query("\r\n\t\t\t\tSELECT u.uid, u.username, p.username AS postusername, p.dateline\r\n\t\t\t\tFROM " . TABLE_PREFIX . "posts p\r\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=p.uid)\r\n\t\t\t\tWHERE p.tid='{$post['tid']}' AND p.visible='1' OR p.pid = '{$post['pid']}'\r\n\t\t\t\tORDER BY p.dateline DESC\r\n\t\t\t\tLIMIT 1");
            $lastpost = $db->fetch_array($query2);
            $query2 = $db->query("\r\n\t\t\t\tSELECT u.uid, u.username, p.username AS postusername, p.dateline\r\n\t\t\t\tFROM " . TABLE_PREFIX . "posts p\r\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=p.uid)\r\n\t\t\t\tWHERE p.tid='{$post['tid']}'\r\n\t\t\t\tORDER BY p.dateline ASC\r\n\t\t\t\tLIMIT 0,1\r\n\t\t\t");
            $firstpost = $db->fetch_array($query2);
            if (!$firstpost['username']) {
                $firstpost['username'] = $firstpost['postusername'];
            }
            if (!$lastpost['username']) {
                $lastpost['username'] = $lastpost['postusername'];
            }
            if (!$lastpost['dateline']) {
                $lastpost['username'] = $firstpost['username'];
                $lastpost['uid'] = $firstpost['uid'];
                $lastpost['dateline'] = $firstpost['dateline'];
            }
            $lastpost['username'] = $db->escape_string($lastpost['username']);
            $firstpost['username'] = $db->escape_string($firstpost['username']);
            $query2 = $db->simple_select("users", "akismetstopped", "uid='{$post['uid']}'");
            $akismetstopped = $db->fetch_field($query2, "akismetstopped") - 1;
            if ($akismetstopped < 0) {
                $akismetstopped = 0;
            }
            $db->update_query("users", array('akismetstopped' => $akismetstopped), "uid='{$post['uid']}'");
            $update_array = array('username' => $firstpost['username'], 'uid' => intval($firstpost['uid']), 'lastpost' => intval($lastpost['dateline']), 'lastposter' => $lastpost['username'], 'lastposteruid' => intval($lastpost['uid']));
            $db->update_query("threads", $update_array, "tid='{$post['tid']}'");
            if ($post['usepostcounts'] != 0) {
                $db->write_query("UPDATE " . TABLE_PREFIX . "users SET postnum=postnum+1 WHERE uid = '{$post['uid']}'");
            }
            $newthreads = $newreplies = 0;
            if ($post['replyto'] == 0) {
                ++$newthreads;
            } else {
                ++$newreplies;
            }
            update_thread_counters($post['tid'], array('replies' => '+' . $newreplies));
            update_forum_counters($post['fid'], array('threads' => '+' . $newthreads, 'posts' => '+1'));
        }
        $approve = array("visible" => 1);
        if ($thread_list) {
            $db->update_query("threads", $approve, "tid IN ({$thread_list})");
        }
        $db->update_query("posts", $approve, "pid IN ({$posts_in})");
        // Log admin action
        log_admin_action();
        flash_message($lang->success_unmarked, 'success');
        admin_redirect("index.php?module=forum-akismet");
    }
    if ($mybb->input['delete'] && $mybb->request_method == "post") {
        $deletepost = $mybb->input['akismet'];
        if (empty($deletepost)) {
            flash_message($lang->error_deletepost, 'error');
            admin_redirect("index.php?module=forum-akismet");
        }
        $posts_in = '';
        $comma = '';
        foreach ($deletepost as $key => $val) {
            $posts_in .= $comma . intval($key);
            $comma = ',';
        }
        $query = $db->simple_select("posts", "pid, tid", "pid IN ({$posts_in}) AND replyto = '0'");
        while ($post = $db->fetch_array($query)) {
            $threadp[$post['pid']] = $post['tid'];
        }
        if (!is_array($threadp)) {
            $threadp = array();
        }
        require_once MYBB_ROOT . "inc/functions_upload.php";
        foreach ($deletepost as $pid => $val) {
            if (array_key_exists($pid, $threadp)) {
                $db->delete_query("posts", "pid IN ({$posts_in})");
                $db->delete_query("attachments", "pid IN ({$posts_in})");
                // Get thread info
                $query = $db->simple_select("threads", "poll", "tid='" . $threadp[$pid] . "'");
                $poll = $db->fetch_field($query, 'poll');
                // Delete threads, redirects, favorites, polls, and poll votes
                $db->delete_query("threads", "tid='" . $threadp[$pid] . "'");
                $db->delete_query("threads", "closed='moved|" . $threadp[$pid] . "'");
                $db->delete_query("threadsubscriptions", "tid='" . $threadp[$pid] . "'");
                $db->delete_query("polls", "tid='" . $threadp[$pid] . "'");
                $db->delete_query("pollvotes", "pid='{$poll}'");
            }
            // Remove attachments
            remove_attachments($pid);
            // Delete the post
            $db->delete_query("posts", "pid='{$pid}'");
        }
        // Log admin action
        log_admin_action();
        flash_message($lang->success_spam_deleted, 'success');
        admin_redirect("index.php?module=forum-akismet");
    }
    if (!$mybb->input['action']) {
        require MYBB_ROOT . "inc/class_parser.php";
        $parser = new postParser();
        $page->output_header($lang->akismet);
        $form = new Form("index.php?module=forum-akismet", "post");
        $table = new Table();
        $table->construct_header($form->generate_check_box("checkall", 1, '', array('class' => 'checkall')), array('width' => '5%'));
        $table->construct_header("Title / Username / Post", array('class' => 'align_center'));
        $mybb->input['page'] = intval($mybb->input['page']);
        if ($mybb->input['page'] > 0) {
            $start = $mybb->input['page'] * 20;
        } else {
            $start = 0;
        }
        $query = $db->simple_select("posts", "COUNT(pid) as spam", "visible = '-4'");
        $total_rows = $db->fetch_field($query, 'spam');
        if ($start > $total_rows) {
            $start = $total_rows - 20;
        }
        if ($start < 0) {
            $start = 0;
        }
        $query = $db->simple_select("posts", "*", "visible = '-4'", array('limit_start' => $start, 'limit' => '20', 'order_by' => 'dateline', 'order_dir' => 'desc'));
        while ($post = $db->fetch_array($query)) {
            if ($post['uid'] != 0) {
                $username = "******"../" . str_replace("{uid}", $post['uid'], PROFILE_URL) . "\" target=\"_blank\">" . format_name($post['username'], $post['usergroup'], $post['displaygroup']) . "</a>";
            } else {
                $username = $post['username'];
            }
            $table->construct_cell($form->generate_check_box("akismet[{$post['pid']}]", 1, ''));
            $table->construct_cell("<span style=\"float: right;\">{$lang->username} {$username}</span> <span style=\"float: left;\">{$lang->title}: " . htmlspecialchars_uni($post['subject']) . " <strong>(" . my_date($mybb->settings['dateformat'], $post['dateline']) . ", " . my_date($mybb->settings['timeformat'], $post['dateline']) . ")</strong></span>");
            $table->construct_row();
            $parser_options = array("allow_html" => 0, "allow_mycode" => 0, "allow_smilies" => 0, "allow_imgcode" => 0, "me_username" => $post['username'], "filter_badwords" => 1);
            $post['message'] = $parser->parse_message($post['message'], $parser_options);
            $table->construct_cell($post['message'], array("colspan" => 2));
            $table->construct_row();
        }
        $num_rows = $table->num_rows();
        if ($num_rows == 0) {
            $table->construct_cell($lang->no_spam_found, array("class" => "align_center", "colspan" => 2));
            $table->construct_row();
        }
        $table->output($lang->detected_spam_messages);
        echo "<br />" . draw_admin_pagination($mybb->input['page'], 20, $total_rows, "index.php?module=forum-akismet&amp;page={page}");
        $buttons[] = $form->generate_submit_button($lang->unmark_selected, array('name' => 'unmark'));
        $buttons[] = $form->generate_submit_button($lang->deleted_selected, array('name' => 'delete'));
        if ($num_rows > 0) {
            $buttons[] = $form->generate_submit_button($lang->delete_all, array('name' => 'delete_all', 'onclick' => "return confirm('{$lang->confirm_spam_deletion}');"));
        }
        $form->output_submit_wrapper($buttons);
        $form->end();
        $page->output_footer();
    }
    exit;
}
Ejemplo n.º 9
0
 }
 $pidin = implode(",", $pidin);
 // Fetch attachments
 $query = $db->simple_select("attachments", "*", "pid IN ({$pidin})");
 while ($attachment = $db->fetch_array($query)) {
     $attachcache[$attachment['pid']][$attachment['aid']] = $attachment;
 }
 $query = $db->query("\n\t\t\tSELECT p.*, u.username AS userusername\n\t\t\tFROM " . TABLE_PREFIX . "posts p\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (p.uid=u.uid)\n\t\t\tWHERE pid IN ({$pidin})\n\t\t\tORDER BY dateline DESC\n\t\t");
 $postsdone = 0;
 $altbg = "trow1";
 $reviewbits = '';
 while ($post = $db->fetch_array($query)) {
     if ($post['userusername']) {
         $post['username'] = $post['userusername'];
     }
     $reviewpostdate = my_date('relative', $post['dateline']);
     $parser_options = array("allow_html" => $forum['allowhtml'], "allow_mycode" => $forum['allowmycode'], "allow_smilies" => $forum['allowsmilies'], "allow_imgcode" => $forum['allowimgcode'], "allow_videocode" => $forum['allowvideocode'], "me_username" => $post['username'], "filter_badwords" => 1);
     if ($post['smilieoff'] == 1) {
         $parser_options['allow_smilies'] = 0;
     }
     if ($mybb->user['showimages'] != 1 && $mybb->user['uid'] != 0 || $mybb->settings['guestimages'] != 1 && $mybb->user['uid'] == 0) {
         $parser_options['allow_imgcode'] = 0;
     }
     if ($mybb->user['showvideos'] != 1 && $mybb->user['uid'] != 0 || $mybb->settings['guestvideos'] != 1 && $mybb->user['uid'] == 0) {
         $parser_options['allow_videocode'] = 0;
     }
     if ($post['visible'] != 1) {
         $altbg = "trow_shaded";
     }
     $post['message'] = $parser->parse_message($post['message'], $parser_options);
     get_post_attachments($post['pid'], $post);
Ejemplo n.º 10
0
         }
         if ($message['icon'] > 0 && $icon_cache[$message['icon']]) {
             $icon = $icon_cache[$message['icon']];
             $icon['path'] = str_replace("{theme}", $theme['imgdir'], $icon['path']);
             $icon['path'] = htmlspecialchars_uni($icon['path']);
             $icon['name'] = htmlspecialchars_uni($icon['name']);
             eval("\$icon = \"" . $templates->get("private_messagebit_icon") . "\";");
         } else {
             $icon = '&#009;';
         }
         if (!trim($message['subject'])) {
             $message['subject'] = $lang->pm_no_subject;
         }
         $message['subject'] = htmlspecialchars_uni($parser->parse_badwords($message['subject']));
         if ($message['folder'] != "3") {
             $senddate = my_date('relative', $message['dateline']);
         } else {
             $senddate = $lang->not_sent;
         }
         $plugins->run_hooks("private_message");
         eval("\$messagelist .= \"" . $templates->get("private_messagebit") . "\";");
     }
 } else {
     eval("\$messagelist .= \"" . $templates->get("private_nomessages") . "\";");
 }
 $pmspacebar = '';
 if ($mybb->usergroup['pmquota'] != '0' && $mybb->usergroup['cancp'] != 1) {
     $query = $db->simple_select("privatemessages", "COUNT(*) AS total", "uid='" . $mybb->user['uid'] . "'");
     $pmscount = $db->fetch_array($query);
     if ($pmscount['total'] == 0) {
         $spaceused = 0;
Ejemplo n.º 11
0
function build_users_view($view)
{
    global $mybb, $db, $cache, $lang, $user_view_fields, $page;
    $view_title = '';
    if ($view['title']) {
        $title_string = "view_title_{$view['vid']}";
        if ($lang->{$title_string}) {
            $view['title'] = $lang->{$title_string};
        }
        $view_title .= " (" . htmlspecialchars_uni($view['title']) . ")";
    }
    // Build the URL to this view
    if (!isset($view['url'])) {
        $view['url'] = "index.php?module=user-users";
    }
    if (!is_array($view['conditions'])) {
        $view['conditions'] = unserialize($view['conditions']);
    }
    if (!is_array($view['fields'])) {
        $view['fields'] = unserialize($view['fields']);
    }
    if (!is_array($view['custom_profile_fields'])) {
        $view['custom_profile_fields'] = unserialize($view['custom_profile_fields']);
    }
    if (isset($mybb->input['username'])) {
        $view['conditions']['username'] = $mybb->input['username'];
    }
    if ($view['vid']) {
        $view['url'] .= "&amp;vid={$view['vid']}";
    } else {
        // If this is a custom view we need to save everything ready to pass it on from page to page
        global $admin_session;
        if (!$mybb->input['search_id']) {
            $search_id = md5(random_str());
            $admin_session['data']['user_views'][$search_id] = $view;
            update_admin_session('user_views', $admin_session['data']['user_views']);
            $mybb->input['search_id'] = $search_id;
        }
        $view['url'] .= "&amp;search_id=" . htmlspecialchars_uni($mybb->input['search_id']);
    }
    if (isset($mybb->input['username'])) {
        $view['url'] .= "&amp;username="******"&amp;", "&", $view['url'])) {
        update_admin_session('last_users_url', str_replace("&amp;", "&", $view['url']));
    }
    if (isset($view['conditions']['referrer'])) {
        $view['url'] .= "&amp;action=referrers&amp;uid=" . htmlspecialchars_uni($view['conditions']['referrer']);
    }
    // Do we not have any views?
    if (empty($view)) {
        return false;
    }
    $table = new Table();
    // Build header for table based view
    if ($view['view_type'] != "card") {
        foreach ($view['fields'] as $field) {
            if (!$user_view_fields[$field]) {
                continue;
            }
            $view_field = $user_view_fields[$field];
            $field_options = array();
            if ($view_field['width']) {
                $field_options['width'] = $view_field['width'];
            }
            if ($view_field['align']) {
                $field_options['class'] = "align_" . $view_field['align'];
            }
            $table->construct_header($view_field['title'], $field_options);
        }
        $table->construct_header("<input type=\"checkbox\" name=\"allbox\" onclick=\"inlineModeration.checkAll(this);\" />");
        // Create a header for the "select" boxes
    }
    $search_sql = '1=1';
    // Build the search SQL for users
    // List of valid LIKE search fields
    $user_like_fields = array("username", "email", "website", "icq", "aim", "yahoo", "msn", "signature", "usertitle");
    foreach ($user_like_fields as $search_field) {
        if (!empty($view['conditions'][$search_field]) && !$view['conditions'][$search_field . '_blank']) {
            $search_sql .= " AND u.{$search_field} LIKE '%" . $db->escape_string_like($view['conditions'][$search_field]) . "%'";
        } else {
            if (!empty($view['conditions'][$search_field . '_blank'])) {
                $search_sql .= " AND u.{$search_field} != ''";
            }
        }
    }
    // EXACT matching fields
    $user_exact_fields = array("referrer");
    foreach ($user_exact_fields as $search_field) {
        if (!empty($view['conditions'][$search_field])) {
            $search_sql .= " AND u.{$search_field}='" . $db->escape_string($view['conditions'][$search_field]) . "'";
        }
    }
    // LESS THAN or GREATER THAN
    $direction_fields = array("postnum");
    foreach ($direction_fields as $search_field) {
        $direction_field = $search_field . "_dir";
        if (isset($view['conditions'][$search_field]) && ($view['conditions'][$search_field] || $view['conditions'][$search_field] === '0') && $view['conditions'][$direction_field]) {
            switch ($view['conditions'][$direction_field]) {
                case "greater_than":
                    $direction = ">";
                    break;
                case "less_than":
                    $direction = "<";
                    break;
                default:
                    $direction = "=";
            }
            $search_sql .= " AND u.{$search_field}{$direction}'" . $db->escape_string($view['conditions'][$search_field]) . "'";
        }
    }
    // Registration searching
    $reg_fields = array("regdate");
    foreach ($reg_fields as $search_field) {
        if (!empty($view['conditions'][$search_field]) && intval($view['conditions'][$search_field])) {
            $threshold = TIME_NOW - intval($view['conditions'][$search_field]) * 24 * 60 * 60;
            $search_sql .= " AND u.{$search_field} >= '{$threshold}'";
        }
    }
    // IP searching
    $ip_fields = array("regip", "lastip");
    foreach ($ip_fields as $search_field) {
        if (!empty($view['conditions'][$search_field])) {
            // IPv6 IP
            if (strpos($view['conditions'][$search_field], ":") !== false) {
                $view['conditions'][$search_field] = str_replace("*", "%", $view['conditions'][$search_field]);
                $ip_sql = "{$search_field} LIKE '" . $db->escape_string($view['conditions'][$search_field]) . "'";
            } else {
                $ip_range = fetch_longipv4_range($view['conditions'][$search_field]);
                if (!is_array($ip_range)) {
                    $ip_sql = "long{$search_field}='{$ip_range}'";
                } else {
                    $ip_sql = "long{$search_field} > '{$ip_range[0]}' AND long{$search_field} < '{$ip_range[1]}'";
                }
            }
            $search_sql .= " AND {$ip_sql}";
        }
    }
    // Post IP searching
    if (!empty($view['conditions']['postip'])) {
        // IPv6 IP
        if (strpos($view['conditions']['postip'], ":") !== false) {
            $view['conditions']['postip'] = str_replace("*", "%", $view['conditions']['postip']);
            $ip_sql = "ipaddress LIKE '" . $db->escape_string($view['conditions']['postip']) . "'";
        } else {
            $ip_range = fetch_longipv4_range($view['conditions']['postip']);
            if (!is_array($ip_range)) {
                $ip_sql = "longipaddress='{$ip_range}'";
            } else {
                $ip_sql = "longipaddress > '{$ip_range[0]}' AND longipaddress < '{$ip_range[1]}'";
            }
        }
        $ip_uids = array(0);
        $query = $db->simple_select("posts", "uid", $ip_sql);
        while ($uid = $db->fetch_field($query, "uid")) {
            $ip_uids[] = $uid;
        }
        $search_sql .= " AND u.uid IN(" . implode(',', $ip_uids) . ")";
        unset($ip_uids);
    }
    // Custom Profile Field searching
    if ($view['custom_profile_fields']) {
        $userfield_sql = '1=1';
        foreach ($view['custom_profile_fields'] as $column => $input) {
            if (is_array($input)) {
                foreach ($input as $value => $text) {
                    if ($value == $column) {
                        $value = $text;
                    }
                    if ($value == $lang->na) {
                        continue;
                    }
                    if (strpos($column, '_blank') !== false) {
                        $column = str_replace('_blank', '', $column);
                        $userfield_sql .= ' AND ' . $db->escape_string($column) . " != ''";
                    } else {
                        $userfield_sql .= ' AND ' . $db->escape_string($column) . "='" . $db->escape_string($value) . "'";
                    }
                }
            } else {
                if (!empty($input)) {
                    if ($input == $lang->na) {
                        continue;
                    }
                    if (strpos($column, '_blank') !== false) {
                        $column = str_replace('_blank', '', $column);
                        $userfield_sql .= ' AND ' . $db->escape_string($column) . " != ''";
                    } else {
                        $userfield_sql .= ' AND ' . $db->escape_string($column) . " LIKE '%" . $db->escape_string($input) . "%'";
                    }
                }
            }
        }
        if ($userfield_sql != '1=1') {
            $userfield_uids = array(0);
            $query = $db->simple_select("userfields", "ufid", $userfield_sql);
            while ($userfield = $db->fetch_array($query)) {
                $userfield_uids[] = $userfield['ufid'];
            }
            $search_sql .= " AND u.uid IN(" . implode(',', $userfield_uids) . ")";
            unset($userfield_uids);
        }
    }
    // Usergroup based searching
    if (isset($view['conditions']['usergroup'])) {
        if (!is_array($view['conditions']['usergroup'])) {
            $view['conditions']['usergroup'] = array($view['conditions']['usergroup']);
        }
        foreach ($view['conditions']['usergroup'] as $usergroup) {
            $usergroup = intval($usergroup);
            if (!$usergroup) {
                continue;
            }
            switch ($db->type) {
                case "pgsql":
                case "sqlite":
                    $additional_sql .= " OR ','||additionalgroups||',' LIKE '%,{$usergroup},%'";
                    break;
                default:
                    $additional_sql .= "OR CONCAT(',',additionalgroups,',') LIKE '%,{$usergroup},%'";
            }
        }
        $search_sql .= " AND (u.usergroup IN (" . implode(",", array_map('intval', $view['conditions']['usergroup'])) . ") {$additional_sql})";
    }
    // COPPA users only?
    if (isset($view['conditions']['coppa'])) {
        $search_sql .= " AND u.coppauser=1 AND u.usergroup=5";
    }
    // Extra SQL?
    if (isset($view['extra_sql'])) {
        $search_sql .= $view['extra_sql'];
    }
    // Lets fetch out how many results we have
    $query = $db->query("\n\t\tSELECT COUNT(u.uid) AS num_results\n\t\tFROM " . TABLE_PREFIX . "users u\n\t\tWHERE {$search_sql}\n\t");
    $num_results = $db->fetch_field($query, "num_results");
    // No matching results then return false
    if (!$num_results) {
        return false;
    } else {
        if (!$view['perpage']) {
            $view['perpage'] = 20;
        }
        $view['perpage'] = intval($view['perpage']);
        // Establish which page we're viewing and the starting index for querying
        // Establish which page we're viewing and the starting index for querying
        if (!isset($mybb->input['page'])) {
            $mybb->input['page'] = 1;
        } else {
            $mybb->input['page'] = intval($mybb->input['page']);
        }
        if ($mybb->input['page']) {
            $start = ($mybb->input['page'] - 1) * $view['perpage'];
        } else {
            $start = 0;
            $mybb->input['page'] = 1;
        }
        $from_bit = "";
        if (isset($mybb->input['from']) && $mybb->input['from'] == "home") {
            $from_bit = "&amp;from=home";
        }
        switch ($view['sortby']) {
            case "regdate":
            case "lastactive":
            case "postnum":
            case "reputation":
                $view['sortby'] = $db->escape_string($view['sortby']);
                break;
            case "numposts":
                $view['sortby'] = "postnum";
                break;
            case "warninglevel":
                $view['sortby'] = "warningpoints";
                break;
            default:
                $view['sortby'] = "username";
        }
        if ($view['sortorder'] != "desc") {
            $view['sortorder'] = "asc";
        }
        $usergroups = $cache->read("usergroups");
        // Fetch matching users
        $query = $db->query("\n\t\t\tSELECT u.*\n\t\t\tFROM " . TABLE_PREFIX . "users u\n\t\t\tWHERE {$search_sql}\n\t\t\tORDER BY {$view['sortby']} {$view['sortorder']}\n\t\t\tLIMIT {$start}, {$view['perpage']}\n\t\t");
        $users = '';
        while ($user = $db->fetch_array($query)) {
            $comma = $groups_list = '';
            $user['view']['username'] = "******"index.php?module=user-users&amp;action=edit&amp;uid={$user['uid']}\">" . format_name($user['username'], $user['usergroup'], $user['displaygroup']) . "</a>";
            $user['view']['usergroup'] = htmlspecialchars_uni($usergroups[$user['usergroup']]['title']);
            if ($user['additionalgroups']) {
                $additional_groups = explode(",", $user['additionalgroups']);
                foreach ($additional_groups as $group) {
                    $groups_list .= $comma . htmlspecialchars_uni($usergroups[$group]['title']);
                    $comma = $lang->comma;
                }
            }
            if (!$groups_list) {
                $groups_list = $lang->none;
            }
            $user['view']['additionalgroups'] = "<small>{$groups_list}</small>";
            $user['view']['email'] = "<a href=\"mailto:" . htmlspecialchars_uni($user['email']) . "\">" . htmlspecialchars_uni($user['email']) . "</a>";
            $user['view']['regdate'] = my_date($mybb->settings['dateformat'], $user['regdate']) . ", " . my_date($mybb->settings['timeformat'], $user['regdate']);
            $user['view']['lastactive'] = my_date($mybb->settings['dateformat'], $user['lastactive']) . ", " . my_date($mybb->settings['timeformat'], $user['lastactive']);
            // Build popup menu
            $popup = new PopupMenu("user_{$user['uid']}", $lang->options);
            $popup->add_item($lang->edit_profile_and_settings, "index.php?module=user-users&amp;action=edit&amp;uid={$user['uid']}");
            $popup->add_item($lang->ban_user, "index.php?module=user-banning&amp;uid={$user['uid']}#username");
            if ($user['usergroup'] == 5) {
                if ($user['coppauser']) {
                    $popup->add_item($lang->approve_coppa_user, "index.php?module=user-users&amp;action=activate_user&amp;uid={$user['uid']}&amp;my_post_key={$mybb->post_code}{$from_bit}");
                } else {
                    $popup->add_item($lang->approve_user, "index.php?module=user-users&amp;action=activate_user&amp;uid={$user['uid']}&amp;my_post_key={$mybb->post_code}{$from_bit}");
                }
            }
            $popup->add_item($lang->delete_user, "index.php?module=user-users&amp;action=delete&amp;uid={$user['uid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->user_deletion_confirmation}')");
            $popup->add_item($lang->show_referred_users, "index.php?module=user-users&amp;action=referrers&amp;uid={$user['uid']}");
            $popup->add_item($lang->show_ip_addresses, "index.php?module=user-users&amp;action=ipaddresses&amp;uid={$user['uid']}");
            $popup->add_item($lang->show_attachments, "index.php?module=forum-attachments&amp;results=1&amp;username="******"-";
            }
            if ($mybb->settings['enablewarningsystem'] != 0 && $usergroups[$user['usergroup']]['canreceivewarnings'] != 0) {
                $warning_level = round($user['warningpoints'] / $mybb->settings['maxwarningpoints'] * 100);
                if ($warning_level > 100) {
                    $warning_level = 100;
                }
                $user['view']['warninglevel'] = get_colored_warning_level($warning_level);
            }
            if ($user['avatar'] && !stristr($user['avatar'], 'http://')) {
                $user['avatar'] = "../{$user['avatar']}";
            }
            if ($view['view_type'] == "card") {
                $scaled_avatar = fetch_scaled_avatar($user, 80, 80);
            } else {
                $scaled_avatar = fetch_scaled_avatar($user, 34, 34);
            }
            if (!$user['avatar']) {
                $user['avatar'] = "styles/{$page->style}/images/default_avatar.gif";
            }
            $user['view']['avatar'] = "<img src=\"" . htmlspecialchars_uni($user['avatar']) . "\" alt=\"\" width=\"{$scaled_avatar['width']}\" height=\"{$scaled_avatar['height']}\" />";
            if ($view['view_type'] == "card") {
                $users .= build_user_view_card($user, $view, $i);
            } else {
                build_user_view_table($user, $view, $table);
            }
        }
        // If card view, we need to output the results
        if ($view['view_type'] == "card") {
            $table->construct_cell($users);
            $table->construct_row();
        }
    }
    if (!isset($view['table_id'])) {
        $view['table_id'] = "users_list";
    }
    $switch_view = "<div class=\"float_right\">";
    $switch_url = $view['url'];
    if ($mybb->input['page'] > 0) {
        $switch_url .= "&amp;page=" . intval($mybb->input['page']);
    }
    if ($view['view_type'] != "card") {
        $switch_view .= "<strong>{$lang->table_view}</strong> | <a href=\"{$switch_url}&amp;type=card\" style=\"font-weight: normal;\">{$lang->card_view}</a>";
    } else {
        $switch_view .= "<a href=\"{$switch_url}&amp;type=table\" style=\"font-weight: normal;\">{$lang->table_view}</a> | <strong>{$lang->card_view}</strong>";
    }
    $switch_view .= "</div>";
    // Do we need to construct the pagination?
    if ($num_results > $view['perpage']) {
        $pagination = draw_admin_pagination($mybb->input['page'], $view['perpage'], $num_results, $view['url'] . "&amp;type={$view['view_type']}");
        $search_class = "float_right";
        $search_style = "";
    } else {
        $search_class = '';
        $search_style = "text-align: right;";
    }
    $search_action = $view['url'];
    // stop &username= in the query string
    if ($view_upos = strpos($search_action, '&amp;username='******'post', 'search_form', 0, '', true);
    $built_view = $search->construct_return;
    $built_view .= "<div class=\"{$search_class}\" style=\"padding-bottom: 3px; margin-top: -9px; {$search_style}\">";
    $built_view .= $search->generate_hidden_field('action', 'search') . "\n";
    if (isset($view['conditions']['username'])) {
        $default_class = '';
        $value = $view['conditions']['username'];
    } else {
        $default_class = "search_default";
        $value = $lang->search_for_user;
    }
    $built_view .= $search->generate_text_box('username', $value, array('id' => 'search_keywords', 'class' => "{$default_class} field150 field_small")) . "\n";
    $built_view .= "<input type=\"submit\" class=\"search_button\" value=\"{$lang->search}\" />\n";
    if ($view['popup']) {
        $built_view .= " <div style=\"display: inline\">{$view['popup']}</div>\n";
    }
    $built_view .= "<script type='text/javascript'>\n\t\tvar form = document.getElementById('search_form');\n\t\tform.onsubmit = function() {\n\t\t\tvar search = document.getElementById('search_keywords');\n\t\t\tif(search.value == '' || search.value == '" . addcslashes($lang->search_for_user, "'") . "')\n\t\t\t{\n\t\t\t\tsearch.focus();\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\tvar search = document.getElementById('search_keywords');\n\t\tsearch.onfocus = function()\n\t\t{\n\t\t\tif(this.value == '" . addcslashes($lang->search_for_user, "'") . "')\n\t\t\t{\n\t\t\t\t\$(this).removeClassName('search_default');\n\t\t\t\tthis.value = '';\n\t\t\t}\n\t\t}\n\t\tsearch.onblur = function()\n\t\t{\n\t\t\tif(this.value == '')\n\t\t\t{\n\t\t\t\t\$(this).addClassName('search_default');\n\t\t\t\tthis.value = '" . addcslashes($lang->search_for_user, "'") . "';\n\t\t\t}\n\t\t}\n\t\t// fix the styling used if we have a different default value\n\t\tif(search.value != '" . addcslashes($lang->search_for_user, "'") . "')\n\t\t{\n\t\t\t\$(search).removeClassName('search_default');\n\t\t}\n\t\t</script>\n";
    $built_view .= "</div>\n";
    // Autocompletion for usernames
    $built_view .= '
	<script type="text/javascript" src="../jscripts/autocomplete.js?ver=140"></script>
	<script type="text/javascript">
	<!--
		new autoComplete("search_keywords", "../xmlhttp.php?action=get_users", {valueSpan: "username"});
	// -->
	</script>';
    $built_view .= $search->end();
    if (isset($pagination)) {
        $built_view .= $pagination;
    }
    if ($view['view_type'] != "card") {
        $checkbox = '';
    } else {
        $checkbox = "<input type=\"checkbox\" name=\"allbox\" onclick=\"inlineModeration.checkAll(this)\" /> ";
    }
    $built_view .= $table->construct_html("{$switch_view}<div>{$checkbox}{$lang->users}{$view_title}</div>", 1, "", $view['table_id']);
    if (isset($pagination)) {
        $built_view .= $pagination;
    }
    $built_view .= '
<script type="text/javascript" src="' . $mybb->settings['bburl'] . '/jscripts/inline_moderation.js?ver=1400"></script>
<form action="index.php?module=user-users" method="post">
<input type="hidden" name="my_post_key" value="' . $mybb->post_code . '" />
<input type="hidden" name="action" value="inline_edit" />
<div class="float_right"><span class="smalltext"><strong>' . $lang->inline_edit . '</strong></span>
<select name="inline_action" class="inline_select">
	<option value="multiactivate">' . $lang->inline_activate . '</option>
	<option value="multiban">' . $lang->inline_ban . '</option>
	<option value="multiusergroup">' . $lang->inline_usergroup . '</option>
	<option value="multidelete">' . $lang->inline_delete . '</option>
	<option value="multiprune">' . $lang->inline_prune . '</option>
</select>
<input type="submit" class="button" name="go" value="' . $lang->go . ' (0)" id="inline_go" />&nbsp;
<input type="button" onclick="javascript:inlineModeration.clearChecked();" value="' . $lang->clear . '" class="button" />
</div>
</form>
<br style="clear: both;" />
<script type="text/javascript">
<!--
	var go_text = "' . $lang->go . '";
	var all_text = "1";
	var inlineType = "user";
	var inlineId = "acp";
// -->
</script>';
    return $built_view;
}
Ejemplo n.º 12
0
     $date_issued = my_date($mybb->settings['dateformat'], $warning['dateline']) . ", " . my_date($mybb->settings['timeformat'], $warning['dateline']);
     if ($warning['type_title']) {
         $warning_type = $warning['type_title'];
     } else {
         $warning_type = $warning['title'];
     }
     $warning_type = htmlspecialchars_uni($warning_type);
     if ($warning['points'] > 0) {
         $warning['points'] = "+{$warning['points']}";
     }
     $points = $lang->sprintf($lang->warning_points, $warning['points']);
     if ($warning['expired'] != 1) {
         if ($warning['expires'] == 0) {
             $expires = $lang->never;
         } else {
             $expires = my_date($mybb->settings['dateformat'], $warning['expires']) . ", " . my_date($mybb->settings['timeformat'], $warning['expires']);
         }
     } else {
         if ($warning['daterevoked']) {
             $expires = $lang->warning_revoked;
         } else {
             if ($warning['expires']) {
                 $expires = $lang->already_expired;
             }
         }
     }
     $alt_bg = alt_trow();
     $plugins->run_hooks("warnings_warning");
     eval("\$warnings .= \"" . $templates->get("warnings_warning") . "\";");
 }
 if (!$warnings) {
Ejemplo n.º 13
0
 $perpage = (int) $mybb->settings['membersperpage'];
 if ($perpage < 1) {
     $perpage = 20;
 }
 $page = $mybb->get_input('page', MyBB::INPUT_INT);
 if ($page && $page > 0) {
     $start = ($page - 1) * $perpage;
 } else {
     $start = 0;
     $page = 1;
 }
 $multipage = multipage($numusers, $perpage, $page, "managegroup.php?gid=" . $gid);
 $users = "";
 while ($user = $db->fetch_array($query)) {
     $altbg = alt_trow();
     $regdate = my_date('relative', $user['regdate']);
     $post = $user;
     $sendpm = $email = '';
     if ($mybb->settings['enablepms'] == 1 && $post['receivepms'] != 0 && $mybb->usergroup['cansendpms'] == 1 && my_strpos("," . $post['ignorelist'] . ",", "," . $mybb->user['uid'] . ",") === false) {
         eval("\$sendpm = \"" . $templates->get("postbit_pm") . "\";");
     }
     if ($user['hideemail'] != 1) {
         eval("\$email = \"" . $templates->get("postbit_email") . "\";");
     } else {
         $email = '';
     }
     $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
     $user['profilelink'] = build_profile_link($user['username'], $user['uid']);
     if (in_array($user['uid'], $leaders_array)) {
         $leader = $lang->leader;
     } else {
Ejemplo n.º 14
0
     $pagination = draw_admin_pagination($page, $per_page, $num_requests, "index.php?module=user-groups&amp;action=join_requests&gid={$group['gid']}");
     echo $pagination;
 }
 $form = new Form("index.php?module=user-groups&amp;action=join_requests&gid={$group['gid']}", "post");
 $table = new Table();
 $table->construct_header($form->generate_check_box("checkall", 1, "", array('class' => 'checkall')), array('width' => 1));
 $table->construct_header($lang->users);
 $table->construct_header($lang->reason);
 $table->construct_header($lang->date_requested, array("class" => 'align_center', "width" => 200));
 $table->construct_header($lang->controls, array("class" => "align_center", "width" => 200));
 $query = $db->query("\n\t\tSELECT j.*, u.username\n\t\tFROM " . TABLE_PREFIX . "joinrequests j\n\t\tINNER JOIN " . TABLE_PREFIX . "users u ON (u.uid=j.uid)\n\t\tWHERE j.gid='{$group['gid']}'\n\t\tORDER BY dateline ASC\n\t\tLIMIT {$start}, {$per_page}\n\t");
 while ($request = $db->fetch_array($query)) {
     $table->construct_cell($form->generate_check_box("users[]", $request['uid'], ""));
     $table->construct_cell("<strong>" . build_profile_link($request['username'], $request['uid'], "_blank") . "</strong>");
     $table->construct_cell(htmlspecialchars_uni($request['reason']));
     $table->construct_cell(my_date('relative', $request['dateline']), array('class' => 'align_center'));
     $popup = new PopupMenu("join_{$request['rid']}", $lang->options);
     $popup->add_item($lang->approve, "index.php?module=user-groups&action=approve_join_request&amp;rid={$request['rid']}&amp;my_post_key={$mybb->post_code}");
     $popup->add_item($lang->deny, "index.php?module=user-groups&action=deny_join_request&amp;rid={$request['rid']}&amp;my_post_key={$mybb->post_code}");
     $table->construct_cell($popup->fetch(), array('class' => "align_center"));
     $table->construct_row();
 }
 if ($table->num_rows() == 0) {
     $table->construct_cell($lang->no_join_requests, array("colspan" => 6));
     $table->construct_row();
 }
 $table->output($lang->join_requests_for . ' ' . htmlspecialchars_uni($group['title']));
 echo $pagination;
 $buttons[] = $form->generate_submit_button($lang->approve_selected_requests, array('name' => 'approve'));
 $buttons[] = $form->generate_submit_button($lang->deny_selected_requests, array('name' => 'deny'));
 $form->output_submit_wrapper($buttons);
Ejemplo n.º 15
0
/**
 * Build a Who's Online row for a specific user
 *
 * @param array Array of user information including activity information
 * @return string Formatted online row
 */
function build_wol_row($user)
{
    global $mybb, $lang, $templates, $theme, $session, $db;
    // We have a registered user
    if ($user['uid'] > 0) {
        // Only those with "canviewwolinvis" permissions can view invisible users
        if ($user['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid']) {
            // Append an invisible mark if the user is invisible
            if ($user['invisible'] == 1) {
                $invisible_mark = "*";
            } else {
                $invisible_mark = '';
            }
            $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
            $online_name = build_profile_link($user['username'], $user['uid']) . $invisible_mark;
        }
    } elseif (!empty($user['bot'])) {
        $online_name = format_name($user['bot'], $user['usergroup']);
    } else {
        $online_name = format_name($lang->guest, 1);
    }
    $online_time = my_date($mybb->settings['timeformat'], $user['time']);
    // Fetch the location name for this users activity
    $location = build_friendly_wol_location($user['activity']);
    // Can view IPs, then fetch the IP template
    if ($mybb->usergroup['canviewonlineips'] == 1) {
        $user['ip'] = my_inet_ntop($db->unescape_binary($user['ip']));
        if ($mybb->usergroup['canmodcp'] == 1 && $mybb->usergroup['canuseipsearch'] == 1) {
            eval("\$lookup = \"" . $templates->get("online_row_ip_lookup") . "\";");
        }
        eval("\$user_ip = \"" . $templates->get("online_row_ip") . "\";");
    } else {
        $user_ip = $lookup = $user['ip'] = '';
    }
    // And finally if we have permission to view this user, return the completed online row
    if ($user['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid']) {
        eval("\$online_row = \"" . $templates->get("online_row") . "\";");
    }
    return $online_row;
}
Ejemplo n.º 16
0
function newpoints_shop_admin_stats()
{
    global $form, $db, $lang, $mybb;
    newpoints_lang_load("newpoints_shop");
    echo "<br />";
    // table
    $table = new Table();
    $table->construct_header($lang->newpoints_shop_item, array('width' => '30%'));
    $table->construct_header($lang->newpoints_shop_username, array('width' => '30%'));
    $table->construct_header($lang->newpoints_shop_price, array('width' => '20%', 'class' => 'align_center'));
    $table->construct_header($lang->newpoints_shop_date, array('width' => '20%', 'class' => 'align_center'));
    $query = $db->simple_select('newpoints_log', '*', 'action=\'shop_purchase\'', array('order_by' => 'date', 'order_dir' => 'DESC', 'limit' => intval($mybb->settings['newpoints_shop_lastpurchases'])));
    while ($stats = $db->fetch_array($query)) {
        $data = explode('-', $stats['data']);
        $item = newpoints_shop_get_item($data[0]);
        $table->construct_cell(htmlspecialchars_uni($item['name']));
        $link = build_profile_link(htmlspecialchars_uni($stats['username']), intval($stats['uid']));
        $table->construct_cell($link);
        $table->construct_cell(newpoints_format_points($data[1]), array('class' => 'align_center'));
        $table->construct_cell(my_date($mybb->settings['dateformat'], intval($stats['date']), '', false) . ", " . my_date($mybb->settings['timeformat'], intval($stats['date'])), array('class' => 'align_center'));
        $table->construct_row();
    }
    if ($table->num_rows() == 0) {
        $table->construct_cell($lang->newpoints_error_gathering, array('colspan' => 4));
        $table->construct_row();
    }
    $table->output($lang->newpoints_stats_lastpurchases);
}
Ejemplo n.º 17
0
function firstpreview_pm()
{
    global $mybb, $db, $charset, $headerinclude, $header;
    $header = '<div class="arrow-down"></div>' . $header;
    // Add jQuery and noConflict for MyBB 1.6.*
    $jquery = '';
    $noconflict = '';
    if ($mybb->version < "1.7.0") {
        $jquery = '<script type="text/javascript">
//<![CDATA[
if (!window.jQuery)
{
document.write(unescape("%3Cscript src=\\"http://code.jquery.com/jquery-latest.min.js\\" type=\\"text/javascript\\"%3E%3C/script%3E"));
}
//]]>
</script>';
        $noconflict = 'jQuery.noConflict();';
    }
    // Background color
    $bg_color = '#aaaaaa';
    if (isset($mybb->settings['firstpreview_bg']) && preg_match('/^#([0-9a-f]{1,6})$/i', $mybb->settings['firstpreview_bg'])) {
        $bg_color = htmlspecialchars_uni($mybb->settings['firstpreview_bg']);
    }
    // Close button
    $close_preview = '#close_preview{display:none;cursor:pointer;background:#000;color:#fff;float:right;font-size:1em;font-weight:bold;text-align:center;width:20px;height:20px;border-radius:5px}';
    if (isset($mybb->settings['firstpreview_close']) && $mybb->settings['firstpreview_close'] == 1) {
        $close_preview = '#close_preview{cursor:pointer;background:#000;color:#fff;float:right;font-size:1em;font-weight:bold;text-align:center;width:20px;height:20px;border-radius:5px}';
    }
    // Insert the code
    $headerinclude .= '
	<!-- start: first_preview_plugin -->
	<style type="text/css">
	.modal_firstpost{text-align:left;border-radius:7px;-moz-border-radius:7px;-webkit-border-radius:7px;border:1px solid ' . $bgcolor . ';display:none;position:absolute;z-index:29000;width:390px;height:180px;overflow:hidden}
	.fpreview{z-index:29001;width:390px;height:180px;overflow:auto;background:' . $bg_color . '}
	.arrow-down{display:none;position:absolute;z-index:28999;width:0;height:0;border-left:20px solid transparent;border-right:20px solid transparent;border-top:20px solid ' . $bg_color . '}
	.prev_content{padding:10px;height:auto;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;-ms-hyphens:auto;-o-hyphens:auto;hyphens:auto;background:none}
	' . $close_preview . '
	</style>
	' . $jquery . '
	<script type="text/javascript">
	//<![CDATA[
	' . $noconflict . '
	<!--
	if(use_xmlhttprequest == 1) {
		jQuery(document).ready(function(e){e(".pmprev").on("touchenter mouseenter",function(){id=e(this).attr("id");pmid=id.replace(/[^\\d.]/g,"");var t=e(this).offset().left;var n=e(this).offset().top-200;showPost=setTimeout(function(){e.ajax({url:"private.php?pmid="+pmid+"&firstpm=1",type:"post",complete:function(t){e(".modal_firstpost").html(t.responseText)}});e(".modal_firstpost").fadeIn("slow");e(".modal_firstpost").css("top",n);e(".modal_firstpost").css("left",t);e(".arrow-down").fadeIn("slow");e(".arrow-down").css("top",n+180);e(".arrow-down").css("left",t+20);},1500)});e(".pmprev").on("mouseleave touchleave touchend",function(){clearTimeout(showPost);});e(".modal_firstpost").on("mouseleave touchmove",function(){e(".modal_firstpost").fadeOut("slow");e(".arrow-down").fadeOut("fast")});e(".modal_firstpost").on("click", "#close_preview", function(){e(".modal_firstpost").fadeOut("slow");e(".arrow-down").fadeOut("fast")})});
	}
	//]]>
	</script>
	<!-- end: first_preview_plugin -->
	';
    // Get the pm preview
    if (isset($mybb->input['firstpm']) && $mybb->input['firstpm'] == 1 && $mybb->request_method == "post") {
        $pmid = (int) $mybb->input['pmid'];
        $query = $db->simple_select('privatemessages', '*', "pmid = '" . $pmid . "'");
        $pm = $db->fetch_array($query);
        // Load the users own messages only
        if ($pm['uid'] != $mybb->user['uid']) {
            return;
        }
        require_once MYBB_ROOT . "inc/class_parser.php";
        $parser = new postParser();
        $pm['subject'] = htmlspecialchars_uni($parser->parse_badwords($pm['subject']));
        $user = get_user($pm['fromid']);
        $idtype = 'pmid';
        $parser_options['allow_html'] = $mybb->settings['pmsallowhtml'];
        $parser_options['allow_mycode'] = $mybb->settings['pmsallowmycode'];
        $parser_options['allow_smilies'] = $mybb->settings['pmsallowsmilies'];
        $parser_options['allow_imgcode'] = $mybb->settings['pmsallowimgcode'];
        $parser_options['allow_videocode'] = $mybb->settings['pmsallowvideocode'];
        $parser_options['me_username'] = $user['username'];
        $parser_options['filter_badwords'] = 1;
        $id = $pmid;
        $pm['message'] = $parser->parse_message($pm['message'], $parser_options);
        $pmdate = my_date($mybb->settings['dateformat'], $pm['dateline']);
        $pmtime = my_date($mybb->settings['timeformat'], $pm['dateline']);
        $pmsent = ' (' . $pmdate . ', ' . $pmtime . ')';
        if (isset($mybb->settings['firstpreview_html']) && $mybb->settings['firstpreview_html'] != 1) {
            $pm['message'] = strip_tags($pm['message'], "<br><p><ul><ol><li>");
        }
        if (!empty($mybb->settings['firstpreview_length']) && $mybb->settings['firstpreview_length'] != "0" && my_strlen($pm['message']) > (int) $mybb->settings['firstpreview_length']) {
            $pm['message'] = preg_replace("!<a([^>]+)>!isU", "", $pm['message']);
            $pm['message'] = str_replace("</a>", "", $pm['message']);
            $pm['message'] = my_substr($pm['message'], 0, (int) $mybb->settings['firstpreview_length']) . '...<p><a href="private.php?action=read&amp;pmid=' . (int) $pm['pmid'] . '">more</a></p>';
        }
        $preview = "<div class=\"fpreview\"><span id=\"close_preview\">&#10060;</span>\n\t\t<div class=\"thead\" style=\"text-align:center; font-weight:bold; min-height:20px;\">" . $pm['subject'] . "</div>\n\t\t<div class=\"tcat\" style=\"padding-left:10px;\">" . build_profile_link(format_name(htmlspecialchars_uni($user['username']), (int) $user['usergroup'], (int) $user['displaygroup']), (int) $pm['fromid']) . "<span class=\"smalltext\">" . $pmsent . "</span></div>\n\t\t<div class=\"prev_content\">" . $pm['message'] . "</div>\n\t\t</div>";
        header("Content-type: text/plain; charset={$charset}");
        echo $preview;
        exit;
    }
}
Ejemplo n.º 18
0
/**
 * Fetch the attachments for a specific post and parse inline [attachment=id] code.
 * Note: assumes you have $attachcache, an array of attachments set up.
 *
 * @param int $id The ID of the item.
 * @param array $post The post or item passed by reference.
 */
function get_post_attachments($id, &$post)
{
    global $attachcache, $mybb, $theme, $templates, $forumpermissions, $lang;
    $validationcount = 0;
    $tcount = 0;
    $post['attachmentlist'] = $post['thumblist'] = $post['imagelist'] = '';
    if (isset($attachcache[$id]) && is_array($attachcache[$id])) {
        // This post has 1 or more attachments
        foreach ($attachcache[$id] as $aid => $attachment) {
            if ($attachment['visible']) {
                // There is an attachment thats visible!
                $attachment['filename'] = htmlspecialchars_uni($attachment['filename']);
                $attachment['filesize'] = get_friendly_size($attachment['filesize']);
                $ext = get_extension($attachment['filename']);
                if ($ext == "jpeg" || $ext == "gif" || $ext == "bmp" || $ext == "png" || $ext == "jpg") {
                    $isimage = true;
                } else {
                    $isimage = false;
                }
                $attachment['icon'] = get_attachment_icon($ext);
                $attachment['downloads'] = my_number_format($attachment['downloads']);
                if (!$attachment['dateuploaded']) {
                    $attachment['dateuploaded'] = $attachment['dateline'];
                }
                $attachdate = my_date('relative', $attachment['dateuploaded']);
                // Support for [attachment=id] code
                if (stripos($post['message'], "[attachment=" . $attachment['aid'] . "]") !== false) {
                    // Show as thumbnail IF image is big && thumbnail exists && setting=='thumb'
                    // Show as full size image IF setting=='fullsize' || (image is small && permissions allow)
                    // Show as download for all other cases
                    if ($attachment['thumbnail'] != "SMALL" && $attachment['thumbnail'] != "" && $mybb->settings['attachthumbnails'] == "yes") {
                        eval("\$attbit = \"" . $templates->get("postbit_attachments_thumbnails_thumbnail") . "\";");
                    } elseif (($attachment['thumbnail'] == "SMALL" && $forumpermissions['candlattachments'] == 1 || $mybb->settings['attachthumbnails'] == "no") && $isimage) {
                        eval("\$attbit = \"" . $templates->get("postbit_attachments_images_image") . "\";");
                    } else {
                        eval("\$attbit = \"" . $templates->get("postbit_attachments_attachment") . "\";");
                    }
                    $post['message'] = preg_replace("#\\[attachment=" . $attachment['aid'] . "]#si", $attbit, $post['message']);
                } else {
                    // Show as thumbnail IF image is big && thumbnail exists && setting=='thumb'
                    // Show as full size image IF setting=='fullsize' || (image is small && permissions allow)
                    // Show as download for all other cases
                    if ($attachment['thumbnail'] != "SMALL" && $attachment['thumbnail'] != "" && $mybb->settings['attachthumbnails'] == "yes") {
                        eval("\$post['thumblist'] .= \"" . $templates->get("postbit_attachments_thumbnails_thumbnail") . "\";");
                        if ($tcount == 5) {
                            $thumblist .= "<br />";
                            $tcount = 0;
                        }
                        ++$tcount;
                    } elseif (($attachment['thumbnail'] == "SMALL" && $forumpermissions['candlattachments'] == 1 || $mybb->settings['attachthumbnails'] == "no") && $isimage) {
                        eval("\$post['imagelist'] .= \"" . $templates->get("postbit_attachments_images_image") . "\";");
                    } else {
                        eval("\$post['attachmentlist'] .= \"" . $templates->get("postbit_attachments_attachment") . "\";");
                    }
                }
            } else {
                $validationcount++;
            }
        }
        if ($validationcount > 0 && is_moderator($post['fid'], "canviewunapprove")) {
            if ($validationcount == 1) {
                $postbit_unapproved_attachments = $lang->postbit_unapproved_attachment;
            } else {
                $postbit_unapproved_attachments = $lang->sprintf($lang->postbit_unapproved_attachments, $validationcount);
            }
            eval("\$post['attachmentlist'] .= \"" . $templates->get("postbit_attachments_attachment_unapproved") . "\";");
        }
        if ($post['thumblist']) {
            eval("\$post['attachedthumbs'] = \"" . $templates->get("postbit_attachments_thumbnails") . "\";");
        } else {
            $post['attachedthumbs'] = '';
        }
        if ($post['imagelist']) {
            eval("\$post['attachedimages'] = \"" . $templates->get("postbit_attachments_images") . "\";");
        } else {
            $post['attachedimages'] = '';
        }
        if ($post['attachmentlist'] || $post['thumblist'] || $post['imagelist']) {
            eval("\$post['attachments'] = \"" . $templates->get("postbit_attachments") . "\";");
        }
    }
}
Ejemplo n.º 19
0
 * Website: http://www.mybb.com
 * License: http://www.mybb.com/about/license
 *
 */
define("IN_MYBB", 1);
define("IN_ADMINCP", 1);
// Here you can change how much of an Admin CP IP address must match in a previous session for the user is validated (defaults to 3 which matches a.b.c)
define("ADMIN_IP_SEGMENTS", 0);
require_once dirname(dirname(__FILE__)) . "/inc/init.php";
$shutdown_queries = $shutdown_functions = array();
send_page_headers();
if (!isset($config['admin_dir']) || !file_exists(MYBB_ROOT . $config['admin_dir'] . "/inc/class_page.php")) {
    $config['admin_dir'] = basename(dirname(__FILE__));
}
define('MYBB_ADMIN_DIR', MYBB_ROOT . $config['admin_dir'] . '/');
define('COPY_YEAR', my_date('Y', TIME_NOW));
require_once MYBB_ADMIN_DIR . "inc/class_page.php";
require_once MYBB_ADMIN_DIR . "inc/class_form.php";
require_once MYBB_ADMIN_DIR . "inc/class_table.php";
require_once MYBB_ADMIN_DIR . "inc/functions.php";
require_once MYBB_ROOT . "inc/functions_user.php";
// Set cookie path to our admin dir temporarily, i.e. so that it affects the ACP only
$loc = get_current_location('', '', true);
$mybb->settings['cookiepath'] = substr($loc, 0, strrpos($loc, "/{$config['admin_dir']}/")) . "/{$config['admin_dir']}/";
if (!isset($cp_language)) {
    if (!file_exists(MYBB_ROOT . "inc/languages/" . $mybb->settings['cplanguage'] . "/admin/home_dashboard.lang.php")) {
        $mybb->settings['cplanguage'] = "english";
    }
    $lang->set_language($mybb->settings['cplanguage'], "admin");
}
// Load global language phrases
Ejemplo n.º 20
0
 $username = format_name($row['username'], $row['usergroup'], $row['displaygroup']);
 if (!$row['uid']) {
     $username_link = $username;
 } else {
     $username_link = build_profile_link($username, $row['uid'], "_blank");
 }
 $mod_username = format_name($row['mod_username'], $row['mod_usergroup'], $row['mod_displaygroup']);
 $mod_username_link = build_profile_link($mod_username, $row['mod_uid'], "_blank");
 $issued_date = my_date($mybb->settings['dateformat'], $row['dateline']) . ' ' . my_date($mybb->settings['timeformat'], $row['dateline']);
 $revoked_text = '';
 if ($row['daterevoked'] > 0) {
     $revoked_date = my_date($mybb->settings['dateformat'], $row['daterevoked']) . ' ' . my_date($mybb->settings['timeformat'], $row['daterevoked']);
     $revoked_text = "<br /><small><strong>{$lang->revoked}</strong> {$revoked_date}</small>";
 }
 if ($row['expires'] > 0) {
     $expire_date = my_date($mybb->settings['dateformat'], $row['expires']) . ' ' . my_date($mybb->settings['timeformat'], $row['expires']);
 } else {
     $expire_date = $lang->never;
 }
 $title = $row['title'];
 if (empty($row['title'])) {
     $title = $row['custom_title'];
 }
 $title = htmlspecialchars_uni($title);
 if ($row['points'] > 0) {
     $points = '+' . $row['points'];
 }
 $table->construct_cell($username_link);
 $table->construct_cell("{$title} ({$points})");
 $table->construct_cell($issued_date, array("class" => "align_center"));
 $table->construct_cell($expire_date . $revoked_text, array("class" => "align_center"));
Ejemplo n.º 21
0
            }
        }
    }
    // Now we build the actual online rows - we do this separately because we need to query all of the specific activity and location information
    $online_rows = '';
    if (is_array($users)) {
        reset($users);
        foreach ($users as $user) {
            $online_rows .= build_wol_row($user);
        }
    }
    if (is_array($guests)) {
        reset($guests);
        foreach ($guests as $user) {
            $online_rows .= build_wol_row($user);
        }
    }
    // Fetch the most online information
    $most_online = $cache->read("mostonline");
    $record_count = $most_online['numusers'];
    $record_date = my_date($mybb->settings['dateformat'], $most_online['time']);
    $record_time = my_date($mybb->settings['timeformat'], $most_online['time']);
    // Set automatic refreshing if enabled
    if ($mybb->settings['refreshwol'] > 0) {
        $refresh_time = $mybb->settings['refreshwol'] * 60;
        $refresh = "<meta http-equiv=\"refresh\" content=\"{$refresh_time};URL=online.php{$refresh_string}\" />";
    }
    $plugins->run_hooks("online_end");
    eval("\$online = \"" . $templates->get("online") . "\";");
    output_page($online);
}
Ejemplo n.º 22
0
/**
 * Build a post bit
 *
 * @param array The post data
 * @param int The type of post bit we're building (1 = preview, 2 = pm, 3 = announcement, else = post)
 * @return string The built post bit
 */
function build_postbit($post, $post_type = 0)
{
    global $db, $altbg, $theme, $mybb, $postcounter;
    global $titlescache, $page, $templates, $forumpermissions, $attachcache;
    global $lang, $ismod, $inlinecookie, $inlinecount, $groupscache, $fid;
    global $plugins, $parser, $cache, $ignored_users, $hascustomtitle;
    $hascustomtitle = 0;
    // Set default values for any fields not provided here
    foreach (array('subject_extra', 'attachments', 'button_rep', 'button_warn', 'button_reply_pm', 'button_replyall_pm', 'button_forward_pm', 'button_delete_pm') as $post_field) {
        if (empty($post[$post_field])) {
            $post[$post_field] = '';
        }
    }
    // Set up the message parser if it doesn't already exist.
    if (!$parser) {
        require_once MYBB_ROOT . "inc/class_parser.php";
        $parser = new postParser();
    }
    $unapproved_shade = '';
    if ($post['visible'] == 0 && $post_type == 0) {
        $altbg = $unapproved_shade = 'trow_shaded';
    } elseif ($altbg == 'trow1') {
        $altbg = 'trow2';
    } else {
        $altbg = 'trow1';
    }
    $post['fid'] = $fid;
    switch ($post_type) {
        case 1:
            // Message preview
            global $forum;
            $parser_options['allow_html'] = $forum['allowhtml'];
            $parser_options['allow_mycode'] = $forum['allowmycode'];
            $parser_options['allow_smilies'] = $forum['allowsmilies'];
            $parser_options['allow_imgcode'] = $forum['allowimgcode'];
            $parser_options['allow_videocode'] = $forum['allowvideocode'];
            $parser_options['me_username'] = $post['username'];
            $parser_options['filter_badwords'] = 1;
            $id = 0;
            break;
        case 2:
            // Private message
            global $message, $pmid;
            $parser_options['allow_html'] = $mybb->settings['pmsallowhtml'];
            $parser_options['allow_mycode'] = $mybb->settings['pmsallowmycode'];
            $parser_options['allow_smilies'] = $mybb->settings['pmsallowsmilies'];
            $parser_options['allow_imgcode'] = $mybb->settings['pmsallowimgcode'];
            $parser_options['allow_videocode'] = $mybb->settings['pmsallowvideocode'];
            $parser_options['me_username'] = $post['username'];
            $parser_options['filter_badwords'] = 1;
            $id = $pmid;
            break;
        case 3:
            // Announcement
            global $announcementarray, $message;
            $parser_options['allow_html'] = $announcementarray['allowhtml'];
            $parser_options['allow_mycode'] = $announcementarray['allowmycode'];
            $parser_options['allow_smilies'] = $announcementarray['allowsmilies'];
            $parser_options['allow_imgcode'] = 1;
            $parser_options['allow_videocode'] = 1;
            $parser_options['me_username'] = $post['username'];
            $parser_options['filter_badwords'] = 1;
            break;
        default:
            // Regular post
            global $forum, $thread, $tid;
            $oldforum = $forum;
            $id = intval($post['pid']);
            $parser_options['allow_html'] = $forum['allowhtml'];
            $parser_options['allow_mycode'] = $forum['allowmycode'];
            $parser_options['allow_smilies'] = $forum['allowsmilies'];
            $parser_options['allow_imgcode'] = $forum['allowimgcode'];
            $parser_options['allow_videocode'] = $forum['allowvideocode'];
            $parser_options['filter_badwords'] = 1;
            if (!$post['username']) {
                $post['username'] = $lang->guest;
            }
            if ($post['userusername']) {
                $parser_options['me_username'] = $post['userusername'];
            } else {
                $parser_options['me_username'] = $post['username'];
            }
            break;
    }
    // Sanatize our custom profile fields for use in templates, if people choose to use them
    foreach ($post as $post_field => $field_value) {
        if (substr($post_field, 0, 3) != 'fid') {
            continue;
        }
        $post[$post_field] = htmlspecialchars_uni($field_value);
    }
    if (!$postcounter) {
        // Used to show the # of the post
        if ($page > 1) {
            if (!$mybb->settings['postsperpage'] || (int) $mybb->settings['postsperpage'] < 1) {
                $mybb->settings['postsperpage'] = 20;
            }
            $postcounter = $mybb->settings['postsperpage'] * ($page - 1);
        } else {
            $postcounter = 0;
        }
        $post_extra_style = "border-top-width: 0;";
    } elseif ($mybb->input['mode'] == "threaded") {
        $post_extra_style = "border-top-width: 0;";
    } else {
        $post_extra_style = "margin-top: 5px;";
    }
    if (!$altbg) {
        // Define the alternate background colour if this is the first post
        $altbg = "trow1";
    }
    $postcounter++;
    // Format the post date and time using my_date
    $post['postdate'] = my_date($mybb->settings['dateformat'], $post['dateline']);
    $post['posttime'] = my_date($mybb->settings['timeformat'], $post['dateline']);
    // Dont want any little 'nasties' in the subject
    $post['subject'] = $parser->parse_badwords($post['subject']);
    // Pm's have been htmlspecialchars_uni()'ed already.
    if ($post_type != 2) {
        $post['subject'] = htmlspecialchars_uni($post['subject']);
    }
    if (empty($post['subject'])) {
        $post['subject'] = '&nbsp;';
    }
    $post['author'] = $post['uid'];
    // Get the usergroup
    if ($post['userusername']) {
        if (!$post['displaygroup']) {
            $post['displaygroup'] = $post['usergroup'];
        }
        $usergroup = $groupscache[$post['displaygroup']];
    } else {
        $usergroup = $groupscache[1];
    }
    if (!is_array($titlescache)) {
        $cached_titles = $cache->read("usertitles");
        if (!empty($cached_titles)) {
            foreach ($cached_titles as $usertitle) {
                $titlescache[$usertitle['posts']] = $usertitle;
            }
        }
        if (is_array($titlescache)) {
            krsort($titlescache);
        }
        unset($usertitle, $cached_titles);
    }
    // Work out the usergroup/title stuff
    $post['groupimage'] = '';
    if (!empty($usergroup['image'])) {
        $language = $mybb->settings['bblanguage'];
        if (!empty($mybb->user['language'])) {
            $language = $mybb->user['language'];
        }
        $usergroup['image'] = str_replace("{lang}", $language, $usergroup['image']);
        $usergroup['image'] = str_replace("{theme}", $theme['imgdir'], $usergroup['image']);
        eval("\$post['groupimage'] = \"" . $templates->get("postbit_groupimage") . "\";");
        if ($mybb->settings['postlayout'] == "classic") {
            $post['groupimage'] .= "<br />";
        }
    }
    if ($post['userusername']) {
        // This post was made by a registered user
        $post['username'] = $post['userusername'];
        $post['profilelink_plain'] = get_profile_link($post['uid']);
        $post['username_formatted'] = format_name($post['username'], $post['usergroup'], $post['displaygroup']);
        $post['profilelink'] = build_profile_link($post['username_formatted'], $post['uid']);
        if (trim($post['usertitle']) != "") {
            $hascustomtitle = 1;
        }
        if ($usergroup['usertitle'] != "" && !$hascustomtitle) {
            $post['usertitle'] = $usergroup['usertitle'];
        } elseif (is_array($titlescache) && !$usergroup['usertitle']) {
            reset($titlescache);
            foreach ($titlescache as $key => $titleinfo) {
                if ($post['postnum'] >= $key) {
                    if (!$hascustomtitle) {
                        $post['usertitle'] = $titleinfo['title'];
                    }
                    $post['stars'] = $titleinfo['stars'];
                    $post['starimage'] = $titleinfo['starimage'];
                    break;
                }
            }
        }
        if ($usergroup['stars']) {
            $post['stars'] = $usergroup['stars'];
        }
        if (empty($post['starimage'])) {
            $post['starimage'] = $usergroup['starimage'];
        }
        if ($post['starimage'] && $post['stars']) {
            // Only display stars if we have an image to use...
            $post['starimage'] = str_replace("{theme}", $theme['imgdir'], $post['starimage']);
            $post['userstars'] = '';
            for ($i = 0; $i < $post['stars']; ++$i) {
                $post['userstars'] .= "<img src=\"" . $post['starimage'] . "\" border=\"0\" alt=\"*\" />";
            }
            $post['userstars'] .= "<br />";
        }
        $postnum = $post['postnum'];
        $post['postnum'] = my_number_format($post['postnum']);
        // Determine the status to show for the user (Online/Offline/Away)
        $timecut = TIME_NOW - $mybb->settings['wolcutoff'];
        if ($post['lastactive'] > $timecut && ($post['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1) && $post['lastvisit'] != $post['lastactive']) {
            eval("\$post['onlinestatus'] = \"" . $templates->get("postbit_online") . "\";");
        } else {
            if ($post['away'] == 1 && $mybb->settings['allowaway'] != 0) {
                eval("\$post['onlinestatus'] = \"" . $templates->get("postbit_away") . "\";");
            } else {
                eval("\$post['onlinestatus'] = \"" . $templates->get("postbit_offline") . "\";");
            }
        }
        if ($post['avatar'] != "" && ($mybb->user['showavatars'] != 0 || !$mybb->user['uid'])) {
            $post['avatar'] = htmlspecialchars_uni($post['avatar']);
            $avatar_dimensions = explode("|", $post['avatardimensions']);
            if ($avatar_dimensions[0] && $avatar_dimensions[1]) {
                list($max_width, $max_height) = explode("x", my_strtolower($mybb->settings['postmaxavatarsize']));
                if ($avatar_dimensions[0] > $max_width || $avatar_dimensions[1] > $max_height) {
                    require_once MYBB_ROOT . "inc/functions_image.php";
                    $scaled_dimensions = scale_image($avatar_dimensions[0], $avatar_dimensions[1], $max_width, $max_height);
                    $avatar_width_height = "width=\"{$scaled_dimensions['width']}\" height=\"{$scaled_dimensions['height']}\"";
                } else {
                    $avatar_width_height = "width=\"{$avatar_dimensions[0]}\" height=\"{$avatar_dimensions[1]}\"";
                }
            }
            eval("\$post['useravatar'] = \"" . $templates->get("postbit_avatar") . "\";");
            $post['avatar_padding'] = "padding-right: 10px;";
        } else {
            $post['useravatar'] = '';
            $post['avatar_padding'] = '';
        }
        eval("\$post['button_find'] = \"" . $templates->get("postbit_find") . "\";");
        if ($mybb->settings['enablepms'] == 1 && $post['receivepms'] != 0 && $mybb->usergroup['cansendpms'] == 1 && my_strpos("," . $post['ignorelist'] . ",", "," . $mybb->user['uid'] . ",") === false) {
            eval("\$post['button_pm'] = \"" . $templates->get("postbit_pm") . "\";");
        }
        if ($post_type != 3 && $mybb->settings['enablereputation'] == 1 && $mybb->settings['postrep'] == 1 && $mybb->usergroup['cangivereputations'] == 1 && $usergroup['usereputationsystem'] == 1 && ($mybb->settings['posrep'] || $mybb->settings['neurep'] || $mybb->settings['negrep']) && $post['uid'] != $mybb->user['uid']) {
            if (!$post['pid']) {
                $post['pid'] = 0;
            }
            eval("\$post['button_rep'] = \"" . $templates->get("postbit_rep_button") . "\";");
        }
        if ($post['website'] != "") {
            $post['website'] = htmlspecialchars_uni($post['website']);
            eval("\$post['button_www'] = \"" . $templates->get("postbit_www") . "\";");
        } else {
            $post['button_www'] = "";
        }
        if ($post['hideemail'] != 1 && $mybb->usergroup['cansendemail'] == 1) {
            eval("\$post['button_email'] = \"" . $templates->get("postbit_email") . "\";");
        } else {
            $post['button_email'] = "";
        }
        $post['userregdate'] = my_date($mybb->settings['regdateformat'], $post['regdate']);
        // Work out the reputation this user has (only show if not announcement)
        if ($post_type != 3 && $usergroup['usereputationsystem'] != 0 && $mybb->settings['enablereputation'] == 1) {
            $post['userreputation'] = get_reputation($post['reputation'], $post['uid']);
            eval("\$post['replink'] = \"" . $templates->get("postbit_reputation") . "\";");
        }
        // Showing the warning level? (only show if not announcement)
        if ($post_type != 3 && $mybb->settings['enablewarningsystem'] != 0 && $usergroup['canreceivewarnings'] != 0 && ($mybb->usergroup['canwarnusers'] != 0 || $mybb->user['uid'] == $post['uid'] && $mybb->settings['canviewownwarning'] != 0)) {
            $warning_level = round($post['warningpoints'] / $mybb->settings['maxwarningpoints'] * 100);
            if ($warning_level > 100) {
                $warning_level = 100;
            }
            $warning_level = get_colored_warning_level($warning_level);
            // If we can warn them, it's not the same person, and we're in a PM or a post.
            if ($mybb->usergroup['canwarnusers'] != 0 && $post['uid'] != $mybb->user['uid'] && ($post_type == 0 || $post_type == 2)) {
                eval("\$post['button_warn'] = \"" . $templates->get("postbit_warn") . "\";");
                $warning_link = "warnings.php?uid={$post['uid']}";
            } else {
                $warning_link = "usercp.php";
            }
            eval("\$post['warninglevel'] = \"" . $templates->get("postbit_warninglevel") . "\";");
        }
        eval("\$post['user_details'] = \"" . $templates->get("postbit_author_user") . "\";");
    } else {
        // Message was posted by a guest or an unknown user
        $post['profilelink'] = format_name($post['username'], 1);
        if ($usergroup['usertitle']) {
            $post['usertitle'] = $usergroup['usertitle'];
        } else {
            $post['usertitle'] = $lang->guest;
        }
        $usergroup['title'] = $lang->na;
        $post['userregdate'] = $lang->na;
        $post['postnum'] = $lang->na;
        $post['button_profile'] = '';
        $post['button_email'] = '';
        $post['button_www'] = '';
        $post['signature'] = '';
        $post['button_pm'] = '';
        $post['button_find'] = '';
        $post['onlinestatus'] = '';
        $post['replink'] = '';
        eval("\$post['user_details'] = \"" . $templates->get("postbit_author_guest") . "\";");
    }
    $post['button_edit'] = '';
    $post['button_quickdelete'] = '';
    $post['button_quote'] = '';
    $post['button_quickquote'] = '';
    $post['button_report'] = '';
    // For private messages, fetch the reply/forward/delete icons
    if ($post_type == 2 && $post['pmid']) {
        global $replyall;
        eval("\$post['button_reply_pm'] = \"" . $templates->get("postbit_reply_pm") . "\";");
        eval("\$post['button_forward_pm'] = \"" . $templates->get("postbit_forward_pm") . "\";");
        eval("\$post['button_delete_pm'] = \"" . $templates->get("postbit_delete_pm") . "\";");
        if ($replyall == true) {
            eval("\$post['button_replyall_pm'] = \"" . $templates->get("postbit_replyall_pm") . "\";");
        }
    }
    if (!$post_type) {
        // Figure out if we need to show an "edited by" message
        $post['editedmsg'] = '';
        if ($post['edituid'] != 0 && $post['edittime'] != 0 && $post['editusername'] != "" && ($mybb->settings['showeditedby'] != 0 && $usergroup['cancp'] == 0 || $mybb->settings['showeditedbyadmin'] != 0 && $usergroup['cancp'] == 1)) {
            $post['editdate'] = my_date($mybb->settings['dateformat'], $post['edittime']);
            $post['edittime'] = my_date($mybb->settings['timeformat'], $post['edittime']);
            $post['editnote'] = $lang->sprintf($lang->postbit_edited, $post['editdate'], $post['edittime']);
            $post['editedprofilelink'] = build_profile_link($post['editusername'], $post['edituid']);
            eval("\$post['editedmsg'] = \"" . $templates->get("postbit_editedby") . "\";");
        }
        if ((is_moderator($fid, "caneditposts") || $forumpermissions['caneditposts'] == 1 && $mybb->user['uid'] == $post['uid']) && $mybb->user['uid'] != 0) {
            eval("\$post['button_edit'] = \"" . $templates->get("postbit_edit") . "\";");
        }
        // Quick Delete button
        $can_delete = 0;
        if ($mybb->user['uid'] == $post['uid']) {
            if ($forumpermissions['candeletethreads'] == 1 && $postcounter == 1) {
                $can_delete = 1;
            } else {
                if ($forumpermissions['candeleteposts'] == 1 && $postcounter != 1) {
                    $can_delete = 1;
                }
            }
        }
        if ((is_moderator($fid, "candeleteposts") || $can_delete == 1) && $mybb->user['uid'] != 0) {
            eval("\$post['button_quickdelete'] = \"" . $templates->get("postbit_quickdelete") . "\";");
        }
        // Inline moderation stuff
        if ($ismod) {
            if (isset($mybb->cookies[$inlinecookie]) && my_strpos($mybb->cookies[$inlinecookie], "|" . $post['pid'] . "|")) {
                $inlinecheck = "checked=\"checked\"";
                $inlinecount++;
            } else {
                $inlinecheck = "";
            }
            eval("\$post['inlinecheck'] = \"" . $templates->get("postbit_inlinecheck") . "\";");
            if ($post['visible'] == 0) {
                $invisiblepost = 1;
            }
        } else {
            $post['inlinecheck'] = "";
        }
        $post['postlink'] = get_post_link($post['pid'], $post['tid']);
        eval("\$post['posturl'] = \"" . $templates->get("postbit_posturl") . "\";");
        global $forum, $thread;
        if ($forum['open'] != 0 && ($thread['closed'] != 1 || is_moderator($forum['fid']))) {
            eval("\$post['button_quote'] = \"" . $templates->get("postbit_quote") . "\";");
        }
        if ($forumpermissions['canpostreplys'] != 0 && ($thread['closed'] != 1 || is_moderator($fid)) && $mybb->settings['multiquote'] != 0 && $forum['open'] != 0 && !$post_type) {
            eval("\$post['button_multiquote'] = \"" . $templates->get("postbit_multiquote") . "\";");
        }
        if ($mybb->user['uid'] != "0") {
            eval("\$post['button_report'] = \"" . $templates->get("postbit_report") . "\";");
        }
        if ($mybb->settings['logip'] != "no") {
            if ($mybb->settings['logip'] == "show") {
                eval("\$post['iplogged'] = \"" . $templates->get("postbit_iplogged_show") . "\";");
            } else {
                if ($mybb->settings['logip'] == "hide" && is_moderator($fid, "canviewips")) {
                    eval("\$post['iplogged'] = \"" . $templates->get("postbit_iplogged_hiden") . "\";");
                } else {
                    $post['iplogged'] = "";
                }
            }
        } else {
            $post['iplogged'] = "";
        }
    } elseif ($post_type == 3) {
        if ($mybb->usergroup['issupermod'] == 1 || is_moderator($fid)) {
            eval("\$post['button_edit'] = \"" . $templates->get("announcement_edit") . "\";");
            eval("\$post['button_quickdelete'] = \"" . $templates->get("announcement_quickdelete") . "\";");
        }
    }
    if ($post['smilieoff'] == 1) {
        $parser_options['allow_smilies'] = 0;
    }
    // If we have incoming search terms to highlight - get it done.
    if (!empty($mybb->input['highlight'])) {
        $parser_options['highlight'] = $mybb->input['highlight'];
        $post['subject'] = $parser->highlight_message($post['subject'], $parser_options['highlight']);
    }
    $post['message'] = $parser->parse_message($post['message'], $parser_options);
    get_post_attachments($id, $post);
    if ($post['includesig'] != 0 && $post['username'] && $post['signature'] != "" && ($mybb->user['uid'] == 0 || $mybb->user['showsigs'] != 0) && ($post['suspendsignature'] == 0 || $post['suspendsignature'] == 1 && $post['suspendsigtime'] != 0 && $post['suspendsigtime'] < TIME_NOW) && $usergroup['canusesig'] == 1 && ($usergroup['canusesigxposts'] == 0 || $usergroup['canusesigxposts'] > 0 && $postnum > $usergroup['canusesigxposts'])) {
        $sig_parser = array("allow_html" => $mybb->settings['sightml'], "allow_mycode" => $mybb->settings['sigmycode'], "allow_smilies" => $mybb->settings['sigsmilies'], "allow_imgcode" => $mybb->settings['sigimgcode'], "me_username" => $post['username'], "filter_badwords" => 1);
        if ($usergroup['signofollow']) {
            $sig_parser['nofollow_on'] = 1;
        }
        $post['signature'] = $parser->parse_message($post['signature'], $sig_parser);
        eval("\$post['signature'] = \"" . $templates->get("postbit_signature") . "\";");
    } else {
        $post['signature'] = "";
    }
    $icon_cache = $cache->read("posticons");
    if ($post['icon'] > 0 && $icon_cache[$post['icon']]) {
        $icon = $icon_cache[$post['icon']];
        $icon['path'] = htmlspecialchars_uni($icon['path']);
        $icon['name'] = htmlspecialchars_uni($icon['name']);
        $post['icon'] = "<img src=\"{$icon['path']}\" alt=\"{$icon['name']}\" style=\"vertical-align: middle;\" />&nbsp;";
    } else {
        $post['icon'] = "";
    }
    $post_visibility = '';
    switch ($post_type) {
        case 1:
            // Message preview
            $post = $plugins->run_hooks("postbit_prev", $post);
            break;
        case 2:
            // Private message
            $post = $plugins->run_hooks("postbit_pm", $post);
            break;
        case 3:
            // Announcement
            $post = $plugins->run_hooks("postbit_announcement", $post);
            break;
        default:
            // Regular post
            $post = $plugins->run_hooks("postbit", $post);
            // Is this author on the ignore list of the current user? Hide this post
            $ignore_bit = '';
            if (is_array($ignored_users) && $post['uid'] != 0 && isset($ignored_users[$post['uid']]) && $ignored_users[$post['uid']] == 1) {
                $ignored_message = $lang->sprintf($lang->postbit_currently_ignoring_user, $post['username']);
                eval("\$ignore_bit = \"" . $templates->get("postbit_ignored") . "\";");
                $post_visibility = "display: none;";
            }
            break;
    }
    if ($mybb->settings['postlayout'] == "classic") {
        eval("\$postbit = \"" . $templates->get("postbit_classic") . "\";");
    } else {
        eval("\$postbit = \"" . $templates->get("postbit") . "\";");
    }
    $GLOBALS['post'] = "";
    return $postbit;
}
Ejemplo n.º 23
0
         $memlastvisitsep = $lang->comma;
         $memlastvisitdate = my_date('relative', $memprofile['lastactive']);
     }
     // Time Online
     $timeonline = $lang->none_registered;
     if ($memprofile['timeonline'] > 0) {
         $timeonline = nice_time($memprofile['timeonline']);
     }
     // Online?
     if (!empty($session)) {
         // Fetch their current location
         $lang->load("online");
         require_once MYBB_ROOT . "inc/functions_online.php";
         $activity = fetch_wol_activity($session['location'], $session['nopermission']);
         $location = build_friendly_wol_location($activity);
         $location_time = my_date($mybb->settings['timeformat'], $memprofile['lastactive']);
         eval("\$online_status = \"" . $templates->get("member_profile_online") . "\";");
     } else {
         eval("\$online_status = \"" . $templates->get("member_profile_offline") . "\";");
     }
 }
 if ($memprofile['invisible'] == 1 && $mybb->usergroup['canviewwolinvis'] != 1 && $memprofile['uid'] != $mybb->user['uid']) {
     $memlastvisitsep = '';
     $memlastvisittime = '';
     $memlastvisitdate = $lang->lastvisit_never;
     if ($memprofile['lastactive']) {
         // We have had at least some active time, hide it instead
         $memlastvisitdate = $lang->lastvisit_hidden;
     }
     $timeonline = $lang->timeonline_hidden;
 }
 $table = new Table();
 $table->construct_header($lang->your_version);
 $table->construct_header($lang->latest_version);
 $table->construct_cell("<strong>" . $mybb->version . "</strong> (" . $mybb->version_code . ")");
 $table->construct_cell($latest_version);
 $table->construct_row();
 $table->output($lang->version_check);
 if ($version_warn) {
     $page->output_error("<p><em>{$lang->error_out_of_date}</em> {$lang->update_forum}</p>");
 } else {
     $page->output_success("<p><em>{$lang->success_up_to_date}</em></p>");
 }
 if ($feed_parser->error == '') {
     foreach ($feed_parser->items as $item) {
         if ($item['date_timestamp']) {
             $stamp = my_date($mybb->settings['dateformat'], $item['date_timestamp']) . ", " . my_date($mybb->settings['timeformat'], $item['date_timestamp']);
         } else {
             $stamp = '';
         }
         if ($item['content']) {
             $content = $item['content'];
         } else {
             $content = $item['description'];
         }
         $table->construct_cell("<span style=\"font-size: 16px;\"><strong>" . $item['title'] . "</strong></span><br /><br />{$content}<strong><span style=\"float: right;\">{$stamp}</span><br /><br /><a href=\"{$item['link']}\" target=\"_blank\">&raquo; {$lang->read_more}</a></strong>");
         $table->construct_row();
     }
 } else {
     $table->construct_cell("{$lang->error_fetch_news} <!-- error code: {$feed_parser->error} -->");
     $table->construct_row();
 }
/**
 * Returns language-friendly string describing $logitem
 * @param array The log item (one row from mybb_adminlogs)
 * @return string The description
 */
function get_admin_log_action($logitem)
{
    global $lang, $plugins, $mybb;
    $logitem['module'] = str_replace('/', '-', $logitem['module']);
    list($module, $action) = explode('-', $logitem['module']);
    $lang_string = 'admin_log_' . $module . '_' . $action . '_' . $logitem['action'];
    // Specific page overrides
    switch ($lang_string) {
        // == CONFIG ==
        case 'admin_log_config_banning_add':
            // Banning IP/Username/Email
        // Banning IP/Username/Email
        case 'admin_log_config_banning_delete':
            // Removing banned IP/username/emails
            switch ($logitem['data'][2]) {
                case 1:
                    $lang_string = 'admin_log_config_banning_' . $logitem['action'] . '_ip';
                    break;
                case 2:
                    $lang_string = 'admin_log_config_banning_' . $logitem['action'] . '_username';
                    break;
                case 3:
                    $lang_string = 'admin_log_config_banning_' . $logitem['action'] . '_email';
                    break;
            }
            break;
        case 'admin_log_config_help_documents_add':
            // Help documents and sections
        // Help documents and sections
        case 'admin_log_config_help_documents_edit':
        case 'admin_log_config_help_documents_delete':
            $lang_string .= "_{$logitem['data'][2]}";
            // adds _section or _document
            break;
        case 'admin_log_config_languages_edit':
            // Editing language variables
            $logitem['data'][1] = basename($logitem['data'][1]);
            if ($logitem['data'][2] == 1) {
                $lang_string = 'admin_log_config_languages_edit_admin';
            }
            break;
        case 'admin_log_config_mycode_toggle_status':
            // Custom MyCode toggle activation
            if ($logitem['data'][2] == 1) {
                $lang_string .= '_enabled';
            } else {
                $lang_string .= '_disabled';
            }
            break;
        case 'admin_log_config_plugins_activate':
            // Installing plugin
            if ($logitem['data'][1]) {
                $lang_string .= '_install';
            }
            break;
        case 'admin_log_config_plugins_deactivate':
            // Uninstalling plugin
            if ($logitem['data'][1]) {
                $lang_string .= '_uninstall';
            }
            break;
            // == FORUM ==
        // == FORUM ==
        case 'admin_log_forum_attachments_delete':
            // Deleting attachments
            if ($logitem['data'][2]) {
                $lang_string .= '_post';
            }
            break;
        case 'admin_log_forum_management_copy':
            // Forum copy
            if ($logitem['data'][4]) {
                $lang_string .= '_with_permissions';
            }
            break;
        case 'admin_log_forum_management_':
            // add mod, permissions, forum orders
            // first parameter already set with action
            $lang_string .= $logitem['data'][0];
            if ($logitem['data'][0] == 'orders' && $logitem['data'][1]) {
                $lang_string .= '_sub';
                // updating forum orders in a subforum
            }
            break;
        case 'admin_log_forum_moderation_queue_':
            //moderation queue
            // first parameter already set with action
            $lang_string .= $logitem['data'][0];
            break;
            // == HOME ==
            // == STYLE ==
        // == HOME ==
        // == STYLE ==
        case 'admin_log_style_templates_delete_template':
            // deleting templates
            // global template set
            if ($logitem['data'][2] == -1) {
                $lang_string .= '_global';
            }
            break;
        case 'admin_log_style_templates_edit_template':
            // editing templates
            // global template set
            if ($logitem['data'][2] == -1) {
                $lang_string .= '_global';
            }
            break;
            // == TOOLS ==
        // == TOOLS ==
        case 'admin_log_tools_adminlog_prune':
            // Admin Log Pruning
            if ($logitem['data'][1] && !$logitem['data'][2]) {
                $lang_string = 'admin_log_tools_adminlog_prune_user';
            } elseif ($logitem['data'][2] && !$logitem['data'][1]) {
                $lang_string = 'admin_log_tools_adminlog_prune_module';
            } elseif ($logitem['data'][1] && $logitem['data'][2]) {
                $lang_string = 'admin_log_tools_adminlog_prune_user_module';
            }
            break;
        case 'admin_log_tools_modlog_prune':
            // Moderator Log Pruning
            if ($logitem['data'][1] && !$logitem['data'][2]) {
                $lang_string = 'admin_log_tools_modlog_prune_user';
            } elseif ($logitem['data'][2] && !$logitem['data'][1]) {
                $lang_string = 'admin_log_tools_modlog_prune_forum';
            } elseif ($logitem['data'][1] && $logitem['data'][2]) {
                $lang_string = 'admin_log_tools_modlog_prune_user_forum';
            }
            break;
        case 'admin_log_tools_backupdb_backup':
            // Create backup
            if ($logitem['data'][0] == 'download') {
                $lang_string = 'admin_log_tools_backupdb_backup_download';
            }
            $logitem['data'][1] = '...' . substr($logitem['data'][1], -20);
            break;
        case 'admin_log_tools_backupdb_dlbackup':
            // Download backup
            $logitem['data'][0] = '...' . substr($logitem['data'][0], -20);
            break;
        case 'admin_log_tools_backupdb_delete':
            // Delete backup
            $logitem['data'][0] = '...' . substr($logitem['data'][0], -20);
            break;
        case 'admin_log_tools_optimizedb_':
            // Optimize DB
            $logitem['data'][0] = @implode(', ', unserialize($logitem['data'][0]));
            break;
        case 'admin_log_tools_recount_rebuild_':
            // Recount and rebuild
            $detail_lang_string = $lang_string . $logitem['data'][0];
            if (isset($lang->{$detail_lang_string})) {
                $lang_string = $detail_lang_string;
            }
            break;
            // == USERS ==
        // == USERS ==
        case 'admin_log_user_admin_permissions_edit':
            // default/group/user admin permissions
            if ($logitem['data'][0] > 0) {
                // User
                $lang_string .= '_user';
            } elseif ($logitem['data'][0] < 0) {
                // Group
                $logitem['data'][0] = abs($logitem['data'][0]);
                $lang_string .= '_group';
            }
            break;
        case 'admin_log_user_banning_':
            // banning
            if ($logitem['data'][2] == 0) {
                $lang_string = 'admin_log_user_banning_add_permanent';
            } else {
                $logitem['data'][2] = my_date($mybb->settings['dateformat'], $logitem['data'][2]);
                $lang_string = 'admin_log_user_banning_add_temporary';
            }
            break;
        case 'admin_log_user_users_inline_banned':
            if ($logitem['data'][1] == 0) {
                $lang_string = 'admin_log_user_users_inline_banned_perm';
            } else {
                $logitem['data'][1] = my_date($mybb->settings['dateformat'], $logitem['data'][1]);
                $lang_string = 'admin_log_user_users_inline_banned_temp';
            }
            break;
    }
    $plugin_array = array('logitem' => &$logitem, 'lang_string' => &$lang_string);
    $plugins->run_hooks("admin_tools_get_admin_log_action", $plugin_array);
    if (isset($lang->{$lang_string})) {
        array_unshift($logitem['data'], $lang->{$lang_string});
        // First parameter for sprintf is the format string
        $string = call_user_func_array(array($lang, 'sprintf'), $logitem['data']);
        if (!$string) {
            $string = $lang->{$lang_string};
            // Fall back to the one in the language pack
        }
    } else {
        // Build a default string
        $string = $logitem['module'] . ' - ' . $logitem['action'];
        if (is_array($logitem['data']) && count($logitem['data']) > 0) {
            $string .= '(' . implode(', ', $logitem['data']) . ')';
        }
    }
    return $string;
}
Ejemplo n.º 26
0
/**
 * Fetch the birthdays for one or more months or a specific day
 *
 * @param mixed Integer of the month or array of months
 * @param int Day of the specific month (if only one month specified above)
 * @return array Array of birthdays
 */
function get_birthdays($months, $day = "")
{
    global $db;
    $year = my_date("Y");
    if (!is_array($months)) {
        $months = array($months);
    }
    foreach ($months as $month) {
        if ($day) {
            $day_where = "{$day}-{$month}";
        } else {
            $day_where = "%-{$month}";
        }
        if ($month == 3 && ($day == 1 || !$day) && my_date("L", gmmktime(0, 0, 0, $month, 1, $year)) != 1) {
            $where[] = "birthday LIKE '29-2%' OR birthday='29-2'";
            $feb_fix = 1;
        }
        $where[] = "birthday LIKE '{$day_where}-%' OR birthday LIKE '{$day_where}'";
    }
    $where = implode(" OR ", $where);
    $bdays = array();
    $query = $db->simple_select("users", "uid, username, birthday, birthdayprivacy, usergroup, displaygroup", $where);
    while ($user = $db->fetch_array($query)) {
        $bday = explode("-", $user['birthday']);
        if ($bday[2] && $bday[2] < $year) {
            $user['age'] = $year - $bday[2];
        }
        if ($feb_fix == 1 && $bday[0] == 29 && $bday[1] == 2) {
            $bdays["1-3"][] = $user;
        } else {
            $bdays["{$bday['0']}-{$bday['1']}"][] = $user;
        }
    }
    if ($day) {
        if (!isset($bdays["{$day}-{$month}"])) {
            return array();
        }
        return $bdays["{$day}-{$month}"];
    }
    return $bdays;
}
Ejemplo n.º 27
0
     if (!empty($awaitingattachments) || !empty($awaitingposts) || !empty($awaitingthreads)) {
         eval("\$awaitingmoderation = \"" . $templates->get("modcp_awaitingmoderation") . "\";");
     }
 }
 $latestfivemodactions = '';
 if (($nummodlogs > 0 || $mybb->usergroup['issupermod'] == 1) && $mybb->usergroup['canviewmodlogs'] == 1) {
     $where = '';
     if ($tflist_modlog) {
         $where = "WHERE (t.fid <> 0 {$tflist_modlog}) OR (!l.fid)";
     }
     $query = $db->query("\n\t\t\tSELECT l.*, u.username, u.usergroup, u.displaygroup, t.subject AS tsubject, f.name AS fname, p.subject AS psubject\n\t\t\tFROM " . TABLE_PREFIX . "moderatorlog l\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=l.uid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=l.tid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "forums f ON (f.fid=l.fid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "posts p ON (p.pid=l.pid)\n\t\t\t{$where}\n\t\t\tORDER BY l.dateline DESC\n\t\t\tLIMIT 5\n\t\t");
     $modlogresults = '';
     while ($logitem = $db->fetch_array($query)) {
         $information = '';
         $logitem['action'] = htmlspecialchars_uni($logitem['action']);
         $log_date = my_date('relative', $logitem['dateline']);
         $trow = alt_trow();
         $username = format_name($logitem['username'], $logitem['usergroup'], $logitem['displaygroup']);
         $logitem['profilelink'] = build_profile_link($username, $logitem['uid']);
         $logitem['ipaddress'] = my_inet_ntop($db->unescape_binary($logitem['ipaddress']));
         if ($logitem['tsubject']) {
             $logitem['tsubject'] = htmlspecialchars_uni($logitem['tsubject']);
             $logitem['thread'] = get_thread_link($logitem['tid']);
             eval("\$information .= \"" . $templates->get("modcp_modlogs_result_thread") . "\";");
         }
         if ($logitem['fname']) {
             $logitem['forum'] = get_forum_link($logitem['fid']);
             eval("\$information .= \"" . $templates->get("modcp_modlogs_result_forum") . "\";");
         }
         if ($logitem['psubject']) {
             $logitem['psubject'] = htmlspecialchars_uni($logitem['psubject']);
Ejemplo n.º 28
0
    static function render_shout($data, $static = false)
    {
        global $mybb;
        $id = $data['id'];
        $text = self::parse($data['text'], $data['username']);
        $date = htmlspecialchars_uni(my_date($mybb->settings['dvz_sb_dateformat'], $data['date']));
        $username = htmlspecialchars_uni($data['username']);
        $user = '******' . (int) $data['uid'] . '">' . format_name($username, $data['usergroup'], $data['displaygroup']) . '</a>';
        $avatar = '<img src="' . (empty($data['avatar']) ? htmlspecialchars_uni($mybb->settings['useravatar']) : htmlspecialchars_uni($data['avatar'])) . '" alt="avatar" />';
        $notes = null;
        $attributes = null;
        $own = $data['uid'] == $mybb->user['uid'];
        if ($static) {
            if (self::access_mod()) {
                $notes .= '<span class="ip">' . my_inet_ntop($data['ipaddress']) . '</span>';
            }
            if (self::access_mod() || self::access_mod_own() && $own) {
                $notes .= '<a href="" class="mod edit">E</a><a href="" class="mod del">X</a>';
            }
        }
        if (self::access_mod() || self::access_mod_own() && $own) {
            $attributes .= ' data-mod';
        }
        if ($own) {
            $attributes .= ' data-own';
        }
        return '
<div class="entry" data-id="' . $id . '" data-username="******"' . $attributes . '>
    <div class="avatar">' . $avatar . '</div>
    <div class="user">' . $user . '</div>
    <div class="text">' . $text . '</div>
    <div class="info">' . $notes . '<span class="date">' . $date . '</span></div>
</div>';
    }
Ejemplo n.º 29
0
     $parser_options['allow_videocode'] = 0;
 }
 $post['message'] = $parser->parse_message($message, $parser_options);
 // Now lets fetch all of the attachments for these posts.
 if ($mybb->settings['enableattachments'] != 0) {
     $query = $db->simple_select("attachments", "*", "pid='{$post['pid']}'");
     while ($attachment = $db->fetch_array($query)) {
         $attachcache[$attachment['pid']][$attachment['aid']] = $attachment;
     }
     require_once MYBB_ROOT . "inc/functions_post.php";
     get_post_attachments($post['pid'], $post);
 }
 // Figure out if we need to show an "edited by" message
 // Only show if at least one of "showeditedby" or "showeditedbyadmin" is enabled
 if ($mybb->settings['showeditedby'] != 0 && $mybb->settings['showeditedbyadmin'] != 0) {
     $post['editdate'] = my_date('relative', TIME_NOW);
     $post['editnote'] = $lang->sprintf($lang->postbit_edited, $post['editdate']);
     $post['editedprofilelink'] = build_profile_link($mybb->user['username'], $mybb->user['uid']);
     $post['editreason'] = trim($editreason);
     $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("\$editedmsg = \"" . $templates->get("postbit_editedby") . "\";");
 }
 // Send our headers.
 header("Content-type: application/json; charset={$charset}");
 $editedmsg_response = null;
 if ($editedmsg) {
    static function render_shout($data, $static = false)
    {
        global $mybb, $lang;
        $id = $data['id'];
        $text = $data['text'];
        $date = my_date($mybb->settings['dvz_sb_dateformat'], $data['date']);
        if ($uid = self::isPvt($text)) {
            if ($uid != $mybb->user['uid'] && $data['username'] != $mybb->user['username']) {
                return;
            }
            $replace = array("/pvt", $uid);
            $lang->load('custom');
            $usernameString = self::getUsername($uid, $data);
            $text = str_replace($replace, "", $text);
        }
        $text = dvz_shoutbox::parse($text, $data['username']);
        if ($usernameString) {
            $replace = array('<p>', '</p>');
            $text = $usernameString . str_replace($replace, "", $text);
        }
        $avatar = '<a href="/member.php?action=profile&' . $data['uid'] . '"><img src="' . (empty($data['avatar']) ? 'images/default_avatar.png' : $data['avatar']) . '" alt="avatar" /></a>';
        $user = '******' . (int) $data['uid'] . '"><a>' . format_name($data['username'], $data['usergroup'], $data['displaygroup']) . '</a></span>';
        $notes = null;
        $attributes = null;
        $own = $data['uid'] == $mybb->user['uid'];
        if ($static) {
            if (dvz_shoutbox::access_mod()) {
                $notes .= '<span class="ip">' . $data['ip'] . '</span>';
            }
            if (dvz_shoutbox::access_mod() || dvz_shoutbox::access_mod_own() && $own) {
                $notes .= '<a href="" class="mod edit">E</a><a href="" class="mod del">X</a>';
            }
        }
        if (dvz_shoutbox::access_mod() || dvz_shoutbox::access_mod_own() && $own) {
            $attributes .= ' data-mod';
        }
        if ($own) {
            $attributes .= ' data-own';
        }
        $notes .= '<a href="" class="mod report">REPORT</a>';
        return '
<div class="entry" data-id="' . $id . '" data-username="******"' . $attributes . '>
    <div class="avatar">' . $avatar . '</div>
    <div class="user">' . $user . ':</div>
    <div class="text">' . $text . '</div>
    <div class="info"><span class="date">' . $date . '</span>' . $notes . '</div>
</div>';
    }