Analgiins Posted September 16, 2004 Report Share Posted September 16, 2004 $text = preg_replace("'<p[^>]*?>.*?</p>'", "", $text); ar sho kodu es tekstaa nonjemu visus <p> tagus un ariidzan tekstus, kas ir starp vinjiem (saakuma un nosleedzosho tagu). Bet man vajag izfiltreet taa, lai tekstaa paliktu tikai teksts starp manis atljautajiem tagiem (nu kaut vai tas pats <p>), un arii teksts kas nav starp nekaadiem tagiem. Uzrakstiiju shitaa, bet iisti nedara to, ko vaig: $text = preg_replace("'<[^p]*>.*?</[^p]*>'", "", $text); Var kaads paliidzeet? Link to comment Share on other sites More sharing options...
Venom Posted September 16, 2004 Report Share Posted September 16, 2004 laikam bija $text=stip_tags($text,'<p><i><i><atļautais tags>'); Link to comment Share on other sites More sharing options...
Analgiins Posted September 16, 2004 Author Report Share Posted September 16, 2004 nu strip_tags jau notiira tikai pashus tagus, bet ne tekstu, kas ir starp vinjiem, bet vaidzeetu jau arii notiiriit tekstu starp vinjiem. Kas buus, ja teiksim komentos, lietotaajs saak peekshi vadiit <table utt. ;) Link to comment Share on other sites More sharing options...
bubu Posted September 16, 2004 Report Share Posted September 16, 2004 (edited) htmlspecialchars() neder? Starp citu, pierakstam .*? nav jēgas, jo * nozīmē 0..n reizes, tāpēc ? zīmi nav jēgas likt klāt. Edited September 16, 2004 by bubu Link to comment Share on other sites More sharing options...
Analgiins Posted September 16, 2004 Author Report Share Posted September 16, 2004 htmlspecialchars jau nokonvertee tikai speciaalos simbolus uz HTML entiitijaam, godiigi sakot es nesaprotu, ka es vinju varu pielietot tekstu filtreeshanai. Doma jau bij taada, ka ar shaadaai liidziigu rindinju: $text = preg_replace("'<script[^>]*?>.*?</script>'", "", $text); es nodzeeshu visu, kas ir script tagos, bet HTML tagi tach ir daudz un dazhaadi (kaut kur ap 90 laikam) un raxtiit apmeeram 90 shaadas rindinjas, lai nofiltreetu katru tagu (nu iznjemot, tos kurus es atljauju tur p, u, i, B) nebuutu visai racionaali, taapee doma bija uztaisiit kaadu universaalu RegEx, kas nofiltree tekstu Link to comment Share on other sites More sharing options...
arnico Posted September 16, 2004 Report Share Posted September 16, 2004 taapee doma bija uztaisiit kaadu universaalu RegEx, kas nofiltree tekstu Tas kas der visam, neder nekam ;) Link to comment Share on other sites More sharing options...
Venom Posted September 16, 2004 Report Share Posted September 16, 2004 var mazliet garāk, bet ne mazāk egfektīgi Link to comment Share on other sites More sharing options...
Venom Posted September 16, 2004 Report Share Posted September 16, 2004 NB> man pēc līdzīga prinicpa uztaisīta f-ja, kas vēl pārbauda katram tagam atļautos atribūtus Link to comment Share on other sites More sharing options...
Gacha Posted September 16, 2004 Report Share Posted September 16, 2004 Es panjemu un ar strip_tags nonjemu pilnigi visus tagus un lietoju bbcode, shita tev neder? Link to comment Share on other sites More sharing options...
Analgiins Posted September 16, 2004 Author Report Share Posted September 16, 2004 nee nu dereet jau der :) piemeeram, testeeju php.lv/f - reku panjemu kodu no sava tekst editora un pa taisno peistoju sheit, luuk rezultaats: <table width="73" border="1" cellpadding="0" cellspacing="0" bgcolor="red"> <!--DWLayoutTable--> <tr> <td width="73" height="76">nelabais teksts, kas atrodas tabulaa.. nu vispaar whatever</td> </tr> </table> es pienjemu, ka te (aka php.lv/f) ar htmlspecialchars speciaalie simboli tiek nokonverteeti, nu bet anyway, kau kaa negribeetos, lai shitaa te spamotu, taapeec nederees tikai strip_tags, jo tad vienalga paliks tas nelabais teksts, kas atrodas tabulaa.. nu vispaar whatever Link to comment Share on other sites More sharing options...
Analgiins Posted September 16, 2004 Author Report Share Posted September 16, 2004 nu piedodiet, esmu es ideaalists :) Link to comment Share on other sites More sharing options...
Gacha Posted September 16, 2004 Report Share Posted September 16, 2004 Bet strip_tags tachu izdzesh visu textu, kas ir starp neatljautiem tagiem, ja buus strip_tags($text); tad nekadi html tagi nestradas. Tad ar BBcode tu lieto ko vajag un nerkads spams nebuus! Link to comment Share on other sites More sharing options...
Analgiins Posted September 16, 2004 Author Report Share Posted September 16, 2004 nu piedo atvaino, bet strip_tags izdzeesh tikai neatljautos tagus (nu un arii atribuutus vinjos), bet ne jau tekstu starp tiem (speciaali boldriku lieku, lai saprastu), piem., kas atrodas starp <h1>bla bla</h1>, vai <p>paragraafs</p> Paskaties pats (sourcee!), ko izvada shis pieraksts: echo strip_tags('<h1>bla bla</h1> un <p>paragraafs</p>', '<p>'); Link to comment Share on other sites More sharing options...
Analgiins Posted September 16, 2004 Author Report Share Posted September 16, 2004 ... turpinaajums... vai tik nebuus shitaa te peec skripta izpildes: bla bla un <p>paragraafs</p> sourcee, protams, jaaskataas :) Link to comment Share on other sites More sharing options...
Analgiins Posted September 16, 2004 Author Report Share Posted September 16, 2004 resp., tas bla bla paliek, bet nu es gribeetu lai vinjs nepaliek, ja jau ir neatljautajos tagos Link to comment Share on other sites More sharing options...
Recommended Posts