News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Letzte Beiträge auslesen

Started by E.T., July 28, 2004, 09:26:26 AM

Previous topic - Next topic

E.T.

Hallo,

ich möchte letzte Forum-Einträge aus einem bestimmten Board auf meiner Seite darstellen. Das ging bei YABBSE mit einer modifizierten SSI, glaube ich. Ist das mit SMF möglich?

mediman

Ja, das geht. Da hat sich im Grunde nix geändert.

mediman
My Projects: http://ticker-oase.de 
Please do not PM me with support requests.

andrea


Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



E.T.

Ich meinte nicht die letzten Beiträge insgesamt, sondern aus einem bestimmten Board. D.h. nicht einfach <?php recentTopics(); ?>, sondern <?php recentTopics(x); ?>, wobei x für ein bestimmtes Board im Forum steht.

mediman

Das modifizieren der SSI ist beim SMF nicht anders zu handhaben, als beim YaBB SE!

mediman
My Projects: http://ticker-oase.de 
Please do not PM me with support requests.

E.T.

Die Frage ist nicht, ob es anders ist oder nicht, sondern, ob es eine modifizierte SSI-Datei zum Runterladen gibt!

Ich kenne mich mit Programmieren schlecht aus. Wenn ich euch aber richtig verstanden habe, nehme ich dann dieselbe SSI-Datei, von der die Rede war und packe sie ins neue SMF-Verzeichnis. Wenn ich das jedoch tue, kriege ich die Meldung: Hacking attempt...

Anbei noch mal die modifizierte SSI-Datei zum Auslesen bestimmter Board bei YABBSE. (Damit wir uns richtig verstehen, worum es geht)

<?php
/*****************************************************************************/
/* SSI.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.        */
/*****************************************************************************/

$ssiphpver 'YaBB SE 1.5.1';

/*******************************   Settings   ********************************/
$full_yabbse_path '.'; // if in same folder as yabb board can be left
// as '.'
$num_recentTopics '10'; // number of topics to display in list of
// recent topics
$num_topBoards '10'; // number of boards to display in board list
$num_topicsViews '10'; // number of topics to show in list of topics
// sorted by number of views
$num_topicsReplies '10'; // number of topics to show in list of topics
// sorted by number of replies
$logOnlinePresence false; // When showing whosOnline() should the user
// requesting the page also be shown as online?
$menuBarStyle '0'; // 0: Automatically determine menu style using
//    forum settings (default)
// 1: Use text menu
// 2: Use image menu
/*****************************************************************************/

include_once ($full_yabbse_path '/Settings.php');
$dbcon mysql_connect($db_server$db_user$db_passwd);
mysql_select_db($db_name);
chdir($boarddir);

include_once (
$sourcedir '/Errors.php');
include_once (
$sourcedir '/Subs.php');
include_once (
$sourcedir '/Load.php');

/* ### Log this click ### */
ClickLog();

/* ### Load the user's cookie (or set to guest) ### */
LoadCookie();

/* ### Load user settings ### */
LoadUserSettings();

if (
function_exists('session_start'))
{
session_start();
$sc session_id();
}
else
$sc '';

// Load modsettings
$modSettings = array();
$request mysql_query("SELECT variable,value FROM {$db_prefix}settings WHERE (variable != 'agreement')") or database_error(__FILE____LINE__);
while (
$row mysql_fetch_array($request))
$modSettings[$row['variable']] = $row['value'];
$chklngfile $chklngfile2 $settings[23];

// Load language file
$MenuType = ($menuBarStyle == '0' $MenuType $menuBarStyle);
if (
$modSettings['userLanguage'] == 1)
{
if ($chklngfile == Null)
include_once($language);
else
include_once($chklngfile2);
}
else
include_once($language);

//Let's say the headers are always done on any call to SSI functions.
$yyheaderdone 1;
$yycopyin 1;

$types_to_register = array('GET''POST''COOKIE''SESSION''SERVER');
foreach (
$types_to_register as $type)
{
$arr = @${'HTTP_' $type '_VARS'};
if (@count($arr) > 0)
extract($arrEXTR_OVERWRITE);
}

if (
$function == 'topPoster' || $function == 'recentTopics' || $function == 'whosOnline' || $function == 'welcome' || $function == 'menubar' || $function == 'logout' || $function == 'login' || $function == 'topBoards' || $function == 'topTopicsViews' || $function == 'topTopicsReplies' || $function == 'latestMember' || $function == 'boardStats')
{
$function(); // Execute Function
exit;
}


/* Display a welcome message like:
Hey, <username>, you have 37 messages, 0 are new.*/

