<?php
/*
NmnNewsletter is a library that provides newsletter service
management for websites running php and mysql.
Copyright (C) 2006 Ivan Preziosi from netmeans.net - Rome.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
For more informations or to join the development of the library contact
the author at: hide@address.com
*/
require_once("includes/config.php");
sessCtrl();
if (isset($_REQUEST["action"])){
$action = $_REQUEST["action"];
}else{
$action = 'add';
}
if (isset($_REQUEST["id_nl"]) && $_REQUEST["action"] != "update"){
$action = 'show';
}
if($_POST["action"] == "add")
{
if($_GET[type]=='html')
{
$message = stripslashes($_POST["message"]);
$body = $message;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=\"".CHARSET."\"" . "\r\n";
$headers .= "Return-Path: ".MAIL_FROM."" ." \r\n";
$headers .= "Reply-To: ".MAIL_FROM."" . "\r\n";
$headers .= "From: ".NAME_FROM." <".MAIL_FROM.">" . "\r\n";
$nlId = Newsletter::addNewsletter($_REQUEST['subject'], $body, '');
if($nlId){
$msg = "<div class=message>".COMPOSE_SAVED_MESSAGE."<br></div>";
}else{
$msg = "<div class=message><span style='color:red;'>".COMPOSE_NOT_SAVED_MESSAGE."<br></span></div>";
}
}
else
{
$message = $_POST["message"];
$body = $message;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/plain; charset=\"".CHARSET."\"" . "\r\n";
$headers .= "Return-Path: ".MAIL_FROM."" ." \r\n";
$headers .= "Reply-To: ".MAIL_FROM."" . "\r\n";
$headers .= "From: ".NAME_FROM." <".MAIL_FROM.">" . "\r\n";
$nlId = Newsletter::addNewsletter($_REQUEST['subject'], '', $body);
if($nlId){
$msg = "<div class=message>".COMPOSE_SAVED_MESSAGE."<br></div>";
}else{
$msg = "<div class=message><span style='color:red;'>".COMPOSE_NOT_SAVED_MESSAGE."<br></span></div>";
}
}
}else if ($action == 'show'){
$idNl = $_REQUEST["id_nl"];
$nlData = Newsletter::getNewsletter($idNl);
$action = "update";
}else if ($action == "update"){
$idNl = $_REQUEST["id_nl"];
$titolo = $_REQUEST["subject"];
$htmlMessage = $_REQUEST["message"];
if (Newsletter::editNewsletter($idNl,$titolo,$htmlMessage,'')){
$msg = "<div class=message>".COMPOSE_UPDATED_MESSAGE."<br></div>";
}else{
$msg = "<div class=message><span style='color:red;'>".COMPOSE_NOT_UPDATED_MESSAGE."<br></span></div>";
}
}
$html='checked';
$text='';
if (USE_TINYMCE){
$editorLink = "<a href=\"javascript:toggleEditor('message');\">".COMPOSEWYSIWYG."</a>";
}else{
$editorLink = "";
}
$mailType = $_GET['type'];
$main .= "
<div class=page_heading>".COMPOSE_TITLE."</div>
$msg
<form name=form action='compose.php?type=$_GET[type]' method='post'>
<input type='hidden' name='id_nl' value='".$idNl."'>
<table width=95%>
<tr>
<td><b>".COMPOSE_SUBJECT."</b><br>
<input class=textField2 type=text name=subject value=\"".htmlspecialchars($nlData["titolo"])."\" title=\"".htmlspecialchars(COMPOSE_SUBJECT_POP)."\"> <span class=error_text id=label_subject></span></td>
</tr>
<tr>
<td><b>".COMPOSE_FROM."</b><br>
<input class=textField2 disabled type=text name=email_from value='".NAME_FROM." <".MAIL_FROM.">'></td>
</tr>
<tr>
<td>
<table cellpadding=0 cellspacing=0 width=95%>
<tr><td><b>".COMPOSE_BODY."</b></td><td align=right>".$editorLink."</td></tr>
<tr><td colspan=2><textarea rows=25 cols=100% id=message name=message title='".COMPOSE_BODY_POP."'>".$nlData["html_body"]."</textarea><span class=error_text id=label_message></span></td></tr>
</table>
</td>
</tr>
<tr>
<td><input class=button type=submit value=".COMPOSE_SAVE_BUTTON."><input type=hidden name=action value=".$action."></td>
</tr>
</table>
</form>
<script language=javascript>
var validator = new Validator('form');
validator.addValidation('subject','req','');
</script>
";
$page = "compose";
$tinyMce = true;
require_once("includes/template.php");
?>