<commit_before><?php
/**
 * Fuel
 *
 * Fuel is a fast, lightweight, community driven PHP5 framework.
 *
 * @package		Fuel
 * @version		1.0
 * @author		Fuel Development Team
 * @license		MIT License
 * @copyright	2010 - 2011 Fuel Development Team
 * @link		http://fuelphp.com
 */

namespace Fuel\Core;

/**
 * Security Class
 *
 * @package		Fuel
 * @category	Core
 * @author		<NAME>
 * @link		http://fuelphp.com/docs/classes/security.html
 */
class Security {

	protected static $csrf_token_key = false;
	protected static $csrf_token = false;
	protected static $csrf_new_token = false;

	/**
	 * Fetches CSRF settings and current token
	 */
	public static function _init()
	{
		static::$csrf_token_key = \Config::get('security.csrf_token_key', 'fuel_csrf_token');

		if (\Config::get('security.csrf_autoload', false))
		{
			static::fetch_token();
		}
	}

	/**
	 * Cleans the request URI
	 */
	public static function clean_uri($uri)
	{
		$filters = \Config::get('security.uri_filter');

		return static::clean($uri, $filters);
	}

	/**
	 * Cleans the $_GET and $_POST arrays
	 */
	public static function clean_input()
	{
		$filters = \Config::get('security.input_filter');

		$_GET = static::clean($_GET, $filters);
		$_POST = static::clean($_POST, $filters);
	}

	/**
	 * Generic variable clean method
	 */
	public static function clean($var, $filters)
	{
		foreach ((array) $filters as $filter)
		{
			if (is_callable('static::'.$filter))
			{
				$var = static::$filter($var);
			}
			elseif (function_exists($filter))
			{
				if (is_array($var))
				{
					foreach($var as $key => $value)
					{
						$var[$key] = $filter($value);
					}
				}
				else
				{
					$var = $filter($var);
				}
			}
			else
			{
				if (is_array($var))
				{<commit_msg>made sure Security filters are defined an array<commit_after><?php
/**
 * Fuel
 *
 * Fuel is a fast, lightweight, community driven PHP5 framework.
 *
 * @package		Fuel
 * @version		1.0
 * @author		Fuel Development Team
 * @license		MIT License
 * @copyright	2010 - 2011 Fuel Development Team
 * @link		http://fuelphp.com
 */

namespace Fuel\Core;

/**
 * Security Class
 *
 * @package		Fuel
 * @category	Core
 * @author		<NAME>
 * @link		http://fuelphp.com/docs/classes/security.html
 */
class Security {

	protected static $csrf_token_key = false;
	protected static $csrf_token = false;
	protected static $csrf_new_token = false;

	/**
	 * Fetches CSRF settings and current token
	 */
	public static function _init()
	{
		static::$csrf_token_key = \Config::get('security.csrf_token_key', 'fuel_csrf_token');

		if (\Config::get('security.csrf_autoload', false))
		{
			static::fetch_token();
		}
	}

	/**
	 * Cleans the request URI
	 */
	public static function clean_uri($uri)
	{
		$filters = \Config::get('security.uri_filter', array());
		$filters = is_array($filters) ? $filters : array($filters);

		return static::clean($uri, $filters);
	}

	/**
	 * Cleans the $_GET and $_POST arrays
	 */
	public static function clean_input()
	{
		$filters = \Config::get('security.input_filter', array());
		$filters = is_array($filters) ? $filters : array($filters);

		$_GET = static::clean($_GET, $filters);
		$_POST = static::clean($_POST, $filters);
	}

	/**
	 * Generic variable clean method
	 */
	public static function clean($var, $filters)
	{
		foreach ($filters as $filter)
		{
			if (is_callable('static::'.$filter))
			{
				$var = static::$filter($var);
			}
			elseif (function_exists($filter))
			{
				if (is_array($var))
				{
					foreach($var as $key => $value)
					{
						$var[$key] = $filter($value);
					}
				}
				else
				{
					$var = $filter($var);
				}
			}
			else
			{
				if (is_array($var))
				{
{'fraction_non_alphanumeric': 0.15869565217391304, 'fraction_numerical': 0.005978260869565218, 'mean_word_length': 3.23590333716916, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5424785', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1256, 'n_words': 292}