74 |
74 |
|
75 |
75 |
// check if mailto mail addresses needs to be filtered
|
76 |
76 |
if($filter_settings['mailto_filter'] == '1') {
|
77 |
|
$output_filter_mode = $output_filter_mode + 2; // 0|2
|
|
77 |
$output_filter_mode = $output_filter_mode + 2; // 0|2
|
78 |
78 |
|
79 |
79 |
// check if Javascript mailto encryption is enabled (call register_frontend_functions in the template)
|
80 |
80 |
$search = '<script type="text/javascript" src="' .WB_URL .'/modules/output_filter/js/mdcr.js"></script>';
|
81 |
81 |
if(strpos($content, $search) !== false) {
|
82 |
|
$output_filter_mode = $output_filter_mode + 4; // 0|4
|
|
82 |
$output_filter_mode = $output_filter_mode + 4; // 0|4
|
83 |
83 |
}
|
84 |
84 |
}
|
85 |
85 |
|
... | ... | |
95 |
95 |
/*
|
96 |
96 |
Sub 1:\b(<a.[^<]*href\s*?=\s*?"\s*?mailto\s*?:\s*?) --> "<a id="yyy" class="xxx" href = " mailto :" ignoring white spaces
|
97 |
97 |
Sub 2:([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}) --> the email address in the mailto: part of the mail link
|
98 |
|
Sub 3:([^"]*?)" --> possible ?Subject&cc... stuff attached to the mail address
|
99 |
|
Sub 4:([^>]*>) --> all class or id statements after the mailto but before closing ..>
|
100 |
|
Sub 5:(.*?)</a>\b --> the mailto text; all characters between >xxxxx</a>
|
101 |
|
Sub 6:|\b([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4})\b --> email addresses which may appear in the text (require word boundaries)
|
|
98 |
Sub 3:([^"]*?)" --> possible ?Subject&cc... stuff attached to the mail address
|
|
99 |
Sub 4:([^>]*>) --> all class or id statements after the mailto but before closing ..>
|
|
100 |
Sub 5:(.*?)</a>\b --> the mailto text; all characters between >xxxxx</a>
|
|
101 |
Sub 6:|\b([A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4})\b --> email addresses which may appear in the text (require word boundaries)
|
102 |
102 |
*/
|
103 |
103 |
|
104 |
104 |
// find all email addresses embedded in the content and filter them using a callback function
|
... | ... | |
154 |
154 |
// check if Javascript encryption routine is enabled
|
155 |
155 |
if(in_array(OUTPUT_FILTER_MODE, array(6,7))) {
|
156 |
156 |
/** USE JAVASCRIPT ENCRYPTION FOR MAILTO LINKS **/
|
157 |
|
|
|
157 |
|
|
158 |
// extract possible class and id attribute from ahref link
|
|
159 |
preg_match('/class\s*?=\s*?("|\')(.*?)\1/ix', $match[0], $class_attr);
|
|
160 |
$class_attr = empty($class_attr) ? '' : 'class="' . $class_attr[2] . '" ';
|
|
161 |
preg_match('/id\s*?=\s*?("|\')(.*?)\1/ix', $match[0], $id_attr);
|
|
162 |
$id_attr = empty($id_attr) ? '' : 'id="' . $id_attr[2] . '" ';
|
|
163 |
|
158 |
164 |
// preprocess mailto link parts for further usage
|
159 |
165 |
$search = array('@', '.', '_', '-'); $replace = array('F', 'Z', 'X', 'K');
|
160 |
166 |
$email_address = str_replace($search, $replace, strtolower($match[2]));
|
... | ... | |
165 |
171 |
$shift = mt_rand(1, 25);
|
166 |
172 |
|
167 |
173 |
// encrypt the email using an adapted Caesar cipher
|
168 |
|
$encrypted_email = "";
|
|
174 |
$encrypted_email = "";
|
169 |
175 |
for($i = strlen($email_address) -1; $i > -1; $i--) {
|
170 |
176 |
if(preg_match('#[FZXK0-9]#', $email_address[$i], $characters)) {
|
171 |
177 |
$encrypted_email .= $email_address[$i];
|
172 |
|
} else {
|
|
178 |
} else {
|
173 |
179 |
$encrypted_email .= chr((ord($email_address[$i]) -97 + $shift) % 26 + 97);
|
174 |
180 |
}
|
175 |
181 |
}
|
176 |
182 |
$encrypted_email .= chr($shift + 97);
|
177 |
183 |
|
178 |
184 |
// build the encrypted Javascript mailto link
|
179 |
|
$mailto_link = "<a href=\"javascript:mdcr('$encrypted_email','$email_subject')\">" .$match[5] ."</a>";
|
|
185 |
$mailto_link = "<a {$class_attr}{$id_attr}href=\"javascript:mdcr('$encrypted_email','$email_subject')\">" .$match[5] ."</a>";
|
180 |
186 |
|
181 |
187 |
return $mailto_link;
|
182 |
188 |
|
class and id attributes in mailto links are no longer ignored by the output filter