Thread Rating:
  • 6 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BB-Codes
#1
Hello!


I made these days a script that introduces bb-codes!
I will explain in a few steps how you can install.

1. First creates a file named bbcode.php and add the following to him:

Code:
<?php





function bb_player($var) {

        $var1=str_replace(' ','+',$var);

        $r1 = mysql_query("SELECT * FROM users WHERE username='$var1[1]'");
        $n1 = mysql_num_rows($r1);
        if($n1=="1") {
            if(isset($_GET['village'])) { $villageid='village='.$_GET['village'].'&'; } else { $villageid=""; }
            $result = mysql_query("SELECT * FROM users WHERE username='$var1[1]'");
            while($row = mysql_fetch_array($result))
            {
                $echo='<a href="game.php?'.$villageid.'screen=info_player&id='.$row['id'].'">'.str_replace('+',' ',$row['username']).'</a>';
                return $echo;
            }
        } else {
            return $var1[1];
        }



}



function bb_ally($var) {
        $var1=str_replace(' ','+',$var);
        $r1 = mysql_query("SELECT * FROM ally WHERE short='$var1[1]'");
        $n1 = mysql_num_rows($r1);
        if($n1=="1") {
            if(isset($_GET['village'])) { $villageid='village='.$_GET['village'].'&'; } else { $villageid=""; }
            $result = mysql_query("SELECT * FROM ally WHERE short='$var1[1]'");
            while($row = mysql_fetch_array($result))
            {
                $echo='<a href="game.php?'.$villageid.'screen=info_ally&id='.$row['id'].'">'.str_replace('+',' ',$row['short']).'</a>';
                return $echo;
            }
        } else {
            return $var1[1];
        }

}






function bb_village($var)
{


        $r1 = mysql_query("SELECT * FROM villages WHERE x='$var[1]' AND y='$var[2]'");
        $n1 = mysql_num_rows($r1);
        if($n1=="1") {
            if(isset($_GET['village'])) { $villageid='village='.$_GET['village'].'&'; } else { $villageid=""; }
            $result = mysql_query("SELECT * FROM villages WHERE x='$var[1]' AND y='$var[2]'");
            while($row = mysql_fetch_array($result))
            {
                $echo='<a href="game.php?'.$villageid.'screen=info_village&id='.$row['id'].'">'.str_replace('+',' ',$row['name']).'</a>';
                return $echo;
            }
        } else {
            $echo="(Sat nevalabil)";
            return $echo;
        }
}





function bb_format($test) {

    $str=$test;
    



    $simple_search = array(  
                '/\[b\](.*?)\[\/b\]/is',  
                '/\[i\](.*?)\[\/i\]/is',  
                '/\[u\](.*?)\[\/u\]/is',  
                '/\[url\=(.*?)\](.*?)\[\/url\]/is',  
                '/\[url\](.*?)\[\/url\]/is',  
                '/\[align\=(left|center|right)\](.*?)\[\/align\]/is',  
                '/\[img\](.*?)\[\/img\]/is',  
                '/\[font\=(.*?)\](.*?)\[\/font\]/is',  
                '/\[size\=(.*?)\](.*?)\[\/size\]/is',  
                '/\[color\=(.*?)\](.*?)\[\/color\]/is',  
                );  





    $simple_replace = array(  
                '<strong>$1</strong>',  
                '<em>$1</em>',  
                '<u>$1</u>',  
                '<a href="$1" rel="nofollow" title="$2 - $1">$2</a>',  
                '<a href="$1" rel="nofollow" title="$1">$1</a>',  
                '<div style="text-align: $1;">$2</div>',  
                '<img src="$1" alt="" />',  
                '<span style="font-family: $1;">$2</span>',  
                '<span style="font-size: $1;">$2</span>',  
                '<span style="color: $1;">$2</span>',  
                );  

  





    $aa = array(  
                '/\[player\](.*?)\[\/player\]/is',  
                );

    $bb = array(  
                '/\[ally\](.*?)\[\/ally\]/is',  
                );


    $cc = array(  
                '/\[village\](.*?)\|(.*?)\[\/village\]/is',  
                );



    $a=preg_replace_callback($aa, "bb_player", $str);
    $b=preg_replace_callback($bb, "bb_ally", $a);
    $c=preg_replace_callback($cc, "bb_village", $b);
    $d=preg_replace($simple_search, $simple_replace, $c);

    return $d;

}


