function isSecured()
 {
     // maybe we have caught authentication data in $_SERVER['REMOTE_USER']
     if ((!$_SERVER['PHP_AUTH_USER'] || !$_SERVER['PHP_AUTH_PW']) && preg_match('/Basic+(.*)$/i', $_SERVER['REMOTE_USER'], $matches)) {
         list($name, $password) = explode(':', base64_decode($matches[1]));
         $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
         $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
     }
     return isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) && VerifSession($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) == "1";
 }
 function get($request, $username, $password)
 {
     $response = new Response($request);
     $response->code = Response::OK;
     $response->addHeader('content-type', 'text/plain');
     ouverture();
     if (VerifSession($username, $password) == "1") {
         $response->body = json_encode(array("compte" => "ok"));
     } else {
         $response->body = json_encode(array("compte" => "ko"));
     }
     return $response;
 }
 function isSecured($user)
 {
     // maybe we have caught authentication data in $_SERVER['REMOTE_USER']
     if ((!$_SERVER['PHP_AUTH_USER'] || !$_SERVER['PHP_AUTH_PW']) && preg_match('/Basic+(.*)$/i', $_SERVER['REMOTE_USER'], $matches)) {
         list($name, $password) = explode(':', base64_decode($matches[1]));
         $_SERVER['PHP_AUTH_USER'] = strip_tags($name);
         $_SERVER['PHP_AUTH_PW'] = strip_tags($password);
     }
     /* 
             if(!(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) && VerifSession($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW'])=="1")) {
     	throw new ResponseException("message!", Response::UNAUTHORIZED);
     }
     */
     return isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']) && $user == $_SERVER['PHP_AUTH_USER'] && VerifSession($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) == "1";
 }
if (isset($_REQUEST['champ'])) 
{
	$champ=$_REQUEST['champ'];
} 
else 
{
    $requete="SELECT phpl_gr_championnats.id_champ FROM phpl_gr_championnats WHERE phpl_gr_championnats.activ_prono='1' ORDER by id desc";
    $resultat=mysql_query ($requete) or die ("probleme " .mysql_error());
    $row= mysql_fetch_array($resultat);
     
    $champ=$row[0];   
}

$connecte = false;

if (isset($_COOKIE['user'])) {$user_pseudo=$_COOKIE['user'];} else {$user_pseudo='';}
if (isset($_COOKIE['mot_de_passe'])) {$user_mdp=$_COOKIE['mot_de_passe'];} else {$user_mdp='';}

$user_id="";
if (VerifSession ($user_pseudo,$user_mdp)=="1")
{
	$requete= "SELECT pseudo, id_prono FROM phpl_membres WHERE pseudo='$user_pseudo'";
	$result = mysql_query($requete);
	$row = mysql_fetch_array($result);
	$user_pseudo=$row[0];
	$user_id=$row[1];
	$connecte = true;
}
?>