<?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.       */
/************************************************************************/
/************************************************************************/
/* Module-Install Version 1.1 - Mai 2005                                */
/* --------------------------                                           */
/* Copyright (c) 2005 Boris L'Ordi-Dépanneur & Hotfirenet               */
/* www.lordi-depanneur.com // www.hotfirenet.com                        */
/*                                                                      */
/* Intégration au coeur de Npds par Boris et Hotfirenet pour SABLE      */
/*                                                                      */
/* Installeur inspiré du programme d'installation d'origine du module   */
/* Hot-Projet développé par Hotfirenet                                  */
/*                                                                      */
/************************************************************************/
function Access_Error () {
  if (file_exists("meta/meta.php"))
     include ("meta/meta.php");
  echo "<title>NPDS</title></head><body bgcolor=\"white\"><br /><p align=\"center\"><span style=\"font-size: 14px; font-family: Arial; font-weight: bold; color: red;\">";
  echo "Access Denied / Acc&egrave;s Refus&eacute;";
  if (cur_charset=="utf-8") echo" / &#x901A;&#x5165;&#x88AB;&#x5426;&#x8BA4;";
  echo "</span>";
  echo "<br /><br /><span style=\"font-size: 12px; font-family: Arial; font-weight: bold; color: black;\">NPDS - Portal System";
  echo "</span></p></body></html>";
  die();
}
if (!eregi("admin.php", $PHP_SELF)) { Access_Error(); }
global $pdst; $pdst="0";

global $language;
$result = mysql_query("select radminsuper from authors where aid='$aid'");
list($radminsuper) = mysql_fetch_row($result);
if ($radminsuper!=1) {
   Access_Error();
}

function detection_module() {
   global $NPDS_Prefix;

   $handle=opendir('modules');
   while ($file=readdir($handle)) {
      if ((!ereg("[.]",$file)) && (!ereg("blog",$file)) && (!ereg("cluster-paradise",$file)) && (!ereg("documentations",$file)) && (!ereg("include",$file)) && (!ereg("meta-lang",$file)) && (!ereg("sform",$file)) && (!ereg("upload",$file))) {
        $modlist.="$file ";
      }
   }
   closedir($handle);
   $modlist=explode(" ",rtrim($modlist));
   sort($modlist);

   for ($i=0; $i<count($modlist); $i++) {
      $queryexiste=mysql_query("select mnom from ".$NPDS_Prefix."modules where mnom='".$modlist[$i]."'");
      if ($queryexiste)
         $moexiste=mysql_num_rows($queryexiste);
      if ((!empty($modlist[$i])) && ($moexiste!=1)) {
         mysql_query("insert into ".$NPDS_Prefix."modules values (NULL, '".$modlist[$i]."', '0')");
      }
   }
}

   include("header.php");
   GraphicAdmin($hlpfile);
   opentable();
   detection_module();
   echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td class=\"HEADER\">\n";
   echo adm_translate("Gestion, Installation Modules");
   echo "</td></tr></table>\n";
   echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">";
   echo "<tr><td width=\"10%\" align=\"center\"><b>ID</b></td><td align=\"left\"><b>".adm_translate("Nom")."</b></td><td align=\"left\"><b>".adm_translate("Fonctions")."</b></td><tr>\n";
   $result = mysql_query("select * from ".$NPDS_Prefix."modules");
   while ($row = mysql_fetch_array($result)) {
       if ($row["minstall"] == 0) {
          if (file_exists("modules/".$row["mnom"]."/install.conf.php")) {
             $status_chngac = "<a href=\"admin.php?op=Module-Install&amp;ModInstall=".$row["mnom"]."\" class=\"NOIR\">".adm_translate("Installer le module")."</a></td><td align=\"right\">[&nbsp;<a href=\"admin.php?op=Module-Install&amp;ModInstall=".$row["mnom"]."&amp;subop=install\" class=\"NOIR\">".adm_translate("Marquer le module comme installé")."</a>&nbsp;]";
          } else {
             $status_chngac = "<span class=\"NOIR\">".adm_translate("Pas d'installeur disponible")."</span></td><td align=\"right\">[&nbsp;<a href=\"admin.php?op=Module-Install&amp;ModInstall=".$row["mnom"]."&amp;subop=install\" class=\"NOIR\">".adm_translate("Marquer le module comme installé")."</a>&nbsp;]";
          }
       } else {
          $status_chngac = "<a href=\"admin.php?op=Module-Install&amp;ModDesinstall=".$row["mnom"]."\" class=\"ROUGE\">".adm_translate("Désinstaller le module")."</a></td><td align=\"right\">&nbsp;";
       }
       $rowcolor=tablos();
       echo "<tr $rowcolor>"
       ."<td align=\"center\">".$row["mid"]."</td>"
       ."<td align=\"left\">".$row["mnom"]."</td>"
       ."<td align=\"left\">".$status_chngac."</td>"
       ."</tr>\n";
   }
   echo "</table>\n";
   closetable();
   include("footer.php");
?>