This commit is contained in:
Martin Stadler
2017-01-26 12:39:28 +01:00
commit 7c355dfd2d
724 changed files with 6154 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
<?php
require('message.inc');
class Contact_Mail extends Message {
private $to = 'Martin Stadler <martin@siarp.de>, Tilman Walther <tilman@tilman.de>';
private $subject = 'Post für Beethoven2000';
private $from = 'From: Beethoven2000 Kontaktformular <abi@beethoven2000.de>';
/**
* Sendet die Mail mit den Übergebenen Parametern.
*/
function __construct ($name, $address, $message) {
if ($this->contains_spam_hints($name . $address . $message, array($name, $address))) {
$this->spam = true;
return true;
}
/* check for missing '@' in address as a spam hint */
/* XXX dirty */
if (!empty($address) && strpos($address, '@') === false) {
$this->spam = true;
return true;
}
$contents = 'Name: ' . $name . "\n";
$contents .= 'eMail: ' . $address . "\n";
$contents .= "\n--------\n";
$contents .= utf8_decode(preg_replace('~\r~', '', $message));
if (!mail($this->to, $this->subject, $contents, $this->from)) {
$this->error = true;
}
}
}
?>
+8
View File
@@ -0,0 +1,8 @@
<!-- footer -->
</div>
</div>
</body>
</html>
+51
View File
@@ -0,0 +1,51 @@
<?php
$http_base = 'http://'. $_SERVER['HTTP_HOST'] .'/';
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<?php foreach ($additional_headers as $additional_header): ?>
<?php echo $additional_header ."\n"; ?>
<?php endforeach; ?>
<style type="text/css">@import "<?php echo $http_base; ?>style.css";</style>
<title><?php echo $page_title; ?></title>
</head>
<body>
<div class="hide">
<a href="#content" accesskey="1">direkt zum Inhalt springen</a> |
<a href="#navigation" accesskey="2">direkt zur Hauptnavigation springen</a>
</div>
<div id="main">
<div id="header">
<div id="head">
<img src="<?php echo $http_base; ?>bilder/logo.gif" alt="Logo" /> <img src="<?php echo $http_base; ?>bilder/jahrgangsfoto.jpg" alt="Jahrgangsfoto" />
</div>
<div id="main_title">Abiturjahrgang 2000 der Beethoven-Oberschule Berlin-Lankwitz</div>
<div id="navigation">
<ul>
<li><a href="<?php echo $http_base; ?>"<?php if ($_SERVER['SCRIPT_NAME'] == '/index.php') echo ' class="active"'; ?> accesskey="3">Start</a></li>
<li><a href="<?php echo $http_base; ?>intern.php"<?php if (strpos($_SERVER['SCRIPT_NAME'], '/intern') !== FALSE) echo ' class="active"'; ?> accesskey="4">Intern</a></li>
<li><a href="<?php echo $http_base; ?>projekt-abibuch/"<?php if ($_SERVER['SCRIPT_NAME'] == '/projekt-abibuch.php') echo ' class="active"'; ?> accesskey="5">Projekt Abibuch</a></li>
<li><a href="<?php echo $http_base; ?>kontakt.php"<?php if ($_SERVER['SCRIPT_NAME'] == '/kontakt.php') echo ' class="active"'; ?> accesskey="6">Kontakt</a></li>
</ul>
</div>
</div>
<div id="content-area">
<!-- end header -->
+47
View File
@@ -0,0 +1,47 @@
<?php
class Message {
/**
* Fehler beim Senden bzw. Speichern der Nachricht.
*/
public $error = false;
/**
* Nachricht enthält möglicherweise Spam.
*/
public $spam = false;
/**
* Gibt an, ob der Eintrag Spam enthalten könnte.
* Prüft, ob Zeilenumbrüche in den Werten von einzeiligen Eingabefeldern vorhanden sind.
* Prüft, ob der übergebene String einen Eintrag der Blacklist enthält.
*/
protected function contains_spam_hints ($test_string, $input) {
foreach ($input as $value) {
if (preg_match('~[\n\r]~', $value)) {
$this->spam = true;
return true;
}
}
$blacklist = array(
'~Content\-T~i',
'~href=~i',
'~http://.+?http://.+?http://~s',
);
foreach ($blacklist as $blackstring) {
if (preg_match($blackstring, $test_string)) {
$this->spam = true;
return true;
}
}
return false;
}
}
?>
+154
View File
@@ -0,0 +1,154 @@
<?php
require('message.inc');
class Shoutbox extends Message {
private $path_to_file = '';
private $entry_lines = array();
private $file_resource;
/**
* Setzt das Attribut $path_to_file auf den übergebenen Wert.
*/
function __construct ($path_to_file) {
$this->path_to_file = $path_to_file;
}
/**
* Liest die Datenbank-Textdatei in das Attribut $entry_lines.
* - überprüft, ob file resource vorhanden und setzt entweder den zeiger auf 0 oder öffnet neue
* - liest aus der Datei das array aus und dreht es um (ACHTUNG: noch mit Zeilenenden)
*/
function read_file () {
if ($this->file_resource) {
fseek($this->file_resource, 0);
}
else {
$this->file_resource = fopen($this->path_to_file, 'r');
if (!$this->file_resource) {
$this->error = true;
return false;
}
flock($this->file_resource, LOCK_EX);
}
$this->entry_lines = file($this->path_to_file);
if ($this->entry_lines === false) {
$this->error = true;
return false;
}
$this->entry_lines = array_reverse($this->entry_lines);
// remove lines with incorrect syntax or comments
$count_entry_lines = count($this->entry_lines); // necessary because count is changed by unsetting entries
for ($i = 0; $i < $count_entry_lines; $i++) {
if (!preg_match('~^\d{10}\t.+?\t.+$~', $this->entry_lines[$i])) {
unset($this->entry_lines[$i]);
}
}
return true;
}
/**
* Gibt den nächsten Eintrag zurück.
* - gibt je Aufruf eine Zeile als Array zurück
* - EOF gibt false zurück
* - ähnlich wie mysql_fetch_row
*/
function get_next_entry ($date_format = 'j.n.y') {
// eine Zeile
$entry = current($this->entry_lines);
next($this->entry_lines);
// ende
if ($entry === false) {
return false;
}
$entry = trim($entry);
$result = explode("\t", $entry);
// date
$result[0] = date($date_format, $result[0]);
// body: maskierte new lines demaskieren und breaks anfügen
$result[2] = preg_replace('~(\\\n)+~', "<br />\n", $result[2]);
return $result;
}
/**
* Speichert einen neuen Eintrag.
* - öffnet Datei zum schreiben (anhängen)
* - schreibt die Eingabe in die letzte Zeile
* - gibt bei Erfolg true zurück
*/
function add_entry ($sender, $message) {
if ($this->contains_spam_hints($sender . $message, array($sender))) {
return false;
}
$this->file_resource = fopen($this->path_to_file, 'a+');
if (!$this->file_resource) {
//$this->error = true; // Wird hier ein Fehler gesetzt, geht wird auch das Anzeigen der shoutbox unterbunden.
return false;
}
flock($this->file_resource, LOCK_EX);
$sender = substr($sender, 0, 25); // auf 25 Zeichen beschränken
$sender = preg_replace(array("~\t~", '~<~', '~>~'), array(' ', '&lt;', '&gt;'), $sender);
$message = substr($message, 0, 220); // auf 220 Zeichen beschränken
// TODO Lange Wörter richtig umbrechen und zwar in der Ausgabe, nicht der Eingabe.
// $message = wordwrap($message, 30, '-'); // nach 30 Zeichen mit '-' umbrechen
$message = preg_replace(array("~\n~", "~\r~"), array('\n', ''), $message); // new line in \n maskieren
$message = preg_replace(array("~\t~", '~<~', '~>~'), array(' ', '&lt;', '&gt;'), $message);
$entry = "\n" . time() . "\t" . $sender . "\t" . $message;
fwrite($this->file_resource, $entry);
/* __mail__ */
$to = 'Martin Stadler <martin@siarp.de>';
$subject = utf8_decode('Neuer Eintrag in der Gruß-Box');
$body =
'Name:' . $sender . "\n" .
'Nachricht: ' . "\n" . preg_replace('~(\\\n)+~', "\n", $message);
$body = utf8_decode(preg_replace('~\r~', '', $body)); // prepare_for_db
$from = 'From: Beethoven2000 Gruß-Box <gruss-box@beethoven2000.de>';
mail($to, $subject, $body, $from);
return true;
}
/**
* Schließt die Datei.
*/
function __destruct () {
fclose($this->file_resource);
}
}
?>