Example #1
0
 function getUnviewable($tableName = '')
 {
     global $db;
     if ($tableName) {
         $tableName = $tableName . '.';
     }
     $wheres = array();
     $wheres[] = '1=1';
     // get forums user cannot view
     $unviewable = get_unviewable_forums(true);
     if ($unviewable) {
         $wheres[] = "{$tableName}fid NOT IN ({$unviewable})";
     }
     // get inactive forums
     $inactive = get_inactive_forums();
     if ($inactive) {
         $wheres[] = "{$tableName}fid NOT IN ({$inactive})";
     }
     // get disallowed forums
     $disallowedforums = $db->escape_string($mybb->settings['tags_disallowedforums']);
     if ($disallowedforums) {
         $wheres[] = "{$tableName} NOT IN ({$disallowedforums})";
     }
     return implode(' AND ', $wheres);
 }
Example #2
0
 }
 // Divide up the cookie using our delimeter
 $multiquoted = explode("|", $mybb->cookies['multiquote']);
 $plugins->run_hooks("xmlhttp_get_multiquoted_start");
 // No values - exit
 if (!is_array($multiquoted)) {
     exit;
 }
 // Loop through each post ID and sanitize it before querying
 foreach ($multiquoted as $post) {
     $quoted_posts[$post] = (int) $post;
 }
 // Join the post IDs back together
 $quoted_posts = implode(",", $quoted_posts);
 // Fetch unviewable forums
 $unviewable_forums = get_unviewable_forums();
 $inactiveforums = get_inactive_forums();
 if ($unviewable_forums) {
     $unviewable_forums = "AND t.fid NOT IN ({$unviewable_forums})";
 }
 if ($inactiveforums) {
     $inactiveforums = "AND t.fid NOT IN ({$inactiveforums})";
 }
 $message = '';
 // Are we loading all quoted posts or only those not in the current thread?
 if (empty($mybb->input['load_all'])) {
     $from_tid = "p.tid != '" . $mybb->get_input('tid', MyBB::INPUT_INT) . "' AND ";
 } else {
     $from_tid = '';
 }
 require_once MYBB_ROOT . "inc/class_parser.php";
/**
 * Builds a friendly named Who's Online location from an "activity" and array of user data. Assumes fetch_wol_activity has already been called.
 *
 * @param array Array containing activity and essential IDs.
 * @return string Location name for the activity being performed.
 */
