eval("\$information .= \"" . $templates->get("modcp_modlogs_result_forum") . "\";"); } if ($logitem['psubject']) { $logitem['psubject'] = htmlspecialchars_uni($logitem['psubject']); $logitem['post'] = get_post_link($logitem['pid']); eval("\$information .= \"" . $templates->get("modcp_modlogs_result_post") . "\";"); } // Edited a user or managed announcement? if (!$logitem['tsubject'] || !$logitem['fname'] || !$logitem['psubject']) { $data = my_unserialize($logitem['data']); if ($data['uid']) { $information = $lang->sprintf($lang->edited_user_info, htmlspecialchars_uni($data['username']), get_profile_link($data['uid'])); } if ($data['aid']) { $data['subject'] = htmlspecialchars_uni($data['subject']); $data['announcement'] = get_announcement_link($data['aid']); eval("\$information .= \"" . $templates->get("modcp_modlogs_result_announcement") . "\";"); } } eval("\$modlogresults .= \"" . $templates->get("modcp_modlogs_result") . "\";"); } if (!$modlogresults) { eval("\$modlogresults = \"" . $templates->get("modcp_modlogs_nologs") . "\";"); } eval("\$latestfivemodactions = \"" . $templates->get("modcp_latestfivemodactions") . "\";"); } $query = $db->query("\n\t\tSELECT b.*, a.username AS adminuser, u.username\n\t\tFROM " . TABLE_PREFIX . "banned b\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (b.uid=u.uid)\n\t\tLEFT JOIN " . TABLE_PREFIX . "users a ON (b.admin=a.uid)\n\t\tWHERE b.bantime != '---' AND b.bantime != 'perm'\n\t\tORDER BY lifted ASC\n\t\tLIMIT 5\n\t"); $banned_cache = array(); while ($banned = $db->fetch_array($query)) { $banned['remaining'] = $banned['lifted'] - TIME_NOW; $banned_cache[$banned['remaining'] . $banned['uid']] = $banned;
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); }
/** * 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; }
$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']); if ($mybb->settings['allowthreadratings'] != 0 && $foruminfo['allowtratings'] != 0 && $fpermissions['canviewthreads'] != 0) { eval("\$rating = \"" . $templates->get("forumdisplay_announcement_rating") . "\";"); $lpbackground = "trow2"; } else { $rating = ''; $lpbackground = "trow1"; } if ($ismod) { eval("\$modann = \"" . $templates->get("forumdisplay_announcements_announcement_modbit") . "\";"); } else { $modann = '';
$trow = alt_trow(); $username = format_name($logitem['username'], $logitem['usergroup'], $logitem['displaygroup']); $logitem['profilelink'] = build_profile_link($username, $logitem['uid'], "_blank"); if ($logitem['tsubject']) { $information = "<strong>{$lang->thread}</strong> <a href=\"../" . get_thread_link($logitem['tid']) . "\" target=\"_blank\">" . htmlspecialchars_uni($logitem['tsubject']) . "</a><br />"; } if ($logitem['fname']) { $information .= "<strong>{$lang->forum}</strong> <a href=\"../" . get_forum_link($logitem['fid']) . "\" target=\"_blank\">" . htmlspecialchars_uni($logitem['fname']) . "</a><br />"; } if (!$logitem['tsubject'] || !$logitem['fname']) { $data = unserialize($logitem['data']); if ($data['uid']) { $information = "<strong>{$lang->user_info}</strong> <a href=\"../" . get_profile_link($data['uid']) . "\" target=\"_blank\">" . htmlspecialchars_uni($data['username']) . "</a>"; } if ($data['aid']) { $information = "<strong>{$lang->announcement}</strong> <a href=\"../" . get_announcement_link($data['aid']) . "\" target=\"_blank\">" . htmlspecialchars_uni($data['subject']) . "</a>"; } } $table->construct_cell($logitem['profilelink']); $table->construct_cell($logitem['dateline'], array("class" => "align_center")); $table->construct_cell($logitem['action'], array("class" => "align_center")); $table->construct_cell($information); $table->construct_cell($logitem['ipaddress'], array("class" => "align_center")); $table->construct_row(); } if ($table->num_rows() == 0) { $table->construct_cell($lang->no_modlogs, array("colspan" => "5")); $table->construct_row(); } $table->output($lang->mod_logs); // Do we need to construct the pagination?
$query = $db->simple_select("forums", "*", "fid='{$id}' AND active!=0 AND password=''"); $forum = $db->fetch_array($query); if (!$forum['fid']) { $action = "404"; } } elseif ($action != 'index') { $action = "404"; } } // Define the full MyBB version location of this page. if ($action == "thread") { define('MYBB_LOCATION', get_thread_link($id)); } elseif ($action == "forum") { define('MYBB_LOCATION', get_forum_link($id)); } elseif ($action == "announcement") { define('MYBB_LOCATION', get_announcement_link($id)); } else { define('MYBB_LOCATION', INDEX_URL); } // Initialise session $session = new session(); $session->init(); if (!$mybb->settings['bblanguage']) { $mybb->settings['bblanguage'] = "english"; } $lang->set_language($mybb->settings['bblanguage']); // Load global language phrases $lang->load("global"); $lang->load("messages"); $lang->load("archive"); // Draw up the basic part of our naviagation
/** * Generate meta tags for an announcement. * * @param int Announcement-ID */ function google_seo_meta_announcement($post) { global $settings, $aid; // Canonical: if ($settings['google_seo_meta_canonical'] && $aid > 0) { google_seo_meta_canonical(get_announcement_link($aid)); } // Description: if ($post) { google_seo_meta_description($post['message']); } }
/** * Redirect if necessary. * */ function google_seo_redirect_hook() { global $db, $mybb, $settings, $plugins, $google_seo_redirect; if ($mybb->request_method == "post") { // Never touch posts. return; } // Build the target URL we should be at: switch (THIS_SCRIPT) { case 'forumdisplay.php': $fid = (int) $mybb->input['fid']; $page = (int) $mybb->input['page']; if ($fid) { // forum as index tweak if ($fid == $settings['google_seo_tweak_index_fid']) { $target = ""; if ($page > 1) { $target = "?page={$page}"; } } else { $target = get_forum_link($fid, $page); } $kill['fid'] = ''; $kill['page'] = ''; $kill['google_seo_forum'] = ''; $kill['google_seo'] = ''; } break; case 'showthread.php': // pid overrules tid, so we must check pid first, // even at the cost of an additional query. if ((int) $mybb->input['pid']) { $tid = google_seo_tid((int) $mybb->input['pid'], (int) $mybb->input['tid'], $settings['google_seo_redirect_posts']); $target = get_post_link((int) $mybb->input['pid'], $tid); $kill['pid'] = ''; $kill['tid'] = ''; $kill['google_seo_thread'] = ''; $kill['google_seo'] = ''; } else { if ((int) $mybb->input['tid']) { $target = get_thread_link((int) $mybb->input['tid'], (int) $mybb->input['page'], (string) $mybb->input['action']); $kill['tid'] = ''; $kill['action'] = ''; $kill['google_seo_thread'] = ''; $kill['google_seo'] = ''; if ($mybb->input['page'] != 'last') { $kill['page'] = ''; } } } break; case 'announcements.php': if ((int) $mybb->input['aid']) { $target = get_announcement_link((int) $mybb->input['aid']); $kill['aid'] = ''; $kill['google_seo_announcement'] = ''; $kill['google_seo'] = ''; } break; case 'member.php': if ((int) $mybb->input['uid']) { if ($settings['google_seo_redirect_litespeed'] && $mybb->input['action'] != 'profile') { // Work around rewrite bug in LiteSpeed (double action conflict). break; } $target = get_profile_link((int) $mybb->input['uid']); $kill['uid'] = ''; $kill['google_seo_user'] = ''; $kill['google_seo'] = ''; if ($mybb->input['action'] == 'profile') { $kill['action'] = ''; } } break; case 'calendar.php': if ((int) $mybb->input['eid']) { if ($settings['google_seo_redirect_litespeed'] && $mybb->input['action'] != 'profile') { // Work around rewrite bug in LiteSpeed (double action conflict). break; } $target = get_event_link((int) $mybb->input['eid']); $kill['eid'] = ''; $kill['google_seo_event'] = ''; $kill['google_seo'] = ''; if ($mybb->input['action'] == 'event') { $kill['action'] = ''; } } else { if (!(int) $mybb->input['calendar']) { // Special case: Default calendar. // Code taken from calendar.php $query = $db->simple_select("calendars", "cid", "", array('order_by' => 'disporder', 'limit' => 1)); $cid = $db->fetch_field($query, "cid"); $mybb->input['calendar'] = $cid; } if ($mybb->input['action'] == "weekview") { $target = get_calendar_week_link((int) $mybb->input['calendar'], (int) str_replace('n', '-', $mybb->input['week'])); $kill['calendar'] = ''; $kill['week'] = ''; $kill['action'] = ''; $kill['google_seo_calendar'] = ''; $kill['google_seo'] = ''; } else { $target = get_calendar_link((int) $mybb->input['calendar'], (int) $mybb->input['year'], (int) $mybb->input['month'], (int) $mybb->input['day']); $kill['calendar'] = ''; $kill['year'] = ''; $kill['month'] = ''; $kill['day'] = ''; $kill['google_seo_calendar'] = ''; $kill['google_seo'] = ''; } } break; } // Verify that we are already at the target. if (isset($target)) { $target = $settings['bburl'] . '/' . urldecode($target); $current = google_seo_redirect_current_url(); // Not identical (although it may only be the query string). if ($current != $target) { // Parse current and target $target_parse = explode("?", $target, 2); $current_parse = explode("?", $current, 2); // Location $location_target = $target_parse[0]; $location_current = $current_parse[0]; // Fix broken query strings (e.g. search.php) $broken_query = preg_replace("/\\?([^&?=]+)([=&])/u", '&$1$2', $current_parse[1]); if ($current_parse[1] != $broken_query) { $change = 1; $current_parse[2] = $current_parse[1]; $current_parse[1] = $broken_query; } // Query $current_dynamic = google_seo_dynamic('?' . $current_parse[1]); $target_dynamic = google_seo_dynamic('?' . $target_parse[1]); parse_str(htmlspecialchars_decode($target_parse[1]), $query_target); parse_str($current_parse[1], $query_current); if (@get_magic_quotes_gpc()) { // Dear PHP, I don't need magic, thank you very much. $mybb->strip_slashes_array($query_target); $mybb->strip_slashes_array($query_current); } $query = $query_current; // Kill query string elements that already are part of the URL. if (!$query[$target_dynamic]) { unset($query[$target_dynamic]); unset($query_current[$target_dynamic]); unset($query_target[$target_dynamic]); } if (!$query[$current_dynamic]) { unset($query[$current_dynamic]); unset($query_current[$current_dynamic]); unset($query_target[$current_dynamic]); } foreach ($kill as $k => $v) { unset($query[$k]); } // Final query, current parameters retained $query = array_merge($query_target, $query); if (count($query) != count($query_current)) { $change = 2; } else { if ($current_dynamic != $target_dynamic) { $change = 3; } else { foreach ($query as $k => $v) { if ($query_current[$k] != $v) { $change = 4; } } } } // Definitely not identical? if ($change || $location_target != $location_current) { // Check if redirect debugging is enabled. if ($settings['google_seo_redirect_debug'] && $mybb->usergroup['cancp'] == 1) { if ($query['google_seo_redirect']) { // print out information about this redirect and return header("Content-type: text/html; charset=UTF-8"); echo "<pre style=\"text-align: left\">"; echo "Google SEO Redirect Debug Information:\n"; echo "!!! WARNING: This may contain cookie authentication data. Don't post debug info in public. !!!\n"; echo htmlspecialchars(print_r(array('THIS_SCRIPT' => THIS_SCRIPT, '_SERVER' => array_merge($_SERVER, array('HTTP_COOKIE' => '')), 'mybb->input' => $mybb->input, 'kill' => $kill, 'target' => $target, 'current' => $current, 'target_parse' => $target_parse, 'current_parse' => $current_parse, 'target_dynamic' => $target_dynamic, 'current_dynamic' => $current_dynamic, 'location_target' => $location_target, 'location_current' => $location_current, 'broken_query' => $broken_query, 'change' => $change, 'query_target' => $query_target, 'query_current' => $query_current, 'query' => $query), true), ENT_COMPAT, "UTF-8"); echo "</pre>"; return; } else { $query['google_seo_redirect'] = "debug"; } } // Redirect but retain query. if ($target_dynamic) { $querystr[] = google_seo_encode($target_dynamic); } foreach ($query as $k => $v) { $querystr[] = urlencode($k) . "=" . urlencode($v); } $location_target = google_seo_encode($location_target); if (sizeof($querystr)) { $location_target .= "?" . implode("&", $querystr); } $google_seo_redirect = $location_target; if ($settings['google_seo_redirect_permission'] && THIS_SCRIPT != "member.php") { // Leave permission checks to the current page. // Add hooks to issue redirect later on. $plugins->add_hook("forumdisplay_end", "google_seo_redirect_header", 2); $plugins->add_hook("postbit", "google_seo_redirect_header", 2); $plugins->add_hook("postbit_announcement", "google_seo_redirect_header", 2); $plugins->add_hook("calendar_editevent_end", "google_seo_redirect_header", 2); $plugins->add_hook("calendar_event_end", "google_seo_redirect_header", 2); $plugins->add_hook("calendar_end", "google_seo_redirect_header", 2); $plugins->add_hook("pre_output_page", "google_seo_redirect_header", 2); // Except on error. $plugins->add_hook("error", "google_seo_redirect_remove_hooks", 2); $plugins->add_hook("no_permission", "google_seo_redirect_remove_hooks", 2); } else { google_seo_redirect_header(); } } } } }