<?php
///////////////////////////////////////////////////////////////////////////////////////////////////////
// BotBanish 9.0.00
// Randem Systems: https://randemsystems.support
// BotBanish Setup
// Date: 06/19/2026
// Usage:
//
// Function:
//		Setup globals and create needed folders
///////////////////////////////////////////////////////////////////////////////////////////////////////

	global $BotBanishSettings;

	$system = BotBanishCheckSystem();

	$seconds = 60;		// Seconds in a minutes
	$minutes = 5;		// Minutes
	$elapsedTime = BotBanishGetCorrectDateTimeB() + ($seconds * $minutes);	// 5 minutes

	switch (strtoupper($system['install_type'])) {

		case 'SERVER':

			BotBanishDefineGlobals('BOTBANISH_SERVER', 1);
			BotBanishDefineGlobals('BOTBANISH_CLIENT', 0);
			BotBanishDefineGlobals('BOTBANISH_SYSTEM', 'SERVER');
			BotBanishDefineGlobals('BOTBANISH_SERVER_CLEANUP', date("Y-m-d H:i:s"));
			BotBanishDefineGlobals('BOTBANISH_SERVER_CLEANUP_RUN', 1);
			BotBanishDefineGlobals('BOTBANISH_SERVER_CLEANUP_DAYS_IP', 365);
			BotBanishDefineGlobals('BOTBANISH_SERVER_CLEANUP_DAYS_LOGS', 30);
			BotBanishDefineGlobals('BOTBANISH_SERVER_SCHEDULED_TASK_TIME', $elapsedTime);
			break;

		case 'CLIENT':

			BotBanishDefineGlobals('BOTBANISH_SERVER', 0);
			BotBanishDefineGlobals('BOTBANISH_CLIENT', 1);
			BotBanishDefineGlobals('BOTBANISH_CLIENT_CLEANUP', date("Y-m-d H:i:s"));
			BotBanishDefineGlobals('BOTBANISH_CLIENT_CLEANUP_RUN', 1);
			BotBanishDefineGlobals('BOTBANISH_CLIENT_CLEANUP_DAYS_IP', 365);
			BotBanishDefineGlobals('BOTBANISH_CLIENT_CLEANUP_DAYS_LOGS', 30);
			BotBanishDefineGlobals('BOTBANISH_CLIENT_SCHEDULED_TASK_TIME', $elapsedTime);

			break;

		default:

			exit('Not in correct folder to run BotBanish install');
			break;
	}

	BotBanishDefineGlobals('BOTBANISH', 1);
	BotBanishDefineGlobals('BOTBANISH_CONFIGURATION', 1);

	BotBanishDefineGlobals('BOTBANISH_DELETE_DATA', 0);
	BotBanishDefineGlobals('BOTBANISH_HONEYPOT_URL', $BotBanishSettings['BOTBANISH_INSTALL_URL'] . 'Subs/BotBanish_RegisterAccount.php');

//================================================================
// Make all folders that we will need
//================================================================

	$download_data = $BotBanishSettings['BOTBANISH_DIR'] . 'data/' . str_ireplace('www.', '', $BotBanishSettings['BOTBANISH_USER_HOST']);

	$folders = array(
						$BotBanishSettings['BOTBANISH_STATIC_DIR'],
						$BotBanishSettings['BOTBANISH_STATIC_LOGS_DIR'],
						$BotBanishSettings['BOTBANISH_STATIC_BACKUPS_DIR'],
						$BotBanishSettings['BOTBANISH_STATIC_HTML_DIR'],
						$BotBanishSettings['BOTBANISH_STATIC_SQL_DIR'],
						$BotBanishSettings['BOTBANISH_STATIC_CACHE_DIR'],
						$BotBanishSettings['BOTBANISH_STATIC_UPLOAD_DIR'],
						$BotBanishSettings['BOTBANISH_STATIC_TEMP_DIR'],
						$download_data,
					);

	foreach ($folders as $folder) {

		if (!is_dir($folder))
			@mkdir($folder, 0755, true);
	}
?>