change word colour system

This commit is contained in:
Tristan Schneider 2024-02-10 23:51:36 +01:00
parent 350445a58c
commit 4c904551dc

View File

@ -6,13 +6,12 @@ header("Cache-Control: no-cache, no-store, must-revalidate");
<?php
function get_color_from_ip($ip) {
$ip_elem = explode(".", $ip);
function get_color_from_userdata($data) {
$css = "background-color: hsl(";
$number = abs(crc32($ip));
$number = abs(crc32($data));
$css .= ($number % 360).", ";
$css .= (50 + (($number >> 3) % 51))."%, ";
$css .= (50 + (($number >> 5) % 51))."%);";
$css .= (50 + (($number >> 5) % 31))."%);"; // maximal 80%, es soll nicht einfach weiß sein
return $css;
}
@ -47,7 +46,8 @@ if (array_key_exists("submitted", $_REQUEST)) {
if ($botrequest) {
$content .= "background-color: darksalmon; color: white;'>";
} else {
$content .= get_color_from_ip($_SERVER['REMOTE_ADDR'])."'>";
// Farbe hängt ab von Benutzer und ändert sich nach gewisser Zeit.
$content .= get_color_from_userdata($_REQUEST["user"].strval(intdiv(time(),60*60*24*7)))."'>";
}
$ends_of_sentence = ['.', '!', '?'];