Subversion Repositories php_guestbook

Compare Revisions

No changes between revisions

Regard whitespace Rev 1 → Rev 2

/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/TODO
0,0 → 1,18
 
Geplant für Version 3.0:
- Mehrsprachigkeit
- JavaScript Smileys mittendrin einfügen, nicht nur hinten anfügen
- Skype, YIM, AIM, Steam, Telegram, Whatsapp usw.
- Adminbereich
- In er E-Mail die Möglichkeit geben, einen Eintrag zu löschen oder zu kommentieren
- $farbe_X -- bessere namen verteilen
 
UTF-8?
 
Nachprüfen:
Gab es weitere Änderungen in der DMWP/THRS-Fassung?
Diese Version 2.x basiert auf Version 1.3 (auf ViathinkSoft veröffentlicht am 26. Dez 2005)
 
Probleme:
- Es kommt keine Fehlermeldung wenn die Tabellen nicht existieren!
 
/trunk/_install/.htaccess
0,0 → 1,3
Order Deny,Allow
Deny From All
 
/trunk/_install/install.php
0,0 → 1,28
#!/usr/bin/php
<?php
 
if (php_sapi_name() != 'cli') {
echo "Please run in CLI mode\n";
exit(1);
}
 
require_once __DIR__ . '/../includes/database.inc.php';
verbinden();
 
$cont = file_get_contents(__DIR__ . '/install.sql');
 
$queries = preg_split('@;\s*\n@ismU', $cont);
 
foreach ($queries as $query) {
$query = trim($query);
if ($query == '') continue;
if (substr($query, 0, 2) == '--') continue;
$query .= ';';
 
mysql_query($query);
 
$err = mysql_error();
if ($err) {
fwrite(STDERR, "mySQL error $err at query $query\n\n");
}
}
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/_install/install.sql
Cannot display: file marked as a binary type.
svn:mime-type = application/x-sql
Property changes:
Added: svn:mime-type
+application/x-sql
\ No newline at end of property
/trunk/_install/upgrade_1.3_to_2.x.php
0,0 → 1,28
#!/usr/bin/php
<?php
 
if (php_sapi_name() != 'cli') {
echo "Please run in CLI mode\n";
exit(1);
}
 
require_once __DIR__ . '/../includes/database.inc.php';
verbinden();
 
$cont = file_get_contents(__DIR__ . '/upgrade_1.3_to_2.x.sql');
 
$queries = preg_split('@;\s*\n@ismU', $cont);
 
foreach ($queries as $query) {
$query = trim($query);
if ($query == '') continue;
if (substr($query, 0, 2) == '--') continue;
$query .= ';';
 
mysql_query($query);
 
$err = mysql_error();
if ($err) {
fwrite(STDERR, "mySQL error $err at query $query\n\n");
}
}
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/_install/upgrade_1.3_to_2.x.sql
Cannot display: file marked as a binary type.
svn:mime-type = application/x-sql
Property changes:
Added: svn:mime-type
+application/x-sql
\ No newline at end of property
/trunk/config/.htaccess
0,0 → 1,3
Order Deny,Allow
Deny From All
 
/trunk/config/config.original.inc.php
0,0 → 1,73
<?php
 
error_reporting(E_ALL | E_NOTICE | E_DEPRECATED | E_STRICT);
 
$charset = 'ISO-8859-1';
 
// Der Titel der Seite
$seitentitel = 'Mein Gästebuch';
 
// Seitenkopf
$seitenkopf = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 
<head>
<meta http-equiv="Content-Type" content="text/html; charset={CHARSET}" />
<title>'.htmlentities($seitentitel).' G&auml;stebuch</title>
</head>
 
<body>';
 
// Seitenfuß
$seitenfuss = '</body></html>';
 
// Farben
$farbe1 = '#505080'; // Rand eines Eintrags
$farbe2 = '#D2DAF0'; // Eintrag Segment 2 (Text) BG
$farbe3 = '#A0B1E0'; // Eintrag Segment 1 (Kopfzeile) BG
$farbe4 = '#333333'; // Erstellungsdatum Schrift
$farbe5 = '#E2E7F5'; // Eintrag Segment 3 (Admin-Kommentar, optional) BG
$farbe6 = 'red'; // Fehlermeldung
$farbe7 = 'blue'; // Pflichtfeld-Stern
$farbe8 = 'green'; // Erfolgsmeldung
$farbe9 = 'black'; // Segment 1 (Kopfzeile) Text
$farbe10 = 'black'; // Segment 2 (Text) Text
$farbe11 = 'black'; // Segment 3 (Admin-Kommentar, optional) Text
 
// Die MySQL-Zugangsdaten
$mysql_server = 'localhost';
$mysql_user = 'root';
$mysql_pass = '';
$mysql_database = 'guestbook';
 
// Die Datenbanktabellennamen
$table_entries = 'gaestebuch_entries';
$table_smileys = 'gaestebuch_smileys';
 
// E-Mail-Adresse
$adminmail = 'your_email_address@example.com';
$adminmail_cc = '';
 
// Einträge pro Seite
$eintraege_proseite = 10;
 
// Vorsicht: Der Server muss autorisiert sein, eine E-Mail zu über diese Domain zu senden (SPF/DKIM)
$cfg_from_email = 'noreply@example.com';
 
// Features
$cfg_feature_simple_antispam = true;
$cfg_automatisch_freischalten = false;
$cfg_unfreigeschaltete_anzegen = false;
$cfg_vorschau = true;
 
// Recaptcha - This is the most secure Captcha
// It also helps against "F5" spamming!
// Get a FREE API key here: https://www.google.com/recaptcha/admin/create
$cfg_recaptcha_enabled = false;
$cfg_recaptcha_pubkey = '';
$cfg_recaptcha_privkey = '';
 
// see https://daniel-lange.com/archives/66-ICQ-web-status-icons.html
$cfg_icq_statusicon = 5;
/trunk/config
Property changes:
Added: svn:ignore
+config.inc.php
/trunk/images/buttons/abschicken.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/buttons/aendern.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/buttons/loeschen.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/buttons/vorschau.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/buttons/zurueck.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/email.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/homepage.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/icqadd.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/001.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/002.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/003.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/004.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/005.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/006.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/007.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/008.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/009.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/010.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/011.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/012.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/013.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/014.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/015.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/016.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/alien.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/angry.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/ass.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/ausrufez.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/biggrin.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/blah.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/confused.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/cool.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/cry.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/death.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/eek.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/frage.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/frown.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/hehe.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/king.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/lol.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/mad.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/pissed.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/redface.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/rolleyes.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/smile.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/tongue.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/smileys/wink.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/images/spacer.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes:
Added: svn:mime-type
+image/gif
\ No newline at end of property
/trunk/includes/.htaccess
0,0 → 1,3
Order Deny,Allow
Deny From All
 
/trunk/includes/SecureMailer.class.php
0,0 → 1,132
<?php
 
/*
* Secure Mailer PHP Class
* Copyright 2009-2013 Daniel Marschall, ViaThinkSoft
* QB_SECURE_MAIL_PARAM (C) Erich Kachel
* Version 2013-04-14
*
* 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.
*/
 
// TODO: getHeaders() als single string , attachments , remove headers etc, headers als array in/out, Braucht man auch ein addRawHeader()?
 
class SecureMailer {
private $headers = '';
 
// TODO: sollte eher private sein, geht aber net
const endl = "\n"; // GMX will kein CRLF! wtf?! (Unter Postfix in Linux)
 
private function QB_SECURE_MAIL_PARAM($param_ = '', $level_ = 2) {
// Verhindert Mail-Header-Injections
// Quelle: http://www.erich-kachel.de/?p=26
 
/* replace until done */
while (!isset($filtered) || ($param_ != $filtered)) {
if (isset($filtered)) {
$param_ = $filtered;
}
 
$filtered = preg_replace("/(Content-Transfer-Encoding:|MIME-Version:|content-type:|Subject:|to:|cc:|bcc:|from:|reply-to:)/ims", '', $param_);
}
 
unset($filtered);
 
if ($level_ >= 2) {
/* replace until done */
while (!isset($filtered) || ($param_ != $filtered)) {
if (isset($filtered)) {
$param_ = $filtered;
}
 
$filtered = preg_replace("/(%0A|\\\\r|%0D|\\\\n|%00|\\\\0|%09|\\\\t|%01|%02|%03|%04|%05|%06|%07|%08|%09|%0B|%0C|%0E|%0F|%10|%11|%12|%13)/ims", '', $param_);
}
}
 
return $param_;
}
 
private function getHeaders() {
return $this->headers;
}
 
private static function mail_base64_encode($text) {
// Why 72? Seen here: http://linux.dsplabs.com.au/munpack-mime-base64-multi-part-attachment-php-perl-decode-email-pdf-p82/
return wordwrap(base64_encode($text), 72, self::endl, true);
}
 
private function headerLine($name, $value) {
// Change 2011-02-09
// LF is OK! CRLF does lead to CR+CRLF on some systems!
// http://bugs.php.net/bug.php?id=15841
// The mail() function is not talking to an SMTP server, so RFC2822 does not apply here. mail() is talking to a command line program on the local system, and it is reasonable to expect that program to require system-native line breaks.
return $this->QB_SECURE_MAIL_PARAM($name).': '.$this->QB_SECURE_MAIL_PARAM($value)."\n";
}
 
public function addHeader($name, $value) {
$this->headers .= $this->headerLine($name, $value);
}
 
public static function utf8Subject($subject) {
return '=?UTF-8?B?'.base64_encode(utf8_encode($subject)).'?=';
}
 
private function _sendMail($recipient, $subject, $message, $add_headers='') {
return @mail(
$this->QB_SECURE_MAIL_PARAM($recipient),
$this->QB_SECURE_MAIL_PARAM($subject),
$this->QB_SECURE_MAIL_PARAM($message, 1),
$this->getHeaders().$add_headers
);
}
 
public function sendMail($recipient, $subject, $message) {
return $this->_sendMail($recipient, $subject, $message, '');
}
 
// TODO: plain aus html berechnen als optional?
public function sendMailHTMLandPlainMultipart($to, $subject, $msg_html, $msg_plain) {
$boundary = uniqid('np');
 
$msg_html = $this->QB_SECURE_MAIL_PARAM($msg_html, 1);
$msg_plain = $this->QB_SECURE_MAIL_PARAM($msg_plain, 1);
 
$add_headers = $this->headerLine('MIME-Version', '1.0');
$add_headers .= $this->headerLine('Content-Type', 'multipart/alternative; boundary="'.$boundary.'"');
 
$message = "This is a MIME encoded message.";
$message .= self::endl;
$message .= self::endl;
$message .= "--" . $boundary . self::endl;
$message .= "Content-type: text/plain; charset=utf-8".self::endl;
$message .= "Content-Transfer-Encoding: base64".self::endl;
$message .= self::endl;
$message .= $this->mail_base64_encode($msg_plain); // better than wordwrap&quoted-printable because of long lines (e.g. links)
$message .= self::endl;
$message .= self::endl;
$message .= "--" . $boundary . self::endl;
$message .= "Content-type: text/html; charset=utf-8".self::endl;
$message .= "Content-Transfer-Encoding: base64".self::endl;
$message .= self::endl;
$message .= $this->mail_base64_encode($msg_html);
$message .= self::endl;
$message .= self::endl."--" . $boundary . "--";
 
return @mail(
$this->QB_SECURE_MAIL_PARAM($to),
$this->QB_SECURE_MAIL_PARAM($subject),
$message,
$this->getHeaders().$add_headers
);
}
}
/trunk/includes/SecureMailer_mastercopy.class.php
0,0 → 1,0
link /home/daniel-marschall/public_html/code/php/SecureMailer.class.phps
Property changes:
Added: svn:special
+*
\ No newline at end of property
/trunk/includes/database.inc.php
0,0 → 1,25
<?php
 
function verbinden() {
global $mysql_database, $mysql_server, $mysql_pass, $mysql_user;
global $link2;
 
$link2 = mysql_connect($mysql_server, $mysql_user, $mysql_pass);
if (!$link2) {
die('<b>Verbindung zum MySQL-Server konnte nicht hergestellt werden! ('.mysql_error().')</b>');
}
 
if (!mysql_select_db($mysql_database)) {
die('<b>Verbindung zum MySQL-Server konnte nicht hergestellt werden! ('.mysql_error().')</b>');
}
 
register_shutdown_function('trennen');
mysql_select_db($mysql_database);
}
 
function trennen() {
global $link2;
@mysql_close($link2);
}
 
?>
/trunk/includes/download_recaptcha.sh
0,0 → 1,11
#!/bin/bash
 
OLDDIR=$( pwd )
DIR=$( dirname "$0" )
 
cd "$DIR"
 
git clone https://github.com/google/recaptcha.git
 
cd "$OLDDIR"
 
Property changes:
Added: svn:executable
+*
\ No newline at end of property
Added: svn:mime-type
+text/x-sh
\ No newline at end of property
/trunk/includes/ip_functions.inc.php
0,0 → 1,61
<?php
 
