accepts bot entries and marks them with a comment

This commit is contained in:
Tristan Schneider 2021-01-23 19:24:55 +01:00
parent 1eef45693e
commit 8440c10e14

View File

@ -26,9 +26,22 @@ if (!is_dir("data")) {
if (array_key_exists("submitted", $_REQUEST)) { if (array_key_exists("submitted", $_REQUEST)) {
$word = urldecode($_REQUEST["submitted"]); $word = urldecode($_REQUEST["submitted"]);
//print("Jemand schreibt ".$word."<br>"); //print("Jemand schreibt ".$word."<br>");
$botrequest = false;
if (isset($_REQUEST["bot"])) {
$botrequest = true;
$content .= "<!-- FranzelbertML -->";
}
$sentences = fopen("./data/sentences.txt", "a") or die("unable to open sentences file"); $sentences = fopen("./data/sentences.txt", "a") or die("unable to open sentences file");
$content = "<span style='"; $content = "<span style='";
if ($botrequest) {
$content .= "background-color: darksalmon; color: white;'>";
} else {
$content .= get_color_from_ip($_SERVER['REMOTE_ADDR'])."'>"; $content .= get_color_from_ip($_SERVER['REMOTE_ADDR'])."'>";
}
$ends_of_sentence = ['.', '!', '?']; $ends_of_sentence = ['.', '!', '?'];
if (preg_match("/\p{L}/", $word[0])) { // check if first character is letter (including ä, ê, ß stuff) if (preg_match("/\p{L}/", $word[0])) { // check if first character is letter (including ä, ê, ß stuff)
@ -36,6 +49,10 @@ if (array_key_exists("submitted", $_REQUEST)) {
} }
$content .= htmlentities($word); $content .= htmlentities($word);
if ($botrequest) {
$content .= "<!-- FranzelbertML -->";
}
$content .= "</span>"; $content .= "</span>";
if (in_array($word[-1], $ends_of_sentence)) { if (in_array($word[-1], $ends_of_sentence)) {