kses
[ class tree: kses ] [ index: kses ] [ all elements ]

Class: kses4

Source Location: /main/inc/lib/kses-0.2.2/oop/php4.class.kses.php

Class Overview


Kses strips evil scripts!


Author(s):

  • Richard R. Vásquez, Jr. (Original procedural code by Ulf Härnhammar)

Version:

  • PHP4 OOP 0.2.2

Copyright:

  • Richard R. Vásquez, Jr. 2003-2005

Methods



Class Details

[line 82]
Kses strips evil scripts!

This class provides the capability for removing unwanted HTML/XHTML, attributes from tags, and protocols contained in links. The net result is a much more powerful tool than the PHP internal strip_tags()

This is a fork of a slick piece of procedural code called 'kses' written by Ulf Harnhammar The entire set of functions was wrapped in a PHP object with some internal modifications by Richard Vasquez (http://www.chaos.org/) 7/25/2003

This upgrade provides the following:

  • Version number synced to procedural version number
  • PHPdoc style documentation has been added to the class. See http://www.phpdoc.org/ for more info.
  • Some methods are now deprecated due to nomenclature style change. See method documentation for specifics.
  • Kses4 now works in E_STRICT
  • Addition of methods AddProtocols(), filterKsestextHook(), RemoveProtocol(), RemoveProtocols() and SetProtocols()
  • Deprecated _hook(), Protocols()
  • Integrated code from kses 0.2.2 into class.




Tags:

author:  Richard R. Vásquez, Jr. (Original procedural code by Ulf Härnhammar)
version:  PHP4 OOP 0.2.2
copyright:  Richard R. Vásquez, Jr. 2003-2005
link:  http://chaos.org/contact/ Contact page with current email address for Richard Vasquez
link:  http://sourceforge.net/projects/kses/ Home Page for Kses
license:  GNU Public License


[ Top ]


Class Methods


constructor kses4 [line 99]

kses4 kses4( )

Constructor for kses.

This sets a default collection of protocols allowed in links, and creates an empty set of allowed HTML tags.




Tags:

since:  PHP4 OOP 0.0.1


[ Top ]

method AddHTML [line 332]

bool AddHTML( [string $tag = ""], [array $attribs = array()])

Adds valid (X)HTML with corresponding attributes that will be kept when stripping 'evil scripts'.

This method accepts one argument that can be either a string or an array of strings. Invalid data will be ignored.




Tags:

return:  Status of Adding (X)HTML and attributes.
since:  PHP4 OOP 0.0.1
access:  public


Parameters:

string   $tag   (X)HTML tag that will be allowed after stripping text.
array   $attribs   Associative array of allowed attributes - key => attribute name - value => attribute parameter

[ Top ]

method AddProtocol [line 213]

bool AddProtocol( [string $protocol = ""])

Adds a single protocol to $this->allowed_protocols.

This method accepts a string argument and adds it to the list of allowed protocols to keep when performing Parse().




Tags:

return:  Status of adding valid protocol.
since:  PHP4 OOP 0.0.1
access:  public


Parameters:

string   $protocol   The name of the protocol to be added.

[ Top ]

method AddProtocols [line 150]

bool AddProtocols( mixed 0)

Allows for single/batch addition of protocols

This method accepts one argument that can be either a string or an array of strings. Invalid data will be ignored.

The argument will be processed, and each string will be added via AddProtocol().




Tags:

return:  Status of adding valid protocols.
see:  kses4::AddProtocol()
since:  PHP4 OOP 0.2.1
access:  public


Parameters:

mixed   0   , A string or array of protocols that will be added to the internal list of allowed protocols.

[ Top ]

method DumpElements [line 315]

array DumpElements( )

Raw dump of allowed (X)HTML elements

This returns an indexed array of allowed (X)HTML elements and attributes for a particular KSES instantiation.




Tags:

return:  The list of allowed elements.
since:  PHP4 OOP 0.2.2
access:  public


[ Top ]

method DumpProtocols [line 300]

array DumpProtocols( )

Raw dump of allowed protocols

This returns an indexed array of allowed protocols for a particular KSES instantiation.




Tags:

return:  The list of allowed protocols.
since:  PHP4 OOP 0.2.2
access:  public


[ Top ]

method filterKsesTextHook [line 573]

string filterKsesTextHook( string $string)

Allows for additional user defined modifications to text.

This method allows for additional modifications to be performed on a string that's being run through Parse(). Currently, it returns the input string 'as is'.

This method is provided for users to extend the kses class for their own requirements.




Tags:

return:  User modified string.
see:  kses4::Parse()
since:  PHP5 OOP 1.0.0
access:  public


Parameters:

string   $string   String to perfrom additional modifications on.

[ Top ]

method Parse [line 122]

string Parse( [string $string = ""])

Basic task of kses - parses $string and strips it as required.

This method strips all the disallowed (X)HTML tags, attributes and protocols from the input $string.




Tags:

return:  The stripped string
since:  PHP4 OOP 0.2.1
access:  public


Parameters:

string   $string   String to be stripped of 'evil scripts'

[ Top ]

method Protocols [line 189]

bool Protocols( )

Allows for single/batch addition of protocols



Tags:

see:  kses4::AddProtocols()
deprecated:  Use AddProtocols()
since:  PHP4 OOP 0.0.1


[ Top ]

method RemoveProtocol [line 392]

bool RemoveProtocol( [string $protocol = ""])

Removes a single protocol from $this->allowed_protocols.

This method accepts a string argument and removes it from the list of allowed protocols to keep when performing Parse().




Tags:

return:  Status of removing valid protocol.
since:  PHP4 OOP 0.2.1
access:  public


Parameters:

string   $protocol   The name of the protocol to be removed.

[ Top ]

method RemoveProtocols [line 438]

bool RemoveProtocols( mixed 0)

Allows for single/batch removal of protocols

This method accepts one argument that can be either a string or an array of strings. Invalid data will be ignored.

The argument will be processed, and each string will be removed via RemoveProtocol().




Tags:

return:  Status of removing valid protocols.
see:  kses4::RemoveProtocol()
since:  PHP5 OOP 0.2.1
access:  public


Parameters:

mixed   0   , A string or array of protocols that will be removed from the internal list of allowed protocols.

[ Top ]

method SetProtocols [line 257]

bool SetProtocols( mixed 0)

Allows for single/batch replacement of protocols

This method accepts one argument that can be either a string or an array of strings. Invalid data will be ignored.

Existing protocols will be removed, then the argument will be processed, and each string will be added via AddProtocol().




Tags:

return:  Status of replacing valid protocols.
see:  kses4::AddProtocol()
since:  PHP4 OOP 0.2.2
access:  public


Parameters:

mixed   0   , A string or array of protocols that will be the new internal list of allowed protocols.

[ Top ]

method _hook [line 552]

string _hook( string $string)

Allows for additional user defined modifications to text.



Tags:

see:  kses4::filterKsesTextHook()
deprecated:  use filterKsesTextHook()
since:  PHP4 OOP 0.0.1


Parameters:

string   $string  

[ Top ]

method _version [line 1153]

string _version( )

Returns PHP4 OOP version # of kses.

Since this class has been refactored and documented and proven to work, I'm syncing the version number to procedural kses.




Tags:

return:  Version number
since:  PHP4 OOP 0.0.1
access:  public


[ Top ]


Documentation generated on Wed, 05 Sep 2007 06:14:59 +0200 by phpDocumentor 1.4.0