Tady je snippet:
Kód: Vybrať všetko
# Show_phpBB2 v1.1 - Etomite v0.6.1 RTM
# Created By: Teddy Hwang
# Special thanks to: John Maats - john-at-pn.nl (original creator of Show_phpBB)
# Usage:
# Make sure $url and $ppath are set to the right locations.
# - $url = the part after your domainname
# If url is - http://www.yourforums.com/forum , then enter in "/forum"
# - ppath = the physical path to the phpBB's config.php, use:
# relative path like: "./forum/config.php"
# or absolute path like "/home/user/public_html/forum"
#
# Change $forumnr variable to match the forum you wish to show
# it can be found in url when you are in the forum you need,
# http://yoursite/forum/viewforum.php?f=2, the 2 is your desired forum
#
# Change $topiccount to number of topics from forumnr you want to see.
# 0 will show none!
# Change $postcount to number of posts from topiccount you want to see.
# 0 will show none!
#
# This test passing variables:
# call snippet like:
# [[Show_phpBB2?forumnr=1&topicnr=10&postcount=1]]
# This will show 1 post of the 1 topics from forum 1.
# Povinné parametry: forumnr= zadávate ID fóra, topicnr= zadáváte ID topicu, postcount= počet zobrazených příspěvků
#
# Version history: 1.1 - added vote extraction
#
//You must change the settings below
$url = "http://www.yourforums.com";
$ppath = "/home/user/public_html/forum/config.php";
include_once("$ppath");
$return = "";
/* ------------------------------------------------------*/
/* Don't mess with this unless you know what ur doing!!! */
/* This is the actual code... */
/* ------------------------------------------------------*/
// retrieve the database information
$db = @mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("died at connection");
@mysql_select_db("$dbname",$db) or die("died at dbname");
// set desired forum
$query="SELECT * FROM ".$table_prefix."forums WHERE forum_id=".$forumnr;
$result1=mysql_query($query);
while($row = mysql_fetch_array($result1)) {
// set desired topic number and define ids
$query="SELECT * FROM ".$table_prefix."topics WHERE forum_id=".$forumnr." AND topic_id=".$topicnr;
$result2=mysql_query($query);
while($row = mysql_fetch_array($result2)) {
$topic_id = "$row[topic_id]";
$title = "$row[topic_title]";
$forumid = "$row[forum_id]";
$replies = "$row[topic_replies]";
$topic_vote = "$row[topic_vote]";
// set desire post number and define post author and post date
$query="SELECT * FROM ".$table_prefix."posts WHERE topic_id=". $topic_id." ORDER BY 'post_id' ASC LIMIT 0 , ". $postcount ;
$result3=mysql_query($query);
while($row = mysql_fetch_array($result3)) {
$post_id = "$row[post_id]";
$poster = "$row[poster_id]";
$time = "$row[post_time]";
# Default time offset (+/-) from server to use if not sent in snippet call
$defaultDiff = 1;
$diff = isset($diff) ? $diff : $defaultDiff;
$timeadjust = ($diff * 60 * 60);
$date = date("j. n. Y, G. i", $time + $timeadjust);
$query="SELECT * FROM ".$table_prefix."users WHERE user_id=".$poster ;
$result4=mysql_query($query);
while($row = mysql_fetch_array($result4)) {
$author = "$row[username]";
// retrieve post_text and replace bbcode and icons
$query="SELECT * FROM ".$table_prefix."posts_text WHERE post_id=".$post_id ;
$result5=mysql_query($query);
while($row = mysql_fetch_array($result5)) {
$text="$row[post_text]";
$text=preg_replace('/\:[0-9a-z\:]+\]/si', ']', $text);
$text=str_replace("[b]","<b>",$text);
$text=str_replace("[/b]","</b>",$text);
$text=str_replace("[i]","<i>",$text);
$text=str_replace("[/i]","</i>",$text);
$text=str_replace("[u]","<u>",$text);
$text=str_replace("[/u]","</u>",$text);
$text=str_replace("[color=darkred]","<font color=\"darkred\">",$text);
$text=str_replace("[color=red]","<font color=\"red\">",$text);
$text=str_replace("[color=orange]","<font color=\"orange\">",$text);
$text=str_replace("[color=brown]","<font color=\"brown\">",$text);
$text=str_replace("[color=yellow]","<font color=\"yellow\">",$text);
$text=str_replace("[color=green]","<font color=\"green\">",$text);
$text=str_replace("[color=olive]","<font color=\"olive\">",$text);
$text=str_replace("[color=cyan]","<font color=\"cyan\">",$text);
$text=str_replace("[color=blue]","<font color=\"blue\">",$text);
$text=str_replace("[color=darkblue]","<font color=\"darkblue\">",$text);
$text=str_replace("[color=indigo]","<font color=\"indigo\">",$text);
$text=str_replace("[color=violet]","<font color=\"violet\">",$text);
$text=str_replace("[color=white]","<font color=\"white\">",$text);
$text=str_replace("[color=black]","<font color=\"black\">",$text);
$text=str_replace("[/color]","</font>",$text);
$text=str_replace("[size=7]","<font size=\"0\">",$text);
$text=str_replace("[size=9]","<font size=\"1\">",$text);
$text=str_replace("[size=12]","<font size=\"2\">",$text);
$text=str_replace("[size=18]","<font size=\"3\">",$text);
$text=str_replace("[size=24]","<font size=\"5\">",$text);
$text=str_replace("[/size]","</font>",$text);
$text= preg_replace('/\[quote\:[0-9a-z\:]+\=\"(.*)\"\](.*)\[\/quote\]/Usi','<fieldset><legend><small>[<font color="red">Cituji - </font>] $1 napsal:</small></legend><i>$2</i></fieldset>',$text);
$text=str_replace("[quote]","<fieldset><legend>\[<font color=\"red\">Quote</font>\]</legend>",$text);
$text=str_replace("[/quote]","</fieldset>",$text);
$text=str_replace("[code]","<fieldset><legend>Code</legend>",$text);
$text=str_replace("
$text= preg_replace('/\[list\](.*)\[\/list\]/si',"<div style=\"padding: 7px\">$1</div>",$text);
$text= preg_replace('/\
- (.*)\[\/list\]/si',"<div style=\"padding: 7px\">$1</div>",$text);
$text=str_replace("[img]","<img src=\"",$text);
$text=str_replace("[/img]","\" alt=\"image\" />",$text);
$text= preg_replace('/\[url\](.*)\[\/url\]/Usi','<a href="$1" target="blank">$1</a>',$text);
$text= preg_replace('/\[url=(.*)\](.*)\[\/url\]/Usi','<a href="$1" target="blank">$2</a>',$text);
$text=str_replace(":D","<img src=\"$url/images/smiles/icon_biggrin.gif\">",$text);
$text=str_replace(":)","<img src=\"$url/images/smiles/icon_smile.gif\">",$text);
$text=str_replace(":(","<img src=\"$url/images/smiles/icon_sad.gif\">",$text);
$text=str_replace(":oops:","<img src=\"$url/images/smiles/icon_redface.gif\">",$text);
$text=str_replace(":o","<img src=\"$url/images/smiles/icon_surprised.gif\">",$text);
$text=str_replace(":shock:","<img src=\"$url/images/smiles/icon_eek.gif\">",$text);
$text=str_replace(":?:","<img src=\"$url/images/smiles/icon_question.gif\">",$text);
$text=str_replace(":?","<img src=\"$url/images/smiles/icon_confused.gif\">",$text);
$text=str_replace("8)","<img src=\"$url/images/smiles/icon_cool.gif\">",$text);
$text=str_replace(":lol:","<img src=\"$url/images/smiles/icon_lol.gif\">",$text);
$text=str_replace(":x","<img src=\"$url/images/smiles/icon_mad.gif\">",$text);
$text=str_replace(":P","<img src=\"$url/images/smiles/icon_razz.gif\">",$text);
$text=str_replace("","<img src=\"$url/images/smiles/icon_cry.gif\">",$text);
$text=str_replace(":evil:","<img src=\"$url/images/smiles/icon_evil.gif\">",$text);
$text=str_replace(":twisted:","<img src=\"$url/images/smiles/icon_twisted.gif\">",$text);
$text=str_replace(":roll:","<img src=\"$url/images/smiles/icon_rolleyes.gif\">",$text);
$text=str_replace("","<img src=\"$url/images/smiles/icon_wink.gif\">",$text);
$text=str_replace(":!:","<img src=\"$url/images/smiles/icon_exclaim.gif\">",$text);
$text=str_replace(":idea:","<img src=\"$url/images/smiles/icon_idea.gif\">",$text);
$text=str_replace(":arrow:","<img src=\"$url/images/smiles/icon_arrow.gif\">",$text);
$text=str_replace(":|","<img src=\"$url/images/smiles/icon_neutral.gif\">",$text);
$text=str_replace(":mrgreen:","<img src=\"$url/images/smiles/icon_mrgreen.gif\">",$text);
$text=str_replace("\n", "\n<br />\n", $text);
// configure the output below as you see fit
// currently, it uses a fieldset/legend system to out put
$return = $return."
<fieldset style=\"border-color: blue;\">
<fieldset><small><b>Příspěvek napsal <a title=\"$author\" href=\"$url/profile.php?mode=viewprofile&u=$poster\" target=\"blank\">$author</a> dne $date</b> .................................. Příspěvky: $replies :: <a title=\"$title\" href=\"$url/viewtopic.php?t=$topic_id&sid=$forumid\" target=\"blank\"><i>vložit nový / prohlédnout</i></a></small></fieldset>";
// if there is a poll, the frontpage will extract the poll and display the poll information including poll question,
// poll options, and results
if ( $topic_vote == 1 ) {
$query="SELECT * FROM ".$table_prefix."vote_desc WHERE topic_id=".$topic_id ;
$result6=mysql_query($query);
while($row = mysql_fetch_array($result6)) {
$vote_id = "$row[vote_id]";
$query="SELECT * FROM ".$table_prefix."vote_desc WHERE vote_id=".$vote_id ;
$result7=mysql_query($query);
while($row = mysql_fetch_array($result7)) {
$vote_text = "$row[vote_text]";
$votecount = 100;
$return = $return."
<hr>
<table border=\"1\" align=\"center\"><tr><td><b><a title=\"$title\" href=\"$url/viewtopic.php?t=$topic_id&sid=$forumid\" target=\"blank\">[POLL]: $vote_text</a></b></td></tr></table>";
$return = $return."<table border=\"0\"><tr><td width=\"50\"> </td><td width=\"345\"><u><i>Vote Option</i></u></td><td><u><i>Votes</i></u></td></tr></table>";
}
}
$query="SELECT * FROM ".$table_prefix."vote_results WHERE vote_id=".$vote_id." ORDER BY 'topic_id' DESC LIMIT 0 , ". $votecount ;
$result8=mysql_query($query);
while($row = mysql_fetch_array($result8)) {
$vote_option_text = "$row[vote_option_text]";
$vote_result = "$row[vote_result]";
$return = $return."<table border=\"0\"><tr><td width=\"50\"> </td><td width=\"330\"><li>$vote_option_text</td><td width=\"50\" align=\"center\">$vote_result</li></td></tr></table>";
}
$return = $return."<hr>";
}
// configure the output below as you see fit
$return = $return.$text."<br>";
$return = $return."</fieldset><br>";
}
}
}
}
}
return $return;[/code]
Syntaxe zápisu:
[[Show_phpBB2?forumnr=1&topicnr=10&postcount=1]]
Povinné parametry: forumnr= zadávate ID fóra, topicnr= zadáváte ID topicu, postcount= počet zobrazených příspěvků. Všechny parametry je nutno zadat, jinak vám to nepojede.
P.S.: Mimochodem, originál byl dost prasácky napsán, musel jsem do toho sáhnout - a ani nyní to asi nebude 100% validní, nicméně to funguje.