/*
* IP functions
* Copyright 2015 Daniel Marschall, ViaThinkSoft
* Version 2015-10-27
*
* 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.
*/
 
function get_real_ip() {
/* Eindeutige IP Adresse erhalten, auch bei Proxies und (neu:) von SSH connections im CLI modus */
// http://lists.phpbar.de/pipermail/php/Week-of-Mon-20040322/007749.html
// Modificated by VTS
// Version: 2015-10-27
 
// TODO: ipv6
 
if (isset($_SERVER['SSH_CLIENT'])) { $ary = explode(' ', $_SERVER['SSH_CLIENT']); return $ary[0]; }
if (isset($_SERVER['SSH_CONNECTION'])) { $ary = explode(' ', $_SERVER['SSH_CONNECTION']); return $ary[0]; }
 
$client_ip = (isset($_SERVER['HTTP_CLIENT_IP'])) ? $_SERVER['HTTP_CLIENT_IP'] : '';
 
// It is not secure to use these, since they are not validated: http://www.thespanner.co.uk/2007/12/02/faking-the-unexpected/
// $x_forwarded_for = (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : '';
$x_forwarded_for = '';
 
$remote_addr = (isset($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : '';
 
if (!empty($client_ip)) {
$ip_expl = explode('.', $client_ip);
$referer = explode('.', $remote_addr);
if ($referer[0] != $ip_expl[0]) {
$ip = array_reverse($ip_expl);
$return = implode('.', $ip);
} else {
$return = $client_ip;
}
} else if (!empty($x_forwarded_for)) {
if (strstr($x_forwarded_for, ',')) {
$ip_expl = explode(',', $x_forwarded_for);
$return = end($ip_expl);
} else {
$return = $x_forwarded_for;
}
} else {
$return = $remote_addr;
}
unset ($client_ip, $x_forwarded_for, $remote_addr, $ip_expl);
return $return;
}
/trunk/includes/ip_functions_mastercopy.inc.php
0,0 → 1,0
link /home/daniel-marschall/public_html/code/php/ip_functions.inc.phps
Property changes:
Added: svn:special
+*
\ No newline at end of property
/trunk/includes/recaptcha/.git/HEAD
0,0 → 1,0
ref: refs/heads/master
/trunk/includes/recaptcha/.git/config
0,0 → 1,11
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://github.com/google/recaptcha.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
/trunk/includes/recaptcha/.git/description
0,0 → 1,0
Unnamed repository; edit this file 'description' to name the repository.
/trunk/includes/recaptcha/.git/hooks/applypatch-msg.sample
0,0 → 1,15
#!/bin/sh
#
# An example hook script to check the commit log message taken by
# applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit. The hook is
# allowed to edit the commit message file.
#
# To enable this hook, rename this file to "applypatch-msg".
 
. git-sh-setup
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
:
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/includes/recaptcha/.git/hooks/commit-msg.sample
0,0 → 1,24
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
 
# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
 
# This example catches duplicate Signed-off-by lines.
 
test "" = "$(grep '^Signed-off-by: ' "$1" |
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
echo >&2 Duplicate Signed-off-by lines.
exit 1
}
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/includes/recaptcha/.git/hooks/post-update.sample
0,0 → 1,8
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
 
exec git update-server-info
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/includes/recaptcha/.git/hooks/pre-applypatch.sample
0,0 → 1,14
#!/bin/sh
#
# An example hook script to verify what is about to be committed
# by applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-applypatch".
 
. git-sh-setup
precommit="$(git rev-parse --git-path hooks/pre-commit)"
test -x "$precommit" && exec "$precommit" ${1+"$@"}
:
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/includes/recaptcha/.git/hooks/pre-commit.sample
0,0 → 1,49
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
 
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
 
# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --bool hooks.allownonascii)
 
# Redirect output to stderr.
exec 1>&2
 
# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
 
This can cause problems if you want to work with people on other platforms.
 
To be portable it is advisable to rename the file.
 
If you know what you are doing you can disable this check using:
 
git config hooks.allownonascii true
EOF
exit 1
fi
 
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/includes/recaptcha/.git/hooks/pre-push.sample
0,0 → 1,53
#!/bin/sh
 
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local sha1> <remote ref> <remote sha1>
#
# This sample shows how to prevent push of commits where the log message starts
# with "WIP" (work in progress).
 
remote="$1"
url="$2"
 
z40=0000000000000000000000000000000000000000
 
while read local_ref local_sha remote_ref remote_sha
do
if [ "$local_sha" = $z40 ]
then
# Handle delete
:
else
if [ "$remote_sha" = $z40 ]
then
# New branch, examine all commits
range="$local_sha"
else
# Update to existing branch, examine new commits
range="$remote_sha..$local_sha"
fi
 
# Check for WIP commit
commit=`git rev-list -n 1 --grep '^WIP' "$range"`
if [ -n "$commit" ]
then
echo >&2 "Found WIP commit in $local_ref, not pushing"
exit 1
fi
fi
done
 
exit 0
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/includes/recaptcha/.git/hooks/pre-rebase.sample
0,0 → 1,169
#!/bin/sh
#
# Copyright (c) 2006, 2008 Junio C Hamano
#
# The "pre-rebase" hook is run just before "git rebase" starts doing
# its job, and can prevent the command from running by exiting with
# non-zero status.
#
# The hook is called with the following parameters:
#
# $1 -- the upstream the series was forked from.
# $2 -- the branch being rebased (or empty when rebasing the current branch).
#
# This sample shows how to prevent topic branches that are already
# merged to 'next' branch from getting rebased, because allowing it
# would result in rebasing already published history.
 
publish=next
basebranch="$1"
if test "$#" = 2
then
topic="refs/heads/$2"
else
topic=`git symbolic-ref HEAD` ||
exit 0 ;# we do not interrupt rebasing detached HEAD
fi
 
case "$topic" in
refs/heads/??/*)
;;
*)
exit 0 ;# we do not interrupt others.
;;
esac
 
# Now we are dealing with a topic branch being rebased
# on top of master. Is it OK to rebase it?
 
# Does the topic really exist?
git show-ref -q "$topic" || {
echo >&2 "No such branch $topic"
exit 1
}
 
# Is topic fully merged to master?
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
if test -z "$not_in_master"
then
echo >&2 "$topic is fully merged to master; better remove it."
exit 1 ;# we could allow it, but there is no point.
fi
 
# Is topic ever merged to next? If so you should not be rebasing it.
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
only_next_2=`git rev-list ^master ${publish} | sort`
if test "$only_next_1" = "$only_next_2"
then
not_in_topic=`git rev-list "^$topic" master`
if test -z "$not_in_topic"
then
echo >&2 "$topic is already up-to-date with master"
exit 1 ;# we could allow it, but there is no point.
else
exit 0
fi
else
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
/usr/bin/perl -e '
my $topic = $ARGV[0];
my $msg = "* $topic has commits already merged to public branch:\n";
my (%not_in_next) = map {
/^([0-9a-f]+) /;
($1 => 1);
} split(/\n/, $ARGV[1]);
for my $elem (map {
/^([0-9a-f]+) (.*)$/;
[$1 => $2];
} split(/\n/, $ARGV[2])) {
if (!exists $not_in_next{$elem->[0]}) {
if ($msg) {
print STDERR $msg;
undef $msg;
}
print STDERR " $elem->[1]\n";
}
}
' "$topic" "$not_in_next" "$not_in_master"
exit 1
fi
 
<<\DOC_END
 
This sample hook safeguards topic branches that have been
published from being rewound.
 
The workflow assumed here is:
 
* Once a topic branch forks from "master", "master" is never
merged into it again (either directly or indirectly).
 
* Once a topic branch is fully cooked and merged into "master",
it is deleted. If you need to build on top of it to correct
earlier mistakes, a new topic branch is created by forking at
the tip of the "master". This is not strictly necessary, but
it makes it easier to keep your history simple.
 
* Whenever you need to test or publish your changes to topic
branches, merge them into "next" branch.
 
The script, being an example, hardcodes the publish branch name
to be "next", but it is trivial to make it configurable via
$GIT_DIR/config mechanism.
 
With this workflow, you would want to know:
 
(1) ... if a topic branch has ever been merged to "next". Young
topic branches can have stupid mistakes you would rather
clean up before publishing, and things that have not been
merged into other branches can be easily rebased without
affecting other people. But once it is published, you would
not want to rewind it.
 
(2) ... if a topic branch has been fully merged to "master".
Then you can delete it. More importantly, you should not
build on top of it -- other people may already want to
change things related to the topic as patches against your
"master", so if you need further changes, it is better to
fork the topic (perhaps with the same name) afresh from the
tip of "master".
 
Let's look at this example:
 
o---o---o---o---o---o---o---o---o---o "next"
/ / / /
/ a---a---b A / /
/ / / /
/ / c---c---c---c B /
/ / / \ /
/ / / b---b C \ /
/ / / / \ /
---o---o---o---o---o---o---o---o---o---o---o "master"
 
 
A, B and C are topic branches.
 
* A has one fix since it was merged up to "next".
 
* B has finished. It has been fully merged up to "master" and "next",
and is ready to be deleted.
 
* C has not merged to "next" at all.
 
We would want to allow C to be rebased, refuse A, and encourage
B to be deleted.
 
To compute (1):
 
git rev-list ^master ^topic next
git rev-list ^master next
 
if these match, topic has not merged in next at all.
 
To compute (2):
 
git rev-list master..topic
 
if this is empty, it is fully merged to "master".
 
DOC_END
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/includes/recaptcha/.git/hooks/pre-receive.sample
0,0 → 1,24
#!/bin/sh
#
# An example hook script to make use of push options.
# The example simply echoes all push options that start with 'echoback='
# and rejects all pushes when the "reject" push option is used.
#
# To enable this hook, rename this file to "pre-receive".
 
if test -n "$GIT_PUSH_OPTION_COUNT"
then
i=0
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
do
eval "value=\$GIT_PUSH_OPTION_$i"
case "$value" in
echoback=*)
echo "echo from the pre-receive-hook: ${value#*=}" >&2
;;
reject)
exit 1
esac
i=$((i + 1))
done
fi
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/includes/recaptcha/.git/hooks/prepare-commit-msg.sample
0,0 → 1,36
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, rename this file to "prepare-commit-msg".
 
# This hook includes three examples. The first comments out the
# "Conflicts:" part of a merge commit.
#
# The second includes the output of "git diff --name-status -r"
# into the message, just before the "git status" output. It is
# commented because it doesn't cope with --amend or with squashed
# commits.
#
# The third example adds a Signed-off-by line to the message, that can
# still be edited. This is rarely a good idea.
 
case "$2,$3" in
merge,)
/usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
 
# ,|template,)
# /usr/bin/perl -i.bak -pe '
# print "\n" . `git diff --cached --name-status -r`
# if /^#/ && $first++ == 0' "$1" ;;
 
*) ;;
esac
 
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/includes/recaptcha/.git/hooks/update.sample
0,0 → 1,128
#!/bin/sh
#
# An example hook script to block unannotated tags from entering.
# Called by "git receive-pack" with arguments: refname sha1-old sha1-new
#
# To enable this hook, rename this file to "update".
#
# Config
# ------
# hooks.allowunannotated
# This boolean sets whether unannotated tags will be allowed into the
# repository. By default they won't be.
# hooks.allowdeletetag
# This boolean sets whether deleting tags will be allowed in the
# repository. By default they won't be.
# hooks.allowmodifytag
# This boolean sets whether a tag may be modified after creation. By default
# it won't be.
# hooks.allowdeletebranch
# This boolean sets whether deleting branches will be allowed in the
# repository. By default they won't be.
# hooks.denycreatebranch
# This boolean sets whether remotely creating branches will be denied
# in the repository. By default this is allowed.
#
 
# --- Command line
refname="$1"
oldrev="$2"
newrev="$3"
 
# --- Safety check
if [ -z "$GIT_DIR" ]; then
echo "Don't run this script from the command line." >&2
echo " (if you want, you could supply GIT_DIR then run" >&2
echo " $0 <ref> <oldrev> <newrev>)" >&2
exit 1
fi
 
if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
echo "usage: $0 <ref> <oldrev> <newrev>" >&2
exit 1
fi
 
# --- Config
allowunannotated=$(git config --bool hooks.allowunannotated)
allowdeletebranch=$(git config --bool hooks.allowdeletebranch)
denycreatebranch=$(git config --bool hooks.denycreatebranch)
allowdeletetag=$(git config --bool hooks.allowdeletetag)
allowmodifytag=$(git config --bool hooks.allowmodifytag)
 
# check for no description
projectdesc=$(sed -e '1q' "$GIT_DIR/description")
case "$projectdesc" in
"Unnamed repository"* | "")
echo "*** Project description file hasn't been set" >&2
exit 1
;;
esac
 
# --- Check types
# if $newrev is 0000...0000, it's a commit to delete a ref.
zero="0000000000000000000000000000000000000000"
if [ "$newrev" = "$zero" ]; then
newrev_type=delete
else
newrev_type=$(git cat-file -t $newrev)
fi
 
case "$refname","$newrev_type" in
refs/tags/*,commit)
# un-annotated tag
short_refname=${refname##refs/tags/}
if [ "$allowunannotated" != "true" ]; then
echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2
echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2
exit 1
fi
;;
refs/tags/*,delete)
# delete tag
if [ "$allowdeletetag" != "true" ]; then
echo "*** Deleting a tag is not allowed in this repository" >&2
exit 1
fi
;;
refs/tags/*,tag)
# annotated tag
if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1
then
echo "*** Tag '$refname' already exists." >&2
echo "*** Modifying a tag is not allowed in this repository." >&2
exit 1
fi
;;
refs/heads/*,commit)
# branch
if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
echo "*** Creating a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/heads/*,delete)
# delete branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a branch is not allowed in this repository" >&2
exit 1
fi
;;
refs/remotes/*,commit)
# tracking branch
;;
refs/remotes/*,delete)
# delete tracking branch
if [ "$allowdeletebranch" != "true" ]; then
echo "*** Deleting a tracking branch is not allowed in this repository" >&2
exit 1
fi
;;
*)
# Anything else (is there anything else?)
echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2
exit 1
;;
esac
 
# --- Finished
exit 0
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/trunk/includes/recaptcha/.git/index
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/includes/recaptcha/.git/info/exclude
0,0 → 1,6
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
/trunk/includes/recaptcha/.git/logs/HEAD
0,0 → 1,0
0000000000000000000000000000000000000000 6990961e664372ddbed7ebc1cd673da7077552e5 root <root@viathinksoft.de> 1503261208 +0200 clone: from https://github.com/google/recaptcha.git
/trunk/includes/recaptcha/.git/logs/refs/heads/master
0,0 → 1,0
0000000000000000000000000000000000000000 6990961e664372ddbed7ebc1cd673da7077552e5 root <root@viathinksoft.de> 1503261208 +0200 clone: from https://github.com/google/recaptcha.git
/trunk/includes/recaptcha/.git/logs/refs/remotes/origin/HEAD
0,0 → 1,0
0000000000000000000000000000000000000000 6990961e664372ddbed7ebc1cd673da7077552e5 root <root@viathinksoft.de> 1503261208 +0200 clone: from https://github.com/google/recaptcha.git
/trunk/includes/recaptcha/.git/objects/pack/pack-6e721fbee4b0c02dc553c0dda0ecf7d62b0893eb.idx
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/includes/recaptcha/.git/objects/pack/pack-6e721fbee4b0c02dc553c0dda0ecf7d62b0893eb.pack
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/trunk/includes/recaptcha/.git/packed-refs
0,0 → 1,8
# pack-refs with: peeled fully-peeled
6990961e664372ddbed7ebc1cd673da7077552e5 refs/remotes/origin/master
3d3e42e31e2f0bd4798d3252c6c02af42004ee50 refs/tags/1.0.0
c800b38d17fdd932978e6c8a788d493810c01a76 refs/tags/1.1.0
090585935d95ebdf2d16dd071b10c9179a94da47 refs/tags/1.1.1
2b7e00566afca82a38a1d3adb8e42c118006296e refs/tags/1.1.2
727c57fb4d77e81f85f1ea69c2dd8549180e16db refs/tags/1.1.3
^5a56d15ca10a7b75158178752b2ad8f755eb4f78
/trunk/includes/recaptcha/.git/refs/heads/master
0,0 → 1,0
6990961e664372ddbed7ebc1cd673da7077552e5
/trunk/includes/recaptcha/.git/refs/remotes/origin/HEAD
0,0 → 1,0
ref: refs/remotes/origin/master
/trunk/includes/recaptcha/.gitignore
0,0 → 1,3
/composer.lock
/nbproject/private/
/vendor/
/trunk/includes/recaptcha/.travis.yml
0,0 → 1,19
language: php
 
sudo: false
 
php:
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- hhvm
- nightly
 
before_script:
- composer install
- phpenv version-name | grep ^5.[34] && echo "extension=apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini ; true
- phpenv version-name | grep ^5.[34] && echo "apc.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini ; true
 
script:
- vendor/bin/phpunit
/trunk/includes/recaptcha/CONTRIBUTING.md
0,0 → 1,24
Want to contribute? Great! First, read this page (including the small print at the end).
 
### Before you contribute
Before we can use your code, you must sign the
[Google Individual Contributor License Agreement](https://developers.google.com/open-source/cla/individual?csw=1)
(CLA), which you can do online. The CLA is necessary mainly because you own the
copyright to your changes, even after your contribution becomes part of our
codebase, so we need your permission to use and distribute your code. We also
need to be sure of various other things—for instance that you'll tell us if you
know that your code infringes on other people's patents. You don't have to sign
the CLA until after you've submitted your code for review and a member has
approved it, but you must do it before we can put your code into our codebase.
Before you start working on a larger contribution, you should get in touch with
us first through the issue tracker with your idea so that we can help out and
possibly guide you. Coordinating up front makes it much easier to avoid
frustration later on.
 
### Code reviews
All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose.
 
### The small print
Contributions made by corporations are covered by a different agreement than
the one above, the Software Grant and Corporate Contributor License Agreement.
Property changes:
Added: svn:mime-type
+text/markdown
\ No newline at end of property
/trunk/includes/recaptcha/LICENSE
0,0 → 1,29
Copyright 2014, Google Inc.
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
 
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
 
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
/trunk/includes/recaptcha/README.md
0,0 → 1,115
# reCAPTCHA PHP client library
 
[![Build Status](https://travis-ci.org/google/recaptcha.svg)](https://travis-ci.org/google/recaptcha)
[![Latest Stable Version](https://poser.pugx.org/google/recaptcha/v/stable.svg)](https://packagist.org/packages/google/recaptcha)
[![Total Downloads](https://poser.pugx.org/google/recaptcha/downloads.svg)](https://packagist.org/packages/google/recaptcha)
 
* Project page: http://www.google.com/recaptcha/
* Repository: https://github.com/google/recaptcha
* Version: 1.1.3
* License: BSD, see [LICENSE](LICENSE)
 
## Description
 
reCAPTCHA is a free CAPTCHA service that protect websites from spam and abuse.
This is Google authored code that provides plugins for third-party integration
with reCAPTCHA.
 
## Installation
 
### Composer (Recommended)
 
[Composer](https://getcomposer.org/) is a widely used dependency manager for PHP
packages. This reCAPTCHA client is available on Packagist as
[`google/recaptcha`](https://packagist.org/packages/google/recaptcha) and can be
installed either by running the `composer require` command or adding the library
to your `composer.json`. To enable Composer for you project, refer to the
project's [Getting Started](https://getcomposer.org/doc/00-intro.md)
documentation.
 
To add this dependency using the command, run the following from within your
project directory:
```
composer require google/recaptcha "~1.1"
```
 
Alternatively, add the dependency directly to your `composer.json` file:
```json
"require": {
"google/recaptcha": "~1.1"
}
```
 
### Direct download (no Composer)
 
If you wish to install the library manually (i.e. without Composer), then you
can use the links on the main project page to either clone the repo or download
the [ZIP file](https://github.com/google/recaptcha/archive/master.zip). For
convenience, an autoloader script is provided in `src/autoload.php` which you
can require into your script instead of Composer's `vendor/autoload.php`. For
example:
 
```php
require('/path/to/recaptcha/src/autoload.php');
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
```
 
The classes in the project are structured according to the
[PSR-4](http://www.php-fig.org/psr/psr-4/) standard, so you may of course also
use your own autoloader or require the needed files directly in your code.
 
### Development install
 
If you would like to contribute to this project or run the unit tests on within
your own environment you will need to install the development dependencies, in
this case that means [PHPUnit](https://phpunit.de/). If you clone the repo and
run `composer install` from within the repo, this will also grab PHPUnit and all
its dependencies for you. If you only need the autoloader installed, then you
can always specify to Composer not to run in development mode, e.g. `composer
install --no-dev`.
 
*Note:* These dependencies are only required for development, there's no
requirement for them to be included in your production code.
 
## Usage
 
First, register keys for your site at https://www.google.com/recaptcha/admin
 
When your app receives a form submission containing the `g-recaptcha-response`
field, you can verify it using:
```php
<?php
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
$resp = $recaptcha->verify($gRecaptchaResponse, $remoteIp);
if ($resp->isSuccess()) {
// verified!
// if Domain Name Validation turned off don't forget to check hostname field
// if($resp->getHostName() === $_SERVER['SERVER_NAME']) { }
} else {
$errors = $resp->getErrorCodes();
}
```
 
You can see an end-to-end working example in
[examples/example-captcha.php](examples/example-captcha.php)
 
## Upgrading
 
### From 1.0.0
 
The previous version of this client is still available on the `1.0.0` tag [in
this repo](https://github.com/google/recaptcha/tree/1.0.0) but it is purely for
reference and will not receive any updates.
 
The major changes in 1.1.0 are:
* installation now via Composer;
* class loading also via Composer;
* classes now namespaced;
* old method call was `$rc->verifyResponse($remoteIp, $response)`, new call is
`$rc->verify($response, $remoteIp)`
 
## Contributing
 
We accept contributions via GitHub Pull Requests, but all contributors need to
be covered by the standard Google Contributor License Agreement. You can find
instructions for this in [CONTRIBUTING](CONTRIBUTING.md)
Property changes:
Added: svn:mime-type
+text/markdown
\ No newline at end of property
/trunk/includes/recaptcha/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/includes/recaptcha/examples/example-captcha.php
0,0 → 1,130
<?php
/**
* Working sample code to accompany the library. The instructions here assume
* you've just cloned the repo. If you've installed via composer, you will want
* to adjust the path to the autoloader.
*
* 1. Run the server. For example, under Linux you can probably use:
* /usr/bin/php -S "localhost:8000" "examples/example-captcha.php"
* 2. Point your browser at http://localhost:8000
* 3. Follow the instructions
*
* @copyright Copyright (c) 2015, Google Inc.
* @link http://www.google.com/recaptcha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
// Initiate the autoloader. The file should be generated by Composer.
// You will provide your own autoloader or require the files directly if you did
// not install via Composer.
require_once __DIR__ . '/../vendor/autoload.php';
 
// Register API keys at https://www.google.com/recaptcha/admin
$siteKey = '';
$secret = '';
 
// reCAPTCHA supported 40+ languages listed here: https://developers.google.com/recaptcha/docs/language
$lang = 'en';
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>reCAPTCHA Example</title>
<link rel="shortcut icon" href="//www.gstatic.com/recaptcha/admin/favicon.ico" type="image/x-icon"/>
<style type="text/css">
body {
margin: 1em 5em 0 5em;
font-family: sans-serif;
}
fieldset {
display: inline;
padding: 1em;
}
</style>
</head>
<body>
<h1>reCAPTCHA Example</h1>
<?php if ($siteKey === '' || $secret === ''): ?>
<h2>Add your keys</h2>
<p>If you do not have keys already then visit <kbd>
<a href = "https://www.google.com/recaptcha/admin">
https://www.google.com/recaptcha/admin</a></kbd> to generate them.
Edit this file and set the respective keys in <kbd>$siteKey</kbd> and
<kbd>$secret</kbd>. Reload the page after this.</p>
<?php
elseif (isset($_POST['g-recaptcha-response'])):
// The POST data here is unfiltered because this is an example.
// In production, *always* sanitise and validate your input'
?>
<h2><kbd>POST</kbd> data</h2>
<kbd><pre><?php var_export($_POST); ?></pre></kbd>
<?php
// If the form submission includes the "g-captcha-response" field
// Create an instance of the service using your secret
$recaptcha = new \ReCaptcha\ReCaptcha($secret);
 
// If file_get_contents() is locked down on your PHP installation to disallow
// its use with URLs, then you can use the alternative request method instead.
// This makes use of fsockopen() instead.
// $recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\SocketPost());
 
// Make the call to verify the response and also pass the user's IP address
$resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
 
if ($resp->isSuccess()):
// If the response is a success, that's it!
?>
<h2>Success!</h2>
<p>That's it. Everything is working. Go integrate this into your real project.</p>
<p><a href="/">Try again</a></p>
<?php
else:
// If it's not successful, then one or more error codes will be returned.
?>
<h2>Something went wrong</h2>
<p>The following error was returned: <?php
foreach ($resp->getErrorCodes() as $code) {
echo '<kbd>' , $code , '</kbd> ';
}
?></p>
<p>Check the error code reference at <kbd><a href="https://developers.google.com/recaptcha/docs/verify#error-code-reference">https://developers.google.com/recaptcha/docs/verify#error-code-reference</a></kbd>.
<p><strong>Note:</strong> Error code <kbd>missing-input-response</kbd> may mean the user just didn't complete the reCAPTCHA.</p>
<p><a href="/">Try again</a></p>
<?php
endif;
else:
// Add the g-recaptcha tag to the form you want to include the reCAPTCHA element
?>
<p>Complete the reCAPTCHA then submit the form.</p>
<form action="/" method="post">
<fieldset>
<legend>An example form</legend>
<p>Example input A: <input type="text" name="ex-a" value="foo"></p>
<p>Example input B: <input type="text" name="ex-b" value="bar"></p>
 
<div class="g-recaptcha" data-sitekey="<?php echo $siteKey; ?>"></div>
<script type="text/javascript"
src="https://www.google.com/recaptcha/api.js?hl=<?php echo $lang; ?>">
</script>
<p><input type="submit" value="Submit" /></p>
</fieldset>
</form>
<?php endif; ?>
</body>
</html>
/trunk/includes/recaptcha/phpunit.xml.dist
0,0 → 1,17
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.4/phpunit.xsd"
colors="true"
verbose="true"
bootstrap="src/autoload.php">
<testsuites>
<testsuite name="reCAPTCHA Test Suite">
<directory>tests/ReCaptcha/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/ReCaptcha/</directory>
</whitelist>
</filter>
</phpunit>
/trunk/includes/recaptcha/src/ReCaptcha/ReCaptcha.php
0,0 → 1,98
<?php
/**
* This is a PHP library that handles calling reCAPTCHA.
*
* @copyright Copyright (c) 2015, Google Inc.
* @link http://www.google.com/recaptcha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
 
namespace ReCaptcha;
 
/**
* reCAPTCHA client.
*/
class ReCaptcha
{
/**
* Version of this client library.
* @const string
*/
const VERSION = 'php_1.1.3';
 
/**
* Shared secret for the site.
* @var string
*/
private $secret;
 
/**
* Method used to communicate with service. Defaults to POST request.
* @var RequestMethod
*/
private $requestMethod;
 
/**
* Create a configured instance to use the reCAPTCHA service.
*
* @param string $secret shared secret between site and reCAPTCHA server.
* @param RequestMethod $requestMethod method used to send the request. Defaults to POST.
* @throws \RuntimeException if $secret is invalid
*/
public function __construct($secret, RequestMethod $requestMethod = null)
{
if (empty($secret)) {
throw new \RuntimeException('No secret provided');
}
 
if (!is_string($secret)) {
throw new \RuntimeException('The provided secret must be a string');
}
 
$this->secret = $secret;
 
if (!is_null($requestMethod)) {
$this->requestMethod = $requestMethod;
} else {
$this->requestMethod = new RequestMethod\Post();
}
}
 
/**
* Calls the reCAPTCHA siteverify API to verify whether the user passes
* CAPTCHA test.
*
* @param string $response The value of 'g-recaptcha-response' in the submitted form.
* @param string $remoteIp The end user's IP address.
* @return Response Response from the service.
*/
public function verify($response, $remoteIp = null)
{
// Discard empty solution submissions
if (empty($response)) {
$recaptchaResponse = new Response(false, array('missing-input-response'));
return $recaptchaResponse;
}
 
$params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION);
$rawResponse = $this->requestMethod->submit($params);
return Response::fromJson($rawResponse);
}
}
/trunk/includes/recaptcha/src/ReCaptcha/RequestMethod/Curl.php
0,0 → 1,74
<?php
/**
* This is a PHP library that handles calling reCAPTCHA.
*
* @copyright Copyright (c) 2015, Google Inc.
* @link http://www.google.com/recaptcha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
 
namespace ReCaptcha\RequestMethod;
 
/**
* Convenience wrapper around the cURL functions to allow mocking.
*/
class Curl
{
 
/**
* @see http://php.net/curl_init
* @param string $url
* @return resource cURL handle
*/
public function init($url = null)
{
return curl_init($url);
}
 
/**
* @see http://php.net/curl_setopt_array
* @param resource $ch
* @param array $options
* @return bool
*/
public function setoptArray($ch, array $options)
{
return curl_setopt_array($ch, $options);
}
 
/**
* @see http://php.net/curl_exec
* @param resource $ch
* @return mixed
*/
public function exec($ch)
{
return curl_exec($ch);
}
 
/**
* @see http://php.net/curl_close
* @param resource $ch
*/
public function close($ch)
{
curl_close($ch);
}
}
/trunk/includes/recaptcha/src/ReCaptcha/RequestMethod/CurlPost.php
0,0 → 1,88
<?php
/**
* This is a PHP library that handles calling reCAPTCHA.
*
* @copyright Copyright (c) 2015, Google Inc.
* @link http://www.google.com/recaptcha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
 
namespace ReCaptcha\RequestMethod;
 
use ReCaptcha\RequestMethod;
use ReCaptcha\RequestParameters;
 
/**
* Sends cURL request to the reCAPTCHA service.
* Note: this requires the cURL extension to be enabled in PHP
* @see http://php.net/manual/en/book.curl.php
*/
class CurlPost implements RequestMethod
{
/**
* URL to which requests are sent via cURL.
* @const string
*/
const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
 
/**
* Curl connection to the reCAPTCHA service
* @var Curl
*/
private $curl;
 
public function __construct(Curl $curl = null)
{
if (!is_null($curl)) {
$this->curl = $curl;
} else {
$this->curl = new Curl();
}
}
 
/**
* Submit the cURL request with the specified parameters.
*
* @param RequestParameters $params Request parameters
* @return string Body of the reCAPTCHA response
*/
public function submit(RequestParameters $params)
{
$handle = $this->curl->init(self::SITE_VERIFY_URL);
 
$options = array(
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $params->toQueryString(),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded'
),
CURLINFO_HEADER_OUT => false,
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => true
);
$this->curl->setoptArray($handle, $options);
 
$response = $this->curl->exec($handle);
$this->curl->close($handle);
 
return $response;
}
}
/trunk/includes/recaptcha/src/ReCaptcha/RequestMethod/Post.php
0,0 → 1,70
<?php
/**
* This is a PHP library that handles calling reCAPTCHA.
*
* @copyright Copyright (c) 2015, Google Inc.
* @link http://www.google.com/recaptcha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
 
namespace ReCaptcha\RequestMethod;
 
use ReCaptcha\RequestMethod;
use ReCaptcha\RequestParameters;
 
/**
* Sends POST requests to the reCAPTCHA service.
*/
class Post implements RequestMethod
{
/**
* URL to which requests are POSTed.
* @const string
*/
const SITE_VERIFY_URL = 'https://www.google.com/recaptcha/api/siteverify';
 
/**
* Submit the POST request with the specified parameters.
*
* @param RequestParameters $params Request parameters
* @return string Body of the reCAPTCHA response
*/
public function submit(RequestParameters $params)
{
/**
* PHP 5.6.0 changed the way you specify the peer name for SSL context options.
* Using "CN_name" will still work, but it will raise deprecated errors.
*/
$peer_key = version_compare(PHP_VERSION, '5.6.0', '<') ? 'CN_name' : 'peer_name';
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => $params->toQueryString(),
// Force the peer to validate (not needed in 5.6.0+, but still works)
'verify_peer' => true,
// Force the peer validation to use www.google.com
$peer_key => 'www.google.com',
),
);
$context = stream_context_create($options);
return file_get_contents(self::SITE_VERIFY_URL, false, $context);
}
}
/trunk/includes/recaptcha/src/ReCaptcha/RequestMethod/Socket.php
0,0 → 1,104
<?php
/**
* This is a PHP library that handles calling reCAPTCHA.
*
* @copyright Copyright (c) 2015, Google Inc.
* @link http://www.google.com/recaptcha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
 
namespace ReCaptcha\RequestMethod;
 
/**
* Convenience wrapper around native socket and file functions to allow for
* mocking.
*/
class Socket
{
private $handle = null;
 
/**
* fsockopen
*
* @see http://php.net/fsockopen
* @param string $hostname
* @param int $port
* @param int $errno
* @param string $errstr
* @param float $timeout
* @return resource
*/
public function fsockopen($hostname, $port = -1, &$errno = 0, &$errstr = '', $timeout = null)
{
$this->handle = fsockopen($hostname, $port, $errno, $errstr, (is_null($timeout) ? ini_get("default_socket_timeout") : $timeout));
 
if ($this->handle != false && $errno === 0 && $errstr === '') {
return $this->handle;
}
return false;
}
 
/**
* fwrite
*
* @see http://php.net/fwrite
* @param string $string
* @param int $length
* @return int | bool
*/
public function fwrite($string, $length = null)
{
return fwrite($this->handle, $string, (is_null($length) ? strlen($string) : $length));
}
 
/**
* fgets
*
* @see http://php.net/fgets
* @param int $length
* @return string
*/
public function fgets($length = null)
{
return fgets($this->handle, $length);
}
 
/**
* feof
*
* @see http://php.net/feof
* @return bool
*/
public function feof()
{
return feof($this->handle);
}
 
/**
* fclose
*
* @see http://php.net/fclose
* @return bool
*/
public function fclose()
{
return fclose($this->handle);
}
}
/trunk/includes/recaptcha/src/ReCaptcha/RequestMethod/SocketPost.php
0,0 → 1,121
<?php
/**
* This is a PHP library that handles calling reCAPTCHA.
*
* @copyright Copyright (c) 2015, Google Inc.
* @link http://www.google.com/recaptcha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
 
namespace ReCaptcha\RequestMethod;
 
use ReCaptcha\RequestMethod;
use ReCaptcha\RequestParameters;
 
/**
* Sends a POST request to the reCAPTCHA service, but makes use of fsockopen()
* instead of get_file_contents(). This is to account for people who may be on
* servers where allow_url_open is disabled.
*/
class SocketPost implements RequestMethod
{
/**
* reCAPTCHA service host.
* @const string
*/
const RECAPTCHA_HOST = 'www.google.com';
 
/**
* @const string reCAPTCHA service path
*/
const SITE_VERIFY_PATH = '/recaptcha/api/siteverify';
 
/**
* @const string Bad request error
*/
const BAD_REQUEST = '{"success": false, "error-codes": ["invalid-request"]}';
 
/**
* @const string Bad response error
*/
const BAD_RESPONSE = '{"success": false, "error-codes": ["invalid-response"]}';
 
/**
* Socket to the reCAPTCHA service
* @var Socket
*/
private $socket;
 
/**
* Constructor
*
* @param \ReCaptcha\RequestMethod\Socket $socket optional socket, injectable for testing
*/
public function __construct(Socket $socket = null)
{
if (!is_null($socket)) {
$this->socket = $socket;
} else {
$this->socket = new Socket();
}
}
 
/**
* Submit the POST request with the specified parameters.
*
* @param RequestParameters $params Request parameters
* @return string Body of the reCAPTCHA response
*/
public function submit(RequestParameters $params)
{
$errno = 0;
$errstr = '';
 
if (false === $this->socket->fsockopen('ssl://' . self::RECAPTCHA_HOST, 443, $errno, $errstr, 30)) {
return self::BAD_REQUEST;
}
 
$content = $params->toQueryString();
 
$request = "POST " . self::SITE_VERIFY_PATH . " HTTP/1.1\r\n";
$request .= "Host: " . self::RECAPTCHA_HOST . "\r\n";
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
$request .= "Content-length: " . strlen($content) . "\r\n";
$request .= "Connection: close\r\n\r\n";
$request .= $content . "\r\n\r\n";
 
$this->socket->fwrite($request);
$response = '';
 
while (!$this->socket->feof()) {
$response .= $this->socket->fgets(4096);
}
 
$this->socket->fclose();
 
if (0 !== strpos($response, 'HTTP/1.1 200 OK')) {
return self::BAD_RESPONSE;
}
 
$parts = preg_split("#\n\s*\n#Uis", $response);
 
return $parts[1];
}
}
/trunk/includes/recaptcha/src/ReCaptcha/RequestMethod.php
0,0 → 1,42
<?php
/**
* This is a PHP library that handles calling reCAPTCHA.
*
* @copyright Copyright (c) 2015, Google Inc.
* @link http://www.google.com/recaptcha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
 
namespace ReCaptcha;
 
/**
* Method used to send the request to the service.
*/
interface RequestMethod
{
 
/**
* Submit the request with the specified parameters.
*
* @param RequestParameters $params Request parameters
* @return string Body of the reCAPTCHA response
*/
public function submit(RequestParameters $params);
}
/trunk/includes/recaptcha/src/ReCaptcha/RequestParameters.php
0,0 → 1,103
<?php
/**
* This is a PHP library that handles calling reCAPTCHA.
*
* @copyright Copyright (c) 2015, Google Inc.
* @link http://www.google.com/recaptcha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
 
namespace ReCaptcha;
 
/**
* Stores and formats the parameters for the request to the reCAPTCHA service.
*/
class RequestParameters
{
/**
* Site secret.
* @var string
*/
private $secret;
 
/**
* Form response.
* @var string
*/
private $response;
 
/**
* Remote user's IP address.
* @var string
*/
private $remoteIp;
 
/**
* Client version.
* @var string
*/
private $version;
 
/**
* Initialise parameters.
*
* @param string $secret Site secret.
* @param string $response Value from g-captcha-response form field.
* @param string $remoteIp User's IP address.
* @param string $version Version of this client library.
*/
public function __construct($secret, $response, $remoteIp = null, $version = null)
{
$this->secret = $secret;
$this->response = $response;
$this->remoteIp = $remoteIp;
$this->version = $version;
}
 
/**
* Array representation.
*
* @return array Array formatted parameters.
*/
public function toArray()
{
$params = array('secret' => $this->secret, 'response' => $this->response);
 
if (!is_null($this->remoteIp)) {
$params['remoteip'] = $this->remoteIp;
}
 
if (!is_null($this->version)) {
$params['version'] = $this->version;
}
 
return $params;
}
 
/**
* Query string representation for HTTP request.
*
* @return string Query string formatted parameters.
*/
public function toQueryString()
{
return http_build_query($this->toArray(), '', '&');
}
}
/trunk/includes/recaptcha/src/ReCaptcha/Response.php
0,0 → 1,122
<?php
/**
* This is a PHP library that handles calling reCAPTCHA.
*
* @copyright Copyright (c) 2015, Google Inc.
* @link http://www.google.com/recaptcha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
 
namespace ReCaptcha;
 
/**
* The response returned from the service.
*/
class Response
{
/**
* Success or failure.
* @var boolean
*/
private $success = false;
 
/**
* Error code strings.
* @var array
*/
private $errorCodes = array();
 
/**
* The hostname of the site where the reCAPTCHA was solved.
* @var string
*/
private $hostname;
 
/**
* Build the response from the expected JSON returned by the service.
*
* @param string $json
* @return \ReCaptcha\Response
*/
public static function fromJson($json)
{
$responseData = json_decode($json, true);
 
if (!$responseData) {
return new Response(false, array('invalid-json'));
}
 
$hostname = isset($responseData['hostname']) ? $responseData['hostname'] : null;
 
if (isset($responseData['success']) && $responseData['success'] == true) {
return new Response(true, array(), $hostname);
}
 
if (isset($responseData['error-codes']) && is_array($responseData['error-codes'])) {
return new Response(false, $responseData['error-codes'], $hostname);
}
 
return new Response(false, array(), $hostname);
}
 
/**
* Constructor.
*
* @param boolean $success
* @param array $errorCodes
* @param string $hostname
*/
public function __construct($success, array $errorCodes = array(), $hostname = null)
{
$this->success = $success;
$this->errorCodes = $errorCodes;
$this->hostname = $hostname;
}
 
/**
* Is success?
*
* @return boolean
*/
public function isSuccess()
{
return $this->success;
}
 
/**
* Get error codes.
*
* @return array
*/
public function getErrorCodes()
{
return $this->errorCodes;
}
 
/**
* Get hostname.
*
* @return string
*/
public function getHostname()
{
return $this->hostname;
}
}
/trunk/includes/recaptcha/src/autoload.php
0,0 → 1,38
<?php
 
