<?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(); }

function L_encrypt($txt) {
   global $userdata;

   $key=substr($userdata[2],8,8);
   return (encryptK($txt, $key));
}

/*****************************************************/
/* 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;
   }

   $fic_edition="";
   $userinfo=getusrinfo($user);
   if (!$userinfo[mns]) {Access_error();}
   if (($rep_upload_minisite!="") and ($DOCUMENTROOT!="")) {
      $fic_edition=$DOCUMENTROOT.$rep_upload_minisite.$op;
      if (!stristr($op,".*://") and !stristr($op,"..") and !stristr($op,"../") and !stristr($op, "script") and !stristr($op, "cookie") and !stristr($op, "iframe") and  !stristr($op, "applet") and !stristr($op, "object") and !stristr($op, "meta")) {
         $fic_edition=removeHack($DOCUMENTROOT.$rep_upload_minisite.$op);
      } else {
         Access_error();
      }
   } else {
      Access_error();
   }

   if ($submitS) {
      $file = fopen($fic_edition, "w");
      if ($op=="carnet.txt") {
         if (substr($story,0,5)!="CRYPT") {
            $story="CRYPT".L_encrypt($story);
         }
      }
      fwrite($file, removeHack(StripCSlashes($story)));
      fclose($file);
   }
/*****************************************************/
/* Entete                                            */
/*****************************************************/
   $Titlesitename.=$uname;
   include("meta/meta.php");
   echo import_css($theme, $language, $site_font, "","");

   global $tiny_mce;
   if ($tiny_mce) {
      $tiny_mce_theme="full";
      echo aff_editeur("tiny_mce","begin");
   }
   echo "</head>\n<body>";
   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=\"op\" value=\"$op\">";
   echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\">";
   echo "<tr><td colspan=\"2\"><textarea name=\"story\" rows=\"25\" cols=\"70\" style=\"width: 100%;\" class=\"textbox\">";

   // lecture du fichier
   $file = fopen($fic_edition, "r");
   if (filesize($fic_edition)>0)
      $fic_tmp=fread($file, filesize($fic_edition));
   if ($op=="carnet.txt") {
      if (substr($fic_tmp,0,5)=="CRYPT") {
         $fic_tmp=decryptK(substr($fic_tmp,5),substr($userdata[2],8,8));
      }
   }
   echo StripCSlashes($fic_tmp);
   fclose($file);
   // lecture du fichier

   echo "</textarea></td></tr><tr>";
   $suffix = strtoLower(substr(strrchr($op, '.' ),1));
   if (($suffix=="htm") or ($suffix=="html")) {
   if ($tiny_mce) {
      echo "<td>".aff_editeur("story","false")."</td>";
      echo aff_editeur("tiny_mce","end");
   } else {
      echo "<td>".aff_editeur("custom","story&minisite=true&membre=$userdata[1]")."</td>";
   }
   }
   echo "<td align=\"right\"><input type=\"submit\" name=\"submitS\" value=\"".translate("Submit")."\" class=\"bouton_standard\"></td></tr>";
   echo "</table></form></body></html>\n";
?>