Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-29-2007, 04:54 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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.
__________________

Last edited by cbk1994; 11-29-2007 at 05:04 AM..
Reply With Quote
  #2  
Old 11-29-2007, 05:31 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
NPC Code:
<<b>Avoided!<</b>



Also, "spam"? span, perhaps.
e: What is "hl"?
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/

Last edited by Tolnaftate2004; 11-29-2007 at 05:56 AM..
Reply With Quote
  #3  
Old 11-29-2007, 01:41 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Tolnaftate2004 View Post
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!
__________________
Reply With Quote
  #4  
Old 11-05-2011, 10:11 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Thanks! Needed this
__________________
Reply With Quote
  #5  
Old 11-05-2011, 09:38 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by xAndrewx View Post
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.
__________________
Reply With Quote
  #6  
Old 11-06-2011, 11:48 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
hehe I noticed some errors, but I modified it

Good idea with the '>'- I'll do that =D Thanks
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:12 AM.


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