/* An autoloader for ReCaptcha\Foo classes. This should be required()
* by the user before attempting to instantiate any of the ReCaptcha
* classes.
*/
 
spl_autoload_register(function ($class) {
if (substr($class, 0, 10) !== 'ReCaptcha\\') {
/* If the class does not lie under the "ReCaptcha" namespace,
* then we can exit immediately.
*/
return;
}
 
/* All of the classes have names like "ReCaptcha\Foo", so we need
* to replace the backslashes with frontslashes if we want the
* name to map directly to a location in the filesystem.
*/
$class = str_replace('\\', '/', $class);
 
/* First, check under the current directory. It is important that
* we look here first, so that we don't waste time searching for
* test classes in the common case.
*/
$path = dirname(__FILE__).'/'.$class.'.php';
if (is_readable($path)) {
require_once $path;
}
 
/* If we didn't find what we're looking for already, maybe it's
* a test class?
*/
$path = dirname(__FILE__).'/../tests/'.$class.'.php';
if (is_readable($path)) {
require_once $path;
}
});
/trunk/includes/recaptcha/tests/ReCaptcha/ReCaptchaTest.php
0,0 → 1,75
<?php
/**
* This is a PHP library that handles calling reCAPTCHA.
*
* @copyright Copyright (c) 2015, Google Inc.
* @link http://www.google.com/recaptcha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
 
namespace ReCaptcha;
 
class ReCaptchaTest extends \PHPUnit_Framework_TestCase
{
 
/**
* @expectedException \RuntimeException
* @dataProvider invalidSecretProvider
*/
public function testExceptionThrownOnInvalidSecret($invalid)
{
$rc = new ReCaptcha($invalid);
}
 