?>

Save the file and exit.


2. Now open the file include.inc.php and add after all code written in the file the following line:
Code:
<?php include('bbcode.php'); ?>
Save the file and exit.





Now start editing files of the design. ( /htdocs/templates/ )

3. Open game_ally_in_ally_overview.tpl

At line 38 find:
Code:
{$ally.intern_text}
Replace with:
Code:
{php} echo bb_format($this->_tpl_vars['ally']['intern_text']); {/php}

At line 54 find:
Code:
{$ally.intern_text}
Replace with:
Code:
{php} echo bb_format($this->_tpl_vars['ally']['intern_text']); {/php}

Save the file and exit.




4. Open game_ally_in_ally_properties.tpl

At line 27 find:
Code:
{$ally.description}
Replace with:
Code:
{php} echo bb_format($this->_tpl_vars['ally']['description']); {/php}

At line 43 find:
Code:
{$ally.description}
Replace with:
Code:
{php} echo bb_format($this->_tpl_vars['ally']['description']); {/php}

Save the file and exit.



5. Open game_info_ally.tpl

At line 28 find:
Code:
{$info.description}
Replace with:
Code:
{php} echo bb_format($this->_tpl_vars['info']['description']); {/php}

Save the file and exit.



6. Open game_info_player.tpl

At line 54 find:
Code:
{$info_user.personal_text}
Replace with:
Code:
{php} echo bb_format($this->_tpl_vars['info_user']['personal_text']); {/php}

Save the file and exit.



7. Open game_mail_arch.tpl

At line 57 find:
Code:
{$mail.text}
Replace with:
Code:
{php} echo bb_format($this->_tpl_vars['mail']['text']); {/php}

Save the file and exit.




8. Open game_mail_in.tpl

At line 57 find:
Code:
{$mail.text}
Replace with:
Code:
{php} echo bb_format($this->_tpl_vars['mail']['text']); {/php}

Save the file and exit.



9. Open game_mail_new.tpl


At line 4 find:
Code:
{$preview_message}
Replace with:
Code:
{php} echo bb_format($this->_tpl_vars['preview_message']); {/php}

Save the file and exit.





10. Open game_mail_out.tpl

At line 57 find:
Code:
{$mail.text}
Replace with:
Code:
{php} echo bb_format($this->_tpl_vars['mail']['text']); {/php}

Save the file and exit.






This is pretty ... more I leave you to discover!

