PHP Utilities

To use these Utilities, you will either need to be on umt.edu servers or have the newest version of the PHP Includes on your server.

Usage

To make these functions available, you'll need to include the utilities class in your script:

include("utility.class.php");

xss_protect

Attempts to filter out code used for cross-site scripting attacks

usage: 

  • @param $data - the string of data to filter
  • @param $strip_tags - true to use PHP's strip_tags function for added security
  • @param $allowed_tags - a list of tags that are allowed in the string of data
  • @return a fully encoded, escaped and (optionally) stripped string of data
  • @author http://jstiles.com/Blog/How-To-Protect-Your-Site-From-XSS-With-PHP
$parsed_data = utility::xss_protect($data, $strip_tags = false, $allowed_tags = "")

site_url

Generates and absolute path to a relative resource.

Usage

  • @param $path - the path to the relative resources
  • @return string containing absolute URL
$url = utility::site_url($path = "")

input

get and parse get parameters.

Usage

  • @param $key - key of the parameter in the query string
  • @return value associated with the key after xss_protection, returns false if key does not exist

$url = utility::input($key)