<?PHP
/************************************************************************/
/* DUNE by NPDS                                                         */
/*                                                                      */
/* NPDS Copyright (c) 2001-2007 by Philippe Brunier                     */
/*                                                                      */
/* Upload / meta fonction and automation for NPDS .                     */
/*                                                                      */
/* 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 (!eregi("modules.php", $PHP_SELF)) { die(); }

/*****************************************************/
/* 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                                            */
/*****************************************************/
   $Titlesitename=$uname;
   include("meta/meta.php");
   echo import_css($theme, $language, $site_font, "","");
   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=\"middle\" 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";
?>