<?php
session_start();
if (isset($_REQUEST['fin']))unset($_SESSION['connecte']);
$_SESSION['place']=-2;
if (file_exists('config/forumdefcondb.inc')) include('config/forumdefcondb.inc');
// Si le fichier forumdefcondb.inc existe, on passe au forum. Sinon, on lance la procédure d'installation .
if (!file_exists('config/forumdefcondb.inc')) {
// On récupère les valeurs des champs du formulaire que l'on a envoyées par POST.
if ((isset($_POST['adbase']))and($_POST['adbase']!="")){
$champ1=true;
}
else $champ1=false;
if ((isset($_POST['log']))and($_POST['log']!="")){
$champ2=true;
}
else $champ2=false;
if ((isset($_POST['base']))and($_POST['base']!="")){
$champ3=true;
}
else $champ3=false;
if ((isset($_POST['admin']))and($_POST['admin']!="")){
$champ4=true;
}
else $champ4=false;
if ((isset($_POST['mdpadmin']))and($_POST['mdpadmin']!="")){
$champ5=true;
}
else $champ5=false;
$result= (($champ1) and ($champ2) and ($champ3)and ($champ4) and ($champ5));
// Si on a obtenu les identifiants de connexion, on les écrit dans le fichier forumdefcondb.inc.txt
if ($result==true) {
$monfichier=fopen('config/forumdefcondb.inc','w+');
fseek($monfichier,0);
$nouvfichier="<?php"."\n";
$nouvfichier.="define('ADBASE','".$_POST['adbase']."');"."\n";
$nouvfichier.="define('LOG','".$_POST['log']."');"."\n";
$nouvfichier.="define('BASE','".$_POST['base']."');"."\n";
$nouvfichier.="define('MDP','".$_POST['mdpasse']."');"."\n";
$nouvfichier.="define('ADMIN','".$_POST['admin']."');"."\n";
$nouvfichier.="define('MDPADMIN','".$_POST['mdpadmin']."');"."\n";
$nouvfichier.="define('MDPFORUM','".$_POST['mdpforum']."');"."\n";
$nouvfichier.="?>";
fputs($monfichier,$nouvfichier);
fclose($monfichier);
// ensuite on crée la table
include "creertable.php";
// et enfin on lance le forum.
$_SESSION['connecte']=true;
include "entete.php";
// Sinon on propose le formulaire d'installation.
} else {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr">
<head>
<title>Installation</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="plugins/paramspip/fichiers/<?php echo $_SESSION['dirarticle'] ?>/install.css" type="text/css" />
</head>
<body >
<div align="center">
<form id="formins" action="" method="post" >
<div class="encadre">BASE DE DONNEES </div>
<table class="tableauinstall" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td class="entgaucheins">L'adresse de la base de données</td>
<td class="entdroiteins" ><input type="text" name="adbase" /></td>
</tr>
<tr>
<td class="entgaucheins">Le login de connexion</td>
<td class="entdroiteins" ><input type="text" name="log" /></td>
</tr>
<tr>
<td class="entgaucheins">Le mot de passe de connexion</td>
<td class="entdroiteins" ><input type="text" name="mdpasse" /></td>
</tr>
<tr>
<td class="entgaucheins">Le nom de la base</td>
<td class="entdroiteins" ><input type="text" name="base" /></td>
</tr>
</table>
<div class="encadre">Administration </div>
<table class="tableauinstall" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td class="entgaucheins">Login</td>
<td class="entdroiteins" ><input type="text" name="admin" /></td>
</tr>
<tr>
<td class="entgaucheins">Mot de passe</td>
<td class="entdroiteins" ><input type="text" name="mdpadmin" /></td>
</tr>
</table>
<div class="encadre">Protection éventuelle</div>
<table class="tableauinstall" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td class="entgaucheins">Mot de passe éventuel </td>
<td class="entdroiteins" ><input type="text" name="mdpforum" /></td>
</tr>
</table>
<input type="submit" class="envoi4" value="Valider" />
</form>
</div>
</body>
</html>
<?php
}
//On propose un formulaire d'entrée dans le cas où le forum est protégé par un mot de passe.
//} elseif (($_SESSION['mdpforum']!="") and ($_POST['mdpforum']!=$_SESSION['mdpforum'])and($_SESSION['connecte']==false)) {
}elseif ((MDPFORUM!="") and ($_POST['mdpforum']!=MDPFORUM)and($_SESSION['connecte']==false)) {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html ; charset=iso-8859-1" />
<title>Mot de passe</title>
<link rel="stylesheet" href="plugins/paramspip/fichiers/<?php echo $_SESSION['dirarticle'] ?>/admin.css" type="text/css" />
</head>
<body >
<form action="" method="post" class="mdpadmin">
Mot de passe : <input name="mdpforum" type="password" value=""/><br/><br/>
<input type="submit" class="envoi4" name="envoi" value="Valider" />
</form>
</body>
</html>
<?php } else {
//La connexion... au forum...
$_SESSION['connecte']=true;
include "entete.php";} ?>