BB-Codes which are active:
  • [ player][/player] ( ex: [ player]Tavicu[/player] )
  • [ ally][/ally] ( ex: [ ally]TA[/ally] )
  • [ village][/village] ( ex: [ village]252|253[/village] )
  • [ b][/b] ( ex: [ b]Text Bold[/b] )
  • [ i][/i] ( ex: [ i]Text italic[/i] )
  • [ u][/u] ( ex: [ u]Text underline[/u] )
  • [ url][/url] ( ex: [ url]http://dslan.gfx-dose.de[/url] )
  • [ url=][/url] ( ex: [ url=http://dslan.gfx-dose.de]DS-Lan[/url] )
  • [ align=][/align] ( ex: [ align=center]Text[/align] )
  • [ img][/img] ( ex: [ img]http://dslan.gfx-dose.de/test.png[/img] )
  • [ font=][/font] ( ex: [ font=Arial]Font test[/font] )
  • [ size=][/size] ( ex: [ size=20]Big font[/size] )
  • [ color=][/color] ( ex: [ color=#6B8E23]Font color[/color] )



PS: I tried and I made this script for the version DsLan v1.1 , I do know if it works on DsLan v1.12!
Reply
#2
Very interesting tutorial.

Kann einer bitte das mal überprüfen?
[Image: create.php?uid=14]
Reply
#3
klar mach ich.

nicht zu empfehlen. zwei fehlermeldungen gleich bei localhost: Warning: main(bbcode.php) [function.main]: failed to open stream: No such file or directory in C:\Users\CHRISSI\Desktop\dslan_v1.12\htdocs\include.inc.php on line 2

Warning: main() [function.include]: Failed opening 'bbcode.php' for inclusion (include_path='.;C:\Users\CHRISSI\Desktop\dslan_v1.12\php\pear\') in C:\Users\CHRISSI\Desktop\dslan_v1.12\htdocs\include.inc.php on line 2
Reply
#4
die bb-codes klappen. die php datei am anfang muss aber bbcode.php heißen, sonst geht es nicht.

Reply
#5
und wo klappt das? achja wenn es bbcode heißt kommt die meldung net^^
Reply
#6
da mal jemand was zum download draus machen was man nurnoch einfügen muss? Big Grin
bb codes sind ne feine sache =)
hail WAR, DER stamm auf s3 o
Reply
#7
ja ok ich übernehm das mit dem download. wird in dem post hier erscheinen.

done:

[Image: download.jpg]
Reply
#8
I'm sorry!

Rename the file bbcodes.php in bbcode.php
Reply
#9
nur so zu info:

in dem templates Ordner heißen alle Dateien mit .tpl am Schluss
[Image: create.php?uid=511]
Reply
#10
abbar-2 das stimmt nicht ganz. guck dir mal events.php an. außerdem muss die datei bbcode.php auch nicht in den template ordner sondern in den htdocs ordner
Reply
#11
ich meinte alle Tempelates Dateien heißen am Ende nicht .php sondern .tpl
[Image: create.php?uid=511]
Reply
#12
^^fast alle^^ aber warum schreibst du das? hat doch gar nichts mit dem thema zu tun
Reply
#13
doch schau doch mal hier:

Quote:Now start editing files of the design. ( /htdocs/templates/ )

3. Open game_ally_in_ally_overview.php

At line 38 find:
Code:
{$ally.intern_text}
Replace with:
Code:
{php} echo bb_format($this->_tpl_vars['ally']['intern_text']); {/php}

At line 54 find:
Code:
{$ally.intern_text}
Replace with:
Code:
{php} echo bb_format($this->_tpl_vars['ally']['intern_text']); {/php}

Save the file and exit.
[Image: create.php?uid=511]
Reply
#14
ups ja das hatte ich übersehen.
Reply
#15
Stamm Bei Nachrichten kommen auch solche meldungen

Übersicht:

Fatal error: Call to undefined function: bb_format() in C:\Users\Fabian\Documents\eigenes_staemme\htdocs\templates_c\%%A7^A79^A791D467%%game_ally_in_ally_overview.tpl.php on line 95

Profil: Fatal error: Call to undefined function: bb_format() in C:\Users\Fabian\Documents\eigenes_staemme\htdocs\templates_c\%%7B^7B7^7B7EBF47%%game_info_ally.tpl.php on line 45

Eigenschaften: Fatal error: Call to undefined function: bb_format() in C:\Users\Fabian\Documents\eigenes_staemme\htdocs\templates_c\%%48^488^4880256D%%game_ally_in_ally_properties.tpl.php on line 55
Reply
#16
bei mir kommen zwar keine fehlermeldungen mehr, aber die bb-codes
zum Beispiel [player]HuGoB0Zz[/player] gehen nicht.
@Tavicu:
When are the BB-Codes active( in messages or something like that?)
and what bb-codes are active. I tried the [player]HuGoB0Zz[/player] but there was no bb-code.
@alle anderen: geht das bei jemandem von euch und wenn welche codes und wann.
Sincerely und Danke im Voraus für eure Antworten
HuGo
mfg HuGo
[Image: ecf8.png]
Support me Smile
Reply
#17
Templates_C ordner leeren bevor man die BB-Codes benutzt
✝ RiP 
Weiter geht's  Cool
Reply
#18
(11.12.2008, 18:13)milos Wrote: Templates_C ordner leeren bevor man die BB-Codes benutzt

hab ich
funktioniert aber immer noch nicht

irgendwie kommt bei mir das hier:

Fatal error: Smarty error: [in game_info_player.tpl line 51]: syntax error: unidentified token '{php' (eac365.tmp, line 1396) in C:\Program Files\DS-LAN\htdocs\lib\smarty\Smarty.class.php on line 1095
mfg HuGo
[Image: ecf8.png]
Support me Smile
Reply
#19
Probier Soft/Reset
✝ RiP 
Weiter geht's  Cool
Reply
#20
hat leider auch nichts genützt
ich müsste doch dann zumindest den [b] code machen können oder?
mfg HuGo
[Image: ecf8.png]
Support me Smile
Reply




Users browsing this thread: 6 Guest(s)