Search
Left Quote    Every day I get up and look through the Forbes list of the richest people in America. If I
- Robert Orben    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: BBCode
  This user is offline  ki
  Subject: "BBCode" Posted: @ 4:14 am on Oct 04 2006   

Member #: 204
Rank: User - (50)
Since: 09/16/06
Posts: 53
From: Florida

Well ive been creating a BB code for my site and well I got some but Its not very what you say effective, it works but I want to make sure It doesnt enable html code but I dont want it to interfere with code to html programming incase for like giving examples? so far I got this.


Code:
$rep = str_replace('&l t;script>',' ',$rep);
$rep = str_replace('&l t;/script>', '',$rep);
$rep = str_replace('&l t;script','',$r ep);
$rep = str_replace('&l t;/table>',' ',$rep);
$rep = str_replace('&l t;table','',$re p);
$rep = str_replace('&l t;table','',$re p);
$rep = str_replace('&l t;b>','',$re p);
$rep = str_replace('&l t;/b>','',$r ep);
$rep = str_replace('&l t;i>','',$re p);
$rep = str_replace('&l t;/i>','',$r ep);
$rep = str_replace('&l t;img','',$rep) ;
$rep = str_replace('&l t;u>','',$re p);
$rep = str_replace('&l t;/u>','',$r ep);
$rep = str_replace('&l t;fieldset','', $rep);
$rep = str_replace('&l t;div','',$rep) ;
$rep = str_replace('&l t;legend','',$r ep);
$rep = str_replace('&l t;b>','',$re p);

$rep = str_replace('','<b>', $rep);
$rep = str_replace('','</b> ',$rep);

$rep = str_replace('[i mg]','<img src="',$re p);
$rep = str_replace('[/ img]','"&g t;',$rep);

$rep = str_replace('','<i>', $rep);
$rep = str_replace('','</i> ',$rep);

$rep = str_replace('[u ]','<u>', $rep);
$rep = str_replace('[/ u]','</u> ',$rep);

$rep = str_replace('&a mp;','&amp; ',$rep);
$rep = str_replace('&q uot;','&quo t;',$rep);

$rep = str_replace('[u rl=(','<a href="',$r ep);
$rep = str_replace(')] ','">', $rep);
$rep = str_replace('[/ url]','</a&g t;',$rep);




woohoo!
    Viewed: 7,231 Times | Reply to This | To top
  This user is offline  ki
  Subject: "re: BBCode" Posted: @ 2:13 pm on Oct 04 2006    

Member #: 204
Rank: User - (50)
Since: 09/16/06
Posts: 53
From: Florida

Never mind about no html I just added replace for the '<' & '>' to the html codes so its fixed but can someone show me hot do to a code command and quote . Thanks




woohoo!

    Viewed: 7,224 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: BBCode" Posted: @ 2:19 am on Oct 05 2006    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

If you don't want user supplied HTML code to be executed, use the function htmlspecialcha rs() .

With BBCode, first define what code you're going to use in replace of HTML. Like on this forum, click "Bold&qu ot;, "Italic& quot;, "Link&qu ot; ect. and the BBCode is added to the text box to type your message.

The BBCode is then converted into HTML with str_replace() before the post or comment is added to the database.

understand now?



Edited at 02:27:52 am on 10/05/06


-bs0d | AllSyntax.com

    Viewed: 7,214 Times | Reply to This | To top
  This user is offline  ki
  Subject: "re: BBCode" Posted: @ 2:57 am on Oct 05 2006    

Member #: 204
Rank: User - (50)
Since: 09/16/06
Posts: 53
From: Florida

Well I already prevented it just by doing the replace on < and > but I got it now but I decode all the stuff from the reading of it




woohoo!

    Viewed: 7,210 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: BBCode" Posted: @ 10:05 pm on Oct 05 2006    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Ok; yea just using htmlspecialchar s() thats what its intended for and its 1 line of code. Good luck!




-bs0d | AllSyntax.com

    Viewed: 7,205 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

This Topic is Locked






"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank