← Back
Editing: newsletter.php
<?php ###___###___###___###___###___###___###___###___###___###___###___###___### ### made with SmaDIB: Smart Database Interface Builder 0.4.0 ### ### by Smartmedia 2000 http://www.smartmedia2000.it/ ### ### info email: smadib@smartmedia2000.it ### ###___###___###___###___###____###____###____###___###___###___###___### require_once ("../funct.php"); require_once ("sess.php"); require_once ("conn.php"); $ptitolo = "Newsletter"; $table = "newsletter"; $html = "y"; require_once ("testacoda.php"); require_once ($dominio."/param_b.php"); $query = new doQuery(); $oggetto = stripslashes ($_POST['oggetto']); $testo = stripslashes ($_POST['testo']); $data = data2date ($_POST['data']); $userfile = $_FILES['userfile']; $utNewsInt = array (999, 23); # utenti che usano la newsletter direttamente con le email degli intestateari nel sistema require_once ("upload.php"); $updir = $dominio."/attach/"; $save_path = $updir; if ($_POST['az'] == "snd") { $act = "verrà inviata il ".date2data ($data); $allega = $_FILES['userfile']['name']; $allega2 = strtolower ($allega); $risupl = preupload ($userfile,$updir); if (strpos ($allega2, '.jpg') || strpos ($allega2, '.png')) # elabora immagine resampleImgN ($allega); # inserisce la newsletter nel db $sql = "INSERT INTO `".$table."_testo` (`id`, `id_utente`, `titolo`, `testo`, `data`, `allega`) VALUES ('', ".ID_UTENTE.", '".addslashes ($oggetto)."', '".addslashes ($testo)."', '".$data."', '".addslashes ($allega)."')"; $query->freeQuery ($sql, 0); if (in_array ($id_utente, $utNewsInt)) $sql2 = "SELECT DISTINCT `email` FROM `persone` WHERE `id_utente` = ".$id_utente." AND `tipo` < 3"; else $sql2 = "SELECT DISTINCT `email` FROM `newsletter` WHERE `id_utente` = ".$id_utente; $ris2 = mysql_query ($sql2, $conn); $conto = mysql_num_rows ($ris2); $ptitolo = "Invio newsletter"; $elenco.= "<p>".$oggetto."</p> <table align=\"center\" width=\"770\"><tr><td bgcolor=\"#EEEEEE\"> ".$testo." </td></tr></table> <p><b>L'email ".$act." alle ".$conto." indirizzi di persone iscritte.</b></p>"; } else { $ptitolo = "Newsletter"; $elenco.= "<form name=\"form1\" method=\"post\" action=\"".$_SERVER['PHP_SELF']."\" enctype=\"multipart/form-data\" id=\"myForm\"> <table align=\"center\" width=\"770\"> <tr bgcolor=\"#EEEEEE\"><td> <b>Oggetto</b><br /><input type=\"text\" name=\"oggetto\" value=\"Newsletter ".NOME_STR."\" size=\"50\" maxlength=\"250\" /><br /> <b>Data spedizione</b> (l'invio è in differita, non sarà possibile recapitarla prima del ".date ("d/m/Y", time()+3600*24)." mattina)<br /> <input type=\"text\" name=\"data\" value=\"".date ("d/m/Y", time()+3600*24)."\" size=\"12\" /><br /> <b>Allegato (solo immagini o pdf, i nomi non devono contenere spazi o apostrofi)</b><br /><input type=\"file\" name=\"userfile\" value=\"\" size=\"30\"><br /> <b>Testo</b><br /> <textarea name=\"testo\" rows=\"30\" cols=\"100\"> <br /> ".$firma." </textarea> </td></tr><tr><td align=\"center\"> <input type=\"submit\" name=\"invio\" value=\"Salva per l'invio\" /> <input type=\"hidden\" name=\"az\" value=\"snd\" /></td></tr> </table></form><br /> <table align=\"center\" width=\"770\"> <tr><td><b>Oggetto / Testo</b></td> <td><b>Allegato</b></td> <td><b>Data spedizione</b></td></tr> <tr bgcolor=\"#000000\"><td colspan=\"3\" height=\"1\"> </td></tr>"; $table = "newsletter_testo"; $rows = $query->selectAll ($table, array('data'=>'DESC'), 0); foreach ($rows as $i=>$row) { $bgcolor = rowCol ($i); $elenco.= " <tr bgcolor=\"#$bgcolor\"> <td>".$row->titolo."</td> <td><a href=\"".$dominio."/attach/".$row->allega."\" target=\"_new\">".$row->allega."</a></td> <td>".date2data ($row->data)."</td></tr> <tr bgcolor=\"#".$bgcolor."\"><td colspan=\"3\">".$row->testo."</td></tr>\n"; } $elenco.= "</table>"; } echo "$testa <h2 align=\"center\">$ptitolo</h2> $elenco $coda"; function resampleImgN ($foto) { global $save_path; list ($width, $height) = getimagesize ($save_path.$foto); $image = imagecreatefromjpeg ($save_path.$foto); $image_sh = imagecreatetruecolor ($width, $height); imagecopyresampled ($image_sh, $image, 0, 0, 0, 0, $width, $height, $width, $height); imagejpeg ($image_sh, $save_path.$foto, 85); exec ("chmod 666 ".$save_path.$foto); } ?>
Save File
Cancel