public function invalidSecretProvider()
{
return array(
array(''),
array(null),
array(0),
array(new \stdClass()),
array(array()),
);
}
 
public function testVerifyReturnsErrorOnMissingResponse()
{
$rc = new ReCaptcha('secret');
$response = $rc->verify('');
$this->assertFalse($response->isSuccess());
$this->assertEquals(array('missing-input-response'), $response->getErrorCodes());
}
 
public function testVerifyReturnsResponse()
{
$method = $this->getMock('\\ReCaptcha\\RequestMethod', array('submit'));
$method->expects($this->once())
->method('submit')
->with($this->callback(function ($params) {
 
return true;
}))
->will($this->returnValue('{"success": true}'));
;
$rc = new ReCaptcha('secret', $method);
$response = $rc->verify('response');
$this->assertTrue($response->isSuccess());
}
}
/trunk/includes/recaptcha/tests/ReCaptcha/RequestMethod/CurlPostTest.php
0,0 → 1,63
<?php
/**
* This is a PHP library that handles calling reCAPTCHA.
*
* @copyright Copyright (c) 2015, Google Inc.
* @link http://www.google.com/recaptcha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
 
namespace ReCaptcha\RequestMethod;
 
use \ReCaptcha\RequestParameters;
 
class CurlPostTest extends \PHPUnit_Framework_TestCase
{
 
protected function setUp()
{
if (!extension_loaded('curl')) {
$this->markTestSkipped(
'The cURL extension is not available.'
);
}
}
 
public function testSubmit()
{
$curl = $this->getMock('\\ReCaptcha\\RequestMethod\\Curl',
array('init', 'setoptArray', 'exec', 'close'));
$curl->expects($this->once())
->method('init')
->willReturn(new \stdClass);
$curl->expects($this->once())
->method('setoptArray')
->willReturn(true);
$curl->expects($this->once())
->method('exec')
->willReturn('RESPONSEBODY');
$curl->expects($this->once())
->method('close');
 
$pc = new CurlPost($curl);
$response = $pc->submit(new RequestParameters("secret", "response"));
$this->assertEquals('RESPONSEBODY', $response);
}
}
/trunk/includes/recaptcha/tests/ReCaptcha/RequestMethod/PostTest.php
0,0 → 1,118
<?php
/**
* This is a PHP library that handles calling reCAPTCHA.
*
* @copyright Copyright (c) 2015, Google Inc.
* @link http://www.google.com/recaptcha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
 
namespace ReCaptcha\RequestMethod;
 
use ReCaptcha\RequestParameters;
 
class PostTest extends \PHPUnit_Framework_TestCase
{
public static $assert = null;
protected $parameters = null;
protected $runcount = 0;
 
public function setUp()
{
$this->parameters = new RequestParameters("secret", "response", "remoteip", "version");
}
 
public function tearDown()
{
self::$assert = null;
}
 
public function testHTTPContextOptions()
{
$req = new Post();
self::$assert = array($this, "httpContextOptionsCallback");
$req->submit($this->parameters);
$this->assertEquals(1, $this->runcount, "The assertion was ran");
}
 
public function testSSLContextOptions()
{
$req = new Post();
self::$assert = array($this, "sslContextOptionsCallback");
$req->submit($this->parameters);
$this->assertEquals(1, $this->runcount, "The assertion was ran");
}
 
public function httpContextOptionsCallback(array $args)
{
$this->runcount++;
$this->assertCommonOptions($args);
 
$options = stream_context_get_options($args[2]);
$this->assertArrayHasKey('http', $options);
 
$this->assertArrayHasKey('method', $options['http']);
$this->assertEquals("POST", $options['http']['method']);
 
$this->assertArrayHasKey('content', $options['http']);
$this->assertEquals($this->parameters->toQueryString(), $options['http']['content']);
 
$this->assertArrayHasKey('header', $options['http']);
$headers = array(
"Content-type: application/x-www-form-urlencoded",
);
foreach ($headers as $header) {
$this->assertContains($header, $options['http']['header']);
}
}
 
public function sslContextOptionsCallback(array $args)
{
$this->runcount++;
$this->assertCommonOptions($args);
 
$options = stream_context_get_options($args[2]);
$this->assertArrayHasKey('http', $options);
$this->assertArrayHasKey('verify_peer', $options['http']);
$this->assertTrue($options['http']['verify_peer']);
 
$key = version_compare(PHP_VERSION, "5.6.0", "<") ? "CN_name" : "peer_name";
 
$this->assertArrayHasKey($key, $options['http']);
$this->assertEquals("www.google.com", $options['http'][$key]);
}
 
protected function assertCommonOptions(array $args)
{
$this->assertCount(3, $args);
$this->assertStringStartsWith("https://www.google.com/", $args[0]);
$this->assertFalse($args[1]);
$this->assertTrue(is_resource($args[2]), "The context options should be a resource");
}
}
 
function file_get_contents()
{
if (PostTest::$assert) {
return call_user_func(PostTest::$assert, func_get_args());
}
// Since we can't represent maxlen in userland...
return call_user_func_array('file_get_contents', func_get_args());
}
/trunk/includes/recaptcha/tests/ReCaptcha/RequestMethod/SocketPostTest.php
0,0 → 1,90
<?php
/**
* This is a PHP library that handles calling reCAPTCHA.
*
* @copyright Copyright (c) 2015, Google Inc.
* @link http://www.google.com/recaptcha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
 
namespace ReCaptcha\RequestMethod;
 
use ReCaptcha\RequestParameters;
 
class SocketPostTest extends \PHPUnit_Framework_TestCase
{
 
public function testSubmitSuccess()
{
$socket = $this->getMock('\\ReCaptcha\\RequestMethod\\Socket', array('fsockopen', 'fwrite', 'fgets', 'feof', 'fclose'));
$socket->expects($this->once())
->method('fsockopen')
->willReturn(true);
$socket->expects($this->once())
->method('fwrite');
$socket->expects($this->once())
->method('fgets')
->willReturn("HTTP/1.1 200 OK\n\nRESPONSEBODY");
$socket->expects($this->exactly(2))
->method('feof')
->will($this->onConsecutiveCalls(false, true));
$socket->expects($this->once())
->method('fclose')
->willReturn(true);
 
$ps = new SocketPost($socket);
$response = $ps->submit(new RequestParameters("secret", "response", "remoteip", "version"));
$this->assertEquals('RESPONSEBODY', $response);
}
 
public function testSubmitBadResponse()
{
$socket = $this->getMock('\\ReCaptcha\\RequestMethod\\Socket', array('fsockopen', 'fwrite', 'fgets', 'feof', 'fclose'));
$socket->expects($this->once())
->method('fsockopen')
->willReturn(true);
$socket->expects($this->once())
->method('fwrite');
$socket->expects($this->once())
->method('fgets')
->willReturn("HTTP/1.1 500 NOPEn\\nBOBBINS");
$socket->expects($this->exactly(2))
->method('feof')
->will($this->onConsecutiveCalls(false, true));
$socket->expects($this->once())
->method('fclose')
->willReturn(true);
 
$ps = new SocketPost($socket);
$response = $ps->submit(new RequestParameters("secret", "response", "remoteip", "version"));
$this->assertEquals(SocketPost::BAD_RESPONSE, $response);
}
 
public function testSubmitBadRequest()
{
$socket = $this->getMock('\\ReCaptcha\\RequestMethod\\Socket', array('fsockopen'));
$socket->expects($this->once())
->method('fsockopen')
->willReturn(false);
$ps = new SocketPost($socket);
$response = $ps->submit(new RequestParameters("secret", "response", "remoteip", "version"));
$this->assertEquals(SocketPost::BAD_REQUEST, $response);
}
}
/trunk/includes/recaptcha/tests/ReCaptcha/RequestParametersTest.php
0,0 → 1,61
<?php
/**
* This is a PHP library that handles calling reCAPTCHA.
*
* @copyright Copyright (c) 2015, Google Inc.
* @link http://www.google.com/recaptcha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
 
namespace ReCaptcha;
 
class RequestParametersTest extends \PHPUnit_Framework_TestCase
{
 
public function provideValidData()
{
return array(
array('SECRET', 'RESPONSE', 'REMOTEIP', 'VERSION',
array('secret' => 'SECRET', 'response' => 'RESPONSE', 'remoteip' => 'REMOTEIP', 'version' => 'VERSION'),
'secret=SECRET&response=RESPONSE&remoteip=REMOTEIP&version=VERSION'),
array('SECRET', 'RESPONSE', null, null,
array('secret' => 'SECRET', 'response' => 'RESPONSE'),
'secret=SECRET&response=RESPONSE'),
);
}
 
/**
* @dataProvider provideValidData
*/
public function testToArray($secret, $response, $remoteIp, $version, $expectedArray, $expectedQuery)
{
$params = new RequestParameters($secret, $response, $remoteIp, $version);
$this->assertEquals($params->toArray(), $expectedArray);
}
 
