Old stuff/old_sites/epik/include/conf.php
(Deskargatu)
<? if ($axx<8) { die; } ?>
<div class="article">
<h2>Configuration du site</h2>
<?
if ($chemin[2] == "accueil")
{
$file = dirname(__FILE__)."/../data/accueil.txt";
if ($_POST['contenu'])
{
$handle = fopen($file,"w") or die("CANT WRITE FILE $file");
$contenu = stripslashes($_POST['contenu']);
fwrite($handle,$contenu) or die("ERROR WRITING $file");
fclose($handle);
echo "<p>Modifié avec succès</p>";
}
else {
$handle = fopen($file,"r") or die("CANT READ FILE $file");
$contenu = fread($handle,filesize($file)) or die("ERROR READING $file");
echo "<form action=\"/site/conf/accueil\" method=\"post\">
<dl><dt>Message d'acceuil:</dt>
<dd><textarea name=\"contenu\" cols=\"60\" rows=\"15\">$contenu</textarea></dd>
<dd><input class=\"button\" type=\"submit\" value=\"Valider\" /></dd>
</dl>
";
}
}
elseif ($chemin[2] == "regles")
{
$file = dirname(__FILE__)."/../data/regles.txt";
if ($_POST['contenu'])
{
$handle = fopen($file,"w") or die("CANT WRITE FILE $file");
$contenu = stripslashes($_POST['contenu']);
fwrite($handle,$contenu) or die("ERROR WRITING $file");
fclose($handle);
echo "<p>Modifié avec succès</p>";
}
else {
$handle = fopen($file,"r") or die("CANT READ FILE $file");
$contenu = fread($handle,filesize($file)) or die("ERROR READING $file");
echo "<form action=\"/site/conf/accueil\" method=\"post\">
<dl><dt>Message d'acceuil:</dt>
<dd><textarea name=\"contenu\" cols=\"60\" rows=\"15\">$contenu</textarea></dd>
<dd><input class=\"button\" type=\"submit\" value=\"Valider\" /></dd>
</dl>
";
}
}
elseif($chemin[2] == "modif_forum")
{
if ($chemin[3] == "creer")
{
if (
!empty($_POST['ref']) and
!empty($_POST['nom']) and
!empty($_POST['description']))
{
echo "Creation ...";
$query = "CREATE TABLE informatique.".$_POST['ref']." (
id int( 11 ) NOT NULL AUTO_INCREMENT ,
com_id int( 11 ) NOT NULL default '0',
topic_id int( 11 ) NOT NULL default '0',
date varchar( 19 ) NOT NULL default '',
pseudo varchar( 50 ) NOT NULL default '',
nom varchar( 100 ) NOT NULL default '',
contenu text NOT NULL ,
UNIQUE KEY id ( id )
) TYPE = MYISAM ;
";
mysql_query($query) or die($query."<br>".mysql_error());
echo "Creation OK";
$query = "INSERT INTO description (ref,nom,description,axx)
VALUES ('".$_POST['ref']."','".$_POST['nom']."','".$_POST['description']."','".$_POST['axx']."')";
mysql_query($query) or die(mysql_error()."<br>$query");
}
else {
echo "<form action=\"/site/conf/modif_forum/creer\" method=\"post\">
<dl>
<dt>Ref</dt><dd><input name=\"ref\" type=\"text\" value=\"forum_qqch\" /></dd>
<dt>Nom</dt><dd><input name=\"nom\" type=\"text\" value=\"Nom\" /></dd>
<dt>Nom</dt><dd><input name=\"description\" type=\"text\" value=\"Description\" /></dd>
<dt>Axx pour vue</dt><dd><input name=\"axx\" type=\"text\" value=\"0\" /></dd>
<dt>Action</dt><dd><input class=\"button\" type=\"submit\" value=\"Valider\" /></dd>
</form>
";
}
}
elseif ($chemin[3] == "supprimer")
{
if (!empty($_POST['ref']))
{
if (ereg("^forum_",$_POST['ref']))
{
$query = "DROP TABLE ".$_POST['ref'];
mysql_query($query) or die(mysql_error());
$query = "DELETE FROM description WHERE ref='".$_POST['ref']."'";
mysql_query($query) or die(mysql_error());
echo "<p>Supprimé avec succès</p>";
}
else { echo "<p>Table pas du forum?</p>"; }
}
else {
echo "<h3 class=\"new\">AUCUNE SUPPRESSION EST REVERSIBLE ! IL N'Y A PAS DE BACKUP !</h3>\n";
$query = "SELECT ref,nom FROM description";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result))
{
echo "<form action=\"/site/conf/modif_forum/supprimer\" method=\"post\">
<dl><dt>".$row['nom']."</dt><dd>=> ".$row['ref']." <input type=\"hidden\" name=\"ref\" value=\"".$row['ref']."\" /></dd>
<dd><input type=\"submit\" class=\"button\" value=\"Supprimer !\" /></dd>
</form>
";
}
}
}
else {
echo "<ul>
<li><a href=\"/site/conf/modif_forum/creer\">Creer une nouvelle table</a></li>
<li><a href=\"/site/conf/modif_forum/supprimer\">Supprimer une table</a></li>
</ul>
";
}
}
elseif ($chemin[2] == "forum")
{
if (!empty($chemin[3]))
{
if ($_POST['nom'] and $_POST['ref'] and $_POST['description'])
{
$query = "UPDATE description SET nom='".$_POST['nom']."',description='".$_POST['description']."',ref='".$_POST['ref']."' WHERE id='$chemin[3]'";
mysql_query($query) or die(mysql_error());
echo "<div class=\"element\">
<p>Modifié avec succès</p>
<p><a href=\"/site/conf/forum\" title=\"Config forum\">Retour sur la config du forum</a></p>
<p><a href=\"/site/conf\" title=\"Config\">Retour sur la configuration du site</a></p>
</div>";
}
else {
$chemin[3] = preg_replace("[^0-9]","",$chemin[3]);
echo " <div class=\"element\">
<h2>Forum</h2>
";
$query = "SELECT id,ref,nom,description FROM description WHERE id='$chemin[3]'";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_assoc($result))
{
echo "
<div>
<form action=\"/site/conf/forum/".$row["id"]."\" method=\"post\">
<dl>
<dt>Nom:</dt><dd><input type=\"text\" name=\"nom\" value=\"".$row["nom"]."\" /></dd>
<dt>Reference:</dt>
<dd><input type=\"text\" name=\"ref\" value=\"".$row["ref"]."\" /></dd>\n
<dt>Description</dt><dd><input size=\"60\" type=\"text\" name=\"description\" value=\"".$row["description"]."\" /></dd>
<dt>Actions</dt><dd><input class=\"button\" type=\"submit\" value=\"Accepter\" /><input class=\"button\" type=\"reset\" value=\"RAZ\" />
</dl>
</form>
</div>
";
}
echo "</div>";
}
}
else {
echo "<div class=\"element\">
<p>Tables existantes:</p>";
$query = "SELECT id,nom FROM description";
$result = mysql_query($query) or die(mysql_error());
echo "<ul>";
while ($row = mysql_fetch_assoc($result))
{
echo "<li><a href=\"/site/conf/forum/".$row["id"],"\" title=\"".$row["nom"]."\">".$row["nom"]."</a></li>\n";
}
echo "</ul></div>";
}
}
else {
echo "<div class=\"element\">
<h2>Menu de configuration</h2>
<ul>
<li><a href=\"/site/conf/forum\" title=\"forum\">Modifier les tables du forum</a></li>
<li><a href=\"/site/conf/modif_forum\" title=\"forum\">Créer/supprimer des tables du forum</a></li>
<li><a href=\"/site/conf/accueil\" title=\"accueil\">Changer la page d'accueil</a></li>
<li><a href=\"/site/conf/regles\" title=\"Regles\">Changer les règles</a></li>
</ul>
</div>
";
}
echo "
</div>
";