website logo
Auteur
avatar
Elcorsu

Forum » » Le coin des codeurs » » [Résolu] - Gérer les abonnements aux articles?


Posté : 11 avr. 2007 à 04:16 icone du post

Voila c'est bon ça marche.
J'ai effacé mes posts précédents pour plus de lisibilité.
C'est le version définitives pour LA GESTION DES SUJETS ACTIFS.
Le nom du fichier est cpgd_abon_article.php.

<?
# Last Update: 11 avril 2007
#######################################################
# NPDS : Nuke Permanent Double-Side Web Portal System
# =========================================
# Original Copyright (c) 2001 by Francisco Burzi (fburzi@ncc.org.ve)
# http://phpnuke.org
#
# This version name NPDS Copyright (c) 2001
# ---------------------------------------------------------------------
# cpgd_abon_article.php created (c) Avril 2007 by Elcorsu
#
# 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.
#######################################################
# définition couleur
$textsize10 = 3; # Grand Titre
$textsize11 = 2; # Titres colonnes
$textsize12 = 1; # Texte Lignes
# définition couleur
$textcolor10 = "red"; # Grand Titre
$textcolor11 = "black"; # Titres colonnes
$textcolor12 = "black"; # Texte Lignes
# définition couleurs du tableau
$bgcolor10 = "#FFCC99"; # Titres colonnes
$bgcolor11 = "#C5AFCC"; # Ligne impaires
$bgcolor12 = "#ABCC11"; # Ligne paires

#--------------------------------------------------
if(!isset($mainfile)) !include!("mainfile.php");

# vérif si Membre
if(isset($user) AND !empty($user)) {
$user2 = explode(":", base_64_decode($user));
$result = mysql_query("SELECT uid, uname FROM users WHERE uid='$user2[0]' AND uname='$user2[1]'");
$object = @mysql_fetch_object($result);
if (is_object($object)) {
if ($user2[0]== $object->uid) define("USER_ID",$user2[0]);
if ($user2[1]== $object->uname) define("USER_NAME",$user2[1]);
# Clear Buffer and Erase var.
mysql_free_result($result); unset($result,$object);
} else Header("location: index.php");
} else Header("location: index.php");

# 1= + cadres droite
# 0= pas de cradres (comme pour le forum)
global $pdst; $pdst=0;
if ($op!="maj_subscribe") {
!include!("header.php");
OpenTable();
echo "<center><font color=\"$textcolor10\" size=\"$textsize10\"><b>Abonnements des membres aux articles</b></font></center>";
echo "<br><br>";
echo "<table width=\"95%\" cellpadding=\"5\" cellspacing=\"0\" align=\"center\" border=\"0\">";
echo "<tr bgcolor=\"$bgcolor10\">";
echo "<td align=\"center\"><font color=\"$textcolor11\" size=\"$textsize11\"><b>N°</b></font></td>";
echo "<td align=\"center\"><font color=\"$textcolor11\" size=\"$textsize11\"><b>ID membre</b></font></td>";
echo "<td align=\"center\"><font color=\"$textcolor11\" size=\"$textsize11\"><b>Nom du membre</b></font></td>";
echo "<td align=\"center\"><font color=\"$textcolor11\" size=\"$textsize11\"><b>Aux articles</b></font></td>";
echo"</tr>";

$res = @mysql_query("SELECT * FROM users ORDER BY name");
$rows = mysql_numrows($res);
$col++;
while ($ligne = mysql_fetch_array($res)) {
# CHANGEMENT COULEUR
$rowColor = ($col % 2) ? $bgcolor11 : $bgcolor12;
# FORMATAGE
$uid = $ligne["uid"];
$name = $ligne["name"];
{
# AFFICHAGE DES LIGNES
echo "<tr bgcolor=\"$rowColor\" valign=\"middle\">";
echo "<td align=\"center\"><font color=\"$textcolor12\" size=\"$textsize11\"><b>$col</b></font></td>";
echo "<td align=\"center\"><font color=\"$textcolor12\" size=\"$textsize11\"><b>$uid</b></font></td>";
echo "<td><font color=\"$textcolor12\" size=\"$textsize11\">$name</font></td>";
//////////////////////////////////insertion du formulaire topics//////////////////////////////////////////////////////////////

echo "<td>";
$result = mysql_query("select topicid, topictext from topics order by topicname");
echo "<form action=\"cpgd_abon_article.php\" method=\"post\">";/////// Nom à changer si vous renommez ce fichier
echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr>";
$pas=0;
while(list($topicid, $topictext) = mysql_fetch_array($result)) {
$pas++;
$resultX = mysql_query("select topicid from subscribe where uid='$uid' and topicid='$topicid'");
if (mysql_num_rows($resultX)=="1") {
echo "<td nowrap=\"nowrap\"><input class=\"texbox\" type=\"checkbox\" name=\"Subtopicid[$topicid]\" checked> ".aff_langue($topictext)."</td>";
} else {
echo "<td nowrap=\"nowrap\"><input class=\"texbox\" type=\"checkbox\" name=\"Subtopicid[$topicid]\"> ".aff_langue($topictext)."</td>";
}
if ($pas>=5) {
echo "</tr><tr>";
$pas=0;
}
}
echo "<td colspan=\"10\" align=\"right\">";
echo "<input type=\"hidden\" name=\"uid\" value=\"$uid\">";
echo "<input type=\"hidden\" name=\"op\" value=\"maj_subscribe\">";
echo "<input class=\"BOUTON_STANDARD\" type=\"submit\" name=\"ok\" value=\"".translate("Submit")."\">";
echo "</td></table>";
echo "</form>";
echo "</td>";
///////////////////////////////////////////fin du formulaire//////////////////////////////////////////////////////////
echo "</tr>\n";
# COMPTEUR LIGNE
$col++;
}
}
echo "</table>";
CloseTable();
mysql_free_result($result);
!include!("footer.php");
}else{
$result = mysql_query("delete from subscribe where uid='$uid' and topicid!='NULL'");
$result = mysql_query("select topicid from topics order by topicid");
while(list($topicid) = mysql_fetch_array($result)) {
if ($Subtopicid[$topicid]=="on") {
$resultX = mysql_query("insert into subscribe (topicid, uid) values ('$topicid','$uid')");
}
}
redirect_!url(!"cpgd_abon_article.php");/////// Nom à changer si vous renommez ce fichier
}
?>


Cet article provient de NPDS
https://www.npds.org/viewtopic.php?topic=22167&forum=5