@ 2014-04-22T13:10:30Z <?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(); }
}
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 5.4.27 0.004 0.039 12.52 5.4.26 0.007 0.036 12.52 5.4.25 0.006 0.038 12.52 5.4.24 0.007 0.034 12.52 5.4.23 0.011 0.034 12.51 5.4.22 0.010 0.036 12.51 5.4.21 0.009 0.040 12.51 5.4.20 0.007 0.040 12.51 5.4.19 0.005 0.038 12.51 5.4.18 0.008 0.036 12.51 5.4.17 0.005 0.038 12.52 5.4.16 0.008 0.035 12.51 5.4.15 0.007 0.036 12.51 5.4.14 0.005 0.038 12.20 5.4.13 0.004 0.038 12.18 5.4.12 0.010 0.038 12.14 5.4.11 0.011 0.036 12.14 5.4.10 0.008 0.035 12.14 5.4.9 0.010 0.039 12.14 5.4.8 0.006 0.042 12.14 5.4.7 0.008 0.041 12.14 5.4.6 0.008 0.041 12.14 5.4.5 0.005 0.041 12.13 5.4.4 0.005 0.035 12.12 5.4.3 0.006 0.043 12.12 5.4.2 0.007 0.044 12.12 5.4.1 0.013 0.039 12.12 5.4.0 0.009 0.043 11.61 5.3.28 0.007 0.043 12.76 5.3.27 0.008 0.040 12.78 5.3.26 0.004 0.043 12.78 5.3.25 0.007 0.043 12.78 5.3.24 0.007 0.047 12.78 5.3.23 0.007 0.045 12.77 5.3.22 0.012 0.051 12.74 5.3.21 0.005 0.047 12.74 5.3.20 0.007 0.041 12.74 5.3.19 0.007 0.045 12.74 5.3.18 0.009 0.041 12.74 5.3.17 0.009 0.039 12.74 5.3.16 0.007 0.046 12.73 5.3.15 0.008 0.042 12.74 5.3.14 0.008 0.042 12.72 5.3.13 0.006 0.043 12.72 5.3.12 0.006 0.044 12.72 5.3.11 0.007 0.051 12.72 5.3.10 0.007 0.041 12.21 5.3.9 0.007 0.039 12.19 5.3.8 0.006 0.038 12.17 5.3.7 0.005 0.038 12.17 5.3.6 0.004 0.038 12.16 5.3.5 0.005 0.037 12.11 5.3.4 0.007 0.042 12.11 5.3.3 0.012 0.038 12.07 5.3.2 0.007 0.036 11.85 5.3.1 0.008 0.037 11.81 5.3.0 0.008 0.041 11.80
preferences:dark mode live preview
139.63 ms | 1394 KiB | 7 Q