Abmelden? # Angabe mit http:// # Enter the page for confirmation that should be shown before unsubscribe will be executed # Page MUST contain a form e.g.
Unsubscribe?
# With http:// $UnsubscribeConfirmationPage=""; # Geben Sie die Seite zur Bestaetigung an, die NACH Absenden der Umfrage angezeigt werden soll # Enter a page that will be shown after submitting unsubscription survey $UnsubscriptionSurveyConfirmationPage=""; # Geben Sie mit Semikolon(;) getrennt die Gruende fuer die Abmeldung an # Specify reasons for unsubscription delimited by semicolon(;) $UnsubscriptionSurveyReasons=""; # Bei der Script-Generierung wird dieser Schluessel anhand des Datums/Uhrzeit erstellt, # der Schluessel kann manuell geaendert werden, darf jedoch NIE leer sein. # The key will be created with help of date/time of script creation. You can change the key # but ist should never be empty. $CryptKey="11/08/2416043131110485"; # Optional zur SICHEREREN Verschluessung der Daten beim Double-Opt-In kann eine Datei verwendet werden, # die die Einmalschluessel mit E-Mail-Adresse und Verfallsdatum enthaelt. # Der Dateiname der Datei sollte so gewaehlt werden, dass dieser SCHWER zu erraten ist. # Die Rechte auf die Datei muessen auf Linux/Unix-Systemen auf 666 gesetzt werden, damit das Script problemlos # lesen und schreiben kann. # Optionaly for better encryption you can use a file to store one time keys. # The filename of file must be very difficult to gues. # On Linux/Unix OS you must create the file and set the rights to 666 to let the script read and write the file. $CryptKeyFile=""; # Verfallsdatum der Eintraege in Tagen # Expiration days $CryptKeyExpiresInterval=30; # Seite, die gezeigt wird, wenn der Key nicht gefunden wird, weil die Zeit $CryptKeyExpiresInterval abgelaufen ist oder # doppelt geklickt wurde und damit die E-Mail-Adresse nicht mehr in der Datei steht. # Page that should be showen when key was not found e.g. user makes a double click or entry is expired ($CryptKeyExpiresInterval) $CryptKeyErrorPage=""; # Charset of Website, when you use utf-8 encoding than you must specify utf-8 $WebsiteContentCharset="iso-8859-1"; # anonymize saved ipv4 or ipv6 address # 0 or not defined no anonymization # 1 = ipv4: last octett will be filled with zero, ipv6: last segment/chunk will be filled with zero # 2 = ipv4: 3th, 4th octett will be filled with zero, ipv6: 7th, 8th segment/chunk will be filled with zero # 3 = ipv4: 2th, 3th, 4th octett will be filled with zero, ipv6: 6th, 7th, 8th segment/chunk will be filled with zero # 4 = ipv4: 1th, 2th, 3th, 4th octett will be filled with zero, ipv6: 5th, 6th, 7th, 8th segment/chunk will be filled with zero define("ip_address_mask_length", 0); ########### Ab hier nichts mehr aendern ##################### ########### Don't change anything at this position ##################### $CRLF = "\r\n"; $DateTimeFormat = 'Y-m-d H:i:s'; # FALLS register_globals off if (ini_get('register_globals') == 0) { if ( isset($_GET['Action']) ) $Action=$_GET['Action']; if ( isset($_GET['EMail']) ) $EMail=$_GET['EMail']; if ( isset($_POST['EMail']) ) $EMail=$_POST['EMail']; if ( isset($_GET['NewEMail']) ) $NewEMail=$_GET['NewEMail']; if ( isset($_POST['NewEMail']) ) $NewEMail=$_POST['NewEMail']; if ( isset($_POST['Action']) ) $Action=$_POST['Action']; if ( isset($_GET['Format']) ) $Format=$_GET['Format']; if ( isset($_POST['Format']) ) $Format=$_POST['Format']; if ( isset($_POST['RG']) ) $RG=$_POST['RG']; if ( isset($_GET['RG']) ) $RG=$_GET['RG']; if ( isset($_GET['EMailb']) ) $EMail=base64_decode($_GET['EMailb']); if ( isset($_POST['EMailb']) ) $EMail=base64_decode($_POST['EMailb']); } $AllowedActions = array("subscribe", "unsubscribe", "confirmation", "unsubscribe_confirm", "edit", "unsubscriptionsurvey"); if (!function_exists ('stripos') ) { function stripos ( $haystack, $needle, $offset=NULL ) { if (isset($offset) && $offset != NULL) return strpos( strtolower($haystack), strtolower($needle), $offset); else return strpos(strtolower($haystack), strtolower($needle), $needle); } } if (!function_exists ('str_ireplace') ) { function str_ireplace($search,$replace,$subject){ $token = chr(1); $haystack = strtolower($subject); $needle = strtolower($search); while (($pos=strpos($haystack,$needle))!==FALSE){ $subject = substr_replace($subject,$token,$pos,strlen($search)); $haystack = substr_replace($haystack,$token,$pos,strlen($search)); } $subject = str_replace($token,$replace,$subject); return $subject; } } if(!function_exists("in_arrayi")){ function in_arrayi($needle, $haystack) { return in_array(strtolower($needle), array_map('strtolower', $haystack)); } } # Helper $Helper = new Helper; $REMOTE_ADDR = $Helper->getOwnIP(); # Crypt $crypt = new EncDec; $crypt->hash = $CryptKey; // List-Unsubscribe-Post header if( isset($_GET["lup"]) && $_GET["lup"] == "lup" && isset($_SERVER['REQUEST_METHOD']) && strtoupper($_SERVER['REQUEST_METHOD']) == "POST" ){ if(!isset($_POST["List-Unsubscribe"])){ print "List-Unsubscribe POST value missing, see https://tools.ietf.org/html/rfc8058."; exit; } if(isset($_POST["List-Unsubscribe"]) && $_POST["List-Unsubscribe"] != "One-Click"){ print "List-Unsubscribe POST value invalid, see https://tools.ietf.org/html/rfc8058."; exit; } $UnsubscribeConfirmationPage=""; $UnsubscriptionSurveyReasons=""; } if(isset($_GET["lup"])) unset($_GET["lup"]); if(isset($_POST["List-Unsubscribe"])) unset($_POST["List-Unsubscribe"]); // List-Unsubscribe-Post header / if ( !isset($Action) || $Action == "" || !in_arrayi($Action, $AllowedActions) ) { print "Es wurde das Feld Action nicht übermittelt! / Field Action was not submitted!"; exit; } if ( ($EMailText == "" || $EMailSubject == "") && $Action == "subscribe" ) { print "Fehler es ist kein E-Mail-Text oder kein Betreff für die Bestätigungs-E-Mail vorhanden."; exit; } if ( (isset($EMail)) && ($Action=="confirmation") ) { if(isset($CryptKeyFile) && $CryptKeyFile != "") { $crypt->hash = $crypt->GetCryptKey($CryptKeyFile, $EMail); if(!$crypt->hash) { if ($CryptKeyErrorPage != "") header("Location: $CryptKeyErrorPage"); else print "Die übergebene E-Mai-Adresse befindet sich nicht (mehr) zur Bestätigung im Verteiler."; exit; } } $EMail = $crypt->phpDecrypt($EMail); } if ( $Action != "unsubscriptionsurvey" && (!isset($EMail) || empty($EMail) || !$Helper->CheckEMail($EMail, $Action == "unsubscribe" || $Action == "unsubscribe_confirm" )) ) { if ($ErrorPage != "") header("Location: $ErrorPage"); else print "Es wurde keine E-Mail-Adresse angegeben oder die E-Mail-Adresse liegt nicht im korrekten Format vor!"; exit; } if ($Action == "edit") { if(!isset($NewEMail)) $NewEMail = $EMail; // alte E-Mail else { if ( ($NewEMail == "") || ( !$Helper->CheckEMail($NewEMail) ) ) { if ($ErrorPage != "") header("Location: $ErrorPage"); else print "Die E-Mail-Adresse liegt nicht im korrekten Format vor!"; exit; } } } ##################################### Spam test if($Action != "unsubscriptionsurvey"){ $teststring=""; reset ($_GET); foreach($_GET as $key => $val){ if(is_array($val)) $val = join(",", $val); $teststring .= "$key=$val"; } reset ($_POST); foreach($_POST as $key => $val){ if(is_array($val)) $val = join(",", $val); $teststring .= "$key=$val"; } if ($Helper->CheckForSpam($teststring) == 1) { print "Error processing form data"; exit; } } ##################################### if ($Action == "unsubscribe" && !empty($UnsubscribeConfirmationPage)) { $page = $Helper->LoadContentFromURL($UnsubscribeConfirmationPage); if(!empty($page)){ $var = array_merge($_GET, $_POST); $html = ""; $var["Action"] = "unsubscribe_confirm"; foreach($var as $key => $value) { if ($key == "SubmitBtn") continue; if(is_array($value)) $value = join(";", $value); $html .= ''; $page = str_ireplace("[$key]", $value, $page); } $page = str_ireplace("", $html."", $page); if (empty($SERVER_NAME)) { $SERVER_NAME = $_SERVER['SERVER_NAME']; } if (empty($SCRIPT_NAME)) { $SCRIPT_NAME = $_SERVER['SCRIPT_NAME']; } if(isset($_SERVER['HTTPS'])) $Script = "https://"; else $Script = "http://"; $Script .= $SERVER_NAME.$SCRIPT_NAME; $page = str_replace('action=""', 'action="'.$Script.'"', $page); $Helper->SetHTMLHeaders($WebsiteContentCharset); print $page; exit; } } if ($Action == "subscribe") { $headers = "From: $Recipient".$CRLF; $headers .= "Return-Path: <$Recipient>".$CRLF; if (empty($SERVER_NAME)) { $SERVER_NAME = $_SERVER['SERVER_NAME']; } if (empty($SCRIPT_NAME)) { $SCRIPT_NAME = $_SERVER['SCRIPT_NAME']; } $message = $Helper->LoadContentFromURL($EMailText); $isUTF8 = $Helper->IsUTF8String($message); if(isset($CryptKeyFile) && $CryptKeyFile != "") { if(!$crypt->AddNewCryptKey($CryptKeyFile, $EMail, $CryptKey)) exit; } if(isset($_SERVER['HTTPS'])) $Link = "https://"; else $Link = "http://"; $Link .= $SERVER_NAME.$SCRIPT_NAME."?Action=confirmation&EMail=".urlencode($crypt->phpEncrypt($EMail)); #Fuer weitere Felder, diesen muessen im HTML-Formular und im SuperMailer angelegt werden! $s=""; reset ($_GET); foreach($_GET as $key => $val){ if(is_array($val)) $val = join(";", $val); $message = str_ireplace ("[$key]", $val, $message); if ($key == "EMail") continue; if ($key == "Action") continue; if ($key == "SubmitBtn") continue; $pos = strpos ($key, "[]"); if ($pos !== false) { $key = substr($key, 0, $pos - 1); } if (is_array($val)) { # RG as array? if($s == "") $s = "$key=".urlencode($crypt->phpEncrypt(join(";", $val))); else $s .= "&$key=".urlencode($crypt->phpEncrypt(join(";", $val))); } else { if($s == "") $s = "$key=".urlencode($crypt->phpEncrypt($val)); else $s .= "&$key=".urlencode($crypt->phpEncrypt($val)); } } reset ($_POST); foreach($_POST as $key => $val){ if(is_array($val)) $val = join(";", $val); $message = str_ireplace ("[$key]", $val, $message); if ($key == "EMail") continue; if ($key == "Action") continue; if ($key == "SubmitBtn") continue; $pos = strpos ($key, "[]"); if ($pos !== false) { $key = substr($key, 0, $pos - 1); } if (is_array($val)) { # RG as array? if($s == "") $s = "$key=".urlencode($crypt->phpEncrypt(join(";", $val))); else $s .= "&$key=".urlencode($crypt->phpEncrypt(join(";", $val))); } else { if($s == "") $s = "$key=".urlencode($crypt->phpEncrypt($val)); else $s .= "&$key=".urlencode($crypt->phpEncrypt($val)); } } if($s != "") $Link .= "&".$s; if(!$isUTF8) $headers .= "Content-Type: text/plain; charset=$WebsiteContentCharset".$CRLF; else $headers .= "Content-Type: text/plain; charset=utf-8".$CRLF; $headers .= "Content-Transfer-Encoding: 8bit".$CRLF; $message = str_replace ("[BESTAETIGUNGSLINK]", $Link, $message); $message = str_replace ("[CONFIRMATIONLINK]", $Link, $message); $old_track_errors = @ini_set('track_errors', 1); if(!mail($EMail, $EMailSubject, $message, $headers)){ if(function_exists("error_get_last") && empty($php_errormsg)){ print "Can't send email, PHP mail() must be configured properly." . " Error: "; print_r(error_get_last()); } else print "Can't send email, PHP mail() must be configured properly." . (isset($php_errormsg) ? " Error: " . $php_errormsg : ""); @ini_set('track_errors', $old_track_errors); exit; } @ini_set('track_errors', $old_track_errors); if ($ConfirmationMailSendOKPage != "") header("Location: $ConfirmationMailSendOKPage"); else print "Ihnen wurde eine E-Mail an die E-Mail-Adresse $EMail mit einem Bestätigungslink zur Aufnahme in unseren Newsletter gesendet.
Bitte klicken Sie in dieser E-Mail auf den Bestätigungslink, damit Ihre E-Mail-Adresse in unseren Newsletter aufgenommen wird.
"; exit; } if($Action == "unsubscriptionsurvey"){ if(isset($_POST["Reason"])){ $headers = "From: $Recipient".$CRLF; $headers .= "Return-Path: <$Recipient>".$CRLF; $message=""; reset ($_GET); foreach($_GET as $key => $val){ if ($key == "EMail") continue; if ($key == "Action") continue; if ($key == "SubmitBtn") continue; if (is_array($val)) $message .= "$key: ".$Helper->RemoveCRLF(join(";", $val))."\n"; else $message .= "$key: ".$Helper->RemoveCRLF($val, " ")."\n"; } reset ($_POST); foreach($_POST as $key => $val){ if ($key == "EMail") continue; if ($key == "Action") continue; if ($key == "SubmitBtn") continue; if (is_array($val)) $message .= "$key: ".$Helper->RemoveCRLF(join(";", $val))."\n"; else $message .= "$key: ".$Helper->RemoveCRLF($val, " ")."\n"; } $message .= "IP: ".$REMOTE_ADDR."\n"; $message .= "DateTime: " . date($DateTimeFormat) . "\n"; $message .= "DatumZeit: " . date($DateTimeFormat) . "\n"; $headers .= "Content-Type: text/plain; charset=$WebsiteContentCharset".$CRLF; $headers .= "Content-Transfer-Encoding: 8bit".$CRLF; $old_track_errors = @ini_set('track_errors', 1); if(!mail($Recipient, "unsubsurvey", $message, $headers)){ if(function_exists("error_get_last") && empty($php_errormsg)){ print "Can't send email(3), PHP mail() must be configured properly." . " Error: "; print_r(error_get_last()); } else print "Can't send email(3), PHP mail() must be configured properly." . (isset($php_errormsg) ? " Error: " . $php_errormsg : ""); @ini_set('track_errors', $old_track_errors); exit; } @ini_set('track_errors', $old_track_errors); } if ($UnsubscriptionSurveyConfirmationPage != "") header("Location: $UnsubscriptionSurveyConfirmationPage"); else print "Vielen Dank für die Teilnahme an unserer Umfrage."; exit; } # Aufruf ueber Bestaetigungs-E-Mail if ($Action=="confirmation") { $Action="subscribe"; } # Aufruf ueber Abmeldebestaetigungsseite if ($Action=="unsubscribe_confirm") { $Action="unsubscribe"; } $headers = "From: $Recipient".$CRLF; $headers .= "Return-Path: <$Recipient>".$CRLF; $headers .= "Content-Type: text/plain; charset=$WebsiteContentCharset".$CRLF; $headers .= "Content-Transfer-Encoding: 8bit".$CRLF; # Alle uebergebenen Werte in die Nachricht uebernehmen $message = ""; reset ($_GET); foreach($_GET as $key => $val){ if ($key == "Action") continue; if ($key == "SubmitBtn") continue; if ($key == "EMail" && $Action == "unsubscribe") continue; if(is_array($val)) $val = join(";", $val); if ($Action == "subscribe") $message .= "$key: ".$crypt->phpDecrypt($val)."\n"; else { if (is_array($val)) # RG as array? $message .= "$key: ".join(";", $val)."\n"; else $message .= "$key: ".$val."\n"; } } reset ($_POST); foreach($_POST as $key => $val){ if ($key == "Action") continue; if ($key == "SubmitBtn") continue; if ($key == "EMail" && $Action == "unsubscribe") continue; if(is_array($val)) $val = join(";", $val); if ($Action == "subscribe") $message .= "$key: ".$crypt->phpDecrypt($val)."\n"; else { if (is_array($val)) # RG as array? $message .= "$key: ".join(";", $val)."\n"; else $message .= "$key: ".$val."\n"; } } if($Action == "unsubscribe"){ $message .= "EMail: <%EMAIL_ADD%>\n"; $emails = explode( strpos($EMail, ",") !== false ? "," : ";", $EMail ); }else{ $emails = array($EMail); } $message .= "IP: ".$REMOTE_ADDR."\n"; $message .= "DateTime: " . date($DateTimeFormat) . "\n"; $message .= "DatumZeit: " . date($DateTimeFormat) . "\n"; # Versenden der Mail $old_track_errors = @ini_set('track_errors', 1); for($i=0; $i", $emails[$i], $message); if(!mail($Recipient, $Action, $_message, $headers)) { if(function_exists("error_get_last") && empty($php_errormsg)){ print "Can't send email(2), PHP mail() must be configured properly." . " Error: "; print_r(error_get_last()); } else print "Can't send email(2), PHP mail() must be configured properly." . (isset($php_errormsg) ? " Error: " . $php_errormsg : ""); @ini_set('track_errors', $old_track_errors); exit; } } @ini_set('track_errors', $old_track_errors); if ($Action == "edit") if ($EditOKPage != "") header("Location: $EditOKPage"); else print "Vielen Dank für die Mitteilung der Änderungen!"; else if ($Action == "subscribe") if ($SubscribeOKPage != "") header("Location: $SubscribeOKPage"); else print "Ihre E-Mail-Adresse $EMail wurde zu unserer Newsletterliste hinzugefügt!"; else{ ## fuer/for Magento Export Script #$Helper->LoadContentFromURL("url to magentoexport.php and params"); if (empty($UnsubscribeOKPage)){ print "Ihre E-Mail-Adresse $EMail wurde aus unserer Newsletterliste entfernt!"; exit; } if(empty($UnsubscriptionSurveyReasons)){ header("Location: $UnsubscribeOKPage"); exit; } $page = $Helper->LoadContentFromURL($UnsubscribeOKPage); if(empty($page) || stripos($page, "", $html."", $page); $reasons = explode(";", $UnsubscriptionSurveyReasons); $html = ""; for($i=0; $iIsUTF8String($reasons[$i])) $reason = utf8_encode($reasons[$i]); else $reason = $reasons[$i]; }else $reason = htmlentities($reasons[$i], ENT_COMPAT, $WebsiteContentCharset); $html .= '
'; } $temp = substr($page, 0, stripos($page, "") + 1); $page = $temp . $html . substr($page, stripos($page, ">") + 1); if (empty($SERVER_NAME)) { $SERVER_NAME = $_SERVER['SERVER_NAME']; } if (empty($SCRIPT_NAME)) { $SCRIPT_NAME = $_SERVER['SCRIPT_NAME']; } if(isset($_SERVER['HTTPS'])) $Script = "https://"; else $Script = "http://"; $Script .= $SERVER_NAME.$SCRIPT_NAME; $page = str_replace('action=""', 'action="'.$Script.'"', $page); $Helper->SetHTMLHeaders($WebsiteContentCharset); print $page; } // ################################################################################## class EncDec{ var $hash; function hexToInt($s, $i) { (int)$j = $i * 2; (string)$s1 = $s; (string)$c = substr($s1, $j, 1); // get the char at position $j, length 1 (string)$c1 = substr($s1, $j+1, 1); // get the char at postion $j + 1, length 1 (int)$k = 0; switch ($c) { case "A": $k += 160; break; case "B": $k += 176; break; case "C": $k += 192; break; case "D": $k += 208; break; case "E": $k += 224; break; case "F": $k += 240; break; case " ": $k += 0; break; default: (int)$k = $k + (16 * (int)$c); break; } switch ($c1) { case "A": $k += 10; break; case "B": $k += 11; break; case "C": $k += 12; break; case "D": $k += 13; break; case "E": $k += 14; break; case "F": $k += 15; break; case " ": $k += 0; break; default: $k += (int)$c1; break; } return $k; } function hexToIntArray($s) { $ai = array(); (string)$s1 = $s; (int)$i = strlen($s1); (int)$j = $i / 2; for($l = 0; $l < $j; $l++) { (int)$k = $this->hexToInt($s1,$l); $ai[$l] = $k; } return $ai; } function charToInt($c) { $ac = array(); $ac[0] = $c; return $ac; } function xorString($ai) { $ac = array(); $s = $this->hash; // (int)$i = strlen($s); $ai1 = $ai; (int)$j = count($ai1); for($i = 0; $i < $j; $i = strlen($s)) $s = $s.$s; for($k = 0; $k < $j; $k++) { (string)$c = substr($s,$k,1); $ac[$k] = chr($ai1[$k] ^ ord($c)); } (string)$s1 = implode('', $ac); return $s1; } function phpDecrypt($s) { { $ai = $this->hexToIntArray($s); (string)$s1 = $this->xorString($ai); return $s1; } } function intToHex($i) { (int)$j = (int)$i / 16; if ((int)$j == 0) { (string)$s = " "; } else { (string)$s = strtoupper(dechex((int)$j)); } (int)$k = (int)$i - (int)$j * 16; (string)$s = $s.strtoupper(dechex($k)); return $s; } function xorCharString($s) { $ai = array(); $ac = preg_split('//', $s, -1, PREG_SPLIT_NO_EMPTY); (string)$s1 = $this->hash; (int)$i = strlen($s1); (int)$j = count($ac); for($i=0; $i < $j; $i = strlen($s1)) { $s1 = $s1.$s1; } for($k = 0; $k < $j; $k++) { $c = substr($s1,$k,1); $ai[$k] = ord($c) ^ ord($ac[$k]); } return $ai; } function phpEncrypt($s) { $ai = $this->xorCharString($s); $s1 = ""; for($i = 0; $i < count($ai); $i++) $s1 = $s1.$this->intToHex((int)$ai[$i]); return $s1; } function GetCryptKey($CryptKeyFile, $EncryptedEMail) { global $CryptKey, $CryptKeyExpiresInterval; $EncryptedEMail = urlencode($EncryptedEMail); if($CryptKeyFile == "") return $CryptKey; $fp = fopen($CryptKeyFile, "r"); if(!$fp) return ""; $contents = ""; while (!feof($fp)) { $buffer = fgets($fp, 4096); $contents .= $buffer; } $a = explode("\n", $contents); $key = ""; $expiredItems = false; for($i=count($a) - 1; $i>=0; $i--) { if(trim($a[$i]) == "") { continue; } $b = explode("|", $a[$i]); if(count($b) < 3) { unset($a[$i]); $expiredItems = true; continue; } if($b[0] == $EncryptedEMail) { $key = $b[1]; unset($a[$i]); $expiredItems = true; continue; } if( time() >= $b[2] + ($CryptKeyExpiresInterval * 24 * 60 * 60) ) { unset($a[$i]); $expiredItems = true; } } fclose($fp); if($expiredItems) { $fp = fopen($CryptKeyFile, "w"); if($fp) { fwrite($fp, join("\n", $a)); fclose($fp); } } return $key; } function AddNewCryptKey($CryptKeyFile, $EMail, &$CryptKey) { $fp = fopen($CryptKeyFile, "a"); if(!$fp) { print "Kann in Datei $CryptKeyFile nicht schreiben.
Can't write to file $CryptKeyFile."; return false; } srand ((double)microtime()*1000000); $CryptKey = rand() . date("HismdY"); $CryptKey = str_replace("|", "-", $CryptKey); $CryptKey = str_replace("\n", "-", $CryptKey); $this->hash = $CryptKey; flock($fp, LOCK_EX); fwrite($fp, urlencode($this->phpEncrypt($EMail))."|".$CryptKey."|".time()."\n"); fclose($fp); return true; } } class Helper{ function IsUTF8String($str) { $len = strlen($str); for($i = 0; $i < $len; $i++){ $c = ord($str[$i]); if ($c > 128) { if (($c > 247)) return false; elseif ($c > 239) $bytes = 4; elseif ($c > 223) $bytes = 3; elseif ($c > 191) $bytes = 2; else return false; if (($i + $bytes) > $len) return false; while ($bytes > 1) { $i++; $b = ord($str[$i]); if ($b < 128 || $b > 191) return false; $bytes--; } } } return true; } function CheckEMail($email, $AllowCommaSeparated = false) { if (strpos($email, "@") === false) return 0; $s = substr($email, strpos($email, "@")); if (count(explode(".", $s)) < 2) return 0; if ( strpos($email, "\n") !== false || strpos($email, "\r") !== false ) return 0; if($AllowCommaSeparated){ if( strpos($email, ",") !== false || strpos($email, ";") !== false ) $emails = explode( strpos($email, ",") !== false ? "," : ";", $email ); if(isset($emails)){ for($i=0; $i $part) { $expandedParts[$key] = str_pad($part, 4, '0', STR_PAD_LEFT); } $NewipAddress = join(':', $expandedParts); $hex = join('', $expandedParts); if(!filter_var($NewipAddress, FILTER_VALIDATE_IP)) { return $ipAddress; } return $NewipAddress; } function _strpos_reverse($string, $charToFind, $relativePos = -1) { // from http://de.php.net/manual/en/function.strpos.php if($relativePos < 0) $relativePos = strlen($string); $searchPos = $relativePos; $searchChar = ''; while ($searchChar != $charToFind) { $newPos = $searchPos-1; $searchChar = substr($string,$newPos,strlen($charToFind)); if($searchChar === false) return FALSE; $searchPos = $newPos; } if (!empty($searchChar)) { return $searchPos; } else { return FALSE; } } function getOwnIP() { if (defined('AF_INET6') && isset($_SERVER['REMOTE_ADDR']) && function_exists("filter_var")) { if(filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){ $ipv6 = str_replace(" ", "", $_SERVER['REMOTE_ADDR']); if(defined("ip_address_mask_length") && ip_address_mask_length > 0) { if(strpos($ipv6, '.') !== false){ $ip = substr($ipv6, $this->_strpos_reverse($ipv6, ':') + 1); $ipv6 = substr( $ipv6, 0, $this->_strpos_reverse($ipv6, ':') + 1); $iplong = ip2long($ip); if($iplong > 0) { switch (ip_address_mask_length) { case 1: $iplong = $iplong & 0xFFFFFF00; break; case 2: $iplong = $iplong & 0xFFFF0000; break; case 3: $iplong = $iplong & 0xFF000000; break; case 4: $iplong = $iplong & 0x00000000; break; } $ip = long2ip($iplong); } $ipv6 = $ipv6 . $ip; } else{ // normal IPv6 $ipv6 = $this->_IPv6ToLongFormat($ipv6); $parts = explode(':', $ipv6); for($i=count($parts); $i > count($parts) - ip_address_mask_length - 1; $i--){ $parts[$i] = "0000"; } $ipv6 = join(':', $parts); } } return $this->_IPv6ToLongFormat($ipv6); } } if(!isset($_SERVER['REMOTE_ADDR'])) $_SERVER['REMOTE_ADDR'] = "127.0.0.1"; /* php-magazin 05-07 (de) S. 38, by C.Fraunholz */ /* modified version from internet */ if (!(isset($_SERVER['HTTP_VIA']) || isset($_SERVER['HTTP_CLIENT_IP']))) { $ip = long2ip(ip2long($_SERVER['REMOTE_ADDR'])); } else { $proxy_ip = long2ip(ip2long($_SERVER['REMOTE_ADDR'])); $tokenc1 = "0.0.0.0"; if (isset($_SERVER['HTTP_CLIENT_IP'])) { $tokenc1 = intval(substr($_SERVER['HTTP_CLIENT_IP'], 0, strpos($_SERVER['HTTP_CLIENT_IP'],"."))); } else { if (isset($_SERVER['HTTP_VIA'])) { $tokenc1 = intval(substr($_SERVER['HTTP_VIA'], 0, strpos($_SERVER['HTTP_VIA'], "."))); } } if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $token1 = intval(substr($_SERVER['HTTP_X_FORWARDED_FOR'], 0, strpos($_SERVER['HTTP_X_FORWARDED_FOR'], "."))); else $token1 = ""; if ($token1 != "" && !($token1 == 10 || $token1 == 192 || $token1 == 127 || $token1 == 224)) { // Proxy $ip = long2ip(ip2long($_SERVER['HTTP_X_FORWARDED_FOR'])); } elseif(isset($_SERVER['HTTP_CLIENT_IP']) && !($tokenc1 == 10 || $tokenc1 == 192 || $tokenc1 == 127 || $tokenc1 == 224)) { $ip = long2ip(ip2long($_SERVER['HTTP_CLIENT_IP'])); } else { $ip = $proxy_ip; } } $c = strpos($ip, ","); if ($c !== false) $ip = substr($ip, 0, $c); if(strpos($ip, "'") !== false) $ip = str_replace("'", "", $ip); if(defined("ip_address_mask_length") && $ip != "" && ip_address_mask_length > 0) { $iplong = ip2long($ip); if($iplong > 0) { switch (ip_address_mask_length) { case 1: $iplong = $iplong & 0xFFFFFF00; break; case 2: $iplong = $iplong & 0xFFFF0000; break; case 3: $iplong = $iplong & 0xFF000000; break; case 4: $iplong = $iplong & 0x00000000; break; } $ip = long2ip($iplong); } } return $ip; } function RemoveCRLF($s, $Replacement = ""){ $s = str_replace("\n", $Replacement, $s); return str_replace("\r", $Replacement, $s); } function LoadContentFromURL($url){ $isURL = stripos($url, "http"); if(!function_exists("stream_context_create") || $isURL === false || $isURL){ $page = join("", file($url)); if(empty($page)){ $s = substr (strrchr ($url, "/"), 1); $page = join("", file($s)); } return $page; } $options = array( 'http' => array( 'method' => "GET", 'Connection: close', // Force the peer to validate (not needed in 5.6.0+, but still works 'verify_peer' => true, 'timeout' => 30, version_compare(PHP_VERSION, '5.6.0', '<') ? 'CN_name' : 'peer_name' => parse_url($url, PHP_URL_HOST), ), ); $context = stream_context_create($options); $ret = file_get_contents($url, false, $context); if($ret === false) $page = ""; else $page = trim($ret); if(empty($page)){ $s = substr (strrchr ($url, "/"), 1); $page = join("", file($s)); } return $page; } function SetHTMLHeaders($DefaultPageEncoding) { // Prevent the browser from caching the result. // Date in the past @header('Expires: Mon, 26 Jul 1997 05:00:00 GMT') ; // always modified @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT') ; // HTTP/1.1 @header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0') ; @header('Cache-Control: post-check=0, pre-check=0', false) ; // HTTP/1.0 @header('Pragma: no-cache') ; // Set the response format. @header( 'Content-Type: text/html; charset='.$DefaultPageEncoding ) ; } } ?>