<?php

sleep(1);
if (array_key_exists("pays", $_REQUEST))
{
	$tomorrow = 0;//60*60*24; // en nb de secondes
	header("Cache-Control: max-age=$tomorrow");
	print_plain();
}
else
{
	print "Usage : $_SERVER[PHP_SELF]?pays=un-code-pays";
}

/** Récupération de la liste des agences pour un pays donné **/

function print_plain()
{
	header("Content-type: text/html; charset=windows-1252");
	$age = get_age($_REQUEST["pays"]);
	$result = array();
	$result[] = "*=-- TOUTES LES AGENCES --";
	foreach ($age as $row)
	{
		$result[] = $row["age_code"]."=".$row["age_nom"];
	}
	print implode(";", $result);
}

function get_age($pays)
{
	include_once("../inc/config.inc.php");
	include_once("../inc/func_txt.inc.php");
	// On se connecte a la base
	$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	// On recupere les enregistrements
	$rech = "SELECT * FROM ".TBAGE." WHERE age_codepays='".str_majuscules($pays)."' AND age_ouvert='1' ORDER BY age_nom";
	$rs = mysql_query($rech) or die(mysql_error());
	// On cree le resultat
	$result = array();
	while($row = mysql_fetch_array($rs))
	{
		$result[] = $row;
	}
	mysql_close();
	return $result;
}

?>