n/oldblog
Archived
1
0
Fork 0
This repository has been archived on 2024-02-13. You can view files and clone it, but cannot push or open issues or pull requests.
oldblog/liens/admin/index.php
2023-04-30 21:50:11 +02:00

490 lines
No EOL
17 KiB
PHP

<?
#############################################
# phpDirectory v1.0 #
# #
# Jean-Yves Fort - 21 avril 2001 #
# jean-yves@lozere-online.com #
# #
# Consulter les documents du repertoire #
# /doc pour plus d'informations sur #
# l'installation, l'auteur, les conditions #
# d'utilisation. #
#############################################
?>
<?
function enregistre( $variable )
{
//ajout des antislashes selon config
if (!get_cfg_var(magic_quotes_gpc))
{
$variable = addslashes($variable);
}
return $variable;
}
function lire( $variable )
{
//supression des antislashes selon config
if (!get_cfg_var(magic_quotes_gpc))
{
$variable = stripslashes($variable);
}
return $variable;
}
require("../conf/db.php"); ?>
<html>
<body>
<a href="testurl.php">Tester la validité des adresses</a>
<h2>Administration</h2>
<?
// supprimer categorie
if (isset($supcat))
{
$numero=0;
$link = mysql_connect($host,$user,$password);
$re=mysql_db_query($base,"select id from ".$basecat." where idsubcat=".$del." ",$link);
$numero=mysql_num_rows($re);
$re2=mysql_db_query($base,"select id from ".$basesites." where cat1=".$del." ",$link);
$numero2=mysql_num_rows($re2);
if (($numero==0) and ($numero2==0))
{
$link = mysql_connect($host,$user,$password);
mysql_db_query($base,"delete from ".$basecat." where id=".$del."",$link);
echo "<HR>La cat&eacute;gorie a &eacute;t&eacute; effac&eacute;e";
}
else { echo "<HR><font color=\"red\"><b>Vous ne pouvez pas supprimer cette cat&eacute;gorie car il existe des sous-cat&eacute;gories ou des sites.</b></font>"; }
}
// valider lien
if (isset($valid))
{
$link = mysql_connect($host,$user,$password);
mysql_db_query($base,"update ".$basesites." set valid=1 where id=".$numlink."",$link);
echo "<HR><font color=\"red\"><b>Le lien a &eacute;t&eacute; valid&eacute;</b></font>";
}
// verification des entrees
if ($addlink==1)
{
if ($add_nom == "")
{echo "<font color=\"red\">- Saisir le nom du site</font><br>"; $addlink=0;}
$nom_len=strlen($add_nom);
if ($nom_len>50)
{echo "<font color=\"red\">- Nom du site trop long (actuellement ".$nom_len." caract&egrave;res)</font><br>"; $addlink=0;}
if ($add_description == "")
{echo "<font color=\"red\">- Saisir la description du site</font><br>"; $addlink=0;}
$des_len=strlen($add_description);
if ($des_len>100)
{echo "<font color=\"red\">- Description trop longue (actuellement ".$des_len." caract&egrave;res)</font><br>"; $addlink=0;}
if ($add_mcles == "")
{echo "<font color=\"red\">- Saisir les mots cl&eacute;s d&eacute;crivant le mieux votre site</font><br>"; $addlink=0;}
$mcles_len=strlen($add_mcles);
if ($mcles_len>250)
{echo "<font color=\"red\">- Trop de mots cl&eacute;s (actuellement ".$mcles_len." caract&egrave;res)</font><br>"; $addlink=0;}
if (($add_url == "")||($add_url == "http://"))
{echo "<font color=\"red\">- Saisir l'URL du site</font><br>"; $addlink=0;}
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.[a-z0-9-]+(\.[a-z0-9-]+)*$", $add_email))
{echo "<font color=\"red\">- Email non valide</font><br>"; $addlink=0;}
$link = mysql_connect($host,$user,$password);
$requete_url=mysql_db_query($base,"select id, url from ".$basesites." where url LIKE \"$add_url\"
",$link);
$num_url=mysql_num_rows($requete_url);
if ($num_url!=0)
{echo "<font color=\"red\">- Un site est d&eacute;j&agrave enregistr&eacute; &agrave cette adresse</font><br>"; $addlink=0;}
}
// ajouter lien
if ($addlink==1)
{
$add_nom=enregistre($add_nom);
$add_description=enregistre($add_description);
$add_mcles=enregistre($add_mcles);
$link = mysql_connect($host,$user,$password);
mysql_db_query($base,"INSERT INTO ".$basesites."(nomsite, url, description, mcles, email, date, cat1, cat2, cat3, valid) values('".$add_nom."','".$add_url."','".$add_description."','".$add_mcles."', '".$add_email."',NOW(),'".$c."','".$add_cat2."','".$add_cat3."',1)",$link);
echo "<HR><font color=\"red\"><b>Le lien a &eacute;t&eacute; ajout&eacute;</b></font>";
}
// appel de tagimport
if($meta==1)
{include("../html/tagimport.php");}
// supprimer lien
if (isset($supplink))
{
$link = mysql_connect($host,$user,$password);
mysql_db_query($base,"delete from ".$basesites." where id=".$numlink."",$link);
echo "<HR><font color=\"red\"><b>Le lien a &eacute;t&eacute; supprim&eacute;</b></font>";
}
// ajouter categorie
if (isset($newcat))
{
$newcat=enregistre($newcat);
$link = mysql_connect($host,$user,$password);
mysql_db_query($base,"insert into ".$basecat." (nomcat, idsubcat) values('".$newcat."', '".$idcat."')",$link);
echo "<HR><font color=\"red\"><b>Cat&eacute;gorie ajout&eacute;e</b></font>";
}
// modifier priorite affichage categorie
if (isset($id_prio))
{
$link = mysql_connect($host,$user,$password);
mysql_db_query($base,"update ".$basecat." set prio='".$prio."' where id=".$id_prio."",$link);
}
// modifier lien
if (isset($edilink))
{
if (isset($ediok))
{
if ($cat==0)
{echo "<HR><font color=\"red\"><b>ATTENTION: La premi&egrave;re cat&eacute;gorie ne peut &ecirc;tre vide</b></font>";
}
else
{
$nom = enregistre($nom);
$description = enregistre($description);
$mcles = enregistre($mcles);
$link = mysql_connect($host,$user,$password);
mysql_db_query($base,"update ".$basesites." set nomsite='".$nomsite."', description='".$description."', mcles='".$mcles."', url='".$url."', email='".$email."', valid='".$valido."', cat1='".$cat."', cat2='".$cat2."',cat3='".$cat3."' where id=".$numlink."",$link);
echo "<HR><font color=\"red\"><b>Lien modifi&eacute;</b></font>";
}
}
else
{
echo "<HR>";
$numero=0;
$link = mysql_connect($host,$user,$password);
$re=mysql_db_query($base,"select * from ".$basesites." where id=".$numlink." ",$link);
$nomsite = mysql_result($re,$numero,"nomsite");
$url = mysql_result($re,$numero,"url");
$email = mysql_result($re,$numero,"email");
$description = mysql_result($re,$numero,"description");
$mcles = mysql_result($re,$numero,"mcles");
$valid = mysql_result($re,$numero,"valid");
$cat = mysql_result($re,$numero,"cat1");
$cat2 = mysql_result($re,$numero,"cat2");
$cat3 = mysql_result($re,$numero,"cat3");
$nom = lire($nom);
$description = lire($description);
$mcles = lire($mcles);
if ($valid==1) { $ok1=" SELECTED"; $ok0=""; }
else { $ok1=""; $ok0=" SELECTED"; }
echo "<form action=\"index.php\">Editer le lien<br><input type=\"hidden\" name=\"edilink\" value=1><input type=\"hidden\" name=\"numlink\" value=\"".$numlink."\"><input type=\"hidden\" name=\"ediok\" value=1><input type=\"hidden\" name=\"c\" value=".$c.">";
echo "<table>
<tr>
<td valign=\"top\">Nom du site</td>
<td><TEXTAREA WRAP=\"physical\" NAME=\"nomsite\" COLS=30 ROWS=3>".$nomsite."</TEXTAREA></td>
</tr>
<tr>
<td valign=\"top\">Description</td>
<td><TEXTAREA WRAP=\"physical\" NAME=\"description\" COLS=30 ROWS=3>".$description."</TEXTAREA></td>
</tr>
<tr>
<td valign=\"top\">Mots cl&eacute;s</td>
<td><TEXTAREA WRAP=\"physical\" NAME=\"mcles\" COLS=30 ROWS=5>".$mcles."</TEXTAREA></td>
</tr>
<tr>
<tr>
<td>URL</td>
<td><INPUT TYPE=\"text\" NAME=\"url\" value=\"".$url."\" SIZE=30 MAXLENGTH=100></td>
</tr>
<tr>
<td>Email</td>
<td><INPUT TYPE=\"text\" NAME=\"email\" value=\"".$email."\" SIZE=30 MAXLENGTH=100></td>
</tr>
<tr>
<td>Valide</td>
<td><SELECT name=\"valido\"><option value=\"1\"".$ok1.">Oui<option value=\"0\"".$ok0.">Non</SELECT></td>
</tr>
</tr>
<tr>
<td>Num&eacute;ro de la cat&eacute;gorie</td>
<td><INPUT TYPE=\"text\" NAME=\"cat\" value=\"".$cat."\" SIZE=30 MAXLENGTH=100></td>
</tr>
<tr>
<td>Cat&eacute;gorie sup. 1 </td>
<td><INPUT TYPE=\"text\" NAME=\"cat2\" value=\"".$cat2."\" SIZE=30 MAXLENGTH=100></td>
</tr>
<tr>
<td>Cat&eacute;gorie sup. 2 </td>
<td><INPUT TYPE=\"text\" NAME=\"cat3\" value=\"".$cat3."\" SIZE=30 MAXLENGTH=100></td>
</tr>
<tr>
<td colspan=2 align=\"right\"><INPUT TYPE=\"submit\" value=\"Ok\"></td>
</tr>
</table>
</form>";
}
}
// modifier categorie
if (isset($edicat))
{
if (isset($ediok))
{
$nomcat=enregistre($nomcat);
$link = mysql_connect($host,$user,$password);
mysql_db_query($base,"update ".$basecat." set nomcat='".$nomcat."', idsubcat='".$idsubcat."' where id=".$c."",$link);
echo "<HR><font color=\"red\"><b>Cat&eacute;gorie modifi&eacute;e</b></font>";
}
else
{
echo "<HR>";
$numero=0;
$link = mysql_connect($host,$user,$password);
$re=mysql_db_query($base,"select nomcat, id, idsubcat from ".$basecat." where id=".$c." ",$link);
$nomcat = mysql_result($re,$numero,"nomcat");
$nomcat=lire($nomcat);
$idsubcat = mysql_result($re,$numero,"idsubcat");
echo "<form action=\"index.php\">Editer la cat&eacute;gorie<br>
<input type=text name=\"nomcat\" value=\"".$nomcat."\"> Sous-cat&eacute;gorie de:
<input type=text SIZE=4 name=\"idsubcat\" value=\"".$idsubcat."\">
<input type=\"hidden\" name=\"edicat\" value=1>
<input type=\"hidden\" name=\"ediok\" value=1>
<input type=\"hidden\" name=\"c\" value=".$c.">
<input type=\"submit\" value=\"Ok\"></form>";
}
}
?>
<hr>
<?
$link = mysql_connect($host,$user,$password);
echo "<a href=\"index.php\">Accueil</a>";
if (isset($c))
{
$x=0;
$i=0;
$requete=mysql_db_query($base,"select nomcat, id, idsubcat from ".$basecat." where id=".$c." ",$link);
$nomcat = mysql_result($requete,$i,"nomcat");
$id = mysql_result($requete,$i,"id");
$idsubcat = mysql_result($requete,$i,"idsubcat");
$nomcat=lire($nomcat);
$varid[$x]=$id;
$varnom[$x]=$nomcat;
if($idsubcat!=0)
{
$x=1;
while($idsubcat!=0)
{
$requete2=mysql_db_query($base,"select nomcat, id, idsubcat from $basecat where id=".$idsubcat." ",$link);
$nomcat = mysql_result($requete2,$i,"nomcat");
$id = mysql_result($requete2,$i,"id");
$idsubcat = mysql_result($requete2,$i,"idsubcat");
$nomcat=lire($nomcat);
$varid[$x]=$id;
$varnom[$x]=$nomcat;
$x++;
}
$x=$x-1;
}
while($x!=-1)
{
echo " > <a href=\"index.php?c=".$varid[$x]."\">".$varnom[$x]."</a>";
$x=$x-1;
}
}
if (!isset($c))
{
$n=0;
$requete3=mysql_db_query($base,"select nomcat, id, prio from ".$basecat." where idsubcat=0 order by prio ",$link);
$nume=mysql_num_rows($requete3);
echo "<br><br><table>";
if ($nume!=0){echo"<tr><td align=center>priorit&eacute;</tr></td>";}
while ( $n<$nume )
{
$nomcat = mysql_result($requete3,$n,"nomcat");
$nomcat=lire($nomcat);
$id = mysql_result($requete3,$n,"id");
$prio = mysql_result($requete3,$n,"prio");
echo "<tr><td>
<form action=\"index.php\">
<INPUT TYPE=\"submit\" value=\">\">
<INPUT TYPE=\"hidden\" name=\"id_prio\" value=".$id.">
<INPUT TYPE=\"text\" NAME=\"prio\" value=\"".$prio."\" SIZE=3 MAXLENGTH=3>
</form></td><td>
<b><a href=\"index.php?c=".$id."\">".$nomcat."</a></b> - [<a href=\"index.php?c=".$id."&edicat=1\">&eacute;diter</a>] [<a href=\"index.php?supcat=1&del=".$id."\">supprimer</a>]<br><br></tr></td>";
$n++;
}
echo "</table>";
echo "<br><form action=\"index.php\">Ajouter une cat&eacute;gorie<br><input type=text name=\"newcat\"><input type=\"hidden\" name=\"idcat\" value=0><input type=\"submit\" value=\"Ok\"></form>";
// liste des sites non valides
echo "Liste des sites en attente de validation:";
$nliens=0;
$requeteliens=mysql_db_query($base,"select nomsite, url, valid, cat1, cat2, cat3 from ".$basesites." where valid=0 order by cat1",$link);
$numliens=mysql_num_rows($requeteliens);
echo "<ul>";
if ($numliens==0)
{echo "<li><b>Aucun site</b>";}
else
{while ( $nliens<$numliens )
{
$nomsite = mysql_result($requeteliens,$nliens,"nomsite");
$nomsite=lire($nomsite);
$url = mysql_result($requeteliens,$nliens,"url");
$cat = mysql_result($requeteliens,$nliens,"cat1");
$cat2 = mysql_result($requeteliens,$nliens,"cat2");
$cat3 = mysql_result($requeteliens,$nliens,"cat3");
echo "<li><b>".$nomsite."</b> - ".$url." - [dans cat&eacute;gorie(s): <a href=\"index.php?c=$cat\">".$cat."</a>";
if ($cat2>0) {echo " - <a href=\"index.php?c=$cat2\">".$cat2."</a>";}
if ($cat3>0) {echo " - <a href=\"index.php?c=$cat3\">".$cat3."</a>";}
echo " ]";
$nliens++;}
}
echo "</ul>";
}
else
{
$n=0;
$requete3=mysql_db_query($base,"select nomcat, id, prio from ".$basecat." where idsubcat=".$c." order by prio",$link);
$nume=mysql_num_rows($requete3);
echo "<br><br><table>";
if ($nume!=0){echo "<tr><td align=center>priorit&eacute;</tr></td>";}
while ( $n<$nume )
{
$nomcat = mysql_result($requete3,$n,"nomcat");
$nomcat=lire($nomcat);
$id = mysql_result($requete3,$n,"id");
$prio = mysql_result($requete3,$n,"prio");
echo "<tr><td>
<form action=\"index.php\">
<INPUT TYPE=\"submit\" value=\">\">
<INPUT TYPE=\"hidden\" name=\"c\" value=".$c.">
<INPUT TYPE=\"hidden\" name=\"id_prio\" value=".$id.">
<INPUT TYPE=\"text\" NAME=\"prio\" value=\"".$prio."\" SIZE=3 MAXLENGTH=3>
</form></td><td>
<b><a href=\"index.php?c=".$id."\">".$nomcat."</a></b> - [<a href=\"index.php?c=".$id."&edicat=1\">&eacute;diter</a>] [<a href=\"index.php?c=".$varid[0]."&supcat=1&del=".$id."\">supprimer</a>]<br><br></tr></td>";
$n++;
}
echo "</table>";
echo "<br><form action=\"index.php\">Ajouter une sous-cat&eacute;gorie<br><input type=text name=\"newcat\"><input type=\"hidden\" name=\"idcat\" value=".$varid[0]."><input type=\"hidden\" name=\"c\" value=".$c."><input type=\"submit\" value=\"Ok\"></form>";
echo "<hr>";
$nliens=0;
$requeteliens=mysql_db_query($base,"select nomsite, url, id, valid, description from ".$basesites." where cat1=".$c." or cat2=".$c." or cat3=".$c." order by nomsite",$link);
$numliens=mysql_num_rows($requeteliens);
echo "<ul>";
while ( $nliens<$numliens )
{
$nomsite = mysql_result($requeteliens,$nliens,"nomsite");
$nomsite=lire($nomsite);
$id = mysql_result($requeteliens,$nliens,"id");
$description = mysql_result($requeteliens,$nliens,"description");
$description=lire($description);
$valid = mysql_result($requeteliens,$nliens,"valid");
$url = mysql_result($requeteliens,$nliens,"url");
echo "<li><b><a href=\"".$url."\">".$nomsite."</a></b> - $description - [<a href=\"index.php?c=".$c."&edilink=1&numlink=".$id."\">&eacute;diter</a>] [<a href=\"index.php?c=".$c."&supplink=1&numlink=".$id."\">supprimer</a>] ";
if ($valid==0) { echo "[<a href=\"index.php?c=".$c."&valid=1&numlink=".$id."\"><b><font color=\"red\">valider</font></b></a>]"; }
$nliens++;
}
echo "</ul><br>";
//ajouter un lien
echo "<form action=\"index.php\">Ajouter un lien<br><input type=\"hidden\" name=\"addlink\" value=1><input type=\"hidden\" name=\"c\" value=".$c.">";
echo "<table>
<tr>
<td valign=\"top\">Nom du site</td>
<td><TEXTAREA WRAP=\"physical\" NAME=\"add_nom\" COLS=30 ROWS=3>".stripslashes($add_nom)."</TEXTAREA></td>
</tr>
<tr>
<td valign=\"top\">Description</td>
<td><TEXTAREA WRAP=\"physical\" NAME=\"add_description\" COLS=30 ROWS=3>".stripslashes($add_description)."</TEXTAREA></td>
</tr>
<tr>
<td valign=\"top\">Mots cl&eacute;s</td>
<td><TEXTAREA WRAP=\"physical\" NAME=\"add_mcles\" COLS=30 ROWS=5>".stripslashes($add_mcles)."</TEXTAREA></td>
</tr>
<tr>
<td>URL</td>
<td><INPUT TYPE=\"text\" NAME=\"add_url\" VALUE=\"$add_url\" SIZE=30 MAXLENGTH=100></td>
</tr>
<tr>
<td>Email</td>
<td><INPUT TYPE=\"text\" NAME=\"add_email\" VALUE=\"$add_email\" SIZE=30 MAXLENGTH=100></td>
</tr>
<tr>
<tr>
<td>Cat&eacute;gorie sup. 1 </td>
<td><INPUT TYPE=\"text\" NAME=\"add_cat2\" SIZE=30 MAXLENGTH=100></td>
</tr>
<tr>
<td>Cat&eacute;gorie sup. 2 </td>
<td><INPUT TYPE=\"text\" NAME=\"add_cat3\" SIZE=30 MAXLENGTH=100></td>
</tr>
<tr>
<td colspan=2 align=\"right\"><INPUT TYPE=\"submit\" value=\"Ajouter le lien\">
</form></td>
</tr>
<tr>
<td colspan=2>
<form action=\"index.php\">Importer les meta-tag de l'URL:
<INPUT TYPE=\"text\" NAME=\"add_url\" VALUE=\"$add_url\" SIZE=30 MAXLENGTH=100>
<input type=\"hidden\" name=\"c\" value=".$c.">
<input type=\"hidden\" name=\"meta\" value=1></td>
</tr>
<tr>
<td colspan=2 align=\"right\"><INPUT TYPE=\"submit\" value=\"Importer\"></td>
</tr>
</form>
</table>
";
}
?>
</body>
</html>