Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
form processing

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
gog



Joined: 18 Jun 2004
Posts: 679
Location: zagreb

PostPosted: 23.06.2006 12:05    Post subject: form processing Add user to your forum ignore list Reply with quote

Do sada sam stvari radio nekako ovako:

Nakon postanja forme ide:

Code:
    function quote_smart($value)
    {
        // Stripslashes
        if (get_magic_quotes_gpc()) {
            $value = stripslashes($value);
        }
        // Quote if not a number or a numeric string
        if (!is_numeric($value)) {
            $value = mysql_real_escape_string($value);
        }
        return $value;
    }


Kako bi se svugdje sve lijepo escapalo, vjerovali iline neki još uvijek imaju magic_quote uključen Sad

Kada vraćam to nazad u formu za editiranje, ide nešto ala:

Code:
        foreach ($row as $key=>$value) {
            $search = array('&', '<', '>', '\'', '"');
            $replace = array('&amp;', '&lt;', '&gt;', '&apos;', '&quot;');
            $row[$key] = str_replace($search, $replace, $value);
        }


zato kaj mi htmlspecialchars ujebu utf-8 znakove iz nekog razloga iako mu stavi utf-8 kao argument.

Da li je ovo gore bullet proof riješenje ili sam možda nešto zaboravio?

Ukoliko je netko spreman podijeliti samnom neku funkciju koja bi se sama brinula da ako su navodnici unutar <> da ih ostavi takvima, a ukoliko su van <> zagrada da ih zamijeni sa &quot; bio bih jako zahvalan...
Back to top
View user's profile Send private message Visit poster's website
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 23.06.2006 13:17    Post subject: Add user to your forum ignore list Reply with quote

Ma ne brini se oko navodnika... escape-aj samo &amp i &lt, mislim da će biti dovoljno
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gog



Joined: 18 Jun 2004
Posts: 679
Location: zagreb

PostPosted: 23.06.2006 14:29    Post subject: Add user to your forum ignore list Reply with quote

Neće, jer mi je naporno pisati &quot; umjesto " svaki put kada pišem tekst ili kopi pejstam Smile
Back to top
View user's profile Send private message Visit poster's website
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 23.06.2006 18:09    Post subject: Add user to your forum ignore list Reply with quote

e sad si me izgubio

start over
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gog



Joined: 18 Jun 2004
Posts: 679
Location: zagreb

PostPosted: 23.06.2006 18:43    Post subject: Add user to your forum ignore list Reply with quote

OK, radi se u biti o dvije stvari. Ajmo ovako:

Kada pišeš nešto u HTML-u " postaje &quot;, & postaje &amp; i sl. No ukoliko je taj navodnik dio od recimo <a href="link">link</a> onda ga ne želiš zamijeniti sa &quot; Smile

Znači, imam text box u koji unesem:

Code:
bla bla bla "bla" bla bla <a href="link">bla</a> bla bla


I želim taj string prije nego ga pohranim u bazu zamijeniti sa:

Code:
bla bla bla &quot;bla&quot; bla bla <a href="link">bla</a> bla bla


p.s. Nisam znao da altgr+c kreira [ code ] Smile[/code]
Back to top
View user's profile Send private message Visit poster's website
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 24.06.2006 21:51    Post subject: Add user to your forum ignore list Reply with quote

Aha, tebe muči "pametni" escape?

Napravi regexp koji nalazi stvari koje ne želiš escape-ati (kao HTML tagove), zamijeni ih sa nekim proizvoljnim placeholderima, escapeaj sve i nakon toga zamijeni placeholdere sa originalnim tagovima

ILI

napravi jednostavan parser koji uzima blok po blok (serijski) i odlučuje da li će ga escape-ati ili neće (ako vidi da je tag onda neće) i kasnije sve slijepi natrag u jedan string?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
_butch



Joined: 10 Sep 2003
Posts: 870
Location: Maichno, Krlovc

PostPosted: 25.06.2006 14:54    Post subject: Add user to your forum ignore list Reply with quote

U biti mozes si napraviti svoj parser, recimo
Code:

bla bla *bla* bla bla  <a href="link">Klik</a>

ti parsa u
Code:

bla bla &quot;bla&quot; <a href="link">Klik</a>

Tipa markdown ili textile..

_________________
FRENCH GUARD: No chance, English bed-wetting types.
I burst my pimples at you and call your door-opening request a silly thing, you tiny-brained wipers of other people's bottoms!
Flikrac
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 25.06.2006 16:56    Post subject: Add user to your forum ignore list Reply with quote

Haha Smile ja sam popizdio nad PHP kad sam pisao Textile klon (TextilePHP je tiha jeza od 4000+ linija) te sam prešao na Ruby

Krenuo sam u njemu i vidio da je stvar već gotova - zove se RedCloth: oba Textile i Markdown u manje od 1000 linija Smile

_butch: niti jedna Textile implementacija nije zapravo parser nego sve rade preko regexpa... parser je ipak malo kompliciranija stvar, ali jednostavan parser za samo ovo (pošto nije programski jezik) ne bi možda bilo teško napraviti
Back to top
View user's profile Send private message Send e-mail Visit poster's website
_butch



Joined: 10 Sep 2003
Posts: 870
Location: Maichno, Krlovc

PostPosted: 25.06.2006 17:40    Post subject: Add user to your forum ignore list Reply with quote

Iako po meni su Textile i Markdown najgora rjesenja za takve stvari, bilokakav text formatting etc. etc.

Sulien: "parser" je uzet metaforicki i treba ga shvatiti pod debelim navodnicima. Smile (opaska autora Smile )
peace out!1

_________________
FRENCH GUARD: No chance, English bed-wetting types.
I burst my pimples at you and call your door-opening request a silly thing, you tiny-brained wipers of other people's bottoms!
Flikrac
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 25.06.2006 19:52    Post subject: Add user to your forum ignore list Reply with quote

Textile je predobra stvar. U Java implementaciji Textile-a si mogao napraviti cijelu stranicu samo plain-text markupom.

Koja su bolja rješenja? FCKeditor? Sigurno ne pisanje HTML-a ručno Confused
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group