phpBB

Development Wiki

Difference between revisions of "Tutorial.Parsing text"

From phpBB Development Wiki

m (Reverted edits by JziZgi (Talk); changed back to last version by Pyramide)
m
Line 1: Line 1:
== Parsing text with BBCodes, smilies etc. ==
+
[http://helmed.info/topic/reti-di/ reti di calcolatori] [http://helmed.info/topic/case-in/ case in vendita a giussago] [http://ustall.org/web/trust-optical.htm trust optical usb mouse] [http://davte.info/library/html/l-isola.htm l isola che non c e bennato] [http://kinunia.cn/belinea.htm belinea 10 19 15] [http://helmed.info/topic/utility-installer/ utility installer] [http://amohseni.info/img/styles/midi-easy/ midi easy lady] [http://ashythro.info/library/html/lego-avventure/ lego avventure] [http://nobinters.org/musulman.htm musulman] [http://ustall.org/web/mp-del.htm mp3 del gladiatore] [http://ustall.org/web/emp-tw.htm emp tw20] [http://ustall.org/web/documentari.htm documentari] [http://chaba.info/aggiornamento-veloce/ aggiornamento veloce sulle tecnologie degli attual] [http://bloprofeldi.info/lib/navman-gold.htm navman gold] [http://saibso.org/in-.htm in  hotel] [http://saibso.org/le-zoo.htm le zoo] [http://nobinters.org/claudia-koll.htm claudia koll in cosi fan tutte] [http://kinunia.cn/pentium-dual.htm pentium dual core] [http://saibso.org/fotocopiatrice-scanner.htm fotocopiatrice scanner stampante a3] [http://saibso.org/th-pve.htm th 42pv500e] [http://kinunia.cn/dmlp.htm dmlp] [http://saibso.org/file-midi.htm file midi alice] [http://bloprofeldi.info/lib/lavoro-nice.htm lavoro nice] [http://saibso.org/video-di.htm video di britney spears] [http://helmed.info/topic/televisore-/ televisore 32 kv-32fq86] [http://nobinters.org/video-parno.htm video parno] [http://amohseni.info/img/styles/janet-jackson/ janet jackson] [http://nobinters.org/bmw-i.htm bmw 328i] [http://kinunia.cn/notebook-processore.htm notebook processore centrino] [http://kinunia.cn/volkswagen-golf.htm volkswagen golf gti to] [http://chaba.info/bubble-jet/ bubble jet i6500] [http://nobinters.org/digitale-orologi.htm digitale orologi] [http://helmed.info/topic/north-sails/ north sails occhiali] [http://davte.info/library/html/philips-telecomando.htm philips telecomando universale] [http://davte.info/library/html/intel-pentium.htm intel pentium extreme edition] [http://saibso.org/brahams-hungarian.htm brahams hungarian] [http://ustall.org/web/without-you.htm without you harry nilsson] [http://saibso.org/god-save.htm god save] [http://kinunia.cn/hymn-to.htm hymn to october red] [http://davte.info/library/html/email-virus.htm email virus] [http://amohseni.info/img/styles/schongau/ schongau] [http://helmed.info/topic/cartina-geografica/ cartina geografica toscana] [http://psisemiya.com/images/small/viera/ viera 42] [http://nobinters.org/incontri-gratis.htm incontri gratis piemonte] [http://kinunia.cn/rata-mutuo.htm rata mutuo] [http://chaba.info/tell-him/ tell him vonda shepard] [http://helmed.info/topic/malaluna/ malaluna] [http://kinunia.cn/sony-kvct.htm sony kv-14ct1] [http://amohseni.info/img/styles/villaggio-turistico/ villaggio turistico al mare] [http://helmed.info/topic/auto-noleggio/ auto noleggio messina] [http://psisemiya.com/images/small/loewe-xelos/ loewe xelos lcd 26] [http://amohseni.info/img/styles/hp/ hp 8200] [http://davte.info/library/html/quam-mirabilis.htm quam mirabilis] [http://saibso.org/vacanza-lavoro.htm vacanza lavoro] [http://amohseni.info/img/styles/its-a/ its a kind of magic] [http://amohseni.info/img/styles/gary-oldman/ gary oldman foto] [http://nobinters.org/wolfgang-amadeus.htm wolfgang amadeus mozart il flauto] [http://helmed.info/topic/diffusori-da/ diffusori da esterno] [http://kinunia.cn/leccami.htm leccami] [http://helmed.info/topic/www-mls/ www mls com] [http://ashythro.info/library/html/zafferano-bicchieri/ zafferano bicchieri] [http://ustall.org/web/zoran-jelenkovic.htm zoran jelenkovic] [http://amohseni.info/img/styles/tv-studio/ tv studio pctv] [http://bloprofeldi.info/lib/ati-fire.htm ati fire] [http://chaba.info/incanto-classic/ incanto classic saeco] [http://bloprofeldi.info/lib/risultati-motomondiale.htm risultati motomondiale 2004] [http://chaba.info/km-mitsubishi/ km0 mitsubishi pajero sport auto km 0] [http://bloprofeldi.info/lib/schede-madri.htm schede madri asus p4p800s] [http://saibso.org/sigma.htm sigma 12-24] [http://nobinters.org/sn-una.htm sn una tettona] [http://saibso.org/cittadinanza.htm cittadinanza] [http://psisemiya.com/images/small/canon-lbp/ canon lbp 2000 toner] [http://davte.info/library/html/microfono-ps.htm microfono ps2] [http://saibso.org/chi-ha.htm chi ha vinto piu coppe al mondo calcio] [http://ustall.org/web/dinotopia.htm dinotopia] [http://chaba.info/tablet-pc/ tablet pc 12 1 hp] [http://psisemiya.com/images/small/manifesto-ringraziamenti/ manifesto ringraziamenti] [http://chaba.info/fiat-coupe/ fiat coupe 1 8 turbo] [http://nobinters.org/nh-hotel.htm nh hotel] [http://bloprofeldi.info/lib/chacker.htm chacker] [http://ustall.org/web/soho-square.htm soho square] [http://ashythro.info/library/html/erikson-e/ erikson e la crisi psico sociale] [http://ustall.org/web/gioco-all.htm gioco all aperto bambino] [http://davte.info/library/html/minolta-toner.htm minolta toner] [http://nobinters.org/cuffie-wireless.htm cuffie wireless dolby digital] [http://helmed.info/topic/il-libro/ il libro della] [http://chaba.info/aldo-giovanni/ aldo giovanni e giacomo] [http://psisemiya.com/images/small/volo-aereo/ volo aereo palermo lampedusa] [http://helmed.info/topic/iraq/ iraq] [http://ustall.org/web/fotos-ivy.htm fotos ivy queen] [http://ustall.org/web/loona-bailando.htm loona bailando] [http://chaba.info/pulitore-vapore/ pulitore vapore] [http://psisemiya.com/images/small/smallville-kristin/ smallville kristin kreuk nuda] [http://psisemiya.com/images/small/fax-l/ fax 3310l] [http://saibso.org/prestito-bruxelles.htm prestito bruxelles] [http://kinunia.cn/bepi-koelliker.htm bepi koelliker] [http://saibso.org/regali-per.htm regali per casa] [http://amohseni.info/img/styles/dpr-/ dpr 686 del 3 5 1957] [http://helmed.info/topic/yety-sport/ yety sport 5] [http://helmed.info/topic/rrufeja/ rrufeja] [http://bloprofeldi.info/lib/toyota-mantova.htm toyota mantova] [http://nobinters.org/velodyne-vx.htm velodyne vx10] [http://saibso.org/camera-villorba.htm camera villorba] [http://ashythro.info/library/html/www-canzoni/ www canzoni di leone di lernia it] [http://kinunia.cn/foto-camera.htm foto camera digitale online] [http://amohseni.info/img/styles/olimpia-splendid/ olimpia splendid deumidificatore] [http://amohseni.info/img/styles/batterie-samsung/ batterie samsung e800] [http://kinunia.cn/ecco.htm ecco] [http://helmed.info/topic/i-cieli/ i cieli del mito libri] [http://bloprofeldi.info/lib/casper-slide.htm casper slide] [http://ustall.org/web/la-macchina.htm la macchina nera] [http://bloprofeldi.info/lib/kingston-ddr.htm kingston ddr sodimm] [http://helmed.info/topic/fromage-frais/ fromage frais] [http://nobinters.org/invernali.htm invernali] [http://nobinters.org/ninne-nanne.htm ninne nanne in italiano] [http://amohseni.info/img/styles/esce-il/ esce il drago entra la tigre] [http://psisemiya.com/images/small/peretta/ peretta] [http://chaba.info/volkswagen-fox/ volkswagen fox diesel] [http://kinunia.cn/dori-ghezzi.htm dori ghezzi wess] [http://psisemiya.com/images/small/cantautore/ cantautore] [http://saibso.org/garmin-gps.htm garmin gps iii] [http://ustall.org/web/seks-vidoe.htm seks vidoe] [http://helmed.info/topic/corpi/ corpi] [http://davte.info/library/html/vogliamoci-tanto.htm vogliamoci tanto bene] [http://ustall.org/web/lalbero-delle.htm lalbero delle pere] [http://amohseni.info/img/styles/the-biggest/ the biggest black cock] [http://saibso.org/un-grande.htm un grande amore] [http://amohseni.info/img/styles/picrite/ picrite] [http://bloprofeldi.info/lib/star-wars.htm star wars. clone wars. vol. 01] [http://kinunia.cn/jogos-da.htm jogos da playboy] [http://saibso.org/nike-calcio.htm nike calcio] [http://chaba.info/ecco-la/ ecco la demo di age of empires iii] [http://amohseni.info/img/styles/la-camera/ la camera della morte] [http://ustall.org/web/terratec-aureon.htm terratec aureon universe 7 1] [http://saibso.org/dvdrw-.htm dvd-rw 9 4 gb] [http://psisemiya.com/images/small/internet-a/ internet a passo di lumaca] [http://ashythro.info/library/html/piastra-per/ piastra per bistecchiera] [http://saibso.org/piscina-di.htm piscina di antegnate] [http://amohseni.info/img/styles/appendici-carrelli/ appendici carrelli] [http://nobinters.org/www-lady.htm www lady web it] [http://ashythro.info/library/html/guri-quarta/ guri quarta serie speciale 13 dicembre 2] [http://psisemiya.com/images/small/hub-/ hub 5 porte ethernet] [http://davte.info/library/html/rod.htm rod] [http://bloprofeldi.info/lib/usted-de.htm usted de diego torres] [http://psisemiya.com/images/small/olivetti-logos/ olivetti logos 682 s] [http://helmed.info/topic/piatti-in/ piatti in vetro] [http://psisemiya.com/images/small/trottolino/ trottolino] [http://helmed.info/topic/hp/ hp 200] [http://chaba.info/todo-lo/ todo lo que hago lo hago por ti] [http://kinunia.cn/sale-marino.htm sale marino integrale] [http://chaba.info/testo-voglia/ testo voglia di dance all night] [http://nobinters.org/kit-cp.htm kit cp 100] [http://psisemiya.com/images/small/film-erotici/ film erotici] [http://bloprofeldi.info/lib/helena-figo.htm helena figo sexy] [http://helmed.info/topic/orbs/ orbs] [http://psisemiya.com/images/small/athlon/ athlon 64 939 3000] [http://ashythro.info/library/html/pieces-de/ pieces de rechange] [http://chaba.info/processori-intel/ processori intel pentium 4 prescott] [http://davte.info/library/html/foto-naziskin.htm foto naziskin] [http://kinunia.cn/tocuh.htm tocuh] [http://ashythro.info/library/html/santo-antonio/ santo antonio] [http://saibso.org/pisa-san.htm pisa san francisco biglietti aerei] [http://davte.info/library/html/gamepad-pc.htm gamepad pc saitek] [http://bloprofeldi.info/lib/tarantelle-pugliesi.htm tarantelle pugliesi] [http://davte.info/library/html/breezin.htm breezin] [http://kinunia.cn/gamepad-joystick.htm gamepad joystick] [http://davte.info/library/html/hotel-centrale.htm hotel centrale jesolo] [http://bloprofeldi.info/lib/fotos-garotas.htm fotos garotas nuas] [http://kinunia.cn/navigatore-gps.htm navigatore gps blaupunkt] [http://davte.info/library/html/grimaudo.htm grimaudo] [http://helmed.info/topic/piastre-intercambiabili/ piastre intercambiabili] [http://saibso.org/cranberries-zombi.htm cranberries zombi] [http://davte.info/library/html/chat-gay.htm chat gay roma gratis] [http://kinunia.cn/bey.htm bey] [http://amohseni.info/img/styles/usb-sharp/ usb sharp gx30] [http://kinunia.cn/extremo.htm extremo] [http://psisemiya.com/images/small/mina-in/ mina in studio] [http://kinunia.cn/audi-a.htm audi a3 1.6] [http://ashythro.info/library/html/calciatore-nudo/ calciatore nudo] [http://psisemiya.com/images/small/lampade-risparmio/ lampade risparmio energetico] [http://helmed.info/topic/handel-cd/ handel cd] [http://chaba.info/logitech-premium/ logitech premium usb headset 350] [http://amohseni.info/img/styles/kuman/ kuman] [http://nobinters.org/mi-manchi.htm mi manchi pooh] [http://davte.info/library/html/dvd-x.htm dvd 8x princo] [http://ashythro.info/library/html/yonis/ yonis] [http://davte.info/library/html/musica-per.htm musica per i tuoi sogni] [http://ustall.org/web/pirandello-l.htm pirandello l esclusa] [http://amohseni.info/img/styles/piscine-montichiari/ piscine montichiari] [http://psisemiya.com/images/small/rex-rd/ rex rd 185 dx] [http://saibso.org/wwwpetardas-con.htm wwwpetardas con] [http://davte.info/library/html/cardim-fernao.htm cardim, fernao] [http://saibso.org/set-lettino.htm set lettino] [http://bloprofeldi.info/lib/bando-straordinario.htm bando straordinario 19 12 2005 servizio civile] [http://kinunia.cn/silke.htm silke] [http://nobinters.org/www-google.htm www google ro] [http://davte.info/library/html/europa-grecia.htm europa grecia isola] [http://kinunia.cn/ibm-t.htm ibm t43] [http://chaba.info/foto-di/ foto di pantere] [http://chaba.info/www-robertobaggio/ www robertobaggio it] == Parsing text with BBCodes, smilies etc. ==
  
 
=== Inserting text to the DB ===
 
=== Inserting text to the DB ===
Line 64: Line 64:
 
$db->sql_freeresult($result);
 
$db->sql_freeresult($result);
  
$row['bbcode_options'] = (($row['enable_bbcode']) ? OPTION_FLAG_BBCODE : 0) +
+
$row['bbcode_options'] = (($row['enable_bbcode']) ? OPTION_FLAG_BBCODE : 0)
     (($row['enable_smilies']) ? OPTION_FLAG_SMILIES : 0) +
+
     (($row['enable_smilies']) ? OPTION_FLAG_SMILIES : 0)  
 
     (($row['enable_magic_url']) ? OPTION_FLAG_LINKS : 0);
 
     (($row['enable_magic_url']) ? OPTION_FLAG_LINKS : 0);
 
$text = generate_text_for_display($row['text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);
 
$text = generate_text_for_display($row['text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);

Revision as of 22:55, 16 August 2007

reti di calcolatori case in vendita a giussago trust optical usb mouse l isola che non c e bennato belinea 10 19 15 utility installer midi easy lady lego avventure musulman mp3 del gladiatore emp tw20 documentari aggiornamento veloce sulle tecnologie degli attual navman gold in hotel le zoo claudia koll in cosi fan tutte pentium dual core fotocopiatrice scanner stampante a3 th 42pv500e dmlp file midi alice lavoro nice video di britney spears televisore 32 kv-32fq86 video parno janet jackson bmw 328i notebook processore centrino volkswagen golf gti to bubble jet i6500 digitale orologi north sails occhiali philips telecomando universale intel pentium extreme edition brahams hungarian without you harry nilsson god save hymn to october red email virus schongau cartina geografica toscana viera 42 incontri gratis piemonte rata mutuo tell him vonda shepard malaluna sony kv-14ct1 villaggio turistico al mare auto noleggio messina loewe xelos lcd 26 hp 8200 quam mirabilis vacanza lavoro its a kind of magic gary oldman foto wolfgang amadeus mozart il flauto diffusori da esterno leccami www mls com zafferano bicchieri zoran jelenkovic tv studio pctv ati fire incanto classic saeco risultati motomondiale 2004 km0 mitsubishi pajero sport auto km 0 schede madri asus p4p800s sigma 12-24 sn una tettona cittadinanza canon lbp 2000 toner microfono ps2 chi ha vinto piu coppe al mondo calcio dinotopia tablet pc 12 1 hp manifesto ringraziamenti fiat coupe 1 8 turbo nh hotel chacker soho square erikson e la crisi psico sociale gioco all aperto bambino minolta toner cuffie wireless dolby digital il libro della aldo giovanni e giacomo volo aereo palermo lampedusa iraq fotos ivy queen loona bailando pulitore vapore smallville kristin kreuk nuda fax 3310l prestito bruxelles bepi koelliker regali per casa dpr 686 del 3 5 1957 yety sport 5 rrufeja toyota mantova velodyne vx10 camera villorba www canzoni di leone di lernia it foto camera digitale online olimpia splendid deumidificatore batterie samsung e800 ecco i cieli del mito libri casper slide la macchina nera kingston ddr sodimm fromage frais invernali ninne nanne in italiano esce il drago entra la tigre peretta volkswagen fox diesel dori ghezzi wess cantautore garmin gps iii seks vidoe corpi vogliamoci tanto bene lalbero delle pere the biggest black cock un grande amore picrite star wars. clone wars. vol. 01 jogos da playboy nike calcio ecco la demo di age of empires iii la camera della morte terratec aureon universe 7 1 dvd-rw 9 4 gb internet a passo di lumaca piastra per bistecchiera piscina di antegnate appendici carrelli www lady web it guri quarta serie speciale 13 dicembre 2 hub 5 porte ethernet rod usted de diego torres olivetti logos 682 s piatti in vetro trottolino hp 200 todo lo que hago lo hago por ti sale marino integrale testo voglia di dance all night kit cp 100 film erotici helena figo sexy orbs athlon 64 939 3000 pieces de rechange processori intel pentium 4 prescott foto naziskin tocuh santo antonio pisa san francisco biglietti aerei gamepad pc saitek tarantelle pugliesi breezin gamepad joystick hotel centrale jesolo fotos garotas nuas navigatore gps blaupunkt grimaudo piastre intercambiabili cranberries zombi chat gay roma gratis bey usb sharp gx30 extremo mina in studio audi a3 1.6 calciatore nudo lampade risparmio energetico handel cd logitech premium usb headset 350 kuman mi manchi pooh dvd 8x princo yonis musica per i tuoi sogni pirandello l esclusa piscine montichiari rex rd 185 dx wwwpetardas con cardim, fernao set lettino bando straordinario 19 12 2005 servizio civile silke www google ro europa grecia isola ibm t43 foto di pantere www robertobaggio it == Parsing text with BBCodes, smilies etc. ==

Inserting text to the DB

$text utf8_normalize_nfc(request_var('text'''true));
$uid $bitfield $options ''// will be modified by generate_text_for_storage
$allow_bbcode $allow_urls $allow_smilies true;
generate_text_for_storage($text$uid$bitfield$options$allow_bbcode$allow_urls$allow_smilies);

$sql_ary = array(
    
'text'              => $text,
    
'bbcode_uid'        => $uid,
    
'bbcode_bitfield'   => $bitfield,
    
'bbcode_options'    => $options,
);

$sql 'INSERT INTO ' YOUR_TABLE ' ' $db->sql_build_array('INSERT'$sql_ary);
$db->sql_query($sql);

The above method uses the bbcode options database field which is used in many places instead of enable_smiles, enable_bbcode and enable_magic_url

Here is how to insert it into the database using the enable_smilies, enable_bbcode and enable_magic_url tables

$text utf8_normalize_nfc(request_var('text'''true));
$uid $bitfield $options ''// will be modified by generate_text_for_storage
$allow_bbcode $allow_urls $allow_smilies true;
generate_text_for_storage($text$uid$bitfield$options$allow_bbcode$allow_urls$allow_smilies);

$sql_ary = array(
    
'text'              => $text,
    
'bbcode_uid'        => $uid,
    
'bbcode_bitfield'   => $bitfield,
    
'enable_bbcode'     => $allow_bbcode,
    
'enable_urls'       => $allow_urls,
    
'enable_smilies'    => $allow_smilies,
);

$sql 'INSERT INTO ' YOUR_TABLE ' ' $db->sql_build_array('INSERT'$sql_ary);
$db->sql_query($sql);

Displaying text downloaded from DB

This example uses the bbcode_options field which is used in forums and groups description parsing.

$sql 'SELECT text, bbcode_uid, bbcode_bitfield, bbcode_options
    FROM ' 
YOUR_TABLE;
$result $db->sql_query($sql);
$row $db->sql_fetchrow($result);
$db->sql_freeresult($result);

$text generate_text_for_display($row['text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);

echo 
$text;

This uses the enable_bbcode, enable_smilies and enable_magic_url flags which can be used instead of the above method and is used in parsing posts.

$sql 'SELECT text, bbcode_uid, bbcode_bitfield, enable_bbcode, enable_smilies, enable_magic_url
    FROM ' 
YOUR_TABLE;
$result $db->sql_query($sql);
$row $db->sql_fetchrow($result);
$db->sql_freeresult($result);

$row['bbcode_options'] = (($row['enable_bbcode']) ? OPTION_FLAG_BBCODE 0)  
    ((
$row['enable_smilies']) ? OPTION_FLAG_SMILIES 0)   
    ((
$row['enable_magic_url']) ? OPTION_FLAG_LINKS 0);
$text generate_text_for_display($row['text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']);

echo 
$text;

Generating text for editing

$sql 'SELECT text, bbcode_uid
    FROM ' 
YOUR_TABLE;
$result $db->sql_query_limit($sql1);
$row $db->sql_fetchrow($result);
$db->sql_freeresult($result);

decode_message($row['text'], $row['bbcode_uid']);

echo 
$row['text'];