@ 2014-04-22T13:05:46Z <?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){
var $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 : " . ";"
return $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.5.11 0.003 0.070 19.48 5.5.10 0.007 0.060 19.45 5.5.9 0.003 0.063 19.43 5.5.8 0.000 0.067 19.23 5.5.7 0.007 0.073 19.54 5.5.6 0.000 0.053 19.21 5.5.5 0.000 0.063 19.23 5.5.4 0.007 0.070 19.38 5.5.3 0.007 0.037 19.50 5.5.2 0.010 0.060 19.39 5.5.1 0.003 0.050 19.31 5.5.0 0.010 0.073 19.45 5.4.27 0.003 0.043 18.89 5.4.26 0.007 0.043 19.14 5.4.25 0.003 0.057 19.14 5.4.24 0.010 0.077 18.95 5.4.23 0.000 0.060 19.10 5.4.22 0.007 0.060 19.18 5.4.21 0.007 0.077 19.11 5.4.20 0.007 0.070 19.27 5.4.19 0.007 0.037 19.11 5.4.18 0.007 0.040 19.19 5.4.17 0.007 0.033 19.10 5.4.16 0.010 0.030 18.97 5.4.15 0.000 0.057 19.16 5.4.14 0.010 0.060 16.48 5.4.13 0.003 0.060 16.48 5.4.12 0.003 0.073 16.54 5.4.11 0.000 0.080 16.41 5.4.10 0.003 0.037 16.50 5.4.9 0.000 0.040 16.47 5.4.8 0.000 0.080 16.49 5.4.7 0.003 0.060 16.61 5.4.6 0.000 0.070 16.44 5.4.5 0.007 0.070 16.70 5.4.4 0.003 0.070 16.54 5.4.3 0.003 0.073 16.32 5.4.2 0.007 0.070 16.58 5.4.1 0.003 0.073 16.53 5.4.0 0.003 0.050 16.04 5.3.28 0.000 0.080 14.71 5.3.27 0.003 0.050 14.77 5.3.26 0.003 0.037 14.75 5.3.25 0.003 0.073 14.71 5.3.24 0.003 0.060 14.70 5.3.23 0.003 0.077 14.74 5.3.22 0.010 0.063 14.58 5.3.21 0.003 0.067 14.80 5.3.20 0.000 0.073 14.63 5.3.19 0.000 0.063 14.81 5.3.18 0.000 0.067 14.71 5.3.17 0.007 0.077 14.54 5.3.16 0.000 0.073 14.81 5.3.15 0.003 0.073 14.54 5.3.14 0.003 0.060 14.64 5.3.13 0.003 0.080 14.57 5.3.12 0.007 0.070 14.56 5.3.11 0.000 0.057 14.65 5.3.10 0.007 0.063 14.29 5.3.9 0.007 0.050 14.14 5.3.8 0.000 0.073 14.06 5.3.7 0.003 0.037 14.16 5.3.6 0.000 0.077 14.25 5.3.5 0.003 0.037 14.05 5.3.4 0.000 0.077 14.09 5.3.3 0.000 0.047 14.00 5.3.2 0.000 0.073 13.76 5.3.1 0.000 0.077 13.80 5.3.0 0.007 0.067 13.79
preferences:dark mode live preview
140.07 ms | 1394 KiB | 7 Q