/**
* @dataProvider provideValidData
*/
public function testToQueryString($secret, $response, $remoteIp, $version, $expectedArray, $expectedQuery)
{
$params = new RequestParameters($secret, $response, $remoteIp, $version);
$this->assertEquals($params->toQueryString(), $expectedQuery);
}
}
/trunk/includes/recaptcha/tests/ReCaptcha/ResponseTest.php
0,0 → 1,84
<?php
/**
* This is a PHP library that handles calling reCAPTCHA.
*
* @copyright Copyright (c) 2015, Google Inc.
* @link http://www.google.com/recaptcha
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
 
namespace ReCaptcha;
 
class ResponseTest extends \PHPUnit_Framework_TestCase
{
 
/**
* @dataProvider provideJson
*/
public function testFromJson($json, $success, $errorCodes, $hostname)
{
$response = Response::fromJson($json);
$this->assertEquals($success, $response->isSuccess());
$this->assertEquals($errorCodes, $response->getErrorCodes());
$this->assertEquals($hostname, $response->getHostname());
}
 
public function provideJson()
{
return array(
array('{"success": true}', true, array(), null),
array('{"success": true, "hostname": "google.com"}', true, array(), 'google.com'),
array('{"success": false, "error-codes": ["test"]}', false, array('test'), null),
array('{"success": false, "error-codes": ["test"], "hostname": "google.com"}', false, array('test'), 'google.com'),
array('{"success": true, "error-codes": ["test"]}', true, array(), null),
array('{"success": true, "error-codes": ["test"], "hostname": "google.com"}', true, array(), 'google.com'),
array('{"success": false}', false, array(), null),
array('{"success": false, "hostname": "google.com"}', false, array(), 'google.com'),
array('BAD JSON', false, array('invalid-json'), null),
);
}
 
