<?

if (!$SITE['reg_global']) {

	$SITE['reg_global'] = 1;
	
	function global_to_session ($chaine) {
	
		$tableau = explode(", ", $chaine);
		$n 	 = count ($tableau);
	
		if ($n) {
	
			for ($i = 0; $i < $n; $i++) {
	
				if (isset($GLOBALS[$tableau[$i]])) { $_SESSION[$tableau[$i]] = $GLOBALS[$tableau[$i]]; }
			}
	
		} else if (isset($GLOBALS[$chaine])) { $_SESSION[$chaine] = $GLOBALS[$chaine]; }
	
		return 1;
	
	}
	
	function session_to_global ($chaine) {
	
		$tableau = explode(", ", $chaine);
		$n 	 = count ($tableau);
	
		if ($n) {
	
			for ($i = 0; $i < $n; $i++) {
	
				if (isset($_SESSION[$tableau[$i]])) { $GLOBALS[$tableau[$i]] = $_SESSION[$tableau[$i]]; }
			}
	
		} else if (isset($_SESSION[$chaine])) { $GLOBALS[$chaine] = $_SESSION[$chaine]; }
	
		return 1;
	
	}
	
	function bloc_to_session ($BLOC, $chaine) {
	
		$tableau = explode(", ", $chaine);
		$n 	 = count ($tableau);
	
		if ($n) {
	
			for ($i = 0; $i < $n; $i++) {
	
				if (isset($BLOC[$tableau[$i]])) { $_SESSION[$tableau[$i]] = $BLOC[$tableau[$i]]; }
			}
	
		} else if (isset($BLOC[$chaine])) { $_SESSION[$chaine] = $BLOC[$chaine]; }
	
		return 1;
	
	}
	
	function bloc_to_global ($BLOC, $chaine) {
	
		$tableau = explode(", ", $chaine);
		$n 	 = count ($tableau);
	
		if ($n) {
	
			for ($i = 0; $i < $n; $i++) {
	
				if (isset($BLOC[$tableau[$i]])) { $GLOBALS[$tableau[$i]] = $BLOC[$tableau[$i]]; }
			}
	
		} else if (isset($BLOC[$chaine])) { $GLOBALS[$chaine] = $BLOC[$chaine]; }
	
		return 1;
	
	}
	
	function get_to_global ($chaine) {
	
		$tableau = explode(", ", $chaine);
		$n 	 = count ($tableau);
	
		if ($n) {
	
			for ($i = 0; $i < $n; $i++) {
	
				if (isset($_GET[$tableau[$i]])) { $GLOBALS[$tableau[$i]] = $_GET[$tableau[$i]]; }
			}
	
		} else if (isset($_GET[$chaine])) { $GLOBALS[$chaine] = $_GET[$chaine]; }
	
		return 1;
	
	}
	
	
	function post_to_global ($chaine) {
	
		$tableau = explode(", ", $chaine);
		$n 	 = count ($tableau);
	
		if ($n) {
	
			for ($i = 0; $i < $n; $i++) {
	
				if (isset($_POST[$tableau[$i]])) { $GLOBALS[$tableau[$i]] = $_POST[$tableau[$i]]; }
			}
	
		} else if (isset($_POST[$chaine])) { $GLOBALS[$chaine] = $_POST[$chaine]; }
	
		return 1;
	
	}
	
	function exist_all_variables ($chaine) {
	
		$tableau = explode(", ", $chaine);
		$n 	 = count ($tableau);
	
		if ($n) {
		
			for ($i = 0; $i < $n; $i++) {
	
				if (!isset($GLOBALS[$tableau[$i]])) { return 0; }
				
			}
	
		} else if (!isset($GLOBALS[$chaine])) { return 0; }
	
		return 1;
	
	}
	
	function echo_all_variables ($chaine) {
	
		$tableau = explode(", ", $chaine);
		$n 	 = count ($tableau);
	
		echo "Contenu des variables globales : <br><br>";
	
		if ($n) {
	
			for ($i = 0; $i < $n; $i++) {
	
				echo "\$GLOBALS['".$tableau[$i]."'] : ".$GLOBALS[$tableau[$i]]."<br>";
			
			}
	
		} else echo "\$GLOBALS['".$chaine."'] : ".$GLOBALS[$chaine]."<br>";
	
		return 1;	
	}
}
?>