<commit_before><?php

namespace iriki;

class user_session extends \iriki\request
{
	private static function generate()
	{
		$seed = time(NULL); //uniqid(time(NULL), true);

		$data = array();

		$data['token'] = (
			\PseudoCrypt::hash($seed, 10) .
			\PseudoCrypt::hash($seed, 4)
		);

		//get ip address
		$data['ip'] = $_SERVER['SERVER_ADDR'];

		$data['started'] = time(NULL);

		return $data;
	}

	public function initiate($request)
	{
    if (!is_null($request))
    {
      $data = $request->getData();
			$parameters = $request->getParameterStatus();

			//generate token
			$data_added = Self::generate();

			$data = array_merge($data, $data_added);

			//insert these three in final parameters
			array_push($parameters['final'], 'token', 'ip', 'started');

      $request->setData($data);
      $request->setParameterStatus($parameters);

      return $request->create($request);
    }
    else
    {
      //fail gracefully some way?
    }
	}


	/*public function validate($request)
	{
		//read
    if (!is_null($request))
    {
			$sessions_found = $request->read($request, false);

			//var_dump($request->getData()); var_dump($request->getParameterStatus());

			if (count($sessions_found) == 1)
			{

			}
			else
			{

			}
      return $sessions_found;
    }
	}*/

	public function invalidate($request)
	{
		//set token authenticated value to false
		if (!is_null($request))
		{
			return $request->read($request);
		}
	}

}

?><commit_msg>user_session validation<commit_after><?php

namespace iriki;

class user_session extends \iriki\request
{
	private static function generate()
	{
		$seed = time(NULL); //uniqid(time(NULL), true);

		$data = array();

		$data['token'] = (
			\PseudoCrypt::hash($seed, 10) .
			\PseudoCrypt::hash($seed, 4)
		);

		//get ip address
		$data['ip'] = $_SERVER['SERVER_ADDR'];

		$data['started'] = time(NULL);

		return $data;
	}

	public function initiate($request)
	{
    if (!is_null($request))
    {
      $data = $request->getData();
			$parameters = $request->getParameterStatus();

			//generate token
			$data_added = Self::generate();

			$data = array_merge($data, $data_added);

			//insert these three in final parameters
			array_push($parameters['final'], 'token', 'ip', 'started');

      $request->setData($data);
      $request->setParameterStatus($parameters);

      return $request->create($request);
    }
    else
    {
      //fail gracefully some way?
    }
	}


	public function validate($request)
	{
		//read
	    if (!is_null($request))
	    {
			$sessions_found = $request->read($request, false);

			//var_dump($request->getData()); var_dump($request->getParameterStatus());

			if (count($sessions_found) == 1)
			{

			}
			else
			{

			}
	      	return $sessions_found;
	    }
	}

	public function invalidate($request)
	{
		//set token authenticated value to false
		if (!is_null($request))
		{
			return $request->read($request);
		}
	}

}

?>
{'fraction_non_alphanumeric': 0.1733196861139543, 'fraction_numerical': 0.002729443875810304, 'mean_word_length': 3.1945636623748213, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4712871', 'n_tokens_mistral': 1111, 'n_tokens_neox': 962, 'n_words': 193}