public function testIsSuccess()
{
$response = new Response(true);
$this->assertTrue($response->isSuccess());
 
$response = new Response(false);
$this->assertFalse($response->isSuccess());
 
$response = new Response(true, array(), 'example.com');
$this->assertEquals('example.com', $response->getHostName());
}
 
public function testGetErrorCodes()
{
$errorCodes = array('test');
$response = new Response(true, $errorCodes);
$this->assertEquals($errorCodes, $response->getErrorCodes());
}
 
public function testGetHostname()
{
$hostname = 'google.com';
$errorCodes = array();
$response = new Response(true, $errorCodes, $hostname);
$this->assertEquals($hostname, $response->getHostname());
}
}
/trunk/index.php
0,0 → 1,778
<?php
 
# ViaThinkSoft PHP Guestbook 2.8.1
# (C) 2003-2017 ViaThinkSoft, Daniel Marschall
# Licensed under GPL v3
 
// Version des Gästebuchs
$version = '2.8.1';
 
if (!file_exists(__DIR__ . '/config/config.inc.php')) {
die('ERROR: File <b>config/config.inc.php</b> does not exist. Please create it using <b>config/config.original.inc.php</b>');
}
require_once __DIR__ . '/config/config.inc.php';
 
if (!isset($cfg_recaptcha_enabled)) $cfg_recaptcha_enabled = false;
if ($cfg_recaptcha_enabled) $cfg_feature_simple_antispam = false;
if (!isset($cfg_icq_statusicon)) $cfg_icq_statusicon = 5;
 
require_once __DIR__ . '/includes/database.inc.php';
verbinden();
 
require_once __DIR__ . '/includes/SecureMailer.class.php';
require_once __DIR__ . '/includes/ip_functions.inc.php';
 
if ($cfg_recaptcha_enabled) {
require_once __DIR__ . '/includes/recaptcha/src/autoload.php';
}
 
# ------------------------------
 
// Funktion zum sichern von E-Mail-Adressen
// $crypt_linktext = 0
// --> geeignet für <img>-links, da $linktext nicht in ASCII übersetzt wird!
// $crypt_linktext = 1
// --> geeignet für text-links für höhere Sicherheit
 
function secure_email($email, $linktext, $crypt_linktext) {
$aus = '';
if ($email != '') {
$aus .= '<script language="JavaScript" type="text/javascript">
<!--
document.write("<a href=\"");'."\n";
 
$gesamttext = 'mailto:'.$email;
for ($i=0; $i<strlen($gesamttext); $i++) {
$aus .= ' document.write("&#'.ord(substr($gesamttext, $i, 1)).';");'."\n";
}
 
$aus .= ' document.write("\">");'."\n";
 
if ($crypt_linktext == '1') {
$gesamttext = $linktext;
for ($i=0; $i<strlen($gesamttext); $i++) {
$aus .= ' document.write("&#'.ord(substr($gesamttext, $i, 1)).';");'."\n";
}
} else {
$gesamttext = str_replace('"', '\"', $linktext);
$aus .= ' document.write("'.$gesamttext.'");';
}
 
$aus .= ' document.write("<\/a>");
// -->
</script>';
}
 
return $aus;
}
 
function myhtmlentities($nachricht) {
global $charset;
return htmlentities($nachricht, ENT_COMPAT | ENT_XHTML, $charset);
}
 
function parse_html($nachricht, $loc_dir = '') {
global $table_smileys;
 
// Smiley pre-parsing
$uid = uniqid();
$result = mysql_query("SELECT `zeichen`, `image`, `beschreibung`, `id` FROM `".mysql_real_escape_string($table_smileys)."` WHERE `enabled` = '1' ORDER BY `id` ASC");
while ($row = mysql_fetch_object($result)) {
# $nachricht = str_replace($row->zeichen, '<img src="images/smileys/'.$row->image.'" alt="'.myhtmlentities($row->beschreibung).'" title="'.myhtmlentities($row->beschreibung).'" />', $nachricht);
$nachricht = str_replace($row->zeichen, "\nSMILEY${uid}:".$row->id.":${uid}YELIMS\n", $nachricht);
}
 
// HTML Parsing
$nachricht = myhtmlentities($nachricht);
# Damit funktioniert wordwrap() nicht gescheit, was für den Mailverkehr wichtig ist. außerdem gibt es dann keinen umbruch in der voransicht
# $nachricht = str_replace(' ', '&nbsp;', $nachricht);
# TODO: man sollte ' '->&nbsp; erst ersetzen, wenn es mehr als 1 leerzeichen ist
$nachricht = nl2br($nachricht);
$nachricht = str_replace('<br>', '<br />', $nachricht); // to be sure
$nachricht = str_replace('<BR>', '<br />', $nachricht); // to be sure
 
// Linkanalyse von phpBB
$nachricht = ' ' . $nachricht;
$nachricht = preg_replace("#([\t\r\n ])([a-z0-9]+?){1}://([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)#i", '\1<a href="\2://\3" target="_blank">\2://\3</a>', $nachricht);
$nachricht = preg_replace("#([\t\r\n ])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)#i", '\1<a href="http://\2.\3" target="_blank">\2.\3</a>', $nachricht);
$nachricht = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $nachricht);
$nachricht = substr($nachricht, 1);
 
// Final smiley parsing
$result = mysql_query("SELECT `zeichen`, `image`, `beschreibung`, `id` FROM `".mysql_real_escape_string($table_smileys)."` WHERE `enabled` = '1' ORDER BY `id` ASC");
while ($row = mysql_fetch_object($result)) {
$nachricht = str_replace("<br />\nSMILEY${uid}:".$row->id.":${uid}YELIMS<br />\n", '<img src="'.$loc_dir.'images/smileys/'.$row->image.'" alt="'.myhtmlentities($row->beschreibung).'" title="'.myhtmlentities($row->beschreibung).'" />', $nachricht);
}
 
return $nachricht;
}
 
function anznachricht($name, $ort, $email, $home, $icq, $nachricht, $kommentar, $zeit, $datum) {
global $farbe1, $farbe2, $farbe3, $farbe4, $farbe5, $farbe6, $farbe7, $farbe8, $farbe9, $farbe10, $farbe11, $this_dir, $cfg_icq_statusicon;
 
$zzeit = explode(":", $zeit);
$zzeit = $zzeit[0].".".$zzeit[1];
$ddatum = explode("-", $datum);
$ddatum = $ddatum[2].".".$ddatum[1].".".$ddatum[0];
$nachricht = parse_html($nachricht, $this_dir);
 
echo '<table border="1" cellpadding="5" cellspacing="0" width="100%" style="border-color:'.$farbe1.';border-collapse:collapse">';
echo ' <tr>';
echo ' <td width="100%" bgcolor="'.$farbe3.'" style="border-color:'.$farbe1.';border-collapse:collapse">';
echo ' <table border="0" cellpadding="0" cellspacing="0" width="100%" style="color:'.$farbe9.'">';
echo ' <tr>';
echo ' <td width="75%" align="left"><b>'.myhtmlentities($name).'</b>';
if ($ort != '') echo ' aus '.myhtmlentities($ort);
echo '</td>';
echo ' <td width="5%">&nbsp;</td>';
echo ' <td width="20%" align="right">';
if ($email != '') {
echo secure_email(myhtmlentities($email), '<img src="images/email.gif" border="0" height="18" width="17" alt="E-Mail-Adresse" title="E-Mail-Adresse" />', 0);
}
if ($home != '') {
echo ' <a href="'.myhtmlentities($home).'" target="_blank"><img src="images/homepage.gif" border="0" height="18" width="16" alt="Homepage" title="Homepage" /></a>';
}
if ($icq != '') {
echo ' <a href="https://icq.com/people/'.urlencode($icq).'" target="_blank"><img src="https://status.icq.com/online.gif?icq='.urlencode($icq).'&amp;img='.$cfg_icq_statusicon.'" alt="Mein ICQ Status" title="Mein ICQ Status" border="0"></a></a>';
}
echo '</td></tr></table></td></tr>';
echo '<tr><td width="100%" bgcolor="'.$farbe2.'" style="color:'.$farbe10.'" align="left">'.$nachricht.'<br /><br /><font size="2" color="'.$farbe4.'">Dieser Eintrag wurde am '.$ddatum.' um '.$zzeit.' Uhr erstellt.</font></td></tr>';
if ($kommentar != '') {
$kommentar = parse_html($kommentar, $this_dir);
echo '<tr><td width="100%" bgcolor="'.$farbe5.'" style="color:'.$farbe11.'" align="left"><b>Kommentar des Seiteneigent&uuml;mers:</b><br /><br />'.$kommentar.'</td></tr>';
}
echo '</table><br />';
}
 
# --------------------------
 
# http://stackoverflow.com/questions/1175096/how-to-find-out-if-you-are-using-https-without-serverhttps
$is_https = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443);
 
$proto = $is_https ? 'https' : 'http';
$inphp = $proto.'://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];
$this_dir = dirname($inphp).'/';
 
$seitenkopf = str_replace('{CHARSET}', $charset, $seitenkopf);
echo $seitenkopf;
 
// Vor der Vorschau alles prüfen
$err_name = false;
$err_nachricht = false;
$err_icq = false;
$err_email = false;
$err_homepage = false;
$err_antispam = false;
$relfehler = '';
 
$view_vorschau = isset($_REQUEST['action']) && ($_REQUEST['action'] == 'vorschau');
$view_abschicken = isset($_REQUEST['action']) && ($_REQUEST['action'] == 'abschicken');
$view_eintrag = isset($_REQUEST['action']) && ($_REQUEST['action'] == 'eintrag');
$view_freischalten = isset($_REQUEST['action']) && ($_REQUEST['action'] == 'freischalten');
 
$name = (isset($_POST['name']) ? trim($_POST['name']) : '');
$ort = (isset($_POST['ort']) ? trim($_POST['ort']) : '');
$email = (isset($_POST['email']) ? trim($_POST['email']) : '');
$homepage = (isset($_POST['homepage']) ? trim($_POST['homepage']) : '');
$icq = (isset($_POST['icq']) ? trim($_POST['icq']) : '');
$nachricht = (isset($_POST['nachricht']) ? trim($_POST['nachricht']) : '');
$antispam = (isset($_POST['antispam']) ? trim($_POST['antispam']) : '');
$kommentar = '';
 
$icq = str_replace('-', '', $icq); // XXX-XXX-XXX -> XXXXXXXXX
 
# -----------------------------------
 
function md5_valid($id, $md5_message) {
global $table_entries;
return md5($table_entries.'-'.$id.'-'.$md5_message.'-GBINT');
}
 
# -----------------------------------
 
