commit 500dec614eca3bebb0c83b8a50d96e69442f1435
Author: Romuald <devnull@localhost>
Date:   Sun Aug 22 19:14:09 2010 +0200

    Gestion du login 'capitaine' pour modifier uniquement les résultats des rencontres.

diff --git a/admin/admin.php b/admin/admin.php
index 0df89b1..53096e6 100644
--- a/admin/admin.php
+++ b/admin/admin.php
@@ -92,7 +92,7 @@
 	$message = "";
 
 	if ($_POST['saison'] && $_POST['div1']) {
-		$path = (IamAdmin()) ? "../datas" : "datas";
+		$path = (authent()) ? "../datas" : "datas";
 		$path .= "/".$_POST['saison']."/".$_POST['div1'];
 		if ($_POST['div2'] != "") $path .= $SEP_DIV.$_POST['div2'];
 		if ($_POST['poule'] != "" || $_POST['phase'] != "") $path .= "/";
diff --git a/functions.php b/functions.php
index 3841a98..18e1cc7 100644
--- a/functions.php
+++ b/functions.php
@@ -63,8 +63,16 @@ function isEmptyDir($dirname) {
 	return $result;
 }
 
+function authent() {
+	return (basename(dirname($_SERVER['PHP_SELF'])) == "admin" && isset($_SERVER['PHP_AUTH_USER']));
+}
+
 function IamAdmin() {
-	return (basename(dirname($_SERVER['PHP_SELF'])) == "admin");
+	return (authent() && $_SERVER['PHP_AUTH_USER'] == "admin");
+}
+
+function IamCaptain() {
+	return (authent() && $_SERVER['PHP_AUTH_USER'] == "capitaine");
 }
 
 function monRmdir($dir) {
diff --git a/index.php b/index.php
index 7b2e7d5..cf16eab 100644
--- a/index.php
+++ b/index.php
@@ -45,7 +45,7 @@
 	if ($division == "") $division = $div1; if ($div2 != "") $division .= $SEP_DIV.$div2;
 	$subdiv = $poule; if ($phase != "") $subdiv .= $SEP_DIV.$phase;
 
-	$path = (IamAdmin()) ? "../datas" : "datas";
+	$path = (authent()) ? "../datas" : "datas";
 	getDirs($path, $saisons);
 	rsort($saisons);
 	if (!in_array($saison, $saisons)) unset($saison, $division, $div1, $div2, $subdiv, $poule, $phase);
@@ -127,7 +127,7 @@
 	<meta http-equiv="Content-language" content="fr" />
 	<meta name="copyright" content="Tous droits r�serv�s - All Rights Reserved" />
 	<meta name="author" content="Romuald DELAVERGNE">
-	<link rel="stylesheet" type="text/css" href="<?=(IamAdmin()) ? "../" : ""?>style/fftt.css" media="screen" title="Normal" />
+	<link rel="stylesheet" type="text/css" href="<?=(authent()) ? "../" : ""?>style/fftt.css" media="screen" title="Normal" />
 </head>
 <html>
 <body>
@@ -205,13 +205,14 @@
 		</div>
 	</form>
 <?php } ?>
-<?php if (IamAdmin()) { ?>
+<?php if (IamAdmin() or IamCaptain()) { ?>
 	<form name="resultats" method="post" action="admin.php">
 		<input type="hidden" name="saison" value="<?=$saison?>" />
 		<input type="hidden" name="div1" value="<?=$div1?>" />
 		<input type="hidden" name="div2" value="<?=$div2?>" />
 		<input type="hidden" name="poule" value="<?=$poule?>" />
 		<input type="hidden" name="phase" value="<?=$phase?>" />
+<?php if (IamAdmin()) { ?>
 		<div id="boutons-global">
 			<select name="typeCompetition">
 				<option value="">championnat</option>
@@ -231,7 +232,7 @@
 <?php 	} ?>
 		</div>
 		<br />
-<?php 	if ($saisons) { ?>
+<?php if ($saisons) { ?>
 		<div id="boutons-championnat">
 			<input type="submit" name="championnat" value="modifier" />
 <?php
@@ -253,6 +254,7 @@
 			<input type="submit" name="championnat" value="forfait g&eacute;n&eacute;ral" />
 			<input type="submit" name="championnat" value="commentaires" />
 		</div>
+<?php 		} ?>
 <?php 	} ?>
 <?php }
 	if ($equipes) foreach ($equipes as $n => $e) {
@@ -370,11 +372,13 @@
 				<td class="colSep">&nbsp;-&nbsp;</td>
 				<td class="colPtsVis"><?=$ptsVis?></td>
 				<td class="colVis"><div<?=($ptsDom != "" && $ptsVis != "" && $ptsVis >= $ptsDom) ? " class=\"vainqueur\"": ""?>><?=$equipes[$visiteur]?></div></td>
-<?php if (IamAdmin()) { ?>
+<?php if (IamAdmin() or IamCaptain()) { ?>
 				<td>
 <?php $value = "$j-$domicile-$visiteur"; ?>
 					<input type="submit" name="rencontre-<?=$value?>" value="modifier" />
+<?php 	if (IamAdmin()) { ?>
 					<input type="submit" name="rencontre-<?=$value?>" value="supprimer" onClick='return confirm("Voulez-vous vraiment effacer cette rencontre entre\n<?=$equipes[$domicile]?> et <?=$equipes[$visiteur]?> ?")' />
+<?php 	} ?>
 				</td>
 <?php } ?>
 			</tr>
