Propojení Etomite s phpBB

V tejto téme sa nachádzajú snippety (rozšírenia) pre Etomite.

Moderátor: Moderators

R - stick
Moderator & CLT
Moderator & CLT
Príspevky: 215
Dátum registrácie: Pi Sep 23, 2005 10:59 am
Bydlisko: Vysoké Studnice (u Jihlavy)
Kontaktovať používateľa:

Propojení Etomite s phpBB

Príspevok od používateľa R - stick »

Docela zajímavá věc - pokud chcete umožnit ke konkrétnímu článku diskusi, můžete použít phpBB. Funguje to tak, že si v phpBB vyberete fórum a v něm topic, který pak připojíte ke článku v Etomite. Demo najdete na http://magazin.sferabubeniku.info/54.htm - pozor, bude tu jen dočasně!!

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("
","</fieldset>",$text);

$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(":cry:","<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(":wink:","<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\">&nbsp;</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\">&nbsp;</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.
Používateľov profilový obrázok
_rasel^
ETOMITE Admin
ETOMITE Admin
Príspevky: 1122
Dátum registrácie: Ut Sep 20, 2005 1:03 am
Bydlisko: Košice (SR)
Kontaktovať používateľa:

Príspevok od používateľa _rasel^ »

Hmm... dik za upraveny snippet. Este ho musim zvalidovat, povodny autor asi nemyslel na XHTML 1.1, ked ho pisal. :lol: Upravim ho tak, aby sa na phpBB aspon mierne podobal, pridam CSS a potom vysledok slahnem do fora... chvilu (zopar dni) to potrva. :roll:
..:: Etomite CMS → Rulezzz !.!.!. ::..
R - stick
Moderator & CLT
Moderator & CLT
Príspevky: 215
Dátum registrácie: Pi Sep 23, 2005 10:59 am
Bydlisko: Vysoké Studnice (u Jihlavy)
Kontaktovať používateľa:

Príspevok od používateľa R - stick »

No - ten snippet v původoní podobě je fakt tragédie - myšlenka dobrá, funkce celkem ujde - ale ten výstup!! Hromada informací je tam duplicitních, je to mizerně uspořádané - no a ta validita !!!

I když s ní bude asi problém, ono totiž v databázi phpBB, ze které si to tahá příspěvky totiž není uloženo všechno košer. A navíc tam dělá dost bordel použití BBcode. Takže to bude pěkná makačka.

Jo - v originálu byly vypsané všechny thready v jednom fóru - já jsem tam přepsal SQL příkaz, protože jsem to potřžeboval napojit na zcela konkrétní thread. Pokud by jso potřeboval, můžu sem dát originák kódu.
Používateľov profilový obrázok
_rasel^
ETOMITE Admin
ETOMITE Admin
Príspevky: 1122
Dátum registrácie: Ut Sep 20, 2005 1:03 am
Bydlisko: Košice (SR)
Kontaktovať používateľa:

Príspevok od používateľa _rasel^ »

Hmm... tak som sa nato pozrel. Budem upravovat snippet, ktory upravil R - stick.

Co upravil R - stick:
Riadok 52 upraveny na:

Kód: Vybrať všetko

$query="SELECT * FROM ".$table_prefix."topics WHERE forum_id=".$forumnr." AND topic_id=".$topicnr;
Riadok 72 upraveny na:

Kód: Vybrať všetko

$date = date("j. n. Y, G. i", $time + $timeadjust);
Riadok 117 upraveny na:

Kód: Vybrať všetko

$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);
Riadok 163 upraveny na:

Kód: Vybrať všetko

$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>";
Riadok 179 upraveny na:

Kód: Vybrať všetko

    $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>";
Riadok 193 upraveny na:

Kód: Vybrať všetko

$return = $return."<hr>";
Riadok 197 a 198 upraveny na:

Kód: Vybrať všetko

$return = $return.$text."<br>";
$return = $return."</fieldset><br>";
Neskor hodim post s validnym R - stick(ovim) sippetom. :eto:
Prílohy
show_phpbb2v1.1.rar
Povodne Show_phpBB2
(2.49 KiB) 229 stiahnutí
Naposledy upravil/-a _rasel^ v St Jún 07, 2006 3:59 pm, upravené celkom 1 krát.
..:: Etomite CMS → Rulezzz !.!.!. ::..
Používateľov profilový obrázok
_rasel^
ETOMITE Admin
ETOMITE Admin
Príspevky: 1122
Dátum registrácie: Ut Sep 20, 2005 1:03 am
Bydlisko: Košice (SR)
Kontaktovať používateľa:

Príspevok od používateľa _rasel^ »

Update!

Show-phpBB

Tak tu je vysledok. Validny snippet Show-phpBB a zopar uprav + dnesny update.

btw: Ak mate Etomite v inom kodovani ako vase phpBB forum, tak potom budete mat mensi problem s diakritikou (vidno v deme = otazniky namiesto diakritiky). :( Ak vie niekto ako konvertovat jednu znakovu sadu na inu, tak pls pomozte.

Demo: http://www.etomite.sk/phpbb
Prílohy
Show-phpBB.rar
Show-phpBB by _rasel^
(2.65 KiB) 252 stiahnutí
..:: Etomite CMS → Rulezzz !.!.!. ::..
R - stick
Moderator & CLT
Moderator & CLT
Príspevky: 215
Dátum registrácie: Pi Sep 23, 2005 10:59 am
Bydlisko: Vysoké Studnice (u Jihlavy)
Kontaktovať používateľa:

Príspevok od používateľa R - stick »

Klobouk dolů - to je bomba!!! Měl by jsi to hodit i na orig. stránky Etomite. Nemá to chybu.
Používateľov profilový obrázok
_rasel^
ETOMITE Admin
ETOMITE Admin
Príspevky: 1122
Dátum registrácie: Ut Sep 20, 2005 1:03 am
Bydlisko: Košice (SR)
Kontaktovať používateľa:

Príspevok od používateľa _rasel^ »

Pridam na stranky Etomite, len co snippet este trocha vylepsim... :D :eto:
..:: Etomite CMS → Rulezzz !.!.!. ::..
Používateľov profilový obrázok
_rasel^
ETOMITE Admin
ETOMITE Admin
Príspevky: 1122
Dátum registrácie: Ut Sep 20, 2005 1:03 am
Bydlisko: Košice (SR)
Kontaktovať používateľa:

Príspevok od používateľa _rasel^ »

Na Etomite.org sa neaky ten piatok nedaju pridavat snippety. :roll:
Nasiel som riesenie, ako odladit znakovu sadu, ale neako mi to nefunguje. :(

Kód: Vybrať všetko

mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_connection=cp1250_latin2");
mysql_query("SET character_set_client=cp1250_latin2");
mysql_query("SET CHARACTER SET utf8");
... ak by nahodou niekto vedel poradit, tak by som bol rad. Skusal som uz vseho-vsudy kombinacie znakovych sad, poradia, ale bez akejkolvek zmeny...
..:: Etomite CMS → Rulezzz !.!.!. ::..
Napísať odpoveď