<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<?php
ini_set("log_errors", 1);
ini_set('error_reporting', E_ALL);

$resultat = Client::getClientWithEMail() or die('Erreur SQL !');
$numrows=count($resultat);
print $numrows;

function getFileList($dir){
  // array to hold return value
  $retval = array();

  // add trailing slash if missing
  if(substr($dir, -1) != "/") $dir .= "/";

  // open pointer to directory and read list of files
  $d = @dir($dir) or die("getFileList: Failed opening directory $dir for reading");
  while(false !== ($entry = $d->read())) {
    // skip hidden files
    if($entry[0] == ".") continue;
    if(is_dir("$dir$entry")) {
      $retval[] = array(
        "name" => "$dir$entry/",
        "type" => filetype("$dir$entry"),
        "size" => 0,
        "lastmod" => filemtime("$dir$entry")
      );
    } elseif(is_readable("$dir$entry")) {
      $retval[] = array(
        "name" => "$dir$entry",
        "type" => mime_content_type("$dir$entry"),
        "size" => filesize("$dir$entry"),
        "lastmod" => filemtime("$dir$entry")
      );
    }
  }
  $d->close();

  return $retval;
}
$dirlist = getFileList("menu/client/promo/uploads");
echo "<br>";
echo "Selectionnez une image à joindre au courrier:";
echo '<form action="menu/client/promo/action_promo.php" id="promoform">';
echo "<table border=\"1\">\n";
  echo "<thead>\n";
  echo "<tr><th></th><th>Name</th><th>Type</th><th>Size</th><th>Last Modified</th></tr>\n";
  echo "</thead>\n";
  echo "<tbody>\n";
  foreach($dirlist as $file) {
    echo "<tr>\n";
    echo "<td><INPUT type=checkbox name=imgjoin value={$file['name']}></td>";
    echo "<td>{$file['name']}</td>\n";
    echo "<td>{$file['type']}</td>\n";
    echo "<td>{$file['size']}</td>\n";
    echo "<td>",date('r', $file['lastmod']),"</td>\n";
    echo "</tr>\n";
  }
  echo "</tbody>\n";
  echo "</table>\n\n";
?>

<html>
<SCRIPT LANGUAGE="JavaScript">
function inspectBox(form) {
  if (!form.imgjoin.checked) {
     var retVal = confirm("Vous n'avez pas selectionné d'image à joindre");
     if (retVal == true) {
        return true;
    } 
    else {
        window.open("index.php");
    }
  }
}
</SCRIPT>
<body>
<br>
<INPUT type=checkbox name="ModeTest" value="ModeTestOn" CHECKED="true">MODE TEST<br>
<br>
Sujet du Mail:<INPUT type=text name="txtSubjct" size="64" required placeholder="Info Centre Honda Genève"><br>
<br>
<script src="menu/client/promo/nicEdit/nicEdit.js" type="text/javascript"></script>
<script type="text/javascript">
bkLib.onDomLoaded(function() {
  new nicEditor({iconsPath : 'menu/client/promo/nicEdit/nicEditorIcons.gif'}).panelInstance('area1');
});
</script>

<textarea rows="20" cols="80" name="promotext" id="area1" form="promoform">
<?php 
  $myfile = fopen("menu/client/promo/promotext.txt", "r") or die("Unable to open file!");
  echo fread($myfile,filesize("menu/client/promo/promotext.txt"));
  fclose($myfile);
?>
</textarea>
  <input type="submit" onClick="inspectBox(this.form)">
</form>

<br><br>
si vous voulez utiliser une autre image :

<form method="POST" action="menu/client/promo/upload.php" enctype="multipart/form-data">
     Fichier : <input type="file" name="fileToUpload">
     <input type="submit" name="envoyer" value="Envoyer le fichier">
</form>

</body>
</html>
