Stefan Bracher

Pageblackboard - Gästebuch und Besucherbeiträge

[Deutsch: English see right column]

Pageblackboard war ein Webseiten Plug-in zum erstellen eines Gästebuches oder für Besucherkommentare auf einer Webseite. Seit dem aufkommen von Facebook und Co. (und deren Plug-Ins) war Pageblackboard nicht mehr nötig und wird daher nicht mehr weiterentwickelt.

Automatische Spamerkennung

Eine der Hauptfunktionen von Pageblackboard war die automatische Spamerkennung. Dies wurde in drei Schritten erreicht: Wortzahl-Minimum, Spam-Mustererkennung und Vokalanteilsbestimmung.

Wortzahl-Minimum

Einfach aber sehr effektiv: Eine Großzahl von Spam-Einträgen kann durch die Anzahl Worte im Text erkannt werden. Ein legitimer Kommentar oder Eintrag besteht normalerweise aus mehreren Wörtern. Die PHP-Funktion str_word_count wurde benutzt im die Wörter in einem Eintrag zu zählen und ihn zu verwerfen wenn die Anzahl Wörter unter einem Mindestwert lag. Der Mindestwert selber ist ein experimenteller Wert: Ein Minimum von fünf Wörter schien die besten Resultate zu produzieren.

Vokalanteil

Näturliche, von Menschen generierte Sprache enthält einen fixen Anteil an Vokalen. Der Vokalanteil von komputergeneriertem Spam weicht oft von diesem „natürlichen“ Wert ab. Der Vokalanteil kann daher als Merkmal zur Spamerkennung benutzt werden.

Die besten Resultate lieferte ein Vokalanteil von 30% +-10%. Dies sowohl für Deutsch als auch für Englisch. Für weitere Sprachen kann der "normale" Anteil sehr einfach durch zählen der Vokale in einem sehr langen Text ermittelt werden. Vokalantail=Vokale/Zeichen.

Die folgende PHP-Funktion kann zur Ermittlung des Vokalanteils eines Textes benutzt werden.

function vowel_quota($string)
{
$length=strlen($string); // Laenge des Textes
$vowels=substr_count($string, "a"); // Anzahl a
$vowels=$vowels+substr_count($string, "e"); // Anzahl e
$vowels=$vowels+substr_count($string, "i"); // Anzahl i
$vowels=$vowels+substr_count($string, "o"); // Anzahl o
$vowels=$vowels+substr_count($string, "u"); // Anzahl u
return ($vowels/$length); // Anteil ausgeben
}

Spam-Mustererkennung

Pageblackboard hatte auch eine Liste mit bekannten Spam-Mustertexten mit denen die Texte verglichen wurden. Wenn zu viele Spam-Fragmente in einem Text erkannt wurden, wurde dieser verworfen.

Da die Liste auch ein paar Stichwörter enthalten kann, die in legitimen Kommentaren vorkommen können, ist es wichtig, einen Text nur als Spam einzustufen, wenn mehrere Stichwörter gefunden wurden. Genau wie viele ist wiederum ein experimenteller Wert. Eine maximal erlaubte Anzahl von drei Übereinstimmungen hat mit der angegebenen Liste am besten funktioniert.

Speichern der Daten in Textdateien

Eine weitere Funktion von Pageblackboard war das Speichern der Kommentare. Diese wurden in Textdateien, direkt auf dem Server wo das Plug-in lief, gespeichert. Das speichern der Daten in Textdateien hatte den Vorteil, keine Datenbank benützen zu müssen. (Zur dieser Zeit waren Datenbanken nicht bei allen Webhostern erhältlich) .

Dateien über FTP speichern

Die Datenspeicherung in Textdateien hat den Nachteil, dass den Dateien die korrekten Nutzerrechte zugeordnet werden müssen. Einerseits muss der Server auf die Datei zum lesen und schreiben zugreifen können, andererseits will man auch keine Sicherheitslücke kreieren. Natürlich kann man mit richtig gesetzten Zugriffsrechten erreichen, aber es gibt auch einen einfacheren Weg: Die Datei über eine FTP-Verbindung auf dem eigenen Server speichern! Der Grosse Vorteil: Unabhängigkeit von der Server-Umgebung. Der FTP-Zugrang funktioniert gleich, egal welches Betriebssystem (Linux, Windows...) auf dem Server läuft.

Beispiel PHP-Code um einen Text per FTP in eine Textdatei zu schreiben:

/** Variablen************************************/
$user['FTP_SERVER']="Die Server IP oder URL";
$user['FTP_USER']="FTP User";
$user['FTP_PASSWORD']="FTP Passwort";
$user['FTP_PATH']="Der relative Pfad vom FTP-Basisordner zum Ordner wo die Textdatei gespeichert werden soll.";
/************************************************/

/*******Daten von Formular holen*******************************/
$filename=time(); // Datum und Uhrzeit als Dateinahme
// Text in HTML-Compatibles Format verwandeln
$text=htmlentities(urldecode($string)); // $string: Zu speichernder Text
$text=str_replace("\n", "<br>", "$text");
/************************************************/

