| 1 |
<?php |
<?php |
| 2 |
|
|
| 3 |
// $Id: invisimail.module,v 1.2.2.1 2007/10/01 22:59:58 crell Exp $ |
// $Id: invisimail.module,v 1.3 2007/10/01 23:07:12 crell Exp $ |
| 4 |
|
|
| 5 |
/** |
/** |
| 6 |
* @file |
* @file |
| 98 |
} |
} |
| 99 |
|
|
| 100 |
function invisimail_callback($matches) { |
function invisimail_callback($matches) { |
|
return $matches[1] . invisimail_ascii_encode($matches[2]) . $matches[3]; |
|
|
} |
|
|
|
|
|
function invisimail_ascii_encode($string) { |
|
| 101 |
$format = $GLOBALS['invisimail_format']; |
$format = $GLOBALS['invisimail_format']; |
| 102 |
$js = variable_get('invisimail_js_'.$format, FALSE); |
$js = variable_get('invisimail_js_'.$format, FALSE); |
| 103 |
$link = variable_get('invisimail_link_'.$format, FALSE); |
$link = variable_get('invisimail_link_'.$format, FALSE); |
| 104 |
|
|
| 105 |
|
return $matches[1] . invisimail_ascii_encode($matches[2], $js, $link) . $matches[3]; |
| 106 |
|
} |
| 107 |
|
|
| 108 |
|
/** |
| 109 |
|
* This function does the actual encoding. |
| 110 |
|
* |
| 111 |
|
* @param $string |
| 112 |
|
* A string which contains only an email addres to be encoded. |
| 113 |
|
* @param $js |
| 114 |
|
* Optional: A boolean which sets whether Javascript is used for encoding. |
| 115 |
|
* @param $link |
| 116 |
|
* Optional: A boolean which set whether the result includes a mailto link. |
| 117 |
|
* @param $text |
| 118 |
|
* Optional: The text to be used for the link. |
| 119 |
|
* @return |
| 120 |
|
* An ascii encoded email address. |
| 121 |
|
*/ |
| 122 |
|
function invisimail_ascii_encode($string, $js = FALSE, $link = FALSE, $text = NULL) { |
| 123 |
|
if ($text == NULL) { |
| 124 |
|
$text = $string; |
| 125 |
|
} |
| 126 |
|
|
| 127 |
if ($js) { |
if ($js) { |
| 128 |
$output = "<script type='text/javascript'><!-- |
$output = "<script type='text/javascript'><!-- |
| 129 |
document.write('"; |
document.write('"; |
| 142 |
|
|
| 143 |
if ($link && !$js) { |
if ($link && !$js) { |
| 144 |
// ascii in this next line is "mailto:" |
// ascii in this next line is "mailto:" |
| 145 |
$output .= "<a href=\"mailto:$encode\">$encode</a>"; |
$output .= "<a href=\"mailto:$encode\">$text</a>"; |
| 146 |
} |
} |
| 147 |
elseif ($link && $js) { |
elseif ($link && $js) { |
| 148 |
$output .= "<a href=\"mailto:'+'$encode'+'\">'+'$encode'+'</a>"; |
$output .= "<a href=\"mailto:'+'$encode'+'\">'+'$text'+'</a>"; |
| 149 |
} |
} |
| 150 |
else { |
else { |
| 151 |
$output .= $encode; |
$output .= $encode; |
| 159 |
|
|
| 160 |
return $output; |
return $output; |
| 161 |
} |
} |
|
|
|
|
?> |
|