function build_friendly_wol_location($user_activity)
{
    global $db, $lang, $uid_list, $aid_list, $pid_list, $tid_list, $fid_list, $ann_list, $eid_list, $plugins, $parser, $mybb;
    global $threads, $forums, $forums_linkto, $forum_cache, $posts, $announcements, $events, $usernames, $attachments;
    // Fetch forum permissions for this user
    $unviewableforums = get_unviewable_forums();
    $inactiveforums = get_inactive_forums();
    $fidnot = '';
    $unviewablefids = $inactivefids = array();
    if ($unviewableforums) {
        $fidnot = " AND fid NOT IN ({$unviewableforums})";
        $unviewablefids = explode(',', $unviewableforums);
    }
    if ($inactiveforums) {
        $fidnot .= " AND fid NOT IN ({$inactiveforums})";
        $inactivefids = explode(',', $inactiveforums);
    }
    // Fetch any users
    if (!is_array($usernames) && count($uid_list) > 0) {
        $uid_sql = implode(",", $uid_list);
        if ($uid_sql != $mybb->user['uid']) {
            $query = $db->simple_select("users", "uid,username", "uid IN ({$uid_sql})");
            while ($user = $db->fetch_array($query)) {
                $usernames[$user['uid']] = $user['username'];
            }
        } else {
            $usernames[$mybb->user['uid']] = $mybb->user['username'];
        }
    }
    // Fetch any attachments
    if (!is_array($attachments) && count($aid_list) > 0) {
        $aid_sql = implode(",", $aid_list);
        $query = $db->simple_select("attachments", "aid,pid", "aid IN ({$aid_sql})");
        while ($attachment = $db->fetch_array($query)) {
            $attachments[$attachment['aid']] = $attachment['pid'];
            $pid_list[] = $attachment['pid'];
        }
    }
    // Fetch any announcements
    if (!is_array($announcements) && count($ann_list) > 0) {
        $aid_sql = implode(",", $ann_list);
        $query = $db->simple_select("announcements", "aid,subject", "aid IN ({$aid_sql}) {$fidnot}");
        while ($announcement = $db->fetch_array($query)) {
            $announcement_title = htmlspecialchars_uni($parser->parse_badwords($announcement['subject']));
            $announcements[$announcement['aid']] = $announcement_title;
        }
    }
    // Fetch any posts
    if (!is_array($posts) && count($pid_list) > 0) {
        $pid_sql = implode(",", $pid_list);
        $query = $db->simple_select("posts", "pid,tid", "pid IN ({$pid_sql}) {$fidnot}");
        while ($post = $db->fetch_array($query)) {
            $posts[$post['pid']] = $post['tid'];
            $tid_list[] = $post['tid'];
        }
    }
    // Fetch any threads
    if (!is_array($threads) && count($tid_list) > 0) {
        $perms = array();
        $tid_sql = implode(",", $tid_list);
        $query = $db->simple_select('threads', 'uid, fid, tid, subject, visible, prefix', "tid IN({$tid_sql}) {$fidnot}");
        $threadprefixes = build_prefixes();
        while ($thread = $db->fetch_array($query)) {
            $thread['threadprefix'] = '';
            if ($thread['prefix'] && !empty($threadprefixes[$thread['prefix']])) {
                $thread['threadprefix'] = $threadprefixes[$thread['prefix']]['displaystyle'];
            }
            if (empty($perms[$thread['fid']])) {
                $perms[$thread['fid']] = forum_permissions($thread['fid']);
            }
            if (isset($perms[$thread['fid']]['canonlyviewownthreads']) && $perms[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid'] && !is_moderator($thread['fid'])) {
                continue;
            }
            if (is_moderator($thread['fid']) || $thread['visible'] == 1) {
                $thread_title = '';
                if ($thread['threadprefix']) {
                    $thread_title = $thread['threadprefix'] . ' ';
                }
                $thread_title .= htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
                $threads[$thread['tid']] = $thread_title;
                $fid_list[] = $thread['fid'];
            }
        }
    }
    // Fetch any forums
    if (!is_array($forums) && count($fid_list) > 0) {
        $fidnot = array_merge($unviewablefids, $inactivefids);
        foreach ($forum_cache as $fid => $forum) {
            if (in_array($fid, $fid_list) && !in_array($fid, $fidnot)) {
                $forums[$fid] = $forum['name'];
                $forums_linkto[$fid] = $forum['linkto'];
            }
        }
    }
    // And finaly any events
    if (!is_array($events) && count($eid_list) > 0) {
        $eid_sql = implode(",", $eid_list);
        $query = $db->simple_select("events", "eid,name", "eid IN ({$eid_sql})");
        while ($event = $db->fetch_array($query)) {
            $events[$event['eid']] = htmlspecialchars_uni($parser->parse_badwords($event['name']));
        }
    }
    // Now we've got everything we need we can put a name to the location
    switch ($user_activity['activity']) {
        // announcement.php functions
        case "announcements":
            if (!empty($announcements[$user_activity['ann']])) {
                $location_name = $lang->sprintf($lang->viewing_announcements, get_announcement_link($user_activity['ann']), $announcements[$user_activity['ann']]);
            } else {
                $location_name = $lang->viewing_announcements2;
            }
            break;
            // attachment.php actions
        // attachment.php actions
        case "attachment":
            $pid = $attachments[$user_activity['aid']];
            $tid = $posts[$pid];
            if (!empty($threads[$tid])) {
                $location_name = $lang->sprintf($lang->viewing_attachment2, $user_activity['aid'], $threads[$tid], get_thread_link($tid));
            } else {
                $location_name = $lang->viewing_attachment;
            }
            break;
            // calendar.php functions
        // calendar.php functions
        case "calendar":
            $location_name = $lang->viewing_calendar;
            break;
        case "calendar_event":
            if (!empty($events[$user_activity['eid']])) {
                $location_name = $lang->sprintf($lang->viewing_event2, get_event_link($user_activity['eid']), $events[$user_activity['eid']]);
            } else {
                $location_name = $lang->viewing_event;
            }
            break;
        case "calendar_addevent":
            $location_name = $lang->adding_event;
            break;
        case "calendar_editevent":
            $location_name = $lang->editing_event;
            break;
        case "contact":
            $location_name = $lang->viewing_contact_us;
            break;
            // editpost.php functions
        // editpost.php functions
        case "editpost":
            $location_name = $lang->editing_post;
            break;
            // forumdisplay.php functions
        // forumdisplay.php functions
        case "forumdisplay":
            if (!empty($forums[$user_activity['fid']])) {
                if ($forums_linkto[$user_activity['fid']]) {
                    $location_name = $lang->sprintf($lang->forum_redirect_to, get_forum_link($user_activity['fid']), $forums[$user_activity['fid']]);
                } else {
                    $location_name = $lang->sprintf($lang->viewing_forum2, get_forum_link($user_activity['fid']), $forums[$user_activity['fid']]);
                }
            } else {
                $location_name = $lang->viewing_forum;
            }
            break;
            // index.php functions
        // index.php functions
        case "index":
            $location_name = $lang->sprintf($lang->viewing_index, $mybb->settings['bbname']);
            break;
            // managegroup.php functions
        // managegroup.php functions
        case "managegroup":
            $location_name = $lang->managing_group;
            break;
            // member.php functions
        // member.php functions
        case "member_activate":
            $location_name = $lang->activating_account;
            break;
        case "member_profile":
            if (!empty($usernames[$user_activity['uid']])) {
                $location_name = $lang->sprintf($lang->viewing_profile2, get_profile_link($user_activity['uid']), $usernames[$user_activity['uid']]);
            } else {
                $location_name = $lang->viewing_profile;
            }
            break;
        case "member_register":
            $location_name = $lang->registering;
            break;
        case "member":
        case "member_login":
            // Guest or member?
            if ($mybb->user['uid'] == 0) {
                $location_name = $lang->logging_in;
            } else {
                $location_name = $lang->logging_in_plain;
            }
            break;
        case "member_logout":
            $location_name = $lang->logging_out;
            break;
        case "member_emailuser":
            $location_name = $lang->emailing_user;
            break;
        case "member_rate":
            $location_name = $lang->rating_user;
            break;
        case "member_resendactivation":
            $location_name = $lang->member_resendactivation;
            break;
        case "member_lostpw":
            $location_name = $lang->member_lostpw;
            break;
            // memberlist.php functions
        // memberlist.php functions
        case "memberlist":
            $location_name = $lang->viewing_memberlist;
            break;
            // misc.php functions
        // misc.php functions
        case "misc_dstswitch":
            $location_name = $lang->changing_dst;
            break;
        case "misc_whoposted":
            if (!empty($threads[$user_activity['tid']])) {
                $location_name = $lang->sprintf($lang->viewing_whoposted2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']]);
            } else {
                $location_name = $lang->viewing_whoposted;
            }
            break;
        case "misc_markread":
            $location_name = $lang->sprintf($lang->marking_read, $mybb->post_code);
            break;
        case "misc_help":
            $location_name = $lang->viewing_helpdocs;
            break;
        case "misc_buddypopup":
            $location_name = $lang->viewing_buddylist;
            break;
        case "misc_smilies":
            $location_name = $lang->viewing_smilies;
            break;
        case "misc_syndication":
            $location_name = $lang->viewing_syndication;
            break;
        case "misc_imcenter":
            $location_name = $lang->viewing_imcenter;
            break;
            // modcp.php functions
        // modcp.php functions
        case "modcp_modlogs":
            $location_name = $lang->viewing_modlogs;
            break;
        case "modcp_announcements":
            $location_name = $lang->managing_announcements;
            break;
        case "modcp_finduser":
            $location_name = $lang->search_for_user;
            break;
        case "modcp_warninglogs":
            $location_name = $lang->managing_warninglogs;
            break;
        case "modcp_ipsearch":
            $location_name = $lang->searching_ips;
            break;
        case "modcp_report":
            $location_name = $lang->viewing_reports;
            break;
        case "modcp_new_announcement":
            $location_name = $lang->adding_announcement;
            break;
        case "modcp_delete_announcement":
            $location_name = $lang->deleting_announcement;
            break;
        case "modcp_edit_announcement":
            $location_name = $lang->editing_announcement;
            break;
        case "modcp_mod_queue":
            $location_name = $lang->managing_modqueue;
            break;
        case "modcp_editprofile":
            $location_name = $lang->editing_user_profiles;
            break;
        case "modcp_banning":
            $location_name = $lang->managing_bans;
            break;
        case "modcp":
            $location_name = $lang->viewing_modcp;
            break;
            // moderation.php functions
        // moderation.php functions
        case "moderation":
            $location_name = $lang->using_modtools;
            break;
            // newreply.php functions
        // newreply.php functions
        case "newreply":
            if (!empty($threads[$user_activity['tid']])) {
                $location_name = $lang->sprintf($lang->replying_thread2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']]);
            } else {
                $location_name = $lang->replying_thread;
            }
            break;
            // newthread.php functions
        // newthread.php functions
        case "newthread":
            if (!empty($forums[$user_activity['fid']])) {
                $location_name = $lang->sprintf($lang->posting_thread2, get_forum_link($user_activity['fid']), $forums[$user_activity['fid']]);
            } else {
                $location_name = $lang->posting_thread;
            }
            break;
            // online.php functions
        // online.php functions
        case "wol":
            $location_name = $lang->viewing_wol;
            break;
        case "woltoday":
            $location_name = $lang->viewing_woltoday;
            break;
            // polls.php functions
        // polls.php functions
        case "newpoll":
            $location_name = $lang->creating_poll;
            break;
        case "editpoll":
            $location_name = $lang->editing_poll;
            break;
        case "showresults":
            $location_name = $lang->viewing_pollresults;
            break;
        case "vote":
            $location_name = $lang->voting_poll;
            break;
            // printthread.php functions
        // printthread.php functions
        case "printthread":
            if (!empty($threads[$user_activity['tid']])) {
                $location_name = $lang->sprintf($lang->printing_thread2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']]);
            } else {
                $location_name = $lang->printing_thread;
            }
            break;
            // private.php functions
        // private.php functions
        case "private_send":
            $location_name = $lang->sending_pm;
            break;
        case "private_read":
            $location_name = $lang->reading_pm;
            break;
        case "private_folders":
            $location_name = $lang->editing_pmfolders;
            break;
        case "private":
            $location_name = $lang->using_pmsystem;
            break;
            /* Ratethread functions */
        /* Ratethread functions */
        case "ratethread":
            $location_name = $lang->rating_thread;
            break;
            // report.php functions
        // report.php functions
        case "report":
            $location_name = $lang->reporting_post;
            break;
            // reputation.php functions
        // reputation.php functions
        case "reputation":
            $location_name = $lang->sprintf($lang->giving_reputation, get_profile_link($user_activity['uid']), $usernames[$user_activity['uid']]);
            break;
        case "reputation_report":
            if (!empty($usernames[$user_activity['uid']])) {
                $location_name = $lang->sprintf($lang->viewing_reputation_report, "reputation.php?uid={$user_activity['uid']}", $usernames[$user_activity['uid']]);
            } else {
                $location_name = $lang->sprintf($lang->viewing_reputation_report2);
            }
            break;
            // search.php functions
        // search.php functions
        case "search":
            $location_name = $lang->sprintf($lang->searching_forum, $mybb->settings['bbname']);
            break;
            // showthread.php functions
        // showthread.php functions
        case "showthread":
            if (!empty($threads[$user_activity['tid']])) {
                $pagenote = '';
                $location_name = $lang->sprintf($lang->reading_thread2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']], $pagenote);
            } else {
                $location_name = $lang->reading_thread;
            }
            break;
        case "showpost":
            if (!empty($posts[$user_activity['pid']]) && !empty($threads[$posts[$user_activity['pid']]])) {
                $pagenote = '';
                $location_name = $lang->sprintf($lang->reading_thread2, get_thread_link($posts[$user_activity['pid']]), $threads[$posts[$user_activity['pid']]], $pagenote);
            } else {
                $location_name = $lang->reading_thread;
            }
            break;
            // showteam.php functions
        // showteam.php functions
        case "showteam":
            $location_name = $lang->viewing_team;
            break;
            // stats.php functions
        // stats.php functions
        case "stats":
            $location_name = $lang->viewing_stats;
            break;
            // usercp.php functions
        // usercp.php functions
        case "usercp_profile":
            $location_name = $lang->updating_profile;
            break;
        case "usercp_editlists":
            $location_name = $lang->managing_buddyignorelist;
            break;
        case "usercp_options":
            $location_name = $lang->updating_options;
            break;
        case "usercp_editsig":
            $location_name = $lang->editing_signature;
            break;
        case "usercp_avatar":
            $location_name = $lang->changing_avatar;
            break;
        case "usercp_subscriptions":
            $location_name = $lang->viewing_subscriptions;
            break;
        case "usercp_favorites":
            $location_name = $lang->viewing_favorites;
            break;
        case "usercp_notepad":
            $location_name = $lang->editing_pad;
            break;
        case "usercp_password":
            $location_name = $lang->editing_password;
            break;
        case "usercp":
            $location_name = $lang->user_cp;
            break;
        case "usercp2_favorites":
            $location_name = $lang->managing_favorites;
            break;
        case "usercp2_subscriptions":
            $location_name = $lang->managing_subscriptions;
            break;
        case "portal":
            $location_name = $lang->viewing_portal;
            break;
            // sendthread.php functions
        // sendthread.php functions
        case "sendthread":
            $location_name = $lang->sending_thread;
            break;
            // warnings.php functions
        // warnings.php functions
        case "warnings_revoke":
            $location_name = $lang->revoking_warning;
            break;
        case "warnings_warn":
            $location_name = $lang->warning_user;
            break;
        case "warnings_view":
            $location_name = $lang->viewing_warning;
            break;
        case "warnings":
            $location_name = $lang->managing_warnings;
            break;
    }
    $plugin_array = array('user_activity' => &$user_activity, 'location_name' => &$location_name);
    $plugins->run_hooks("build_friendly_wol_location_end", $plugin_array);
    if (isset($user_activity['nopermission']) && $user_activity['nopermission'] == 1) {
        $location_name = $lang->viewing_noperms;
    }
    if (!$location_name) {
        $location_name = $lang->sprintf($lang->unknown_location, $user_activity['location']);
    }
    return $location_name;
}
Example #4
0
/**
 * Generate the list of items for a sitemap.
 * This will be handed to google_seo_sitemap() to produce the XML output.
 *
 * @param string XML Sitemap URL scheme
 * @param string type of items to list in sitemap
 * @param int page number
 * @param int number of items per page
 * @return array List of items (in case of main index)
 */
function google_seo_sitemap_gen($scheme, $type, $page, $pagination)
{
    global $lang, $db, $mybb, $settings;
    global $google_seo_url_optimize;
    if (!$settings["google_seo_sitemap_{$type}"]) {
        return;
    }
    switch ($type) {
        case "forums":
            $table = 'forums';
            $idname = 'fid';
            $datename = 'lastpost';
            $getlink = 'get_forum_link';
            // Additional permission check.
            $unviewableforums = get_unviewable_forums();
            $inactiveforums = get_inactive_forums();
            if ($unviewableforums) {
                $condition[] = "fid NOT IN ({$unviewableforums})";
            }
            if ($inactiveforums) {
                $condition[] = "fid NOT IN ({$inactiveforums})";
            }
            // passwords already taken care of unviewable forums,
            // but linkto needs special treatment...
            $condition[] = "linkto=''";
            if ($condition) {
                $condition = implode(" AND ", $condition);
            }
            // Include pages?
            if ($settings['google_seo_sitemap_forums'] == 2) {
                $pagescount = ', threads AS pagescount';
                $perpage = $mybb->settings['threadsperpage'];
                if (!$perpage) {
                    $perpage = 20;
                }
            }
            break;
        case "threads":
            $table = 'threads';
            $idname = 'tid';
            $datename = 'lastpost';
            $getlink = 'get_thread_link';
            $condition = "visible>0 AND closed NOT LIKE 'moved|%'";
            // Additional permission check.
            $unviewableforums = get_unviewable_forums(true);
            $inactiveforums = get_inactive_forums();
            if ($unviewableforums) {
                $condition .= " AND fid NOT IN ({$unviewableforums})";
            }
            if ($inactiveforums) {
                $condition .= " AND fid NOT IN ({$inactiveforums})";
            }
            // Include pages?
            if ($settings['google_seo_sitemap_threads'] == 2) {
                $pagescount = ', replies+1 AS pagescount';
                $perpage = $settings['postsperpage'];
                if (!$perpage) {
                    $perpage = 20;
                }
            }
            break;
        case "users":
            if (!$mybb->usergroup['canviewprofiles']) {
                return;
            }
            $table = 'users';
            $idname = 'uid';
            $datename = 'regdate';
            $getlink = 'get_profile_link';
            $condition = '1=1';
            break;
        case "announcements":
            $table = 'announcements';
            $idname = 'aid';
            $datename = 'startdate';
            $getlink = 'get_announcement_link';
            $time = TIME_NOW;
            $condition = "startdate <= '{$time}' AND (enddate >= '{$time}' OR enddate='0')";
            // Additional permission check.
            $unviewableforums = get_unviewable_forums(true);
            $inactiveforums = get_inactive_forums();
            if ($unviewableforums) {
                $condition .= " AND fid NOT IN ({$unviewableforums})";
            }
            if ($inactiveforums) {
                $condition .= " AND fid NOT IN ({$inactiveforums})";
            }
            break;
        case "calendars":
            if ($mybb->settings['enablecalendar'] == 0 || $mybb->usergroup['canviewcalendar'] == 0) {
                return;
            }
            $table = 'calendars';
            $idname = 'cid';
            $datename = 'disporder';
            $getlink = 'get_calendar_link';
            $condition = '1=1';
            // Calendar permission check.
            $unviewablecalendars = google_seo_get_unviewable_calendars();
            if ($unviewablecalendars) {
                $condition = "cid NOT IN ({$unviewablecalendars})";
            }
            break;
        case "events":
            // Global permission check.
            if ($mybb->settings['enablecalendar'] == 0 || $mybb->usergroup['canviewcalendar'] == 0) {
                return;
            }
            $table = 'events';
            $idname = 'eid';
            $datename = 'dateline';
            $getlink = 'get_event_link';
            // Event specific permission check.
            $condition = "visible=1 AND private=0";
            // Calendar permission check.
            $unviewablecalendars = google_seo_get_unviewable_calendars();
            if ($unviewablecalendars) {
                $condition .= " AND cid NOT IN ({$unviewablecalendars})";
            }
            break;
        default:
            error($lang->googleseo_sitemap_pageinvalid);
    }
    if (!$page) {
        // Do a pagination index.
        $query = $db->simple_select($table, "MAX({$datename}) AS lastmod, FLOOR({$idname}/{$pagination}.0)+1 AS page", "{$condition} GROUP BY FLOOR({$idname}/{$pagination}.0)");
        $url = google_seo_expand($scheme, array('url' => $type));
        $url .= (strpos($url, '?') === false ? '?' : '&amp;') . 'page=';
        while ($row = $db->fetch_array($query)) {
            $row['loc'] = "{$url}{$row['page']}";
            $items[] = $row;
        }
        // Do not build a sitemap here. Instead return the items.
        // This way, items for all types can be collected for the main index page.
        return $items;
    }
    // Build the sitemap for this page.
    $min = ($page - 1) * $pagination;
    $max = $min + $pagination;
    $query = $db->simple_select($table, "{$idname},{$datename}{$pagescount}", "{$condition} AND {$idname} > {$min} AND {$idname} <= {$max}", array('order_by' => $idname));
    while ($row = $db->fetch_array($query)) {
        $id = $row[$idname];
        $ids[] = $id;
        $dates[$id] = $row[$datename];
        if ($pagescount) {
            $pages[$id] = (int) (($row['pagescount'] - 1) / $perpage) + 1;
        } else {
            $pages[$id] = 0;
        }
        // Google SEO URL Optimization:
        $type2id = array('users' => GOOGLE_SEO_USER, 'announcements' => GOOGLE_SEO_ANNOUNCEMENT, 'forums' => GOOGLE_SEO_FORUM, 'threads' => GOOGLE_SEO_THREAD, 'events' => GOOGLE_SEO_EVENT, 'calendars' => GOOGLE_SEO_CALENDAR);
        $google_seo_url_optimize[$type2id[$type]][$id] = 0;
    }
    if (!sizeof($ids)) {
        error($lang->googleseo_sitemap_emptyorinvalid);
    }
    foreach ($ids as $id) {
        $item = array();
        $item['loc'] = call_user_func($getlink, $id);
        if ($dates[$id]) {
            $item['lastmod'] = $dates[$id];
        }
        $items[] = $item;
        for ($p = 2; $p <= $pages[$id]; $p += 1) {
            $item = array();
            $item['loc'] = call_user_func($getlink, $id, $p);
            if ($dates[$id]) {
                $item['lastmod'] = $dates[$id];
            }
            // Give pages of items a lower priority.
            // TODO: Temporary solution until I make this a setting.
            $item['priority'] = '0.2';
            $items[] = $item;
        }
    }
    google_seo_sitemap("url", $items);
}
Example #5
0
 // Fetch the reputations which will be displayed on this page
 $query = $db->query("\n\t\tSELECT r.*, r.uid AS rated_uid, u.uid, u.username, u.reputation AS user_reputation, u.usergroup AS user_usergroup, u.displaygroup AS user_displaygroup\n\t\tFROM " . TABLE_PREFIX . "reputation r\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=r.adduid)\n\t\tWHERE r.uid='{$user['uid']}' {$conditions}\n\t\tORDER BY {$order}\n\t\tLIMIT {$start}, {$perpage}\n\t");
 // Gather a list of items that have post reputation
 $reputation_cache = $post_cache = $post_reputation = array();
 while ($reputation_vote = $db->fetch_array($query)) {
     $reputation_cache[] = $reputation_vote;
     // If this is a post, hold it and gather some information about it
     if ($reputation_vote['pid'] && !isset($post_cache[$reputation_vote['pid']])) {
         $post_cache[$reputation_vote['pid']] = $reputation_vote['pid'];
     }
 }
 if (!empty($post_cache)) {
     $pids = implode(',', $post_cache);
     $sql = array("p.pid IN ({$pids})");
     // get forums user cannot view
     $unviewable = get_unviewable_forums(true);
     if ($unviewable) {
         $sql[] = "p.fid NOT IN ({$unviewable})";
     }
     // get inactive forums
     $inactive = get_inactive_forums();
     if ($inactive) {
         $sql[] = "p.fid NOT IN ({$inactive})";
     }
     if (!$mybb->user['ismoderator']) {
         $sql[] = "p.visible='1'";
         $sql[] = "t.visible='1'";
     }
     $sql = implode(' AND ', $sql);
     $query = $db->query("\n\t\t\tSELECT p.pid, p.uid, p.fid, p.visible, p.message, t.tid, t.subject, t.visible AS thread_visible\n\t\t\tFROM " . TABLE_PREFIX . "posts p\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=p.tid)\n\t\t\tWHERE {$sql}\n\t\t");
     $forumpermissions = array();
function asb_rand_quote_get_quote($settings, $width)
{
    global $db, $mybb, $templates, $lang, $theme;
    if (!$lang->asb_addon) {
        $lang->load('asb_addon');
    }
    // get forums user cannot view
    $unviewable = get_unviewable_forums(true);
    if ($unviewable) {
        $unviewwhere = " AND p.fid NOT IN ({$unviewable})";
    }
    // get inactive forums
    $inactive = get_inactive_forums();
    if ($inactive) {
        $inactivewhere = " AND p.fid NOT IN ({$inactive})";
    }
    if ($settings['important_threads_only']) {
        $important_threads = ' AND NOT t.sticky=0';
    }
    // build the exclude conditions
    $show['fids'] = asb_build_id_list($settings['forum_show_list'], 'p.fid');
    $show['tids'] = asb_build_id_list($settings['thread_show_list'], 'p.tid');
    $hide['fids'] = asb_build_id_list($settings['forum_hide_list'], 'p.fid');
    $hide['tids'] = asb_build_id_list($settings['thread_hide_list'], 'p.tid');
    $where['show'] = asb_build_SQL_where($show, ' OR ');
    $where['hide'] = asb_build_SQL_where($hide, ' OR ', ' NOT ');
    $query_where = $important_threads . $unviewwhere . $inactivewhere . asb_build_SQL_where($where, ' AND ', ' AND ');
    $post_query = $db->query("\n\t\tSELECT\n\t\t\tp.pid, p.message, p.fid, p.tid, p.subject, p.uid,\n\t\t\tu.username, u.usergroup, u.displaygroup, u.avatar,\n\t\t\tt.sticky\n\t\tFROM {$db->table_prefix}posts p\n\t\tLEFT JOIN {$db->table_prefix}users u ON (u.uid=p.uid)\n\t\tLEFT JOIN {$db->table_prefix}threads t ON (t.tid=p.tid)\n\t\tWHERE\n\t\t\tp.visible='1'{$query_where}\n\t\tORDER BY\n\t\t\tRAND()\n\t\tLIMIT 1;");
    // if there was 1 . . .
    if ($db->num_rows($post_query) == 0) {
        return false;
    }
    $rand_post = $db->fetch_array($post_query);
    // build a post parser
    require_once MYBB_ROOT . 'inc/class_parser.php';
    $parser = new postParser();
    // we just need the text and smilies (we'll parse them after we check length)
    $pattern = "|[[\\/\\!]*?[^\\[\\]]*?]|si";
    $new_message = asb_strip_url(preg_replace($pattern, '$1', $rand_post['message']));
    // get some dimensions that make sense in relation to column width
    $asb_width = (int) $width;
    $asb_inner_size = $asb_width * 0.83;
    $avatar_size = (int) ($asb_inner_size / 5);
    $font_size = $asb_width / 4.5;
    $font_size = max(10, min(16, $font_size));
    $username_font_size = (int) ($font_size * 0.9);
    $title_font_size = (int) ($font_size * 0.65);
    $message_font_size = (int) $font_size;
    if (strlen($new_message) < $settings['min_length']) {
        if ($settings['default_text']) {
            $new_message = $settings['default_text'];
        } else {
            // nothing to show
            return false;
        }
    }
    if ($settings['max_length'] && strlen($new_message) > $settings['max_length']) {
        $new_message = substr($new_message, 0, $settings['max_length']) . ' . . .';
    }
    // set up the user name link so that it displays correctly for the display group of the user
    $plain_text_username = htmlspecialchars_uni($rand_post['username']);
    $username = format_name($plain_text_username, $rand_post['usergroup'], $rand_post['displaygroup']);
    $author_link = get_profile_link($rand_post['uid']);
    $post_link = get_post_link($rand_post['pid'], $rand_post['tid']) . '#pid' . $rand_post['pid'];
    $thread_link = get_thread_link($rand_post['tid']);
    // allow smilies, but kill
    $parser_options = array("allow_smilies" => 1);
    $new_message = str_replace(array('<br />', '/me'), array('', " * {$plain_text_username}"), $parser->parse_message($new_message . ' ', $parser_options));
    // if the user has an avatar then display it, otherwise force the default avatar.
    $avatar_filename = "{$theme['imgdir']}/default_avatar.gif";
    if ($rand_post['avatar'] != '') {
        $avatar_filename = $rand_post['avatar'];
    }
    $avatar_alt = $lang->sprintf($lang->asb_random_quote_users_profile, $plain_text_username);
    eval("\$read_more = \"" . $templates->get('asb_rand_quote_read_more') . "\";");
    if (my_strlen($rand_post['subject']) > 40) {
        $rand_post['subject'] = my_substr($rand_post['subject'], 0, 40) . ' . . .';
    }
    if (substr(strtolower($rand_post['subject']), 0, 3) == 're:') {
        $rand_post['subject'] = substr($rand_post['subject'], 3);
    }
    $rand_post['subject'] = htmlspecialchars_uni($parser->parse_badwords($rand_post['subject']));
    $thread_title_link = <<<EOF
<strong><a href="{$thread_link}" title="{$lang->asb_random_quotes_read_more_threadlink_title}"><span style="font-size: {$title_font_size}px;">{$rand_post['subject']}</span></a></strong>
EOF;
    // eval() the template
    eval("\$this_quote = \"" . $templates->get("asb_rand_quote_sidebox") . "\";");
    return $this_quote;
}
Example #7
0
function ps_GetUnviewable($name = "")
{
    global $mybb, $forum_cache;
    $unviewwhere = $comma = '';
    $name ? $name .= '.' : NULL;
    $unviewable = get_unviewable_forums();
    if ($mybb->settings['ps_ignoreforums']) {
        !is_array($forum_cache) ? cache_forums() : NULL;
        if (in_array($mybb->settings['ps_ignoreforums'], array(-1, 'all'))) {
            foreach ($forum_cache as $fid => $forum) {
                $ignoreforums[] = $forum['fid'];
            }
        } else {
            $ignoreforums = explode(',', $mybb->settings['ps_ignoreforums']);
        }
        if (count($ignoreforums)) {
            $unviewable ? $unviewable .= ',' : NULL;
            foreach ($ignoreforums as $fid) {
                $unviewable .= $comma . "'" . intval($fid) . "'";
                $comma = ',';
            }
        }
    }
    if ($unviewable) {
        $unviewwhere = "AND " . $name . "fid NOT IN (" . $unviewable . ")";
    }
    return array($unviewwhere, explode(',', $unviewable));
}
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;
}
Example #9
0
function tapatalk_fetch_wol_activity_end(&$user_activity)
{
    global $uid_list, $aid_list, $pid_list, $tid_list, $fid_list, $ann_list, $eid_list, $plugins, $user, $parameters;
    if ($user_activity['activity'] == 'unknown' && strpos($user_activity['location'], 'mobiquo') !== false) {
        //$user_activity['activity'] = 'tapatalk';
        $method = 'unknown';
        $path_arr = parse_url($user_activity['location']);
        $param = -2;
        $unviewableforums = get_unviewable_forums();
        if (!empty($path_arr['query'])) {
            $param_arr = explode('&amp;', $path_arr['query']);
            $method = str_replace('method=', '', $param_arr[0]);
            $param = str_replace('params=', '', $param_arr[1]);
        }
        switch ($method) {
            case 'get_config':
            case 'get_forum':
            case 'get_participated_forum':
            case 'login_forum':
            case 'get_forum_status':
            case 'get_topic':
                if (is_numeric($param)) {
                    $fid_list[] = $param;
                }
                $user_activity['activity'] = "forumdisplay";
                $user_activity['fid'] = $param;
                break;
            case 'logout_user':
                $user_activity['activity'] = "member_logout";
                break;
            case 'get_user_info':
                $user_activity['activity'] = "member_profile";
                break;
            case 'register':
                $user_activity['activity'] = "member_register";
                break;
            case 'forget_password':
                $user_activity['activity'] = "member_lostpw";
                break;
            case 'login':
                $user_activity['activity'] = "member_login";
                break;
            case 'get_online_users':
                $user_activity['activity'] = "wol";
                break;
            case 'get_user_topic':
            case 'get_user_reply_post':
                $user_activity['activity'] = "usercp";
                break;
            case 'new_topic':
                if (is_numeric($param)) {
                    $fid_list[] = $param;
                }
                $user_activity['activity'] = "newthread";
                $user_activity['fid'] = $param;
                break;
            case 'search':
            case 'search_topic':
            case 'search_post':
            case 'get_unread_topic':
            case 'get_participated_topic':
            case 'get_latest_topic':
                $user_activity['activity'] = "search";
                break;
            case 'get_quote_post':
            case 'reply_post':
                $user_activity['activity'] = "newreply";
                break;
            case 'get_thread':
                if (is_numeric($param)) {
                    $tid_list[] = $param;
                }
                $user_activity['activity'] = "showthread";
                $user_activity['tid'] = $param;
                break;
            case 'get_thread_by_post':
                if (is_numeric($param)) {
                    $pid_list[] = $param;
                    $user_activity['activity'] = "showpost";
                    $user_activity['pid'] = $param;
                }
                break;
            case 'create_message':
            case 'get_box_info':
            case 'get_box':
            case 'get_quote_pm':
            case 'delete_message':
            case 'mark_pm_unread':
                $user_activity['activity'] = "private";
                break;
            case 'get_message':
                $user_activity['activity'] = "private_read";
                break;
            default:
                if (strpos($method, 'm_') === 0) {
                    $user_activity['activity'] = "moderation";
                } else {
                    if (strstr($method, '_post')) {
                        $user_activity['activity'] = "showpost";
                    } else {
                        if (strpos($user_activity['location'], 'mobiquo') !== false) {
                            $user_activity['activity'] = "index";
                        }
                    }
                }
                break;
        }
    }
}
Example #10
0
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;
    }
}
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;
}
Example #12
0
function get_quote_post_func($xmlrpc_params)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups;
    require_once MYBB_ROOT . $mybb->settings['tapatalk_directory'] . '/emoji/emoji.class.php';
    $input = Tapatalk_Input::filterXmlInput(array('post_id' => Tapatalk_Input::STRING), $xmlrpc_params);
    $lang->load("newreply");
    $parser = new postParser();
    $pids = explode('-', $input['post_id']);
    $message = '';
    foreach ($pids as $pid) {
        $query = $db->simple_select("posts", "tid", "pid = '{$pid}'");
        if ($db->num_rows($query) == 0) {
            return xmlrespfalse("Invalid post");
        }
        $post = $db->fetch_array($query);
        $tid = $post['tid'];
        $options = array("limit" => 1);
        $query = $db->simple_select("threads", "*", "tid='" . $tid . "'");
        if ($db->num_rows($query) == 0) {
            return xmlrespfalse($lang->error_invalidthread);
        }
        $thread = $db->fetch_array($query);
        $fid = $thread['fid'];
        // Get forum info
        $forum = get_forum($fid);
        if (!$forum) {
            return xmlrespfalse($lang->error_invalidforum);
        }
        $forumpermissions = forum_permissions($fid);
        if ($thread['visible'] == 0 && !is_moderator($fid) || $thread['visible'] < 0) {
            return xmlrespfalse($lang->error_invalidthread);
        }
        if ($forum['open'] == 0 || $forum['type'] != "f") {
            return xmlrespfalse($lang->error_closedinvalidforum);
        }
        if ($mybb->user['uid'] < 1 || $forumpermissions['canview'] == 0 || $forumpermissions['canpostreplys'] == 0 || $mybb->user['suspendposting'] == 1) {
            return tt_no_permission();
        }
        if ($forumpermissions['canonlyviewthreads'] == 1 && $thread['uid'] != $mybb->user['uid']) {
            return tt_no_permission();
        }
        tt_check_forum_password($forum['fid']);
        // Check to see if the thread is closed, and if the user is a mod.
        if (!is_moderator($fid, "caneditposts")) {
            if ($thread['closed'] == 1) {
                return xmlrespfalse($lang->redirect_threadclosed);
            }
        }
        // Is the currently logged in user a moderator of this forum?
        if (is_moderator($fid)) {
            $ismod = true;
        } else {
            $ismod = false;
        }
        $unviewable_forums = get_unviewable_forums();
        if ($unviewable_forums) {
            $unviewable_forums = "AND t.fid NOT IN ({$unviewable_forums})";
        }
        if (is_moderator($fid)) {
            $visible_where = "AND p.visible != 2";
        } else {
            $visible_where = "AND p.visible > 0";
        }
        require_once MYBB_ROOT . "inc/functions_posting.php";
        $query = $db->query("\n\t\t\tSELECT p.subject, p.message, p.pid, p.tid, p.username, p.dateline, u.username AS userusername\n\t\t\tFROM " . TABLE_PREFIX . "posts p\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=p.tid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=p.uid)\n\t\t\tWHERE p.pid = {$pid} {$unviewable_forums} {$visible_where}\n\t\t");
        $load_all = intval($mybb->input['load_all_quotes']);
        if ($db->num_rows($query) == 0) {
            return xmlrespfalse("Invalid post");
        }
        $quoted_post = $db->fetch_array($query);
        // Only show messages for the current thread
        if ($quoted_post['tid'] == $tid || $load_all == 1) {
            // If this post was the post for which a quote button was clicked, set the subject
            if ($pid == $quoted_post['pid']) {
                $subject = preg_replace('#RE:\\s?#i', '', $quoted_post['subject']);
                $subject = "RE: " . $subject;
            }
            $message .= parse_quoted_message($quoted_post);
            $quoted_ids[] = $quoted_post['pid'];
        } else {
            ++$external_quotes;
        }
        if ($mybb->settings['maxquotedepth'] != '0') {
            $message = remove_message_quotes($message);
        }
    }
    $result = new xmlrpcval(array('post_id' => new xmlrpcval($pid), 'post_title' => new xmlrpcval($subject, 'base64'), 'post_content' => new xmlrpcval(tapatalkEmoji::covertNameToEmoji($message), 'base64')), 'struct');
    return new xmlrpcresp($result);
}