<commit_before><?php
/**
 *
 * @package     openflame-framework
 * @subpackage  session
 * @copyright   (c) 2010 - 2011 openflame-project.org
 * @license     http://opensource.org/licenses/mit-license.php The MIT License
 * @link        https://github.com/OpenFlame/OpenFlame-Framework
 *
 * Minimum Requirement: PHP 5.3.0
 */

namespace OpenFlame\Framework\Session\Client;
use \OpenFlame\Framework\Core;
use OpenFlame\Framework\Dependency\Injector;

/**
 * OpenFlame Framework - Session Client-side identification,
 * 		Sessions client engine prototype
 *
 *
 * @license     http://opensource.org/licenses/mit-license.php The MIT License
 * @link        https://github.com/OpenFlame/OpenFlame-Framework
 */
class EngineCookie implements EngineInterface
{
	/*
	 * @var Cookie options
	 */
	private $options;

	/*
	 * @var injector
	 */
	private $injector;

	/*
	 * Initialize the engine
	 * @param array options - Associative array of options
	 * @return void
	 */
	public function init(&$options)
	{
		$this->injector = Injector::getInstance();
		$input = $this->injector->get('input');

		// Sanity check, we should not have cookie expirations less than our 
		// session, otherwise the driver will take a shit over the filesystem
		// until garbage collection comes around
		$options['cookie.expire'] = (isset($options['cookie.expire']) && $options['cookie.expire'] < $options['session.expire']) ?
			$options['session.expire'] : @$options['cookie.expire'];

		// Fallback on SERVER_NAME
		$options['cookie.domain'] = isset($options['cookie.domain']) ? 
			(string) $options['cookie.domain'] : $input->getInput('SERVER::SERVER_NAME', '')->getClean();

		// Fallback on /
		$options['cookie.path'] = isset($options['cookie.path']) ?
			(string) $options['cookie.path'] : '/';

		// Cast these properly
		$options['cookie.name'] = isset($options['cookie.name']) ? (string) $options['cookie.name'] : 'sid';
		$options['cookie.secure'] = isset($options['cookie.secure']) ? (boolean) $options['cookie.secure'] : false;

		$this->options = $options;
	}

	/*
	 * Get the SID of the current visitor<commit_msg>Changed default cookie expiry, filesystem still does not gc(), DO NOT USE LIVE YET<commit_after><?php
/**
 *
 * @package     openflame-framework
 * @subpackage  session
 * @copyright   (c) 2010 - 2011 openflame-project.org
 * @license     http://opensource.org/licenses/mit-license.php The MIT License
 * @link        https://github.com/OpenFlame/OpenFlame-Framework
 *
 * Minimum Requirement: PHP 5.3.0
 */

namespace OpenFlame\Framework\Session\Client;
use \OpenFlame\Framework\Core;
use OpenFlame\Framework\Dependency\Injector;

/**
 * OpenFlame Framework - Session Client-side identification,
 * 		Sessions client engine prototype
 *
 *
 * @license     http://opensource.org/licenses/mit-license.php The MIT License
 * @link        https://github.com/OpenFlame/OpenFlame-Framework
 */
class EngineCookie implements EngineInterface
{
	/*
	 * @var Cookie options
	 */
	private $options;

	/*
	 * @var injector
	 */
	private $injector;

	/*
	 * Initialize the engine
	 * @param array options - Associative array of options
	 * @return void
	 */
	public function init(&$options)
	{
		$this->injector = Injector::getInstance();
		$input = $this->injector->get('input');

		// Sanity check, we should not have cookie expirations less than our 
		// session, otherwise the driver will take a shit over the filesystem
		// until garbage collection comes around
		$options['cookie.expire'] = isset($options['cookie.expire']) ?
			$options['cookie.expire'] : 0;

		// Fallback on SERVER_NAME
		$options['cookie.domain'] = isset($options['cookie.domain']) ? 
			(string) $options['cookie.domain'] : $input->getInput('SERVER::SERVER_NAME', '')->getClean();

		// Fallback on /
		$options['cookie.path'] = isset($options['cookie.path']) ?
			(string) $options['cookie.path'] : '/';

		// Cast these properly
		$options['cookie.name'] = isset($options['cookie.name']) ? (string) $options['cookie.name'] : 'sid';
		$options['cookie.secure'] = isset($options['cookie.secure']) ? (boolean) $options['cookie.secure'] : false;

		$this->options = $options;
	}

	/*
	 * Get the SID of the current visitor
{'fraction_non_alphanumeric': 0.1578821845933699, 'fraction_numerical': 0.005485332697352731, 'mean_word_length': 3.893815635939323, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 15, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3806213', 'n_tokens_mistral': 1355, 'n_tokens_neox': 1260, 'n_words': 300}