mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 03:42:11 +01:00 
			
		
		
		
	Initial commit
This commit is contained in:
		
							
								
								
									
										60
									
								
								server_files/config.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								server_files/config.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,60 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * Config options
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
$YEAR = 2020;
 | 
			
		||||
$URL_BASE = "https://galaxyoyo.com/tfjm";
 | 
			
		||||
$LOCAL_PATH = "/var/www/html/tfjm";
 | 
			
		||||
$MAIL_ADDRESS = "contact@galaxyoyo.com";
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
* DB infos
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
$DB_HOST = "localhost";
 | 
			
		||||
$DB_NAME = "tfjm";
 | 
			
		||||
$DB_USER = "galaxyoyo";
 | 
			
		||||
$DB_PWD = "***REMOVED***";
 | 
			
		||||
 | 
			
		||||
try {
 | 
			
		||||
	$DB = new PDO("mysql:host=$DB_HOST;dbname=$DB_NAME;charset=utf8", "$DB_USER", "$DB_PWD", array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
 | 
			
		||||
}
 | 
			
		||||
catch (Exception $ex) {
 | 
			
		||||
	die("Erreur lors de la connexion à la base de données : " . $ex->getMessage());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
session_start();
 | 
			
		||||
 | 
			
		||||
if (isset($_SESSION["user_id"])) {
 | 
			
		||||
	$response = $DB->query("SELECT * FROM `users` WHERE `id` ='" . $_SESSION["user_id"] . "' AND `year` = '$YEAR';");
 | 
			
		||||
	$data = $response->fetch();
 | 
			
		||||
	if ($data === FALSE)
 | 
			
		||||
		unset($_SESSION["user_id"]);
 | 
			
		||||
	else {
 | 
			
		||||
		$_SESSION["email"] = $data["email"];
 | 
			
		||||
		$_SESSION["surname"] = $data["surname"];
 | 
			
		||||
		$_SESSION["first_name"] = $data["first_name"];
 | 
			
		||||
		$_SESSION["birth_date"] = $data["birth_date"];
 | 
			
		||||
		$_SESSION["role"] = $data["role"];
 | 
			
		||||
		$_SESSION["team_id"] = $data["team_id"];
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (isset($_SESSION["user_id"]) && isset($_SESSION["team_id"]) && $_SESSION["team_id"] != NULL) {
 | 
			
		||||
		$response = $DB->query("SELECT `tournament`, `validation_status` FROM `teams` WHERE `id` ='" . $_SESSION["team_id"] . "' AND `year` = '$YEAR';");
 | 
			
		||||
		$data = $response->fetch();
 | 
			
		||||
		$_SESSION["tournament_id"] = $data["tournament"];
 | 
			
		||||
		$_SESSION["team_validation_status"] = $data["validation_status"];
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
setlocale(LC_ALL, "fr_FR.utf8");
 | 
			
		||||
 | 
			
		||||
function echo_date($date = NULL, $with_time = false) {
 | 
			
		||||
	if ($date == NULL)
 | 
			
		||||
		$date = date("yyyy-mm-dd");
 | 
			
		||||
 | 
			
		||||
	return strftime("%d %B %G" . ($with_time ? " %H:%M" : ""), strtotime($date));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
		Reference in New Issue
	
	Block a user