<commit_before><?php
namespace Niysu\Filters;

/**
 * @copyright 	2012 <NAME> <<EMAIL>>
 * @license 	MIT http://opensource.org/licenses/MIT
 * @link 		http://github.com/Tomaka17/niysu
 */
class POSTRequestFilter extends \Niysu\HTTPRequestFilterInterface {
	public function __construct(\Niysu\HTTPRequestInterface $request) {
		parent::__construct($request);
	}

	public function __get($varName) {
		return $this->getPOSTData()->$varName;
	}
	
	public function __isset($varName) {
		return isset($this->getPOSTData()->$varName);
	}
	
	public function isPOSTContentType() {
		if (substr($this->getContentTypeHeader(), 0, 33) == 'application/x-www-form-urlencoded')
			return true;
		/*if (substr($this->getContentTypeHeader(), 0, 19) == 'multipart/form-data')
			return true;*/
		return false;
	}

	public function isValidPOSTData() {
		if (!$this->isPOSTContentType())
			return false;
		
		try {
			$this->getPOSTData();
			return true;

		} catch(\Exception $e) {
			return false;
		}
	}

	public function getPOSTData() {
		if (!$this->dataCacheStale)
			return $this->dataCache;

		$array = [];
		parse_str($this->getRawData(), $array);
		return (object)$array;

		$this->dataCacheStale = false;
		return $this->dataCache;
	}


	private $dataCache;
	private $dataCacheStale = true;
}
<commit_msg>Started working on file uploads<commit_after><?php
namespace Niysu\Filters;

/**
 * @copyright 	2012 <NAME> <<EMAIL>>
 * @license 	MIT http://opensource.org/licenses/MIT
 * @link 		http://github.com/Tomaka17/niysu
 */
class POSTRequestFilter extends \Niysu\HTTPRequestFilterInterface {
	public function __construct(\Niysu\HTTPRequestInterface $request) {
		parent::__construct($request);
	}

	public function __get($varName) {
		return $this->getPOSTData()->$varName;
	}
	
	public function __isset($varName) {
		return isset($this->getPOSTData()->$varName);
	}

	public function getFile($fileID) {
		$g = self::isGlobalRequest($this);
		if (!$g)
			return null;
		if (!isset($_FILES[$fileID]))
			return null;

		return (object)$_FILES[$fileID];
	}
	
	public function isPOSTContentType() {
		if (substr($this->getContentTypeHeader(), 0, 33) == 'application/x-www-form-urlencoded')
			return true;
		/*if (substr($this->getContentTypeHeader(), 0, 19) == 'multipart/form-data')
			return true;*/
		return false;
	}

	public function isValidPOSTData() {
		if (!$this->isPOSTContentType())
			return false;
		
		try {
			$this->getPOSTData();
			return true;

		} catch(\Exception $e) {
			return false;
		}
	}

	public function getPOSTData() {
		if (!$this->dataCacheStale)
			return $this->dataCache;

		$array = [];
		parse_str($this->getRawData(), $array);
		return (object)$array;

		$this->dataCacheStale = false;
		return $this->dataCache;
	}



	private static function isGlobalRequest(\Niyu\HTTPRequestInterface $rq) {
		if ($rq instanceof \Niysu\HTTPRequestGlobal)
			return true;
		if ($rq instanceof \Niysu\HTTPRequestFilterInterface)
			return $rq->getSource();
		return false;
	}


	private $dataCache;
	private $dataCacheStale = true;
}

{'fraction_non_alphanumeric': 0.14833438089252043, 'fraction_numerical': 0.00754242614707731, 'mean_word_length': 3.470505617977528, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1444684', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1027, 'n_words': 210}