<?php
///////////////////////////////////////////////////////////////////////////////////////////////////////
// BotBanish 8.0.00
// Randem Systems: https://randemsystems.support
// BotBanish Session Object Class
// Date: 04/26/2026
// Usage:
//
///////////////////////////////////////////////////////////////////////////////////////////////////////

class BotBanishSession {
    // Properties

	public $sessionInfo;
	
    // Constructor
    public function __construct() {
		
		$ip = BotBanishGetIP();
		
		$this->sessionInfo = array(
			'botip' => BotBanishGetIP(),
			'name' =>  '',
			'user' => '',
			'value' => '',
			'func' => '',
			'firsthit' => 0,
			'lasthit' => 0,
			'hitcount' => 0,
			'countryinfo' => function_exists('BotBanishGetCountryInfo') ? BotBanishGetCountryInfoSession($ip) : 'US',
			'geodata' => function_exists('BotBanishGetGeoData') ? BotBanishGetGeoDataSession($ip) : array(),
			'webserver' => '',
			'serverurl' => '',
			'scripturl' => $this->getSessionURL(),
			'locked' => false,
		);
    }

	public function getSessionURL() {
	
		global $BotBanishSettings;
		
		$url = isset($BotBanishSettings['BOTBANISH_INSTALL_URL']) ? $BotBanishSettings['BOTBANISH_INSTALL_URL'] :	'';
		
		if (empty($url)) {
			
			$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http");
			$url = $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
		}
		
		return $url;
	}
	
	public function getSessionInfo() {

		return $this->sessionInfo;
	}

	public function setSessionInfo($session = object) {

		$this->sessionInfo = $arr;
	}

	public function getSessionKey($key) {

		global $BotBanishSettings;
		
		$key = strtolower($key);
		
		if (isset($this->sessionInfo[$key]))
			return $this->sessionInfo[$key];

		return false;
	}

	public function setSessionKey($key, $data = '') {

		$key = strtolower($key);
		$this->sessionInfo[$key] = $data;
		
		// Indicate that the session information has been changed
		// This is used in the cache module to determine if the cache object should be written to disk
		
		$this->sessionInfo['updated'] = true;
	}
}
?>