<?ob_start();
if (file_exists("secret/liste.txt")){
$dir=".";
} else {
$dir="..";
}
$self = basename($PHP_SELF);
$expire=3650*24*3600;
/* $nom=$HTTP_POST_VARS["nom"];
$pass=$HTTP_POST_VARS["pass"];
if (($nom=="") && ($pass=="")) {
$nom=$HTTP_GET_VARS["nom"];
$pass=$HTTP_GET_VARS["pass"];
}
$deconnecte=$HTTP_POST_VARS["deconnecte"];
*/
if ($deconnecte!="") {
/* remplacer le repertoire du forum et le nom de domaine */
setcookie($pass,"",time()+$expire,"/demo/","mathosphere.free.fr");
Header("Location:".$dir."/message.php");
exit();
}
if (($nom!="") && ($pass!="")){
$passc=crypt($pass,"leforumlamathosphere");
$passc=ereg_replace(":", "",$passc);
$fp = fopen ($dir."/secret/liste.txt", "r");
while (!feof($fp)) {
$lignee = fgets($fp, 4096);
$ligne[$i]=explode(":",$lignee);
if (($ligne[$i][0]==$nom) && ($ligne[$i][1]==$passc)) {
/* remplacer le repertoire du forum et le nom de domaine */
setcookie($nom,$pass,time()+$expire,"/demo/","mathosphere.free.fr");
echo $nom." ".$passc;
Header("Location:".$dir."/message.php");
exit();
}
$i++;
}
fclose($fp);
}
ob_end_flush();
$fp = fopen ($dir."/secret/liste.txt", "r");
$i=false;
while (!feof($fp) && ($i==false)) {
$lignee = fgets($fp, 4096);
$ligne=explode(":",$lignee);
$connecteb=ereg_replace(":", "",crypt($HTTP_COOKIE_VARS[$ligne[0]],"leforumlamathosphere"));
if ($ligne[1]==$connecteb) {
$connecte=$ligne[0];
$i=true;
}
}
fclose($fp);
/* $connecte=$HTTP_COOKIE_VARS["mathforum"]; */
echo "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">";
echo "<html><head><title>forum la mathosphere</title>";
echo "<link rel=\"stylesheet\" href=\"".$dir."/../style.css\" type=\"text/css\">";
echo "</head><body>";
echo "<p id=\"p1\">forum mathématique</p><br />";
echo "<p id=\"fin\">";
echo "<a href=\"".$dir."/../index.php\">Sommaire</a><br>2002 - mathosphère</p>";
echo "<div class=\"back\"><span class=\"p2\">";
if ($dir=="..") echo "<a href=\"".$dir."/message.php\">liste des topics</a><br />";
if ($connecte!="") {
echo "<a href=\"".$dir."/listemembres.php\">liste des membres</a><br/>";
echo "Connecté sous $connecte";
echo "<form method=\"post\">";
echo "<input name=\"deconnecte\" type=\"submit\" value=\"Déconnexion\"><input name=\"pass\" type=\"hidden\" value=\"".$connecte."\"></form></span>";
echo "</div>";
}
else {
echo "<table><tr><td>Pour devenir membre : </td><td><a href=\"".$dir."/inscription.php\">S'INSCRIRE</a></td></tr>";
echo "<tr><td>Si vous êtes déjà membre : </td><td><form method=\"post\" action=\"".$self."\">";
echo "Nom : ";
echo "<input name=\"nom\" type=\"text\" size=\"10\"> ";
echo "Mot de passe : ";
echo "<input name=\"pass\" type=\"password\" size=\"10\">";
echo " <input name=\"submit\" type=\"submit\" value=\"Connexion\"></td></tr></table>";
echo "</span>";
echo "</form>";
echo "</div>";
}
?>