<?
session_start();
$now = time();
$newsstyle = "HTML-DESIGNCODE";
include("./scripts/sqlconnect.php");
if($_GET[nid] != ""){ $nid = $_GET[nid]; }
elseif($_GET[preview] != ""){ $nid = $_GET[preview]; }
elseif($_GET[sendnews] != ""){ $nid = $_GET[sendnews]; }
$sqlquery_news_01 = mysql_query("SELECT id,title,title1,text1,link1,image1,title2,text2,link2,image2,title3,text3,link3,image3,title4,text4,link4,image4,title5,text5,link5,image5 FROM Newsletter WHERE id = '$nid'");
$sql_news_01 = mysql_fetch_array($sqlquery_news_01);
if($sql_news_01[id] != ""){
if($sql_news_01[text1] != ""){
if($sql_news_01[link1] != ""){ $link = "<p><a href=\"".$sql_news_01[link1]."\" target=\"_blank\">Klicken Sie hier für den Weblink</a>"; }
else{ $link = ""; }
if($sql_news_01[image1] != ""){
$content1 = "<b>".$sql_news_01[title1]."</b><br><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"left\" valign=\"top\"><font face=\"Verdana,Arial\" size=\"2\">".$sql_news_01[text1].$link."</font></td><td> </td><td align=\"right\" valign=\"top\"><img src=\"http://www.domain.land/images/newsletter/".$sql_news_01[image1]."\" border=\"0\"></td></tr></table>";
}
else{
$content1 = "<b>".$sql_news_01[title1]."</b><br>".$sql_news_01[text1].$link;
}
$content1 .= "<p><hr>";
}
if($sql_news_01[text2] != ""){
if($sql_news_01[link2] != ""){ $link = "<p><a href=\"".$sql_news_01[link2]."\" target=\"_blank\">Klicken Sie hier für den Weblink</a>"; }
else{ $link = ""; }
if($sql_news_01[image2] != ""){
$content2 = "<b>".$sql_news_01[title2]."</b><br><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"left\" valign=\"top\"><font face=\"Verdana,Arial\" size=\"2\">".$sql_news_01[text2].$link."</font></td><td> </td><td align=\"right\" valign=\"top\"><img src=\"http://www.domain.land/images/newsletter/".$sql_news_01[image2]."\" border=\"0\"></td></tr></table>";
}
else{
$content2 = "<b>".$sql_news_01[title2]."</b><br>".$sql_news_01[text2].$link;
}
$content2 .= "<p><hr>";
}
if($sql_news_01[text3] != ""){
if($sql_news_01[link3] != ""){ $link = "<p><a href=\"".$sql_news_01[link3]."\" target=\"_blank\">Klicken Sie hier für den Weblink</a>"; }
else{ $link = ""; }
if($sql_news_01[image3] != ""){
$content3 = "<b>".$sql_news_01[title3]."</b><br><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"left\" valign=\"top\"><font face=\"Verdana,Arial\" size=\"2\">".$sql_news_01[text3].$link."</font></td><td> </td><td align=\"right\" valign=\"top\"><img src=\"http://www.domain.land/images/newsletter/".$sql_news_01[image3]."\" border=\"0\"></td></tr></table>";
}
else{
$content3 = "<b>".$sql_news_01[title3]."</b><br>".$sql_news_01[text3].$link;
}
$content3 .= "<p><hr>";
}
if($sql_news_01[text4] != ""){
if($sql_news_01[link4] != ""){ $link = "<p><a href=\"".$sql_news_01[link4]."\" target=\"_blank\">Klicken Sie hier für den Weblink</a>"; }
else{ $link = ""; }
if($sql_news_01[image4] != ""){
$content4 = "<b>".$sql_news_01[title4]."</b><br><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"left\" valign=\"top\"><font face=\"Verdana,Arial\" size=\"2\">".$sql_news_01[text4].$link."</font></td><td> </td><td align=\"right\" valign=\"top\"><img src=\"http://www.domain.land/images/newsletter/".$sql_news_01[image4]."\" border=\"0\"></td></tr></table>";
}
else{
$content4 = "<b>".$sql_news_01[title4]."</b><br>".$sql_news_01[text4].$link;
}
$content4 .= "<p><hr>";
}
if($sql_news_01[text5] != ""){
if($sql_news_01[link5] != ""){ $link = "<p><a href=\"".$sql_news_01[link5]."\" target=\"_blank\">Klicken Sie hier für den Weblink</a>"; }
else{ $link = ""; }
if($sql_news_01[image5] != ""){
$content5 = "<b>".$sql_news_01[title5]."</b><br><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"left\" valign=\"top\"><font face=\"Verdana,Arial\" size=\"2\">".$sql_news_01[text5].$link."</font></td><td> </td><td align=\"right\" valign=\"top\"><img src=\"http://www.domain.land/images/newsletter/".$sql_news_01[image5]."\" border=\"0\"></td></tr></table>";
}
else{
$content5 = "<b>".$sql_news_01[title5]."</b><br>".$sql_news_01[text5].$link;
}
$content5 .= "<p><hr>";
}
$newscontent = $content1.$content2.$content3.$content4.$content5;
$newslettercode = str_replace("[NEWSLETTERTITLE]",$sql_news_01[title],$newsstyle);
$newslettercode = str_replace("[NEWSLETTERCONTENT]",$newscontent,$newslettercode);
}
// NEWSLETTER-VORSCHAU
if($_GET[preview] != ""){
$newslettercode = str_replace("[PREVIEW]"," <br><center><font face=\"Verdana,Arial\" size=\"4\"><b><a href=\"./index.php?p=815&news_edit=".$_GET[preview]."\"><font color=\"#000000\">Newsletter nachbearbeiten</font></a> | <a href=\"./newsletter.php?sendnews=".$_GET[preview]."&okid=25thz4s67ewg4g4g38k5\"><font color=\"#000000\">Newsletter versenden</font></a></b></font></center><p>",$newslettercode);
$newslettercode = str_replace("[NEWSLETTERUNSUB]","",$newslettercode);
echo($newslettercode);
}
// HIER IST DAS PROBLEM!!
// NEWSLETTER WIRD GELESEN
elseif($_GET[getpic] != "" & $_GET[newspic] != ""){
echo("http://www.domain.land/images/logo.gif");
mysql_query("INSERT INTO Newsletter_Watched VALUES('$now','$_GET[newspic]','$_GET[getpic]')");
}
// NEWSLETTER WIRD VERSCHICKT
elseif($_GET[sendnews] != "" AND $_GET[okid] == "2hwga26"){
if($_SESSION[xtranet] != ""){
$sqlquery_news_02 = mysql_query("SELECT id,title FROM Newsletter WHERE id = '$_GET[sendnews]'");
$sql_news_02 = mysql_fetch_array($sqlquery_news_02);
if($sql_news_02[id] != ""){
$unsub1 = "";
echo("<b>Newsletter erfolgreich versendet an:</b><p>");
$sqlquery_news_03 = mysql_query("SELECT id,email FROM Newsletter_Emails WHERE unsubscribed = '' ORDER BY id ASC");
while($sql_news_03 = mysql_fetch_array($sqlquery_news_03)){
$unsub = "</tr><tr><td align=\"center\" valign=\"bottom\"><font face=\"Verdana,Arial\" size=\"1\"><a href=\"http://www.domain.land/index.php?p=887&unsub=".$sql_news_03[id]."\" target=\"_blank\" color=\"black\">Klicken Sie hier um sich von diesem Newsletter abzumelden.</a></font></td>";
$picstring1 = "http://www.domain.land/images/logo.gif";
$picstring2 = "http://www.domain.land/newsletter.php?getpic=".$sql_news_03[id]."&newspic=".$sql_news_02[id];
$newslettercode = str_replace("[PREVIEW]","",$newslettercode);
$newslettercode = str_replace("[NEWSLETTERUNSUB]",$unsub,$newslettercode);
if($unsub1 != ""){ $newslettercode = str_replace($unsub1,$unsub,$newslettercode);; }
$newslettercode = str_replace($picstring1,$picstring2,$newslettercode);
$newsheader = "MIME-Version: 1.0\r\n";
$newsheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$newsheader .= "From: Test-Newsletter <newsletter@domain.land>\r\n";
mail($sql_news_03[email],"Test-".$sql_news_02[title],$newslettercode,$newsheader);
echo($sql_news_03[email]."<br>");
$unsub1 = $unsub;
sleep(2);
}
}
}
}
?>