<?php
	set_time_limit(0);
	
	$includes = array(
		"../include/config.php",
		"../include/functions.php",
	);
	
	foreach($includes as $file) {
		if(file_exists($file)) {
			include($file);
		} else {
			die("Eroare la includerea fisierelor necesare!");
		}
	}
	
	// Conectare la bazele de date
	$DBlist = array(
		"account",
	);
	
	foreach($DBlist as $db) {
		if(isset($databases[$db])) {
			error_reporting(0);
			$DBCon[$db] = mysqli_connect($databases[$db]["host"] . ":" . $databases[$db]["port"], $databases[$db]["user"], $databases[$db]["password"], $databases[$db]["name"]);
			if(!$DBCon[$db]) {
				die(mysqli_connect_error($DBCon[$db]));
			}
			error_reporting(-1);
		} else {
			die("No information found in order to connect to database '$db'.");
		}
	}
	
	$UpdateSQL = mysqli_query($DBCon["account"], "UPDATE `account` SET `status` = 'OK', `banned_until` = '0000-00-00 00:00:00' WHERE `status` = 'BLOCK' AND `banned_until` < NOW() AND `banned_until` != '0000-00-00 00:00:00';");
	if(!$UpdateSQL) {
		die(mysqli_error($DBCon["account"]));
	} else {
		echo mysqli_affected_rows($DBCon["account"]) . " conturi blocate temporar au fost deblocate!";
	}
	
?>