function welcome()
{
global $username,$txt,$cgi,$db_prefix,$realname$ID_MEMBER;


if ($username != 'Guest')
{
$request mysql_query("SELECT COUNT(*), readBy FROM {$db_prefix}instant_messages WHERE (ID_MEMBER_TO=$ID_MEMBER AND deletedBy != 1) GROUP BY readBy") or database_error(__FILE____LINE__);

if (mysql_num_rows($request) == 0)
$munred $mnum 0;
elseif (mysql_num_rows($request) == 1)
{
list($mnum$readBy) = mysql_fetch_array($request);
if ($readBy == 0)
$munred $mnum;
else
$munred 0;
}
else
{
list($munred$dummy) = mysql_fetch_row($request);
list($mnum$dummy) = mysql_fetch_row($request);
$mnum += $munred;
}

$isare = ($munred == '1' $txt['newmessages0'] : $txt['newmessages1']);
$messages = ($mnum == '1' $txt[471] : $txt[153]);

$yyim "$txt[152] <a href=\"$cgi;action=im\">$mnum $messages</a>$txt[newmessages4] $munred $isare $txt[newmessages2].";
}

$tmp = ($realname == '' $username $realname);
$yyuname = ($username == 'Guest' "$txt[248] <b>$txt[28]</b>. $txt[249] <a href=\"$cgi;action=login\">$txt[34]</a> $txt[377] <a href=\"$cgi;action=register\">$txt[97]</a>." "$txt[247] <b>$tmp</b>, ");
echo $yyuname $yyim;
}


/* Display a menubar bar like the one on top of the forum */

function menubar()
{
global $scripturl$txt$menusep$img$settings$username$enable_notification$cgi$helpfile;

$yymenu "<a href=\"$scripturl\">$img[home]</a>$menusep<a href=\"$helpfile\" target=_blank>$img[help]</a>$menusep<a href=\"$cgi;action=search\">$img[search]</a>";
if($settings[7] == 'Administrator')
$yymenu .= $menusep "<a href=\"$cgi;action=admin\">$img[admin]</a>";
if($username == 'Guest')
$yymenu .= $menusep "<a href=\"$cgi;action=login\">$img[login]</a>$menusep<a href=\"$cgi;action=register\">$img[register]</a>";
else
{
$euser urlencode($username);
$yymenu .= "$menusep<a href=\"$cgi;action=profile;user=$euser\">$img[profile]</a>";
if ($enable_notification)
$yymenu .= "$menusep<a href=\"$cgi;action=shownotify\">$img[notification]</a>";
if ($modSettings['cal_enabled'] == 1)
$yymenu .= "$menusep<a href=\"$scripturl?action=calendar\">$img[calendar]</a>";
$yymenu .= "$menusep<a href=\"$cgi;action=logout;sesc=" session_id() . "\">$img[logout]</a>";
}
echo $yymenu;
}

/* Show the logout link if the user is logged in */

function logout()
{
global $username$txt$cgi$db_prefix$realname;

$tmp = ($realname == '' $username $realname);
if($username != 'Guest')
$yylogout "<a href=\"$cgi;action=logout;sesc=" session_id() . "\">$txt[108]</a>";
echo $yylogout;
}


/* Show a list of topics, the most recent first */