if ($view_freischalten) {
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : '';
$md5 = isset($_REQUEST['md5']) ? $_REQUEST['md5'] : '';
 
echo '<h1>G&auml;stebucheintrag freischalten</h1>';
 
if (($id == '') || ($md5 == '')) {
die('<p><font color="'.$farbe6.'">Ein Fehler ist aufgetreten. Fehler in den Parametern.</font></p>'.$seitenfuss);
}
 
$result = mysql_query("SELECT `show`, MD5(`nachricht`) AS `md5` FROM `".mysql_real_escape_string($table_entries)."` WHERE `id` = '".mysql_real_escape_string($id)."'");
$row = mysql_fetch_array($result);
if ($row['show'] == 1) {
echo '<p><font color="'.$farbe8.'">Eintrag ist bereits freigeschaltet!</font></p>';
} else {
$md5_valid = md5_valid($id, $row['md5']);
if (strtolower($md5) == strtolower($md5_valid)) {
mysql_query("UPDATE `".mysql_real_escape_string($table_entries)."` SET `show` = '1' WHERE `id` = '".mysql_real_escape_string($id)."'");
echo '<p><font color="'.$farbe8.'">Eintrag erfolgreich freigeschaltet!</font></p>';
} else {
echo '<p><font color="'.$farbe6.'">Keine Berechtigung, den Eintrag freizuschalten!</font></p>';
}
}
 
die($seitenfuss);
}
 
if ($cfg_feature_simple_antispam) {
// NG: erster block der IP adresse hinzufügen
$antispam_awaiting = (date('d')-15) * (2+date('m')) * 2 + 1337 + date('Y');
}
 
