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


Messages In This Thread
BB-Codes - by Tavicu - 14.10.2008, 00:01
RE: BB-Codes - by emoser - 14.10.2008, 19:02
RE: BB-Codes - by Narutofan XXl - 14.10.2008, 19:26
RE: BB-Codes - by Black Arrow - 14.10.2008, 21:39
RE: BB-Codes - by Narutofan XXl - 15.10.2008, 08:20
RE: BB-Codes - by -Xan- - 15.10.2008, 10:46
RE: BB-Codes - by Narutofan XXl - 15.10.2008, 11:30
RE: BB-Codes - by Tavicu - 15.10.2008, 11:43
RE: BB-Codes - by abbar-2 - 16.10.2008, 08:57
RE: BB-Codes - by Narutofan XXl - 16.10.2008, 14:37
RE: BB-Codes - by abbar-2 - 16.10.2008, 15:30
RE: BB-Codes - by Narutofan XXl - 16.10.2008, 15:31
RE: BB-Codes - by abbar-2 - 16.10.2008, 15:45
RE: BB-Codes - by Narutofan XXl - 16.10.2008, 18:43
RE: BB-Codes - by deLaKing - 01.11.2008, 22:29
RE: BB-Codes - by HuGoB0Zz - 07.12.2008, 20:52
RE: BB-Codes - by Milu2K - 11.12.2008, 18:13
RE: BB-Codes - by HuGoB0Zz - 12.12.2008, 16:36
RE: BB-Codes - by Milu2K - 12.12.2008, 17:53
RE: BB-Codes - by HuGoB0Zz - 12.12.2008, 18:00
RE: BB-Codes - by Milu2K - 12.12.2008, 18:02
RE: BB-Codes - by HuGoB0Zz - 12.12.2008, 18:06
RE: BB-Codes - by Milu2K - 12.12.2008, 18:13
RE: BB-Codes - by HuGoB0Zz - 12.12.2008, 18:14
RE: BB-Codes - by Milu2K - 12.12.2008, 18:16
RE: BB-Codes - by HuGoB0Zz - 12.12.2008, 18:23
RE: BB-Codes - by Milu2K - 12.12.2008, 18:25
RE: BB-Codes - by Tayflore - 06.03.2009, 15:56
RE: BB-Codes - by BritneyBitch - 06.03.2009, 17:12
RE: BB-Codes - by Tayflore - 06.03.2009, 17:32
RE: BB-Codes - by Black Arrow - 06.03.2009, 17:46
RE: BB-Codes - by Agamendon - 06.03.2009, 17:53
RE: BB-Codes - by Tayflore - 06.03.2009, 18:42
RE: BB-Codes - by Tayflore - 12.03.2009, 21:15
RE: BB-Codes - by Agamendon - 13.03.2009, 13:40
RE: BB-Codes - by agrafix - 13.03.2009, 22:42
RE: BB-Codes - by Tayflore - 13.03.2009, 23:29
RE: BB-Codes - by agrafix - 14.03.2009, 10:07
RE: BB-Codes - by Tayflore - 14.03.2009, 10:28
RE: BB-Codes - by Tayflore - 18.03.2009, 21:19
RE: BB-Codes - by Milu2K - 18.03.2009, 21:41
RE: BB-Codes - by m1cr0 - 11.10.2009, 11:55
RE: BB-Codes - by Arthas - 11.10.2009, 12:20
RE: BB-Codes - by Sascha van Lichtenstein - 11.10.2009, 13:25
RE: BB-Codes - by Arthas - 11.10.2009, 13:44
RE: BB-Codes - by Arthas - 12.10.2009, 17:23
RE: BB-Codes - by Deceptecons - 03.05.2010, 20:22



Users browsing this thread: 1 Guest(s)