コード例 #1
0
function fetch_forum_announcements($pid = 0, $depth = 1)
{
    global $mybb, $db, $lang, $announcements, $templates, $announcements_forum, $moderated_forums;
    static $forums_by_parent, $forum_cache, $parent_forums;
    if (!is_array($forum_cache)) {
        $forum_cache = cache_forums();
    }
    if (!is_array($parent_forums) && $mybb->user['issupermod'] != 1) {
        // Get a list of parentforums to show for normal moderators
        $parent_forums = array();
        foreach ($moderated_forums as $mfid) {
            $parent_forums = array_merge($parent_forums, explode(',', $forum_cache[$mfid]['parentlist']));
        }
    }
    if (!is_array($forums_by_parent)) {
        foreach ($forum_cache as $forum) {
            $forums_by_parent[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
        }
    }
    if (!is_array($forums_by_parent[$pid])) {
        return;
    }
    foreach ($forums_by_parent[$pid] as $children) {
        foreach ($children as $forum) {
            if ($forum['active'] == 0 || !is_moderator($forum['fid'])) {
                // Check if this forum is a parent of a moderated forum
                if (in_array($forum['fid'], $parent_forums)) {
                    // A child is moderated, so print out this forum's title.  RECURSE!
                    $trow = alt_trow();
                    eval("\$announcements_forum .= \"" . $templates->get("modcp_announcements_forum_nomod") . "\";");
                } else {
                    // No subforum is moderated by this mod, so safely continue
                    continue;
                }
            } else {
                // This forum is moderated by the user, so print out the forum's title, and its announcements
                $trow = alt_trow();
                $padding = 40 * ($depth - 1);
                eval("\$announcements_forum .= \"" . $templates->get("modcp_announcements_forum") . "\";");
                if ($announcements[$forum['fid']]) {
                    foreach ($announcements[$forum['fid']] as $aid => $announcement) {
                        $trow = alt_trow();
                        if ($announcement['enddate'] < TIME_NOW && $announcement['enddate'] != 0) {
                            $icon = "<img src=\"images/minioff.gif\" alt=\"({$lang->expired})\" title=\"{$lang->expired_announcement}\"  style=\"vertical-align: middle;\" /> ";
                        } else {
                            $icon = "<img src=\"images/minion.gif\" alt=\"({$lang->active})\" title=\"{$lang->active_announcement}\"  style=\"vertical-align: middle;\" /> ";
                        }
                        $subject = htmlspecialchars_uni($announcement['subject']);
                        eval("\$announcements_forum .= \"" . $templates->get("modcp_announcements_announcement") . "\";");
                    }
                }
            }
            // Build the list for any sub forums of this forum
            if ($forums_by_parent[$forum['fid']]) {
                fetch_forum_announcements($forum['fid'], $depth + 1);
            }
        }
    }
}
コード例 #2
0
function trader_view_rep($uid = 1)
{
    global $mybb, $db, $templates, $pagination, $mypostkey, $header, $headerinclude, $footer, $theme, $posreps, $negreps, $neutreps, $totalreps, $lang;
    $lang->load("tradefeedback");
    $uid = intval($uid);
    if (!$uid) {
        $uid = $mybb->user['uid'];
    }
    if (!$uid) {
        error($lang->feedback_invalid_user);
    }
    if ($mybb->input['fid']) {
        $colspan = 5;
        $fidonly = "AND f.fid=" . intval($mybb->input['fid']) . " ";
    } else {
        $colspan = 6;
        $detailcolumn = "<th class=\"tcat\">{$lang->feedback_details}</th>";
    }
    $url = "tradefeedback.php?action=view&uid={$uid}";
    if (isset($mybb->input['value'])) {
        $value = intval($mybb->input['value']);
        $valuesql = " AND f.value={$value}";
        $url .= "&value={$value}";
    }
    if (isset($mybb->input['type'])) {
        $type = $db->escape_string($mybb->input['type']);
        $typesql = " AND f.type='{$type}'";
        $url .= "&type={$type}";
    }
    $approved = 1;
    if ($mybb->usergroup['canmodcp'] && $mybb->usergroup['issupermod']) {
        $approved = 0;
    }
    // Count the number of reps to figure out pagination
    $query = $db->simple_select("trade_feedback f", "COUNT(f.fid) as reps", "f.receiver={$uid} AND f.approved >= {$approved} {$valuesql} {$fidonly} {$typesql}");
    $total = $db->fetch_field($query, "reps");
    if (!$total) {
        $noresults = "<tr><td colspan=\"{$colspan}\">{$lang->feedback_no_results}</td></tr>";
    }
    $userquery = $db->simple_select("users", "username, posreps, neutreps, negreps", "uid={$uid}");
    $feedback = $db->fetch_array($userquery);
    $receiverusername = $feedback['username'];
    add_breadcrumb($lang->sprintf($lang->feedback_profile, $receiverusername), "member.php?action=profile&uid={$uid}");
    add_breadcrumb($lang->sprintf($lang->feedback_page_title, $receiverusername), "tradefeedback.php?action=view&uid={$uid}");
    $posreps = $feedback['posreps'];
    $neutreps = $feedback['neutreps'];
    $negreps = $feedback['negreps'];
    $totalreps = $posreps + $neutreps + $negreps;
    $perpage = 20;
    $pages = ceil($total / $perpage);
    if ($mybb->input['page']) {
        $pages = intval($mybb->input['page']);
    } else {
        $page = 1;
    }
    if ($page < 1) {
        $page = 1;
    }
    if ($page > $pages) {
        $page = $pages;
    }
    $start = $page * $perpage - $perpage;
    if ($start < 0) {
        $start = 0;
    }
    $pagination = multipage($total, $perpage, $page, $url);
    // Actually fetch the feedback
    $query = $db->query("SELECT f.*, u.username, u.usergroup, u.displaygroup\n    FROM " . TABLE_PREFIX . "trade_feedback f\n    LEFT JOIN " . TABLE_PREFIX . "users u\n    ON(f.giver=u.uid)\n    WHERE f.receiver={$uid} AND f.approved >= {$approved} {$valuesql} {$fidonly} {$typesql}\n    ORDER BY f.dateline DESC\n    LIMIT {$start} , {$perpage}");
    while ($feedback = $db->fetch_array($query)) {
        $feedback['formattedname'] = format_name($feedback['username'], $feedback['usergroup'], $feedback['displaygroup']);
        $feedback['profilelink'] = build_profile_link($feedback['formattedname'], $feedback['giver']);
        $feedback['dateline'] = my_date($mybb->settings['dateformat'], $feedback['dateline'], "", 0);
        if ($feedback['threadlink'] && $mybb->input['fid']) {
            $threadlink = "<br /><a href=\"" . htmlspecialchars_uni($feedback['threadlink']) . "\" target=\"_blank\">{$lang->feedback_threadlink}</a>";
        }
        if ($feedback['value'] == 1) {
            $feedback['smilyurl'] = $mybb->settings['bburl'] . "/images/smilies/smile.png";
        } else {
            if ($feedback['value'] == 0) {
                $feedback['smilyurl'] = $mybb->settings['bburl'] . "/images/smilies/undecided.png";
            } else {
                $feedback['smilyurl'] = $mybb->settings['bburl'] . "/images/smilies/angry.png";
            }
        }
        $feedback['type'] = ucfirst($feedback['type']);
        if ($mybb->usergroup['canmodcp'] && $mybb->usergroup['issupermod']) {
            if ($feedback['approved'] == 1) {
                $approvedtext = $lang->feedback_options_unapprove;
                $approvedlinkpart = "unapprove";
                $tdclass = alt_trow();
            } else {
                $approvedtext = $lang->feedback_options_approve;
                $approvedlinkpart = "approve";
                $tdclass = "trow_shaded";
            }
            eval("\$modbit = \"" . $templates->get("tradefeedback_mod") . "\";");
        }
        if (!$mybb->input['fid']) {
            $detaillink = "<td class=\"{$tdclass}\"><a href=\"" . $mybb->settings['bburl'] . "/tradefeedback.php?action=view&amp;uid=" . $mybb->input['uid'] . "&amp;fid=" . $feedback['fid'] . "\">{$lang->feedback_view_details}</a></td>";
            if (strlen($feedback['comments']) >= 50) {
                $feedback['comments'] = my_substr($feedback['comments'], 0, 50) . "...";
            }
        }
        if ($mybb->user['uid'] && $mybb->usergroup['isbannedgroup'] == 0) {
            eval("\$report = \"" . $templates->get("tradefeedback_report") . "\";");
        }
        $feedback['comments'] = htmlspecialchars_uni($feedback['comments']);
        eval("\$tradefeedback .= \"" . $templates->get("tradefeedback_view_rep") . "\";");
        unset($threadlink);
        unset($detaillink);
    }
    $lang->feedback_stats = $lang->sprintf($lang->feedback_stats, $receiverusername);
    $lang->feedback_page_title = $lang->sprintf($lang->feedback_page_title, $receiverusername);
    $lang->leave_feedback = $lang->sprintf($lang->leave_feedback, $receiverusername);
    eval("\$tradefeedback_view_page = \"" . $templates->get("tradefeedback_view_page") . "\";");
    output_page($tradefeedback_view_page);
}
コード例 #3
0
ファイル: member.php プロジェクト: nicopinto/fantasitura.com
                 $parser_options = array("allow_html" => $customfield['allowhtml'], "allow_mycode" => $customfield['allowmycode'], "allow_smilies" => $customfield['allowsmilies'], "allow_imgcode" => $customfield['allowimgcode'], "allow_videocode" => $customfield['allowvideocode'], "filter_badwords" => 1);
                 if ($customfield['type'] == "textarea") {
                     $parser_options['me_username'] = $memprofile['username'];
                 } else {
                     $parser_options['nl2br'] = 0;
                 }
                 if ($mybb->user['showimages'] != 1 && $mybb->user['uid'] != 0 || $mybb->settings['guestimages'] != 1 && $mybb->user['uid'] == 0) {
                     $parser_options['allow_imgcode'] = 0;
                 }
                 $customfieldval = $parser->parse_message($userfields[$field], $parser_options);
             }
         }
         if ($customfieldval) {
             $customfield['name'] = htmlspecialchars_uni($customfield['name']);
             eval("\$customfields .= \"" . $templates->get("member_profile_customfields_field") . "\";");
             $bgcolor = alt_trow();
         }
     }
 }
 if ($customfields) {
     eval("\$profilefields = \"" . $templates->get("member_profile_customfields") . "\";");
 }
 $memprofile['postnum'] = my_number_format($memprofile['postnum']);
 $lang->ppd_percent_total = $lang->sprintf($lang->ppd_percent_total, my_number_format($ppd), $post_percent);
 $memprofile['threadnum'] = my_number_format($memprofile['threadnum']);
 $lang->tpd_percent_total = $lang->sprintf($lang->tpd_percent_total, my_number_format($tpd), $thread_percent);
 $formattedname = format_name($memprofile['username'], $memprofile['usergroup'], $memprofile['displaygroup']);
 $bannedbit = '';
 if ($memperms['isbannedgroup'] == 1 && $mybb->usergroup['canbanusers'] == 1) {
     // Fetch details on their ban
     $query = $db->simple_select('banned b LEFT JOIN ' . TABLE_PREFIX . 'users a ON (b.admin=a.uid)', 'b.*, a.username AS adminuser', "b.uid='{$uid}'", array('limit' => 1));
コード例 #4
0
 $numusers = $db->num_rows($query);
 $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;
コード例 #5
0
ファイル: warnings.php プロジェクト: GeorgeLVP/mybb
        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) {
        eval("\$warnings = \"" . $templates->get("warnings_no_warnings") . "\";");
    }
    $plugins->run_hooks("warnings_end");
    eval("\$warnings = \"" . $templates->get("warnings") . "\";");
    output_page($warnings);
}
function find_warnlevels_to_check(&$query, &$max_expiration_times, &$check_levels)
{
    global $db;
    // we have some warning levels we need to revoke
    $max_expiration_times = array(1 => -1, 2 => -1, 3 => -1);
コード例 #6
0
/**
* Build a list of forum bits.
*
* @param int The parent forum to fetch the child forums for (0 assumes all)
* @param int The depth to return forums with.
* @return array Array of information regarding the child forums of this parent forum
*/
function build_forumbits($pid = 0, $depth = 1)
{
    global $fcache, $moderatorcache, $forumpermissions, $theme, $mybb, $templates, $bgcolor, $collapsed, $lang, $showdepth, $plugins, $parser, $forum_viewers;
    $forum_listing = '';
    // If no forums exist with this parent, do nothing
    if (!is_array($fcache[$pid])) {
        return;
    }
    // Foreach of the forums in this parent
    foreach ($fcache[$pid] as $parent) {
        foreach ($parent as $forum) {
            $forums = $subforums = $sub_forums = '';
            $lastpost_data = '';
            $counters = '';
            $forum_viewers_text = '';
            $forum_viewers_text_plain = '';
            // Get the permissions for this forum
            $permissions = $forumpermissions[$forum['fid']];
            // If this user doesnt have permission to view this forum and we're hiding private forums, skip this forum
            if ($permissions['canview'] != 1 && $mybb->settings['hideprivateforums'] == 1) {
                continue;
            }
            $plugins->run_hooks_by_ref("build_forumbits_forum", $forum);
            // Build the link to this forum
            $forum_url = get_forum_link($forum['fid']);
            // This forum has a password, and the user isn't authenticated with it - hide post information
            $hideinfo = false;
            $showlockicon = 0;
            if ($permissions['canviewthreads'] != 1) {
                $hideinfo = true;
            }
            if ($forum['password'] != '' && $mybb->cookies['forumpass'][$forum['fid']] != md5($mybb->user['uid'] . $forum['password'])) {
                $hideinfo = true;
                $showlockicon = 1;
            }
            $lastpost_data = array("lastpost" => $forum['lastpost'], "lastpostsubject" => $forum['lastpostsubject'], "lastposter" => $forum['lastposter'], "lastposttid" => $forum['lastposttid'], "lastposteruid" => $forum['lastposteruid']);
            // Fetch subforums of this forum
            if (isset($fcache[$forum['fid']])) {
                $forum_info = build_forumbits($forum['fid'], $depth + 1);
                // Increment forum counters with counters from child forums
                $forum['threads'] += $forum_info['counters']['threads'];
                $forum['posts'] += $forum_info['counters']['posts'];
                $forum['unapprovedthreads'] += $forum_info['counters']['unapprovedthreads'];
                $forum['unapprovedposts'] += $forum_info['counters']['unapprovedposts'];
                $forum['viewers'] += $forum_info['counters']['viewing'];
                // If the child forums' lastpost is greater than the one for this forum, set it as the child forums greatest.
                if ($forum_info['lastpost']['lastpost'] > $lastpost_data['lastpost']) {
                    $lastpost_data = $forum_info['lastpost'];
                }
                $sub_forums = $forum_info['forum_list'];
            }
            // If we are hiding information (lastpost) because we aren't authenticated against the password for this forum, remove them
            if ($hideinfo == true) {
                unset($lastpost_data);
            }
            // If the current forums lastpost is greater than other child forums of the current parent, overwrite it
            if ($lastpost_data['lastpost'] > $parent_lastpost['lastpost']) {
                $parent_lastpost = $lastpost_data;
            }
            if (is_array($forum_viewers) && $forum_viewers[$forum['fid']] > 0) {
                $forum['viewers'] = $forum_viewers[$forum['fid']];
            }
            // Increment the counters for the parent forum (returned later)
            if ($hideinfo != true) {
                $parent_counters['threads'] += $forum['threads'];
                $parent_counters['posts'] += $forum['posts'];
                $parent_counters['unapprovedposts'] += $forum['unapprovedposts'];
                $parent_counters['unapprovedthreads'] += $forum['unapprovedthreads'];
                $parent_counters['viewers'] += $forum['viewers'];
            }
            // Done with our math, lets talk about displaying - only display forums which are under a certain depth
            if ($depth > $showdepth) {
                continue;
            }
            // Get the lightbulb status indicator for this forum based on the lastpost
            $lightbulb = get_forum_lightbulb($forum, $lastpost_data, $showlockicon);
            // Fetch the number of unapproved threads and posts for this forum
            $unapproved = get_forum_unapproved($forum);
            if ($hideinfo == true) {
                unset($unapproved);
            }
            // Sanitize name and description of forum.
            $forum['name'] = preg_replace("#&(?!\\#[0-9]+;)#si", "&amp;", $forum['name']);
            // Fix & but allow unicode
            $forum['description'] = preg_replace("#&(?!\\#[0-9]+;)#si", "&amp;", $forum['description']);
            // Fix & but allow unicode
            $forum['name'] = preg_replace("#&([^\\#])(?![a-z1-4]{1,10};)#i", "&#038;\$1", $forum['name']);
            $forum['description'] = preg_replace("#&([^\\#])(?![a-z1-4]{1,10};)#i", "&#038;\$1", $forum['description']);
            // If this is a forum and we've got subforums of it, load the subforums list template
            if ($depth == 2 && $sub_forums) {
                eval("\$subforums = \"" . $templates->get("forumbit_subforums") . "\";");
            } else {
                if ($depth == 3) {
                    if ($donecount < $mybb->settings['subforumsindex']) {
                        $statusicon = '';
                        // Showing mini status icons for this forum
                        if ($mybb->settings['subforumsstatusicons'] == 1) {
                            $lightbulb['folder'] = "mini" . $lightbulb['folder'];
                            eval("\$statusicon = \"" . $templates->get("forumbit_depth3_statusicon", 1, 0) . "\";");
                        }
                        // Fetch the template and append it to the list
                        eval("\$forum_list .= \"" . $templates->get("forumbit_depth3", 1, 0) . "\";");
                        $comma = ', ';
                    }
                    // Have we reached our max visible subforums? put a nice message and break out of the loop
                    ++$donecount;
                    if ($donecount == $mybb->settings['subforumsindex']) {
                        if (subforums_count($fcache[$pid]) > $donecount) {
                            $forum_list .= $comma . $lang->sprintf($lang->more_subforums, subforums_count($fcache[$pid]) - $donecount);
                        }
                    }
                    continue;
                }
            }
            // Forum is a category, set template type
            if ($forum['type'] == 'c') {
                $forumcat = '_cat';
            } else {
                $forumcat = '_forum';
            }
            if ($forum['linkto'] == '') {
                // No posts have been made in this forum - show never text
                if (($lastpost_data['lastpost'] == 0 || $lastpost_data['lastposter'] == '') && $hideinfo != true) {
                    $lastpost = "<div style=\"text-align: center;\">{$lang->lastpost_never}</div>";
                } elseif ($hideinfo != true) {
                    // Format lastpost date and time
                    $lastpost_date = my_date($mybb->settings['dateformat'], $lastpost_data['lastpost']);
                    $lastpost_time = my_date($mybb->settings['timeformat'], $lastpost_data['lastpost']);
                    // Set up the last poster, last post thread id, last post subject and format appropriately
                    $lastpost_profilelink = build_profile_link($lastpost_data['lastposter'], $lastpost_data['lastposteruid']);
                    $lastpost_link = get_thread_link($lastpost_data['lastposttid'], 0, "lastpost");
                    $lastpost_subject = $full_lastpost_subject = $parser->parse_badwords($lastpost_data['lastpostsubject']);
                    if (my_strlen($lastpost_subject) > 25) {
                        $lastpost_subject = my_substr($lastpost_subject, 0, 25) . "...";
                    }
                    $lastpost_subject = htmlspecialchars_uni($lastpost_subject);
                    $full_lastpost_subject = htmlspecialchars_uni($full_lastpost_subject);
                    // Call lastpost template
                    if ($depth != 1) {
                        eval("\$lastpost = \"" . $templates->get("forumbit_depth{$depth}_forum_lastpost") . "\";");
                    }
                }
                if ($mybb->settings['showforumviewing'] != 0 && $forum['viewers'] > 0) {
                    if ($forum['viewers'] == 1) {
                        $forum_viewers_text = $lang->viewing_one;
                    } else {
                        $forum_viewers_text = $lang->sprintf($lang->viewing_multiple, $forum['viewers']);
                    }
                    $forum_viewers_text_plain = $forum_viewers_text;
                    $forum_viewers_text = "<span class=\"smalltext\">{$forum_viewers_text}</span>";
                }
            }
            // If this forum is a link or is password protected and the user isn't authenticated, set lastpost and counters to "-"
            if ($forum['linkto'] != '' || $hideinfo == true) {
                $lastpost = "<div style=\"text-align: center;\">-</div>";
                $posts = "-";
                $threads = "-";
            } else {
                $posts = my_number_format($forum['posts']);
                $threads = my_number_format($forum['threads']);
            }
            // Moderator column is not off
            if ($mybb->settings['modlist'] != 0) {
                $done_moderators = array();
                $moderators = '';
                // Fetch list of moderators from this forum and its parents
                $parentlistexploded = explode(',', $forum['parentlist']);
                foreach ($parentlistexploded as $mfid) {
                    // This forum has moderators
                    if (is_array($moderatorcache[$mfid])) {
                        // Fetch each moderator from the cache and format it, appending it to the list
                        foreach ($moderatorcache[$mfid] as $moderator) {
                            if (in_array($moderator['uid'], $done_moderators)) {
                                continue;
                            }
                            $moderators .= "{$comma}<a href=\"" . get_profile_link($moderator['uid']) . "\">" . htmlspecialchars_uni($moderator['username']) . "</a>";
                            $comma = ', ';
                            $done_moderators[] = $moderator['uid'];
                        }
                    }
                }
                $comma = '';
                // If we have a moderators list, load the template
                if ($moderators) {
                    eval("\$modlist = \"" . $templates->get("forumbit_moderators") . "\";");
                } else {
                    $modlist = '';
                }
            }
            // Descriptions aren't being shown - blank them
            if ($mybb->settings['showdescriptions'] == 0) {
                $forum['description'] = '';
            }
            // Check if this category is either expanded or collapsed and hide it as necessary.
            $expdisplay = '';
            $collapsed_name = "cat_{$forum['fid']}_c";
            if (isset($collapsed[$collapsed_name]) && $collapsed[$collapsed_name] == "display: show;") {
                $expcolimage = "collapse_collapsed.gif";
                $expdisplay = "display: none;";
                $expaltext = "[+]";
            } else {
                $expcolimage = "collapse.gif";
                $expaltext = "[-]";
            }
            // Swap over the alternate backgrounds
            $bgcolor = alt_trow();
            // Add the forum to the list
            eval("\$forum_list .= \"" . $templates->get("forumbit_depth{$depth}{$forumcat}") . "\";");
        }
    }
    // Return an array of information to the parent forum including child forums list, counters and lastpost information
    return array("forum_list" => $forum_list, "counters" => $parent_counters, "lastpost" => $parent_lastpost);
}
コード例 #7
0
 function xthreads_tpl_forumbits_tplget(&$obj, &$forum, $title, $eslashes, $htmlcomments)
 {
     if ($forum['xthreads_hideforum']) {
         // alternate the bgcolor if applicable (so we get no net change)
         if ($title == 'forumbit_depth1_cat' || $title == 'forumbit_depth2_cat' || $title == 'forumbit_depth2_forum') {
             $GLOBALS['bgcolor'] = alt_trow();
         }
         return 'return "";';
     }
     global $forum_tpl_prefixes;
     if (!empty($forum_tpl_prefixes[$forum['fid']])) {
         foreach ($forum_tpl_prefixes[$forum['fid']] as &$p) {
             if (isset($obj->cache[$p . $title]) && !isset($obj->non_existant_templates[$p . $title])) {
                 $title = $p . $title;
                 break;
             }
         }
     }
     return 'return "' . $obj->xthreads_tpl_forumbits_get($title, $eslashes, $htmlcomments) . '";';
 }
コード例 #8
0
ファイル: teamonline.php プロジェクト: ambsalinas/anima
function teamonline_show()
{
    global $cache, $groupscache, $db, $mybb, $teamonline, $lang, $theme, $templates, $online;
    $lang->load('teamonline');
    if ($mybb->settings['teamonline_gid']) {
        $gid = " IN (" . $mybb->settings['teamonline_gid'] . ")";
        $timesearch = TIME_NOW - $mybb->settings['wolcutoffmins'] * 60;
        $teamonline_row = '';
        $trowbg = alt_trow();
        $query = $db->query("\n\t\t\tSELECT s.sid, s.ip, s.uid, u.username, s.time, u.avatar, u.usergroup, u.displaygroup, u.invisible\n\t\t\tFROM " . TABLE_PREFIX . "sessions s\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (s.uid=u.uid)\n\t\t\tWHERE u.usergroup {$gid} AND time>'{$timesearch}'\n\t\t\tORDER BY u.username ASC, s.time DESC\n\t\t\t");
        if (!$db->num_rows($query)) {
            eval("\$teamonline_no = \"" . $templates->get("teamonline_no") . "\";");
            $invisible = 0;
            $membercount = 0;
        } else {
            if (!is_array($groupscache)) {
                $groupscache = $cache->read("usergroups");
            }
            while ($online = $db->fetch_array($query)) {
                $invisible_mark = '';
                if ($online['invisible'] == 1) {
                    $invisible_mark = '*';
                }
                if ($online['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $online['uid'] == $mybb->user['uid']) {
                    $avatar_teamonline = format_avatar($online['avatar']);
                    $online['username'] = format_name($online['username'], $online['usergroup'], $online['displaygroup']);
                    $online['profilelink'] = build_profile_link($online['username'], $online['uid']) . $invisible_mark;
                    $online['groupname'] = $groupscache[$online['usergroup']]['title'];
                    eval("\$teamonline_row .= \"" . $templates->get("teamonline_row") . "\";");
                }
                $invisible += $online['invisible'];
                $membercount++;
            }
        }
        eval("\$teamonline = \"" . $templates->get("teamonline") . "\";");
    }
}
コード例 #9
0
ファイル: alerts.php プロジェクト: WhiteNeo/MyAlerts
/**
 * View all alerts.
 *
 * @param MyBB       $mybb      MyBB core object.
 * @param MyLanguage $lang      Language object.
 * @param templates  $templates Template manager.
 * @param array      $theme     Details about the current theme.
 */
function myalerts_view_alerts($mybb, $lang, $templates, $theme)
{
    if (MybbStuff_MyAlerts_AlertManager::getInstance() === false) {
        myalerts_create_instances();
    }
    $alerts = MybbStuff_MyAlerts_AlertManager::getInstance()->getAlerts(0, 10);
    if (!isset($lang->myalerts)) {
        $lang->load('myalerts');
    }
    add_breadcrumb($lang->myalerts_page_title, 'alerts.php?action=alerts');
    require_once __DIR__ . '/inc/functions_user.php';
    usercp_menu();
    $numAlerts = MybbStuff_MyAlerts_AlertManager::getInstance()->getNumAlerts();
    $page = (int) $mybb->input['page'];
    $pages = ceil($numAlerts / $mybb->settings['myalerts_perpage']);
    if ($page > $pages or $page <= 0) {
        $page = 1;
    }
    if ($page) {
        $start = ($page - 1) * $mybb->settings['myalerts_perpage'];
    } else {
        $start = 0;
        $page = 1;
    }
    $multipage = multipage($numAlerts, $mybb->settings['myalerts_perpage'], $page, "alerts.php");
    $alertsList = MybbStuff_MyAlerts_AlertManager::getInstance()->getAlerts($start);
    $readAlerts = array();
    if (is_array($alertsList) && !empty($alertsList)) {
        foreach ($alertsList as $alertObject) {
            $altbg = alt_trow();
            $alert = parse_alert($alertObject);
            if ($alert['message']) {
                eval("\$alertsListing .= \"" . $templates->get('myalerts_alert_row') . "\";");
            }
            $readAlerts[] = $alert['id'];
        }
    } else {
        $altbg = 'trow1';
        eval("\$alertsListing = \"" . $templates->get('myalerts_alert_row_no_alerts') . "\";");
    }
    MybbStuff_MyAlerts_AlertManager::getInstance()->markRead($readAlerts);
    global $headerinclude, $header, $footer, $usercpnav;
    $content = '';
    eval("\$content = \"" . $templates->get('myalerts_page') . "\";");
    output_page($content);
}
コード例 #10
0
/**
* Build a list of forum bits.
*
* @param int $pid The parent forum to fetch the child forums for (0 assumes all)
* @param int $depth The depth to return forums with.
* @return array Array of information regarding the child forums of this parent forum
*/
function build_forumbits($pid = 0, $depth = 1)
{
    global $db, $fcache, $moderatorcache, $forumpermissions, $theme, $mybb, $templates, $bgcolor, $collapsed, $lang, $showdepth, $plugins, $parser, $forum_viewers;
    static $private_forums;
    $forum_listing = '';
    // If no forums exist with this parent, do nothing
    if (empty($fcache[$pid]) || !is_array($fcache[$pid])) {
        return;
    }
    $parent_counters['threads'] = 0;
    $parent_counters['posts'] = 0;
    $parent_counters['unapprovedposts'] = 0;
    $parent_counters['unapprovedthreads'] = 0;
    $parent_counters['viewers'] = 0;
    $forum_list = $comma = '';
    $donecount = 0;
    // Foreach of the forums in this parent
    foreach ($fcache[$pid] as $parent) {
        foreach ($parent as $forum) {
            $subforums = $sub_forums = '';
            $lastpost_data = array('lastpost' => 0);
            $forum_viewers_text = '';
            $forum_viewers_text_plain = '';
            // Get the permissions for this forum
            $permissions = $forumpermissions[$forum['fid']];
            // If this user doesnt have permission to view this forum and we're hiding private forums, skip this forum
            if ($permissions['canview'] != 1 && $mybb->settings['hideprivateforums'] == 1) {
                continue;
            }
            $forum = $plugins->run_hooks("build_forumbits_forum", $forum);
            // Build the link to this forum
            $forum_url = get_forum_link($forum['fid']);
            // This forum has a password, and the user isn't authenticated with it - hide post information
            $hideinfo = $hidecounters = false;
            $hidelastpostinfo = false;
            $showlockicon = 0;
            if (isset($permissions['canviewthreads']) && $permissions['canviewthreads'] != 1) {
                $hideinfo = true;
            }
            if (isset($permissions['canonlyviewownthreads']) && $permissions['canonlyviewownthreads'] == 1) {
                $hidecounters = true;
                // If we only see our own threads, find out if there's a new post in one of them so the lightbulb shows
                if (!is_array($private_forums)) {
                    $private_forums = $fids = array();
                    foreach ($fcache as $fcache_p) {
                        foreach ($fcache_p as $parent_p) {
                            foreach ($parent_p as $forum_p) {
                                if ($forumpermissions[$forum_p['fid']]['canonlyviewownthreads']) {
                                    $fids[] = $forum_p['fid'];
                                }
                            }
                        }
                    }
                    if (!empty($fids)) {
                        $fids = implode(',', $fids);
                        $query = $db->simple_select("threads", "tid, fid, subject, lastpost, lastposter, lastposteruid", "uid = '{$mybb->user['uid']}' AND fid IN ({$fids}) AND visible != '-2'", array("order_by" => "lastpost", "order_dir" => "desc"));
                        while ($thread = $db->fetch_array($query)) {
                            if (!$private_forums[$thread['fid']]) {
                                $private_forums[$thread['fid']] = $thread;
                            }
                        }
                    }
                }
                if ($private_forums[$forum['fid']]['lastpost']) {
                    $forum['lastpost'] = $private_forums[$forum['fid']]['lastpost'];
                    $lastpost_data = array("lastpost" => $private_forums[$forum['fid']]['lastpost'], "lastpostsubject" => $private_forums[$forum['fid']]['subject'], "lastposter" => $private_forums[$forum['fid']]['lastposter'], "lastposttid" => $private_forums[$forum['fid']]['tid'], "lastposteruid" => $private_forums[$forum['fid']]['lastposteruid']);
                }
            } else {
                $lastpost_data = array("lastpost" => $forum['lastpost'], "lastpostsubject" => $forum['lastpostsubject'], "lastposter" => $forum['lastposter'], "lastposttid" => $forum['lastposttid'], "lastposteruid" => $forum['lastposteruid']);
            }
            if ($forum['password'] != '' && $mybb->cookies['forumpass'][$forum['fid']] !== md5($mybb->user['uid'] . $forum['password'])) {
                $hideinfo = true;
                $showlockicon = 1;
            }
            // Fetch subforums of this forum
            if (isset($fcache[$forum['fid']])) {
                $forum_info = build_forumbits($forum['fid'], $depth + 1);
                // Increment forum counters with counters from child forums
                $forum['threads'] += $forum_info['counters']['threads'];
                $forum['posts'] += $forum_info['counters']['posts'];
                $forum['unapprovedthreads'] += $forum_info['counters']['unapprovedthreads'];
                $forum['unapprovedposts'] += $forum_info['counters']['unapprovedposts'];
                if (!empty($forum_info['counters']['viewing'])) {
                    $forum['viewers'] += $forum_info['counters']['viewing'];
                }
                // If the child forums' lastpost is greater than the one for this forum, set it as the child forums greatest.
                if ($forum_info['lastpost']['lastpost'] > $lastpost_data['lastpost']) {
                    $lastpost_data = $forum_info['lastpost'];
                    /*
                    					// If our subforum is unread, then so must be our parents. Force our parents to unread as well
                    					if(strstr($forum_info['lightbulb']['folder'], "on") !== false)
                    					{
                    						$forum['lastread'] = 0;
                    					}
                    					// Otherwise, if we  have an explicit record in the db, we must make sure that it is explicitly set
                    					else
                    					{
                    						$lastpost_data['lastpost'] = $forum['lastpost'];
                    					}*/
                }
                $sub_forums = $forum_info['forum_list'];
            }
            // If we are hiding information (lastpost) because we aren't authenticated against the password for this forum, remove them
            if ($hidelastpostinfo == true) {
                $lastpost_data = array('lastpost' => 0, 'lastposter' => '');
            }
            // If the current forums lastpost is greater than other child forums of the current parent, overwrite it
            if (!isset($parent_lastpost) || $lastpost_data['lastpost'] > $parent_lastpost['lastpost']) {
                $parent_lastpost = $lastpost_data;
            }
            if (is_array($forum_viewers) && isset($forum_viewers[$forum['fid']]) && $forum_viewers[$forum['fid']] > 0) {
                $forum['viewers'] = $forum_viewers[$forum['fid']];
            }
            // Increment the counters for the parent forum (returned later)
            if ($hideinfo != true && $hidecounters != true) {
                $parent_counters['threads'] += $forum['threads'];
                $parent_counters['posts'] += $forum['posts'];
                $parent_counters['unapprovedposts'] += $forum['unapprovedposts'];
                $parent_counters['unapprovedthreads'] += $forum['unapprovedthreads'];
                if (!empty($forum['viewers'])) {
                    $parent_counters['viewers'] += $forum['viewers'];
                }
            }
            // Done with our math, lets talk about displaying - only display forums which are under a certain depth
            if ($depth > $showdepth) {
                continue;
            }
            // Get the lightbulb status indicator for this forum based on the lastpost
            $lightbulb = get_forum_lightbulb($forum, $lastpost_data, $showlockicon);
            // Fetch the number of unapproved threads and posts for this forum
            $unapproved = get_forum_unapproved($forum);
            if ($hideinfo == true) {
                unset($unapproved);
            }
            // Sanitize name and description of forum.
            $forum['name'] = preg_replace("#&(?!\\#[0-9]+;)#si", "&amp;", $forum['name']);
            // Fix & but allow unicode
            $forum['description'] = preg_replace("#&(?!\\#[0-9]+;)#si", "&amp;", $forum['description']);
            // Fix & but allow unicode
            $forum['name'] = preg_replace("#&([^\\#])(?![a-z1-4]{1,10};)#i", "&#038;\$1", $forum['name']);
            $forum['description'] = preg_replace("#&([^\\#])(?![a-z1-4]{1,10};)#i", "&#038;\$1", $forum['description']);
            // If this is a forum and we've got subforums of it, load the subforums list template
            if ($depth == 2 && $sub_forums) {
                eval("\$subforums = \"" . $templates->get("forumbit_subforums") . "\";");
            } else {
                if ($depth == 3) {
                    if ($donecount < $mybb->settings['subforumsindex']) {
                        $statusicon = '';
                        // Showing mini status icons for this forum
                        if ($mybb->settings['subforumsstatusicons'] == 1) {
                            $lightbulb['folder'] = "mini" . $lightbulb['folder'];
                            eval("\$statusicon = \"" . $templates->get("forumbit_depth3_statusicon", 1, 0) . "\";");
                        }
                        // Fetch the template and append it to the list
                        eval("\$forum_list .= \"" . $templates->get("forumbit_depth3", 1, 0) . "\";");
                        $comma = $lang->comma;
                    }
                    // Have we reached our max visible subforums? put a nice message and break out of the loop
                    ++$donecount;
                    if ($donecount == $mybb->settings['subforumsindex']) {
                        if (subforums_count($fcache[$pid]) > $donecount) {
                            $forum_list .= $comma . $lang->sprintf($lang->more_subforums, subforums_count($fcache[$pid]) - $donecount);
                        }
                    }
                    continue;
                }
            }
            // Forum is a category, set template type
            if ($forum['type'] == 'c') {
                $forumcat = '_cat';
            } else {
                $forumcat = '_forum';
            }
            if ($forum['linkto'] == '') {
                // No posts have been made in this forum - show never text
                if (($lastpost_data['lastpost'] == 0 || $lastpost_data['lastposter'] == '') && $hideinfo != true) {
                    eval("\$lastpost = \"" . $templates->get("forumbit_depth2_forum_lastpost_never") . "\";");
                } elseif ($hideinfo != true) {
                    // Format lastpost date and time
                    $lastpost_date = my_date('relative', $lastpost_data['lastpost']);
                    // Set up the last poster, last post thread id, last post subject and format appropriately
                    $lastpost_profilelink = build_profile_link($lastpost_data['lastposter'], $lastpost_data['lastposteruid']);
                    $lastpost_link = get_thread_link($lastpost_data['lastposttid'], 0, "lastpost");
                    $lastpost_subject = $full_lastpost_subject = $parser->parse_badwords($lastpost_data['lastpostsubject']);
                    if (my_strlen($lastpost_subject) > 25) {
                        $lastpost_subject = my_substr($lastpost_subject, 0, 25) . "...";
                    }
                    $lastpost_subject = htmlspecialchars_uni($lastpost_subject);
                    $full_lastpost_subject = htmlspecialchars_uni($full_lastpost_subject);
                    // Call lastpost template
                    if ($depth != 1) {
                        eval("\$lastpost = \"" . $templates->get("forumbit_depth{$depth}_forum_lastpost") . "\";");
                    }
                }
                if ($mybb->settings['showforumviewing'] != 0 && $forum['viewers'] > 0) {
                    if ($forum['viewers'] == 1) {
                        $forum_viewers_text = $lang->viewing_one;
                    } else {
                        $forum_viewers_text = $lang->sprintf($lang->viewing_multiple, $forum['viewers']);
                    }
                    $forum_viewers_text_plain = $forum_viewers_text;
                    eval("\$forum_viewers_text = \"" . $templates->get("forumbit_depth2_forum_viewers") . "\";");
                }
            }
            // If this forum is a link or is password protected and the user isn't authenticated, set counters to "-"
            if ($forum['linkto'] != '' || $hideinfo == true || $hidecounters == true) {
                $posts = "-";
                $threads = "-";
            } else {
                $posts = my_number_format($forum['posts']);
                $threads = my_number_format($forum['threads']);
            }
            // If this forum is a link or is password protected and the user isn't authenticated, set lastpost to "-"
            if ($forum['linkto'] != '' || $hideinfo == true || $hidelastpostinfo == true) {
                eval("\$lastpost = \"" . $templates->get("forumbit_depth2_forum_lastpost_hidden") . "\";");
            }
            // Moderator column is not off
            if ($mybb->settings['modlist'] != 0) {
                $done_moderators = array("users" => array(), "groups" => array());
                $moderators = '';
                // Fetch list of moderators from this forum and its parents
                $parentlistexploded = explode(',', $forum['parentlist']);
                foreach ($parentlistexploded as $mfid) {
                    // This forum has moderators
                    if (isset($moderatorcache[$mfid]) && is_array($moderatorcache[$mfid])) {
                        // Fetch each moderator from the cache and format it, appending it to the list
                        foreach ($moderatorcache[$mfid] as $modtype) {
                            foreach ($modtype as $moderator) {
                                if ($moderator['isgroup']) {
                                    if (in_array($moderator['id'], $done_moderators['groups'])) {
                                        continue;
                                    }
                                    $moderator['title'] = htmlspecialchars_uni($moderator['title']);
                                    eval("\$moderators .= \"" . $templates->get("forumbit_moderators_group", 1, 0) . "\";");
                                    $done_moderators['groups'][] = $moderator['id'];
                                } else {
                                    if (in_array($moderator['id'], $done_moderators['users'])) {
                                        continue;
                                    }
                                    $moderator['profilelink'] = get_profile_link($moderator['id']);
                                    $moderator['username'] = htmlspecialchars_uni($moderator['username']);
                                    eval("\$moderators .= \"" . $templates->get("forumbit_moderators_user", 1, 0) . "\";");
                                    $done_moderators['users'][] = $moderator['id'];
                                }
                                $comma = $lang->comma;
                            }
                        }
                    }
                }
                $comma = '';
                // If we have a moderators list, load the template
                if ($moderators) {
                    eval("\$modlist = \"" . $templates->get("forumbit_moderators") . "\";");
                } else {
                    $modlist = '';
                }
            }
            // Descriptions aren't being shown - blank them
            if ($mybb->settings['showdescriptions'] == 0) {
                $forum['description'] = '';
            }
            // Check if this category is either expanded or collapsed and hide it as necessary.
            $expdisplay = '';
            $collapsed_name = "cat_{$forum['fid']}_c";
            if (isset($collapsed[$collapsed_name]) && $collapsed[$collapsed_name] == "display: show;") {
                $expcolimage = "collapse_collapsed.png";
                $expdisplay = "display: none;";
                $expthead = " thead_collapsed";
                $expaltext = "[+]";
            } else {
                $expcolimage = "collapse.png";
                $expthead = "";
                $expaltext = "[-]";
            }
            // Swap over the alternate backgrounds
            $bgcolor = alt_trow();
            // Add the forum to the list
            eval("\$forum_list .= \"" . $templates->get("forumbit_depth{$depth}{$forumcat}") . "\";");
        }
    }
    if (!isset($parent_lastpost)) {
        $parent_lastpost = 0;
    }
    if (!isset($lightbulb)) {
        $lightbulb = '';
    }
    // Return an array of information to the parent forum including child forums list, counters and lastpost information
    return array("forum_list" => $forum_list, "counters" => $parent_counters, "lastpost" => $parent_lastpost, "lightbulb" => $lightbulb);
}
コード例 #11
0
ファイル: mysupport.php プロジェクト: myWebDev/MySupport
function mysupport_modcp_support_denial()
{
    global $mybb;
    if ($mybb->settings['enablemysupport'] != 1) {
        return;
    }
    global $db, $cache, $lang, $theme, $templates, $headerinclude, $header, $footer, $modcp_nav, $mod_log_action, $redirect;
    $lang->load("mysupport");
    if ($mybb->input['action'] == "supportdenial") {
        if (!mysupport_usergroup("canmanagesupportdenial")) {
            error_no_permission();
        }
        add_breadcrumb($lang->nav_modcp, "modcp.php");
        add_breadcrumb($lang->support_denial, "modcp.php?action=supportdenial");
        if ($mybb->input['do'] == "do_denysupport") {
            verify_post_check($mybb->input['my_post_key']);
            if ($mybb->settings['enablemysupportsupportdenial'] != 1) {
                mysupport_error($lang->support_denial_not_enabled);
                exit;
            }
            // get username from UID
            // this is if we're revoking via the list of denied users, we specify a UID here
            if ($mybb->input['uid']) {
                $uid = intval($mybb->input['uid']);
                $user = get_user($uid);
                $username = $user['username'];
            } elseif ($mybb->input['username']) {
                $username = $db->escape_string($mybb->input['username']);
                $query = $db->simple_select("users", "uid", "username = '******'");
                $uid = $db->fetch_field($query, "uid");
            }
            if (!$uid || !$username) {
                mysupport_error($lang->support_denial_reason_invalid_user);
                exit;
            }
            if (isset($mybb->input['deniedsupportreason'])) {
                $deniedsupportreason = intval($mybb->input['deniedsupportreason']);
            } else {
                $deniedsupportreason = 0;
            }
            if ($mybb->input['tid'] != 0) {
                $tid = intval($mybb->input['tid']);
                $thread_info = get_thread($tid);
                $fid = $thread_info['fid'];
                $redirect_url = get_thread_link($tid);
            } else {
                $redirect_url = "modcp.php?action=supportdenial";
            }
            $mod_log_action = "";
            $redirect = "";
            $mysupport_cache = $cache->read("mysupport");
            // -1 is if we're revoking and 0 is no reason, so those are exempt
            if (!array_key_exists($deniedsupportreason, $mysupport_cache['deniedreasons']) && $deniedsupportreason != -1 && $deniedsupportreason != 0) {
                mysupport_error($lang->support_denial_reason_invalid_reason);
                exit;
            } elseif ($deniedsupportreason == -1) {
                $update = array("deniedsupport" => 0, "deniedsupportreason" => 0, "deniedsupportuid" => 0);
                $db->update_query("users", $update, "uid = '" . intval($uid) . "'");
                $update = array("closed" => 0, "closedbymysupport" => 0);
                $mysupport_forums = implode(",", array_map("intval", mysupport_forums()));
                $db->update_query("threads", $update, "uid = '" . intval($uid) . "' AND fid IN (" . $db->escape_string($mysupport_forums) . ") AND closed = '1' AND closedbymysupport = '2'");
                mysupport_mod_log_action(11, $lang->sprintf($lang->deny_support_revoke_mod_log, $username));
                mysupport_redirect_message($lang->sprintf($lang->deny_support_revoke_success, htmlspecialchars_uni($username)));
            } else {
                $update = array("deniedsupport" => 1, "deniedsupportreason" => intval($deniedsupportreason), "deniedsupportuid" => intval($mybb->user['uid']));
                $db->update_query("users", $update, "uid = '" . intval($uid) . "'");
                if ($mybb->settings['mysupportclosewhendenied'] == 1) {
                    $update = array("closed" => 1, "closedbymysupport" => 2);
                    $mysupport_forums = implode(",", array_map("intval", mysupport_forums()));
                    $db->update_query("threads", $update, "uid = '" . intval($uid) . "' AND fid IN (" . $db->escape_string($mysupport_forums) . ") AND closed = '0'");
                }
                if ($deniedsupportreason != 0) {
                    $deniedsupportreason = $db->fetch_field($query, "name");
                    mysupport_mod_log_action(11, $lang->sprintf($lang->deny_support_mod_log_reason, $username, $deniedsupportreason));
                } else {
                    mysupport_mod_log_action(11, $lang->sprintf($lang->deny_support_mod_log, $username));
                }
                mysupport_redirect_message($lang->sprintf($lang->deny_support_success, htmlspecialchars_uni($username)));
            }
            if (!empty($mod_log_action)) {
                $mod_log_data = array("fid" => intval($fid), "tid" => intval($tid));
                log_moderator_action($mod_log_data, $mod_log_action);
            }
            redirect($redirect_url, $redirect);
        } elseif ($mybb->input['do'] == "denysupport") {
            if ($mybb->settings['enablemysupportsupportdenial'] != 1) {
                mysupport_error($lang->support_denial_not_enabled);
                exit;
            }
            $uid = intval($mybb->input['uid']);
            $tid = intval($mybb->input['tid']);
            $user = get_user($uid);
            $username = $user['username'];
            $user_link = build_profile_link(htmlspecialchars_uni($username), intval($uid), "blank");
            if ($mybb->input['uid']) {
                $deny_support_to = $lang->sprintf($lang->deny_support_to, htmlspecialchars_uni($username));
            } else {
                $deny_support_to = $lang->deny_support_to_user;
            }
            add_breadcrumb($deny_support_to);
            $deniedreasons = "";
            $deniedreasons .= "<label for=\"deniedsupportreason\">{$lang->reason}:</label> <select name=\"deniedsupportreason\" id=\"deniedsupportreason\">\n";
            // if they've not been denied support yet or no reason was given, show an empty option that will be selected
            if ($user['deniedsupport'] == 0 || $user['deniedsupportreason'] == 0) {
                $deniedreasons .= "<option value=\"0\"></option>\n";
            }
            $mysupport_cache = $cache->read("mysupport");
            if (!empty($mysupport_cache['deniedreasons'])) {
                // if there's one or more reasons set, show them in a dropdown
                foreach ($mysupport_cache['deniedreasons'] as $deniedreasons) {
                    $selected = "";
                    // if a reason has been given, we'd be editing it, so this would select the current one
                    if ($user['deniedsupport'] == 1 && $user['deniedsupportreason'] == $deniedreason['mid']) {
                        $selected = " selected=\"selected\"";
                    }
                    $deniedreasons .= "<option value=\"" . intval($deniedreason['mid']) . "\"{$selected}>" . htmlspecialchars_uni($deniedreason['name']) . "</option>\n";
                }
            }
            $deniedreasons .= "<option value=\"0\">{$lang->support_denial_reasons_none}</option>\n";
            // if they've been denied support, give an option to revoke it
            if ($user['deniedsupport'] == 1) {
                $deniedreasons .= "<option value=\"0\">-----</option>\n";
                $deniedreasons .= "<option value=\"-1\">{$lang->revoke}</option>\n";
            }
            $deniedreasons .= "</select>\n";
            eval("\$deny_support = \"" . $templates->get('mysupport_deny_support_deny') . "\";");
            eval("\$deny_support_page = \"" . $templates->get('mysupport_deny_support') . "\";");
            output_page($deny_support_page);
        } else {
            $query = $db->write_query("\r\n\t\t\t\tSELECT u1.username AS support_denied_username, u1.uid AS support_denied_uid, u2.username AS support_denier_username, u2.uid AS support_denier_uid, m.name AS support_denied_reason\r\n\t\t\t\tFROM " . TABLE_PREFIX . "users u\r\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "mysupport m ON (u.deniedsupportreason = m.mid)\r\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u1 ON (u1.uid = u.uid)\r\n\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u2 ON (u2.uid = u.deniedsupportuid)\r\n\t\t\t\tWHERE u.deniedsupport = '1'\r\n\t\t\t\tORDER BY u1.username ASC\r\n\t\t\t");
            if ($db->num_rows($query) > 0) {
                while ($denieduser = $db->fetch_array($query)) {
                    $bgcolor = alt_trow();
                    $support_denied_user = build_profile_link(htmlspecialchars_uni($denieduser['support_denied_username']), intval($denieduser['support_denied_uid']));
                    $support_denier_user = build_profile_link(htmlspecialchars_uni($denieduser['support_denier_username']), intval($denieduser['support_denier_uid']));
                    if (empty($denieduser['support_denied_reason'])) {
                        $support_denial_reason = $lang->support_denial_no_reason;
                    } else {
                        $support_denial_reason = $denieduser['support_denied_reason'];
                    }
                    eval("\$denied_users .= \"" . $templates->get('mysupport_deny_support_list_user') . "\";");
                }
            } else {
                $denied_users = "<tr><td class=\"trow1\" align=\"center\" colspan=\"5\">{$lang->support_denial_no_users}</td></tr>";
            }
            eval("\$deny_support = \"" . $templates->get('mysupport_deny_support_list') . "\";");
            eval("\$deny_support_page = \"" . $templates->get('mysupport_deny_support') . "\";");
            output_page($deny_support_page);
        }
    }
}
コード例 #12
0
ファイル: tslinkfunctions.php プロジェクト: f0nt4/TSLink
function tslink_modcp()
{
    global $db, $mybb, $lang, $templates, $theme, $headerinclude, $header, $footer, $modcp_nav, $multipage;
    require __DIR__ . '/config.php';
    $tslink_modcp_access = explode(',', $tslink_modcp_groups);
    $mybb_user_groups = explode(',', $mybb->user['additionalgroups']);
    if (simple_array_intersect($tslink_modcp_access, $mybb_user_groups) || $mybb->usergroup['cancp'] == 1) {
        eval('$tslink_modcp_menu_template = "' . $templates->get('tslink_modcp_menu') . '";');
        $modcp_nav = str_replace('<!-- tslink -->', $tslink_modcp_menu_template, $modcp_nav);
    }
    if ($mybb->input['action'] == 'tslink_dochange') {
        $mybb_uid = intval($mybb->input['uid']);
        $changeto = intval($mybb->input['changeto']);
        $db->query('UPDATE ' . TABLE_PREFIX . "users SET memberstatus= '" . $changeto . "' WHERE uid='" . $mybb_uid . "'");
        $queryUser = $db->simple_select('users', 'username, lastip', "uid='{$mybb_uid}'");
        $bin_ip_in_db = $db->fetch_field($queryUser, 'lastip');
        $givenip = my_inet_ntop($db->unescape_binary($bin_ip_in_db));
        $forUser = $db->fetch_field($queryUser, 'username');
        // If there's an ip of the user in de database, update the unique id's in the database
        if (!empty($givenip)) {
            tslink_log("=============================================================\n=================== " . date('d-m-Y H:i:s') . " =====================\n=============================================================\n", $forUser);
            tslink_log('Started on ModCP by ' . $mybb->user['username'] . ' - IP address of user available (' . $givenip . ') - doing tslink_update_uids & tslink_update_groups', $forUser);
            $tslink_update_uids_results = tslink_update_uids($givenip);
            tslink_log($tslink_update_uids_results, $forUser);
            $message = $lang->tslink_status_changed;
        }
        // If there's no lastip of the user in the database - dont try to update the unique id's in the database
        if (empty($givenip)) {
            tslink_log("=============================================================\n=================== " . date('d-m-Y H:i:s') . " =====================\n=============================================================\n", $forUser);
            tslink_log('Started on ModCP ' . $mybb->user['username'] . ' - IP address of user NOT available - only doing tslink_update_groups to update previously registered TS uids', $forUser);
            $tslink_update_groups_results = tslink_update_groups($mybb_uid);
            tslink_log($tslink_update_groups_results, $forUser);
            $message = $lang->tslink_status_changed;
        }
        redirect('modcp.php?action=tslink', $message);
    }
    if ($mybb->input['action'] == 'tslink') {
        add_breadcrumb($lang->nav_modcp, 'modcp.php');
        add_breadcrumb($lang->tslink_title, 'modcp.php?action=tslink');
        global $db, $mybb, $lang, $templates, $theme, $headerinclude, $header, $footer, $modcp_nav, $multipage;
        $query = $db->simple_select('users', 'uid, username, memberstatus', '', ['order_by' => 'username', 'order_dir' => 'ASC']);
        while ($users = $db->fetch_array($query)) {
            $alt_bg = alt_trow();
            $user['username'] = build_profile_link($users['username'], $users['uid']);
            if ($users['memberstatus'] == '0') {
                $status = 'Member';
                $linktochange = '<a href="modcp.php?action=tslink_dochange&amp;uid=' . $users['uid'] . '&amp;changeto=1">' . $lang->tslink_modcp_changestatus1 . ' </a>-
                                        <a href="modcp.php?action=tslink_dochange&amp;uid=' . $users['uid'] . '&amp;changeto=2"> ' . $lang->tslink_modcp_changestatus2 . '</a>
                                        ';
            } elseif ($users['memberstatus'] == '1') {
                $status = 'Donating Member';
                $linktochange = '<a href="modcp.php?action=tslink_dochange&amp;uid=' . $users['uid'] . '&amp;changeto=0">' . $lang->tslink_modcp_changestatus0 . ' </a>-
                                        <a href="modcp.php?action=tslink_dochange&amp;uid=' . $users['uid'] . '&amp;changeto=2"> ' . $lang->tslink_modcp_changestatus2 . '</a>
                                        ';
            } elseif ($users['memberstatus'] == '2') {
                $status = 'VIP Member';
                $linktochange = '<a href="modcp.php?action=tslink_dochange&amp;uid=' . $users['uid'] . '&amp;changeto=0">' . $lang->tslink_modcp_changestatus0 . ' </a>-
                                        <a href="modcp.php?action=tslink_dochange&amp;uid=' . $users['uid'] . '&amp;changeto=1"> ' . $lang->tslink_modcp_changestatus1 . '</a>
                                        ';
            }
            eval('$tslink_rows .= "' . $templates->get('tslink_modcp_row') . '";');
        }
        eval('$content = "' . $templates->get('tslink_modcp_page_template') . '";');
        output_page($content);
    }
}
コード例 #13
0
ファイル: recentthread.php プロジェクト: ambsalinas/anima
function recentthread_list_threads($return = false)
{
    global $mybb, $db, $templates, $recentthreadtable, $recentthreads, $settings, $canviewrecentthreads, $cache, $theme;
    // First check permissions
    if (!recentthread_can_view()) {
        return;
    }
    require_once MYBB_ROOT . "inc/functions_search.php";
    $threadlimit = (int) $mybb->settings['recentthread_threadcount'];
    if (!$threadlimit) {
        $threadlimit = 15;
    }
    $onlyusfids = array();
    // Check group permissions if we can't view threads not started by us
    $group_permissions = forum_permissions();
    foreach ($group_permissions as $fid => $forum_permissions) {
        if ($forum_permissions['canonlyviewownthreads'] == 1) {
            $onlyusfids[] = $fid;
        }
    }
    if (!empty($onlyusfids)) {
        $where .= "AND ((t.fid IN(" . implode(',', $onlyusfids) . ") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(" . implode(',', $onlyusfids) . "))";
    }
    $approved = 0;
    // Moderators can view unapproved threads
    if ($mybb->usergroup['canmodcp'] == 1) {
        $approved = -1;
    }
    $unsearchableforums = get_unsearchable_forums();
    $unviewableforums = get_unviewable_forums();
    if ($unsearchableforums && $unviewableforums) {
        $forumarray = explode(",", $unsearchableforums . "," . $unviewableforums);
        $newarray = array_unique($forumarray);
        $unsearchableforumssql = " AND t.fid NOT IN(" . implode(",", $newarray) . ") ";
    }
    // Take into account any ignored forums
    if ($mybb->settings['recentthread_forumskip']) {
        $ignoreforums = " AND t.fid NOT IN(" . $mybb->settings['recentthread_forumskip'] . ") ";
    }
    $forums = $cache->read("forums");
    $query = $db->query("\n\t\t\tSELECT t.*, u.username AS userusername, u.usergroup, u.displaygroup, u.avatar as threadavatar, u.avatardimensions as threaddimensions, lp.usergroup AS lastusergroup, lp.avatar as lastavatar, lp.avatardimensions as lastdimensions, lp.displaygroup as lastdisplaygroup\n\t\t\tFROM " . TABLE_PREFIX . "threads t\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=t.uid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users lp ON (t.lastposteruid=lp.uid)\n\t\t\tWHERE 1=1 {$where} AND t.visible > {$approved} {$unsearchableforumssql} {$ignoreforums}\n\t\t\tORDER BY t.lastpost DESC\n\t\t\tLIMIT {$threadlimit}\n\t\t");
    while ($thread = $db->fetch_array($query)) {
        $trow = alt_trow();
        $thread['forum'] = $forums[$thread['fid']]['name'];
        $threadlink = get_thread_link($thread['tid'], "", "newpost");
        $lastpostlink = get_thread_link($thread['tid'], "", "lastpost");
        $lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
        $lastposttime = my_date($mybb->settings['timeformat'], $thread['lastpost']);
        $lastposttimeago = my_date("relative", $thread['lastpost']);
        $lastposter = $thread['lastposter'];
        $lastposteruid = $thread['lastposteruid'];
        $thread['author'] = build_profile_link(format_name($thread['userusername'], $thread['usergroup'], $thread['displaygroup']), $thread['uid']);
        // Don't link to guest's profiles (they have no profile).
        if ($lastposteruid == 0) {
            $lastposterlink = $lastposter;
        } else {
            $lastposterlink = build_profile_link(format_name($lastposter, $thread['lastusergroup'], $thread['lastdisplaygroup']), $lastposteruid);
        }
        if ($mybb->settings['recentthread_threadavatar']) {
            $threadavatar = format_avatar($thread['threadavatar'], $thread['threaddimensions']);
            $avatarurl = $threadavatar['image'];
            $dimensions = $threadavatar['width_height'];
            eval("\$posteravatar = \"" . $templates->get("recentthread_avatar") . "\";");
        }
        if ($mybb->settings['recentthread_lastavatar']) {
            $lastposteravatar = format_avatar($thread['lastavatar'], $thread['lastdimensions']);
            $avatarurl = $lastposteravatar['image'];
            $dimensions = $lastposteravatar['width_height'];
            eval("\$lastavatar = \"" . $templates->get("recentthread_avatar") . "\";");
        }
        // Now check the length of subjects
        $length = (int) $mybb->settings['recentthread_subject_length'];
        if (strlen($thread['subject']) > $length && $length != 0) {
            // Figure out if we need to split it up.
            $title = my_substr($thread['subject'], 0, $length);
            if ($mybb->settings['recentthread_subject_breaker']) {
                $words = explode(" ", $title);
                $count = count($words) - 1;
                $currenttitle = "";
                for ($x = 0; $x < $count; $x++) {
                    $currenttitle .= $words[$x] . " ";
                }
                $thread['subject'] = $currenttitle . " ...";
            }
            if (!$mybb->settings['recentthread_subject_breaker']) {
                $thread['subject'] = $title . "...";
            }
        }
        // Moderator stuff baby!
        if (is_moderator($thread['fid'])) {
            $ismod = TRUE;
            // fetch the inline mod column
        } else {
            $ismod = FALSE;
        }
        if (is_moderator($thread['fid'], "caneditposts") || $fpermissions['caneditposts'] == 1) {
            $can_edit_titles = 1;
        } else {
            $can_edit_titles = 0;
        }
        $inline_edit_class = '';
        if ($thread['uid'] == $mybb->user['uid'] && $thread['closed'] != 1 && $mybb->user['uid'] != 0 && $can_edit_titles == 1 || $ismod == true) {
            $inline_edit_class = "subject_editable";
        }
        eval("\$recentthreads .= \"" . $templates->get("recentthread_thread") . "\";");
        unset($posteravatar);
        unset($lastavatar);
    }
    eval("\$recentthreadtable = \"" . $templates->get("recentthread") . "\";");
    if ($return) {
        return $recentthreadtable;
    }
}
コード例 #14
0
ファイル: cookielaw.php プロジェクト: Blackbeeard/Cookie-Law
function cookielaw_misc()
{
    global $mybb, $lang, $templates, $theme, $cookielaw_info, $header, $headerinclude, $footer;
    $lang->load('cookielaw');
    if ($mybb->input['action'] == 'cookielaw_change') {
        if (isset($mybb->input['more_info'])) {
            // hack to show no redirect
            $mybb->settings['redirects'] = 0;
            redirect('misc.php?action=cookielaw_info');
        } else {
            if (isset($mybb->input['disallow'])) {
                cookielaw_clear_cookies();
                my_setcookie('mybb[allow_cookies]', '0');
            } else {
                my_setcookie('mybb[allow_cookies]', '1');
                if ($mybb->input['okay']) {
                    $lang->cookielaw_redirect = '';
                }
            }
            redirect('index.php', $lang->cookielaw_redirect);
        }
    } elseif ($mybb->input['action'] == 'cookielaw_info') {
        $cookies_rows = '';
        $cookies = cookielaw_get_cookies();
        foreach ($cookies as $cookie_name => $info) {
            if (isset($info['mod']) || isset($info['admin'])) {
                $cookie_user_type = '';
                if ($info['mod']) {
                    $cookie_user_type = $lang->cookielaw_info_cookies_set_mod;
                } elseif ($info['admin']) {
                    $cookie_user_type = $lang->cookielaw_info_cookies_set_admin;
                }
                $trow = alt_trow();
                $cookie_description = 'cookielaw_cookie_' . $cookie_name . '_desc';
                $cookies_rows .= '<tr>
					<td class="' . $trow . '">' . $cookie_name . '</td>
					<td class="' . $trow . '">' . $lang->{$cookie_description} . '</td>
					<td class="' . $trow . '" align="center">' . $cookie_user_type . '</td>
					<td class="' . $trow . '" align="center">-</td>
				</tr>';
            } else {
                if (substr($mybb->version, 0, 3) == '1.6') {
                    $ext = 'gif';
                } elseif (substr($mybb->version, 0, 3) == '1.8') {
                    $ext = 'png';
                }
                $cookie_member = $cookie_guest = '';
                if ($info['member']) {
                    $cookie_member = '<img src="' . $mybb->settings['bburl'] . '/images/valid.' . $ext . '" alt="" title="" />';
                } else {
                    $cookie_member = '<img src="' . $mybb->settings['bburl'] . '/images/invalid.' . $ext . '" alt="" title="" />';
                }
                if ($info['guest']) {
                    $cookie_guest = '<img src="' . $mybb->settings['bburl'] . '/images/valid.' . $ext . '" alt="" title="" />';
                } else {
                    $cookie_guest = '<img src="' . $mybb->settings['bburl'] . '/images/invalid.' . $ext . '" alt="" title="" />';
                }
                $trow = alt_trow();
                $cookie_description = 'cookielaw_cookie_' . $cookie_name . '_desc';
                $cookies_rows .= '<tr>
					<td class="' . $trow . '">' . $cookie_name . '</td>
					<td class="' . $trow . '">' . $lang->{$cookie_description} . '</td>
					<td class="' . $trow . '" align="center">' . $cookie_member . '</td>
					<td class="' . $trow . '" align="center">' . $cookie_guest . '</td>
				</tr>';
            }
        }
        if ($mybb->settings['cookielaw_method'] == 'opt') {
            eval("\$buttons = \"" . $templates->get("cookielaw_buttons_" . $mybb->settings['cookielaw_method']) . "\";");
        }
        eval("\$cookielaw_info = \"" . $templates->get("cookielaw_info") . "\";");
        output_page($cookielaw_info);
    }
}
コード例 #15
0
ファイル: mylikes.php プロジェクト: JN-Jones/MyLikes
function mylikes_popup()
{
    global $db, $mybb, $lang, $groupscache, $templates;
    if ($mybb->input['action'] == "likes_recount") {
        // Rebuild the cache for this post - the reputation/like counter may have changed
        if (!empty($mybb->input['pid'])) {
            JB_MyLikes_Like::cache($mybb->input['pid']);
        }
        exit;
    }
    if ($mybb->input['action'] != "likes") {
        return;
    }
    if (empty($mybb->input['pid']) || empty($mybb->input['uid'])) {
        error_no_permission();
    }
    $lang->load("mylikes");
    $pid = $mybb->get_input("pid");
    $uid = $mybb->get_input("uid");
    $query = $db->simple_select("reputation", "*", "uid={$uid} AND pid={$pid}");
    $users = "";
    while ($like = $db->fetch_array($query)) {
        $user = get_user($like['adduid']);
        $name = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
        $profile_link = build_profile_link($name, $user['uid'], '_blank', 'if(window.opener) { window.opener.location = this.href; return false; }');
        $send_pm = '';
        if ($mybb->user['receivepms'] != 0 && $user['receivepms'] != 0 && $groupscache[$user['usergroup']]['canusepms'] != 0) {
            eval("\$send_pm = \"" . $templates->get("misc_buddypopup_user_sendpm") . "\";");
        }
        if ($user['lastactive']) {
            $last_active = $lang->sprintf($lang->last_active, my_date('relative', $user['lastactive']));
        } else {
            $last_active = $lang->sprintf($lang->last_active, $lang->never);
        }
        $user['avatar'] = format_avatar(htmlspecialchars_uni($user['avatar']), $user['avatardimensions'], '44x44');
        $online_alt = alt_trow();
        $users .= eval($templates->render("misc_mylikes_like"));
    }
    if (empty($users)) {
        $users = eval($templates->render("misc_mylikes_nolikes"));
    }
    echo eval($templates->render("misc_mylikes", 1, 0));
    exit;
}
コード例 #16
0
ファイル: xt_updatehooks.php プロジェクト: sunnybutani/webc
function xthreads_input_generate(&$data, &$threadfields, $fid, $tid = 0)
{
    global $tfinput, $tfinputrow, $extra_threadfields, $lang, $xthreads_threadin_tabindex_shift, $mybb;
    if (!$lang->xthreads_attachfile) {
        $lang->load('xthreads');
    }
    // if a thread ID is supplied, grab the current values
    if ($tid) {
        static $tfd_cache = null;
        if (!isset($tfd_cache)) {
            $tfd_cache = array();
        }
        if (!isset($tfd_cache[$tid])) {
            // we should only ever have one thread, but we'll be flexible...
            global $db;
            $tfd_cache[$tid] = $db->fetch_array($db->simple_select('threadfields_data', '*', 'tid=' . $tid));
        }
        $tfd =& $tfd_cache[$tid];
    }
    $tfinput = $tfinputrow = array();
    $extra_threadfields = '';
    foreach ($threadfields as $k => $tf) {
        $tf['title'] = htmlspecialchars_uni($tf['title']);
        $tf['field'] = htmlspecialchars_uni($tf['field']);
        $tf['desc'] = htmlspecialchars_uni($tf['desc']);
        $vars = array('KEY' => $tf['field'], 'NAME_PROP' => ' name="xthreads_' . $tf['field'] . '"', 'MAXLEN' => (int) $tf['maxlen'], 'WIDTH' => (int) $tf['fieldwidth'], 'HEIGHT' => (int) $tf['fieldheight'], 'TABINDEX' => '', 'TABINDEX_PROP' => '', 'REQUIRED' => $tf['editable'] == XTHREADS_EDITABLE_REQ, 'MULTIPLE' => xthreads_empty($tf['multival']) ? '' : 1, 'MULTIPLE_LIMIT' => $tf['multival_limit'], 'MULTIPLE_PROP' => '');
        if ($vars['MAXLEN']) {
            $vars['MAXLEN_PROP'] = ' maxlength="' . $vars['MAXLEN'] . '"';
        }
        if ($vars['WIDTH']) {
            $vars['WIDTH_PROP_SIZE'] = ' size="' . $vars['WIDTH'] . '"';
            $vars['WIDTH_CSS'] = 'width: ' . $vars['WIDTH'] / 2 . 'em;';
            // only used for select box [in Firefox, seems we need to divide by 2 to get the equivalent width]
            $vars['WIDTH_PROP_COLS'] = ' cols="' . $vars['WIDTH'] . '"';
        }
        if (!$vars['HEIGHT'] && !xthreads_empty($tf['multival'])) {
            $vars['HEIGHT'] = 5;
        }
        if ($vars['HEIGHT']) {
            $vars['HEIGHT_PROP_SIZE'] = ' size="' . $vars['HEIGHT'] . '"';
            $vars['HEIGHT_CSS'] = 'height: ' . $vars['HEIGHT'] / 2 . 'em;';
            $vars['HEIGHT_PROP_ROWS'] = ' rows="' . $vars['HEIGHT'] . '"';
        }
        if ($vars['MULTIPLE']) {
            $vars['MULTIPLE_PROP'] = ' multiple="multiple"';
        }
        if ($vars['REQUIRED']) {
            $vars['REQUIRED_PROP'] = ' required="required"';
        }
        $using_default = false;
        if (!isset($data)) {
            // no threadfield data set for this thread
            $defval = '';
        } elseif (isset($data[$k])) {
            $defval = $data[$k];
        } elseif ($tid) {
            // currently set value
            $defval = $tfd[$k];
        } elseif ($tf['inputtype'] != XTHREADS_INPUT_FILE) {
            $defval = eval_str($tf['defaultval']);
            // we don't want $defval to be an array for textual inputs, so split it later
            $using_default = true;
        }
        unset($defvals);
        switch ($tf['inputtype']) {
            case XTHREADS_INPUT_SELECT:
            case XTHREADS_INPUT_RADIO:
            case XTHREADS_INPUT_CHECKBOX:
                $vals = $tf['vallist'];
                if (!xthreads_empty($tf['multival'])) {
                    if ($using_default) {
                        $defval = explode("\n", str_replace("\r", '', $defval));
                    }
                    if (is_array($defval)) {
                        $defvals =& $defval;
                    } else {
                        $defvals = explode("\n", str_replace("\r", '', $defval));
                    }
                    $defvals = array_map('htmlspecialchars_uni', $defvals);
                    unset($vals['']);
                } elseif ($tf['editable'] != XTHREADS_EDITABLE_REQ && $tf['inputtype'] != XTHREADS_INPUT_CHECKBOX) {
                    if (!isset($vals[''])) {
                        // can't array_unshift with a key...
                        $vals = array('' => '<span style="font-style: italic;">' . $lang->xthreads_val_blank . '</span>') + $vals;
                    }
                } else {
                    unset($vals['']);
                }
                break;
            case XTHREADS_INPUT_FILE:
                if (!xthreads_empty($tf['multival']) && !is_array($defval)) {
                    $defval = explode(',', $defval);
                }
        }
        if (!isset($defvals) && ($tf['inputtype'] != XTHREADS_INPUT_FILE && $tf['inputtype'] != XTHREADS_INPUT_FILE_URL)) {
            $defval = htmlspecialchars_uni($defval);
        }
        if ($tf['tabstop']) {
            $vars['TABINDEX'] = ++$xthreads_threadin_tabindex_shift + 1;
            $vars['TABINDEX_PROP'] = ' tabindex="__xt_' . $vars['TABINDEX'] . '"';
            xthreads_fix_tabindexes();
        }
        if ($tf['formhtml']) {
            $evalfunc = 'xthreads_evalcache_' . $tf['field'];
        } else {
            $evalfunc = 'xthreads_input_generate_defhtml_' . $tf['inputtype'];
        }
        switch ($tf['inputtype']) {
            case XTHREADS_INPUT_TEXTAREA:
                $vars['VALUE'] =& $defval;
                break;
            case XTHREADS_INPUT_SELECT:
                if (!xthreads_empty($tf['multival'])) {
                    $vars['NAME_PROP'] = ' name="xthreads_' . $tf['field'] . '[]"';
                }
                $vars['ITEMS'] = '';
                foreach ($vals as $val => $valdisp) {
                    if ((!$tid || $tfd[$k] != $val) && !xthreads_tfvalue_settable($tf, $val)) {
                        continue;
                    }
                    $val = htmlspecialchars_uni($val);
                    $vars['VALUE'] =& $val;
                    $vars['SELECTED'] = isset($defvals) && in_array($val, $defvals) || $defval === $val ? ' selected="selected"' : '';
                    if (preg_match('~^\\<span style\\="([^"]*?)"\\>(.*)\\</span\\>$~is', $valdisp, $style)) {
                        $vars['LABEL'] = $style[2];
                        $vars['STYLECSS'] = $style[1];
                        $vars['STYLE'] = ' style="' . $vars['STYLECSS'] . '"';
                    } else {
                        $vars['LABEL'] = $valdisp;
                        $vars['STYLE'] = $vars['STYLECSS'] = '';
                    }
                    $vars['LABEL'] = htmlspecialchars_uni($vars['LABEL']);
                    $vars['ITEMS'] .= $evalfunc('formhtml_item', $vars);
                }
                break;
            case XTHREADS_INPUT_CHECKBOX:
                $vars['NAME_PROP'] = ' name="xthreads_' . $tf['field'] . '[]"';
                // fall through
            // fall through
            case XTHREADS_INPUT_RADIO:
                $vars['ITEMS'] = '';
                foreach ($vals as $val => &$valdisp) {
                    if ((!$tid || $tfd[$k] != $val) && !xthreads_tfvalue_settable($tf, $val)) {
                        continue;
                    }
                    $val = htmlspecialchars_uni($val);
                    if (isset($defvals) && in_array($val, $defvals) || $defval === $val) {
                        $vars['SELECTED'] = ' selected="selected"';
                        $vars['CHECKED'] = ' checked="checked"';
                    } else {
                        $vars['SELECTED'] = $vars['CHECKED'] = '';
                    }
                    $vars['VALUE'] =& $val;
                    $vars['LABEL'] =& $valdisp;
                    $vars['ITEMS'] .= $evalfunc('formhtml_item', $vars);
                    $vars['TABINDEX_PROP'] = '';
                    // or maybe make each thing tabbable?
                }
                break;
            case XTHREADS_INPUT_FILE:
                if (!xthreads_empty($tf['multival'])) {
                    $vars['NAME_PROP'] = ' name="xthreads_' . $tf['field'] . '[]"';
                    // lame language hack
                    $GLOBALS['lang_xthreads_attachfile'] = $lang->xthreads_attachfile_plural;
                    $GLOBALS['lang_xthreads_attachurl'] = $lang->xthreads_attachurl_plural;
                } else {
                    $GLOBALS['lang_xthreads_attachfile'] = $lang->xthreads_attachfile;
                    $GLOBALS['lang_xthreads_attachurl'] = $lang->xthreads_attachurl;
                }
                $vars['MAXSIZE'] = $tf['filemaxsize'];
                $vars['RESTRICT_TYPE'] = $tf['fileimage'] ? 'image' : '';
                $vars['ACCEPT_PROP'] = $vars['RESTRICT_TYPE'] ? ' accept="' . $vars['RESTRICT_TYPE'] . '/*"' : '';
                if (XTHREADS_ALLOW_URL_FETCH) {
                    // TODO: test if this environment can really fetch URLs
                    $vars['VALUE_URL'] = htmlspecialchars_uni($mybb->input['xtaurl_' . $tf['field']]);
                    if (xthreads_empty($vars['VALUE_URL'])) {
                        $vars['VALUE_URL'] = 'http://';
                    }
                    if ($vars['VALUE_URL'] != 'http://' || $mybb->input['xtasel_' . $tf['field']] == 'url') {
                        $vars['CHECKED_UPLOAD'] = '';
                        $vars['SELECTED_UPLOAD'] = '';
                        $vars['CHECKED_URL'] = ' checked="checked"';
                        $vars['SELECTED_URL'] = ' selected="selected"';
                    } else {
                        $vars['CHECKED_UPLOAD'] = ' checked="checked"';
                        $vars['SELECTED_UPLOAD'] = ' selected="selected"';
                        $vars['CHECKED_URL'] = '';
                        $vars['SELECTED_URL'] = '';
                    }
                }
                $vars['ITEMS'] = '';
                global $xta_cache, $db;
                if ($defval) {
                    foreach (is_array($defval) ? $defval : array($defval) as $aid) {
                        if (!$aid || !is_numeric($aid)) {
                            continue;
                        }
                        if (!isset($xta_cache[$aid])) {
                            static $done_xta_cache = false;
                            // need to cache them
                            if (!$done_xta_cache) {
                                $done_xta_cache = true;
                                $qextra = '';
                                if ($mybb->input['posthash']) {
                                    $qextra .= ' OR posthash="' . $db->escape_string($mybb->input['posthash']) . '"';
                                }
                                if ($GLOBALS['thread']['tid']) {
                                    $qextra .= ' OR tid=' . $GLOBALS['thread']['tid'];
                                }
                                $query = $db->simple_select('xtattachments', '*', 'aid IN(' . (is_array($defval) ? implode(',', $defval) : $defval) . ')' . $qextra);
                                while ($xta = $db->fetch_array($query)) {
                                    $xta_cache[$xta['aid']] = $xta;
                                }
                                $db->free_result($query);
                                unset($xta);
                            }
                        }
                        xthreads_sanitize_disp_set_xta_fields($vars['ATTACH'], $aid, $tf);
                        if (isset($vars['ATTACH']['md5hash'])) {
                            $vars['ATTACH_MD5_TITLE'] = ' title="' . $lang->sprintf($lang->xthreads_md5hash, $vars['ATTACH']['md5hash']) . '" ';
                        }
                        if (is_array($mybb->input['xtarm_' . $tf['field']])) {
                            if ($mybb->input['xtarm_' . $tf['field']][$aid]) {
                                $vars['REMOVE_CHECKED'] = ' checked="checked"';
                            }
                        } else {
                            if ($mybb->input['xtarm_' . $tf['field']]) {
                                $vars['REMOVE_CHECKED'] = ' checked="checked"';
                            }
                        }
                        $vars['ITEMS'] .= $evalfunc('formhtml_item', $vars);
                    }
                }
                break;
            case XTHREADS_INPUT_FILE_URL:
                // TODO:
                break;
            default:
                // text
                $vars['VALUE'] =& $defval;
                if (!xthreads_empty($tf['multival'])) {
                    $defval = str_replace("\n", ', ', $defval);
                }
                break;
        }
        $tfinput[$k] = $evalfunc('formhtml', $vars);
        $altbg = alt_trow();
        $inputfield =& $tfinput[$k];
        eval('$tfinputrow[$k] = "' . $GLOBALS['templates']->get('post_threadfields_inputrow') . '";');
        if (!($tf['hidefield'] & XTHREADS_HIDE_INPUT)) {
            $extra_threadfields .= $tfinputrow[$k];
        }
    }
}
コード例 #17
0
ファイル: misc.php プロジェクト: olada/mybbintegrator
        eval("\$smiliespage = \"" . $templates->get("misc_smilies_popup", 1, 0) . "\";");
        output_page($smiliespage);
    } else {
        add_breadcrumb($lang->nav_smilies);
        $class = "trow1";
        $smilies_cache = $cache->read("smilies");
        if (is_array($smilies_cache)) {
            $extra_class = $onclick = '';
            foreach ($smilies_cache as $smilie) {
                $smilie['image'] = str_replace("{theme}", $theme['imgdir'], $smilie['image']);
                $smilie['image'] = htmlspecialchars_uni($mybb->get_asset_url($smilie['image']));
                $smilie['name'] = htmlspecialchars_uni($smilie['name']);
                $smilie['find'] = nl2br(htmlspecialchars_uni($smilie['find']));
                eval('$smilie_image = "' . $templates->get('smilie') . '";');
                eval("\$smilies .= \"" . $templates->get("misc_smilies_smilie") . "\";");
                $class = alt_trow();
            }
        }
        eval("\$smiliespage = \"" . $templates->get("misc_smilies") . "\";");
        output_page($smiliespage);
    }
} elseif ($mybb->input['action'] == "imcenter") {
    $mybb->input['imtype'] = $mybb->get_input('imtype');
    if ($mybb->input['imtype'] != "aim" && $mybb->input['imtype'] != "skype" && $mybb->input['imtype'] != "yahoo") {
        error($lang->error_invalidimtype);
    }
    $uid = $mybb->get_input('uid', MyBB::INPUT_INT);
    $user = get_user($uid);
    if (!$user) {
        error($lang->error_invaliduser);
    }
コード例 #18
0
function latest_threads_get_threadlist($settings, $width)
{
    global $db, $mybb, $templates, $lang, $cache, $gotounread, $theme;
    if (!$lang->asb_addon) {
        $lang->load('asb_addon');
    }
    if ($mybb->user['uid'] == 0) {
        $query = $db->query("\n\t\t\tSELECT\n\t\t\t\tfid\n\t\t\tFROM {$db->table_prefix}forums\n\t\t\tWHERE\n\t\t\t\tactive != 0\n\t\t\tORDER BY\n\t\t\t\tpid, disporder\n\t\t");
        $forumsread = my_unserialize($mybb->cookies['mybb']['forumread']);
    } else {
        $query = $db->query("\n\t\t\tSELECT\n\t\t\t\tf.fid, fr.dateline AS lastread\n\t\t\tFROM {$db->table_prefix}forums f\n\t\t\tLEFT JOIN {$db->table_prefix}forumsread fr ON (fr.fid=f.fid AND fr.uid='{$mybb->user['uid']}')\n\t\t\tWHERE\n\t\t\t\tf.active != 0\n\t\t\tORDER BY\n\t\t\t\tpid, disporder\n\t\t");
    }
    while ($forum = $db->fetch_array($query)) {
        if ($mybb->user['uid'] == 0) {
            if ($forumsread[$forum['fid']]) {
                $forum['lastread'] = $forumsread[$forum['fid']];
            }
        }
        $readforums[$forum['fid']] = $forum['lastread'];
    }
    // Build a post parser
    require_once MYBB_ROOT . 'inc/class_parser.php';
    $parser = new postParser();
    // get forums user cannot view
    $unviewable = get_unviewable_forums(true);
    if ($unviewable) {
        $unviewwhere = " AND t.fid NOT IN ({$unviewable})";
    }
    // get inactive forums
    $inactive = get_inactive_forums();
    if ($inactive) {
        $inactivewhere = " AND t.fid NOT IN ({$inactive})";
    }
    // new threads only?
    if ((int) $settings['new_threads_only'] > 0) {
        // use admin's time limit
        $thread_time_limit = TIME_NOW - 60 * 60 * 24 * (int) $settings['new_threads_only'];
        $new_threads = " AND t.dateline > {$thread_time_limit}";
    }
    if ($settings['important_threads_only']) {
        $important_threads = ' AND NOT t.sticky=0';
    }
    // build the exclude conditions
    $show['fids'] = asb_build_id_list($settings['forum_show_list'], 't.fid');
    $show['tids'] = asb_build_id_list($settings['thread_show_list'], 't.tid');
    $hide['fids'] = asb_build_id_list($settings['forum_hide_list'], 't.fid');
    $hide['tids'] = asb_build_id_list($settings['thread_hide_list'], 't.tid');
    $where['show'] = asb_build_SQL_where($show, ' OR ');
    $where['hide'] = asb_build_SQL_where($hide, ' OR ', ' NOT ');
    $query_where = $new_threads . $important_threads . $unviewwhere . $inactivewhere . asb_build_SQL_where($where, ' AND ', ' AND ');
    $altbg = alt_trow();
    $maxtitlelen = 48;
    $threadlist = '';
    // query for the latest forum discussions
    $query = $db->query("\n\t\tSELECT\n\t\t\tt.*,\n\t\t\tu.username, u.avatar, u.usergroup, u.displaygroup\n\t\tFROM {$db->table_prefix}threads t\n\t\tLEFT JOIN {$db->table_prefix}users u ON (u.uid=t.lastposteruid)\n\t\tWHERE\n\t\t\tt.visible='1' AND t.closed NOT LIKE 'moved|%'{$query_where}\n\t\tORDER BY\n\t\t\tt.lastpost DESC\n\t\tLIMIT\n\t\t\t0, " . (int) $settings['max_threads']);
    if ($db->num_rows($query) == 0) {
        // no content
        return false;
    }
    $thread_cache = array();
    while ($thread = $db->fetch_array($query)) {
        $thread_cache[$thread['tid']] = $thread;
    }
    $thread_ids = implode(",", array_keys($thread_cache));
    // fetch the read threads.
    if ($mybb->user['uid'] && $mybb->settings['threadreadcut'] > 0) {
        $query = $db->simple_select('threadsread', 'tid,dateline', "uid='{$mybb->user['uid']}' AND tid IN({$thread_ids})");
        while ($readthread = $db->fetch_array($query)) {
            $thread_cache[$readthread['tid']]['lastread'] = $readthread['dateline'];
        }
    }
    foreach ($thread_cache as $thread) {
        $forumpermissions[$thread['fid']] = forum_permissions($thread['fid']);
        // make sure we can view this thread
        if ($forumpermissions[$thread['fid']]['canview'] == 0 || $forumpermissions[$thread['fid']]['canviewthreads'] == 0 || $forumpermissions[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid']) {
            continue;
        }
        $lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
        $lastposttime = my_date($mybb->settings['timeformat'], $thread['lastpost']);
        // don't link to guest's profiles (they have no profile).
        if ($thread['lastposteruid'] == 0) {
            $lastposterlink = $thread['lastposter'];
        } else {
            if ($settings['last_poster_avatar']) {
                if (strlen(trim($thread['avatar'])) == 0) {
                    $thread['avatar'] = "{$theme['imgdir']}/default_avatar.gif";
                }
                $avatar_width = (int) min($width / 2, max($width / 8, $settings['avatar_width']));
                $last_poster_name = <<<EOF
<img src="{$thread['avatar']}" alt="{$thread['last_post']}" title="{$thread['lastposter']}'s profile" style="width: {$avatar_width}px;"/>
EOF;
                format_name($thread['lastposter'], $thread['usergroup'], $thread['displaygroup']);
                $lp_template = 'asb_latest_threads_last_poster_avatar';
            } else {
                $last_poster_name = format_name($thread['lastposter'], $thread['usergroup'], $thread['displaygroup']);
                $lp_template = 'asb_latest_threads_last_poster_name';
            }
            $lastposterlink = build_profile_link($last_poster_name, $thread['lastposteruid']);
        }
        if (my_strlen($thread['subject']) > $maxtitlelen) {
            $thread['subject'] = my_substr($thread['subject'], 0, $maxtitlelen) . "...";
        }
        $thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
        $thread['threadlink'] = get_thread_link($thread['tid']);
        $thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
        eval("\$last_poster = \"" . $templates->get($lp_template) . "\";");
        $gotounread = '';
        $last_read = 0;
        if ($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid']) {
            $forum_read = $readforums[$thread['fid']];
            $read_cutoff = TIME_NOW - $mybb->settings['threadreadcut'] * 60 * 60 * 24;
            if ($forum_read == 0 || $forum_read < $read_cutoff) {
                $forum_read = $read_cutoff;
            }
        } else {
            $forum_read = $forumsread[$thread['fid']];
        }
        if ($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid'] && $thread['lastpost'] > $forum_read) {
            if ($thread['lastread']) {
                $last_read = $thread['lastread'];
            } else {
                $last_read = $read_cutoff;
            }
        } else {
            $last_read = my_get_array_cookie('threadread', $thread['tid']);
        }
        if ($forum_read > $last_read) {
            $last_read = $forum_read;
        }
        if ($thread['lastpost'] > $last_read && $last_read) {
            $thread['newpostlink'] = get_thread_link($thread['tid'], 0, 'newpost');
            eval("\$gotounread = \"" . $templates->get("asb_latest_threads_gotounread") . "\";");
            $unreadpost = 1;
        }
        eval("\$threadlist .= \"" . $templates->get("asb_latest_threads_thread") . "\";");
        $altbg = alt_trow();
    }
    if ($threadlist) {
        return $threadlist;
    }
    // no content
    return false;
}
コード例 #19
0
 public function buddylist_process($buddylist, $count, $memprofile, $limit, $page)
 {
     global $lang, $templates, $settings, $mybb, $theme;
     MyProfileUtils::lang_load_myprofile();
     if (count($buddylist) == 0) {
         /* show them we've got no friends :( */
         $count_friends_text = $lang->sprintf($lang->mp_buddylist_no_friend, $memprofile["username"]);
         $count_colspan = 1;
     } else {
         $count_friends_text = $lang->sprintf($lang->mp_buddylist_friends, $memprofile["username"], $count, count($buddylist));
         $count_colspan = 4;
         $buddylist_content = "";
         for ($col = 0; $col < count($buddylist); $col += 4) {
             $row_content = "";
             for ($row = 0; $row < 4; $row++) {
                 if (isset($buddylist[$col + $row])) {
                     $buddy = $buddylist[$col + $row];
                     $td_class = alt_trow();
                     $profile_link = get_profile_link($buddy["uid"]);
                     list($avatar_src, $avatar_width_height) = array_values(format_avatar($buddy["avatar"], $buddy["avatardimensions"], $settings["mpbuddylistavatarmaxdimensions"]));
                     $username = format_name(htmlspecialchars_uni($buddy["username"]), $buddy["usergroup"], $buddy["displaygroup"]);
                     eval("\$row_content .= \"" . $templates->get('myprofile_buddylist_buddy') . "\";");
                 } else {
                     $td_class = alt_trow();
                     $td_colspan = 4 - $row;
                     $td_width = $td_colspan * 20;
                     eval("\$row_content .= \"" . $templates->get('myprofile_buddylist_spacer') . "\";");
                     break;
                 }
             }
             eval("\$buddylist_content .= \"" . $templates->get('myprofile_buddylist_row') . "\";");
         }
     }
     $buddylist_pagination = multipage($count, $limit, $page, "javascript:MyProfile.buddylistLoadPage({page});");
     if ($buddylist_pagination == null) {
         $buddylist_pagination_style = 'style="display: none;"';
     }
     eval("\$buddylist_count .= \"" . $templates->get('myprofile_buddylist_buddy_count') . "\";");
     eval("\$myprofile_buddylist .= \"" . $templates->get('myprofile_buddylist', 1, 0) . "\";");
     return array("html" => $myprofile_buddylist, "count" => $count, "shown" => count($buddylist));
 }
コード例 #20
0
ファイル: myalerts.php プロジェクト: harrygg/MyAlerts
function myalerts_xmlhttp()
{
    global $mybb, $lang, $templates, $db;
    if (!isset($lang->myalerts)) {
        $lang->load('myalerts');
    }
    myalerts_create_instances();
    if ($mybb->get_input('action') == 'getNewAlerts') {
        header('Content-Type: application/json');
        $newAlerts = MybbStuff_MyAlerts_AlertManager::getInstance()->getAlerts(0, $mybb->settings['myalerts_dropdown_limit']);
        $alertsListing = '';
        $alertsToReturn = array();
        if (is_array($newAlerts) && !empty($newAlerts)) {
            $toMarkRead = array();
            foreach ($newAlerts as $alertObject) {
                $altbg = alt_trow();
                $alert = parse_alert($alertObject);
                $alertsToReturn[] = $alert;
                if (isset($mybb->input['from']) && $mybb->input['from'] == 'header') {
                    if ($alert['message']) {
                        $alertsListing .= eval($templates->render('myalerts_alert_row_popup', true, false));
                    }
                } else {
                    if ($alert['message']) {
                        $alertsListing .= eval($templates->render('myalerts_alert_row', true, false));
                    }
                }
                $toMarkRead[] = $alertObject->getId();
            }
            MybbStuff_MyAlerts_AlertManager::getInstance()->markRead($toMarkRead);
        } else {
            $from = $mybb->get_input('from', MyBB::INPUT_STRING);
            $altbg = alt_trow();
            if (!empty($from) && $from == 'header') {
                $alertsListing = eval($templates->render('myalerts_alert_row_popup_no_alerts', true, false));
            } else {
                $alertsListing = eval($templates->render('myalerts_alert_row_no_alerts', true, false));
            }
        }
        echo json_encode(array('alerts' => $alertsToReturn, 'template' => $alertsListing));
    }
    if ($mybb->get_input('action') == 'myalerts_delete') {
        header('Content-Type: application/json');
        $id = $mybb->get_input('id', MyBB::INPUT_INT);
        $userId = (int) $mybb->user['uid'];
        $toReturn = array();
        if ($id > 0) {
            if (!verify_post_check($mybb->get_input('my_post_key'), true)) {
                $toReturn = array('errors' => array($lang->invalid_post_code));
            } else {
                $db->delete_query('alerts', "id = {$id} AND uid = {$userId}");
                $newAlerts = MybbStuff_MyAlerts_AlertManager::getInstance()->getUnreadAlerts();
                $alertsListing = '';
                $alertsToReturn = array();
                if (is_array($newAlerts) && !empty($newAlerts)) {
                    $toMarkRead = array();
                    foreach ($newAlerts as $alertObject) {
                        $altbg = alt_trow();
                        $alert = parse_alert($alertObject);
                        $alertsToReturn[] = $alert;
                        if (isset($mybb->input['from']) && $mybb->input['from'] == 'header') {
                            if ($alert['message']) {
                                $alertsListing .= eval($templates->render('myalerts_alert_row_popup', true, false));
                            }
                        } else {
                            if ($alert['message']) {
                                $alertsListing .= eval($templates->render('myalerts_alert_row', true, false));
                            }
                        }
                        $toMarkRead[] = $alertObject->getId();
                    }
                    MybbStuff_MyAlerts_AlertManager::getInstance()->markRead($toMarkRead);
                } else {
                    $from = $mybb->get_input('from', MyBB::INPUT_STRING);
                    $altbg = alt_trow();
                    if (!empty($from) && $from == 'header') {
                        $alertsListing = eval($templates->render('myalerts_alert_row_popup_no_alerts', true, false));
                    } else {
                        $alertsListing = eval($templates->render('myalerts_alert_row_no_alerts', true, false));
                    }
                }
                $toReturn = array('success' => true, 'template' => $alertsListing);
            }
        } else {
            $toReturn = array('errors' => array($lang->myalerts_error_alert_not_found));
        }
        echo json_encode($toReturn);
    }
    if ($mybb->input['action'] == 'getNumUnreadAlerts') {
        echo MybbStuff_MyAlerts_AlertManager::getInstance()->getNumUnreadAlerts();
    }
}
コード例 #21
0
function mytwconnect_usercp()
{
    global $mybb, $lang, $inlinesuccess;
    // Load API in certain areas
    if (in_array($mybb->input['action'], array('twlink', 'do_twlink')) or $_SESSION['twlogin'] or $mybb->input['action'] == 'mytwconnect' and $mybb->request_method == 'post') {
        require_once MYBB_ROOT . "inc/plugins/MyTwitterConnect/class_twitter.php";
        $TwitterConnect = new MyTwitter();
    }
    $settingsToCheck = array('twavatar', 'twbio', 'twlocation');
    if (!$lang->mytwconnect) {
        $lang->load('mytwconnect');
    }
    // Authenticate
    if ($mybb->input['action'] == 'twlink') {
        $TwitterConnect->set_fallback('usercp.php?action=do_twlink');
        $TwitterConnect->authenticate();
    }
    // Link account to his Twitter's one
    if ($mybb->input['action'] == 'do_twlink') {
        $TwitterConnect->obtain_tokens();
        $user = $TwitterConnect->get_user();
        if ($user) {
            $TwitterConnect->link_user('', $user['id']);
        } else {
            error($lang->mytwconnect_error_noauth);
        }
        $TwitterConnect->redirect('usercp.php?action=mytwconnect', '', $lang->mytwconnect_success_linked);
    }
    // Settings page
    if ($mybb->input['action'] == 'mytwconnect') {
        global $db, $lang, $theme, $templates, $headerinclude, $header, $footer, $plugins, $usercpnav;
        add_breadcrumb($lang->nav_usercp, 'usercp.php');
        add_breadcrumb($lang->mytwconnect_page_title, 'usercp.php?action=mytwconnect');
        // The user is changing his settings
        if ($mybb->request_method == 'post' or $_SESSION['twlogin']) {
            if ($mybb->request_method == 'post') {
                verify_post_check($mybb->input['my_post_key']);
            }
            // He's unlinking his account
            if ($mybb->input['unlink']) {
                $TwitterConnect->unlink_user();
                redirect('usercp.php?action=mytwconnect', $lang->mytwconnect_success_accunlinked, $lang->mytwconnect_success_accunlinked_title);
            } else {
                $settings = array();
                foreach ($settingsToCheck as $setting) {
                    $settings[$setting] = 0;
                    if ($mybb->input[$setting] == 1) {
                        $settings[$setting] = 1;
                    }
                    // Build a list of parameters to include in the fallback URL
                    $loginUrlExtra .= "&{$setting}=" . $settings[$setting];
                }
                // Process the tokens
                if ($_SESSION['twlogin']) {
                    $TwitterConnect->obtain_tokens();
                }
                $user = $TwitterConnect->get_user();
                // This user is not logged in with Twitter
                if (!$user) {
                    // Store a token in the session, we will check for it in the next call
                    $_SESSION['twlogin'] = 1;
                    $TwitterConnect->set_fallback("usercp.php?action=mytwconnect" . $loginUrlExtra);
                    $TwitterConnect->authenticate();
                    return;
                }
                if ($db->update_query('users', $settings, 'uid = ' . (int) $mybb->user['uid'])) {
                    unset($_SESSION['twlogin']);
                    $newUser = array_merge($mybb->user, $settings);
                    $TwitterConnect->sync($newUser, $user);
                    redirect('usercp.php?action=mytwconnect', $lang->mytwconnect_success_settingsupdated, $lang->mytwconnect_success_settingsupdated_title);
                }
            }
        }
        $options = '';
        if ($mybb->user['mytw_uid']) {
            // Checking if admins and users want to sync that stuff
            foreach ($settingsToCheck as $setting) {
                $tempKey = 'mytwconnect_' . $setting;
                if (!$mybb->settings[$tempKey]) {
                    continue;
                }
                $userSettings[$setting] = 0;
                if ($mybb->user[$setting]) {
                    $userSettings[$setting] = 1;
                }
            }
            $text = $lang->setting_mytwconnect_whattosync;
            $unlink = "<input type=\"submit\" class=\"button\" name=\"unlink\" value=\"{$lang->mytwconnect_settings_unlink}\" />";
            if ($userSettings) {
                foreach ($userSettings as $setting => $value) {
                    $tempKey = 'mytwconnect_settings_' . $setting;
                    $checked = '';
                    if ($value) {
                        $checked = " checked=\"checked\"";
                    }
                    $label = $lang->{$tempKey};
                    $altbg = alt_trow();
                    eval("\$options .= \"" . $templates->get('mytwconnect_usercp_settings_setting') . "\";");
                }
            } else {
                $text = $lang->setting_mytwconnect_connected;
            }
        } else {
            $text = $lang->setting_mytwconnect_linkaccount;
            eval("\$options = \"" . $templates->get('mytwconnect_usercp_settings_linkprofile') . "\";");
        }
        eval("\$content = \"" . $templates->get('mytwconnect_usercp_settings') . "\";");
        output_page($content);
    }
}
コード例 #22
0
function ougc_awards_profile()
{
    global $mybb, $memprofile, $templates;
    $memprofile['ougc_awards'] = '';
    $limit = (int) $mybb->settings['ougc_awards_profile'];
    $limit = $limit > 100 ? 100 : ($limit < 1 && $limit != -1 ? 1 : $limit);
    if ($limit < 0 && $limit != -1 || my_strpos($templates->cache['member_profile'], '{$memprofile[\'ougc_awards\']}') === false) {
        return;
    }
    global $db, $lang, $theme, $templates, $awards;
    $awards->lang_load();
    $awards->set_url(null, get_profile_link($memprofile['uid']));
    // Query our data.
    if ($limit == -1) {
        // Get awards
        $query = $db->query('
			SELECT u.*, a.*
			FROM ' . TABLE_PREFIX . 'ougc_awards_users u
			LEFT JOIN ' . TABLE_PREFIX . 'ougc_awards a ON (u.aid=a.aid)
			WHERE u.uid=\'' . (int) $memprofile['uid'] . '\' AND a.visible=\'1\'
			ORDER BY u.date desc');
    } else {
        // First we need to figure out the total amount of awards.
        $query = $db->query('
			SELECT COUNT(au.aid) AS awards
			FROM ' . TABLE_PREFIX . 'ougc_awards_users au
			LEFT JOIN ' . TABLE_PREFIX . 'ougc_awards a ON (au.aid=a.aid)
			WHERE au.uid=\'' . (int) $memprofile['uid'] . '\' AND a.visible=\'1\'
			ORDER BY au.date desc
		');
        $awardscount = (int) $db->fetch_field($query, 'awards');
        $page = (string) $mybb->input['view'] == 'awards' ? (int) $mybb->input['page'] : 0;
        if ($page > 0) {
            $start = ($page - 1) * $limit;
            if ($page > ceil($awardscount / $limit)) {
                $start = 0;
                $page = 1;
            }
        } else {
            $start = 0;
            $page = 1;
        }
        // We want to keep $mybb->input['view'] intact for other plugins, ;)
        $multipage = (string) multipage($awardscount, $limit, $page, $awards->build_url('view=awards'));
        eval('$multipage = "' . $templates->get('ougcawards_profile_multipage') . '";');
        $query = $db->query('
			SELECT au.*, a.*
			FROM ' . TABLE_PREFIX . 'ougc_awards_users au
			LEFT JOIN ' . TABLE_PREFIX . 'ougc_awards a ON (au.aid=a.aid)
			WHERE au.uid=\'' . (int) $memprofile['uid'] . '\' AND a.visible=\'1\'
			ORDER BY au.date desc
			LIMIT ' . $start . ', ' . $limit);
    }
    // Output our awards.
    if (!$db->num_rows($query)) {
        eval('$awardlist = "' . $templates->get('ougcawards_profile_row_empty') . '";');
    } else {
        $awardlist = '';
        while ($award = $db->fetch_array($query)) {
            $trow = alt_trow();
            if ($name = $awards->get_award_info('name', $award['aid'])) {
                $award['name'] = $name;
            }
            if ($description = $awards->get_award_info('description', $award['aid'])) {
                $award['description'] = $description;
            }
            if ($reason = $awards->get_award_info('reason', $award['aid'], $award['gid'])) {
                $award['reason'] = $reason;
            }
            if (empty($award['reason'])) {
                $award['reason'] = $lang->ougc_awards_pm_noreason;
            }
            $awards->parse_text($award['reason']);
            $award['image'] = $awards->get_award_icon($award['aid']);
            $award['date'] = $lang->sprintf($lang->ougc_awards_profile_tine, my_date($mybb->settings['dateformat'], $award['date']), my_date($mybb->settings['timeformat'], $award['date']));
            eval('$awardlist .= "' . $templates->get('ougcawards_profile_row') . '";');
        }
    }
    $lang->ougc_awards_profile_title = $lang->sprintf($lang->ougc_awards_profile_title, htmlspecialchars_uni($memprofile['username']));
    eval('$memprofile[\'ougc_awards\'] = "' . $templates->get('ougcawards_profile') . '";');
}
コード例 #23
0
ファイル: newpoints_shop.php プロジェクト: ambsalinas/anima
function newpoints_shop_stats()
{
    global $mybb, $db, $templates, $cache, $theme, $newpoints_shop_lastpurchases, $last_purchases, $lang;
    // load language
    newpoints_lang_load("newpoints_shop");
    $last_purchases = '';
    // build stats table
    $query = $db->simple_select('newpoints_log', '*', 'action=\'shop_purchase\'', array('order_by' => 'date', 'order_dir' => 'DESC', 'limit' => intval($mybb->settings['newpoints_shop_lastpurchases'])));
    while ($purchase = $db->fetch_array($query)) {
        $bgcolor = alt_trow();
        $data = explode('-', $purchase['data']);
        $item = newpoints_shop_get_item($data[0]);
        $purchase['item'] = htmlspecialchars_uni($item['name']);
        $link = build_profile_link(htmlspecialchars_uni($purchase['username']), intval($purchase['uid']));
        $purchase['user'] = $link;
        $purchase['date'] = my_date($mybb->settings['dateformat'], intval($purchase['date']), '', false);
        eval("\$last_purchases .= \"" . $templates->get('newpoints_shop_stats_purchase') . "\";");
    }
    if (!$last_purchases) {
        eval("\$last_purchases = \"" . $templates->get('newpoints_shop_stats_nopurchase') . "\";");
    }
    eval("\$newpoints_shop_lastpurchases = \"" . $templates->get('newpoints_shop_stats') . "\";");
}
コード例 #24
0
function get_subscribed_topic_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    $lang->load("usercp");
    $parser = new postParser();
    $input = Tapatalk_Input::filterXmlInput(array('start_num' => Tapatalk_Input::INT, 'last_num' => Tapatalk_Input::INT), $xmlrpc_params);
    if ($mybb->user['uid'] == 0 || $mybb->usergroup['canusercp'] == 0) {
        return tt_no_permission();
    }
    $query = $db->simple_select("forumpermissions", "*", "gid='" . $db->escape_string($mybb->user['usergroup']) . "'");
    while ($permissions = $db->fetch_array($query)) {
        $permissioncache[$permissions['gid']][$permissions['fid']] = $permissions;
    }
    while ($forum = $db->fetch_array($query)) {
        if ($mybb->user['uid'] == 0) {
            if ($forumsread[$forum['fid']]) {
                $forum['lastread'] = $forumsread[$forum['fid']];
            }
        }
        $readforums[$forum['fid']] = $forum['lastread'];
    }
    require_once MYBB_ROOT . "inc/functions_forumlist.php";
    $fpermissions = forum_permissions();
    list($start, $limit) = process_page($input['start_num'], $input['last_num']);
    // Thread visiblity
    $visible = "AND t.visible != 0";
    if (is_moderator() == true) {
        $visible = '';
    }
    // Do Multi Pages
    $query = $db->query("\n\t\tSELECT COUNT(ts.tid) as threads\n\t\tFROM " . TABLE_PREFIX . "threadsubscriptions ts\n\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid = ts.tid)\n\t\tWHERE ts.uid = '" . $mybb->user['uid'] . "' {$visible}\n\t");
    $threadcount = $db->fetch_field($query, "threads");
    // Fetch subscriptions
    $query = $db->query("\n\t\tSELECT s.*, t.*, t.username AS threadusername, u.username, u.username, u.avatar, if({$mybb->user['uid']} > 0 and s.uid = {$mybb->user['uid']}, 1, 0) as subscribed, po.message, f.name as forumname, IF(b.lifted > UNIX_TIMESTAMP() OR b.lifted = 0, 1, 0) as isbanned\n\t\tFROM " . TABLE_PREFIX . "threadsubscriptions s\n\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (s.tid=t.tid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid = t.uid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "banned b ON (b.uid = t.uid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "posts po ON (po.pid = t.firstpost)\n\t\tleft join " . TABLE_PREFIX . "forums f on f.fid = t.fid\n\t\tWHERE s.uid='" . $mybb->user['uid'] . "' {$visible}\n\t\tORDER BY t.lastpost DESC\n\t\tLIMIT {$start}, {$limit}\n\t");
    while ($subscription = $db->fetch_array($query)) {
        $forumpermissions = $fpermissions[$subscription['fid']];
        if ($forumpermissions['canview'] == 0 || $forumpermissions['canviewthreads'] == 0) {
            // Hmm, you don't have permission to view this thread - unsubscribe!
            $del_subscriptions[] = $subscription['tid'];
        } else {
            if ($subscription['tid']) {
                $subscriptions[$subscription['tid']] = $subscription;
            }
        }
    }
    if (is_array($del_subscriptions)) {
        $tids = implode(',', $del_subscriptions);
        if ($tids) {
            $db->delete_query("threadsubscriptions", "tid IN ({$tids}) AND uid='{$mybb->user['uid']}'");
        }
    }
    $topic_list = array();
    if (is_array($subscriptions)) {
        $tids = implode(",", array_keys($subscriptions));
        // Build a forum cache.
        $query = $db->query("\n\t\t\tSELECT f.fid, fr.dateline AS lastread\n\t\t\tFROM " . TABLE_PREFIX . "forums f\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "forumsread fr ON (fr.fid=f.fid AND fr.uid='{$mybb->user['uid']}')\n\t\t\tWHERE f.active != 0\n\t\t\tORDER BY pid, disporder\n\t\t");
        while ($forum = $db->fetch_array($query)) {
            if ($mybb->user['uid'] == 0) {
                if ($forumsread[$forum['fid']]) {
                    $forum['lastread'] = $forumsread[$forum['fid']];
                }
            }
            $readforums[$forum['fid']] = $forum['lastread'];
        }
        // Read threads
        if ($mybb->settings['threadreadcut'] > 0) {
            $query = $db->simple_select("threadsread", "*", "uid='{$mybb->user['uid']}' AND tid IN ({$tids})");
            while ($readthread = $db->fetch_array($query)) {
                $subscriptions[$readthread['tid']]['lastread'] = $readthread['dateline'];
            }
        }
        // Now we can build our subscription list
        foreach ($subscriptions as $thread) {
            $bgcolor = alt_trow();
            $folder = '';
            $prefix = '';
            // If this thread has a prefix, insert a space between prefix and subject
            if ($thread['prefix'] != 0) {
                $thread['threadprefix'] .= '&nbsp;';
            }
            // Sanitize
            $thread['subject'] = $parser->parse_badwords($thread['subject']);
            $gotounread = '';
            $isnew = 0;
            $donenew = 0;
            $lastread = 0;
            $unreadpost = 0;
            if ($mybb->settings['threadreadcut'] > 0 && $mybb->user['uid']) {
                $forum_read = $readforums[$thread['fid']];
                $read_cutoff = TIME_NOW - $mybb->settings['threadreadcut'] * 60 * 60 * 24;
                if ($forum_read == 0 || $forum_read < $read_cutoff) {
                    $forum_read = $read_cutoff;
                }
            } else {
                $forum_read = $forumsread[$thread['fid']];
            }
            if ($mybb->settings['threadreadcut'] > 0 && $thread['lastpost'] > $forum_read) {
                $cutoff = TIME_NOW - $mybb->settings['threadreadcut'] * 60 * 60 * 24;
            }
            if ($thread['lastpost'] > $cutoff) {
                if ($thread['lastpost'] > $cutoff) {
                    if ($thread['lastread']) {
                        $lastread = $thread['lastread'];
                    } else {
                        $lastread = 1;
                    }
                }
            }
            if (!$lastread) {
                $readcookie = $threadread = my_get_array_cookie("threadread", $thread['tid']);
                if ($readcookie > $forum_read) {
                    $lastread = $readcookie;
                } else {
                    $lastread = $forum_read;
                }
            }
            if ($thread['lastpost'] > $lastread && $lastread) {
                $unreadpost = 1;
            }
            $topic_list[] = new xmlrpcval(array('forum_id' => new xmlrpcval($thread['fid'], 'string'), 'forum_name' => new xmlrpcval(basic_clean($thread['forumname']), 'base64'), 'topic_id' => new xmlrpcval($thread['tid'], 'string'), 'topic_title' => new xmlrpcval($thread['subject'], 'base64'), 'topic_author_id' => new xmlrpcval($thread['uid'], 'string'), 'post_author_name' => new xmlrpcval($thread['username'], 'base64'), 'can_subscribe' => new xmlrpcval(true, 'boolean'), 'is_subscribed' => new xmlrpcval((bool) $thread['subscribed'], 'boolean'), 'is_closed' => new xmlrpcval((bool) $thread['closed'], 'boolean'), 'short_content' => new xmlrpcval(process_short_content($thread['message'], $parser), 'base64'), 'icon_url' => new xmlrpcval(absolute_url($thread['avatar']), 'string'), 'post_time' => new xmlrpcval(mobiquo_iso8601_encode($thread['lastpost']), 'dateTime.iso8601'), 'reply_number' => new xmlrpcval($thread['replies'], 'int'), 'view_number' => new xmlrpcval($thread['views'], 'int'), 'new_post' => new xmlrpcval($unreadpost, 'boolean'), 'can_delete' => new xmlrpcval(is_moderator($thread['fid'], "candeleteposts"), 'boolean'), 'can_close' => new xmlrpcval(is_moderator($thread['fid'], "canopenclosethreads"), 'boolean'), 'can_approve' => new xmlrpcval(is_moderator($thread['fid'], "canopenclosethreads"), 'boolean'), 'can_stick' => new xmlrpcval(is_moderator($thread['fid'], "canmanagethreads"), 'boolean'), 'can_merge' => new xmlrpcval(is_moderator($thread['fid'], "canmanagethreads"), 'boolean'), 'can_merge_post' => new xmlrpcval(is_moderator($thread['fid'], "canmanagethreads"), 'boolean'), 'can_move' => new xmlrpcval(is_moderator($thread['fid'], "canmovetononmodforum"), 'boolean'), 'can_ban' => new xmlrpcval($mybb->usergroup['canmodcp'] == 1, 'boolean'), 'can_rename' => new xmlrpcval(false, 'boolean'), 'is_ban' => new xmlrpcval($thread['isbanned'], 'boolean'), 'is_sticky' => new xmlrpcval($thread['sticky'], 'boolean'), 'is_approved' => new xmlrpcval(!!$thread['visible'], 'boolean'), 'is_deleted' => new xmlrpcval(false, 'boolean')), 'struct');
        }
    }
    $result = new xmlrpcval(array('total_topic_num' => new xmlrpcval($threadcount, 'int'), 'topics' => new xmlrpcval($topic_list, 'array')), 'struct');
    return new xmlrpcresp($result);
}
コード例 #25
0
function asb_staff_online_box_get_online_staff($settings, $width)
{
    global $db, $mybb, $templates, $lang, $cache, $theme;
    if (!$lang->asb_addon) {
        $lang->load('asb_addon');
    }
    // get our setting value
    $max_rows = (int) $settings['max_staff'];
    // if max_rows is set to 0 then show nothing
    if (!$max_rows) {
        return false;
    }
    // store our users and groups here
    $usergroups = array();
    $users = array();
    // get all the groups admin has specified should be shown on showteam.php
    $query = $db->simple_select('usergroups', 'gid, title, usertitle, image', 'showforumteam=1', array('order_by' => 'disporder'));
    while ($usergroup = $db->fetch_array($query)) {
        // store them in our array
        $usergroups[$usergroup['gid']] = $usergroup;
    }
    // get all the users of those specific groups
    $groups_in = implode(',', array_keys($usergroups));
    // if there were no groups . . .
    if (!$groups_in) {
        // there is nothing to show
        return false;
    }
    // set the time based on ACP settings
    $timesearch = TIME_NOW - $mybb->settings['wolcutoff'];
    // get all the users that are in staff groups that have been online within the allowed cutoff time
    $query = $db->query("\n\t\tSELECT\n\t\t\ts.sid, s.ip, s.uid, s.time, s.location,\n\t\t\tu.username, u.invisible, u.usergroup, u.displaygroup, u.avatar\n\t\tFROM {$db->table_prefix}sessions s\n\t\tLEFT JOIN {$db->table_prefix}users u ON (s.uid=u.uid)\n\t\tWHERE\n\t\t\t(displaygroup IN ({$groups_in}) OR (displaygroup='0' AND usergroup IN ({$groups_in}))) AND s.time > '{$timesearch}'\n\t\tORDER BY\n\t\t\tu.username ASC, s.time DESC\n\t");
    // loop through our users
    while ($user = $db->fetch_array($query)) {
        // if displaygroup is not 0 (display primary group) . . .
        if ($user['displaygroup'] != 0) {
            // then use this group
            $group = $user['displaygroup'];
        } else {
            // otherwise use the primary group
            $group = $user['usergroup'];
        }
        // if this user group is in a staff group then add the info to the list
        if ($usergroups[$group]) {
            $usergroups[$group]['user_list'][$user['uid']] = $user;
        }
    }
    // make sure we start from nothing
    $grouplist = '';
    $counter = 1;
    // loop through each user group
    foreach ($usergroups as $usergroup) {
        // if there are no users or we have reached our limit . . .
        if (!isset($usergroup['user_list']) || $counter > $max_rows) {
            // skip an iteration
            continue;
        }
        // we use this for the alternating table row bgcolor
        $bgcolor = '';
        // loop through all users
        foreach ($usergroup['user_list'] as $user) {
            // if we are over our limit
            if ($counter > $max_rows) {
                // don't add any more
                continue;
            }
            // prepare the info
            // alt and title for image are the same
            $staff_avatar_alt = $staff_avatar_title = $user['username'] . '\'s profile';
            // if the user has an avatar then display it, otherwise force the default avatar.
            $staff_avatar_filename = "{$theme['imgdir']}/default_avatar.gif";
            if ($user['avatar'] != '') {
                $staff_avatar_filename = $user['avatar'];
            }
            // avatar properties
            $staff_avatar_dimensions = '100%';
            // user name link properties
            $staff_link_title = $user['username'];
            $staff_username = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
            // link (for avatar and user name)
            $staff_profile_link = get_profile_link($user['uid']);
            // badge alt and title are the same
            $staff_badge_alt = $staff_badge_title = $usergroup['usertitle'];
            // if the user's group has a badge image . . .
            $staff_badge = "{$staff_badge_alt}";
            if ($usergroup['image']) {
                // store it (if nothing is store alt property will display group default usertitle)
                $staff_badge_filename = $usergroup['image'];
                $staff_badge = <<<EOF
<img src="{$staff_badge_filename}" alt="{$staff_badge_alt}" title="{$staff_badge_title}" width="{$staff_badge_width}"/>
EOF;
            }
            // give us an alternating bgcolor
            $bgcolor = alt_trow();
            // incremenet the counter
            ++$counter;
            // add this row to the table
            eval("\$online_staff .= \"" . $templates->get("asb_staff_online_bit") . "\";");
        }
    }
    // if there were staff members online . . .
    if ($online_staff) {
        // show them
        return $online_staff;
    } else {
        // otherwise apologize profusely
        return false;
    }
}
コード例 #26
0
function replyban_run()
{
    global $db, $mybb, $lang, $templates, $theme, $headerinclude, $header, $footer, $replyban, $moderation;
    $lang->load("replyban");
    if ($mybb->input['action'] != "replyban" && $mybb->input['action'] != "do_replyban" && $mybb->input['action'] != "liftreplyban") {
        return;
    }
    if ($mybb->input['action'] == "replyban") {
        $tid = $mybb->get_input('tid', MyBB::INPUT_INT);
        $thread = get_thread($tid);
        if (!is_moderator($thread['fid'], "canmanagethreads")) {
            error_no_permission();
        }
        if (!$thread['tid']) {
            error($lang->error_invalidthread);
        }
        $thread['subject'] = htmlspecialchars_uni($thread['subject']);
        $lang->reply_bans_for = $lang->sprintf($lang->reply_bans_for, $thread['subject']);
        check_forum_password($thread['fid']);
        build_forum_breadcrumb($thread['fid']);
        add_breadcrumb($thread['subject'], get_thread_link($thread['tid']));
        add_breadcrumb($lang->reply_bans);
        $query = $db->query("\r\n\t\t\tSELECT r.*, u.username\r\n\t\t\tFROM " . TABLE_PREFIX . "replybans r\r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (r.uid=u.uid)\r\n\t\t\tWHERE r.tid='{$thread['tid']}'\r\n\t\t\tORDER BY r.dateline DESC\r\n\t\t");
        while ($ban = $db->fetch_array($query)) {
            $ban['reason'] = htmlspecialchars_uni($ban['reason']);
            $ban['username'] = build_profile_link($ban['username'], $ban['uid']);
            if ($ban['lifted'] == 0) {
                $ban['lifted'] = $lang->permanent;
            } else {
                $ban['lifted'] = my_date('relative', $ban['lifted'], '', 2);
            }
            $alt_bg = alt_trow();
            eval("\$ban_bit .= \"" . $templates->get("moderation_replyban_bit") . "\";");
        }
        if (!$ban_bit) {
            eval("\$ban_bit = \"" . $templates->get("moderation_replyban_no_bans") . "\";");
        }
        // Generate the banned times dropdown
        $liftlist = '';
        $bantimes = fetch_ban_times();
        foreach ($bantimes as $time => $title) {
            $selected = '';
            if (isset($banned['bantime']) && $banned['bantime'] == $time) {
                $selected = " selected=\"selected\"";
            }
            $thattime = '';
            if ($time != '---') {
                $dateline = TIME_NOW;
                if (isset($banned['dateline'])) {
                    $dateline = $banned['dateline'];
                }
                $thatime = my_date("D, jS M Y @ g:ia", ban_date2timestamp($time, $dateline));
                $thattime = " ({$thatime})";
            }
            eval("\$liftlist .= \"" . $templates->get("moderation_replyban_liftlist") . "\";");
        }
        eval("\$replyban = \"" . $templates->get("moderation_replyban") . "\";");
        output_page($replyban);
    }
    if ($mybb->input['action'] == "do_replyban" && $mybb->request_method == "post") {
        // Verify incoming POST request
        verify_post_check($mybb->get_input('my_post_key'));
        $tid = $mybb->get_input('tid', MyBB::INPUT_INT);
        $thread = get_thread($tid);
        if (!is_moderator($thread['fid'], "canmanagethreads")) {
            error_no_permission();
        }
        if (!$thread['tid']) {
            error($lang->error_invalidthread);
        }
        $user = get_user_by_username($mybb->input['username'], array('fields' => array('username')));
        if (!$user['uid']) {
            error($lang->error_invaliduser);
        }
        $mybb->input['reason'] = $mybb->get_input('reason');
        if (!trim($mybb->input['reason'])) {
            error($lang->error_missing_reason);
        }
        $query = $db->simple_select('replybans', 'rid', "uid='{$user['uid']}' AND tid='{$thread['tid']}'");
        $existingban = $db->fetch_field($query, 'rid');
        if ($existingban > 0) {
            error($lang->error_alreadybanned);
        }
        if ($mybb->get_input('liftban') == '---') {
            $lifted = 0;
        } else {
            $lifted = ban_date2timestamp($mybb->get_input('liftban'), 0);
        }
        $reason = my_substr($mybb->input['reason'], 0, 240);
        $insert_array = array('uid' => $user['uid'], 'tid' => $thread['tid'], 'dateline' => TIME_NOW, 'reason' => $db->escape_string($reason), 'lifted' => $db->escape_string($lifted));
        $db->insert_query('replybans', $insert_array);
        log_moderator_action(array("tid" => $thread['tid'], "fid" => $thread['fid'], "uid" => $user['uid'], "username" => $user['username']), $lang->user_reply_banned);
        moderation_redirect("moderation.php?action=replyban&tid={$thread['tid']}", $lang->redirect_user_banned_replying);
    }
    if ($mybb->input['action'] == "liftreplyban") {
        // Verify incoming POST request
        verify_post_check($mybb->get_input('my_post_key'));
        $rid = $mybb->get_input('rid', MyBB::INPUT_INT);
        $query = $db->simple_select("replybans", "*", "rid='{$rid}'");
        $ban = $db->fetch_array($query);
        if (!$ban['rid']) {
            error($lang->error_invalidreplyban);
        }
        $thread = get_thread($ban['tid']);
        $user = get_user($ban['uid']);
        if (!$thread['tid']) {
            error($lang->error_invalidthread);
        }
        if (!is_moderator($thread['fid'], "canmanagethreads")) {
            error_no_permission();
        }
        $db->delete_query("replybans", "rid='{$ban['rid']}'");
        log_moderator_action(array("tid" => $thread['tid'], "fid" => $thread['fid'], "uid" => $user['uid'], "username" => $user['username']), $lang->user_reply_banned_lifted);
        moderation_redirect("moderation.php?action=replyban&tid={$thread['tid']}", $lang->redirect_reply_ban_lifted);
    }
    exit;
}
コード例 #27
0
ファイル: xt_sthreadhooks.php プロジェクト: sunnybutani/webc
function xthreads_showthread()
{
    global $thread, $threadfields, $threadfields_display, $threadfields_display_rows, $templates, $theme, $threadfield_cache;
    // just do an extra query to grab the threadfields
    xthreads_get_threadfields($thread['tid'], $threadfields, false, $thread);
    // generate stuff to show on showthread
    // $threadfield_cache should always be set here
    $threadfields_display = $threadfields_display_rows = '';
    if (!empty($threadfields)) {
        foreach ($threadfields as $k => &$val) {
            $tf =& $threadfield_cache[$k];
            if ($tf['hidefield'] & XTHREADS_HIDE_THREAD) {
                continue;
            }
            if ($tf['inputtype'] == XTHREADS_INPUT_FILE) {
                $value =& $val['value'];
            } else {
                $value =& $val;
            }
            $title = htmlspecialchars_uni($tf['title']);
            $bgcolor = alt_trow();
            eval('$threadfields_display_rows .= "' . $templates->get('showthread_threadfield_row') . '";');
        }
    }
    unset($value);
    if ($threadfields_display_rows) {
        eval('$threadfields_display = "' . $templates->get('showthread_threadfields') . '";');
    }
    global $mybb;
    /*
    if($mybb->input['action'] == 'xtnext' || $mybb->input['action'] == 'xtprev') {
    	global $db;
    	$add_join = false;
    	
    	$nf = 'lastpost';
    	switch($mybb->input['order']) {
    		case 'subject':
    		case 'replies':
    		case 'views':
    			$nf = $mybb->input['order'];
    			break;
    		
    		case 'starter':  $nf = 'username'; break;
    		case 'started':  $nf = 'dateline'; break;
    		case 'rating': // this is f***ing slow, but then, that's the best MyBB can do
    			unset($nf);
    			$nextfield = 'IF(t.numratings=0, 0, t.totalratings / t.numratings)';
    			$curval = ($thread['numratings'] ? $thread['totalratings'] / $thread['numratings'] : 0);
    			break;
    		
    		// more XThreads sort options
    		// TODO: prefix, icon
    		
    		case 'lastposter':
    		case 'numratings':
    		case 'attachmentcount':
    			$nf = $mybb->input['order'];
    			break;
    		
    		
    		default:
    			// TODO: threadfields sorting
    			if(substr($mybb->input['order'], 0, 3) == 'tf_') {
    				$add_join = true;
    				
    			} elseif(substr($mybb->input['order'], 0, 4) == 'tfa_') {
    				$add_join = true;
    				
    			}
    			break;
    		
    	}
    	if(isset($nf)) {
    		if($add_join) {
    			$nextfield = 'tfd.`'.$nf.'`';
    			$curval = $threadfields[$nf];
    		} else {
    			$nextfield = 't.'.$nf;
    			$curval = $thread[$nf];
    		}
    	}
    	if(is_string($curval))
    		$curval = '"'.$db->escape_string($curval).'"';
    	$cond = $nextfield.($mybb->input['action']=='xtprev' ? '<':'>').$curval;
    	
    	// TODO: additional filtering
    	
    	$cond .= ' AND t.fid='.$thread['fid'].' AND t.visible=1 AND t.closed NOT LIKE "moved|%"';
    	$order_dir = ($mybb->input['action'] == 'xtprev' ? 'desc':'asc');
    	
    	$join = '';
    	if($add_join)
    		$join = 'LEFT JOIN '.$db->table_prefix.'threadfields_data tfd ON t.tid=tfd.tid';
    	$query = $db->query('
    		SELECT t.tid FROM '.$db->table_prefix.'threads t
    		'.$join.'
    		WHERE '.$cond.'
    		ORDER BY '.$nextfield.' '.$order_dir.', t.tid '.$order_dir.'
    		LIMIT 1
    	');
    	$nexttid = $db->fetch_field($query, 'tid');
    	if(!$nexttid)
    		error($GLOBALS['lang']->error_nonextoldest);
    	
    	header('Location: '.htmlspecialchars_decode(get_thread_link($nexttid)));
    	exit;
    }
    */
    // fix screwy jeditable default
    if ($mybb->version_code >= 1800) {
        $GLOBALS['header'] .= '<script type="text/javascript"><!--
try { jQuery.fn.editable.defaults.placeholder=""; } catch(x) {}
// -->
</script>';
    }
}
コード例 #28
0
ファイル: get_topic.php プロジェクト: dthiago/tapatalk-mybb
function get_announcement_list($foruminfo, $fid)
{
    // Gather forum stats
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $time, $mybbgroups, $cache;
    $has_announcements = $has_modtools = false;
    $forum_stats = $cache->read("forumsdisplay");
    $parser = new postParser();
    if (is_array($forum_stats)) {
        if (!empty($forum_stats[-1]['modtools']) || !empty($forum_stats[$fid]['modtools'])) {
            // Mod tools are specific to forums, not parents
            $has_modtools = true;
        }
        if (!empty($forum_stats[-1]['announcements']) || !empty($forum_stats[$fid]['announcements'])) {
            // Global or forum-specific announcements
            $has_announcements = true;
        }
    }
    $parentlist = $foruminfo['parentlist'];
    $parentlistexploded = explode(",", $parentlist);
    foreach ($parentlistexploded as $mfid) {
        if (!empty($forum_stats[$mfid]['announcements'])) {
            $has_announcements = true;
        }
    }
    $announcementlist = $topic_list = array();
    if ($has_announcements == true) {
        $limit = '';
        $announcements = '';
        if ($mybb->settings['announcementlimit']) {
            $limit = "LIMIT 0, " . $mybb->settings['announcementlimit'];
        }
        $sql = build_parent_list($fid, "fid", "OR", $parentlist);
        $time = TIME_NOW;
        $query = $db->query("\n\t\t\tSELECT a.*, u.username\n\t\t\tFROM " . TABLE_PREFIX . "announcements a\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=a.uid)\n\t\t\tWHERE a.startdate<='{$time}' AND (a.enddate>='{$time}' OR a.enddate='0') AND ({$sql} OR fid='-1')\n\t\t\tORDER BY a.startdate DESC {$limit}\n\t\t");
        // See if this announcement has been read in our announcement array
        $cookie = array();
        if (isset($mybb->cookies['mybb']['announcements'])) {
            $cookie = my_unserialize(stripslashes($mybb->cookies['mybb']['announcements']));
        }
        $announcementlist = '';
        $bgcolor = alt_trow(true);
        // Reset the trow colors
        while ($announcement = $db->fetch_array($query)) {
            if ($announcement['startdate'] > $mybb->user['lastvisit'] && !$cookie[$announcement['aid']]) {
                $new_class = ' class="subject_new"';
                $folder = "newfolder";
            } else {
                $new_class = ' class="subject_old"';
                $folder = "folder";
            }
            // Mmm, eat those announcement cookies if they're older than our last visit
            if (isset($cookie[$announcement['aid']]) && $cookie[$announcement['aid']] < $mybb->user['lastvisit']) {
                unset($cookie[$announcement['aid']]);
            }
            $announcement['announcementlink'] = get_announcement_link($announcement['aid']);
            $announcement['subject'] = $parser->parse_badwords($announcement['subject']);
            $announcement['subject'] = htmlspecialchars_uni($announcement['subject']);
            $postdate = my_date('relative', $announcement['startdate']);
            $announcement['profilelink'] = build_profile_link($announcement['username'], $announcement['uid']);
            $announcementlist[] = $announcement;
        }
        if (empty($cookie)) {
            // Clean up cookie crumbs
            my_setcookie('mybb[announcements]', 0, TIME_NOW - 60 * 60 * 24 * 365);
        } else {
            if (!empty($cookie)) {
                my_setcookie("mybb[announcements]", addslashes(serialize($cookie)), -1);
            }
        }
        foreach ($announcementlist as $announce) {
            $user_info = get_user($announce['uid']);
            $icon_url = absolute_url($user_info['avatar']);
            $xmlrpc_topic = new xmlrpcval(array('forum_id' => new xmlrpcval($fid, 'string'), 'topic_id' => new xmlrpcval('ann_' . $announce['aid'], 'string'), 'topic_title' => new xmlrpcval(basic_clean($announce['subject']), 'base64'), 'topic_author_id' => new xmlrpcval($announce['uid'], 'string'), 'topic_author_name' => new xmlrpcval(basic_clean($announce['username']), 'base64'), 'icon_url' => new xmlrpcval(absolute_url($icon_url), 'string'), 'reply_number' => new xmlrpcval(0, 'int'), 'view_number' => new xmlrpcval(0, 'int'), 'short_content' => new xmlrpcval(process_short_content($announce['message'], $parser), 'base64')), 'struct');
            $topic_list[] = $xmlrpc_topic;
        }
    }
    $response = new xmlrpcval(array('total_topic_num' => new xmlrpcval(count($announcementlist), 'int'), 'forum_id' => new xmlrpcval($fid), 'forum_name' => new xmlrpcval(basic_clean($foruminfo['name']), 'base64'), 'can_post' => new xmlrpcval(false, 'boolean'), 'can_upload' => new xmlrpcval(false, 'boolean'), 'topics' => new xmlrpcval($topic_list, 'array')), 'struct');
    return new xmlrpcresp($response);
}
コード例 #29
0
 if ($pagecnt) {
     $start = ($pagecnt - 1) * $perpage;
 } else {
     $start = 0;
     $pagecnt = 1;
 }
 $table = new Table();
 $table->construct_header($lang->username, array('width' => '10%'));
 $table->construct_header($lang->date, array('class' => 'align_center', 'width' => '15%'));
 $table->construct_header($lang->information, array('class' => 'align_center', 'width' => '65%'));
 $table->construct_header($lang->ipaddress, array('class' => 'align_center', 'width' => '10%'));
 $query = $db->query("\n\t\tSELECT l.*, u.username, u.usergroup, u.displaygroup\n\t\tFROM " . TABLE_PREFIX . "adminlog l\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=l.uid)\n\t\tWHERE 1=1 {$where}\n\t\tORDER BY {$sortby} {$order}\n\t\tLIMIT {$start}, {$perpage}\n\t");
 while ($logitem = $db->fetch_array($query)) {
     $information = '';
     $logitem['dateline'] = date("jS M Y, G:i", $logitem['dateline']);
     $trow = alt_trow();
     $username = format_name($logitem['username'], $logitem['usergroup'], $logitem['displaygroup']);
     $logitem['profilelink'] = build_profile_link($username, $logitem['uid'], "_blank");
     $logitem['data'] = unserialize($logitem['data']);
     // Get detailed information from meta
     $information = get_admin_log_action($logitem);
     $table->construct_cell($logitem['profilelink']);
     $table->construct_cell($logitem['dateline'], array('class' => 'align_center'));
     $table->construct_cell($information);
     $table->construct_cell($logitem['ipaddress'], array('class' => 'align_center'));
     $table->construct_row();
 }
 if ($table->num_rows() == 0) {
     $table->construct_cell($lang->no_adminlogs, array('colspan' => '4'));
     $table->construct_row();
 }
コード例 #30
0
function recent_posts_get_postlist($settings)
{
    global $db, $mybb, $templates, $lang, $cache, $postlist, $gotounread, $theme;
    // load custom language phrases
    if (!$lang->asb_addon) {
        $lang->load('asb_addon');
    }
    // get forums user cannot view
    $unviewable = get_unviewable_forums(true);
    if ($unviewable) {
        $unviewwhere = " AND p.fid NOT IN ({$unviewable})";
    }
    // get inactive forums
    $inactive = get_inactive_forums();
    if ($inactive) {
        $inactivewhere = " AND p.fid NOT IN ({$inactive})";
    }
    if ($settings['important_threads_only']) {
        $important_threads = ' AND NOT t.sticky=0';
    }
    // build the exclude conditions
    $show['fids'] = asb_build_id_list($settings['forum_show_list'], 'p.fid');
    $show['tids'] = asb_build_id_list($settings['thread_show_list'], 'p.tid');
    $hide['fids'] = asb_build_id_list($settings['forum_hide_list'], 'p.fid');
    $hide['tids'] = asb_build_id_list($settings['thread_hide_list'], 'p.tid');
    $where['show'] = asb_build_SQL_where($show, ' OR ');
    $where['hide'] = asb_build_SQL_where($hide, ' OR ', ' NOT ');
    $query_where = $important_threads . $unviewwhere . $inactivewhere . asb_build_SQL_where($where, ' AND ', ' AND ');
    $altbg = alt_trow();
    $maxtitlelen = 48;
    $postlist = '';
    // Query for the latest forum discussions
    $query = $db->query("\n\t\tSELECT p.tid, p.pid, p.message, p.fid, p.dateline, p.subject,\n\t\t\tu.username, u.uid, u.displaygroup, u.usergroup,\n\t\t\tt.sticky\n\t\tFROM {$db->table_prefix}posts p\n\t\tLEFT JOIN {$db->table_prefix}users u ON (u.uid=p.uid)\n\t\tLEFT JOIN {$db->table_prefix}threads t ON (t.tid=p.tid)\n\t\tWHERE\n\t\t\tp.visible='1'{$query_where}\n\t\tORDER BY\n\t\t\tp.dateline DESC\n\t\tLIMIT\n\t\t\t0, " . (int) $settings['max_posts']);
    if ($db->num_rows($query) == 0) {
        // no content
        return false;
    }
    // Build a post parser
    require_once MYBB_ROOT . 'inc/class_parser.php';
    $parser = new postParser();
    $post_cache = array();
    while ($post = $db->fetch_array($query)) {
        $post_cache[$post['pid']] = $post;
    }
    foreach ($post_cache as $post) {
        $forumpermissions[$post['fid']] = forum_permissions($post['fid']);
        // make sure we can view this post
        if ($forumpermissions[$post['fid']]['canview'] == 0 || $forumpermissions[$post['fid']]['canviewthreads'] == 0 || $forumpermissions[$post['fid']]['canonlyviewownthreads'] == 1 && $post['uid'] != $mybb->user['uid']) {
            continue;
        }
        $lastposttime = my_date($mybb->settings['timeformat'], $post['dateline']);
        // don't link to guest's profiles (they have no profile).
        if ($post['uid'] == 0) {
            $post_author = $post['username'];
        } else {
            $post_author_name = format_name($post['username'], $post['usergroup'], $post['displaygroup']);
            $post_author = build_profile_link($post_author_name, $post['uid']);
        }
        if (my_strlen($post['subject']) > $maxtitlelen) {
            $post['subject'] = my_substr($post['subject'], 0, $maxtitlelen) . '...';
        }
        if (substr(strtolower($post['subject']), 0, 3) == 're:') {
            $post['subject'] = substr($post['subject'], 3);
        }
        $post['subject'] = htmlspecialchars_uni($parser->parse_badwords($post['subject']));
        $post['link'] = get_thread_link($post['tid']) . "&amp;pid={$post['pid']}#pid{$post['pid']}";
        // we just need the text and smilies (we'll parse them after we check length)
        $pattern = "|[[\\/\\!]*?[^\\[\\]]*?]|si";
        $post_excerpt = strip_tags(str_replace('<br />', '', asb_strip_url(preg_replace($pattern, '$1', $post['message']))));
        if (strlen($post_excerpt) > $settings['max_length']) {
            $post_excerpt = substr($post_excerpt, 0, $settings['max_length']) . ' . . .';
        }
        eval("\$postlist .= \"" . $templates->get("asb_recent_posts_post") . "\";");
        $altbg = alt_trow();
    }
    return $postlist;
}