<?php
include "checklog.php";
$mitt = "<<1-email>>";
if (isset($HTTP_COOKIE_VARS["bonews_mitt"])) {
	$mitt = urldecode($HTTP_COOKIE_VARS["bonews_mitt"]);
}
$ogg = "";
if (isset($HTTP_COOKIE_VARS["bonews_ogg"])) {
	$ogg = urldecode($HTTP_COOKIE_VARS["bonews_ogg"]);
}
$dest = 0;
if (isset($HTTP_COOKIE_VARS["bonews_dest"])) {
	$dest = intval($HTTP_COOKIE_VARS["bonews_dest"]);
}
$enc = 0;
if (isset($HTTP_COOKIE_VARS["bonews_enc"])) {
	$enc = intval($HTTP_COOKIE_VARS["bonews_enc"]);
}
$test = "1";
if (isset($HTTP_COOKIE_VARS["bonews_test"])) {
	$test = intval($HTTP_COOKIE_VARS["bonews_test"]);
}
$listini = "yyyyyyyyyy";
if (isset($HTTP_COOKIE_VARS["bonews_list"])) {
	$listini= $HTTP_COOKIE_VARS["bonews_list"];
}

$destsel = Array('','','');
$encsel = Array('','');
$inclist = Array('','','','','','','','','','');
for ($i = 0; $i < 10; $i++) {
	if ($listini[$i] == "y") {
		$inclist[$i] = "checked";
	}
}
$destsel[$dest] = "checked";
$encsel[$enc] = "checked";
if ($test == "1") {$test = "checked";}

?>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<base target="_self">
<link rel="stylesheet" href="backoffice.css" type="text/css">

<script language="JavaScript">
<!--

function LoadFile() {
	document.view.action.value = "upload";
	SaveSettings();
	document.view.submit();
}

function Manda() {
	document.view.action.value = "send";
	SaveSettings();
	document.view.submit();
}

function SaveSettings() {
	document.cookie = "bonews_mitt=" + escape(document.view.mittente.value);
	document.cookie = "bonews_ogg=" + escape(document.view.oggetto.value);
	top.frames["intestazione"].document.tmpform.tmpfield1.value = escape(document.view.messaggio.value);
	valore = "0";
	if (document.view.destinatari[1].checked) {
		valore = "1";
	}
	if (document.view.destinatari[2].checked) {
		valore = "2";
	}
	document.cookie = "bonews_dest=" + valore;
	valore = "0";
	if (document.view.tipo[1].checked) {
		valore = "1";
	}
	document.cookie = "bonews_enc=" + valore;
	valore = "0";
	if (document.view.prova.checked) {
		valore = "1";
	}
	document.cookie = "bonews_test=" + valore;

	stringalistini = "";
	valore = "n";
	if (document.view.listino1.checked) {
		valore = "y";
	}
	stringalistini = stringalistini + valore;
	valore = "n";
	if (document.view.listino2.checked) {
		valore = "y";
	}
	stringalistini = stringalistini + valore;
	valore = "n";
	if (document.view.listino3.checked) {
		valore = "y";
	}
	stringalistini = stringalistini + valore;
	valore = "n";
	if (document.view.listino4.checked) {
		valore = "y";
	}
	stringalistini = stringalistini + valore;
	valore = "n";
	if (document.view.listino5.checked) {
		valore = "y";
	}
	stringalistini = stringalistini + valore;
	valore = "n";
	if (document.view.listino6.checked) {
		valore = "y";
	}
	stringalistini = stringalistini + valore;
	valore = "n";
	if (document.view.listino7.checked) {
		valore = "y";
	}
	stringalistini = stringalistini + valore;
	valore = "n";
	if (document.view.listino8.checked) {
		valore = "y";
	}
	stringalistini = stringalistini + valore;
	valore = "n";
	if (document.view.listino9.checked) {
		valore = "y";
	}
	stringalistini = stringalistini + valore;
	valore = "n";
	if (document.view.listino10.checked) {
		valore = "y";
	}
	stringalistini = stringalistini + valore;
	document.cookie = "bonews_list=" + stringalistini;
}

function Svuota() {
	document.cookie = "bonews_mitt=" + escape("<<1-email>>");
	document.cookie = "bonews_ogg=";
	document.cookie = "bonews_dest=0";
	document.cookie = "bonews_enc=0";
	document.cookie = "bonews_test=1";
	document.cookie = "bonews_list=yyyyyyyyyy";
	top.frames["intestazione"].document.tmpform.tmpfield1.value = "";
	self.location = self.location;
}

