Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Detect HTML (https://forums.graalonline.com/forums/showthread.php?t=77749)

cbk1994 11-29-2007 04:54 AM

Detect HTML
 
I made this quickly for my message system that used GUIs.

I'll probably eventually make it simply remove the HTML, but for now it's a way to tell if they inputted HTML.

An example is if you have a GUI message system, and someone massed <img src="block.png"> for example. You could disable HTML, but then if you needed colors, etc, you couldn't use them.

The way I used it was this:
PHP Code:

if ( player.chat.starts":mass" ) )
  {
    
temp.txt player.chat.substring).trim();
    
temp.removeHTMLtemp.txt );
    
triggerserver"gui"name"massMessage"temp.);
  } 

Here is the class.

Script for class functions_removehtml:
PHP Code:

public function removeHTMLtext )
{
  
this.html = { "a""b""body""br""center""font""hl""hr""i""ignorelinebreaks""img""p""spam""ul""ol""li""div" };

  for ( 
temp.this.html )
  {
    
temp."<" temp.a;
    if ( 
text.pos( @ temp.) > -)
    {
      
temp.= ( text.pos( @ temp.) );
      
text text.substring0temp.) @ text.substringtemp.);
    }
    
temp."</" temp.a;
    if ( 
text.pos( @ temp.) > -)
    {
      
temp.= ( text.pos( @ temp.) );
      
text text.substring0temp.) @ text.substringtemp.);
    }
  }
  return 
text;
}
//#CLIENTSIDE
public function removeHTMLtext )
{
  
this.html = { "a""b""body""br""center""font""hl""hr""i""ignorelinebreaks""img""p""spam""ul""ol""li""div" };

  for ( 
temp.this.html )
  {
    
temp."<" temp.a;
    if ( 
text.pos( @ temp.) > -)
    {
      
temp.= ( text.pos( @ temp.) );
      
text text.substring0temp.) @ text.substringtemp.);
    }
    
temp."</" temp.a;
    if ( 
text.pos( @ temp.) > -)
    {
      
temp.= ( text.pos( @ temp.) );
      
text text.substring0temp.) @ text.substringtemp.);
    }
  }
  return 
text;


It's a very simple script, but I figured someone might get some use out of it. When I make it remove HTML, I will update it.

Feel free to leave feedback!
Thanks,
Chris Zakuto

EDIT: Updated it to remove the HTML instead of just giving an error. It removes the < right before it, making it not work. There was also another error that I fixed.

Tolnaftate2004 11-29-2007 05:31 AM

NPC Code:
<<b>Avoided!<</b>



Also, "spam"? span, perhaps.
e: What is "hl"?

cbk1994 11-29-2007 01:41 PM

Quote:

Originally Posted by Tolnaftate2004 (Post 1361179)
NPC Code:
<<b>Avoided!<</b>



Also, "spam"? span, perhaps.
e: What is "hl"?

hl is horizontal line.

Looks like I made a typo. And an error.

I'll fix those after school today and repost! Thank you for the feedback!

xAndrewx 11-05-2011 10:11 AM

Thanks! Needed this :)

cbk1994 11-05-2011 09:38 PM

Quote:

Originally Posted by xAndrewx (Post 1673207)
Thanks! Needed this :)

Not sure what you're using it for but couldn't you just replace every instance of > with &gt;? That's what I usually do in places where HTML shouldn't be allowed.

Also, I'm pretty sure this script has some big holes in it. I wrote it many years ago.

xAndrewx 11-06-2011 11:48 AM

hehe I noticed some errors, but I modified it ^^

Good idea with the '>'- I'll do that =D Thanks


All times are GMT +2. The time now is 10:18 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.