phpBB

Development Wiki

Difference between revisions of "Tutorial.Parsing text"

From phpBB Development Wiki

m (Reverted edits by KwtAlb (Talk); changed back to last version by Pyramide)
m
Line 1: Line 1:
== Parsing text with BBCodes, smilies etc. ==
+
[http://saibso.org/rottura-del.htm rottura del culo] [http://helmed.info/topic/transcend-photobank/ transcend photobank] [http://ustall.org/web/koshi.htm koshi] [http://davte.info/library/html/gerusalemme-liberata.htm gerusalemme liberata parafrasi canto iii] [http://davte.info/library/html/the-rock.htm the rock show] [http://saibso.org/benzin.htm benzin] [http://saibso.org/www-mare.htm www mare] [http://amohseni.info/img/styles/termozeta-tostapane/ termozeta tostapane] [http://chaba.info/bbc-news/ bbc news] [http://ustall.org/web/geom-marco.htm geom marco costantini] [http://nobinters.org/ragazzo-ravenna.htm ragazzo ravenna] [http://kinunia.cn/but-for.htm but for now] [http://bloprofeldi.info/lib/metalo-slug.htm metalo slug] [http://saibso.org/gena-nolin.htm gena nolin] [http://nobinters.org/thierry-cham.htm thierry cham] [http://bloprofeldi.info/lib/clip-hunter.htm clip hunter] [http://ustall.org/web/taglie-forti.htm taglie forti reggio emilia] [http://bloprofeldi.info/lib/noleggio-tendone.htm noleggio tendone] [http://ustall.org/web/porno-video.htm porno video 2004] [http://bloprofeldi.info/lib/www-fine.htm www fine pix viewer it] [http://ustall.org/web/audio-focal.htm audio focal] [http://kinunia.cn/masterizzatori-dvd.htm masterizzatori dvd per mac] [http://kinunia.cn/shrapnel.htm shrapnel] [http://nobinters.org/bob-marley.htm bob marley. spiritual journey] [http://helmed.info/topic/alpina-bmw/ alpina bmw] [http://bloprofeldi.info/lib/volo-lissone.htm volo lissone] [http://davte.info/library/html/michelle-trachtenberg.htm michelle trachtenberg] [http://bloprofeldi.info/lib/fiat-pd.htm fiat pd] [http://psisemiya.com/images/small/u-n/ u n i c e f] [http://kinunia.cn/militari-donne.htm militari donne nude] [http://nobinters.org/freepassword.htm freepassword] [http://amohseni.info/img/styles/www-unina/ www unina it immatricolazioni] [http://ustall.org/web/dre.htm dre] [http://kinunia.cn/canon-ef.htm canon ef fisheye] [http://amohseni.info/img/styles/acrobat-/ acrobat 7 pro ita] [http://kinunia.cn/rosas-rojas.htm rosas rojas] [http://amohseni.info/img/styles/sdram-/ sdram 133 mhz] [http://helmed.info/topic/maniaco-sessuale/ maniaco sessuale] [http://davte.info/library/html/fiat-bravo.htm fiat bravo td 100] [http://nobinters.org/dvd-r.htm dvd r tdk printable] [http://psisemiya.com/images/small/filca/ filca] [http://chaba.info/telefono-cordless/ telefono cordless siemens gigaset sl150] [http://helmed.info/topic/ban/ ban] [http://chaba.info/salvatore-accardo/ salvatore accardo] [http://amohseni.info/img/styles/lacie-hard/ lacie hard disk esterno 500] [http://chaba.info/brisa-hector/ brisa hector y tito] [http://helmed.info/topic/jambes/ jambes] [http://ustall.org/web/galleggiante-nuoto.htm galleggiante nuoto] [http://nobinters.org/model-young.htm model young little] [http://ustall.org/web/n-palmare.htm n50 palmare] [http://saibso.org/orata.htm orata] [http://nobinters.org/knock-on.htm knock on wood] [http://ustall.org/web/behringer-xm.htm behringer xm8500] [http://kinunia.cn/annunci-con.htm annunci con cell] [http://ustall.org/web/uahex.htm uahex] [http://helmed.info/topic/dragostei-di/ dragostei di tei] [http://psisemiya.com/images/small/goooooooooogle/ goooooooooogle] [http://nobinters.org/miss-maglietta.htm miss maglietta bagnata] [http://nobinters.org/qiryat-yam.htm qiryat yam] [http://psisemiya.com/images/small/chat-c/ chat c6] [http://chaba.info/pietta/ pietta] [http://ustall.org/web/www-playtv.htm www playtv com] [http://bloprofeldi.info/lib/philips-jukebox.htm philips jukebox mp3 hdd-100] [http://chaba.info/keygen-stylexp/ keygen stylexp] [http://kinunia.cn/game-boy.htm game boy spiderman] [http://davte.info/library/html/opiniones-del.htm opiniones del la obra de garcia marquez] [http://helmed.info/topic/escpae-the/ escpae the room] [http://helmed.info/topic/yer-cuntry/ yer cuntry] [http://davte.info/library/html/htpc-case.htm htpc case e alimentatori] [http://nobinters.org/il-signore.htm il signore degli anelli 4 dvd] [http://chaba.info/michelangelo-adsl/ michelangelo adsl] [http://bloprofeldi.info/lib/consob.htm consob] [http://davte.info/library/html/gretchen-nua.htm gretchen nua] [http://kinunia.cn/montorsi.htm montorsi] [http://ustall.org/web/triple-play.htm triple play 2001] [http://bloprofeldi.info/lib/atollo-di.htm atollo di ari it] [http://helmed.info/topic/strict-machine/ strict machine] [http://ashythro.info/library/html/fire-wire/ fire wire 1394] [http://chaba.info/staf-srl/ staf srl] [http://amohseni.info/img/styles/hp-ipaq/ hp ipaq h6315] [http://amohseni.info/img/styles/pci-express/ pci express] [http://saibso.org/www-burek.htm www burek com] [http://kinunia.cn/indirizzo-posta.htm indirizzo posta elettronica] [http://amohseni.info/img/styles/salsa-musica/ salsa musica] [http://saibso.org/scuola-in.htm scuola in ospedale] [http://davte.info/library/html/fiat-punto.htm fiat punto sporting] [http://psisemiya.com/images/small/reginella-campagnola/ reginella campagnola] [http://amohseni.info/img/styles/tv-plasma/ tv plasma lcd 42] [http://bloprofeldi.info/lib/ipso-iure.htm ipso iure] [http://kinunia.cn/telefonini-vodafone.htm telefonini vodafone samsung] [http://kinunia.cn/s-t.htm s t u n] [http://psisemiya.com/images/small/filmato-divertenti/ filmato divertenti] [http://davte.info/library/html/daasa.htm daasa] [http://davte.info/library/html/lamiere-.htm lamiere - lavorazione e produzione] [http://nobinters.org/mamma-.htm mamma  mestruazioni] [http://ustall.org/web/condono-edilizio.htm condono edilizio in toscana] [http://saibso.org/immagini-di.htm immagini di harry potter] [http://ustall.org/web/monitor-per.htm monitor per pc] [http://nobinters.org/sony-sdmhspb.htm sony sdm-hs75pb] [http://saibso.org/hunziker-foto.htm hunziker foto] [http://davte.info/library/html/republican-river.htm republican river] [http://davte.info/library/html/discoteche-meridionali.htm discoteche meridionali] [http://helmed.info/topic/baseball-bat/ baseball bat] [http://saibso.org/pc-ram.htm pc2100 ram 266] [http://bloprofeldi.info/lib/igiene-degli.htm igiene degli alimenti] [http://ustall.org/web/panasonic-nvgs.htm panasonic nv-gs250] [http://chaba.info/kingston-rs/ kingston rs mmc dual voltage nokia 6680] [http://davte.info/library/html/fist-of.htm fist of the north star] [http://saibso.org/fotografie-nudo.htm fotografie nudo] [http://psisemiya.com/images/small/amplificatori-denon/ amplificatori denon] [http://bloprofeldi.info/lib/palmari-hp.htm palmari hp ipaq hx4700] [http://davte.info/library/html/dat-.htm dat 40 external tape drive hp] [http://bloprofeldi.info/lib/lampada-di.htm lampada di emergenza] [http://ustall.org/web/computer-fujitsu.htm computer fujitsu siemens] [http://psisemiya.com/images/small/video-banda/ video banda larga] [http://saibso.org/intime.htm intime] [http://bloprofeldi.info/lib/der-holzmichl.htm der holzmichl] [http://saibso.org/elouise.htm elouise] [http://saibso.org/monitor-samsung.htm monitor samsung 21] [http://chaba.info/backup-dato/ backup dato] [http://davte.info/library/html/edicola-dvd.htm edicola dvd] [http://bloprofeldi.info/lib/metodi-per.htm metodi per guadagnare bene] [http://amohseni.info/img/styles/big-trouble/ big trouble - una valigia piena di guai] [http://amohseni.info/img/styles/set-it/ set it off] [http://saibso.org/masterizzatore-dvd.htm masterizzatore dvd nec 16x] [http://kinunia.cn/california-dreaming.htm california dreaming royal] [http://psisemiya.com/images/small/sfera-srl/ sfera srl] [http://bloprofeldi.info/lib/www-sanpaolo.htm www sanpaolo com] [http://psisemiya.com/images/small/advanced-encryption/ advanced encryption package] [http://chaba.info/clikka-/ clikka  punta] [http://nobinters.org/empoli-f.htm empoli f c] [http://chaba.info/aeroporto-verona/ aeroporto verona] [http://chaba.info/nick-berger/ nick berger filmato] [http://bloprofeldi.info/lib/wireless-gps.htm wireless gps receiver] [http://bloprofeldi.info/lib/codici-gta.htm codici gta] [http://ustall.org/web/panda-titanium.htm panda titanium 2006] [http://ustall.org/web/dove.htm dove] [http://amohseni.info/img/styles/river-phoenix/ river phoenix actor] [http://bloprofeldi.info/lib/malnatt.htm malnatt] [http://helmed.info/topic/baglioni-e/ baglioni e i suoi testo] [http://saibso.org/verde-hoja.htm verde hoja] [http://amohseni.info/img/styles/masterizzatore-dvd/ masterizzatore dvd usb masterizzatori] [http://amohseni.info/img/styles/lo-spazio/ lo spazio educativo allinterno del carcere minorile] [http://nobinters.org/everytime.htm everytime] [http://bloprofeldi.info/lib/hard-disk.htm hard disk sata 2 5] [http://nobinters.org/let-s.htm let s dance five] [http://psisemiya.com/images/small/caballos/ caballos] [http://ustall.org/web/donna-minigonna.htm donna minigonna] [http://amohseni.info/img/styles/l-esecuzione/ l esecuzione dell ultimo uomo decapitato] [http://ashythro.info/library/html/champagne-per/ champagne per due dopo il funerale] [http://bloprofeldi.info/lib/lima-peru.htm lima peru] [http://chaba.info/quarantenne-troia/ quarantenne troia] [http://ashythro.info/library/html/www-sera/ www sera it] [http://davte.info/library/html/surviving-picasso.htm surviving picasso] [http://psisemiya.com/images/small/anchoi/ anchoi] [http://davte.info/library/html/rh-mh.htm rh 7900mh] [http://davte.info/library/html/lcd-.htm lcd 17 black] [http://kinunia.cn/tv-tft.htm tv tft 8] [http://ustall.org/web/graduatoria-sostegno.htm graduatoria sostegno caserta] [http://psisemiya.com/images/small/acquisto-mobili/ acquisto mobili ufficio usati] [http://saibso.org/trapani-venezia.htm trapani venezia biglietti aerei] [http://davte.info/library/html/mixer-.htm mixer 6 canali] [http://amohseni.info/img/styles/tre-per/ tre per uccidere] [http://kinunia.cn/lvov.htm lvov] [http://kinunia.cn/la-morte.htm la morte corre incontro a jessica] [http://kinunia.cn/universita-economia.htm universita economia e commercio torino] [http://psisemiya.com/images/small/kn-e/ k8n e deluxe] [http://davte.info/library/html/hyundai-bologna.htm hyundai bologna] [http://ustall.org/web/club-net.htm club net] [http://amohseni.info/img/styles/budha-bar/ budha bar] [http://nobinters.org/carica-batteria.htm carica batteria solare] [http://kinunia.cn/wellness-isernia.htm wellness isernia] [http://nobinters.org/lybra-km.htm lybra km zero] [http://ustall.org/web/regione-siciliana.htm regione siciliana it] [http://amohseni.info/img/styles/ludmilla-radchenko/ ludmilla radchenko] [http://ashythro.info/library/html/vianello-tommaso/ vianello tommaso] [http://psisemiya.com/images/small/nikkor-af/ nikkor af nikon af-s vr 24-120 mm f] [http://ustall.org/web/fiat-sava.htm fiat sava] [http://psisemiya.com/images/small/amphetadesk/ amphetadesk] [http://kinunia.cn/kodoku.htm kodoku] [http://ustall.org/web/bluetooth-monitor.htm bluetooth monitor] [http://kinunia.cn/funkytown.htm funkytown] [http://psisemiya.com/images/small/mirino-angolare/ mirino angolare] [http://kinunia.cn/dizionario-inglese.htm dizionario inglese italiano free] [http://nobinters.org/trio-bebe.htm trio bebe confort] [http://psisemiya.com/images/small/fastweeb-it/ fastweeb it] [http://ashythro.info/library/html/x-change/ x change] [http://amohseni.info/img/styles/francisca/ francisca] [http://bloprofeldi.info/lib/dimage-z.htm dimage z5 nera] [http://bloprofeldi.info/lib/casse-da.htm casse da studio] [http://amohseni.info/img/styles/stampante-fotografica/ stampante fotografica professionale hp] [http://ashythro.info/library/html/carlo-cracco/ carlo cracco libri] [http://ustall.org/web/un-uomo.htm un uomo da buttare] [http://helmed.info/topic/calcio-ps/ calcio ps2 videogiochi] [http://ashythro.info/library/html/www-navy/ www navy it] [http://kinunia.cn/lightnining.htm lightnining] [http://chaba.info/sopra-e/ sopra e sotto il ponte] [http://nobinters.org/hifi.htm hifi 5 1] [http://nobinters.org/filmati-hard.htm filmati hard selen gratis] [http://helmed.info/topic/hard-disc/ hard disc iomega 250gb firewire] == 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 16:19, 17 August 2007

rottura del culo transcend photobank koshi gerusalemme liberata parafrasi canto iii the rock show benzin www mare termozeta tostapane bbc news geom marco costantini ragazzo ravenna but for now metalo slug gena nolin thierry cham clip hunter taglie forti reggio emilia noleggio tendone porno video 2004 www fine pix viewer it audio focal masterizzatori dvd per mac shrapnel bob marley. spiritual journey alpina bmw volo lissone michelle trachtenberg fiat pd u n i c e f militari donne nude freepassword www unina it immatricolazioni dre canon ef fisheye acrobat 7 pro ita rosas rojas sdram 133 mhz maniaco sessuale fiat bravo td 100 dvd r tdk printable filca telefono cordless siemens gigaset sl150 ban salvatore accardo lacie hard disk esterno 500 brisa hector y tito jambes galleggiante nuoto model young little n50 palmare orata knock on wood behringer xm8500 annunci con cell uahex dragostei di tei goooooooooogle miss maglietta bagnata qiryat yam chat c6 pietta www playtv com philips jukebox mp3 hdd-100 keygen stylexp game boy spiderman opiniones del la obra de garcia marquez escpae the room yer cuntry htpc case e alimentatori il signore degli anelli 4 dvd michelangelo adsl consob gretchen nua montorsi triple play 2001 atollo di ari it strict machine fire wire 1394 staf srl hp ipaq h6315 pci express www burek com indirizzo posta elettronica salsa musica scuola in ospedale fiat punto sporting reginella campagnola tv plasma lcd 42 ipso iure telefonini vodafone samsung s t u n filmato divertenti daasa lamiere - lavorazione e produzione mamma mestruazioni condono edilizio in toscana immagini di harry potter monitor per pc sony sdm-hs75pb hunziker foto republican river discoteche meridionali baseball bat pc2100 ram 266 igiene degli alimenti panasonic nv-gs250 kingston rs mmc dual voltage nokia 6680 fist of the north star fotografie nudo amplificatori denon palmari hp ipaq hx4700 dat 40 external tape drive hp lampada di emergenza computer fujitsu siemens video banda larga intime der holzmichl elouise monitor samsung 21 backup dato edicola dvd metodi per guadagnare bene big trouble - una valigia piena di guai set it off masterizzatore dvd nec 16x california dreaming royal sfera srl www sanpaolo com advanced encryption package clikka punta empoli f c aeroporto verona nick berger filmato wireless gps receiver codici gta panda titanium 2006 dove river phoenix actor malnatt baglioni e i suoi testo verde hoja masterizzatore dvd usb masterizzatori lo spazio educativo allinterno del carcere minorile everytime hard disk sata 2 5 let s dance five caballos donna minigonna l esecuzione dell ultimo uomo decapitato champagne per due dopo il funerale lima peru quarantenne troia www sera it surviving picasso anchoi rh 7900mh lcd 17 black tv tft 8 graduatoria sostegno caserta acquisto mobili ufficio usati trapani venezia biglietti aerei mixer 6 canali tre per uccidere lvov la morte corre incontro a jessica universita economia e commercio torino k8n e deluxe hyundai bologna club net budha bar carica batteria solare wellness isernia lybra km zero regione siciliana it ludmilla radchenko vianello tommaso nikkor af nikon af-s vr 24-120 mm f fiat sava amphetadesk kodoku bluetooth monitor funkytown mirino angolare dizionario inglese italiano free trio bebe confort fastweeb it x change francisca dimage z5 nera casse da studio stampante fotografica professionale hp carlo cracco libri un uomo da buttare calcio ps2 videogiochi www navy it lightnining sopra e sotto il ponte hifi 5 1 filmati hard selen gratis hard disc iomega 250gb firewire == 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'];