<?
class mailriddler {
var $mailarray = array();
function convert() {
$returnstring = '';
foreach ($this->mailarray as $key => $email) {
$tmp = '';
for ($i=0; $i<strlen($email);$i++)
$tmp .= ", ".ord($email[$i]);
$returnstring .= "mailarray[".$key."] = new Array(".substr($tmp, 2).")\n";
}
return $returnstring;
}
function init () {
echo '<script language="JavaScript" type="text/javascript">'."\n";
echo "var mailarray = new Array();\n";
echo $this->convert();
echo "function mailoutput(mailtoshow) {\n";
echo " var thismail='';\n";
echo " for (i=0;i<mailtoshow.length;i++)\n";
echo " thismail+=String.fromCharCode(mailtoshow[i]);\n";
echo " return thismail;\n";
echo "}\n";
echo "</script>\n";
}
function add($item) {
if (is_array($item)) {
$this->mailarray = $this->mailarray + $item;
} else {
$this->mailarray[] = $item;
}
}
function mailto($item, $title="", $subject = "", $additional = "") {
if ($subject != "")
$subjectstring = "?subject=".rawurlencode($subject);
if (isset($this->mailarray[$item]) || in_array($item, $this->mailarray)) {
if (in_array($item, $this->mailarray))
$item = array_search($item, $this->mailarray);
$riddled_email = "mailarray[".$item."]";
} else {
$tmp = "";
for ($i=0; $i<strlen($item);$i++)
$tmp .= ", ".ord($item[$i]);
$riddled_email = "Array(".substr($tmp, 2).")";
}
if ($title == "")
$title = "'+mailoutput(".$riddled_email.")+'";
else
$title = addslashes($title);
$linkstring = "mailto:'+mailoutput(".$riddled_email.")+'";
$returnstring ='<script language="JavaScript" type="text/javascript">document.write(\'<a href="'.$linkstring.$subjectstring.'" '.addslashes($additional).'>'.$title.'</a>\')</script>';
return $returnstring;
}
}
?>
|