<?php
/**
* Erstellt für 01art Webdesign
* Datei: mail.php
* Beschreibung: E-Mail-Klasse
*
* Autor: Ernesto Giménez <e@01art.de>
* Contributors:
* Datum: 28.03.13 12:42
* Letzte Änderung: 02.05.2013
*/
class eMail {
private $filterdomain, $name, $text, $recipient;
public function __construct() {
$this->custom_input = "";
}
public function setDomain($domain) {
$this->filterdomain = $domain;
}
public function setName($name) {
$this->name = $this->spamproof($name);
$this->name = $this->charakterproof($this->name);
}
public function setSiteName($sitename) {
$this->sitename = addslashes($sitename);
}
public function setText($text) {
$this->text = $this->spamproof($text);
}
public function setKopf($kopf) {
$this->kopf = $kopf;
}
public function setRecipient($recipient) {
$this->recipient = $this->spamproof($recipient);
}
public function setRedirect($redirect) {
$this->redirect = $redirect;
}
public function ehost() {
return gethostbyaddr($_SERVER["REMOTE_ADDR"]);
}
public function evaluate($email) {
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
return "nonvalid-email";
}
$email = $this->charakterproof($email);
return $this->spamproof($email);
}
public function recode_charset($string,$cs_from,$cs_to) { // Umcodierung
$trans_tbl["ASCII"] = array("&", "¡", "€", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "", "®", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "é", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ");
$trans_tbl["UNICODE"] = array("&", "¡", "€", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "­", "®", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ");
$trans_tbl["HTML"] = array("&", "¡", "€", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "­", "®", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "×", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "Þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ");
return str_replace($trans_tbl[$cs_from], $trans_tbl[$cs_to], $string);
}
public function define_sonderzeichen() {
$sonderzeichen=array( "ö" => "ö", "ü" => "ü", "ß" => "ß","ä" => "ä", "Ä" => "Ä", "Ãœ" => "Ü", "Ö" => "Ö", "é" => "é", "è" => "é", "ê" => "ê", "á" => "á", "²" => "²", "°" => "°", "ñ" => "ñ", "Ã'" => "Ñ", "à " => "à", "ô" => "ô",
"€" => "€",
"'" => "\"",
"„" => "\"",
"‘" => "\"",
"’" => "'",
"Â" => " ");
return $sonderzeichen;
}
private function spamproof($objekt) {
// old proof
/*
if ((preg_match("/@".$this->filterdomain."/i", $email)) || (preg_match("/@aol.com/i", $this->name)) || (preg_match("/@/i", $this->name)) || (preg_match("/url=http/i", $this->text)) || (preg_match("/Content-Type:/i", $this->text)) || (preg_match("/bcc:/i", $email)) || (preg_match("/Content-Type:/i", $this->text)) || (preg_match("/bcc:/i", $this->text)) ) {
header ("Location: http://".$this->filterdomain."/");
exit();
}
return $email;
*/
if ( preg_match("/(to:|cc:|bcc:|from:|subject:|reply-to:|content-type:|MIME-Version:|multipart\/mixed|Content-Transfer-Encoding:)/ims", $objekt))
{
header("Location: http://".$this->filterdomain."/");
exit();
}
return $objekt;
}
private function charakterproof($objekt) {
if (preg_match("/%0A|%0D|%00|\\0|%09|%01|%02|%03|%04|%05|%06|%07|%08|%09|%0B|%0C|%0E|%0F|%10|%11|%12|%13/i", $objekt))
{
header("Location: http://".$this->filterdomain."/");
exit();
}
return $objekt;
}
public function edate() {
$hourdiff = "0"; // hours difference between server time and local time
$timeadjust = ($hourdiff * 60 * 60);
return date("d F Y, G:i:s",time() + $timeadjust);
}
private function eheader($email) {
$header = "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/plain; charset=UTF-8\r\n";
$header .= "Content-Transfer-Encoding: 8bit\r\n";
$header .= "From: \"$this->name\"<$email>\r\n";
//$header .= "bcc: $recipient\r\n";
$header .= "Return-path: $this->recipient\r\n";
$header .= "X-Mailer: 01art Webdesign Internet-Mailer \r\n";
return $header;
}
private function email_send_template($email) {
mail( $this->recipient,
$this->sitename." E-Mail-Form", email_content($email).
//"=======================================================\n". $this->kopf .
//"\n=======================================================\n" . PHP_EOL .
//"Date of entry : " . $this->edate() . " o'clock \nMr/Mrs " . $this->name .
//" has given the following information: " . PHP_EOL .
//"\n____________________________________________________________\n\n" . PHP_EOL .
//"CONTACT\n" . PHP_EOL .
//"Name: " . $this->name .
//"\nEmail: ". $email . $this->custom_input .
//"\n____________________________________________________________\n\n" . PHP_EOL .
//"Message: \n" . $this->text .
//"\n____________________________________________________________\n" . PHP_EOL .
//"____________________________________________________________\n" . PHP_EOL .
//"Browser and operating system of the sender : " . $_SERVER['HTTP_USER_AGENT'] .
//"\nIP of the sender : ".$_SERVER['REMOTE_ADDR']." \nRemote Host of the sender : " .
$this->ehost(),
$this->eheader($email)
);
return;
}
private static function email_content($email){
$mainContent = "=======================================================\n".$this->kopf.
"\n=======================================================\n" . PHP_EOL .
"Date of entry : " . $this->edate() . " o'clock \nMr/Mrs " . $this->name .
" has given the following information: " . PHP_EOL .
"\n____________________________________________________________\n\n" . PHP_EOL .
"CONTACT\n" . PHP_EOL .
"Name: " . $this->name .
"\nEmail: ". $email . $this->custom_input .
"\n____________________________________________________________\n\n" . PHP_EOL .
"Message: \n" . $this->text .
"\n____________________________________________________________\n" . PHP_EOL .
"____________________________________________________________\n" . PHP_EOL .
"Browser and operating system of the sender : " . $_SERVER['HTTP_USER_AGENT'] .
"\nIP of the sender : ".$_SERVER['REMOTE_ADDR']." \nRemote Host of the sender : " . ";"
echo $this->mainContent;
}
public static function fillContent(){
return $mainContent;
}
public function send_mail($from) {
if (isset($from)) {
$email = $this->evaluate($from);
}
if (isset($this->name, $email) && ($email != "nonvalid-email") ){
$this->email_send_template($email);
header("Location: ".$this->redirect);
}
else {exit(); }
}
}
- Output for 5.4.0 - 5.4.27
- Parse error: syntax error, unexpected 'echo' (T_ECHO) in /in/nUOWN on line 194
Process exited with code 255. - Output for 5.3.0 - 5.3.28
- Parse error: syntax error, unexpected T_ECHO in /in/nUOWN on line 194
Process exited with code 255.
preferences:
174.13 ms | 1386 KiB | 64 Q