<?PHP
/************************************************************************/
/* NPDS V : Net Portal Dynamic System .                                 */
/* ===========================                                          */
/*                                                                      */
/* Original Copyright (c) 2001 by Francisco Burzi (fburzi@ncc.org.ve)   */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This version name NPDS Copyright (c) 2001-2005 by Philippe Brunier   */
/*                                                                      */
/* 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.       */
/************************************************************************/
if (!function_exists("Mysql_Connexion")) {include ("mainfile.php");}
   $segment=4; // if you put : pdst=0 then you can put segment=5 (or more)

   if ($op!="maj_subscribe") {
        include("header.php");
        $result = mysql_query("select topicid, topicname, topicimage, topictext from topics order by topicname");
        if (mysql_num_rows($result)==0) {
           opentable();
        }
        if (mysql_num_rows($result) > 0) {
           OpenTable();
           echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
           echo translate("Current Active Topics");
           echo "</td></tr></table>\n";
           echo "<br />".translate("Click to list all articles in this topic")."<br /><br />
           <table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr>";
           while(list($topicid, $topicname, $topicimage, $topictext) = mysql_fetch_array($result)) {
               echo "<td align=\"center\">";
               if ((($topicimage) or ($topicimage!="")) and (file_exists("$tipath$topicimage"))) {
                  echo "<a href=\"index.php?op=newtopic&amp;topic=$topicid\" class=\"NOIR\"><img src=\"$tipath$topicimage\" border=\"0\" alt=\"\" />";
                  echo "<br />".aff_langue($topictext)."</a></td>";
               } else {
                  echo "<a href=\"index.php?op=newtopic&amp;topic=$topicid\" class=\"NOIR\">".aff_langue($topictext)."</a></td>";
               }
               $count++;
               if ($count == $segment) {
                  echo "</tr><tr>";
                  $count = 0;
               }
           }
           echo "</tr></table>";
           if ($subscribe) {
              if ($user) {
                 $result = mysql_query("select topicid, topictext from topics order by topicname");
                 echo "<form action=\"topics.php\" method=\"post\">";
                 echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
                 echo translate("Manage your subscribes");
                 echo "</td></tr></table>\n";
                 echo "<br />";
                 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='$cookie[0]' 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><td width=\"4%\">&nbsp;</td>";
                    } else {
                       echo "<td nowrap=\"nowrap\"><input class=\"texbox\" type=\"checkbox\" name=\"Subtopicid[$topicid]\"> ".aff_langue($topictext)."</td><td width=\"4%\">&nbsp;</td>";
                    }
                    if ($pas>=3) {
                       echo "</tr><tr>";
                       $pas=0;
                    }
                 }
                 echo "</tr><tr><td colspan=\"10\" align=\"right\">";
                 echo "<input type=\"hidden\" name=\"op\" value=\"maj_subscribe\">";
                 echo "<input class=\"BOUTON_STANDARD\" type=\"submit\" name=\"ok\" value=\"".translate("Submit")."\">";
                 echo "</td></tr></table>";
                 echo "</form>";
              }
           }
        }
        CloseTable();
        mysql_free_result($result);
        include("footer.php");
   } else {
      if ($subscribe) {
         if ($user) {
            $result = mysql_query("delete from subscribe where uid='$cookie[0]' 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','$cookie[0]')");
               }
            }
            redirect_url("topics.php");
         }
      }
   }
?>