Posté : 16-11-2003 16:46
DSL, pour me faire pardonner, voici le code en intégral:
<?PHP
****************************************************************************** ***********/
/* NPDS V - MetaTags 0.1b (20020803) ! */
/* based on PHPNuke's metatags admin module (http://www.phpnuke.org) */
/* M. PASCAL aKa EBH (plan.net@free.fr) */
/* */
/* This program is free software. You can redistribute it and/or modify it under the */
/* terms of the GNU General Public License as published by the Free Software Foundation */
/* either version 2 of the license. */
/* */
/* ver 0.1c : ajout des effets de transitions (fonctionne uniquement avec IE) */
/* */
/* ver 0.1b : suppression 'include(config.php)' */
/* */
/* ver 0.1a : ajout/modification d'options, */
/* page de manuel manual/metatags.html */
/* */
/* ver 0.1 : adaptation de metatags, HTML/CSS (en attente de CLASS admin) */
/* */
****************************************************************************** ***********/
function Access_Error () {
echo "<html><body bgcolor=white><BR><center><b><font face=arial color=Red size=3>";
echo "Access Denied / Accès Refusé";
echo "<BR><BR><font size=1 color=black>NPDS - Portal System / Générateur de portail";
echo "</font></b></body></html>";
die();
}
if (!eregi("admin.php", $PHP_SELF)) { Access_Error(); }
global $pdst; $pdst = "0";
global $language;
$hlpfile = "manual/$language/metatags.html";
$result = mysql_query("SELECT radminsuper FROM authors WHERE aid='$aid'");
list($radminsuper) = mysql_fetch_row($result);
if ($radminsuper != 1) {
Access_Error();
} else {
function GetMetaTags($filename)
{
if(file_exists($filename))
{
$temp = file($filename);
while($line = each($temp))
{
$aline = trim(stripslashes($line[value]));
if(ereg(".*<META (name|http-equiv)="(.*)" content="(.*)".*>", $aline, $regs))
{
$regs[2] = strtolower($regs[2]);
$tags[$regs[2]] = $regs[3];
}
}
}
return $tags;
}
function MetaTagAdmin($saved = false)
{
global $hlpfile;
$tags = GetMetaTags("meta/meta.php");
include("header.php");
GraphicAdmin($hlpfile);
OpenTable();
echo "<TABLE WIDTH=100% CELLSPACING=2 CELLPADDING=2 BORDER=0><TR><TD CLASS="HEADER">n";
echo adm_translate("Administration des MétaTags");
echo "</TD></TR></TABLE>n";
echo "<BR>n";
if($saved)
{
echo "<center><b><FONT CLASS="ROUGE">".adm_translate("Vos MétaTags ont été modifiés avec succès !")."<BR></FONT></b></center>n";
}
if(strstr(getenv("HTTP_USER_AGENT"),"MSIE"))
{
$max_car = 90;
}
else
{
$max_car = 65;
}
echo "<FORM action="admin.php" method="post">n";
echo "<B>".adm_translate("Auteur(s)")." :</B><BR>n";
echo "<INPUT class="TEXTBOX_STANDARD" type="text" name="newtag[author]" value="".$tags[author]."" size="".$max_car."" maxlength="100"><BR>n";
echo adm_translate("(Ex. : nom du webmaster)")."<BR><BR>n";
echo "<B>".adm_translate("Propriétaire")." :</B><BR>n";
echo "<INPUT class="TEXTBOX_STANDARD" type="text" name="newtag[owner]" value="".$tags[owner]."" size="".$max_car."" maxlength="100"><BR>n";
echo adm_translate("(Ex. : nom de votre compagnie/service)")."<BR><BR>n";
echo "<B>".adm_translate("Adresse e-mail principale")." :</B><BR>n";
echo "<INPUT class="TEXTBOX_STANDARD" type="text" name="newtag[reply-to]" value="".$tags['reply-to']."" size="".$max_car."" maxlength="100"><BR>n";
echo adm_translate("(Ex. : l'adresse e-mail du webmaster)")."<BR><BR>n";
echo "<B>".adm_translate("Langue principale")." :</B><BR>n";
echo "<INPUT class="TEXTBOX_STANDARD" type="text" name="newtag[language]" value="".$tags['language']."" size="6" maxlength="5"><BR>n";
echo adm_translate("(Ex. : fr(Français), en(Anglais), en-us(Américain), de(Allemand), it(Italien), pt(Portugais), etc)")."<BR><BR>n";
echo "<B>".adm_translate("Description")." :</B><BR>n";
echo "<INPUT class="TEXTBOX_STANDARD" type="text" name="newtag[description]" value="".$tags[description]."" size="".$max_car."" maxlength="200"><BR>n";
echo adm_translate("(Brève description des centres d'intérêt du site. 200 caractères maxi.)")."<BR><BR>n";
echo "<B>".adm_translate("Mot(s) clé(s)")." :</B><BR>n";
echo "<INPUT class="TEXTBOX_STANDARD" type="text" name="newtag[keywords]" value="".$tags[keywords]."" size="".$max_car."" maxlength="1000"><BR>n";
echo adm_translate("(Définissez un ou plusieurs mot(s) clé(s). 1000 caractères maxi.<BR>Remarques : une lettre accentuée équivaut le plus souvent à 8 caractères. La majorité des moteurs de recherche font la distinction minuscule/majuscule. Séparez vos mots par une virgule)")."<BR><BR>n";
echo "<B>".adm_translate("Audience")." :</B><BR>n";
echo "<SELECT class="TEXTBOX_STANDARD" name="newtag[rating]">n";
echo "<OPTION value="general"".(!strcasecmp($tags[rating], 'general') ? " selected" : "").">".adm_translate("Tout public")."</OPTION>n";
echo "<OPTION value="mature"".(!strcasecmp($tags[rating], 'mature') ? " selected" : "").">".adm_translate("Adulte")."</OPT ION>n";
echo "<OPTION value="restricted"".(!strcasecmp($tags[rating], 'restricted') ? " selected" : "").">".adm_translate("Accès restreint")."</OPTION>n";
echo "<OPTION value="14 years"".(!strcasecmp($tags[rating], '14 years') ? " selected" : "").">".adm_translate("14 ans")."</OPTION>n";
echo "</SELECT><BR>n";
echo adm_translate("(Définissez le public intéressé par votre site)")."<BR><BR>n";
echo "<B>".adm_translate("Distribution")." :</B><BR>n";
echo "<SELECT class="TEXTBOX_STANDARD" name="newtag[distribution]">n";
echo "<OPTION value="global"".(!strcasecmp($tags[distribution], 'global') ? " selected" : "").">".adm_translate("Large")."</OPTI ON>n";
echo "<OPTION value="local"".(!strcasecmp($tags[distribution], 'local') ? " selected" : "").">".adm_translate("Restreinte")."< /OPTION>n";
echo "</SELECT><BR><BR>n";
echo "<B>".adm_translate("Copyright")." :</B><BR>n";
echo "<INPUT class="TEXTBOX_STANDARD" type="text" name="newtag[copyright]" value="".$tags[copyright]."" size="$max_car" maxlength="100"><BR>n";
echo adm_translate("(Informations légales)")."<BR><BR>n";
echo "<B>".adm_translate("Robots/Spiders")." :</B><BR>n";
echo "<SELECT class="TEXTBOX_STANDARD" name="newtag[robots]">n";
echo "<OPTION value="all"".(!strcasecmp($tags[robots], 'all') ? " selected" : "").">".adm_translate("Tout contenu (page/liens/etc)")."</OPTION>n";
echo "<OPTION value="none"".(!strcasecmp($tags[robots], 'none') ? " selected" : "").">".adm_translate("Aucune indexation")."</OPTION>n";
echo "<OPTION value="index,follow"".(!strcasecmp($tags[robots], 'index,follow') ? " selected" : "").">".adm_translate("Page courante et liens locaux")."</OPTION>n";
echo "<OPTION value="index,nofollow"".(!strcasecmp($tags[robots], 'index,nofollow') ? " selected" : "").">".adm_translate("Page courante sans liens locaux")."</OPTION>n";
echo "<OPTION value="noindex,follow"".(!strcasecmp($tags[robots], 'noindex,follow') ? " selected" : "").">".adm_translate("Liens locaux sauf page courante")."</OPTION>n";
echo "<OPTION value="noindex,nofollow"".(!strcasecmp($tags[robots], 'noindex,nofollow') ? " selected" : "").">".adm_translate("Ni page courante, ni liens locaux")."</OPTION>n";
echo "</SELECT><BR>n";
echo adm_translate("(Définissez la méthode d'analyse que doivent adopter les robots des moteurs de recherche)")."<BR><BR>n";
echo "<B>".adm_translate("Fréquence de visite des Robots/Spiders")." :</B><BR>n";
echo "<INPUT class="TEXTBOX_STANDARD" type="text" name="newtag[revisit-after]" value="".$tags['revisit-after']."" size="20" maxlength="30"><BR>n";
echo adm_translate("(Ex. : 16 days. Remarque : ne définissez pas de fréquence inférieure à 14 jours !)")."<BR><BR>n";
echo "<INPUT type="hidden" name="op" value="MetaTagSave">n";
echo "<INPUT class="BOUTON_STANDARD" type="submit" value="".adm_translate("Enregistrer")."">n&quo t;;
echo "</FORM>n";
CloseTable();
include("footer.php");
}
function MetaTagMakeSingleTag($name, $content, $type='name')
{
return "echo "<META $type=\"".$name."\" content=\"".$content."\">\n";n";
}
function MetaTagSave($filename, $tags)
{
if(!is_array($tags)) { return false; }
global $adminmail, $Version_Id, $Version_Num, $Version_Sub;
$fh = fopen($filename, "w");
if($fh)
{
$content = "<?phpn"
."if(eregi("meta.php",$PHP_SELF))n"
."{n"
." Header("Location: ../index.php");n"
." die();n"
."}n"
."/* Ne modifiez pas ce fichier manuellement. Utilisez l'interface d'administration */n"
."/* Do not change anything in this file manually. Use the administration interface*/n";
$content .= MetaTagMakeSingleTag('content-type', "text/html; charset=ISO-8859-1", 'http-equiv');
$content .= MetaTagMakeSingleTag('content-script-type', 'text/javascript', 'http-equiv');
$content .= MetaTagMakeSingleTag('content-style-type', 'text/css', 'http-equiv');
$content .= MetaTagMakeSingleTag('expires', '0', 'http-equiv');
$content .= MetaTagMakeSingleTag('pragma', 'no-cache', 'http-equiv');
$content .= MetaTagMakeSingleTag('identifier-url', '$nuke_url', 'http-equiv');
$content .= MetaTagMakeSingleTag('page-enter', 'BlendTrans(Duration=2.0)', 'http-equiv');
$content .= MetaTagMakeSingleTag('page-exit', 'RevealTrans(Duration=2, Transition=Random Effect)', 'http-equiv');
if(!empty($tags[author]))
{
$tags[author] = htmlspecialchars(stripslashes($tags[author]));
$content .= MetaTagMakeSingleTag('author', $tags[author]);
}
if(!empty($tags[owner]))
{
$tags[owner] = htmlspecialchars(stripslashes($tags[owner]));
$content .= MetaTagMakeSingleTag('owner', $tags[owner]);
}
if(!empty($tags['reply-to']))
{
$tags['reply-to'] = htmlspecialchars(stripslashes($tags['reply-to']));
$content .= MetaTagMakeSingleTag('reply-to', $tags['reply-to']);
}
else
{
$content .= MetaTagMakeSingleTag('reply-to', $adminmail);
}
if(!empty($tags[language]))
{
$tags[language] = htmlspecialchars(stripslashes($tags[language]));
$content .= MetaTagMakeSingleTag('language', $tags[language]);
if($tags[language] == "fr")
{
$content .= MetaTagMakeSingleTag('content-language', 'fr, fr-be, fr-ca, fr-lu, fr-ch', 'http-equiv');
}
else
{
$content .= MetaTagMakeSingleTag('content-language', '$tags[language]', 'http-equiv');
}
}
if(!empty($tags[description]))
{
$tags[description] = htmlspecialchars(stripslashes($tags[description]));
$content .= MetaTagMakeSingleTag('description', $tags[description]);
}
if(!empty($tags[keywords]))
{
$tags[keywords] = htmlspecialchars(stripslashes($tags[keywords]));
$content .= MetaTagMakeSingleTag('keywords', $tags[keywords]);
}
if(!empty($tags[rating]))
{
$tags[rating] = htmlspecialchars(stripslashes($tags[rating]));
$content .= MetaTagMakeSingleTag('rating', $tags[rating]);
}
if(!empty($tags[distribution]))
{
$tags[distribution] = htmlspecialchars(stripslashes($tags[distribution]));
$content .= MetaTagMakeSingleTag('distribution', $tags[distribution]);
}
if(!empty($tags[copyright]))
{
$tags[copyright] = htmlspecialchars(stripslashes($tags[copyright]));
$content .= MetaTagMakeSingleTag('copyright', $tags[copyright]);
}
if(!empty($tags['revisit-after']))
{
$tags['revisit-after'] = htmlspecialchars(stripslashes($tags['revisit-after']));
$content .= MetaTagMakeSingleTag('revisit-after', $tags['revisit-after']);
}
else
{
$content .= MetaTagMakeSingleTag('revisit-after', "14 days");
}
$content .= MetaTagMakeSingleTag('resource-type', "document");
$content .= MetaTagMakeSingleTag('robots', $tags[robots]);
$content .= MetaTagMakeSingleTag('generator', "$Version_Id $Version_Num $Version_Sub");
$content .= "?>";
fwrite($fh, $content);
fclose($fh);
return true;
}
return false;
}
switch($op)
{
case "MetaTagSave":
$meta_saved = MetaTagSave("meta/meta.php", $newtag);
case "MetaTagAdmin":
MetaTagAdmin($meta_saved);
break;
}
}
?> |