Jump to content

Recommended Posts

Posted (edited)

I'm trying to write a stringregexp to catch all html tags except the basics (b, i, u, and s) but it isn't going so well...

I don't think StringRegExp() is necessary.. just do something like this:

StringReplace($content, "<span>", "")

Ah, but you would have to do every single tag individually.. :shocked:

Edit: Double post.. oops.. sorry!

Edited by sandman

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

  • Replies 80
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted (edited)

got it!

Run this on all of your posts before putting them into the database:

Func _StringStripBadHtml ($s)
    Return StringRegExpReplace ($s, "(</?[^<>buis]>)|(</?[^/<>][^<>]+>)", "")
EndFunc

That will allow basic tags: <b>, <i>, <u>, and <s>, but it will delete any other html tags, including <script>.

*is proud* :shocked:

edit: oh, and that is tested. It definitely works.

Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Posted (edited)

got it!

Run this on all of your posts before putting them into the database:

Func _StringStripBadHtml ($s)
    Return StringRegExpReplace ($s, "(</?[^<>buis]>)|(</?[^/<>][^<>]+>)", "")
EndFunc

That will allow basic tags: <b>, <i>, <u>, and <s>, but it will delete any other html tags, including &lt;script>.

*is proud* :(

edit: oh, and that is tested. It definitely works.

Oh, hehe.. scratch my last post, I didn't know StringRegExp() had that capability.

Edit: I am adding it into the mod for v0.2 :shocked:

Edited by sandman

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Posted

Oh, hehe.. scratch my last post, I didn't know StringRegExp() had that capability.

Edit: I am adding it into the mod for v0.2 :shocked:

yeah, regular expressions are pretty powerful if you know what you're doing.

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Posted (edited)

Okay, v0.2 is up for grabs. Check the first post for download. Senton-Bomb.. do you think you could set up the host again now that its secure?

Edit: Whoa, I think all my posts on this topic have been edited at least twice.. :shocked:

Edited by sandman

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Posted

StringReplace(StringReplace(StringReplace($s, @CRLF, @CR), @LF, @CR), @CR, "<br />")

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Posted

That's added into v0.2 also. thanks!

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Posted (edited)

You need to add default.css into your website root :shocked:

Another edit :( : Also, I forgot to change one variable.. the line break thingy won't work. I will edit this again when I have posted the fixed version.

Edited by sandman

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Posted

fixed admin.auw:

;admin.auw
;HTML coding and AU3 Coding by sandman (may_contain_peanuts2@yahoo.com)
;CSS skin by www.freecsstemplates.com

#include "web.au3"
#include <File.au3>

_StartWebApp("BlogIt Administration")
Global $content = "<link rel='stylesheet' href='..\default.css'><div id='logo'><h1><a href='#'>blogit</a></h1><h2><a href='#'>administration panel</a></h2></div><div id='menu'><ul><li class='active'><a href='index.auw' title=''>Homepage</a></li><li><a href='#' title=''>Archive</a></li></ul></div><div id='wrapper'> <div id='col-two'><div class='boxed'><h2 class='title'>add an entry</h2><div class='content'><form method='get' width=100%><textarea rows='10' cols='70%' name='content'></textarea><div id='smallfont'>HTML code is allowed, except any CSS references, DIV, SPAN, or P tags.</div><p align='right'><input type='reset' value='Clear Form' name='B2'><input type='submit' value='Submit Post'></p></form>"
If _Get("content") = "" Then
    Echo($content)
Else
    $content &= "<center><img src='loading.gif' width='32' height='32'><br>Please wait.. posting entry."
    Echo($content)
    $newentry = _Get("content")
    $entry = StringReplace($newentry, "+", " ")
    $headerthingy = "<div class='boxed'><h2 class='title'>Post</h2><div class='content'>"
    ;add to the post header
    $headerPG = FileOpen("html/postheader.html", 01)
    $footerPG = FileRead("html/postfooter.html", 01)
    $entryy =  StringRegExpReplace ($entry, "(</?[^<>buis]>)|(</?[^/<>][^<>]+>)", "")
    $entryyy = StringReplace(StringReplace(StringReplace($entryy, @CRLF, @CR), @LF, @CR), @CR, "<br />")                ;automatically change line breaks to <br />
    FileWriteLine($headerPG, @CRLF & $headerthingy & $entryyy & $footerPG & "</div></div>")
    If @Error Then _MsgBox(@error)
    ;create the archive file
    _FileCreate("entries\" & @YEAR & "." & @MON & "." & @YDAY & "-" & @HOUR & "-" & @MIN & "-" & @SEC & ".txt")
    FileWrite("entries\" & @YEAR & "." & @MON & "." & @YDAY & "-" & @HOUR & "-" & @MIN & "-" & @SEC & ".txt", $entryy)
    Sleep(2000)
    $content = "<br>Entry posted! <a href='index.auw'>View Your Blog</a>"
    Echo($content)
EndIf

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Posted

Thanks, I fixed that.. but in your code you also need to change the archive file to write from $entryyy, not $entryy.

Anyway, new bugfixed version is up.. please get the new one.

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Posted (edited)

New bug found: Along with the new allowing of <a> tags, now every post is linked. Theguy0000 is fixing it right now..

Oh, man.. that makes me feel unimportant. Well, it'll be fixed soon.

Edit: Oops.. double post again :">

Anyway, that wasn't a real bug, just an unclosed <a> tag.

Edited by sandman

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Posted

New bug found: Along with the new allowing of <a> tags, now every post is linked. Theguy0000 is fixing it right now..

Oh, man.. that makes me feel unimportant. Well, it'll be fixed soon.

it's not a problem with the code. It is not a bug.

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Posted (edited)

I'm trying to write a stringregexp to catch all html tags except the basics (b, i, u, and s) but it isn't going so well...

Me and RazerM wrote this for Cobra.. Back in the days.. :shocked:

edit: code was corrupted due to forum update.

Edited by Manadar
Posted

you do know that I already got it working, right?

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Posted

Yeah, we did it in a way that's a little bit simpler :shocked:

$entry = StringRegExpReplace($newentry, '(</?[^<>buis]>)|(</?[^/<>a][^<>]+>)', "")

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Posted (edited)

What RazerM and me did is totally different, it's much more a simulation of BB code then stripping not allowed HTML tags. The function I posted also allows for colors and gradients in text and smilies, which is a lot more functionality then what you build and that is why it are so many more lines..

We have different goals in mind, but I figured you may as well want it.

@Sandman, :shocked:.

Edited by Manadar
Posted

Archiving is now optional in 0.21.. check the new download on my first post.

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Posted

updated to 0.21, now the css doesnt work on anything.

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Posted (edited)

0.21 had very minimal changes.. it still should work fine.

Edit: Oh, wait.. I may have changed one of the header files by accident. I updated the ZIP download on my first post, if that's not the problem, tell me right away :shocked:

Edited by sandman

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...