<?PHP
/************************************************************************/
/* Upload / meta fonction and automation for NPDS .                     */
/* 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.       */
/*                                                                      */
/* Copyright Dev 2003                                                   */
/************************************************************************/
if (!eregi("modules.php", $PHP_SELF)) { die(); }
global $Titlesitename;

/*****************************************************/
/* Include et definition                             */
/*****************************************************/
   include_once("modules/upload/lang/upload.lang-$language.php");
   include_once("modules/upload/include_minisite/upload.conf.minisite.php");
   if ($userdata[9]!="") {
      if (!$file=@opendir("themes/$userdata[9]")) {
         $theme=$Default_Theme;
      } else {
         $theme=$userdata[9];
      }
   } else {
      $theme=$Default_Theme;
   }
   $userinfo=getusrinfo($user);
   if (!$userinfo[mns]) {Access_error();}
   if (($rep_upload_minisite!="") and ($DOCUMENTROOT!="")) {
      $destination=$DOCUMENTROOT.$rep_upload_minisite;
      if (!stristr($actiontype,".*://") and !stristr($actiontype,"..") and !stristr($actiontype,"../") and !stristr($actiontype, "script") and !stristr($actiontype, "cookie") and !stristr($actiontype, "iframe") and  !stristr($actiontype, "applet") and !stristr($actiontype, "object") and !stristr($actiontype, "meta")) {
         $directory=$racine."/modules/upload/include_minisite/themes/".$actiontype;
      } else {
         Access_error();
      }
   } else {
      Access_error();
   }

/*****************************************************/
/* Entete                                            */
/*****************************************************/
   include("meta/meta.php");
   echo import_css($theme, $language, $site_font);
   echo "<title>$Titlesitename - $uname</title>\n";
   echo "</head>\n<body>";
   if ($actiontype) {
      if ($op==upload_translate("Oui")) {
         // copy le theme dans le répertoire MNS du membre
         $handle=opendir($DOCUMENTROOT.$directory);
         while ($file = readdir($handle)) {
            if (!is_dir($DOCUMENTROOT.$directory."/".$file)) {
               copy ($DOCUMENTROOT.$directory."/".$file, $destination.$file);
            }
         }
         closedir($handle);
         unset ($filelist);
         echo "<script type=\"text/javascript\" language=\"JavaScript\">
               <!--
               window.close();
               //-->
               </script>";
         die();
         // copy le theme dans le répertoire MNS du membre
      } else if ($op=="") {
         echo "<form name=\"adminForm\" method=\"POST\" action=\"$PHP_SELF\" enctype=\"multipart/form-data\">";
         echo "<input type=\"hidden\" name=\"ModPath\" value=\"$ModPath\">\n<input type=\"hidden\" name=\"ModStart\" value=\"$ModStart\">\n";
         echo "<input type=\"hidden\" name=\"actiontype\" value=\"$actiontype\">\n";
         echo "<p align=\"center\"><span class=\"ROUGE\">".upload_translate("Etes vous certains de vouloir installer le thème")." :</span><br /><br /><span class=\"NOIR\" style=\"font-size: 12px;\"> $actiontype</span><br /><br />";
         echo "<input class=\"BOUTON_STANDARD\" type=\"submit\" name=\"op\" value=\"".upload_translate("Oui")."\">&nbsp;&nbsp;";
         echo "<input class=\"BOUTON_STANDARD\" type=\"submit\" name=\"op\" value=\"".upload_translate("Non")."\"></p>";
         echo "<hr noshade class=\"ONGL\">";

         if (file_exists($DOCUMENTROOT.$racine."/modules/upload/include_minisite/themes/message-".$language.".php")) {
            include ($DOCUMENTROOT.$racine."/modules/upload/include_minisite/themes/message-".$language.".php");
         }
         echo "<br /><br /><p align=\"center\"><a href=\"http://www.npds.org\ class=\"NOIR\">MiniSites - copyrights NPDS</a></p>";
         die();
      }
   }

   echo "<form name=\"adminForm\" method=\"post\" action=\"$PHP_SELF\" enctype=\"multipart/form-data\">";
   echo "<input type=\"hidden\" name=\"ModPath\" value=\"$ModPath\">\n<input type=\"hidden\" name=\"ModStart\" value=\"$ModStart\">\n";
   // modele
   echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\">";
   echo "<tr><td valign=\"center\" class=\"NOIR\">".upload_translate("Modèles")." :";
   echo "&nbsp;&nbsp;<input class=\"BOUTON_STANDARD\" type=\"submit\" name=\"submit\" value=\"".upload_translate("Installer")."\"><hr noshade class=\"ONGL\"></td></tr>";

   $directory=$racine."/modules/upload/include_minisite/themes";
   $handle=opendir($DOCUMENTROOT.$directory);
   while ($file = readdir($handle)) $filelist[] = $file;
   asort($filelist);
   while (list ($key, $file) = each ($filelist)) {
      if (!ereg("\.",$file)) {
         if (file_exists($DOCUMENTROOT.$directory."/".$file."/hardcopy.jpg")) {
            $hardcopy="<img src=\"".$directory."/".$file."/hardcopy.jpg\" border=\"0\">";
         } else {
            $hardcopy="";
         }
         echo "<tr><td class=\"NOIR\"><b>=> ".$file."</b><br />&nbsp;".$hardcopy;
         echo "<input class=\"TEXBOX\" type=\"radio\" name=\"actiontype\" value=\"".$file."\">";
         echo "<hr noshade class=\"ONGL\"></td></tr>";
      }
   }
   closedir($handle);
   unset ($filelist);
   echo "</table>\n";
   echo "</body></html>\n";
?>