/trunk/LICENSE |
---|
0,0 → 1,202 |
Apache License |
Version 2.0, January 2004 |
http://www.apache.org/licenses/ |
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION |
1. Definitions. |
"License" shall mean the terms and conditions for use, reproduction, |
and distribution as defined by Sections 1 through 9 of this document. |
"Licensor" shall mean the copyright owner or entity authorized by |
the copyright owner that is granting the License. |
"Legal Entity" shall mean the union of the acting entity and all |
other entities that control, are controlled by, or are under common |
control with that entity. For the purposes of this definition, |
"control" means (i) the power, direct or indirect, to cause the |
direction or management of such entity, whether by contract or |
otherwise, or (ii) ownership of fifty percent (50%) or more of the |
outstanding shares, or (iii) beneficial ownership of such entity. |
"You" (or "Your") shall mean an individual or Legal Entity |
exercising permissions granted by this License. |
"Source" form shall mean the preferred form for making modifications, |
including but not limited to software source code, documentation |
source, and configuration files. |
"Object" form shall mean any form resulting from mechanical |
transformation or translation of a Source form, including but |
not limited to compiled object code, generated documentation, |
and conversions to other media types. |
"Work" shall mean the work of authorship, whether in Source or |
Object form, made available under the License, as indicated by a |
copyright notice that is included in or attached to the work |
(an example is provided in the Appendix below). |
"Derivative Works" shall mean any work, whether in Source or Object |
form, that is based on (or derived from) the Work and for which the |
editorial revisions, annotations, elaborations, or other modifications |
represent, as a whole, an original work of authorship. For the purposes |
of this License, Derivative Works shall not include works that remain |
separable from, or merely link (or bind by name) to the interfaces of, |
the Work and Derivative Works thereof. |
"Contribution" shall mean any work of authorship, including |
the original version of the Work and any modifications or additions |
to that Work or Derivative Works thereof, that is intentionally |
submitted to Licensor for inclusion in the Work by the copyright owner |
or by an individual or Legal Entity authorized to submit on behalf of |
the copyright owner. For the purposes of this definition, "submitted" |
means any form of electronic, verbal, or written communication sent |
to the Licensor or its representatives, including but not limited to |
communication on electronic mailing lists, source code control systems, |
and issue tracking systems that are managed by, or on behalf of, the |
Licensor for the purpose of discussing and improving the Work, but |
excluding communication that is conspicuously marked or otherwise |
designated in writing by the copyright owner as "Not a Contribution." |
"Contributor" shall mean Licensor and any individual or Legal Entity |
on behalf of whom a Contribution has been received by Licensor and |
subsequently incorporated within the Work. |
2. Grant of Copyright License. Subject to the terms and conditions of |
this License, each Contributor hereby grants to You a perpetual, |
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
copyright license to reproduce, prepare Derivative Works of, |
publicly display, publicly perform, sublicense, and distribute the |
Work and such Derivative Works in Source or Object form. |
3. Grant of Patent License. Subject to the terms and conditions of |
this License, each Contributor hereby grants to You a perpetual, |
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
(except as stated in this section) patent license to make, have made, |
use, offer to sell, sell, import, and otherwise transfer the Work, |
where such license applies only to those patent claims licensable |
by such Contributor that are necessarily infringed by their |
Contribution(s) alone or by combination of their Contribution(s) |
with the Work to which such Contribution(s) was submitted. If You |
institute patent litigation against any entity (including a |
cross-claim or counterclaim in a lawsuit) alleging that the Work |
or a Contribution incorporated within the Work constitutes direct |
or contributory patent infringement, then any patent licenses |
granted to You under this License for that Work shall terminate |
as of the date such litigation is filed. |
4. Redistribution. You may reproduce and distribute copies of the |
Work or Derivative Works thereof in any medium, with or without |
modifications, and in Source or Object form, provided that You |
meet the following conditions: |
(a) You must give any other recipients of the Work or |
Derivative Works a copy of this License; and |
(b) You must cause any modified files to carry prominent notices |
stating that You changed the files; and |
(c) You must retain, in the Source form of any Derivative Works |
that You distribute, all copyright, patent, trademark, and |
attribution notices from the Source form of the Work, |
excluding those notices that do not pertain to any part of |
the Derivative Works; and |
(d) If the Work includes a "NOTICE" text file as part of its |
distribution, then any Derivative Works that You distribute must |
include a readable copy of the attribution notices contained |
within such NOTICE file, excluding those notices that do not |
pertain to any part of the Derivative Works, in at least one |
of the following places: within a NOTICE text file distributed |
as part of the Derivative Works; within the Source form or |
documentation, if provided along with the Derivative Works; or, |
within a display generated by the Derivative Works, if and |
wherever such third-party notices normally appear. The contents |
of the NOTICE file are for informational purposes only and |
do not modify the License. You may add Your own attribution |
notices within Derivative Works that You distribute, alongside |
or as an addendum to the NOTICE text from the Work, provided |
that such additional attribution notices cannot be construed |
as modifying the License. |
You may add Your own copyright statement to Your modifications and |
may provide additional or different license terms and conditions |
for use, reproduction, or distribution of Your modifications, or |
for any such Derivative Works as a whole, provided Your use, |
reproduction, and distribution of the Work otherwise complies with |
the conditions stated in this License. |
5. Submission of Contributions. Unless You explicitly state otherwise, |
any Contribution intentionally submitted for inclusion in the Work |
by You to the Licensor shall be under the terms and conditions of |
this License, without any additional terms or conditions. |
Notwithstanding the above, nothing herein shall supersede or modify |
the terms of any separate license agreement you may have executed |
with Licensor regarding such Contributions. |
6. Trademarks. This License does not grant permission to use the trade |
names, trademarks, service marks, or product names of the Licensor, |
except as required for reasonable and customary use in describing the |
origin of the Work and reproducing the content of the NOTICE file. |
7. Disclaimer of Warranty. Unless required by applicable law or |
agreed to in writing, Licensor provides the Work (and each |
Contributor provides its Contributions) on an "AS IS" BASIS, |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
implied, including, without limitation, any warranties or conditions |
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A |
PARTICULAR PURPOSE. You are solely responsible for determining the |
appropriateness of using or redistributing the Work and assume any |
risks associated with Your exercise of permissions under this License. |
8. Limitation of Liability. In no event and under no legal theory, |
whether in tort (including negligence), contract, or otherwise, |
unless required by applicable law (such as deliberate and grossly |
negligent acts) or agreed to in writing, shall any Contributor be |
liable to You for damages, including any direct, indirect, special, |
incidental, or consequential damages of any character arising as a |
result of this License or out of the use or inability to use the |
Work (including but not limited to damages for loss of goodwill, |
work stoppage, computer failure or malfunction, or any and all |
other commercial damages or losses), even if such Contributor |
has been advised of the possibility of such damages. |
9. Accepting Warranty or Additional Liability. While redistributing |
the Work or Derivative Works thereof, You may choose to offer, |
and charge a fee for, acceptance of support, warranty, indemnity, |
or other liability obligations and/or rights consistent with this |
License. However, in accepting such obligations, You may act only |
on Your own behalf and on Your sole responsibility, not on behalf |
of any other Contributor, and only if You agree to indemnify, |
defend, and hold each Contributor harmless for any liability |
incurred by, or claims asserted against, such Contributor by reason |
of your accepting any such warranty or additional liability. |
END OF TERMS AND CONDITIONS |
APPENDIX: How to apply the Apache License to your work. |
To apply the Apache License to your work, attach the following |
boilerplate notice, with the fields enclosed by brackets "[]" |
replaced with your own identifying information. (Don't include |
the brackets!) The text should be enclosed in the appropriate |
comment syntax for the file format. We also recommend that a |
file or class name and description of purpose be included on the |
same "printed page" as the copyright notice for easier |
identification within third-party archives. |
Copyright 2018 Daniel Marschall, ViaThinkSoft |
Licensed under the Apache License, Version 2.0 (the "License"); |
you may not use this file except in compliance with the License. |
You may obtain a copy of the License at |
http://www.apache.org/licenses/LICENSE-2.0 |
Unless required by applicable law or agreed to in writing, software |
distributed under the License is distributed on an "AS IS" BASIS, |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
See the License for the specific language governing permissions and |
limitations under the License. |
/trunk/README.md |
---|
0,0 → 1,31 |
# ViaThinkSoft AntiSpam-Schutz |
Folgende Funktion soll Ihnen helfen, E-Mail-Adressen per JavaScript-Ausgabe sicher darzustellen, sodass der Benutzer sie auch anklicken und verwenden kann. |
**Beschreibung** |
Jedes Zeichen wird einzeln mit dem Zeichen-Code in einer einzelnen Zeile geschrieben. Selbst mailto, @ und .de werden mit verschlüsselt. Folglich kann man den Mechanismus als sehr sicher einstufen. |
Der Benutzer muss JavaScript aktiviert haben, um die E-Mail-Adresse zu sehen. Die Verwendung von JavaScript ist aber Webseiten üblich und ist bei allen Browser standardmäßig aktiviert. |
Vorteilhaft ist, dass kein Spam-Bot diesen Mechanismus kennt, da dieser nicht häufig angewandt wird. Ich bitte daher, diesen Spamschutz nicht in große Systeme ohne Erlaubnis einzubauen, da bei zu starkem Bekanntheitsgrades der JavaScript-Struktur, die Spam-Bots dem Mechanismus entgegenwirken könnten. |
Auch ohne PHP ist der Spamschutz möglich, da der Code bereits im Voraus berechnet und die Ausgabe in einer HTML-Datei eingebaut werden kann. |
**Benutzung** |
- 1. Parameter: E-Mail-Adresse ohne Angabe von "mailto:" |
- 2. Parameter: Angabe des Linktextes oder des Linkbildes |
- 3. Parameter: Soll der 2. Parameter auch verschlüsselt werden? Nur ein Text darf verschlüsselt werden, ein Bild nicht! Der Link-Text muss verschlüsselt werden, wenn er die E-Mail-Adresse enthält, da sonst der Schutz verfällt. |
- 4. Parameter (Optional): Die CSS-Klasse für den Link. |
**Beispiele** |
<?php |
echo secure_email('test@example.com', 'Schreib mir!', 0); |
echo secure_email('test@example.com', 'test@example.com', 1); |
echo secure_email('test@example.com', '<img src="...">', 0); |
?> |
/trunk/composer.json |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/json |
Property changes: |
Added: svn:mime-type |
+application/json |
\ No newline at end of property |
/trunk/examples/antispam-example.php |
---|
0,0 → 1,39 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
"http://www.w3.org/TR/html4/loose.dtd"> |
<html> |
<head> |
<title>ViaThinkSoft AntiSpam Test</title> |
</head> |
<body> |
<?php |
echo '<form action="'.$_SERVER['PHP_SELF'].'"> |
E-Mail-Adresse: <input name="email" value="'.$_GET['email'].'"><br> |
Linktext: <input name="linktext" value="'.$_GET['linktext'].'"><br> |
Linktext verschlüsseln: <input type="checkbox" name="crypt_linktext" checked><br> |
V3 anstelle von V4 nutzen: <input type="checkbox" name="use_v3" checked><br> |
<input type="submit"> |
</form>'; |
if ($_GET['use_v3']) { |
include '../v3.inc.php'; |
} else { |
include '../v4.inc.php'; |
} |
$x = secure_email($_GET['email'], $_GET['linktext'], isset($_GET['crypt_linktext'])); |
echo '<p>Implementierung:</p>'; |
echo '<textarea cols="120" rows="20">'.htmlentities($x).'</textarea>'; |
echo '<hr>'; |
echo '<p>Vorschau:</p>'; |
echo $x; |
?> |
</body> |
</html> |
/trunk/examples/autofilter-example1.inc.php |
---|
0,0 → 1,94 |
<?php |
// This is an example of the ViaThinkSoft AntiSpam 3.02 |
// for ViaThinkSoft Sigma as filter plugin (modified $content) |
// Use it for your website! |
include __DIR__ . '/../v3.inc.php'; // AntiSpam v3 |
// CONFIGURATION |
define('CFG_MAKE_MAIL_ADDRESSES_CLICKABLE', true); |
// CODE |
function alas_js_crypt($text) |
{ |
$tmp = ''; |
for ($i=0; $i<strlen($text); $i++) |
{ |
$tmp .= 'document.write("&#'.ord(substr($text, $i, 1)).';");'; |
} |
return $tmp; |
} |
function secure_email_triv($email) |
{ |
$aus = ''; |
if ($email != '') |
{ |
$aus .= '<script language="JavaScript" type="text/javascript"><!--'."\n"; |
$aus .= alas_js_crypt($email); |
$aus .= '// --></script>'; |
} |
return $aus; |
} |
function getAddrSpec() { |
// Ref: http://www.iamcal.com/publish/articles/php/parsing_email/ |
$qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'; |
$dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'; |
$atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'. |
'\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'; |
$quoted_pair = '\\x5c[\\x00-\\x7f]'; |
$domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d"; |
$quoted_string = "\\x22($qtext|$quoted_pair)*\\x22"; |
$domain_ref = $atom; |
$sub_domain = "($domain_ref|$domain_literal)"; |
$word = "($atom|$quoted_string)"; |
$domain = "$sub_domain(\\x2e$sub_domain)*"; |
$local_part = "$word(\\x2e$word)*"; |
$addr_spec = "$local_part\\x40$domain"; |
return $addr_spec; |
} |
function is_valid_email_address($email){ |
$addr_spec = getAddrSpec(); |
return preg_match("!^$addr_spec$!", $email) ? true : false; |
} |
function auto_secure_mail_addresses($content) { |
$addr_spec = getAddrSpec(); |
// Step 1: Parse links and make them secure |
$content = preg_replace_callback("/<a(.+?)mailto:($addr_spec)(.+?)>(.+?)<\/a>/sm", |
function($a) { |
$mailaddr = $a[2]; |
$linktext = $a[14]; // Letztes |
return secure_email($mailaddr, $linktext, is_valid_email_address($linktext)); |
}, $content); // TODO! Kann Greedy werden! |
// Step 2: Find all further mail addresses, make then clickable and prevent spam bots |
$content = preg_replace_callback("/($addr_spec)/sm", function($a) { |
$mailaddr = $a[1]; // Letztes |
if (CFG_MAKE_MAIL_ADDRESSES_CLICKABLE) { |
return secure_email($mailaddr, $mailaddr, true); |
} else { |
return secure_email_triv($mailaddr); |
} |
}, $content); |
// Output |
return $content; |
} |
if (isset($content)) { |
$content = auto_secure_mail_addresses($content); |
} |
/trunk/examples/autofilter-example2.inc.php |
---|
0,0 → 1,308 |
<?php |
// ======================================================================== |
// SOURCE: SIGMA 3.0 ANTISPAM CONFIG |
define('CFG_MAKE_MAIL_ADDRESSES_CLICKABLE', true); |
define('CFG_CORRET_MISSING_MAILTO', true); |
define('CFG_DEFAULT_CLASS', 'mail-addr'); |
// ======================================================================== |
// SOURCE: SIGMA 3.0 ANTISPAM FILTER |
function alas_js_crypt($text) |
{ |
$tmp = ''; |
for ($i=0; $i<strlen($text); $i++) |
{ |
$tmp .= 'document.write("&#'.ord(substr($text, $i, 1)).';");'; |
} |
return $tmp; |
} |
function secure_email_triv($email) |
{ |
$aus = ''; |
if ($email != '') |
{ |
$aus .= '<script language="JavaScript" type="text/javascript"><!--'."\n"; |
$aus .= alas_js_crypt($email); |
$aus .= '// --></script>'; |
} |
return $aus; |
} |
function getAddrSpec() { |
// Ref: http://www.iamcal.com/publish/articles/php/parsing_email/ |
$qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]'; |
$dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]'; |
$atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+'; |
$quoted_pair = '\\x5c[\\x00-\\x7f]'; |
$domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d"; |
$quoted_string = "\\x22($qtext|$quoted_pair)*\\x22"; |
$domain_ref = $atom; |
$sub_domain = "($domain_ref|$domain_literal)"; |
$word = "($atom|$quoted_string)"; |
$domain = "$sub_domain(\\x2e$sub_domain)*"; |
$local_part = "$word(\\x2e$word)*"; |
$addr_spec = "$local_part\\x40$domain"; |
return $addr_spec; |
} |
function is_valid_email_address($email) { |
// TODO: Hier lieber einen korrekten Mailvalidator verwenden (C.Sayers Lösung)? |
$ary = explode('?', $email); |
$email = $ary[0]; |
$addr_spec = getAddrSpec(); |
return preg_match("!^$addr_spec$!", $email); |
} |
class MailLinkProtector extends UrlParseIterator { |
var $correct_missing_mailto; |
protected function link_callback($complete, $pre, $post, $urltype, $bracket, $url, $linktext) { |
if (beginsWithI($url, 'mailto:')) { |
// Link ist eine Mailadresse |
$mailaddr = remove_beginning_i($url, 'mailto:'); |
return secure_email($mailaddr, $linktext, is_valid_email_address($linktext), CFG_DEFAULT_CLASS); |
} else if (($this->correct_missing_mailto) && (is_valid_email_address($url))) { |
// Hier hat jemand "mailto:" vergessen. Wir korrigieren das mal... |
$mailaddr = $url; |
return secure_email($mailaddr, $linktext, is_valid_email_address($linktext), CFG_DEFAULT_CLASS); |
} else { |
// Normaler Link |
return $complete; |
} |
} |
} |
function protect_mail_address_urls($content, $correct_missing_mailto = true) { |
$t = new MailLinkProtector; |
$t->correct_missing_mailto = $correct_missing_mailto; |
return $t->process($content); |
} |
function auto_secure_mail_addresses($content) { |
// Step 1: Parse links and make them secure |
$content = protect_mail_address_urls($content, CFG_CORRET_MISSING_MAILTO); |
// Step 2: Find all further mail addresses, make then clickable and prevent spam bots |
$addr_spec = getAddrSpec(); |
// This fixes an error if the file is unix converted... |
// The error occoured at server4.configcenter.info: |
// [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 |
// [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" |
$content = str_replace("\n", "\r\n", $content); |
// Diese Zeichen ausschließen, damit z.B. Satzzeichen am Ende einer E-Mail-Adresse, Anführungszeichen oder Klammern nicht |
// als Teil der Adresse angesehen werden. Die Liste ist länger als $addr_spec eigentlich benötigt (z.B. schließt $addr_spec |
// einen Punkt am Ende automatisch aus). Aber sicher ist sicher. |
$exclude_mail_chars_beginning = '\^°!"§$%&/()=\?´`}\]\[{\+*~\'#-_\.:,;'; |
$exclude_mail_chars_ending = $exclude_mail_chars_beginning; |
$content = preg_replace_callback("@(?![$exclude_mail_chars_beginning])($addr_spec)(?<![$exclude_mail_chars_ending])@sm", function($a) { |
$mailaddr = $a[1]; // Letztes |
if (CFG_MAKE_MAIL_ADDRESSES_CLICKABLE) { |
return secure_email($mailaddr, $mailaddr, true, CFG_DEFAULT_CLASS); |
} else { |
return secure_email_triv($mailaddr); |
} |
}, $content); |
// Output |
return $content; |
} |
// ======================================================================== |
// SOURCE: SIGMA 3.0 _sigma.php |
class UrlParseIterator { |
var $use_original_bracket_at_link = false; |
var $use_original_bracket_at_css = false; |
var $use_original_bracket_at_other = false; |
protected function process_url($url) { |
// Overwrite this method in a derivate! |
return $url; |
} |
// LINK |
private function link_style_regex() { |
return "@(<a\s[^>]*(href)\s*=\s*)(?(?=[\"'])(([\"'])([^>]*)\\4)|()([^ >]*?))([^>]*>)(.*)</a>@ismU"; |
} |
protected function link_callback($complete, $pre, $post, $urltype, $bracket, $url, $linktext) { |
$url = $this->process_url($url); |
return $pre.$bracket.$url.$bracket.$post.$linktext.'</a>'; |
} |
private function link_first_callback($c) { |
$complete = $c[0]; |
$pre = $c[1]; |
$post = $c[8]; |
$urltype = $c[2]; // = href |
if ($this->use_original_bracket_at_link) { |
$bracket = $c[4]; |
} else { |
$bracket = '"'; |
} |
$url = $c[5].$c[7]; // Either [5] OR [7] is filled, so I simply concat them. |
$linktext = $c[9]; |
return $this->link_callback($complete, $pre, $post, $urltype, $bracket, $url, $linktext); |
} |
// CSS |
private function css_style_regex() { |
return "/url\(\s*(?(?=[\"'])(([\"'])([^>]*)\\2)|([^\)]*?))\)/isUm"; |
} |
protected function css_callback($complete, $bracket, $url) { |
$url = $this->process_url($url); |
return 'url('.$bracket.$url.$bracket.')'; |
} |
private function css_first_callback($c) { |
$complete = $c[0]; |
if ($this->use_original_bracket_at_css) { |
$bracket = $c[2]; |
} else { |
$bracket = "'"; |
} |
if (!isset($c[4])) $c[4] = ''; |
$url = $c[3].$c[4]; // Either [3] OR [4] is filled, so I simply concat them. |
return $this->css_callback($complete, $bracket, $url); |
} |
// Other (does not include a-href, but base-href etc.) |
private function other_style_regex() { |
return "/((<(?!a\s)[^><]*)(href)|src|background|code)\s*=\s*(?(?=[\"'])(([\"'])([^>]*)\\5)|([^ >]*?))/isUm"; |
} |
protected function other_callback($complete, $bracket, $type, $url) { |
$url = $this->process_url($url); |
return $type.'='.$bracket.$url.$bracket; |
} |
private function other_first_callback($c) { |
// Aufgrund des regex ist bei einem href $c[0] nicht href="..." sondern <base ... href="..." |
// Wir verdecken diesen zusätzlichen Anfang, leiten ihn an die abstrakte callback-Funktion weiter |
// und fügen später beim zurückliefern diesen Präfix $pre wieder hinzu. |
$pre = $c[2]; |
$complete = remove_beginning($c[0], $pre); |
if ($c[3] == '') { |
$type = $c[1]; |
} else { |
$type = $c[3]; |
} |
if ($this->use_original_bracket_at_other) { |
$bracket = $c[5]; |
} else { |
$bracket = '"'; |
} |
if (!isset($c[7])) $c[7] = ''; |
$url = $c[6].$c[7]; // Either [6] OR [7] is filled, so I simply concat them. |
return $pre.$this->other_callback($complete, $bracket, $type, $url); |
} |
// Processing functions |
private function process_links($content) { |
$r = preg_replace_callback($this->link_style_regex(), array(&$this, 'link_first_callback'), $content); |
if ($r == null) return $content; // z.B. bei doppeltem ALAS-Processing! |
return $r; |
} |
private function process_other($content) { |
$r = preg_replace_callback($this->other_style_regex(), array(&$this, 'other_first_callback'), $content); |
if ($r == null) return $content; |
return $r; |
} |
private function process_css($content) { |
$r = preg_replace_callback($this->css_style_regex(), array(&$this, 'css_first_callback'), $content); |
if ($r == null) return $content; |
return $r; |
} |
public function process($content) { |
$content = $this->process_links($content); |
$content = $this->process_other($content); |
$content = $this->process_css($content); |
return $content; |
} |
} |
// ======================================================================== |
// SOURCE: VIATHINKSOFT ANTI SPAM |
include '../v3.inc.php'; |
// ======================================================================== |
// SOURCE: SIGMA 3.0 _sigma.php |
function remove_beginning($content, $beginning) { |
if (beginsWith($content, $beginning)) { |
return substr($content, strlen($beginning), strlen($content)-strlen($beginning)); |
} else { |
return $content; |
} |
} |
function beginsWithI($content, $beginning) { |
return beginsWith(strtolower($content), strtolower($beginning)); |
} |
function beginsWith($content, $beginning) { |
// return substr($content, 0, strlen($beginning)) == $beginning; |
return (strncmp($content, $beginning, strlen($beginning)) == 0); |
} |
function remove_beginning_i($content, $beginning) { |
if (beginsWithI($content, $beginning)) { |
return substr($content, strlen($beginning), strlen($content)-strlen($beginning)); |
} else { |
return $content; |
} |
} |
// ======================================================================== |
// USAGE: |
// $content = auto_secure_mail_addresses($content); |
// ======================================================================== |
/trunk/phpstan.neon.dist |
---|
0,0 → 1,15 |
parameters: |
level: 5 |
fileExtensions: |
- php |
- phps |
paths: |
- . |
excludePaths: |
analyseAndScan: |
- .phpstan.tmp |
tmpDir: .phpstan.tmp |
ignoreErrors: |
- '#is always (true|false)\.#' |
#- '#Call to function assert\(\) with false will always evaluate to false\.#' |
#- '#with no typehint specified\.#' |
/trunk/todo.txt |
---|
0,0 → 1,11 |
ToDo 3.x |
- Nothing :-) |
ToDo 4.x |
- Pack everything in a PHP class |
- Allow to add things before and after the content of <a>...</a> (e.g. font colors) |
- Allow to add things before and after the script/noscript part (because of W3C validity) |
- Make the text links variable |
- Implement $css_class like in v3 |
Property changes: |
Added: svn:mime-type |
+text/plain |
\ No newline at end of property |
/trunk/v3.inc.php |
---|
0,0 → 1,58 |
<?php |
// PHP-AntiSpam-Funktion "secure_email", Version 3.1 of 2022-01-09 |
// by Daniel Marschall [www.daniel-marschall.de], ViaThinkSoft |
// License: Apache 2.0 License |
class VtsAntiSpam3 { |
private function alas_js_crypt($text) |
{ |
$tmp = ''; |
for ($i=0; $i<strlen($text); $i++) |
{ |
$tmp .= 'document.write("&#'.ord(substr($text, $i, 1)).';");'; |
} |
return $tmp; |
} |
private function alas_js_write($text) |
{ |
$text = str_replace('\\', '\\\\', $text); |
$text = str_replace('"', '\"', $text); |
$text = str_replace('/', '\/', $text); // W3C Validation </a> -> <\/a> |
return 'document.write("'.$text.'");'; |
} |
public function secure_email($email, $linktext, $crypt_linktext, $css_class='') |
{ |
// No new lines to avoid a JavaScript error! |
$linktext = str_replace("\r", ' ', $linktext); |
$linktext = str_replace("\n", ' ', $linktext); |
$aus = ''; |
if ($email != '') |
{ |
$aus .= '<script><!--'."\n"; // type="text/javascript" is not necessary in HTML5 |
$aus .= $this->alas_js_write('<a '); |
if ($css_class != '') $aus .= $this->alas_js_write('class="'.$css_class.'" '); |
$aus .= $this->alas_js_write('href="'); |
$aus .= $this->alas_js_crypt('mailto:'.$email); |
$aus .= $this->alas_js_write('">'); |
$aus .= $crypt_linktext ? $this->alas_js_crypt($linktext) : $this->alas_js_write($linktext); |
$aus .= $this->alas_js_write('</a>').'// --></script>'; |
} |
return $aus.'<noscript>Please enable JavaScript to display this email address.</noscript>'; |
} |
} |
# ------------------------------------------------------------------------------ |
function secure_email($email, $linktext, $crypt_linktext, $css_class='') { |
$antispam = new VtsAntiSpam3(); |
$res = $antispam->secure_email($email, $linktext, $crypt_linktext); |
return $res; |
} |
/trunk/v4.inc.php |
---|
0,0 → 1,162 |
<?php |
/* |
* ViaThinkSoft Anti-Spam Script for PHP |
* (C) 2009-2022 ViaThinkSoft |
* Revision: 2022-11-05 (Version 4.1.1) |
* License: Apache 2.0 License |
*/ |
class VtsAntiSpam4 { |
public $garbageLength = 5; |
public function __construct() { |
self::randomize(); |
} |
private static function randomize() { |
// Anfagswert über aktuelle Mikrosekunde setzen |
// http://de2.php.net/manual/de/function.srand.php |
list($usec, $sec) = explode(' ', microtime()); |
$seed = (int)((int)$sec + ((float)$usec * 100000)); |
srand($seed); |
} |
private function RandomString($len) { |
// http://www.jonasjohn.de/snippets/php/rand-str.htm |
$randstr = ''; |
//srand((double)microtime()*1000000); |
for($i=0;$i<$len;$i++) { |
$n = rand(48,120); |
while (($n >= 58 && $n <= 64) || ($n >= 91 && $n <= 96)) { |
$n = rand(48,120); |
} |
$randstr .= chr($n); |
} |
return $randstr; |
} |
private function js_randombreaks() { |
$len = rand(0, $this->garbageLength); |
$r = ''; |
$one_line_comment = false; |
for($i=0;$i<$len;$i++) { |
$m = rand(0, 3); |
if ($m == 0) { |
$r .= ' '; |
} else if ($m == 1) { |
$r .= '//'; |
$r .= $this->RandomString($i); |
$one_line_comment = true; |
} else if ($m == 2) { |
$r .= "\r\n"; |
$one_line_comment = false; |
} else { |
$r .= "\t"; |
} |
} |
if ($one_line_comment) $r .= "\r\n"; |
return $r; |
} |
private function alas_js_crypt($text) { |
$tmp = ''; |
for ($i=0; $i<strlen($text); $i++) { |
$tmp .= $this->js_randombreaks(); |
$tmp .= 'document.write("&#'.ord(substr($text, $i, 1)).';");'; |
$tmp .= $this->js_randombreaks(); |
} |
$tmp = $this->js_randombreaks().$tmp.$this->js_randombreaks(); |
return $tmp; |
} |
private function alas_noscript_crypt($text){ |
$tmp = ''; |
for ($i=0; $i<strlen($text); $i++) { |
$tmp .= '<span style="display:inline;">&#'.ord(substr($text, $i, 1)).';</span>'; |
$tmp .= '<!--'.$this->js_randombreaks().'-->'; |
$tmp .= '<span style="display:none;">'.$this->RandomString(rand(0, $this->garbageLength)).'</span>'; |
} |
return $tmp; |
} |
private function alas_js_write($text) { |
$text = str_replace('\\', '\\\\', $text); |
$text = str_replace('"', '\"', $text); |
$text = str_replace('/', '\/', $text); // W3C Validation </a> -> <\/a> |
$ret = ''; |
$ret .= $this->js_randombreaks(); |
$ret .= 'document.write("'.$text.'");'; |
$ret .= $this->js_randombreaks(); |
return $ret; |
} |
public function secure_email($email, $linktext, $crypt_linktext) |
{ |
// No new lines to avoid a JavaScript error! |
$linktext = str_replace("\r", ' ', $linktext); |
$linktext = str_replace("\n", ' ', $linktext); |
$aus = ''; |
if ($email != '') { |
$zid = 'ALAS-4.0-'.DecHex(crc32($email)).'-'.DecHex(crc32($linktext)).'-'.($crypt_linktext ? 'S' : 'L'); |
$title = 'ViaThinkSoft "ALAS" Anti-Spam'; |
$aus .= "<!-- BEGIN $title [ID $zid] -->\r\n"; |
$aus .= '<script language="JavaScript" type="text/javascript"><!--'."\n"; |
$aus .= $this->alas_js_write('<a href="'); |
$aus .= $this->alas_js_crypt('mailto:'.$email); |
$aus .= $this->alas_js_write('">'); |
$aus .= $crypt_linktext ? $this->alas_js_crypt($linktext) : $this->alas_js_write($linktext); |
$aus .= $this->alas_js_write('</a>').'// --></script>'; |
$aus .= '<noscript>'; |
if ($linktext != $email) $aus .= ($crypt_linktext ? $this->alas_noscript_crypt($linktext) : $linktext).' '; |
$aus .= $this->alas_noscript_crypt("[ $email ]"); |
$aus .= '</noscript>'; |
$aus .= "\r\n<!-- END $title [ID $zid] -->\r\n"; |
} |
return $aus; |
} |
public function secure_email_autodetect($email, $linktext) { |
// Automatisch erkennen, ob der $linktext für Spambots interessant ist oder nicht |
$pos = strpos($linktext, '@'); |
return $this->secure_email($email, $linktext, $pos !== false); |
} |
public function secure_email_identical_text($email) { |
return $this->secure_email_autodetect($email, $email); |
} |
} |
# ------------------------------------------------------------------------------ |
function secure_email($email, $linktext, $crypt_linktext, $css_class='') { |
if (!empty($css_class)) { |
// TODO |
throw new Exception("CSSClass is not yet implemented in AntiSpam v4"); |
} |
$antispam = new VtsAntiSpam4(); |
$res = $antispam->secure_email($email, $linktext, $crypt_linktext); |
return $res; |
} |
function secure_email_autodetect($email, $linktext) { |
$antispam = new VtsAntiSpam4(); |
$res = $antispam->secure_email_autodetect($email, $linktext); |
return $res; |
} |
function secure_email_identical_text($email) { |
$antispam = new VtsAntiSpam4(); |
$res = $antispam->secure_email_identical_text($email); |
return $res; |
} |
/trunk |
---|
Property changes: |
Added: svn:ignore |
+.phpstan.tmp |
+phpstan.neon |
+ |