if (($view_vorschau) || ($view_abschicken)) {
// Name prüfen
if ($name == '') $err_name = true;
 
// Nachricht prüfen
if ($nachricht == '') $err_nachricht = true;
 
// ICQ prüfen, wenn angegeben
if ((!preg_match('/^[0-9]+$/', $icq)) && ($icq != '')) $err_icq = true;
 
// E-Mail-Adresse prüfen, wenn angegeben
if ((!preg_match('/^[a-z0-9\.\-_\+]+@[a-z0-9\-_]+\.([a-z0-9\-_]+\.)*?[a-z]+$/is', $email)) && ($email != '')) $err_email = true;
 
// Homepage prüfen, wenn angegeben
if ($homepage != '') {
if (!preg_match('#^http[s]?:\/\/#i', $homepage)) {
$homepage = 'http://' . $homepage;
}
if (!preg_match('#^http[s]?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $homepage)) {
$err_homepage = true;
}
}
 
// AntiSpam prüfen
if (($cfg_feature_simple_antispam) && ($antispam != $antispam_awaiting)) $err_antispam = true;
 
// Fehler?
if (($err_name) || ($err_nachricht) || ($err_icq) || ($err_email) || ($err_homepage) || ($err_antispam)) {
$relfehler = '<font color="'.$farbe6.'"><u>Fehler</u>: Es wurden nicht alle Pflichtfelder ausgef&uuml;llt oder einige Felder enthalten einen Fehler!</font>';
}
 
if (!$relfehler) {
$datum = date('Y-m-d');
$zeit = date('H:i:s');
$ip = get_real_ip(); // $_SERVER['REMOTE_ADDR'];
$host = gethostbyaddr($ip);
$whois_service = "https://whois.viathinksoft.de/whois/$ip";
 
if ($view_vorschau) {
echo '<h1>G&auml;stebucheintrag Vorschau</h1>';
echo '<div align="center">';
 
anznachricht($name, $ort, $email, $homepage, $icq, $nachricht, $kommentar, $zeit, $datum);
 
echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr>\n";
 
echo "<td>\n";
echo "<form action=\"$inphp\" method=\"post\" name=\"frm2\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"eintrag\" />\n";
echo "<input type=\"hidden\" name=\"name\" value=\"".myhtmlentities($name)."\" />\n";
echo "<input type=\"hidden\" name=\"ort\" value=\"".myhtmlentities($ort)."\" />\n";
echo "<input type=\"hidden\" name=\"email\" value=\"".myhtmlentities($email)."\" />\n";
echo "<input type=\"hidden\" name=\"homepage\" value=\"".myhtmlentities($homepage)."\" />\n";
echo "<input type=\"hidden\" name=\"icq\" value=\"".myhtmlentities($icq)."\" />\n";
echo "<input type=\"hidden\" name=\"nachricht\" value=\"".myhtmlentities($nachricht)."\" />\n";
if ($cfg_feature_simple_antispam) echo "<input type=\"hidden\" name=\"antispam\" value=\"".myhtmlentities($antispam)."\" />\n";
echo "<a href=\"javascript:document.frm2.submit()\"><img src=\"images/buttons/aendern.gif\" border=\"0\" height=\"31\" width=\"146\" alt=\"&Auml;ndern\" title=\"&Auml;ndern\" /></a>";
echo "</form>";
echo "</td>";
 
echo "<td><img src=\"images/spacer.gif\" height=\"1\" width=\"30\" alt=\"\" /></td>";
 
echo "<td>\n";
echo "<form action=\"$inphp\" method=\"post\" name=\"frm1\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"abschicken\" />\n";
echo "<input type=\"hidden\" name=\"name\" value=\"".myhtmlentities($name)."\" />\n";
echo "<input type=\"hidden\" name=\"ort\" value=\"".myhtmlentities($ort)."\" />\n";
echo "<input type=\"hidden\" name=\"email\" value=\"".myhtmlentities($email)."\" />\n";
echo "<input type=\"hidden\" name=\"homepage\" value=\"".myhtmlentities($homepage)."\" />\n";
echo "<input type=\"hidden\" name=\"icq\" value=\"".myhtmlentities($icq)."\" />\n";
echo "<input type=\"hidden\" name=\"nachricht\" value=\"".myhtmlentities($nachricht)."\" />\n";
if ($cfg_feature_simple_antispam) echo "<input type=\"hidden\" name=\"antispam\" value=\"".myhtmlentities($antispam)."\" />\n";
echo "<a href=\"javascript:document.frm1.submit()\"><img src=\"images/buttons/abschicken.gif\" border=\"0\" height=\"31\" width=\"146\" alt=\"Abschicken\" title=\"Abschicken\" /></a>";
echo "</form>";
echo "</td>";
 
echo "</tr></table></div>\n";
} elseif ($view_abschicken) {
$pass_final_recaptcha = true;
if ($cfg_recaptcha_enabled) {
if (!isset($_POST['g-recaptcha-response'])) {
$pass_final_recaptcha = false;
} else {
$recaptcha = new \ReCaptcha\ReCaptcha($cfg_recaptcha_privkey);
$resp = $recaptcha->verify($_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
$pass_final_recaptcha = $resp->isSuccess();
}
}
 
if (!$pass_final_recaptcha) {
echo '<h1>Bitte Sicherheitsfrage beantworten</h1>';
echo '<p>Bitte tippen Sie den dargestellten Code ab. Dadurch wird sichergestellt dass Sie ein Mensch und kein Spam-Bot sind.</p>';
 
echo "<form action=\"$inphp\" method=\"post\" name=\"frm1\">\n";
 
echo '<div class="g-recaptcha" data-sitekey="'.$cfg_recaptcha_pubkey.'"></div>';
echo '<script type="text/javascript" src="https://www.google.com/recaptcha/api.js"></script>';
echo '<br>';
 
echo "<input type=\"hidden\" name=\"action\" value=\"abschicken\" />\n";
echo "<input type=\"hidden\" name=\"name\" value=\"".myhtmlentities($name)."\" />\n";
echo "<input type=\"hidden\" name=\"ort\" value=\"".myhtmlentities($ort)."\" />\n";
echo "<input type=\"hidden\" name=\"email\" value=\"".myhtmlentities($email)."\" />\n";
echo "<input type=\"hidden\" name=\"homepage\" value=\"".myhtmlentities($homepage)."\" />\n";
echo "<input type=\"hidden\" name=\"icq\" value=\"".myhtmlentities($icq)."\" />\n";
echo "<input type=\"hidden\" name=\"nachricht\" value=\"".myhtmlentities($nachricht)."\" />\n";
if ($cfg_feature_simple_antispam) echo "<input type=\"hidden\" name=\"antispam\" value=\"".myhtmlentities($antispam)."\" />\n";
echo "<a href=\"javascript:document.frm1.submit()\"><img src=\"images/buttons/abschicken.gif\" border=\"0\" height=\"31\" width=\"146\" alt=\"Abschicken\" title=\"Abschicken\" /></a>";
echo "</form>";
} else {
$daten = "'".mysql_real_escape_string($name)."'";
$felder = '`name`';
 
if ($ort != '') {
$daten .= ", '".mysql_real_escape_string($ort)."'";
$felder .= ', `ort`';
}
 
if ($email != '') {
$daten .= ", '".mysql_real_escape_string($email)."'";
$felder .= ', `email`';
}
 
if ($homepage != '') {
$daten .= ", '".mysql_real_escape_string($homepage)."'";
$felder .= ', `homepage`';
}
 
if ($icq != '') {
$daten .= ", '".mysql_real_escape_string($icq)."'";
$felder .= ', `icq`';
}
 
$daten .= ", '".mysql_real_escape_string("$datum $zeit")."'";
$felder .= ', `timestamp`';
 
$daten .= ", '".mysql_real_escape_string($ip)."'";
$felder .= ', `ip`';
 
$daten .= ", '".mysql_real_escape_string($nachricht)."'";
$felder .= ', `nachricht`';
 
$show = $cfg_automatisch_freischalten ? '1' : '0';
$daten .= ", '".mysql_real_escape_string($show)."'";
$felder .= ', `show`';
 
$result = mysql_query("INSERT INTO `".mysql_real_escape_string($table_entries)."` ($felder) VALUES ($daten)");
$id = mysql_insert_id();
 
$md5 = md5($nachricht);
$md5_valid = md5_valid($id, $md5);
 
// Send mail
 
$ger_datum = date('d.m.Y', strtotime($datum));
 
$msg_html = "<h1>".myhtmlentities($seitentitel)." - G&auml;stebucheintrag</h1>\n";
$msg_html .= "<b>Name:</b> ".myhtmlentities($name)."<br />\n";
$msg_html .= "<b>E-Mail:</b> ".myhtmlentities($email)."<br />\n";
$msg_html .= "<b>Ort:</b> ".myhtmlentities($ort)."<br />\n";
$msg_html .= "<b>Homepage:</b> ".myhtmlentities($homepage)."<br />\n";
$msg_html .= "<b>ICQ:</b> ".myhtmlentities($icq)."<br />\n";
$msg_html .= "<b>Datum:</b> $ger_datum<br />\n";
$msg_html .= "<b>Uhrzeit:</b> $zeit<br />\n";
$msg_html .= "<br />\n";
$msg_html .= "<b>Nachricht:</b> ".parse_html($nachricht, $this_dir)."<br />\n";
$msg_html .= "<br />\n";
$msg_html .= "<i>Datensatz Nr. $id wurde erstellt.</i><br />\n";
$msg_html .= "<br />\n";
$msg_html .= "<font size=\"+1\"><b>Absenderdaten:</b></font><br />\n";
$msg_html .= "<br />\n";
$msg_html .= "<b>IP-Adresse:</b> <a href=\"$whois_service\" target=\"_blank\">$ip</a> ($host)<br />\n";
$msg_html .= "<b>Browser:</b> ".$_SERVER['HTTP_USER_AGENT']."<br />\n";
$msg_html .= "<br />\n";
if (!$cfg_automatisch_freischalten) {
$msg_html .= '<i>Klicken Sie <a href="'."$inphp?action=freischalten&amp;id=$id&amp;md5=".urlencode($md5_valid).'" target="_blank">hier</a>, um den Eintrag freizuschalten. Schalten Sie den Eintrag nicht frei, so bleibt er unver&ouml;ffentlicht.</i><br />'."\n";
}
 
$msg_plain = "$seitentitel - Gästebucheintrag\n\n";
$msg_plain .= "Name: $name\n";
$msg_plain .= "E-Mail: $email\n";
$msg_plain .= "Ort: $ort\n";
$msg_plain .= "Homepage: $homepage\n";
$msg_plain .= "ICQ: $icq\n";
$msg_plain .= "Datum: $ger_datum\n";
$msg_plain .= "Uhrzeit: $zeit\n";
$msg_plain .= "\n";
$msg_plain .= "Nachricht: $nachricht\n";
$msg_plain .= "\n";
$msg_plain .= "Datensatz Nr. $id wurde erstellt.\n";
$msg_plain .= "\n";
$msg_plain .= "Absenderdaten:\n";
$msg_plain .= "\n";
$msg_plain .= "IP-Adresse: $ip ($host) - Whois-Lookup at $whois_service\n";
$msg_plain .= "Browser: ".$_SERVER['HTTP_USER_AGENT']."\n";
$msg_plain .= "\n";
if (!$cfg_automatisch_freischalten) {
$msg_plain .= "Öffnen Sie $inphp?action=freischalten&id=$id&md5=".urlencode($md5_valid)." , um den Eintrag freizuschalten. Schalten Sie den Eintrag nicht frei, so bleibt er unver&ouml;ffentlicht.\n";
}
 
$h = new SecureMailer(); // Includes Anti Mail-Header-Injection
 
/*
# http://www.phpbox.de/tipsundtricks/emailsumlaute.php
$h->addHeader('Mime-Version', '1.0');
$h->addHeader('Content-Type', 'text/html; charset='.$charset);
 
$h->addHeader('Content-Transfer-Encoding', 'quoted-printable');
# $msg_html = wordwrap($msg_html);
# $msg_html = quoted_printable_encode($msg_html);
$msg_html = quoted_printable_encode2($msg_html);
*/
 
if ($cfg_from_email != '') {
$h->addHeader('From', $cfg_from_email);
}
if ($email != '') {
$h->addHeader('Reply-To', $email);
}
 
if ((isset($adminmail_cc)) && ($adminmail_cc != '')) {
$h->addHeader('CC', $adminmail_cc);
}
 
$h->addHeader('X-Mailer', 'PHP/'.phpversion());
 
$subject = "$seitentitel - Gästebucheintrag";
$subject = SecureMailer::utf8Subject($subject);
 
# $gesendet = $h->sendMail($adminmail, $subject, $msg_html);
$gesendet = $h->sendMailHTMLandPlainMultipart($adminmail, $subject, $msg_html, $msg_plain);
 
if (!$gesendet) {
echo '<p><font color="'.$farbe6.'">FEHLER BEIM SENDEN DER MAIL!</font></p>';
}
 
if ($result) {
echo '<h1 align="center">G&auml;stebucheintrag abgeschickt</h1>
 
<div align="center">
 
<p><font color="'.$farbe8.'">Ihr G&auml;stebucheintrag wurde erfolgreich eingetragen!</font></p>
 
<p>Bitte beachten Sie, dass der Eintrag erst nach einer Pr&uuml;fung des Seiteninhabers freigeschaltet wird.</p>
 
<p><a href="'.$inphp.'"><img src="images/buttons/zurueck.gif" alt="Zur&uuml;ck" title="Zur&uuml;ck" height="31" width="146" border="0" /></a></p>
 
</div>';
 
} else {
echo "<p>".mysql_error()."</p>";
echo '<p><font color="'.$farbe6.'">Es ist ein schwerer Fehler aufgetreten. Versuchen Sie es nocheinmal.</font></p>';
}
}
}
}
}
 
if ($relfehler || $view_eintrag) {
echo '<h1>G&auml;stebucheintrag</h1>';
 
echo '<p>Bitte f&uuml;llen Sie die unteren Felder aus. Die mit <font color="'.$farbe7.'">*</font> gekennzeichneten
Felder m&uuml;ssen ausgef&uuml;llt werden! Um Missbrauch zu vermeiden, wird die
IP-Adresse gespeichert.';
echo ' Die Eintr&auml;ge werden erst nach einer Pr&uuml;fung ver&ouml;ffentlicht.';
echo '</p>';
 
if (isset($relfehler)) {
echo "<p>$relfehler</p>";
}
 
echo '<br />
 
<form action="'.$inphp.'" method="post" name="frm">
<input type="hidden" name="action" value="'.($cfg_vorschau ? 'vorschau' : 'abschicken').'" />
 
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="right">';
 
if ($err_name) {
echo '<font color="'.$farbe6.'">Name *:</font>';
} else {
echo 'Name <font color="'.$farbe7.'">*</font>:';
}
 
echo '</td>
<td><img src="images/spacer.gif" height="1" width="10" alt="" /></td>
<td><input maxlength="40" size="66" name="name" value="'.$name.'" /></td>
</tr>
<tr>
<td align="right">Wohnort:</td>
<td><img src="images/spacer.gif" height="1" width="10" alt="" /></td>
<td><input maxlength="40" size="66" name="ort" value="'.$ort.'" /></td>
</tr>
<tr>
<td align="right">';
 
if ($err_email) {
echo '<font color="'.$farbe6.'">E-Mail:</font>';
} else {
echo 'E-Mail:';
}
 
echo '</td>
<td><img src="images/spacer.gif" height="1" width="10" alt="" /></td>
<td><input maxlength="40" size="66" name="email" value="'.$email.'" /></td>
</tr>
<tr>
<td align="right">';
 
if ($err_homepage) {
echo '<font color="'.$farbe6.'">Homepage:</font>';
} else {
echo 'Homepage:';
}
 
echo '</td>
<td><img src="images/spacer.gif" height="1" width="10" alt="" /></td>
<td><input maxlength="40" size="66" name="homepage" value="'.$homepage.'" /></td>
</tr>
<tr>
<td align="right">';
 
if ($err_icq) {
echo '<font color="'.$farbe6.'">ICQ:</font>';
} else {
echo 'ICQ:';
}
 
echo '</td>
<td><img src="images/spacer.gif" height="1" width="10" alt="" /></td>
<td><input maxlength="40" size="66" name="icq" value="'.$icq.'" /></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>';
 
if ($cfg_feature_simple_antispam) {
echo '<tr>
<td align="right">';
 
if ($err_antispam) {
echo '<font color="'.$farbe6.'">Bitte <!--&quot;-->'.$antispam_awaiting.'<!--&quot;--> eingeben *:</font>';
} else {
echo 'Bitte <!--&quot;-->'.$antispam_awaiting.'<!--&quot;--> eingeben <font color="'.$farbe7.'">*</font>:';
}
 
echo '</td>
<td><img src="images/spacer.gif" height="1" width="10" alt="" /></td>
<td><input maxlength="40" size="66" name="antispam" value="'.$antispam.'" /> (AntiSpam-Frage)</td>
</tr>
 
<tr>
<td colspan="3">&nbsp;</td>
</tr>';
}
 
echo '<tr>
<td align="right">Smileys:</td>
<td><img src="images/spacer.gif" height="1" width="10" alt="" /></td>
<td><script language="JavaScript" type="text/javascript">
<!--
function setsmiley(smiley) {
frm.nachricht.value = frm.nachricht.value + smiley;
}
// -->
</script>';
 
$result = mysql_query("SELECT `zeichen`, `image`, `beschreibung` FROM `".mysql_real_escape_string($table_smileys)."` WHERE `enabled` = '1' AND `show_in_editor` = '1' ORDER BY `id` ASC");
while ($row = mysql_fetch_object($result)) {
echo "<a href=\"javascript:setsmiley(' ".addslashes(myhtmlentities($row->zeichen))." ')\">".
'<img src="images/smileys/'.$row->image.'" border="0" alt="'.myhtmlentities($row->beschreibung).'" title="'.myhtmlentities($row->beschreibung).'" /></a>&nbsp;';
}
 
echo '</td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td valign="top" align="right">';
 
if ($err_nachricht) {
echo '<font color="'.$farbe6.'">Nachricht *:</font>';
} else {
echo 'Nachricht <font color="'.$farbe7.'">*</font>:';
}
 
echo '</td>
<td><img src="images/spacer.gif" height="1" width="10" alt="" /></td>
<td><textarea name="nachricht" rows="5" cols="50">'.$nachricht.'</textarea><!-- wrap="virtual" --></td>
</tr>
<tr>
<td colspan="2"><img src="images/spacer.gif" height="1" width="10" alt="" /></td>
<td><br />
<a href="javascript:document.frm.submit()">';
if ($cfg_vorschau) {
echo '<img height="31" alt="Vorschau" title="Vorschau" src="images/buttons/vorschau.gif" width="146" border="0" />';
} else {
echo '<img src="images/buttons/abschicken.gif" border="0" height="31" width="146" alt="Abschicken" title="Abschicken" />';
}
echo '</a> <!--
<img src="images/spacer.gif" height="1" width="30" alt="" />
<a href="javascript:document.frm.reset()">
<img height="31" alt="L&ouml;schen" title="L&ouml;schen" src="images/buttons/loeschen.gif" width="146" border="0" /></a>
-->
</td>
</tr>
</table>
 
</form>
 
<p align="center"><a href="'.$inphp.'">Zur&uuml;ck zu den Eintr&auml;gen</a></p>';
} else if ((!$view_vorschau) && (!$view_abschicken) && (!$view_eintrag)) {
echo '<h1 align="center">G&auml;stebuch</h1>
 
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">[ <a href="'.$inphp.'?action=eintrag">Neuen Eintrag hinzuf&uuml;gen</a> ]</td></tr></table><br />';
 
$cond = ($cfg_unfreigeschaltete_anzegen) ? '' : " WHERE `show` = '1'";
 
$result = mysql_query("SELECT * FROM `".mysql_real_escape_string($table_entries)."`$cond");
if ($result) $number = mysql_num_rows($result); else $number = 0;
$max_page = ceil($number / $eintraege_proseite);
 
$seiten = isset($_REQUEST['seiten']) ? $_REQUEST['seiten'] : 1;
if (!isset($seiten) || ($seiten > $max_page) || ($seiten < 0)) $seiten = '1';
 
$result = mysql_query("SELECT * FROM `".mysql_real_escape_string($table_entries)."`$cond ORDER BY `id` DESC LIMIT ".($seiten-1)*$eintraege_proseite.",".$eintraege_proseite);
 
$keineeintraege = true;
 
if ($result) {
while ($row = mysql_fetch_object($result)) {
$xry = explode(' ', $row->timestamp);
$datum = $xry[0];
$zeit = $xry[1];
anznachricht($row->name, $row->ort, $row->email, $row->homepage, $row->icq, $row->nachricht, $row->kommentar, $zeit, $datum);
$keineeintraege = false;
}
}
 
if ($keineeintraege) {
echo '<div align="center">Es sind keine Eintr&auml;ge vorhanden!</div>';
}
 
if ((!$keineeintraege) && ($max_page != 1)) {
echo '<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr><td align="center"><p class="klein2">Seite: ';
for ($i=1; $i<=$max_page; $i++) {
if ($seiten != $i) {
echo "<a href=\"$inphp?seiten=$i\">[$i]</a>\n";
} else {
echo "<b>[$i]</b>\n";
}
}
echo '</p></td></tr></table>';
}
 
}
 
echo '<p align="center">OpenSource PHP-G&auml;stebuch von <a href="http://www.viathinksoft.de/" target="_blank">ViaThinkSoft</a>, Version '.$version.'</p>';
 
echo $seitenfuss;
 
# ---
 
// This is the only function which works with GMX.
// wordwrap+quoted_printable_encode does not work, since it would insert whitespaces.
// http://www.php.net/manual/en/function.quoted-printable-encode.php#97230
function quoted_printable_encode2($input, $line_max = 75) {
$hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
$lines = preg_split("/(?:\r\n|\r|\n)/", $input);
$linebreak = "=0D=0A=\r\n";
/* the linebreak also counts as characters in the mime_qp_long_line
* rule of spam-assassin */
$line_max = $line_max - strlen($linebreak);
$escape = "=";
$output = "";
$cur_conv_line = "";
$length = 0;
$whitespace_pos = 0;
$addtl_chars = 0;
 
// iterate lines
for ($j=0; $j<count($lines); $j++) {
$line = $lines[$j];
$linlen = strlen($line);
 
// iterate chars
for ($i = 0; $i < $linlen; $i++) {
$c = substr($line, $i, 1);
$dec = ord($c);
 
$length++;
 
if ($dec == 32) {
// space occurring at end of line, need to encode
if (($i == ($linlen - 1))) {
$c = "=20";
$length += 2;
}
 
$addtl_chars = 0;
$whitespace_pos = $i;
} elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) {
$h2 = floor($dec/16); $h1 = floor($dec%16);
$c = $escape . $hex[$h2] . $hex[$h1];
$length += 2;
$addtl_chars += 2;
}
 
// length for wordwrap exceeded, get a newline into the text
if ($length >= $line_max) {
$cur_conv_line .= $c;
 
// read only up to the whitespace for the current line
$whitesp_diff = $i - $whitespace_pos + $addtl_chars;
 
/* the text after the whitespace will have to be read
* again ( + any additional characters that came into
* existence as a result of the encoding process after the whitespace)
*
* Also, do not start at 0, if there was *no* whitespace in
* the whole line */
if (($i + $addtl_chars) > $whitesp_diff) {
$output .= substr($cur_conv_line, 0, (strlen($cur_conv_line) - $whitesp_diff)) . $linebreak;
$i = $i - $whitesp_diff + $addtl_chars;
} else {
$output .= $cur_conv_line . $linebreak;
}
 
$cur_conv_line = "";
$length = 0;
$whitespace_pos = 0;
} else {
// length for wordwrap not reached, continue reading
$cur_conv_line .= $c;
}
} // end of for
 
$length = 0;
$whitespace_pos = 0;
$output .= $cur_conv_line;
$cur_conv_line = "";
 
if ($j<=count($lines)-1) {
$output .= $linebreak;
}
} // end for
 
return trim($output);
} // end quoted_printable_encode
/trunk
Property changes:
Added: svn:ignore
+_private