<commit_before><?php
/**
 * DRAIWIKI
 * Open source wiki software
 *
 * @version     1.0 Alpha 1
 * @author      <NAME>
 * @copyright   DraiWiki, 2017
 * @license     Apache 2.0
 *
 * Class information:
 * This class adds a session to the database
 * @since 		1.0 Alpha 1
 * @author 		DraiWiki development team
 */

namespace DraiWiki\src\database\models;

if (!defined('DraiWiki')) {
	header('Location: ../index.php');
	die('You\'re really not supposed to be here.');
}

use \DraiWiki\src\database\controllers\Connection;
use \DraiWiki\src\database\controllers\Query;
use \DraiWiki\src\main\controllers\Main;
use \SessionHandlerInterface;

class SessionHandler implements SessionHandlerInterface {

	public function __construct() {
		$this->_database = Connection::instantiate();

		session_set_save_handler(
			[$this, 'open'],
			[$this, 'close'],
			[$this, 'read'],
			[$this, 'write'],
			[$this, 'destroy'],
			[$this, 'gc']
		);
		register_shutdown_function('session_write_close');
		session_name(Main::$config->read('session', 'COOKIE_ID'));
	}

	/**
	 * Servers running Ubuntu or its deratives (this may apply to other Debian-based systems as well) do
	 * not automatically run the garbage collector. Thus, we need to call it ourselves.
	 * @return void
	 */
	public function __destruct() {
		$probability = rand(0, 2);
		if ($probability == 0)
			$this->gc(ini_get('session.gc_max_lifetime'));
	}

	public function open($savePath, $sessionKey) {
		/*$query = new Query('
			SELECT data
				FROM {db_prefix}sessions
				WHERE session_key = :session_key
				LIMIT 1
		');

		$query->setParams([
			'session_key' => $sessionKey
		]);
		$result = $query->execute();

		foreach ($result as $resultFound) {
			return true;<commit_msg>! Fixed typo: init_get() should be ini_get()<commit_after><?php
/**
 * DRAIWIKI
 * Open source wiki software
 *
 * @version     1.0 Alpha 1
 * @author      <NAME>
 * @copyright   DraiWiki, 2017
 * @license     Apache 2.0
 *
 * Class information:
 * This class adds a session to the database
 * @since 		1.0 Alpha 1
 * @author 		DraiWiki development team
 */

namespace DraiWiki\src\database\models;

if (!defined('DraiWiki')) {
	header('Location: ../index.php');
	die('You\'re really not supposed to be here.');
}

use \DraiWiki\src\database\controllers\Connection;
use \DraiWiki\src\database\controllers\Query;
use \DraiWiki\src\main\controllers\Main;
use \SessionHandlerInterface;

class SessionHandler implements SessionHandlerInterface {

	public function __construct() {
		$this->_database = Connection::instantiate();

		session_set_save_handler(
			[$this, 'open'],
			[$this, 'close'],
			[$this, 'read'],
			[$this, 'write'],
			[$this, 'destroy'],
			[$this, 'gc']
		);
		register_shutdown_function('session_write_close');
		session_name(Main::$config->read('session', 'COOKIE_ID'));
	}

	/**
	 * Servers running Ubuntu or its deratives (this may apply to other Debian-based systems as well) do
	 * not automatically run the garbage collector. Thus, we need to call it ourselves.
	 * @return void
	 */
	public function __destruct() {
		$probability = rand(0, 1000);
		if ($probability == 0)
			$this->gc(ini_get('session.gc_max_lifetime'));
	}

	public function open($savePath, $sessionKey) {
		/*$query = new Query('
			SELECT data
				FROM {db_prefix}sessions
				WHERE session_key = :session_key
				LIMIT 1
		');

		$query->setParams([
			'session_key' => $sessionKey
		]);
		$result = $query->execute();

		foreach ($result as $resultFound) {
			return true;
{'fraction_non_alphanumeric': 0.14464692482915717, 'fraction_numerical': 0.009965831435079727, 'mean_word_length': 3.899581589958159, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '2969822', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1147, 'n_words': 305}