Location: PHPKode > projects > Db-newsletter > db-newsletter/send.php
<?
/*
Copyright (c) 2007-2008, Daniel Braun

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

  session_start(); 

 include ("include/mysql.php");
 include ("navi.php");
 include ("include/auth.php");
  
  //Einstellungen einlesen//
  $sql = mysql_query("SELECT * FROM settings");
  
  while ($ds = mysql_fetch_object($sql))
 {
  $anrede_m = $ds -> anrede_m;
  $anrede_f = $ds -> anrede_f;
  $un       = $ds -> un; //Abmelde Text
  $absender = $ds -> absender;
  $art      = $ds -> art;
  $ab       = $ds -> ordner;
  //Ende Einstellungen einlesen// 
 } 
   

    
  $sql = mysql_query("SELECT * FROM liste");

  while ($ds = mysql_fetch_object($sql))
  {
   //Felder aus Tabelle
   $id       = md5($ds -> id);
   $vorname  = $ds -> vorname;
   $nachname = $ds -> nachname;
   $anrede   = $ds -> anrede; 
   $email    = $ds -> email; 
   $status   = $ds -> status;
   
   //e-mail aus Formular
   $newsletter = $_POST['newsletter']; //Text aus Formular
   $betreff = $_POST['betreff']; //Text aus Formular

  
   // Eingaben ersetzen
   if($anrede == "Herr")
   {
    $temp = str_replace("(Anrede)", "$anrede_m", "$newsletter"); //Anrede Mann
   }
   if($anrede == "Frau")
   {
    $temp = str_replace("(Anrede)", "$anrede_f", "$newsletter"); //Anrede Frau
   }
   
   $newsletter = str_replace("(Nachname)", "$nachname", "$temp"); //Nachname einsetzen
   $temp       = str_replace("(Vorname)", "$vorname", "$newsletter"); //Vorname einsetzen
   $newsletter = str_replace("(Ende)", "$un", "$temp"); //Schluss
   $temp       = str_replace("(Abmelden)", "$ab", "$newsletter");//Abmelde-Link
   $newsletter = str_replace("(id)", "$id", "$temp"); //Link einsetzen
   
$temp = $newsletter;
   
   //Bildschirm-Ausgabe
   if($art == "text")
   {
    $newsletter = str_replace("\r", "", "$temp");
    $newsletter_show = str_replace("\n", "<br>", "$newsletter");
   }
   else
   {
    $newsletter = str_replace('\"', "\"", "$temp");
    $newsletter_show = "$newsletter";
   }

   //Wenn ausgetragen nicht senden
   if ($status != "old" && $status != "o")
   {
    $inhalt = "$newsletter"; 
    $header = "From: $absender\n";
    if($art == "html")
    {
     
$header .= "Content-type: text/html\n"; 
    }
    @mail($email,$betreff,$inhalt,$header);
   }

  }

  

?>


<html>
<head><link rel="stylesheet" type="text/css" href="style.css">

	<body>

			<div style="position:absolute;top:10px;left:130px;width:670px;height:184px;">
				<table width="670" border="1" cellspacing="2" cellpadding="0">
					<tr>
						<td>
							<div align="center">
								<p></p>
								<p></p>
								<p></p>
								<? echo "$newsletter_show <br>"; ?>
								<p></p>
								<p></p>
								<p></p>
							</div>
						</td>
					</tr>
				</table>
			</div>
		</div>
		<p></p>
	</body>

</html>


<?mysql_close($dz);?>




Return current item: Db-newsletter