Hallo Leute,
ich betreue seit einiger Zeit eine Intranetseite meiner Firma. Jetzt hat die Seite immer wudnerbar funktioniert, aber nun sind wir auf einen neuen Server umgezogen und jetzt funktioniert der Newsletterversand nicht mehr.
Ich stell mal am besten die ganzen Dateien hier rein. Ich hoffe mir kann jemand helfen:
newsletter.php
newsletter.class.php
abo.class.php
Ich hoffe mir kann einer weiterhelfen, bzw. sagen, was ich falsch mache. Ich bin nämlich ratlos. Ich rätsel schon seit knapp 3 Tagen daran und weiß net weiter.
Solltet ihr ncoh fragen haben, beantworte ich alle!
ich betreue seit einiger Zeit eine Intranetseite meiner Firma. Jetzt hat die Seite immer wudnerbar funktioniert, aber nun sind wir auf einen neuen Server umgezogen und jetzt funktioniert der Newsletterversand nicht mehr.
Ich stell mal am besten die ganzen Dateien hier rein. Ich hoffe mir kann jemand helfen:
newsletter.php
PHP:
<script language="php">
//Variablendeklarationen
//------------------
$uploaddir = './files/newsletter/';
$no_rights = "You aren't logged in or don't have the required rights to use this function";
//------------------
//Konfigurationsdatei einbinden
//------------------
$config = "../layout/config.php";
include($config);
//------------------
//Stylesheet einbinden
//------------------
$style = "../".$style;
echo "<link rel='stylesheet' type='text/css' href='$style'>";
//------------------
//Klassen einbinden
//------------------
require_once("classes/newsletter.class.php");
require_once("../classes/db_connection.class.php");
require_once("../classes/abo.class.php");
//------------------
//Datenbankverbindung aufbauen
//------------------
$db_conn_class = new db_connection;
$db_conn_class->server = $db_server;
$db_conn_class->user = $db_user;
$db_conn_class->pass = $db_password;
$db_conn_class->dbase = $db_database;
$db_conn_class->db_connect();
//------------------
//Zugriffsberechtigung prüfen
//------------------
include("../layout/config_rights.php");
if(!$admin_right) die($no_rights);
//------------------
//newsletter-Objekt erzeugen
//------------------
$newsletter_class = new newsletter;
//------------------
echo "<h4>Knowledge Database - Create Newsletter</h4><hr>";
//Newsletter Formular(wenn newsletter noch nicht abgeschickt)
//---------------------
if(!$send_nl){
echo "With this function you can create a newsletter that is sent to all MES users.<br><br>";
echo "The Content of the email is generated automatically. It contains the NEWS and new DOCUMENTS since the last NEWSLETTER.<br><br>";
echo "If you want the newsletter to contain additional information, you can write them into the following textfield.<br><br>";
echo " <form action='".$_SERVER[PHP_SELF]."' method='post' enctype='multipart/form-data'>
<textarea name='add_inf' cols='50' rows='5'></textarea><br>
<input type='file' name='file' size='44'><br><hr>";
echo" <input type='submit' name='send_nl' value='send newsletter'>
<form>";
}
//---------------------
//wenn newsletter abgeschickt
//---------------------
else{
//Newsletterinhalte generieren
//---------------------
//Datei hochladen, wenn vorhanden
//---------------------
if($send_nl){
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploaddir.$_FILES['file']['name'])){
$filetype = $_FILES['file']['type'];
}
else{
$filetype = "";
}
}
//aktuelle News generieren, wenn vorhanden
//---------------------
if($newsletter_class->give_news()){
for($i=0; $i<count($newsletter_class->news); $i++){
$mes_news .= "<p><i>".$newsletter_class->news[$i][datetime]."</i></p><h5>".$newsletter_class->news[$i][headline]."</h5><p>".$newsletter_class->news[$i][text]."</p><br>";
}
}
else
$mes_news = "There are no NEWS to be reported on the MES Online Documentation";
//---------------------
//zusätzliche Infos einbinden, wenn vorhanden
//---------------------
$add_inf = nl2br($add_inf);
//Layout festlegen
//---------------------
$style = "<style type='text/css'>
body {
background-color:#EFEFEF;
font-family:Arial,Helvetica,sans-serif;
font-weight:normal;
font-size:10pt;
color:black;
scrollbar-face-color: #F0F0F0;
scrollbar-track-color: #E0E0E0;
scrollbar-highlight-color: #B0B0B0;
scrollbar-shadow-color: #B0B0B0;
scrollbar-darkshadow-color: #FFFFFF;
scrollbar-3dlight-color: #FFFFFF;
scrollbar-arrow-color: #B0B0B0;
}
p,ul,ol,li,td,th,address,blockquote,hr, .standard {
font-size:10pt;
}
a { text-decoration:none; color:#204080 }
a:hover { text-decoration:underline; color:#0000A0 }
h1,h2,h3,h4,h5,h6, .H1,.H2,.H3,.H4,.H5,.H6 {
color:#808080;
font-weight:normal;
}
h1,.H1 { font-size:28pt }
h2,.H2 { font-size:22pt }
h3,.H3 { font-size:18pt }
h4,.H4 { font-size:14pt }
h5,.H5 { font-size:12pt }
h6,.H6 { font-size:10pt }
.H8,.H9 {
font-family: Arial,Helvetica,sans-serif;
font-style:normal;
font-weight:bold;
color:#EFEFEF;
background-color:#004080
}
.H8 { font-size:12pt }
.H9 { font-size:10pt }
small, .small {
font-size:8pt
}
em,strong {
font-weight:bold
}
kbd,code,pre, .fixed {
font-family:Courier New,Courier;
font-size:10pt;
}
#temicblau {
color:#004080
}
</style>";
//---------------------
//Inhalte in Email Grundgerüst einfügen
//-----------------
//Mail Titel
$mail_title = "Newsletter ".date(d).".".date(m).".".date(Y);
//HTML-Inhalt
$mail_text = "<html>
<head>
<title>MES</title>";
$mail_text .= $style;
$mail_text .= " </head>
<body bgcolor='#EFEFEF'>
<table border='0' width='909'>
<tr>
<td width='452'>
<p align='center'>
<i><u><b>
<font size='5'>
<font color='#0000FF'>M</font>
<font color='#808080'>anufacturing </font>
</font>
</b></u></i><br>
<i><u><b>
<font size='5'>
<font color='#0000FF'>E</font>
<font color='#808080'>xecution </font>
</font>
</b></u></i><br>
<i><u><b>
<font size='5'>
<font color='#0000FF'>S</font>
<font color='#808080'>ystem </font>
</font>
</b></u></i>
</td>
<td width='452' bgcolor='#C0C0C0'>
<h1 align='center'><b><font color='#0000FF'> <font face='Comic Sans MS'>NEWSLETTER </font></font></b></h1>
</td>
<td width='443'>
<p align='center'>
<i><u><b>
<font size='5'>
<font color='#0000FF'>M</font>
<font color='#808080'>anufacturing </font>
</font>
</b></u></i><br>
<i><u><b>
<font size='5'>
<font color='#0000FF'>E</font>
<font color='#808080'>xecution </font>
</font>
</b></u></i><br>
<i><u><b>
<font size='5'>
<font color='#0000FF'>S</font>
<font color='#808080'>ystem </font>
</font>
</b></u></i>
</p>
</td>
</tr>
</table>
<hr>
<table border='0' width='100%'>
<tr>
<td width='49%' bgcolor='#FFFFFF'>
<h4>Dear MES User,</h4>
<p>in this Newsletter you find the latest News from the <b><a href='http://intra.ing.temic.de/home/oe/index.php'>MES Online
documentation</a>. </p>
</td>
<td width='2%'>
</td>
<td width='49%' bgcolor='#FFFFFF'>
<h4>Content</h4>
<ul>
<li>MES News</li>
<li>Additional Information</li>
<li>Last 10 documents uploaded</li>
</ul>
</td>
</tr>
</table>
<hr>
<table border='0' width='100%' bgcolor='#FFFFFF'>
<tr>
<td>
<h4><a name='MES_NEWS'>MES NEWS</a></h4>
<p>$mes_news</p>
</td>
</tr>
</table>
<br>
<hr>
<table border='0' width='100%' bgcolor='#FFFFFF'>
<tr>
<td>
<h4><a name='Additional_Information'>Additional Information</a></h4>
<p>$add_inf</p>
</td>
</tr>
</table>
<table border='0' width='100%' bgcolor='#FFFFFF'>
<tr>
<td>
<h4><a name='Last 10 documents uploaded'>Last 10 documents uploaded</a></h4>
</td>
</tr>
<tr>
<td>
<table width='100%' cellpadding='5px'>";
$res = mysql_query("SELECT * FROM docs ORDER BY id desc");
$num = mysql_num_rows($res);
$mail_text.=" <tr bgcolor='#C0C0C0'>
<td>Category</td>
<td>Description</td>
<td>Revision</td>
<td>Date</td>
<td>Author</td>
</tr>";
for($i=0; $i<10; $i++)
{
$mes_docs = mysql_fetch_assoc($res);
$mail_text .= "<td><a href='docs.php?category_nr=" . $mes_docs["cat_id"] . "'>" . $mes_docs["category"] . "</a></td>
<td>" . $mes_docs["headline"] . "</td>
<td>" . $mes_docs["revision"] . "</td>
<td>" . $mes_docs["date"] . " </td>
<td>" . $mes_docs["author"] . "</td>
<tr>";
}
//---------------------
//Email senden
//---------------------
$mail = $newsletter_class->return_mail();
//print_r($mail); //Test zum ausgeben der Email adressen
for($i=0; $i<count($mail); $i++){
$send_email = $mail[$i];
$verschluesselt = md5($send_email);
//mail an email-adressen die nl abonniert haben
$file1 = $uploaddir.$_FILES['file']['name'];
$file_name = $_FILES['file']['name'];
$message = "<html><head></head><body><h1>inhalt</h1></body></html>";
$boundary = strtoupper(md5(uniqid(time())));
$mail_header = "From: MES Online Documentation\n";
$mail_header .= "MIME-Version: 1.0";
$mail_header .= "\nContent-Type: multipart/mixed; boundary=$boundary";
$mail_header .= "\n\nThis is a multi-part message in MIME format -- Dies ist eine mehrteilige Nachricht im MIME-Format";
$mail_body = "\n--$boundary";
$mail_body .= "\nContent-Type: text/html";
$mail_body .= "\nContent-Transfer-Encoding: 8bit";
$mail_body .= "\n\n$mail_text";
$mail_body .= "\n--$boundary";
if( $filetype != ""){
$file_content1 = fread(fopen($file1,"r"),filesize($file1));
$file_content1 = chunk_split(base64_encode($file_content1));
$mail_body .= "\nContent-Type: $filetype; name=\"$file_name\"";
$mail_body .= "\nContent-Transfer-Encoding: base64";
//$mail_body .= "\nContent-Disposition: attachment; filename=\"$file_name\"";
$mail_body .= "\nContent-ID: bild1\r\n\r\n";
$mail_body .= $file_content1 . "\n\n";
$mail_body .= "\n--$boundary";
}
$mail_body .= "\nContent-Type: text/html";
$mail_body .= "\nContent-Transfer-Encoding: 8bit";
$mail_body .= "\n\n$mail_zus_text";
$mail_body .= "\n--$boundary--";
$extra = "From: MES Online Documentation\r\n";
$extra .= "MIME-Version: 1.0\r\n";
$extra .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$extra .= "Content-Transfer-Encoding: 8bit ";
//Newsletter senden
@mail($send_email,$mail_title,$mail_body,$mail_header);//zum test: $ mail durch §to ersetzen
//last Newsletter Datum updaten
$newsletter_class->update_last_nl_date();
}
//---------------------
echo "The newsletter has been sent!";
//evtl.hochgeladene Datei löschen
//---------------------
@unlink("$file1");
//---------------------
}
//Datenbankverbindung trennen
//------------------
$db_conn_class->db_disconnect();
//------------------
</script>
newsletter.class.php
PHP:
<script language="php">
class newsletter{
//Variablen deklarieren
//-----------------
var $last_nl;
var $news;
var $docs;
//-----------------
//Konstruktor
//-----------------
function newsletter(){
$query_last_nl = "SELECT date FROM last_nl";
$res_last_nl = mysql_query($query_last_nl);
$this->last_nl = mysql_result($res_last_nl, 0, "date");
}
//News
//-----------------
function give_news(){
$query_news = "SELECT * FROM news WHERE datetime > '$this->last_nl' ORDER BY datetime DESC";
$res_news = mysql_query($query_news);
for($i=0; $i<mysql_num_rows($res_news); $i++)
{
$this->news[$i][id] = mysql_result($res_news, $i, "id");
$this->news[$i][datetime] = mysql_result($res_news, $i, "datetime");
$this->news[$i][headline] = mysql_result($res_news, $i, "headline");
$text_ohne_br = mysql_result($res_news, $i, "text");
$this->news[$i][text] = nl2br($text_ohne_br);
}
if($this->news) return true;
else return false;
}
//Mailadressen aller MES-User zurückgeben
//-----------------
function return_mail(){
$query_mail = "SELECT email FROM abo";
$res_mail = mysql_query($query_mail);
for($i=0; $i<mysql_num_rows($res_mail); $i++) {
$nl_mails[$i] = mysql_result($res_mail, $i, "email");
}
return $nl_mails;
}
//Datum, an dem der letzte Newsletter versendet wurde, aktualisieren
function update_last_nl_date(){
$date = date("Y-m-d H:m:s");
$query_update = "UPDATE last_nl SET date = '$date'";
mysql_query($query_update);
}
}
</script>
abo.class.php
PHP:
<script language="php">
class abo{
//Variablen deklarieren
//-----------------
var $code;
var $email;
var $boards;
var $new_boards;
var $delete_boards;
//-----------------
//nach zu code gehörender mailadresse suchen (bei deletions)
//-----------------
function find_email(){
$query = "SELECT email FROM abo";
$res = mysql_query($query);
for($i=0; $i<mysql_num_rows($res); $i++){
$mail = mysql_result($res, $i, "email");
/*if(md5($mail)==$this->code){
$this->email=$mail;
$this->boards = mysql_result($res, $i, "foren");
return true;
}*/
}
return false;
}
//-----------------
//prüfen ob schon abo vorhanden (bei suscriptions)
//-----------------
function abo_exists(){
//eintrag suchen
$query = "SELECT * FROM abo WHERE email = '$this->email'";
@$res = mysql_query($query);
@$num = mysql_num_rows($res);
if($num<1) return false;
else {
$this->boards = mysql_result($res, 0, "foren");
return true;
}
}
//-----------------
//newsletter abo eintragen
//-----------------
function subscribe_nl(){
if($this->abo_exists()){
//updaten
$query = "UPDATE abo SET newsletter = '1', last_newsletter = '0000-00-00 00:00:00' WHERE email = '$this->email'";
if(mysql_query($query)) return true;
else return false;
}
else{
//neu eintragen
$query=" INSERT `abo` (`email`, `newsletter`) VALUES ('$this->email', '1')";
if(mysql_query($query)) return true;
else return false;
}
}
//-----------------
//docs abo eintragen
//---------------------
/*function subscribe_docs()
{
if($this->abo_exists())
{
//updaten
$query = "UPDATE abo SET docs = '1', last_newsletter = '0000-00-00 00:00:00' WHERE email ='$this->email'";
if(mysql_query($query))
return true;
else
return false;
}
else
{
//neu eintragen
$query=" INSERT `abo` (`email`, `docs`) VALUES ('$this->email', '1')";
if(mysql_query($query))
return true;
else
return false;
}
}*/
//------------------------
//forum abo eintragen
//-----------------
/*function subscribe_board(){
//wenn adresse schon vorhanden
if($this->abo_exists()){
//konvertiere string in array
$boards_array = unserialize($this->boards);
//arrays verbinden
$boards_array = array_merge($boards_array, $this->new_boards);
//doppelte einträge löschen
$boards_array = array_unique($boards_array);
//leere einträge löschen
$boards_array = array_values($boards_array);
//array in string konvertieren
$this->boards = serialize($boards_array);
//neuen string in db eintragen
$update= "UPDATE `abo` SET `foren` = '$this->boards' ";
$update.= " WHERE `email` = '$this->email'";
if(mysql_query($update)) return true;
else return false;
}
//wenn emailadresse noch nicht eingetragen
else{
$foren = serialize($this->new_boards);
$query =" INSERT `abo` (`email`, `foren`) VALUES ('$this->email', '$foren')";
if(mysql_query($query)) return true;
else return false;
}
}*/
//-----------------
//foren abo löschen
//-----------------
/*function del_board_suscr(){
$boards_array = unserialize($this->boards);
//neues array erzeugen
$boards_array = array_diff($boards_array, $this->delete_boards);
//leere einträge löschen
$boards_array = array_values($boards_array);
//array in string konvertieren
$this->boards = serialize($boards_array);
//neuen string in db eintragen
$update= "UPDATE abo SET `foren` = '$this->boards'";
$update.= " WHERE `email` = '$this->email'";
if(mysql_query($update)) return true;
else return false;
}*/
//-----------------
//newsletter abo löschen
//-----------------
function del_nl_suscr(){
$update= "UPDATE abo SET `newsletter` = '0'";
$update.= " WHERE `email` = '$this->email'";
if(mysql_query($update)) return true;
else return false;
}
//-----------------
}
</script>
Ich hoffe mir kann einer weiterhelfen, bzw. sagen, was ich falsch mache. Ich bin nämlich ratlos. Ich rätsel schon seit knapp 3 Tagen daran und weiß net weiter.
Solltet ihr ncoh fragen haben, beantworte ich alle!