//Login auf dem FTP-Server
$ftp_server=$user['FTP_SERVER'];
$ftpstream = @ftp_connect($ftp_server);
$login = @ftp_login($ftpstream, $user[FTP_USER], $user[FTP_PASSWORD]);

if($login)
 {
  // Verbindung zum Server erstellt
  $temp = tmpfile();
  fwrite($temp, "$text\n");
  fseek($temp, 0);
  ftp_fput($ftpstream, "$user[FTP_PATH]$time.txt", $temp, FTP_BINARY);
  }

// Schliesse FTP Verbindung
@ftp_close($ftpstream);

Kommentar und Gästebuch Plug-ins für die Webseite

Gut, Pageblackboard ist nicht mehr aktiv, aber wo finde ich denn jetzt ein Plug-In mit dem man Kommentare auf meiner Seite hinterlassen kann?

Facebook-Kommentare

Facebook hat mehrere Webseiten-Plug-Ins. Eines davon ist die Facebook Comments Box.

Google+ - Kommentare

Um dasselbe mit Google+: Google+ -Kommentare.

Pageblackboard - User Comments on your Website

[English: Deutsche Version siehe links]

Pageblackboard was a website-plug-in to allow user comments on your own website or to create a guestbook. Since the days of social media sites (and their plugins) it is obsolete and thus no longer maintained.

Automatic Spam detection

One of the main features of Pageblackboard was the automatic spam detection. This was achieved in three steps: Minimal word count, spam pattern comparison and vowel quota verification.

Minimal word count

It sounds simple, but a lot of spam can be detected by simply counting the number of words in a text. Legitimate user comments usually consist of several words. The PHP-function str_word_count was used to identify the number of words and reject a comment if this number was below a certain threshold. The threshold itself is an experimental value: A minimum of 5 words turned out to work best.

Vowel quota verification

Natural, human generated language has a certain quota of vowels. Often, computer generated spam can be detected by simply verifying that the vowel quota matches the expected quota for natural language.

For English, a target vowel quota of 30 percent, with a permitted variation of +- 10%, turned out to work best. For other languages, the quota can be established by counting the numbers of vowels and total number of characters in a large text: Quota=Vowels/Characters.

The following PHP-function can be used to identify the vowel quota of a string:

function vowel_quota($string)
{
$length=strlen($string); // Length of the string
$vowels=substr_count($string, "a"); // Number of a's
$vowels=$vowels+substr_count($string, "e"); // Number of e's
$vowels=$vowels+substr_count($string, "i"); // Number of i's
$vowels=$vowels+substr_count($string, "o"); // Number of o's
$vowels=$vowels+substr_count($string, "u"); // Number of u's
return ($vowels/$length); // Return quota
}

Spam pattern

Pageblackboard also had a list with known spam-patterns. If the number of patterns in a submitted text exceeded a certain number of known spam patterns, it was rejected.

As the list can contain a few words that can also occur in a legitimate user comment, it is really important to reject a text only if a certain number of patterns match. This number is a purely experimental value. A maximal number of 3 matches turned out to work best with the given list.

Storing the user comments in text files

Another feature of Pageblackboard was that the comments were stored in a text file, directly on the server running the plug-in. Storing the data in a text file had the advantage of not requiring a database (what at the time was not offered by every webhosting company).

Using an FTP connection to save the file

Storing information in a text file brings the problem of having to give the correct access rights to the file in question. On one side, the server needs to be able to write the file, on the other, you do don't want to create a security leak by giving too loose file permissions. Of course this can be done, but a simpler method turned out to be to simply submit the file by ftp to the server itself. This also has the big advantage, that it will work the same independent of your hosting environment (Windows, Linux, ...).

Example PHP-code to store a string in a textfile on a server:

/** Variables************************************/
$user['FTP_SERVER']="YOUR SERVER IP or URL";
$user['FTP_USER']="FTP Username";
$user['FTP_PASSWORD']="FTP Password";
$user['FTP_PATH']="Path from the FTP root to the folder the files should be saved in";
/************************************************/

/*******Get Data*******************************/
$filename=time(); // A timestring used as a the filename
// Converting the text in html-compatible format
$text=htmlentities(urldecode($string)); // $string: text to be saved
$text=str_replace("\n", "<br>", "$text");
/************************************************/

//Login to the FTP server
$ftp_server=$user['FTP_SERVER'];
$ftpstream = @ftp_connect($ftp_server);
$login = @ftp_login($ftpstream, $user[FTP_USER], $user[FTP_PASSWORD]);

if($login)
 {
  //Connection to FTP server established
  $temp = tmpfile();
  fwrite($temp, "$text\n");
  fseek($temp, 0);
  ftp_fput($ftpstream, "$user[FTP_PATH]$time.txt", $temp, FTP_BINARY);
  }

//Close FTP connection
@ftp_close($ftpstream);

User Comment Plug-ins

OK, Pageblackboard is not maintained anymore, but where can I find plug-ins that allow users to leave comments on my website?

Facebook - Comment Box

Facebook offers many plug-ins that you can use on your website. One of them is the Facebook Comments Box.

Google+ - Comments

Here you can find a description of how to achieve the same using Google+.