Encode modifizierter Quellcode
Quellcode:
<?php
/*
* URL Encoder script.
* Version 1.0 - February 2002
* (c) 2002, Paul Gregg <pgregg@pgregg.com>
* http://www.pgregg.com
*
* Modified 2005 http://www.email-spamschutz.de
*
* Function: Take an href link and the visible text and make an obfuscated
* link to prevent search engines (or spam harvesters) from picking it up.
*
* Open Source Code: If you use this code on your site for public
* access (i.e. on the Internet) then you must attribute the author and
* source web site: http://www.pgregg.com/projects/
* You must also make this original source code available for download
* unmodified or provide a link to the source. Additionally you must provide
* the source to any modified or translated versions or derivatives.
*
*/
$PHP_SELF = $_SERVER['PHP_SELF'];
$href = isset($_GET['href']) ? $_GET['href'] : '';
$text = isset($_GET['text']) ? $_GET['text'] : '';
$func = isset($_GET['func']) ? $_GET['func'] : '';
$encoder_functions = array (
"transpose" => "Vertauschte Zeichen / Javscript",
"hash" => "Hash Zeichen / Kein Javscript"
);
$valid_functions = array_keys($encoder_functions);
$funktion = $encoder_functions;
if ($href != "") {
# Encode the $href string according to the selected function
if ($text == "")
$text = "Email";
Function escapeencode ($str) {
$ret = "";
$arr = unpack("C*", $str);
foreach ($arr as $char)
$ret .= sprintf("%%%X", $char);
return $ret;
}
Function transpose($str) {
# function takes the string and swaps the order of each group of 2 chars
$len = strlen($str);
$ret = "";
for ($i=0; $i<$len; $i=$i+2) {
if ($i+1 == $len)
$ret .= substr($str, $i, 1);
else
$ret .= sprintf("%s%s", substr($str, $i+1, 1), substr($str, $i, 1));
}
return $ret;
}
# replace wierd chars in the href
$href = preg_replace("/[;,]/", "", $href);
if (! isset($func) ) {
$func = "transpose";
} else {
if (! in_array($func, $valid_functions) )
$func = "transpose"; # prevent bogus functions
}
if ($func == 'transpose') {
$funktion = htmlspecialchars('Vertauschte Zeichen / Javascript');
} else {
$funktion = htmlspecialchars('Hash Zeichen / Kein Javascript');
}
echo ('<p>Verschlüssele Link <b>'.htmlspecialchars($href).'</b> mit der Funktion <b>'.$funktion.'</b></p>');
if ($func == "transpose") {
$code = sprintf("var s='%s';var r='';for(var
i=0; i<s.length; i++,i++) {r=r+s.substring(i+1,i+2)+s.substring(i,i+1)}document.write('<a href=\"'+r+'\">%s</a>');", transpose($href), $text);
$UserCode = sprintf("%s%s%s",
"<SCRIPT language=\"javascript\">eval(unescape('",
escapeencode($code),
"'))</SCRIPT>");
} elseif ($func == "hash") {
$prepend = "";
if (preg_match("/^mailto:/", $href)) {
$href = preg_replace("/^mailto:/", "", $href);
$prepend = "mailto:";
}
if (preg_match("/^http:\/\//", $href)) {
$href = preg_replace("/^http:\/\//", "", $href);
list($server,$url) = split("/", $href, 2);
$href = $url;
$prepend = "http://$server/";
}
$UserCode = sprintf("<a href=\"%s%s\">%s</a>",
$prepend,
escapeencode($href), $text);
}
printf("<br><p>Einfach den folgenden Code per Copy&Past an die Stelle Ihrer Seite einbinden, wo der Link erscheinen soll:</p><textarea rows=5 cols=50>\n%s\n</textarea>\n<br><br>\n<b>Vorschau:</b> %s</p>\n",
htmlspecialchars($UserCode), $UserCode);
}
?>
Original Version | Zurück zum Script