function recentTopics ($boardid=0)
{
global $settings$scripturl$txt$censored$db_prefix$num_recentTopics$username$img$ID_MEMBER$cgi;

//Limit recent topics to 24 hours. Uncomment the following line for more speed
//$timeLimit = 24 * 60 * 60;
$request mysql_query("
SELECT m.ID_MSG
FROM 
{$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b,{$db_prefix}categories AS c
WHERE t.ID_TOPIC=m.ID_TOPIC
AND b.ID_BOARD=t.ID_BOARD
AND c.ID_CAT=b.ID_CAT
"
.(($boardid<>0) ? "AND b.ID_BOARD=$boardid " '')."
AND (FIND_IN_SET('
$settings[7]', c.memberGroups) != 0 OR c.memberGroups='' OR '$settings[7]' LIKE 'Administrator' OR '$settings[7]' LIKE 'Global Moderator')
. ($timeLimit 'AND m.posterTime>' . (time() - $timeLimit) : '') . "
ORDER BY posterTime DESC
LIMIT 0, 
$num_recentTopics;") 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.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, IFNULL(lt.logTime, 0) AS isRead, IFNULL(lmr.logTime, 0) AS isMarkedRead
FROM 
{$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards as b
LEFT JOIN 
{$db_prefix}members AS mem ON (mem.ID_MEMBER=m.ID_MEMBER)
LEFT JOIN 
{$db_prefix}log_topics AS lt ON (lt.ID_TOPIC=t.ID_TOPIC AND lt.ID_MEMBER=$ID_MEMBER)
LEFT JOIN 
{$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD=t.ID_BOARD AND lmr.ID_MEMBER=$ID_MEMBER)
WHERE m.ID_MSG IN (" 
implode(','$messages) . ")
AND t.ID_TOPIC=m.ID_TOPIC
AND b.ID_BOARD=t.ID_BOARD
ORDER BY m.posterTime DESC;"
) or database_error(__FILE____LINE__);

if (mysql_num_rows($request) > 0)
{
$post '<table border="0">';

while ($row mysql_fetch_array($request))
{
$new = ($row['isRead'] >= $row['posterTime'] || $row['isMarkedRead'] >= $row['posterTime'] ? false true);
if (!$new || $username == 'Guest')
$new '';
else
$new '<a href="' $cgi $row['ID_BOARD'] . ';action=display;threadid=' $row['ID_TOPIC'] . ';start=new">' $img['new'] . '</a>';

$post .= '<tr>';

if ($row['ID_MEMBER'] != -1)
{
$euser urlencode($row['posterName']);
$dummy "<a href=\"$scripturl?action=viewprofile;user=$euser\">$row[posterDisplayName]</a>";
}
else
$dummy $row['posterName'];

$post .= '





<td valign="top">
<font size="1">
<a href="' 
$cgi $row['ID_BOARD'] . ';action=display;threadid=' $row['ID_TOPIC'] . ';start=' $row['numReplies'] . ';boardseen=1">' $row['subject'] . '</a> ' $txt[525] . ' ' $dummy ' ' $new '
</font>
</td>
<td align="right" nowrap="nowrap">
<font size="1">
timeformat($row['posterTime']) . '
</font>
</td>



</tr>'
;
}

$post .= '</table>';
}
else
$post '---';
}
else
$post '---';

CensorTxt($post);

echo $post;

foreach ($censored as $tmpa => $tmpb)
$thepost str_replace($tmpa,$tmpb,$thepost );

echo $thepost;
}

/* Show the user with the highest number of posts */

function topPoster()
{
global $db_prefix,$scripturl;

ob_end_clean();
$request mysql_query("SELECT memberName,realName FROM {$db_prefix}members ORDER BY posts DESC LIMIT 1") or database_error(__FILE____LINE__);
$row mysql_fetch_array($request);
echo "<a href=\"$scripturl?action=viewprofile;user=$row[memberName]\">$row[realName]</a>";
}


/* Display a list of boards with their number of topics and posts. Sorted by
number of posts. */

function topBoards()
{
global $db_prefix,$txt,$scripturl$num_topBoards;

ob_end_clean();
$request mysql_query("SELECT name, numTopics, numPosts, ID_BOARD FROM {$db_prefix}boards ORDER BY numPosts DESC LIMIT $num_topBoards") or database_error(__FILE____LINE__);
echo '
<table>
<tr>
<th align="left"><font size="1">' 
$txt['yse82'] . '</font></th>
<th align="left"><font size="1">' 
$txt[330] . '</font></th>
<th align="left"><font size="1">' 
$txt[21] . '</font></th>
</tr>'
;
while ($row mysql_fetch_array($request))
{
echo '
<tr>
<td><font size="1"><a href="' 
$scripturl '?board=' $row['ID_BOARD'] . '">' $row['name'] . '</a></font></td>
<td align="right"><font size="1">' 
$row['numTopics'] . '</font></td>
<td align="right"><font size="1">' 
$row['numPosts'] . '</font></td>
</tr>'
;
}
echo '
</table>'
;
}


/* Display a list of topics with their number of views. The best read topic
first. */

function topTopicsViews()
{
global $db_prefix$txt$scripturl$num_topicsViews$cgi;

ob_end_clean();
$request mysql_query("
SELECT 
{$db_prefix}topics.*,m.*
FROM 
{$db_prefix}topics,{$db_prefix}messages as m, {$db_prefix}messages as mes
WHERE m.ID_MSG=
{$db_prefix}topics.ID_FIRST_MSG
AND mes.ID_MSG=
{$db_prefix}topics.ID_LAST_MSG
ORDER BY 
{$db_prefix}topics.numViews DESC
LIMIT 
$num_topicsViews") or database_error(__FILE____LINE__);
echo '
<table>
<tr>
<th align="left">&nbsp;</th>
<th align="left"><font size="1">' 
$txt[330] . '</font></th>
</tr>'
;
while ($row mysql_fetch_array($request))
echo '
<tr>
<td align="left">
<font size="1"><a href="' 
$cgi $row['ID_BOARD'] . ';action=display;threadid=' $row['ID_TOPIC'] , ';start=0">' $row['subject'] . '</a></font>
</td>
<td align="right"><font size="1">' 
$row['numViews'] . '</font></td>
</tr>'
;
echo '
</table>'
;
}


/* Display a list of topics with their number of replies. The topic with most
replies first. */

function topTopicsReplies()
{
global $db_prefix$txt$scripturl$num_topicsReplies$cgi;

ob_end_clean();
$request mysql_query("
SELECT 
{$db_prefix}topics.*,m.*
FROM 
{$db_prefix}topics,{$db_prefix}messages as m, {$db_prefix}messages as mes
WHERE m.ID_MSG=
{$db_prefix}topics.ID_FIRST_MSG
AND mes.ID_MSG=
{$db_prefix}topics.ID_LAST_MSG
ORDER BY 
{$db_prefix}topics.numReplies DESC
LIMIT 
$num_topicsReplies") or database_error(__FILE____LINE__);

echo '
<table>
<tr>
<th align="left">&nbsp;</th>
<th align="left"><font size="1">' 
$txt[110] . '</font></th>
</tr>'
;
while ($row mysql_fetch_array($request))
echo '
<tr>
<td align="left">
<font size="1"><a href="' 
$cgi $row['ID_BOARD'] . ';action=display;threadid=' $row['ID_TOPIC'] , ';start=0">' $row['subject'] . '</a></font>
</td>
<td align="right"><font size="1">' 
$row['numReplies'] . '</font></td>
</tr>'
;
echo '
</table>'
;
}


/* Show latest member that has registered on the forum */

function latestMember()
{
global $db_prefix$txt$scripturl$modSettings;

ob_end_clean();
$euser urlencode($modSettings['latestMember']);
$thelatestmember "<a href=\"$scripturl?action=viewprofile;user=$euser\">$modSettings[latestRealName]</a>";
echo "$txt[201] $thelatestmember$txt[581]<br />";

}


/* Show some board statistics. For example:
Total Members: 1004
Total Posts: 38075
Total Topics: 1151
Total Categories: 6
Total Boards: 10 */

function boardStats()
{
global $db_prefix$txt$scripturl$modSettings;

ob_end_clean();
$latestmember $modSettings['latestMember'];
$latestRealName $modSettings['latestRealName'];
$memcount $modSettings['memberCount'];
$totalm $modSettings['totalMessages'];
$totalt $modSettings['totalTopics'];

$result mysql_query("SELECT COUNT(*) as totalb FROM {$db_prefix}boards;") or database_error(__FILE____LINE__);
$row mysql_fetch_row($result);
$numboards $row[0];
$result mysql_query("SELECT COUNT(*) as totalc FROM {$db_prefix}categories;") or database_error(__FILE____LINE__);
$row mysql_fetch_row($result);
$numcats $row[0];
echo '
$txt[488] . ' <a href="' $scripturl '?action=mlall">' $memcount '</a><br />
$txt[489] . ' ' $totalm '<br />
$txt[490] . ' ' $totalt ' <br />
$txt[658] . ' ' $numcats '<br />
$txt[665] . ' ' $numboards;
}


/* Show a list of current users online */

function whosOnline()
{
global $scripturl$db_prefix$txt$logOnlinePresence;

if ($logOnlinePresence)
WriteLog();

ob_end_clean();
$guests 0;
$tmpusers = array();
$request3 mysql_query("SELECT identity FROM {$db_prefix}log_online WHERE 1 ORDER BY logTime DESC") or database_error(__FILE____LINE__);

while ($tmp mysql_fetch_array($request3))
{
$identity $tmp['identity'];
$request4 mysql_query("SELECT realName, memberGroup, memberName FROM {$db_prefix}members WHERE (ID_MEMBER='$identity') LIMIT 1") or database_error(__FILE____LINE__);
if (mysql_num_rows($request4) > 0){
$tmp2 mysql_fetch_array($request4);
if ($tmp2['memberGroup'] == "Administrator")
$tmpusers[] = "<a href=\"$scripturl?action=viewprofile;user=$tmp2[memberName]\"><font color=\"red\">$tmp2[realName]</font></a>";
elseif ($tmp2['memberGroup']=="Global Moderator")
$tmpusers[] = "<a href=\"$scripturl?action=viewprofile;user=$tmp2[memberName]\"><font color=\"blue\">$tmp2[realName]</font></a>";
elseif ($tmp2['memberGroup']=="YaBB SE Developer")
$tmpusers[] = "<a href=\"$scripturl?action=viewprofile;user=$tmp2[memberName]\"><font color=\"green\">$tmp2[realName]</font></a>";
elseif ($tmp2['memberGroup']=="Mod Team")
$tmpusers[] = "<a href=\"$scripturl?action=viewprofile;user=$tmp2[memberName]\"><font color=\"orange\">$tmp2[realName]</font></a>";
else
$tmpusers[] = "<a href=\"$scripturl?action=viewprofile;user=$tmp2[memberName]\">$tmp2[realName]</a>";
}
else
$guests ++;
}
$users implode(', '$tmpusers);
$numusersonline sizeof($tmpusers);
echo
$guests ' ' $txt[141] . ', ' $numusersonline ' ' $txt[142] . '<br />
$users;
}

/* Show a login form */

function login()
{
global $username,$cgi,$txt;

$user 'user';
$pass 'pass';
ob_end_clean();
print '
<table border="0" cellspacing="1" cellpadding="0">
<form action="' 
$cgi ';action=login2" method="post">
<tr>
<td align="right">' 
$user ':&nbsp;</td>
<td><input type="text" name="user" size="9" value="' 
$username '"></td>
</tr><tr>
<td align="right">' 
$pass ':&nbsp;</td>
<td><input type="password" name="passwrd" size="9" /></td>
</tr><tr>
<td>&nbsp;</td>
<td><input type="hidden" name="cookielength" value="' 
$txt['yse50'] . '"><input type="submit" value="' $txt[34] . '"></td>
</tr>
</form>
</table>'
;
}
?>

andrea

Es sollte nicht notwendig sein, die SSI.php Datei zu ändern.

Beispiel:

ssi_boardNews(7, 3);

ruft vom Board Nummer 7 die 3 letzten Beiträge ab.

Betr. der Fehlermeldung: hast Du versucht, die YaBBSE SSI.php in SMF zu includen?

Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



E.T.

Ja, daran habe ich auch schon gedacht. Ich würde aber gern die letzten vier Topics beispielsweise aus dem Board 7 nur als Links darstellen (ohne dazugehörigen Text und ohne die Zusätze ,,Kommentare/Kommentar schreiben"), um sie in einer Tabelle unterzubringen. Z.B. so wie hier [nofollow]. (siehe unten)

QuoteBetr. der Fehlermeldung: hast Du versucht, die YaBBSE SSI.php in SMF zu includen?

Ja, ich weiß, dass das nicht besonders intelligent war  :D

andrea

Quote from: E.T. on July 30, 2004, 01:36:32 PM
Ja, daran habe ich auch schon gedacht. Ich würde aber gern die letzten vier Topics beispielsweise aus dem Board 7 nur als Links darstellen (ohne dazugehörigen Text und ohne die Zusätze ,,Kommentare/Kommentar schreiben"), um sie in einer Tabelle unterzubringen. Z.B. so wie hier. (siehe unten)

Dann ruf die oben erwähnte ssi_boardNews Funktion mit der Array-Methode auf, der Aufruf sieht dann z.B. so aus:

$mynews = ssi_boardNews(7, 3, 'array');

Der Array $mynews enthält dann alle Newsfelder und Du kannst die Ausgabe mit Deinem eigenen HTML Code darstellen.

Auch hier ist es nicht notwendig, die SSI.php abzuändern.

Andrea Hubacher
Ex Lead Support Specialist
www.simplemachines.org

Personal Signature:
Most recent work:
10 Aqua Themes for SMF



Mario472

#9
Öhm, vielleicht hab ich ja irgendwas überlesen - aber wie schaffe ich es jetzt beispielsweise aus den letzten 3 Topics aus Board Nummer 7 jeweils nur den Titel als Link ins Forum auf meiner Startseite anzeigen zu lassen?
MfG, Mario.

SMF 2.0

FreakaZ

Um mal andrea's Beispiel zu folgen ...


$mynews = ssi_boardNews(7, 3, '', '', 'array');

echo '<a href="', $mynews[0]['href'], '">', $mynews[0]['subject'], '</a><br />' ;
echo '<a href="', $mynews[1]['href'], '">', $mynews[1]['subject'], '</a><br />' ;
echo '<a href="', $mynews[2]['href'], '">', $mynews[2]['subject'], '</a><br />' ;


Das wäre dann die simple Antwort. :) Stellt nur Link und Title der letzten 3 Posts dar. Wenn man flexibler bleiben will, sollte man ne Schleife benutzen.

MfG
FreakaZ

Mario472

:D Funktioniert perfekt, ich danke recht herzlich! ;)
MfG, Mario.

SMF 2.0

Advertisement: