---------------------------------------------------------------------------------
<?php
/*****************************************************************************/
/* Recent.php */
/*****************************************************************************/
/* YaBB SE: Yet another Bulletin Board Splinter Edition */
/* Open-Source Project inspired by Zef Hemel ([email protected]) */
/* Software Version: YaBB SE 1.5.1 */
/* Software by: The YaBB SE Development Team */
/* ========================================================================= */
/* Software Distributed by: http://www.yabbse.org */
/* Copyright 2001-2003 by: http://www.lewismedia.com (Lewis Media) */
/* Support, News, Updates at: http://www.yabbse.org/community */
/* Inspired and Ported From: http://www.yabbforum.com */
/*****************************************************************************/
/* This program is free software; you may redistribute it and/or modify it */
/* under the terms of the provided license as published by Lewis Media. */
/* */
/* This program is distributed in the hope that it will be useful, but */
/* WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the provided */
/* license for more information. */
/* */
/* See license.txt for details of the YaBB SE license. The latest version */
/* of this license can be found at the distributor's site seen above. */
/*****************************************************************************/
$recentphpver = 'YaBB SE 1.5.1';
function LastPost()
{
global $settings, $scripturl, $txt, $censored, $recentsender, $db_prefix, $sc;
if (!isset($recentsender))
$recentsender='';
$request = mysql_query("
SELECT m.posterTime, m2.subject, m.ID_TOPIC, t.ID_BOARD, m.posterName, t.numReplies, t.ID_FIRST_MSG
FROM {$db_prefix}boards AS b, {$db_prefix}categories AS c
LEFT JOIN {$db_prefix}topics AS t ON (t.ID_TOPIC=b.ID_LAST_TOPIC)
LEFT JOIN {$db_prefix}messages AS m ON (m.ID_MSG=t.ID_LAST_MSG)
LEFT JOIN {$db_prefix}messages AS m2 ON (m2.ID_MSG=t.ID_FIRST_MSG)
WHERE c.ID_CAT=b.ID_CAT
AND (FIND_IN_SET('$settings[7]', c.memberGroups) != 0 OR c.memberGroups='' OR '$settings[7]' LIKE 'Administrator' OR '$settings[7]' LIKE 'Global Moderator')
ORDER BY m.posterTime DESC
LIMIT 1;") or database_error(__FILE__, __LINE__);
if (mysql_num_rows($request) == 0)
return;
$row = mysql_fetch_array($request);
CensorTxt($row['subject']);
if ($recentsender == 'admin')
{
$row['subject'] = ((strlen(un_html_entities($row['subject']))>25) ? (htmlspecialchars(substr(un_html_entities($row['subject']), 0, 22)) . "...") : $row['subject']);
$post = "\"<a href=\"$scripturl?board=$row[ID_BOARD];action=display;threadid=$row[ID_TOPIC];start=new\">$row[subject]</a>\" (" . timeformat($row['posterTime']) . ")\n";
}
else
{
$post = "$txt[234] \"<a href=\"$scripturl?board=$row[ID_BOARD];action=display;threadid=$row[ID_TOPIC];start=new\">$row[subject]</a>\" $txt[235] (" . timeformat($row['posterTime']) . ")<br />\n";
}
echo $post;
}
function RecentPosts()
{
global $settings, $txt, $yytitle, $censored, $scripturl, $enable_ubbc, $enable_notification, $menusep, $db_prefix;
global $cgi, $img, $color, $imagesdir, $realNames, $sc;
$display = 10;
// in order to optimize speed, this query gets the ($display * 4)
// latest messageID's. guessing that that will be enough to cover
// ($display) topics a user is allowed to see.
$request = mysql_query("
SELECT ID_MSG
FROM {$db_prefix}messages AS m
WHERE 1
ORDER BY posterTime DESC
LIMIT 0, " . ($display * 4)) or database_error(__FILE__, __LINE__);
$messages = array();
while ($row = mysql_fetch_array($request))
$messages[] = $row['ID_MSG'];
$yytitle = $txt[214];
template_header();
if (count($messages))
{
$request = mysql_query("
SELECT m.smiliesEnabled, m.posterTime, m.ID_MSG, m.subject, m.body, m.ID_TOPIC, t.ID_BOARD, b.name AS bname, c.name AS cname, t.numReplies, m.ID_MEMBER, m2.ID_MEMBER AS ID_FIRST_MEMBER, m.posterName, m2.posterName AS firstPosterName, IFNULL(mem.realName, m.posterName) AS posterDisplayName, IFNULL(mem2.realName, m2.posterName) AS firstPosterDisplayName
FROM {$db_prefix}messages AS m, {$db_prefix}messages AS m2, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}categories AS c
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER=m.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS mem2 ON (mem2.ID_MEMBER=m2.ID_MEMBER)
WHERE m.ID_MSG IN (" . implode(',', $messages) . ")
AND m2.ID_MSG=t.ID_FIRST_MSG
AND t.ID_TOPIC=m.ID_TOPIC
AND b.ID_BOARD=t.ID_BOARD
AND c.ID_CAT=b.ID_CAT
AND (FIND_IN_SET('$settings[7]', c.memberGroups) != 0 OR c.memberGroups='' OR '$settings[7]'='Administrator' OR '$settings[7]'='Global Moderator')
ORDER BY m.posterTime DESC
LIMIT 0, $display") or database_error(__FILE__, __LINE__);
$counter = 0;
while ($row = mysql_fetch_array($request))
{
$counter ++;
if ($row['ID_MEMBER'] != '-1')
{
$euser=urlencode($row['posterName']);
$row['posterName'] = "<a href=\"$scripturl?action=viewprofile;user=$euser\">$row[posterDisplayName]</a>";
}
if ($row['ID_FIRST_MEMBER'] != '-1')
{
$euser=urlencode($row[firstPosterName]);
$row['firstPosterName'] = "<a href=\"$scripturl?action=viewprofile;user=$euser\">$row[firstPosterDisplayName]</a>";
}
$message = $row['body'];
CensorTxt($message);
CensorTxt($row['subject']);
if ($enable_ubbc)
$message = DoUBBC($message, $row['smiliesEnabled']);
if ($enable_notification)
$notify = "$menusep<a href=\"$scripturl?board=$row[ID_BOARD];action=notify;threadid=$row[ID_TOPIC];start=$row[numReplies]\">$img[notify_sm]</a>";
$row['posterTime'] = timeformat($row['posterTime']);
global $settings, $scripturl, $txt, $censored, $recentsender, $db_prefix, $post, $dummy;
$showlatestcount = 5;
if (!isset($recentsender))
$recentsender = '';
// in order to optimize speed, this query gets the ($showlatestcount * 4)
// latest messageID's. guessing that that will be enough to cover
// ($showlatestcount) topics a user is allowed to see.
$request = mysql_query("
SELECT m.ID_MSG
FROM {$db_prefix}messages AS m
ORDER BY m.posterTime DESC
LIMIT 0, " . ($showlatestcount * 4)) or database_error(__FILE__, __LINE__);
$messages = array();
while ($row = mysql_fetch_array($request))
$messages[] = $row['ID_MSG'];
if (count($messages))
{
$request = mysql_query("
SELECT m.ID_MSG, m.posterTime, m.subject, m.ID_TOPIC, m.posterName, m.ID_MEMBER, IFNULL(mem.realName, m.posterName) AS posterDisplayName, t.numReplies, t.ID_BOARD, t.ID_FIRST_MSG, b.name AS bName
FROM {$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}categories AS c
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER=m.ID_MEMBER)
WHERE m.ID_MSG IN (" . implode(',', $messages) . ")
AND t.ID_TOPIC=m.ID_TOPIC
AND b.ID_BOARD=t.ID_BOARD
AND c.ID_CAT=b.ID_CAT
AND (FIND_IN_SET('$settings[7]', c.memberGroups) != 0 OR c.memberGroups='' OR '$settings[7]' LIKE 'Administrator' OR '$settings[7]' LIKE 'Global Moderator')
ORDER BY m.posterTime DESC
LIMIT 0, $showlatestcount;") or database_error(__FILE__, __LINE__);
if (mysql_num_rows($request) > 0)
{
$post = '<table width="100%" border="0">';
while ($row = mysql_fetch_array($request))
{
$post .= '<tr>';