function LoadMessage() {
	document.view.messaggio.value=unescape(top.frames["intestazione"].document.tmpform.tmpfield1.value);
}
//-->
</script>
</head>

<body topmargin="0" leftmargin="4" marginwidth="4" marginheight="0" class="tooltip" onLoad="LoadMessage()">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td width="50%"><span class="titolo">Newsletter - </span><span class="sottotitolo">Composizione 
      messaggio </span></td>
    <td width="25%"><span class="sottotitolo"><a href="bonews2.php" target="_self">&gt;&gt;Selezione 
      Utenti </a></span></td>
    <td width="25%">&nbsp;</td>
  </tr>
</table>
<form enctype="multipart/form-data" name="view" action="bonews1update.php" method="post">
  <table border="1" bordercolor="#333399" cellpadding="4" cellspacing="0">
    <tr><td>
        <table border="0" class="form">
          <tr> 
            <td colspan="4" class="intestazione">Messaggio</td>
          </tr>
          <tr> 
            <td>&nbsp;Mittente:</td>
            <td colspan="3"> 
              <input type="text" name="mittente" size="80" class="pulsante" value="<?php echo MakeClean($mitt); ?>">
            </td>
          </tr>
          <tr> 
            <td>Oggetto:</td>
            <td colspan="3"> 
              <input type="text" name="oggetto" size="80" class="pulsante" value="<?php echo MakeClean($ogg); ?>">
            </td>
          </tr>
          <tr> 
            <td>Destinatari:</td>
            <td> 
              <input type="radio" <?php echo $destsel[0]; ?> name="destinatari" value="0">
              Utenti selezionati</td>
            <td align="center"> 
              <input type="radio" <?php echo $destsel[1]; ?> name="destinatari" value="1">
              Iscritti alla newsletter</td>
            <td align="right"> 
              <input type="radio" <?php echo $destsel[2]; ?> name="destinatari" value="2">
              Tutti gli utenti registrati</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td colspan="3" nowrap> &nbsp;&nbsp;Listini:&nbsp; 
              <input type="checkbox" <?php echo $inclist[0]; ?> name="listino1" value="y">
              1&nbsp; 
              <input type="checkbox" <?php echo $inclist[1]; ?> name="listino2" value="y">
              2&nbsp; 
              <input type="checkbox" <?php echo $inclist[2]; ?> name="listino3" value="y">
              3&nbsp; 
              <input type="checkbox" <?php echo $inclist[3]; ?> name="listino4" value="y">
              4&nbsp; 
              <input type="checkbox" <?php echo $inclist[4]; ?> name="listino5" value="y">
              5&nbsp; 
              <input type="checkbox" <?php echo $inclist[5]; ?> name="listino6" value="y">
              6&nbsp; 
              <input type="checkbox" <?php echo $inclist[6]; ?> name="listino7" value="y">
              7&nbsp; 
              <input type="checkbox" <?php echo $inclist[7]; ?> name="listino8" value="y">
              8&nbsp; 
              <input type="checkbox" <?php echo $inclist[8]; ?> name="listino9" value="y">
              9&nbsp; 
              <input type="checkbox" <?php echo $inclist[9]; ?> name="listino10" value="y">
              10</td>
          </tr>
          <tr> 
            <td>Testo:</td>
            <td colspan="3">Carica da file: 
              <input type="file" name="msgfile" class="pulsante" onChange="LoadFile();">
              <input type="hidden" name="action" value="">
            </td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td colspan="3"> 
              <textarea name="messaggio" cols="80" rows="10" class="pulsante"></textarea>
            </td>
          </tr>
          <tr> 
            <td>Invia come:</td>
            <td> 
              <input type="radio" <?php echo $encsel[0]; ?> name="tipo" value="0">
              Testo normale</td>
            <td> 
              <input type="radio" <?php echo $encsel[1]; ?> name="tipo" value="1">
              HTML</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td colspan="3">&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td> 
              <input type="button" name="Submit" value="Invia" class="pulsante" onClick="Manda();">
            </td>
            <td> 
              <input type="checkbox" <?php echo $test; ?> name="prova" value="1">
              Invio di prova (invia solo al mittente)</td>
            <td align="right"> 
              <input type="button" name="Reset" value="Reset" class="pulsante" onClick="Svuota();">
            </td>
          </tr>
        </table>
  </td></tr></table>
</form>
<p>&nbsp;</p>
<form name="help"><input type="hidden" name="pagina" value="newsletter.htm"></form>
</body>
</html>
