<script type="text/javascript" language="JavaScript">
<!-- // Hide for old browsers
var has_submitted = 0;

function checkForm(f) {
  if (has_submitted == 0) {
    sel=false;
    for (i = 0; i < f.elements.length; i++) {
       if ( (f.elements[i].name == 'del_att[]')&&(f.elements[i].checked) ){
        sel = true;
        break;
      }
    }
    if (sel) {
      if (window.confirm("<?php echo upload_translate("Supprimer les fichiers sélectionnés ?")?>") ) {
         has_submitted = 1;
         setTimeout('has_submitted=0', 5000);
         return true;
     } else {
        return false;         
     }
    } else {
       has_submitted = 1;
       setTimeout('has_submitted=0', 5000);
       return true;
    }
  } else {
    alert("<?php echo upload_translate("Cette page a déjà été envoyée, veuillez patienter")?>");
    return false;
  }
}

function uniqueSubmit(f) {
  if (has_submitted == 0) {
    has_submitted = 1;
    setTimeout('has_submitted=0', 5000);
    f.submit();
  } else {
    alert("<?php echo upload_translate("Cette page a déjà été envoyée, veuillez patienter")?>");
    return false;
  }
}

function deleteFile(f) {
  sel=false;
  for (i = 0; i < f.elements.length; i++) {
    if ( (f.elements[i].name == 'del_att[]')&&(f.elements[i].checked) ){
      sel = true;
      break;
    }
  }
  if (sel == false) {
    f.actiontype.value='';
    alert("<?php echo upload_translate("Vous devez tout d'abord choisir la Pièce jointe à supprimer")?>");
    return false;
  } else {
    if (window.confirm("<?php echo upload_translate("Supprimer les fichiers sélectionnés ?")?>") ) {
      f.actiontype.value='delete';
      uniqueSubmit(f);
      return true;
    } else {
      return false;
    }
  }
}

function uploadFile(f) {
  if(f.pcfile.value.length>0) {
    f.actiontype.value='upload';
    uniqueSubmit(f);
  } else {
    f.actiontype.value='';
    alert ("<?php echo upload_translate("Vous devez selectionner un fichier")?>");
   f.pcfile.focus();
  }
}

function confirmSendFile(f) {
  if (window.confirm("<?php echo upload_translate("Joindre le fichier maintenant ?")?>") ) {
    uploadFile(f);
  }
}

function raff() {
  document.location.href='modules.php?ModPath=upload&ModStart=include_minisite/upload_minisite2&apli=minisite';
  return true;
}
function themes() {
  window.open('modules.php?ModPath=upload&ModStart=include_minisite/themes','TtmpMinisite', 'menubar=no,location=no,directories=no,status=no,copyhistory=no,toolbar=no,scrollbars=yes,resizable=yes, width=220, height=450');
  return true;
}

// End of script -->
</script>

<?PHP
/************************************************************************/
/* Upload / meta fonction and automation for NPDS .                     */
/* This version name NPDS Copyright (c) 2001-2004 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 Snipe 2003                                                 */
/************************************************************************/
   global $PHP_SELF,$ModPath,$ModStart,$apli, $MAX_FILE_SIZE;
   echo "<form method=\"post\" action=\"$PHP_SELF\" enctype=\"multipart/form-data\" name=\"form0\" onSubmit=\"return checkForm(this);\">";
   echo "<input type=\"hidden\" name=\"actiontype\" value=\"\">\n<input type=\"hidden\" name=\"ModPath\" value=\"$ModPath\">\n<input type=\"hidden\" name=\"ModStart\" value=\"$ModStart\">\n";
   echo "<input type=\"hidden\" name=\"apli\" value=\"$apli\">";

   $tsz = 0;
   $att = getUserAttachmentsfile();

   $att_count = count($att);
   $display_att = true;
   $att_table="<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td width=\"1%\">&nbsp;</td><td class=\"header\">".
   upload_translate("Fichier :")."</td><td class=\"header\" width=\"5%\" nowrap=\"nowrap\">".upload_translate("Taille :")."</td><td class=\"header\" width=\"5%\" nowrap=\"nowrap\">".upload_translate("Type :")."</td><td class=\"header\" width=\"5%\" nowrap=\"nowrap\">".upload_translate("Prévisualisation :")."</td></tr>";

   $Fichier = new File("");
   for ($i=0; $i<$att_count; $i++) {
      $rowcolor=tablos();
      $tsz += $att[$i]['att_size'];
      $att_size=$att[$i]['att_size'];
      $att_type=$att[$i]['att_type'];
      $sz = $Fichier->Pretty_Size($att[$i]['att_size']);
      $att_url = $url_upload.$racine."/getfile.php?att_id=$uname&amp;apli=minisite&amp;att_name=".rawurlencode($att[$i][att_name]);
      $suffix = strtoLower(substr(strrchr($att[$i]['att_name'], '.' ),1));
      if (($att_type=="text/plain") or ($att_type=="text/html")) {
         $att_edition="<a href=\"javascript:void(0);\" onClick=\"window.open('modules.php?ModPath=upload&ModStart=include_minisite/edition&op=".$att[$i][att_name]."','EtmpMinisite', 'menubar=no,location=no,directories=no,status=no,copyhistory=no,toolbar=no,scrollbars=yes,resizable=yes, width=750, height=450');\" class=\"noir\">".$att[$i]['att_name']."</a>";
      } else {
         $att_edition=$att[$i]['att_name'];
      }
      $att_table.="<tr ".$rowcolor."><td>".getCheckBox('del_att[]', $att[$i][att_name], 0, "")."</td><td>&nbsp;".$att_edition."</td><td align=\"center\">".$sz."</td><td nowrap=\"nowrap\"><span style=\"font-size: 10px;\">".$att[$i]['att_type']."</span></td>";
      if (substr($att_type,0,5)=="image") {
         $att_table.="<td align=\"center\"><img src=\"".$att_url."\" ".$att[$i][att_img_size]." alt=\"\" /></td>";
      } else {
         $att_table.="<td align=\"center\"><a href=\"".$att_url."\" target=\"_blank\" class=\"noir\"><span style=\"font-size: 10px;\">".$att[$i]['att_name']."</span></a></td>";
      }
      $att_table.="</tr>";
   }
   $total_sz = $Fichier->Pretty_Size($tsz);
   if ($ibid=theme_image("upload/arrow.gif")) {$imgtmp=$ibid;} else {$imgtmp="images/upload/arrow.gif";}
   $att_table.="<tr><td colspan=\"2\" align=\"left\"><img src=\"".$imgtmp."\" border=\"0\" alt=\"\" align=\"center\" />";
   $att_table.="<a href=\"#\" onclick=\"deleteFile(document.form0); return false;\">".upload_translate("Supprimer les fichier sélectionnés")."</a></td><td align=\"right\"><b>".upload_translate("Total :")."</b></td><td align=\"center\"><b>".$total_sz."</b></td><td>&nbsp;</td></tr>";

   $file_upload_button="<script type=\"text/javascript\" language=\"JavaScript\">\n<!-- // Hide for old browsers\n";
   $file_upload_button.="document.write ('<input type=\"button\" class=\"bouton_standard\" value=\"".upload_translate("Joindre")."\" onClick=\"uploadFile(this.form);\">";
   $file_upload_button.="</td><td><input type=\"button\" class=\"bouton_standard\" value=\"".upload_translate("Raffraichir la page")."\" onClick=\"raff();\"></td>";
   $file_upload_button.="</td><td><input type=\"button\" class=\"bouton_standard\" value=\"".upload_translate("Modèles")."\" onClick=\"themes();\"></td>');\n";
   $file_upload_button.=" // End of script -->\n</script>";

   $att_upload_table="<tr><td colspan=\"2\" align=\"left\">".upload_translate("Fichier joint :")."&nbsp;<input type=\"file\" class=\"textbox_standard\" name=\"pcfile\" width=\"260\" size=\"35\" onChange=\"confirmSendFile(this.form);\"></td><td>".$file_upload_button."</td></tr></table>";

   $att_form="<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\"><tr><td colspan=\"2\" align=\"center\"><hr noshade></td></tr><tr><td colspan=\"2\" align=\"left\">".upload_translate("Pièces jointes :")." (<span style=\"font-size: 10px;\">".$bn_allowed_extensions."</span>)&nbsp;&nbsp;QUOTA : ".$Fichier->Pretty_Size($MAX_FILE_SIZE_TOTAL)." / ".$MAX_FILE_SIZE." ( ".$Fichier->Pretty_Size($MAX_FILE_SIZE)." ) </td></tr><tr><td colspan=\"1\" align=\"center\">";
   $att_form.=$att_table.$att_upload_table;
   $att_form.="</td></tr><tr><td colspan=\"2\" align=\"center\"><hr noshade></td></tr></table>";
   echo $att_form."<br />".$thanks_msg;
   echo "</body></html>";
   ob_end_flush();
?>