Rev 5 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5 | Rev 6 | ||
---|---|---|---|
1 | <?php |
1 | <?php |
2 | 2 | ||
3 | // ======================================================================== |
3 | // ======================================================================== |
4 | 4 | ||
5 | // SOURCE: SIGMA 3.0 ANTISPAM CONFIG |
5 | // SOURCE: SIGMA 3.0 ANTISPAM CONFIG |
6 | 6 | ||
7 | define('CFG_MAKE_MAIL_ADDRESSES_CLICKABLE', true); |
7 | define('CFG_MAKE_MAIL_ADDRESSES_CLICKABLE', true); |
8 | define('CFG_CORRET_MISSING_MAILTO', true); |
8 | define('CFG_CORRET_MISSING_MAILTO', true); |
9 | define('CFG_DEFAULT_CLASS', 'mail-addr'); |
9 | define('CFG_DEFAULT_CLASS', 'mail-addr'); |
10 | 10 | ||
11 | // ======================================================================== |
11 | // ======================================================================== |
12 | 12 | ||
13 | // SOURCE: SIGMA 3.0 ANTISPAM FILTER |
13 | // SOURCE: SIGMA 3.0 ANTISPAM FILTER |
14 | 14 | ||
15 | function secure_email_triv($email) |
- | |
16 | { |
- | |
17 | if (!function_exists('alas_js_crypt')) |
- | |
18 | { |
- | |
19 | function alas_js_crypt($text) |
15 | function alas_js_crypt($text) |
20 | { |
16 | { |
21 | $tmp = ''; |
17 | $tmp = ''; |
22 | for ($i=0; $i<strlen($text); $i++) |
18 | for ($i=0; $i<strlen($text); $i++) |
23 | { |
19 | { |
24 | $tmp .= 'document.write("&#'.ord(substr($text, $i, 1)).';");'; |
20 | $tmp .= 'document.write("&#'.ord(substr($text, $i, 1)).';");'; |
25 | } |
21 | } |
26 | return $tmp; |
22 | return $tmp; |
27 | } |
23 | } |
28 | } |
- | |
29 | 24 | ||
- | 25 | function secure_email_triv($email) |
|
- | 26 | { |
|
30 | $aus = ''; |
27 | $aus = ''; |
31 | if ($email != '') |
28 | if ($email != '') |
32 | { |
29 | { |
33 | $aus .= '<script language="JavaScript" type="text/javascript"><!--'."\n"; |
30 | $aus .= '<script language="JavaScript" type="text/javascript"><!--'."\n"; |
34 | $aus .= alas_js_crypt($email); |
31 | $aus .= alas_js_crypt($email); |
35 | $aus .= '// --></script>'; |
32 | $aus .= '// --></script>'; |
36 | } |
33 | } |
37 | return $aus; |
34 | return $aus; |
38 | } |
35 | } |
39 | 36 | ||
40 | function getAddrSpec() { |
37 | function getAddrSpec() { |
41 | // Ref: http://www.iamcal.com/publish/articles/php/parsing_email/ |
38 | // Ref: http://www.iamcal.com/publish/articles/php/parsing_email/ |
42 | 39 | ||
43 | $qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'; |
40 | $qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'; |
44 | $dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'; |
41 | $dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'; |
45 | $atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'; |
42 | $atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'; |
46 | $quoted_pair = '\\x5c[\\x00-\\x7f]'; |
43 | $quoted_pair = '\\x5c[\\x00-\\x7f]'; |
47 | $domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d"; |
44 | $domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d"; |
48 | $quoted_string = "\\x22($qtext|$quoted_pair)*\\x22"; |
45 | $quoted_string = "\\x22($qtext|$quoted_pair)*\\x22"; |
49 | $domain_ref = $atom; |
46 | $domain_ref = $atom; |
50 | $sub_domain = "($domain_ref|$domain_literal)"; |
47 | $sub_domain = "($domain_ref|$domain_literal)"; |
51 | $word = "($atom|$quoted_string)"; |
48 | $word = "($atom|$quoted_string)"; |
52 | $domain = "$sub_domain(\\x2e$sub_domain)*"; |
49 | $domain = "$sub_domain(\\x2e$sub_domain)*"; |
53 | $local_part = "$word(\\x2e$word)*"; |
50 | $local_part = "$word(\\x2e$word)*"; |
54 | $addr_spec = "$local_part\\x40$domain"; |
51 | $addr_spec = "$local_part\\x40$domain"; |
55 | 52 | ||
56 | return $addr_spec; |
53 | return $addr_spec; |
57 | } |
54 | } |
58 | 55 | ||
59 | function is_valid_email_address($email) { |
56 | function is_valid_email_address($email) { |
60 | // TODO: Hier lieber einen korrekten Mailvalidator verwenden (C.Sayers Lösung)? |
57 | // TODO: Hier lieber einen korrekten Mailvalidator verwenden (C.Sayers Lösung)? |
61 | 58 | ||
62 | $ary = explode('?', $email); |
59 | $ary = explode('?', $email); |
63 | $email = $ary[0]; |
60 | $email = $ary[0]; |
64 | 61 | ||
65 | $addr_spec = getAddrSpec(); |
62 | $addr_spec = getAddrSpec(); |
66 | return preg_match("!^$addr_spec$!", $email); |
63 | return preg_match("!^$addr_spec$!", $email); |
67 | } |
64 | } |
68 | 65 | ||
69 | class MailLinkProtector extends UrlParseIterator { |
66 | class MailLinkProtector extends UrlParseIterator { |
70 | var $correct_missing_mailto; |
67 | var $correct_missing_mailto; |
71 | 68 | ||
72 | protected function link_callback($complete, $pre, $post, $urltype, $bracket, $url, $linktext) { |
69 | protected function link_callback($complete, $pre, $post, $urltype, $bracket, $url, $linktext) { |
73 | if (beginsWithI($url, 'mailto:')) { |
70 | if (beginsWithI($url, 'mailto:')) { |
74 | // Link ist eine Mailadresse |
71 | // Link ist eine Mailadresse |
75 | $mailaddr = remove_beginning_i($url, 'mailto:'); |
72 | $mailaddr = remove_beginning_i($url, 'mailto:'); |
76 | return secure_email($mailaddr, $linktext, is_valid_email_address($linktext), CFG_DEFAULT_CLASS); |
73 | return secure_email($mailaddr, $linktext, is_valid_email_address($linktext), CFG_DEFAULT_CLASS); |
77 | } else if (($this->correct_missing_mailto) && (is_valid_email_address($url))) { |
74 | } else if (($this->correct_missing_mailto) && (is_valid_email_address($url))) { |
78 | // Hier hat jemand "mailto:" vergessen. Wir korrigieren das mal... |
75 | // Hier hat jemand "mailto:" vergessen. Wir korrigieren das mal... |
79 | $mailaddr = $url; |
76 | $mailaddr = $url; |
80 | return secure_email($mailaddr, $linktext, is_valid_email_address($linktext), CFG_DEFAULT_CLASS); |
77 | return secure_email($mailaddr, $linktext, is_valid_email_address($linktext), CFG_DEFAULT_CLASS); |
81 | } else { |
78 | } else { |
82 | // Normaler Link |
79 | // Normaler Link |
83 | return $complete; |
80 | return $complete; |
84 | } |
81 | } |
85 | } |
82 | } |
86 | } |
83 | } |
87 | 84 | ||
88 | function link_cb_2($a) { |
- | |
89 | $mailaddr = $a[1]; // Letztes |
- | |
90 | - | ||
91 | if (CFG_MAKE_MAIL_ADDRESSES_CLICKABLE) { |
- | |
92 | return secure_email($mailaddr, $mailaddr, true, CFG_DEFAULT_CLASS); |
- | |
93 | } else { |
- | |
94 | return secure_email_triv($mailaddr); |
- | |
95 | } |
- | |
96 | } |
- | |
97 | - | ||
98 | function protect_mail_address_urls($content, $correct_missing_mailto = true) { |
85 | function protect_mail_address_urls($content, $correct_missing_mailto = true) { |
99 | $t = new MailLinkProtector; |
86 | $t = new MailLinkProtector; |
100 | $t->correct_missing_mailto = $correct_missing_mailto; |
87 | $t->correct_missing_mailto = $correct_missing_mailto; |
101 | return $t->process($content); |
88 | return $t->process($content); |
102 | } |
89 | } |
103 | 90 | ||
104 | function auto_secure_mail_addresses($content) { |
91 | function auto_secure_mail_addresses($content) { |
105 | // Step 1: Parse links and make them secure |
92 | // Step 1: Parse links and make them secure |
106 | 93 | ||
107 | $content = protect_mail_address_urls($content, CFG_CORRET_MISSING_MAILTO); |
94 | $content = protect_mail_address_urls($content, CFG_CORRET_MISSING_MAILTO); |
108 | 95 | ||
109 | // Step 2: Find all further mail addresses, make then clickable and prevent spam bots |
96 | // Step 2: Find all further mail addresses, make then clickable and prevent spam bots |
110 | 97 | ||
111 | $addr_spec = getAddrSpec(); |
98 | $addr_spec = getAddrSpec(); |
112 | 99 | ||
113 | // This fixes an error if the file is unix converted... |
100 | // This fixes an error if the file is unix converted... |
114 | // The error occoured at server4.configcenter.info: |
101 | // The error occoured at server4.configcenter.info: |
115 | // [Fri Mar 26 20:23:24 2010] [error] [client 87.165.172.145] (104)Connection reset by peer: FastCGI: comm with server "/home/www/web66/html/cgi-bin/php-fcgi-starter" aborted: read failed |
102 | // [Fri Mar 26 20:23:24 2010] [error] [client 87.165.172.145] (104)Connection reset by peer: FastCGI: comm with server "/home/www/web66/html/cgi-bin/php-fcgi-starter" aborted: read failed |
116 | // [Fri Mar 26 20:23:24 2010] [error] [client 87.165.172.145] FastCGI: incomplete headers (0 bytes) received from server "/home/www/web66/html/cgi-bin/php-fcgi-starter" |
103 | // [Fri Mar 26 20:23:24 2010] [error] [client 87.165.172.145] FastCGI: incomplete headers (0 bytes) received from server "/home/www/web66/html/cgi-bin/php-fcgi-starter" |
117 | $content = str_replace("\n", "\r\n", $content); |
104 | $content = str_replace("\n", "\r\n", $content); |
118 | 105 | ||
119 | // Diese Zeichen ausschließen, damit z.B. Satzzeichen am Ende einer E-Mail-Adresse, Anführungszeichen oder Klammern nicht |
106 | // Diese Zeichen ausschließen, damit z.B. Satzzeichen am Ende einer E-Mail-Adresse, Anführungszeichen oder Klammern nicht |
120 | // als Teil der Adresse angesehen werden. Die Liste ist länger als $addr_spec eigentlich benötigt (z.B. schließt $addr_spec |
107 | // als Teil der Adresse angesehen werden. Die Liste ist länger als $addr_spec eigentlich benötigt (z.B. schließt $addr_spec |
121 | // einen Punkt am Ende automatisch aus). Aber sicher ist sicher. |
108 | // einen Punkt am Ende automatisch aus). Aber sicher ist sicher. |
122 | $exclude_mail_chars_beginning = '\^°!"§$%&/()=\?´`}\]\[{\+*~\'#-_\.:,;'; |
109 | $exclude_mail_chars_beginning = '\^°!"§$%&/()=\?´`}\]\[{\+*~\'#-_\.:,;'; |
123 | $exclude_mail_chars_ending = $exclude_mail_chars_beginning; |
110 | $exclude_mail_chars_ending = $exclude_mail_chars_beginning; |
124 | 111 | ||
125 | $content = preg_replace_callback("@(?![$exclude_mail_chars_beginning])($addr_spec)(?<![$exclude_mail_chars_ending])@sm", 'link_cb_2', $content); |
112 | $content = preg_replace_callback("@(?![$exclude_mail_chars_beginning])($addr_spec)(?<![$exclude_mail_chars_ending])@sm", function($a) { |
- | 113 | $mailaddr = $a[1]; // Letztes |
|
- | 114 | ||
- | 115 | if (CFG_MAKE_MAIL_ADDRESSES_CLICKABLE) { |
|
- | 116 | return secure_email($mailaddr, $mailaddr, true, CFG_DEFAULT_CLASS); |
|
- | 117 | } else { |
|
- | 118 | return secure_email_triv($mailaddr); |
|
- | 119 | } |
|
- | 120 | }, $content); |
|
126 | 121 | ||
127 | // Output |
122 | // Output |
128 | 123 | ||
129 | return $content; |
124 | return $content; |
130 | } |
125 | } |
131 | 126 | ||
132 | // ======================================================================== |
127 | // ======================================================================== |
133 | 128 | ||
134 | // SOURCE: SIGMA 3.0 _sigma.php |
129 | // SOURCE: SIGMA 3.0 _sigma.php |
135 | 130 | ||
136 | class UrlParseIterator { |
131 | class UrlParseIterator { |
137 | var $use_original_bracket_at_link = false; |
132 | var $use_original_bracket_at_link = false; |
138 | var $use_original_bracket_at_css = false; |
133 | var $use_original_bracket_at_css = false; |
139 | var $use_original_bracket_at_other = false; |
134 | var $use_original_bracket_at_other = false; |
140 | 135 | ||
141 | protected function process_url($url) { |
136 | protected function process_url($url) { |
142 | // Overwrite this method in a derivate! |
137 | // Overwrite this method in a derivate! |
143 | return $url; |
138 | return $url; |
144 | } |
139 | } |
145 | 140 | ||
146 | // LINK |
141 | // LINK |
147 | 142 | ||
148 | private function link_style_regex() { |
143 | private function link_style_regex() { |
149 | return "@(<a\s[^>]*(href)\s*=\s*)(?(?=[\"'])(([\"'])([^>]*)\\4)|()([^ >]*?))([^>]*>)(.*)</a>@ismU"; |
144 | return "@(<a\s[^>]*(href)\s*=\s*)(?(?=[\"'])(([\"'])([^>]*)\\4)|()([^ >]*?))([^>]*>)(.*)</a>@ismU"; |
150 | } |
145 | } |
151 | 146 | ||
152 | protected function link_callback($complete, $pre, $post, $urltype, $bracket, $url, $linktext) { |
147 | protected function link_callback($complete, $pre, $post, $urltype, $bracket, $url, $linktext) { |
153 | $url = $this->process_url($url); |
148 | $url = $this->process_url($url); |
154 | 149 | ||
155 | return $pre.$bracket.$url.$bracket.$post.$linktext.'</a>'; |
150 | return $pre.$bracket.$url.$bracket.$post.$linktext.'</a>'; |
156 | } |
151 | } |
157 | 152 | ||
158 | private function link_first_callback($c) { |
153 | private function link_first_callback($c) { |
159 | $complete = $c[0]; |
154 | $complete = $c[0]; |
160 | 155 | ||
161 | $pre = $c[1]; |
156 | $pre = $c[1]; |
162 | $post = $c[8]; |
157 | $post = $c[8]; |
163 | 158 | ||
164 | $urltype = $c[2]; // = href |
159 | $urltype = $c[2]; // = href |
165 | 160 | ||
166 | if ($this->use_original_bracket_at_link) { |
161 | if ($this->use_original_bracket_at_link) { |
167 | $bracket = $c[4]; |
162 | $bracket = $c[4]; |
168 | } else { |
163 | } else { |
169 | $bracket = '"'; |
164 | $bracket = '"'; |
170 | } |
165 | } |
171 | 166 | ||
172 | $url = $c[5].$c[7]; // Either [5] OR [7] is filled, so I simply concat them. |
167 | $url = $c[5].$c[7]; // Either [5] OR [7] is filled, so I simply concat them. |
173 | 168 | ||
174 | $linktext = $c[9]; |
169 | $linktext = $c[9]; |
175 | 170 | ||
176 | return $this->link_callback($complete, $pre, $post, $urltype, $bracket, $url, $linktext); |
171 | return $this->link_callback($complete, $pre, $post, $urltype, $bracket, $url, $linktext); |
177 | } |
172 | } |
178 | 173 | ||
179 | // CSS |
174 | // CSS |
180 | 175 | ||
181 | private function css_style_regex() { |
176 | private function css_style_regex() { |
182 | return "/url\(\s*(?(?=[\"'])(([\"'])([^>]*)\\2)|([^\)]*?))\)/isUm"; |
177 | return "/url\(\s*(?(?=[\"'])(([\"'])([^>]*)\\2)|([^\)]*?))\)/isUm"; |
183 | } |
178 | } |
184 | 179 | ||
185 | protected function css_callback($complete, $bracket, $url) { |
180 | protected function css_callback($complete, $bracket, $url) { |
186 | $url = $this->process_url($url); |
181 | $url = $this->process_url($url); |
187 | 182 | ||
188 | return 'url('.$bracket.$url.$bracket.')'; |
183 | return 'url('.$bracket.$url.$bracket.')'; |
189 | } |
184 | } |
190 | 185 | ||
191 | private function css_first_callback($c) { |
186 | private function css_first_callback($c) { |
192 | $complete = $c[0]; |
187 | $complete = $c[0]; |
193 | 188 | ||
194 | if ($this->use_original_bracket_at_css) { |
189 | if ($this->use_original_bracket_at_css) { |
195 | $bracket = $c[2]; |
190 | $bracket = $c[2]; |
196 | } else { |
191 | } else { |
197 | $bracket = "'"; |
192 | $bracket = "'"; |
198 | } |
193 | } |
199 | 194 | ||
200 | if (!isset($c[4])) $c[4] = ''; |
195 | if (!isset($c[4])) $c[4] = ''; |
201 | $url = $c[3].$c[4]; // Either [3] OR [4] is filled, so I simply concat them. |
196 | $url = $c[3].$c[4]; // Either [3] OR [4] is filled, so I simply concat them. |
202 | 197 | ||
203 | return $this->css_callback($complete, $bracket, $url); |
198 | return $this->css_callback($complete, $bracket, $url); |
204 | } |
199 | } |
205 | 200 | ||
206 | // Other (does not include a-href, but base-href etc.) |
201 | // Other (does not include a-href, but base-href etc.) |
207 | 202 | ||
208 | private function other_style_regex() { |
203 | private function other_style_regex() { |
209 | return "/((<(?!a\s)[^><]*)(href)|src|background|code)\s*=\s*(?(?=[\"'])(([\"'])([^>]*)\\5)|([^ >]*?))/isUm"; |
204 | return "/((<(?!a\s)[^><]*)(href)|src|background|code)\s*=\s*(?(?=[\"'])(([\"'])([^>]*)\\5)|([^ >]*?))/isUm"; |
210 | } |
205 | } |
211 | 206 | ||
212 | protected function other_callback($complete, $bracket, $type, $url) { |
207 | protected function other_callback($complete, $bracket, $type, $url) { |
213 | $url = $this->process_url($url); |
208 | $url = $this->process_url($url); |
214 | 209 | ||
215 | return $type.'='.$bracket.$url.$bracket; |
210 | return $type.'='.$bracket.$url.$bracket; |
216 | } |
211 | } |
217 | 212 | ||
218 | private function other_first_callback($c) { |
213 | private function other_first_callback($c) { |
219 | // Aufgrund des regex ist bei einem href $c[0] nicht href="..." sondern <base ... href="..." |
214 | // Aufgrund des regex ist bei einem href $c[0] nicht href="..." sondern <base ... href="..." |
220 | // Wir verdecken diesen zusätzlichen Anfang, leiten ihn an die abstrakte callback-Funktion weiter |
215 | // Wir verdecken diesen zusätzlichen Anfang, leiten ihn an die abstrakte callback-Funktion weiter |
221 | // und fügen später beim zurückliefern diesen Präfix $pre wieder hinzu. |
216 | // und fügen später beim zurückliefern diesen Präfix $pre wieder hinzu. |
222 | $pre = $c[2]; |
217 | $pre = $c[2]; |
223 | 218 | ||
224 | $complete = remove_beginning($c[0], $pre); |
219 | $complete = remove_beginning($c[0], $pre); |
225 | 220 | ||
226 | if ($c[3] == '') { |
221 | if ($c[3] == '') { |
227 | $type = $c[1]; |
222 | $type = $c[1]; |
228 | } else { |
223 | } else { |
229 | $type = $c[3]; |
224 | $type = $c[3]; |
230 | } |
225 | } |
231 | 226 | ||
232 | if ($this->use_original_bracket_at_other) { |
227 | if ($this->use_original_bracket_at_other) { |
233 | $bracket = $c[5]; |
228 | $bracket = $c[5]; |
234 | } else { |
229 | } else { |
235 | $bracket = '"'; |
230 | $bracket = '"'; |
236 | } |
231 | } |
237 | 232 | ||
238 | if (!isset($c[7])) $c[7] = ''; |
233 | if (!isset($c[7])) $c[7] = ''; |
239 | $url = $c[6].$c[7]; // Either [6] OR [7] is filled, so I simply concat them. |
234 | $url = $c[6].$c[7]; // Either [6] OR [7] is filled, so I simply concat them. |
240 | 235 | ||
241 | return $pre.$this->other_callback($complete, $bracket, $type, $url); |
236 | return $pre.$this->other_callback($complete, $bracket, $type, $url); |
242 | } |
237 | } |
243 | 238 | ||
244 | // Processing functions |
239 | // Processing functions |
245 | 240 | ||
246 | private function process_links($content) { |
241 | private function process_links($content) { |
247 | $r = preg_replace_callback($this->link_style_regex(), array(&$this, 'link_first_callback'), $content); |
242 | $r = preg_replace_callback($this->link_style_regex(), array(&$this, 'link_first_callback'), $content); |
248 | if ($r == null) return $content; // z.B. bei doppeltem ALAS-Processing! |
243 | if ($r == null) return $content; // z.B. bei doppeltem ALAS-Processing! |
249 | return $r; |
244 | return $r; |
250 | } |
245 | } |
251 | 246 | ||
252 | private function process_other($content) { |
247 | private function process_other($content) { |
253 | $r = preg_replace_callback($this->other_style_regex(), array(&$this, 'other_first_callback'), $content); |
248 | $r = preg_replace_callback($this->other_style_regex(), array(&$this, 'other_first_callback'), $content); |
254 | if ($r == null) return $content; |
249 | if ($r == null) return $content; |
255 | return $r; |
250 | return $r; |
256 | } |
251 | } |
257 | 252 | ||
258 | private function process_css($content) { |
253 | private function process_css($content) { |
259 | $r = preg_replace_callback($this->css_style_regex(), array(&$this, 'css_first_callback'), $content); |
254 | $r = preg_replace_callback($this->css_style_regex(), array(&$this, 'css_first_callback'), $content); |
260 | if ($r == null) return $content; |
255 | if ($r == null) return $content; |
261 | return $r; |
256 | return $r; |
262 | } |
257 | } |
263 | 258 | ||
264 | public function process($content) { |
259 | public function process($content) { |
265 | $content = $this->process_links($content); |
260 | $content = $this->process_links($content); |
266 | $content = $this->process_other($content); |
261 | $content = $this->process_other($content); |
267 | $content = $this->process_css($content); |
262 | $content = $this->process_css($content); |
268 | 263 | ||
269 | return $content; |
264 | return $content; |
270 | } |
265 | } |
271 | } |
266 | } |
272 | 267 | ||
273 | // ======================================================================== |
268 | // ======================================================================== |
274 | 269 | ||
275 | // SOURCE: VIATHINKSOFT ANTI SPAM |
270 | // SOURCE: VIATHINKSOFT ANTI SPAM |
276 | 271 | ||
277 | include '../v3.inc.php'; |
272 | include '../v3.inc.php'; |
278 | 273 | ||
279 | // ======================================================================== |
274 | // ======================================================================== |
280 | 275 | ||
281 | // SOURCE: SIGMA 3.0 _sigma.php |
276 | // SOURCE: SIGMA 3.0 _sigma.php |
282 | 277 | ||
283 | function remove_beginning($content, $beginning) { |
278 | function remove_beginning($content, $beginning) { |
284 | if (beginsWith($content, $beginning)) { |
279 | if (beginsWith($content, $beginning)) { |
285 | return substr($content, strlen($beginning), strlen($content)-strlen($beginning)); |
280 | return substr($content, strlen($beginning), strlen($content)-strlen($beginning)); |
286 | } else { |
281 | } else { |
287 | return $content; |
282 | return $content; |
288 | } |
283 | } |
289 | } |
284 | } |
290 | 285 | ||
291 | function beginsWithI($content, $beginning) { |
286 | function beginsWithI($content, $beginning) { |
292 | return beginsWith(strtolower($content), strtolower($beginning)); |
287 | return beginsWith(strtolower($content), strtolower($beginning)); |
293 | } |
288 | } |
294 | 289 | ||
295 | function beginsWith($content, $beginning) { |
290 | function beginsWith($content, $beginning) { |
296 | // return substr($content, 0, strlen($beginning)) == $beginning; |
291 | // return substr($content, 0, strlen($beginning)) == $beginning; |
297 | return (strncmp($content, $beginning, strlen($beginning)) == 0); |
292 | return (strncmp($content, $beginning, strlen($beginning)) == 0); |
298 | } |
293 | } |
299 | 294 | ||
300 | function remove_beginning_i($content, $beginning) { |
295 | function remove_beginning_i($content, $beginning) { |
301 | if (beginsWithI($content, $beginning)) { |
296 | if (beginsWithI($content, $beginning)) { |
302 | return substr($content, strlen($beginning), strlen($content)-strlen($beginning)); |
297 | return substr($content, strlen($beginning), strlen($content)-strlen($beginning)); |
303 | } else { |
298 | } else { |
304 | return $content; |
299 | return $content; |
305 | } |
300 | } |
306 | } |
301 | } |
307 | 302 | ||
308 | // ======================================================================== |
303 | // ======================================================================== |
309 | 304 | ||
310 | // USAGE: |
305 | // USAGE: |
311 | // $content = auto_secure_mail_addresses($content); |
306 | // $content = auto_secure_mail_addresses($content); |
312 | 307 | ||
313 | // ======================================================================== |
308 | // ======================================================================== |
314 | 309 |